Skip to content

chore: update schemas, fix codegen bugs, add condition toggle (default: false)#799

Merged
pyramation merged 3 commits intomainfrom
devin/1773296925-update-schemas-fix-comments
Mar 12, 2026
Merged

chore: update schemas, fix codegen bugs, add condition toggle (default: false)#799
pyramation merged 3 commits intomainfrom
devin/1773296925-update-schemas-fix-comments

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Mar 12, 2026

chore: update schemas, fix codegen bugs, add condition toggle (default: false)

Summary

Four changes bundled together:

1. Schema update from constructive-db

Copied the 5 .graphql schema files (admin, auth, public, app, objects — excluding private) from constructive-db PR #567 (deps/mar-11) into sdk/constructive-sdk/schemas/, then regenerated both constructive-sdk and constructive-cli from them.

2. Codegen duplicate identifier bug fix

generateCustomInputTypes was re-emitting custom scalar types (e.g. ConstructiveInternalTypeEmail, ConstructiveInternalTypeOrigin) that had already been emitted by generateCustomScalarTypes, causing TS2300: Duplicate identifier build failures. Fixed by passing the set of already-generated custom scalar and enum type names into generateCustomInputTypes so it skips them.

3. Optional condition generation toggle (new feature)

Added a condition config option (codegen.condition, defaults to false) that controls whether condition types and condition arguments are generated on findMany/findFirst methods. When set to false (the default):

  • Condition types are skipped in input-types-generator.ts (generateTableConditionTypes and collectConditionExtraInputTypes are bypassed)
  • Model methods omit conditionTypeName from imports, type parameters, and runtime arguments
  • FindManyArgs and FindFirstArgs gain default type params (TCondition = never, TOrderBy = never) so they work with variable arity
  • buildFindManyDocument/buildFindFirstDocument accept optional conditionTypeName parameter

Users can opt in to condition generation by setting codegen: { condition: true }.

This is useful after migrating vector search from condition to filter per PR #796 - the SDK no longer includes unused condition types by default.

4. Regenerated SDK output (bulk of diff)

The regenerated SDK/CLI output now omits condition types by default (reflecting the new condition: false default). The diff shows -5,106 lines of condition-related types and plumbing removed:

  • No XxxCondition interface declarations in input-types.ts
  • Model files no longer import condition types
  • findMany signature: FindManyArgs<S, Filter, OrderBy> (3 params, no condition)
  • findFirst signature: FindFirstArgs<S, Filter> (2 params, no condition)
  • No condition property in method args objects
  • No conditionTypeName argument in buildFindManyDocument/buildFindFirstDocument calls

Review & Testing Checklist for Human

  • CRITICAL: Verify OrderBy type parameter positioning bug: When condition: false, the model generator passes 3 type params to FindManyArgs<TSelect, TWhere, TCondition = never, TOrderBy = never>, which places OrderBy in the TCondition position instead of TOrderBy. This means orderBy field is typed as never[] instead of the actual order-by enum. Test by:

    1. Setting condition: false in codegen config
    2. Regenerating SDK
    3. Attempting to use findMany({ orderBy: ['ID_ASC'] }) in TypeScript
    4. Verify it type-checks correctly (it probably won't - this is likely a bug)
  • Verify alreadyGeneratedTypes fix doesn't suppress needed types: The duplicate type fix pre-seeds generatedTypes with customScalarTypes ∪ enumTypes. Spot-check a generated input-types.ts to ensure all expected input object types are present.

  • Breaking change review - condition now defaults to false: Existing codebases upgrading will see condition types removed from generated code unless they explicitly set codegen: { condition: true }. Verify:

    • Is this the intended default behavior going forward?
    • Do any internal repos depend on condition types being present?
    • Should there be a migration guide for users upgrading?
  • Verify template type param defaults work correctly: The select-types.ts template uses TCondition = never, TOrderBy = never defaults. Verify:

    • When condition is enabled (4 params): FindManyArgs<S, Where, Condition, OrderBy> works correctly
    • When condition is disabled (3 params): FindManyArgs<S, Where, OrderBy> - check if OrderBy ends up in correct position or TCondition position

Test Plan

  1. Unit tests: Run pnpm test in the codegen package — ✅ All 310 tests pass
  2. Build verification: Run pnpm build at repo root — ✅ Full build succeeds with no TypeScript errors (but doesn't catch semantic issues with type param positions)
  3. Manual testing required: Generate SDK with condition: false, then write code that uses findMany({ orderBy: [...] }) and verify it compiles and runs correctly
  4. Manual testing required: Generate SDK with condition: true, verify condition types work as before

Updates Since Last Revision

  • Changed default from condition: true to condition: false: The feature now defaults to omitting condition types. Users who want condition types must opt in with codegen: { condition: true }.
  • Regenerated SDK/CLI with new default: All ~300+ model files now omit condition types, reducing generated code by 5,106 lines.
  • Updated config JSDoc: The @default comment now correctly states false instead of true.

Notes

Link to Devin Session: https://app.devin.ai/sessions/c7c114e9d17e421bba9564e48d0421c0
Requested by: @pyramation

@devin-ai-integration
Copy link
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

Add a 'condition' config option (default: true) that controls whether
condition types and condition arguments are generated on findMany/findFirst.

When set to false:
- Condition types are not generated in input-types
- Condition params are omitted from model method signatures
- FindManyArgs/FindFirstArgs use default 'never' for TCondition

This allows users to turn off condition generation when using
connection-filter's filter argument exclusively.
@devin-ai-integration devin-ai-integration bot changed the title chore: update schemas from constructive-db, fix codegen duplicate type bug, update vector comments chore: update schemas, fix codegen bugs, add optional condition generation toggle Mar 12, 2026
…on types

Changes the default value of codegen.condition from true to false.
Users can still opt in with codegen: { condition: true }.
Regenerated SDK and CLI output now omits condition types by default.
@devin-ai-integration devin-ai-integration bot changed the title chore: update schemas, fix codegen bugs, add optional condition generation toggle chore: update schemas, fix codegen bugs, add condition toggle (default: false) Mar 12, 2026
@pyramation pyramation merged commit 0e36123 into main Mar 12, 2026
43 checks passed
@pyramation pyramation deleted the devin/1773296925-update-schemas-fix-comments branch March 12, 2026 23:53
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