Skip to content

feat(gen): add dart and json output languages to gen types - #6230

Draft
spydon wants to merge 4 commits into
developfrom
feat/gen-types-json-dart
Draft

feat(gen): add dart and json output languages to gen types#6230
spydon wants to merge 4 commits into
developfrom
feat/gen-types-json-dart

Conversation

@spydon

@spydon spydon commented Aug 17, 2026

Copy link
Copy Markdown

Summary

Adds two --lang values to supabase gen types, making supabase gen types --lang dart work end to end:

  • json: passes the language-neutral GeneratorMetadata introspection document (the @supabase/postgrest-typegen contract) straight through (the same catalog introspection the typescript/go/swift/python generators consume, with exact nullability, defaults, and identity information). This gives third-party and community type generators a single high-fidelity source instead of parsing lossy API descriptions.
  • dart: runs the pg-meta container with the json generator, collects the metadata instead of printing it, and pipes it through dart run supabase_typegen --input - --output - on the host. The generated Dart code arrives on stdout like every other language; the typegen's summary line goes to stderr. Requires the Dart SDK on PATH and the supabase_typegen package as a dev dependency of the current project; a missing SDK or failing typegen produces an actionable error.

Both languages work on every connection path (--local, --db-url, --linked, --project-id, and the implicit linked fallback), since non-TypeScript languages already run pg-meta directly.

Draft because of upstream dependencies:

Implementation notes:

  • The lang additions are TS-only and documented in docs/go-cli-divergences.md; SIDE_EFFECTS.md covers the new dart subprocess and the json-collection behavior.
  • The invocation contract (dart run supabase_typegen --input - --output -) is pinned in types.shared.ts so the handler and tests share one definition.
  • Integration tests cover the json passthrough env, the dart pipe (metadata collected rather than printed, dart argv, generated code on stdout), and the non-zero typegen exit error.

Linked issue

Closes #

  • The linked issue is open and carries the open-for-contribution label (or I'm a Supabase maintainer).

Checklist

  • The PR title follows Conventional Commits (e.g. fix(cli): …).
  • Tests added or updated for the change.
  • pnpm check:all and pnpm test pass for the workspace(s) I touched (check:all fully; unit and integration suites for gen types pass, the docker-dependent e2e suite was not run locally).

lvinist added a commit to lvinist/mine-flow-app that referenced this pull request Aug 25, 2026
… harden guard

- Remove lib/core/data/models/generated/database.dart (10-line hand-written
  stub of empty classes; Dart typegen was removed from the Supabase CLI —
  supabase/cli#6230 to restore it is still a draft)
- Add supabase/types/database.ts: real 'supabase gen types --lang typescript'
  output against staging (714 lines, all 9 tables + enums), now the committed
  contract artifact per Option 1 decision
- Harden tool/check_supabase_contracts.dart: reject artifacts missing the
  'export type Database' / '__InternalSupabase' typegen markers or under a
  minimum size (stub class of phantom close); repoint all paths
- Update guard tests: +stub-rejection case, artifact helpers; 4/4 pass

Verification: dart run tool/check_supabase_contracts.dart exit 0;
flutter test 435/435 (was 434); flutter analyze 0 issues.
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