Repository navigation
feat(api-sync): generate SDK methods for new spec operations (operation-insert) - #71
Merged
Merged
Conversation
…on-insert) Extends the deterministic patcher with an operation-insert change kind so STANDARD spec operations (JSON in/out, path/query/body params, belonging to an existing resource by literal path segment) no longer need a human: the generator adds the method to the right resource, synthesizes Input/Output types from the operation's schemas (reusing whole-schema/canonical-enum symbols already mapped in spec-map.json where possible), and records new schema map entries for any never-before-modeled named schema so future field/enum drift on it stays patchable. Discovery is state-based (like enum-insert/field-insert), not a diff against the previous spec: a spec operation with no matching SDK endpoint is a gap whether the spec just introduced it or a human deleted the SDK method by hand. NON-STANDARD operations (multipart/binary, non-JSON content, no matching resource, ambiguous resource ownership, required header/cookie params) stay needs-human with a precise reason; a handful of pre-existing, already-known non-standard gaps (the Rfi family, POST /v1/upload/analyze) are grandfathered into a new ignore.operations list so this doesn't regress previously-tolerated coverage gaps into a sudden CI failure. Any operation-insert bumps minor, matching the existing classifyBump rule. --check now also fails on a pending, un-applied operation-insert, same as existing drift. Claude-Session: https://claude.ai/code/session_01F1stiNzuNtJXoXtiW9ZCbs
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
What
Extends the deterministic api-sync patcher (scripts/api-sync/) with an
operation-insertapplicable change kind. New spec operations that are STANDARD no longer need a human touch; the generator writes the endpoint method itself.Classifier boundary
STANDARD (auto-generated):
application/json)./v1/instances/{instance_id}/...).bank-accountsin.../customers/{customer_id}/bank-accounts/{id}, not the genericcustomerscontainer).(instanceId: string, client: InternalApiClient)signature.Idempotency-Key, never modeled by this SDK); a required one is out of scope.For a STANDARD operation, the generator:
list/get/create/update/delete, plus any trailing literal segment PascalCased, e.g.createEvm).typegen.ts), reusing:types/index.d.ts) when a spec-inlined enum's value set matches one exactly, instead of a fresh inline literal union;NON-STANDARD (stays needs-human, precise reason, never guessed):
available/*,upload, the instances resource's own{id}-keyed CRUD,/e/...tracking routes)(instanceId, client)shapeDiscovery is state-based (mirrors enum-insert/field-insert): a spec operation with no matching SDK endpoint is a gap whether the spec just introduced it or a human deleted the SDK method by hand, not a diff against the previous spec snapshot. A precise per-operation path-shape matcher (
resource-registry.ts) does the discovery for the common instance-scoped case; the existing coarsecoverage.tsheuristic (last-segment-appears-anywhere) is reused as a fallback for the handful of operations outside that template's scope, so an already-hand-implementedavailable/*-style endpoint doesn't turn into a spurious finding every run.A handful of pre-existing, already-known non-standard gaps (the Rfi family,
POST /v1/upload/analyze) are grandfathered into a newignore.operationslist in spec-map.json, so this doesn't turn previously-tolerated coverage gaps into a sudden CI failure — a genuinely new non-standard gap still fails needs-human until a human reviews and either builds it by hand or adds it to the ignore list.Any operation-insert bumps
minor(existingclassifyBumprule, now reachable).--checkfails on a pending, un-applied operation-insert the same way it fails on pending enum/field drift today.Golden self-test evidence
scripts/api-sync/operation-gen.golden.test.ts: in a scratch copy of the whole repo, deletespayins.get(+GetPayinInput/GetPayinResponse) andquotes.create(+CreateQuoteInput/CreateQuoteResponse), then runs--applyagainst the committed snapshot spec. Asserts:bun run check-typesandbun run testpass against the regenerated repo--applyrun is byte-identical (idempotent)--checkpasses clean afterwardscripts/api-sync/operation-gen.test.ts: isolated classifier unit tests against a synthetic fixture resource/spec — a GET-by-id classifies STANDARD with the expected method/type text, amultipart/form-datarequest body classifies NON-STANDARD with a precise reason, and a request body referencing a never-before-modeled named schema gets a new spec-map.json schema entry.Also ran the full local gauntlet clean:
bun run check-types,bun run test(182 tests),bun run contract-check,bun run sync:check(against the live repo, no regressions on the 130 existing known divergences),bun run lint:check.What still needs a human
Multipart/binary uploads, anything outside the
instances/{instance_id}template shape (a brand-new top-level resource,available/*-style bare-client resources), ambiguous or unowned path segments, and required header/cookie params. All of these fail loud with a specific reason instead of silently guessing.Claude-Session: https://claude.ai/code/session_01F1stiNzuNtJXoXtiW9ZCbs