prisma-guard 1.21.1 → 1.22.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.
@@ -95,7 +95,7 @@ interface NestedSelectArgs {
95
95
  };
96
96
  skip?: true;
97
97
  }
98
- type ShapeOrFn<TCtx = unknown> = ShapeConfig | ((ctx: TCtx) => ShapeConfig);
98
+ type ShapeOrFn$1<TCtx = unknown> = ShapeConfig | ((ctx: TCtx) => ShapeConfig);
99
99
  interface ScopeEntry {
100
100
  readonly fk: string;
101
101
  readonly root: string;
@@ -158,7 +158,7 @@ declare function createGuard<TModels extends TypeMap = TypeMap, TRoots extends s
158
158
  }): {
159
159
  input: (model: Extract<keyof TModels, string>, opts: InputOpts) => InputSchema;
160
160
  model: (model: Extract<keyof TModels, string>, opts: ModelOpts) => zod.ZodObject<any, zod_v4_core.$strip>;
161
- query: <TCtx = unknown>(model: Extract<keyof TModels, string>, method: QueryMethod, config_: ShapeOrFn<TCtx> | Record<string, ShapeOrFn<TCtx>>) => QuerySchema<TCtx>;
161
+ query: <TCtx = unknown>(model: Extract<keyof TModels, string>, method: QueryMethod, config_: ShapeOrFn$1<TCtx> | Record<string, ShapeOrFn$1<TCtx>>) => QuerySchema<TCtx>;
162
162
  extension: <TCtx extends Record<string, unknown> = Record<string, unknown>>(contextFn?: () => TCtx) => {
163
163
  name: string;
164
164
  model: TModelExt;
@@ -191,4 +191,138 @@ declare function unsupported(): {
191
191
  __brand: 'unsupported';
192
192
  };
193
193
 
194
- export { CallerError, type EnumMap, type FieldMeta, type GuardConfig, type GuardGeneratedConfig, type GuardInput, type GuardLogger, type GuardShape, type GuardShapeOrFn, type GuardedModel, type InputOpts, type InputSchema, type MissingScopeContextMode, type ModelOpts, type MutationMethod, type NestedIncludeArgs, type NestedSelectArgs, PolicyError, type QueryMethod, type QuerySchema, type ScopeEntry, type ScopeMap, type ShapeConfig, ShapeError, type ShapeOrFn, type TypeMap, type UniqueConstraint, type UniqueMap, type ZodChains, type ZodDefaults, createGuard, force, unsupported };
194
+ declare const OPERATION_SHAPE_KEYS: {
195
+ readonly findMany: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
196
+ readonly findFirst: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
197
+ readonly findFirstOrThrow: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
198
+ readonly findUnique: readonly ["where", "include", "select"];
199
+ readonly findUniqueOrThrow: readonly ["where", "include", "select"];
200
+ readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
201
+ readonly count: readonly ["where", "select", "cursor", "orderBy", "skip", "take"];
202
+ readonly aggregate: readonly ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
203
+ readonly groupBy: readonly ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"];
204
+ readonly create: readonly ["data", "select", "include"];
205
+ readonly createMany: readonly ["data"];
206
+ readonly createManyAndReturn: readonly ["data", "select", "include"];
207
+ readonly update: readonly ["data", "where", "select", "include"];
208
+ readonly updateMany: readonly ["data", "where"];
209
+ readonly updateManyAndReturn: readonly ["data", "where", "select", "include"];
210
+ readonly upsert: readonly ["where", "create", "update", "select", "include"];
211
+ readonly delete: readonly ["where", "select", "include"];
212
+ readonly deleteMany: readonly ["where"];
213
+ };
214
+ type OperationName = keyof typeof OPERATION_SHAPE_KEYS;
215
+ type OperationShapeKey<O extends OperationName> = (typeof OPERATION_SHAPE_KEYS)[O][number];
216
+
217
+ interface FieldMetaConst {
218
+ readonly type: string;
219
+ readonly isList: boolean;
220
+ readonly isRequired: boolean;
221
+ readonly isId: boolean;
222
+ readonly isRelation: boolean;
223
+ readonly hasDefault: boolean;
224
+ readonly isUpdatedAt: boolean;
225
+ readonly isEnum?: boolean;
226
+ readonly isUnique?: boolean;
227
+ readonly isUnsupported?: boolean;
228
+ }
229
+ type TypeMapConst = Record<string, Record<string, FieldMetaConst>>;
230
+ type ShapeDepth = 0 | 1 | 2 | 3;
231
+ type DecDepth<D extends ShapeDepth> = D extends 3 ? 2 : D extends 2 ? 1 : D extends 1 ? 0 : 0;
232
+ type AllFields<TM extends TypeMapConst, M extends keyof TM> = keyof TM[M] & string;
233
+ type ScalarFields<TM extends TypeMapConst, M extends keyof TM> = {
234
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : K;
235
+ }[keyof TM[M]] & string;
236
+ type RelationFields<TM extends TypeMapConst, M extends keyof TM> = {
237
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? K : never;
238
+ }[keyof TM[M]] & string;
239
+ type WritableFields<TM extends TypeMapConst, M extends keyof TM> = {
240
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['isUpdatedAt'] extends true ? never : K;
241
+ }[keyof TM[M]] & string;
242
+ type UniqueFields<TM extends TypeMapConst, M extends keyof TM> = {
243
+ [K in keyof TM[M]]: TM[M][K]['isUnique'] extends true ? K : TM[M][K]['isId'] extends true ? K : never;
244
+ }[keyof TM[M]] & string;
245
+ type NumericScalarType = 'Int' | 'BigInt' | 'Float' | 'Decimal';
246
+ type ComparableScalarType = NumericScalarType | 'String' | 'DateTime';
247
+ type NumericFields<TM extends TypeMapConst, M extends keyof TM> = {
248
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['type'] extends NumericScalarType ? K : never;
249
+ }[keyof TM[M]] & string;
250
+ type ComparableFields<TM extends TypeMapConst, M extends keyof TM> = {
251
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['type'] extends ComparableScalarType ? K : never;
252
+ }[keyof TM[M]] & string;
253
+ type RelTarget<TM extends TypeMapConst, M extends keyof TM, K extends keyof TM[M]> = TM[M][K]['type'] extends string ? Extract<keyof TM, TM[M][K]['type']> : never;
254
+ type LooseNestedArgs = {
255
+ select?: Record<string, unknown>;
256
+ include?: Record<string, unknown>;
257
+ where?: Record<string, unknown>;
258
+ orderBy?: Record<string, unknown>;
259
+ cursor?: Record<string, unknown>;
260
+ take?: number | {
261
+ max: number;
262
+ default?: number;
263
+ };
264
+ skip?: true;
265
+ };
266
+ type TypedWhere<TM extends TypeMapConst, M extends keyof TM> = Partial<Record<AllFields<TM, M> | 'AND' | 'OR' | 'NOT', unknown>>;
267
+ type TypedNestedRelArgs<TM extends TypeMapConst, T, D extends ShapeDepth> = T extends keyof TM ? D extends 0 ? LooseNestedArgs : {
268
+ select?: TypedProjection<TM, T, DecDepth<D>>;
269
+ include?: TypedInclude<TM, T, DecDepth<D>>;
270
+ where?: TypedWhere<TM, T>;
271
+ orderBy?: true | Partial<Record<AllFields<TM, T>, unknown>>;
272
+ cursor?: Partial<Record<UniqueFields<TM, T>, true>>;
273
+ take?: number | {
274
+ max: number;
275
+ default?: number;
276
+ };
277
+ skip?: true;
278
+ } : LooseNestedArgs;
279
+ type TypedProjection<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth> = {
280
+ [K in AllFields<TM, M>]?: K extends RelationFields<TM, M> ? true | TypedNestedRelArgs<TM, RelTarget<TM, M, K>, D> : true;
281
+ };
282
+ type TypedInclude<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth> = {
283
+ [K in RelationFields<TM, M>]?: true | TypedNestedRelArgs<TM, RelTarget<TM, M, K>, D>;
284
+ };
285
+ type TypedCountSelect<TM extends TypeMapConst, M extends keyof TM> = Partial<Record<ScalarFields<TM, M> | '_all', true>>;
286
+ type TypedCountField<TM extends TypeMapConst, M extends keyof TM> = true | Partial<Record<ScalarFields<TM, M> | '_all', true>>;
287
+ type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth> = {
288
+ where: TypedWhere<TM, M>;
289
+ select: TypedProjection<TM, M, D>;
290
+ include: TypedInclude<TM, M, D>;
291
+ orderBy: true | Partial<Record<AllFields<TM, M>, unknown>>;
292
+ cursor: Partial<Record<UniqueFields<TM, M>, true>>;
293
+ take: number | {
294
+ max: number;
295
+ default?: number;
296
+ };
297
+ skip: true;
298
+ distinct: ScalarFields<TM, M>[];
299
+ by: ScalarFields<TM, M>[];
300
+ having: Partial<Record<ScalarFields<TM, M>, unknown>>;
301
+ _count: TypedCountField<TM, M>;
302
+ _avg: Partial<Record<NumericFields<TM, M>, true>>;
303
+ _sum: Partial<Record<NumericFields<TM, M>, true>>;
304
+ _min: Partial<Record<ComparableFields<TM, M>, true>>;
305
+ _max: Partial<Record<ComparableFields<TM, M>, true>>;
306
+ data: Partial<Record<WritableFields<TM, M>, unknown>>;
307
+ create: Partial<Record<WritableFields<TM, M>, unknown>>;
308
+ update: Partial<Record<WritableFields<TM, M>, unknown>>;
309
+ };
310
+ type BaseOperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth> = Partial<Pick<TypedShapeProps<TM, M, D>, Extract<OperationShapeKey<O>, keyof TypedShapeProps<TM, M, D>>>>;
311
+ type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
312
+ [P in K]-?: NonNullable<T[P]>;
313
+ };
314
+ type CountShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth> = Omit<BaseOperationShape<TM, M, 'count', D>, 'select'> & {
315
+ select?: TypedCountSelect<TM, M>;
316
+ };
317
+ type OperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth = 1> = O extends 'findUnique' ? RequireKeys<BaseOperationShape<TM, M, 'findUnique', D>, 'where'> : O extends 'findUniqueOrThrow' ? RequireKeys<BaseOperationShape<TM, M, 'findUniqueOrThrow', D>, 'where'> : O extends 'groupBy' ? RequireKeys<BaseOperationShape<TM, M, 'groupBy', D>, 'by'> : O extends 'count' ? CountShape<TM, M, D> : BaseOperationShape<TM, M, O, D>;
318
+ type TypedGuardShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth = 1> = Partial<TypedShapeProps<TM, M, D>>;
319
+ type ShapeFn<S, TCtx> = (ctx: TCtx) => S;
320
+ type ShapeOrFn<S, TCtx> = S | ShapeFn<S, TCtx>;
321
+ declare const namedShapeBrand: unique symbol;
322
+ type NamedShapeMap<S, TCtx> = Record<string, ShapeOrFn<S, TCtx>> & {
323
+ readonly [namedShapeBrand]: true;
324
+ };
325
+ declare function namedShapes<S, TCtx = unknown>(shapes: Record<string, ShapeOrFn<S, TCtx>>): NamedShapeMap<S, TCtx>;
326
+ type ShapeInput<S, TCtx = unknown> = ShapeOrFn<S, TCtx> | NamedShapeMap<S, TCtx>;
327
+
328
+ export { CallerError, type ComparableFields, type EnumMap, type FieldMeta, type FieldMetaConst, type GuardConfig, type GuardGeneratedConfig, type GuardInput, type GuardLogger, type GuardShape, type GuardShapeOrFn, type GuardedModel, type InputOpts, type InputSchema, type MissingScopeContextMode, type ModelOpts, type MutationMethod, type NamedShapeMap, type NestedIncludeArgs, type NestedSelectArgs, type NumericFields, type OperationName, type OperationShape, PolicyError, type QueryMethod, type QuerySchema, type ScopeEntry, type ScopeMap, type ShapeConfig, type ShapeDepth, ShapeError, type ShapeInput, type ShapeOrFn$1 as ShapeOrFn, type TypeMap, type TypeMapConst, type TypedCountSelect, type TypedGuardShape, type TypedInclude, type TypedProjection, type TypedShapeProps, type TypedWhere, type UniqueConstraint, type UniqueMap, type ZodChains, type ZodDefaults, createGuard, force, namedShapes, unsupported };
@@ -95,7 +95,7 @@ interface NestedSelectArgs {
95
95
  };
96
96
  skip?: true;
97
97
  }
