@zenstackhq/language 3.0.0-beta.7 → 3.0.0-beta.9
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 +155 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +156 -51
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +13 -13
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -3
- package/dist/utils.d.ts +2 -3
- package/dist/utils.js +12 -11
- package/dist/utils.js.map +1 -1
- package/package.json +6 -5
- package/res/stdlib.zmodel +18 -17
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
|
/**
|
|
@@ -486,9 +487,9 @@ attribute @db.ByteA() @@@targetField([BytesField]) @@@prisma
|
|
|
486
487
|
//////////////////////////////////////////////
|
|
487
488
|
|
|
488
489
|
/**
|
|
489
|
-
* Validates length of a string field.
|
|
490
|
+
* Validates length of a string field or list field.
|
|
490
491
|
*/
|
|
491
|
-
attribute @length(_ min: Int?, _ max: Int?, _ message: String?) @@@targetField([StringField]) @@@validation
|
|
492
|
+
attribute @length(_ min: Int?, _ max: Int?, _ message: String?) @@@targetField([StringField, ListField]) @@@validation
|
|
492
493
|
|
|
493
494
|
/**
|
|
494
495
|
* Validates a string field value starts with the given text.
|
|
@@ -543,22 +544,22 @@ attribute @upper() @@@targetField([StringField]) @@@validation
|
|
|
543
544
|
/**
|
|
544
545
|
* Validates a number field is greater than the given value.
|
|
545
546
|
*/
|
|
546
|
-
attribute @gt(_ value:
|
|
547
|
+
attribute @gt(_ value: Any, _ message: String?) @@@targetField([IntField, FloatField, DecimalField, BigIntField]) @@@validation
|
|
547
548
|
|
|
548
549
|
/**
|
|
549
550
|
* Validates a number field is greater than or equal to the given value.
|
|
550
551
|
*/
|
|
551
|
-
attribute @gte(_ value:
|
|
552
|
+
attribute @gte(_ value: Any, _ message: String?) @@@targetField([IntField, FloatField, DecimalField, BigIntField]) @@@validation
|
|
552
553
|
|
|
553
554
|
/**
|
|
554
555
|
* Validates a number field is less than the given value.
|
|
555
556
|
*/
|
|
556
|
-
attribute @lt(_ value:
|
|
557
|
+
attribute @lt(_ value: Any, _ message: String?) @@@targetField([IntField, FloatField, DecimalField, BigIntField]) @@@validation
|
|
557
558
|
|
|
558
559
|
/**
|
|
559
560
|
* Validates a number field is less than or equal to the given value.
|
|
560
561
|
*/
|
|
561
|
-
attribute @lte(_ value:
|
|
562
|
+
attribute @lte(_ value: Any, _ message: String?) @@@targetField([IntField, FloatField, DecimalField, BigIntField]) @@@validation
|
|
562
563
|
|
|
563
564
|
/**
|
|
564
565
|
* Validates the entity with a complex condition.
|
|
@@ -566,9 +567,9 @@ attribute @lte(_ value: Int, _ message: String?) @@@targetField([IntField, Float
|
|
|
566
567
|
attribute @@validate(_ value: Boolean, _ message: String?, _ path: String[]?) @@@validation
|
|
567
568
|
|
|
568
569
|
/**
|
|
569
|
-
*
|
|
570
|
+
* Returns the length of a string field or a list field.
|
|
570
571
|
*/
|
|
571
|
-
function length(field:
|
|
572
|
+
function length(field: Any): Int {
|
|
572
573
|
} @@@expressionContext([ValidationRule])
|
|
573
574
|
|
|
574
575
|
|
|
@@ -581,19 +582,19 @@ function regex(field: String, regex: String): Boolean {
|
|
|
581
582
|
/**
|
|
582
583
|
* Validates a string field value is a valid email address.
|
|
583
584
|
*/
|
|
584
|
-
function
|
|
585
|
+
function isEmail(field: String): Boolean {
|
|
585
586
|
} @@@expressionContext([ValidationRule])
|
|
586
587
|
|
|
587
588
|
/**
|
|
588
589
|
* Validates a string field value is a valid ISO datetime.
|
|
589
590
|
*/
|
|
590
|
-
function
|
|
591
|
+
function isDateTime(field: String): Boolean {
|
|
591
592
|
} @@@expressionContext([ValidationRule])
|
|
592
593
|
|
|
593
594
|
/**
|
|
594
595
|
* Validates a string field value is a valid url.
|
|
595
596
|
*/
|
|
596
|
-
function
|
|
597
|
+
function isUrl(field: String): Boolean {
|
|
597
598
|
} @@@expressionContext([ValidationRule])
|
|
598
599
|
|
|
599
600
|
//////////////////////////////////////////////
|
|
@@ -666,7 +667,7 @@ attribute @@@deprecated(_ message: String)
|
|
|
666
667
|
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
667
668
|
* @param condition: a boolean expression that controls if the operation should be allowed.
|
|
668
669
|
*/
|
|
669
|
-
attribute @@allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
|
|
670
|
+
attribute @@allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'post-update'","'delete'", "'all'"]), _ condition: Boolean)
|
|
670
671
|
|
|
671
672
|
/**
|
|
672
673
|
* Defines an access policy that allows the annotated field to be read or updated.
|
|
@@ -676,7 +677,7 @@ attribute @@allow(_ operation: String @@@completionHint(["'create'", "'read'", "
|
|
|
676
677
|
* @param condition: a boolean expression that controls if the operation should be allowed.
|
|
677
678
|
* @param override: a boolean value that controls if the field-level policy should override the model-level policy.
|
|
678
679
|
*/
|
|
679
|
-
attribute @allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean, _ override: Boolean?)
|
|
680
|
+
// attribute @allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean, _ override: Boolean?)
|
|
680
681
|
|
|
681
682
|
/**
|
|
682
683
|
* Defines an access policy that denies a set of operations when the given condition is true.
|
|
@@ -684,7 +685,7 @@ attribute @allow(_ operation: String @@@completionHint(["'create'", "'read'", "'
|
|
|
684
685
|
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
685
686
|
* @param condition: a boolean expression that controls if the operation should be denied.
|
|
686
687
|
*/
|
|
687
|
-
attribute @@deny(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
|
|
688
|
+
attribute @@deny(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'post-update'","'delete'", "'all'"]), _ condition: Boolean)
|
|
688
689
|
|
|
689
690
|
/**
|
|
690
691
|
* Defines an access policy that denies the annotated field to be read or updated.
|
|
@@ -692,7 +693,7 @@ attribute @@deny(_ operation: String @@@completionHint(["'create'", "'read'", "'
|
|
|
692
693
|
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
693
694
|
* @param condition: a boolean expression that controls if the operation should be denied.
|
|
694
695
|
*/
|
|
695
|
-
attribute @deny(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
|
|
696
|
+
// attribute @deny(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
|
|
696
697
|
|
|
697
698
|
/**
|
|
698
699
|
* Checks if the current user can perform the given operation on the given field.
|
|
@@ -705,8 +706,8 @@ function check(field: Any, operation: String?): Boolean {
|
|
|
705
706
|
} @@@expressionContext([AccessPolicy])
|
|
706
707
|
|
|
707
708
|
/**
|
|
708
|
-
* Gets
|
|
709
|
+
* Gets entity's value before an update. Only valid when used in a "post-update" policy rule.
|
|
709
710
|
*/
|
|
710
|
-
function
|
|
711
|
+
function before(): Any {
|
|
711
712
|
} @@@expressionContext([AccessPolicy])
|
|
712
713
|
|