@zenstackhq/language 3.5.6 → 3.6.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.
Files changed (45) hide show
  1. package/dist/ast-Clidp86c.cjs +1465 -0
  2. package/dist/ast-Clidp86c.cjs.map +1 -0
  3. package/dist/ast-DEfhnj8j.mjs +765 -0
  4. package/dist/ast-DEfhnj8j.mjs.map +1 -0
  5. package/dist/ast-DQDdBZQ3.d.mts +525 -0
  6. package/dist/ast-W2h6Qtfk.d.cts +525 -0
  7. package/dist/ast.cjs +130 -1432
  8. package/dist/ast.cjs.map +1 -1
  9. package/dist/ast.d.cts +2 -541
  10. package/dist/ast.d.mts +2 -0
  11. package/dist/ast.mjs +20 -0
  12. package/dist/ast.mjs.map +1 -0
  13. package/dist/factory.cjs +754 -2030
  14. package/dist/factory.cjs.map +1 -1
  15. package/dist/factory.d.cts +220 -215
  16. package/dist/factory.d.mts +289 -0
  17. package/dist/factory.mjs +778 -0
  18. package/dist/factory.mjs.map +1 -0
  19. package/dist/index.cjs +2691 -5454
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +104 -103
  22. package/dist/index.d.mts +170 -0
  23. package/dist/index.mjs +6925 -0
  24. package/dist/index.mjs.map +1 -0
  25. package/dist/utils-BB6L7ug2.mjs +529 -0
  26. package/dist/utils-BB6L7ug2.mjs.map +1 -0
  27. package/dist/utils-CfXGZkv7.cjs +842 -0
  28. package/dist/utils-CfXGZkv7.cjs.map +1 -0
  29. package/dist/utils.cjs +47 -1650
  30. package/dist/utils.d.cts +101 -10
  31. package/dist/{utils.d.ts → utils.d.mts} +101 -10
  32. package/dist/utils.mjs +2 -0
  33. package/package.json +16 -15
  34. package/dist/ast.d.ts +0 -541
  35. package/dist/ast.js +0 -1288
  36. package/dist/ast.js.map +0 -1
  37. package/dist/factory.d.ts +0 -284
  38. package/dist/factory.js +0 -2020
  39. package/dist/factory.js.map +0 -1
  40. package/dist/index.d.ts +0 -169
  41. package/dist/index.js +0 -9656
  42. package/dist/index.js.map +0 -1
  43. package/dist/utils.cjs.map +0 -1
  44. package/dist/utils.js +0 -1572
  45. package/dist/utils.js.map +0 -1
package/dist/utils.d.cts CHANGED
@@ -1,19 +1,21 @@
1
- import { DataModel, TypeDef, DataField, Enum, EnumField, FunctionDecl, Attribute, AttributeParam, DataModelAttribute, Model, AbstractDeclaration, DataFieldAttribute, InternalAttribute, Expression, ConfigExpr, BinaryExpr, ReferenceExpr, BuiltinType, ExpressionType, ModelImport } from './ast.cjs';
2
- import { AstNode, LangiumDocuments, LangiumDocument, URI, Reference } from 'langium';
1
+ import { A as Enum, D as DataModel, F as FunctionDecl, G as ModelImport, M as Expression, N as ExpressionType, O as DataModelAttribute, T as DataFieldAttribute, W as Model, _ as BuiltinType, b as ConfigExpr, et as ReferenceExpr, f as AttributeParam, j as EnumField, m as BinaryExpr, s as AbstractDeclaration, st as TypeDef, u as Attribute, w as DataField, z as InternalAttribute } from "./ast-W2h6Qtfk.cjs";
2
+ import { AstNode, LangiumDocument, LangiumDocuments, Reference, URI } from "langium";
3
3
 
4
+ //#region src/constants.d.ts
4
5
  /**
5
6
  * Expression context
6
7
  */
7
8
  declare enum ExpressionContext {
8
- DefaultValue = "DefaultValue",
9
- AccessPolicy = "AccessPolicy",
10
- ValidationRule = "ValidationRule",
11
- Index = "Index"
9
+ DefaultValue = "DefaultValue",
10
+ AccessPolicy = "AccessPolicy",
11
+ ValidationRule = "ValidationRule",
12
+ Index = "Index"
12
13
  }
13
-
14
+ //#endregion
15
+ //#region src/utils.d.ts
14
16
  type AttributeTarget = DataModel | TypeDef | DataField | Enum | EnumField | FunctionDecl | Attribute | AttributeParam;
