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