Skip to content

feat(sdk)!: remove defineAuth getConnectionToken helper - #1622

Merged
toiroakr merged 36 commits into
v2from
refactor/remove-auth-connection-token
Jul 3, 2026
Merged

feat(sdk)!: remove defineAuth getConnectionToken helper#1622
toiroakr merged 36 commits into
v2from
refactor/remove-auth-connection-token

Conversation

@dqn

@dqn dqn commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

SDK v2 no longer exposes the deprecated defineAuth() connection-token helper; runtime code should use authconnection.getConnectionToken() instead.

Migration

import { auth } from "../tailor.config";

await auth.getConnectionToken("google");

becomes:

import { authconnection } from "@tailor-platform/sdk/runtime";

await authconnection.getConnectionToken("google");

Notes

  • This is a breaking change for code that fetches connection tokens through the auth export from tailor.config.
  • The codemod rewrites direct auth.getConnectionToken(...) calls where auth is a named tailor.config import; other patterns are reported for review.

@changeset-bot

changeset-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b71c5d8

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

This PR includes changesets to release 3 packages
Name Type
@tailor-platform/sdk Major
@tailor-platform/sdk-codemod Patch
@tailor-platform/create-sdk Major

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

pkg-pr-new Bot commented Jul 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: b71c5d8

@github-actions

This comment has been minimized.

@dqn
dqn force-pushed the refactor/remove-auth-connection-token branch from 545480f to 7bd70fa Compare July 2, 2026 03:22
@github-actions

This comment has been minimized.

@dqn
dqn marked this pull request as ready for review July 2, 2026 03:42
@dqn
dqn requested a review from a team as a code owner July 2, 2026 03:42
@dqn
dqn requested a review from toiroakr July 2, 2026 03:42

while (start > 0 && /[ \t]/.test(source[start - 1]!)) start--;
if (source[start - 1] === ",") start--;
return { startPos: start, endPos, insertedText: "" };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endPos isn't declared anywhere in this scope (only end is).

This branch runs when removing the last specifier (no trailing comma) in a multi-specifier import, so it throws Cannot find name 'endPos' and fails to build.

Should be end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b71c5d8.

