_common library

Classes

DartCompositeTypeMappers
Merges multiple TypeMappers instances into a single one whose tables are the union of the delegates'. Earlier delegates take precedence on regex conflicts because mapper lookup is first-match-wins and addAll keeps the first inserted entry per key when merging into the buffer in order.
DartCoreTypeMappers
Maps each Dart type to the code that reads it from JSON and writes it back.
DartFirestoreTypeMappers
Firestore-specific type mappers. Currently covers cloud_firestore's Timestamp only; future PG_/SQLITE_-style dialect families will live in sibling classes (DartPostgresTypeMappers, DartSqliteTypeMappers, etc.) and be composed alongside DartCoreTypeMappers at generation time.
DartPostgresTypeMappers
Postgres-flavoured prefix vocabulary. Two flavours of entry live here:
DartSqliteTypeMappers
SQLite-flavoured prefix vocabulary.
DartStrictTypeMappers
Per-field opt-in mappers that emit json_serializable-style direct as casts instead of the defensive letOrNull chain used by DartCoreTypeMappers. Throws a TypeError on shape mismatch (caught by the generated fromJsonOrNull try/catch and turned into a null model).

Functions

extractInsightsFromFile(String filePath, AnalysisContextCollection analysisContextCollection) → Future<List<ClassInsight<GenerateDartModel>>>
Analyzes the Dart file at filePath using analysisContextCollection, and and extracts class insights from it.
generateDartModels(List<String> args, {required String defaultTemplatePathOrUrl}) → Future<void>
generateDartModelsAi(List<String> args) → Future<void>
Broker-agnostic version of generateDartModelsGemeni. Pick the provider at the CLI with --broker openai|anthropic|gemini. API keys come from --api-key or, when absent, from the broker-specific env var via EnvKeyResolver. The model id defaults to the first model the broker lists for the resolved key, so common cases work with zero flags.
generateDartModelsFromDbml(List<String> args) → Future<void>
Reads a DBML file (one or many Table blocks, optional enum blocks and trailing Ref: lines) and emits one annotated abstract Dart class per Table plus one Dart enum per DBML enum — the inverse of generateDbml.
generateDbml(List<String> args, {String defaultOutputPath = 'schema.dbml'}) → Future<void>
Walks every Dart file under inputPath, extracts each @GenerateDartModel annotation, and writes one DBML file describing the schema as a single Table per model plus trailing Ref: lines for the foreign keys captured in references:.
resolveReachableEnums(Iterable<String> filePaths, AnalysisContextCollection analysisContextCollection) → Future<Map<String, List<String>>>
Resolves every Dart enum declared in or reachable from the given source files into a dartName → variants map. Used by the DBML emitter to turn @enum-tagged field types (UserRoleType@enum) into proper DBML Enum "<name>" { ... } blocks plus enum(<name>) column types instead of the silent text fallback.

Exceptions / Errors

UnmappedTypeException
Thrown when a field's type has no type mapper, so the generator cannot write the code that reads it from JSON or writes it to JSON.