@zenstackhq/language 3.0.0-beta.9 → 3.0.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/dist/index.cjs +1524 -235
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -19
- package/dist/index.d.ts +89 -19
- package/dist/index.js +1470 -185
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +99 -8
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +7 -5
- package/dist/utils.d.ts +7 -5
- package/dist/utils.js +93 -5
- package/dist/utils.js.map +1 -1
- package/package.json +9 -11
- package/res/stdlib.zmodel +30 -97
package/res/stdlib.zmodel
CHANGED
|
@@ -126,11 +126,11 @@ function dbgenerated(expr: String?): Any {
|
|
|
126
126
|
function contains(field: String, search: String, caseInSensitive: Boolean?): Boolean {
|
|
127
127
|
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
function search(field: String, search: String): Boolean {
|
|
133
|
-
} @@@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])
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
* Checks the field value starts with the search string. By default, the search is case-sensitive, and
|
|
@@ -151,52 +151,29 @@ function endsWith(field: String, search: String, caseInSensitive: Boolean?): Boo
|
|
|
151
151
|
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
154
|
+
* Checks if the list field has the given search value
|
|
155
155
|
*/
|
|
156
156
|
function has(field: Any[], search: Any): Boolean {
|
|
157
157
|
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
|
-
*
|
|
160
|
+
* Checks if the list field has at least one element of the search list
|
|
161
161
|
*/
|
|
162
|
-
function
|
|
162
|
+
function hasSome(field: Any[], search: Any[]): Boolean {
|
|
163
163
|
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
*
|
|
166
|
+
* Checks if the list field has every element of the search list
|
|
167
167
|
*/
|
|
168
|
-
function
|
|
168
|
+
function hasEvery(field: Any[], search: Any[]): Boolean {
|
|
169
169
|
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
|
-
*
|
|
172
|
+
* Checks if the list field is empty
|
|
173
173
|
*/
|
|
174
174
|
function isEmpty(field: Any[]): Boolean {
|
|
175
175
|
} @@@expressionContext([AccessPolicy, ValidationRule])
|
|
176
176
|
|
|
177
|
-
/**
|
|
178
|
-
* The name of the model for which the policy rule is defined. If the rule is
|
|
179
|
-
* inherited to a sub model, this function returns the name of the sub model.
|
|
180
|
-
*
|
|
181
|
-
* @param optional parameter to control the casing of the returned value. Valid
|
|
182
|
-
* values are "original", "upper", "lower", "capitalize", "uncapitalize". Defaults
|
|
183
|
-
* to "original".
|
|
184
|
-
*/
|
|
185
|
-
function currentModel(casing: String?): String {
|
|
186
|
-
} @@@expressionContext([AccessPolicy])
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* The operation for which the policy rule is defined for. Note that a rule with
|
|
190
|
-
* "all" operation is expanded to "create", "read", "update", and "delete" rules,
|
|
191
|
-
* and the function returns corresponding value for each expanded version.
|
|
192
|
-
*
|
|
193
|
-
* @param optional parameter to control the casing of the returned value. Valid
|
|
194
|
-
* values are "original", "upper", "lower", "capitalize", "uncapitalize". Defaults
|
|
195
|
-
* to "original".
|
|
196
|
-
*/
|
|
197
|
-
function currentOperation(casing: String?): String {
|
|
198
|
-
} @@@expressionContext([AccessPolicy])
|
|
199
|
-
|
|
200
177
|
/**
|
|
201
178
|
* Marks an attribute to be only applicable to certain field types.
|
|
202
179
|
*/
|
|
@@ -405,15 +382,24 @@ attribute @map(_ name: String) @@@prisma
|
|
|
405
382
|
attribute @@map(_ name: String) @@@prisma
|
|
406
383
|
|
|
407
384
|
/**
|
|
408
|
-
* Exclude a field from the
|
|
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.
|
|
409
387
|
*/
|
|
410
388
|
attribute @ignore() @@@prisma
|
|
411
389
|
|
|
412
390
|
/**
|
|
413
|
-
* Exclude a model from the
|
|
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.
|
|
414
393
|
*/
|
|
415
394
|
attribute @@ignore() @@@prisma
|
|
416
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Indicates that the field should be omitted by default when read with an ORM client. The omission can be
|
|
398
|
+
* overridden in options passed to create `ZenStackClient`, or at query time by explicitly passing in an
|
|
399
|
+
* `omit` clause. The attribute is only effective for ORM query APIs, not for query-builder APIs.
|
|
400
|
+
*/
|
|
401
|
+
attribute @omit()
|
|
402
|
+
|
|
417
403
|
/**
|
|
418
404
|
* Automatically stores the time when a record was last updated.
|
|
419
405
|
*/
|
|
@@ -475,12 +461,12 @@ attribute @db.JsonB() @@@targetField([JsonField]) @@@prisma
|
|
|
475
461
|
|
|
476
462
|
attribute @db.ByteA() @@@targetField([BytesField]) @@@prisma
|
|
477
463
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
464
|
+
/**
|
|
465
|
+
* Specifies the schema to use in a multi-schema PostgreSQL database.
|
|
466
|
+
*
|
|
467
|
+
* @param map: The name of the database schema.
|
|
468
|
+
*/
|
|
469
|
+
attribute @@schema(_ map: String) @@@prisma
|
|
484
470
|
|
|
485
471
|
//////////////////////////////////////////////
|
|
486
472
|
// Begin validation attributes and functions
|
|
@@ -574,9 +560,9 @@ function length(field: Any): Int {
|
|
|
574
560
|
|
|
575
561
|
|
|
576
562
|
/**
|
|
577
|
-
* Validates a string field value matches a regex.
|
|
563
|
+
* Validates a string field value matches a regex pattern.
|
|
578
564
|
*/
|
|
579
|
-
function regex(field: String,
|
|
565
|
+
function regex(field: String, pattern: String): Boolean {
|
|
580
566
|
} @@@expressionContext([ValidationRule])
|
|
581
567
|
|
|
582
568
|
/**
|
|
@@ -658,56 +644,3 @@ attribute @meta(_ name: String, _ value: Any)
|
|
|
658
644
|
* Marks an attribute as deprecated.
|
|
659
645
|
*/
|
|
660
646
|
attribute @@@deprecated(_ message: String)
|
|
661
|
-
|
|
662
|
-
/* --- Policy Plugin --- */
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* Defines an access policy that allows a set of operations when the given condition is true.
|
|
666
|
-
*
|
|
667
|
-
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
668
|
-
* @param condition: a boolean expression that controls if the operation should be allowed.
|
|
669
|
-
*/
|
|
670
|
-
attribute @@allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'post-update'","'delete'", "'all'"]), _ condition: Boolean)
|
|
671
|
-
|
|
672
|
-
/**
|
|
673
|
-
* Defines an access policy that allows the annotated field to be read or updated.
|
|
674
|
-
* You can pass a third argument as `true` to make it override the model-level policies.
|
|
675
|
-
*
|
|
676
|
-
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
677
|
-
* @param condition: a boolean expression that controls if the operation should be allowed.
|
|
678
|
-
* @param override: a boolean value that controls if the field-level policy should override the model-level policy.
|
|
679
|
-
*/
|
|
680
|
-
// attribute @allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean, _ override: Boolean?)
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* Defines an access policy that denies a set of operations when the given condition is true.
|
|
684
|
-
*
|
|
685
|
-
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
686
|
-
* @param condition: a boolean expression that controls if the operation should be denied.
|
|
687
|
-
*/
|
|
688
|
-
attribute @@deny(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'post-update'","'delete'", "'all'"]), _ condition: Boolean)
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Defines an access policy that denies the annotated field to be read or updated.
|
|
692
|
-
*
|
|
693
|
-
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
694
|
-
* @param condition: a boolean expression that controls if the operation should be denied.
|
|
695
|
-
*/
|
|
696
|
-
// attribute @deny(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* Checks if the current user can perform the given operation on the given field.
|
|
700
|
-
*
|
|
701
|
-
* @param field: The field to check access for
|
|
702
|
-
* @param operation: The operation to check access for. Can be "read", "create", "update", or "delete". If the operation is not provided,
|
|
703
|
-
* it defaults the operation of the containing policy rule.
|
|
704
|
-
*/
|
|
705
|
-
function check(field: Any, operation: String?): Boolean {
|
|
706
|
-
} @@@expressionContext([AccessPolicy])
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* Gets entity's value before an update. Only valid when used in a "post-update" policy rule.
|
|
710
|
-
*/
|
|
711
|
-
function before(): Any {
|
|
712
|
-
} @@@expressionContext([AccessPolicy])
|
|
713
|
-
|