Skip to content

feat(sdk): add bundle log level config#1341

Open
dqn wants to merge 8 commits into
mainfrom
feat/bundle-log-level
Open

feat(sdk): add bundle log level config#1341
dqn wants to merge 8 commits into
mainfrom
feat/bundle-log-level

Conversation

@dqn
Copy link
Copy Markdown
Contributor

@dqn dqn commented Jun 5, 2026

Summary

Adds defineConfig({ logLevel }) support to control which console.* calls are retained in bundled Tailor functions.

Main changes

  • Adds logLevel config parsing, types, docs, and changeset coverage with DEBUG as the default.
  • Applies log-level-based manualPureFunctions across resolver, executor, workflow, auth hook, and function test-run bundles.
  • Includes the resolved bundle log level in bundle cache hashing.
  • Extracts composable function treeshake helpers so future bundle-time drops can add independent treeshake fragments.

Supported log levels

  • DEBUG: keeps all checked console methods.
  • INFO: drops console.debug and console.trace; keeps info, warn, and error methods.
  • WARN: drops debug and info-level methods; keeps console.warn, console.error, and console.assert.
  • ERROR: drops debug, info, and warn methods; keeps console.error and console.assert.
  • SILENT: drops all configured console methods, including debug, info, warn, error, and assert.

Bundle output check

  • With WARN, generated bundled JS drops console.debug, console.log, and console.info, while keeping console.warn and console.error.
  • With DEBUG, generated bundled JS keeps all checked console methods.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 5, 2026

🦋 Changeset detected

Latest commit: 372de1a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tailor-platform/sdk Minor
@tailor-platform/create-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 5, 2026

Open in StackBlitz

pnpm add https://pkg.pr.new/@tailor-platform/create-sdk@372de1a
pnpm add https://pkg.pr.new/@tailor-platform/sdk@372de1a

commit: 372de1a

@github-actions

This comment has been minimized.

@dqn dqn marked this pull request as ready for review June 5, 2026 12:02
@dqn dqn requested review from remiposo and toiroakr as code owners June 5, 2026 12:02
@github-actions

This comment has been minimized.

@claude
Copy link
Copy Markdown

claude Bot commented Jun 5, 2026

📖 Docs Consistency Check

✅ No inconsistencies found between documentation and implementation.

Checked areas:

  • Configuration documentation (packages/sdk/docs/configuration.md):

    • Accurately documents the logLevel config option at lines 42-51
    • Correctly lists supported values: "DEBUG", "INFO", "WARN", "ERROR", "SILENT"
    • Correctly states default is "DEBUG"
    • Provides accurate example usage with process.env.LOG_LEVEL ?? "DEBUG"
    • Correctly explains it's a bundle-time setting
  • Implementation consistency:

    • Type definitions match documentation (src/types/app-config.ts:85-99)
    • Schema validation correctly implemented (src/parser/app-config/schema.ts:51-53)
    • Log level behavior matches PR description across all bundlers
    • Bundle cache correctly includes logLevel in hash computation
  • Example code (example/tailor.config.ts:104):

    • Updated with the new logLevel option
    • Uses the documented pattern with environment variable fallback
  • Service documentation (packages/sdk/docs/services/):

    • Existing console.log examples in executor.md and workflow.md remain valid
    • These examples will work correctly with logLevel config (may be dropped at bundle time depending on level)
  • Developer guide (AGENTS.md):

    • References to example/tailor.config.ts and configuration.md are current
    • No updates needed since it delegates to those resources

Implementation coverage verified:

  • ✅ Resolvers: src/cli/services/resolver/bundler.ts
  • ✅ Executors: src/cli/services/executor/bundler.ts
  • ✅ Workflows: src/cli/services/workflow/bundler.ts
  • ✅ Auth hooks: src/cli/services/auth/bundler.ts
  • ✅ HTTP adapters: src/cli/services/http-adapter/bundler.ts
  • ✅ Function test-run: src/cli/commands/function/bundle.ts

