Skip to content

feat(typegen)!: generate only from the document the Supabase CLI pipes in - #1963

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/typegen-cli-only
Oct 16, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/typegen-cli-only

Conversation

@spydon

@spydon spydon commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What

supabase_typegen no longer connects to a database itself. Its only input is now the GeneratorMetadata document that supabase gen types --lang dart pipes in on stdin. Before this change it could also run on its own, through a Dart port of the @supabase/postgrest-typegen introspection. That port repeated work the CLI flow already does: pg-meta introspects the database, sorts the document with sortGeneratorMetadata and attaches rpcFunctions.

Changes

  • Removed the --local, --linked, --project-ref, --db-url and --dump-metadata options. --schema, --output and --import stay.
  • Deleted the package:supabase_typegen/introspection.dart library: the vendored introspection SQL, the supabase db query runner, the config.toml schema defaults, the sort pass and its ICU collation.
  • Deleted the Dart port of resolveRpcFunctions. The parser now reads rpcFunctions from the document, and a document without that collection describes no RPC functions.
  • Removed the introspection drift workflow, the parity test's Postgres container in test.yml, and the now unused toml, collection and postgres dependencies.
  • Updated the README and MIGRATION.md to use supabase gen types --lang dart.

The test/fixtures/generator_metadata.json fixture is still generated by the upstream TypeScript introspection (tool/regenerate_fixture.ts), so the generator and parser tests run against exactly the document the CLI produces.

Breaking

Running dart run supabase_typegen --local (or any other connection option) now fails with an unknown option error. Use supabase gen types --lang dart --local > lib/supabase_schema.g.dart instead.

Summary by CodeRabbit

  • Usage
    • Generate Dart types through the Supabase CLI for local, linked, or project-ID databases.
    • The type-generation utility now accepts generator metadata from standard input instead of connecting to databases directly.
    • RPC functions are included only when the supplied metadata contains RPC function information.
  • Documentation
    • Updated migration and package guidance to use the CLI’s type-generation commands and describe schema selection and generated-code formatting.

…s in

Remove the built-in database introspection and the --local, --linked,
--project-ref, --db-url and --dump-metadata options. supabase_typegen now
only reads the GeneratorMetadata document that
`supabase gen types --lang dart` pipes in on stdin, which pg-meta has
already introspected, sorted and resolved rpcFunctions for.
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: supabase/supabase-flutter/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eff1c079-aec9-47fc-873d-b87bb1dd1e14
📥 Commits

Reviewing files that changed from the base of the PR and between 8d9a929 and 689a671.

⛔ Files ignored due to path filters: 1
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing: 42
  • .github/workflows/test.yml
  • .github/workflows/typegen-drift.yml
  • MIGRATION.md
  • packages/supabase_typegen/README.md
  • packages/supabase_typegen/bin/supabase_typegen.dart
  • packages/supabase_typegen/lib/introspection.dart
  • packages/supabase_typegen/lib/src/generator_metadata_parser.dart
  • packages/supabase_typegen/lib/src/introspection/collation.dart
  • packages/supabase_typegen/lib/src/introspection/introspect.dart
  • packages/supabase_typegen/lib/src/introspection/pg_format.dart
  • packages/supabase_typegen/lib/src/introspection/queryable.dart
  • packages/supabase_typegen/lib/src/introspection/relationships.dart
  • packages/supabase_typegen/lib/src/introspection/sort.dart
  • packages/supabase_typegen/lib/src/introspection/sql/columns_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/foreign_tables_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/functions_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/helpers.dart
  • packages/supabase_typegen/lib/src/introspection/sql/materialized_views_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/primary_keys_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/schemas_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/table_relationships_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/tables_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/types_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/views_key_dependencies_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/views_sql.dart
  • packages/supabase_typegen/lib/src/introspection/supabase_cli_io.dart
  • packages/supabase_typegen/lib/src/introspection/supabase_config_io.dart
  • packages/supabase_typegen/lib/src/rpc_functions.dart
  • packages/supabase_typegen/pubspec.yaml
  • packages/supabase_typegen/test/generator_metadata_parser_test.dart
  • packages/supabase_typegen/test/introspection/introspect_test.dart
  • packages/supabase_typegen/test/introspection/parity_test.dart
  • packages/supabase_typegen/test/introspection/pg_format_test.dart
  • packages/supabase_typegen/test/introspection/relationships_test.dart
  • packages/supabase_typegen/test/introspection/sort_test.dart
  • packages/supabase_typegen/test/introspection/sql_test.dart
  • packages/supabase_typegen/test/introspection/supabase_cli_test.dart
  • packages/supabase_typegen/test/introspection/supabase_config_test.dart
  • packages/supabase_typegen/test/rpc_functions_test.dart
  • packages/supabase_typegen/tool/check_introspection_drift.ts
  • packages/supabase_typegen/tool/dump_introspection_sql.dart
  • packages/supabase_typegen/tool/regenerate_fixture.ts
