prisma-guard 1.28.1 → 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
 
@@ -197,10 +206,10 @@ declare const OPERATION_SHAPE_KEYS: {
197
206
  readonly groupBy: readonly ["where", "orderBy", "by", "having", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
198
207
  readonly create: readonly ["data", "include", "select"];
199
208
  readonly createMany: readonly ["data", "skipDuplicates"];
200
- readonly createManyAndReturn: readonly ["data", "select", "skipDuplicates"];
209
+ readonly createManyAndReturn: readonly ["data", "select", "include", "skipDuplicates"];
201
210
  readonly update: readonly ["where", "data", "include", "select"];
202
211
  readonly updateMany: readonly ["where", "data"];
203
- readonly updateManyAndReturn: readonly ["where", "data", "select"];
212
+ readonly updateManyAndReturn: readonly ["where", "data", "select", "include"];
204
213
  readonly upsert: readonly ["where", "create", "update", "include", "select"];
205
214
  readonly delete: readonly ["where", "include", "select"];
206
215
  readonly deleteMany: readonly ["where"];
@@ -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
 
@@ -197,10 +206,10 @@ declare const OPERATION_SHAPE_KEYS: {
197
206
  readonly groupBy: readonly ["where", "orderBy", "by", "having", "take", "skip", "_count", "_avg", "_sum", "_min", "_max"];
198
207
  readonly create: readonly ["data", "include", "select"];
199
208
  readonly createMany: readonly ["data", "skipDuplicates"];
200
- readonly createManyAndReturn: readonly ["data", "select", "skipDuplicates"];
209
+ readonly createManyAndReturn: readonly ["data", "select", "include", "skipDuplicates"];
201
210
  readonly update: readonly ["where", "data", "include", "select"];
202
211
  readonly updateMany: readonly ["where", "data"];
203
- readonly updateManyAndReturn: readonly ["where", "data", "select"];
212
+ readonly updateManyAndReturn: readonly ["where", "data", "select", "include"];
204
213
  readonly upsert: readonly ["where", "create", "update", "include", "select"];
205
214
  readonly delete: readonly ["where", "include", "select"];
206
215
  readonly deleteMany: readonly ["where"];