@prisma/security-rules 0.3.6 → 0.3.7
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 +53 -63
- package/assets/rpc.png +0 -0
- package/dist/index.cjs +1 -1137
- package/dist/index.d.cts +20 -170
- package/dist/index.d.ts +20 -170
- package/dist/index.js +1 -1109
- package/package.json +2 -4
package/dist/index.d.cts
CHANGED
@@ -1,105 +1,10 @@
|
|
1
|
-
import
|
2
|
-
import { Prisma as Prisma$1 } from '@prisma/client/extension';
|
3
|
-
import { Prisma } from '@prisma/client/scripts/default-index.js';
|
4
|
-
import * as _prisma_client_runtime_library from '@prisma/client/runtime/library';
|
5
|
-
import * as _prisma_extension_pulse_workerd from '@prisma/extension-pulse/workerd';
|
1
|
+
import { Prisma } from '@prisma/client/extension';
|
6
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
* Specifies the caching parameters for Accelerate.
|
13
|
-
*
|
14
|
-
* `cacheStrategy` only applies when used with an Accelerate connection string.
|
15
|
-
*/
|
16
|
-
readonly cacheStrategy?: {
|
17
|
-
/**
|
18
|
-
* `swr` is short for Stale-While-Revalidate.
|
19
|
-
*
|
20
|
-
* `swr` defines the number of seconds that Accelerate may serve _stale_ cache data.
|
21
|
-
* _Stale_ data is a cache hit, but the cache will be refreshed in the background by Accelerate.
|
22
|
-
* The Prisma operation will not be blocked while data is refreshed.
|
23
|
-
*
|
24
|
-
* Use `swr` to reduce the latency of accessing the data while still maintaining
|
25
|
-
* a more up-to-date value in the Accelerate cache.
|
26
|
-
* `swr` without `ttl` will not reduce database load since Accelerate will
|
27
|
-
* run the query in the background.
|
28
|
-
*
|
29
|
-
* `swr` can be combined with `ttl`.
|
30
|
-
* `swr` applies **after** `ttl` has expired.
|
31
|
-
* The total number of seconds data will be cached is `ttl + swr`.
|
32
|
-
*
|
33
|
-
* `swr` only applies when used with an Accelerate connection string.
|
34
|
-
*/
|
35
|
-
readonly swr?: number;
|
36
|
-
/**
|
37
|
-
* `ttl` is short for Time-to-Live.
|
38
|
-
*
|
39
|
-
* `ttl` defines the number of seconds that Accelerate may serve _fresh_ cache data.
|
40
|
-
* _Fresh_ data is a cache hit and will not execute the query against the database.
|
41
|
-
*
|
42
|
-
* Use `ttl` to reduce database load and latency for data that does not
|
43
|
-
* require frequent updates.
|
44
|
-
* `ttl` without `swr` will incur a blocking database query for the first
|
45
|
-
* request after `ttl` expires.
|
46
|
-
*
|
47
|
-
* It's recommended to combine `ttl` and `swr` to maintain low latency while
|
48
|
-
* Accelerate refreshes cached data in the background.
|
49
|
-
* `swr` applies **after** `ttl` has expired.
|
50
|
-
* The total number of seconds data will be cached is `ttl + swr`.
|
51
|
-
*
|
52
|
-
* `ttl` only applies when used with an Accelerate connection string.
|
53
|
-
*/
|
54
|
-
readonly ttl?: number;
|
55
|
-
/**
|
56
|
-
* `tags` allow you to attach string values to the query's cache entry
|
57
|
-
* that can later be used to invalidate the cache.
|
58
|
-
*
|
59
|
-
* A tag may only contain alphanumeric characters and underscores.
|
60
|
-
* Each tag may contain a maximum of 64 characters.
|
61
|
-
* A maximum of 5 tags are allowed per query.
|
62
|
-
*/
|
63
|
-
readonly tags?: ReadonlyArray<string>;
|
64
|
-
};
|
65
|
-
}
|
66
|
-
interface AccelerateInfo {
|
67
|
-
/**
|
68
|
-
* The cache status of the response.
|
69
|
-
* * `ttl` indicates a cache hit within the `ttl` duration and no database query was executed
|
70
|
-
* * `swr` indicates a cache hit within the `swr` duration and the data is being refreshed by Accelerate in the background
|
71
|
-
* * `miss` indicates that both `ttl` and `swr` have expired and the database query was executed by the request
|
72
|
-
* * `none` indicates that no cache strategy was specified and the database query was executed by the request
|
73
|
-
*/
|
74
|
-
cacheStatus: "ttl" | "swr" | "miss" | "none";
|
75
|
-
/**
|
76
|
-
* The date the response was last refreshed.
|
77
|
-
*/
|
78
|
-
lastModified: Date;
|
79
|
-
/**
|
80
|
-
* The datacenter region that received the request.
|
81
|
-
*/
|
82
|
-
region: string;
|
83
|
-
/**
|
84
|
-
* Unique identifier of the request. Useful for troubleshooting.
|
85
|
-
*/
|
86
|
-
requestId: string;
|
87
|
-
/**
|
88
|
-
* The unique signature of the Prisma operation.
|
89
|
-
*/
|
90
|
-
signature: string;
|
91
|
-
}
|
92
|
-
type AccelerateInvalidateInput = {
|
93
|
-
/** Invalidate cache by tags set in the query `cacheStrategy`. */
|
94
|
-
tags: ReadonlyArray<string>;
|
95
|
-
};
|
96
|
-
interface AcceleratePromise<T> extends Prisma.PrismaPromise<T> {
|
97
|
-
withAccelerateInfo(): Prisma.PrismaPromise<{
|
98
|
-
data: T;
|
99
|
-
info: AccelerateInfo | null;
|
100
|
-
}>;
|
101
|
-
}
|
102
|
-
|
4
|
+
declare type Narrowable = string | number | bigint | boolean | [];
|
5
|
+
declare type Exact<A, W> = (A extends unknown ? W extends A ? {
|
6
|
+
[K in keyof A]: Exact<A[K], W[K]>;
|
7
|
+
} : W : never) | (A extends Narrowable ? A : never);
|
103
8
|
type CoerceAnyToNever<T> = unknown extends T ? never : T;
|
104
9
|
type CoerceNeverToValue<T, V> = [T] extends [never] ? V : T;
|
105
10
|
type ModelKeys<T> = {
|
@@ -107,7 +12,6 @@ type ModelKeys<T> = {
|
|
107
12
|
}[keyof T];
|
108
13
|
type Rules<C, Ctx extends StandardSchemaV1, AllModelKeys extends ModelKeys<C> = ModelKeys<C>> = {
|
109
14
|
[K in AllModelKeys]?: {
|
110
|
-
pulse?: PulseRuleShape<C, K, Ctx>;
|
111
15
|
read?: OpRuleShape<ReadOperation, C, K, Ctx>;
|
112
16
|
create?: OpRuleShape<CreateOperation, C, K, Ctx>;
|
113
17
|
delete?: OpRuleShape<DeleteOperation, C, K, Ctx>;
|
@@ -117,7 +21,6 @@ type Rules<C, Ctx extends StandardSchemaV1, AllModelKeys extends ModelKeys<C> =
|
|
117
21
|
} & {
|
118
22
|
$transaction?: boolean;
|
119
23
|
$allModels?: {
|
120
|
-
pulse?: AnyPulseRuleShape<Ctx>;
|
121
24
|
read?: AnyOpRuleShape<ReadOperation, Ctx>;
|
122
25
|
create?: AnyOpRuleShape<CreateOperation, Ctx>;
|
123
26
|
delete?: AnyOpRuleShape<DeleteOperation, Ctx>;
|
@@ -125,38 +28,6 @@ type Rules<C, Ctx extends StandardSchemaV1, AllModelKeys extends ModelKeys<C> =
|
|
125
28
|
$allOperations?: AnyOpRuleShape<Operation, Ctx>;
|
126
29
|
} | boolean;
|
127
30
|
};
|
128
|
-
/** <Pulse> */
|
129
|
-
/** <Pulse:Model> */
|
130
|
-
type PulseRuleShape<C, K extends keyof C, Ctx extends StandardSchemaV1> = boolean | PulseRuleShapeStatic<C, K> | PulseRuleShapeCallback<C, K, Ctx>;
|
131
|
-
type PulseWhere<C, K extends keyof C> = Partial<Pick<Prisma$1.Args<C[K], "findMany">["where"], keyof Prisma$1.Payload<C[K], "findMany">["scalars"]>>;
|
132
|
-
type PulseRuleShapeCallback<C, K extends keyof C, Ctx extends StandardSchemaV1> = {
|
133
|
-
(ctx: {
|
134
|
-
context: StandardSchemaV1.InferOutput<Ctx>;
|
135
|
-
action: "create" | "update" | "delete";
|
136
|
-
model: K;
|
137
|
-
}): MaybePromise<boolean | PulseRuleShapeStatic<C, K>>;
|
138
|
-
};
|
139
|
-
type PulseRuleShapeStatic<C, K extends keyof C, Where = PulseWhere<C, K>> = {
|
140
|
-
$select?: {
|
141
|
-
[K in keyof Where]: boolean;
|
142
|
-
};
|
143
|
-
$where?: Where;
|
144
|
-
};
|
145
|
-
/** </Pulse:Model> */
|
146
|
-
/** <Pulse:Any> */
|
147
|
-
type AnyPulseRuleShape<Ctx extends StandardSchemaV1> = boolean | AnyPulseRuleShapeStatic | AnyPulseRuleShapeCallback<Ctx>;
|
148
|
-
type AnyPulseRuleShapeCallback<Ctx extends StandardSchemaV1> = {
|
149
|
-
(ctx: {
|
150
|
-
context: StandardSchemaV1.InferOutput<Ctx>;
|
151
|
-
action: "create" | "update" | "delete";
|
152
|
-
}): MaybePromise<boolean | AnyPulseRuleShapeStatic>;
|
153
|
-
};
|
154
|
-
type AnyPulseRuleShapeStatic = {
|
155
|
-
$select?: Record<string, boolean>;
|
156
|
-
$where?: object;
|
157
|
-
};
|
158
|
-
/** </Pulse:Any> */
|
159
|
-
/** </Pulse> */
|
160
31
|
/** <Operation> */
|
161
32
|
type DeleteOperation = "delete" | "deleteMany";
|
162
33
|
type UpdateOperation = "update" | "updateMany" | "updateManyAndReturn" | "upsert";
|
@@ -165,7 +36,7 @@ type ReadOperation = "aggregate" | "count" | "findFirst" | "findFirstOrThrow" |
|
|
165
36
|
type Operation = CreateOperation | DeleteOperation | UpdateOperation | ReadOperation;
|
166
37
|
/** <Operation:Model> */
|
167
38
|
type OpRuleShape<O extends Operation, C, K extends keyof C, Ctx extends StandardSchemaV1> = boolean | OpRuleShapeWhere<O, C, K> | OpRuleShapeCallback<O, C, K, Ctx> | OpRuleShapeVerbose<O, C, K, Ctx>;
|
168
|
-
type OpRuleShapeWhere<O extends Operation, C, K extends keyof C> = Prisma
|
39
|
+
type OpRuleShapeWhere<O extends Operation, C, K extends keyof C> = Prisma.Args<C[K], O> extends {
|
169
40
|
where?: infer W;
|
170
41
|
} ? {
|
171
42
|
$where: W;
|
@@ -174,7 +45,7 @@ type OpRuleShapeWhere<O extends Operation, C, K extends keyof C> = Prisma$1.Args
|
|
174
45
|
type OpCtx<O extends Operation, C, K extends keyof C, Ctx extends StandardSchemaV1> = K extends unknown ? O extends unknown ? {
|
175
46
|
model: K;
|
176
47
|
operation: O;
|
177
|
-
args: CoerceAnyToNever<Prisma
|
48
|
+
args: CoerceAnyToNever<Prisma.Args<C[K], O>>;
|
178
49
|
context: StandardSchemaV1.InferOutput<Ctx>;
|
179
50
|
uuid?: string;
|
180
51
|
} : never : never;
|
@@ -227,50 +98,29 @@ type AnyOpRuleShapeVerbose<O extends Operation, Ctx extends StandardSchemaV1> =
|
|
227
98
|
/** </Operation:Any> */
|
228
99
|
/** </Operation> */
|
229
100
|
type MaybePromise<T> = T | Promise<T>;
|
230
|
-
type FieldsOf<O extends Operation, C, K extends keyof C, P extends Record<string, unknown> = Prisma
|
231
|
-
declare function
|
101
|
+
type FieldsOf<O extends Operation, C, K extends keyof C, P extends Record<string, unknown> = Prisma.Payload<C[K], O>> = CoerceNeverToValue<keyof P["scalars"] | keyof P["objects"] | keyof P["composites"], string>;
|
102
|
+
declare function defineRules<C extends object, R, CtxSchema extends StandardSchemaV1 = StandardSchemaV1>(args: {
|
103
|
+
prisma: C;
|
232
104
|
contextSchema?: CtxSchema;
|
233
|
-
rules: R
|
234
|
-
}):
|
235
|
-
$
|
236
|
-
subscribe<TModel, TArgs>(this: TModel, args?: Prisma$1.Exact<TArgs, _prisma_extension_pulse_workerd.PulseSubscribeArgs<TModel>>): Promise<_prisma_extension_pulse_workerd.PulseSubscription<_prisma_extension_pulse_workerd.PulseResultType<_prisma_extension_pulse_workerd.Omit<TArgs, "name">, Prisma$1.Result<TModel, TArgs, "findFirstOrThrow">>>>;
|
237
|
-
stream<TModel_1, TArgs_1>(this: TModel_1, args?: Prisma$1.Exact<TArgs_1, _prisma_extension_pulse_workerd.PulseStreamArgs<TModel_1>>): Promise<_prisma_extension_pulse_workerd.PulseSubscription<_prisma_extension_pulse_workerd.PulseResultType<_prisma_extension_pulse_workerd.Omit<TArgs_1, "name">, Prisma$1.Result<TModel_1, TArgs_1, "findFirstOrThrow">>>>;
|
238
|
-
};
|
239
|
-
}, {}, {}> & _prisma_client_runtime_library.DefaultArgs & _prisma_client_runtime_library.InternalArgs<{}, {
|
240
|
-
$allModels: {
|
241
|
-
aggregate<T, A>(this: T, args: _prisma_client_runtime_library.Exact<A, _prisma_client_runtime_library.Args_3<T, "aggregate"> & PrismaCacheStrategy>): AcceleratePromise<_prisma_client_runtime_library.Result_2<T, A, "aggregate">>;
|
242
|
-
count<T_1, A_1>(this: T_1, args?: _prisma_client_runtime_library.Exact<A_1, _prisma_client_runtime_library.Args_3<T_1, "count"> & PrismaCacheStrategy> | undefined): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_1, A_1, "count">>;
|
243
|
-
findFirst<T_2, A_2>(this: T_2, args?: _prisma_client_runtime_library.Exact<A_2, _prisma_client_runtime_library.Args_3<T_2, "findFirst"> & PrismaCacheStrategy> | undefined): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_2, A_2, "findFirst"> | null>;
|
244
|
-
findFirstOrThrow<T_3, A_3>(this: T_3, args?: _prisma_client_runtime_library.Exact<A_3, _prisma_client_runtime_library.Args_3<T_3, "findFirstOrThrow"> & PrismaCacheStrategy> | undefined): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_3, A_3, "findFirstOrThrow">>;
|
245
|
-
findMany<T_4, A_4>(this: T_4, args?: _prisma_client_runtime_library.Exact<A_4, _prisma_client_runtime_library.Args_3<T_4, "findMany"> & PrismaCacheStrategy> | undefined): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_4, A_4, "findMany">>;
|
246
|
-
findUnique<T_5, A_5>(this: T_5, args: _prisma_client_runtime_library.Exact<A_5, _prisma_client_runtime_library.Args_3<T_5, "findUnique"> & PrismaCacheStrategy>): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_5, A_5, "findUnique"> | null>;
|
247
|
-
findUniqueOrThrow<T_6, A_6>(this: T_6, args: _prisma_client_runtime_library.Exact<A_6, _prisma_client_runtime_library.Args_3<T_6, "findUniqueOrThrow"> & PrismaCacheStrategy>): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_6, A_6, "findUniqueOrThrow">>;
|
248
|
-
groupBy<T_7, A_7>(this: T_7, args: _prisma_client_runtime_library.Exact<A_7, _prisma_client_runtime_library.Args_3<T_7, "groupBy"> & PrismaCacheStrategy>): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_7, A_7, "groupBy">>;
|
249
|
-
};
|
250
|
-
}, {}, {
|
251
|
-
$accelerate: {
|
252
|
-
invalidate: (input: AccelerateInvalidateInput) => Promise<{
|
253
|
-
requestId: string;
|
254
|
-
}>;
|
255
|
-
};
|
256
|
-
}> & _prisma_client_runtime_library.InternalArgs<{}, {}, {}, {}> & _prisma_client_runtime_library.InternalArgs<{}, {}, {}, {
|
257
|
-
$policy: {
|
105
|
+
rules: Exact<R, Rules<C, CtxSchema>>;
|
106
|
+
}): C & {
|
107
|
+
$rules: {
|
258
108
|
setGlobalContext(ctx: StandardSchemaV1.InferInput<CtxSchema>): void;
|
259
109
|
contextSchema: unknown;
|
260
|
-
rules: R
|
110
|
+
rules: Exact<R, Rules<C, CtxSchema, ModelKeys<C>>>;
|
261
111
|
};
|
262
|
-
}
|
112
|
+
};
|
263
113
|
|
264
114
|
/**
|
265
115
|
* Allow only accessing the models on the client object.
|
266
116
|
*/
|
267
117
|
type KeepObjectsOnly<T> = {
|
268
|
-
[K in keyof T as K extends `$${string}` ? (K extends "$transaction" | "$
|
118
|
+
[K in keyof T as K extends `$${string}` ? (K extends "$transaction" | "$rules" ? K : never) : K]: T[K];
|
269
119
|
};
|
270
|
-
type
|
271
|
-
declare const
|
120
|
+
type AuthorizedClient<T> = KeepObjectsOnly<T>;
|
121
|
+
declare const AuthorizedClient: new <T>(args: {
|
272
122
|
url?: string;
|
273
123
|
publicKey: string;
|
274
|
-
}) =>
|
124
|
+
}) => AuthorizedClient<T>;
|
275
125
|
|
276
|
-
export {
|
126
|
+
export { AuthorizedClient, defineRules };
|
package/dist/index.d.ts
CHANGED
@@ -1,105 +1,10 @@
|
|
1
|
-
import
|
2
|
-
import { Prisma as Prisma$1 } from '@prisma/client/extension';
|
3
|
-
import { Prisma } from '@prisma/client/scripts/default-index.js';
|
4
|
-
import * as _prisma_client_runtime_library from '@prisma/client/runtime/library';
|
5
|
-
import * as _prisma_extension_pulse_workerd from '@prisma/extension-pulse/workerd';
|
1
|
+
import { Prisma } from '@prisma/client/extension';
|
6
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
* Specifies the caching parameters for Accelerate.
|
13
|
-
*
|
14
|
-
* `cacheStrategy` only applies when used with an Accelerate connection string.
|
15
|
-
*/
|
16
|
-
readonly cacheStrategy?: {
|
17
|
-
/**
|
18
|
-
* `swr` is short for Stale-While-Revalidate.
|
19
|
-
*
|
20
|
-
* `swr` defines the number of seconds that Accelerate may serve _stale_ cache data.
|
21
|
-
* _Stale_ data is a cache hit, but the cache will be refreshed in the background by Accelerate.
|
22
|
-
* The Prisma operation will not be blocked while data is refreshed.
|
23
|
-
*
|
24
|
-
* Use `swr` to reduce the latency of accessing the data while still maintaining
|
25
|
-
* a more up-to-date value in the Accelerate cache.
|
26
|
-
* `swr` without `ttl` will not reduce database load since Accelerate will
|
27
|
-
* run the query in the background.
|
28
|
-
*
|
29
|
-
* `swr` can be combined with `ttl`.
|
30
|
-
* `swr` applies **after** `ttl` has expired.
|
31
|
-
* The total number of seconds data will be cached is `ttl + swr`.
|
32
|
-
*
|
33
|
-
* `swr` only applies when used with an Accelerate connection string.
|
34
|
-
*/
|
35
|
-
readonly swr?: number;
|
36
|
-
/**
|
37
|
-
* `ttl` is short for Time-to-Live.
|
38
|
-
*
|
39
|
-
* `ttl` defines the number of seconds that Accelerate may serve _fresh_ cache data.
|
40
|
-
* _Fresh_ data is a cache hit and will not execute the query against the database.
|
41
|
-
*
|
42
|
-
* Use `ttl` to reduce database load and latency for data that does not
|
43
|
-
* require frequent updates.
|
44
|
-
* `ttl` without `swr` will incur a blocking database query for the first
|
45
|
-
* request after `ttl` expires.
|
46
|
-
*
|
47
|
-
* It's recommended to combine `ttl` and `swr` to maintain low latency while
|
48
|
-
* Accelerate refreshes cached data in the background.
|
49
|
-
* `swr` applies **after** `ttl` has expired.
|
50
|
-
* The total number of seconds data will be cached is `ttl + swr`.
|
51
|
-
*
|
52
|
-
* `ttl` only applies when used with an Accelerate connection string.
|
53
|
-
*/
|
54
|
-
readonly ttl?: number;
|
55
|
-
/**
|
56
|
-
* `tags` allow you to attach string values to the query's cache entry
|
57
|
-
* that can later be used to invalidate the cache.
|
58
|
-
*
|
59
|
-
* A tag may only contain alphanumeric characters and underscores.
|
60
|
-
* Each tag may contain a maximum of 64 characters.
|
61
|
-
* A maximum of 5 tags are allowed per query.
|
62
|
-
*/
|
63
|
-
readonly tags?: ReadonlyArray<string>;
|
64
|
-
};
|
65
|
-
}
|
66
|
-
interface AccelerateInfo {
|
67
|
-
/**
|
68
|
-
* The cache status of the response.
|
69
|
-
* * `ttl` indicates a cache hit within the `ttl` duration and no database query was executed
|
70
|
-
* * `swr` indicates a cache hit within the `swr` duration and the data is being refreshed by Accelerate in the background
|
71
|
-
* * `miss` indicates that both `ttl` and `swr` have expired and the database query was executed by the request
|
72
|
-
* * `none` indicates that no cache strategy was specified and the database query was executed by the request
|
73
|
-
*/
|
74
|
-
cacheStatus: "ttl" | "swr" | "miss" | "none";
|
75
|
-
/**
|
76
|
-
* The date the response was last refreshed.
|
77
|
-
*/
|
78
|
-
lastModified: Date;
|
79
|
-
/**
|
80
|
-
* The datacenter region that received the request.
|
81
|
-
*/
|
82
|
-
region: string;
|
83
|
-
/**
|
84
|
-
* Unique identifier of the request. Useful for troubleshooting.
|
85
|
-
*/
|
86
|
-
requestId: string;
|
87
|
-
/**
|
88
|
-
* The unique signature of the Prisma operation.
|
89
|
-
*/
|
90
|
-
signature: string;
|
91
|
-
}
|
92
|
-
type AccelerateInvalidateInput = {
|
93
|
-
/** Invalidate cache by tags set in the query `cacheStrategy`. */
|
94
|
-
tags: ReadonlyArray<string>;
|
95
|
-
};
|
96
|
-
interface AcceleratePromise<T> extends Prisma.PrismaPromise<T> {
|
97
|
-
withAccelerateInfo(): Prisma.PrismaPromise<{
|
98
|
-
data: T;
|
99
|
-
info: AccelerateInfo | null;
|
100
|
-
}>;
|
101
|
-
}
|
102
|
-
|
4
|
+
declare type Narrowable = string | number | bigint | boolean | [];
|
5
|
+
declare type Exact<A, W> = (A extends unknown ? W extends A ? {
|
6
|
+
[K in keyof A]: Exact<A[K], W[K]>;
|
7
|
+
} : W : never) | (A extends Narrowable ? A : never);
|
103
8
|
type CoerceAnyToNever<T> = unknown extends T ? never : T;
|
104
9
|
type CoerceNeverToValue<T, V> = [T] extends [never] ? V : T;
|
105
10
|
type ModelKeys<T> = {
|
@@ -107,7 +12,6 @@ type ModelKeys<T> = {
|
|
107
12
|
}[keyof T];
|
108
13
|
type Rules<C, Ctx extends StandardSchemaV1, AllModelKeys extends ModelKeys<C> = ModelKeys<C>> = {
|
109
14
|
[K in AllModelKeys]?: {
|
110
|
-
pulse?: PulseRuleShape<C, K, Ctx>;
|
111
15
|
read?: OpRuleShape<ReadOperation, C, K, Ctx>;
|
112
16
|
create?: OpRuleShape<CreateOperation, C, K, Ctx>;
|
113
17
|
delete?: OpRuleShape<DeleteOperation, C, K, Ctx>;
|
@@ -117,7 +21,6 @@ type Rules<C, Ctx extends StandardSchemaV1, AllModelKeys extends ModelKeys<C> =
|
|
117
21
|
} & {
|
118
22
|
$transaction?: boolean;
|
119
23
|
$allModels?: {
|
120
|
-
pulse?: AnyPulseRuleShape<Ctx>;
|
121
24
|
read?: AnyOpRuleShape<ReadOperation, Ctx>;
|
122
25
|
create?: AnyOpRuleShape<CreateOperation, Ctx>;
|
123
26
|
delete?: AnyOpRuleShape<DeleteOperation, Ctx>;
|
@@ -125,38 +28,6 @@ type Rules<C, Ctx extends StandardSchemaV1, AllModelKeys extends ModelKeys<C> =
|
|
125
28
|
$allOperations?: AnyOpRuleShape<Operation, Ctx>;
|
126
29
|
} | boolean;
|
127
30
|
};
|
128
|
-
/** <Pulse> */
|
129
|
-
/** <Pulse:Model> */
|
130
|
-
type PulseRuleShape<C, K extends keyof C, Ctx extends StandardSchemaV1> = boolean | PulseRuleShapeStatic<C, K> | PulseRuleShapeCallback<C, K, Ctx>;
|
131
|
-
type PulseWhere<C, K extends keyof C> = Partial<Pick<Prisma$1.Args<C[K], "findMany">["where"], keyof Prisma$1.Payload<C[K], "findMany">["scalars"]>>;
|
132
|
-
type PulseRuleShapeCallback<C, K extends keyof C, Ctx extends StandardSchemaV1> = {
|
133
|
-
(ctx: {
|
134
|
-
context: StandardSchemaV1.InferOutput<Ctx>;
|
135
|
-
action: "create" | "update" | "delete";
|
136
|
-
model: K;
|
137
|
-
}): MaybePromise<boolean | PulseRuleShapeStatic<C, K>>;
|
138
|
-
};
|
139
|
-
type PulseRuleShapeStatic<C, K extends keyof C, Where = PulseWhere<C, K>> = {
|
140
|
-
$select?: {
|
141
|
-
[K in keyof Where]: boolean;
|
142
|
-
};
|
143
|
-
$where?: Where;
|
144
|
-
};
|
145
|
-
/** </Pulse:Model> */
|
146
|
-
/** <Pulse:Any> */
|
147
|
-
type AnyPulseRuleShape<Ctx extends StandardSchemaV1> = boolean | AnyPulseRuleShapeStatic | AnyPulseRuleShapeCallback<Ctx>;
|
148
|
-
type AnyPulseRuleShapeCallback<Ctx extends StandardSchemaV1> = {
|
149
|
-
(ctx: {
|
150
|
-
context: StandardSchemaV1.InferOutput<Ctx>;
|
151
|
-
action: "create" | "update" | "delete";
|
152
|
-
}): MaybePromise<boolean | AnyPulseRuleShapeStatic>;
|
153
|
-
};
|
154
|
-
type AnyPulseRuleShapeStatic = {
|
155
|
-
$select?: Record<string, boolean>;
|
156
|
-
$where?: object;
|
157
|
-
};
|
158
|
-
/** </Pulse:Any> */
|
159
|
-
/** </Pulse> */
|
160
31
|
/** <Operation> */
|
161
32
|
type DeleteOperation = "delete" | "deleteMany";
|
162
33
|
type UpdateOperation = "update" | "updateMany" | "updateManyAndReturn" | "upsert";
|
@@ -165,7 +36,7 @@ type ReadOperation = "aggregate" | "count" | "findFirst" | "findFirstOrThrow" |
|
|
165
36
|
type Operation = CreateOperation | DeleteOperation | UpdateOperation | ReadOperation;
|
166
37
|
/** <Operation:Model> */
|
167
38
|
type OpRuleShape<O extends Operation, C, K extends keyof C, Ctx extends StandardSchemaV1> = boolean | OpRuleShapeWhere<O, C, K> | OpRuleShapeCallback<O, C, K, Ctx> | OpRuleShapeVerbose<O, C, K, Ctx>;
|
168
|
-
type OpRuleShapeWhere<O extends Operation, C, K extends keyof C> = Prisma
|
39
|
+
type OpRuleShapeWhere<O extends Operation, C, K extends keyof C> = Prisma.Args<C[K], O> extends {
|
169
40
|
where?: infer W;
|
170
41
|
} ? {
|
171
42
|
$where: W;
|
@@ -174,7 +45,7 @@ type OpRuleShapeWhere<O extends Operation, C, K extends keyof C> = Prisma$1.Args
|
|
174
45
|
type OpCtx<O extends Operation, C, K extends keyof C, Ctx extends StandardSchemaV1> = K extends unknown ? O extends unknown ? {
|
175
46
|
model: K;
|
176
47
|
operation: O;
|
177
|
-
args: CoerceAnyToNever<Prisma
|
48
|
+
args: CoerceAnyToNever<Prisma.Args<C[K], O>>;
|
178
49
|
context: StandardSchemaV1.InferOutput<Ctx>;
|
179
50
|
uuid?: string;
|
180
51
|
} : never : never;
|
@@ -227,50 +98,29 @@ type AnyOpRuleShapeVerbose<O extends Operation, Ctx extends StandardSchemaV1> =
|
|
227
98
|
/** </Operation:Any> */
|
228
99
|
/** </Operation> */
|
229
100
|
type MaybePromise<T> = T | Promise<T>;
|
230
|
-
type FieldsOf<O extends Operation, C, K extends keyof C, P extends Record<string, unknown> = Prisma
|
231
|
-
declare function
|
101
|
+
type FieldsOf<O extends Operation, C, K extends keyof C, P extends Record<string, unknown> = Prisma.Payload<C[K], O>> = CoerceNeverToValue<keyof P["scalars"] | keyof P["objects"] | keyof P["composites"], string>;
|
102
|
+
declare function defineRules<C extends object, R, CtxSchema extends StandardSchemaV1 = StandardSchemaV1>(args: {
|
103
|
+
prisma: C;
|
232
104
|
contextSchema?: CtxSchema;
|
233
|
-
rules: R
|
234
|
-
}):
|
235
|
-
$
|
236
|
-
subscribe<TModel, TArgs>(this: TModel, args?: Prisma$1.Exact<TArgs, _prisma_extension_pulse_workerd.PulseSubscribeArgs<TModel>>): Promise<_prisma_extension_pulse_workerd.PulseSubscription<_prisma_extension_pulse_workerd.PulseResultType<_prisma_extension_pulse_workerd.Omit<TArgs, "name">, Prisma$1.Result<TModel, TArgs, "findFirstOrThrow">>>>;
|
237
|
-
stream<TModel_1, TArgs_1>(this: TModel_1, args?: Prisma$1.Exact<TArgs_1, _prisma_extension_pulse_workerd.PulseStreamArgs<TModel_1>>): Promise<_prisma_extension_pulse_workerd.PulseSubscription<_prisma_extension_pulse_workerd.PulseResultType<_prisma_extension_pulse_workerd.Omit<TArgs_1, "name">, Prisma$1.Result<TModel_1, TArgs_1, "findFirstOrThrow">>>>;
|
238
|
-
};
|
239
|
-
}, {}, {}> & _prisma_client_runtime_library.DefaultArgs & _prisma_client_runtime_library.InternalArgs<{}, {
|
240
|
-
$allModels: {
|
241
|
-
aggregate<T, A>(this: T, args: _prisma_client_runtime_library.Exact<A, _prisma_client_runtime_library.Args_3<T, "aggregate"> & PrismaCacheStrategy>): AcceleratePromise<_prisma_client_runtime_library.Result_2<T, A, "aggregate">>;
|
242
|
-
count<T_1, A_1>(this: T_1, args?: _prisma_client_runtime_library.Exact<A_1, _prisma_client_runtime_library.Args_3<T_1, "count"> & PrismaCacheStrategy> | undefined): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_1, A_1, "count">>;
|
243
|
-
findFirst<T_2, A_2>(this: T_2, args?: _prisma_client_runtime_library.Exact<A_2, _prisma_client_runtime_library.Args_3<T_2, "findFirst"> & PrismaCacheStrategy> | undefined): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_2, A_2, "findFirst"> | null>;
|
244
|
-
findFirstOrThrow<T_3, A_3>(this: T_3, args?: _prisma_client_runtime_library.Exact<A_3, _prisma_client_runtime_library.Args_3<T_3, "findFirstOrThrow"> & PrismaCacheStrategy> | undefined): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_3, A_3, "findFirstOrThrow">>;
|
245
|
-
findMany<T_4, A_4>(this: T_4, args?: _prisma_client_runtime_library.Exact<A_4, _prisma_client_runtime_library.Args_3<T_4, "findMany"> & PrismaCacheStrategy> | undefined): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_4, A_4, "findMany">>;
|
246
|
-
findUnique<T_5, A_5>(this: T_5, args: _prisma_client_runtime_library.Exact<A_5, _prisma_client_runtime_library.Args_3<T_5, "findUnique"> & PrismaCacheStrategy>): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_5, A_5, "findUnique"> | null>;
|
247
|
-
findUniqueOrThrow<T_6, A_6>(this: T_6, args: _prisma_client_runtime_library.Exact<A_6, _prisma_client_runtime_library.Args_3<T_6, "findUniqueOrThrow"> & PrismaCacheStrategy>): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_6, A_6, "findUniqueOrThrow">>;
|
248
|
-
groupBy<T_7, A_7>(this: T_7, args: _prisma_client_runtime_library.Exact<A_7, _prisma_client_runtime_library.Args_3<T_7, "groupBy"> & PrismaCacheStrategy>): AcceleratePromise<_prisma_client_runtime_library.Result_2<T_7, A_7, "groupBy">>;
|
249
|
-
};
|
250
|
-
}, {}, {
|
251
|
-
$accelerate: {
|
252
|
-
invalidate: (input: AccelerateInvalidateInput) => Promise<{
|
253
|
-
requestId: string;
|
254
|
-
}>;
|
255
|
-
};
|
256
|
-
}> & _prisma_client_runtime_library.InternalArgs<{}, {}, {}, {}> & _prisma_client_runtime_library.InternalArgs<{}, {}, {}, {
|
257
|
-
$policy: {
|
105
|
+
rules: Exact<R, Rules<C, CtxSchema>>;
|
106
|
+
}): C & {
|
107
|
+
$rules: {
|
258
108
|
setGlobalContext(ctx: StandardSchemaV1.InferInput<CtxSchema>): void;
|
259
109
|
contextSchema: unknown;
|
260
|
-
rules: R
|
110
|
+
rules: Exact<R, Rules<C, CtxSchema, ModelKeys<C>>>;
|
261
111
|
};
|
262
|
-
}
|
112
|
+
};
|
263
113
|
|
264
114
|
/**
|
265
115
|
* Allow only accessing the models on the client object.
|
266
116
|
*/
|
267
117
|
type KeepObjectsOnly<T> = {
|
268
|
-
[K in keyof T as K extends `$${string}` ? (K extends "$transaction" | "$
|
118
|
+
[K in keyof T as K extends `$${string}` ? (K extends "$transaction" | "$rules" ? K : never) : K]: T[K];
|
269
119
|
};
|
270
|
-
type
|
271
|
-
declare const
|
120
|
+
type AuthorizedClient<T> = KeepObjectsOnly<T>;
|
121
|
+
declare const AuthorizedClient: new <T>(args: {
|
272
122
|
url?: string;
|
273
123
|
publicKey: string;
|
274
|
-
}) =>
|
124
|
+
}) => AuthorizedClient<T>;
|
275
125
|
|
276
|
-
export {
|
126
|
+
export { AuthorizedClient, defineRules };
|