supabase_typegen library

Generates typed Supabase table definitions, row extension types and column tokens from a database schema.

Classes

ColumnDescription
Description of a single table column.
DatabaseDescription
Description of the schemas of a database that types are generated for, the input to the code generator.
EnumDescription
Description of a Postgres enum type.
ForeignKeyDescription
The target of a foreign key column.
RelationshipDescription
A foreign key from sourceTable to targetTable.
TableDescription
Description of a table or view.

Enums

ColumnTypeKind
The Dart-relevant type of a column, derived from the Postgres type at parse time so that later stages never have to compare type name strings.

Properties

minimumLanguageVersion → Version
The lowest language version the generated code is valid for: the value types omit unset columns with null-aware map elements, which need Dart 3.8.
final

Functions

camelCase(String name) → String
Converts name to camelCase, for example created_at to createdAt.
formatWithSdk(String code, Version languageVersion, {String? path}) → Future<String?>
Formats code with the dart format of the Dart SDK running this program, for languageVersion, so the result is exactly what that formatter leaves unchanged in a project on that language version. With path, the path the code is written to, the formatter also applies the formatter settings of the analysis_options.yaml that governs that path, such as its page width.
generateDartCode(DatabaseDescription database, {String importUri = 'package:postgrest/postgrest.dart', Version? languageVersion}) → String
Generates a Dart source file with typed table definitions, row extension types, insert and update value types, column tokens and Postgres enums for the schemas of database.
memberIdentifier(String name) → String
Converts name to a valid Dart member identifier in camelCase.
packageLanguageVersion({Directory? startDirectory}) → Version?
The language version of the Dart package startDirectory belongs to, resolved the way dart format and the analyzer resolve it: the lower bound of the environment.sdk constraint in the pubspec.yaml of startDirectory, which defaults to the current directory, or of its nearest ancestor. Returns null when no such pubspec exists or it has no SDK constraint.
parseGeneratorMetadata(Map<String, dynamic> document, {List<String>? schemaNames}) → DatabaseDescription
Parses a GeneratorMetadata document, the introspection contract of @supabase/postgrest-typegen, into a DatabaseDescription of the schemas named in schemaNames, or of every schema the document lists when none are given. Named schemas the document does not list are left out.
pascalCase(String name) → String
Converts name to PascalCase, for example author_stats to AuthorStats.
snakeCase(String name) → String
Converts name to snake_case, for example mapByMood to map_by_mood.