Skip to content

fix: orm interfaces findX#1026

Open
yyyyaaa wants to merge 8 commits intomainfrom
fix/orm-interfaces-findx-752
Open

fix: orm interfaces findX#1026
yyyyaaa wants to merge 8 commits intomainfrom
fix/orm-interfaces-findx-752

Conversation

@yyyyaaa
Copy link
Copy Markdown
Contributor

@yyyyaaa yyyyaaa commented Apr 25, 2026

fixes https://github.com/constructive-io/constructive-planning/issues/752

ORM model interfaces (the core fix)

findFirst — single object return ✓
findFirst(
args: FindFirstArgs<S, UserFilter, UserOrderBy> & { select: S } & StrictSelect<S, UserSelect>
): QueryBuilder<{
user: InferSelectResult<UserWithRelations, S> | null; // ← singular, was array
}>
With transform callback: (data) => ({ user: data.users?.nodes?.[0] ?? null })

findOne — single object return ✓
Same { user: ... | null } shape as findFirst, using buildFindManyDocument with where: { id: { equalTo: args.id } }, first: 1.

Coverage across SDKs (constructive-sdk only — others mirror)

  • findFirst<...> declarations: 168 (auth: 9, objects: 5, admin: 34, public: 120)
  • Unique singular { xxx: InferSelectResult<XxxWithRelations, S> | null } return shapes: 120 distinct entities
  • Regression check: 0 instances of findFirst returning an array

FindFirstArgs interface (in generated select-types.ts)

export interface FindFirstArgs<TSelect, TWhere, TOrderBy = never> {
select?: TSelect;
where?: TWhere;
orderBy?: TOrderBy[]; // ← new orderBy support
}

CLI (sdk/constructive-cli)

  • Help text includes --orderBy under "Find-First Options" (verified user.ts and others)
  • handleFindFirst calls parseFindFirstArgs<FindFirstArgs<UserSelect, UserFilter, UserOrderBy>>(argv, defaultSelect)

React hooks (sdk/constructive-react)

  • useUserQuery returns UseQueryResult<{ user: InferSelectResult<UserWithRelations, S> | null }>
  • Delegates to getClient().user.findOne(...) — picks up the new singular shape transparently
  • fetchUserQuery and prefetchUserQuery mirror the same contract

migrate-client SDK

Same pattern verified on SqlAction.findFirst — returns { sqlAction: ... | null } with SqlActionOrderBy type param.

Build + typecheck (already done)

  • All 4 SDKs build clean
  • tsc --noEmit passes with zero errors on all 4 SDKs
  • 306 codegen tests pass, 119 snapshots green

@yyyyaaa yyyyaaa requested a review from pyramation April 25, 2026 06:06
@pyramation
Copy link
Copy Markdown
Contributor

nice is this ready to review?

@yyyyaaa
Copy link
Copy Markdown
Contributor Author

yyyyaaa commented Apr 28, 2026

yep, pr ready

@pyramation
Copy link
Copy Markdown
Contributor

out of curiosity, breaking changes? so we'll need to change FE before we do this one?

@yyyyaaa yyyyaaa force-pushed the fix/orm-interfaces-findx-752 branch from 474d2e0 to 815edac Compare May 8, 2026 03:48
@socket-security
Copy link
Copy Markdown

@socket-security
Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn Critical
Critical CVE: Handlebars.js has JavaScript Injection via AST Type Confusion

CVE: GHSA-2w6w-674q-4c4q Handlebars.js has JavaScript Injection via AST Type Confusion (CRITICAL)

Affected versions: >= 4.0.0 < 4.7.9

Patched version: 4.7.9

From: pnpm-lock.yamlnpm/handlebars@4.7.8

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/handlebars@4.7.8. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm entities is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: pnpm-lock.yamlnpm/entities@4.5.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/entities@4.5.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm entities is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: pnpm-lock.yamlnpm/entities@6.0.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/entities@6.0.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm markdown-it is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: pnpm-lock.yamlnpm/markdown-it@14.1.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/markdown-it@14.1.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

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.

2 participants