15
17
  declare function hasAttribute(decl: AttributeTarget, name: string): boolean;
16
- declare function getAttribute(decl: AttributeTarget, name: string): DataFieldAttribute | DataModelAttribute | undefined;
18
+ declare function getAttribute(decl: AttributeTarget, name: string): DataModelAttribute | DataFieldAttribute | undefined;
17
19
  declare function isFromStdlib(node: AstNode): boolean;
18
20
  declare function isAuthInvocation(node: AstNode): boolean;
19
21
  /**
@@ -28,8 +30,17 @@ declare function typeAssignable(destType: ExpressionType, sourceType: Expression
28
30
  * Maps a ZModel builtin type to expression type
29
31
  */
30
32
  declare function mapBuiltinTypeToExpressionType(type: BuiltinType | ExpressionType): ExpressionType;
33
+ /**
34
+ * Determines if the given expression is an invocation of `auth` or a member access on the result of an `auth` invocation (e.g. `auth().role`).
35
+ */
31
36
  declare function isAuthOrAuthMemberAccess(expr: Expression): boolean;
37
+ /**
38
+ * Determines if the given expression is a reference to an enum field.
39
+ */
32
40
  declare function isEnumFieldReference(node: AstNode): node is ReferenceExpr;
41
+ /**
42
+ * Determines if the given expression is a reference to a data field.
43
+ */
33
44
  declare function isDataFieldReference(node: AstNode): node is ReferenceExpr;
34
45
  /**
35
46
  * Returns if the given field is a relation field.
@@ -39,8 +50,17 @@ declare function isRelationshipField(field: DataField): boolean;
39
50
  * Returns if the given field is a computed field.
40
51
  */
41
52
  declare function isComputedField(field: DataField): boolean;
53
+ /**
54
+ * Determines if the given data model is a delegate model (i.e. marked with `@@delegate` attribute).
55
+ */
42
56
  declare function isDelegateModel(node: AstNode): boolean;
57
+ /**
58
+ * Resolves the given reference and returns the target AST node. Throws an error if the reference is not resolved.
59
+ */
43
60
  declare function resolved<T extends AstNode>(ref: Reference<T>): T;
61
+ /**
62
+ * Gets all base models and mixins of a data model or type def, recursively.
63
+ */
44
64
  declare function getRecursiveBases(decl: DataModel | TypeDef, includeDelegate?: boolean, documents?: LangiumDocuments, seen?: Set<DataModel | TypeDef>): (TypeDef | DataModel)[];
45
65
  /**
46
66
  * Gets `@@id` fields declared at the data model level (including search in base models)
@@ -56,32 +76,99 @@ declare function getModelUniqueFields(model: DataModel): DataField[];
56
76
  * TODO: merge this with {@link getModelUniqueFields}
57
77
  */
58
78
  declare function getUniqueFields(model: DataModel): DataField[][];
79
+ /**
80
+ * Finds the first ancestor of the given AST node that satisfies the given predicate function. Returns `undefined` if no such ancestor is found.
81
+ */
59
82
  declare function findUpAst(node: AstNode, predicate: (node: AstNode) => boolean): AstNode | undefined;
83
+ /**
84
+ * Tries to get the literal value from the given expression. Returns `undefined` if the expression is not a literal or if the literal value cannot be determined.
85
+ */
60
86
  declare function getLiteral<T extends string | number | boolean | any = any>(expr: Expression | ConfigExpr | undefined): T | undefined;
87
+ /**
88
+ * Tries to get an object literal from the given expression. Returns `undefined` if the expression is not an object literal or if any of the field values cannot be determined.
89
+ */
61
90
  declare function getObjectLiteral<T>(expr: Expression | ConfigExpr | undefined): T | undefined;
62
91
  declare function getLiteralArray<T extends string | number | boolean | any = any>(expr: Expression | ConfigExpr | undefined): T[] | undefined;
92
+ /**
93
+ * Gets the value of the argument with the given name from the given attribute. Returns `undefined` if no such argument is found or if the argument value cannot be determined.
94
+ */
63
95
  declare function getAttributeArg(attr: DataModelAttribute | DataFieldAttribute | InternalAttribute, name: string): Expression | undefined;
96
+ /**
97
+ * Gets the literal value of the argument with the given name from the given attribute. Returns `undefined` if no such argument is found or if the argument value cannot be determined or is not a literal.
98
+ */
64
99
  declare function getAttributeArgLiteral<T extends string | number | boolean>(attr: DataModelAttribute | DataFieldAttribute | InternalAttribute, name: string): T | undefined;
