refactor(codegen): convert ORM generators from ts-morph to Babel AST #612
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR completes the migration of all ORM code generators from ts-morph to Babel AST (
@babel/types+@babel/generator). This follows the React Query codegen migration in PR #611.Files converted to Babel AST:
orm/input-types-generator.ts- generates TypeScript interfaces for filters, CRUD inputs, and payload typesorm/model-generator.ts- generates model classes with findMany, findFirst, create, update, delete methodsorm/barrel.ts- generates index.ts barrel exportsorm/custom-ops-generator.ts- generates custom query/mutation operation factoriesorm/client-generator.ts- generates createClient factory functiontypes.ts- generates entity interfaces and filter typesRemoved:
ts-ast.ts- no longer neededts-morphdependency from package.jsonAll 135 tests pass with 56 snapshots updated to match Babel AST output format.
Review & Testing Checklist for Human
pnpm example:codegen:ormorpnpm example:codegen:orm:schemaparseTypeAnnotationfunction incustom-ops-generator.ts(lines 136-154) - this does string parsing to convert type strings to AST nodes and may have edge casesRecommended test plan:
pnpm example:codegen:orm:schemato generate ORM code from the example schemaexamples/output/generated-orm-schema/Notes
The static runtime code in
client-generator.ts(OrmClient class, QueryBuilder class, select-types) still uses template strings since this is runtime code that doesn't change based on schema - this is intentional.Link to Devin run: https://app.devin.ai/sessions/4d5df52ad251452da815b8cb06618596
Requested by: @pyramation