Skip to content

refactor(cli): reuse fetchExistingResourcesWithLabels in deploy planning - #1613

Merged
toiroakr merged 5 commits into
mainfrom
refactor/dedup-deploy-fetchers
Jul 2, 2026
Merged

refactor(cli): reuse fetchExistingResourcesWithLabels in deploy planning#1613
toiroakr merged 5 commits into
mainfrom
refactor/dedup-deploy-fetchers

Conversation

@dqn

@dqn dqn commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Deduplicate existing-resource fetching in the deploy command by routing auth, IdP, resolver, secret manager, function registry, and TailorDB planning through the shared fetchExistingResourcesWithLabels helper; no user-facing behavior change.

dqn added 2 commits July 1, 2026 20:53
The deploy planners for auth, IdP, resolver, secret manager, function
registry, and TailorDB each inlined the same list-then-attach-labels
sequence that the shared fetchExistingResourcesWithLabels helper already
encapsulates (and that executor/workflow/staticwebsite/aigateway already
use). Route these six through the helper. No behavior change.

Claude-Session: https://claude.ai/code/session_01Xyr7Zg3HUNUJH1qg6AMqZq
Drop implementation details (helper name, per-service list) from the
changeset body; a user-invisible internal refactor only needs the
one-line user-facing summary.

Claude-Session: https://claude.ai/code/session_0113cu8MxKAhhutUGaXJqmQH
@changeset-bot

changeset-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 342a22a

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 Patch
@tailor-platform/create-sdk Patch

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@342a22a
pnpm add https://pkg.pr.new/@tailor-platform/sdk@342a22a

commit: 342a22a

@github-actions

This comment has been minimized.

@dqn
dqn marked this pull request as ready for review July 1, 2026 12:20
@dqn
dqn requested a review from a team as a code owner July 1, 2026 12:20
@dqn
dqn requested a review from toiroakr July 1, 2026 12:20

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📖 Docs Quality & Consistency Check

✅ Docs are consistent with the implementation and contain no user-facing internal-detail leaks.

