Skip to content

refactor(cli): consolidate the duplicated pick helpers into one shared util#88

Merged
yasserstudio merged 1 commit into
mainfrom
chore/consolidate-pick-util
Jun 13, 2026
Merged

refactor(cli): consolidate the duplicated pick helpers into one shared util#88
yasserstudio merged 1 commit into
mainfrom
chore/consolidate-pick-util

Conversation

@yasserstudio

Copy link
Copy Markdown
Owner

Tech-debt cleanup: the accounts, regions, and datasources write commands each carried their own copy of the same allowlist-pick that strips output-only fields from a parsed --file body before a PATCH updateMask.

  • Moves the generic pick<T>(obj, fields) to packages/cli/src/commands/_shared.ts (it lived in accounts.ts).
  • regions.ts / datasources.ts drop their pickWritable copies and call the shared pick with their own field-list constants (both now as const satisfies readonly (keyof T)[], so the allowlist still compile-guards against drift).
  • Net −17 lines; one source of truth for the helper.

Behavior-preserving — no command output or API payload changes. The function body moved byte-for-byte; every field list is unchanged. Verified: build + lint + typecheck + format clean, all 583 tests pass. Two-agent review (correctness + safety) returned 0 findings — confirmed identical picked-fields at every call site and no prototype-pollution vector (keys come from the fixed allowlist, never the untrusted body).

No changeset — this is an internal, user-invisible refactor, so it rides the next versioned release rather than cutting a no-op patch. (Separately: checked deps — the safe dev-dep updates were already current in the lockfile; no bump needed.)

…d util

The accounts (generic pick<T>), regions (pickWritable), and datasources
(pickWritable) commands each had a copy of the same allowlist-pick that strips
output-only fields from a parsed --file body before a PATCH. Move the generic
pick<T> to _shared.ts and have all three use it; regions/datasources keep their
own field-list constants (now satisfies-guarded) and pass them in.

Behavior-preserving — no command output or API payload changes.
@yasserstudio yasserstudio merged commit 0744320 into main Jun 13, 2026
7 checks passed
@yasserstudio yasserstudio deleted the chore/consolidate-pick-util branch June 13, 2026 12:03
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.

1 participant