@zenstackhq/language 3.0.0-beta.25 → 3.0.0-beta.27
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 +24 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/res/stdlib.zmodel +7 -0
package/dist/index.cjs
CHANGED
|
@@ -7046,6 +7046,13 @@ var FunctionInvocationValidator = class {
|
|
|
7046
7046
|
}
|
|
7047
7047
|
return true;
|
|
7048
7048
|
}
|
|
7049
|
+
_checkAuth(expr, accept) {
|
|
7050
|
+
if (!expr.$resolvedType) {
|
|
7051
|
+
accept("error", 'cannot resolve `auth()` - make sure you have a model or type with `@auth` attribute or named "User"', {
|
|
7052
|
+
node: expr
|
|
7053
|
+
});
|
|
7054
|
+
}
|
|
7055
|
+
}
|
|
7049
7056
|
_checkLength(expr, accept) {
|
|
7050
7057
|
const msg = "argument must be a string or list field";
|
|
7051
7058
|
const fieldArg = expr.args[0].value;
|
|
@@ -7155,6 +7162,15 @@ var FunctionInvocationValidator = class {
|
|
|
7155
7162
|
}
|
|
7156
7163
|
}
|
|
7157
7164
|
};
|
|
7165
|
+
_ts_decorate2([
|
|
7166
|
+
func("auth"),
|
|
7167
|
+
_ts_metadata2("design:type", Function),
|
|
7168
|
+
_ts_metadata2("design:paramtypes", [
|
|
7169
|
+
typeof InvocationExpr === "undefined" ? Object : InvocationExpr,
|
|
7170
|
+
typeof ValidationAcceptor === "undefined" ? Object : ValidationAcceptor
|
|
7171
|
+
]),
|
|
7172
|
+
_ts_metadata2("design:returntype", void 0)
|
|
7173
|
+
], FunctionInvocationValidator.prototype, "_checkAuth", null);
|
|
7158
7174
|
_ts_decorate2([
|
|
7159
7175
|
func("length"),
|
|
7160
7176
|
_ts_metadata2("design:type", Function),
|
|
@@ -7263,6 +7279,7 @@ function registerValidationChecks(services) {
|
|
|
7263
7279
|
const checks = {
|
|
7264
7280
|
Model: validator.checkModel,
|
|
7265
7281
|
DataSource: validator.checkDataSource,
|
|
7282
|
+
GeneratorDecl: validator.checkGenerator,
|
|
7266
7283
|
DataModel: validator.checkDataModel,
|
|
7267
7284
|
TypeDef: validator.checkTypeDef,
|
|
7268
7285
|
Enum: validator.checkEnum,
|
|
@@ -7288,6 +7305,11 @@ var ZModelValidator = class {
|
|
|
7288
7305
|
checkDataSource(node, accept) {
|
|
7289
7306
|
new DataSourceValidator().validate(node, accept);
|
|
7290
7307
|
}
|
|
7308
|
+
checkGenerator(node, accept) {
|
|
7309
|
+
accept("warning", '"generator" is not used by ZenStack and should be removed.', {
|
|
7310
|
+
node
|
|
7311
|
+
});
|
|
7312
|
+
}
|
|
7291
7313
|
checkDataModel(node, accept) {
|
|
7292
7314
|
new DataModelValidator().validate(node, accept);
|
|
7293
7315
|
}
|
|
@@ -8744,10 +8766,7 @@ var ZModelScopeProvider = class extends import_langium11.DefaultScopeProvider {
|
|
|
8744
8766
|
const referenceType = this.reflection.getReferenceType(context);
|
|
8745
8767
|
const globalScope = this.getGlobalScope(referenceType, context);
|
|
8746
8768
|
const node = context.container;
|
|
8747
|
-
const allowTypeDefScope = (
|
|
8748
|
-
// isAuthOrAuthMemberAccess(node.operand) ||
|
|
8749
|
-
!!import_langium11.AstUtils.getContainerOfType(node, isTypeDef)
|
|
8750
|
-
);
|
|
8769
|
+
const allowTypeDefScope = isAuthOrAuthMemberAccess(node.operand) || !!import_langium11.AstUtils.getContainerOfType(node, isTypeDef);
|
|
8751
8770
|
return (0, import_ts_pattern5.match)(node.operand).when(isReferenceExpr, (operand) => {
|
|
8752
8771
|
const ref = operand.target.ref;
|
|
8753
8772
|
if (isDataField(ref)) {
|
|
@@ -8776,7 +8795,7 @@ var ZModelScopeProvider = class extends import_langium11.DefaultScopeProvider {
|
|
|
8776
8795
|
const referenceType = this.reflection.getReferenceType(context);
|
|
8777
8796
|
const globalScope = this.getGlobalScope(referenceType, context);
|
|
8778
8797
|
const collection = collectionPredicate.left;
|
|
8779
|
-
const allowTypeDefScope =
|
|
8798
|
+
const allowTypeDefScope = isAuthOrAuthMemberAccess(collection);
|
|
8780
8799
|
return (0, import_ts_pattern5.match)(collection).when(isReferenceExpr, (expr) => {
|
|
8781
8800
|
const ref = expr.target.ref;
|
|
8782
8801
|
if (isDataField(ref)) {
|