100
+ /**
101
+ * Gets the allowed expression contexts for the given function declaration by looking for `@@expressionContext` attribute.
102
+ * Returns an empty array if no such attribute is found or if the attribute value cannot be determined.
103
+ */
65
104
  declare function getFunctionExpressionContext(funcDecl: FunctionDecl): ExpressionContext[];
105
+ /**
106
+ * Gets the data field referenced by the given expression, if any. Returns `undefined` if the expression is not a reference to a data field.
107
+ */
66
108
  declare function getFieldReference(expr: Expression): DataField | undefined;
67
109
  declare function isCheckInvocation(node: AstNode): boolean;
110
+ /**
111
+ * Resolves the transitive imports of the given model and returns the list of imported models. The given model itself is not included in the result.
112
+ */
68
113
  declare function resolveTransitiveImports(documents: LangiumDocuments, model: Model): Model[];
114
+ /**
115
+ * Resolves the given import and returns the imported model. Returns `undefined`
116
+ * if the import cannot be resolved.
117
+ */
69
118
  declare function resolveImport(documents: LangiumDocuments, imp: ModelImport): Model | undefined;
119
+ /**
120
+ * Resolves the given import and returns the URI of the imported model.
121
+ * Returns `undefined` if the import cannot be resolved.
122
+ */
70
123
  declare function resolveImportUri(imp: ModelImport): URI | undefined;
71
124
  /**
72
125
  * Gets data models and type defs in the ZModel schema.
73
126
  */
74
127
  declare function getDataModelAndTypeDefs(model: Model, includeIgnored?: boolean): (DataModel | TypeDef)[];
128
+ /**
129
+ * Gets all declarations of the given model and its transitive imports.
130
+ */
75
131
  declare function getAllDeclarationsIncludingImports(documents: LangiumDocuments, model: Model): AbstractDeclaration[];
132
+ /**
133
+ * Gets the model used for auth context, by looking for a model with `@@auth` attribute or a model named `User`.
134
+ * Returns `undefined` if no such model is found.
135
+ */
76
136
  declare function getAuthDecl(decls: (DataModel | TypeDef)[]): DataModel | TypeDef | undefined;
77
137
  declare function isBeforeInvocation(node: AstNode): boolean;
138
+ /**
139
+ * Determines if the given AST node is a collection predicate.
140
+ */
78
141
  declare function isCollectionPredicate(node: AstNode): node is BinaryExpr;
142
+ /**
143
+ * Gets all data models and type defs from the given documents registry.
144
+ */
79
145
  declare function getAllLoadedDataModelsAndTypeDefs(langiumDocuments: LangiumDocuments): (DataModel | TypeDef)[];
146
+ /**
147
+ * Gets all data models from the given documents registry and the transitive imports of the given model.
148
+ */
80
149
  declare function getAllDataModelsIncludingImports(documents: LangiumDocuments, model: Model): DataModel[];
150
+ /**
151
+ * Gets all data models and type defs from the given documents registry and the transitive imports
152
+ * of the given model. If `fromModel` is not provided, returns all loaded data models and type defs.
153
+ */
81
154
  declare function getAllLoadedAndReachableDataModelsAndTypeDefs(langiumDocuments: LangiumDocuments, fromModel?: DataModel): (DataModel | TypeDef)[];
155
+ /**
156
+ * Gets the containing data model of the given AST node, if any.
157
+ * Returns `undefined` if the node is not contained in a data model.
158
+ */
82
159
  declare function getContainingDataModel(node: AstNode): DataModel | undefined;
160
+ /**
161
+ * Determines if the given AST node can contain members.
162
+ */
83
163
  declare function isMemberContainer(node: unknown): node is DataModel | TypeDef;
164
+ /**
165
+ * Gets all fields of a data model or type def, including inherited fields from base models and mixins.
166
+ */
84
167
  declare function getAllFields(decl: DataModel | TypeDef, includeIgnored?: boolean, seen?: Set<DataModel | TypeDef>): DataField[];
168
+ /**
169
+ * Gets all attributes of a data model or type def, including inherited attributes
170
+ * from base models and mixins.
171
+ */
85
172
  declare function getAllAttributes(decl: DataModel | TypeDef, seen?: Set<DataModel | TypeDef>): DataModelAttribute[];
86
173
  /**
87
174
  * Retrieve the document in which the given AST node is contained. A reference to the document is
@@ -90,10 +177,14 @@ declare function getAllAttributes(decl: DataModel | TypeDef, seen?: Set<DataMode
90
177
  * @throws an error if the node is not contained in a document.
91
178
  */
