All per-schema/per-table code generation MUST use Babel AST (@babel/types + generateCode()).
Never use lines.push(), string concatenation, or template literals to build generated TypeScript code.
Reference implementations:
src/core/codegen/orm/model-generator.ts— per-table ORM model classessrc/core/codegen/orm/client-generator.ts— createClient factorysrc/core/codegen/orm/custom-ops-generator.ts— custom query/mutation operations
No lines.push(...), no backtick template literals containing code, no string + operators
for building generated source files. If you find yourself writing lines.push(\import ...`), stop and use t.importDeclaration(...)` instead.
Static runtime code that does not vary per-schema belongs in src/core/codegen/templates/
as real .ts files. These are read at codegen time via readTemplateFile() and written
to the output directory with only the header replaced.
This gives you:
- Syntax highlighting and IDE support while editing templates
- A clear boundary between "code that generates code" and "code that IS the output"
Reference implementations:
src/core/codegen/templates/orm-client.tssrc/core/codegen/templates/query-builder.tssrc/core/codegen/templates/select-types.ts