@zenstackhq/language 3.0.0-alpha.3 → 3.0.0-alpha.30
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/ast.cjs +97 -158
- package/dist/ast.cjs.map +1 -1
- package/dist/ast.d.cts +99 -133
- package/dist/ast.d.ts +99 -133
- package/dist/ast.js +81 -146
- package/dist/ast.js.map +1 -1
- package/dist/index.cjs +755 -691
- 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 +716 -652
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1528 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +94 -0
- package/dist/utils.d.ts +94 -0
- package/dist/utils.js +1453 -0
- package/dist/utils.js.map +1 -0
- package/package.json +21 -10
- package/res/stdlib.zmodel +54 -108
package/dist/index.cjs
CHANGED
|
@@ -40,47 +40,14 @@ __export(src_exports, {
|
|
|
40
40
|
loadDocument: () => loadDocument
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(src_exports);
|
|
43
|
-
var
|
|
43
|
+
var import_langium11 = require("langium");
|
|
44
44
|
var import_node = require("langium/node");
|
|
45
45
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
46
46
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
47
47
|
var import_node_url2 = require("url");
|
|
48
48
|
|
|
49
|
-
// src/constants.ts
|
|
50
|
-
var SUPPORTED_PROVIDERS = [
|
|
51
|
-
"sqlite",
|
|
52
|
-
"postgresql"
|
|
53
|
-
];
|
|
54
|
-
var SCALAR_TYPES = [
|
|
55
|
-
"String",
|
|
56
|
-
"Int",
|
|
57
|
-
"Float",
|
|
58
|
-
"Decimal",
|
|
59
|
-
"BigInt",
|
|
60
|
-
"Boolean",
|
|
61
|
-
"Bytes",
|
|
62
|
-
"DateTime"
|
|
63
|
-
];
|
|
64
|
-
var STD_LIB_MODULE_NAME = "stdlib.zmodel";
|
|
65
|
-
var PLUGIN_MODULE_NAME = "plugin.zmodel";
|
|
66
|
-
var IssueCodes = /* @__PURE__ */ function(IssueCodes2) {
|
|
67
|
-
IssueCodes2["MissingOppositeRelation"] = "miss-opposite-relation";
|
|
68
|
-
return IssueCodes2;
|
|
69
|
-
}({});
|
|
70
|
-
var ExpressionContext = /* @__PURE__ */ function(ExpressionContext2) {
|
|
71
|
-
ExpressionContext2["DefaultValue"] = "DefaultValue";
|
|
72
|
-
ExpressionContext2["AccessPolicy"] = "AccessPolicy";
|
|
73
|
-
ExpressionContext2["ValidationRule"] = "ValidationRule";
|
|
74
|
-
ExpressionContext2["Index"] = "Index";
|
|
75
|
-
return ExpressionContext2;
|
|
76
|
-
}({});
|
|
77
|
-
|
|
78
|
-
// src/module.ts
|
|
79
|
-
var import_langium11 = require("langium");
|
|
80
|
-
var import_lsp = require("langium/lsp");
|
|
81
|
-
|
|
82
49
|
// src/generated/ast.ts
|
|
83
|
-
var
|
|
50
|
+
var langium = __toESM(require("langium"), 1);
|
|
84
51
|
var AbstractDeclaration = "AbstractDeclaration";
|
|
85
52
|
var ConfigExpr = "ConfigExpr";
|
|
86
53
|
var Expression = "Expression";
|
|
@@ -96,7 +63,6 @@ __name(isLiteralExpr, "isLiteralExpr");
|
|
|
96
63
|
var MemberAccessTarget = "MemberAccessTarget";
|
|
97
64
|
var ReferenceTarget = "ReferenceTarget";
|
|
98
65
|
var TypeDeclaration = "TypeDeclaration";
|
|
99
|
-
var TypeDefFieldTypes = "TypeDefFieldTypes";
|
|
100
66
|
var Argument = "Argument";
|
|
101
67
|
var ArrayExpr = "ArrayExpr";
|
|
102
68
|
function isArrayExpr(item) {
|
|
@@ -129,6 +95,21 @@ __name(isConfigArrayExpr, "isConfigArrayExpr");
|
|
|
129
95
|
var ConfigField = "ConfigField";
|
|
130
96
|
var ConfigInvocationArg = "ConfigInvocationArg";
|
|
131
97
|
var ConfigInvocationExpr = "ConfigInvocationExpr";
|
|
98
|
+
var DataField = "DataField";
|
|
99
|
+
function isDataField(item) {
|
|
100
|
+
return reflection.isInstance(item, DataField);
|
|
101
|
+
}
|
|
102
|
+
__name(isDataField, "isDataField");
|
|
103
|
+
var DataFieldAttribute = "DataFieldAttribute";
|
|
104
|
+
function isDataFieldAttribute(item) {
|
|
105
|
+
return reflection.isInstance(item, DataFieldAttribute);
|
|
106
|
+
}
|
|
107
|
+
__name(isDataFieldAttribute, "isDataFieldAttribute");
|
|
108
|
+
var DataFieldType = "DataFieldType";
|
|
109
|
+
function isDataFieldType(item) {
|
|
110
|
+
return reflection.isInstance(item, DataFieldType);
|
|
111
|
+
}
|
|
112
|
+
__name(isDataFieldType, "isDataFieldType");
|
|
132
113
|
var DataModel = "DataModel";
|
|
133
114
|
function isDataModel(item) {
|
|
134
115
|
return reflection.isInstance(item, DataModel);
|
|
@@ -139,21 +120,6 @@ function isDataModelAttribute(item) {
|
|
|
139
120
|
return reflection.isInstance(item, DataModelAttribute);
|
|
140
121
|
}
|
|
141
122
|
__name(isDataModelAttribute, "isDataModelAttribute");
|
|
142
|
-
var DataModelField = "DataModelField";
|
|
143
|
-
function isDataModelField(item) {
|
|
144
|
-
return reflection.isInstance(item, DataModelField);
|
|
145
|
-
}
|
|
146
|
-
__name(isDataModelField, "isDataModelField");
|
|
147
|
-
var DataModelFieldAttribute = "DataModelFieldAttribute";
|
|
148
|
-
function isDataModelFieldAttribute(item) {
|
|
149
|
-
return reflection.isInstance(item, DataModelFieldAttribute);
|
|
150
|
-
}
|
|
151
|
-
__name(isDataModelFieldAttribute, "isDataModelFieldAttribute");
|
|
152
|
-
var DataModelFieldType = "DataModelFieldType";
|
|
153
|
-
function isDataModelFieldType(item) {
|
|
154
|
-
return reflection.isInstance(item, DataModelFieldType);
|
|
155
|
-
}
|
|
156
|
-
__name(isDataModelFieldType, "isDataModelFieldType");
|
|
157
123
|
var DataSource = "DataSource";
|
|
158
124
|
function isDataSource(item) {
|
|
159
125
|
return reflection.isInstance(item, DataSource);
|
|
@@ -207,6 +173,10 @@ function isObjectExpr(item) {
|
|
|
207
173
|
}
|
|
208
174
|
__name(isObjectExpr, "isObjectExpr");
|
|
209
175
|
var Plugin = "Plugin";
|
|
176
|
+
function isPlugin(item) {
|
|
177
|
+
return reflection.isInstance(item, Plugin);
|
|
178
|
+
}
|
|
179
|
+
__name(isPlugin, "isPlugin");
|
|
210
180
|
var PluginField = "PluginField";
|
|
211
181
|
var Procedure = "Procedure";
|
|
212
182
|
var ProcedureParam = "ProcedureParam";
|
|
@@ -231,15 +201,9 @@ function isTypeDef(item) {
|
|
|
231
201
|
return reflection.isInstance(item, TypeDef);
|
|
232
202
|
}
|
|
233
203
|
__name(isTypeDef, "isTypeDef");
|
|
234
|
-
var TypeDefField = "TypeDefField";
|
|
235
|
-
function isTypeDefField(item) {
|
|
236
|
-
return reflection.isInstance(item, TypeDefField);
|
|
237
|
-
}
|
|
238
|
-
__name(isTypeDefField, "isTypeDefField");
|
|
239
|
-
var TypeDefFieldType = "TypeDefFieldType";
|
|
240
204
|
var UnaryExpr = "UnaryExpr";
|
|
241
205
|
var UnsupportedFieldType = "UnsupportedFieldType";
|
|
242
|
-
var ZModelAstReflection = class extends
|
|
206
|
+
var ZModelAstReflection = class extends langium.AbstractAstReflection {
|
|
243
207
|
static {
|
|
244
208
|
__name(this, "ZModelAstReflection");
|
|
245
209
|
}
|
|
@@ -259,11 +223,11 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
259
223
|
ConfigField,
|
|
260
224
|
ConfigInvocationArg,
|
|
261
225
|
ConfigInvocationExpr,
|
|
226
|
+
DataField,
|
|
227
|
+
DataFieldAttribute,
|
|
228
|
+
DataFieldType,
|
|
262
229
|
DataModel,
|
|
263
230
|
DataModelAttribute,
|
|
264
|
-
DataModelField,
|
|
265
|
-
DataModelFieldAttribute,
|
|
266
|
-
DataModelFieldType,
|
|
267
231
|
DataSource,
|
|
268
232
|
Enum,
|
|
269
233
|
EnumField,
|
|
@@ -294,9 +258,6 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
294
258
|
ThisExpr,
|
|
295
259
|
TypeDeclaration,
|
|
296
260
|
TypeDef,
|
|
297
|
-
TypeDefField,
|
|
298
|
-
TypeDefFieldType,
|
|
299
|
-
TypeDefFieldTypes,
|
|
300
261
|
UnaryExpr,
|
|
301
262
|
UnsupportedFieldType
|
|
302
263
|
];
|
|
@@ -329,16 +290,13 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
329
290
|
case ConfigArrayExpr: {
|
|
330
291
|
return this.isSubtype(ConfigExpr, supertype);
|
|
331
292
|
}
|
|
332
|
-
case
|
|
333
|
-
return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype);
|
|
334
|
-
}
|
|
335
|
-
case DataModelField:
|
|
336
|
-
case TypeDefField: {
|
|
293
|
+
case DataField: {
|
|
337
294
|
return this.isSubtype(MemberAccessTarget, supertype) || this.isSubtype(ReferenceTarget, supertype);
|
|
338
295
|
}
|
|
296
|
+
case DataModel:
|
|
339
297
|
case Enum:
|
|
340
298
|
case TypeDef: {
|
|
341
|
-
return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype)
|
|
299
|
+
return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype);
|
|
342
300
|
}
|
|
343
301
|
case EnumField:
|
|
344
302
|
case FunctionParam: {
|
|
@@ -357,18 +315,22 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
357
315
|
const referenceId = `${refInfo.container.$type}:${refInfo.property}`;
|
|
358
316
|
switch (referenceId) {
|
|
359
317
|
case "AttributeParamType:reference":
|
|
360
|
-
case "
|
|
318
|
+
case "DataFieldType:reference":
|
|
361
319
|
case "FunctionParamType:reference": {
|
|
362
320
|
return TypeDeclaration;
|
|
363
321
|
}
|
|
364
|
-
case "
|
|
365
|
-
return DataModel;
|
|
366
|
-
}
|
|
322
|
+
case "DataFieldAttribute:decl":
|
|
367
323
|
case "DataModelAttribute:decl":
|
|
368
|
-
case "DataModelFieldAttribute:decl":
|
|
369
324
|
case "InternalAttribute:decl": {
|
|
370
325
|
return Attribute;
|
|
371
326
|
}
|
|
327
|
+
case "DataModel:baseModel": {
|
|
328
|
+
return DataModel;
|
|
329
|
+
}
|
|
330
|
+
case "DataModel:mixins":
|
|
331
|
+
case "TypeDef:mixins": {
|
|
332
|
+
return TypeDef;
|
|
333
|
+
}
|
|
372
334
|
case "InvocationExpr:function": {
|
|
373
335
|
return FunctionDecl;
|
|
374
336
|
}
|
|
@@ -378,9 +340,6 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
378
340
|
case "ReferenceExpr:target": {
|
|
379
341
|
return ReferenceTarget;
|
|
380
342
|
}
|
|
381
|
-
case "TypeDefFieldType:reference": {
|
|
382
|
-
return TypeDefFieldTypes;
|
|
383
|
-
}
|
|
384
343
|
default: {
|
|
385
344
|
throw new Error(`${referenceId} is not a valid reference id.`);
|
|
386
345
|
}
|
|
@@ -567,9 +526,9 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
567
526
|
]
|
|
568
527
|
};
|
|
569
528
|
}
|
|
570
|
-
case
|
|
529
|
+
case DataField: {
|
|
571
530
|
return {
|
|
572
|
-
name:
|
|
531
|
+
name: DataField,
|
|
573
532
|
properties: [
|
|
574
533
|
{
|
|
575
534
|
name: "attributes",
|
|
@@ -579,31 +538,18 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
579
538
|
name: "comments",
|
|
580
539
|
defaultValue: []
|
|
581
540
|
},
|
|
582
|
-
{
|
|
583
|
-
name: "fields",
|
|
584
|
-
defaultValue: []
|
|
585
|
-
},
|
|
586
|
-
{
|
|
587
|
-
name: "isAbstract",
|
|
588
|
-
defaultValue: false
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
name: "isView",
|
|
592
|
-
defaultValue: false
|
|
593
|
-
},
|
|
594
541
|
{
|
|
595
542
|
name: "name"
|
|
596
543
|
},
|
|
597
544
|
{
|
|
598
|
-
name: "
|
|
599
|
-
defaultValue: []
|
|
545
|
+
name: "type"
|
|
600
546
|
}
|
|
601
547
|
]
|
|
602
548
|
};
|
|
603
549
|
}
|
|
604
|
-
case
|
|
550
|
+
case DataFieldAttribute: {
|
|
605
551
|
return {
|
|
606
|
-
name:
|
|
552
|
+
name: DataFieldAttribute,
|
|
607
553
|
properties: [
|
|
608
554
|
{
|
|
609
555
|
name: "args",
|
|
@@ -615,61 +561,73 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
615
561
|
]
|
|
616
562
|
};
|
|
617
563
|
}
|
|
618
|
-
case
|
|
564
|
+
case DataFieldType: {
|
|
619
565
|
return {
|
|
620
|
-
name:
|
|
566
|
+
name: DataFieldType,
|
|
621
567
|
properties: [
|
|
622
568
|
{
|
|
623
|
-
name: "
|
|
624
|
-
defaultValue:
|
|
569
|
+
name: "array",
|
|
570
|
+
defaultValue: false
|
|
625
571
|
},
|
|
626
572
|
{
|
|
627
|
-
name: "
|
|
628
|
-
defaultValue:
|
|
573
|
+
name: "optional",
|
|
574
|
+
defaultValue: false
|
|
629
575
|
},
|
|
630
576
|
{
|
|
631
|
-
name: "
|
|
577
|
+
name: "reference"
|
|
632
578
|
},
|
|
633
579
|
{
|
|
634
580
|
name: "type"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
name: "unsupported"
|
|
635
584
|
}
|
|
636
585
|
]
|
|
637
586
|
};
|
|
638
587
|
}
|
|
639
|
-
case
|
|
588
|
+
case DataModel: {
|
|
640
589
|
return {
|
|
641
|
-
name:
|
|
590
|
+
name: DataModel,
|
|
642
591
|
properties: [
|
|
643
592
|
{
|
|
644
|
-
name: "
|
|
593
|
+
name: "attributes",
|
|
645
594
|
defaultValue: []
|
|
646
595
|
},
|
|
647
596
|
{
|
|
648
|
-
name: "
|
|
649
|
-
}
|
|
650
|
-
]
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
case DataModelFieldType: {
|
|
654
|
-
return {
|
|
655
|
-
name: DataModelFieldType,
|
|
656
|
-
properties: [
|
|
597
|
+
name: "baseModel"
|
|
598
|
+
},
|
|
657
599
|
{
|
|
658
|
-
name: "
|
|
659
|
-
defaultValue:
|
|
600
|
+
name: "comments",
|
|
601
|
+
defaultValue: []
|
|
660
602
|
},
|
|
661
603
|
{
|
|
662
|
-
name: "
|
|
604
|
+
name: "fields",
|
|
605
|
+
defaultValue: []
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: "isView",
|
|
663
609
|
defaultValue: false
|
|
664
610
|
},
|
|
665
611
|
{
|
|
666
|
-
name: "
|
|
612
|
+
name: "mixins",
|
|
613
|
+
defaultValue: []
|
|
667
614
|
},
|
|
668
615
|
{
|
|
669
|
-
name: "
|
|
616
|
+
name: "name"
|
|
617
|
+
}
|
|
618
|
+
]
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
case DataModelAttribute: {
|
|
622
|
+
return {
|
|
623
|
+
name: DataModelAttribute,
|
|
624
|
+
properties: [
|
|
625
|
+
{
|
|
626
|
+
name: "args",
|
|
627
|
+
defaultValue: []
|
|
670
628
|
},
|
|
671
629
|
{
|
|
672
|
-
name: "
|
|
630
|
+
name: "decl"
|
|
673
631
|
}
|
|
674
632
|
]
|
|
675
633
|
};
|
|
@@ -1043,49 +1001,11 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
1043
1001
|
defaultValue: []
|
|
1044
1002
|
},
|
|
1045
1003
|
{
|
|
1046
|
-
name: "
|
|
1047
|
-
}
|
|
1048
|
-
]
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
case TypeDefField: {
|
|
1052
|
-
return {
|
|
1053
|
-
name: TypeDefField,
|
|
1054
|
-
properties: [
|
|
1055
|
-
{
|
|
1056
|
-
name: "attributes",
|
|
1057
|
-
defaultValue: []
|
|
1058
|
-
},
|
|
1059
|
-
{
|
|
1060
|
-
name: "comments",
|
|
1004
|
+
name: "mixins",
|
|
1061
1005
|
defaultValue: []
|
|
1062
1006
|
},
|
|
1063
1007
|
{
|
|
1064
1008
|
name: "name"
|
|
1065
|
-
},
|
|
1066
|
-
{
|
|
1067
|
-
name: "type"
|
|
1068
|
-
}
|
|
1069
|
-
]
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1072
|
-
case TypeDefFieldType: {
|
|
1073
|
-
return {
|
|
1074
|
-
name: TypeDefFieldType,
|
|
1075
|
-
properties: [
|
|
1076
|
-
{
|
|
1077
|
-
name: "array",
|
|
1078
|
-
defaultValue: false
|
|
1079
|
-
},
|
|
1080
|
-
{
|
|
1081
|
-
name: "optional",
|
|
1082
|
-
defaultValue: false
|
|
1083
|
-
},
|
|
1084
|
-
{
|
|
1085
|
-
name: "reference"
|
|
1086
|
-
},
|
|
1087
|
-
{
|
|
1088
|
-
name: "type"
|
|
1089
1009
|
}
|
|
1090
1010
|
]
|
|
1091
1011
|
};
|
|
@@ -1124,18 +1044,51 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
1124
1044
|
};
|
|
1125
1045
|
var reflection = new ZModelAstReflection();
|
|
1126
1046
|
|
|
1047
|
+
// src/constants.ts
|
|
1048
|
+
var SUPPORTED_PROVIDERS = [
|
|
1049
|
+
"sqlite",
|
|
1050
|
+
"postgresql"
|
|
1051
|
+
];
|
|
1052
|
+
var SCALAR_TYPES = [
|
|
1053
|
+
"String",
|
|
1054
|
+
"Int",
|
|
1055
|
+
"Float",
|
|
1056
|
+
"Decimal",
|
|
1057
|
+
"BigInt",
|
|
1058
|
+
"Boolean",
|
|
1059
|
+
"Bytes",
|
|
1060
|
+
"DateTime"
|
|
1061
|
+
];
|
|
1062
|
+
var STD_LIB_MODULE_NAME = "stdlib.zmodel";
|
|
1063
|
+
var PLUGIN_MODULE_NAME = "plugin.zmodel";
|
|
1064
|
+
var IssueCodes = /* @__PURE__ */ function(IssueCodes2) {
|
|
1065
|
+
IssueCodes2["MissingOppositeRelation"] = "miss-opposite-relation";
|
|
1066
|
+
return IssueCodes2;
|
|
1067
|
+
}({});
|
|
1068
|
+
var ExpressionContext = /* @__PURE__ */ function(ExpressionContext2) {
|
|
1069
|
+
ExpressionContext2["DefaultValue"] = "DefaultValue";
|
|
1070
|
+
ExpressionContext2["AccessPolicy"] = "AccessPolicy";
|
|
1071
|
+
ExpressionContext2["ValidationRule"] = "ValidationRule";
|
|
1072
|
+
ExpressionContext2["Index"] = "Index";
|
|
1073
|
+
return ExpressionContext2;
|
|
1074
|
+
}({});
|
|
1075
|
+
|
|
1076
|
+
// src/module.ts
|
|
1077
|
+
var import_langium10 = require("langium");
|
|
1078
|
+
var import_lsp = require("langium/lsp");
|
|
1079
|
+
|
|
1127
1080
|
// src/generated/grammar.ts
|
|
1128
|
-
var
|
|
1081
|
+
var import_langium = require("langium");
|
|
1129
1082
|
var loadedZModelGrammar;
|
|
1130
|
-
var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZModelGrammar = (0,
|
|
1083
|
+
var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZModelGrammar = (0, import_langium.loadGrammarFromJson)(`{
|
|
1131
1084
|
"$type": "Grammar",
|
|
1132
1085
|
"isDeclared": true,
|
|
1133
1086
|
"name": "ZModel",
|
|
1134
1087
|
"rules": [
|
|
1135
1088
|
{
|
|
1136
1089
|
"$type": "ParserRule",
|
|
1137
|
-
"name": "Model",
|
|
1138
1090
|
"entry": true,
|
|
1091
|
+
"name": "Model",
|
|
1139
1092
|
"definition": {
|
|
1140
1093
|
"$type": "Group",
|
|
1141
1094
|
"elements": [
|
|
@@ -1246,7 +1199,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
1246
1199
|
{
|
|
1247
1200
|
"$type": "RuleCall",
|
|
1248
1201
|
"rule": {
|
|
1249
|
-
"$ref": "#/rules@
|
|
1202
|
+
"$ref": "#/rules@42"
|
|
1250
1203
|
},
|
|
1251
1204
|
"arguments": []
|
|
1252
1205
|
},
|
|
@@ -1821,8 +1774,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
1821
1774
|
},
|
|
1822
1775
|
{
|
|
1823
1776
|
"$type": "ParserRule",
|
|
1824
|
-
"name": "ConfigInvocationArgList",
|
|
1825
1777
|
"fragment": true,
|
|
1778
|
+
"name": "ConfigInvocationArgList",
|
|
1826
1779
|
"definition": {
|
|
1827
1780
|
"$type": "Group",
|
|
1828
1781
|
"elements": [
|
|
@@ -2129,8 +2082,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
2129
2082
|
},
|
|
2130
2083
|
{
|
|
2131
2084
|
"$type": "ParserRule",
|
|
2132
|
-
"name": "ReferenceArgList",
|
|
2133
2085
|
"fragment": true,
|
|
2086
|
+
"name": "ReferenceArgList",
|
|
2134
2087
|
"definition": {
|
|
2135
2088
|
"$type": "Group",
|
|
2136
2089
|
"elements": [
|
|
@@ -2946,8 +2899,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
2946
2899
|
},
|
|
2947
2900
|
{
|
|
2948
2901
|
"$type": "ParserRule",
|
|
2949
|
-
"name": "ArgumentList",
|
|
2950
2902
|
"fragment": true,
|
|
2903
|
+
"name": "ArgumentList",
|
|
2951
2904
|
"definition": {
|
|
2952
2905
|
"$type": "Group",
|
|
2953
2906
|
"elements": [
|
|
@@ -3040,16 +2993,6 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3040
2993
|
{
|
|
3041
2994
|
"$type": "Group",
|
|
3042
2995
|
"elements": [
|
|
3043
|
-
{
|
|
3044
|
-
"$type": "Assignment",
|
|
3045
|
-
"feature": "isAbstract",
|
|
3046
|
-
"operator": "?=",
|
|
3047
|
-
"terminal": {
|
|
3048
|
-
"$type": "Keyword",
|
|
3049
|
-
"value": "abstract"
|
|
3050
|
-
},
|
|
3051
|
-
"cardinality": "?"
|
|
3052
|
-
},
|
|
3053
2996
|
{
|
|
3054
2997
|
"$type": "Keyword",
|
|
3055
2998
|
"value": "model"
|
|
@@ -3067,45 +3010,59 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3067
3010
|
}
|
|
3068
3011
|
},
|
|
3069
3012
|
{
|
|
3070
|
-
"$type": "
|
|
3013
|
+
"$type": "Alternatives",
|
|
3071
3014
|
"elements": [
|
|
3072
3015
|
{
|
|
3073
|
-
"$type": "
|
|
3074
|
-
"
|
|
3016
|
+
"$type": "RuleCall",
|
|
3017
|
+
"rule": {
|
|
3018
|
+
"$ref": "#/rules@38"
|
|
3019
|
+
},
|
|
3020
|
+
"arguments": []
|
|
3075
3021
|
},
|
|
3076
3022
|
{
|
|
3077
|
-
"$type": "
|
|
3078
|
-
"
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3023
|
+
"$type": "RuleCall",
|
|
3024
|
+
"rule": {
|
|
3025
|
+
"$ref": "#/rules@39"
|
|
3026
|
+
},
|
|
3027
|
+
"arguments": []
|
|
3028
|
+
},
|
|
3029
|
+
{
|
|
3030
|
+
"$type": "Group",
|
|
3031
|
+
"elements": [
|
|
3032
|
+
{
|
|
3033
|
+
"$type": "RuleCall",
|
|
3034
|
+
"rule": {
|
|
3035
|
+
"$ref": "#/rules@39"
|
|
3036
|
+
},
|
|
3037
|
+
"arguments": []
|
|
3084
3038
|
},
|
|
3085
|
-
|
|
3086
|
-
|
|
3039
|
+
{
|
|
3040
|
+
"$type": "RuleCall",
|
|
3041
|
+
"rule": {
|
|
3042
|
+
"$ref": "#/rules@38"
|
|
3043
|
+
},
|
|
3044
|
+
"arguments": []
|
|
3045
|
+
}
|
|
3046
|
+
]
|
|
3087
3047
|
},
|
|
3088
3048
|
{
|
|
3089
3049
|
"$type": "Group",
|
|
3090
3050
|
"elements": [
|
|
3091
3051
|
{
|
|
3092
|
-
"$type": "
|
|
3093
|
-
"
|
|
3052
|
+
"$type": "RuleCall",
|
|
3053
|
+
"rule": {
|
|
3054
|
+
"$ref": "#/rules@38"
|
|
3055
|
+
},
|
|
3056
|
+
"arguments": []
|
|
3094
3057
|
},
|
|
3095
3058
|
{
|
|
3096
|
-
"$type": "
|
|
3097
|
-
"
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
"type": {
|
|
3102
|
-
"$ref": "#/rules@37"
|
|
3103
|
-
},
|
|
3104
|
-
"deprecatedSyntax": false
|
|
3105
|
-
}
|
|
3059
|
+
"$type": "RuleCall",
|
|
3060
|
+
"rule": {
|
|
3061
|
+
"$ref": "#/rules@39"
|
|
3062
|
+
},
|
|
3063
|
+
"arguments": []
|
|
3106
3064
|
}
|
|
3107
|
-
]
|
|
3108
|
-
"cardinality": "*"
|
|
3065
|
+
]
|
|
3109
3066
|
}
|
|
3110
3067
|
],
|
|
3111
3068
|
"cardinality": "?"
|
|
@@ -3154,7 +3111,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3154
3111
|
"terminal": {
|
|
3155
3112
|
"$type": "RuleCall",
|
|
3156
3113
|
"rule": {
|
|
3157
|
-
"$ref": "#/rules@
|
|
3114
|
+
"$ref": "#/rules@40"
|
|
3158
3115
|
},
|
|
3159
3116
|
"arguments": []
|
|
3160
3117
|
}
|
|
@@ -3189,7 +3146,92 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3189
3146
|
},
|
|
3190
3147
|
{
|
|
3191
3148
|
"$type": "ParserRule",
|
|
3192
|
-
"
|
|
3149
|
+
"fragment": true,
|
|
3150
|
+
"name": "WithClause",
|
|
3151
|
+
"definition": {
|
|
3152
|
+
"$type": "Group",
|
|
3153
|
+
"elements": [
|
|
3154
|
+
{
|
|
3155
|
+
"$type": "Keyword",
|
|
3156
|
+
"value": "with"
|
|
3157
|
+
},
|
|
3158
|
+
{
|
|
3159
|
+
"$type": "Assignment",
|
|
3160
|
+
"feature": "mixins",
|
|
3161
|
+
"operator": "+=",
|
|
3162
|
+
"terminal": {
|
|
3163
|
+
"$type": "CrossReference",
|
|
3164
|
+
"type": {
|
|
3165
|
+
"$ref": "#/rules@42"
|
|
3166
|
+
},
|
|
3167
|
+
"deprecatedSyntax": false
|
|
3168
|
+
}
|
|
3169
|
+
},
|
|
3170
|
+
{
|
|
3171
|
+
"$type": "Group",
|
|
3172
|
+
"elements": [
|
|
3173
|
+
{
|
|
3174
|
+
"$type": "Keyword",
|
|
3175
|
+
"value": ",",
|
|
3176
|
+
"cardinality": "?"
|
|
3177
|
+
},
|
|
3178
|
+
{
|
|
3179
|
+
"$type": "Assignment",
|
|
3180
|
+
"feature": "mixins",
|
|
3181
|
+
"operator": "+=",
|
|
3182
|
+
"terminal": {
|
|
3183
|
+
"$type": "CrossReference",
|
|
3184
|
+
"type": {
|
|
3185
|
+
"$ref": "#/rules@42"
|
|
3186
|
+
},
|
|
3187
|
+
"deprecatedSyntax": false
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
],
|
|
3191
|
+
"cardinality": "*"
|
|
3192
|
+
}
|
|
3193
|
+
]
|
|
3194
|
+
},
|
|
3195
|
+
"definesHiddenTokens": false,
|
|
3196
|
+
"entry": false,
|
|
3197
|
+
"hiddenTokens": [],
|
|
3198
|
+
"parameters": [],
|
|
3199
|
+
"wildcard": false
|
|
3200
|
+
},
|
|
3201
|
+
{
|
|
3202
|
+
"$type": "ParserRule",
|
|
3203
|
+
"fragment": true,
|
|
3204
|
+
"name": "ExtendsClause",
|
|
3205
|
+
"definition": {
|
|
3206
|
+
"$type": "Group",
|
|
3207
|
+
"elements": [
|
|
3208
|
+
{
|
|
3209
|
+
"$type": "Keyword",
|
|
3210
|
+
"value": "extends"
|
|
3211
|
+
},
|
|
3212
|
+
{
|
|
3213
|
+
"$type": "Assignment",
|
|
3214
|
+
"feature": "baseModel",
|
|
3215
|
+
"operator": "=",
|
|
3216
|
+
"terminal": {
|
|
3217
|
+
"$type": "CrossReference",
|
|
3218
|
+
"type": {
|
|
3219
|
+
"$ref": "#/rules@37"
|
|
3220
|
+
},
|
|
3221
|
+
"deprecatedSyntax": false
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
]
|
|
3225
|
+
},
|
|
3226
|
+
"definesHiddenTokens": false,
|
|
3227
|
+
"entry": false,
|
|
3228
|
+
"hiddenTokens": [],
|
|
3229
|
+
"parameters": [],
|
|
3230
|
+
"wildcard": false
|
|
3231
|
+
},
|
|
3232
|
+
{
|
|
3233
|
+
"$type": "ParserRule",
|
|
3234
|
+
"name": "DataField",
|
|
3193
3235
|
"definition": {
|
|
3194
3236
|
"$type": "Group",
|
|
3195
3237
|
"elements": [
|
|
@@ -3225,7 +3267,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3225
3267
|
"terminal": {
|
|
3226
3268
|
"$type": "RuleCall",
|
|
3227
3269
|
"rule": {
|
|
3228
|
-
"$ref": "#/rules@
|
|
3270
|
+
"$ref": "#/rules@41"
|
|
3229
3271
|
},
|
|
3230
3272
|
"arguments": []
|
|
3231
3273
|
}
|
|
@@ -3254,7 +3296,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3254
3296
|
},
|
|
3255
3297
|
{
|
|
3256
3298
|
"$type": "ParserRule",
|
|
3257
|
-
"name": "
|
|
3299
|
+
"name": "DataFieldType",
|
|
3258
3300
|
"definition": {
|
|
3259
3301
|
"$type": "Group",
|
|
3260
3302
|
"elements": [
|
|
@@ -3292,7 +3334,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3292
3334
|
"terminal": {
|
|
3293
3335
|
"$type": "CrossReference",
|
|
3294
3336
|
"type": {
|
|
3295
|
-
"$ref": "#/types@
|
|
3337
|
+
"$ref": "#/types@2"
|
|
3296
3338
|
},
|
|
3297
3339
|
"terminal": {
|
|
3298
3340
|
"$type": "RuleCall",
|
|
@@ -3379,6 +3421,14 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3379
3421
|
"arguments": []
|
|
3380
3422
|
}
|
|
3381
3423
|
},
|
|
3424
|
+
{
|
|
3425
|
+
"$type": "RuleCall",
|
|
3426
|
+
"rule": {
|
|
3427
|
+
"$ref": "#/rules@38"
|
|
3428
|
+
},
|
|
3429
|
+
"arguments": [],
|
|
3430
|
+
"cardinality": "?"
|
|
3431
|
+
},
|
|
3382
3432
|
{
|
|
3383
3433
|
"$type": "Keyword",
|
|
3384
3434
|
"value": "{"
|
|
@@ -3393,7 +3443,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3393
3443
|
"terminal": {
|
|
3394
3444
|
"$type": "RuleCall",
|
|
3395
3445
|
"rule": {
|
|
3396
|
-
"$ref": "#/rules@
|
|
3446
|
+
"$ref": "#/rules@40"
|
|
3397
3447
|
},
|
|
3398
3448
|
"arguments": []
|
|
3399
3449
|
}
|
|
@@ -3407,160 +3457,15 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3407
3457
|
"rule": {
|
|
3408
3458
|
"$ref": "#/rules@57"
|
|
3409
3459
|
},
|
|
3410
|
-
"arguments": []
|
|
3411
|
-
}
|
|
3412
|
-
}
|
|
3413
|
-
],
|
|
3414
|
-
"cardinality": "*"
|
|
3415
|
-
},
|
|
3416
|
-
{
|
|
3417
|
-
"$type": "Keyword",
|
|
3418
|
-
"value": "}"
|
|
3419
|
-
}
|
|
3420
|
-
]
|
|
3421
|
-
},
|
|
3422
|
-
"definesHiddenTokens": false,
|
|
3423
|
-
"entry": false,
|
|
3424
|
-
"fragment": false,
|
|
3425
|
-
"hiddenTokens": [],
|
|
3426
|
-
"parameters": [],
|
|
3427
|
-
"wildcard": false
|
|
3428
|
-
},
|
|
3429
|
-
{
|
|
3430
|
-
"$type": "ParserRule",
|
|
3431
|
-
"name": "TypeDefField",
|
|
3432
|
-
"definition": {
|
|
3433
|
-
"$type": "Group",
|
|
3434
|
-
"elements": [
|
|
3435
|
-
{
|
|
3436
|
-
"$type": "Assignment",
|
|
3437
|
-
"feature": "comments",
|
|
3438
|
-
"operator": "+=",
|
|
3439
|
-
"terminal": {
|
|
3440
|
-
"$type": "RuleCall",
|
|
3441
|
-
"rule": {
|
|
3442
|
-
"$ref": "#/rules@71"
|
|
3443
|
-
},
|
|
3444
|
-
"arguments": []
|
|
3445
|
-
},
|
|
3446
|
-
"cardinality": "*"
|
|
3447
|
-
},
|
|
3448
|
-
{
|
|
3449
|
-
"$type": "Assignment",
|
|
3450
|
-
"feature": "name",
|
|
3451
|
-
"operator": "=",
|
|
3452
|
-
"terminal": {
|
|
3453
|
-
"$type": "RuleCall",
|
|
3454
|
-
"rule": {
|
|
3455
|
-
"$ref": "#/rules@52"
|
|
3456
|
-
},
|
|
3457
|
-
"arguments": []
|
|
3458
|
-
}
|
|
3459
|
-
},
|
|
3460
|
-
{
|
|
3461
|
-
"$type": "Assignment",
|
|
3462
|
-
"feature": "type",
|
|
3463
|
-
"operator": "=",
|
|
3464
|
-
"terminal": {
|
|
3465
|
-
"$type": "RuleCall",
|
|
3466
|
-
"rule": {
|
|
3467
|
-
"$ref": "#/rules@42"
|
|
3468
|
-
},
|
|
3469
|
-
"arguments": []
|
|
3470
|
-
}
|
|
3471
|
-
},
|
|
3472
|
-
{
|
|
3473
|
-
"$type": "Assignment",
|
|
3474
|
-
"feature": "attributes",
|
|
3475
|
-
"operator": "+=",
|
|
3476
|
-
"terminal": {
|
|
3477
|
-
"$type": "RuleCall",
|
|
3478
|
-
"rule": {
|
|
3479
|
-
"$ref": "#/rules@56"
|
|
3480
|
-
},
|
|
3481
|
-
"arguments": []
|
|
3482
|
-
},
|
|
3483
|
-
"cardinality": "*"
|
|
3484
|
-
}
|
|
3485
|
-
]
|
|
3486
|
-
},
|
|
3487
|
-
"definesHiddenTokens": false,
|
|
3488
|
-
"entry": false,
|
|
3489
|
-
"fragment": false,
|
|
3490
|
-
"hiddenTokens": [],
|
|
3491
|
-
"parameters": [],
|
|
3492
|
-
"wildcard": false
|
|
3493
|
-
},
|
|
3494
|
-
{
|
|
3495
|
-
"$type": "ParserRule",
|
|
3496
|
-
"name": "TypeDefFieldType",
|
|
3497
|
-
"definition": {
|
|
3498
|
-
"$type": "Group",
|
|
3499
|
-
"elements": [
|
|
3500
|
-
{
|
|
3501
|
-
"$type": "Alternatives",
|
|
3502
|
-
"elements": [
|
|
3503
|
-
{
|
|
3504
|
-
"$type": "Assignment",
|
|
3505
|
-
"feature": "type",
|
|
3506
|
-
"operator": "=",
|
|
3507
|
-
"terminal": {
|
|
3508
|
-
"$type": "RuleCall",
|
|
3509
|
-
"rule": {
|
|
3510
|
-
"$ref": "#/rules@62"
|
|
3511
|
-
},
|
|
3512
|
-
"arguments": []
|
|
3513
|
-
}
|
|
3514
|
-
},
|
|
3515
|
-
{
|
|
3516
|
-
"$type": "Assignment",
|
|
3517
|
-
"feature": "reference",
|
|
3518
|
-
"operator": "=",
|
|
3519
|
-
"terminal": {
|
|
3520
|
-
"$type": "CrossReference",
|
|
3521
|
-
"type": {
|
|
3522
|
-
"$ref": "#/types@2"
|
|
3523
|
-
},
|
|
3524
|
-
"terminal": {
|
|
3525
|
-
"$type": "RuleCall",
|
|
3526
|
-
"rule": {
|
|
3527
|
-
"$ref": "#/rules@51"
|
|
3528
|
-
},
|
|
3529
|
-
"arguments": []
|
|
3530
|
-
},
|
|
3531
|
-
"deprecatedSyntax": false
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
3534
|
-
]
|
|
3535
|
-
},
|
|
3536
|
-
{
|
|
3537
|
-
"$type": "Group",
|
|
3538
|
-
"elements": [
|
|
3539
|
-
{
|
|
3540
|
-
"$type": "Assignment",
|
|
3541
|
-
"feature": "array",
|
|
3542
|
-
"operator": "?=",
|
|
3543
|
-
"terminal": {
|
|
3544
|
-
"$type": "Keyword",
|
|
3545
|
-
"value": "["
|
|
3546
|
-
}
|
|
3547
|
-
},
|
|
3548
|
-
{
|
|
3549
|
-
"$type": "Keyword",
|
|
3550
|
-
"value": "]"
|
|
3460
|
+
"arguments": []
|
|
3461
|
+
}
|
|
3551
3462
|
}
|
|
3552
3463
|
],
|
|
3553
|
-
"cardinality": "
|
|
3464
|
+
"cardinality": "*"
|
|
3554
3465
|
},
|
|
3555
3466
|
{
|
|
3556
|
-
"$type": "
|
|
3557
|
-
"
|
|
3558
|
-
"operator": "?=",
|
|
3559
|
-
"terminal": {
|
|
3560
|
-
"$type": "Keyword",
|
|
3561
|
-
"value": "?"
|
|
3562
|
-
},
|
|
3563
|
-
"cardinality": "?"
|
|
3467
|
+
"$type": "Keyword",
|
|
3468
|
+
"value": "}"
|
|
3564
3469
|
}
|
|
3565
3470
|
]
|
|
3566
3471
|
},
|
|
@@ -3971,7 +3876,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3971
3876
|
"terminal": {
|
|
3972
3877
|
"$type": "CrossReference",
|
|
3973
3878
|
"type": {
|
|
3974
|
-
"$ref": "#/types@
|
|
3879
|
+
"$ref": "#/types@2"
|
|
3975
3880
|
},
|
|
3976
3881
|
"terminal": {
|
|
3977
3882
|
"$type": "RuleCall",
|
|
@@ -4585,7 +4490,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
4585
4490
|
"terminal": {
|
|
4586
4491
|
"$type": "CrossReference",
|
|
4587
4492
|
"type": {
|
|
4588
|
-
"$ref": "#/types@
|
|
4493
|
+
"$ref": "#/types@2"
|
|
4589
4494
|
},
|
|
4590
4495
|
"terminal": {
|
|
4591
4496
|
"$type": "RuleCall",
|
|
@@ -4639,7 +4544,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
4639
4544
|
},
|
|
4640
4545
|
{
|
|
4641
4546
|
"$type": "ParserRule",
|
|
4642
|
-
"name": "
|
|
4547
|
+
"name": "DataFieldAttribute",
|
|
4643
4548
|
"definition": {
|
|
4644
4549
|
"$type": "Group",
|
|
4645
4550
|
"elements": [
|
|
@@ -4815,8 +4720,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
4815
4720
|
},
|
|
4816
4721
|
{
|
|
4817
4722
|
"$type": "ParserRule",
|
|
4818
|
-
"name": "AttributeArgList",
|
|
4819
4723
|
"fragment": true,
|
|
4724
|
+
"name": "AttributeArgList",
|
|
4820
4725
|
"definition": {
|
|
4821
4726
|
"$type": "Group",
|
|
4822
4727
|
"elements": [
|
|
@@ -5156,13 +5061,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
5156
5061
|
{
|
|
5157
5062
|
"$type": "SimpleType",
|
|
5158
5063
|
"typeRef": {
|
|
5159
|
-
"$ref": "#/rules@
|
|
5160
|
-
}
|
|
5161
|
-
},
|
|
5162
|
-
{
|
|
5163
|
-
"$type": "SimpleType",
|
|
5164
|
-
"typeRef": {
|
|
5165
|
-
"$ref": "#/rules@41"
|
|
5064
|
+
"$ref": "#/rules@40"
|
|
5166
5065
|
}
|
|
5167
5066
|
},
|
|
5168
5067
|
{
|
|
@@ -5178,42 +5077,10 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
5178
5077
|
"$type": "Type",
|
|
5179
5078
|
"name": "MemberAccessTarget",
|
|
5180
5079
|
"type": {
|
|
5181
|
-
"$type": "
|
|
5182
|
-
"
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
"typeRef": {
|
|
5186
|
-
"$ref": "#/rules@38"
|
|
5187
|
-
}
|
|
5188
|
-
},
|
|
5189
|
-
{
|
|
5190
|
-
"$type": "SimpleType",
|
|
5191
|
-
"typeRef": {
|
|
5192
|
-
"$ref": "#/rules@41"
|
|
5193
|
-
}
|
|
5194
|
-
}
|
|
5195
|
-
]
|
|
5196
|
-
}
|
|
5197
|
-
},
|
|
5198
|
-
{
|
|
5199
|
-
"$type": "Type",
|
|
5200
|
-
"name": "TypeDefFieldTypes",
|
|
5201
|
-
"type": {
|
|
5202
|
-
"$type": "UnionType",
|
|
5203
|
-
"types": [
|
|
5204
|
-
{
|
|
5205
|
-
"$type": "SimpleType",
|
|
5206
|
-
"typeRef": {
|
|
5207
|
-
"$ref": "#/rules@40"
|
|
5208
|
-
}
|
|
5209
|
-
},
|
|
5210
|
-
{
|
|
5211
|
-
"$type": "SimpleType",
|
|
5212
|
-
"typeRef": {
|
|
5213
|
-
"$ref": "#/rules@44"
|
|
5214
|
-
}
|
|
5215
|
-
}
|
|
5216
|
-
]
|
|
5080
|
+
"$type": "SimpleType",
|
|
5081
|
+
"typeRef": {
|
|
5082
|
+
"$ref": "#/rules@40"
|
|
5083
|
+
}
|
|
5217
5084
|
}
|
|
5218
5085
|
},
|
|
5219
5086
|
{
|
|
@@ -5231,7 +5098,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
5231
5098
|
{
|
|
5232
5099
|
"$type": "SimpleType",
|
|
5233
5100
|
"typeRef": {
|
|
5234
|
-
"$ref": "#/rules@
|
|
5101
|
+
"$ref": "#/rules@42"
|
|
5235
5102
|
}
|
|
5236
5103
|
},
|
|
5237
5104
|
{
|
|
@@ -5270,13 +5137,14 @@ var ZModelGeneratedModule = {
|
|
|
5270
5137
|
};
|
|
5271
5138
|
|
|
5272
5139
|
// src/validators/attribute-application-validator.ts
|
|
5273
|
-
var
|
|
5140
|
+
var import_langium3 = require("langium");
|
|
5274
5141
|
var import_pluralize = __toESM(require("pluralize"), 1);
|
|
5275
5142
|
|
|
5276
5143
|
// src/utils.ts
|
|
5277
|
-
var
|
|
5278
|
-
var
|
|
5144
|
+
var import_common_helpers = require("@zenstackhq/common-helpers");
|
|
5145
|
+
var import_langium2 = require("langium");
|
|
5279
5146
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
5147
|
+
var import_path = __toESM(require("path"), 1);
|
|
5280
5148
|
function hasAttribute(decl, name) {
|
|
5281
5149
|
return !!getAttribute(decl, name);
|
|
5282
5150
|
}
|
|
@@ -5286,7 +5154,7 @@ function getAttribute(decl, name) {
|
|
|
5286
5154
|
}
|
|
5287
5155
|
__name(getAttribute, "getAttribute");
|
|
5288
5156
|
function isFromStdlib(node) {
|
|
5289
|
-
const model =
|
|
5157
|
+
const model = import_langium2.AstUtils.getContainerOfType(node, isModel);
|
|
5290
5158
|
return !!model && !!model.$document && model.$document.uri.path.endsWith(STD_LIB_MODULE_NAME);
|
|
5291
5159
|
}
|
|
5292
5160
|
__name(isFromStdlib, "isFromStdlib");
|
|
@@ -5348,10 +5216,10 @@ function isEnumFieldReference(node) {
|
|
|
5348
5216
|
return isReferenceExpr(node) && isEnumField(node.target.ref);
|
|
5349
5217
|
}
|
|
5350
5218
|
__name(isEnumFieldReference, "isEnumFieldReference");
|
|
5351
|
-
function
|
|
5352
|
-
return isReferenceExpr(node) &&
|
|
5219
|
+
function isDataFieldReference(node) {
|
|
5220
|
+
return isReferenceExpr(node) && isDataField(node.target.ref);
|
|
5353
5221
|
}
|
|
5354
|
-
__name(
|
|
5222
|
+
__name(isDataFieldReference, "isDataFieldReference");
|
|
5355
5223
|
function isRelationshipField(field) {
|
|
5356
5224
|
return isDataModel(field.type.reference?.ref);
|
|
5357
5225
|
}
|
|
@@ -5371,43 +5239,14 @@ function resolved(ref) {
|
|
|
5371
5239
|
return ref.ref;
|
|
5372
5240
|
}
|
|
5373
5241
|
__name(resolved, "resolved");
|
|
5374
|
-
function
|
|
5375
|
-
for (const base of start.superTypes) {
|
|
5376
|
-
if (base.ref === target) {
|
|
5377
|
-
return [
|
|
5378
|
-
base.ref
|
|
5379
|
-
];
|
|
5380
|
-
}
|
|
5381
|
-
const path4 = findUpInheritance(base.ref, target);
|
|
5382
|
-
if (path4) {
|
|
5383
|
-
return [
|
|
5384
|
-
base.ref,
|
|
5385
|
-
...path4
|
|
5386
|
-
];
|
|
5387
|
-
}
|
|
5388
|
-
}
|
|
5389
|
-
return void 0;
|
|
5390
|
-
}
|
|
5391
|
-
__name(findUpInheritance, "findUpInheritance");
|
|
5392
|
-
function getModelFieldsWithBases(model, includeDelegate = true) {
|
|
5393
|
-
if (model.$baseMerged) {
|
|
5394
|
-
return model.fields;
|
|
5395
|
-
} else {
|
|
5396
|
-
return [
|
|
5397
|
-
...model.fields,
|
|
5398
|
-
...getRecursiveBases(model, includeDelegate).flatMap((base) => base.fields)
|
|
5399
|
-
];
|
|
5400
|
-
}
|
|
5401
|
-
}
|
|
5402
|
-
__name(getModelFieldsWithBases, "getModelFieldsWithBases");
|
|
5403
|
-
function getRecursiveBases(dataModel, includeDelegate = true, seen = /* @__PURE__ */ new Set()) {
|
|
5242
|
+
function getRecursiveBases(decl, includeDelegate = true, seen = /* @__PURE__ */ new Set()) {
|
|
5404
5243
|
const result = [];
|
|
5405
|
-
if (seen.has(
|
|
5244
|
+
if (seen.has(decl)) {
|
|
5406
5245
|
return result;
|
|
5407
5246
|
}
|
|
5408
|
-
seen.add(
|
|
5409
|
-
|
|
5410
|
-
const baseDecl =
|
|
5247
|
+
seen.add(decl);
|
|
5248
|
+
decl.mixins.forEach((mixin) => {
|
|
5249
|
+
const baseDecl = mixin.ref;
|
|
5411
5250
|
if (baseDecl) {
|
|
5412
5251
|
if (!includeDelegate && isDelegateModel(baseDecl)) {
|
|
5413
5252
|
return;
|
|
@@ -5420,14 +5259,13 @@ function getRecursiveBases(dataModel, includeDelegate = true, seen = /* @__PURE_
|
|
|
5420
5259
|
}
|
|
5421
5260
|
__name(getRecursiveBases, "getRecursiveBases");
|
|
5422
5261
|
function getModelIdFields(model) {
|
|
5423
|
-
const modelsToCheck =
|
|
5424
|
-
model
|
|
5425
|
-
] : [
|
|
5262
|
+
const modelsToCheck = [
|
|
5426
5263
|
model,
|
|
5427
5264
|
...getRecursiveBases(model)
|
|
5428
5265
|
];
|
|
5429
5266
|
for (const modelToCheck of modelsToCheck) {
|
|
5430
|
-
const
|
|
5267
|
+
const allAttributes = getAllAttributes(modelToCheck);
|
|
5268
|
+
const idAttr = allAttributes.find((attr) => attr.decl.$refText === "@@id");
|
|
5431
5269
|
if (!idAttr) {
|
|
5432
5270
|
continue;
|
|
5433
5271
|
}
|
|
@@ -5441,14 +5279,13 @@ function getModelIdFields(model) {
|
|
|
5441
5279
|
}
|
|
5442
5280
|
__name(getModelIdFields, "getModelIdFields");
|
|
5443
5281
|
function getModelUniqueFields(model) {
|
|
5444
|
-
const modelsToCheck =
|
|
5445
|
-
model
|
|
5446
|
-
] : [
|
|
5282
|
+
const modelsToCheck = [
|
|
5447
5283
|
model,
|
|
5448
5284
|
...getRecursiveBases(model)
|
|
5449
5285
|
];
|
|
5450
5286
|
for (const modelToCheck of modelsToCheck) {
|
|
5451
|
-
const
|
|
5287
|
+
const allAttributes = getAllAttributes(modelToCheck);
|
|
5288
|
+
const uniqueAttr = allAttributes.find((attr) => attr.decl.$refText === "@@unique");
|
|
5452
5289
|
if (!uniqueAttr) {
|
|
5453
5290
|
continue;
|
|
5454
5291
|
}
|
|
@@ -5557,8 +5394,8 @@ function resolveTransitiveImports(documents, model) {
|
|
|
5557
5394
|
}
|
|
5558
5395
|
__name(resolveTransitiveImports, "resolveTransitiveImports");
|
|
5559
5396
|
function resolveTransitiveImportsInternal(documents, model, initialModel = model, visited = /* @__PURE__ */ new Set(), models = /* @__PURE__ */ new Set()) {
|
|
5560
|
-
const doc =
|
|
5561
|
-
const initialDoc =
|
|
5397
|
+
const doc = import_langium2.AstUtils.getDocument(model);
|
|
5398
|
+
const initialDoc = import_langium2.AstUtils.getDocument(initialModel);
|
|
5562
5399
|
if (initialDoc.uri.fsPath.toLowerCase() !== doc.uri.fsPath.toLowerCase()) {
|
|
5563
5400
|
models.add(model);
|
|
5564
5401
|
}
|
|
@@ -5595,34 +5432,24 @@ function resolveImport(documents, imp) {
|
|
|
5595
5432
|
}
|
|
5596
5433
|
__name(resolveImport, "resolveImport");
|
|
5597
5434
|
function resolveImportUri(imp) {
|
|
5598
|
-
if (!imp.path)
|
|
5599
|
-
|
|
5600
|
-
imp.path += ".zmodel";
|
|
5601
|
-
}
|
|
5602
|
-
if (!imp.path.startsWith(".") && // Respect relative paths
|
|
5603
|
-
!import_path.default.isAbsolute(imp.path)) {
|
|
5604
|
-
const contextPath = imp.$container.$document ? import_path.default.dirname(imp.$container.$document.uri.fsPath) : process.cwd();
|
|
5605
|
-
imp.path = findNodeModulesFile(imp.path, contextPath) ?? imp.path;
|
|
5435
|
+
if (!imp.path) {
|
|
5436
|
+
return void 0;
|
|
5606
5437
|
}
|
|
5607
|
-
const doc =
|
|
5438
|
+
const doc = import_langium2.AstUtils.getDocument(imp);
|
|
5608
5439
|
const dir = import_path.default.dirname(doc.uri.fsPath);
|
|
5609
|
-
|
|
5440
|
+
const importPath = imp.path.endsWith(".zmodel") ? imp.path : `${imp.path}.zmodel`;
|
|
5441
|
+
return import_langium2.URI.file(import_path.default.resolve(dir, importPath));
|
|
5610
5442
|
}
|
|
5611
5443
|
__name(resolveImportUri, "resolveImportUri");
|
|
5612
|
-
function
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
]
|
|
5619
|
-
});
|
|
5620
|
-
return resolvedPath;
|
|
5621
|
-
} catch (error) {
|
|
5622
|
-
return void 0;
|
|
5444
|
+
function getDataModelAndTypeDefs(model, includeIgnored = false) {
|
|
5445
|
+
const r = model.declarations.filter((d) => isDataModel(d) || isTypeDef(d));
|
|
5446
|
+
if (includeIgnored) {
|
|
5447
|
+
return r;
|
|
5448
|
+
} else {
|
|
5449
|
+
return r.filter((model2) => !hasAttribute(model2, "@@ignore"));
|
|
5623
5450
|
}
|
|
5624
5451
|
}
|
|
5625
|
-
__name(
|
|
5452
|
+
__name(getDataModelAndTypeDefs, "getDataModelAndTypeDefs");
|
|
5626
5453
|
function getAllDeclarationsIncludingImports(documents, model) {
|
|
5627
5454
|
const imports = resolveTransitiveImports(documents, model);
|
|
5628
5455
|
return model.declarations.concat(...imports.map((imp) => imp.declarations));
|
|
@@ -5659,7 +5486,7 @@ __name(getAllDataModelsIncludingImports, "getAllDataModelsIncludingImports");
|
|
|
5659
5486
|
function getAllLoadedAndReachableDataModelsAndTypeDefs(langiumDocuments, fromModel) {
|
|
5660
5487
|
const allDataModels = getAllLoadedDataModelsAndTypeDefs(langiumDocuments);
|
|
5661
5488
|
if (fromModel) {
|
|
5662
|
-
const model =
|
|
5489
|
+
const model = import_langium2.AstUtils.getContainerOfType(fromModel, isModel);
|
|
5663
5490
|
if (model) {
|
|
5664
5491
|
const transitiveDataModels = getAllDataModelsIncludingImports(langiumDocuments, model);
|
|
5665
5492
|
transitiveDataModels.forEach((dm) => {
|
|
@@ -5687,6 +5514,58 @@ function isMemberContainer(node) {
|
|
|
5687
5514
|
return isDataModel(node) || isTypeDef(node);
|
|
5688
5515
|
}
|
|
5689
5516
|
__name(isMemberContainer, "isMemberContainer");
|
|
5517
|
+
function getAllFields(decl, includeIgnored = false, seen = /* @__PURE__ */ new Set()) {
|
|
5518
|
+
if (seen.has(decl)) {
|
|
5519
|
+
return [];
|
|
5520
|
+
}
|
|
5521
|
+
seen.add(decl);
|
|
5522
|
+
const fields = [];
|
|
5523
|
+
for (const mixin of decl.mixins) {
|
|
5524
|
+
(0, import_common_helpers.invariant)(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);
|
|
5525
|
+
fields.push(...getAllFields(mixin.ref, includeIgnored, seen));
|
|
5526
|
+
}
|
|
5527
|
+
if (isDataModel(decl) && decl.baseModel) {
|
|
5528
|
+
(0, import_common_helpers.invariant)(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);
|
|
5529
|
+
fields.push(...getAllFields(decl.baseModel.ref, includeIgnored, seen));
|
|
5530
|
+
}
|
|
5531
|
+
fields.push(...decl.fields.filter((f) => includeIgnored || !hasAttribute(f, "@ignore")));
|
|
5532
|
+
return fields;
|
|
5533
|
+
}
|
|
5534
|
+
__name(getAllFields, "getAllFields");
|
|
5535
|
+
function getAllAttributes(decl, seen = /* @__PURE__ */ new Set()) {
|
|
5536
|
+
if (seen.has(decl)) {
|
|
5537
|
+
return [];
|
|
5538
|
+
}
|
|
5539
|
+
seen.add(decl);
|
|
5540
|
+
const attributes = [];
|
|
5541
|
+
for (const mixin of decl.mixins) {
|
|
5542
|
+
(0, import_common_helpers.invariant)(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);
|
|
5543
|
+
attributes.push(...getAllAttributes(mixin.ref, seen));
|
|
5544
|
+
}
|
|
5545
|
+
if (isDataModel(decl) && decl.baseModel) {
|
|
5546
|
+
(0, import_common_helpers.invariant)(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);
|
|
5547
|
+
attributes.push(...getAllAttributes(decl.baseModel.ref, seen));
|
|
5548
|
+
}
|
|
5549
|
+
attributes.push(...decl.attributes);
|
|
5550
|
+
return attributes;
|
|
5551
|
+
}
|
|
5552
|
+
__name(getAllAttributes, "getAllAttributes");
|
|
5553
|
+
function getDocument(node) {
|
|
5554
|
+
const rootNode = findRootNode(node);
|
|
5555
|
+
const result = rootNode.$document;
|
|
5556
|
+
if (!result) {
|
|
5557
|
+
throw new Error("AST node has no document.");
|
|
5558
|
+
}
|
|
5559
|
+
return result;
|
|
5560
|
+
}
|
|
5561
|
+
__name(getDocument, "getDocument");
|
|
5562
|
+
function findRootNode(node) {
|
|
5563
|
+
while (node.$container) {
|
|
5564
|
+
node = node.$container;
|
|
5565
|
+
}
|
|
5566
|
+
return node;
|
|
5567
|
+
}
|
|
5568
|
+
__name(findRootNode, "findRootNode");
|
|
5690
5569
|
|
|
5691
5570
|
// src/validators/attribute-application-validator.ts
|
|
5692
5571
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -5714,7 +5593,7 @@ var AttributeApplicationValidator = class {
|
|
|
5714
5593
|
static {
|
|
5715
5594
|
__name(this, "AttributeApplicationValidator");
|
|
5716
5595
|
}
|
|
5717
|
-
validate(attr, accept) {
|
|
5596
|
+
validate(attr, accept, contextDataModel) {
|
|
5718
5597
|
const decl = attr.decl.ref;
|
|
5719
5598
|
if (!decl) {
|
|
5720
5599
|
return;
|
|
@@ -5726,21 +5605,13 @@ var AttributeApplicationValidator = class {
|
|
|
5726
5605
|
});
|
|
5727
5606
|
return;
|
|
5728
5607
|
}
|
|
5729
|
-
if (
|
|
5608
|
+
if (isDataField(targetDecl) && !isValidAttributeTarget(decl, targetDecl)) {
|
|
5730
5609
|
accept("error", `attribute "${decl.name}" cannot be used on this type of field`, {
|
|
5731
5610
|
node: attr
|
|
5732
5611
|
});
|
|
5733
5612
|
}
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
node: attr
|
|
5737
|
-
});
|
|
5738
|
-
}
|
|
5739
|
-
if (isTypeDef(targetDecl) && !hasAttribute(decl, "@@@supportTypeDef")) {
|
|
5740
|
-
accept("error", `attribute "${decl.name}" cannot be used on type declarations`, {
|
|
5741
|
-
node: attr
|
|
5742
|
-
});
|
|
5743
|
-
}
|
|
5613
|
+
this.checkDeprecation(attr, accept);
|
|
5614
|
+
this.checkDuplicatedAttributes(attr, accept, contextDataModel);
|
|
5744
5615
|
const filledParams = /* @__PURE__ */ new Set();
|
|
5745
5616
|
for (const arg of attr.args) {
|
|
5746
5617
|
let paramDecl;
|
|
@@ -5788,6 +5659,28 @@ var AttributeApplicationValidator = class {
|
|
|
5788
5659
|
checker.value.call(this, attr, accept);
|
|
5789
5660
|
}
|
|
5790
5661
|
}
|
|
5662
|
+
checkDeprecation(attr, accept) {
|
|
5663
|
+
const deprecateAttr = attr.decl.ref?.attributes.find((a) => a.decl.ref?.name === "@@@deprecated");
|
|
5664
|
+
if (deprecateAttr) {
|
|
5665
|
+
const message = getStringLiteral(deprecateAttr.args[0]?.value) ?? `Attribute "${attr.decl.ref?.name}" is deprecated`;
|
|
5666
|
+
accept("warning", message, {
|
|
5667
|
+
node: attr
|
|
5668
|
+
});
|
|
5669
|
+
}
|
|
5670
|
+
}
|
|
5671
|
+
checkDuplicatedAttributes(attr, accept, contextDataModel) {
|
|
5672
|
+
const attrDecl = attr.decl.ref;
|
|
5673
|
+
if (!attrDecl?.attributes.some((a) => a.decl.ref?.name === "@@@once")) {
|
|
5674
|
+
return;
|
|
5675
|
+
}
|
|
5676
|
+
const allAttributes = contextDataModel ? getAllAttributes(contextDataModel) : attr.$container.attributes;
|
|
5677
|
+
const duplicates = allAttributes.filter((a) => a.decl.ref === attrDecl && a !== attr);
|
|
5678
|
+
if (duplicates.length > 0) {
|
|
5679
|
+
accept("error", `Attribute "${attrDecl.name}" can only be applied once`, {
|
|
5680
|
+
node: attr
|
|
5681
|
+
});
|
|
5682
|
+
}
|
|
5683
|
+
}
|
|
5791
5684
|
_checkModelLevelPolicy(attr, accept) {
|
|
5792
5685
|
const kind = getStringLiteral(attr.args[0]?.value);
|
|
5793
5686
|
if (!kind) {
|
|
@@ -5819,7 +5712,7 @@ var AttributeApplicationValidator = class {
|
|
|
5819
5712
|
"all"
|
|
5820
5713
|
], attr, accept);
|
|
5821
5714
|
const expr = attr.args[1]?.value;
|
|
5822
|
-
if (expr &&
|
|
5715
|
+
if (expr && import_langium3.AstUtils.streamAst(expr).some((node) => isFutureExpr(node))) {
|
|
5823
5716
|
accept("error", `"future()" is not allowed in field-level policy rules`, {
|
|
5824
5717
|
node: expr
|
|
5825
5718
|
});
|
|
@@ -5836,7 +5729,7 @@ var AttributeApplicationValidator = class {
|
|
|
5836
5729
|
}
|
|
5837
5730
|
_checkValidate(attr, accept) {
|
|
5838
5731
|
const condition = attr.args[0]?.value;
|
|
5839
|
-
if (condition &&
|
|
5732
|
+
if (condition && import_langium3.AstUtils.streamAst(condition).some((node) => isDataFieldReference(node) && isDataModel(node.$resolvedType?.decl))) {
|
|
5840
5733
|
accept("error", `\`@@validate\` condition cannot use relation fields`, {
|
|
5841
5734
|
node: condition
|
|
5842
5735
|
});
|
|
@@ -5845,9 +5738,18 @@ var AttributeApplicationValidator = class {
|
|
|
5845
5738
|
_checkUnique(attr, accept) {
|
|
5846
5739
|
const fields = attr.args[0]?.value;
|
|
5847
5740
|
if (!fields) {
|
|
5741
|
+
accept("error", `expects an array of field references`, {
|
|
5742
|
+
node: attr.args[0]
|
|
5743
|
+
});
|
|
5848
5744
|
return;
|
|
5849
5745
|
}
|
|
5850
5746
|
if (isArrayExpr(fields)) {
|
|
5747
|
+
if (fields.items.length === 0) {
|
|
5748
|
+
accept("error", `\`@@unique\` expects at least one field reference`, {
|
|
5749
|
+
node: fields
|
|
5750
|
+
});
|
|
5751
|
+
return;
|
|
5752
|
+
}
|
|
5851
5753
|
fields.items.forEach((item) => {
|
|
5852
5754
|
if (!isReferenceExpr(item)) {
|
|
5853
5755
|
accept("error", `Expecting a field reference`, {
|
|
@@ -5855,7 +5757,7 @@ var AttributeApplicationValidator = class {
|
|
|
5855
5757
|
});
|
|
5856
5758
|
return;
|
|
5857
5759
|
}
|
|
5858
|
-
if (!
|
|
5760
|
+
if (!isDataField(item.target.ref)) {
|
|
5859
5761
|
accept("error", `Expecting a field reference`, {
|
|
5860
5762
|
node: item
|
|
5861
5763
|
});
|
|
@@ -5874,8 +5776,8 @@ var AttributeApplicationValidator = class {
|
|
|
5874
5776
|
}
|
|
5875
5777
|
}
|
|
5876
5778
|
rejectEncryptedFields(attr, accept) {
|
|
5877
|
-
|
|
5878
|
-
if (
|
|
5779
|
+
import_langium3.AstUtils.streamAllContents(attr).forEach((node) => {
|
|
5780
|
+
if (isDataFieldReference(node) && hasAttribute(node.target.ref, "@encrypted")) {
|
|
5879
5781
|
accept("error", `Encrypted fields cannot be used in policy rules`, {
|
|
5880
5782
|
node
|
|
5881
5783
|
});
|
|
@@ -5925,6 +5827,7 @@ _ts_decorate([
|
|
|
5925
5827
|
], AttributeApplicationValidator.prototype, "_checkValidate", null);
|
|
5926
5828
|
_ts_decorate([
|
|
5927
5829
|
check("@@unique"),
|
|
5830
|
+
check("@@id"),
|
|
5928
5831
|
_ts_metadata("design:type", Function),
|
|
5929
5832
|
_ts_metadata("design:paramtypes", [
|
|
5930
5833
|
typeof AttributeApplication === "undefined" ? Object : AttributeApplication,
|
|
@@ -5940,7 +5843,7 @@ function assignableToAttributeParam(arg, param, attr) {
|
|
|
5940
5843
|
let dstType = param.type.type;
|
|
5941
5844
|
let dstIsArray = param.type.array;
|
|
5942
5845
|
if (dstType === "ContextType") {
|
|
5943
|
-
if (
|
|
5846
|
+
if (isDataField(attr.$container)) {
|
|
5944
5847
|
dstIsArray = attr.$container.type.array;
|
|
5945
5848
|
}
|
|
5946
5849
|
}
|
|
@@ -5957,14 +5860,14 @@ function assignableToAttributeParam(arg, param, attr) {
|
|
|
5957
5860
|
}
|
|
5958
5861
|
if (dstType === "FieldReference" || dstType === "TransitiveFieldReference") {
|
|
5959
5862
|
if (dstIsArray) {
|
|
5960
|
-
return isArrayExpr(arg.value) && !arg.value.items.find((item) => !isReferenceExpr(item) || !
|
|
5863
|
+
return isArrayExpr(arg.value) && !arg.value.items.find((item) => !isReferenceExpr(item) || !isDataField(item.target.ref));
|
|
5961
5864
|
} else {
|
|
5962
|
-
return isReferenceExpr(arg.value) &&
|
|
5865
|
+
return isReferenceExpr(arg.value) && isDataField(arg.value.target.ref);
|
|
5963
5866
|
}
|
|
5964
5867
|
}
|
|
5965
5868
|
if (isEnum(argResolvedType.decl)) {
|
|
5966
5869
|
let attrArgDeclType = dstRef?.ref;
|
|
5967
|
-
if (dstType === "ContextType" &&
|
|
5870
|
+
if (dstType === "ContextType" && isDataField(attr.$container) && attr.$container?.type?.reference) {
|
|
5968
5871
|
attrArgDeclType = resolved(attr.$container.type.reference);
|
|
5969
5872
|
dstIsArray = attr.$container.type.array;
|
|
5970
5873
|
}
|
|
@@ -5974,7 +5877,7 @@ function assignableToAttributeParam(arg, param, attr) {
|
|
|
5974
5877
|
return false;
|
|
5975
5878
|
}
|
|
5976
5879
|
if (dstType === "ContextType") {
|
|
5977
|
-
if (
|
|
5880
|
+
if (isDataField(attr.$container)) {
|
|
5978
5881
|
if (!attr.$container?.type?.type) {
|
|
5979
5882
|
return false;
|
|
5980
5883
|
}
|
|
@@ -6042,8 +5945,8 @@ function isValidAttributeTarget(attrDecl, targetDecl) {
|
|
|
6042
5945
|
return allowed;
|
|
6043
5946
|
}
|
|
6044
5947
|
__name(isValidAttributeTarget, "isValidAttributeTarget");
|
|
6045
|
-
function validateAttributeApplication(attr, accept) {
|
|
6046
|
-
new AttributeApplicationValidator().validate(attr, accept);
|
|
5948
|
+
function validateAttributeApplication(attr, accept, contextDataModel) {
|
|
5949
|
+
new AttributeApplicationValidator().validate(attr, accept, contextDataModel);
|
|
6047
5950
|
}
|
|
6048
5951
|
__name(validateAttributeApplication, "validateAttributeApplication");
|
|
6049
5952
|
|
|
@@ -6058,7 +5961,8 @@ var AttributeValidator = class {
|
|
|
6058
5961
|
};
|
|
6059
5962
|
|
|
6060
5963
|
// src/validators/datamodel-validator.ts
|
|
6061
|
-
var
|
|
5964
|
+
var import_common_helpers2 = require("@zenstackhq/common-helpers");
|
|
5965
|
+
var import_langium4 = require("langium");
|
|
6062
5966
|
|
|
6063
5967
|
// src/validators/common.ts
|
|
6064
5968
|
function validateDuplicatedDeclarations(container, decls, accept) {
|
|
@@ -6070,8 +5974,8 @@ function validateDuplicatedDeclarations(container, decls, accept) {
|
|
|
6070
5974
|
for (const [name, decls2] of Object.entries(groupByName)) {
|
|
6071
5975
|
if (decls2.length > 1) {
|
|
6072
5976
|
let errorField = decls2[1];
|
|
6073
|
-
if (
|
|
6074
|
-
const nonInheritedFields = decls2.filter((x) => !(
|
|
5977
|
+
if (isDataField(decls2[0])) {
|
|
5978
|
+
const nonInheritedFields = decls2.filter((x) => !(isDataField(x) && x.$container !== container));
|
|
6075
5979
|
if (nonInheritedFields.length > 0) {
|
|
6076
5980
|
errorField = nonInheritedFields.slice(-1)[0];
|
|
6077
5981
|
}
|
|
@@ -6090,22 +5994,21 @@ var DataModelValidator = class {
|
|
|
6090
5994
|
__name(this, "DataModelValidator");
|
|
6091
5995
|
}
|
|
6092
5996
|
validate(dm, accept) {
|
|
6093
|
-
|
|
6094
|
-
this.validateBaseDelegateModel(dm, accept);
|
|
6095
|
-
validateDuplicatedDeclarations(dm, getModelFieldsWithBases(dm), accept);
|
|
5997
|
+
validateDuplicatedDeclarations(dm, getAllFields(dm), accept);
|
|
6096
5998
|
this.validateAttributes(dm, accept);
|
|
6097
5999
|
this.validateFields(dm, accept);
|
|
6098
|
-
if (dm.
|
|
6099
|
-
this.
|
|
6000
|
+
if (dm.mixins.length > 0) {
|
|
6001
|
+
this.validateMixins(dm, accept);
|
|
6100
6002
|
}
|
|
6003
|
+
this.validateInherits(dm, accept);
|
|
6101
6004
|
}
|
|
6102
6005
|
validateFields(dm, accept) {
|
|
6103
|
-
const allFields =
|
|
6006
|
+
const allFields = getAllFields(dm);
|
|
6104
6007
|
const idFields = allFields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === "@id"));
|
|
6105
6008
|
const uniqueFields = allFields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === "@unique"));
|
|
6106
6009
|
const modelLevelIds = getModelIdFields(dm);
|
|
6107
6010
|
const modelUniqueFields = getModelUniqueFields(dm);
|
|
6108
|
-
if (
|
|
6011
|
+
if (idFields.length === 0 && modelLevelIds.length === 0 && uniqueFields.length === 0 && modelUniqueFields.length === 0) {
|
|
6109
6012
|
accept("error", "Model must have at least one unique criteria. Either mark a single field with `@id`, `@unique` or add a multi field criterion with `@@id([])` or `@@unique([])` to the model.", {
|
|
6110
6013
|
node: dm
|
|
6111
6014
|
});
|
|
@@ -6136,11 +6039,9 @@ var DataModelValidator = class {
|
|
|
6136
6039
|
});
|
|
6137
6040
|
}
|
|
6138
6041
|
dm.fields.forEach((field) => this.validateField(field, accept));
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
});
|
|
6143
|
-
}
|
|
6042
|
+
allFields.filter((x) => isDataModel(x.type.reference?.ref)).forEach((y) => {
|
|
6043
|
+
this.validateRelationField(dm, y, accept);
|
|
6044
|
+
});
|
|
6144
6045
|
}
|
|
6145
6046
|
validateField(field, accept) {
|
|
6146
6047
|
if (field.type.array && field.type.optional) {
|
|
@@ -6154,9 +6055,9 @@ var DataModelValidator = class {
|
|
|
6154
6055
|
});
|
|
6155
6056
|
}
|
|
6156
6057
|
if (field.type.array && !isDataModel(field.type.reference?.ref)) {
|
|
6157
|
-
const provider = this.getDataSourceProvider(
|
|
6058
|
+
const provider = this.getDataSourceProvider(import_langium4.AstUtils.getContainerOfType(field, isModel));
|
|
6158
6059
|
if (provider === "sqlite") {
|
|
6159
|
-
accept("error", `
|
|
6060
|
+
accept("error", `List type is not supported for "${provider}" provider.`, {
|
|
6160
6061
|
node: field.type
|
|
6161
6062
|
});
|
|
6162
6063
|
}
|
|
@@ -6182,7 +6083,7 @@ var DataModelValidator = class {
|
|
|
6182
6083
|
return getLiteral(provider.value);
|
|
6183
6084
|
}
|
|
6184
6085
|
validateAttributes(dm, accept) {
|
|
6185
|
-
dm.
|
|
6086
|
+
getAllAttributes(dm).forEach((attr) => validateAttributeApplication(attr, accept, dm));
|
|
6186
6087
|
}
|
|
6187
6088
|
parseRelation(field, accept) {
|
|
6188
6089
|
const relAttr = field.attributes.find((attr) => attr.decl.ref?.name === "@relation");
|
|
@@ -6301,11 +6202,20 @@ var DataModelValidator = class {
|
|
|
6301
6202
|
if (!thisRelation.valid) {
|
|
6302
6203
|
return;
|
|
6303
6204
|
}
|
|
6304
|
-
if (this.isFieldInheritedFromDelegateModel(field
|
|
6205
|
+
if (this.isFieldInheritedFromDelegateModel(field)) {
|
|
6305
6206
|
return;
|
|
6306
6207
|
}
|
|
6208
|
+
if (this.isSelfRelation(field)) {
|
|
6209
|
+
if (!thisRelation.name) {
|
|
6210
|
+
accept("error", "Self-relation field must have a name in @relation attribute", {
|
|
6211
|
+
node: field
|
|
6212
|
+
});
|
|
6213
|
+
return;
|
|
6214
|
+
}
|
|
6215
|
+
}
|
|
6307
6216
|
const oppositeModel = field.type.reference.ref;
|
|
6308
|
-
let oppositeFields =
|
|
6217
|
+
let oppositeFields = getAllFields(oppositeModel, false).filter((f) => f !== field && // exclude self in case of self relation
|
|
6218
|
+
f.type.reference?.ref?.name === contextModel.name);
|
|
6309
6219
|
oppositeFields = oppositeFields.filter((f) => {
|
|
6310
6220
|
const fieldRel = this.parseRelation(f);
|
|
6311
6221
|
return fieldRel.valid && fieldRel.name === thisRelation.name;
|
|
@@ -6317,7 +6227,7 @@ var DataModelValidator = class {
|
|
|
6317
6227
|
};
|
|
6318
6228
|
info.property = "name";
|
|
6319
6229
|
const container = field.$container;
|
|
6320
|
-
const relationFieldDocUri =
|
|
6230
|
+
const relationFieldDocUri = import_langium4.AstUtils.getDocument(container).textDocument.uri;
|
|
6321
6231
|
const relationDataModelName = container.name;
|
|
6322
6232
|
const data = {
|
|
6323
6233
|
relationFieldName: field.name,
|
|
@@ -6342,26 +6252,37 @@ var DataModelValidator = class {
|
|
|
6342
6252
|
const oppositeField = oppositeFields[0];
|
|
6343
6253
|
const oppositeRelation = this.parseRelation(oppositeField);
|
|
6344
6254
|
let relationOwner;
|
|
6345
|
-
if (
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
if (thisRelation?.references || thisRelation?.fields) {
|
|
6356
|
-
accept("error", '"fields" and "references" must be provided only on one side of relation field', {
|
|
6357
|
-
node: field
|
|
6358
|
-
});
|
|
6359
|
-
return;
|
|
6360
|
-
} else {
|
|
6361
|
-
relationOwner = field;
|
|
6255
|
+
if (field.type.array && oppositeField.type.array) {
|
|
6256
|
+
for (const r of [
|
|
6257
|
+
thisRelation,
|
|
6258
|
+
oppositeRelation
|
|
6259
|
+
]) {
|
|
6260
|
+
if (r.fields?.length || r.references?.length) {
|
|
6261
|
+
accept("error", 'Implicit many-to-many relation cannot have "fields" or "references" in @relation attribute', {
|
|
6262
|
+
node: r === thisRelation ? field : oppositeField
|
|
6263
|
+
});
|
|
6264
|
+
}
|
|
6362
6265
|
}
|
|
6363
6266
|
} else {
|
|
6364
|
-
if (
|
|
6267
|
+
if (thisRelation?.references?.length && thisRelation.fields?.length) {
|
|
6268
|
+
if (oppositeRelation?.references || oppositeRelation?.fields) {
|
|
6269
|
+
accept("error", '"fields" and "references" must be provided only on one side of relation field', {
|
|
6270
|
+
node: oppositeField
|
|
6271
|
+
});
|
|
6272
|
+
return;
|
|
6273
|
+
} else {
|
|
6274
|
+
relationOwner = oppositeField;
|
|
6275
|
+
}
|
|
6276
|
+
} else if (oppositeRelation?.references?.length && oppositeRelation.fields?.length) {
|
|
6277
|
+
if (thisRelation?.references || thisRelation?.fields) {
|
|
6278
|
+
accept("error", '"fields" and "references" must be provided only on one side of relation field', {
|
|
6279
|
+
node: field
|
|
6280
|
+
});
|
|
6281
|
+
return;
|
|
6282
|
+
} else {
|
|
6283
|
+
relationOwner = field;
|
|
6284
|
+
}
|
|
6285
|
+
} else {
|
|
6365
6286
|
[
|
|
6366
6287
|
field,
|
|
6367
6288
|
oppositeField
|
|
@@ -6372,78 +6293,85 @@ var DataModelValidator = class {
|
|
|
6372
6293
|
});
|
|
6373
6294
|
}
|
|
6374
6295
|
});
|
|
6296
|
+
return;
|
|
6375
6297
|
}
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
});
|
|
6382
|
-
return;
|
|
6383
|
-
}
|
|
6384
|
-
if (relationOwner !== field && !relationOwner.type.array) {
|
|
6385
|
-
const containingModel = field.$container;
|
|
6386
|
-
const uniqueFieldList = getUniqueFields(containingModel);
|
|
6387
|
-
if (containingModel !== contextModel) {
|
|
6388
|
-
uniqueFieldList.push(...getUniqueFields(contextModel));
|
|
6298
|
+
if (!relationOwner.type.array && !relationOwner.type.optional) {
|
|
6299
|
+
accept("error", "Relation field needs to be list or optional", {
|
|
6300
|
+
node: relationOwner
|
|
6301
|
+
});
|
|
6302
|
+
return;
|
|
6389
6303
|
}
|
|
6390
|
-
|
|
6391
|
-
const
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
}
|
|
6396
|
-
if (uniqueFieldList.some((list) => list.includes(refField))) {
|
|
6397
|
-
return;
|
|
6398
|
-
}
|
|
6399
|
-
accept("error", `Field "${refField.name}" on model "${containingModel.name}" is part of a one-to-one relation and must be marked as @unique or be part of a model-level @@unique attribute`, {
|
|
6400
|
-
node: refField
|
|
6401
|
-
});
|
|
6304
|
+
if (relationOwner !== field && !relationOwner.type.array) {
|
|
6305
|
+
const containingModel = field.$container;
|
|
6306
|
+
const uniqueFieldList = getUniqueFields(containingModel);
|
|
6307
|
+
if (containingModel !== contextModel) {
|
|
6308
|
+
uniqueFieldList.push(...getUniqueFields(contextModel));
|
|
6402
6309
|
}
|
|
6403
|
-
|
|
6310
|
+
thisRelation.fields?.forEach((ref) => {
|
|
6311
|
+
const refField = ref.target.ref;
|
|
6312
|
+
if (refField) {
|
|
6313
|
+
if (refField.attributes.find((a) => a.decl.ref?.name === "@id" || a.decl.ref?.name === "@unique")) {
|
|
6314
|
+
return;
|
|
6315
|
+
}
|
|
6316
|
+
if (uniqueFieldList.some((list) => list.includes(refField))) {
|
|
6317
|
+
return;
|
|
6318
|
+
}
|
|
6319
|
+
accept("error", `Field "${refField.name}" on model "${containingModel.name}" is part of a one-to-one relation and must be marked as @unique or be part of a model-level @@unique attribute`, {
|
|
6320
|
+
node: refField
|
|
6321
|
+
});
|
|
6322
|
+
}
|
|
6323
|
+
});
|
|
6324
|
+
}
|
|
6404
6325
|
}
|
|
6405
6326
|
}
|
|
6406
6327
|
// checks if the given field is inherited directly or indirectly from a delegate model
|
|
6407
|
-
isFieldInheritedFromDelegateModel(field
|
|
6408
|
-
|
|
6409
|
-
if (basePath && basePath.some(isDelegateModel)) {
|
|
6410
|
-
return true;
|
|
6411
|
-
} else {
|
|
6412
|
-
return false;
|
|
6413
|
-
}
|
|
6414
|
-
}
|
|
6415
|
-
validateBaseAbstractModel(model, accept) {
|
|
6416
|
-
model.superTypes.forEach((superType, index) => {
|
|
6417
|
-
if (!superType.ref?.isAbstract && !superType.ref?.attributes.some((attr) => attr.decl.ref?.name === "@@delegate")) accept("error", `Model ${superType.$refText} cannot be extended because it's neither abstract nor marked as "@@delegate"`, {
|
|
6418
|
-
node: model,
|
|
6419
|
-
property: "superTypes",
|
|
6420
|
-
index
|
|
6421
|
-
});
|
|
6422
|
-
});
|
|
6328
|
+
isFieldInheritedFromDelegateModel(field) {
|
|
6329
|
+
return isDelegateModel(field.$container);
|
|
6423
6330
|
}
|
|
6424
|
-
|
|
6425
|
-
if (model.
|
|
6426
|
-
|
|
6331
|
+
validateInherits(model, accept) {
|
|
6332
|
+
if (!model.baseModel) {
|
|
6333
|
+
return;
|
|
6334
|
+
}
|
|
6335
|
+
(0, import_common_helpers2.invariant)(model.baseModel.ref, "baseModel must be resolved");
|
|
6336
|
+
if (!isDelegateModel(model.baseModel.ref)) {
|
|
6337
|
+
accept("error", `Model ${model.baseModel.$refText} cannot be extended because it's not a delegate model`, {
|
|
6427
6338
|
node: model,
|
|
6428
|
-
property: "
|
|
6339
|
+
property: "baseModel"
|
|
6429
6340
|
});
|
|
6341
|
+
return;
|
|
6430
6342
|
}
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
dm
|
|
6343
|
+
const seen = [];
|
|
6344
|
+
const todo = [
|
|
6345
|
+
model.baseModel.ref
|
|
6435
6346
|
];
|
|
6436
|
-
const todo = dm.superTypes.map((superType) => superType.ref);
|
|
6437
6347
|
while (todo.length > 0) {
|
|
6438
6348
|
const current = todo.shift();
|
|
6439
6349
|
if (seen.includes(current)) {
|
|
6440
|
-
accept("error", `
|
|
6350
|
+
accept("error", `Cyclic inheritance detected: ${seen.map((m) => m.name).join(" -> ")} -> ${current.name}`, {
|
|
6351
|
+
node: model
|
|
6352
|
+
});
|
|
6353
|
+
return;
|
|
6354
|
+
}
|
|
6355
|
+
seen.push(current);
|
|
6356
|
+
if (current.baseModel) {
|
|
6357
|
+
(0, import_common_helpers2.invariant)(current.baseModel.ref, "baseModel must be resolved");
|
|
6358
|
+
todo.push(current.baseModel.ref);
|
|
6359
|
+
}
|
|
6360
|
+
}
|
|
6361
|
+
}
|
|
6362
|
+
validateMixins(dm, accept) {
|
|
6363
|
+
const seen = [];
|
|
6364
|
+
const todo = dm.mixins.map((mixin) => mixin.ref);
|
|
6365
|
+
while (todo.length > 0) {
|
|
6366
|
+
const current = todo.shift();
|
|
6367
|
+
if (seen.includes(current)) {
|
|
6368
|
+
accept("error", `Cyclic mixin detected: ${seen.map((m) => m.name).join(" -> ")} -> ${current.name}`, {
|
|
6441
6369
|
node: dm
|
|
6442
6370
|
});
|
|
6443
6371
|
return;
|
|
6444
6372
|
}
|
|
6445
6373
|
seen.push(current);
|
|
6446
|
-
todo.push(...current.
|
|
6374
|
+
todo.push(...current.mixins.map((mixin) => mixin.ref));
|
|
6447
6375
|
}
|
|
6448
6376
|
}
|
|
6449
6377
|
};
|
|
@@ -6479,26 +6407,15 @@ var DataSourceValidator = class {
|
|
|
6479
6407
|
}
|
|
6480
6408
|
}
|
|
6481
6409
|
validateUrl(ds, accept) {
|
|
6482
|
-
const
|
|
6483
|
-
if (!
|
|
6484
|
-
|
|
6485
|
-
node: ds
|
|
6486
|
-
});
|
|
6410
|
+
const urlField = ds.fields.find((f) => f.name === "url");
|
|
6411
|
+
if (!urlField) {
|
|
6412
|
+
return;
|
|
6487
6413
|
}
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
"
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
if (!field) {
|
|
6494
|
-
continue;
|
|
6495
|
-
}
|
|
6496
|
-
const value = getStringLiteral(field.value);
|
|
6497
|
-
if (!value && !(isInvocationExpr(field.value) && field.value.function.ref?.name === "env")) {
|
|
6498
|
-
accept("error", `"${fieldName}" must be set to a string literal or an invocation of "env" function`, {
|
|
6499
|
-
node: field.value
|
|
6500
|
-
});
|
|
6501
|
-
}
|
|
6414
|
+
const value = getStringLiteral(urlField.value);
|
|
6415
|
+
if (!value && !(isInvocationExpr(urlField.value) && urlField.value.function.ref?.name === "env")) {
|
|
6416
|
+
accept("error", `"${urlField.name}" must be set to a string literal or an invocation of "env" function`, {
|
|
6417
|
+
node: urlField.value
|
|
6418
|
+
});
|
|
6502
6419
|
}
|
|
6503
6420
|
}
|
|
6504
6421
|
validateRelationMode(ds, accept) {
|
|
@@ -6522,7 +6439,6 @@ var EnumValidator = class {
|
|
|
6522
6439
|
static {
|
|
6523
6440
|
__name(this, "EnumValidator");
|
|
6524
6441
|
}
|
|
6525
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
6526
6442
|
validate(_enum, accept) {
|
|
6527
6443
|
validateDuplicatedDeclarations(_enum, _enum.fields, accept);
|
|
6528
6444
|
this.validateAttributes(_enum, accept);
|
|
@@ -6539,7 +6455,7 @@ var EnumValidator = class {
|
|
|
6539
6455
|
};
|
|
6540
6456
|
|
|
6541
6457
|
// src/validators/expression-validator.ts
|
|
6542
|
-
var
|
|
6458
|
+
var import_langium5 = require("langium");
|
|
6543
6459
|
var ExpressionValidator = class {
|
|
6544
6460
|
static {
|
|
6545
6461
|
__name(this, "ExpressionValidator");
|
|
@@ -6551,7 +6467,7 @@ var ExpressionValidator = class {
|
|
|
6551
6467
|
node: expr
|
|
6552
6468
|
});
|
|
6553
6469
|
} else {
|
|
6554
|
-
const hasReferenceResolutionError =
|
|
6470
|
+
const hasReferenceResolutionError = import_langium5.AstUtils.streamAst(expr).some((node) => {
|
|
6555
6471
|
if (isMemberAccessExpr(node)) {
|
|
6556
6472
|
return !!node.member.error;
|
|
6557
6473
|
}
|
|
@@ -6651,7 +6567,7 @@ var ExpressionValidator = class {
|
|
|
6651
6567
|
case "==":
|
|
6652
6568
|
case "!=": {
|
|
6653
6569
|
if (this.isInValidationContext(expr)) {
|
|
6654
|
-
if (
|
|
6570
|
+
if (isDataFieldReference(expr.left) && isNullExpr(expr.right) || isDataFieldReference(expr.right) && isNullExpr(expr.left)) {
|
|
6655
6571
|
return;
|
|
6656
6572
|
}
|
|
6657
6573
|
}
|
|
@@ -6680,11 +6596,11 @@ var ExpressionValidator = class {
|
|
|
6680
6596
|
node: expr
|
|
6681
6597
|
});
|
|
6682
6598
|
}
|
|
6683
|
-
if (
|
|
6599
|
+
if (isDataFieldReference(expr.left) && (isThisExpr(expr.right) || isDataFieldReference(expr.right))) {
|
|
6684
6600
|
accept("error", "comparison between model-typed fields are not supported", {
|
|
6685
6601
|
node: expr
|
|
6686
6602
|
});
|
|
6687
|
-
} else if (
|
|
6603
|
+
} else if (isDataFieldReference(expr.right) && (isThisExpr(expr.left) || isDataFieldReference(expr.left))) {
|
|
6688
6604
|
accept("error", "comparison between model-typed fields are not supported", {
|
|
6689
6605
|
node: expr
|
|
6690
6606
|
});
|
|
@@ -6737,7 +6653,7 @@ var FunctionDeclValidator = class {
|
|
|
6737
6653
|
};
|
|
6738
6654
|
|
|
6739
6655
|
// src/validators/function-invocation-validator.ts
|
|
6740
|
-
var
|
|
6656
|
+
var import_langium6 = require("langium");
|
|
6741
6657
|
var import_ts_pattern = require("ts-pattern");
|
|
6742
6658
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
6743
6659
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6779,7 +6695,7 @@ var FunctionInvocationValidator = class {
|
|
|
6779
6695
|
let curr = expr.$container;
|
|
6780
6696
|
let containerAttribute;
|
|
6781
6697
|
while (curr) {
|
|
6782
|
-
if (isDataModelAttribute(curr) ||
|
|
6698
|
+
if (isDataModelAttribute(curr) || isDataFieldAttribute(curr)) {
|
|
6783
6699
|
containerAttribute = curr;
|
|
6784
6700
|
break;
|
|
6785
6701
|
}
|
|
@@ -6880,7 +6796,7 @@ var FunctionInvocationValidator = class {
|
|
|
6880
6796
|
_checkCheck(expr, accept) {
|
|
6881
6797
|
let valid = true;
|
|
6882
6798
|
const fieldArg = expr.args[0].value;
|
|
6883
|
-
if (!
|
|
6799
|
+
if (!isDataFieldReference(fieldArg) || !isDataModel(fieldArg.$resolvedType?.decl)) {
|
|
6884
6800
|
accept("error", "argument must be a relation field", {
|
|
6885
6801
|
node: expr.args[0]
|
|
6886
6802
|
});
|
|
@@ -6939,7 +6855,7 @@ var FunctionInvocationValidator = class {
|
|
|
6939
6855
|
if (!rule) {
|
|
6940
6856
|
continue;
|
|
6941
6857
|
}
|
|
6942
|
-
|
|
6858
|
+
import_langium6.AstUtils.streamAst(rule).forEach((node) => {
|
|
6943
6859
|
if (isCheckInvocation(node)) {
|
|
6944
6860
|
tasks.push(node);
|
|
6945
6861
|
}
|
|
@@ -6967,10 +6883,10 @@ var SchemaValidator = class {
|
|
|
6967
6883
|
constructor(documents) {
|
|
6968
6884
|
this.documents = documents;
|
|
6969
6885
|
}
|
|
6970
|
-
|
|
6971
|
-
|
|
6886
|
+
validate(model, accept) {
|
|
6887
|
+
this.validateImports(model, accept);
|
|
6972
6888
|
validateDuplicatedDeclarations(model, model.declarations, accept);
|
|
6973
|
-
const importedModels =
|
|
6889
|
+
const importedModels = resolveTransitiveImports(this.documents, model);
|
|
6974
6890
|
const importedNames = new Set(importedModels.flatMap((m) => m.declarations.map((d) => d.name)));
|
|
6975
6891
|
for (const declaration of model.declarations) {
|
|
6976
6892
|
if (importedNames.has(declaration.name)) {
|
|
@@ -6992,16 +6908,16 @@ var SchemaValidator = class {
|
|
|
6992
6908
|
});
|
|
6993
6909
|
}
|
|
6994
6910
|
}
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
const importedModel =
|
|
6998
|
-
const importPath = imp.path.endsWith(".zmodel") ? imp.path : `${imp.path}.zmodel`;
|
|
6911
|
+
validateImports(model, accept) {
|
|
6912
|
+
model.imports.forEach((imp) => {
|
|
6913
|
+
const importedModel = resolveImport(this.documents, imp);
|
|
6999
6914
|
if (!importedModel) {
|
|
6915
|
+
const importPath = imp.path.endsWith(".zmodel") ? imp.path : `${imp.path}.zmodel`;
|
|
7000
6916
|
accept("error", `Cannot find model file ${importPath}`, {
|
|
7001
6917
|
node: imp
|
|
7002
6918
|
});
|
|
7003
6919
|
}
|
|
7004
|
-
})
|
|
6920
|
+
});
|
|
7005
6921
|
}
|
|
7006
6922
|
};
|
|
7007
6923
|
|
|
@@ -7094,9 +7010,9 @@ var ZModelValidator = class {
|
|
|
7094
7010
|
};
|
|
7095
7011
|
|
|
7096
7012
|
// src/zmodel-linker.ts
|
|
7097
|
-
var
|
|
7013
|
+
var import_langium7 = require("langium");
|
|
7098
7014
|
var import_ts_pattern2 = require("ts-pattern");
|
|
7099
|
-
var ZModelLinker = class extends
|
|
7015
|
+
var ZModelLinker = class extends import_langium7.DefaultLinker {
|
|
7100
7016
|
static {
|
|
7101
7017
|
__name(this, "ZModelLinker");
|
|
7102
7018
|
}
|
|
@@ -7106,15 +7022,15 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7106
7022
|
this.descriptions = services.workspace.AstNodeDescriptionProvider;
|
|
7107
7023
|
}
|
|
7108
7024
|
//#region Reference linking
|
|
7109
|
-
async link(document, cancelToken =
|
|
7025
|
+
async link(document, cancelToken = import_langium7.Cancellation.CancellationToken.None) {
|
|
7110
7026
|
if (document.parseResult.lexerErrors?.length > 0 || document.parseResult.parserErrors?.length > 0) {
|
|
7111
7027
|
return;
|
|
7112
7028
|
}
|
|
7113
|
-
for (const node of
|
|
7114
|
-
await (0,
|
|
7029
|
+
for (const node of import_langium7.AstUtils.streamContents(document.parseResult.value)) {
|
|
7030
|
+
await (0, import_langium7.interruptAndCheck)(cancelToken);
|
|
7115
7031
|
this.resolve(node, document);
|
|
7116
7032
|
}
|
|
7117
|
-
document.state =
|
|
7033
|
+
document.state = import_langium7.DocumentState.Linked;
|
|
7118
7034
|
}
|
|
7119
7035
|
linkReference(container, property, document, extraScopes) {
|
|
7120
7036
|
if (this.resolveFromScopeProviders(container, property, document, extraScopes)) {
|
|
@@ -7182,8 +7098,8 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7182
7098
|
case DataModel:
|
|
7183
7099
|
this.resolveDataModel(node, document, extraScopes);
|
|
7184
7100
|
break;
|
|
7185
|
-
case
|
|
7186
|
-
this.
|
|
7101
|
+
case DataField:
|
|
7102
|
+
this.resolveDataField(node, document, extraScopes);
|
|
7187
7103
|
break;
|
|
7188
7104
|
default:
|
|
7189
7105
|
this.resolveDefault(node, document, extraScopes);
|
|
@@ -7264,7 +7180,7 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7264
7180
|
if (node.function.ref) {
|
|
7265
7181
|
const funcDecl = node.function.ref;
|
|
7266
7182
|
if (isAuthInvocation(node)) {
|
|
7267
|
-
const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.langiumDocuments(),
|
|
7183
|
+
const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.langiumDocuments(), import_langium7.AstUtils.getContainerOfType(node, isDataModel));
|
|
7268
7184
|
const authDecl = getAuthDecl(allDecls);
|
|
7269
7185
|
if (authDecl) {
|
|
7270
7186
|
node.$resolvedType = {
|
|
@@ -7329,10 +7245,10 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7329
7245
|
resolveAttributeArg(node, document, extraScopes) {
|
|
7330
7246
|
const attrParam = this.findAttrParamForArg(node);
|
|
7331
7247
|
const attrAppliedOn = node.$container.$container;
|
|
7332
|
-
if (attrParam?.type.type === "TransitiveFieldReference" &&
|
|
7248
|
+
if (attrParam?.type.type === "TransitiveFieldReference" && isDataField(attrAppliedOn)) {
|
|
7333
7249
|
const transitiveDataModel = attrAppliedOn.type.reference?.ref;
|
|
7334
7250
|
if (transitiveDataModel) {
|
|
7335
|
-
const scopeProvider = /* @__PURE__ */ __name((name) =>
|
|
7251
|
+
const scopeProvider = /* @__PURE__ */ __name((name) => getAllFields(transitiveDataModel).find((f) => f.name === name), "scopeProvider");
|
|
7336
7252
|
if (isArrayExpr(node.value)) {
|
|
7337
7253
|
node.value.items.forEach((item) => {
|
|
7338
7254
|
if (isReferenceExpr(item)) {
|
|
@@ -7388,7 +7304,7 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7388
7304
|
resolveDataModel(node, document, extraScopes) {
|
|
7389
7305
|
return this.resolveDefault(node, document, extraScopes);
|
|
7390
7306
|
}
|
|
7391
|
-
|
|
7307
|
+
resolveDataField(node, document, extraScopes) {
|
|
7392
7308
|
this.resolve(node.type, document, extraScopes);
|
|
7393
7309
|
let scopes = extraScopes;
|
|
7394
7310
|
if (node.type.reference?.ref && isEnum(node.type.reference.ref)) {
|
|
@@ -7404,12 +7320,12 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7404
7320
|
resolveDefault(node, document, extraScopes) {
|
|
7405
7321
|
for (const [property, value] of Object.entries(node)) {
|
|
7406
7322
|
if (!property.startsWith("$")) {
|
|
7407
|
-
if ((0,
|
|
7323
|
+
if ((0, import_langium7.isReference)(value)) {
|
|
7408
7324
|
this.linkReference(node, property, document, extraScopes);
|
|
7409
7325
|
}
|
|
7410
7326
|
}
|
|
7411
7327
|
}
|
|
7412
|
-
for (const child of
|
|
7328
|
+
for (const child of import_langium7.AstUtils.streamContents(node)) {
|
|
7413
7329
|
this.resolve(child, document, extraScopes);
|
|
7414
7330
|
}
|
|
7415
7331
|
}
|
|
@@ -7417,7 +7333,7 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7417
7333
|
//#region Utils
|
|
7418
7334
|
resolveToDeclaredType(node, type) {
|
|
7419
7335
|
let nullable = false;
|
|
7420
|
-
if (
|
|
7336
|
+
if (isDataFieldType(type)) {
|
|
7421
7337
|
nullable = type.optional;
|
|
7422
7338
|
if (type.unsupported) {
|
|
7423
7339
|
node.$resolvedType = {
|
|
@@ -7453,9 +7369,9 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7453
7369
|
};
|
|
7454
7370
|
|
|
7455
7371
|
// src/zmodel-scope.ts
|
|
7456
|
-
var
|
|
7372
|
+
var import_langium8 = require("langium");
|
|
7457
7373
|
var import_ts_pattern3 = require("ts-pattern");
|
|
7458
|
-
var ZModelScopeComputation = class extends
|
|
7374
|
+
var ZModelScopeComputation = class extends import_langium8.DefaultScopeComputation {
|
|
7459
7375
|
static {
|
|
7460
7376
|
__name(this, "ZModelScopeComputation");
|
|
7461
7377
|
}
|
|
@@ -7465,9 +7381,9 @@ var ZModelScopeComputation = class extends import_langium9.DefaultScopeComputati
|
|
|
7465
7381
|
}
|
|
7466
7382
|
async computeExports(document, cancelToken) {
|
|
7467
7383
|
const result = await super.computeExports(document, cancelToken);
|
|
7468
|
-
for (const node of
|
|
7384
|
+
for (const node of import_langium8.AstUtils.streamAllContents(document.parseResult.value)) {
|
|
7469
7385
|
if (cancelToken) {
|
|
7470
|
-
await (0,
|
|
7386
|
+
await (0, import_langium8.interruptAndCheck)(cancelToken);
|
|
7471
7387
|
}
|
|
7472
7388
|
if (isEnumField(node)) {
|
|
7473
7389
|
const desc = this.services.workspace.AstNodeDescriptionProvider.createDescription(node, node.name, document);
|
|
@@ -7478,9 +7394,17 @@ var ZModelScopeComputation = class extends import_langium9.DefaultScopeComputati
|
|
|
7478
7394
|
}
|
|
7479
7395
|
processNode(node, document, scopes) {
|
|
7480
7396
|
super.processNode(node, document, scopes);
|
|
7397
|
+
if (isDataModel(node)) {
|
|
7398
|
+
const bases = getRecursiveBases(node);
|
|
7399
|
+
for (const base of bases) {
|
|
7400
|
+
for (const field of base.fields) {
|
|
7401
|
+
scopes.add(node, this.descriptions.createDescription(field, this.nameProvider.getName(field)));
|
|
7402
|
+
}
|
|
7403
|
+
}
|
|
7404
|
+
}
|
|
7481
7405
|
}
|
|
7482
7406
|
};
|
|
7483
|
-
var ZModelScopeProvider = class extends
|
|
7407
|
+
var ZModelScopeProvider = class extends import_langium8.DefaultScopeProvider {
|
|
7484
7408
|
static {
|
|
7485
7409
|
__name(this, "ZModelScopeProvider");
|
|
7486
7410
|
}
|
|
@@ -7489,19 +7413,19 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7489
7413
|
super(services), this.services = services;
|
|
7490
7414
|
}
|
|
7491
7415
|
getGlobalScope(referenceType, context) {
|
|
7492
|
-
const model =
|
|
7416
|
+
const model = import_langium8.AstUtils.getContainerOfType(context.container, isModel);
|
|
7493
7417
|
if (!model) {
|
|
7494
|
-
return
|
|
7418
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7495
7419
|
}
|
|
7496
7420
|
const importedUris = model.imports.map(resolveImportUri).filter((url) => !!url);
|
|
7497
7421
|
const importedElements = this.indexManager.allElements(referenceType).filter((des) => (
|
|
7498
7422
|
// allow current document
|
|
7499
|
-
|
|
7423
|
+
import_langium8.UriUtils.equals(des.documentUri, model.$document?.uri) || // allow stdlib
|
|
7500
7424
|
des.documentUri.path.endsWith(STD_LIB_MODULE_NAME) || // allow plugin models
|
|
7501
7425
|
des.documentUri.path.endsWith(PLUGIN_MODULE_NAME) || // allow imported documents
|
|
7502
|
-
importedUris.some((importedUri) =>
|
|
7426
|
+
importedUris.some((importedUri) => import_langium8.UriUtils.equals(des.documentUri, importedUri))
|
|
7503
7427
|
));
|
|
7504
|
-
return new
|
|
7428
|
+
return new import_langium8.StreamScope(importedElements);
|
|
7505
7429
|
}
|
|
7506
7430
|
getScope(context) {
|
|
7507
7431
|
if (isMemberAccessExpr(context.container) && context.container.operand && context.property === "member") {
|
|
@@ -7521,23 +7445,20 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7521
7445
|
const node = context.container;
|
|
7522
7446
|
const allowTypeDefScope = (
|
|
7523
7447
|
// isAuthOrAuthMemberAccess(node.operand) ||
|
|
7524
|
-
!!
|
|
7448
|
+
!!import_langium8.AstUtils.getContainerOfType(node, isTypeDef)
|
|
7525
7449
|
);
|
|
7526
7450
|
return (0, import_ts_pattern3.match)(node.operand).when(isReferenceExpr, (operand) => {
|
|
7527
7451
|
const ref = operand.target.ref;
|
|
7528
|
-
if (
|
|
7452
|
+
if (isDataField(ref)) {
|
|
7529
7453
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7530
7454
|
}
|
|
7531
|
-
return
|
|
7455
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7532
7456
|
}).when(isMemberAccessExpr, (operand) => {
|
|
7533
7457
|
const ref = operand.member.ref;
|
|
7534
|
-
if (
|
|
7535
|
-
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7536
|
-
}
|
|
7537
|
-
if (isTypeDefField(ref) && !ref.type.array) {
|
|
7458
|
+
if (isDataField(ref) && !ref.type.array) {
|
|
7538
7459
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7539
7460
|
}
|
|
7540
|
-
return
|
|
7461
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7541
7462
|
}).when(isThisExpr, () => {
|
|
7542
7463
|
return this.createScopeForContainingModel(node, globalScope);
|
|
7543
7464
|
}).when(isInvocationExpr, (operand) => {
|
|
@@ -7547,8 +7468,8 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7547
7468
|
if (isFutureInvocation(operand)) {
|
|
7548
7469
|
return this.createScopeForContainingModel(node, globalScope);
|
|
7549
7470
|
}
|
|
7550
|
-
return
|
|
7551
|
-
}).otherwise(() =>
|
|
7471
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7472
|
+
}).otherwise(() => import_langium8.EMPTY_SCOPE);
|
|
7552
7473
|
}
|
|
7553
7474
|
getCollectionPredicateScope(context, collectionPredicate) {
|
|
7554
7475
|
const referenceType = this.reflection.getReferenceType(context);
|
|
@@ -7557,51 +7478,51 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7557
7478
|
const allowTypeDefScope = false;
|
|
7558
7479
|
return (0, import_ts_pattern3.match)(collection).when(isReferenceExpr, (expr) => {
|
|
7559
7480
|
const ref = expr.target.ref;
|
|
7560
|
-
if (
|
|
7481
|
+
if (isDataField(ref)) {
|
|
7561
7482
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7562
7483
|
}
|
|
7563
|
-
return
|
|
7484
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7564
7485
|
}).when(isMemberAccessExpr, (expr) => {
|
|
7565
7486
|
const ref = expr.member.ref;
|
|
7566
|
-
if (
|
|
7487
|
+
if (isDataField(ref)) {
|
|
7567
7488
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7568
7489
|
}
|
|
7569
|
-
return
|
|
7490
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7570
7491
|
}).when(isInvocationExpr, (expr) => {
|
|
7571
7492
|
const returnTypeDecl = expr.function.ref?.returnType.reference?.ref;
|
|
7572
7493
|
if (isDataModel(returnTypeDecl)) {
|
|
7573
7494
|
return this.createScopeForContainer(returnTypeDecl, globalScope, allowTypeDefScope);
|
|
7574
7495
|
} else {
|
|
7575
|
-
return
|
|
7496
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7576
7497
|
}
|
|
7577
7498
|
}).when(isAuthInvocation, (expr) => {
|
|
7578
7499
|
return this.createScopeForAuth(expr, globalScope);
|
|
7579
|
-
}).otherwise(() =>
|
|
7500
|
+
}).otherwise(() => import_langium8.EMPTY_SCOPE);
|
|
7580
7501
|
}
|
|
7581
7502
|
createScopeForContainingModel(node, globalScope) {
|
|
7582
|
-
const model =
|
|
7503
|
+
const model = import_langium8.AstUtils.getContainerOfType(node, isDataModel);
|
|
7583
7504
|
if (model) {
|
|
7584
7505
|
return this.createScopeForContainer(model, globalScope);
|
|
7585
7506
|
} else {
|
|
7586
|
-
return
|
|
7507
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7587
7508
|
}
|
|
7588
7509
|
}
|
|
7589
7510
|
createScopeForContainer(node, globalScope, includeTypeDefScope = false) {
|
|
7590
7511
|
if (isDataModel(node)) {
|
|
7591
|
-
return this.createScopeForNodes(
|
|
7512
|
+
return this.createScopeForNodes(getAllFields(node), globalScope);
|
|
7592
7513
|
} else if (includeTypeDefScope && isTypeDef(node)) {
|
|
7593
7514
|
return this.createScopeForNodes(node.fields, globalScope);
|
|
7594
7515
|
} else {
|
|
7595
|
-
return
|
|
7516
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7596
7517
|
}
|
|
7597
7518
|
}
|
|
7598
7519
|
createScopeForAuth(node, globalScope) {
|
|
7599
|
-
const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.services.shared.workspace.LangiumDocuments,
|
|
7520
|
+
const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.services.shared.workspace.LangiumDocuments, import_langium8.AstUtils.getContainerOfType(node, isDataModel));
|
|
7600
7521
|
const authDecl = getAuthDecl(decls);
|
|
7601
7522
|
if (authDecl) {
|
|
7602
7523
|
return this.createScopeForContainer(authDecl, globalScope, true);
|
|
7603
7524
|
} else {
|
|
7604
|
-
return
|
|
7525
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7605
7526
|
}
|
|
7606
7527
|
}
|
|
7607
7528
|
};
|
|
@@ -7618,12 +7539,12 @@ function getCollectionPredicateContext(node) {
|
|
|
7618
7539
|
__name(getCollectionPredicateContext, "getCollectionPredicateContext");
|
|
7619
7540
|
|
|
7620
7541
|
// src/zmodel-workspace-manager.ts
|
|
7621
|
-
var
|
|
7542
|
+
var import_langium9 = require("langium");
|
|
7622
7543
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
7623
7544
|
var import_node_path = __toESM(require("path"), 1);
|
|
7624
7545
|
var import_node_url = require("url");
|
|
7625
7546
|
var import_meta = {};
|
|
7626
|
-
var ZModelWorkspaceManager = class extends
|
|
7547
|
+
var ZModelWorkspaceManager = class extends import_langium9.DefaultWorkspaceManager {
|
|
7627
7548
|
static {
|
|
7628
7549
|
__name(this, "ZModelWorkspaceManager");
|
|
7629
7550
|
}
|
|
@@ -7651,7 +7572,7 @@ var ZModelWorkspaceManager = class extends import_langium10.DefaultWorkspaceMana
|
|
|
7651
7572
|
console.log(`Found installed zenstack package stdlib at: ${installedStdlibPath}`);
|
|
7652
7573
|
break;
|
|
7653
7574
|
}
|
|
7654
|
-
} catch
|
|
7575
|
+
} catch {
|
|
7655
7576
|
continue;
|
|
7656
7577
|
}
|
|
7657
7578
|
}
|
|
@@ -7662,8 +7583,69 @@ var ZModelWorkspaceManager = class extends import_langium10.DefaultWorkspaceMana
|
|
|
7662
7583
|
stdLibPath = import_node_path.default.join(_dirname, "../res", STD_LIB_MODULE_NAME);
|
|
7663
7584
|
console.log(`Using bundled stdlib in extension:`, stdLibPath);
|
|
7664
7585
|
}
|
|
7665
|
-
const stdlib = await this.documentFactory.fromUri(
|
|
7586
|
+
const stdlib = await this.documentFactory.fromUri(import_langium9.URI.file(stdLibPath));
|
|
7666
7587
|
collector(stdlib);
|
|
7588
|
+
const documents = this.langiumDocuments.all;
|
|
7589
|
+
const pluginModels = /* @__PURE__ */ new Set();
|
|
7590
|
+
documents.forEach((doc) => {
|
|
7591
|
+
const parsed = doc.parseResult.value;
|
|
7592
|
+
parsed.declarations.forEach((decl) => {
|
|
7593
|
+
if (isPlugin(decl)) {
|
|
7594
|
+
const providerField = decl.fields.find((f) => f.name === "provider");
|
|
7595
|
+
if (providerField) {
|
|
7596
|
+
const provider = getLiteral(providerField.value);
|
|
7597
|
+
if (provider) {
|
|
7598
|
+
pluginModels.add(provider);
|
|
7599
|
+
}
|
|
7600
|
+
}
|
|
7601
|
+
}
|
|
7602
|
+
});
|
|
7603
|
+
});
|
|
7604
|
+
if (pluginModels.size > 0) {
|
|
7605
|
+
console.log(`Used plugin modules: ${Array.from(pluginModels)}`);
|
|
7606
|
+
const pendingPluginModules = new Set(pluginModels);
|
|
7607
|
+
await Promise.all(folders.map((wf) => [
|
|
7608
|
+
wf,
|
|
7609
|
+
this.getRootFolder(wf)
|
|
7610
|
+
]).map(async (entry) => this.loadPluginModels(...entry, pendingPluginModules, collector)));
|
|
7611
|
+
}
|
|
7612
|
+
}
|
|
7613
|
+
async loadPluginModels(workspaceFolder, folderPath, pendingPluginModels, collector) {
|
|
7614
|
+
const content = (await this.fileSystemProvider.readDirectory(folderPath)).sort((a, b) => {
|
|
7615
|
+
if (a.isDirectory && b.isDirectory) {
|
|
7616
|
+
const aName = import_langium9.UriUtils.basename(a.uri);
|
|
7617
|
+
if (aName === "node_modules") {
|
|
7618
|
+
return -1;
|
|
7619
|
+
} else {
|
|
7620
|
+
return 1;
|
|
7621
|
+
}
|
|
7622
|
+
} else {
|
|
7623
|
+
return 0;
|
|
7624
|
+
}
|
|
7625
|
+
});
|
|
7626
|
+
for (const entry of content) {
|
|
7627
|
+
if (entry.isDirectory) {
|
|
7628
|
+
const name = import_langium9.UriUtils.basename(entry.uri);
|
|
7629
|
+
if (name === "node_modules") {
|
|
7630
|
+
for (const plugin of Array.from(pendingPluginModels)) {
|
|
7631
|
+
const path4 = import_langium9.UriUtils.joinPath(entry.uri, plugin, PLUGIN_MODULE_NAME);
|
|
7632
|
+
try {
|
|
7633
|
+
await this.fileSystemProvider.readFile(path4);
|
|
7634
|
+
const document = await this.langiumDocuments.getOrCreateDocument(path4);
|
|
7635
|
+
collector(document);
|
|
7636
|
+
console.log(`Adding plugin document from ${path4.path}`);
|
|
7637
|
+
pendingPluginModels.delete(plugin);
|
|
7638
|
+
if (pendingPluginModels.size === 0) {
|
|
7639
|
+
return;
|
|
7640
|
+
}
|
|
7641
|
+
} catch {
|
|
7642
|
+
}
|
|
7643
|
+
}
|
|
7644
|
+
} else {
|
|
7645
|
+
await this.loadPluginModels(workspaceFolder, entry.uri, pendingPluginModels, collector);
|
|
7646
|
+
}
|
|
7647
|
+
}
|
|
7648
|
+
}
|
|
7667
7649
|
}
|
|
7668
7650
|
};
|
|
7669
7651
|
|
|
@@ -7684,8 +7666,8 @@ var ZModelSharedModule = {
|
|
|
7684
7666
|
}
|
|
7685
7667
|
};
|
|
7686
7668
|
function createZModelLanguageServices(context) {
|
|
7687
|
-
const shared = (0,
|
|
7688
|
-
const ZModelLanguage = (0,
|
|
7669
|
+
const shared = (0, import_langium10.inject)((0, import_lsp.createDefaultSharedModule)(context), ZModelGeneratedSharedModule, ZModelSharedModule);
|
|
7670
|
+
const ZModelLanguage = (0, import_langium10.inject)((0, import_lsp.createDefaultModule)({
|
|
7689
7671
|
shared
|
|
7690
7672
|
}), ZModelGeneratedModule, ZModelLanguageModule);
|
|
7691
7673
|
shared.ServiceRegistry.register(ZModelLanguage);
|
|
@@ -7736,14 +7718,20 @@ async function loadDocument(fileName, pluginModelFiles = []) {
|
|
|
7736
7718
|
};
|
|
7737
7719
|
}
|
|
7738
7720
|
const _dirname = typeof __dirname !== "undefined" ? __dirname : import_node_path2.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
7739
|
-
const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
7740
|
-
const pluginDocs = await Promise.all(pluginModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
7721
|
+
const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(import_langium11.URI.file(import_node_path2.default.resolve(import_node_path2.default.join(_dirname, "../res", STD_LIB_MODULE_NAME))));
|
|
7722
|
+
const pluginDocs = await Promise.all(pluginModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(import_langium11.URI.file(import_node_path2.default.resolve(file)))));
|
|
7741
7723
|
const langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
7742
|
-
const document = await langiumDocuments.getOrCreateDocument(
|
|
7724
|
+
const document = await langiumDocuments.getOrCreateDocument(import_langium11.URI.file(import_node_path2.default.resolve(fileName)));
|
|
7725
|
+
const importedURIs = await loadImports(document, langiumDocuments);
|
|
7726
|
+
const importedDocuments = [];
|
|
7727
|
+
for (const uri of importedURIs) {
|
|
7728
|
+
importedDocuments.push(await langiumDocuments.getOrCreateDocument(uri));
|
|
7729
|
+
}
|
|
7743
7730
|
await services.shared.workspace.DocumentBuilder.build([
|
|
7744
7731
|
stdLib,
|
|
7745
7732
|
...pluginDocs,
|
|
7746
|
-
document
|
|
7733
|
+
document,
|
|
7734
|
+
...importedDocuments
|
|
7747
7735
|
], {
|
|
7748
7736
|
validation: true
|
|
7749
7737
|
});
|
|
@@ -7770,6 +7758,20 @@ async function loadDocument(fileName, pluginModelFiles = []) {
|
|
|
7770
7758
|
warnings
|
|
7771
7759
|
};
|
|
7772
7760
|
}
|
|
7761
|
+
const model = document.parseResult.value;
|
|
7762
|
+
const imported = mergeImportsDeclarations(langiumDocuments, model);
|
|
7763
|
+
imported.forEach((model2) => {
|
|
7764
|
+
langiumDocuments.deleteDocument(model2.$document.uri);
|
|
7765
|
+
services.shared.workspace.IndexManager.remove(model2.$document.uri);
|
|
7766
|
+
});
|
|
7767
|
+
const additionalErrors = validationAfterImportMerge(model);
|
|
7768
|
+
if (additionalErrors.length > 0) {
|
|
7769
|
+
return {
|
|
7770
|
+
success: false,
|
|
7771
|
+
errors: additionalErrors,
|
|
7772
|
+
warnings
|
|
7773
|
+
};
|
|
7774
|
+
}
|
|
7773
7775
|
return {
|
|
7774
7776
|
success: true,
|
|
7775
7777
|
model: document.parseResult.value,
|
|
@@ -7777,6 +7779,68 @@ async function loadDocument(fileName, pluginModelFiles = []) {
|
|
|
7777
7779
|
};
|
|
7778
7780
|
}
|
|
7779
7781
|
__name(loadDocument, "loadDocument");
|
|
7782
|
+
async function loadImports(document, documents, uris = /* @__PURE__ */ new Set()) {
|
|
7783
|
+
const uriString = document.uri.toString();
|
|
7784
|
+
if (!uris.has(uriString)) {
|
|
7785
|
+
uris.add(uriString);
|
|
7786
|
+
const model = document.parseResult.value;
|
|
7787
|
+
for (const imp of model.imports) {
|
|
7788
|
+
const importedModel = resolveImport(documents, imp);
|
|
7789
|
+
if (importedModel) {
|
|
7790
|
+
const importedDoc = getDocument(importedModel);
|
|
7791
|
+
await loadImports(importedDoc, documents, uris);
|
|
7792
|
+
}
|
|
7793
|
+
}
|
|
7794
|
+
}
|
|
7795
|
+
return Array.from(uris).filter((x) => uriString != x).map((e) => import_langium11.URI.parse(e));
|
|
7796
|
+
}
|
|
7797
|
+
__name(loadImports, "loadImports");
|
|
7798
|
+
function mergeImportsDeclarations(documents, model) {
|
|
7799
|
+
const importedModels = resolveTransitiveImports(documents, model);
|
|
7800
|
+
const importedDeclarations = importedModels.flatMap((m) => m.declarations);
|
|
7801
|
+
model.declarations.push(...importedDeclarations);
|
|
7802
|
+
model.imports = [];
|
|
7803
|
+
linkContentToContainer(model);
|
|
7804
|
+
return importedModels;
|
|
7805
|
+
}
|
|
7806
|
+
__name(mergeImportsDeclarations, "mergeImportsDeclarations");
|
|
7807
|
+
function linkContentToContainer(node) {
|
|
7808
|
+
for (const [name, value] of Object.entries(node)) {
|
|
7809
|
+
if (!name.startsWith("$")) {
|
|
7810
|
+
if (Array.isArray(value)) {
|
|
7811
|
+
value.forEach((item, index) => {
|
|
7812
|
+
if ((0, import_langium11.isAstNode)(item)) {
|
|
7813
|
+
item.$container = node;
|
|
7814
|
+
item.$containerProperty = name;
|
|
7815
|
+
item.$containerIndex = index;
|
|
7816
|
+
}
|
|
7817
|
+
});
|
|
7818
|
+
} else if ((0, import_langium11.isAstNode)(value)) {
|
|
7819
|
+
value.$container = node;
|
|
7820
|
+
value.$containerProperty = name;
|
|
7821
|
+
}
|
|
7822
|
+
}
|
|
7823
|
+
}
|
|
7824
|
+
}
|
|
7825
|
+
__name(linkContentToContainer, "linkContentToContainer");
|
|
7826
|
+
function validationAfterImportMerge(model) {
|
|
7827
|
+
const errors = [];
|
|
7828
|
+
const dataSources = model.declarations.filter((d) => isDataSource(d));
|
|
7829
|
+
if (dataSources.length === 0) {
|
|
7830
|
+
errors.push("Validation error: schema must have a datasource declaration");
|
|
7831
|
+
} else {
|
|
7832
|
+
if (dataSources.length > 1) {
|
|
7833
|
+
errors.push("Validation error: multiple datasource declarations are not allowed");
|
|
7834
|
+
}
|
|
7835
|
+
}
|
|
7836
|
+
const decls = getDataModelAndTypeDefs(model, true);
|
|
7837
|
+
const authDecls = decls.filter((d) => hasAttribute(d, "@@auth"));
|
|
7838
|
+
if (authDecls.length > 1) {
|
|
7839
|
+
errors.push("Validation error: Multiple `@@auth` declarations are not allowed");
|
|
7840
|
+
}
|
|
7841
|
+
return errors;
|
|
7842
|
+
}
|
|
7843
|
+
__name(validationAfterImportMerge, "validationAfterImportMerge");
|
|
7780
7844
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7781
7845
|
0 && (module.exports = {
|
|
7782
7846
|
DocumentLoadError,
|