92
179
  declare function getDocument<T extends AstNode = AstNode>(node: AstNode): LangiumDocument<T>;
180
+ /**
181
+ * Gets the list of plugin documents from the given model.
182
+ */
93
183
  declare function getPluginDocuments(model: Model, schemaPath: string): string[];
94
184
  /**
95
185
  * Returns the root node of the given AST node by following the `$container` references.
96
186
  */
97
187
  declare function findRootNode(node: AstNode): AstNode;
98
-
99
- export { type AttributeTarget, findRootNode, findUpAst, getAllAttributes, getAllDataModelsIncludingImports, getAllDeclarationsIncludingImports, getAllFields, getAllLoadedAndReachableDataModelsAndTypeDefs, getAllLoadedDataModelsAndTypeDefs, getAttribute, getAttributeArg, getAttributeArgLiteral, getAuthDecl, getContainingDataModel, getDataModelAndTypeDefs, getDocument, getFieldReference, getFunctionExpressionContext, getLiteral, getLiteralArray, getModelIdFields, getModelUniqueFields, getObjectLiteral, getPluginDocuments, getRecursiveBases, getStringLiteral, getUniqueFields, hasAttribute, isAuthInvocation, isAuthOrAuthMemberAccess, isBeforeInvocation, isCheckInvocation, isCollectionPredicate, isComputedField, isDataFieldReference, isDelegateModel, isEnumFieldReference, isFromStdlib, isMemberContainer, isRelationshipField, mapBuiltinTypeToExpressionType, resolveImport, resolveImportUri, resolveTransitiveImports, resolved, typeAssignable };
188
+ //#endregion
189
+ export { AttributeTarget, findRootNode, findUpAst, getAllAttributes, getAllDataModelsIncludingImports, getAllDeclarationsIncludingImports, getAllFields, getAllLoadedAndReachableDataModelsAndTypeDefs, getAllLoadedDataModelsAndTypeDefs, getAttribute, getAttributeArg, getAttributeArgLiteral, getAuthDecl, getContainingDataModel, getDataModelAndTypeDefs, getDocument, getFieldReference, getFunctionExpressionContext, getLiteral, getLiteralArray, getModelIdFields, getModelUniqueFields, getObjectLiteral, getPluginDocuments, getRecursiveBases, getStringLiteral, getUniqueFields, hasAttribute, isAuthInvocation, isAuthOrAuthMemberAccess, isBeforeInvocation, isCheckInvocation, isCollectionPredicate, isComputedField, isDataFieldReference, isDelegateModel, isEnumFieldReference, isFromStdlib, isMemberContainer, isRelationshipField, mapBuiltinTypeToExpressionType, resolveImport, resolveImportUri, resolveTransitiveImports, resolved, typeAssignable };
190
+ //# sourceMappingURL=utils.d.cts.map
@@ -1,19 +1,21 @@
1
- import { DataModel, TypeDef, DataField, Enum, EnumField, FunctionDecl, Attribute, AttributeParam, DataModelAttribute, Model, AbstractDeclaration, DataFieldAttribute, InternalAttribute, Expression, ConfigExpr, BinaryExpr, ReferenceExpr, BuiltinType, ExpressionType, ModelImport } from './ast.js';
2
- import { AstNode, LangiumDocuments, LangiumDocument, URI, Reference } from 'langium';
1
+ import { A as Enum, D as DataModel, F as FunctionDecl, G as ModelImport, M as Expression, N as ExpressionType, O as DataModelAttribute, T as DataFieldAttribute, W as Model, _ as BuiltinType, b as ConfigExpr, et as ReferenceExpr, f as AttributeParam, j as EnumField, m as BinaryExpr, s as AbstractDeclaration, st as TypeDef, u as Attribute, w as DataField, z as InternalAttribute } from "./ast-DQDdBZQ3.mjs";
2
+ import { AstNode, LangiumDocument, LangiumDocuments, Reference, URI } from "langium";
3
3
 
4
+ //#region src/constants.d.ts
4
5
  /**
5
6
  * Expression context
6
7
  */
7
8
  declare enum ExpressionContext {
8
- DefaultValue = "DefaultValue",
9
- AccessPolicy = "AccessPolicy",
10
- ValidationRule = "ValidationRule",
11
- Index = "Index"
9
+ DefaultValue = "DefaultValue",
10
+ AccessPolicy = "AccessPolicy",
11
+ ValidationRule = "ValidationRule",
12
+ Index = "Index"
12
13
  }
