refactor(cli): consolidate the duplicated pick helpers into one shared util#88
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tech-debt cleanup: the
accounts,regions, anddatasourceswrite commands each carried their own copy of the same allowlist-pick that strips output-only fields from a parsed--filebody before a PATCHupdateMask.pick<T>(obj, fields)topackages/cli/src/commands/_shared.ts(it lived inaccounts.ts).regions.ts/datasources.tsdrop theirpickWritablecopies and call the sharedpickwith their own field-list constants (both nowas const satisfies readonly (keyof T)[], so the allowlist still compile-guards against drift).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.)