feat(smithy): add canonical Smithy model for PostgREST (DatabaseService)#52
Closed
grdsdev wants to merge 2 commits into
Closed
feat(smithy): add canonical Smithy model for PostgREST (DatabaseService)#52grdsdev wants to merge 2 commits into
grdsdev wants to merge 2 commits into
Conversation
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.
Collaborator
Author
|
Work folded into #51 (the living draft for Smithy models). |
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.
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):SelectRows(GET),InsertRows(POST),UpdateRows(PATCH),UpsertRows(PUT),DeleteRows(DELETE)CallRpcPost(POST),CallRpcGet(GET)Key design decisions:
FilterOperatorenum — 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: StringMaponSelectRows,UpdateRows,UpsertRows,DeleteRows— each map entry serialises to a?column=op.valuequery 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: StringMaponCallRpcGet— 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
StringMapadded tocommon.smithy— reusablemap<String, String>shape.functions.smithyupdated —@httpQueryParams query: StringMapadded to all function inputs, resolving the previously documented limitation thatFunctionInvokeOptions.querycould not be expressed in Smithy.smithy-build.json—database-openapiprojection 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
smithy build— verifydatabase-openapiprojection emitsDatabaseService.openapi.jsoncleanlypython patch-openapi.pyon the new artifact — verify it applies without errorFilterOperatorenum appears in the generated OpenAPIcomponents/schemasfilters/args/querymap params appear asin: querywithschema: { type: object, additionalProperties: { type: string } }in the generated OpenAPIfunctions.smithybuilds correctly andqueryparam appears on all five function operations