13
-
14
+ //#endregion
15
+ //#region src/utils.d.ts
14
16
  type AttributeTarget = DataModel | TypeDef | DataField | Enum | EnumField | FunctionDecl | Attribute | AttributeParam;
15
17
  declare function hasAttribute(decl: AttributeTarget, name: string): boolean;
16
- declare function getAttribute(decl: AttributeTarget, name: string): DataFieldAttribute | DataModelAttribute | undefined;
18
+ declare function getAttribute(decl: AttributeTarget, name: string): DataModelAttribute | DataFieldAttribute | undefined;
17
19
  declare function isFromStdlib(node: AstNode): boolean;
18
20
  declare function isAuthInvocation(node: AstNode): boolean;
19
21
  /**
@@ -28,8 +30,17 @@ declare function typeAssignable(destType: ExpressionType, sourceType: Expression
28
30
  * Maps a ZModel builtin type to expression type
29
31
  */
30
32
  declare function mapBuiltinTypeToExpressionType(type: BuiltinType | ExpressionType): ExpressionType;
33
+ /**
34
+ * Determines if the given expression is an invocation of `auth` or a member access on the result of an `auth` invocation (e.g. `auth().role`).
35
+ */
31
36
  declare function isAuthOrAuthMemberAccess(expr: Expression): boolean;
37
+ /**
38
+ * Determines if the given expression is a reference to an enum field.
39
+ */
32
40
  declare function isEnumFieldReference(node: AstNode): node is ReferenceExpr;
41
+ /**
42
+ * Determines if the given expression is a reference to a data field.
43
+ */
33
44
  declare function isDataFieldReference(node: AstNode): node is ReferenceExpr;
34
45
  /**
35
46
  * Returns if the given field is a relation field.
@@ -39,8 +50,17 @@ declare function isRelationshipField(field: DataField): boolean;
39
50
  * Returns if the given field is a computed field.
40
51
  */
41
52
  declare function isComputedField(field: DataField): boolean;
53
+ /**
54
+ * Determines if the given data model is a delegate model (i.e. marked with `@@delegate` attribute).
55
+ */
42
56
  declare function isDelegateModel(node: AstNode): boolean;
57
+ /**
58
+ * Resolves the given reference and returns the target AST node. Throws an error if the reference is not resolved.
59
+ */
43
60
  declare function resolved<T extends AstNode>(ref: Reference<T>): T;
61
+ /**
62
+ * Gets all base models and mixins of a data model or type def, recursively.
63
+ */
44
64
  declare function getRecursiveBases(decl: DataModel | TypeDef, includeDelegate?: boolean, documents?: LangiumDocuments, seen?: Set<DataModel | TypeDef>): (TypeDef | DataModel)[];
45
65
  /**
46
66
  * Gets `@@id` fields declared at the data model level (including search in base models)
@@ -56,32 +76,99 @@ declare function getModelUniqueFields(model: DataModel): DataField[];
56
76
  * TODO: merge this with {@link getModelUniqueFields}
57
77
  */
58
78
  declare function getUniqueFields(model: DataModel): DataField[][];
79
+ /**
80
+ * Finds the first ancestor of the given AST node that satisfies the given predicate function. Returns `undefined` if no such ancestor is found.
81
+ */
59
82
  declare function findUpAst(node: AstNode, predicate: (node: AstNode) => boolean): AstNode | undefined;
83
+ /**
84
+ * Tries to get the literal value from the given expression. Returns `undefined` if the expression is not a literal or if the literal value cannot be determined.
85
+ */
60
86
  declare function getLiteral<T extends string | number | boolean | any = any>(expr: Expression | ConfigExpr | undefined): T | undefined;
87
+ /**
88
+ * Tries to get an object literal from the given expression. Returns `undefined` if the expression is not an object literal or if any of the field values cannot be determined.
89
+ */
61
90
  declare function getObjectLiteral<T>(expr: Expression | ConfigExpr | undefined): T | undefined;
62
91
  declare function getLiteralArray<T extends string | number | boolean | any = any>(expr: Expression | ConfigExpr | undefined): T[] | undefined;
92
+ /**
93
+ * Gets the value of the argument with the given name from the given attribute. Returns `undefined` if no such argument is found or if the argument value cannot be determined.
94
+ */
63
95
  declare function getAttributeArg(attr: DataModelAttribute | DataFieldAttribute | InternalAttribute, name: string): Expression | undefined;
