feat(sdk)!: remove defineAuth getConnectionToken helper - #1622
Conversation
🦋 Changeset detectedLatest commit: b71c5d8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
commit: |
This comment has been minimized.
This comment has been minimized.
545480f to
7bd70fa
Compare
This comment has been minimized.
This comment has been minimized.
|
|
||
| while (start > 0 && /[ \t]/.test(source[start - 1]!)) start--; | ||
| if (source[start - 1] === ",") start--; | ||
| return { startPos: start, endPos, insertedText: "" }; |
There was a problem hiding this comment.
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.
| if (binding) collectBindingNames(binding, names); | ||
| } | ||
| for (const param of root.findAll({ | ||
| rule: { any: [{ kind: "required_parameter" }, { kind: "optional_parameter" }] }, |
There was a problem hiding this comment.
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.
| } | ||
|
|
||
| function quickFilter(source: string): boolean { | ||
| return source.includes(GET_CONNECTION_TOKEN) && source.includes("tailor.config"); |
There was a problem hiding this comment.
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.
| let start = range.start.index; | ||
| let end = range.end.index; | ||
| while (end < source.length && /[ \t]/.test(source[end]!)) end++; | ||
| if (source[end] === ",") { |
There was a problem hiding this comment.
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).
| @@ -0,0 +1,436 @@ | |||
| import { parse, Lang } from "@ast-grep/napi"; | |||
There was a problem hiding this comment.
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.
Code Metrics Report (packages/sdk)
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%)DetailsSDK Configure Bundle Size
Runtime Performance
Type Performance (instantiations)
Reported by octocov |
…nnection-token feat(sdk)!: remove defineAuth getConnectionToken helper
…nnection-token feat(sdk)!: remove defineAuth getConnectionToken helper
…nnection-token feat(sdk)!: remove defineAuth getConnectionToken helper
Summary
SDK v2 no longer exposes the deprecated
defineAuth()connection-token helper; runtime code should useauthconnection.getConnectionToken()instead.Migration
becomes:
Notes
authexport fromtailor.config.auth.getConnectionToken(...)calls whereauthis a namedtailor.configimport; other patterns are reported for review.