feat: add json generator exposing the raw generator metadata - #1106
Closed
spydon wants to merge 1 commit into
Closed
feat: add json generator exposing the raw generator metadata#1106spydon wants to merge 1 commit into
spydon wants to merge 1 commit into
Conversation
This was referenced Aug 17, 2026
feat: add supabase_typegen package generating typed table definitions
supabase/supabase-flutter#1635
Draft
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.
Important
Duplicate of the postgrest-typegen extraction: the
GeneratorMetadatacontract in supabase/pg-toolbelt#302 is the same language-neutral document this PR exposes, and #1084 makes postgres-meta consume that package. Thejsonoutput is reimplemented on top of the package in #1110, stacked on #1084. Closed in favor of that stack.What kind of change does this PR introduce?
Feature: a new
jsongenerator alongside the existing typescript, go, swift, and python ones.What is the current behavior?
The introspection metadata that all type generators consume (
GeneratorMetadata: schemas, tables, foreign tables, views, materialized views, columns, relationships, functions, and types) is only available rendered through one of the four built-in language templates. Anyone building a type generator for another language (Dart, Kotlin, C#, and the various community SDKs) has to fall back on lossier sources such as the PostgREST OpenAPI description, which for example cannot distinguish a nullable column from aNOT NULLcolumn with a database default.What is the new behavior?
GET /generators/jsonreturns the rawGeneratorMetadataas pretty-printed JSON, supporting the sameincluded_schemas/excluded_schemasquery parameters as the other generators.PG_META_GENERATE_TYPES=json(and thegen:types:jsonnpm script) emits the same document on stdout, so the Supabase CLI can expose it assupabase gen types --lang jsonand--lang dart(feat(gen): add dart and json output languages to gen types cli#6230).versionfield (currently1) so external consumers can detect breaking shape changes; additive changes do not require a bump.This gives third-party and community type generators a single high-fidelity, language-neutral introspection source instead of each reimplementing catalog queries or parsing lossy API descriptions.
Additional context
The template is a stable-key-order
JSON.stringifyover the existinggetGeneratorMetadataresult, so it adds no new queries and stays in sync with whatever the built-in generators see. Tests assert the envelope shape and specifically the fidelity data that motivated the endpoint (nullability, defaults, identity columns, enum values, views, materialized views, and function return types).Why a JSON dump instead of a Dart template in this repo?
The concrete first consumer is the upcoming Dart type generator for supabase-flutter (supabase/supabase-flutter#1635). We deliberately chose not to contribute a
dart.tstemplate here, for reasons that apply equally to any future language:The JSON generator is the piece that genuinely belongs here: the introspection metadata is postgres-meta's domain, every language needs the same document, and one endpoint serves Dart, Kotlin, C#, and the community SDKs alike without this repo taking on a template per language.