96
+ /**
97
+ * Gets the literal value of the argument with the given name from the given attribute. Returns `undefined` if no such argument is found or if the argument value cannot be determined or is not a literal.
98
+ */
64
99
  declare function getAttributeArgLiteral<T extends string | number | boolean>(attr: DataModelAttribute | DataFieldAttribute | InternalAttribute, name: string): T | undefined;
100
+ /**
101
+ * Gets the allowed expression contexts for the given function declaration by looking for `@@expressionContext` attribute.
102
+ * Returns an empty array if no such attribute is found or if the attribute value cannot be determined.
103
+ */
65
104
  declare function getFunctionExpressionContext(funcDecl: FunctionDecl): ExpressionContext[];
105
+ /**
106
+ * Gets the data field referenced by the given expression, if any. Returns `undefined` if the expression is not a reference to a data field.
107
+ */
66
108
  declare function getFieldReference(expr: Expression): DataField | undefined;
67
109
  declare function isCheckInvocation(node: AstNode): boolean;
110
+ /**
111
+ * Resolves the transitive imports of the given model and returns the list of imported models. The given model itself is not included in the result.
112
+ */
68
113
  declare function resolveTransitiveImports(documents: LangiumDocuments, model: Model): Model[];
114
+ /**
115
+ * Resolves the given import and returns the imported model. Returns `undefined`
116
+ * if the import cannot be resolved.
117
+ */
69
118
  declare function resolveImport(documents: LangiumDocuments, imp: ModelImport): Model | undefined;
119
+ /**
120
+ * Resolves the given import and returns the URI of the imported model.
121
+ * Returns `undefined` if the import cannot be resolved.
122
+ */
70
123
  declare function resolveImportUri(imp: ModelImport): URI | undefined;
71
124
  /**
72
125
  * Gets data models and type defs in the ZModel schema.
73
126
  */
74
127
  declare function getDataModelAndTypeDefs(model: Model, includeIgnored?: boolean): (DataModel | TypeDef)[];
128
+ /**
129
+ * Gets all declarations of the given model and its transitive imports.
130
+ */
75
131
  declare function getAllDeclarationsIncludingImports(documents: LangiumDocuments, model: Model): AbstractDeclaration[];
132
+ /**
133
+ * Gets the model used for auth context, by looking for a model with `@@auth` attribute or a model named `User`.
134
+ * Returns `undefined` if no such model is found.
135
+ */
76
136
  declare function getAuthDecl(decls: (DataModel | TypeDef)[]): DataModel | TypeDef | undefined;
77
137
  declare function isBeforeInvocation(node: AstNode): boolean;
138
+ /**
139
+ * Determines if the given AST node is a collection predicate.
140
+ */
78
141
  declare function isCollectionPredicate(node: AstNode): node is BinaryExpr;
142
+ /**
143
+ * Gets all data models and type defs from the given documents registry.
144
+ */
79
145
  declare function getAllLoadedDataModelsAndTypeDefs(langiumDocuments: LangiumDocuments): (DataModel | TypeDef)[];
146
+ /**
147
+ * Gets all data models from the given documents registry and the transitive imports of the given model.
148
+ */
80
149
  declare function getAllDataModelsIncludingImports(documents: LangiumDocuments, model: Model): DataModel[];
150
+ /**
151
+ * Gets all data models and type defs from the given documents registry and the transitive imports
152
+ * of the given model. If `fromModel` is not provided, returns all loaded data models and type defs.
153
+ */
81
154
  declare function getAllLoadedAndReachableDataModelsAndTypeDefs(langiumDocuments: LangiumDocuments, fromModel?: DataModel): (DataModel | TypeDef)[];
155
+ /**
156
+ * Gets the containing data model of the given AST node, if any.
157
+ * Returns `undefined` if the node is not contained in a data model.
158
+ */
82
159
  declare function getContainingDataModel(node: AstNode): DataModel | undefined;
160
+ /**
161
+ * Determines if the given AST node can contain members.
162
+ */
83
163
  declare function isMemberContainer(node: unknown): node is DataModel | TypeDef;
164
+ /**
165
+ * Gets all fields of a data model or type def, including inherited fields from base models and mixins.
166
+ */
84
167
  declare function getAllFields(decl: DataModel | TypeDef, includeIgnored?: boolean, seen?: Set<DataModel | TypeDef>): DataField[];
168
+ /**
169
+ * Gets all attributes of a data model or type def, including inherited attributes
170
+ * from base models and mixins.
171
+ */
85
172
  declare function getAllAttributes(decl: DataModel | TypeDef, seen?: Set<DataModel | TypeDef>): DataModelAttribute[];
