Skip to content

feat(smithy): add canonical Smithy model for PostgREST (DatabaseService)#52

Closed
grdsdev wants to merge 2 commits into
mainfrom
claude/happy-brattain-ebac12
Closed

feat(smithy): add canonical Smithy model for PostgREST (DatabaseService)#52
grdsdev wants to merge 2 commits into
mainfrom
claude/happy-brattain-ebac12

Conversation

@grdsdev

@grdsdev grdsdev commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds model/database.smithy — a canonical Smithy IDL definition for the PostgREST HTTP API — completing the set of Supabase service models alongside Storage and Functions.

What's modelled

DatabaseService (base URL: /rest/v1):

Group Operations
Row CRUD SelectRows (GET), InsertRows (POST), UpdateRows (PATCH), UpsertRows (PUT), DeleteRows (DELETE)
RPC CallRpcPost (POST), CallRpcGet (GET)

Key design decisions:

  • FilterOperator enum — all 24 PostgREST operators (eq, neq, lt, lte, gt, gte, like, ilike, match, imatch, is, isdistinct, in, cs, cd, ov, sl, sr, nxl, nxr, adj, fts, plfts, phfts, wfts) with SQL-equivalent doc comments. Generated as typed constants in every SDK.

  • @httpQueryParams filters: StringMap on SelectRows, UpdateRows, UpsertRows, DeleteRows — each map entry serialises to a ?column=op.value query parameter (e.g. {"id": "eq.5", "name": "like.foo*"}?id=eq.5&name=like.foo*). The query-builder API (.eq(), .like(), etc.) that constructs this map stays hand-written — that's a UX layer, not a transport gap.

  • @httpQueryParams args: StringMap on CallRpcGet — same pattern for function-specific GET parameters.

  • Bodies are Blob — row and RPC response shapes are table-dependent and cannot be statically typed in the model.

  • Write ops use code 200 — PostgREST returns 204 (no body) by default and 200 (with body) for Prefer: return=representation. Smithy requires a single success code; 200 is used throughout so generators emit body-parsing code. Documented as known limitation feat: add review-spec and review-spec-compliance skills #6.

Also in this PR

  • StringMap added to common.smithy — reusable map<String, String> shape.

  • functions.smithy updated@httpQueryParams query: StringMap added to all function inputs, resolving the previously documented limitation that FunctionInvokeOptions.query could not be expressed in Smithy.

  • smithy-build.jsondatabase-openapi projection added.

  • README.md — documents the new service, its filter/RPC design, and the updated known-limitations table (now 6 entries, down from 6 after resolving the Functions query-params gap).

Test plan

  • Run smithy build — verify database-openapi projection emits DatabaseService.openapi.json cleanly
  • Run python patch-openapi.py on the new artifact — verify it applies without error
  • Confirm FilterOperator enum appears in the generated OpenAPI components/schemas
  • Confirm filters / args / query map params appear as in: query with schema: { type: object, additionalProperties: { type: string } } in the generated OpenAPI
  • Verify functions.smithy builds correctly and query param appears on all five function operations

grdsdev added 2 commits July 1, 2026 06:03
Adds Smithy IDL definitions for Supabase Storage and Edge Functions HTTP
APIs as a shared source-of-truth for cross-SDK codegen spikes. Each SDK
team runs their own generator toolchain against the same models.

Includes:
- model/common.smithy  — shared shapes (StringList)
- model/storage.smithy — buckets, objects, signed URLs, TUS resumable uploads
- model/functions.smithy — invoke operations for GET/POST/PUT/PATCH/DELETE
- smithy-build.json    — Smithy CLI / Gradle build config
- patch-openapi.py     — post-generation patches for streaming blob and multipart
- openapi/             — committed generated OpenAPI 3.0 artifacts (patched)

Known limitations documented in README (streaming blob format, multipart,
dynamic query params). Auth and PostgREST models are not yet included —
each SDK spike (SDK-1103 through SDK-1109) must assess those layers.

Related: RFC auto-generating parts of the Supabase SDKs
Swift spike: supabase/supabase-swift#1047
Adds model/database.smithy covering the full PostgREST HTTP surface:

- SelectRows / InsertRows / UpdateRows / UpsertRows / DeleteRows on /{table}
- CallRpcPost / CallRpcGet on /rpc/{functionName}
- Fixed query params: select, order, limit, offset, on_conflict, columns
- Well-known headers: Prefer, Range, Range-Unit, Accept, Accept-Profile,
  Content-Profile, Content-Range
- FilterOperator enum — all 24 PostgREST operators generated as typed constants
- @httpQueryParams filters: StringMap on read/write inputs so column=op.value
  filter params are model-declared and generated (not hand-wired middleware)
- @httpQueryParams args: StringMap on CallRpcGet for function-specific params

Also adds StringMap to common.smithy and uses it in functions.smithy to express
FunctionInvokeOptions.query (previously listed as a known limitation).

Adds database-openapi projection to smithy-build.json.
@grdsdev
grdsdev requested a review from a team as a code owner July 1, 2026 09:21
@grdsdev

grdsdev commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Work folded into #51 (the living draft for Smithy models).

@grdsdev grdsdev closed this Jul 1, 2026
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