Note: The feature applies to "deployment functions" (resolvers, executors, workflows, auth hooks, HTTP adapters). TailorDB migrations use a separate bundler and are intentionally not affected, which is consistent with the documentation's description of "deployment functions."

Re-run this check by adding the docs-check label to the PR.


@dqn
Copy link
Copy Markdown
Contributor Author

dqn commented Jun 5, 2026

Missing logLevel config option in the example

Fixed in 586da2d.

@dqn dqn added the docs-check Trigger Docs Consistency Check label Jun 5, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the docs-check Trigger Docs Consistency Check label Jun 5, 2026
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Code Metrics Report (packages/sdk)

main (a0d07a9) #1341 (cb8d7a6) +/-
Coverage 66.0% 66.1% +0.0%
Code to Test Ratio 1:0.4 1:0.4 +0.0
Details
  |                    | main (a0d07a9) | #1341 (cb8d7a6) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          66.0% |           66.1% | +0.0% |
  |   Files            |            394 |             396 |    +2 |
  |   Lines            |          13517 |           13548 |   +31 |
+ |   Covered          |           8930 |            8961 |   +31 |
+ | Code to Test Ratio |          1:0.4 |           1:0.4 |  +0.0 |
  |   Code             |          90255 |           90574 |  +319 |
+ |   Test             |          39186 |           39339 |  +153 |

Code coverage of files in pull request scope (84.6% → 85.3%)

Files Coverage +/- Status
packages/sdk/src/cli/cache/bundle-cache.ts 100.0% 0.0% modified
packages/sdk/src/cli/commands/function/bundle.ts 96.5% +0.1% modified
packages/sdk/src/cli/commands/function/test-run.ts 53.1% 0.0% modified
packages/sdk/src/cli/services/application.ts 82.7% +0.1% modified
packages/sdk/src/cli/services/auth/bundler.ts 96.4% 0.0% modified
packages/sdk/src/cli/services/executor/bundler.ts 85.1% 0.0% modified
packages/sdk/src/cli/services/http-adapter/bundler.ts 91.7% 0.0% modified
packages/sdk/src/cli/services/resolver/bundler.ts 94.8% 0.0% modified
packages/sdk/src/cli/services/workflow/bundler.ts 93.9% 0.0% modified
packages/sdk/src/cli/shared/bundle-log-level.ts 100.0% +100.0% added
packages/sdk/src/cli/shared/function-treeshake.ts 100.0% +100.0% added
packages/sdk/src/parser/app-config/schema.ts 100.0% 0.0% modified
packages/sdk/src/types/app-config.ts 100.0% +100.0% modified

SDK Configure Bundle Size

main (a0d07a9) #1341 (cb8d7a6) +/-
configure-index-size 19.37KB 19.37KB 0KB
dependency-chunks-size 34.65KB 34.65KB 0KB
total-bundle-size 54.02KB 54.02KB 0KB

Runtime Performance

main (a0d07a9) #1341 (cb8d7a6) +/-
Generate Median 2,743ms 2,818ms 75ms
Generate Max 2,817ms 2,866ms 49ms
Apply Build Median 2,782ms 2,871ms 89ms
Apply Build Max 2,826ms 2,889ms 63ms

Type Performance (instantiations)

main (a0d07a9) #1341 (cb8d7a6) +/-
tailordb-basic 33,963 33,980 17
tailordb-optional 3,841 3,841 0
tailordb-relation 5,921 5,921 0
tailordb-validate 2,566 2,566 0
tailordb-hooks 5,767 5,767 0
tailordb-object 12,136 12,136 0
tailordb-enum 2,462 2,462 0
resolver-basic 9,424 9,424 0
resolver-nested 26,111 26,111 0
resolver-array 18,187 18,187 0
executor-schedule 4,234 4,234 0
executor-webhook 873 873 0
executor-record 6,659 6,659 0
executor-resolver 4,369 4,369 0
executor-operation-function 868 868 0
executor-operation-gql 869 869 0
executor-operation-webhook 888 888 0
executor-operation-workflow 1,714 1,714 0

Reported by octocov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants