@zenstackhq/language 3.9.8 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ast-C3-ORZMv.d.cts → ast-B9snHdj1.d.mts} +17 -5
- package/dist/{ast-DSXl7TDv.cjs → ast-CbYfvKuN.cjs} +19 -2
- package/dist/ast-CbYfvKuN.cjs.map +1 -0
- package/dist/{ast-DoH2ngKH.d.mts → ast-DZ3cHwI-.d.cts} +17 -5
- package/dist/{ast-DJOHdY8l.mjs → ast-taPWpbmU.mjs} +14 -3
- package/dist/ast-taPWpbmU.mjs.map +1 -0
- package/dist/ast.cjs +2 -1
- package/dist/ast.d.cts +2 -2
- package/dist/ast.d.mts +2 -2
- package/dist/ast.mjs +2 -2
- package/dist/factory.cjs +1 -1
- package/dist/factory.d.cts +1 -1
- package/dist/factory.d.mts +1 -1
- package/dist/factory.mjs +1 -1
- package/dist/index.cjs +330 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +330 -106
- package/dist/index.mjs.map +1 -1
- package/dist/{utils-jgngKwh1.mjs → utils-BWba17ro.mjs} +43 -3
- package/dist/utils-BWba17ro.mjs.map +1 -0
- package/dist/{utils-C3bnOGl-.cjs → utils-DZ0ZKE35.cjs} +66 -2
- package/dist/utils-DZ0ZKE35.cjs.map +1 -0
- package/dist/utils.cjs +5 -1
- package/dist/utils.d.cts +23 -2
- package/dist/utils.d.mts +23 -2
- package/dist/utils.mjs +2 -2
- package/package.json +9 -9
- package/dist/ast-DJOHdY8l.mjs.map +0 -1
- package/dist/ast-DSXl7TDv.cjs.map +0 -1
- package/dist/utils-C3bnOGl-.cjs.map +0 -1
- package/dist/utils-jgngKwh1.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as GeneratorDecl, B as ObjectExpr,
|
|
1
|
+
import { A as GeneratorDecl, B as ObjectExpr, C as Enum, Ct as isDataFieldType, D as FunctionDecl, Dt as isEnum, Et as isDataSource, Ft as isGeneratorDecl, G as ReferenceArg, H as PluginField, Ht as isModelImport, I as Model, It as isInternalAttribute, J as StringLiteral, Jt as isProcedure, K as ReferenceExpr, Kt as isPlugin, L as ModelImport, Lt as isInvocationExpr, M as InvocationExpr, Mt as isFunctionDecl, N as LiteralExpr, Nt as isFunctionParam, O as FunctionParam, Ot as isEnumField, P as MemberAccessExpr, Pt as isFunctionParamType, Q as UnaryExpr, R as NullExpr, Rt as isLiteralExpr, S as DataSource, St as isDataFieldParam, Tt as isDataModelAttribute, Ut as isNullExpr, V as Plugin, Vt as isModel, Wt as isNumberLiteral, Y as ThisExpr, Yt as isProcedureParam, Z as TypeDef, Zt as isReferenceExpr, _ as DataFieldAttribute, a as AttributeArg, an as isUnaryExpr, at as isAttribute, b as DataModel, bt as isDataFieldAttribute, c as BinaryExpr, ct as isAttributeParamType, d as ConfigArrayExpr, dt as isBooleanLiteral, et as ZModelAstReflection, g as DataField, gt as isConfigField, h as ConfigInvocationExpr, i as Attribute, in as isTypeDef, it as isArrayExpr, k as FunctionParamType, l as BooleanLiteral, lt as isBinaryExpr, mt as isConfigArrayExpr, nn as isThisExpr, nt as isAbstractDeclaration, o as AttributeParam, ot as isAttributeArg, p as ConfigField, pt as isCollectionPredicateBinding, qt as isPluginField, r as ArrayExpr, s as AttributeParamType, st as isAttributeParam, tn as isStringLiteral, w as EnumField, wt as isDataModel, x as DataModelAttribute, yt as isDataField, z as NumberLiteral, zt as isMemberAccessExpr } from "./ast-taPWpbmU.mjs";
|
|
2
2
|
import { BinaryExprOperatorPriority } from "./ast.mjs";
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as resolved, A as getUniqueFields, B as isEnumFieldReference, C as getNumberLiteral, D as getRecursiveBases, E as getPrimitiveTypeDefThisField, F as isCheckInvocation, G as isNativeTypeMappingAttribute, I as isCollectionPredicate, J as isRelationshipField, K as isPrimitiveTypeDef, L as isComputedField, M as isAuthInvocation, N as isAuthOrAuthMemberAccess, P as isBeforeInvocation, Q as resolveTransitiveImports, R as isDataFieldReference, S as getModelUniqueFields, T as getPluginDocuments, U as isManyToManyField, V as isFromStdlib, W as isMemberContainer, X as resolveImport, Y as mapBuiltinTypeToExpressionType, Z as resolveImportUri, a as getAllDeclarationsIncludingImports, at as SCALAR_TYPES, et as typeAssignable, f as getAuthDecl, g as getDocument, h as getDataSourceProvider, j as hasAttribute, k as getStringLiteral, l as getAttribute, m as getDataModelAndTypeDefs, n as findUpAst, nt as ExpressionContext, o as getAllFields, ot as STD_LIB_MODULE_NAME, p as getContainingDataModel, r as getAllAttributes, rt as IssueCodes, s as getAllLoadedAndReachableDataModelsAndTypeDefs, st as SUPPORTED_PROVIDERS, tt as DB_PROVIDERS_SUPPORTING_LIST_TYPE, u as getAttributeArg, v as getFunctionExpressionContext, x as getModelIdFields, y as getLiteral, z as isDelegateModel } from "./utils-BWba17ro.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { invariant } from "@zenstackhq/common-helpers";
|
|
6
6
|
import { AstUtils, Cancellation, DefaultCommentProvider, DefaultDocumentBuilder, DefaultLinker, DefaultScopeComputation, DefaultScopeProvider, DefaultWorkspaceManager, DocumentState, EMPTY_SCOPE, JSDocDocumentationProvider, StreamScope, TextDocument, URI, UriUtils, inject, interruptAndCheck, isAstNode, loadGrammarFromJson } from "langium";
|
|
@@ -77,7 +77,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
77
77
|
"terminal": {
|
|
78
78
|
"$type": "RuleCall",
|
|
79
79
|
"rule": {
|
|
80
|
-
"$ref": "#/rules@
|
|
80
|
+
"$ref": "#/rules@72"
|
|
81
81
|
},
|
|
82
82
|
"arguments": []
|
|
83
83
|
}
|
|
@@ -151,7 +151,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
151
151
|
{
|
|
152
152
|
"$type": "RuleCall",
|
|
153
153
|
"rule": {
|
|
154
|
-
"$ref": "#/rules@
|
|
154
|
+
"$ref": "#/rules@56"
|
|
155
155
|
},
|
|
156
156
|
"arguments": []
|
|
157
157
|
},
|
|
@@ -177,7 +177,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
177
177
|
{
|
|
178
178
|
"$type": "RuleCall",
|
|
179
179
|
"rule": {
|
|
180
|
-
"$ref": "#/rules@
|
|
180
|
+
"$ref": "#/rules@74"
|
|
181
181
|
},
|
|
182
182
|
"arguments": [],
|
|
183
183
|
"cardinality": "*"
|
|
@@ -234,7 +234,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
234
234
|
{
|
|
235
235
|
"$type": "RuleCall",
|
|
236
236
|
"rule": {
|
|
237
|
-
"$ref": "#/rules@
|
|
237
|
+
"$ref": "#/rules@74"
|
|
238
238
|
},
|
|
239
239
|
"arguments": [],
|
|
240
240
|
"cardinality": "*"
|
|
@@ -291,7 +291,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
291
291
|
{
|
|
292
292
|
"$type": "RuleCall",
|
|
293
293
|
"rule": {
|
|
294
|
-
"$ref": "#/rules@
|
|
294
|
+
"$ref": "#/rules@74"
|
|
295
295
|
},
|
|
296
296
|
"arguments": [],
|
|
297
297
|
"cardinality": "*"
|
|
@@ -339,7 +339,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
339
339
|
{
|
|
340
340
|
"$type": "RuleCall",
|
|
341
341
|
"rule": {
|
|
342
|
-
"$ref": "#/rules@
|
|
342
|
+
"$ref": "#/rules@74"
|
|
343
343
|
},
|
|
344
344
|
"arguments": [],
|
|
345
345
|
"cardinality": "*"
|
|
@@ -396,7 +396,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
396
396
|
{
|
|
397
397
|
"$type": "RuleCall",
|
|
398
398
|
"rule": {
|
|
399
|
-
"$ref": "#/rules@
|
|
399
|
+
"$ref": "#/rules@74"
|
|
400
400
|
},
|
|
401
401
|
"arguments": [],
|
|
402
402
|
"cardinality": "*"
|
|
@@ -478,7 +478,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
478
478
|
"terminal": {
|
|
479
479
|
"$type": "RuleCall",
|
|
480
480
|
"rule": {
|
|
481
|
-
"$ref": "#/rules@
|
|
481
|
+
"$ref": "#/rules@73"
|
|
482
482
|
},
|
|
483
483
|
"arguments": []
|
|
484
484
|
}
|
|
@@ -497,7 +497,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
497
497
|
"terminal": {
|
|
498
498
|
"$type": "RuleCall",
|
|
499
499
|
"rule": {
|
|
500
|
-
"$ref": "#/rules@
|
|
500
|
+
"$ref": "#/rules@72"
|
|
501
501
|
},
|
|
502
502
|
"arguments": []
|
|
503
503
|
}
|
|
@@ -516,7 +516,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
516
516
|
"terminal": {
|
|
517
517
|
"$type": "RuleCall",
|
|
518
518
|
"rule": {
|
|
519
|
-
"$ref": "#/rules@
|
|
519
|
+
"$ref": "#/rules@66"
|
|
520
520
|
},
|
|
521
521
|
"arguments": []
|
|
522
522
|
}
|
|
@@ -631,7 +631,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
631
631
|
"terminal": {
|
|
632
632
|
"$type": "RuleCall",
|
|
633
633
|
"rule": {
|
|
634
|
-
"$ref": "#/rules@
|
|
634
|
+
"$ref": "#/rules@71"
|
|
635
635
|
},
|
|
636
636
|
"arguments": []
|
|
637
637
|
}
|
|
@@ -723,7 +723,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
723
723
|
"terminal": {
|
|
724
724
|
"$type": "RuleCall",
|
|
725
725
|
"rule": {
|
|
726
|
-
"$ref": "#/rules@
|
|
726
|
+
"$ref": "#/rules@71"
|
|
727
727
|
},
|
|
728
728
|
"arguments": []
|
|
729
729
|
}
|
|
@@ -917,7 +917,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
917
917
|
"terminal": {
|
|
918
918
|
"$type": "RuleCall",
|
|
919
919
|
"rule": {
|
|
920
|
-
"$ref": "#/rules@
|
|
920
|
+
"$ref": "#/rules@55"
|
|
921
921
|
},
|
|
922
922
|
"arguments": []
|
|
923
923
|
},
|
|
@@ -1011,7 +1011,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
1011
1011
|
"terminal": {
|
|
1012
1012
|
"$type": "RuleCall",
|
|
1013
1013
|
"rule": {
|
|
1014
|
-
"$ref": "#/rules@
|
|
1014
|
+
"$ref": "#/rules@71"
|
|
1015
1015
|
},
|
|
1016
1016
|
"arguments": []
|
|
1017
1017
|
}
|
|
@@ -1126,7 +1126,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
1126
1126
|
{
|
|
1127
1127
|
"$type": "RuleCall",
|
|
1128
1128
|
"rule": {
|
|
1129
|
-
"$ref": "#/rules@
|
|
1129
|
+
"$ref": "#/rules@72"
|
|
1130
1130
|
},
|
|
1131
1131
|
"arguments": []
|
|
1132
1132
|
}
|
|
@@ -1851,7 +1851,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
1851
1851
|
"terminal": {
|
|
1852
1852
|
"$type": "RuleCall",
|
|
1853
1853
|
"rule": {
|
|
1854
|
-
"$ref": "#/rules@
|
|
1854
|
+
"$ref": "#/rules@74"
|
|
1855
1855
|
},
|
|
1856
1856
|
"arguments": []
|
|
1857
1857
|
},
|
|
@@ -1993,7 +1993,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
1993
1993
|
"terminal": {
|
|
1994
1994
|
"$type": "RuleCall",
|
|
1995
1995
|
"rule": {
|
|
1996
|
-
"$ref": "#/rules@
|
|
1996
|
+
"$ref": "#/rules@60"
|
|
1997
1997
|
},
|
|
1998
1998
|
"arguments": []
|
|
1999
1999
|
}
|
|
@@ -2023,17 +2023,34 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2023
2023
|
"value": "with"
|
|
2024
2024
|
},
|
|
2025
2025
|
{
|
|
2026
|
-
"$type": "
|
|
2027
|
-
"
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
"
|
|
2026
|
+
"$type": "Alternatives",
|
|
2027
|
+
"elements": [
|
|
2028
|
+
{
|
|
2029
|
+
"$type": "Assignment",
|
|
2030
|
+
"feature": "mixins",
|
|
2031
|
+
"operator": "+=",
|
|
2032
|
+
"terminal": {
|
|
2033
|
+
"$type": "CrossReference",
|
|
2034
|
+
"type": {
|
|
2035
|
+
"$ref": "#/rules@44"
|
|
2036
|
+
},
|
|
2037
|
+
"deprecatedSyntax": false,
|
|
2038
|
+
"isMulti": false
|
|
2039
|
+
}
|
|
2033
2040
|
},
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2041
|
+
{
|
|
2042
|
+
"$type": "Assignment",
|
|
2043
|
+
"feature": "base",
|
|
2044
|
+
"operator": "=",
|
|
2045
|
+
"terminal": {
|
|
2046
|
+
"$type": "RuleCall",
|
|
2047
|
+
"rule": {
|
|
2048
|
+
"$ref": "#/rules@65"
|
|
2049
|
+
},
|
|
2050
|
+
"arguments": []
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
]
|
|
2037
2054
|
},
|
|
2038
2055
|
{
|
|
2039
2056
|
"$type": "Group",
|
|
@@ -2106,7 +2123,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2106
2123
|
"terminal": {
|
|
2107
2124
|
"$type": "RuleCall",
|
|
2108
2125
|
"rule": {
|
|
2109
|
-
"$ref": "#/rules@
|
|
2126
|
+
"$ref": "#/rules@74"
|
|
2110
2127
|
},
|
|
2111
2128
|
"arguments": []
|
|
2112
2129
|
},
|
|
@@ -2191,7 +2208,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2191
2208
|
"terminal": {
|
|
2192
2209
|
"$type": "RuleCall",
|
|
2193
2210
|
"rule": {
|
|
2194
|
-
"$ref": "#/rules@
|
|
2211
|
+
"$ref": "#/rules@59"
|
|
2195
2212
|
},
|
|
2196
2213
|
"arguments": []
|
|
2197
2214
|
},
|
|
@@ -2212,7 +2229,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2212
2229
|
{
|
|
2213
2230
|
"$type": "RuleCall",
|
|
2214
2231
|
"rule": {
|
|
2215
|
-
"$ref": "#/rules@
|
|
2232
|
+
"$ref": "#/rules@74"
|
|
2216
2233
|
},
|
|
2217
2234
|
"arguments": [],
|
|
2218
2235
|
"cardinality": "*"
|
|
@@ -2277,7 +2294,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2277
2294
|
"terminal": {
|
|
2278
2295
|
"$type": "RuleCall",
|
|
2279
2296
|
"rule": {
|
|
2280
|
-
"$ref": "#/rules@
|
|
2297
|
+
"$ref": "#/rules@65"
|
|
2281
2298
|
},
|
|
2282
2299
|
"arguments": []
|
|
2283
2300
|
}
|
|
@@ -2364,7 +2381,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2364
2381
|
"terminal": {
|
|
2365
2382
|
"$type": "RuleCall",
|
|
2366
2383
|
"rule": {
|
|
2367
|
-
"$ref": "#/rules@
|
|
2384
|
+
"$ref": "#/rules@74"
|
|
2368
2385
|
},
|
|
2369
2386
|
"arguments": []
|
|
2370
2387
|
},
|
|
@@ -2420,7 +2437,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2420
2437
|
"terminal": {
|
|
2421
2438
|
"$type": "RuleCall",
|
|
2422
2439
|
"rule": {
|
|
2423
|
-
"$ref": "#/rules@
|
|
2440
|
+
"$ref": "#/rules@60"
|
|
2424
2441
|
},
|
|
2425
2442
|
"arguments": []
|
|
2426
2443
|
}
|
|
@@ -2487,7 +2504,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2487
2504
|
"terminal": {
|
|
2488
2505
|
"$type": "RuleCall",
|
|
2489
2506
|
"rule": {
|
|
2490
|
-
"$ref": "#/rules@
|
|
2507
|
+
"$ref": "#/rules@74"
|
|
2491
2508
|
},
|
|
2492
2509
|
"arguments": []
|
|
2493
2510
|
},
|
|
@@ -2535,7 +2552,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2535
2552
|
"terminal": {
|
|
2536
2553
|
"$type": "RuleCall",
|
|
2537
2554
|
"rule": {
|
|
2538
|
-
"$ref": "#/rules@
|
|
2555
|
+
"$ref": "#/rules@60"
|
|
2539
2556
|
},
|
|
2540
2557
|
"arguments": []
|
|
2541
2558
|
}
|
|
@@ -2566,7 +2583,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2566
2583
|
"terminal": {
|
|
2567
2584
|
"$type": "RuleCall",
|
|
2568
2585
|
"rule": {
|
|
2569
|
-
"$ref": "#/rules@
|
|
2586
|
+
"$ref": "#/rules@74"
|
|
2570
2587
|
},
|
|
2571
2588
|
"arguments": []
|
|
2572
2589
|
},
|
|
@@ -2579,7 +2596,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2579
2596
|
"terminal": {
|
|
2580
2597
|
"$type": "RuleCall",
|
|
2581
2598
|
"rule": {
|
|
2582
|
-
"$ref": "#/rules@
|
|
2599
|
+
"$ref": "#/rules@55"
|
|
2583
2600
|
},
|
|
2584
2601
|
"arguments": []
|
|
2585
2602
|
}
|
|
@@ -2591,7 +2608,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2591
2608
|
"terminal": {
|
|
2592
2609
|
"$type": "RuleCall",
|
|
2593
2610
|
"rule": {
|
|
2594
|
-
"$ref": "#/rules@
|
|
2611
|
+
"$ref": "#/rules@59"
|
|
2595
2612
|
},
|
|
2596
2613
|
"arguments": []
|
|
2597
2614
|
},
|
|
@@ -2612,7 +2629,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2612
2629
|
{
|
|
2613
2630
|
"$type": "RuleCall",
|
|
2614
2631
|
"rule": {
|
|
2615
|
-
"$ref": "#/rules@
|
|
2632
|
+
"$ref": "#/rules@74"
|
|
2616
2633
|
},
|
|
2617
2634
|
"arguments": [],
|
|
2618
2635
|
"cardinality": "*"
|
|
@@ -2725,7 +2742,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2725
2742
|
"terminal": {
|
|
2726
2743
|
"$type": "RuleCall",
|
|
2727
2744
|
"rule": {
|
|
2728
|
-
"$ref": "#/rules@
|
|
2745
|
+
"$ref": "#/rules@61"
|
|
2729
2746
|
},
|
|
2730
2747
|
"arguments": []
|
|
2731
2748
|
},
|
|
@@ -2746,7 +2763,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2746
2763
|
{
|
|
2747
2764
|
"$type": "RuleCall",
|
|
2748
2765
|
"rule": {
|
|
2749
|
-
"$ref": "#/rules@
|
|
2766
|
+
"$ref": "#/rules@74"
|
|
2750
2767
|
},
|
|
2751
2768
|
"arguments": [],
|
|
2752
2769
|
"cardinality": "*"
|
|
@@ -2811,7 +2828,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2811
2828
|
"terminal": {
|
|
2812
2829
|
"$type": "RuleCall",
|
|
2813
2830
|
"rule": {
|
|
2814
|
-
"$ref": "#/rules@
|
|
2831
|
+
"$ref": "#/rules@64"
|
|
2815
2832
|
},
|
|
2816
2833
|
"arguments": []
|
|
2817
2834
|
}
|
|
@@ -2872,7 +2889,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2872
2889
|
{
|
|
2873
2890
|
"$type": "RuleCall",
|
|
2874
2891
|
"rule": {
|
|
2875
|
-
"$ref": "#/rules@
|
|
2892
|
+
"$ref": "#/rules@74"
|
|
2876
2893
|
},
|
|
2877
2894
|
"arguments": [],
|
|
2878
2895
|
"cardinality": "*"
|
|
@@ -2930,7 +2947,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
2930
2947
|
{
|
|
2931
2948
|
"$type": "RuleCall",
|
|
2932
2949
|
"rule": {
|
|
2933
|
-
"$ref": "#/rules@
|
|
2950
|
+
"$ref": "#/rules@74"
|
|
2934
2951
|
},
|
|
2935
2952
|
"arguments": [],
|
|
2936
2953
|
"cardinality": "*"
|
|
@@ -3032,7 +3049,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3032
3049
|
"terminal": {
|
|
3033
3050
|
"$type": "RuleCall",
|
|
3034
3051
|
"rule": {
|
|
3035
|
-
"$ref": "#/rules@
|
|
3052
|
+
"$ref": "#/rules@61"
|
|
3036
3053
|
},
|
|
3037
3054
|
"arguments": []
|
|
3038
3055
|
},
|
|
@@ -3054,7 +3071,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3054
3071
|
{
|
|
3055
3072
|
"$type": "RuleCall",
|
|
3056
3073
|
"rule": {
|
|
3057
|
-
"$ref": "#/rules@
|
|
3074
|
+
"$ref": "#/rules@71"
|
|
3058
3075
|
},
|
|
3059
3076
|
"arguments": []
|
|
3060
3077
|
},
|
|
@@ -3104,6 +3121,30 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3104
3121
|
"fragment": false,
|
|
3105
3122
|
"parameters": []
|
|
3106
3123
|
},
|
|
3124
|
+
{
|
|
3125
|
+
"$type": "ParserRule",
|
|
3126
|
+
"name": "DataFieldName",
|
|
3127
|
+
"dataType": "string",
|
|
3128
|
+
"definition": {
|
|
3129
|
+
"$type": "Alternatives",
|
|
3130
|
+
"elements": [
|
|
3131
|
+
{
|
|
3132
|
+
"$type": "RuleCall",
|
|
3133
|
+
"rule": {
|
|
3134
|
+
"$ref": "#/rules@55"
|
|
3135
|
+
},
|
|
3136
|
+
"arguments": []
|
|
3137
|
+
},
|
|
3138
|
+
{
|
|
3139
|
+
"$type": "Keyword",
|
|
3140
|
+
"value": "this"
|
|
3141
|
+
}
|
|
3142
|
+
]
|
|
3143
|
+
},
|
|
3144
|
+
"entry": false,
|
|
3145
|
+
"fragment": false,
|
|
3146
|
+
"parameters": []
|
|
3147
|
+
},
|
|
3107
3148
|
{
|
|
3108
3149
|
"$type": "ParserRule",
|
|
3109
3150
|
"name": "RegularIDWithTypeNames",
|
|
@@ -3193,7 +3234,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3193
3234
|
"terminal": {
|
|
3194
3235
|
"$type": "RuleCall",
|
|
3195
3236
|
"rule": {
|
|
3196
|
-
"$ref": "#/rules@
|
|
3237
|
+
"$ref": "#/rules@74"
|
|
3197
3238
|
},
|
|
3198
3239
|
"arguments": []
|
|
3199
3240
|
},
|
|
@@ -3213,21 +3254,21 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3213
3254
|
{
|
|
3214
3255
|
"$type": "RuleCall",
|
|
3215
3256
|
"rule": {
|
|
3216
|
-
"$ref": "#/rules@
|
|
3257
|
+
"$ref": "#/rules@68"
|
|
3217
3258
|
},
|
|
3218
3259
|
"arguments": []
|
|
3219
3260
|
},
|
|
3220
3261
|
{
|
|
3221
3262
|
"$type": "RuleCall",
|
|
3222
3263
|
"rule": {
|
|
3223
|
-
"$ref": "#/rules@
|
|
3264
|
+
"$ref": "#/rules@69"
|
|
3224
3265
|
},
|
|
3225
3266
|
"arguments": []
|
|
3226
3267
|
},
|
|
3227
3268
|
{
|
|
3228
3269
|
"$type": "RuleCall",
|
|
3229
3270
|
"rule": {
|
|
3230
|
-
"$ref": "#/rules@
|
|
3271
|
+
"$ref": "#/rules@70"
|
|
3231
3272
|
},
|
|
3232
3273
|
"arguments": []
|
|
3233
3274
|
}
|
|
@@ -3248,7 +3289,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3248
3289
|
"terminal": {
|
|
3249
3290
|
"$type": "RuleCall",
|
|
3250
3291
|
"rule": {
|
|
3251
|
-
"$ref": "#/rules@
|
|
3292
|
+
"$ref": "#/rules@57"
|
|
3252
3293
|
},
|
|
3253
3294
|
"arguments": []
|
|
3254
3295
|
}
|
|
@@ -3267,7 +3308,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3267
3308
|
"terminal": {
|
|
3268
3309
|
"$type": "RuleCall",
|
|
3269
3310
|
"rule": {
|
|
3270
|
-
"$ref": "#/rules@
|
|
3311
|
+
"$ref": "#/rules@57"
|
|
3271
3312
|
},
|
|
3272
3313
|
"arguments": []
|
|
3273
3314
|
}
|
|
@@ -3289,7 +3330,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3289
3330
|
"terminal": {
|
|
3290
3331
|
"$type": "RuleCall",
|
|
3291
3332
|
"rule": {
|
|
3292
|
-
"$ref": "#/rules@
|
|
3333
|
+
"$ref": "#/rules@61"
|
|
3293
3334
|
},
|
|
3294
3335
|
"arguments": []
|
|
3295
3336
|
},
|
|
@@ -3314,7 +3355,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3314
3355
|
"terminal": {
|
|
3315
3356
|
"$type": "RuleCall",
|
|
3316
3357
|
"rule": {
|
|
3317
|
-
"$ref": "#/rules@
|
|
3358
|
+
"$ref": "#/rules@74"
|
|
3318
3359
|
},
|
|
3319
3360
|
"arguments": []
|
|
3320
3361
|
},
|
|
@@ -3353,7 +3394,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3353
3394
|
"terminal": {
|
|
3354
3395
|
"$type": "RuleCall",
|
|
3355
3396
|
"rule": {
|
|
3356
|
-
"$ref": "#/rules@
|
|
3397
|
+
"$ref": "#/rules@58"
|
|
3357
3398
|
},
|
|
3358
3399
|
"arguments": []
|
|
3359
3400
|
}
|
|
@@ -3365,7 +3406,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3365
3406
|
"terminal": {
|
|
3366
3407
|
"$type": "RuleCall",
|
|
3367
3408
|
"rule": {
|
|
3368
|
-
"$ref": "#/rules@
|
|
3409
|
+
"$ref": "#/rules@61"
|
|
3369
3410
|
},
|
|
3370
3411
|
"arguments": []
|
|
3371
3412
|
},
|
|
@@ -3396,7 +3437,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3396
3437
|
{
|
|
3397
3438
|
"$type": "RuleCall",
|
|
3398
3439
|
"rule": {
|
|
3399
|
-
"$ref": "#/rules@
|
|
3440
|
+
"$ref": "#/rules@64"
|
|
3400
3441
|
},
|
|
3401
3442
|
"arguments": []
|
|
3402
3443
|
},
|
|
@@ -3485,12 +3526,12 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3485
3526
|
"terminal": {
|
|
3486
3527
|
"$type": "CrossReference",
|
|
3487
3528
|
"type": {
|
|
3488
|
-
"$ref": "#/rules@
|
|
3529
|
+
"$ref": "#/rules@56"
|
|
3489
3530
|
},
|
|
3490
3531
|
"terminal": {
|
|
3491
3532
|
"$type": "RuleCall",
|
|
3492
3533
|
"rule": {
|
|
3493
|
-
"$ref": "#/rules@
|
|
3534
|
+
"$ref": "#/rules@70"
|
|
3494
3535
|
},
|
|
3495
3536
|
"arguments": []
|
|
3496
3537
|
},
|
|
@@ -3508,7 +3549,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3508
3549
|
{
|
|
3509
3550
|
"$type": "RuleCall",
|
|
3510
3551
|
"rule": {
|
|
3511
|
-
"$ref": "#/rules@
|
|
3552
|
+
"$ref": "#/rules@62"
|
|
3512
3553
|
},
|
|
3513
3554
|
"arguments": [],
|
|
3514
3555
|
"cardinality": "?"
|
|
@@ -3535,7 +3576,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3535
3576
|
{
|
|
3536
3577
|
"$type": "RuleCall",
|
|
3537
3578
|
"rule": {
|
|
3538
|
-
"$ref": "#/rules@
|
|
3579
|
+
"$ref": "#/rules@74"
|
|
3539
3580
|
},
|
|
3540
3581
|
"arguments": [],
|
|
3541
3582
|
"cardinality": "*"
|
|
@@ -3547,12 +3588,12 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3547
3588
|
"terminal": {
|
|
3548
3589
|
"$type": "CrossReference",
|
|
3549
3590
|
"type": {
|
|
3550
|
-
"$ref": "#/rules@
|
|
3591
|
+
"$ref": "#/rules@56"
|
|
3551
3592
|
},
|
|
3552
3593
|
"terminal": {
|
|
3553
3594
|
"$type": "RuleCall",
|
|
3554
3595
|
"rule": {
|
|
3555
|
-
"$ref": "#/rules@
|
|
3596
|
+
"$ref": "#/rules@69"
|
|
3556
3597
|
},
|
|
3557
3598
|
"arguments": []
|
|
3558
3599
|
},
|
|
@@ -3570,7 +3611,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3570
3611
|
{
|
|
3571
3612
|
"$type": "RuleCall",
|
|
3572
3613
|
"rule": {
|
|
3573
|
-
"$ref": "#/rules@
|
|
3614
|
+
"$ref": "#/rules@62"
|
|
3574
3615
|
},
|
|
3575
3616
|
"arguments": [],
|
|
3576
3617
|
"cardinality": "?"
|
|
@@ -3601,12 +3642,12 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3601
3642
|
"terminal": {
|
|
3602
3643
|
"$type": "CrossReference",
|
|
3603
3644
|
"type": {
|
|
3604
|
-
"$ref": "#/rules@
|
|
3645
|
+
"$ref": "#/rules@56"
|
|
3605
3646
|
},
|
|
3606
3647
|
"terminal": {
|
|
3607
3648
|
"$type": "RuleCall",
|
|
3608
3649
|
"rule": {
|
|
3609
|
-
"$ref": "#/rules@
|
|
3650
|
+
"$ref": "#/rules@68"
|
|
3610
3651
|
},
|
|
3611
3652
|
"arguments": []
|
|
3612
3653
|
},
|
|
@@ -3624,7 +3665,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3624
3665
|
{
|
|
3625
3666
|
"$type": "RuleCall",
|
|
3626
3667
|
"rule": {
|
|
3627
|
-
"$ref": "#/rules@
|
|
3668
|
+
"$ref": "#/rules@62"
|
|
3628
3669
|
},
|
|
3629
3670
|
"arguments": [],
|
|
3630
3671
|
"cardinality": "?"
|
|
@@ -3656,7 +3697,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3656
3697
|
"terminal": {
|
|
3657
3698
|
"$type": "RuleCall",
|
|
3658
3699
|
"rule": {
|
|
3659
|
-
"$ref": "#/rules@
|
|
3700
|
+
"$ref": "#/rules@63"
|
|
3660
3701
|
},
|
|
3661
3702
|
"arguments": []
|
|
3662
3703
|
}
|
|
@@ -3675,7 +3716,7 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
3675
3716
|
"terminal": {
|
|
3676
3717
|
"$type": "RuleCall",
|
|
3677
3718
|
"rule": {
|
|
3678
|
-
"$ref": "#/rules@
|
|
3719
|
+
"$ref": "#/rules@63"
|
|
3679
3720
|
},
|
|
3680
3721
|
"arguments": []
|
|
3681
3722
|
}
|
|
@@ -4018,6 +4059,12 @@ const ZModelGrammar = () => loadedZModelGrammar ?? (loadedZModelGrammar = loadGr
|
|
|
4018
4059
|
"typeRef": {
|
|
4019
4060
|
"$ref": "#/rules@30"
|
|
4020
4061
|
}
|
|
4062
|
+
},
|
|
4063
|
+
{
|
|
4064
|
+
"$type": "SimpleType",
|
|
4065
|
+
"typeRef": {
|
|
4066
|
+
"$ref": "#/rules@46"
|
|
4067
|
+
}
|
|
4021
4068
|
}
|
|
4022
4069
|
]
|
|
4023
4070
|
}
|
|
@@ -4173,6 +4220,10 @@ var AttributeApplicationValidator = class {
|
|
|
4173
4220
|
const decl = attr.decl.ref;
|
|
4174
4221
|
if (!decl) return;
|
|
4175
4222
|
const targetDecl = attr.$container;
|
|
4223
|
+
if ((isPrimitiveTypeDef(targetDecl) || isPrimitiveTypeDef(targetDecl.$container)) && !hasAttribute(attr.decl.ref, "@@@validation")) {
|
|
4224
|
+
accept("error", `attribute "${decl.name}" cannot be used with primitive type defs`, { node: attr });
|
|
4225
|
+
return;
|
|
4226
|
+
}
|
|
4176
4227
|
if (decl.name === "@@@targetField" && !isAttribute(targetDecl)) {
|
|
4177
4228
|
accept("error", `attribute "${decl.name}" can only be used on attribute declarations`, { node: attr });
|
|
4178
4229
|
return;
|
|
@@ -4278,7 +4329,7 @@ var AttributeApplicationValidator = class {
|
|
|
4278
4329
|
accept("error", `expects a string literal`, { node: attr.args[0] });
|
|
4279
4330
|
return;
|
|
4280
4331
|
}
|
|
4281
|
-
this.validatePolicyKinds(kind, [
|
|
4332
|
+
const kinds = this.validatePolicyKinds(kind, [
|
|
4282
4333
|
"read",
|
|
4283
4334
|
"update",
|
|
4284
4335
|
"all"
|
|
@@ -4286,12 +4337,22 @@ var AttributeApplicationValidator = class {
|
|
|
4286
4337
|
const expr = attr.args[1]?.value;
|
|
4287
4338
|
if (expr && AstUtils.streamAst(expr).some((node) => isBeforeInvocation(node))) accept("error", `"before()" is not allowed in field-level policies`, { node: expr });
|
|
4288
4339
|
const field = attr.$container;
|
|
4289
|
-
if (isRelationshipField(field))
|
|
4340
|
+
if (isRelationshipField(field)) if (isManyToManyField(field)) {
|
|
4341
|
+
if (kinds.some((k) => k !== "update")) accept("error", `Only 'update' policies are allowed on many-to-many relation fields`, { node: attr });
|
|
4342
|
+
} else accept("error", `Field-level policies are only allowed for implicit many-to-many relation fields`, { node: attr });
|
|
4290
4343
|
if (isComputedField(field)) accept("error", `Field-level policies are not allowed for computed fields.`, { node: attr });
|
|
4291
4344
|
}
|
|
4292
4345
|
_checkValidate(attr, accept) {
|
|
4293
4346
|
const condition = attr.args[0]?.value;
|
|
4294
|
-
if (condition
|
|
4347
|
+
if (condition) {
|
|
4348
|
+
if (AstUtils.streamAst(condition).some((node) => isDataFieldReference(node) && isDataModel(node.$resolvedType?.decl))) {
|
|
4349
|
+
accept("error", `\`@@validate\` condition cannot use relation fields`, { node: condition });
|
|
4350
|
+
return;
|
|
4351
|
+
}
|
|
4352
|
+
if (isPrimitiveTypeDef(attr.$container) && AstUtils.streamAst(condition).some((node) => isThisExpr(node))) {
|
|
4353
|
+
if (!getPrimitiveTypeDefThisField(attr.$container)) accept("error", "primitive type def cannot reference `this` field without declaring it", { node: condition });
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4295
4356
|
}
|
|
4296
4357
|
_checkId(attr, accept) {
|
|
4297
4358
|
if (getContainingDataModel(attr)?.isView) accept("error", `\`@id\` is not allowed for views`, { node: attr });
|
|
@@ -4487,8 +4548,11 @@ function assignableToAttributeParam(arg, param, attr) {
|
|
|
4487
4548
|
} else if (dstType) {
|
|
4488
4549
|
if (typeof argResolvedType?.decl !== "string") return genericError;
|
|
4489
4550
|
if (dstType === "ContextType") if (isDataField(attr.$container)) {
|
|
4490
|
-
if (
|
|
4491
|
-
|
|
4551
|
+
if (attr.$container.type.reference?.ref && isPrimitiveTypeDef(attr.$container.type.reference.ref)) dstType = mapBuiltinTypeToExpressionType(attr.$container.type.reference.ref.base);
|
|
4552
|
+
else {
|
|
4553
|
+
if (!attr.$container?.type?.type) return genericError;
|
|
4554
|
+
dstType = mapBuiltinTypeToExpressionType(attr.$container.type.type);
|
|
4555
|
+
}
|
|
4492
4556
|
dstIsArray = attr.$container.type.array;
|
|
4493
4557
|
} else dstType = "Any";
|
|
4494
4558
|
if (typeAssignable(dstType, argResolvedType.decl, arg.value) && dstIsArray === argResolvedType.array) return success;
|
|
@@ -4505,34 +4569,35 @@ function isValidAttributeTarget(attrDecl, targetDecl) {
|
|
|
4505
4569
|
return ref && "name" in ref && typeof ref.name === "string" ? ref.name : void 0;
|
|
4506
4570
|
}).filter((name) => !!name);
|
|
4507
4571
|
let allowed = false;
|
|
4572
|
+
const targetDeclType = targetDecl.$resolvedType?.decl ?? targetDecl.type.type;
|
|
4508
4573
|
for (const allowedType of fieldTypes) {
|
|
4509
4574
|
switch (allowedType) {
|
|
4510
4575
|
case "StringField":
|
|
4511
|
-
allowed = allowed ||
|
|
4576
|
+
allowed = allowed || targetDeclType === "String";
|
|
4512
4577
|
break;
|
|
4513
4578
|
case "IntField":
|
|
4514
|
-
allowed = allowed ||
|
|
4579
|
+
allowed = allowed || targetDeclType === "Int";
|
|
4515
4580
|
break;
|
|
4516
4581
|
case "BigIntField":
|
|
4517
|
-
allowed = allowed ||
|
|
4582
|
+
allowed = allowed || targetDeclType === "BigInt";
|
|
4518
4583
|
break;
|
|
4519
4584
|
case "FloatField":
|
|
4520
|
-
allowed = allowed ||
|
|
4585
|
+
allowed = allowed || targetDeclType === "Float";
|
|
4521
4586
|
break;
|
|
4522
4587
|
case "DecimalField":
|
|
4523
|
-
allowed = allowed ||
|
|
4588
|
+
allowed = allowed || targetDeclType === "Decimal";
|
|
4524
4589
|
break;
|
|
4525
4590
|
case "BooleanField":
|
|
4526
|
-
allowed = allowed ||
|
|
4591
|
+
allowed = allowed || targetDeclType === "Boolean";
|
|
4527
4592
|
break;
|
|
4528
4593
|
case "DateTimeField":
|
|
4529
|
-
allowed = allowed ||
|
|
4594
|
+
allowed = allowed || targetDeclType === "DateTime";
|
|
4530
4595
|
break;
|
|
4531
4596
|
case "JsonField":
|
|
4532
|
-
allowed = allowed ||
|
|
4597
|
+
allowed = allowed || targetDeclType === "Json";
|
|
4533
4598
|
break;
|
|
4534
4599
|
case "BytesField":
|
|
4535
|
-
allowed = allowed ||
|
|
4600
|
+
allowed = allowed || targetDeclType === "Bytes";
|
|
4536
4601
|
break;
|
|
4537
4602
|
case "ModelField":
|
|
4538
4603
|
allowed = allowed || isDataModel(targetDecl.type.reference?.ref);
|
|
@@ -4602,7 +4667,7 @@ var DataModelValidator = class {
|
|
|
4602
4667
|
this.validateAttributes(dm, accept);
|
|
4603
4668
|
this.validateFields(dm, accept);
|
|
4604
4669
|
this.validateOnceInModelAttributes(dm, accept);
|
|
4605
|
-
if (dm.mixins.length > 0) this.validateMixins(dm, accept);
|
|
4670
|
+
if (dm.mixins.length > 0 || dm.base) this.validateMixins(dm, accept);
|
|
4606
4671
|
this.validateInherits(dm, accept);
|
|
4607
4672
|
this.validateDelegateMap(dm, accept);
|
|
4608
4673
|
}
|
|
@@ -4619,7 +4684,7 @@ var DataModelValidator = class {
|
|
|
4619
4684
|
else (idFields.length > 0 ? idFields : modelLevelIds).forEach((idField) => {
|
|
4620
4685
|
if (idField.type.optional) accept("error", "Field with @id attribute must not be optional", { node: idField });
|
|
4621
4686
|
const isArray = idField.type.array;
|
|
4622
|
-
const isValidType = SCALAR_TYPES.includes(idField.type.type) || isEnum(idField.type.reference?.ref);
|
|
4687
|
+
const isValidType = SCALAR_TYPES.includes(idField.$resolvedType?.decl ?? idField.type.type) || isEnum(idField.type.reference?.ref);
|
|
4623
4688
|
if (isArray || !isValidType) accept("error", "Field with @id attribute must be of scalar or enum type", { node: idField });
|
|
4624
4689
|
});
|
|
4625
4690
|
dm.fields.forEach((field) => this.validateField(field, accept));
|
|
@@ -4632,7 +4697,7 @@ var DataModelValidator = class {
|
|
|
4632
4697
|
if (field.params.length > 0 && !hasAttribute(field, "@computed")) accept("error", "Only `@computed` fields can declare parameters", { node: field });
|
|
4633
4698
|
if (field.type.unsupported && !isStringLiteral(field.type.unsupported.value)) accept("error", "Unsupported type argument must be a string literal", { node: field.type.unsupported });
|
|
4634
4699
|
field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));
|
|
4635
|
-
if (isTypeDef(field.type.reference?.ref)) {
|
|
4700
|
+
if (isTypeDef(field.type.reference?.ref) && !isPrimitiveTypeDef(field.type.reference.ref)) {
|
|
4636
4701
|
if (!hasAttribute(field, "@json")) accept("error", "Custom-typed field must have @json attribute", { node: field });
|
|
4637
4702
|
if (this.typeDefHasModelField(field.type.reference.ref)) accept("error", "Type used as JSON field type cannot have relation fields", { node: field });
|
|
4638
4703
|
}
|
|
@@ -4842,6 +4907,10 @@ var DataModelValidator = class {
|
|
|
4842
4907
|
}
|
|
4843
4908
|
}
|
|
4844
4909
|
validateMixins(dm, accept) {
|
|
4910
|
+
if (dm.base) {
|
|
4911
|
+
accept("error", `model "${dm.name}" cannot use a primitive type as a mixin`, { node: dm });
|
|
4912
|
+
return;
|
|
4913
|
+
}
|
|
4845
4914
|
const seen = [];
|
|
4846
4915
|
const todo = dm.mixins.map((mixin) => mixin.ref);
|
|
4847
4916
|
while (todo.length > 0) {
|
|
@@ -4852,6 +4921,7 @@ var DataModelValidator = class {
|
|
|
4852
4921
|
}
|
|
4853
4922
|
seen.push(current);
|
|
4854
4923
|
todo.push(...current.mixins.map((mixin) => mixin.ref));
|
|
4924
|
+
if (current.base) accept("error", `cannot use primitive type def "${current.name}" as a mixin`, { node: dm });
|
|
4855
4925
|
}
|
|
4856
4926
|
}
|
|
4857
4927
|
validateDelegateMap(dm, accept) {
|
|
@@ -5023,6 +5093,7 @@ var ExpressionValidator = class {
|
|
|
5023
5093
|
}
|
|
5024
5094
|
validateReferenceExpr(expr, accept) {
|
|
5025
5095
|
if (isCollectionPredicateBinding(expr.target.ref) && !isMemberAccessExpr(expr.$container)) accept("error", "Collection predicate binding cannot be used without a member access", { node: expr });
|
|
5096
|
+
if (isEnum(expr.target.ref) && !this.isInPolicyOrValidationAttribute(expr)) accept("error", "Enum reference can only be used with policy and validation attributes", { node: expr });
|
|
5026
5097
|
}
|
|
5027
5098
|
validateMemberAccessExpr(expr, accept) {
|
|
5028
5099
|
if (isBeforeInvocation(expr.operand) && isDataModel(expr.$resolvedType?.decl)) accept("error", "relation fields cannot be accessed from `before()`", { node: expr });
|
|
@@ -5116,6 +5187,16 @@ var ExpressionValidator = class {
|
|
|
5116
5187
|
isInValidationContext(node) {
|
|
5117
5188
|
return findUpAst(node, (n) => isDataModelAttribute(n) && n.decl.$refText === "@@validate");
|
|
5118
5189
|
}
|
|
5190
|
+
isInPolicyOrValidationAttribute(node) {
|
|
5191
|
+
const attrs = [
|
|
5192
|
+
"@allow",
|
|
5193
|
+
"@@allow",
|
|
5194
|
+
"@deny",
|
|
5195
|
+
"@@deny",
|
|
5196
|
+
"@@validate"
|
|
5197
|
+
];
|
|
5198
|
+
return findUpAst(node, (n) => (isDataModelAttribute(n) || isDataFieldAttribute(n)) && attrs.includes(n.decl.$refText));
|
|
5199
|
+
}
|
|
5119
5200
|
isNotModelFieldExpr(expr) {
|
|
5120
5201
|
return isLiteralExpr(expr) || isEnumFieldReference(expr) || isNullExpr(expr) || isAuthOrAuthMemberAccess(expr) || isArrayExpr(expr) && expr.items.every((item) => this.isNotModelFieldExpr(item));
|
|
5121
5202
|
}
|
|
@@ -5272,7 +5353,7 @@ var FunctionInvocationValidator = class {
|
|
|
5272
5353
|
_checkLength(expr, accept) {
|
|
5273
5354
|
const msg = "argument must be a string or list field";
|
|
5274
5355
|
const fieldArg = expr.args[0].value;
|
|
5275
|
-
if (!isDataFieldReference(fieldArg)) {
|
|
5356
|
+
if (!isDataFieldReference(fieldArg) && !isThisExpr(fieldArg)) {
|
|
5276
5357
|
accept("error", msg, { node: expr.args[0] });
|
|
5277
5358
|
return;
|
|
5278
5359
|
}
|
|
@@ -5451,6 +5532,7 @@ var TypeDefValidator = class {
|
|
|
5451
5532
|
validateDuplicatedDeclarations(typeDef, typeDef.fields, accept);
|
|
5452
5533
|
this.validateAttributes(typeDef, accept);
|
|
5453
5534
|
this.validateFields(typeDef, accept);
|
|
5535
|
+
this.validatePrimitiveTypeDef(typeDef, accept);
|
|
5454
5536
|
}
|
|
5455
5537
|
validateAttributes(typeDef, accept) {
|
|
5456
5538
|
typeDef.attributes.forEach((attr) => validateAttributeApplication(attr, accept));
|
|
@@ -5461,6 +5543,21 @@ var TypeDefValidator = class {
|
|
|
5461
5543
|
validateField(field, accept) {
|
|
5462
5544
|
field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));
|
|
5463
5545
|
}
|
|
5546
|
+
validatePrimitiveTypeDef(typeDef, accept) {
|
|
5547
|
+
if (typeDef.base) {
|
|
5548
|
+
if (typeDef.fields.length > 1) accept("error", "primitive type def must only declare 1 field", { node: typeDef });
|
|
5549
|
+
const thisField = getPrimitiveTypeDefThisField(typeDef);
|
|
5550
|
+
if (thisField) {
|
|
5551
|
+
if (thisField.type.type !== typeDef.base) accept("error", "primitive type def's \"this\" field must match the declared type", { node: thisField });
|
|
5552
|
+
if (thisField.type.array) accept("error", "primitive type def's \"this\" field must be scalar", { node: thisField });
|
|
5553
|
+
if (thisField.type.optional) accept("error", "primitive type def's \"this\" field must not be optional", { node: thisField });
|
|
5554
|
+
}
|
|
5555
|
+
if (typeDef.mixins.length > 0) accept("error", `primitive type def cannot use mixins`, { node: typeDef });
|
|
5556
|
+
} else {
|
|
5557
|
+
const primitiveTypeDefs = typeDef.mixins.filter((m) => !!m.ref?.base);
|
|
5558
|
+
for (const primitiveTypeDef of primitiveTypeDefs) accept("error", `cannot use primitive type def "${primitiveTypeDef.$refText}" as a mixin`, { node: typeDef });
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5464
5561
|
};
|
|
5465
5562
|
//#endregion
|
|
5466
5563
|
//#region src/validator.ts
|
|
@@ -6473,6 +6570,11 @@ var ZModelLinker = class extends DefaultLinker {
|
|
|
6473
6570
|
};
|
|
6474
6571
|
} else if (isEnumField(target)) this.resolveToBuiltinTypeOrDecl(node, target.$container);
|
|
6475
6572
|
else if (isDataField(target) || isFunctionParam(target)) this.resolveToDeclaredType(node, target.type);
|
|
6573
|
+
else if (isEnum(target)) node.$resolvedType = {
|
|
6574
|
+
decl: target,
|
|
6575
|
+
array: true,
|
|
6576
|
+
nullable: false
|
|
6577
|
+
};
|
|
6476
6578
|
}
|
|
6477
6579
|
}
|
|
6478
6580
|
resolveArray(node, document, extraScopes) {
|
|
@@ -6529,8 +6631,18 @@ var ZModelLinker = class extends DefaultLinker {
|
|
|
6529
6631
|
}
|
|
6530
6632
|
}
|
|
6531
6633
|
let decl = node.$container;
|
|
6532
|
-
while (decl
|
|
6533
|
-
|
|
6634
|
+
while (decl) {
|
|
6635
|
+
if (isPrimitiveTypeDef(decl)) {
|
|
6636
|
+
const thisField = getPrimitiveTypeDefThisField(decl);
|
|
6637
|
+
if (thisField?.type.type) this.resolveToBuiltinTypeOrDecl(node, thisField.type.type);
|
|
6638
|
+
return;
|
|
6639
|
+
}
|
|
6640
|
+
if (isDataModel(decl)) {
|
|
6641
|
+
this.resolveToBuiltinTypeOrDecl(node, decl);
|
|
6642
|
+
return;
|
|
6643
|
+
}
|
|
6644
|
+
decl = decl.$container;
|
|
6645
|
+
}
|
|
6534
6646
|
}
|
|
6535
6647
|
resolveNull(node, _document, _extraScopes) {
|
|
6536
6648
|
this.resolveToBuiltinTypeOrDecl(node, "Null");
|
|
@@ -6583,10 +6695,16 @@ var ZModelLinker = class extends DefaultLinker {
|
|
|
6583
6695
|
resolveDataField(node, document, extraScopes) {
|
|
6584
6696
|
this.resolve(node.type, document, extraScopes);
|
|
6585
6697
|
let scopes = extraScopes;
|
|
6586
|
-
if (node.type.reference?.ref
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6698
|
+
if (node.type.reference?.ref) {
|
|
6699
|
+
if (isEnum(node.type.reference.ref)) {
|
|
6700
|
+
const contextEnum = node.type.reference.ref;
|
|
6701
|
+
const enumScope = (name) => contextEnum.fields.find((f) => f.name === name);
|
|
6702
|
+
scopes = [enumScope, ...scopes];
|
|
6703
|
+
} else if (isPrimitiveTypeDef(node.type.reference.ref)) node.$resolvedType = {
|
|
6704
|
+
decl: node.type.reference.ref.base,
|
|
6705
|
+
array: node.type.array,
|
|
6706
|
+
nullable: node.type.optional
|
|
6707
|
+
};
|
|
6590
6708
|
}
|
|
6591
6709
|
this.resolveDefault(node, document, scopes);
|
|
6592
6710
|
}
|
|
@@ -6615,6 +6733,11 @@ var ZModelLinker = class extends DefaultLinker {
|
|
|
6615
6733
|
array: type.array,
|
|
6616
6734
|
nullable
|
|
6617
6735
|
};
|
|
6736
|
+
else if (type.reference?.ref && isPrimitiveTypeDef(type.reference.ref)) node.$resolvedType = {
|
|
6737
|
+
decl: type.reference.ref.base,
|
|
6738
|
+
array: type.array,
|
|
6739
|
+
nullable
|
|
6740
|
+
};
|
|
6618
6741
|
else if (type.reference) node.$resolvedType = {
|
|
6619
6742
|
decl: type.reference.ref,
|
|
6620
6743
|
array: type.array,
|
|
@@ -6674,6 +6797,8 @@ var ZModelScopeProvider = class extends DefaultScopeProvider {
|
|
|
6674
6797
|
if (isReferenceExpr(context.container) && context.property === "target") {
|
|
6675
6798
|
const containerCollectionPredicate = getCollectionPredicateContext(context.container);
|
|
6676
6799
|
if (containerCollectionPredicate) return this.getCollectionPredicateScope(context, containerCollectionPredicate);
|
|
6800
|
+
const targetModel = this.getTransitiveFieldReferenceTargetModel(context);
|
|
6801
|
+
if (targetModel) return this.getTransitiveFieldReferenceScope(targetModel);
|
|
6677
6802
|
}
|
|
6678
6803
|
return super.getScope(context);
|
|
6679
6804
|
}
|
|
@@ -6727,6 +6852,26 @@ var ZModelScopeProvider = class extends DefaultScopeProvider {
|
|
|
6727
6852
|
return this.createScopeForAuth(expr, globalScope);
|
|
6728
6853
|
}).otherwise(() => EMPTY_SCOPE);
|
|
6729
6854
|
}
|
|
6855
|
+
getTransitiveFieldReferenceScope(dm) {
|
|
6856
|
+
return this.createScope(getAllFields(dm).map((field) => this.descriptions.createDescription(field, field.name)));
|
|
6857
|
+
}
|
|
6858
|
+
getTransitiveFieldReferenceTargetModel(context) {
|
|
6859
|
+
let current = context.container;
|
|
6860
|
+
while (current) {
|
|
6861
|
+
if (isAttributeArg(current)) {
|
|
6862
|
+
const attr = current.$container;
|
|
6863
|
+
if (!isDataFieldAttribute(attr)) return;
|
|
6864
|
+
const decl = attr.decl.ref;
|
|
6865
|
+
if (!decl) return;
|
|
6866
|
+
if ((current.name ? decl.params.find((p) => p.name === current.name) : decl.params[attr.args.indexOf(current)])?.type?.type !== "TransitiveFieldReference") return;
|
|
6867
|
+
const field = attr.$container;
|
|
6868
|
+
if (!isDataField(field)) return;
|
|
6869
|
+
const targetType = field.type?.reference?.ref;
|
|
6870
|
+
return isDataModel(targetType) ? targetType : void 0;
|
|
6871
|
+
}
|
|
6872
|
+
current = current.$container;
|
|
6873
|
+
}
|
|
6874
|
+
}
|
|
6730
6875
|
createScopeForContainingModel(node, globalScope) {
|
|
6731
6876
|
const model = AstUtils.getContainerOfType(node, isDataModel);
|
|
6732
6877
|
if (model) return this.createScopeForContainer(model, globalScope);
|
|
@@ -6770,17 +6915,33 @@ var ZModelSemanticTokenProvider = class extends AbstractSemanticTokenProvider {
|
|
|
6770
6915
|
property: "baseModel",
|
|
6771
6916
|
type: SemanticTokenTypes.type
|
|
6772
6917
|
});
|
|
6773
|
-
} else if (
|
|
6918
|
+
} else if (isTypeDef(node)) {
|
|
6919
|
+
acceptor({
|
|
6920
|
+
node,
|
|
6921
|
+
property: "name",
|
|
6922
|
+
type: SemanticTokenTypes.type
|
|
6923
|
+
});
|
|
6924
|
+
acceptor({
|
|
6925
|
+
node,
|
|
6926
|
+
property: "mixins",
|
|
6927
|
+
type: SemanticTokenTypes.type
|
|
6928
|
+
});
|
|
6929
|
+
acceptor({
|
|
6930
|
+
node,
|
|
6931
|
+
property: "base",
|
|
6932
|
+
type: SemanticTokenTypes.type
|
|
6933
|
+
});
|
|
6934
|
+
} else if (isDataSource(node) || isGeneratorDecl(node) || isPlugin(node)) acceptor({
|
|
6774
6935
|
node,
|
|
6775
6936
|
property: "name",
|
|
6776
6937
|
type: SemanticTokenTypes.type
|
|
6777
6938
|
});
|
|
6778
|
-
else if (isDataField(node) || isConfigField(node) ||
|
|
6939
|
+
else if (isDataField(node) || isConfigField(node) || isPluginField(node)) acceptor({
|
|
6779
6940
|
node,
|
|
6780
6941
|
property: "name",
|
|
6781
|
-
type: SemanticTokenTypes.
|
|
6942
|
+
type: SemanticTokenTypes.property
|
|
6782
6943
|
});
|
|
6783
|
-
else if (isDataFieldType(node)) if (node.type) acceptor({
|
|
6944
|
+
else if (isDataFieldType(node) || isFunctionParamType(node) || isAttributeParamType(node)) if (node.type) acceptor({
|
|
6784
6945
|
node,
|
|
6785
6946
|
property: "type",
|
|
6786
6947
|
type: SemanticTokenTypes.type
|
|
@@ -6790,31 +6951,94 @@ var ZModelSemanticTokenProvider = class extends AbstractSemanticTokenProvider {
|
|
|
6790
6951
|
property: "reference",
|
|
6791
6952
|
type: SemanticTokenTypes.macro
|
|
6792
6953
|
});
|
|
6793
|
-
else if (isDataModelAttribute(node) || isDataFieldAttribute(node) || isInternalAttribute(node))
|
|
6954
|
+
else if (isDataModelAttribute(node) || isDataFieldAttribute(node) || isInternalAttribute(node)) {
|
|
6955
|
+
acceptor({
|
|
6956
|
+
node,
|
|
6957
|
+
property: "decl",
|
|
6958
|
+
type: SemanticTokenTypes.decorator
|
|
6959
|
+
});
|
|
6960
|
+
if (node.decl.$refText === "@regex" && node.args[0]) acceptor({
|
|
6961
|
+
node: node.args[0],
|
|
6962
|
+
property: "value",
|
|
6963
|
+
type: SemanticTokenTypes.regexp
|
|
6964
|
+
});
|
|
6965
|
+
} else if (isAttribute(node)) acceptor({
|
|
6794
6966
|
node,
|
|
6795
|
-
property: "
|
|
6796
|
-
type: SemanticTokenTypes.
|
|
6967
|
+
property: "name",
|
|
6968
|
+
type: SemanticTokenTypes.decorator
|
|
6797
6969
|
});
|
|
6798
6970
|
else if (isInvocationExpr(node)) acceptor({
|
|
6799
6971
|
node,
|
|
6800
6972
|
property: "function",
|
|
6801
6973
|
type: SemanticTokenTypes.function
|
|
6802
6974
|
});
|
|
6803
|
-
else if (isFunctionDecl(node) ||
|
|
6975
|
+
else if (isFunctionDecl(node) || isProcedure(node)) {
|
|
6976
|
+
acceptor({
|
|
6977
|
+
node,
|
|
6978
|
+
property: "name",
|
|
6979
|
+
type: SemanticTokenTypes.function
|
|
6980
|
+
});
|
|
6981
|
+
if ("mutation" in node && node.mutation) acceptor({
|
|
6982
|
+
node,
|
|
6983
|
+
property: "mutation",
|
|
6984
|
+
type: SemanticTokenTypes.modifier
|
|
6985
|
+
});
|
|
6986
|
+
} else if (isReferenceExpr(node)) if (isEnumField(node.target.ref)) acceptor({
|
|
6987
|
+
node,
|
|
6988
|
+
property: "target",
|
|
6989
|
+
type: SemanticTokenTypes.enumMember
|
|
6990
|
+
});
|
|
6991
|
+
else if (isFunctionParam(node.target.ref)) acceptor({
|
|
6804
6992
|
node,
|
|
6805
|
-
property: "
|
|
6806
|
-
type: SemanticTokenTypes.
|
|
6993
|
+
property: "target",
|
|
6994
|
+
type: SemanticTokenTypes.parameter
|
|
6807
6995
|
});
|
|
6808
|
-
else if (
|
|
6996
|
+
else if (isCollectionPredicateBinding(node.target.ref)) acceptor({
|
|
6809
6997
|
node,
|
|
6810
6998
|
property: "target",
|
|
6811
6999
|
type: SemanticTokenTypes.variable
|
|
6812
7000
|
});
|
|
7001
|
+
else acceptor({
|
|
7002
|
+
node,
|
|
7003
|
+
property: "target",
|
|
7004
|
+
type: SemanticTokenTypes.property
|
|
7005
|
+
});
|
|
6813
7006
|
else if (isMemberAccessExpr(node)) acceptor({
|
|
6814
7007
|
node,
|
|
6815
7008
|
property: "member",
|
|
6816
7009
|
type: SemanticTokenTypes.property
|
|
6817
7010
|
});
|
|
7011
|
+
else if (isNumberLiteral(node)) acceptor({
|
|
7012
|
+
node,
|
|
7013
|
+
property: "value",
|
|
7014
|
+
type: SemanticTokenTypes.number
|
|
7015
|
+
});
|
|
7016
|
+
else if (isUnaryExpr(node) || isBinaryExpr(node)) {
|
|
7017
|
+
if (node.operator !== "in") acceptor({
|
|
7018
|
+
node,
|
|
7019
|
+
property: "operator",
|
|
7020
|
+
type: SemanticTokenTypes.operator
|
|
7021
|
+
});
|
|
7022
|
+
} else if (isEnumField(node)) acceptor({
|
|
7023
|
+
node,
|
|
7024
|
+
property: "name",
|
|
7025
|
+
type: SemanticTokenTypes.enumMember
|
|
7026
|
+
});
|
|
7027
|
+
else if (isEnum(node)) acceptor({
|
|
7028
|
+
node,
|
|
7029
|
+
property: "name",
|
|
7030
|
+
type: SemanticTokenTypes.enum
|
|
7031
|
+
});
|
|
7032
|
+
else if (isFunctionParam(node) || isAttributeArg(node) || isAttributeParam(node) || isProcedureParam(node) || isDataFieldParam(node)) acceptor({
|
|
7033
|
+
node,
|
|
7034
|
+
property: "name",
|
|
7035
|
+
type: SemanticTokenTypes.parameter
|
|
7036
|
+
});
|
|
7037
|
+
else if (isCollectionPredicateBinding(node)) acceptor({
|
|
7038
|
+
node,
|
|
7039
|
+
property: "name",
|
|
7040
|
+
type: SemanticTokenTypes.variable
|
|
7041
|
+
});
|
|
6818
7042
|
}
|
|
6819
7043
|
};
|
|
6820
7044
|
//#endregion
|