Codegen: emit offline-sync adapters + paged queries, read spec from file#74
Merged
Conversation
Extends the SQLDelight codegen so the whole Supabase -> typed local DB chain generates from one OpenAPI document: - .sq tables gain countAll + offset page + keyset pageAfter queries. - New SupabaseSqlDelightAdapterGenerator emits SupabaseAdapters.kt: a supabaseAdapters(driver) factory wiring each table into an offline-sync LocalStore as its source of truth. Each entry is a generic SqlDelightTableAdapter configured by a column descriptor (kind + nullability) and primary key — no per-table conversion code is generated. Enabled with --format sqldelight --adapters true. - --spec <openapi.json> reads the schema from a local file (no network, no key); --url/--key still work. Verified live against supabase-codegen/sample/openapi.json: generates the .sq files + SupabaseAdapters.kt, and the generated adapters compile against the offline-sync runtime. Logged under Unreleased.
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
Closes the Supabase → typed local DB loop so the whole thing generates from one OpenAPI document.
.sqschema — paginationGenerated tables now also emit
countAll, offsetpage, and keysetpageAfterqueries (alongside the existingselectAll/selectById/upsert/deleteById).New: offline-sync adapter generation
SupabaseSqlDelightAdapterGeneratoremits aSupabaseAdapters.ktwith asupabaseAdapters(driver)factory that wires each generated table into an offline-syncLocalStoreas its single source of truth. Each entry is a genericSqlDelightTableAdapterconfigured by a column descriptor (storage kind + nullability) and primary key — no per-table conversion code is generated, because that logic lives once in the offline-sync runtime. Enable with--format sqldelight --adapters true.New: read the spec from a file
--spec <openapi.json>reads the schema from disk — no network, no key.--url/--keystill work.Verified live
Ran against a checked-in sample (
supabase-codegen/sample/openapi.json):The generated
SupabaseAdapters.ktcompiles cleanly against the offline-sync runtime (core + store-sqldelight + SQLDelight runtime) — column kinds (BOOL/INTEGER/REAL/JSON/TEXT), nullability, and pk all resolved from the spec.Tests
SupabaseSqlDelightAdapterGeneratorTestcovers the factory shape, runtime imports, pk wiring, every column-kind classification, and the new paged.sqqueries.:supabase-codegen:buildgreen (tests + detekt + spotless).Logged under Unreleased — no version bump.