basalt_codegen library Getting Started

build_runner code generator for the Basalt Dart ORM. Wire it via build.yaml; it derives a RowMapper<T> for every @Queryable class and toInsert() / toUpdate() extensions for @Insertable / @AsChangeset classes.

Classes

AsChangesetGenerator Getting Started
Emits a toUpdate() extension for each @AsChangeset data class.
ChangesetEmitter
Emits a toUpdate() extension that builds an UpdateStatement<Tbl> whose SET clause covers every writable column (everything except @Column(readOnly: true)); the caller appends .where(...), typically on the primary key. Pure string emit, so it is unit-testable without the analyzer.
ClassInfo
Everything the code generator needs to know about a single @Queryable class, resolved from its element. Collected for the whole relation closure reachable from a generated class so each .g.dart is self-contained — it never references generated symbols from another library.
ColumnArg
One constructor column mapped to a schema accessor expression, plus its read/write direction from @Column(readOnly:) / @Column(writeOnly:).
EdgeAnalyzer
Parses @Relation / @Column metadata from analyzer elements.
InsertableGenerator Getting Started
Emits a toInsert() extension for each @Insertable data class — on the class itself (single-row insert) and on Iterable of it (one multi-row batch INSERT). Independent of @Queryable, so a write-only DTO works on its own.
InsertEmitter
Emits a toInsert() extension that builds an InsertStatement<Tbl> from a data class instance, setting every writable column (everything except @Column(readOnly: true)) via TableColumn.set. Pure string emit, so it is unit-testable without the analyzer.
ModelCodeGenerator
Generates the ${Class}Query companion from a resolved QueryableModel.
QueryableClassCodegen
Bridges analyzer metadata to ModelCodeGenerator.
QueryableGenerator Getting Started
Generates a ${Class}Query companion for each @Queryable class — the companion is the canonical query (extends MappedQuery/FoldMappedQuery) and carries the alias-parameterized static fromRow reader plus its RowMapper. @Relation fields drive nested joins with per-edge depth limits and path-based table aliases.
QueryableModel
Root inputs for one @Queryable class plus the resolved info for every class reachable through its relations (classInfos, keyed by class name). The closure makes generation self-contained across files: the emitted .g.dart defines every nested reader it needs locally.
QueryGetterEmitter
Emits the constructor + _build()/_decode members of a ${Class}Query companion whose query joins the class's @Relation targets with aliased joins.
ReaderEmitter
Emits the public, alias-parameterized static fromRow reader member of the generated ${Class}Query companion.
RelationArg
A nested relation argument inlined into a unified reader.
RelationCallEmitter
Builds the inline relation expressions placed inside a unified reader.
RelationEdge
A @Relation edge extracted from a constructor parameter.
RelationTreeBuilder
Unrolls join trees for relation queries with path-based table aliases.
SelectQueryEmitter
Emits the constructor + _build() members of a ${Class}Query companion for a @Queryable class that has no relations: the query selects exactly the class's readable columns (a column subset of the table) and decodes them with fromRow. This is the "Selectable" analog — projecting a chosen set of columns into a lightweight view class, so db.fetch(UserQuery()) reads only those columns instead of SELECT *.
TreeNode
One node in the unrolled join tree for a relation query.

Extensions

ModelCodeGeneratorJoin on ModelCodeGenerator
Convenience for callers that want a single chunk (e.g. tests).

Constants

aggChecker → const TypeChecker
asChangesetChecker → const TypeChecker
columnChecker → const TypeChecker
hasManyChecker → const TypeChecker
insertableChecker → const TypeChecker
queryableChecker → const TypeChecker
relationChecker → const TypeChecker

Functions

camelCase(String snake) String
generateQueryableClass(ClassElement element) Iterable<String>
Generates code units for a single @Queryable-annotated element.
lowerFirst(String s) String
queryableBuilder(BuilderOptions options) → Builder Getting Started
build_runner entry point (wired in build.yaml). Emits a shared part so the generated readers/mappers and toInsert()/toUpdate() extensions live in <file>.g.dart alongside the user's classes. A class can carry several of @Queryable/@Insertable/@AsChangeset; each generator contributes its own (non-overlapping) units to the same part.
ucFirst(String s) String
validateRelationDepth(int depth, Element element) int
Top-level so the depth guard is unit-testable without analyzer mocks.

Typedefs

RelationEdgesLookup = List<RelationEdge> Function(String targetClass)