Checked areas:

  • CLI documentation (packages/sdk/docs/cli/application.md) - Deploy command behavior documentation remains accurate; no changes needed since this is a pure refactoring with no user-visible behavior changes
  • Service documentation (packages/sdk/docs/services/*.md) - Not affected by internal deploy command refactoring
  • Developer guide (AGENTS.md) - No updates needed; no pattern or gotcha changes
  • Example code (example/) - Not affected; examples don't use internal deploy command functions
  • CLI public API (packages/sdk/src/cli/lib.ts) - Verified that fetchExistingResourcesWithLabels and related functions are not exposed to SDK users
  • Changeset (.changeset/dedup-deploy-fetchers.md) - Accurately describes this as "Internal refactoring" with "No user-facing behavior change"

PR Summary:
This PR refactors the deploy command to deduplicate existing-resource fetching logic by consolidating six similar code blocks (in auth, IdP, resolver, secret manager, function registry, and TailorDB planning) into a shared helper function fetchExistingResourcesWithLabels. The changes are:

  • Purely internal to packages/sdk/src/cli/commands/deploy/ (not part of the public API)
  • No behavior changes to the deploy command
  • No new user-facing APIs or configuration options
  • JSDoc comments in owned-resource.ts document internal functions not exposed to users

Verification:

  • Confirmed the helper function is not exported from packages/sdk/src/cli/lib.ts (the public CLI API entry point)
  • Verified user-facing documentation describes observable behavior (unmanaged resources, ownership conflicts) without mentioning implementation details
  • Checked that no new internal details were leaked to published docs, examples, or JSDoc on exported symbols

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


}
},
getName: (resource) => resource.namespace?.name,
getTrn: (workspaceId, name) => resourceTrn(workspaceId, "auth", name),

@toiroakr toiroakr Jul 1, 2026

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.

The workspaceId argument in getTrn is redundant as it simply passes the workspaceId from the closure at the call site.

By changing the getTrn(name) signature in owned-resource.ts and updating the call site to (name) => resourceTrn(workspaceId, "auth", name), you can remove this argument in all six locations.

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 5a56d47.

@toiroakr

toiroakr commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The same pattern for deduplication remains in auth-connection.ts:136-164 (fetchAll + suppressing NotFound + calling getMetadata with Promise.all and manually constructing WithLabel).

Since there is a possibility that this same pattern was added in parallel in a separate PR, it would be helpful if you could also align this with fetchExistingResourcesWithLabels, depending on the merge order.

// Fetch existing function registry entries
const existingFunctions = await fetchAll(async (pageToken, maxPageSize) => {
try {
// Fetch existing function registry entries with their labels

@toiroakr toiroakr Jul 1, 2026

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 comment is merely a paraphrase of the function name fetchExistingResourcesWithLabels and does not provide any information that cannot already be gathered from the code.

Suggested change
// Fetch existing function registry entries with their labels

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 5a56d47.

@toiroakr toiroakr assigned dqn and unassigned toiroakr Jul 1, 2026
@dqn
dqn requested a review from toiroakr July 1, 2026 18:11
@dqn dqn removed their assignment Jul 1, 2026
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Code Metrics Report (packages/sdk)

main (a58efe9) #1613 (8858c6f) +/-
Coverage 71.1% 71.2% +0.0%
Code to Test Ratio 1:0.4 1:0.4 +0.0
Details
  |                    | main (a58efe9) | #1613 (8858c6f) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          71.1% |           71.2% | +0.0% |
  |   Files            |            428 |             428 |     0 |
  |   Lines            |          15781 |           15737 |   -44 |
- |   Covered          |          11235 |           11211 |   -24 |
+ | Code to Test Ratio |          1:0.4 |           1:0.4 |  +0.0 |
  |   Code             |         107143 |          107004 |  -139 |
  |   Test             |          48418 |           48418 |     0 |

Code coverage of files in pull request scope (77.2% → 77.7%)

Files Coverage +/- Status
packages/sdk/src/cli/commands/deploy/aigateway.ts 78.7% 0.0% modified
packages/sdk/src/cli/commands/deploy/auth.ts 67.9% +0.3% modified
packages/sdk/src/cli/commands/deploy/executor.ts 80.0% 0.0% modified
packages/sdk/src/cli/commands/deploy/function-registry.ts 91.3% +2.0% modified
packages/sdk/src/cli/commands/deploy/idp.ts 80.3% +1.1% modified
packages/sdk/src/cli/commands/deploy/owned-resource.ts 85.1% 0.0% modified
packages/sdk/src/cli/commands/deploy/resolver.ts 81.0% +1.7% modified
packages/sdk/src/cli/commands/deploy/secret-manager.ts 92.0% +2.1% modified
packages/sdk/src/cli/commands/deploy/staticwebsite.ts 88.3% 0.0% modified
packages/sdk/src/cli/commands/deploy/tailordb/index.ts 77.0% +0.4% modified
packages/sdk/src/cli/commands/deploy/workflow.ts 73.6% 0.0% modified
packages/sdk/src/cli/commands/workflow/waiter.ts 72.8% -2.2% affected
packages/sdk/src/cli/shared/context.ts 78.8% 0.0% modified

SDK Configure Bundle Size

main (a58efe9) #1613 (8858c6f) +/-
configure-index-size 20.32KB 20.32KB 0KB
dependency-chunks-size 47.13KB 47.13KB 0KB
total-bundle-size 67.45KB 67.45KB 0KB

Runtime Performance

main (a58efe9) #1613 (8858c6f) +/-
Generate Median 3,050ms 2,864ms -186ms
Generate Max 3,092ms 2,935ms -157ms
Apply Build Median 3,102ms 2,893ms -209ms
Apply Build Max 3,145ms 2,920ms -225ms

Type Performance (instantiations)

main (a58efe9) #1613 (8858c6f) +/-
tailordb-basic 39,480 39,480 0
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,272 0
resolver-nested 26,139 26,139 0
resolver-array 18,078 18,078 0
executor-schedule 4,310 4,310 0
executor-webhook 949 949 0
executor-record 5,664 5,664 0
executor-resolver 4,108 4,108 0
executor-operation-function 937 937 0
executor-operation-gql 945 945 0
executor-operation-webhook 956 956 0
executor-operation-workflow 1,785 1,785 0

Reported by octocov

@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 95c52a3 into main Jul 2, 2026
41 checks passed
@toiroakr
toiroakr deleted the refactor/dedup-deploy-fetchers branch July 2, 2026 00:39
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