98
- type ShapeOrFn<TCtx = unknown> = ShapeConfig | ((ctx: TCtx) => ShapeConfig);
98
+ type ShapeOrFn$1<TCtx = unknown> = ShapeConfig | ((ctx: TCtx) => ShapeConfig);
99
99
  interface ScopeEntry {
100
100
  readonly fk: string;
101
101
  readonly root: string;
@@ -158,7 +158,7 @@ declare function createGuard<TModels extends TypeMap = TypeMap, TRoots extends s
158
158
  }): {
159
159
  input: (model: Extract<keyof TModels, string>, opts: InputOpts) => InputSchema;
160
160
  model: (model: Extract<keyof TModels, string>, opts: ModelOpts) => zod.ZodObject<any, zod_v4_core.$strip>;
161
- query: <TCtx = unknown>(model: Extract<keyof TModels, string>, method: QueryMethod, config_: ShapeOrFn<TCtx> | Record<string, ShapeOrFn<TCtx>>) => QuerySchema<TCtx>;
161
+ query: <TCtx = unknown>(model: Extract<keyof TModels, string>, method: QueryMethod, config_: ShapeOrFn$1<TCtx> | Record<string, ShapeOrFn$1<TCtx>>) => QuerySchema<TCtx>;
162
162
  extension: <TCtx extends Record<string, unknown> = Record<string, unknown>>(contextFn?: () => TCtx) => {
163
163
  name: string;
164
164
  model: TModelExt;
@@ -191,4 +191,138 @@ declare function unsupported(): {
191
191
  __brand: 'unsupported';
192
192
  };
193
193
 
194
- export { CallerError, type EnumMap, type FieldMeta, type GuardConfig, type GuardGeneratedConfig, type GuardInput, type GuardLogger, type GuardShape, type GuardShapeOrFn, type GuardedModel, type InputOpts, type InputSchema, type MissingScopeContextMode, type ModelOpts, type MutationMethod, type NestedIncludeArgs, type NestedSelectArgs, PolicyError, type QueryMethod, type QuerySchema, type ScopeEntry, type ScopeMap, type ShapeConfig, ShapeError, type ShapeOrFn, type TypeMap, type UniqueConstraint, type UniqueMap, type ZodChains, type ZodDefaults, createGuard, force, unsupported };
194
+ declare const OPERATION_SHAPE_KEYS: {
195
+ readonly findMany: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
196
+ readonly findFirst: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
197
+ readonly findFirstOrThrow: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
198
+ readonly findUnique: readonly ["where", "include", "select"];
199
+ readonly findUniqueOrThrow: readonly ["where", "include", "select"];
200
+ readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
201
+ readonly count: readonly ["where", "select", "cursor", "orderBy", "skip", "take"];
202
+ readonly aggregate: readonly ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
203
+ readonly groupBy: readonly ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"];
204
+ readonly create: readonly ["data", "select", "include"];
205
+ readonly createMany: readonly ["data"];
206
+ readonly createManyAndReturn: readonly ["data", "select", "include"];
207
+ readonly update: readonly ["data", "where", "select", "include"];
208
+ readonly updateMany: readonly ["data", "where"];
209
+ readonly updateManyAndReturn: readonly ["data", "where", "select", "include"];
210
+ readonly upsert: readonly ["where", "create", "update", "select", "include"];
211
+ readonly delete: readonly ["where", "select", "include"];
212
+ readonly deleteMany: readonly ["where"];
213
+ };
214
+ type OperationName = keyof typeof OPERATION_SHAPE_KEYS;
215
+ type OperationShapeKey<O extends OperationName> = (typeof OPERATION_SHAPE_KEYS)[O][number];
216
+
217
+ interface FieldMetaConst {
218
+ readonly type: string;
219
+ readonly isList: boolean;
220
+ readonly isRequired: boolean;
221
+ readonly isId: boolean;
222
+ readonly isRelation: boolean;
223
+ readonly hasDefault: boolean;
224
+ readonly isUpdatedAt: boolean;
225
+ readonly isEnum?: boolean;
226
+ readonly isUnique?: boolean;
227
+ readonly isUnsupported?: boolean;
228
+ }
229
+ type TypeMapConst = Record<string, Record<string, FieldMetaConst>>;
230
+ type ShapeDepth = 0 | 1 | 2 | 3;
231
+ type DecDepth<D extends ShapeDepth> = D extends 3 ? 2 : D extends 2 ? 1 : D extends 1 ? 0 : 0;
232
+ type AllFields<TM extends TypeMapConst, M extends keyof TM> = keyof TM[M] & string;
233
+ type ScalarFields<TM extends TypeMapConst, M extends keyof TM> = {
234
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : K;
235
+ }[keyof TM[M]] & string;
236
+ type RelationFields<TM extends TypeMapConst, M extends keyof TM> = {
237
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? K : never;
238
+ }[keyof TM[M]] & string;
239
+ type WritableFields<TM extends TypeMapConst, M extends keyof TM> = {
240
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['isUpdatedAt'] extends true ? never : K;
241
+ }[keyof TM[M]] & string;
242
+ type UniqueFields<TM extends TypeMapConst, M extends keyof TM> = {
243
+ [K in keyof TM[M]]: TM[M][K]['isUnique'] extends true ? K : TM[M][K]['isId'] extends true ? K : never;
244
+ }[keyof TM[M]] & string;
245
+ type NumericScalarType = 'Int' | 'BigInt' | 'Float' | 'Decimal';
246
+ type ComparableScalarType = NumericScalarType | 'String' | 'DateTime';
247
+ type NumericFields<TM extends TypeMapConst, M extends keyof TM> = {
248
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['type'] extends NumericScalarType ? K : never;
249
+ }[keyof TM[M]] & string;
250
+ type ComparableFields<TM extends TypeMapConst, M extends keyof TM> = {
251
+ [K in keyof TM[M]]: TM[M][K]['isRelation'] extends true ? never : TM[M][K]['type'] extends ComparableScalarType ? K : never;
252
+ }[keyof TM[M]] & string;
253
+ type RelTarget<TM extends TypeMapConst, M extends keyof TM, K extends keyof TM[M]> = TM[M][K]['type'] extends string ? Extract<keyof TM, TM[M][K]['type']> : never;
254
+ type LooseNestedArgs = {
255
+ select?: Record<string, unknown>;
256
+ include?: Record<string, unknown>;
257
+ where?: Record<string, unknown>;
258
+ orderBy?: Record<string, unknown>;
259
+ cursor?: Record<string, unknown>;
260
+ take?: number | {
261
+ max: number;
262
+ default?: number;
263
+ };
264
+ skip?: true;
265
+ };
266
+ type TypedWhere<TM extends TypeMapConst, M extends keyof TM> = Partial<Record<AllFields<TM, M> | 'AND' | 'OR' | 'NOT', unknown>>;
267
+ type TypedNestedRelArgs<TM extends TypeMapConst, T, D extends ShapeDepth> = T extends keyof TM ? D extends 0 ? LooseNestedArgs : {
268
+ select?: TypedProjection<TM, T, DecDepth<D>>;
269
+ include?: TypedInclude<TM, T, DecDepth<D>>;
270
+ where?: TypedWhere<TM, T>;
271
+ orderBy?: true | Partial<Record<AllFields<TM, T>, unknown>>;
272
+ cursor?: Partial<Record<UniqueFields<TM, T>, true>>;
273
+ take?: number | {
274
+ max: number;
275
+ default?: number;
276
+ };
277
+ skip?: true;
278
+ } : LooseNestedArgs;
279
+ type TypedProjection<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth> = {
280
+ [K in AllFields<TM, M>]?: K extends RelationFields<TM, M> ? true | TypedNestedRelArgs<TM, RelTarget<TM, M, K>, D> : true;
281
+ };
282
+ type TypedInclude<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth> = {
283
+ [K in RelationFields<TM, M>]?: true | TypedNestedRelArgs<TM, RelTarget<TM, M, K>, D>;
284
+ };
285
+ type TypedCountSelect<TM extends TypeMapConst, M extends keyof TM> = Partial<Record<ScalarFields<TM, M> | '_all', true>>;
286
+ type TypedCountField<TM extends TypeMapConst, M extends keyof TM> = true | Partial<Record<ScalarFields<TM, M> | '_all', true>>;
287
+ type TypedShapeProps<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth> = {
288
+ where: TypedWhere<TM, M>;
289
+ select: TypedProjection<TM, M, D>;
290
+ include: TypedInclude<TM, M, D>;
291
+ orderBy: true | Partial<Record<AllFields<TM, M>, unknown>>;
292
+ cursor: Partial<Record<UniqueFields<TM, M>, true>>;
293
+ take: number | {
294
+ max: number;
295
+ default?: number;
296
+ };
297
+ skip: true;
298
+ distinct: ScalarFields<TM, M>[];
299
+ by: ScalarFields<TM, M>[];
300
+ having: Partial<Record<ScalarFields<TM, M>, unknown>>;
301
+ _count: TypedCountField<TM, M>;
302
+ _avg: Partial<Record<NumericFields<TM, M>, true>>;
303
+ _sum: Partial<Record<NumericFields<TM, M>, true>>;
304
+ _min: Partial<Record<ComparableFields<TM, M>, true>>;
305
+ _max: Partial<Record<ComparableFields<TM, M>, true>>;
306
+ data: Partial<Record<WritableFields<TM, M>, unknown>>;
307
+ create: Partial<Record<WritableFields<TM, M>, unknown>>;
308
+ update: Partial<Record<WritableFields<TM, M>, unknown>>;
309
+ };
310
+ type BaseOperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth> = Partial<Pick<TypedShapeProps<TM, M, D>, Extract<OperationShapeKey<O>, keyof TypedShapeProps<TM, M, D>>>>;
311
+ type RequireKeys<T, K extends keyof T> = Omit<T, K> & {
312
+ [P in K]-?: NonNullable<T[P]>;
313
+ };
314
+ type CountShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth> = Omit<BaseOperationShape<TM, M, 'count', D>, 'select'> & {
315
+ select?: TypedCountSelect<TM, M>;
316
+ };
317
+ type OperationShape<TM extends TypeMapConst, M extends keyof TM, O extends OperationName, D extends ShapeDepth = 1> = O extends 'findUnique' ? RequireKeys<BaseOperationShape<TM, M, 'findUnique', D>, 'where'> : O extends 'findUniqueOrThrow' ? RequireKeys<BaseOperationShape<TM, M, 'findUniqueOrThrow', D>, 'where'> : O extends 'groupBy' ? RequireKeys<BaseOperationShape<TM, M, 'groupBy', D>, 'by'> : O extends 'count' ? CountShape<TM, M, D> : BaseOperationShape<TM, M, O, D>;
318
+ type TypedGuardShape<TM extends TypeMapConst, M extends keyof TM, D extends ShapeDepth = 1> = Partial<TypedShapeProps<TM, M, D>>;
319
+ type ShapeFn<S, TCtx> = (ctx: TCtx) => S;
320
+ type ShapeOrFn<S, TCtx> = S | ShapeFn<S, TCtx>;
321
+ declare const namedShapeBrand: unique symbol;
322
+ type NamedShapeMap<S, TCtx> = Record<string, ShapeOrFn<S, TCtx>> & {
323
+ readonly [namedShapeBrand]: true;
324
+ };
325
+ declare function namedShapes<S, TCtx = unknown>(shapes: Record<string, ShapeOrFn<S, TCtx>>): NamedShapeMap<S, TCtx>;
326
+ type ShapeInput<S, TCtx = unknown> = ShapeOrFn<S, TCtx> | NamedShapeMap<S, TCtx>;
327
+
328
+ export { CallerError, type ComparableFields, type EnumMap, type FieldMeta, type FieldMetaConst, type GuardConfig, type GuardGeneratedConfig, type GuardInput, type GuardLogger, type GuardShape, type GuardShapeOrFn, type GuardedModel, type InputOpts, type InputSchema, type MissingScopeContextMode, type ModelOpts, type MutationMethod, type NamedShapeMap, type NestedIncludeArgs, type NestedSelectArgs, type NumericFields, type OperationName, type OperationShape, PolicyError, type QueryMethod, type QuerySchema, type ScopeEntry, type ScopeMap, type ShapeConfig, type ShapeDepth, ShapeError, type ShapeInput, type ShapeOrFn$1 as ShapeOrFn, type TypeMap, type TypeMapConst, type TypedCountSelect, type TypedGuardShape, type TypedInclude, type TypedProjection, type TypedShapeProps, type TypedWhere, type UniqueConstraint, type UniqueMap, type ZodChains, type ZodDefaults, createGuard, force, namedShapes, unsupported };
@@ -793,7 +793,7 @@ function createSchemaBuilder(typeMap, zodChains, enumMap, scalarBase, zodDefault
793
793
  import { z as z7 } from "zod";
794
794
 
795
795
  // src/shared/constants.ts
796
- var SHAPE_CONFIG_KEYS = /* @__PURE__ */ new Set([
796
+ var SHAPE_CONFIG_KEY_LIST = [
797
797
  "where",
798
798
  "include",
799
799
  "select",
@@ -809,13 +809,15 @@ var SHAPE_CONFIG_KEYS = /* @__PURE__ */ new Set([
809
809
  "_min",
810
810
  "_max",
811
811
  "by"
812
- ]);
813
- var GUARD_SHAPE_KEYS = /* @__PURE__ */ new Set([
812
+ ];
813
+ var SHAPE_CONFIG_KEYS = new Set(SHAPE_CONFIG_KEY_LIST);
814
+ var GUARD_SHAPE_KEY_LIST = [
814
815
  "data",
815
816
  "create",
816
817
  "update",
817
- ...SHAPE_CONFIG_KEYS
818
- ]);
818
+ ...SHAPE_CONFIG_KEY_LIST
819
+ ];
820
+ var GUARD_SHAPE_KEYS = new Set(GUARD_SHAPE_KEY_LIST);
819
821
  var COMBINATOR_KEYS = /* @__PURE__ */ new Set(["AND", "OR", "NOT"]);
820
822
  var TO_MANY_RELATION_OPS = /* @__PURE__ */ new Set(["some", "every", "none"]);
821
823
  var TO_ONE_RELATION_OPS = /* @__PURE__ */ new Set(["is", "isNot"]);
@@ -2453,67 +2455,51 @@ function createProjectionBuilder(typeMap, enumMap, deps) {
2453
2455
  return { buildIncludeSchema, buildSelectSchema, buildIncludeCountSchema };
2454
2456
  }
2455
2457
 
2456
- // src/runtime/query-builder.ts
2457
- var METHOD_ALLOWED_ARGS = {
2458
- findMany: /* @__PURE__ */ new Set([
2459
- "where",
2460
- "include",
2461
- "select",
2462
- "orderBy",
2463
- "cursor",
2464
- "take",
2465
- "skip",
2466
- "distinct"
2467
- ]),
2468
- findFirst: /* @__PURE__ */ new Set([
2469
- "where",
2470
- "include",
2471
- "select",
2472
- "orderBy",
2473
- "cursor",
2474
- "take",
2475
- "skip",
2476
- "distinct"
2477
- ]),
2478
- findFirstOrThrow: /* @__PURE__ */ new Set([
2479
- "where",
2480
- "include",
2481
- "select",
2482
- "orderBy",
2483
- "cursor",
2484
- "take",
2485
- "skip",
2486
- "distinct"
2487
- ]),
2488
- findUnique: /* @__PURE__ */ new Set(["where", "include", "select"]),
2489
- findUniqueOrThrow: /* @__PURE__ */ new Set(["where", "include", "select"]),
2490
- count: /* @__PURE__ */ new Set(["where", "select", "cursor", "orderBy", "skip", "take"]),
2491
- aggregate: /* @__PURE__ */ new Set([
2492
- "where",
2493
- "orderBy",
2494
- "cursor",
2495
- "take",
2496
- "skip",
2497
- "_count",
2498
- "_avg",
2499
- "_sum",
2500
- "_min",
2501
- "_max"
2502
- ]),
2503
- groupBy: /* @__PURE__ */ new Set([
2504
- "where",
2505
- "by",
2506
- "having",
2507
- "_count",
2508
- "_avg",
2509
- "_sum",
2510
- "_min",
2511
- "_max",
2512
- "orderBy",
2513
- "take",
2514
- "skip"
2515
- ])
2458
+ // src/shared/operation-shape-keys.ts
2459
+ var OPERATION_SHAPE_KEYS = {
2460
+ findMany: ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"],
2461
+ findFirst: ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"],
2462
+ findFirstOrThrow: ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"],
2463
+ findUnique: ["where", "include", "select"],
2464
+ findUniqueOrThrow: ["where", "include", "select"],
2465
+ findManyPaginated: ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"],
2466
+ count: ["where", "select", "cursor", "orderBy", "skip", "take"],
2467
+ aggregate: ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"],
2468
+ groupBy: ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"],
2469
+ create: ["data", "select", "include"],
2470
+ createMany: ["data"],
2471
+ createManyAndReturn: ["data", "select", "include"],
2472
+ update: ["data", "where", "select", "include"],
2473
+ updateMany: ["data", "where"],
2474
+ updateManyAndReturn: ["data", "where", "select", "include"],
2475
+ upsert: ["where", "create", "update", "select", "include"],
2476
+ delete: ["where", "select", "include"],
2477
+ deleteMany: ["where"]
2478
+ };
2479
+ var READ_METHOD_ALLOWED_ARGS = {
2480
+ findMany: new Set(OPERATION_SHAPE_KEYS.findMany),
2481
+ findFirst: new Set(OPERATION_SHAPE_KEYS.findFirst),
2482
+ findFirstOrThrow: new Set(OPERATION_SHAPE_KEYS.findFirstOrThrow),
2483
+ findUnique: new Set(OPERATION_SHAPE_KEYS.findUnique),
2484
+ findUniqueOrThrow: new Set(OPERATION_SHAPE_KEYS.findUniqueOrThrow),
2485
+ count: new Set(OPERATION_SHAPE_KEYS.count),
2486
+ aggregate: new Set(OPERATION_SHAPE_KEYS.aggregate),
2487
+ groupBy: new Set(OPERATION_SHAPE_KEYS.groupBy)
2516
2488
  };
2489
+ var MUTATION_SHAPE_KEYS = {
2490
+ create: new Set(OPERATION_SHAPE_KEYS.create),
2491
+ createMany: new Set(OPERATION_SHAPE_KEYS.createMany),
2492
+ createManyAndReturn: new Set(OPERATION_SHAPE_KEYS.createManyAndReturn),
2493
+ update: new Set(OPERATION_SHAPE_KEYS.update),
2494
+ updateMany: new Set(OPERATION_SHAPE_KEYS.updateMany),
2495
+ updateManyAndReturn: new Set(OPERATION_SHAPE_KEYS.updateManyAndReturn),
2496
+ upsert: new Set(OPERATION_SHAPE_KEYS.upsert),
2497
+ delete: new Set(OPERATION_SHAPE_KEYS.delete),
2498
+ deleteMany: new Set(OPERATION_SHAPE_KEYS.deleteMany)
2499
+ };
2500
+
2501
+ // src/runtime/query-builder.ts
2502
+ var METHOD_ALLOWED_ARGS = READ_METHOD_ALLOWED_ARGS;
2517
2503
  var UNIQUE_WHERE_METHODS = /* @__PURE__ */ new Set([
2518
2504
  "findUnique",
2519
2505
  "findUniqueOrThrow"
@@ -5261,12 +5247,18 @@ function createGuard(config) {
5261
5247
  }
5262
5248
  };
5263
5249
  }
5250
+
5251
+ // src/shared/typed-shape.ts
5252
+ function namedShapes(shapes) {
5253
+ return shapes;
5254
+ }
5264
5255
  export {
5265
5256
  CallerError,
5266
5257
  PolicyError,
5267
5258
  ShapeError,
5268
5259
  createGuard,
5269
5260
  force,
5261
+ namedShapes,
5270
5262
  unsupported
5271
5263
  };
5272
5264
  //# sourceMappingURL=index.js.map