@zenstackhq/language 3.0.0-alpha.3 → 3.0.0-alpha.31
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.js
CHANGED
|
@@ -8,47 +8,14 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
// src/index.ts
|
|
11
|
-
import { URI as URI3 } from "langium";
|
|
11
|
+
import { isAstNode, URI as URI3 } from "langium";
|
|
12
12
|
import { NodeFileSystem } from "langium/node";
|
|
13
|
-
import fs3 from "
|
|
14
|
-
import path3 from "
|
|
15
|
-
import { fileURLToPath as fileURLToPath2 } from "
|
|
16
|
-
|
|
17
|
-
// src/constants.ts
|
|
18
|
-
var SUPPORTED_PROVIDERS = [
|
|
19
|
-
"sqlite",
|
|
20
|
-
"postgresql"
|
|
21
|
-
];
|
|
22
|
-
var SCALAR_TYPES = [
|
|
23
|
-
"String",
|
|
24
|
-
"Int",
|
|
25
|
-
"Float",
|
|
26
|
-
"Decimal",
|
|
27
|
-
"BigInt",
|
|
28
|
-
"Boolean",
|
|
29
|
-
"Bytes",
|
|
30
|
-
"DateTime"
|
|
31
|
-
];
|
|
32
|
-
var STD_LIB_MODULE_NAME = "stdlib.zmodel";
|
|
33
|
-
var PLUGIN_MODULE_NAME = "plugin.zmodel";
|
|
34
|
-
var IssueCodes = /* @__PURE__ */ function(IssueCodes2) {
|
|
35
|
-
IssueCodes2["MissingOppositeRelation"] = "miss-opposite-relation";
|
|
36
|
-
return IssueCodes2;
|
|
37
|
-
}({});
|
|
38
|
-
var ExpressionContext = /* @__PURE__ */ function(ExpressionContext2) {
|
|
39
|
-
ExpressionContext2["DefaultValue"] = "DefaultValue";
|
|
40
|
-
ExpressionContext2["AccessPolicy"] = "AccessPolicy";
|
|
41
|
-
ExpressionContext2["ValidationRule"] = "ValidationRule";
|
|
42
|
-
ExpressionContext2["Index"] = "Index";
|
|
43
|
-
return ExpressionContext2;
|
|
44
|
-
}({});
|
|
45
|
-
|
|
46
|
-
// src/module.ts
|
|
47
|
-
import { inject } from "langium";
|
|
48
|
-
import { createDefaultModule, createDefaultSharedModule } from "langium/lsp";
|
|
13
|
+
import fs3 from "fs";
|
|
14
|
+
import path3 from "path";
|
|
15
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
49
16
|
|
|
50
17
|
// src/generated/ast.ts
|
|
51
|
-
import
|
|
18
|
+
import * as langium from "langium";
|
|
52
19
|
var AbstractDeclaration = "AbstractDeclaration";
|
|
53
20
|
var ConfigExpr = "ConfigExpr";
|
|
54
21
|
var Expression = "Expression";
|
|
@@ -64,7 +31,6 @@ __name(isLiteralExpr, "isLiteralExpr");
|
|
|
64
31
|
var MemberAccessTarget = "MemberAccessTarget";
|
|
65
32
|
var ReferenceTarget = "ReferenceTarget";
|
|
66
33
|
var TypeDeclaration = "TypeDeclaration";
|
|
67
|
-
var TypeDefFieldTypes = "TypeDefFieldTypes";
|
|
68
34
|
var Argument = "Argument";
|
|
69
35
|
var ArrayExpr = "ArrayExpr";
|
|
70
36
|
function isArrayExpr(item) {
|
|
@@ -97,6 +63,21 @@ __name(isConfigArrayExpr, "isConfigArrayExpr");
|
|
|
97
63
|
var ConfigField = "ConfigField";
|
|
98
64
|
var ConfigInvocationArg = "ConfigInvocationArg";
|
|
99
65
|
var ConfigInvocationExpr = "ConfigInvocationExpr";
|
|
66
|
+
var DataField = "DataField";
|
|
67
|
+
function isDataField(item) {
|
|
68
|
+
return reflection.isInstance(item, DataField);
|
|
69
|
+
}
|
|
70
|
+
__name(isDataField, "isDataField");
|
|
71
|
+
var DataFieldAttribute = "DataFieldAttribute";
|
|
72
|
+
function isDataFieldAttribute(item) {
|
|
73
|
+
return reflection.isInstance(item, DataFieldAttribute);
|
|
74
|
+
}
|
|
75
|
+
__name(isDataFieldAttribute, "isDataFieldAttribute");
|
|
76
|
+
var DataFieldType = "DataFieldType";
|
|
77
|
+
function isDataFieldType(item) {
|
|
78
|
+
return reflection.isInstance(item, DataFieldType);
|
|
79
|
+
}
|
|
80
|
+
__name(isDataFieldType, "isDataFieldType");
|
|
100
81
|
var DataModel = "DataModel";
|
|
101
82
|
function isDataModel(item) {
|
|
102
83
|
return reflection.isInstance(item, DataModel);
|
|
@@ -107,21 +88,6 @@ function isDataModelAttribute(item) {
|
|
|
107
88
|
return reflection.isInstance(item, DataModelAttribute);
|
|
108
89
|
}
|
|
109
90
|
__name(isDataModelAttribute, "isDataModelAttribute");
|
|
110
|
-
var DataModelField = "DataModelField";
|
|
111
|
-
function isDataModelField(item) {
|
|
112
|
-
return reflection.isInstance(item, DataModelField);
|
|
113
|
-
}
|
|
114
|
-
__name(isDataModelField, "isDataModelField");
|
|
115
|
-
var DataModelFieldAttribute = "DataModelFieldAttribute";
|
|
116
|
-
function isDataModelFieldAttribute(item) {
|
|
117
|
-
return reflection.isInstance(item, DataModelFieldAttribute);
|
|
118
|
-
}
|
|
119
|
-
__name(isDataModelFieldAttribute, "isDataModelFieldAttribute");
|
|
120
|
-
var DataModelFieldType = "DataModelFieldType";
|
|
121
|
-
function isDataModelFieldType(item) {
|
|
122
|
-
return reflection.isInstance(item, DataModelFieldType);
|
|
123
|
-
}
|
|
124
|
-
__name(isDataModelFieldType, "isDataModelFieldType");
|
|
125
91
|
var DataSource = "DataSource";
|
|
126
92
|
function isDataSource(item) {
|
|
127
93
|
return reflection.isInstance(item, DataSource);
|
|
@@ -175,6 +141,10 @@ function isObjectExpr(item) {
|
|
|
175
141
|
}
|
|
176
142
|
__name(isObjectExpr, "isObjectExpr");
|
|
177
143
|
var Plugin = "Plugin";
|
|
144
|
+
function isPlugin(item) {
|
|
145
|
+
return reflection.isInstance(item, Plugin);
|
|
146
|
+
}
|
|
147
|
+
__name(isPlugin, "isPlugin");
|
|
178
148
|
var PluginField = "PluginField";
|
|
179
149
|
var Procedure = "Procedure";
|
|
180
150
|
var ProcedureParam = "ProcedureParam";
|
|
@@ -199,15 +169,9 @@ function isTypeDef(item) {
|
|
|
199
169
|
return reflection.isInstance(item, TypeDef);
|
|
200
170
|
}
|
|
201
171
|
__name(isTypeDef, "isTypeDef");
|
|
202
|
-
var TypeDefField = "TypeDefField";
|
|
203
|
-
function isTypeDefField(item) {
|
|
204
|
-
return reflection.isInstance(item, TypeDefField);
|
|
205
|
-
}
|
|
206
|
-
__name(isTypeDefField, "isTypeDefField");
|
|
207
|
-
var TypeDefFieldType = "TypeDefFieldType";
|
|
208
172
|
var UnaryExpr = "UnaryExpr";
|
|
209
173
|
var UnsupportedFieldType = "UnsupportedFieldType";
|
|
210
|
-
var ZModelAstReflection = class extends AbstractAstReflection {
|
|
174
|
+
var ZModelAstReflection = class extends langium.AbstractAstReflection {
|
|
211
175
|
static {
|
|
212
176
|
__name(this, "ZModelAstReflection");
|
|
213
177
|
}
|
|
@@ -227,11 +191,11 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
227
191
|
ConfigField,
|
|
228
192
|
ConfigInvocationArg,
|
|
229
193
|
ConfigInvocationExpr,
|
|
194
|
+
DataField,
|
|
195
|
+
DataFieldAttribute,
|
|
196
|
+
DataFieldType,
|
|
230
197
|
DataModel,
|
|
231
198
|
DataModelAttribute,
|
|
232
|
-
DataModelField,
|
|
233
|
-
DataModelFieldAttribute,
|
|
234
|
-
DataModelFieldType,
|
|
235
199
|
DataSource,
|
|
236
200
|
Enum,
|
|
237
201
|
EnumField,
|
|
@@ -262,9 +226,6 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
262
226
|
ThisExpr,
|
|
263
227
|
TypeDeclaration,
|
|
264
228
|
TypeDef,
|
|
265
|
-
TypeDefField,
|
|
266
|
-
TypeDefFieldType,
|
|
267
|
-
TypeDefFieldTypes,
|
|
268
229
|
UnaryExpr,
|
|
269
230
|
UnsupportedFieldType
|
|
270
231
|
];
|
|
@@ -297,16 +258,13 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
297
258
|
case ConfigArrayExpr: {
|
|
298
259
|
return this.isSubtype(ConfigExpr, supertype);
|
|
299
260
|
}
|
|
300
|
-
case
|
|
301
|
-
return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype);
|
|
302
|
-
}
|
|
303
|
-
case DataModelField:
|
|
304
|
-
case TypeDefField: {
|
|
261
|
+
case DataField: {
|
|
305
262
|
return this.isSubtype(MemberAccessTarget, supertype) || this.isSubtype(ReferenceTarget, supertype);
|
|
306
263
|
}
|
|
264
|
+
case DataModel:
|
|
307
265
|
case Enum:
|
|
308
266
|
case TypeDef: {
|
|
309
|
-
return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype)
|
|
267
|
+
return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype);
|
|
310
268
|
}
|
|
311
269
|
case EnumField:
|
|
312
270
|
case FunctionParam: {
|
|
@@ -325,18 +283,22 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
325
283
|
const referenceId = `${refInfo.container.$type}:${refInfo.property}`;
|
|
326
284
|
switch (referenceId) {
|
|
327
285
|
case "AttributeParamType:reference":
|
|
328
|
-
case "
|
|
286
|
+
case "DataFieldType:reference":
|
|
329
287
|
case "FunctionParamType:reference": {
|
|
330
288
|
return TypeDeclaration;
|
|
331
289
|
}
|
|
332
|
-
case "
|
|
333
|
-
return DataModel;
|
|
334
|
-
}
|
|
290
|
+
case "DataFieldAttribute:decl":
|
|
335
291
|
case "DataModelAttribute:decl":
|
|
336
|
-
case "DataModelFieldAttribute:decl":
|
|
337
292
|
case "InternalAttribute:decl": {
|
|
338
293
|
return Attribute;
|
|
339
294
|
}
|
|
295
|
+
case "DataModel:baseModel": {
|
|
296
|
+
return DataModel;
|
|
297
|
+
}
|
|
298
|
+
case "DataModel:mixins":
|
|
299
|
+
case "TypeDef:mixins": {
|
|
300
|
+
return TypeDef;
|
|
301
|
+
}
|
|
340
302
|
case "InvocationExpr:function": {
|
|
341
303
|
return FunctionDecl;
|
|
342
304
|
}
|
|
@@ -346,9 +308,6 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
346
308
|
case "ReferenceExpr:target": {
|
|
347
309
|
return ReferenceTarget;
|
|
348
310
|
}
|
|
349
|
-
case "TypeDefFieldType:reference": {
|
|
350
|
-
return TypeDefFieldTypes;
|
|
351
|
-
}
|
|
352
311
|
default: {
|
|
353
312
|
throw new Error(`${referenceId} is not a valid reference id.`);
|
|
354
313
|
}
|
|
@@ -535,9 +494,9 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
535
494
|
]
|
|
536
495
|
};
|
|
537
496
|
}
|
|
538
|
-
case
|
|
497
|
+
case DataField: {
|
|
539
498
|
return {
|
|
540
|
-
name:
|
|
499
|
+
name: DataField,
|
|
541
500
|
properties: [
|
|
542
501
|
{
|
|
543
502
|
name: "attributes",
|
|
@@ -547,31 +506,18 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
547
506
|
name: "comments",
|
|
548
507
|
defaultValue: []
|
|
549
508
|
},
|
|
550
|
-
{
|
|
551
|
-
name: "fields",
|
|
552
|
-
defaultValue: []
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
name: "isAbstract",
|
|
556
|
-
defaultValue: false
|
|
557
|
-
},
|
|
558
|
-
{
|
|
559
|
-
name: "isView",
|
|
560
|
-
defaultValue: false
|
|
561
|
-
},
|
|
562
509
|
{
|
|
563
510
|
name: "name"
|
|
564
511
|
},
|
|
565
512
|
{
|
|
566
|
-
name: "
|
|
567
|
-
defaultValue: []
|
|
513
|
+
name: "type"
|
|
568
514
|
}
|
|
569
515
|
]
|
|
570
516
|
};
|
|
571
517
|
}
|
|
572
|
-
case
|
|
518
|
+
case DataFieldAttribute: {
|
|
573
519
|
return {
|
|
574
|
-
name:
|
|
520
|
+
name: DataFieldAttribute,
|
|
575
521
|
properties: [
|
|
576
522
|
{
|
|
577
523
|
name: "args",
|
|
@@ -583,61 +529,73 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
583
529
|
]
|
|
584
530
|
};
|
|
585
531
|
}
|
|
586
|
-
case
|
|
532
|
+
case DataFieldType: {
|
|
587
533
|
return {
|
|
588
|
-
name:
|
|
534
|
+
name: DataFieldType,
|
|
589
535
|
properties: [
|
|
590
536
|
{
|
|
591
|
-
name: "
|
|
592
|
-
defaultValue:
|
|
537
|
+
name: "array",
|
|
538
|
+
defaultValue: false
|
|
593
539
|
},
|
|
594
540
|
{
|
|
595
|
-
name: "
|
|
596
|
-
defaultValue:
|
|
541
|
+
name: "optional",
|
|
542
|
+
defaultValue: false
|
|
597
543
|
},
|
|
598
544
|
{
|
|
599
|
-
name: "
|
|
545
|
+
name: "reference"
|
|
600
546
|
},
|
|
601
547
|
{
|
|
602
548
|
name: "type"
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
name: "unsupported"
|
|
603
552
|
}
|
|
604
553
|
]
|
|
605
554
|
};
|
|
606
555
|
}
|
|
607
|
-
case
|
|
556
|
+
case DataModel: {
|
|
608
557
|
return {
|
|
609
|
-
name:
|
|
558
|
+
name: DataModel,
|
|
610
559
|
properties: [
|
|
611
560
|
{
|
|
612
|
-
name: "
|
|
561
|
+
name: "attributes",
|
|
613
562
|
defaultValue: []
|
|
614
563
|
},
|
|
615
564
|
{
|
|
616
|
-
name: "
|
|
617
|
-
}
|
|
618
|
-
]
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
case DataModelFieldType: {
|
|
622
|
-
return {
|
|
623
|
-
name: DataModelFieldType,
|
|
624
|
-
properties: [
|
|
565
|
+
name: "baseModel"
|
|
566
|
+
},
|
|
625
567
|
{
|
|
626
|
-
name: "
|
|
627
|
-
defaultValue:
|
|
568
|
+
name: "comments",
|
|
569
|
+
defaultValue: []
|
|
628
570
|
},
|
|
629
571
|
{
|
|
630
|
-
name: "
|
|
572
|
+
name: "fields",
|
|
573
|
+
defaultValue: []
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: "isView",
|
|
631
577
|
defaultValue: false
|
|
632
578
|
},
|
|
633
579
|
{
|
|
634
|
-
name: "
|
|
580
|
+
name: "mixins",
|
|
581
|
+
defaultValue: []
|
|
635
582
|
},
|
|
636
583
|
{
|
|
637
|
-
name: "
|
|
584
|
+
name: "name"
|
|
585
|
+
}
|
|
586
|
+
]
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
case DataModelAttribute: {
|
|
590
|
+
return {
|
|
591
|
+
name: DataModelAttribute,
|
|
592
|
+
properties: [
|
|
593
|
+
{
|
|
594
|
+
name: "args",
|
|
595
|
+
defaultValue: []
|
|
638
596
|
},
|
|
639
597
|
{
|
|
640
|
-
name: "
|
|
598
|
+
name: "decl"
|
|
641
599
|
}
|
|
642
600
|
]
|
|
643
601
|
};
|
|
@@ -1011,49 +969,11 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
1011
969
|
defaultValue: []
|
|
1012
970
|
},
|
|
1013
971
|
{
|
|
1014
|
-
name: "
|
|
1015
|
-
}
|
|
1016
|
-
]
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
case TypeDefField: {
|
|
1020
|
-
return {
|
|
1021
|
-
name: TypeDefField,
|
|
1022
|
-
properties: [
|
|
1023
|
-
{
|
|
1024
|
-
name: "attributes",
|
|
1025
|
-
defaultValue: []
|
|
1026
|
-
},
|
|
1027
|
-
{
|
|
1028
|
-
name: "comments",
|
|
972
|
+
name: "mixins",
|
|
1029
973
|
defaultValue: []
|
|
1030
974
|
},
|
|
1031
975
|
{
|
|
1032
976
|
name: "name"
|
|
1033
|
-
},
|
|
1034
|
-
{
|
|
1035
|
-
name: "type"
|
|
1036
|
-
}
|
|
1037
|
-
]
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
case TypeDefFieldType: {
|
|
1041
|
-
return {
|
|
1042
|
-
name: TypeDefFieldType,
|
|
1043
|
-
properties: [
|
|
1044
|
-
{
|
|
1045
|
-
name: "array",
|
|
1046
|
-
defaultValue: false
|
|
1047
|
-
},
|
|
1048
|
-
{
|
|
1049
|
-
name: "optional",
|
|
1050
|
-
defaultValue: false
|
|
1051
|
-
},
|
|
1052
|
-
{
|
|
1053
|
-
name: "reference"
|
|
1054
|
-
},
|
|
1055
|
-
{
|
|
1056
|
-
name: "type"
|
|
1057
977
|
}
|
|
1058
978
|
]
|
|
1059
979
|
};
|
|
@@ -1092,6 +1012,39 @@ var ZModelAstReflection = class extends AbstractAstReflection {
|
|
|
1092
1012
|
};
|
|
1093
1013
|
var reflection = new ZModelAstReflection();
|
|
1094
1014
|
|
|
1015
|
+
// src/constants.ts
|
|
1016
|
+
var SUPPORTED_PROVIDERS = [
|
|
1017
|
+
"sqlite",
|
|
1018
|
+
"postgresql"
|
|
1019
|
+
];
|
|
1020
|
+
var SCALAR_TYPES = [
|
|
1021
|
+
"String",
|
|
1022
|
+
"Int",
|
|
1023
|
+
"Float",
|
|
1024
|
+
"Decimal",
|
|
1025
|
+
"BigInt",
|
|
1026
|
+
"Boolean",
|
|
1027
|
+
"Bytes",
|
|
1028
|
+
"DateTime"
|
|
1029
|
+
];
|
|
1030
|
+
var STD_LIB_MODULE_NAME = "stdlib.zmodel";
|
|
1031
|
+
var PLUGIN_MODULE_NAME = "plugin.zmodel";
|
|
1032
|
+
var IssueCodes = /* @__PURE__ */ function(IssueCodes2) {
|
|
1033
|
+
IssueCodes2["MissingOppositeRelation"] = "miss-opposite-relation";
|
|
1034
|
+
return IssueCodes2;
|
|
1035
|
+
}({});
|
|
1036
|
+
var ExpressionContext = /* @__PURE__ */ function(ExpressionContext2) {
|
|
1037
|
+
ExpressionContext2["DefaultValue"] = "DefaultValue";
|
|
1038
|
+
ExpressionContext2["AccessPolicy"] = "AccessPolicy";
|
|
1039
|
+
ExpressionContext2["ValidationRule"] = "ValidationRule";
|
|
1040
|
+
ExpressionContext2["Index"] = "Index";
|
|
1041
|
+
return ExpressionContext2;
|
|
1042
|
+
}({});
|
|
1043
|
+
|
|
1044
|
+
// src/module.ts
|
|
1045
|
+
import { inject } from "langium";
|
|
1046
|
+
import { createDefaultModule, createDefaultSharedModule } from "langium/lsp";
|
|
1047
|
+
|
|
1095
1048
|
// src/generated/grammar.ts
|
|
1096
1049
|
import { loadGrammarFromJson } from "langium";
|
|
1097
1050
|
var loadedZModelGrammar;
|
|
@@ -1102,8 +1055,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
1102
1055
|
"rules": [
|
|
1103
1056
|
{
|
|
1104
1057
|
"$type": "ParserRule",
|
|
1105
|
-
"name": "Model",
|
|
1106
1058
|
"entry": true,
|
|
1059
|
+
"name": "Model",
|
|
1107
1060
|
"definition": {
|
|
1108
1061
|
"$type": "Group",
|
|
1109
1062
|
"elements": [
|
|
@@ -1214,7 +1167,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
1214
1167
|
{
|
|
1215
1168
|
"$type": "RuleCall",
|
|
1216
1169
|
"rule": {
|
|
1217
|
-
"$ref": "#/rules@
|
|
1170
|
+
"$ref": "#/rules@42"
|
|
1218
1171
|
},
|
|
1219
1172
|
"arguments": []
|
|
1220
1173
|
},
|
|
@@ -1789,8 +1742,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
1789
1742
|
},
|
|
1790
1743
|
{
|
|
1791
1744
|
"$type": "ParserRule",
|
|
1792
|
-
"name": "ConfigInvocationArgList",
|
|
1793
1745
|
"fragment": true,
|
|
1746
|
+
"name": "ConfigInvocationArgList",
|
|
1794
1747
|
"definition": {
|
|
1795
1748
|
"$type": "Group",
|
|
1796
1749
|
"elements": [
|
|
@@ -2097,8 +2050,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
2097
2050
|
},
|
|
2098
2051
|
{
|
|
2099
2052
|
"$type": "ParserRule",
|
|
2100
|
-
"name": "ReferenceArgList",
|
|
2101
2053
|
"fragment": true,
|
|
2054
|
+
"name": "ReferenceArgList",
|
|
2102
2055
|
"definition": {
|
|
2103
2056
|
"$type": "Group",
|
|
2104
2057
|
"elements": [
|
|
@@ -2914,8 +2867,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
2914
2867
|
},
|
|
2915
2868
|
{
|
|
2916
2869
|
"$type": "ParserRule",
|
|
2917
|
-
"name": "ArgumentList",
|
|
2918
2870
|
"fragment": true,
|
|
2871
|
+
"name": "ArgumentList",
|
|
2919
2872
|
"definition": {
|
|
2920
2873
|
"$type": "Group",
|
|
2921
2874
|
"elements": [
|
|
@@ -3008,16 +2961,6 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3008
2961
|
{
|
|
3009
2962
|
"$type": "Group",
|
|
3010
2963
|
"elements": [
|
|
3011
|
-
{
|
|
3012
|
-
"$type": "Assignment",
|
|
3013
|
-
"feature": "isAbstract",
|
|
3014
|
-
"operator": "?=",
|
|
3015
|
-
"terminal": {
|
|
3016
|
-
"$type": "Keyword",
|
|
3017
|
-
"value": "abstract"
|
|
3018
|
-
},
|
|
3019
|
-
"cardinality": "?"
|
|
3020
|
-
},
|
|
3021
2964
|
{
|
|
3022
2965
|
"$type": "Keyword",
|
|
3023
2966
|
"value": "model"
|
|
@@ -3035,45 +2978,59 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3035
2978
|
}
|
|
3036
2979
|
},
|
|
3037
2980
|
{
|
|
3038
|
-
"$type": "
|
|
2981
|
+
"$type": "Alternatives",
|
|
3039
2982
|
"elements": [
|
|
3040
2983
|
{
|
|
3041
|
-
"$type": "
|
|
3042
|
-
"
|
|
2984
|
+
"$type": "RuleCall",
|
|
2985
|
+
"rule": {
|
|
2986
|
+
"$ref": "#/rules@38"
|
|
2987
|
+
},
|
|
2988
|
+
"arguments": []
|
|
2989
|
+
},
|
|
2990
|
+
{
|
|
2991
|
+
"$type": "RuleCall",
|
|
2992
|
+
"rule": {
|
|
2993
|
+
"$ref": "#/rules@39"
|
|
2994
|
+
},
|
|
2995
|
+
"arguments": []
|
|
3043
2996
|
},
|
|
3044
2997
|
{
|
|
3045
|
-
"$type": "
|
|
3046
|
-
"
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
2998
|
+
"$type": "Group",
|
|
2999
|
+
"elements": [
|
|
3000
|
+
{
|
|
3001
|
+
"$type": "RuleCall",
|
|
3002
|
+
"rule": {
|
|
3003
|
+
"$ref": "#/rules@39"
|
|
3004
|
+
},
|
|
3005
|
+
"arguments": []
|
|
3052
3006
|
},
|
|
3053
|
-
|
|
3054
|
-
|
|
3007
|
+
{
|
|
3008
|
+
"$type": "RuleCall",
|
|
3009
|
+
"rule": {
|
|
3010
|
+
"$ref": "#/rules@38"
|
|
3011
|
+
},
|
|
3012
|
+
"arguments": []
|
|
3013
|
+
}
|
|
3014
|
+
]
|
|
3055
3015
|
},
|
|
3056
3016
|
{
|
|
3057
3017
|
"$type": "Group",
|
|
3058
3018
|
"elements": [
|
|
3059
3019
|
{
|
|
3060
|
-
"$type": "
|
|
3061
|
-
"
|
|
3020
|
+
"$type": "RuleCall",
|
|
3021
|
+
"rule": {
|
|
3022
|
+
"$ref": "#/rules@38"
|
|
3023
|
+
},
|
|
3024
|
+
"arguments": []
|
|
3062
3025
|
},
|
|
3063
3026
|
{
|
|
3064
|
-
"$type": "
|
|
3065
|
-
"
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
"type": {
|
|
3070
|
-
"$ref": "#/rules@37"
|
|
3071
|
-
},
|
|
3072
|
-
"deprecatedSyntax": false
|
|
3073
|
-
}
|
|
3027
|
+
"$type": "RuleCall",
|
|
3028
|
+
"rule": {
|
|
3029
|
+
"$ref": "#/rules@39"
|
|
3030
|
+
},
|
|
3031
|
+
"arguments": []
|
|
3074
3032
|
}
|
|
3075
|
-
]
|
|
3076
|
-
"cardinality": "*"
|
|
3033
|
+
]
|
|
3077
3034
|
}
|
|
3078
3035
|
],
|
|
3079
3036
|
"cardinality": "?"
|
|
@@ -3122,7 +3079,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3122
3079
|
"terminal": {
|
|
3123
3080
|
"$type": "RuleCall",
|
|
3124
3081
|
"rule": {
|
|
3125
|
-
"$ref": "#/rules@
|
|
3082
|
+
"$ref": "#/rules@40"
|
|
3126
3083
|
},
|
|
3127
3084
|
"arguments": []
|
|
3128
3085
|
}
|
|
@@ -3157,7 +3114,92 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3157
3114
|
},
|
|
3158
3115
|
{
|
|
3159
3116
|
"$type": "ParserRule",
|
|
3160
|
-
"
|
|
3117
|
+
"fragment": true,
|
|
3118
|
+
"name": "WithClause",
|
|
3119
|
+
"definition": {
|
|
3120
|
+
"$type": "Group",
|
|
3121
|
+
"elements": [
|
|
3122
|
+
{
|
|
3123
|
+
"$type": "Keyword",
|
|
3124
|
+
"value": "with"
|
|
3125
|
+
},
|
|
3126
|
+
{
|
|
3127
|
+
"$type": "Assignment",
|
|
3128
|
+
"feature": "mixins",
|
|
3129
|
+
"operator": "+=",
|
|
3130
|
+
"terminal": {
|
|
3131
|
+
"$type": "CrossReference",
|
|
3132
|
+
"type": {
|
|
3133
|
+
"$ref": "#/rules@42"
|
|
3134
|
+
},
|
|
3135
|
+
"deprecatedSyntax": false
|
|
3136
|
+
}
|
|
3137
|
+
},
|
|
3138
|
+
{
|
|
3139
|
+
"$type": "Group",
|
|
3140
|
+
"elements": [
|
|
3141
|
+
{
|
|
3142
|
+
"$type": "Keyword",
|
|
3143
|
+
"value": ",",
|
|
3144
|
+
"cardinality": "?"
|
|
3145
|
+
},
|
|
3146
|
+
{
|
|
3147
|
+
"$type": "Assignment",
|
|
3148
|
+
"feature": "mixins",
|
|
3149
|
+
"operator": "+=",
|
|
3150
|
+
"terminal": {
|
|
3151
|
+
"$type": "CrossReference",
|
|
3152
|
+
"type": {
|
|
3153
|
+
"$ref": "#/rules@42"
|
|
3154
|
+
},
|
|
3155
|
+
"deprecatedSyntax": false
|
|
3156
|
+
}
|
|
3157
|
+
}
|
|
3158
|
+
],
|
|
3159
|
+
"cardinality": "*"
|
|
3160
|
+
}
|
|
3161
|
+
]
|
|
3162
|
+
},
|
|
3163
|
+
"definesHiddenTokens": false,
|
|
3164
|
+
"entry": false,
|
|
3165
|
+
"hiddenTokens": [],
|
|
3166
|
+
"parameters": [],
|
|
3167
|
+
"wildcard": false
|
|
3168
|
+
},
|
|
3169
|
+
{
|
|
3170
|
+
"$type": "ParserRule",
|
|
3171
|
+
"fragment": true,
|
|
3172
|
+
"name": "ExtendsClause",
|
|
3173
|
+
"definition": {
|
|
3174
|
+
"$type": "Group",
|
|
3175
|
+
"elements": [
|
|
3176
|
+
{
|
|
3177
|
+
"$type": "Keyword",
|
|
3178
|
+
"value": "extends"
|
|
3179
|
+
},
|
|
3180
|
+
{
|
|
3181
|
+
"$type": "Assignment",
|
|
3182
|
+
"feature": "baseModel",
|
|
3183
|
+
"operator": "=",
|
|
3184
|
+
"terminal": {
|
|
3185
|
+
"$type": "CrossReference",
|
|
3186
|
+
"type": {
|
|
3187
|
+
"$ref": "#/rules@37"
|
|
3188
|
+
},
|
|
3189
|
+
"deprecatedSyntax": false
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
]
|
|
3193
|
+
},
|
|
3194
|
+
"definesHiddenTokens": false,
|
|
3195
|
+
"entry": false,
|
|
3196
|
+
"hiddenTokens": [],
|
|
3197
|
+
"parameters": [],
|
|
3198
|
+
"wildcard": false
|
|
3199
|
+
},
|
|
3200
|
+
{
|
|
3201
|
+
"$type": "ParserRule",
|
|
3202
|
+
"name": "DataField",
|
|
3161
3203
|
"definition": {
|
|
3162
3204
|
"$type": "Group",
|
|
3163
3205
|
"elements": [
|
|
@@ -3193,7 +3235,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3193
3235
|
"terminal": {
|
|
3194
3236
|
"$type": "RuleCall",
|
|
3195
3237
|
"rule": {
|
|
3196
|
-
"$ref": "#/rules@
|
|
3238
|
+
"$ref": "#/rules@41"
|
|
3197
3239
|
},
|
|
3198
3240
|
"arguments": []
|
|
3199
3241
|
}
|
|
@@ -3222,7 +3264,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3222
3264
|
},
|
|
3223
3265
|
{
|
|
3224
3266
|
"$type": "ParserRule",
|
|
3225
|
-
"name": "
|
|
3267
|
+
"name": "DataFieldType",
|
|
3226
3268
|
"definition": {
|
|
3227
3269
|
"$type": "Group",
|
|
3228
3270
|
"elements": [
|
|
@@ -3260,7 +3302,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3260
3302
|
"terminal": {
|
|
3261
3303
|
"$type": "CrossReference",
|
|
3262
3304
|
"type": {
|
|
3263
|
-
"$ref": "#/types@
|
|
3305
|
+
"$ref": "#/types@2"
|
|
3264
3306
|
},
|
|
3265
3307
|
"terminal": {
|
|
3266
3308
|
"$type": "RuleCall",
|
|
@@ -3348,187 +3390,50 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3348
3390
|
}
|
|
3349
3391
|
},
|
|
3350
3392
|
{
|
|
3351
|
-
"$type": "
|
|
3352
|
-
"
|
|
3353
|
-
|
|
3354
|
-
{
|
|
3355
|
-
"$type": "Alternatives",
|
|
3356
|
-
"elements": [
|
|
3357
|
-
{
|
|
3358
|
-
"$type": "Assignment",
|
|
3359
|
-
"feature": "fields",
|
|
3360
|
-
"operator": "+=",
|
|
3361
|
-
"terminal": {
|
|
3362
|
-
"$type": "RuleCall",
|
|
3363
|
-
"rule": {
|
|
3364
|
-
"$ref": "#/rules@41"
|
|
3365
|
-
},
|
|
3366
|
-
"arguments": []
|
|
3367
|
-
}
|
|
3368
|
-
},
|
|
3369
|
-
{
|
|
3370
|
-
"$type": "Assignment",
|
|
3371
|
-
"feature": "attributes",
|
|
3372
|
-
"operator": "+=",
|
|
3373
|
-
"terminal": {
|
|
3374
|
-
"$type": "RuleCall",
|
|
3375
|
-
"rule": {
|
|
3376
|
-
"$ref": "#/rules@57"
|
|
3377
|
-
},
|
|
3378
|
-
"arguments": []
|
|
3379
|
-
}
|
|
3380
|
-
}
|
|
3381
|
-
],
|
|
3382
|
-
"cardinality": "*"
|
|
3383
|
-
},
|
|
3384
|
-
{
|
|
3385
|
-
"$type": "Keyword",
|
|
3386
|
-
"value": "}"
|
|
3387
|
-
}
|
|
3388
|
-
]
|
|
3389
|
-
},
|
|
3390
|
-
"definesHiddenTokens": false,
|
|
3391
|
-
"entry": false,
|
|
3392
|
-
"fragment": false,
|
|
3393
|
-
"hiddenTokens": [],
|
|
3394
|
-
"parameters": [],
|
|
3395
|
-
"wildcard": false
|
|
3396
|
-
},
|
|
3397
|
-
{
|
|
3398
|
-
"$type": "ParserRule",
|
|
3399
|
-
"name": "TypeDefField",
|
|
3400
|
-
"definition": {
|
|
3401
|
-
"$type": "Group",
|
|
3402
|
-
"elements": [
|
|
3403
|
-
{
|
|
3404
|
-
"$type": "Assignment",
|
|
3405
|
-
"feature": "comments",
|
|
3406
|
-
"operator": "+=",
|
|
3407
|
-
"terminal": {
|
|
3408
|
-
"$type": "RuleCall",
|
|
3409
|
-
"rule": {
|
|
3410
|
-
"$ref": "#/rules@71"
|
|
3411
|
-
},
|
|
3412
|
-
"arguments": []
|
|
3393
|
+
"$type": "RuleCall",
|
|
3394
|
+
"rule": {
|
|
3395
|
+
"$ref": "#/rules@38"
|
|
3413
3396
|
},
|
|
3414
|
-
"
|
|
3415
|
-
|
|
3416
|
-
{
|
|
3417
|
-
"$type": "Assignment",
|
|
3418
|
-
"feature": "name",
|
|
3419
|
-
"operator": "=",
|
|
3420
|
-
"terminal": {
|
|
3421
|
-
"$type": "RuleCall",
|
|
3422
|
-
"rule": {
|
|
3423
|
-
"$ref": "#/rules@52"
|
|
3424
|
-
},
|
|
3425
|
-
"arguments": []
|
|
3426
|
-
}
|
|
3397
|
+
"arguments": [],
|
|
3398
|
+
"cardinality": "?"
|
|
3427
3399
|
},
|
|
3428
3400
|
{
|
|
3429
|
-
"$type": "
|
|
3430
|
-
"
|
|
3431
|
-
"operator": "=",
|
|
3432
|
-
"terminal": {
|
|
3433
|
-
"$type": "RuleCall",
|
|
3434
|
-
"rule": {
|
|
3435
|
-
"$ref": "#/rules@42"
|
|
3436
|
-
},
|
|
3437
|
-
"arguments": []
|
|
3438
|
-
}
|
|
3401
|
+
"$type": "Keyword",
|
|
3402
|
+
"value": "{"
|
|
3439
3403
|
},
|
|
3440
|
-
{
|
|
3441
|
-
"$type": "Assignment",
|
|
3442
|
-
"feature": "attributes",
|
|
3443
|
-
"operator": "+=",
|
|
3444
|
-
"terminal": {
|
|
3445
|
-
"$type": "RuleCall",
|
|
3446
|
-
"rule": {
|
|
3447
|
-
"$ref": "#/rules@56"
|
|
3448
|
-
},
|
|
3449
|
-
"arguments": []
|
|
3450
|
-
},
|
|
3451
|
-
"cardinality": "*"
|
|
3452
|
-
}
|
|
3453
|
-
]
|
|
3454
|
-
},
|
|
3455
|
-
"definesHiddenTokens": false,
|
|
3456
|
-
"entry": false,
|
|
3457
|
-
"fragment": false,
|
|
3458
|
-
"hiddenTokens": [],
|
|
3459
|
-
"parameters": [],
|
|
3460
|
-
"wildcard": false
|
|
3461
|
-
},
|
|
3462
|
-
{
|
|
3463
|
-
"$type": "ParserRule",
|
|
3464
|
-
"name": "TypeDefFieldType",
|
|
3465
|
-
"definition": {
|
|
3466
|
-
"$type": "Group",
|
|
3467
|
-
"elements": [
|
|
3468
3404
|
{
|
|
3469
3405
|
"$type": "Alternatives",
|
|
3470
3406
|
"elements": [
|
|
3471
3407
|
{
|
|
3472
3408
|
"$type": "Assignment",
|
|
3473
|
-
"feature": "
|
|
3474
|
-
"operator": "
|
|
3475
|
-
"terminal": {
|
|
3476
|
-
"$type": "RuleCall",
|
|
3477
|
-
"rule": {
|
|
3478
|
-
"$ref": "#/rules@62"
|
|
3479
|
-
},
|
|
3480
|
-
"arguments": []
|
|
3481
|
-
}
|
|
3482
|
-
},
|
|
3483
|
-
{
|
|
3484
|
-
"$type": "Assignment",
|
|
3485
|
-
"feature": "reference",
|
|
3486
|
-
"operator": "=",
|
|
3487
|
-
"terminal": {
|
|
3488
|
-
"$type": "CrossReference",
|
|
3489
|
-
"type": {
|
|
3490
|
-
"$ref": "#/types@2"
|
|
3491
|
-
},
|
|
3492
|
-
"terminal": {
|
|
3493
|
-
"$type": "RuleCall",
|
|
3494
|
-
"rule": {
|
|
3495
|
-
"$ref": "#/rules@51"
|
|
3496
|
-
},
|
|
3497
|
-
"arguments": []
|
|
3498
|
-
},
|
|
3499
|
-
"deprecatedSyntax": false
|
|
3500
|
-
}
|
|
3501
|
-
}
|
|
3502
|
-
]
|
|
3503
|
-
},
|
|
3504
|
-
{
|
|
3505
|
-
"$type": "Group",
|
|
3506
|
-
"elements": [
|
|
3507
|
-
{
|
|
3508
|
-
"$type": "Assignment",
|
|
3509
|
-
"feature": "array",
|
|
3510
|
-
"operator": "?=",
|
|
3409
|
+
"feature": "fields",
|
|
3410
|
+
"operator": "+=",
|
|
3511
3411
|
"terminal": {
|
|
3512
|
-
"$type": "
|
|
3513
|
-
"
|
|
3412
|
+
"$type": "RuleCall",
|
|
3413
|
+
"rule": {
|
|
3414
|
+
"$ref": "#/rules@40"
|
|
3415
|
+
},
|
|
3416
|
+
"arguments": []
|
|
3514
3417
|
}
|
|
3515
3418
|
},
|
|
3516
3419
|
{
|
|
3517
|
-
"$type": "
|
|
3518
|
-
"
|
|
3420
|
+
"$type": "Assignment",
|
|
3421
|
+
"feature": "attributes",
|
|
3422
|
+
"operator": "+=",
|
|
3423
|
+
"terminal": {
|
|
3424
|
+
"$type": "RuleCall",
|
|
3425
|
+
"rule": {
|
|
3426
|
+
"$ref": "#/rules@57"
|
|
3427
|
+
},
|
|
3428
|
+
"arguments": []
|
|
3429
|
+
}
|
|
3519
3430
|
}
|
|
3520
3431
|
],
|
|
3521
|
-
"cardinality": "
|
|
3432
|
+
"cardinality": "*"
|
|
3522
3433
|
},
|
|
3523
3434
|
{
|
|
3524
|
-
"$type": "
|
|
3525
|
-
"
|
|
3526
|
-
"operator": "?=",
|
|
3527
|
-
"terminal": {
|
|
3528
|
-
"$type": "Keyword",
|
|
3529
|
-
"value": "?"
|
|
3530
|
-
},
|
|
3531
|
-
"cardinality": "?"
|
|
3435
|
+
"$type": "Keyword",
|
|
3436
|
+
"value": "}"
|
|
3532
3437
|
}
|
|
3533
3438
|
]
|
|
3534
3439
|
},
|
|
@@ -3939,7 +3844,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
3939
3844
|
"terminal": {
|
|
3940
3845
|
"$type": "CrossReference",
|
|
3941
3846
|
"type": {
|
|
3942
|
-
"$ref": "#/types@
|
|
3847
|
+
"$ref": "#/types@2"
|
|
3943
3848
|
},
|
|
3944
3849
|
"terminal": {
|
|
3945
3850
|
"$type": "RuleCall",
|
|
@@ -4553,7 +4458,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
4553
4458
|
"terminal": {
|
|
4554
4459
|
"$type": "CrossReference",
|
|
4555
4460
|
"type": {
|
|
4556
|
-
"$ref": "#/types@
|
|
4461
|
+
"$ref": "#/types@2"
|
|
4557
4462
|
},
|
|
4558
4463
|
"terminal": {
|
|
4559
4464
|
"$type": "RuleCall",
|
|
@@ -4607,7 +4512,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
4607
4512
|
},
|
|
4608
4513
|
{
|
|
4609
4514
|
"$type": "ParserRule",
|
|
4610
|
-
"name": "
|
|
4515
|
+
"name": "DataFieldAttribute",
|
|
4611
4516
|
"definition": {
|
|
4612
4517
|
"$type": "Group",
|
|
4613
4518
|
"elements": [
|
|
@@ -4783,8 +4688,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
4783
4688
|
},
|
|
4784
4689
|
{
|
|
4785
4690
|
"$type": "ParserRule",
|
|
4786
|
-
"name": "AttributeArgList",
|
|
4787
4691
|
"fragment": true,
|
|
4692
|
+
"name": "AttributeArgList",
|
|
4788
4693
|
"definition": {
|
|
4789
4694
|
"$type": "Group",
|
|
4790
4695
|
"elements": [
|
|
@@ -5124,13 +5029,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
5124
5029
|
{
|
|
5125
5030
|
"$type": "SimpleType",
|
|
5126
5031
|
"typeRef": {
|
|
5127
|
-
"$ref": "#/rules@
|
|
5128
|
-
}
|
|
5129
|
-
},
|
|
5130
|
-
{
|
|
5131
|
-
"$type": "SimpleType",
|
|
5132
|
-
"typeRef": {
|
|
5133
|
-
"$ref": "#/rules@41"
|
|
5032
|
+
"$ref": "#/rules@40"
|
|
5134
5033
|
}
|
|
5135
5034
|
},
|
|
5136
5035
|
{
|
|
@@ -5146,42 +5045,10 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
5146
5045
|
"$type": "Type",
|
|
5147
5046
|
"name": "MemberAccessTarget",
|
|
5148
5047
|
"type": {
|
|
5149
|
-
"$type": "
|
|
5150
|
-
"
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
"typeRef": {
|
|
5154
|
-
"$ref": "#/rules@38"
|
|
5155
|
-
}
|
|
5156
|
-
},
|
|
5157
|
-
{
|
|
5158
|
-
"$type": "SimpleType",
|
|
5159
|
-
"typeRef": {
|
|
5160
|
-
"$ref": "#/rules@41"
|
|
5161
|
-
}
|
|
5162
|
-
}
|
|
5163
|
-
]
|
|
5164
|
-
}
|
|
5165
|
-
},
|
|
5166
|
-
{
|
|
5167
|
-
"$type": "Type",
|
|
5168
|
-
"name": "TypeDefFieldTypes",
|
|
5169
|
-
"type": {
|
|
5170
|
-
"$type": "UnionType",
|
|
5171
|
-
"types": [
|
|
5172
|
-
{
|
|
5173
|
-
"$type": "SimpleType",
|
|
5174
|
-
"typeRef": {
|
|
5175
|
-
"$ref": "#/rules@40"
|
|
5176
|
-
}
|
|
5177
|
-
},
|
|
5178
|
-
{
|
|
5179
|
-
"$type": "SimpleType",
|
|
5180
|
-
"typeRef": {
|
|
5181
|
-
"$ref": "#/rules@44"
|
|
5182
|
-
}
|
|
5183
|
-
}
|
|
5184
|
-
]
|
|
5048
|
+
"$type": "SimpleType",
|
|
5049
|
+
"typeRef": {
|
|
5050
|
+
"$ref": "#/rules@40"
|
|
5051
|
+
}
|
|
5185
5052
|
}
|
|
5186
5053
|
},
|
|
5187
5054
|
{
|
|
@@ -5199,7 +5066,7 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
5199
5066
|
{
|
|
5200
5067
|
"$type": "SimpleType",
|
|
5201
5068
|
"typeRef": {
|
|
5202
|
-
"$ref": "#/rules@
|
|
5069
|
+
"$ref": "#/rules@42"
|
|
5203
5070
|
}
|
|
5204
5071
|
},
|
|
5205
5072
|
{
|
|
@@ -5242,9 +5109,10 @@ import { AstUtils as AstUtils2 } from "langium";
|
|
|
5242
5109
|
import pluralize from "pluralize";
|
|
5243
5110
|
|
|
5244
5111
|
// src/utils.ts
|
|
5112
|
+
import { invariant } from "@zenstackhq/common-helpers";
|
|
5245
5113
|
import { AstUtils, URI } from "langium";
|
|
5114
|
+
import fs from "fs";
|
|
5246
5115
|
import path from "path";
|
|
5247
|
-
import fs from "node:fs";
|
|
5248
5116
|
function hasAttribute(decl, name) {
|
|
5249
5117
|
return !!getAttribute(decl, name);
|
|
5250
5118
|
}
|
|
@@ -5316,10 +5184,10 @@ function isEnumFieldReference(node) {
|
|
|
5316
5184
|
return isReferenceExpr(node) && isEnumField(node.target.ref);
|
|
5317
5185
|
}
|
|
5318
5186
|
__name(isEnumFieldReference, "isEnumFieldReference");
|
|
5319
|
-
function
|
|
5320
|
-
return isReferenceExpr(node) &&
|
|
5187
|
+
function isDataFieldReference(node) {
|
|
5188
|
+
return isReferenceExpr(node) && isDataField(node.target.ref);
|
|
5321
5189
|
}
|
|
5322
|
-
__name(
|
|
5190
|
+
__name(isDataFieldReference, "isDataFieldReference");
|
|
5323
5191
|
function isRelationshipField(field) {
|
|
5324
5192
|
return isDataModel(field.type.reference?.ref);
|
|
5325
5193
|
}
|
|
@@ -5339,43 +5207,14 @@ function resolved(ref) {
|
|
|
5339
5207
|
return ref.ref;
|
|
5340
5208
|
}
|
|
5341
5209
|
__name(resolved, "resolved");
|
|
5342
|
-
function
|
|
5343
|
-
for (const base of start.superTypes) {
|
|
5344
|
-
if (base.ref === target) {
|
|
5345
|
-
return [
|
|
5346
|
-
base.ref
|
|
5347
|
-
];
|
|
5348
|
-
}
|
|
5349
|
-
const path4 = findUpInheritance(base.ref, target);
|
|
5350
|
-
if (path4) {
|
|
5351
|
-
return [
|
|
5352
|
-
base.ref,
|
|
5353
|
-
...path4
|
|
5354
|
-
];
|
|
5355
|
-
}
|
|
5356
|
-
}
|
|
5357
|
-
return void 0;
|
|
5358
|
-
}
|
|
5359
|
-
__name(findUpInheritance, "findUpInheritance");
|
|
5360
|
-
function getModelFieldsWithBases(model, includeDelegate = true) {
|
|
5361
|
-
if (model.$baseMerged) {
|
|
5362
|
-
return model.fields;
|
|
5363
|
-
} else {
|
|
5364
|
-
return [
|
|
5365
|
-
...model.fields,
|
|
5366
|
-
...getRecursiveBases(model, includeDelegate).flatMap((base) => base.fields)
|
|
5367
|
-
];
|
|
5368
|
-
}
|
|
5369
|
-
}
|
|
5370
|
-
__name(getModelFieldsWithBases, "getModelFieldsWithBases");
|
|
5371
|
-
function getRecursiveBases(dataModel, includeDelegate = true, seen = /* @__PURE__ */ new Set()) {
|
|
5210
|
+
function getRecursiveBases(decl, includeDelegate = true, seen = /* @__PURE__ */ new Set()) {
|
|
5372
5211
|
const result = [];
|
|
5373
|
-
if (seen.has(
|
|
5212
|
+
if (seen.has(decl)) {
|
|
5374
5213
|
return result;
|
|
5375
5214
|
}
|
|
5376
|
-
seen.add(
|
|
5377
|
-
|
|
5378
|
-
const baseDecl =
|
|
5215
|
+
seen.add(decl);
|
|
5216
|
+
decl.mixins.forEach((mixin) => {
|
|
5217
|
+
const baseDecl = mixin.ref;
|
|
5379
5218
|
if (baseDecl) {
|
|
5380
5219
|
if (!includeDelegate && isDelegateModel(baseDecl)) {
|
|
5381
5220
|
return;
|
|
@@ -5388,14 +5227,13 @@ function getRecursiveBases(dataModel, includeDelegate = true, seen = /* @__PURE_
|
|
|
5388
5227
|
}
|
|
5389
5228
|
__name(getRecursiveBases, "getRecursiveBases");
|
|
5390
5229
|
function getModelIdFields(model) {
|
|
5391
|
-
const modelsToCheck =
|
|
5392
|
-
model
|
|
5393
|
-
] : [
|
|
5230
|
+
const modelsToCheck = [
|
|
5394
5231
|
model,
|
|
5395
5232
|
...getRecursiveBases(model)
|
|
5396
5233
|
];
|
|
5397
5234
|
for (const modelToCheck of modelsToCheck) {
|
|
5398
|
-
const
|
|
5235
|
+
const allAttributes = getAllAttributes(modelToCheck);
|
|
5236
|
+
const idAttr = allAttributes.find((attr) => attr.decl.$refText === "@@id");
|
|
5399
5237
|
if (!idAttr) {
|
|
5400
5238
|
continue;
|
|
5401
5239
|
}
|
|
@@ -5409,14 +5247,13 @@ function getModelIdFields(model) {
|
|
|
5409
5247
|
}
|
|
5410
5248
|
__name(getModelIdFields, "getModelIdFields");
|
|
5411
5249
|
function getModelUniqueFields(model) {
|
|
5412
|
-
const modelsToCheck =
|
|
5413
|
-
model
|
|
5414
|
-
] : [
|
|
5250
|
+
const modelsToCheck = [
|
|
5415
5251
|
model,
|
|
5416
5252
|
...getRecursiveBases(model)
|
|
5417
5253
|
];
|
|
5418
5254
|
for (const modelToCheck of modelsToCheck) {
|
|
5419
|
-
const
|
|
5255
|
+
const allAttributes = getAllAttributes(modelToCheck);
|
|
5256
|
+
const uniqueAttr = allAttributes.find((attr) => attr.decl.$refText === "@@unique");
|
|
5420
5257
|
if (!uniqueAttr) {
|
|
5421
5258
|
continue;
|
|
5422
5259
|
}
|
|
@@ -5563,34 +5400,24 @@ function resolveImport(documents, imp) {
|
|
|
5563
5400
|
}
|
|
5564
5401
|
__name(resolveImport, "resolveImport");
|
|
5565
5402
|
function resolveImportUri(imp) {
|
|
5566
|
-
if (!imp.path)
|
|
5567
|
-
|
|
5568
|
-
imp.path += ".zmodel";
|
|
5569
|
-
}
|
|
5570
|
-
if (!imp.path.startsWith(".") && // Respect relative paths
|
|
5571
|
-
!path.isAbsolute(imp.path)) {
|
|
5572
|
-
const contextPath = imp.$container.$document ? path.dirname(imp.$container.$document.uri.fsPath) : process.cwd();
|
|
5573
|
-
imp.path = findNodeModulesFile(imp.path, contextPath) ?? imp.path;
|
|
5403
|
+
if (!imp.path) {
|
|
5404
|
+
return void 0;
|
|
5574
5405
|
}
|
|
5575
5406
|
const doc = AstUtils.getDocument(imp);
|
|
5576
5407
|
const dir = path.dirname(doc.uri.fsPath);
|
|
5577
|
-
|
|
5408
|
+
const importPath = imp.path.endsWith(".zmodel") ? imp.path : `${imp.path}.zmodel`;
|
|
5409
|
+
return URI.file(path.resolve(dir, importPath));
|
|
5578
5410
|
}
|
|
5579
5411
|
__name(resolveImportUri, "resolveImportUri");
|
|
5580
|
-
function
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
]
|
|
5587
|
-
});
|
|
5588
|
-
return resolvedPath;
|
|
5589
|
-
} catch (error) {
|
|
5590
|
-
return void 0;
|
|
5412
|
+
function getDataModelAndTypeDefs(model, includeIgnored = false) {
|
|
5413
|
+
const r = model.declarations.filter((d) => isDataModel(d) || isTypeDef(d));
|
|
5414
|
+
if (includeIgnored) {
|
|
5415
|
+
return r;
|
|
5416
|
+
} else {
|
|
5417
|
+
return r.filter((model2) => !hasAttribute(model2, "@@ignore"));
|
|
5591
5418
|
}
|
|
5592
5419
|
}
|
|
5593
|
-
__name(
|
|
5420
|
+
__name(getDataModelAndTypeDefs, "getDataModelAndTypeDefs");
|
|
5594
5421
|
function getAllDeclarationsIncludingImports(documents, model) {
|
|
5595
5422
|
const imports = resolveTransitiveImports(documents, model);
|
|
5596
5423
|
return model.declarations.concat(...imports.map((imp) => imp.declarations));
|
|
@@ -5655,6 +5482,58 @@ function isMemberContainer(node) {
|
|
|
5655
5482
|
return isDataModel(node) || isTypeDef(node);
|
|
5656
5483
|
}
|
|
5657
5484
|
__name(isMemberContainer, "isMemberContainer");
|
|
5485
|
+
function getAllFields(decl, includeIgnored = false, seen = /* @__PURE__ */ new Set()) {
|
|
5486
|
+
if (seen.has(decl)) {
|
|
5487
|
+
return [];
|
|
5488
|
+
}
|
|
5489
|
+
seen.add(decl);
|
|
5490
|
+
const fields = [];
|
|
5491
|
+
for (const mixin of decl.mixins) {
|
|
5492
|
+
invariant(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);
|
|
5493
|
+
fields.push(...getAllFields(mixin.ref, includeIgnored, seen));
|
|
5494
|
+
}
|
|
5495
|
+
if (isDataModel(decl) && decl.baseModel) {
|
|
5496
|
+
invariant(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);
|
|
5497
|
+
fields.push(...getAllFields(decl.baseModel.ref, includeIgnored, seen));
|
|
5498
|
+
}
|
|
5499
|
+
fields.push(...decl.fields.filter((f) => includeIgnored || !hasAttribute(f, "@ignore")));
|
|
5500
|
+
return fields;
|
|
5501
|
+
}
|
|
5502
|
+
__name(getAllFields, "getAllFields");
|
|
5503
|
+
function getAllAttributes(decl, seen = /* @__PURE__ */ new Set()) {
|
|
5504
|
+
if (seen.has(decl)) {
|
|
5505
|
+
return [];
|
|
5506
|
+
}
|
|
5507
|
+
seen.add(decl);
|
|
5508
|
+
const attributes = [];
|
|
5509
|
+
for (const mixin of decl.mixins) {
|
|
5510
|
+
invariant(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);
|
|
5511
|
+
attributes.push(...getAllAttributes(mixin.ref, seen));
|
|
5512
|
+
}
|
|
5513
|
+
if (isDataModel(decl) && decl.baseModel) {
|
|
5514
|
+
invariant(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);
|
|
5515
|
+
attributes.push(...getAllAttributes(decl.baseModel.ref, seen));
|
|
5516
|
+
}
|
|
5517
|
+
attributes.push(...decl.attributes);
|
|
5518
|
+
return attributes;
|
|
5519
|
+
}
|
|
5520
|
+
__name(getAllAttributes, "getAllAttributes");
|
|
5521
|
+
function getDocument(node) {
|
|
5522
|
+
const rootNode = findRootNode(node);
|
|
5523
|
+
const result = rootNode.$document;
|
|
5524
|
+
if (!result) {
|
|
5525
|
+
throw new Error("AST node has no document.");
|
|
5526
|
+
}
|
|
5527
|
+
return result;
|
|
5528
|
+
}
|
|
5529
|
+
__name(getDocument, "getDocument");
|
|
5530
|
+
function findRootNode(node) {
|
|
5531
|
+
while (node.$container) {
|
|
5532
|
+
node = node.$container;
|
|
5533
|
+
}
|
|
5534
|
+
return node;
|
|
5535
|
+
}
|
|
5536
|
+
__name(findRootNode, "findRootNode");
|
|
5658
5537
|
|
|
5659
5538
|
// src/validators/attribute-application-validator.ts
|
|
5660
5539
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -5682,7 +5561,7 @@ var AttributeApplicationValidator = class {
|
|
|
5682
5561
|
static {
|
|
5683
5562
|
__name(this, "AttributeApplicationValidator");
|
|
5684
5563
|
}
|
|
5685
|
-
validate(attr, accept) {
|
|
5564
|
+
validate(attr, accept, contextDataModel) {
|
|
5686
5565
|
const decl = attr.decl.ref;
|
|
5687
5566
|
if (!decl) {
|
|
5688
5567
|
return;
|
|
@@ -5694,21 +5573,13 @@ var AttributeApplicationValidator = class {
|
|
|
5694
5573
|
});
|
|
5695
5574
|
return;
|
|
5696
5575
|
}
|
|
5697
|
-
if (
|
|
5576
|
+
if (isDataField(targetDecl) && !isValidAttributeTarget(decl, targetDecl)) {
|
|
5698
5577
|
accept("error", `attribute "${decl.name}" cannot be used on this type of field`, {
|
|
5699
5578
|
node: attr
|
|
5700
5579
|
});
|
|
5701
5580
|
}
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
node: attr
|
|
5705
|
-
});
|
|
5706
|
-
}
|
|
5707
|
-
if (isTypeDef(targetDecl) && !hasAttribute(decl, "@@@supportTypeDef")) {
|
|
5708
|
-
accept("error", `attribute "${decl.name}" cannot be used on type declarations`, {
|
|
5709
|
-
node: attr
|
|
5710
|
-
});
|
|
5711
|
-
}
|
|
5581
|
+
this.checkDeprecation(attr, accept);
|
|
5582
|
+
this.checkDuplicatedAttributes(attr, accept, contextDataModel);
|
|
5712
5583
|
const filledParams = /* @__PURE__ */ new Set();
|
|
5713
5584
|
for (const arg of attr.args) {
|
|
5714
5585
|
let paramDecl;
|
|
@@ -5756,6 +5627,28 @@ var AttributeApplicationValidator = class {
|
|
|
5756
5627
|
checker.value.call(this, attr, accept);
|
|
5757
5628
|
}
|
|
5758
5629
|
}
|
|
5630
|
+
checkDeprecation(attr, accept) {
|
|
5631
|
+
const deprecateAttr = attr.decl.ref?.attributes.find((a) => a.decl.ref?.name === "@@@deprecated");
|
|
5632
|
+
if (deprecateAttr) {
|
|
5633
|
+
const message = getStringLiteral(deprecateAttr.args[0]?.value) ?? `Attribute "${attr.decl.ref?.name}" is deprecated`;
|
|
5634
|
+
accept("warning", message, {
|
|
5635
|
+
node: attr
|
|
5636
|
+
});
|
|
5637
|
+
}
|
|
5638
|
+
}
|
|
5639
|
+
checkDuplicatedAttributes(attr, accept, contextDataModel) {
|
|
5640
|
+
const attrDecl = attr.decl.ref;
|
|
5641
|
+
if (!attrDecl?.attributes.some((a) => a.decl.ref?.name === "@@@once")) {
|
|
5642
|
+
return;
|
|
5643
|
+
}
|
|
5644
|
+
const allAttributes = contextDataModel ? getAllAttributes(contextDataModel) : attr.$container.attributes;
|
|
5645
|
+
const duplicates = allAttributes.filter((a) => a.decl.ref === attrDecl && a !== attr);
|
|
5646
|
+
if (duplicates.length > 0) {
|
|
5647
|
+
accept("error", `Attribute "${attrDecl.name}" can only be applied once`, {
|
|
5648
|
+
node: attr
|
|
5649
|
+
});
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5759
5652
|
_checkModelLevelPolicy(attr, accept) {
|
|
5760
5653
|
const kind = getStringLiteral(attr.args[0]?.value);
|
|
5761
5654
|
if (!kind) {
|
|
@@ -5804,7 +5697,7 @@ var AttributeApplicationValidator = class {
|
|
|
5804
5697
|
}
|
|
5805
5698
|
_checkValidate(attr, accept) {
|
|
5806
5699
|
const condition = attr.args[0]?.value;
|
|
5807
|
-
if (condition && AstUtils2.streamAst(condition).some((node) =>
|
|
5700
|
+
if (condition && AstUtils2.streamAst(condition).some((node) => isDataFieldReference(node) && isDataModel(node.$resolvedType?.decl))) {
|
|
5808
5701
|
accept("error", `\`@@validate\` condition cannot use relation fields`, {
|
|
5809
5702
|
node: condition
|
|
5810
5703
|
});
|
|
@@ -5813,9 +5706,18 @@ var AttributeApplicationValidator = class {
|
|
|
5813
5706
|
_checkUnique(attr, accept) {
|
|
5814
5707
|
const fields = attr.args[0]?.value;
|
|
5815
5708
|
if (!fields) {
|
|
5709
|
+
accept("error", `expects an array of field references`, {
|
|
5710
|
+
node: attr.args[0]
|
|
5711
|
+
});
|
|
5816
5712
|
return;
|
|
5817
5713
|
}
|
|
5818
5714
|
if (isArrayExpr(fields)) {
|
|
5715
|
+
if (fields.items.length === 0) {
|
|
5716
|
+
accept("error", `\`@@unique\` expects at least one field reference`, {
|
|
5717
|
+
node: fields
|
|
5718
|
+
});
|
|
5719
|
+
return;
|
|
5720
|
+
}
|
|
5819
5721
|
fields.items.forEach((item) => {
|
|
5820
5722
|
if (!isReferenceExpr(item)) {
|
|
5821
5723
|
accept("error", `Expecting a field reference`, {
|
|
@@ -5823,7 +5725,7 @@ var AttributeApplicationValidator = class {
|
|
|
5823
5725
|
});
|
|
5824
5726
|
return;
|
|
5825
5727
|
}
|
|
5826
|
-
if (!
|
|
5728
|
+
if (!isDataField(item.target.ref)) {
|
|
5827
5729
|
accept("error", `Expecting a field reference`, {
|
|
5828
5730
|
node: item
|
|
5829
5731
|
});
|
|
@@ -5843,7 +5745,7 @@ var AttributeApplicationValidator = class {
|
|
|
5843
5745
|
}
|
|
5844
5746
|
rejectEncryptedFields(attr, accept) {
|
|
5845
5747
|
AstUtils2.streamAllContents(attr).forEach((node) => {
|
|
5846
|
-
if (
|
|
5748
|
+
if (isDataFieldReference(node) && hasAttribute(node.target.ref, "@encrypted")) {
|
|
5847
5749
|
accept("error", `Encrypted fields cannot be used in policy rules`, {
|
|
5848
5750
|
node
|
|
5849
5751
|
});
|
|
@@ -5893,6 +5795,7 @@ _ts_decorate([
|
|
|
5893
5795
|
], AttributeApplicationValidator.prototype, "_checkValidate", null);
|
|
5894
5796
|
_ts_decorate([
|
|
5895
5797
|
check("@@unique"),
|
|
5798
|
+
check("@@id"),
|
|
5896
5799
|
_ts_metadata("design:type", Function),
|
|
5897
5800
|
_ts_metadata("design:paramtypes", [
|
|
5898
5801
|
typeof AttributeApplication === "undefined" ? Object : AttributeApplication,
|
|
@@ -5908,7 +5811,7 @@ function assignableToAttributeParam(arg, param, attr) {
|
|
|
5908
5811
|
let dstType = param.type.type;
|
|
5909
5812
|
let dstIsArray = param.type.array;
|
|
5910
5813
|
if (dstType === "ContextType") {
|
|
5911
|
-
if (
|
|
5814
|
+
if (isDataField(attr.$container)) {
|
|
5912
5815
|
dstIsArray = attr.$container.type.array;
|
|
5913
5816
|
}
|
|
5914
5817
|
}
|
|
@@ -5925,14 +5828,14 @@ function assignableToAttributeParam(arg, param, attr) {
|
|
|
5925
5828
|
}
|
|
5926
5829
|
if (dstType === "FieldReference" || dstType === "TransitiveFieldReference") {
|
|
5927
5830
|
if (dstIsArray) {
|
|
5928
|
-
return isArrayExpr(arg.value) && !arg.value.items.find((item) => !isReferenceExpr(item) || !
|
|
5831
|
+
return isArrayExpr(arg.value) && !arg.value.items.find((item) => !isReferenceExpr(item) || !isDataField(item.target.ref));
|
|
5929
5832
|
} else {
|
|
5930
|
-
return isReferenceExpr(arg.value) &&
|
|
5833
|
+
return isReferenceExpr(arg.value) && isDataField(arg.value.target.ref);
|
|
5931
5834
|
}
|
|
5932
5835
|
}
|
|
5933
5836
|
if (isEnum(argResolvedType.decl)) {
|
|
5934
5837
|
let attrArgDeclType = dstRef?.ref;
|
|
5935
|
-
if (dstType === "ContextType" &&
|
|
5838
|
+
if (dstType === "ContextType" && isDataField(attr.$container) && attr.$container?.type?.reference) {
|
|
5936
5839
|
attrArgDeclType = resolved(attr.$container.type.reference);
|
|
5937
5840
|
dstIsArray = attr.$container.type.array;
|
|
5938
5841
|
}
|
|
@@ -5942,7 +5845,7 @@ function assignableToAttributeParam(arg, param, attr) {
|
|
|
5942
5845
|
return false;
|
|
5943
5846
|
}
|
|
5944
5847
|
if (dstType === "ContextType") {
|
|
5945
|
-
if (
|
|
5848
|
+
if (isDataField(attr.$container)) {
|
|
5946
5849
|
if (!attr.$container?.type?.type) {
|
|
5947
5850
|
return false;
|
|
5948
5851
|
}
|
|
@@ -6010,8 +5913,8 @@ function isValidAttributeTarget(attrDecl, targetDecl) {
|
|
|
6010
5913
|
return allowed;
|
|
6011
5914
|
}
|
|
6012
5915
|
__name(isValidAttributeTarget, "isValidAttributeTarget");
|
|
6013
|
-
function validateAttributeApplication(attr, accept) {
|
|
6014
|
-
new AttributeApplicationValidator().validate(attr, accept);
|
|
5916
|
+
function validateAttributeApplication(attr, accept, contextDataModel) {
|
|
5917
|
+
new AttributeApplicationValidator().validate(attr, accept, contextDataModel);
|
|
6015
5918
|
}
|
|
6016
5919
|
__name(validateAttributeApplication, "validateAttributeApplication");
|
|
6017
5920
|
|
|
@@ -6026,6 +5929,7 @@ var AttributeValidator = class {
|
|
|
6026
5929
|
};
|
|
6027
5930
|
|
|
6028
5931
|
// src/validators/datamodel-validator.ts
|
|
5932
|
+
import { invariant as invariant2 } from "@zenstackhq/common-helpers";
|
|
6029
5933
|
import { AstUtils as AstUtils3 } from "langium";
|
|
6030
5934
|
|
|
6031
5935
|
// src/validators/common.ts
|
|
@@ -6038,8 +5942,8 @@ function validateDuplicatedDeclarations(container, decls, accept) {
|
|
|
6038
5942
|
for (const [name, decls2] of Object.entries(groupByName)) {
|
|
6039
5943
|
if (decls2.length > 1) {
|
|
6040
5944
|
let errorField = decls2[1];
|
|
6041
|
-
if (
|
|
6042
|
-
const nonInheritedFields = decls2.filter((x) => !(
|
|
5945
|
+
if (isDataField(decls2[0])) {
|
|
5946
|
+
const nonInheritedFields = decls2.filter((x) => !(isDataField(x) && x.$container !== container));
|
|
6043
5947
|
if (nonInheritedFields.length > 0) {
|
|
6044
5948
|
errorField = nonInheritedFields.slice(-1)[0];
|
|
6045
5949
|
}
|
|
@@ -6058,22 +5962,21 @@ var DataModelValidator = class {
|
|
|
6058
5962
|
__name(this, "DataModelValidator");
|
|
6059
5963
|
}
|
|
6060
5964
|
validate(dm, accept) {
|
|
6061
|
-
|
|
6062
|
-
this.validateBaseDelegateModel(dm, accept);
|
|
6063
|
-
validateDuplicatedDeclarations(dm, getModelFieldsWithBases(dm), accept);
|
|
5965
|
+
validateDuplicatedDeclarations(dm, getAllFields(dm), accept);
|
|
6064
5966
|
this.validateAttributes(dm, accept);
|
|
6065
5967
|
this.validateFields(dm, accept);
|
|
6066
|
-
if (dm.
|
|
6067
|
-
this.
|
|
5968
|
+
if (dm.mixins.length > 0) {
|
|
5969
|
+
this.validateMixins(dm, accept);
|
|
6068
5970
|
}
|
|
5971
|
+
this.validateInherits(dm, accept);
|
|
6069
5972
|
}
|
|
6070
5973
|
validateFields(dm, accept) {
|
|
6071
|
-
const allFields =
|
|
5974
|
+
const allFields = getAllFields(dm);
|
|
6072
5975
|
const idFields = allFields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === "@id"));
|
|
6073
5976
|
const uniqueFields = allFields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === "@unique"));
|
|
6074
5977
|
const modelLevelIds = getModelIdFields(dm);
|
|
6075
5978
|
const modelUniqueFields = getModelUniqueFields(dm);
|
|
6076
|
-
if (
|
|
5979
|
+
if (idFields.length === 0 && modelLevelIds.length === 0 && uniqueFields.length === 0 && modelUniqueFields.length === 0) {
|
|
6077
5980
|
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.", {
|
|
6078
5981
|
node: dm
|
|
6079
5982
|
});
|
|
@@ -6104,11 +6007,9 @@ var DataModelValidator = class {
|
|
|
6104
6007
|
});
|
|
6105
6008
|
}
|
|
6106
6009
|
dm.fields.forEach((field) => this.validateField(field, accept));
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
});
|
|
6111
|
-
}
|
|
6010
|
+
allFields.filter((x) => isDataModel(x.type.reference?.ref)).forEach((y) => {
|
|
6011
|
+
this.validateRelationField(dm, y, accept);
|
|
6012
|
+
});
|
|
6112
6013
|
}
|
|
6113
6014
|
validateField(field, accept) {
|
|
6114
6015
|
if (field.type.array && field.type.optional) {
|
|
@@ -6124,7 +6025,7 @@ var DataModelValidator = class {
|
|
|
6124
6025
|
if (field.type.array && !isDataModel(field.type.reference?.ref)) {
|
|
6125
6026
|
const provider = this.getDataSourceProvider(AstUtils3.getContainerOfType(field, isModel));
|
|
6126
6027
|
if (provider === "sqlite") {
|
|
6127
|
-
accept("error", `
|
|
6028
|
+
accept("error", `List type is not supported for "${provider}" provider.`, {
|
|
6128
6029
|
node: field.type
|
|
6129
6030
|
});
|
|
6130
6031
|
}
|
|
@@ -6150,7 +6051,7 @@ var DataModelValidator = class {
|
|
|
6150
6051
|
return getLiteral(provider.value);
|
|
6151
6052
|
}
|
|
6152
6053
|
validateAttributes(dm, accept) {
|
|
6153
|
-
dm.
|
|
6054
|
+
getAllAttributes(dm).forEach((attr) => validateAttributeApplication(attr, accept, dm));
|
|
6154
6055
|
}
|
|
6155
6056
|
parseRelation(field, accept) {
|
|
6156
6057
|
const relAttr = field.attributes.find((attr) => attr.decl.ref?.name === "@relation");
|
|
@@ -6269,11 +6170,20 @@ var DataModelValidator = class {
|
|
|
6269
6170
|
if (!thisRelation.valid) {
|
|
6270
6171
|
return;
|
|
6271
6172
|
}
|
|
6272
|
-
if (this.isFieldInheritedFromDelegateModel(field
|
|
6173
|
+
if (this.isFieldInheritedFromDelegateModel(field)) {
|
|
6273
6174
|
return;
|
|
6274
6175
|
}
|
|
6176
|
+
if (this.isSelfRelation(field)) {
|
|
6177
|
+
if (!thisRelation.name) {
|
|
6178
|
+
accept("error", "Self-relation field must have a name in @relation attribute", {
|
|
6179
|
+
node: field
|
|
6180
|
+
});
|
|
6181
|
+
return;
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6275
6184
|
const oppositeModel = field.type.reference.ref;
|
|
6276
|
-
let oppositeFields =
|
|
6185
|
+
let oppositeFields = getAllFields(oppositeModel, false).filter((f) => f !== field && // exclude self in case of self relation
|
|
6186
|
+
f.type.reference?.ref?.name === contextModel.name);
|
|
6277
6187
|
oppositeFields = oppositeFields.filter((f) => {
|
|
6278
6188
|
const fieldRel = this.parseRelation(f);
|
|
6279
6189
|
return fieldRel.valid && fieldRel.name === thisRelation.name;
|
|
@@ -6310,26 +6220,37 @@ var DataModelValidator = class {
|
|
|
6310
6220
|
const oppositeField = oppositeFields[0];
|
|
6311
6221
|
const oppositeRelation = this.parseRelation(oppositeField);
|
|
6312
6222
|
let relationOwner;
|
|
6313
|
-
if (
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
if (thisRelation?.references || thisRelation?.fields) {
|
|
6324
|
-
accept("error", '"fields" and "references" must be provided only on one side of relation field', {
|
|
6325
|
-
node: field
|
|
6326
|
-
});
|
|
6327
|
-
return;
|
|
6328
|
-
} else {
|
|
6329
|
-
relationOwner = field;
|
|
6223
|
+
if (field.type.array && oppositeField.type.array) {
|
|
6224
|
+
for (const r of [
|
|
6225
|
+
thisRelation,
|
|
6226
|
+
oppositeRelation
|
|
6227
|
+
]) {
|
|
6228
|
+
if (r.fields?.length || r.references?.length) {
|
|
6229
|
+
accept("error", 'Implicit many-to-many relation cannot have "fields" or "references" in @relation attribute', {
|
|
6230
|
+
node: r === thisRelation ? field : oppositeField
|
|
6231
|
+
});
|
|
6232
|
+
}
|
|
6330
6233
|
}
|
|
6331
6234
|
} else {
|
|
6332
|
-
if (
|
|
6235
|
+
if (thisRelation?.references?.length && thisRelation.fields?.length) {
|
|
6236
|
+
if (oppositeRelation?.references || oppositeRelation?.fields) {
|
|
6237
|
+
accept("error", '"fields" and "references" must be provided only on one side of relation field', {
|
|
6238
|
+
node: oppositeField
|
|
6239
|
+
});
|
|
6240
|
+
return;
|
|
6241
|
+
} else {
|
|
6242
|
+
relationOwner = oppositeField;
|
|
6243
|
+
}
|
|
6244
|
+
} else if (oppositeRelation?.references?.length && oppositeRelation.fields?.length) {
|
|
6245
|
+
if (thisRelation?.references || thisRelation?.fields) {
|
|
6246
|
+
accept("error", '"fields" and "references" must be provided only on one side of relation field', {
|
|
6247
|
+
node: field
|
|
6248
|
+
});
|
|
6249
|
+
return;
|
|
6250
|
+
} else {
|
|
6251
|
+
relationOwner = field;
|
|
6252
|
+
}
|
|
6253
|
+
} else {
|
|
6333
6254
|
[
|
|
6334
6255
|
field,
|
|
6335
6256
|
oppositeField
|
|
@@ -6340,78 +6261,85 @@ var DataModelValidator = class {
|
|
|
6340
6261
|
});
|
|
6341
6262
|
}
|
|
6342
6263
|
});
|
|
6264
|
+
return;
|
|
6343
6265
|
}
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
});
|
|
6350
|
-
return;
|
|
6351
|
-
}
|
|
6352
|
-
if (relationOwner !== field && !relationOwner.type.array) {
|
|
6353
|
-
const containingModel = field.$container;
|
|
6354
|
-
const uniqueFieldList = getUniqueFields(containingModel);
|
|
6355
|
-
if (containingModel !== contextModel) {
|
|
6356
|
-
uniqueFieldList.push(...getUniqueFields(contextModel));
|
|
6266
|
+
if (!relationOwner.type.array && !relationOwner.type.optional) {
|
|
6267
|
+
accept("error", "Relation field needs to be list or optional", {
|
|
6268
|
+
node: relationOwner
|
|
6269
|
+
});
|
|
6270
|
+
return;
|
|
6357
6271
|
}
|
|
6358
|
-
|
|
6359
|
-
const
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
}
|
|
6364
|
-
if (uniqueFieldList.some((list) => list.includes(refField))) {
|
|
6365
|
-
return;
|
|
6366
|
-
}
|
|
6367
|
-
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`, {
|
|
6368
|
-
node: refField
|
|
6369
|
-
});
|
|
6272
|
+
if (relationOwner !== field && !relationOwner.type.array) {
|
|
6273
|
+
const containingModel = field.$container;
|
|
6274
|
+
const uniqueFieldList = getUniqueFields(containingModel);
|
|
6275
|
+
if (containingModel !== contextModel) {
|
|
6276
|
+
uniqueFieldList.push(...getUniqueFields(contextModel));
|
|
6370
6277
|
}
|
|
6371
|
-
|
|
6278
|
+
thisRelation.fields?.forEach((ref) => {
|
|
6279
|
+
const refField = ref.target.ref;
|
|
6280
|
+
if (refField) {
|
|
6281
|
+
if (refField.attributes.find((a) => a.decl.ref?.name === "@id" || a.decl.ref?.name === "@unique")) {
|
|
6282
|
+
return;
|
|
6283
|
+
}
|
|
6284
|
+
if (uniqueFieldList.some((list) => list.includes(refField))) {
|
|
6285
|
+
return;
|
|
6286
|
+
}
|
|
6287
|
+
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`, {
|
|
6288
|
+
node: refField
|
|
6289
|
+
});
|
|
6290
|
+
}
|
|
6291
|
+
});
|
|
6292
|
+
}
|
|
6372
6293
|
}
|
|
6373
6294
|
}
|
|
6374
6295
|
// checks if the given field is inherited directly or indirectly from a delegate model
|
|
6375
|
-
isFieldInheritedFromDelegateModel(field
|
|
6376
|
-
|
|
6377
|
-
if (basePath && basePath.some(isDelegateModel)) {
|
|
6378
|
-
return true;
|
|
6379
|
-
} else {
|
|
6380
|
-
return false;
|
|
6381
|
-
}
|
|
6382
|
-
}
|
|
6383
|
-
validateBaseAbstractModel(model, accept) {
|
|
6384
|
-
model.superTypes.forEach((superType, index) => {
|
|
6385
|
-
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"`, {
|
|
6386
|
-
node: model,
|
|
6387
|
-
property: "superTypes",
|
|
6388
|
-
index
|
|
6389
|
-
});
|
|
6390
|
-
});
|
|
6296
|
+
isFieldInheritedFromDelegateModel(field) {
|
|
6297
|
+
return isDelegateModel(field.$container);
|
|
6391
6298
|
}
|
|
6392
|
-
|
|
6393
|
-
if (model.
|
|
6394
|
-
|
|
6299
|
+
validateInherits(model, accept) {
|
|
6300
|
+
if (!model.baseModel) {
|
|
6301
|
+
return;
|
|
6302
|
+
}
|
|
6303
|
+
invariant2(model.baseModel.ref, "baseModel must be resolved");
|
|
6304
|
+
if (!isDelegateModel(model.baseModel.ref)) {
|
|
6305
|
+
accept("error", `Model ${model.baseModel.$refText} cannot be extended because it's not a delegate model`, {
|
|
6395
6306
|
node: model,
|
|
6396
|
-
property: "
|
|
6307
|
+
property: "baseModel"
|
|
6397
6308
|
});
|
|
6309
|
+
return;
|
|
6398
6310
|
}
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
dm
|
|
6311
|
+
const seen = [];
|
|
6312
|
+
const todo = [
|
|
6313
|
+
model.baseModel.ref
|
|
6403
6314
|
];
|
|
6404
|
-
const todo = dm.superTypes.map((superType) => superType.ref);
|
|
6405
6315
|
while (todo.length > 0) {
|
|
6406
6316
|
const current = todo.shift();
|
|
6407
6317
|
if (seen.includes(current)) {
|
|
6408
|
-
accept("error", `
|
|
6318
|
+
accept("error", `Cyclic inheritance detected: ${seen.map((m) => m.name).join(" -> ")} -> ${current.name}`, {
|
|
6319
|
+
node: model
|
|
6320
|
+
});
|
|
6321
|
+
return;
|
|
6322
|
+
}
|
|
6323
|
+
seen.push(current);
|
|
6324
|
+
if (current.baseModel) {
|
|
6325
|
+
invariant2(current.baseModel.ref, "baseModel must be resolved");
|
|
6326
|
+
todo.push(current.baseModel.ref);
|
|
6327
|
+
}
|
|
6328
|
+
}
|
|
6329
|
+
}
|
|
6330
|
+
validateMixins(dm, accept) {
|
|
6331
|
+
const seen = [];
|
|
6332
|
+
const todo = dm.mixins.map((mixin) => mixin.ref);
|
|
6333
|
+
while (todo.length > 0) {
|
|
6334
|
+
const current = todo.shift();
|
|
6335
|
+
if (seen.includes(current)) {
|
|
6336
|
+
accept("error", `Cyclic mixin detected: ${seen.map((m) => m.name).join(" -> ")} -> ${current.name}`, {
|
|
6409
6337
|
node: dm
|
|
6410
6338
|
});
|
|
6411
6339
|
return;
|
|
6412
6340
|
}
|
|
6413
6341
|
seen.push(current);
|
|
6414
|
-
todo.push(...current.
|
|
6342
|
+
todo.push(...current.mixins.map((mixin) => mixin.ref));
|
|
6415
6343
|
}
|
|
6416
6344
|
}
|
|
6417
6345
|
};
|
|
@@ -6447,26 +6375,15 @@ var DataSourceValidator = class {
|
|
|
6447
6375
|
}
|
|
6448
6376
|
}
|
|
6449
6377
|
validateUrl(ds, accept) {
|
|
6450
|
-
const
|
|
6451
|
-
if (!
|
|
6452
|
-
|
|
6453
|
-
node: ds
|
|
6454
|
-
});
|
|
6378
|
+
const urlField = ds.fields.find((f) => f.name === "url");
|
|
6379
|
+
if (!urlField) {
|
|
6380
|
+
return;
|
|
6455
6381
|
}
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
"
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
if (!field) {
|
|
6462
|
-
continue;
|
|
6463
|
-
}
|
|
6464
|
-
const value = getStringLiteral(field.value);
|
|
6465
|
-
if (!value && !(isInvocationExpr(field.value) && field.value.function.ref?.name === "env")) {
|
|
6466
|
-
accept("error", `"${fieldName}" must be set to a string literal or an invocation of "env" function`, {
|
|
6467
|
-
node: field.value
|
|
6468
|
-
});
|
|
6469
|
-
}
|
|
6382
|
+
const value = getStringLiteral(urlField.value);
|
|
6383
|
+
if (!value && !(isInvocationExpr(urlField.value) && urlField.value.function.ref?.name === "env")) {
|
|
6384
|
+
accept("error", `"${urlField.name}" must be set to a string literal or an invocation of "env" function`, {
|
|
6385
|
+
node: urlField.value
|
|
6386
|
+
});
|
|
6470
6387
|
}
|
|
6471
6388
|
}
|
|
6472
6389
|
validateRelationMode(ds, accept) {
|
|
@@ -6490,7 +6407,6 @@ var EnumValidator = class {
|
|
|
6490
6407
|
static {
|
|
6491
6408
|
__name(this, "EnumValidator");
|
|
6492
6409
|
}
|
|
6493
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
6494
6410
|
validate(_enum, accept) {
|
|
6495
6411
|
validateDuplicatedDeclarations(_enum, _enum.fields, accept);
|
|
6496
6412
|
this.validateAttributes(_enum, accept);
|
|
@@ -6619,7 +6535,7 @@ var ExpressionValidator = class {
|
|
|
6619
6535
|
case "==":
|
|
6620
6536
|
case "!=": {
|
|
6621
6537
|
if (this.isInValidationContext(expr)) {
|
|
6622
|
-
if (
|
|
6538
|
+
if (isDataFieldReference(expr.left) && isNullExpr(expr.right) || isDataFieldReference(expr.right) && isNullExpr(expr.left)) {
|
|
6623
6539
|
return;
|
|
6624
6540
|
}
|
|
6625
6541
|
}
|
|
@@ -6648,11 +6564,11 @@ var ExpressionValidator = class {
|
|
|
6648
6564
|
node: expr
|
|
6649
6565
|
});
|
|
6650
6566
|
}
|
|
6651
|
-
if (
|
|
6567
|
+
if (isDataFieldReference(expr.left) && (isThisExpr(expr.right) || isDataFieldReference(expr.right))) {
|
|
6652
6568
|
accept("error", "comparison between model-typed fields are not supported", {
|
|
6653
6569
|
node: expr
|
|
6654
6570
|
});
|
|
6655
|
-
} else if (
|
|
6571
|
+
} else if (isDataFieldReference(expr.right) && (isThisExpr(expr.left) || isDataFieldReference(expr.left))) {
|
|
6656
6572
|
accept("error", "comparison between model-typed fields are not supported", {
|
|
6657
6573
|
node: expr
|
|
6658
6574
|
});
|
|
@@ -6747,7 +6663,7 @@ var FunctionInvocationValidator = class {
|
|
|
6747
6663
|
let curr = expr.$container;
|
|
6748
6664
|
let containerAttribute;
|
|
6749
6665
|
while (curr) {
|
|
6750
|
-
if (isDataModelAttribute(curr) ||
|
|
6666
|
+
if (isDataModelAttribute(curr) || isDataFieldAttribute(curr)) {
|
|
6751
6667
|
containerAttribute = curr;
|
|
6752
6668
|
break;
|
|
6753
6669
|
}
|
|
@@ -6848,7 +6764,7 @@ var FunctionInvocationValidator = class {
|
|
|
6848
6764
|
_checkCheck(expr, accept) {
|
|
6849
6765
|
let valid = true;
|
|
6850
6766
|
const fieldArg = expr.args[0].value;
|
|
6851
|
-
if (!
|
|
6767
|
+
if (!isDataFieldReference(fieldArg) || !isDataModel(fieldArg.$resolvedType?.decl)) {
|
|
6852
6768
|
accept("error", "argument must be a relation field", {
|
|
6853
6769
|
node: expr.args[0]
|
|
6854
6770
|
});
|
|
@@ -6935,10 +6851,10 @@ var SchemaValidator = class {
|
|
|
6935
6851
|
constructor(documents) {
|
|
6936
6852
|
this.documents = documents;
|
|
6937
6853
|
}
|
|
6938
|
-
|
|
6939
|
-
|
|
6854
|
+
validate(model, accept) {
|
|
6855
|
+
this.validateImports(model, accept);
|
|
6940
6856
|
validateDuplicatedDeclarations(model, model.declarations, accept);
|
|
6941
|
-
const importedModels =
|
|
6857
|
+
const importedModels = resolveTransitiveImports(this.documents, model);
|
|
6942
6858
|
const importedNames = new Set(importedModels.flatMap((m) => m.declarations.map((d) => d.name)));
|
|
6943
6859
|
for (const declaration of model.declarations) {
|
|
6944
6860
|
if (importedNames.has(declaration.name)) {
|
|
@@ -6960,16 +6876,16 @@ var SchemaValidator = class {
|
|
|
6960
6876
|
});
|
|
6961
6877
|
}
|
|
6962
6878
|
}
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
const importedModel =
|
|
6966
|
-
const importPath = imp.path.endsWith(".zmodel") ? imp.path : `${imp.path}.zmodel`;
|
|
6879
|
+
validateImports(model, accept) {
|
|
6880
|
+
model.imports.forEach((imp) => {
|
|
6881
|
+
const importedModel = resolveImport(this.documents, imp);
|
|
6967
6882
|
if (!importedModel) {
|
|
6883
|
+
const importPath = imp.path.endsWith(".zmodel") ? imp.path : `${imp.path}.zmodel`;
|
|
6968
6884
|
accept("error", `Cannot find model file ${importPath}`, {
|
|
6969
6885
|
node: imp
|
|
6970
6886
|
});
|
|
6971
6887
|
}
|
|
6972
|
-
})
|
|
6888
|
+
});
|
|
6973
6889
|
}
|
|
6974
6890
|
};
|
|
6975
6891
|
|
|
@@ -7150,8 +7066,8 @@ var ZModelLinker = class extends DefaultLinker {
|
|
|
7150
7066
|
case DataModel:
|
|
7151
7067
|
this.resolveDataModel(node, document, extraScopes);
|
|
7152
7068
|
break;
|
|
7153
|
-
case
|
|
7154
|
-
this.
|
|
7069
|
+
case DataField:
|
|
7070
|
+
this.resolveDataField(node, document, extraScopes);
|
|
7155
7071
|
break;
|
|
7156
7072
|
default:
|
|
7157
7073
|
this.resolveDefault(node, document, extraScopes);
|
|
@@ -7297,10 +7213,10 @@ var ZModelLinker = class extends DefaultLinker {
|
|
|
7297
7213
|
resolveAttributeArg(node, document, extraScopes) {
|
|
7298
7214
|
const attrParam = this.findAttrParamForArg(node);
|
|
7299
7215
|
const attrAppliedOn = node.$container.$container;
|
|
7300
|
-
if (attrParam?.type.type === "TransitiveFieldReference" &&
|
|
7216
|
+
if (attrParam?.type.type === "TransitiveFieldReference" && isDataField(attrAppliedOn)) {
|
|
7301
7217
|
const transitiveDataModel = attrAppliedOn.type.reference?.ref;
|
|
7302
7218
|
if (transitiveDataModel) {
|
|
7303
|
-
const scopeProvider = /* @__PURE__ */ __name((name) =>
|
|
7219
|
+
const scopeProvider = /* @__PURE__ */ __name((name) => getAllFields(transitiveDataModel).find((f) => f.name === name), "scopeProvider");
|
|
7304
7220
|
if (isArrayExpr(node.value)) {
|
|
7305
7221
|
node.value.items.forEach((item) => {
|
|
7306
7222
|
if (isReferenceExpr(item)) {
|
|
@@ -7356,7 +7272,7 @@ var ZModelLinker = class extends DefaultLinker {
|
|
|
7356
7272
|
resolveDataModel(node, document, extraScopes) {
|
|
7357
7273
|
return this.resolveDefault(node, document, extraScopes);
|
|
7358
7274
|
}
|
|
7359
|
-
|
|
7275
|
+
resolveDataField(node, document, extraScopes) {
|
|
7360
7276
|
this.resolve(node.type, document, extraScopes);
|
|
7361
7277
|
let scopes = extraScopes;
|
|
7362
7278
|
if (node.type.reference?.ref && isEnum(node.type.reference.ref)) {
|
|
@@ -7385,7 +7301,7 @@ var ZModelLinker = class extends DefaultLinker {
|
|
|
7385
7301
|
//#region Utils
|
|
7386
7302
|
resolveToDeclaredType(node, type) {
|
|
7387
7303
|
let nullable = false;
|
|
7388
|
-
if (
|
|
7304
|
+
if (isDataFieldType(type)) {
|
|
7389
7305
|
nullable = type.optional;
|
|
7390
7306
|
if (type.unsupported) {
|
|
7391
7307
|
node.$resolvedType = {
|
|
@@ -7446,6 +7362,14 @@ var ZModelScopeComputation = class extends DefaultScopeComputation {
|
|
|
7446
7362
|
}
|
|
7447
7363
|
processNode(node, document, scopes) {
|
|
7448
7364
|
super.processNode(node, document, scopes);
|
|
7365
|
+
if (isDataModel(node)) {
|
|
7366
|
+
const bases = getRecursiveBases(node);
|
|
7367
|
+
for (const base of bases) {
|
|
7368
|
+
for (const field of base.fields) {
|
|
7369
|
+
scopes.add(node, this.descriptions.createDescription(field, this.nameProvider.getName(field)));
|
|
7370
|
+
}
|
|
7371
|
+
}
|
|
7372
|
+
}
|
|
7449
7373
|
}
|
|
7450
7374
|
};
|
|
7451
7375
|
var ZModelScopeProvider = class extends DefaultScopeProvider {
|
|
@@ -7493,16 +7417,13 @@ var ZModelScopeProvider = class extends DefaultScopeProvider {
|
|
|
7493
7417
|
);
|
|
7494
7418
|
return match3(node.operand).when(isReferenceExpr, (operand) => {
|
|
7495
7419
|
const ref = operand.target.ref;
|
|
7496
|
-
if (
|
|
7420
|
+
if (isDataField(ref)) {
|
|
7497
7421
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7498
7422
|
}
|
|
7499
7423
|
return EMPTY_SCOPE;
|
|
7500
7424
|
}).when(isMemberAccessExpr, (operand) => {
|
|
7501
7425
|
const ref = operand.member.ref;
|
|
7502
|
-
if (
|
|
7503
|
-
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7504
|
-
}
|
|
7505
|
-
if (isTypeDefField(ref) && !ref.type.array) {
|
|
7426
|
+
if (isDataField(ref) && !ref.type.array) {
|
|
7506
7427
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7507
7428
|
}
|
|
7508
7429
|
return EMPTY_SCOPE;
|
|
@@ -7525,13 +7446,13 @@ var ZModelScopeProvider = class extends DefaultScopeProvider {
|
|
|
7525
7446
|
const allowTypeDefScope = false;
|
|
7526
7447
|
return match3(collection).when(isReferenceExpr, (expr) => {
|
|
7527
7448
|
const ref = expr.target.ref;
|
|
7528
|
-
if (
|
|
7449
|
+
if (isDataField(ref)) {
|
|
7529
7450
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7530
7451
|
}
|
|
7531
7452
|
return EMPTY_SCOPE;
|
|
7532
7453
|
}).when(isMemberAccessExpr, (expr) => {
|
|
7533
7454
|
const ref = expr.member.ref;
|
|
7534
|
-
if (
|
|
7455
|
+
if (isDataField(ref)) {
|
|
7535
7456
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7536
7457
|
}
|
|
7537
7458
|
return EMPTY_SCOPE;
|
|
@@ -7556,7 +7477,7 @@ var ZModelScopeProvider = class extends DefaultScopeProvider {
|
|
|
7556
7477
|
}
|
|
7557
7478
|
createScopeForContainer(node, globalScope, includeTypeDefScope = false) {
|
|
7558
7479
|
if (isDataModel(node)) {
|
|
7559
|
-
return this.createScopeForNodes(
|
|
7480
|
+
return this.createScopeForNodes(getAllFields(node), globalScope);
|
|
7560
7481
|
} else if (includeTypeDefScope && isTypeDef(node)) {
|
|
7561
7482
|
return this.createScopeForNodes(node.fields, globalScope);
|
|
7562
7483
|
} else {
|
|
@@ -7586,10 +7507,10 @@ function getCollectionPredicateContext(node) {
|
|
|
7586
7507
|
__name(getCollectionPredicateContext, "getCollectionPredicateContext");
|
|
7587
7508
|
|
|
7588
7509
|
// src/zmodel-workspace-manager.ts
|
|
7589
|
-
import { DefaultWorkspaceManager, URI as URI2 } from "langium";
|
|
7590
|
-
import fs2 from "
|
|
7591
|
-
import path2 from "
|
|
7592
|
-
import { fileURLToPath } from "
|
|
7510
|
+
import { DefaultWorkspaceManager, URI as URI2, UriUtils as UriUtils2 } from "langium";
|
|
7511
|
+
import fs2 from "fs";
|
|
7512
|
+
import path2 from "path";
|
|
7513
|
+
import { fileURLToPath } from "url";
|
|
7593
7514
|
var ZModelWorkspaceManager = class extends DefaultWorkspaceManager {
|
|
7594
7515
|
static {
|
|
7595
7516
|
__name(this, "ZModelWorkspaceManager");
|
|
@@ -7618,7 +7539,7 @@ var ZModelWorkspaceManager = class extends DefaultWorkspaceManager {
|
|
|
7618
7539
|
console.log(`Found installed zenstack package stdlib at: ${installedStdlibPath}`);
|
|
7619
7540
|
break;
|
|
7620
7541
|
}
|
|
7621
|
-
} catch
|
|
7542
|
+
} catch {
|
|
7622
7543
|
continue;
|
|
7623
7544
|
}
|
|
7624
7545
|
}
|
|
@@ -7631,6 +7552,67 @@ var ZModelWorkspaceManager = class extends DefaultWorkspaceManager {
|
|
|
7631
7552
|
}
|
|
7632
7553
|
const stdlib = await this.documentFactory.fromUri(URI2.file(stdLibPath));
|
|
7633
7554
|
collector(stdlib);
|
|
7555
|
+
const documents = this.langiumDocuments.all;
|
|
7556
|
+
const pluginModels = /* @__PURE__ */ new Set();
|
|
7557
|
+
documents.forEach((doc) => {
|
|
7558
|
+
const parsed = doc.parseResult.value;
|
|
7559
|
+
parsed.declarations.forEach((decl) => {
|
|
7560
|
+
if (isPlugin(decl)) {
|
|
7561
|
+
const providerField = decl.fields.find((f) => f.name === "provider");
|
|
7562
|
+
if (providerField) {
|
|
7563
|
+
const provider = getLiteral(providerField.value);
|
|
7564
|
+
if (provider) {
|
|
7565
|
+
pluginModels.add(provider);
|
|
7566
|
+
}
|
|
7567
|
+
}
|
|
7568
|
+
}
|
|
7569
|
+
});
|
|
7570
|
+
});
|
|
7571
|
+
if (pluginModels.size > 0) {
|
|
7572
|
+
console.log(`Used plugin modules: ${Array.from(pluginModels)}`);
|
|
7573
|
+
const pendingPluginModules = new Set(pluginModels);
|
|
7574
|
+
await Promise.all(folders.map((wf) => [
|
|
7575
|
+
wf,
|
|
7576
|
+
this.getRootFolder(wf)
|
|
7577
|
+
]).map(async (entry) => this.loadPluginModels(...entry, pendingPluginModules, collector)));
|
|
7578
|
+
}
|
|
7579
|
+
}
|
|
7580
|
+
async loadPluginModels(workspaceFolder, folderPath, pendingPluginModels, collector) {
|
|
7581
|
+
const content = (await this.fileSystemProvider.readDirectory(folderPath)).sort((a, b) => {
|
|
7582
|
+
if (a.isDirectory && b.isDirectory) {
|
|
7583
|
+
const aName = UriUtils2.basename(a.uri);
|
|
7584
|
+
if (aName === "node_modules") {
|
|
7585
|
+
return -1;
|
|
7586
|
+
} else {
|
|
7587
|
+
return 1;
|
|
7588
|
+
}
|
|
7589
|
+
} else {
|
|
7590
|
+
return 0;
|
|
7591
|
+
}
|
|
7592
|
+
});
|
|
7593
|
+
for (const entry of content) {
|
|
7594
|
+
if (entry.isDirectory) {
|
|
7595
|
+
const name = UriUtils2.basename(entry.uri);
|
|
7596
|
+
if (name === "node_modules") {
|
|
7597
|
+
for (const plugin of Array.from(pendingPluginModels)) {
|
|
7598
|
+
const path4 = UriUtils2.joinPath(entry.uri, plugin, PLUGIN_MODULE_NAME);
|
|
7599
|
+
try {
|
|
7600
|
+
await this.fileSystemProvider.readFile(path4);
|
|
7601
|
+
const document = await this.langiumDocuments.getOrCreateDocument(path4);
|
|
7602
|
+
collector(document);
|
|
7603
|
+
console.log(`Adding plugin document from ${path4.path}`);
|
|
7604
|
+
pendingPluginModels.delete(plugin);
|
|
7605
|
+
if (pendingPluginModels.size === 0) {
|
|
7606
|
+
return;
|
|
7607
|
+
}
|
|
7608
|
+
} catch {
|
|
7609
|
+
}
|
|
7610
|
+
}
|
|
7611
|
+
} else {
|
|
7612
|
+
await this.loadPluginModels(workspaceFolder, entry.uri, pendingPluginModels, collector);
|
|
7613
|
+
}
|
|
7614
|
+
}
|
|
7615
|
+
}
|
|
7634
7616
|
}
|
|
7635
7617
|
};
|
|
7636
7618
|
|
|
@@ -7706,10 +7688,16 @@ async function loadDocument(fileName, pluginModelFiles = []) {
|
|
|
7706
7688
|
const pluginDocs = await Promise.all(pluginModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(URI3.file(path3.resolve(file)))));
|
|
7707
7689
|
const langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
7708
7690
|
const document = await langiumDocuments.getOrCreateDocument(URI3.file(path3.resolve(fileName)));
|
|
7691
|
+
const importedURIs = await loadImports(document, langiumDocuments);
|
|
7692
|
+
const importedDocuments = [];
|
|
7693
|
+
for (const uri of importedURIs) {
|
|
7694
|
+
importedDocuments.push(await langiumDocuments.getOrCreateDocument(uri));
|
|
7695
|
+
}
|
|
7709
7696
|
await services.shared.workspace.DocumentBuilder.build([
|
|
7710
7697
|
stdLib,
|
|
7711
7698
|
...pluginDocs,
|
|
7712
|
-
document
|
|
7699
|
+
document,
|
|
7700
|
+
...importedDocuments
|
|
7713
7701
|
], {
|
|
7714
7702
|
validation: true
|
|
7715
7703
|
});
|
|
@@ -7736,6 +7724,20 @@ async function loadDocument(fileName, pluginModelFiles = []) {
|
|
|
7736
7724
|
warnings
|
|
7737
7725
|
};
|
|
7738
7726
|
}
|
|
7727
|
+
const model = document.parseResult.value;
|
|
7728
|
+
const imported = mergeImportsDeclarations(langiumDocuments, model);
|
|
7729
|
+
imported.forEach((model2) => {
|
|
7730
|
+
langiumDocuments.deleteDocument(model2.$document.uri);
|
|
7731
|
+
services.shared.workspace.IndexManager.remove(model2.$document.uri);
|
|
7732
|
+
});
|
|
7733
|
+
const additionalErrors = validationAfterImportMerge(model);
|
|
7734
|
+
if (additionalErrors.length > 0) {
|
|
7735
|
+
return {
|
|
7736
|
+
success: false,
|
|
7737
|
+
errors: additionalErrors,
|
|
7738
|
+
warnings
|
|
7739
|
+
};
|
|
7740
|
+
}
|
|
7739
7741
|
return {
|
|
7740
7742
|
success: true,
|
|
7741
7743
|
model: document.parseResult.value,
|
|
@@ -7743,6 +7745,68 @@ async function loadDocument(fileName, pluginModelFiles = []) {
|
|
|
7743
7745
|
};
|
|
7744
7746
|
}
|
|
7745
7747
|
__name(loadDocument, "loadDocument");
|
|
7748
|
+
async function loadImports(document, documents, uris = /* @__PURE__ */ new Set()) {
|
|
7749
|
+
const uriString = document.uri.toString();
|
|
7750
|
+
if (!uris.has(uriString)) {
|
|
7751
|
+
uris.add(uriString);
|
|
7752
|
+
const model = document.parseResult.value;
|
|
7753
|
+
for (const imp of model.imports) {
|
|
7754
|
+
const importedModel = resolveImport(documents, imp);
|
|
7755
|
+
if (importedModel) {
|
|
7756
|
+
const importedDoc = getDocument(importedModel);
|
|
7757
|
+
await loadImports(importedDoc, documents, uris);
|
|
7758
|
+
}
|
|
7759
|
+
}
|
|
7760
|
+
}
|
|
7761
|
+
return Array.from(uris).filter((x) => uriString != x).map((e) => URI3.parse(e));
|
|
7762
|
+
}
|
|
7763
|
+
__name(loadImports, "loadImports");
|
|
7764
|
+
function mergeImportsDeclarations(documents, model) {
|
|
7765
|
+
const importedModels = resolveTransitiveImports(documents, model);
|
|
7766
|
+
const importedDeclarations = importedModels.flatMap((m) => m.declarations);
|
|
7767
|
+
model.declarations.push(...importedDeclarations);
|
|
7768
|
+
model.imports = [];
|
|
7769
|
+
linkContentToContainer(model);
|
|
7770
|
+
return importedModels;
|
|
7771
|
+
}
|
|
7772
|
+
__name(mergeImportsDeclarations, "mergeImportsDeclarations");
|
|
7773
|
+
function linkContentToContainer(node) {
|
|
7774
|
+
for (const [name, value] of Object.entries(node)) {
|
|
7775
|
+
if (!name.startsWith("$")) {
|
|
7776
|
+
if (Array.isArray(value)) {
|
|
7777
|
+
value.forEach((item, index) => {
|
|
7778
|
+
if (isAstNode(item)) {
|
|
7779
|
+
item.$container = node;
|
|
7780
|
+
item.$containerProperty = name;
|
|
7781
|
+
item.$containerIndex = index;
|
|
7782
|
+
}
|
|
7783
|
+
});
|
|
7784
|
+
} else if (isAstNode(value)) {
|
|
7785
|
+
value.$container = node;
|
|
7786
|
+
value.$containerProperty = name;
|
|
7787
|
+
}
|
|
7788
|
+
}
|
|
7789
|
+
}
|
|
7790
|
+
}
|
|
7791
|
+
__name(linkContentToContainer, "linkContentToContainer");
|
|
7792
|
+
function validationAfterImportMerge(model) {
|
|
7793
|
+
const errors = [];
|
|
7794
|
+
const dataSources = model.declarations.filter((d) => isDataSource(d));
|
|
7795
|
+
if (dataSources.length === 0) {
|
|
7796
|
+
errors.push("Validation error: schema must have a datasource declaration");
|
|
7797
|
+
} else {
|
|
7798
|
+
if (dataSources.length > 1) {
|
|
7799
|
+
errors.push("Validation error: multiple datasource declarations are not allowed");
|
|
7800
|
+
}
|
|
7801
|
+
}
|
|
7802
|
+
const decls = getDataModelAndTypeDefs(model, true);
|
|
7803
|
+
const authDecls = decls.filter((d) => hasAttribute(d, "@@auth"));
|
|
7804
|
+
if (authDecls.length > 1) {
|
|
7805
|
+
errors.push("Validation error: Multiple `@@auth` declarations are not allowed");
|
|
7806
|
+
}
|
|
7807
|
+
return errors;
|
|
7808
|
+
}
|
|
7809
|
+
__name(validationAfterImportMerge, "validationAfterImportMerge");
|
|
7746
7810
|
export {
|
|
7747
7811
|
DocumentLoadError,
|
|
7748
7812
|
ZModelLanguageMetaData,
|