💤 Files with no reviewable changes: 36
  • packages/supabase_typegen/lib/src/introspection/sql/materialized_views_sql.dart
  • packages/supabase_typegen/test/introspection/sort_test.dart
  • packages/supabase_typegen/test/introspection/supabase_config_test.dart
  • packages/supabase_typegen/test/introspection/sql_test.dart
  • packages/supabase_typegen/test/introspection/relationships_test.dart
  • .github/workflows/typegen-drift.yml
  • packages/supabase_typegen/tool/check_introspection_drift.ts
  • packages/supabase_typegen/lib/introspection.dart
  • packages/supabase_typegen/test/introspection/parity_test.dart
  • packages/supabase_typegen/lib/src/introspection/sql/columns_sql.dart
  • packages/supabase_typegen/test/generator_metadata_parser_test.dart
  • packages/supabase_typegen/lib/src/introspection/sql/foreign_tables_sql.dart
  • packages/supabase_typegen/lib/src/introspection/queryable.dart
  • packages/supabase_typegen/lib/src/introspection/sql/functions_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/primary_keys_sql.dart
  • packages/supabase_typegen/lib/src/introspection/collation.dart
  • packages/supabase_typegen/test/rpc_functions_test.dart
  • packages/supabase_typegen/lib/src/introspection/sql/schemas_sql.dart
  • packages/supabase_typegen/lib/src/rpc_functions.dart
  • packages/supabase_typegen/tool/dump_introspection_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/views_sql.dart
  • packages/supabase_typegen/lib/src/introspection/relationships.dart
  • packages/supabase_typegen/test/introspection/supabase_cli_test.dart
  • packages/supabase_typegen/lib/src/introspection/sql/types_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/table_relationships_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/tables_sql.dart
  • packages/supabase_typegen/lib/src/introspection/sql/helpers.dart
  • packages/supabase_typegen/pubspec.yaml
  • packages/supabase_typegen/lib/src/introspection/sort.dart
  • packages/supabase_typegen/lib/src/introspection/pg_format.dart
  • packages/supabase_typegen/test/introspection/introspect_test.dart
  • packages/supabase_typegen/lib/src/introspection/supabase_config_io.dart
  • packages/supabase_typegen/test/introspection/pg_format_test.dart
  • packages/supabase_typegen/lib/src/introspection/introspect.dart
  • packages/supabase_typegen/lib/src/introspection/sql/views_key_dependencies_sql.dart
  • packages/supabase_typegen/lib/src/introspection/supabase_cli_io.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The typegen command now reads generator metadata from stdin instead of introspecting databases. The package's introspection and RPC-resolution code, related tests, and drift tooling are removed. Documentation and CI are updated to use the Supabase CLI generation workflow.

Changes: Supabase type generation via CLI

Layer / File(s) Summary
Read and parse generator metadata
packages/supabase_typegen/bin/supabase_typegen.dart, packages/supabase_typegen/lib/src/generator_metadata_parser.dart, packages/supabase_typegen/test/generator_metadata_parser_test.dart
The command reads JSON metadata from stdin, validates its shape, and passes requested schemas to the parser. Missing rpcFunctions now produces an empty collection instead of invoking a fallback resolver.
Remove package-owned database introspection
packages/supabase_typegen/lib/introspection.dart, packages/supabase_typegen/lib/src/introspection/*, packages/supabase_typegen/lib/src/introspection/sql/*, packages/supabase_typegen/lib/src/rpc_functions.dart, packages/supabase_typegen/pubspec.yaml, packages/supabase_typegen/test/introspection/*, packages/supabase_typegen/test/rpc_functions_test.dart, packages/supabase_typegen/tool/*
Database query interfaces, SQL builders, metadata sorting, relationship expansion, and RPC resolution are removed, along with their tests, related dependencies, and SQL drift tools.
Update CLI usage and CI
MIGRATION.md, packages/supabase_typegen/README.md, .github/workflows/test.yml, .github/workflows/typegen-drift.yml, packages/supabase_typegen/tool/regenerate_fixture.ts
The documentation uses Supabase CLI generation commands. The test workflow removes typegen-specific database setup, and the introspection drift workflow is deleted. Fixture instructions now refer to the revision bundled by the CLI.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SupabaseCLI
  participant TypegenCLI
  participant MetadataParser
  participant OutputFile
  SupabaseCLI->>TypegenCLI: GeneratorMetadata JSON on stdin
  TypegenCLI->>MetadataParser: Parse metadata and requested schemas
  MetadataParser-->>TypegenCLI: Parsed generator data
  TypegenCLI->>OutputFile: Write generated Dart code
Loading

Suggested reviewers: cmelchior

Merge Risk: ⚪ Minimal · up to 689a6

No actionable merge-blocking issue was established. The documented CLI generation path remains subject to normal integration checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main breaking change: type generation now uses only the document piped from the Supabase CLI.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (5 skipped: 5 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
spydon merged commit b44859b into main Oct 16, 2026
46 checks passed
@spydon
spydon deleted the lukasklingsbo/typegen-cli-only branch October 16, 2026 11:05
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