refactor(codegen): generic type params + condition default false [schema propagation]#927
Merged
pyramation merged 5 commits intomainfrom Mar 28, 2026
Merged
Conversation
Auto-generated by schema-propagation workflow. Source: constructive-db@cbf608a84
…arseFindManyArgs/parseFindFirstArgs Instead of casting ORM args to 'any', the helpers are now generic: parseFindManyArgs<T>() / parseFindFirstArgs<T>() The codegen passes specific table types: parseFindManyArgs<FindManyArgs<CarSelect, CarFilter, CarCondition, CarsOrderBy>>(...) This gives proper type safety at the ORM call site without escape hatches. The internal 'as unknown as T' cast in the helpers is the single known bridge between the untyped CLI argv layer and the typed ORM interface.
…first-class, condition is opt-in - Change all condition checks from `!== false` to `=== true` (8 locations) - Flip function parameter defaults from `= true` to `= false` - Thread config.codegen.condition through CLI codegen TableCommandOptions - Update tests that explicitly test condition types to pass condition: true - Update snapshots to reflect condition-disabled output
… params
The ORM's findMany/findFirst methods require select to be present
(via intersection & { select: SelectType }). parseFindManyArgs always
sets select at runtime, but the generic type parameter only had
FindManyArgs<...> where select is optional.
Fix: generate FindManyArgs<...> & { select: SelectType } as the
type parameter, making the type match what the ORM expects.
…condition default false Regenerated using updated codegen that: - Uses proper generic type parameters instead of as any - Makes select required via intersection type - Defaults condition to false (where/filter is first-class)
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Applies two codegen improvements to the schema propagation branch and regenerates all SDK output (CLI, React hooks, ORM, docs).
Codegen changes
Generic type parameters replace
as any:parseFindManyArgs<T>andparseFindFirstArgs<T>are now generic. The table command generator instantiates them with per-table types (e.g.parseFindManyArgs<AnimalFindManyArgs & { select: AnimalSelect }>(…)), so downstream ORM calls are fully typed without anyas anycasts.Intersection types for required
select: Generated type params useFindManyArgs<Select, Filter, never, OrderBy> & { select: Select }to satisfy the ORM's expectation thatselectis always present (the runtime helpers always set it fromdefaultSelect).Condition defaults to
false: Allcondition !== falsechecks flipped tocondition === trueacross 8 locations.where/filteris the first-class API; condition types are now opt-in viaconfig.codegen.condition = true.Regenerated output
~155 files of regenerated SDK CLI commands, React hooks, ORM models, and agent skill docs. These reflect:
handleList/handleFindFirst/handleSearchhandlersfind-first, and--selectexamplessummary/guidancefields; MetaField gainsisPrimaryKey/isForeignKey/description)Review & Testing Checklist for Human
sdk/constructive-cli/src/public/commands/table.ts) and verifyparseFindManyArgs<TableFindManyArgs & { select: TableSelect }>appears instead ofas any. This is the core fix.sdk/constructive-sdk/src/public/orm/types.ts), confirm no*Conditioninterfaces are generated. If your project needs them, setconfig.codegen.condition = true.as unknown as Tin cli-utils.ts — the runtime helpers (parseFindManyArgs,parseFindFirstArgs) still cast internally viaas unknown as Tsince they build the args object dynamically. Verify this is acceptable vs. further refactoring the helper to return a properly typed builder.summaryandguidancefields; MetaField gainedisPrimaryKey,isForeignKey,description. These come from the schema propagation base, not from this PR's work. Confirm they're expected.pnpm buildin the monorepo to verify full compilation. If you have a running ConstructiveDB instance, exercisecsdk <table> list --where.<field>.<op> <value>andcsdk <table> find-firstto verify the generated CLI works at runtime.Notes
mainwith the same codegen fixes but without regenerated SDK output). The intent is to have both PRs available — merge whichever lands cleanly first.graphql/codegen/src/(the codegen engine itself).Link to Devin session: https://app.devin.ai/sessions/c92c3a11450342f8875625a60fa1be28
Requested by: @pyramation