Skip to content

refactor(codegen): generic type params + condition default false [schema propagation]#927

Merged
pyramation merged 5 commits intomainfrom
devin/1774668423-schema-propagation-generic-types
Mar 28, 2026
Merged

refactor(codegen): generic type params + condition default false [schema propagation]#927
pyramation merged 5 commits intomainfrom
devin/1774668423-schema-propagation-generic-types

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Mar 28, 2026

Summary

Applies two codegen improvements to the schema propagation branch and regenerates all SDK output (CLI, React hooks, ORM, docs).

Codegen changes

  1. Generic type parameters replace as any: parseFindManyArgs<T> and parseFindFirstArgs<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 any as any casts.

  2. Intersection types for required select: Generated type params use FindManyArgs<Select, Filter, never, OrderBy> & { select: Select } to satisfy the ORM's expectation that select is always present (the runtime helpers always set it from defaultSelect).

  3. Condition defaults to false: All condition !== false checks flipped to condition === true across 8 locations. where/filter is the first-class API; condition types are now opt-in via config.codegen.condition = true.

Regenerated output

~155 files of regenerated SDK CLI commands, React hooks, ORM models, and agent skill docs. These reflect:

  • Generic type params in all handleList / handleFindFirst / handleSearch handlers
  • No condition types generated (since condition defaults to false)
  • Updated docs with pagination, filtering, cursor, find-first, and --select examples
  • Schema updates from the base branch (NodeTypeRegistry gains summary/guidance fields; MetaField gains isPrimaryKey/isForeignKey/description)

Review & Testing Checklist for Human

  • Spot-check generated handler files — open 2-3 generated CLI command files (e.g. sdk/constructive-cli/src/public/commands/table.ts) and verify parseFindManyArgs<TableFindManyArgs & { select: TableSelect }> appears instead of as any. This is the core fix.
  • Verify condition types are absent — in the generated ORM types file (sdk/constructive-sdk/src/public/orm/types.ts), confirm no *Condition interfaces are generated. If your project needs them, set config.codegen.condition = true.
  • as unknown as T in cli-utils.ts — the runtime helpers (parseFindManyArgs, parseFindFirstArgs) still cast internally via as unknown as T since they build the args object dynamically. Verify this is acceptable vs. further refactoring the helper to return a properly typed builder.
  • Schema changes from base branch — NodeTypeRegistry gained summary and guidance fields; MetaField gained isPrimaryKey, isForeignKey, description. These come from the schema propagation base, not from this PR's work. Confirm they're expected.
  • Test plan: Run pnpm build in the monorepo to verify full compilation. If you have a running ConstructiveDB instance, exercise csdk <table> list --where.<field>.<op> <value> and csdk <table> find-first to verify the generated CLI works at runtime.

Notes

Link to Devin session: https://app.devin.ai/sessions/c92c3a11450342f8875625a60fa1be28
Requested by: @pyramation


Open with Devin

github-actions bot and others added 5 commits March 28, 2026 02:40
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)
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit cda85f9 into main Mar 28, 2026
44 checks passed
@pyramation pyramation deleted the devin/1774668423-schema-propagation-generic-types branch March 28, 2026 03:59
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant