@zenstackhq/language 3.0.0-beta.2 → 3.0.0-beta.20

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/res/stdlib.zmodel CHANGED
@@ -48,6 +48,7 @@ enum AttributeTargetField {
48
48
  BytesField
49
49
  ModelField
50
50
  TypeDefField
51
+ ListField
51
52
  }
52
53
 
53
54
  /**
@@ -117,83 +118,62 @@ function dbgenerated(expr: String?): Any {
117
118
  } @@@expressionContext([DefaultValue])
118
119
 
119
120
  /**
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.
121
+ * Checks if the field value contains the search string. By default, the search is case-sensitive, and
122
+ * "LIKE" operator is used to match. If `caseInSensitive` is true, "ILIKE" operator is used if
123
+ * supported, otherwise it still falls back to "LIKE" and delivers whatever the database's
124
+ * behavior is.
128
125
  */
129
126
  function contains(field: String, search: String, caseInSensitive: Boolean?): Boolean {
130
127
  } @@@expressionContext([AccessPolicy, ValidationRule])
131
128
 
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])
129
+ // /**
130
+ // * 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.
131
+ // */
132
+ // function search(field: String, search: String): Boolean {
133
+ // } @@@expressionContext([AccessPolicy])
137
134
 
138
135
  /**
139
- * If the field value starts with the search string
136
+ * Checks the field value starts with the search string. By default, the search is case-sensitive, and
137
+ * "LIKE" operator is used to match. If `caseInSensitive` is true, "ILIKE" operator is used if
138
+ * supported, otherwise it still falls back to "LIKE" and delivers whatever the database's
139
+ * behavior is.
140
140
  */
141
- function startsWith(field: String, search: String): Boolean {
141
+ function startsWith(field: String, search: String, caseInSensitive: Boolean?): Boolean {
142
142
  } @@@expressionContext([AccessPolicy, ValidationRule])
143
143
 
144
144
  /**
145
- * If the field value ends with the search string
145
+ * Checks if the field value ends with the search string. By default, the search is case-sensitive, and
146
+ * "LIKE" operator is used to match. If `caseInSensitive` is true, "ILIKE" operator is used if
147
+ * supported, otherwise it still falls back to "LIKE" and delivers whatever the database's
148
+ * behavior is.
146
149
  */
147
- function endsWith(field: String, search: String): Boolean {
150
+ function endsWith(field: String, search: String, caseInSensitive: Boolean?): Boolean {
148
151
  } @@@expressionContext([AccessPolicy, ValidationRule])
149
152
 
150
153
  /**
151
- * If the field value (a list) has the given search value
154
+ * Checks if the list field has the given search value
152
155
  */
153
156
  function has(field: Any[], search: Any): Boolean {
154
157
  } @@@expressionContext([AccessPolicy, ValidationRule])
155
158
 
156
159
  /**
157
- * If the field value (a list) has every element of the search list
160
+ * Checks if the list field has at least one element of the search list
158
161
  */
159
- function hasEvery(field: Any[], search: Any[]): Boolean {
162
+ function hasSome(field: Any[], search: Any[]): Boolean {
160
163
  } @@@expressionContext([AccessPolicy, ValidationRule])
161
164
 
162
165
  /**
163
- * If the field value (a list) has at least one element of the search list
166
+ * Checks if the list field has every element of the search list
164
167
  */
165
- function hasSome(field: Any[], search: Any[]): Boolean {
168
+ function hasEvery(field: Any[], search: Any[]): Boolean {
166
169
  } @@@expressionContext([AccessPolicy, ValidationRule])
167
170
 
168
171
  /**
169
- * If the field value (a list) is empty
172
+ * Checks if the list field is empty
170
173
  */
171
174
  function isEmpty(field: Any[]): Boolean {
172
175
  } @@@expressionContext([AccessPolicy, ValidationRule])
173
176
 
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
177
  /**
198
178
  * Marks an attribute to be only applicable to certain field types.
199
179
  */
@@ -402,12 +382,14 @@ attribute @map(_ name: String) @@@prisma
402
382
  attribute @@map(_ name: String) @@@prisma
403
383
 
404
384
  /**
405
- * Exclude a field from the Prisma Client (for example, a field that you do not want Prisma users to update).
385
+ * Exclude a field from the ORM Client (for example, a field that you do not want Prisma users to update).
386
+ * The field is still recognized by database schema migrations.
406
387
  */
407
388
  attribute @ignore() @@@prisma
408
389
 
409
390
  /**
410
- * Exclude a model from the Prisma Client (for example, a model that you do not want Prisma users to update).
391
+ * Exclude a model from the ORM Client (for example, a model that you do not want Prisma users to update).
392
+ * The model is still recognized by database schema migrations.
411
393
  */
412
394
  attribute @@ignore() @@@prisma
413
395
 
@@ -484,9 +466,9 @@ attribute @db.ByteA() @@@targetField([BytesField]) @@@prisma
484
466
  //////////////////////////////////////////////
485
467
 
486
468
  /**
487
- * Validates length of a string field.
469
+ * Validates length of a string field or list field.
488
470
  */
489
- attribute @length(_ min: Int?, _ max: Int?, _ message: String?) @@@targetField([StringField]) @@@validation
471
+ attribute @length(_ min: Int?, _ max: Int?, _ message: String?) @@@targetField([StringField, ListField]) @@@validation
490
472
 
491
473
  /**
492
474
  * Validates a string field value starts with the given text.
@@ -541,22 +523,22 @@ attribute @upper() @@@targetField([StringField]) @@@validation
541
523
  /**
542
524
  * Validates a number field is greater than the given value.
543
525
  */
544
- attribute @gt(_ value: Int, _ message: String?) @@@targetField([IntField, FloatField, DecimalField]) @@@validation
526
+ attribute @gt(_ value: Any, _ message: String?) @@@targetField([IntField, FloatField, DecimalField, BigIntField]) @@@validation
545
527
 
546
528
  /**
547
529
  * Validates a number field is greater than or equal to the given value.
548
530
  */
549
- attribute @gte(_ value: Int, _ message: String?) @@@targetField([IntField, FloatField, DecimalField]) @@@validation
531
+ attribute @gte(_ value: Any, _ message: String?) @@@targetField([IntField, FloatField, DecimalField, BigIntField]) @@@validation
550
532
 
551
533
  /**
552
534
  * Validates a number field is less than the given value.
553
535
  */
554
- attribute @lt(_ value: Int, _ message: String?) @@@targetField([IntField, FloatField, DecimalField]) @@@validation
536
+ attribute @lt(_ value: Any, _ message: String?) @@@targetField([IntField, FloatField, DecimalField, BigIntField]) @@@validation
555
537
 
556
538
  /**
557
539
  * Validates a number field is less than or equal to the given value.
558
540
  */
559
- attribute @lte(_ value: Int, _ message: String?) @@@targetField([IntField, FloatField, DecimalField]) @@@validation
541
+ attribute @lte(_ value: Any, _ message: String?) @@@targetField([IntField, FloatField, DecimalField, BigIntField]) @@@validation
560
542
 
561
543
  /**
562
544
  * Validates the entity with a complex condition.
@@ -564,46 +546,36 @@ attribute @lte(_ value: Int, _ message: String?) @@@targetField([IntField, Float
564
546
  attribute @@validate(_ value: Boolean, _ message: String?, _ path: String[]?) @@@validation
565
547
 
566
548
  /**
567
- * Validates length of a string field.
549
+ * Returns the length of a string field or a list field.
568
550
  */
569
- function length(field: String, min: Int, max: Int?): Boolean {
551
+ function length(field: Any): Int {
570
552
  } @@@expressionContext([ValidationRule])
571
553
 
572
554
 
573
555
  /**
574
- * Validates a string field value matches a regex.
556
+ * Validates a string field value matches a regex pattern.
575
557
  */
576
- function regex(field: String, regex: String): Boolean {
558
+ function regex(field: String, pattern: String): Boolean {
577
559
  } @@@expressionContext([ValidationRule])
578
560
 
579
561
  /**
580
562
  * Validates a string field value is a valid email address.
581
563
  */
582
- function email(field: String): Boolean {
564
+ function isEmail(field: String): Boolean {
583
565
  } @@@expressionContext([ValidationRule])
584
566
 
585
567
  /**
586
568
  * Validates a string field value is a valid ISO datetime.
587
569
  */
588
- function datetime(field: String): Boolean {
570
+ function isDateTime(field: String): Boolean {
589
571
  } @@@expressionContext([ValidationRule])
590
572
 
591
573
  /**
592
574
  * Validates a string field value is a valid url.
593
575
  */
594
- function url(field: String): Boolean {
576
+ function isUrl(field: String): Boolean {
595
577
  } @@@expressionContext([ValidationRule])
596
578
 
597
- /**
598
- * Checks if the current user can perform the given operation on the given field.
599
- *
600
- * @param field: The field to check access for
601
- * @param operation: The operation to check access for. Can be "read", "create", "update", or "delete". If the operation is not provided,
602
- * it defaults the operation of the containing policy rule.
603
- */
604
- function check(field: Any, operation: String?): Boolean {
605
- } @@@expressionContext([AccessPolicy])
606
-
607
579
  //////////////////////////////////////////////
608
580
  // End validation attributes and functions
609
581
  //////////////////////////////////////////////