Skip to content

feat: add supabase_typegen package generating typed table definitions - #1635

Draft
spydon wants to merge 18 commits into
feat/typed-table-accessfrom
feat/supabase-gen
Draft

feat: add supabase_typegen package generating typed table definitions#1635
spydon wants to merge 18 commits into
feat/typed-table-accessfrom
feat/supabase-gen

Conversation

@spydon

@spydon spydon commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature (draft, layer 2 of the typed table access work, stacked on #1634). Adds a new supabase_typegen package: a standalone code generator that turns a database schema into the typed table definitions introduced in #1634, so users get the fully typed surface without writing any of it by hand.

Linear: SDK-1362

What is the new behavior?

supabase gen types --lang json --local > schema.json
dart run supabase_typegen --input schema.json

reads the language-neutral GeneratorMetadata introspection document (the @supabase/postgrest-typegen contract from supabase/pg-toolbelt#302, which postgres-meta itself consumes after supabase/postgres-meta#1084; --input - reads it from stdin) and emits one Dart file containing, per table:

  • a zero-cost row extension type over the decoded JSON map with typed getters (DateTime parsing, double/num coercion, List casts, Postgres enum mapping),
  • Insert and Update value extension types that implement Map<String, dynamic>, with required parameters derived from NOT NULL-without-default columns and null-aware omission for everything else; explicit SQL NULL writes go through generated set…ToNull copy methods that only exist for nullable, writable columns,
  • a PostgrestTable definition plus TableColumn tokens for compile-time checked filters,
  • Dart enums for Postgres enums with wire-name mapping (toString returns the wire name so enum values work directly in filters).

See packages/supabase_typegen/test/goldens/supabase_schema.dart for what the output looks like for the fixture schema.

Design choices worth reviewing:

  • Introspection source: the GeneratorMetadata contract of @supabase/postgrest-typegen (feat(postgrest-typegen): add package with multi-language code generation pg-toolbelt#302), the same document the TypeScript, Go, Swift, and Python generators consume; structural validation rejects non-matching documents. It comes straight from the database catalog, so the output is exact where API-derived descriptions are lossy: NOT NULL columns with a database default read as non-nullable but stay optional on insert, identity columns are recognized, and GENERATED ALWAYS columns appear in the row type but are excluded from the insert and update types. This is the single introspection source; the parser is a pure function over the JSON document behind the SchemaDescription model.
  • Naming: books emits BooksRow/BooksInsert/BooksUpdate plus a Books namespace class (no English singularization, so names stay predictable). Identifiers are sanitized against Dart reserved words and Map member names with a $ suffix, and collisions are deduplicated.
  • Lint-clean output: the emitted code (checked in as a golden) passes supabase_lints and DCM with zero issues, including the strict extension type rules.

Deliberately deferred: foreign key relationship getters (the fk targets are already parsed into the model) and typed rpc functions.

Additional context

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ed84de26-7a87-4ec3-b972-372f2da9ed17

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/supabase-gen

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

spydon added a commit that referenced this pull request Jul 23, 2026
## What kind of change does this PR introduce?

Feature. Adds an empty skeleton for a new `supabase_typegen` package so
we can publish it to pub.dev and reserve the name.

The full generator implementation lands separately in #1635; this PR
intentionally contains only the minimal publishable placeholder.

## What is the new behavior?

A new `packages/supabase_typegen` package containing:

- a publishable `pubspec.yaml` (version `0.1.0`, no `publish_to: none`)
so the melos release pipeline picks it up,
- a placeholder library, `README`, `CHANGELOG` and `LICENSE`,
- `supabase_lints` wired in via `analysis_options.yaml` (analyzes
clean).

It is wired into:

- the root workspace in `pubspec.yaml`,
- the Dart CI test matrix in `test.yml`,
- the pana release matrix in `release-pana.yml`,
- the SDK compliance parse ignore (`.sdk-parse-ignore`), since it is a
development-time tool rather than SDK client surface.

## Additional context

The README and CHANGELOG flag `0.1.0` as a name-reserving placeholder;
the generator implementation will replace it in a later release.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a new `supabase_typegen` package placeholder (v0.1.0) to
generate typed Dart table definitions from Supabase schemas.
* **Documentation**
* Added initial README and changelog entries documenting current
placeholder status and reserved pub.dev name.
* **CI / Chores**
* Updated release and test workflows to run checks for
`supabase_typegen` when relevant, including coverage carryforward.
* Excluded `supabase_typegen` from SDK public API scanning
(development-time generator).
* **Legal**
  * Added the MIT license for the new package.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@spydon
spydon force-pushed the feat/typed-table-access branch from 17d12c1 to 6a64143 Compare July 23, 2026 11:48
@spydon
spydon force-pushed the feat/supabase-gen branch from 07cdee7 to c795ded Compare July 23, 2026 11:53
Vinzent03 pushed a commit that referenced this pull request Jul 28, 2026
## What kind of change does this PR introduce?

Feature. Adds an empty skeleton for a new `supabase_typegen` package so
we can publish it to pub.dev and reserve the name.

The full generator implementation lands separately in #1635; this PR
intentionally contains only the minimal publishable placeholder.

## What is the new behavior?

A new `packages/supabase_typegen` package containing:

- a publishable `pubspec.yaml` (version `0.1.0`, no `publish_to: none`)
so the melos release pipeline picks it up,
- a placeholder library, `README`, `CHANGELOG` and `LICENSE`,
- `supabase_lints` wired in via `analysis_options.yaml` (analyzes
clean).

It is wired into:

- the root workspace in `pubspec.yaml`,
- the Dart CI test matrix in `test.yml`,
- the pana release matrix in `release-pana.yml`,
- the SDK compliance parse ignore (`.sdk-parse-ignore`), since it is a
development-time tool rather than SDK client surface.

## Additional context

The README and CHANGELOG flag `0.1.0` as a name-reserving placeholder;
the generator implementation will replace it in a later release.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a new `supabase_typegen` package placeholder (v0.1.0) to
generate typed Dart table definitions from Supabase schemas.
* **Documentation**
* Added initial README and changelog entries documenting current
placeholder status and reserved pub.dev name.
* **CI / Chores**
* Updated release and test workflows to run checks for
`supabase_typegen` when relevant, including coverage carryforward.
* Excluded `supabase_typegen` from SDK public API scanning
(development-time generator).
* **Legal**
  * Added the MIT license for the new package.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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