prisma-guard 1.28.0 → 1.29.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.
@@ -140,10 +140,19 @@ interface GuardShape extends ShapeConfig {
140
140
  }
141
141
  type GuardShapeOrFn = GuardShape | ((ctx: any) => GuardShape);
142
142
  type GuardInput = GuardShapeOrFn | Record<string, GuardShapeOrFn>;
143
+ interface GuardResolvedShape {
144
+ shape: GuardShape;
145
+ body: Record<string, unknown>;
146
+ effectiveReadBody: Record<string, unknown>;
147
+ matchedKey: string;
148
+ wasDynamic: boolean;
149
+ }
143
150
  type GuardableMethodName = QueryMethod | MutationMethod;
144
151
  type AnyFn = (...args: any[]) => any;
145
152
  type DelegateMethod<TDelegate, K extends PropertyKey> = K extends keyof TDelegate ? TDelegate[K] extends AnyFn ? TDelegate[K] : never : never;
146
153
  type GuardedModel<TDelegate> = {
154
+ resolve(body?: unknown): GuardResolvedShape;
155
+ } & {
147
156
  [K in GuardableMethodName as DelegateMethod<TDelegate, K> extends never ? never : K]: DelegateMethod<TDelegate, K>;
148
157
  };
149
158
 
@@ -187,21 +196,22 @@ declare function unsupported(): {
187
196
 
188
197
  declare const OPERATION_SHAPE_KEYS: {
189
198
  readonly findMany: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
199
+ readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
190
200
  readonly findFirst: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
191
201
  readonly findFirstOrThrow: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
192
202
  readonly findUnique: readonly ["where", "include", "select"];
193
203
  readonly findUniqueOrThrow: readonly ["where", "include", "select"];
194
204
  readonly count: readonly ["where", "select", "cursor", "orderBy", "skip", "take"];
195
205
  readonly aggregate: readonly ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
196
- readonly groupBy: readonly ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"];
197
- readonly create: readonly ["data", "select", "include"];
198
- readonly createMany: readonly ["data"];
199
- readonly createManyAndReturn: readonly ["data", "select", "include"];
200
- readonly update: readonly ["data", "where", "select", "include"];
201
- readonly updateMany: readonly ["data", "where"];
202
- readonly updateManyAndReturn: readonly ["data", "where", "select", "include"];
203
- readonly upsert: readonly ["where", "create", "update", "select", "include"];
204
- readonly delete: readonly ["where", "select", "include"];
206
+ readonly groupBy: readonly ["where", "orderBy", "by", "having", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
207
+ readonly create: readonly ["data", "include", "select"];
208
+ readonly createMany: readonly ["data", "skipDuplicates"];
209
+ readonly createManyAndReturn: readonly ["data", "select", "include", "skipDuplicates"];
210
+ readonly update: readonly ["where", "data", "include", "select"];
211
+ readonly updateMany: readonly ["where", "data"];
212
+ readonly updateManyAndReturn: readonly ["where", "data", "select", "include"];
213
+ readonly upsert: readonly ["where", "create", "update", "include", "select"];
214
+ readonly delete: readonly ["where", "include", "select"];
205
215
  readonly deleteMany: readonly ["where"];
206
216
  };
207
217
  type OperationName = keyof typeof OPERATION_SHAPE_KEYS;
@@ -140,10 +140,19 @@ interface GuardShape extends ShapeConfig {
140
140
  }
141
141
  type GuardShapeOrFn = GuardShape | ((ctx: any) => GuardShape);
142
142
  type GuardInput = GuardShapeOrFn | Record<string, GuardShapeOrFn>;
143
+ interface GuardResolvedShape {
144
+ shape: GuardShape;
145
+ body: Record<string, unknown>;
146
+ effectiveReadBody: Record<string, unknown>;
147
+ matchedKey: string;
148
+ wasDynamic: boolean;
149
+ }
143
150
  type GuardableMethodName = QueryMethod | MutationMethod;
144
151
  type AnyFn = (...args: any[]) => any;
145
152
  type DelegateMethod<TDelegate, K extends PropertyKey> = K extends keyof TDelegate ? TDelegate[K] extends AnyFn ? TDelegate[K] : never : never;
146
153
  type GuardedModel<TDelegate> = {
154
+ resolve(body?: unknown): GuardResolvedShape;
155
+ } & {
147
156
  [K in GuardableMethodName as DelegateMethod<TDelegate, K> extends never ? never : K]: DelegateMethod<TDelegate, K>;
148
157
  };
149
158
 
@@ -187,21 +196,22 @@ declare function unsupported(): {
187
196
 
188
197
  declare const OPERATION_SHAPE_KEYS: {
189
198
  readonly findMany: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
199
+ readonly findManyPaginated: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
190
200
  readonly findFirst: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
191
201
  readonly findFirstOrThrow: readonly ["where", "include", "select", "orderBy", "cursor", "take", "skip", "distinct"];
192
202
  readonly findUnique: readonly ["where", "include", "select"];
193
203
  readonly findUniqueOrThrow: readonly ["where", "include", "select"];
194
204
  readonly count: readonly ["where", "select", "cursor", "orderBy", "skip", "take"];
195
205
  readonly aggregate: readonly ["where", "orderBy", "cursor", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
196
- readonly groupBy: readonly ["where", "by", "having", "_count", "_avg", "_sum", "_min", "_max", "orderBy", "take", "skip"];
197
- readonly create: readonly ["data", "select", "include"];
198
- readonly createMany: readonly ["data"];
199
- readonly createManyAndReturn: readonly ["data", "select", "include"];
200
- readonly update: readonly ["data", "where", "select", "include"];
201
- readonly updateMany: readonly ["data", "where"];
202
- readonly updateManyAndReturn: readonly ["data", "where", "select", "include"];
203
- readonly upsert: readonly ["where", "create", "update", "select", "include"];
204
- readonly delete: readonly ["where", "select", "include"];
206
+ readonly groupBy: readonly ["where", "orderBy", "by", "having", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
207
+ readonly create: readonly ["data", "include", "select"];
208
+ readonly createMany: readonly ["data", "skipDuplicates"];
209
+ readonly createManyAndReturn: readonly ["data", "select", "include", "skipDuplicates"];
210
+ readonly update: readonly ["where", "data", "include", "select"];
211
+ readonly updateMany: readonly ["where", "data"];
212
+ readonly updateManyAndReturn: readonly ["where", "data", "select", "include"];
213
+ readonly upsert: readonly ["where", "create", "update", "include", "select"];
214
+ readonly delete: readonly ["where", "include", "select"];
205
215
  readonly deleteMany: readonly ["where"];
206
216
  };
207
217
  type OperationName = keyof typeof OPERATION_SHAPE_KEYS;