@vibeorm/generator 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ export function generateDelegates(params: { schema: Schema }): string {
|
|
|
47
47
|
const extraImports = hasJsonField ? ", JsonValue" : "";
|
|
48
48
|
parts.push(`import type { ${payloadImports}${extraImports} } from "./models.ts";`);
|
|
49
49
|
|
|
50
|
-
parts.push(`import type { GetResult } from "./result.ts";`);
|
|
50
|
+
parts.push(`import type { GetResult, Exact } from "./result.ts";`);
|
|
51
51
|
|
|
52
52
|
// Import enums if any models have enum fields
|
|
53
53
|
if (schema.enums.length > 0) {
|
|
@@ -123,7 +123,7 @@ ${findManyWhereBlock}${includeBlock}
|
|
|
123
123
|
* });
|
|
124
124
|
*/
|
|
125
125
|
findMany<T extends ${model.name}FindManyArgs>(
|
|
126
|
-
args?: T,
|
|
126
|
+
args?: Exact<T, ${model.name}FindManyArgs>,
|
|
127
127
|
): Promise<GetResult<${p}, T, "findMany">>;
|
|
128
128
|
|
|
129
129
|
/**
|
|
@@ -138,7 +138,7 @@ ${findManyWhereBlock}
|
|
|
138
138
|
* });
|
|
139
139
|
*/
|
|
140
140
|
findFirst<T extends ${model.name}FindFirstArgs>(
|
|
141
|
-
args?: T,
|
|
141
|
+
args?: Exact<T, ${model.name}FindFirstArgs>,
|
|
142
142
|
): Promise<GetResult<${p}, T, "findFirst">>;
|
|
143
143
|
|
|
144
144
|
/**
|
|
@@ -150,7 +150,7 @@ ${uniqueWhereBlock}
|
|
|
150
150
|
* });
|
|
151
151
|
*/
|
|
152
152
|
findUnique<T extends ${model.name}FindUniqueArgs>(
|
|
153
|
-
args: T,
|
|
153
|
+
args: Exact<T, ${model.name}FindUniqueArgs>,
|
|
154
154
|
): Promise<GetResult<${p}, T, "findUnique">>;
|
|
155
155
|
|
|
156
156
|
/**
|
|
@@ -162,14 +162,14 @@ ${uniqueWhereBlock}
|
|
|
162
162
|
* });
|
|
163
163
|
*/
|
|
164
164
|
findUniqueOrThrow<T extends ${model.name}FindUniqueArgs>(
|
|
165
|
-
args: T,
|
|
165
|
+
args: Exact<T, ${model.name}FindUniqueArgs>,
|
|
166
166
|
): Promise<GetResult<${p}, T, "findUniqueOrThrow">>;
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Find the first ${model.name} record matching a filter, or throw if not found.
|
|
170
170
|
*/
|
|
171
171
|
findFirstOrThrow<T extends ${model.name}FindFirstArgs>(
|
|
172
|
-
args?: T,
|
|
172
|
+
args?: Exact<T, ${model.name}FindFirstArgs>,
|
|
173
173
|
): Promise<GetResult<${p}, T, "findFirstOrThrow">>;
|
|
174
174
|
|
|
175
175
|
/**
|
|
@@ -181,7 +181,7 @@ ${createDataBlock}
|
|
|
181
181
|
* });
|
|
182
182
|
*/
|
|
183
183
|
create<T extends ${model.name}CreateArgs>(
|
|
184
|
-
args: T,
|
|
184
|
+
args: Exact<T, ${model.name}CreateArgs>,
|
|
185
185
|
): Promise<GetResult<${p}, T, "create">>;
|
|
186
186
|
|
|
187
187
|
/**
|
|
@@ -209,7 +209,7 @@ ${createManyDataBlock}
|
|
|
209
209
|
* });
|
|
210
210
|
*/
|
|
211
211
|
createManyAndReturn<T extends ${model.name}CreateManyAndReturnArgs>(
|
|
212
|
-
args: T,
|
|
212
|
+
args: Exact<T, ${model.name}CreateManyAndReturnArgs>,
|
|
213
213
|
): Promise<GetResult<${p}, T, "createManyAndReturn">>;
|
|
214
214
|
|
|
215
215
|
/**
|
|
@@ -222,7 +222,7 @@ ${updateDataBlock}
|
|
|
222
222
|
* });
|
|
223
223
|
*/
|
|
224
224
|
update<T extends ${model.name}UpdateArgs>(
|
|
225
|
-
args: T,
|
|
225
|
+
args: Exact<T, ${model.name}UpdateArgs>,
|
|
226
226
|
): Promise<GetResult<${p}, T, "update">>;
|
|
227
227
|
|
|
228
228
|
/**
|
|
@@ -236,7 +236,7 @@ ${upsertUpdateBlock}
|
|
|
236
236
|
* });
|
|
237
237
|
*/
|
|
238
238
|
upsert<T extends ${model.name}UpsertArgs>(
|
|
239
|
-
args: T,
|
|
239
|
+
args: Exact<T, ${model.name}UpsertArgs>,
|
|
240
240
|
): Promise<GetResult<${p}, T, "upsert">>;
|
|
241
241
|
|
|
242
242
|
/**
|
|
@@ -248,7 +248,7 @@ ${uniqueWhereBlock}
|
|
|
248
248
|
* });
|
|
249
249
|
*/
|
|
250
250
|
delete<T extends ${model.name}DeleteArgs>(
|
|
251
|
-
args: T,
|
|
251
|
+
args: Exact<T, ${model.name}DeleteArgs>,
|
|
252
252
|
): Promise<GetResult<${p}, T, "delete">>;
|
|
253
253
|
|
|
254
254
|
/**
|
|
@@ -36,6 +36,25 @@ type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
|
36
36
|
/** Flatten intersection types for cleaner hover tooltips */
|
|
37
37
|
type Compute<T> = T extends Function ? T : { [K in keyof T]: T[K] } & unknown;
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Enforces strict type safety by recursively rejecting excess properties.
|
|
41
|
+
*
|
|
42
|
+
* TypeScript's structural subtyping allows objects to have extra properties
|
|
43
|
+
* when passed through generics (\`<T extends Args>\`). This utility type
|
|
44
|
+
* maps any key in A that is NOT in W to \`never\`, causing a compile-time
|
|
45
|
+
* error when unknown keys (e.g. typos in where/select/include) are used.
|
|
46
|
+
*
|
|
47
|
+
* Primitives, arrays, functions, and Dates are passed through unchanged
|
|
48
|
+
* to preserve literal types for return type narrowing via GetFindResult.
|
|
49
|
+
*/
|
|
50
|
+
export type Exact<A, W> = W extends unknown
|
|
51
|
+
? A extends W
|
|
52
|
+
? A extends Record<string, unknown>
|
|
53
|
+
? { [K in keyof A]: K extends keyof W ? Exact<A[K], W[K]> : never }
|
|
54
|
+
: A
|
|
55
|
+
: W
|
|
56
|
+
: never;
|
|
57
|
+
|
|
39
58
|
/** Extract scalar fields from a payload (default selection) */
|
|
40
59
|
type DefaultSelection<P extends OperationPayload> = P["scalars"];
|
|
41
60
|
|