86
173
  /**
87
174
  * Retrieve the document in which the given AST node is contained. A reference to the document is
@@ -90,10 +177,14 @@ declare function getAllAttributes(decl: DataModel | TypeDef, seen?: Set<DataMode
90
177
  * @throws an error if the node is not contained in a document.
91
178
  */
92
179
  declare function getDocument<T extends AstNode = AstNode>(node: AstNode): LangiumDocument<T>;
180
+ /**
181
+ * Gets the list of plugin documents from the given model.
182
+ */
93
183
  declare function getPluginDocuments(model: Model, schemaPath: string): string[];
94
184
  /**
95
185
  * Returns the root node of the given AST node by following the `$container` references.
96
186
  */
97
187
  declare function findRootNode(node: AstNode): AstNode;
98
-
99
- export { type AttributeTarget, findRootNode, findUpAst, getAllAttributes, getAllDataModelsIncludingImports, getAllDeclarationsIncludingImports, getAllFields, getAllLoadedAndReachableDataModelsAndTypeDefs, getAllLoadedDataModelsAndTypeDefs, getAttribute, getAttributeArg, getAttributeArgLiteral, getAuthDecl, getContainingDataModel, getDataModelAndTypeDefs, getDocument, getFieldReference, getFunctionExpressionContext, getLiteral, getLiteralArray, getModelIdFields, getModelUniqueFields, getObjectLiteral, getPluginDocuments, getRecursiveBases, getStringLiteral, getUniqueFields, hasAttribute, isAuthInvocation, isAuthOrAuthMemberAccess, isBeforeInvocation, isCheckInvocation, isCollectionPredicate, isComputedField, isDataFieldReference, isDelegateModel, isEnumFieldReference, isFromStdlib, isMemberContainer, isRelationshipField, mapBuiltinTypeToExpressionType, resolveImport, resolveImportUri, resolveTransitiveImports, resolved, typeAssignable };
188
+ //#endregion
189
+ export { AttributeTarget, findRootNode, findUpAst, getAllAttributes, getAllDataModelsIncludingImports, getAllDeclarationsIncludingImports, getAllFields, getAllLoadedAndReachableDataModelsAndTypeDefs, getAllLoadedDataModelsAndTypeDefs, getAttribute, getAttributeArg, getAttributeArgLiteral, getAuthDecl, getContainingDataModel, getDataModelAndTypeDefs, getDocument, getFieldReference, getFunctionExpressionContext, getLiteral, getLiteralArray, getModelIdFields, getModelUniqueFields, getObjectLiteral, getPluginDocuments, getRecursiveBases, getStringLiteral, getUniqueFields, hasAttribute, isAuthInvocation, isAuthOrAuthMemberAccess, isBeforeInvocation, isCheckInvocation, isCollectionPredicate, isComputedField, isDataFieldReference, isDelegateModel, isEnumFieldReference, isFromStdlib, isMemberContainer, isRelationshipField, mapBuiltinTypeToExpressionType, resolveImport, resolveImportUri, resolveTransitiveImports, resolved, typeAssignable };
190
+ //# sourceMappingURL=utils.d.mts.map
package/dist/utils.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { A as isBeforeInvocation, B as mapBuiltinTypeToExpressionType, C as getPluginDocuments, D as hasAttribute, E as getUniqueFields, F as isDelegateModel, G as typeAssignable, H as resolveImportUri, I as isEnumFieldReference, L as isFromStdlib, M as isCollectionPredicate, N as isComputedField, O as isAuthInvocation, P as isDataFieldReference, R as isMemberContainer, S as getObjectLiteral, T as getStringLiteral, U as resolveTransitiveImports, V as resolveImport, W as resolved, _ as getFunctionExpressionContext, a as getAllDeclarationsIncludingImports, b as getModelIdFields, c as getAllLoadedDataModelsAndTypeDefs, d as getAttributeArgLiteral, f as getAuthDecl, g as getFieldReference, h as getDocument, i as getAllDataModelsIncludingImports, j as isCheckInvocation, k as isAuthOrAuthMemberAccess, l as getAttribute, m as getDataModelAndTypeDefs, n as findUpAst, o as getAllFields, p as getContainingDataModel, r as getAllAttributes, s as getAllLoadedAndReachableDataModelsAndTypeDefs, t as findRootNode, u as getAttributeArg, v as getLiteral, w as getRecursiveBases, x as getModelUniqueFields, y as getLiteralArray, z as isRelationshipField } from "./utils-BB6L7ug2.mjs";
2
+ export { findRootNode, findUpAst, getAllAttributes, getAllDataModelsIncludingImports, getAllDeclarationsIncludingImports, getAllFields, getAllLoadedAndReachableDataModelsAndTypeDefs, getAllLoadedDataModelsAndTypeDefs, getAttribute, getAttributeArg, getAttributeArgLiteral, getAuthDecl, getContainingDataModel, getDataModelAndTypeDefs, getDocument, getFieldReference, getFunctionExpressionContext, getLiteral, getLiteralArray, getModelIdFields, getModelUniqueFields, getObjectLiteral, getPluginDocuments, getRecursiveBases, getStringLiteral, getUniqueFields, hasAttribute, isAuthInvocation, isAuthOrAuthMemberAccess, isBeforeInvocation, isCheckInvocation, isCollectionPredicate, isComputedField, isDataFieldReference, isDelegateModel, isEnumFieldReference, isFromStdlib, isMemberContainer, isRelationshipField, mapBuiltinTypeToExpressionType, resolveImport, resolveImportUri, resolveTransitiveImports, resolved, typeAssignable };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@zenstackhq/language",
3
3
  "displayName": "ZenStack Language Tooling",
