prisma-guard 1.27.0 → 1.28.0

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;
@@ -201,7 +191,6 @@ declare const OPERATION_SHAPE_KEYS: {
201
191
  readonly findFirstOrThrow: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
202
192
  readonly findUnique: readonly ["where", "include", "select"];
203
193
  readonly findUniqueOrThrow: readonly ["where", "include", "select"];
204
- readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
205
194
  readonly count: readonly ["where", "select", "cursor", "orderBy", "skip", "take"];
206
195
  readonly aggregate: readonly ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
207
196
  readonly groupBy: readonly ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"];
@@ -248,9 +237,10 @@ type RelationFields<TM extends TypeMapConst, M extends keyof TM> = {
248
237
  type ListRelationFields<TM extends TypeMapConst, M extends keyof TM> = {
249
238
  [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? TM[M][K]['isList'] extends true ? K : never : never;
250
239
  }[keyof TM[M]] & string;
251
- type WritableFields<TM extends TypeMapConst, M extends keyof TM> = {
240
+ type WritableScalarFields<TM extends TypeMapConst, M extends keyof TM> = {
252
241
  [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['isUpdatedAt'] extends true ? never : K;
253
242
  }[keyof TM[M]] & string;
243
+ type WritableFields<TM extends TypeMapConst, M extends keyof TM> = WritableScalarFields<TM, M> | RelationFields<TM, M>;
254
244
  type UniqueFields<TM extends TypeMapConst, M extends keyof TM> = {
255
245
  [K in keyof TM[M]]: TM[M][K]['isUnique'] extends true ? K : TM[M][K]['isId'] extends true ? K : never;
256
246
  }[keyof TM[M]] & string;
@@ -333,6 +323,23 @@ type TypedInclude<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDe
333
323
  };
334
324
  type TypedCountSelect<TM extends TypeMapConst, M extends keyof TM> = Partial<Record<ScalarFields<TM, M> | '_all', true>>;
335
325
  type TypedCountField<TM extends TypeMapConst, M extends keyof TM> = true | Partial<Record<ScalarFields<TM, M> | '_all', true>>;
326
+ interface TypedRelationWriteConfig {
327
+ connect?: unknown;
328
+ connectOrCreate?: unknown;
329
+ create?: unknown;
330
+ createMany?: unknown;
331
+ disconnect?: unknown;
332
+ delete?: unknown;
333
+ set?: unknown;
334
+ update?: unknown;
335
+ updateMany?: unknown;
336
+ upsert?: unknown;
337
+ deleteMany?: unknown;
338
+ }
339
+ type WritableFieldValue<TM extends TypeMapConst, M extends keyof TM, K extends keyof TM[M]> = TM[M][K]['isRelation'] extends true ? TypedRelationWriteConfig : unknown;
340
+ type TypedDataShape<TM extends TypeMapConst, M extends keyof TM> = Partial<{
341
+ [K in WritableFields<TM, M>]: WritableFieldValue<TM, M, K>;
342
+ }>;
336
343
  type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst = {}> = {
337
344
  where: TypedWhere<TM, M>;
338
345
  select: TypedProjection<TM, M, D, UM>;
@@ -352,9 +359,9 @@ type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends Shap
352
359
  _sum: Partial<Record<NumericFields<TM, M>, true>>;
353
360
  _min: Partial<Record<ComparableFields<TM, M>, true>>;
354
361
  _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>>;
362
+ data: TypedDataShape<TM, M>;
363
+ create: TypedDataShape<TM, M>;
364
+ update: TypedDataShape<TM, M>;
358
365
  };
359
366
  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
367
  type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
@@ -363,13 +370,39 @@ type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
363
370
  type CountShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'count', D, UM>, 'select'> & {
364
371
  select?: TypedCountSelect<TM, M>;
365
372
  };
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>;
373
+ 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'> & {
374
+ where: TypedUniqueWhere<TM, M, UM>;
375
+ };
376
+ type RequiredUpdateShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'update', D, UM>, 'where' | 'data'> & {
377
+ where: TypedUniqueWhere<TM, M, UM>;
378
+ data: TypedDataShape<TM, M>;
368
379
  };
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'> & {
380
+ 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'> & {
370
381
  where: TypedUniqueWhere<TM, M, UM>;
382
+ create: TypedDataShape<TM, M>;
383
+ update: TypedDataShape<TM, M>;
384
+ };
385
+ type RequiredCreateShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'create', D, UM>, 'data'> & {
386
+ data: TypedDataShape<TM, M>;
387
+ };
388
+ type RequiredCreateManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'createMany', D, UM>, 'data'> & {
389
+ data: TypedDataShape<TM, M>;
390
+ };
391
+ type RequiredCreateManyAndReturnShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'createManyAndReturn', D, UM>, 'data'> & {
392
+ data: TypedDataShape<TM, M>;
393
+ };
394
+ type RequiredUpdateManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'updateMany', D, UM>, 'data' | 'where'> & {
395
+ data: TypedDataShape<TM, M>;
396
+ where: TypedWhere<TM, M>;
397
+ };
398
+ type RequiredUpdateManyAndReturnShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'updateManyAndReturn', D, UM>, 'data' | 'where'> & {
399
+ data: TypedDataShape<TM, M>;
400
+ where: TypedWhere<TM, M>;
401
+ };
402
+ type RequiredDeleteManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'deleteMany', D, UM>, 'where'> & {
403
+ where: TypedWhere<TM, M>;
371
404
  };
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>;
405
+ 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
406
  type TypedGuardShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth = 1, UM extends UniqueMapConst = {}> = Partial<TypedShapeProps<TM, M, D, UM>>;
374
407
  type ShapeFn<S, TCtx> = (ctx: TCtx) => S;
375
408
  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;
@@ -201,7 +191,6 @@ declare const OPERATION_SHAPE_KEYS: {
201
191
  readonly findFirstOrThrow: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
202
192
  readonly findUnique: readonly ["where", "include", "select"];
203
193
  readonly findUniqueOrThrow: readonly ["where", "include", "select"];
204
- readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
205
194
  readonly count: readonly ["where", "select", "cursor", "orderBy", "skip", "take"];
206
195
  readonly aggregate: readonly ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
207
196
  readonly groupBy: readonly ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"];
@@ -248,9 +237,10 @@ type RelationFields<TM extends TypeMapConst, M extends keyof TM> = {
248
237
  type ListRelationFields<TM extends TypeMapConst, M extends keyof TM> = {
249
238
  [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? TM[M][K]['isList'] extends true ? K : never : never;
250
239
  }[keyof TM[M]] & string;
251
- type WritableFields<TM extends TypeMapConst, M extends keyof TM> = {
240
+ type WritableScalarFields<TM extends TypeMapConst, M extends keyof TM> = {
252
241
  [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['isUpdatedAt'] extends true ? never : K;
253
242
  }[keyof TM[M]] & string;
243
+ type WritableFields<TM extends TypeMapConst, M extends keyof TM> = WritableScalarFields<TM, M> | RelationFields<TM, M>;
254
244
  type UniqueFields<TM extends TypeMapConst, M extends keyof TM> = {
255
245
  [K in keyof TM[M]]: TM[M][K]['isUnique'] extends true ? K : TM[M][K]['isId'] extends true ? K : never;
256
246
  }[keyof TM[M]] & string;
@@ -333,6 +323,23 @@ type TypedInclude<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDe
333
323
  };
334
324
  type TypedCountSelect<TM extends TypeMapConst, M extends keyof TM> = Partial<Record<ScalarFields<TM, M> | '_all', true>>;
335
325
  type TypedCountField<TM extends TypeMapConst, M extends keyof TM> = true | Partial<Record<ScalarFields<TM, M> | '_all', true>>;
326
+ interface TypedRelationWriteConfig {
327
+ connect?: unknown;
328
+ connectOrCreate?: unknown;
329
+ create?: unknown;
330
+ createMany?: unknown;
331
+ disconnect?: unknown;
332
+ delete?: unknown;
333
+ set?: unknown;
334
+ update?: unknown;
335
+ updateMany?: unknown;
336
+ upsert?: unknown;
337
+ deleteMany?: unknown;
338
+ }
339
+ type WritableFieldValue<TM extends TypeMapConst, M extends keyof TM, K extends keyof TM[M]> = TM[M][K]['isRelation'] extends true ? TypedRelationWriteConfig : unknown;
340
+ type TypedDataShape<TM extends TypeMapConst, M extends keyof TM> = Partial<{
341
+ [K in WritableFields<TM, M>]: WritableFieldValue<TM, M, K>;
342
+ }>;
336
343
  type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst = {}> = {
337
344
  where: TypedWhere<TM, M>;
338
345
  select: TypedProjection<TM, M, D, UM>;
@@ -352,9 +359,9 @@ type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends Shap
352
359
  _sum: Partial<Record<NumericFields<TM, M>, true>>;
353
360
  _min: Partial<Record<ComparableFields<TM, M>, true>>;
354
361
  _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>>;
362
+ data: TypedDataShape<TM, M>;
363
+ create: TypedDataShape<TM, M>;
364
+ update: TypedDataShape<TM, M>;
358
365
  };
359
366
  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
367
  type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
@@ -363,13 +370,39 @@ type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
363
370
  type CountShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'count', D, UM>, 'select'> & {
364
371
  select?: TypedCountSelect<TM, M>;
365
372
  };
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>;
373
+ 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'> & {
374
+ where: TypedUniqueWhere<TM, M, UM>;
375
+ };
376
+ type RequiredUpdateShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'update', D, UM>, 'where' | 'data'> & {
377
+ where: TypedUniqueWhere<TM, M, UM>;
378
+ data: TypedDataShape<TM, M>;
368
379
  };
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'> & {
380
+ 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'> & {
370
381
  where: TypedUniqueWhere<TM, M, UM>;
382
+ create: TypedDataShape<TM, M>;
383
+ update: TypedDataShape<TM, M>;
384
+ };
385
+ type RequiredCreateShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'create', D, UM>, 'data'> & {
386
+ data: TypedDataShape<TM, M>;
387
+ };
388
+ type RequiredCreateManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'createMany', D, UM>, 'data'> & {
389
+ data: TypedDataShape<TM, M>;
390
+ };
391
+ type RequiredCreateManyAndReturnShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'createManyAndReturn', D, UM>, 'data'> & {
392
+ data: TypedDataShape<TM, M>;
393
+ };
394
+ type RequiredUpdateManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'updateMany', D, UM>, 'data' | 'where'> & {
395
+ data: TypedDataShape<TM, M>;
396
+ where: TypedWhere<TM, M>;
397
+ };
398
+ type RequiredUpdateManyAndReturnShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'updateManyAndReturn', D, UM>, 'data' | 'where'> & {
399
+ data: TypedDataShape<TM, M>;
400
+ where: TypedWhere<TM, M>;
401
+ };
402
+ type RequiredDeleteManyShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth, UM extends UniqueMapConst> = Omit<BaseOperationShape<TM, M, 'deleteMany', D, UM>, 'where'> & {
403
+ where: TypedWhere<TM, M>;
371
404
  };
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>;
405
+ 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
406
  type TypedGuardShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth = 1, UM extends UniqueMapConst = {}> = Partial<TypedShapeProps<TM, M, D, UM>>;
374
407
  type ShapeFn<S, TCtx> = (ctx: TCtx) => S;
375
408
  type ShapeOrFn<S, TCtx> = S | ShapeFn<S, TCtx>;