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.
- package/README.md +75 -1
- package/dist/generator/index.js +50 -40
- package/dist/generator/index.js.map +1 -1
- package/dist/runtime/index.cjs +265 -183
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +19 -9
- package/dist/runtime/index.d.ts +19 -9
- package/dist/runtime/index.js +265 -183
- package/dist/runtime/index.js.map +1 -1
- package/package.json +1 -1
package/dist/runtime/index.d.cts
CHANGED
|
@@ -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", "
|
|
197
|
-
readonly create: readonly ["data", "
|
|
198
|
-
readonly createMany: readonly ["data"];
|
|
199
|
-
readonly createManyAndReturn: readonly ["data", "select", "include"];
|
|
200
|
-
readonly update: readonly ["
|
|
201
|
-
readonly updateMany: readonly ["
|
|
202
|
-
readonly updateManyAndReturn: readonly ["
|
|
203
|
-
readonly upsert: readonly ["where", "create", "update", "
|
|
204
|
-
readonly delete: readonly ["where", "
|
|
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;
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -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", "
|
|
197
|
-
readonly create: readonly ["data", "
|
|
198
|
-
readonly createMany: readonly ["data"];
|
|
199
|
-
readonly createManyAndReturn: readonly ["data", "select", "include"];
|
|
200
|
-
readonly update: readonly ["
|
|
201
|
-
readonly updateMany: readonly ["
|
|
202
|
-
readonly updateManyAndReturn: readonly ["
|
|
203
|
-
readonly upsert: readonly ["where", "create", "update", "
|
|
204
|
-
readonly delete: readonly ["where", "
|
|
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;
|