4
4
  "description": "ZenStack ZModel language specification",
5
- "version": "3.5.6",
5
+ "version": "3.6.0",
6
6
  "type": "module",
7
7
  "author": {
8
8
  "name": "ZenStack Team",
@@ -21,8 +21,8 @@
21
21
  "exports": {
22
22
  ".": {
23
23
  "import": {
24
- "types": "./dist/index.d.ts",
25
- "default": "./dist/index.js"
24
+ "types": "./dist/index.d.mts",
25
+ "default": "./dist/index.mjs"
26
26
  },
27
27
  "require": {
28
28
  "types": "./dist/index.d.cts",
@@ -31,8 +31,8 @@
31
31
  },
32
32
  "./ast": {
33
33
  "import": {
34
- "types": "./dist/ast.d.ts",
35
- "default": "./dist/ast.js"
34
+ "types": "./dist/ast.d.mts",
35
+ "default": "./dist/ast.mjs"
36
36
  },
37
37
  "require": {
38
38
  "types": "./dist/ast.d.cts",
@@ -41,8 +41,8 @@
41
41
  },
42
42
  "./utils": {
43
43
  "import": {
44
- "types": "./dist/utils.d.ts",
45
- "default": "./dist/utils.js"
44
+ "types": "./dist/utils.d.mts",
45
+ "default": "./dist/utils.mjs"
46
46
  },
47
47
  "require": {
48
48
  "types": "./dist/utils.d.cts",
@@ -51,8 +51,8 @@
51
51
  },
52
52
  "./factory": {
53
53
  "import": {
54
- "types": "./dist/factory.d.ts",
55
- "default": "./dist/factory.js"
54
+ "types": "./dist/factory.d.mts",
55
+ "default": "./dist/factory.mjs"
56
56
  },
57
57
  "require": {
58
58
  "types": "./dist/factory.d.cts",
@@ -69,7 +69,7 @@
69
69
  "pluralize": "^8.0.0",
70
70
  "ts-pattern": "^5.7.1",
71
71
  "vscode-languageserver": "^9.0.1",
72
- "@zenstackhq/common-helpers": "3.5.6"
72
+ "@zenstackhq/common-helpers": "3.6.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/pluralize": "^0.0.33",
@@ -77,14 +77,15 @@
77
77
  "glob": "^11.1.0",
78
78
  "langium-cli": "3.5.0",
79
79
  "tmp": "^0.2.4",
80
- "@zenstackhq/typescript-config": "3.5.6",
81
- "@zenstackhq/vitest-config": "3.5.6",
82
- "@zenstackhq/eslint-config": "3.5.6"
80
+ "@zenstackhq/eslint-config": "3.6.0",
81
+ "@zenstackhq/typescript-config": "3.6.0",
82
+ "@zenstackhq/vitest-config": "3.6.0",
83
+ "@zenstackhq/tsdown-config": "3.6.0"
83
84
  },
84
85
  "funding": "https://github.com/sponsors/zenstackhq",
85
86
  "scripts": {
86
- "build": "pnpm langium:generate && tsc --noEmit && tsup-node",
87
- "watch": "tsup-node --watch",
87
+ "build": "pnpm langium:generate && tsx scripts/patch-generated-ast.ts && tsc --noEmit && tsdown",
88
+ "watch": "tsdown --watch",
88
89
  "lint": "eslint src --ext ts",
89
90
  "test": "vitest run",
90
91
  "langium:generate": "langium generate",