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
nameto camelCase, for examplecreated_attocreatedAt. -
formatWithSdk(
String code, Version languageVersion, {String? path}) → Future< String?> -
Formats
codewith thedart formatof the Dart SDK running this program, forlanguageVersion, so the result is exactly what that formatter leaves unchanged in a project on that language version. Withpath, the path the code is written to, the formatter also applies theformattersettings of theanalysis_options.yamlthat 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
nameto a valid Dart member identifier in camelCase. -
packageLanguageVersion(
{Directory? startDirectory}) → Version? -
The language version of the Dart package
startDirectorybelongs to, resolved the waydart formatand the analyzer resolve it: the lower bound of theenvironment.sdkconstraint in thepubspec.yamlofstartDirectory, which defaults to the current directory, or of its nearest ancestor. Returnsnullwhen no such pubspec exists or it has no SDK constraint. -
parseGeneratorMetadata(
Map< String, dynamic> document, {List<String> ? schemaNames}) → DatabaseDescription -
Parses a
GeneratorMetadatadocument, the introspection contract of@supabase/postgrest-typegen, into a DatabaseDescription of the schemas named inschemaNames, 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
nameto PascalCase, for exampleauthor_statstoAuthorStats. -
snakeCase(
String name) → String -
Converts
nameto snake_case, for examplemapByMoodtomap_by_mood.