@zenstackhq/language 2.15.1 → 3.0.0-alpha.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/LICENSE +1 -1
- package/dist/ast.cjs +1472 -0
- package/dist/ast.cjs.map +1 -0
- package/dist/ast.d.cts +566 -0
- package/dist/ast.d.ts +566 -0
- package/dist/ast.js +1331 -0
- package/dist/ast.js.map +1 -0
- package/dist/index.cjs +7790 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +94 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.js +7755 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -33
- package/res/stdlib.zmodel +721 -0
- package/README.md +0 -5
- package/ast.d.ts +0 -55
- package/ast.js +0 -37
- package/ast.js.map +0 -1
- package/generated/ast.d.ts +0 -485
- package/generated/ast.js +0 -640
- package/generated/ast.js.map +0 -1
- package/generated/grammar.d.ts +0 -6
- package/generated/grammar.js +0 -3941
- package/generated/grammar.js.map +0 -1
- package/generated/module.d.ts +0 -12
- package/generated/module.js +0 -23
- package/generated/module.js.map +0 -1
- package/module.d.ts +0 -1
- package/module.js +0 -18
- package/module.js.map +0 -1
- package/syntaxes/zmodel.tmLanguage +0 -113
- package/syntaxes/zmodel.tmLanguage.json +0 -71
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing referential integrity related actions
|
|
3
|
+
* @see https://www.prisma.io/docs/orm/prisma-schema/data-model/relations/referential-actions
|
|
4
|
+
*/
|
|
5
|
+
enum ReferentialAction {
|
|
6
|
+
/**
|
|
7
|
+
* Used with "onDelete": deleting a referenced record will trigger the deletion of referencing record.
|
|
8
|
+
* Used with "onUpdate": updates the relation scalar fields if the referenced scalar fields of the dependent record are updated.
|
|
9
|
+
*/
|
|
10
|
+
Cascade
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Used with "onDelete": prevents the deletion if any referencing records exist.
|
|
14
|
+
* Used with "onUpdate": prevents the identifier of a referenced record from being changed.
|
|
15
|
+
*/
|
|
16
|
+
Restrict
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Similar to 'Restrict', the difference between the two is dependent on the database being used.
|
|
20
|
+
*/
|
|
21
|
+
NoAction
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Used with "onDelete": the scalar field of the referencing object will be set to NULL.
|
|
25
|
+
* Used with "onUpdate": when updating the identifier of a referenced object, the scalar fields of the referencing objects will be set to NULL.
|
|
26
|
+
*/
|
|
27
|
+
SetNull
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Used with "onDelete": the scalar field of the referencing object will be set to the fields default value.
|
|
31
|
+
* Used with "onUpdate": the scalar field of the referencing object will be set to the fields default value.
|
|
32
|
+
*/
|
|
33
|
+
SetDefault
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Enum representing all possible field types
|
|
38
|
+
*/
|
|
39
|
+
enum AttributeTargetField {
|
|
40
|
+
StringField
|
|
41
|
+
IntField
|
|
42
|
+
BigIntField
|
|
43
|
+
FloatField
|
|
44
|
+
DecimalField
|
|
45
|
+
BooleanField
|
|
46
|
+
DateTimeField
|
|
47
|
+
JsonField
|
|
48
|
+
BytesField
|
|
49
|
+
ModelField
|
|
50
|
+
TypeDefField
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Indicates the expression context a function can be used.
|
|
55
|
+
*/
|
|
56
|
+
enum ExpressionContext {
|
|
57
|
+
// used in @default
|
|
58
|
+
DefaultValue
|
|
59
|
+
|
|
60
|
+
// used in @@allow and @@deny
|
|
61
|
+
AccessPolicy
|
|
62
|
+
|
|
63
|
+
// used in @@validate
|
|
64
|
+
ValidationRule
|
|
65
|
+
|
|
66
|
+
// used in @@index
|
|
67
|
+
Index
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Reads value from an environment variable.
|
|
72
|
+
*/
|
|
73
|
+
function env(name: String): String {
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Gets current date-time (as DateTime type).
|
|
78
|
+
*/
|
|
79
|
+
function now(): DateTime {
|
|
80
|
+
} @@@expressionContext([DefaultValue, AccessPolicy, ValidationRule])
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Generates a globally unique identifier based on the UUID specs.
|
|
84
|
+
*/
|
|
85
|
+
function uuid(version: Int?): String {
|
|
86
|
+
} @@@expressionContext([DefaultValue])
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Generates a globally unique identifier based on the CUID spec.
|
|
90
|
+
*/
|
|
91
|
+
function cuid(version: Int?): String {
|
|
92
|
+
} @@@expressionContext([DefaultValue])
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Generates an identifier based on the nanoid spec.
|
|
96
|
+
*/
|
|
97
|
+
function nanoid(length: Int?): String {
|
|
98
|
+
} @@@expressionContext([DefaultValue])
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Generates an identifier based on the ulid spec.
|
|
102
|
+
*/
|
|
103
|
+
function ulid(): String {
|
|
104
|
+
} @@@expressionContext([DefaultValue])
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Creates a sequence of integers in the underlying database and assign the incremented
|
|
108
|
+
* values to the ID values of the created records based on the sequence.
|
|
109
|
+
*/
|
|
110
|
+
function autoincrement(): Int {
|
|
111
|
+
} @@@expressionContext([DefaultValue])
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Represents default values that cannot be expressed in the Prisma schema (such as random()).
|
|
115
|
+
*/
|
|
116
|
+
function dbgenerated(expr: String?): Any {
|
|
117
|
+
} @@@expressionContext([DefaultValue])
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Gets entities value before an update. Only valid when used in a "update" policy rule.
|
|
121
|
+
*/
|
|
122
|
+
function future(): Any {
|
|
123
|
+
} @@@expressionContext([AccessPolicy])
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* If the field value contains the search string. By default, the search is case-sensitive,
|
|
127
|
+
* but you can override the behavior with the "caseInSensitive" argument.
|
|
128
|
+
*/
|
|
129
|
+
function contains(field: String, search: String, caseInSensitive: Boolean?): Boolean {
|
|
130
|
+
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* If the field value matches the search condition with [full-text-search](https://www.prisma.io/docs/concepts/components/prisma-client/full-text-search). Need to enable "fullTextSearch" preview feature to use.
|
|
134
|
+
*/
|
|
135
|
+
function search(field: String, search: String): Boolean {
|
|
136
|
+
} @@@expressionContext([AccessPolicy])
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* If the field value starts with the search string
|
|
140
|
+
*/
|
|
141
|
+
function startsWith(field: String, search: String): Boolean {
|
|
142
|
+
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* If the field value ends with the search string
|
|
146
|
+
*/
|
|
147
|
+
function endsWith(field: String, search: String): Boolean {
|
|
148
|
+
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* If the field value (a list) has the given search value
|
|
152
|
+
*/
|
|
153
|
+
function has(field: Any[], search: Any): Boolean {
|
|
154
|
+
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* If the field value (a list) has every element of the search list
|
|
158
|
+
*/
|
|
159
|
+
function hasEvery(field: Any[], search: Any[]): Boolean {
|
|
160
|
+
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* If the field value (a list) has at least one element of the search list
|
|
164
|
+
*/
|
|
165
|
+
function hasSome(field: Any[], search: Any[]): Boolean {
|
|
166
|
+
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* If the field value (a list) is empty
|
|
170
|
+
*/
|
|
171
|
+
function isEmpty(field: Any[]): Boolean {
|
|
172
|
+
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The name of the model for which the policy rule is defined. If the rule is
|
|
176
|
+
* inherited to a sub model, this function returns the name of the sub model.
|
|
177
|
+
*
|
|
178
|
+
* @param optional parameter to control the casing of the returned value. Valid
|
|
179
|
+
* values are "original", "upper", "lower", "capitalize", "uncapitalize". Defaults
|
|
180
|
+
* to "original".
|
|
181
|
+
*/
|
|
182
|
+
function currentModel(casing: String?): String {
|
|
183
|
+
} @@@expressionContext([AccessPolicy])
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The operation for which the policy rule is defined for. Note that a rule with
|
|
187
|
+
* "all" operation is expanded to "create", "read", "update", and "delete" rules,
|
|
188
|
+
* and the function returns corresponding value for each expanded version.
|
|
189
|
+
*
|
|
190
|
+
* @param optional parameter to control the casing of the returned value. Valid
|
|
191
|
+
* values are "original", "upper", "lower", "capitalize", "uncapitalize". Defaults
|
|
192
|
+
* to "original".
|
|
193
|
+
*/
|
|
194
|
+
function currentOperation(casing: String?): String {
|
|
195
|
+
} @@@expressionContext([AccessPolicy])
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Marks an attribute to be only applicable to certain field types.
|
|
199
|
+
*/
|
|
200
|
+
attribute @@@targetField(_ targetField: AttributeTargetField[])
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Marks an attribute to be applicable to type defs and fields.
|
|
204
|
+
*/
|
|
205
|
+
attribute @@@supportTypeDef()
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Marks an attribute to be used for data validation.
|
|
209
|
+
*/
|
|
210
|
+
attribute @@@validation()
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Indicates the expression context a function can be used.
|
|
214
|
+
*/
|
|
215
|
+
attribute @@@expressionContext(_ context: ExpressionContext[])
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Indicates an attribute is directly supported by the Prisma schema.
|
|
219
|
+
*/
|
|
220
|
+
attribute @@@prisma()
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Provides hint for auto-completion.
|
|
224
|
+
*/
|
|
225
|
+
attribute @@@completionHint(_ values: String[])
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Defines a single-field ID on the model.
|
|
229
|
+
*
|
|
230
|
+
* @param map: The name of the underlying primary key constraint in the database.
|
|
231
|
+
* @param length: Allows you to specify a maximum length for the subpart of the value to be indexed.
|
|
232
|
+
* @param sort: Allows you to specify in what order the entries of the ID are stored in the database. The available options are Asc and Desc.
|
|
233
|
+
* @param clustered: Defines whether the ID is clustered or non-clustered. Defaults to true.
|
|
234
|
+
*/
|
|
235
|
+
attribute @id(map: String?, length: Int?, sort: SortOrder?, clustered: Boolean?) @@@prisma @@@supportTypeDef
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Defines a default value for a field.
|
|
239
|
+
* @param value: An expression (e.g. 5, true, now(), auth()).
|
|
240
|
+
*/
|
|
241
|
+
attribute @default(_ value: ContextType, map: String?) @@@prisma @@@supportTypeDef
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Defines a unique constraint for this field.
|
|
245
|
+
*
|
|
246
|
+
* @param length: Allows you to specify a maximum length for the subpart of the value to be indexed.
|
|
247
|
+
* @param sort: Allows you to specify in what order the entries of the constraint are stored in the database. The available options are Asc and Desc.
|
|
248
|
+
* @param clustered: Boolean Defines whether the constraint is clustered or non-clustered. Defaults to false.
|
|
249
|
+
*/
|
|
250
|
+
attribute @unique(map: String?, length: Int?, sort: SortOrder?, clustered: Boolean?) @@@prisma
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Defines a multi-field ID (composite ID) on the model.
|
|
254
|
+
*
|
|
255
|
+
* @param fields: A list of field names - for example, [firstname, lastname]
|
|
256
|
+
* @param name: The name that Prisma Client will expose for the argument covering all fields, e.g. fullName in fullName: { firstName: "First", lastName: "Last"}
|
|
257
|
+
* @param map: The name of the underlying primary key constraint in the database.
|
|
258
|
+
* @param length: Allows you to specify a maximum length for the subpart of the value to be indexed.
|
|
259
|
+
* @param sort: Allows you to specify in what order the entries of the ID are stored in the database. The available options are Asc and Desc.
|
|
260
|
+
* @param clustered: Defines whether the ID is clustered or non-clustered. Defaults to true.
|
|
261
|
+
*/
|
|
262
|
+
attribute @@id(_ fields: FieldReference[], name: String?, map: String?, length: Int?, sort: SortOrder?, clustered: Boolean?) @@@prisma
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Defines a compound unique constraint for the specified fields.
|
|
266
|
+
*
|
|
267
|
+
* @param fields: A list of field names - for example, [firstname, lastname]. Fields must be mandatory.
|
|
268
|
+
* @param name: The name of the unique combination of fields - defaults to fieldName1_fieldName2_fieldName3
|
|
269
|
+
* @param length: Allows you to specify a maximum length for the subpart of the value to be indexed.
|
|
270
|
+
* @param sort: Allows you to specify in what order the entries of the constraint are stored in the database. The available options are Asc and Desc.
|
|
271
|
+
* @param clustered: Boolean Defines whether the constraint is clustered or non-clustered. Defaults to false.
|
|
272
|
+
*/
|
|
273
|
+
attribute @@unique(_ fields: FieldReference[], name: String?, map: String?, length: Int?, sort: SortOrder?, clustered: Boolean?) @@@prisma
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Index types
|
|
277
|
+
*/
|
|
278
|
+
enum IndexType {
|
|
279
|
+
BTree
|
|
280
|
+
Hash
|
|
281
|
+
Gist
|
|
282
|
+
Gin
|
|
283
|
+
SpGist
|
|
284
|
+
Brin
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Operator class for index
|
|
289
|
+
*/
|
|
290
|
+
enum IndexOperatorClass {
|
|
291
|
+
// GIN
|
|
292
|
+
ArrayOps
|
|
293
|
+
JsonbOps
|
|
294
|
+
JsonbPathOps
|
|
295
|
+
|
|
296
|
+
// Gist
|
|
297
|
+
InetOps
|
|
298
|
+
|
|
299
|
+
// SpGist
|
|
300
|
+
TextOps
|
|
301
|
+
|
|
302
|
+
// BRIN
|
|
303
|
+
BitMinMaxOps
|
|
304
|
+
VarBitMinMaxOps
|
|
305
|
+
BpcharBloomOps
|
|
306
|
+
BpcharMinMaxOps
|
|
307
|
+
ByteaBloomOps
|
|
308
|
+
ByteaMinMaxOps
|
|
309
|
+
DateBloomOps
|
|
310
|
+
DateMinMaxOps
|
|
311
|
+
DateMinMaxMultiOps
|
|
312
|
+
Float4BloomOps
|
|
313
|
+
Float4MinMaxOps
|
|
314
|
+
Float4MinMaxMultiOps
|
|
315
|
+
Float8BloomOps
|
|
316
|
+
Float8MinMaxOps
|
|
317
|
+
Float8MinMaxMultiOps
|
|
318
|
+
InetInclusionOps
|
|
319
|
+
InetBloomOps
|
|
320
|
+
InetMinMaxOps
|
|
321
|
+
InetMinMaxMultiOps
|
|
322
|
+
Int2BloomOps
|
|
323
|
+
Int2MinMaxOps
|
|
324
|
+
Int2MinMaxMultiOps
|
|
325
|
+
Int4BloomOps
|
|
326
|
+
Int4MinMaxOps
|
|
327
|
+
Int4MinMaxMultiOps
|
|
328
|
+
Int8BloomOps
|
|
329
|
+
Int8MinMaxOps
|
|
330
|
+
Int8MinMaxMultiOps
|
|
331
|
+
NumericBloomOps
|
|
332
|
+
NumericMinMaxOps
|
|
333
|
+
NumericMinMaxMultiOps
|
|
334
|
+
OidBloomOps
|
|
335
|
+
OidMinMaxOps
|
|
336
|
+
OidMinMaxMultiOps
|
|
337
|
+
TextBloomOps
|
|
338
|
+
TextMinMaxOps
|
|
339
|
+
TextMinMaxMultiOps
|
|
340
|
+
TimestampBloomOps
|
|
341
|
+
TimestampMinMaxOps
|
|
342
|
+
TimestampMinMaxMultiOps
|
|
343
|
+
TimestampTzBloomOps
|
|
344
|
+
TimestampTzMinMaxOps
|
|
345
|
+
TimestampTzMinMaxMultiOps
|
|
346
|
+
TimeBloomOps
|
|
347
|
+
TimeMinMaxOps
|
|
348
|
+
TimeMinMaxMultiOps
|
|
349
|
+
TimeTzBloomOps
|
|
350
|
+
TimeTzMinMaxOps
|
|
351
|
+
TimeTzMinMaxMultiOps
|
|
352
|
+
UuidBloomOps
|
|
353
|
+
UuidMinMaxOps
|
|
354
|
+
UuidMinMaxMultiOps
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Index sort order
|
|
359
|
+
*/
|
|
360
|
+
enum SortOrder {
|
|
361
|
+
Asc
|
|
362
|
+
Desc
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Defines an index in the database.
|
|
367
|
+
*
|
|
368
|
+
* @params fields: A list of field names - for example, [firstname, lastname]
|
|
369
|
+
* @params name: The name that Prisma Client will expose for the argument covering all fields, e.g. fullName in fullName: { firstName: "First", lastName: "Last"}
|
|
370
|
+
* @params map: The name of the index in the underlying database (Prisma generates an index name that respects identifier length limits if you do not specify a name. Prisma uses the following naming convention: tablename.field1_field2_field3_unique)
|
|
371
|
+
* @params length: Allows you to specify a maximum length for the subpart of the value to be indexed.
|
|
372
|
+
* @params sort: Allows you to specify in what order the entries of the index or constraint are stored in the database. The available options are asc and desc.
|
|
373
|
+
* @params clustered: Defines whether the index is clustered or non-clustered. Defaults to false.
|
|
374
|
+
* @params type: Allows you to specify an index access method. Defaults to BTree.
|
|
375
|
+
*/
|
|
376
|
+
attribute @@index(_ fields: FieldReference[], name: String?, map: String?, length: Int?, sort: SortOrder?, clustered: Boolean?, type: IndexType?) @@@prisma
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Defines meta information about the relation.
|
|
380
|
+
*
|
|
381
|
+
* @param name: Sometimes (e.g. to disambiguate a relation) Defines the name of the relationship. In an m-n-relation, it also determines the name of the underlying relation table.
|
|
382
|
+
* @param fields: A list of fields of the current model
|
|
383
|
+
* @param references: A list of fields of the model on the other side of the relation
|
|
384
|
+
* @param map: Defines a custom name for the foreign key in the database.
|
|
385
|
+
* @param onUpdate: Defines the referential action to perform when a referenced entry in the referenced model is being updated.
|
|
386
|
+
* @param onDelete: Defines the referential action to perform when a referenced entry in the referenced model is being deleted.
|
|
387
|
+
*/
|
|
388
|
+
attribute @relation(_ name: String?, fields: FieldReference[]?, references: TransitiveFieldReference[]?, onDelete: ReferentialAction?, onUpdate: ReferentialAction?, map: String?) @@@prisma
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Maps a field name or enum value from the schema to a column with a different name in the database.
|
|
392
|
+
*
|
|
393
|
+
* @param name: The database column name.
|
|
394
|
+
*/
|
|
395
|
+
attribute @map(_ name: String) @@@prisma
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Maps the schema model name to a table with a different name, or an enum name to a different underlying enum in the database.
|
|
399
|
+
*
|
|
400
|
+
* @param name: The database column name.
|
|
401
|
+
*/
|
|
402
|
+
attribute @@map(_ name: String) @@@prisma
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Exclude a field from the Prisma Client (for example, a field that you do not want Prisma users to update).
|
|
406
|
+
*/
|
|
407
|
+
attribute @ignore() @@@prisma
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Exclude a model from the Prisma Client (for example, a model that you do not want Prisma users to update).
|
|
411
|
+
*/
|
|
412
|
+
attribute @@ignore() @@@prisma
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Automatically stores the time when a record was last updated.
|
|
416
|
+
*/
|
|
417
|
+
attribute @updatedAt() @@@targetField([DateTimeField]) @@@prisma
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Add full text index (MySQL only).
|
|
421
|
+
*/
|
|
422
|
+
attribute @@fulltext(_ fields: FieldReference[], map: String?) @@@prisma
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
// String type modifiers
|
|
426
|
+
|
|
427
|
+
enum MSSQLServerTypes {
|
|
428
|
+
Max
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
attribute @db.String(_ x: Int?) @@@targetField([StringField]) @@@prisma
|
|
432
|
+
attribute @db.Text() @@@targetField([StringField]) @@@prisma
|
|
433
|
+
attribute @db.NText() @@@targetField([StringField]) @@@prisma
|
|
434
|
+
attribute @db.Char(_ x: Int?) @@@targetField([StringField]) @@@prisma
|
|
435
|
+
attribute @db.NChar(_ x: Int?) @@@targetField([StringField]) @@@prisma
|
|
436
|
+
attribute @db.VarChar(_ x: Any?) @@@targetField([StringField]) @@@prisma
|
|
437
|
+
attribute @db.NVarChar(_ x: Any?) @@@targetField([StringField]) @@@prisma
|
|
438
|
+
attribute @db.CatalogSingleChar() @@@targetField([StringField]) @@@prisma
|
|
439
|
+
attribute @db.TinyText() @@@targetField([StringField]) @@@prisma
|
|
440
|
+
attribute @db.MediumText() @@@targetField([StringField]) @@@prisma
|
|
441
|
+
attribute @db.LongText() @@@targetField([StringField]) @@@prisma
|
|
442
|
+
attribute @db.Bit(_ x: Int?) @@@targetField([StringField, BooleanField, BytesField]) @@@prisma
|
|
443
|
+
attribute @db.VarBit(_ x: Int?) @@@targetField([StringField]) @@@prisma
|
|
444
|
+
attribute @db.Uuid() @@@targetField([StringField]) @@@prisma
|
|
445
|
+
attribute @db.UniqueIdentifier() @@@targetField([StringField]) @@@prisma
|
|
446
|
+
attribute @db.Xml() @@@targetField([StringField]) @@@prisma
|
|
447
|
+
attribute @db.Inet() @@@targetField([StringField]) @@@prisma
|
|
448
|
+
attribute @db.Citext() @@@targetField([StringField]) @@@prisma
|
|
449
|
+
|
|
450
|
+
// Boolean type modifiers
|
|
451
|
+
|
|
452
|
+
attribute @db.Boolean() @@@targetField([BooleanField]) @@@prisma
|
|
453
|
+
attribute @db.TinyInt(_ x: Int?) @@@targetField([BooleanField, IntField]) @@@prisma
|
|
454
|
+
attribute @db.Bool() @@@targetField([BooleanField]) @@@prisma
|
|
455
|
+
|
|
456
|
+
// Int type modifiers
|
|
457
|
+
|
|
458
|
+
attribute @db.Int() @@@targetField([IntField]) @@@prisma
|
|
459
|
+
attribute @db.Integer() @@@targetField([IntField]) @@@prisma
|
|
460
|
+
attribute @db.SmallInt() @@@targetField([IntField]) @@@prisma
|
|
461
|
+
attribute @db.Oid() @@@targetField([IntField]) @@@prisma
|
|
462
|
+
attribute @db.UnsignedInt() @@@targetField([IntField]) @@@prisma
|
|
463
|
+
attribute @db.UnsignedSmallInt() @@@targetField([IntField]) @@@prisma
|
|
464
|
+
attribute @db.MediumInt() @@@targetField([IntField]) @@@prisma
|
|
465
|
+
attribute @db.UnsignedMediumInt() @@@targetField([IntField]) @@@prisma
|
|
466
|
+
attribute @db.UnsignedTinyInt() @@@targetField([IntField]) @@@prisma
|
|
467
|
+
attribute @db.Year() @@@targetField([IntField]) @@@prisma
|
|
468
|
+
attribute @db.Int4() @@@targetField([IntField]) @@@prisma
|
|
469
|
+
attribute @db.Int2() @@@targetField([IntField]) @@@prisma
|
|
470
|
+
|
|
471
|
+
// BigInt type modifiers
|
|
472
|
+
|
|
473
|
+
attribute @db.BigInt() @@@targetField([BigIntField]) @@@prisma
|
|
474
|
+
attribute @db.UnsignedBigInt() @@@targetField([BigIntField]) @@@prisma
|
|
475
|
+
attribute @db.Int8() @@@targetField([BigIntField]) @@@prisma
|
|
476
|
+
|
|
477
|
+
// Float/Decimal type modifiers
|
|
478
|
+
attribute @db.DoublePrecision() @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
479
|
+
attribute @db.Real() @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
480
|
+
attribute @db.Float() @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
481
|
+
attribute @db.Decimal(_ p: Int?, _ s: Int?) @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
482
|
+
attribute @db.Double() @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
483
|
+
attribute @db.Money() @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
484
|
+
attribute @db.SmallMoney() @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
485
|
+
attribute @db.Float8() @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
486
|
+
attribute @db.Float4() @@@targetField([FloatField, DecimalField]) @@@prisma
|
|
487
|
+
|
|
488
|
+
// DateTime type modifiers
|
|
489
|
+
|
|
490
|
+
attribute @db.DateTime(_ x: Int?) @@@targetField([DateTimeField]) @@@prisma
|
|
491
|
+
attribute @db.DateTime2() @@@targetField([DateTimeField]) @@@prisma
|
|
492
|
+
attribute @db.SmallDateTime() @@@targetField([DateTimeField]) @@@prisma
|
|
493
|
+
attribute @db.DateTimeOffset() @@@targetField([DateTimeField]) @@@prisma
|
|
494
|
+
attribute @db.Timestamp(_ x: Int?) @@@targetField([DateTimeField]) @@@prisma
|
|
495
|
+
attribute @db.Timestamptz(_ x: Int?) @@@targetField([DateTimeField]) @@@prisma
|
|
496
|
+
attribute @db.Date() @@@targetField([DateTimeField]) @@@prisma
|
|
497
|
+
attribute @db.Time(_ x: Int?) @@@targetField([DateTimeField]) @@@prisma
|
|
498
|
+
attribute @db.Timetz(_ x: Int?) @@@targetField([DateTimeField]) @@@prisma
|
|
499
|
+
|
|
500
|
+
// Json type modifiers
|
|
501
|
+
|
|
502
|
+
attribute @db.Json() @@@targetField([JsonField]) @@@prisma
|
|
503
|
+
attribute @db.JsonB() @@@targetField([JsonField]) @@@prisma
|
|
504
|
+
|
|
505
|
+
// Bytes type modifiers
|
|
506
|
+
|
|
507
|
+
attribute @db.Bytes() @@@targetField([BytesField]) @@@prisma
|
|
508
|
+
attribute @db.ByteA() @@@targetField([BytesField]) @@@prisma
|
|
509
|
+
attribute @db.LongBlob() @@@targetField([BytesField]) @@@prisma
|
|
510
|
+
attribute @db.Binary() @@@targetField([BytesField]) @@@prisma
|
|
511
|
+
attribute @db.VarBinary(_ x: Int?) @@@targetField([BytesField]) @@@prisma
|
|
512
|
+
attribute @db.TinyBlob() @@@targetField([BytesField]) @@@prisma
|
|
513
|
+
attribute @db.Blob() @@@targetField([BytesField]) @@@prisma
|
|
514
|
+
attribute @db.MediumBlob() @@@targetField([BytesField]) @@@prisma
|
|
515
|
+
attribute @db.Image() @@@targetField([BytesField]) @@@prisma
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Specifies the schema to use in a multi-schema database. https://www.prisma.io/docs/guides/database/multi-schema.
|
|
519
|
+
*
|
|
520
|
+
* @param: The name of the database schema.
|
|
521
|
+
*/
|
|
522
|
+
attribute @@schema(_ name: String) @@@prisma
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Indicates that the field is a password field and needs to be hashed before persistence.
|
|
526
|
+
*
|
|
527
|
+
* ZenStack uses `bcryptjs` library to hash password. You can use the `saltLength` parameter
|
|
528
|
+
* to configure the cost of hashing, or use `salt` parameter to provide an explicit salt.
|
|
529
|
+
* By default, salt length of 12 is used.
|
|
530
|
+
*
|
|
531
|
+
* @see https://www.npmjs.com/package/bcryptjs for details
|
|
532
|
+
*
|
|
533
|
+
* @param saltLength: length of salt to use (cost factor for the hash function)
|
|
534
|
+
* @param salt: salt to use (a pregenerated valid salt)
|
|
535
|
+
*/
|
|
536
|
+
attribute @password(saltLength: Int?, salt: String?) @@@targetField([StringField])
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Indicates that the field is encrypted when storing in the DB and should be decrypted when read
|
|
541
|
+
*
|
|
542
|
+
* ZenStack uses the Web Crypto API to encrypt and decrypt the field.
|
|
543
|
+
*/
|
|
544
|
+
attribute @encrypted() @@@targetField([StringField])
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Indicates that the field should be omitted when read from the generated services.
|
|
548
|
+
*/
|
|
549
|
+
attribute @omit()
|
|
550
|
+
|
|
551
|
+
//////////////////////////////////////////////
|
|
552
|
+
// Begin validation attributes and functions
|
|
553
|
+
//////////////////////////////////////////////
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Validates length of a string field.
|
|
557
|
+
*/
|
|
558
|
+
attribute @length(_ min: Int?, _ max: Int?, _ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Validates a string field value starts with the given text.
|
|
562
|
+
*/
|
|
563
|
+
attribute @startsWith(_ text: String, _ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Validates a string field value ends with the given text.
|
|
567
|
+
*/
|
|
568
|
+
attribute @endsWith(_ text: String, _ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Validates a string field value contains the given text.
|
|
572
|
+
*/
|
|
573
|
+
attribute @contains(_ text: String, _ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Validates a string field value matches a regex.
|
|
577
|
+
*/
|
|
578
|
+
attribute @regex(_ regex: String, _ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Validates a string field value is a valid email address.
|
|
582
|
+
*/
|
|
583
|
+
attribute @email(_ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Validates a string field value is a valid ISO datetime.
|
|
587
|
+
*/
|
|
588
|
+
attribute @datetime(_ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Validates a string field value is a valid url.
|
|
592
|
+
*/
|
|
593
|
+
attribute @url(_ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Trims whitespaces from the start and end of the string.
|
|
597
|
+
*/
|
|
598
|
+
attribute @trim() @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Transform entire string toLowerCase.
|
|
602
|
+
*/
|
|
603
|
+
attribute @lower() @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Transform entire string toUpperCase.
|
|
607
|
+
*/
|
|
608
|
+
attribute @upper() @@@targetField([StringField]) @@@validation @@@supportTypeDef
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Validates a number field is greater than the given value.
|
|
612
|
+
*/
|
|
613
|
+
attribute @gt(_ value: Int, _ message: String?) @@@targetField([IntField, FloatField, DecimalField]) @@@validation @@@supportTypeDef
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Validates a number field is greater than or equal to the given value.
|
|
617
|
+
*/
|
|
618
|
+
attribute @gte(_ value: Int, _ message: String?) @@@targetField([IntField, FloatField, DecimalField]) @@@validation @@@supportTypeDef
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Validates a number field is less than the given value.
|
|
622
|
+
*/
|
|
623
|
+
attribute @lt(_ value: Int, _ message: String?) @@@targetField([IntField, FloatField, DecimalField]) @@@validation @@@supportTypeDef
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Validates a number field is less than or equal to the given value.
|
|
627
|
+
*/
|
|
628
|
+
attribute @lte(_ value: Int, _ message: String?) @@@targetField([IntField, FloatField, DecimalField]) @@@validation @@@supportTypeDef
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Validates the entity with a complex condition.
|
|
632
|
+
*/
|
|
633
|
+
attribute @@validate(_ value: Boolean, _ message: String?, _ path: String[]?) @@@validation @@@supportTypeDef
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Validates length of a string field.
|
|
637
|
+
*/
|
|
638
|
+
function length(field: String, min: Int, max: Int?): Boolean {
|
|
639
|
+
} @@@expressionContext([ValidationRule])
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Validates a string field value matches a regex.
|
|
644
|
+
*/
|
|
645
|
+
function regex(field: String, regex: String): Boolean {
|
|
646
|
+
} @@@expressionContext([ValidationRule])
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Validates a string field value is a valid email address.
|
|
650
|
+
*/
|
|
651
|
+
function email(field: String): Boolean {
|
|
652
|
+
} @@@expressionContext([ValidationRule])
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Validates a string field value is a valid ISO datetime.
|
|
656
|
+
*/
|
|
657
|
+
function datetime(field: String): Boolean {
|
|
658
|
+
} @@@expressionContext([ValidationRule])
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Validates a string field value is a valid url.
|
|
662
|
+
*/
|
|
663
|
+
function url(field: String): Boolean {
|
|
664
|
+
} @@@expressionContext([ValidationRule])
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Checks if the current user can perform the given operation on the given field.
|
|
668
|
+
*
|
|
669
|
+
* @param field: The field to check access for
|
|
670
|
+
* @param operation: The operation to check access for. Can be "read", "create", "update", or "delete". If the operation is not provided,
|
|
671
|
+
* it defaults the operation of the containing policy rule.
|
|
672
|
+
*/
|
|
673
|
+
function check(field: Any, operation: String?): Boolean {
|
|
674
|
+
} @@@expressionContext([AccessPolicy])
|
|
675
|
+
|
|
676
|
+
//////////////////////////////////////////////
|
|
677
|
+
// End validation attributes and functions
|
|
678
|
+
//////////////////////////////////////////////
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* A utility attribute to allow passthrough of arbitrary attribute text to the generated Prisma schema.
|
|
682
|
+
*/
|
|
683
|
+
attribute @prisma.passthrough(_ text: String)
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* A utility attribute to allow passthrough of arbitrary attribute text to the generated Prisma schema.
|
|
687
|
+
*/
|
|
688
|
+
attribute @@prisma.passthrough(_ text: String)
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Marks a model to be a delegate. Used for implementing polymorphism.
|
|
692
|
+
*/
|
|
693
|
+
attribute @@delegate(_ discriminator: FieldReference)
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Used for specifying operator classes for GIN index.
|
|
697
|
+
*/
|
|
698
|
+
function raw(value: String): Any {
|
|
699
|
+
} @@@expressionContext([Index])
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Marks a field to be strong-typed JSON.
|
|
703
|
+
*/
|
|
704
|
+
attribute @json() @@@targetField([TypeDefField])
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Marks a field to be computed.
|
|
708
|
+
*/
|
|
709
|
+
attribute @computed()
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Gets the current login user.
|
|
713
|
+
*/
|
|
714
|
+
function auth(): Any {
|
|
715
|
+
} @@@expressionContext([DefaultValue, AccessPolicy])
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Used to specify the model for resolving `auth()` function call in access policies. A Zmodel
|
|
719
|
+
* can have at most one model with this attribute. By default, the model named "User" is used.
|
|
720
|
+
*/
|
|
721
|
+
attribute @@auth() @@@supportTypeDef
|