prisma-guard 1.27.1 → 1.28.1

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.
@@ -51,10 +51,24 @@ type ModelOpts = {
51
51
  type QueryMethod = 'findMany' | 'findFirst' | 'findFirstOrThrow' | 'findUnique' | 'findUniqueOrThrow' | 'count' | 'aggregate' | 'groupBy';
52
52
  type MutationMethod = 'create' | 'createMany' | 'createManyAndReturn' | 'update' | 'updateMany' | 'updateManyAndReturn' | 'upsert' | 'delete' | 'deleteMany';
53
53
  type OrderByFieldConfig = true | Record<string, true>;
54
+ interface NestedArgs {
55
+ where?: Record<string, unknown>;
56
+ include?: Record<string, true | NestedArgs>;
57
+ select?: Record<string, true | NestedArgs>;
58
+ orderBy?: Record<string, OrderByFieldConfig>;
59
+ cursor?: Record<string, unknown>;
60
+ take?: number | {
61
+ max: number;
62
+ default?: number;
63
+ };
64
+ skip?: true;
65
+ }
66
+ type NestedIncludeArgs = NestedArgs;
67
+ type NestedSelectArgs = NestedArgs;
54
68
  interface ShapeConfig {
55
69
  where?: Record<string, unknown>;
56
- include?: Record<string, true | NestedIncludeArgs>;
57
- select?: Record<string, true | NestedSelectArgs>;
70
+ include?: Record<string, true | NestedArgs>;
71
+ select?: Record<string, true | NestedArgs>;
58
72
  orderBy?: true | Record<string, OrderByFieldConfig>;
59
73
  cursor?: Record<string, unknown>;
60
74
  take?: number | {
@@ -71,30 +85,6 @@ interface ShapeConfig {
71
85
  by?: string[];
72
86
  having?: Record<string, true>;
73
87
  }
74
- interface NestedIncludeArgs {
75
- where?: Record<string, unknown>;
76
- include?: Record<string, true | NestedIncludeArgs>;
77
- select?: Record<string, true | NestedSelectArgs>;
78
- orderBy?: Record<string, OrderByFieldConfig>;
79
- cursor?: Record<string, unknown>;
80
- take?: number | {
81
- max: number;
82
- default?: number;
83
- };
84
- skip?: true;
85
- }
86
- interface NestedSelectArgs {
87
- where?: Record<string, unknown>;
88
- include?: Record<string, true | NestedIncludeArgs>;
89
- select?: Record<string, true | NestedSelectArgs>;
90
- orderBy?: Record<string, OrderByFieldConfig>;
91
- cursor?: Record<string, unknown>;
92
- take?: number | {
93
- max: number;
94
- default?: number;
95
- };
96
- skip?: true;
97
- }
98
88
  type ShapeOrFn$1<TCtx = unknown> = ShapeConfig | ((ctx: TCtx) => ShapeConfig);
99
89
  interface ScopeEntry {
100
90
  readonly fk: string;
@@ -197,22 +187,22 @@ declare function unsupported(): {
197
187
 
198
188
  declare const OPERATION_SHAPE_KEYS: {
199
189
  readonly findMany: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
190
+ readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
200
191
  readonly findFirst: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
201
192
  readonly findFirstOrThrow: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
202
193
  readonly findUnique: readonly ["where", "include", "select"];
203
194
  readonly findUniqueOrThrow: readonly ["where", "include", "select"];
204
- readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
205
195
  readonly count: readonly ["where", "select", "cursor", "orderBy", "skip", "take"];
206
196
  readonly aggregate: readonly ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
207
- readonly groupBy: readonly ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"];
208
- readonly create: readonly ["data", "select", "include"];
209
- readonly createMany: readonly ["data"];
210
- readonly createManyAndReturn: readonly ["data", "select", "include"];
211
- readonly update: readonly ["data", "where", "select", "include"];
212
- readonly updateMany: readonly ["data", "where"];
213
- readonly updateManyAndReturn: readonly ["data", "where", "select", "include"];
214
- readonly upsert: readonly ["where", "create", "update", "select", "include"];
215
- readonly delete: readonly ["where", "select", "include"];
197
+ readonly groupBy: readonly ["where", "orderBy", "by", "having", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
198
+ readonly create: readonly ["data", "include", "select"];
199
+ readonly createMany: readonly ["data", "skipDuplicates"];
200
+ readonly createManyAndReturn: readonly ["data", "select", "skipDuplicates"];
201
+ readonly update: readonly ["where", "data", "include", "select"];
202
+ readonly updateMany: readonly ["where", "data"];
203
+ readonly updateManyAndReturn: readonly ["where", "data", "select"];
204
+ readonly upsert: readonly ["where", "create", "update", "include", "select"];
205
+ readonly delete: readonly ["where", "include", "select"];
216
206
  readonly deleteMany: readonly ["where"];
217
207
  };
218
208
  type OperationName = keyof typeof OPERATION_SHAPE_KEYS;
@@ -248,9 +238,10 @@ type RelationFields<TM extends TypeMapConst, M extends keyof TM> = {
248
238
  type ListRelationFields<TM extends TypeMapConst, M extends keyof TM> = {
249
239
  [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? TM[M][K]['isList'] extends true ? K : never : never;
250
240
  }[keyof TM[M]] & string;
251
- type WritableFields<TM extends TypeMapConst, M extends keyof TM> = {
241
+ type WritableScalarFields<TM extends TypeMapConst, M extends keyof TM> = {
252
242
  [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['isUpdatedAt'] extends true ? never : K;
253
243
  }[keyof TM[M]] & string;
244
+ type WritableFields<TM extends TypeMapConst, M extends keyof TM> = WritableScalarFields<TM, M> | RelationFields<TM, M>;
254
245
  type UniqueFields<TM extends TypeMapConst, M extends keyof TM> = {
255
246
  [K in keyof TM[M]]: TM[M][K]['isUnique'] extends true ? K : TM[M][K]['isId'] extends true ? K : never;
256
247
  }[keyof TM[M]] & string;
@@ -333,6 +324,23 @@ type TypedInclude<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDe
333
324
  };
334
325
  type TypedCountSelect<TM extends TypeMapConst, M extends keyof TM> = Partial<Record<ScalarFields<TM, M> | '_all', true>>;
335
326
  type TypedCountField<TM extends TypeMapConst, M extends keyof TM> = true | Partial<Record<ScalarFields<TM, M> | '_all', true>>;
327
+ interface TypedRelationWriteConfig {
328
+ connect?: unknown;
329
+ connectOrCreate?: unknown;
330
+ create?: unknown;
331
+ createMany?: unknown;
332
+ disconnect?: unknown;
333
+ delete?: unknown;
334
+ set?: unknown;
335
+ update?: unknown;
336
+ updateMany?: unknown;
337
+ upsert?: unknown;
338
+ deleteMany?: unknown;
339
+ }
340
+ type WritableFieldValue<TM extends TypeMapConst, M extends keyof TM, K extends keyof TM[M]> = TM[M][K]['isRelation'] extends true ? TypedRelationWriteConfig : unknown;
341
+ type TypedDataShape<TM extends TypeMapConst, M extends keyof TM> = Partial<{
342
+ [K in WritableFields<TM, M>]: WritableFieldValue<TM, M, K>;
343
+ }>;
336
344
  type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst = {}> = {
337
345
  where: TypedWhere<TM, M>;
338
346
  select: TypedProjection<TM, M, D, UM>;
@@ -352,9 +360,9 @@ type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends Shap
352
360
  _sum: Partial<Record<NumericFields<TM, M>, true>>;
353
361
  _min: Partial<Record<ComparableFields<TM, M>, true>>;
354
362
  _max: Partial<Record<ComparableFields<TM, M>, true>>;
355
- data: Partial<Record<WritableFields<TM, M>, unknown>>;
356
- create: Partial<Record<WritableFields<TM, M>, unknown>>;
357
- update: Partial<Record<WritableFields<TM, M>, unknown>>;
363
+ data: TypedDataShape<TM, M>;
364
+ create: TypedDataShape<TM, M>;
365
+ update: TypedDataShape<TM, M>;
358
366
  };
359
367
  type BaseOperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth, UM extends UniqueMapConst> = Partial<Pick<TypedShapeProps<TM, M, D, UM>, Extract<OperationShapeKey<O>, keyof TypedShapeProps<TM, M, D, UM>>>>;
360
368
  type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
@@ -363,13 +371,39 @@ type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
363
371
  type CountShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'count', D, UM>, 'select'> & {
364
372
  select?: TypedCountSelect<TM, M>;
365
373
  };
366
- type UniqueWhereShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, O, D, UM>, 'where'> & {
367
- where?: TypedUniqueWhere<TM, M, UM>;
374
+ type WithUniqueWhereRequired<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, O, D, UM>, 'where'> & {
375
+ where: TypedUniqueWhere<TM, M, UM>;
368
376
  };
369
- type RequiredUniqueWhereShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, O, D, UM>, 'where'> & {
377
+ type RequiredUpdateShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'update', D, UM>, 'where' | 'data'> & {
370
378
  where: TypedUniqueWhere<TM, M, UM>;
379
+ data: TypedDataShape<TM, M>;
380
+ };
381
+ type RequiredUpsertShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'upsert', D, UM>, 'where' | 'create' | 'update'> & {
382
+ where: TypedUniqueWhere<TM, M, UM>;
383
+ create: TypedDataShape<TM, M>;
384
+ update: TypedDataShape<TM, M>;
385
+ };
386
+ type RequiredCreateShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'create', D, UM>, 'data'> & {
387
+ data: TypedDataShape<TM, M>;
388
+ };
389
+ type RequiredCreateManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'createMany', D, UM>, 'data'> & {
390
+ data: TypedDataShape<TM, M>;
391
+ };
392
+ type RequiredCreateManyAndReturnShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'createManyAndReturn', D, UM>, 'data'> & {
393
+ data: TypedDataShape<TM, M>;
394
+ };
395
+ type RequiredUpdateManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'updateMany', D, UM>, 'data' | 'where'> & {
396
+ data: TypedDataShape<TM, M>;
397
+ where: TypedWhere<TM, M>;
398
+ };
399
+ type RequiredUpdateManyAndReturnShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'updateManyAndReturn', D, UM>, 'data' | 'where'> & {
400
+ data: TypedDataShape<TM, M>;
401
+ where: TypedWhere<TM, M>;
402
+ };
403
+ type RequiredDeleteManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'deleteMany', D, UM>, 'where'> & {
404
+ where: TypedWhere<TM, M>;
371
405
  };
372
- type OperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth = 1, UM extends UniqueMapConst = {}> = O extends 'findUnique' ? RequiredUniqueWhereShape<TM, M, 'findUnique', D, UM> : O extends 'findUniqueOrThrow' ? RequiredUniqueWhereShape<TM, M, 'findUniqueOrThrow', D, UM> : O extends 'update' ? UniqueWhereShape<TM, M, 'update', D, UM> : O extends 'delete' ? UniqueWhereShape<TM, M, 'delete', D, UM> : O extends 'upsert' ? UniqueWhereShape<TM, M, 'upsert', D, UM> : O extends 'groupBy' ? RequireKeys<BaseOperationShape<TM, M, 'groupBy', D, UM>, 'by'> : O extends 'count' ? CountShape<TM, M, D, UM> : BaseOperationShape<TM, M, O, D, UM>;
406
+ type OperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth = 1, UM extends UniqueMapConst = {}> = O extends 'findUnique' ? WithUniqueWhereRequired<TM, M, 'findUnique', D, UM> : O extends 'findUniqueOrThrow' ? WithUniqueWhereRequired<TM, M, 'findUniqueOrThrow', D, UM> : O extends 'update' ? RequiredUpdateShape<TM, M, D, UM> : O extends 'delete' ? WithUniqueWhereRequired<TM, M, 'delete', D, UM> : O extends 'upsert' ? RequiredUpsertShape<TM, M, D, UM> : O extends 'create' ? RequiredCreateShape<TM, M, D, UM> : O extends 'createMany' ? RequiredCreateManyShape<TM, M, D, UM> : O extends 'createManyAndReturn' ? RequiredCreateManyAndReturnShape<TM, M, D, UM> : O extends 'updateMany' ? RequiredUpdateManyShape<TM, M, D, UM> : O extends 'updateManyAndReturn' ? RequiredUpdateManyAndReturnShape<TM, M, D, UM> : O extends 'deleteMany' ? RequiredDeleteManyShape<TM, M, D, UM> : O extends 'groupBy' ? RequireKeys<BaseOperationShape<TM, M, 'groupBy', D, UM>, 'by'> : O extends 'count' ? CountShape<TM, M, D, UM> : BaseOperationShape<TM, M, O, D, UM>;
373
407
  type TypedGuardShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth = 1, UM extends UniqueMapConst = {}> = Partial<TypedShapeProps<TM, M, D, UM>>;
374
408
  type ShapeFn<S, TCtx> = (ctx: TCtx) => S;
375
409
  type ShapeOrFn<S, TCtx> = S | ShapeFn<S, TCtx>;
@@ -51,10 +51,24 @@ type ModelOpts = {
51
51
  type QueryMethod = 'findMany' | 'findFirst' | 'findFirstOrThrow' | 'findUnique' | 'findUniqueOrThrow' | 'count' | 'aggregate' | 'groupBy';
52
52
  type MutationMethod = 'create' | 'createMany' | 'createManyAndReturn' | 'update' | 'updateMany' | 'updateManyAndReturn' | 'upsert' | 'delete' | 'deleteMany';
53
53
  type OrderByFieldConfig = true | Record<string, true>;
54
+ interface NestedArgs {
55
+ where?: Record<string, unknown>;
56
+ include?: Record<string, true | NestedArgs>;
57
+ select?: Record<string, true | NestedArgs>;
58
+ orderBy?: Record<string, OrderByFieldConfig>;
59
+ cursor?: Record<string, unknown>;
60
+ take?: number | {
61
+ max: number;
62
+ default?: number;
63
+ };
64
+ skip?: true;
65
+ }
66
+ type NestedIncludeArgs = NestedArgs;
67
+ type NestedSelectArgs = NestedArgs;
54
68
  interface ShapeConfig {
55
69
  where?: Record<string, unknown>;
56
- include?: Record<string, true | NestedIncludeArgs>;
57
- select?: Record<string, true | NestedSelectArgs>;
70
+ include?: Record<string, true | NestedArgs>;
71
+ select?: Record<string, true | NestedArgs>;
58
72
  orderBy?: true | Record<string, OrderByFieldConfig>;
59
73
  cursor?: Record<string, unknown>;
60
74
  take?: number | {
@@ -71,30 +85,6 @@ interface ShapeConfig {
71
85
  by?: string[];
72
86
  having?: Record<string, true>;
73
87
  }
74
- interface NestedIncludeArgs {
75
- where?: Record<string, unknown>;
76
- include?: Record<string, true | NestedIncludeArgs>;
77
- select?: Record<string, true | NestedSelectArgs>;
78
- orderBy?: Record<string, OrderByFieldConfig>;
79
- cursor?: Record<string, unknown>;
80
- take?: number | {
81
- max: number;
82
- default?: number;
83
- };
84
- skip?: true;
85
- }
86
- interface NestedSelectArgs {
87
- where?: Record<string, unknown>;
88
- include?: Record<string, true | NestedIncludeArgs>;
89
- select?: Record<string, true | NestedSelectArgs>;
90
- orderBy?: Record<string, OrderByFieldConfig>;
91
- cursor?: Record<string, unknown>;
92
- take?: number | {
93
- max: number;
94
- default?: number;
95
- };
96
- skip?: true;
97
- }
98
88
  type ShapeOrFn$1<TCtx = unknown> = ShapeConfig | ((ctx: TCtx) => ShapeConfig);
99
89
  interface ScopeEntry {
100
90
  readonly fk: string;
@@ -197,22 +187,22 @@ declare function unsupported(): {
197
187
 
198
188
  declare const OPERATION_SHAPE_KEYS: {
199
189
  readonly findMany: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
190
+ readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
200
191
  readonly findFirst: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
201
192
  readonly findFirstOrThrow: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
202
193
  readonly findUnique: readonly ["where", "include", "select"];
203
194
  readonly findUniqueOrThrow: readonly ["where", "include", "select"];
204
- readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
205
195
  readonly count: readonly ["where", "select", "cursor", "orderBy", "skip", "take"];
206
196
  readonly aggregate: readonly ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
207
- readonly groupBy: readonly ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"];
208
- readonly create: readonly ["data", "select", "include"];
209
- readonly createMany: readonly ["data"];
210
- readonly createManyAndReturn: readonly ["data", "select", "include"];
211
- readonly update: readonly ["data", "where", "select", "include"];
212
- readonly updateMany: readonly ["data", "where"];
213
- readonly updateManyAndReturn: readonly ["data", "where", "select", "include"];
214
- readonly upsert: readonly ["where", "create", "update", "select", "include"];
215
- readonly delete: readonly ["where", "select", "include"];
197
+ readonly groupBy: readonly ["where", "orderBy", "by", "having", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
198
+ readonly create: readonly ["data", "include", "select"];
199
+ readonly createMany: readonly ["data", "skipDuplicates"];
200
+ readonly createManyAndReturn: readonly ["data", "select", "skipDuplicates"];
201
+ readonly update: readonly ["where", "data", "include", "select"];
202
+ readonly updateMany: readonly ["where", "data"];
203
+ readonly updateManyAndReturn: readonly ["where", "data", "select"];
204
+ readonly upsert: readonly ["where", "create", "update", "include", "select"];
205
+ readonly delete: readonly ["where", "include", "select"];
216
206
  readonly deleteMany: readonly ["where"];
217
207
  };
218
208
  type OperationName = keyof typeof OPERATION_SHAPE_KEYS;
@@ -248,9 +238,10 @@ type RelationFields<TM extends TypeMapConst, M extends keyof TM> = {
248
238
  type ListRelationFields<TM extends TypeMapConst, M extends keyof TM> = {
249
239
  [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? TM[M][K]['isList'] extends true ? K : never : never;
250
240
  }[keyof TM[M]] & string;
251
- type WritableFields<TM extends TypeMapConst, M extends keyof TM> = {
241
+ type WritableScalarFields<TM extends TypeMapConst, M extends keyof TM> = {
252
242
  [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['isUpdatedAt'] extends true ? never : K;
253
243
  }[keyof TM[M]] & string;
244
+ type WritableFields<TM extends TypeMapConst, M extends keyof TM> = WritableScalarFields<TM, M> | RelationFields<TM, M>;
254
245
  type UniqueFields<TM extends TypeMapConst, M extends keyof TM> = {
255
246
  [K in keyof TM[M]]: TM[M][K]['isUnique'] extends true ? K : TM[M][K]['isId'] extends true ? K : never;
256
247
  }[keyof TM[M]] & string;
@@ -333,6 +324,23 @@ type TypedInclude<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDe
333
324
  };
334
325
  type TypedCountSelect<TM extends TypeMapConst, M extends keyof TM> = Partial<Record<ScalarFields<TM, M> | '_all', true>>;
335
326
  type TypedCountField<TM extends TypeMapConst, M extends keyof TM> = true | Partial<Record<ScalarFields<TM, M> | '_all', true>>;
327
+ interface TypedRelationWriteConfig {
328
+ connect?: unknown;
329
+ connectOrCreate?: unknown;
330
+ create?: unknown;
331
+ createMany?: unknown;
332
+ disconnect?: unknown;
333
+ delete?: unknown;
334
+ set?: unknown;
335
+ update?: unknown;
336
+ updateMany?: unknown;
337
+ upsert?: unknown;
338
+ deleteMany?: unknown;
339
+ }
340
+ type WritableFieldValue<TM extends TypeMapConst, M extends keyof TM, K extends keyof TM[M]> = TM[M][K]['isRelation'] extends true ? TypedRelationWriteConfig : unknown;
341
+ type TypedDataShape<TM extends TypeMapConst, M extends keyof TM> = Partial<{
342
+ [K in WritableFields<TM, M>]: WritableFieldValue<TM, M, K>;
343
+ }>;
336
344
  type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst = {}> = {
337
345
  where: TypedWhere<TM, M>;
338
346
  select: TypedProjection<TM, M, D, UM>;
@@ -352,9 +360,9 @@ type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends Shap
352
360
  _sum: Partial<Record<NumericFields<TM, M>, true>>;
353
361
  _min: Partial<Record<ComparableFields<TM, M>, true>>;
354
362
  _max: Partial<Record<ComparableFields<TM, M>, true>>;
355
- data: Partial<Record<WritableFields<TM, M>, unknown>>;
356
- create: Partial<Record<WritableFields<TM, M>, unknown>>;
357
- update: Partial<Record<WritableFields<TM, M>, unknown>>;
363
+ data: TypedDataShape<TM, M>;
364
+ create: TypedDataShape<TM, M>;
365
+ update: TypedDataShape<TM, M>;
358
366
  };
359
367
  type BaseOperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth, UM extends UniqueMapConst> = Partial<Pick<TypedShapeProps<TM, M, D, UM>, Extract<OperationShapeKey<O>, keyof TypedShapeProps<TM, M, D, UM>>>>;
360
368
  type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
@@ -363,13 +371,39 @@ type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
363
371
  type CountShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'count', D, UM>, 'select'> & {
364
372
  select?: TypedCountSelect<TM, M>;
365
373
  };
366
- type UniqueWhereShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, O, D, UM>, 'where'> & {
367
- where?: TypedUniqueWhere<TM, M, UM>;
374
+ type WithUniqueWhereRequired<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, O, D, UM>, 'where'> & {
375
+ where: TypedUniqueWhere<TM, M, UM>;
368
376
  };
369
- type RequiredUniqueWhereShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, O, D, UM>, 'where'> & {
377
+ type RequiredUpdateShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'update', D, UM>, 'where' | 'data'> & {
370
378
  where: TypedUniqueWhere<TM, M, UM>;
379
+ data: TypedDataShape<TM, M>;
380
+ };
381
+ type RequiredUpsertShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'upsert', D, UM>, 'where' | 'create' | 'update'> & {
382
+ where: TypedUniqueWhere<TM, M, UM>;
383
+ create: TypedDataShape<TM, M>;
384
+ update: TypedDataShape<TM, M>;
385
+ };
386
+ type RequiredCreateShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'create', D, UM>, 'data'> & {
387
+ data: TypedDataShape<TM, M>;
388
+ };
389
+ type RequiredCreateManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'createMany', D, UM>, 'data'> & {
390
+ data: TypedDataShape<TM, M>;
391
+ };
392
+ type RequiredCreateManyAndReturnShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'createManyAndReturn', D, UM>, 'data'> & {
393
+ data: TypedDataShape<TM, M>;
394
+ };
395
+ type RequiredUpdateManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'updateMany', D, UM>, 'data' | 'where'> & {
396
+ data: TypedDataShape<TM, M>;
397
+ where: TypedWhere<TM, M>;
398
+ };
399
+ type RequiredUpdateManyAndReturnShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'updateManyAndReturn', D, UM>, 'data' | 'where'> & {
400
+ data: TypedDataShape<TM, M>;
401
+ where: TypedWhere<TM, M>;
402
+ };
403
+ type RequiredDeleteManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'deleteMany', D, UM>, 'where'> & {
404
+ where: TypedWhere<TM, M>;
371
405
  };
372
- type OperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth = 1, UM extends UniqueMapConst = {}> = O extends 'findUnique' ? RequiredUniqueWhereShape<TM, M, 'findUnique', D, UM> : O extends 'findUniqueOrThrow' ? RequiredUniqueWhereShape<TM, M, 'findUniqueOrThrow', D, UM> : O extends 'update' ? UniqueWhereShape<TM, M, 'update', D, UM> : O extends 'delete' ? UniqueWhereShape<TM, M, 'delete', D, UM> : O extends 'upsert' ? UniqueWhereShape<TM, M, 'upsert', D, UM> : O extends 'groupBy' ? RequireKeys<BaseOperationShape<TM, M, 'groupBy', D, UM>, 'by'> : O extends 'count' ? CountShape<TM, M, D, UM> : BaseOperationShape<TM, M, O, D, UM>;
406
+ type OperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth = 1, UM extends UniqueMapConst = {}> = O extends 'findUnique' ? WithUniqueWhereRequired<TM, M, 'findUnique', D, UM> : O extends 'findUniqueOrThrow' ? WithUniqueWhereRequired<TM, M, 'findUniqueOrThrow', D, UM> : O extends 'update' ? RequiredUpdateShape<TM, M, D, UM> : O extends 'delete' ? WithUniqueWhereRequired<TM, M, 'delete', D, UM> : O extends 'upsert' ? RequiredUpsertShape<TM, M, D, UM> : O extends 'create' ? RequiredCreateShape<TM, M, D, UM> : O extends 'createMany' ? RequiredCreateManyShape<TM, M, D, UM> : O extends 'createManyAndReturn' ? RequiredCreateManyAndReturnShape<TM, M, D, UM> : O extends 'updateMany' ? RequiredUpdateManyShape<TM, M, D, UM> : O extends 'updateManyAndReturn' ? RequiredUpdateManyAndReturnShape<TM, M, D, UM> : O extends 'deleteMany' ? RequiredDeleteManyShape<TM, M, D, UM> : O extends 'groupBy' ? RequireKeys<BaseOperationShape<TM, M, 'groupBy', D, UM>, 'by'> : O extends 'count' ? CountShape<TM, M, D, UM> : BaseOperationShape<TM, M, O, D, UM>;
373
407
  type TypedGuardShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth = 1, UM extends UniqueMapConst = {}> = Partial<TypedShapeProps<TM, M, D, UM>>;
374
408
  type ShapeFn<S, TCtx> = (ctx: TCtx) => S;
375
409
  type ShapeOrFn<S, TCtx> = S | ShapeFn<S, TCtx>;