feat(api): support v2 namespace endpoints in @supabase/api - #6142
Draft
Coly010 wants to merge 4 commits into
Draft
feat(api): support v2 namespace endpoints in @supabase/api#6142Coly010 wants to merge 4 commits into
Coly010 wants to merge 4 commits into
Conversation
Fetch and merge both Management API OpenAPI documents (/api/v1-json and
/api/v2-json), derive client namespaces from the path, and regenerate the
snapshot so v2 operations are callable as api.v2.<operation>.
- download-openapi.ts: two-document fetch (hard-fail on a missing doc),
structural merge with collision asserts, tolerant remove override op,
committed source pin in scripts/openapi-source.json (staging for now:
GET /v2/projects/{ref}/config has not shipped to prod yet)
- generate.ts: version namespace derived from the leading path segment,
duplicate-operation hard error; v1 output is byte-identical
- openapi-overrides.json: remove the v2 webhook paths (upstream spec bug:
duplicated, non-version-prefixed operationIds) and APIErrorObject
- api-package-sync.yml: pin hourly sync to prod, diff the source pin
- generate:check script + README spec-pipeline/override/merge-gate docs
- generated-contract-sync.unit.test.ts: bijection between the committed openapi.json snapshot and the generated contracts/effect client, so a hand-edited snapshot or client fails CI - client.unit.test.ts: 404 on a v2 operation surfaces as a StatusCodeError with the response status; v2 requests carry identical auth/base-url wiring; nested V2ProjectConfigResponse payload decodes strictly - effect.unit.test.ts: same-named v1/v2 operations are separately addressable per namespace - export OpenApiDocument/OpenApiOperation types from generate.ts for typed test fixtures
ApiClient now carries a v2 namespace, so the v1-only mock object no longer overlaps the ApiClient type. The legacy shell only calls v1 operations; v2 calls die loudly as wiring bugs.
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 changed
`@supabase/api` previously modeled only the Management API v1 namespace. The upstream API now publishes two OpenAPI documents (`/api/v1-json` and `/api/v2-json`), and the config endpoint needed by CLI-2156/CLI-2064 lives on v2. This PR makes v2 a first-class namespace:
`GET /v2/projects/{ref}/config` (`api.v2.getProjectConfig`, the proving case from CLI-2137/CLI-2157) has not shipped to prod yet, so the committed snapshot is generated from `api.supabase.green`. After the webhook removals, that endpoint is the entire prod↔staging delta. Do not merge until either:
Otherwise develop's first hourly sync after merge will auto-merge a PR deleting the endpoint from the client. Fallback if a staging-sourced snapshot is unacceptable: switch the sidecar to prod and inject the config endpoint via `add` overrides (~10KB) — the `add` hard-fails the day prod ships it, a self-removing reminder.
Known limitation
Three v2 operations (`v2-list-organization-members`, `v2-list-organization-projects`, `v2-list-organization-github-connections`) declare `style: deepObject` object query params, which the client currently serializes as JSON strings rather than `page[size]=...`. Documented in the README; the typed surface is correct, the wire format for those params is not.
Part of CLI-2157 (unblocks CLI-2156 and CLI-2064).