if (binding) collectBindingNames(binding, names);
}
for (const param of root.findAll({
rule: { any: [{ kind: "required_parameter" }, { kind: "optional_parameter" }] },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bare arrow-function params (list.map(auth => ...)) and catch (auth) {...} bindings aren't caught here.

They aren't wrapped in required_parameter/optional_parameter — the identifier is a direct child of arrow_function/catch_clause — so the shadow goes undetected and a call on the locally-shadowed auth gets incorrectly rewritten to authconnection.getConnectionToken(...).

Worth also scanning the direct identifier child of arrow_function/catch_clause.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b71c5d8.

}

function quickFilter(source: string): boolean {
return source.includes(GET_CONNECTION_TOKEN) && source.includes("tailor.config");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gates on the literal substring "tailor.config", so if auth is re-exported from a differently-named module, both the rewrite and the LLM-review fallback (reviewFindings is gated by the same function) are silently skipped.

Every other unsupported pattern (default import, etc.) is explicitly routed to LLM review — this one gets no feedback at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b71c5d8.

let start = range.start.index;
let end = range.end.index;
while (end < source.length && /[ \t]/.test(source[end]!)) end++;
if (source[end] === ",") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the trailing comma this only skips spaces/tabs, not the newline.

Removing auth, from a multi-line named-import list leaves a blank/whitespace-only line behind (the existing fixtures only cover the single-specifier case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b71c5d8.

@@ -0,0 +1,436 @@
import { parse, Lang } from "@ast-grep/napi";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

collectBindingNames/localDeclarationNames/findImportStatements/importSource etc. are near-duplicates of the same-named functions in v2/runtime-globals-opt-in and v2/auth-invoker-unwrap.

There's no shared helper module under packages/sdk-codemod/src/, so each codemod reimplements this independently.

Could be a separate PR, but extracting a shared module would help as more codemods get added.

@toiroakr toiroakr assigned dqn and unassigned toiroakr Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Code Metrics Report (packages/sdk)

main (1f4c68a) #1622 (1d0dd56) +/-
Coverage 71.8% 72.4% +0.5%
Code to Test Ratio 1:0.4 1:0.4 +0.0
Details
  |                    | main (1f4c68a) | #1622 (1d0dd56) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          71.8% |           72.4% | +0.5% |
  |   Files            |            429 |             424 |    -5 |
  |   Lines            |          16000 |           15811 |  -189 |
- |   Covered          |          11491 |           11449 |   -42 |
+ | Code to Test Ratio |          1:0.4 |           1:0.4 |  +0.0 |
  |   Code             |         109312 |          107940 | -1372 |
+ |   Test             |          49682 |           49717 |   +35 |

Code coverage of files in pull request scope (77.4% → 78.6%)

Details
Files Coverage +/- Status
packages/sdk-codemod/src/registry.ts 0.0% -60.0% modified
packages/sdk/example/tailordb/user.ts 0.0% -100.0% affected
packages/sdk/llm-challenge/src/types.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/test_fixtures/tailor.config.generators-compat.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/test_fixtures/tailor.config.plugins-compat.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/aigateway.ts 78.7% -21.3% affected
packages/sdk/src/cli/commands/deploy/auth-invoker.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/auth.ts 67.6% -0.4% affected
packages/sdk/src/cli/commands/deploy/executor.ts 80.1% +0.1% affected
packages/sdk/src/cli/commands/deploy/function-registry.ts 89.3% -2.1% affected
packages/sdk/src/cli/commands/deploy/idp.ts 79.1% -1.2% affected
packages/sdk/src/cli/commands/deploy/invoker.ts 100.0% +100.0% affected
packages/sdk/src/cli/commands/deploy/resolver.ts 79.3% -1.8% affected
packages/sdk/src/cli/commands/deploy/secret-manager.ts 89.9% -2.2% affected
packages/sdk/src/cli/commands/deploy/tailordb/index.ts 76.6% -6.8% affected
packages/sdk/src/cli/commands/function/logs.ts 39.7% -4.6% affected
packages/sdk/src/cli/commands/function/test-run.ts 56.8% -3.4% affected
packages/sdk/src/cli/commands/generate/service.ts 58.3% -9.9% affected
packages/sdk/src/cli/commands/login.ts 37.3% -0.6% affected
packages/sdk/src/cli/commands/profile/create.ts 77.2% +72.7% affected
packages/sdk/src/cli/commands/profile/update.ts 92.3% +0.2% affected
packages/sdk/src/cli/commands/tailordb/migrate/db-types-generator.ts 96.5% -0.8% affected
packages/sdk/src/cli/commands/tailordb/migrate/diff-calculator.ts 73.4% +0.7% affected
packages/sdk/src/cli/commands/tailordb/migrate/snapshot.ts 75.8% -4.6% affected
packages/sdk/src/cli/commands/user/switch.ts 88.2% +0.7% affected
packages/sdk/src/cli/commands/workflow/start.ts 83.6% +12.5% affected
packages/sdk/src/cli/commands/workspace/create.ts 86.7% +0.2% affected
packages/sdk/src/cli/crashreport/report.ts 88.0% +2.2% affected
packages/sdk/src/cli/index.ts 27.2% -6.1% affected
packages/sdk/src/cli/query/type-field-order.ts 85.7% +85.7% affected
packages/sdk/src/cli/services/application.ts 84.1% +3.3% modified
packages/sdk/src/cli/services/executor/loader.ts 84.6% +1.2% affected
packages/sdk/src/cli/services/workflow/service.ts 83.7% +3.7% affected
packages/sdk/src/cli/shared/auth-namespace.ts 100.0% +100.0% affected
packages/sdk/src/cli/shared/config-loader.ts 74.1% -8.2% affected
packages/sdk/src/cli/shared/context.ts 94.4% +15.5% affected
packages/sdk/src/cli/shared/register-ts-hook.ts 100.0% +100.0% affected
packages/sdk/src/cli/shared/type-generator.ts 82.4% -0.3% affected
packages/sdk/src/cli/ts-hook.mjs 84.4% +84.4% affected
packages/sdk/src/configure/services/auth/index.ts 100.0% +25.0% modified
packages/sdk/src/configure/services/auth/types.ts 0.0% 0.0% modified
packages/sdk/src/configure/services/staticwebsite/index.ts 100.0% +100.0% affected
packages/sdk/src/configure/services/tailordb/schema.ts 82.1% +0.5% affected
packages/sdk/src/configure/services/workflow/job.ts 90.0% +4.2% affected
packages/sdk/src/configure/services/workflow/registry.ts 95.0% +11.1% affected
packages/sdk/src/configure/services/workflow/test-env-key.ts 100.0% +6.6% affected
packages/sdk/src/configure/services/workflow/workflow.ts 66.6% +6.6% affected
packages/sdk/src/parser/service/auth/schema.ts 92.3% +5.1% affected
packages/sdk/src/parser/service/tailordb/builder-helpers.ts 85.7% +85.7% affected
packages/sdk/src/parser/service/tailordb/field.ts 96.4% -3.6% affected
packages/sdk/src/plugin/builtin/seed/index.ts 0.0% -1.6% affected
packages/sdk/src/vitest/mock.ts 95.4% +2.4% affected
packages/sdk/src/vitest/workflow-local.ts 76.5% +76.5% affected
packages/sdk/src/vitest/workflow-runtime.ts 57.1% +23.8% affected

SDK Configure Bundle Size

main (1f4c68a) #1622 (1d0dd56) +/-
configure-index-size 20.32KB 21.31KB 0.99KB
dependency-chunks-size 47.12KB 34.8KB -12.32KB
total-bundle-size 67.44KB 56.11KB -11.33KB

Runtime Performance

main (1f4c68a) #1622 (1d0dd56) +/-
Generate Median 3,015ms 2,938ms -77ms
Generate Max 3,033ms 3,096ms 63ms
Apply Build Median 3,076ms 2,958ms -118ms
Apply Build Max 3,092ms 2,996ms -96ms

Type Performance (instantiations)

main (1f4c68a) #1622 (1d0dd56) +/-
tailordb-basic 39,489 39,083 -406
tailordb-optional 4,385 4,385 0
tailordb-relation 5,103 5,103 0
tailordb-validate 742 742 0
tailordb-hooks 5,222 5,222 0
tailordb-object 12,510 12,510 0
tailordb-enum 1,450 1,450 0
resolver-basic 9,272 9,247 -25
resolver-nested 26,139 26,114 -25
resolver-array 18,078 18,053 -25
executor-schedule 4,310 4,297 -13
executor-webhook 949 936 -13
executor-record 5,664 5,651 -13
executor-resolver 4,108 4,092 -16
executor-operation-function 937 924 -13
executor-operation-gql 945 932 -13
executor-operation-webhook 956 943 -13
executor-operation-workflow 1,789 1,764 -25

Reported by octocov

@dqn
dqn requested a review from toiroakr July 2, 2026 23:03
@dqn dqn assigned toiroakr and unassigned dqn Jul 2, 2026

@toiroakr toiroakr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@toiroakr
toiroakr merged commit 232f1d4 into v2 Jul 3, 2026
44 checks passed
@toiroakr
toiroakr deleted the refactor/remove-auth-connection-token branch July 3, 2026 01:24
toiroakr added a commit that referenced this pull request Jul 31, 2026
…nnection-token

feat(sdk)!: remove defineAuth getConnectionToken helper
toiroakr added a commit that referenced this pull request Jul 31, 2026
…nnection-token

feat(sdk)!: remove defineAuth getConnectionToken helper
toiroakr added a commit that referenced this pull request Jul 31, 2026
…nnection-token

feat(sdk)!: remove defineAuth getConnectionToken helper
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