fix: orm interfaces findX#1026
Open
yyyyaaa wants to merge 4 commits into
Open
Conversation
Contributor
|
nice is this ready to review? |
Contributor
Author
|
yep, pr ready |
Contributor
|
out of curiosity, breaking changes? so we'll need to change FE before we do this one? |
474d2e0 to
815edac
Compare
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
pyramation
reviewed
May 12, 2026
| export { createFetch } from './localhost-fetch'; | ||
| export type { FetchFunction } from './localhost-fetch'; | ||
| export { createFetch } from './localhost-fetch.js'; | ||
| export type { FetchFunction } from './localhost-fetch.js'; |
Contributor
There was a problem hiding this comment.
why .js? we are not using esm
pyramation
reviewed
May 12, 2026
| const nodeRequire = getNodeModuleLoader(); | ||
| if (nodeRequire) { | ||
| const http = nodeRequire('node:' + 'http') as typeof import('node:http'); | ||
| const https = nodeRequire('node:' + 'https') as typeof import('node:https'); |
Contributor
There was a problem hiding this comment.
should we use our fetch library? what is this for?
Contributor
There was a problem hiding this comment.
pyramation
reviewed
May 12, 2026
| "import": "./esm/runtime/index.js", | ||
| "require": "./runtime/index.js" | ||
| } | ||
| }, |
Contributor
There was a problem hiding this comment.
yea we don't use exports — see constructive-skills pnpm
65b829b to
20702c4
Compare
Templates and snapshots updated; CLI table command + ORM client/model generators now treat findFirst/findOne as singular (use the singular noun, not the by-id query name, as the result key). Server-test and test-app integration coverage updated to assert single-object shape.
- Drop .js extensions from runtime re-exports (repo is CJS w/ moduleResolution: node; .js belongs to ESM/Node16). - Replace local localhost-fetch.ts with @constructive-io/fetch@^1.0.0 (already used by packages/upload-client; same API surface). - Drop the package.json "exports" map; sub-paths resolve via filesystem walk like every other publishable package in this monorepo. Lockfile regenerated.
Picks up findFirst/findOne single-object return, runtime export alignment, and new tables/bulk mutations merged from main.
20702c4 to
70085fb
Compare
The earlier SDK regen pass missed 30 model files in
sdk/constructive-cli/src/{admin,public}/orm/models/ — tables added on
main by automated bot commits between May 9-11 using the pre-#752
codegen. They retained the old 6-arg buildFindFirstDocument call,
breaking the CLI build with TS2345 once query-builder.ts moved to the
new 7-arg signature.
Re-ran pregenerate (rimraf) + generate cleanly across all four SDK
targets: @constructive-sdk/cli, @constructive-io/sdk,
@constructive-io/react, @pgpmjs/migrate-client.
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.
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)
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)
React hooks (sdk/constructive-react)
migrate-client SDK
Same pattern verified on SqlAction.findFirst — returns { sqlAction: ... | null } with SqlActionOrderBy type param.
Build + typecheck (already done)