@zenstackhq/runtime 1.1.1 → 1.2.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/cross/index.d.mts +229 -0
- package/cross/index.d.ts +229 -0
- package/cross/index.js +464 -0
- package/cross/index.js.map +1 -0
- package/cross/index.mjs +431 -0
- package/cross/index.mjs.map +1 -0
- package/enhancements/index.d.ts +2 -3
- package/enhancements/index.js +2 -3
- package/enhancements/index.js.map +1 -1
- package/enhancements/model-data-visitor.d.ts +1 -1
- package/enhancements/model-data-visitor.js +2 -2
- package/enhancements/model-data-visitor.js.map +1 -1
- package/enhancements/omit.d.ts +2 -1
- package/enhancements/omit.js +4 -5
- package/enhancements/omit.js.map +1 -1
- package/enhancements/password.d.ts +2 -1
- package/enhancements/password.js +2 -2
- package/enhancements/password.js.map +1 -1
- package/enhancements/policy/handler.d.ts +2 -1
- package/enhancements/policy/handler.js +14 -15
- package/enhancements/policy/handler.js.map +1 -1
- package/enhancements/policy/index.d.ts +2 -1
- package/enhancements/policy/index.js +2 -2
- package/enhancements/policy/index.js.map +1 -1
- package/enhancements/policy/policy-utils.d.ts +4 -4
- package/enhancements/policy/policy-utils.js +11 -11
- package/enhancements/policy/policy-utils.js.map +1 -1
- package/enhancements/proxy.d.ts +2 -2
- package/enhancements/proxy.js.map +1 -1
- package/enhancements/types.d.ts +2 -17
- package/enhancements/types.js.map +1 -1
- package/enhancements/utils.d.ts +3 -19
- package/enhancements/utils.js +1 -44
- package/enhancements/utils.js.map +1 -1
- package/enhancements/where-visitor.d.ts +1 -2
- package/enhancements/where-visitor.js +3 -4
- package/enhancements/where-visitor.js.map +1 -1
- package/package.json +10 -5
- package/types.d.ts +0 -58
- package/types.js +0 -14
- package/types.js.map +1 -1
- package/enhancements/model-meta.d.ts +0 -10
- package/enhancements/model-meta.js +0 -21
- package/enhancements/model-meta.js.map +0 -1
- package/enhancements/nested-write-visitor.d.ts +0 -75
- package/enhancements/nested-write-visitor.js +0 -241
- package/enhancements/nested-write-visitor.js.map +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime information of a data model or field attribute
|
|
3
|
+
*/
|
|
4
|
+
type RuntimeAttribute = {
|
|
5
|
+
name: string;
|
|
6
|
+
args: Array<{
|
|
7
|
+
name?: string;
|
|
8
|
+
value: unknown;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Runtime information of a data model field
|
|
13
|
+
*/
|
|
14
|
+
type FieldInfo = {
|
|
15
|
+
/**
|
|
16
|
+
* Field name
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* Field type name
|
|
21
|
+
*/
|
|
22
|
+
type: string;
|
|
23
|
+
/**
|
|
24
|
+
* If the field is an ID field or part of a multi-field ID
|
|
25
|
+
*/
|
|
26
|
+
isId: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* If the field type is a data model (or an optional/array of data model)
|
|
29
|
+
*/
|
|
30
|
+
isDataModel: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* If the field is an array
|
|
33
|
+
*/
|
|
34
|
+
isArray: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* If the field is optional
|
|
37
|
+
*/
|
|
38
|
+
isOptional: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Attributes on the field
|
|
41
|
+
*/
|
|
42
|
+
attributes: RuntimeAttribute[];
|
|
43
|
+
/**
|
|
44
|
+
* If the field is a relation field, the field name of the reverse side of the relation
|
|
45
|
+
*/
|
|
46
|
+
backLink?: string;
|
|
47
|
+
/**
|
|
48
|
+
* If the field is the owner side of a relation
|
|
49
|
+
*/
|
|
50
|
+
isRelationOwner: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* If the field is a foreign key field
|
|
53
|
+
*/
|
|
54
|
+
isForeignKey: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Mapping from foreign key field names to relation field names
|
|
57
|
+
*/
|
|
58
|
+
foreignKeyMapping?: Record<string, string>;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Metadata for a model-level unique constraint
|
|
62
|
+
* e.g.: @@unique([a, b])
|
|
63
|
+
*/
|
|
64
|
+
type UniqueConstraint = {
|
|
65
|
+
name: string;
|
|
66
|
+
fields: string[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* ZModel data model metadata
|
|
70
|
+
*/
|
|
71
|
+
type ModelMeta = {
|
|
72
|
+
/**
|
|
73
|
+
* Model fields
|
|
74
|
+
*/
|
|
75
|
+
fields: Record<string, Record<string, FieldInfo>>;
|
|
76
|
+
/**
|
|
77
|
+
* Model unique constraints
|
|
78
|
+
*/
|
|
79
|
+
uniqueConstraints: Record<string, Record<string, UniqueConstraint>>;
|
|
80
|
+
/**
|
|
81
|
+
* Information for cascading delete
|
|
82
|
+
*/
|
|
83
|
+
deleteCascade: Record<string, string[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Name of model that backs the `auth()` function
|
|
86
|
+
*/
|
|
87
|
+
authModel?: string;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Resolves a model field to its metadata. Returns undefined if not found.
|
|
91
|
+
*/
|
|
92
|
+
declare function resolveField(modelMeta: ModelMeta, model: string, field: string): FieldInfo | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Gets all fields of a model.
|
|
95
|
+
*/
|
|
96
|
+
declare function getFields(modelMeta: ModelMeta, model: string): Record<string, FieldInfo>;
|
|
97
|
+
|
|
98
|
+
type NestedReadVisitorCallback = {
|
|
99
|
+
field?: (model: string, field: FieldInfo | undefined, kind: 'include' | 'select' | undefined, args: unknown) => void | boolean;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Visitor for nested read payload.
|
|
103
|
+
*/
|
|
104
|
+
declare class NestedReadVisitor {
|
|
105
|
+
private readonly modelMeta;
|
|
106
|
+
private readonly callback;
|
|
107
|
+
constructor(modelMeta: ModelMeta, callback: NestedReadVisitorCallback);
|
|
108
|
+
doVisit(model: string, field: FieldInfo | undefined, kind: 'include' | 'select' | undefined, args: unknown): void;
|
|
109
|
+
visit(model: string, args: unknown): void;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Prisma write operation kinds
|
|
114
|
+
*/
|
|
115
|
+
declare const PrismaWriteActions: readonly ["create", "createMany", "connectOrCreate", "update", "updateMany", "upsert", "connect", "disconnect", "set", "delete", "deleteMany"];
|
|
116
|
+
/**
|
|
117
|
+
* Prisma write operation kinds
|
|
118
|
+
*/
|
|
119
|
+
type PrismaWriteActionType = (typeof PrismaWriteActions)[number];
|
|
120
|
+
/**
|
|
121
|
+
* Maybe promise
|
|
122
|
+
*/
|
|
123
|
+
type MaybePromise<T> = T | Promise<T> | PromiseLike<T>;
|
|
124
|
+
|
|
125
|
+
type NestingPathItem = {
|
|
126
|
+
field?: FieldInfo;
|
|
127
|
+
model: string;
|
|
128
|
+
where: any;
|
|
129
|
+
unique: boolean;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Context for visiting
|
|
133
|
+
*/
|
|
134
|
+
type NestedWriteVisitorContext = {
|
|
135
|
+
/**
|
|
136
|
+
* Parent data, can be used to replace fields
|
|
137
|
+
*/
|
|
138
|
+
parent: any;
|
|
139
|
+
/**
|
|
140
|
+
* Current field, undefined if toplevel
|
|
141
|
+
*/
|
|
142
|
+
field?: FieldInfo;
|
|
143
|
+
/**
|
|
144
|
+
* A top-down path of all nested update conditions and corresponding field till now
|
|
145
|
+
*/
|
|
146
|
+
nestingPath: NestingPathItem[];
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* NestedWriteVisitor's callback actions. A call back function should return true or void to indicate
|
|
150
|
+
* that the visitor should continue traversing its children, or false to stop. It can also return an object
|
|
151
|
+
* to let the visitor traverse it instead of its original children.
|
|
152
|
+
*/
|
|
153
|
+
type NestedWriterVisitorCallback = {
|
|
154
|
+
create?: (model: string, args: any[], context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
155
|
+
createMany?: (model: string, args: {
|
|
156
|
+
data: any;
|
|
157
|
+
skipDuplicates?: boolean;
|
|
158
|
+
}, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
159
|
+
connectOrCreate?: (model: string, args: {
|
|
160
|
+
where: object;
|
|
161
|
+
create: any;
|
|
162
|
+
}, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
163
|
+
connect?: (model: string, args: object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
164
|
+
disconnect?: (model: string, args: object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
165
|
+
set?: (model: string, args: object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
166
|
+
update?: (model: string, args: object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
167
|
+
updateMany?: (model: string, args: {
|
|
168
|
+
where?: object;
|
|
169
|
+
data: any;
|
|
170
|
+
}, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
171
|
+
upsert?: (model: string, args: {
|
|
172
|
+
where: object;
|
|
173
|
+
create: any;
|
|
174
|
+
update: any;
|
|
175
|
+
}, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
176
|
+
delete?: (model: string, args: object | boolean, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
177
|
+
deleteMany?: (model: string, args: any | object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
178
|
+
field?: (field: FieldInfo, action: PrismaWriteActionType, data: any, context: NestedWriteVisitorContext) => MaybePromise<void>;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Recursive visitor for nested write (create/update) payload.
|
|
182
|
+
*/
|
|
183
|
+
declare class NestedWriteVisitor {
|
|
184
|
+
private readonly modelMeta;
|
|
185
|
+
private readonly callback;
|
|
186
|
+
constructor(modelMeta: ModelMeta, callback: NestedWriterVisitorCallback);
|
|
187
|
+
private isPrismaWriteAction;
|
|
188
|
+
/**
|
|
189
|
+
* Start visiting
|
|
190
|
+
*
|
|
191
|
+
* @see NestedWriterVisitorCallback
|
|
192
|
+
*/
|
|
193
|
+
visit(model: string, action: PrismaWriteActionType, args: any): Promise<void>;
|
|
194
|
+
private doVisit;
|
|
195
|
+
private visitSubPayload;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Gets models read (including nested ones) given a query args.
|
|
200
|
+
* @param model
|
|
201
|
+
* @param targetModels
|
|
202
|
+
* @param modelMeta
|
|
203
|
+
* @param args
|
|
204
|
+
* @returns
|
|
205
|
+
*/
|
|
206
|
+
declare function getReadModels(model: string, modelMeta: ModelMeta, args: any): string[];
|
|
207
|
+
/**
|
|
208
|
+
* Gets mutated models (including nested ones) given a mutation args.
|
|
209
|
+
*/
|
|
210
|
+
declare function getMutatedModels(model: string, operation: PrismaWriteActionType, mutationArgs: any, modelMeta: ModelMeta): Promise<string[]>;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Gets field names in a data model entity, filtering out internal fields.
|
|
214
|
+
*/
|
|
215
|
+
declare function getModelFields(data: object): string[];
|
|
216
|
+
/**
|
|
217
|
+
* Array or scalar
|
|
218
|
+
*/
|
|
219
|
+
type Enumerable<T> = T | Array<T>;
|
|
220
|
+
/**
|
|
221
|
+
* Uniformly enumerates an array or scalar.
|
|
222
|
+
*/
|
|
223
|
+
declare function enumerate<T>(x: Enumerable<T>): T[];
|
|
224
|
+
/**
|
|
225
|
+
* Zip two arrays or scalars.
|
|
226
|
+
*/
|
|
227
|
+
declare function zip<T1, T2>(x: Enumerable<T1>, y: Enumerable<T2>): Array<[T1, T2]>;
|
|
228
|
+
|
|
229
|
+
export { Enumerable, FieldInfo, MaybePromise, ModelMeta, NestedReadVisitor, NestedReadVisitorCallback, NestedWriteVisitor, NestedWriteVisitorContext, NestedWriterVisitorCallback, PrismaWriteActionType, PrismaWriteActions, RuntimeAttribute, UniqueConstraint, enumerate, getFields, getModelFields, getMutatedModels, getReadModels, resolveField, zip };
|
package/cross/index.d.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime information of a data model or field attribute
|
|
3
|
+
*/
|
|
4
|
+
type RuntimeAttribute = {
|
|
5
|
+
name: string;
|
|
6
|
+
args: Array<{
|
|
7
|
+
name?: string;
|
|
8
|
+
value: unknown;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Runtime information of a data model field
|
|
13
|
+
*/
|
|
14
|
+
type FieldInfo = {
|
|
15
|
+
/**
|
|
16
|
+
* Field name
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* Field type name
|
|
21
|
+
*/
|
|
22
|
+
type: string;
|
|
23
|
+
/**
|
|
24
|
+
* If the field is an ID field or part of a multi-field ID
|
|
25
|
+
*/
|
|
26
|
+
isId: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* If the field type is a data model (or an optional/array of data model)
|
|
29
|
+
*/
|
|
30
|
+
isDataModel: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* If the field is an array
|
|
33
|
+
*/
|
|
34
|
+
isArray: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* If the field is optional
|
|
37
|
+
*/
|
|
38
|
+
isOptional: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Attributes on the field
|
|
41
|
+
*/
|
|
42
|
+
attributes: RuntimeAttribute[];
|
|
43
|
+
/**
|
|
44
|
+
* If the field is a relation field, the field name of the reverse side of the relation
|
|
45
|
+
*/
|
|
46
|
+
backLink?: string;
|
|
47
|
+
/**
|
|
48
|
+
* If the field is the owner side of a relation
|
|
49
|
+
*/
|
|
50
|
+
isRelationOwner: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* If the field is a foreign key field
|
|
53
|
+
*/
|
|
54
|
+
isForeignKey: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Mapping from foreign key field names to relation field names
|
|
57
|
+
*/
|
|
58
|
+
foreignKeyMapping?: Record<string, string>;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Metadata for a model-level unique constraint
|
|
62
|
+
* e.g.: @@unique([a, b])
|
|
63
|
+
*/
|
|
64
|
+
type UniqueConstraint = {
|
|
65
|
+
name: string;
|
|
66
|
+
fields: string[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* ZModel data model metadata
|
|
70
|
+
*/
|
|
71
|
+
type ModelMeta = {
|
|
72
|
+
/**
|
|
73
|
+
* Model fields
|
|
74
|
+
*/
|
|
75
|
+
fields: Record<string, Record<string, FieldInfo>>;
|
|
76
|
+
/**
|
|
77
|
+
* Model unique constraints
|
|
78
|
+
*/
|
|
79
|
+
uniqueConstraints: Record<string, Record<string, UniqueConstraint>>;
|
|
80
|
+
/**
|
|
81
|
+
* Information for cascading delete
|
|
82
|
+
*/
|
|
83
|
+
deleteCascade: Record<string, string[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Name of model that backs the `auth()` function
|
|
86
|
+
*/
|
|
87
|
+
authModel?: string;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Resolves a model field to its metadata. Returns undefined if not found.
|
|
91
|
+
*/
|
|
92
|
+
declare function resolveField(modelMeta: ModelMeta, model: string, field: string): FieldInfo | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Gets all fields of a model.
|
|
95
|
+
*/
|
|
96
|
+
declare function getFields(modelMeta: ModelMeta, model: string): Record<string, FieldInfo>;
|
|
97
|
+
|
|
98
|
+
type NestedReadVisitorCallback = {
|
|
99
|
+
field?: (model: string, field: FieldInfo | undefined, kind: 'include' | 'select' | undefined, args: unknown) => void | boolean;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Visitor for nested read payload.
|
|
103
|
+
*/
|
|
104
|
+
declare class NestedReadVisitor {
|
|
105
|
+
private readonly modelMeta;
|
|
106
|
+
private readonly callback;
|
|
107
|
+
constructor(modelMeta: ModelMeta, callback: NestedReadVisitorCallback);
|
|
108
|
+
doVisit(model: string, field: FieldInfo | undefined, kind: 'include' | 'select' | undefined, args: unknown): void;
|
|
109
|
+
visit(model: string, args: unknown): void;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Prisma write operation kinds
|
|
114
|
+
*/
|
|
115
|
+
declare const PrismaWriteActions: readonly ["create", "createMany", "connectOrCreate", "update", "updateMany", "upsert", "connect", "disconnect", "set", "delete", "deleteMany"];
|
|
116
|
+
/**
|
|
117
|
+
* Prisma write operation kinds
|
|
118
|
+
*/
|
|
119
|
+
type PrismaWriteActionType = (typeof PrismaWriteActions)[number];
|
|
120
|
+
/**
|
|
121
|
+
* Maybe promise
|
|
122
|
+
*/
|
|
123
|
+
type MaybePromise<T> = T | Promise<T> | PromiseLike<T>;
|
|
124
|
+
|
|
125
|
+
type NestingPathItem = {
|
|
126
|
+
field?: FieldInfo;
|
|
127
|
+
model: string;
|
|
128
|
+
where: any;
|
|
129
|
+
unique: boolean;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Context for visiting
|
|
133
|
+
*/
|
|
134
|
+
type NestedWriteVisitorContext = {
|
|
135
|
+
/**
|
|
136
|
+
* Parent data, can be used to replace fields
|
|
137
|
+
*/
|
|
138
|
+
parent: any;
|
|
139
|
+
/**
|
|
140
|
+
* Current field, undefined if toplevel
|
|
141
|
+
*/
|
|
142
|
+
field?: FieldInfo;
|
|
143
|
+
/**
|
|
144
|
+
* A top-down path of all nested update conditions and corresponding field till now
|
|
145
|
+
*/
|
|
146
|
+
nestingPath: NestingPathItem[];
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* NestedWriteVisitor's callback actions. A call back function should return true or void to indicate
|
|
150
|
+
* that the visitor should continue traversing its children, or false to stop. It can also return an object
|
|
151
|
+
* to let the visitor traverse it instead of its original children.
|
|
152
|
+
*/
|
|
153
|
+
type NestedWriterVisitorCallback = {
|
|
154
|
+
create?: (model: string, args: any[], context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
155
|
+
createMany?: (model: string, args: {
|
|
156
|
+
data: any;
|
|
157
|
+
skipDuplicates?: boolean;
|
|
158
|
+
}, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
159
|
+
connectOrCreate?: (model: string, args: {
|
|
160
|
+
where: object;
|
|
161
|
+
create: any;
|
|
162
|
+
}, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
163
|
+
connect?: (model: string, args: object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
164
|
+
disconnect?: (model: string, args: object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
165
|
+
set?: (model: string, args: object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
166
|
+
update?: (model: string, args: object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
167
|
+
updateMany?: (model: string, args: {
|
|
168
|
+
where?: object;
|
|
169
|
+
data: any;
|
|
170
|
+
}, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
171
|
+
upsert?: (model: string, args: {
|
|
172
|
+
where: object;
|
|
173
|
+
create: any;
|
|
174
|
+
update: any;
|
|
175
|
+
}, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
176
|
+
delete?: (model: string, args: object | boolean, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
177
|
+
deleteMany?: (model: string, args: any | object, context: NestedWriteVisitorContext) => MaybePromise<boolean | object | void>;
|
|
178
|
+
field?: (field: FieldInfo, action: PrismaWriteActionType, data: any, context: NestedWriteVisitorContext) => MaybePromise<void>;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Recursive visitor for nested write (create/update) payload.
|
|
182
|
+
*/
|
|
183
|
+
declare class NestedWriteVisitor {
|
|
184
|
+
private readonly modelMeta;
|
|
185
|
+
private readonly callback;
|
|
186
|
+
constructor(modelMeta: ModelMeta, callback: NestedWriterVisitorCallback);
|
|
187
|
+
private isPrismaWriteAction;
|
|
188
|
+
/**
|
|
189
|
+
* Start visiting
|
|
190
|
+
*
|
|
191
|
+
* @see NestedWriterVisitorCallback
|
|
192
|
+
*/
|
|
193
|
+
visit(model: string, action: PrismaWriteActionType, args: any): Promise<void>;
|
|
194
|
+
private doVisit;
|
|
195
|
+
private visitSubPayload;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Gets models read (including nested ones) given a query args.
|
|
200
|
+
* @param model
|
|
201
|
+
* @param targetModels
|
|
202
|
+
* @param modelMeta
|
|
203
|
+
* @param args
|
|
204
|
+
* @returns
|
|
205
|
+
*/
|
|
206
|
+
declare function getReadModels(model: string, modelMeta: ModelMeta, args: any): string[];
|
|
207
|
+
/**
|
|
208
|
+
* Gets mutated models (including nested ones) given a mutation args.
|
|
209
|
+
*/
|
|
210
|
+
declare function getMutatedModels(model: string, operation: PrismaWriteActionType, mutationArgs: any, modelMeta: ModelMeta): Promise<string[]>;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Gets field names in a data model entity, filtering out internal fields.
|
|
214
|
+
*/
|
|
215
|
+
declare function getModelFields(data: object): string[];
|
|
216
|
+
/**
|
|
217
|
+
* Array or scalar
|
|
218
|
+
*/
|
|
219
|
+
type Enumerable<T> = T | Array<T>;
|
|
220
|
+
/**
|
|
221
|
+
* Uniformly enumerates an array or scalar.
|
|
222
|
+
*/
|
|
223
|
+
declare function enumerate<T>(x: Enumerable<T>): T[];
|
|
224
|
+
/**
|
|
225
|
+
* Zip two arrays or scalars.
|
|
226
|
+
*/
|
|
227
|
+
declare function zip<T1, T2>(x: Enumerable<T1>, y: Enumerable<T2>): Array<[T1, T2]>;
|
|
228
|
+
|
|
229
|
+
export { Enumerable, FieldInfo, MaybePromise, ModelMeta, NestedReadVisitor, NestedReadVisitorCallback, NestedWriteVisitor, NestedWriteVisitorContext, NestedWriterVisitorCallback, PrismaWriteActionType, PrismaWriteActions, RuntimeAttribute, UniqueConstraint, enumerate, getFields, getModelFields, getMutatedModels, getReadModels, resolveField, zip };
|