@zenstackhq/language 3.0.0-alpha.19 → 3.0.0-alpha.20

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/generated/ast.ts","../src/constants.ts","../src/module.ts","../src/generated/grammar.ts","../src/generated/module.ts","../src/validators/attribute-application-validator.ts","../src/utils.ts","../src/validators/attribute-validator.ts","../src/validators/datamodel-validator.ts","../src/validators/common.ts","../src/validators/datasource-validator.ts","../src/validators/enum-validator.ts","../src/validators/expression-validator.ts","../src/validators/function-decl-validator.ts","../src/validators/function-invocation-validator.ts","../src/validators/schema-validator.ts","../src/validators/typedef-validator.ts","../src/validator.ts","../src/zmodel-linker.ts","../src/zmodel-scope.ts","../src/zmodel-workspace-manager.ts"],"sourcesContent":["import { isAstNode, URI, type LangiumDocument, type LangiumDocuments, type Mutable } from 'langium';\nimport { NodeFileSystem } from 'langium/node';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isDataSource, type AstNode, type Model } from './ast';\nimport { STD_LIB_MODULE_NAME } from './constants';\nimport { createZModelLanguageServices } from './module';\nimport { getDataModelAndTypeDefs, getDocument, hasAttribute, resolveImport, resolveTransitiveImports } from './utils';\n\nexport function createZModelServices() {\n return createZModelLanguageServices(NodeFileSystem);\n}\n\nexport class DocumentLoadError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n\nexport async function loadDocument(\n fileName: string,\n pluginModelFiles: string[] = [],\n): Promise<\n { success: true; model: Model; warnings: string[] } | { success: false; errors: string[]; warnings: string[] }\n> {\n const { ZModelLanguage: services } = createZModelServices();\n const extensions = services.LanguageMetaData.fileExtensions;\n if (!extensions.includes(path.extname(fileName))) {\n return {\n success: false,\n errors: ['invalid schema file extension'],\n warnings: [],\n };\n }\n\n if (!fs.existsSync(fileName)) {\n return {\n success: false,\n errors: ['schema file does not exist'],\n warnings: [],\n };\n }\n\n // load standard library\n\n // isomorphic __dirname\n const _dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));\n const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(\n URI.file(path.resolve(path.join(_dirname, '../res', STD_LIB_MODULE_NAME))),\n );\n\n // load plugin model files\n const pluginDocs = await Promise.all(\n pluginModelFiles.map((file) =>\n services.shared.workspace.LangiumDocuments.getOrCreateDocument(URI.file(path.resolve(file))),\n ),\n );\n\n // load the document\n const langiumDocuments = services.shared.workspace.LangiumDocuments;\n const document = await langiumDocuments.getOrCreateDocument(URI.file(path.resolve(fileName)));\n\n // load imports\n const importedURIs = await loadImports(document, langiumDocuments);\n const importedDocuments: LangiumDocument[] = [];\n for (const uri of importedURIs) {\n importedDocuments.push(await langiumDocuments.getOrCreateDocument(uri));\n }\n\n // build the document together with standard library, plugin modules, and imported documents\n await services.shared.workspace.DocumentBuilder.build([stdLib, ...pluginDocs, document, ...importedDocuments], {\n validation: true,\n });\n\n const diagnostics = langiumDocuments.all\n .flatMap((doc) => (doc.diagnostics ?? []).map((diag) => ({ doc, diag })))\n .filter(({ diag }) => diag.severity === 1 || diag.severity === 2)\n .toArray();\n\n const errors: string[] = [];\n const warnings: string[] = [];\n\n if (diagnostics.length > 0) {\n for (const { doc, diag } of diagnostics) {\n const message = `${path.relative(process.cwd(), doc.uri.fsPath)}:${\n diag.range.start.line + 1\n }:${diag.range.start.character + 1} - ${diag.message}`;\n\n if (diag.severity === 1) {\n errors.push(message);\n } else {\n warnings.push(message);\n }\n }\n }\n\n if (errors.length > 0) {\n return {\n success: false,\n errors,\n warnings,\n };\n }\n\n const model = document.parseResult.value as Model;\n\n // merge all declarations into the main document\n const imported = mergeImportsDeclarations(langiumDocuments, model);\n\n // remove imported documents\n imported.forEach((model) => {\n langiumDocuments.deleteDocument(model.$document!.uri);\n services.shared.workspace.IndexManager.remove(model.$document!.uri);\n });\n\n // extra validation after merging imported declarations\n const additionalErrors = validationAfterImportMerge(model);\n if (additionalErrors.length > 0) {\n return {\n success: false,\n errors: additionalErrors,\n warnings,\n };\n }\n\n return {\n success: true,\n model: document.parseResult.value as Model,\n warnings,\n };\n}\n\nasync function loadImports(document: LangiumDocument, documents: LangiumDocuments, uris: Set<string> = new Set()) {\n const uriString = document.uri.toString();\n if (!uris.has(uriString)) {\n uris.add(uriString);\n const model = document.parseResult.value as Model;\n for (const imp of model.imports) {\n const importedModel = resolveImport(documents, imp);\n if (importedModel) {\n const importedDoc = getDocument(importedModel);\n await loadImports(importedDoc, documents, uris);\n }\n }\n }\n return Array.from(uris)\n .filter((x) => uriString != x)\n .map((e) => URI.parse(e));\n}\n\nfunction mergeImportsDeclarations(documents: LangiumDocuments, model: Model) {\n const importedModels = resolveTransitiveImports(documents, model);\n\n const importedDeclarations = importedModels.flatMap((m) => m.declarations);\n model.declarations.push(...importedDeclarations);\n\n // remove import directives\n model.imports = [];\n\n // fix $container, $containerIndex, and $containerProperty\n linkContentToContainer(model);\n\n return importedModels;\n}\n\nfunction linkContentToContainer(node: AstNode): void {\n for (const [name, value] of Object.entries(node)) {\n if (!name.startsWith('$')) {\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n if (isAstNode(item)) {\n (item as Mutable<AstNode>).$container = node;\n (item as Mutable<AstNode>).$containerProperty = name;\n (item as Mutable<AstNode>).$containerIndex = index;\n }\n });\n } else if (isAstNode(value)) {\n (value as Mutable<AstNode>).$container = node;\n (value as Mutable<AstNode>).$containerProperty = name;\n }\n }\n }\n}\n\nfunction validationAfterImportMerge(model: Model) {\n const errors: string[] = [];\n const dataSources = model.declarations.filter((d) => isDataSource(d));\n if (dataSources.length === 0) {\n errors.push('Validation error: schema must have a datasource declaration');\n } else {\n if (dataSources.length > 1) {\n errors.push('Validation error: multiple datasource declarations are not allowed');\n }\n }\n\n // at most one `@@auth` model\n const decls = getDataModelAndTypeDefs(model, true);\n const authDecls = decls.filter((d) => hasAttribute(d, '@@auth'));\n if (authDecls.length > 1) {\n errors.push('Validation error: Multiple `@@auth` declarations are not allowed');\n }\n return errors;\n}\n\nexport * from './module';\n","/******************************************************************************\n * This file was generated by langium-cli 3.5.0.\n * DO NOT EDIT MANUALLY!\n ******************************************************************************/\n\n/* eslint-disable */\nimport * as langium from 'langium';\n\nexport const ZModelTerminals = {\n WS: /\\s+/,\n INTERNAL_ATTRIBUTE_NAME: /@@@([_a-zA-Z][\\w_]*\\.)*[_a-zA-Z][\\w_]*/,\n MODEL_ATTRIBUTE_NAME: /@@([_a-zA-Z][\\w_]*\\.)*[_a-zA-Z][\\w_]*/,\n FIELD_ATTRIBUTE_NAME: /@([_a-zA-Z][\\w_]*\\.)*[_a-zA-Z][\\w_]*/,\n ID: /[_a-zA-Z][\\w_]*/,\n STRING: /\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'/,\n NUMBER: /[+-]?[0-9]+(\\.[0-9]+)?/,\n TRIPLE_SLASH_COMMENT: /\\/\\/\\/[^\\n\\r]*/,\n ML_COMMENT: /\\/\\*[\\s\\S]*?\\*\\//,\n SL_COMMENT: /\\/\\/[^\\n\\r]*/,\n};\n\nexport type ZModelTerminalNames = keyof typeof ZModelTerminals;\n\nexport type ZModelKeywordNames =\n | \"!\"\n | \"!=\"\n | \"&&\"\n | \"(\"\n | \")\"\n | \",\"\n | \".\"\n | \":\"\n | \";\"\n | \"<\"\n | \"<=\"\n | \"=\"\n | \"==\"\n | \">\"\n | \">=\"\n | \"?\"\n | \"Any\"\n | \"BigInt\"\n | \"Boolean\"\n | \"Bytes\"\n | \"ContextType\"\n | \"DateTime\"\n | \"Decimal\"\n | \"FieldReference\"\n | \"Float\"\n | \"Int\"\n | \"Json\"\n | \"Null\"\n | \"Object\"\n | \"String\"\n | \"TransitiveFieldReference\"\n | \"Unsupported\"\n | \"[\"\n | \"]\"\n | \"^\"\n | \"_\"\n | \"abstract\"\n | \"attribute\"\n | \"datasource\"\n | \"enum\"\n | \"extends\"\n | \"false\"\n | \"function\"\n | \"generator\"\n | \"import\"\n | \"in\"\n | \"model\"\n | \"mutation\"\n | \"null\"\n | \"plugin\"\n | \"procedure\"\n | \"this\"\n | \"true\"\n | \"type\"\n | \"view\"\n | \"with\"\n | \"{\"\n | \"||\"\n | \"}\";\n\nexport type ZModelTokenNames = ZModelTerminalNames | ZModelKeywordNames;\n\nexport type AbstractDeclaration = Attribute | DataModel | DataSource | Enum | FunctionDecl | GeneratorDecl | Plugin | Procedure | TypeDef;\n\nexport const AbstractDeclaration = 'AbstractDeclaration';\n\nexport function isAbstractDeclaration(item: unknown): item is AbstractDeclaration {\n return reflection.isInstance(item, AbstractDeclaration);\n}\n\nexport type Boolean = boolean;\n\nexport function isBoolean(item: unknown): item is Boolean {\n return typeof item === 'boolean';\n}\n\nexport type BuiltinType = 'BigInt' | 'Boolean' | 'Bytes' | 'DateTime' | 'Decimal' | 'Float' | 'Int' | 'Json' | 'String';\n\nexport function isBuiltinType(item: unknown): item is BuiltinType {\n return item === 'String' || item === 'Boolean' || item === 'Int' || item === 'BigInt' || item === 'Float' || item === 'Decimal' || item === 'DateTime' || item === 'Json' || item === 'Bytes';\n}\n\nexport type ConfigExpr = ConfigArrayExpr | InvocationExpr | LiteralExpr;\n\nexport const ConfigExpr = 'ConfigExpr';\n\nexport function isConfigExpr(item: unknown): item is ConfigExpr {\n return reflection.isInstance(item, ConfigExpr);\n}\n\nexport type Expression = ArrayExpr | BinaryExpr | InvocationExpr | LiteralExpr | MemberAccessExpr | NullExpr | ObjectExpr | ReferenceExpr | ThisExpr | UnaryExpr;\n\nexport const Expression = 'Expression';\n\nexport function isExpression(item: unknown): item is Expression {\n return reflection.isInstance(item, Expression);\n}\n\nexport type ExpressionType = 'Any' | 'Boolean' | 'DateTime' | 'Float' | 'Int' | 'Null' | 'Object' | 'String' | 'Unsupported';\n\nexport function isExpressionType(item: unknown): item is ExpressionType {\n return item === 'String' || item === 'Int' || item === 'Float' || item === 'Boolean' || item === 'DateTime' || item === 'Null' || item === 'Object' || item === 'Any' || item === 'Unsupported';\n}\n\nexport type LiteralExpr = BooleanLiteral | NumberLiteral | StringLiteral;\n\nexport const LiteralExpr = 'LiteralExpr';\n\nexport function isLiteralExpr(item: unknown): item is LiteralExpr {\n return reflection.isInstance(item, LiteralExpr);\n}\n\nexport type MemberAccessTarget = DataField;\n\nexport const MemberAccessTarget = 'MemberAccessTarget';\n\nexport function isMemberAccessTarget(item: unknown): item is MemberAccessTarget {\n return reflection.isInstance(item, MemberAccessTarget);\n}\n\nexport type ReferenceTarget = DataField | EnumField | FunctionParam;\n\nexport const ReferenceTarget = 'ReferenceTarget';\n\nexport function isReferenceTarget(item: unknown): item is ReferenceTarget {\n return reflection.isInstance(item, ReferenceTarget);\n}\n\nexport type RegularID = 'abstract' | 'attribute' | 'datasource' | 'enum' | 'import' | 'in' | 'model' | 'plugin' | 'type' | 'view' | string;\n\nexport function isRegularID(item: unknown): item is RegularID {\n return item === 'model' || item === 'enum' || item === 'attribute' || item === 'datasource' || item === 'plugin' || item === 'abstract' || item === 'in' || item === 'view' || item === 'import' || item === 'type' || (typeof item === 'string' && (/[_a-zA-Z][\\w_]*/.test(item)));\n}\n\nexport type RegularIDWithTypeNames = 'Any' | 'BigInt' | 'Boolean' | 'Bytes' | 'DateTime' | 'Decimal' | 'Float' | 'Int' | 'Json' | 'Null' | 'Object' | 'String' | 'Unsupported' | RegularID;\n\nexport function isRegularIDWithTypeNames(item: unknown): item is RegularIDWithTypeNames {\n return isRegularID(item) || item === 'String' || item === 'Boolean' || item === 'Int' || item === 'BigInt' || item === 'Float' || item === 'Decimal' || item === 'DateTime' || item === 'Json' || item === 'Bytes' || item === 'Null' || item === 'Object' || item === 'Any' || item === 'Unsupported';\n}\n\nexport type TypeDeclaration = DataModel | Enum | TypeDef;\n\nexport const TypeDeclaration = 'TypeDeclaration';\n\nexport function isTypeDeclaration(item: unknown): item is TypeDeclaration {\n return reflection.isInstance(item, TypeDeclaration);\n}\n\nexport interface Argument extends langium.AstNode {\n readonly $container: InvocationExpr;\n readonly $type: 'Argument';\n value: Expression;\n}\n\nexport const Argument = 'Argument';\n\nexport function isArgument(item: unknown): item is Argument {\n return reflection.isInstance(item, Argument);\n}\n\nexport interface ArrayExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr;\n readonly $type: 'ArrayExpr';\n items: Array<Expression>;\n}\n\nexport const ArrayExpr = 'ArrayExpr';\n\nexport function isArrayExpr(item: unknown): item is ArrayExpr {\n return reflection.isInstance(item, ArrayExpr);\n}\n\nexport interface Attribute extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'Attribute';\n attributes: Array<InternalAttribute>;\n comments: Array<string>;\n name: string;\n params: Array<AttributeParam>;\n}\n\nexport const Attribute = 'Attribute';\n\nexport function isAttribute(item: unknown): item is Attribute {\n return reflection.isInstance(item, Attribute);\n}\n\nexport interface AttributeArg extends langium.AstNode {\n readonly $container: DataFieldAttribute | DataModelAttribute | InternalAttribute;\n readonly $type: 'AttributeArg';\n name?: RegularID;\n value: Expression;\n}\n\nexport const AttributeArg = 'AttributeArg';\n\nexport function isAttributeArg(item: unknown): item is AttributeArg {\n return reflection.isInstance(item, AttributeArg);\n}\n\nexport interface AttributeParam extends langium.AstNode {\n readonly $container: Attribute;\n readonly $type: 'AttributeParam';\n attributes: Array<InternalAttribute>;\n comments: Array<string>;\n default: boolean;\n name: RegularID;\n type: AttributeParamType;\n}\n\nexport const AttributeParam = 'AttributeParam';\n\nexport function isAttributeParam(item: unknown): item is AttributeParam {\n return reflection.isInstance(item, AttributeParam);\n}\n\nexport interface AttributeParamType extends langium.AstNode {\n readonly $container: AttributeParam;\n readonly $type: 'AttributeParamType';\n array: boolean;\n optional: boolean;\n reference?: langium.Reference<TypeDeclaration>;\n type?: 'ContextType' | 'FieldReference' | 'TransitiveFieldReference' | ExpressionType;\n}\n\nexport const AttributeParamType = 'AttributeParamType';\n\nexport function isAttributeParamType(item: unknown): item is AttributeParamType {\n return reflection.isInstance(item, AttributeParamType);\n}\n\nexport interface BinaryExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'BinaryExpr';\n left: Expression;\n operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | 'in' | '||';\n right: Expression;\n}\n\nexport const BinaryExpr = 'BinaryExpr';\n\nexport function isBinaryExpr(item: unknown): item is BinaryExpr {\n return reflection.isInstance(item, BinaryExpr);\n}\n\nexport interface BooleanLiteral extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;\n readonly $type: 'BooleanLiteral';\n value: Boolean;\n}\n\nexport const BooleanLiteral = 'BooleanLiteral';\n\nexport function isBooleanLiteral(item: unknown): item is BooleanLiteral {\n return reflection.isInstance(item, BooleanLiteral);\n}\n\nexport interface ConfigArrayExpr extends langium.AstNode {\n readonly $container: ConfigField;\n readonly $type: 'ConfigArrayExpr';\n items: Array<ConfigInvocationExpr | LiteralExpr>;\n}\n\nexport const ConfigArrayExpr = 'ConfigArrayExpr';\n\nexport function isConfigArrayExpr(item: unknown): item is ConfigArrayExpr {\n return reflection.isInstance(item, ConfigArrayExpr);\n}\n\nexport interface ConfigField extends langium.AstNode {\n readonly $container: DataSource | GeneratorDecl;\n readonly $type: 'ConfigField';\n name: RegularID;\n value: ConfigExpr;\n}\n\nexport const ConfigField = 'ConfigField';\n\nexport function isConfigField(item: unknown): item is ConfigField {\n return reflection.isInstance(item, ConfigField);\n}\n\nexport interface ConfigInvocationArg extends langium.AstNode {\n readonly $container: ConfigInvocationExpr;\n readonly $type: 'ConfigInvocationArg';\n name: string;\n value: LiteralExpr;\n}\n\nexport const ConfigInvocationArg = 'ConfigInvocationArg';\n\nexport function isConfigInvocationArg(item: unknown): item is ConfigInvocationArg {\n return reflection.isInstance(item, ConfigInvocationArg);\n}\n\nexport interface ConfigInvocationExpr extends langium.AstNode {\n readonly $container: ConfigArrayExpr;\n readonly $type: 'ConfigInvocationExpr';\n args: Array<ConfigInvocationArg>;\n name: string;\n}\n\nexport const ConfigInvocationExpr = 'ConfigInvocationExpr';\n\nexport function isConfigInvocationExpr(item: unknown): item is ConfigInvocationExpr {\n return reflection.isInstance(item, ConfigInvocationExpr);\n}\n\nexport interface DataField extends langium.AstNode {\n readonly $container: DataModel | TypeDef;\n readonly $type: 'DataField';\n attributes: Array<DataFieldAttribute>;\n comments: Array<string>;\n name: RegularIDWithTypeNames;\n type: DataFieldType;\n}\n\nexport const DataField = 'DataField';\n\nexport function isDataField(item: unknown): item is DataField {\n return reflection.isInstance(item, DataField);\n}\n\nexport interface DataFieldAttribute extends langium.AstNode {\n readonly $container: DataField | EnumField;\n readonly $type: 'DataFieldAttribute';\n args: Array<AttributeArg>;\n decl: langium.Reference<Attribute>;\n}\n\nexport const DataFieldAttribute = 'DataFieldAttribute';\n\nexport function isDataFieldAttribute(item: unknown): item is DataFieldAttribute {\n return reflection.isInstance(item, DataFieldAttribute);\n}\n\nexport interface DataFieldType extends langium.AstNode {\n readonly $container: DataField;\n readonly $type: 'DataFieldType';\n array: boolean;\n optional: boolean;\n reference?: langium.Reference<TypeDeclaration>;\n type?: BuiltinType;\n unsupported?: UnsupportedFieldType;\n}\n\nexport const DataFieldType = 'DataFieldType';\n\nexport function isDataFieldType(item: unknown): item is DataFieldType {\n return reflection.isInstance(item, DataFieldType);\n}\n\nexport interface DataModel extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'DataModel';\n attributes: Array<DataModelAttribute>;\n baseModel?: langium.Reference<DataModel>;\n comments: Array<string>;\n fields: Array<DataField>;\n isView: boolean;\n mixins: Array<langium.Reference<TypeDef>>;\n name: RegularID;\n}\n\nexport const DataModel = 'DataModel';\n\nexport function isDataModel(item: unknown): item is DataModel {\n return reflection.isInstance(item, DataModel);\n}\n\nexport interface DataModelAttribute extends langium.AstNode {\n readonly $container: DataModel | Enum | TypeDef;\n readonly $type: 'DataModelAttribute';\n args: Array<AttributeArg>;\n decl: langium.Reference<Attribute>;\n}\n\nexport const DataModelAttribute = 'DataModelAttribute';\n\nexport function isDataModelAttribute(item: unknown): item is DataModelAttribute {\n return reflection.isInstance(item, DataModelAttribute);\n}\n\nexport interface DataSource extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'DataSource';\n fields: Array<ConfigField>;\n name: RegularID;\n}\n\nexport const DataSource = 'DataSource';\n\nexport function isDataSource(item: unknown): item is DataSource {\n return reflection.isInstance(item, DataSource);\n}\n\nexport interface Enum extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'Enum';\n attributes: Array<DataModelAttribute>;\n comments: Array<string>;\n fields: Array<EnumField>;\n name: RegularID;\n}\n\nexport const Enum = 'Enum';\n\nexport function isEnum(item: unknown): item is Enum {\n return reflection.isInstance(item, Enum);\n}\n\nexport interface EnumField extends langium.AstNode {\n readonly $container: Enum;\n readonly $type: 'EnumField';\n attributes: Array<DataFieldAttribute>;\n comments: Array<string>;\n name: RegularIDWithTypeNames;\n}\n\nexport const EnumField = 'EnumField';\n\nexport function isEnumField(item: unknown): item is EnumField {\n return reflection.isInstance(item, EnumField);\n}\n\nexport interface FieldInitializer extends langium.AstNode {\n readonly $container: ObjectExpr;\n readonly $type: 'FieldInitializer';\n name: RegularID | string;\n value: Expression;\n}\n\nexport const FieldInitializer = 'FieldInitializer';\n\nexport function isFieldInitializer(item: unknown): item is FieldInitializer {\n return reflection.isInstance(item, FieldInitializer);\n}\n\nexport interface FunctionDecl extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'FunctionDecl';\n attributes: Array<InternalAttribute>;\n expression?: Expression;\n name: RegularID;\n params: Array<FunctionParam>;\n returnType: FunctionParamType;\n}\n\nexport const FunctionDecl = 'FunctionDecl';\n\nexport function isFunctionDecl(item: unknown): item is FunctionDecl {\n return reflection.isInstance(item, FunctionDecl);\n}\n\nexport interface FunctionParam extends langium.AstNode {\n readonly $container: FunctionDecl | Procedure;\n readonly $type: 'FunctionParam';\n name: RegularID;\n optional: boolean;\n type: FunctionParamType;\n}\n\nexport const FunctionParam = 'FunctionParam';\n\nexport function isFunctionParam(item: unknown): item is FunctionParam {\n return reflection.isInstance(item, FunctionParam);\n}\n\nexport interface FunctionParamType extends langium.AstNode {\n readonly $container: FunctionDecl | FunctionParam | Procedure | ProcedureParam;\n readonly $type: 'FunctionParamType';\n array: boolean;\n reference?: langium.Reference<TypeDeclaration>;\n type?: ExpressionType;\n}\n\nexport const FunctionParamType = 'FunctionParamType';\n\nexport function isFunctionParamType(item: unknown): item is FunctionParamType {\n return reflection.isInstance(item, FunctionParamType);\n}\n\nexport interface GeneratorDecl extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'GeneratorDecl';\n fields: Array<ConfigField>;\n name: RegularID;\n}\n\nexport const GeneratorDecl = 'GeneratorDecl';\n\nexport function isGeneratorDecl(item: unknown): item is GeneratorDecl {\n return reflection.isInstance(item, GeneratorDecl);\n}\n\nexport interface InternalAttribute extends langium.AstNode {\n readonly $container: Attribute | AttributeParam | FunctionDecl | Procedure;\n readonly $type: 'InternalAttribute';\n args: Array<AttributeArg>;\n decl: langium.Reference<Attribute>;\n}\n\nexport const InternalAttribute = 'InternalAttribute';\n\nexport function isInternalAttribute(item: unknown): item is InternalAttribute {\n return reflection.isInstance(item, InternalAttribute);\n}\n\nexport interface InvocationExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigField | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'InvocationExpr';\n args: Array<Argument>;\n function: langium.Reference<FunctionDecl>;\n}\n\nexport const InvocationExpr = 'InvocationExpr';\n\nexport function isInvocationExpr(item: unknown): item is InvocationExpr {\n return reflection.isInstance(item, InvocationExpr);\n}\n\nexport interface MemberAccessExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'MemberAccessExpr';\n member: langium.Reference<MemberAccessTarget>;\n operand: Expression;\n}\n\nexport const MemberAccessExpr = 'MemberAccessExpr';\n\nexport function isMemberAccessExpr(item: unknown): item is MemberAccessExpr {\n return reflection.isInstance(item, MemberAccessExpr);\n}\n\nexport interface Model extends langium.AstNode {\n readonly $type: 'Model';\n declarations: Array<AbstractDeclaration>;\n imports: Array<ModelImport>;\n}\n\nexport const Model = 'Model';\n\nexport function isModel(item: unknown): item is Model {\n return reflection.isInstance(item, Model);\n}\n\nexport interface ModelImport extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'ModelImport';\n path: string;\n}\n\nexport const ModelImport = 'ModelImport';\n\nexport function isModelImport(item: unknown): item is ModelImport {\n return reflection.isInstance(item, ModelImport);\n}\n\nexport interface NullExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'NullExpr';\n value: 'null';\n}\n\nexport const NullExpr = 'NullExpr';\n\nexport function isNullExpr(item: unknown): item is NullExpr {\n return reflection.isInstance(item, NullExpr);\n}\n\nexport interface NumberLiteral extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;\n readonly $type: 'NumberLiteral';\n value: string;\n}\n\nexport const NumberLiteral = 'NumberLiteral';\n\nexport function isNumberLiteral(item: unknown): item is NumberLiteral {\n return reflection.isInstance(item, NumberLiteral);\n}\n\nexport interface ObjectExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr;\n readonly $type: 'ObjectExpr';\n fields: Array<FieldInitializer>;\n}\n\nexport const ObjectExpr = 'ObjectExpr';\n\nexport function isObjectExpr(item: unknown): item is ObjectExpr {\n return reflection.isInstance(item, ObjectExpr);\n}\n\nexport interface Plugin extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'Plugin';\n fields: Array<PluginField>;\n name: RegularID;\n}\n\nexport const Plugin = 'Plugin';\n\nexport function isPlugin(item: unknown): item is Plugin {\n return reflection.isInstance(item, Plugin);\n}\n\nexport interface PluginField extends langium.AstNode {\n readonly $container: Plugin;\n readonly $type: 'PluginField';\n name: RegularID;\n value: ArrayExpr | LiteralExpr | ObjectExpr;\n}\n\nexport const PluginField = 'PluginField';\n\nexport function isPluginField(item: unknown): item is PluginField {\n return reflection.isInstance(item, PluginField);\n}\n\nexport interface Procedure extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'Procedure';\n attributes: Array<InternalAttribute>;\n mutation: boolean;\n name: RegularID;\n params: Array<FunctionParam | ProcedureParam>;\n returnType: FunctionParamType;\n}\n\nexport const Procedure = 'Procedure';\n\nexport function isProcedure(item: unknown): item is Procedure {\n return reflection.isInstance(item, Procedure);\n}\n\nexport interface ProcedureParam extends langium.AstNode {\n readonly $container: Procedure;\n readonly $type: 'ProcedureParam';\n name: RegularID;\n optional: boolean;\n type: FunctionParamType;\n}\n\nexport const ProcedureParam = 'ProcedureParam';\n\nexport function isProcedureParam(item: unknown): item is ProcedureParam {\n return reflection.isInstance(item, ProcedureParam);\n}\n\nexport interface ReferenceArg extends langium.AstNode {\n readonly $container: ReferenceExpr;\n readonly $type: 'ReferenceArg';\n name: string;\n value: Expression;\n}\n\nexport const ReferenceArg = 'ReferenceArg';\n\nexport function isReferenceArg(item: unknown): item is ReferenceArg {\n return reflection.isInstance(item, ReferenceArg);\n}\n\nexport interface ReferenceExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'ReferenceExpr';\n args: Array<ReferenceArg>;\n target: langium.Reference<ReferenceTarget>;\n}\n\nexport const ReferenceExpr = 'ReferenceExpr';\n\nexport function isReferenceExpr(item: unknown): item is ReferenceExpr {\n return reflection.isInstance(item, ReferenceExpr);\n}\n\nexport interface StringLiteral extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;\n readonly $type: 'StringLiteral';\n value: string;\n}\n\nexport const StringLiteral = 'StringLiteral';\n\nexport function isStringLiteral(item: unknown): item is StringLiteral {\n return reflection.isInstance(item, StringLiteral);\n}\n\nexport interface ThisExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'ThisExpr';\n value: 'this';\n}\n\nexport const ThisExpr = 'ThisExpr';\n\nexport function isThisExpr(item: unknown): item is ThisExpr {\n return reflection.isInstance(item, ThisExpr);\n}\n\nexport interface TypeDef extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'TypeDef';\n attributes: Array<DataModelAttribute>;\n comments: Array<string>;\n fields: Array<DataField>;\n mixins: Array<langium.Reference<TypeDef>>;\n name: RegularID;\n}\n\nexport const TypeDef = 'TypeDef';\n\nexport function isTypeDef(item: unknown): item is TypeDef {\n return reflection.isInstance(item, TypeDef);\n}\n\nexport interface UnaryExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'UnaryExpr';\n operand: Expression;\n operator: '!';\n}\n\nexport const UnaryExpr = 'UnaryExpr';\n\nexport function isUnaryExpr(item: unknown): item is UnaryExpr {\n return reflection.isInstance(item, UnaryExpr);\n}\n\nexport interface UnsupportedFieldType extends langium.AstNode {\n readonly $container: DataFieldType;\n readonly $type: 'UnsupportedFieldType';\n value: LiteralExpr;\n}\n\nexport const UnsupportedFieldType = 'UnsupportedFieldType';\n\nexport function isUnsupportedFieldType(item: unknown): item is UnsupportedFieldType {\n return reflection.isInstance(item, UnsupportedFieldType);\n}\n\nexport type ZModelAstType = {\n AbstractDeclaration: AbstractDeclaration\n Argument: Argument\n ArrayExpr: ArrayExpr\n Attribute: Attribute\n AttributeArg: AttributeArg\n AttributeParam: AttributeParam\n AttributeParamType: AttributeParamType\n BinaryExpr: BinaryExpr\n BooleanLiteral: BooleanLiteral\n ConfigArrayExpr: ConfigArrayExpr\n ConfigExpr: ConfigExpr\n ConfigField: ConfigField\n ConfigInvocationArg: ConfigInvocationArg\n ConfigInvocationExpr: ConfigInvocationExpr\n DataField: DataField\n DataFieldAttribute: DataFieldAttribute\n DataFieldType: DataFieldType\n DataModel: DataModel\n DataModelAttribute: DataModelAttribute\n DataSource: DataSource\n Enum: Enum\n EnumField: EnumField\n Expression: Expression\n FieldInitializer: FieldInitializer\n FunctionDecl: FunctionDecl\n FunctionParam: FunctionParam\n FunctionParamType: FunctionParamType\n GeneratorDecl: GeneratorDecl\n InternalAttribute: InternalAttribute\n InvocationExpr: InvocationExpr\n LiteralExpr: LiteralExpr\n MemberAccessExpr: MemberAccessExpr\n MemberAccessTarget: MemberAccessTarget\n Model: Model\n ModelImport: ModelImport\n NullExpr: NullExpr\n NumberLiteral: NumberLiteral\n ObjectExpr: ObjectExpr\n Plugin: Plugin\n PluginField: PluginField\n Procedure: Procedure\n ProcedureParam: ProcedureParam\n ReferenceArg: ReferenceArg\n ReferenceExpr: ReferenceExpr\n ReferenceTarget: ReferenceTarget\n StringLiteral: StringLiteral\n ThisExpr: ThisExpr\n TypeDeclaration: TypeDeclaration\n TypeDef: TypeDef\n UnaryExpr: UnaryExpr\n UnsupportedFieldType: UnsupportedFieldType\n}\n\nexport class ZModelAstReflection extends langium.AbstractAstReflection {\n\n getAllTypes(): string[] {\n return [AbstractDeclaration, Argument, ArrayExpr, Attribute, AttributeArg, AttributeParam, AttributeParamType, BinaryExpr, BooleanLiteral, ConfigArrayExpr, ConfigExpr, ConfigField, ConfigInvocationArg, ConfigInvocationExpr, DataField, DataFieldAttribute, DataFieldType, DataModel, DataModelAttribute, DataSource, Enum, EnumField, Expression, FieldInitializer, FunctionDecl, FunctionParam, FunctionParamType, GeneratorDecl, InternalAttribute, InvocationExpr, LiteralExpr, MemberAccessExpr, MemberAccessTarget, Model, ModelImport, NullExpr, NumberLiteral, ObjectExpr, Plugin, PluginField, Procedure, ProcedureParam, ReferenceArg, ReferenceExpr, ReferenceTarget, StringLiteral, ThisExpr, TypeDeclaration, TypeDef, UnaryExpr, UnsupportedFieldType];\n }\n\n protected override computeIsSubtype(subtype: string, supertype: string): boolean {\n switch (subtype) {\n case ArrayExpr:\n case BinaryExpr:\n case MemberAccessExpr:\n case NullExpr:\n case ObjectExpr:\n case ReferenceExpr:\n case ThisExpr:\n case UnaryExpr: {\n return this.isSubtype(Expression, supertype);\n }\n case Attribute:\n case DataSource:\n case FunctionDecl:\n case GeneratorDecl:\n case Plugin:\n case Procedure: {\n return this.isSubtype(AbstractDeclaration, supertype);\n }\n case BooleanLiteral:\n case NumberLiteral:\n case StringLiteral: {\n return this.isSubtype(LiteralExpr, supertype);\n }\n case ConfigArrayExpr: {\n return this.isSubtype(ConfigExpr, supertype);\n }\n case DataField: {\n return this.isSubtype(MemberAccessTarget, supertype) || this.isSubtype(ReferenceTarget, supertype);\n }\n case DataModel:\n case Enum:\n case TypeDef: {\n return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype);\n }\n case EnumField:\n case FunctionParam: {\n return this.isSubtype(ReferenceTarget, supertype);\n }\n case InvocationExpr:\n case LiteralExpr: {\n return this.isSubtype(ConfigExpr, supertype) || this.isSubtype(Expression, supertype);\n }\n default: {\n return false;\n }\n }\n }\n\n getReferenceType(refInfo: langium.ReferenceInfo): string {\n const referenceId = `${refInfo.container.$type}:${refInfo.property}`;\n switch (referenceId) {\n case 'AttributeParamType:reference':\n case 'DataFieldType:reference':\n case 'FunctionParamType:reference': {\n return TypeDeclaration;\n }\n case 'DataFieldAttribute:decl':\n case 'DataModelAttribute:decl':\n case 'InternalAttribute:decl': {\n return Attribute;\n }\n case 'DataModel:baseModel': {\n return DataModel;\n }\n case 'DataModel:mixins':\n case 'TypeDef:mixins': {\n return TypeDef;\n }\n case 'InvocationExpr:function': {\n return FunctionDecl;\n }\n case 'MemberAccessExpr:member': {\n return MemberAccessTarget;\n }\n case 'ReferenceExpr:target': {\n return ReferenceTarget;\n }\n default: {\n throw new Error(`${referenceId} is not a valid reference id.`);\n }\n }\n }\n\n getTypeMetaData(type: string): langium.TypeMetaData {\n switch (type) {\n case Argument: {\n return {\n name: Argument,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case ArrayExpr: {\n return {\n name: ArrayExpr,\n properties: [\n { name: 'items', defaultValue: [] }\n ]\n };\n }\n case Attribute: {\n return {\n name: Attribute,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'name' },\n { name: 'params', defaultValue: [] }\n ]\n };\n }\n case AttributeArg: {\n return {\n name: AttributeArg,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case AttributeParam: {\n return {\n name: AttributeParam,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'default', defaultValue: false },\n { name: 'name' },\n { name: 'type' }\n ]\n };\n }\n case AttributeParamType: {\n return {\n name: AttributeParamType,\n properties: [\n { name: 'array', defaultValue: false },\n { name: 'optional', defaultValue: false },\n { name: 'reference' },\n { name: 'type' }\n ]\n };\n }\n case BinaryExpr: {\n return {\n name: BinaryExpr,\n properties: [\n { name: 'left' },\n { name: 'operator' },\n { name: 'right' }\n ]\n };\n }\n case BooleanLiteral: {\n return {\n name: BooleanLiteral,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case ConfigArrayExpr: {\n return {\n name: ConfigArrayExpr,\n properties: [\n { name: 'items', defaultValue: [] }\n ]\n };\n }\n case ConfigField: {\n return {\n name: ConfigField,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case ConfigInvocationArg: {\n return {\n name: ConfigInvocationArg,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case ConfigInvocationExpr: {\n return {\n name: ConfigInvocationExpr,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case DataField: {\n return {\n name: DataField,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'name' },\n { name: 'type' }\n ]\n };\n }\n case DataFieldAttribute: {\n return {\n name: DataFieldAttribute,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'decl' }\n ]\n };\n }\n case DataFieldType: {\n return {\n name: DataFieldType,\n properties: [\n { name: 'array', defaultValue: false },\n { name: 'optional', defaultValue: false },\n { name: 'reference' },\n { name: 'type' },\n { name: 'unsupported' }\n ]\n };\n }\n case DataModel: {\n return {\n name: DataModel,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'baseModel' },\n { name: 'comments', defaultValue: [] },\n { name: 'fields', defaultValue: [] },\n { name: 'isView', defaultValue: false },\n { name: 'mixins', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case DataModelAttribute: {\n return {\n name: DataModelAttribute,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'decl' }\n ]\n };\n }\n case DataSource: {\n return {\n name: DataSource,\n properties: [\n { name: 'fields', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case Enum: {\n return {\n name: Enum,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'fields', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case EnumField: {\n return {\n name: EnumField,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case FieldInitializer: {\n return {\n name: FieldInitializer,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case FunctionDecl: {\n return {\n name: FunctionDecl,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'expression' },\n { name: 'name' },\n { name: 'params', defaultValue: [] },\n { name: 'returnType' }\n ]\n };\n }\n case FunctionParam: {\n return {\n name: FunctionParam,\n properties: [\n { name: 'name' },\n { name: 'optional', defaultValue: false },\n { name: 'type' }\n ]\n };\n }\n case FunctionParamType: {\n return {\n name: FunctionParamType,\n properties: [\n { name: 'array', defaultValue: false },\n { name: 'reference' },\n { name: 'type' }\n ]\n };\n }\n case GeneratorDecl: {\n return {\n name: GeneratorDecl,\n properties: [\n { name: 'fields', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case InternalAttribute: {\n return {\n name: InternalAttribute,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'decl' }\n ]\n };\n }\n case InvocationExpr: {\n return {\n name: InvocationExpr,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'function' }\n ]\n };\n }\n case MemberAccessExpr: {\n return {\n name: MemberAccessExpr,\n properties: [\n { name: 'member' },\n { name: 'operand' }\n ]\n };\n }\n case Model: {\n return {\n name: Model,\n properties: [\n { name: 'declarations', defaultValue: [] },\n { name: 'imports', defaultValue: [] }\n ]\n };\n }\n case ModelImport: {\n return {\n name: ModelImport,\n properties: [\n { name: 'path' }\n ]\n };\n }\n case NullExpr: {\n return {\n name: NullExpr,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case NumberLiteral: {\n return {\n name: NumberLiteral,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case ObjectExpr: {\n return {\n name: ObjectExpr,\n properties: [\n { name: 'fields', defaultValue: [] }\n ]\n };\n }\n case Plugin: {\n return {\n name: Plugin,\n properties: [\n { name: 'fields', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case PluginField: {\n return {\n name: PluginField,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case Procedure: {\n return {\n name: Procedure,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'mutation', defaultValue: false },\n { name: 'name' },\n { name: 'params', defaultValue: [] },\n { name: 'returnType' }\n ]\n };\n }\n case ProcedureParam: {\n return {\n name: ProcedureParam,\n properties: [\n { name: 'name' },\n { name: 'optional', defaultValue: false },\n { name: 'type' }\n ]\n };\n }\n case ReferenceArg: {\n return {\n name: ReferenceArg,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case ReferenceExpr: {\n return {\n name: ReferenceExpr,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'target' }\n ]\n };\n }\n case StringLiteral: {\n return {\n name: StringLiteral,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case ThisExpr: {\n return {\n name: ThisExpr,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case TypeDef: {\n return {\n name: TypeDef,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'fields', defaultValue: [] },\n { name: 'mixins', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case UnaryExpr: {\n return {\n name: UnaryExpr,\n properties: [\n { name: 'operand' },\n { name: 'operator' }\n ]\n };\n }\n case UnsupportedFieldType: {\n return {\n name: UnsupportedFieldType,\n properties: [\n { name: 'value' }\n ]\n };\n }\n default: {\n return {\n name: type,\n properties: []\n };\n }\n }\n }\n}\n\nexport const reflection = new ZModelAstReflection();\n","/**\n * Supported Prisma db providers\n */\nexport const SUPPORTED_PROVIDERS = [\n 'sqlite',\n 'postgresql',\n // TODO: other providers\n // 'mysql',\n // 'sqlserver',\n // 'cockroachdb',\n];\n\n/**\n * All scalar types\n */\nexport const SCALAR_TYPES = ['String', 'Int', 'Float', 'Decimal', 'BigInt', 'Boolean', 'Bytes', 'DateTime'];\n\n/**\n * Name of standard library module\n */\nexport const STD_LIB_MODULE_NAME = 'stdlib.zmodel';\n\n/**\n * Name of module contributed by plugins\n */\nexport const PLUGIN_MODULE_NAME = 'plugin.zmodel';\n\n/**\n * Validation issues\n */\nexport enum IssueCodes {\n MissingOppositeRelation = 'miss-opposite-relation',\n}\n\n/**\n * Expression context\n */\nexport enum ExpressionContext {\n DefaultValue = 'DefaultValue',\n AccessPolicy = 'AccessPolicy',\n ValidationRule = 'ValidationRule',\n Index = 'Index',\n}\n","import { inject, type DeepPartial, type Module } from 'langium';\nimport {\n createDefaultModule,\n createDefaultSharedModule,\n type DefaultSharedModuleContext,\n type LangiumServices,\n type LangiumSharedServices,\n type PartialLangiumServices,\n} from 'langium/lsp';\nimport { ZModelGeneratedModule, ZModelGeneratedSharedModule, ZModelLanguageMetaData } from './generated/module';\nimport { ZModelValidator, registerValidationChecks } from './validator';\nimport { ZModelLinker } from './zmodel-linker';\nimport { ZModelScopeComputation, ZModelScopeProvider } from './zmodel-scope';\nimport { ZModelWorkspaceManager } from './zmodel-workspace-manager';\nexport { ZModelLanguageMetaData };\n\n/**\n * Declaration of custom services - add your own service classes here.\n */\nexport type ZModelAddedServices = {\n validation: {\n ZModelValidator: ZModelValidator;\n };\n};\n\n/**\n * Union of Langium default services and your custom services - use this as constructor parameter\n * of custom service classes.\n */\nexport type ZModelServices = LangiumServices & ZModelAddedServices;\n\n/**\n * Dependency injection module that overrides Langium default services and contributes the\n * declared custom services. The Langium defaults can be partially specified to override only\n * selected services, while the custom services must be fully specified.\n */\nexport const ZModelLanguageModule: Module<ZModelServices, PartialLangiumServices & ZModelAddedServices> = {\n references: {\n ScopeComputation: (services) => new ZModelScopeComputation(services),\n ScopeProvider: (services) => new ZModelScopeProvider(services),\n Linker: (services) => new ZModelLinker(services),\n },\n validation: {\n ZModelValidator: (services) => new ZModelValidator(services),\n },\n};\n\nexport type ZModelSharedServices = LangiumSharedServices;\n\nexport const ZModelSharedModule: Module<ZModelSharedServices, DeepPartial<ZModelSharedServices>> = {\n workspace: {\n WorkspaceManager: (services) => new ZModelWorkspaceManager(services),\n },\n};\n\n/**\n * Create the full set of services required by Langium.\n *\n * First inject the shared services by merging two modules:\n * - Langium default shared services\n * - Services generated by langium-cli\n *\n * Then inject the language-specific services by merging three modules:\n * - Langium default language-specific services\n * - Services generated by langium-cli\n * - Services specified in this file\n *\n * @param context Optional module context with the LSP connection\n * @returns An object wrapping the shared services and the language-specific services\n */\nexport function createZModelLanguageServices(context: DefaultSharedModuleContext): {\n shared: LangiumSharedServices;\n ZModelLanguage: ZModelServices;\n} {\n const shared = inject(createDefaultSharedModule(context), ZModelGeneratedSharedModule, ZModelSharedModule);\n const ZModelLanguage = inject(createDefaultModule({ shared }), ZModelGeneratedModule, ZModelLanguageModule);\n shared.ServiceRegistry.register(ZModelLanguage);\n registerValidationChecks(ZModelLanguage);\n if (!context.connection) {\n // We don't run inside a language server\n // Therefore, initialize the configuration provider instantly\n shared.workspace.ConfigurationProvider.initialized({});\n }\n return { shared, ZModelLanguage };\n}\n","/******************************************************************************\n * This file was generated by langium-cli 3.5.0.\n * DO NOT EDIT MANUALLY!\n ******************************************************************************/\n\nimport type { Grammar } from 'langium';\nimport { loadGrammarFromJson } from 'langium';\n\nlet loadedZModelGrammar: Grammar | undefined;\nexport const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModelGrammar = loadGrammarFromJson(`{\n \"$type\": \"Grammar\",\n \"isDeclared\": true,\n \"name\": \"ZModel\",\n \"rules\": [\n {\n \"$type\": \"ParserRule\",\n \"entry\": true,\n \"name\": \"Model\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"imports\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@1\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"declarations\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@2\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ModelImport\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"import\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"path\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@69\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \";\",\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"AbstractDeclaration\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@3\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@4\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@6\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@37\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@42\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@44\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@46\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@53\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@50\"\n },\n \"arguments\": []\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataSource\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"datasource\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@5\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"GeneratorDecl\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"generator\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@5\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigField\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@18\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Plugin\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"plugin\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@7\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"PluginField\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@13\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@24\"\n },\n \"arguments\": []\n }\n ]\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Expression\",\n \"definition\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@33\"\n },\n \"arguments\": []\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"NumberLiteral\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@70\"\n },\n \"arguments\": []\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"StringLiteral\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@69\"\n },\n \"arguments\": []\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"BooleanLiteral\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@63\"\n },\n \"arguments\": []\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"LiteralExpr\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@9\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@10\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@11\"\n },\n \"arguments\": []\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ArrayExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"items\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"items\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigInvocationExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@68\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@15\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"ConfigInvocationArgList\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@16\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@16\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigInvocationArg\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@68\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigArrayExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"items\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@14\"\n },\n \"arguments\": []\n }\n ]\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"items\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@14\"\n },\n \"arguments\": []\n }\n ]\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigExpr\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@26\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@17\"\n },\n \"arguments\": []\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ThisExpr\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"this\"\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"NullExpr\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"null\"\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ReferenceExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"target\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@0\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@52\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@22\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"ReferenceArgList\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@23\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@23\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ReferenceArg\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@68\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ObjectExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@25\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@25\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \",\",\n \"cardinality\": \"?\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"FieldInitializer\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@69\"\n },\n \"arguments\": []\n }\n ]\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"InvocationExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"function\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@46\"\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@35\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"MemberAccessExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@34\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"MemberAccessExpr\"\n },\n \"feature\": \"operand\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \".\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"member\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@1\"\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"UnaryExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"!\"\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operand\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@27\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"CollectionPredicateExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@27\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"!\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"^\"\n }\n ]\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"InExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@29\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"in\"\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@29\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ComparisonExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@30\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \">\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"<\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \">=\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"<=\"\n }\n ]\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@30\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"EqualityExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@31\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"==\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"!=\"\n }\n ]\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@31\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"LogicalExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@32\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"&&\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"||\"\n }\n ]\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@32\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"PrimaryExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ]\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@19\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@20\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@28\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@26\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@13\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@21\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@24\"\n },\n \"arguments\": []\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"ArgumentList\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@36\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@36\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Argument\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataModel\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"model\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@38\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@39\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@39\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@38\"\n },\n \"arguments\": []\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@38\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@39\"\n },\n \"arguments\": []\n }\n ]\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"isView\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"view\"\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n }\n ]\n }\n ]\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@40\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@57\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"WithClause\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"with\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"mixins\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@42\"\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\",\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"mixins\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@42\"\n },\n \"deprecatedSyntax\": false\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"ExtendsClause\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"extends\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"baseModel\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@37\"\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataField\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@52\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@41\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@56\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataFieldType\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@62\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"unsupported\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@43\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"reference\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@2\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"array\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"optional\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"TypeDef\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"type\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@38\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@40\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@57\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"UnsupportedFieldType\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"Unsupported\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Enum\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"enum\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@45\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@57\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"+\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"EnumField\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@52\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@56\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"FunctionDecl\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"function\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@47\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@47\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"returnType\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@48\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"expression\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@58\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"FunctionParam\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@48\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"optional\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"FunctionParamType\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@61\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"reference\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@2\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"array\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ProcedureParam\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@48\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"optional\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Procedure\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"mutation\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"mutation\"\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"procedure\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@49\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@47\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"returnType\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@48\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@58\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"RegularID\",\n \"dataType\": \"string\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@68\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"model\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"enum\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"attribute\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"datasource\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"plugin\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"abstract\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"in\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"view\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"import\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"type\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"RegularIDWithTypeNames\",\n \"dataType\": \"string\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"String\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Boolean\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Int\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"BigInt\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Float\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Decimal\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"DateTime\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Json\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Bytes\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Null\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Object\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Any\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Unsupported\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Attribute\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"attribute\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@65\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@66\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@67\"\n },\n \"arguments\": []\n }\n ]\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@54\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@54\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@58\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"AttributeParam\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"default\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"_\"\n },\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@55\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@58\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"AttributeParamType\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@61\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"FieldReference\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"TransitiveFieldReference\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"ContextType\"\n }\n ]\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"reference\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@2\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"array\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"optional\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataFieldAttribute\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"decl\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@53\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@67\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@59\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataModelAttribute\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"decl\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@53\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@66\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@59\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"InternalAttribute\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"decl\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@53\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@65\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@59\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"AttributeArgList\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@60\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@60\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"AttributeArg\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ExpressionType\",\n \"dataType\": \"string\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"String\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Int\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Float\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Boolean\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"DateTime\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Null\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Object\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Any\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Unsupported\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"BuiltinType\",\n \"dataType\": \"string\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"String\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Boolean\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Int\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"BigInt\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Float\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Decimal\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"DateTime\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Json\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Bytes\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Boolean\",\n \"dataType\": \"boolean\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"true\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"false\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"hidden\": true,\n \"name\": \"WS\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\\\\s+/\"\n },\n \"fragment\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"INTERNAL_ATTRIBUTE_NAME\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/@@@([_a-zA-Z][\\\\\\\\w_]*\\\\\\\\.)*[_a-zA-Z][\\\\\\\\w_]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"MODEL_ATTRIBUTE_NAME\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/@@([_a-zA-Z][\\\\\\\\w_]*\\\\\\\\.)*[_a-zA-Z][\\\\\\\\w_]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"FIELD_ATTRIBUTE_NAME\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/@([_a-zA-Z][\\\\\\\\w_]*\\\\\\\\.)*[_a-zA-Z][\\\\\\\\w_]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"ID\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/[_a-zA-Z][\\\\\\\\w_]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"STRING\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\"(\\\\\\\\\\\\\\\\.|[^\\\\\"\\\\\\\\\\\\\\\\])*\\\\\"|'(\\\\\\\\\\\\\\\\.|[^'\\\\\\\\\\\\\\\\])*'/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"NUMBER\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/[+-]?[0-9]+(\\\\\\\\.[0-9]+)?/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"TRIPLE_SLASH_COMMENT\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\\\\/\\\\\\\\/\\\\\\\\/[^\\\\\\\\n\\\\\\\\r]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"hidden\": true,\n \"name\": \"ML_COMMENT\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\\\\/\\\\\\\\*[\\\\\\\\s\\\\\\\\S]*?\\\\\\\\*\\\\\\\\//\"\n },\n \"fragment\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"hidden\": true,\n \"name\": \"SL_COMMENT\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\\\\/\\\\\\\\/[^\\\\\\\\n\\\\\\\\r]*/\"\n },\n \"fragment\": false\n }\n ],\n \"types\": [\n {\n \"$type\": \"Type\",\n \"name\": \"ReferenceTarget\",\n \"type\": {\n \"$type\": \"UnionType\",\n \"types\": [\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@47\"\n }\n },\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@40\"\n }\n },\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@45\"\n }\n }\n ]\n }\n },\n {\n \"$type\": \"Type\",\n \"name\": \"MemberAccessTarget\",\n \"type\": {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@40\"\n }\n }\n },\n {\n \"$type\": \"Type\",\n \"name\": \"TypeDeclaration\",\n \"type\": {\n \"$type\": \"UnionType\",\n \"types\": [\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@37\"\n }\n },\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@42\"\n }\n },\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@44\"\n }\n }\n ]\n }\n }\n ],\n \"definesHiddenTokens\": false,\n \"hiddenTokens\": [],\n \"imports\": [],\n \"interfaces\": [],\n \"usedGrammars\": []\n}`));\n","/******************************************************************************\n * This file was generated by langium-cli 3.5.0.\n * DO NOT EDIT MANUALLY!\n ******************************************************************************/\n\nimport type { LangiumSharedCoreServices, LangiumCoreServices, LangiumGeneratedCoreServices, LangiumGeneratedSharedCoreServices, LanguageMetaData, Module } from 'langium';\nimport { ZModelAstReflection } from './ast.js';\nimport { ZModelGrammar } from './grammar.js';\n\nexport const ZModelLanguageMetaData = {\n languageId: 'zmodel',\n fileExtensions: ['.zmodel'],\n caseInsensitive: false,\n mode: 'development'\n} as const satisfies LanguageMetaData;\n\nexport const ZModelGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedCoreServices> = {\n AstReflection: () => new ZModelAstReflection()\n};\n\nexport const ZModelGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedCoreServices> = {\n Grammar: () => ZModelGrammar(),\n LanguageMetaData: () => ZModelLanguageMetaData,\n parser: {}\n};\n","import { AstUtils, type ValidationAcceptor } from 'langium';\nimport pluralize from 'pluralize';\nimport {\n ArrayExpr,\n Attribute,\n AttributeArg,\n AttributeParam,\n DataModelAttribute,\n DataField,\n DataFieldAttribute,\n InternalAttribute,\n ReferenceExpr,\n isArrayExpr,\n isAttribute,\n isDataModel,\n isDataField,\n isEnum,\n isReferenceExpr,\n isTypeDef,\n} from '../generated/ast';\nimport {\n getAllAttributes,\n getStringLiteral,\n hasAttribute,\n isDataFieldReference,\n isDelegateModel,\n isFutureExpr,\n isRelationshipField,\n mapBuiltinTypeToExpressionType,\n resolved,\n typeAssignable,\n} from '../utils';\nimport type { AstValidator } from './common';\nimport type { DataModel } from '../ast';\n\n// a registry of function handlers marked with @check\nconst attributeCheckers = new Map<string, PropertyDescriptor>();\n\n// function handler decorator\nfunction check(name: string) {\n return function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) {\n if (!attributeCheckers.get(name)) {\n attributeCheckers.set(name, descriptor);\n }\n return descriptor;\n };\n}\n\ntype AttributeApplication = DataModelAttribute | DataFieldAttribute | InternalAttribute;\n\n/**\n * Validates function declarations.\n */\nexport default class AttributeApplicationValidator implements AstValidator<AttributeApplication> {\n validate(attr: AttributeApplication, accept: ValidationAcceptor, contextDataModel?: DataModel) {\n const decl = attr.decl.ref;\n if (!decl) {\n return;\n }\n\n const targetDecl = attr.$container;\n if (decl.name === '@@@targetField' && !isAttribute(targetDecl)) {\n accept('error', `attribute \"${decl.name}\" can only be used on attribute declarations`, { node: attr });\n return;\n }\n\n if (isDataField(targetDecl) && !isValidAttributeTarget(decl, targetDecl)) {\n accept('error', `attribute \"${decl.name}\" cannot be used on this type of field`, { node: attr });\n }\n\n this.checkDeprecation(attr, accept);\n this.checkDuplicatedAttributes(attr, accept, contextDataModel);\n\n const filledParams = new Set<AttributeParam>();\n\n for (const arg of attr.args) {\n let paramDecl: AttributeParam | undefined;\n if (!arg.name) {\n paramDecl = decl.params.find((p) => p.default && !filledParams.has(p));\n if (!paramDecl) {\n accept('error', `Unexpected unnamed argument`, {\n node: arg,\n });\n return;\n }\n } else {\n paramDecl = decl.params.find((p) => p.name === arg.name);\n if (!paramDecl) {\n accept('error', `Attribute \"${decl.name}\" doesn't have a parameter named \"${arg.name}\"`, {\n node: arg,\n });\n return;\n }\n }\n\n if (!assignableToAttributeParam(arg, paramDecl, attr)) {\n accept('error', `Value is not assignable to parameter`, {\n node: arg,\n });\n return;\n }\n\n if (filledParams.has(paramDecl)) {\n accept('error', `Parameter \"${paramDecl.name}\" is already provided`, { node: arg });\n return;\n }\n filledParams.add(paramDecl);\n arg.$resolvedParam = paramDecl;\n }\n\n const missingParams = decl.params.filter((p) => !p.type.optional && !filledParams.has(p));\n if (missingParams.length > 0) {\n accept(\n 'error',\n `Required ${pluralize('parameter', missingParams.length)} not provided: ${missingParams\n .map((p) => p.name)\n .join(', ')}`,\n { node: attr },\n );\n return;\n }\n\n // run checkers for specific attributes\n const checker = attributeCheckers.get(decl.name);\n if (checker) {\n checker.value.call(this, attr, accept);\n }\n }\n\n private checkDeprecation(attr: AttributeApplication, accept: ValidationAcceptor) {\n const deprecateAttr = attr.decl.ref?.attributes.find((a) => a.decl.ref?.name === '@@@deprecated');\n if (deprecateAttr) {\n const message =\n getStringLiteral(deprecateAttr.args[0]?.value) ?? `Attribute \"${attr.decl.ref?.name}\" is deprecated`;\n accept('warning', message, { node: attr });\n }\n }\n\n private checkDuplicatedAttributes(\n attr: AttributeApplication,\n accept: ValidationAcceptor,\n contextDataModel?: DataModel,\n ) {\n const attrDecl = attr.decl.ref;\n if (!attrDecl?.attributes.some((a) => a.decl.ref?.name === '@@@once')) {\n return;\n }\n\n const allAttributes = contextDataModel ? getAllAttributes(contextDataModel) : attr.$container.attributes;\n const duplicates = allAttributes.filter((a) => a.decl.ref === attrDecl && a !== attr);\n if (duplicates.length > 0) {\n accept('error', `Attribute \"${attrDecl.name}\" can only be applied once`, { node: attr });\n }\n }\n\n @check('@@allow')\n @check('@@deny')\n // @ts-expect-error\n private _checkModelLevelPolicy(attr: AttributeApplication, accept: ValidationAcceptor) {\n const kind = getStringLiteral(attr.args[0]?.value);\n if (!kind) {\n accept('error', `expects a string literal`, {\n node: attr.args[0]!,\n });\n return;\n }\n this.validatePolicyKinds(kind, ['create', 'read', 'update', 'delete', 'all'], attr, accept);\n\n // @encrypted fields cannot be used in policy rules\n this.rejectEncryptedFields(attr, accept);\n }\n\n @check('@allow')\n @check('@deny')\n // @ts-expect-error\n private _checkFieldLevelPolicy(attr: AttributeApplication, accept: ValidationAcceptor) {\n const kind = getStringLiteral(attr.args[0]?.value);\n if (!kind) {\n accept('error', `expects a string literal`, {\n node: attr.args[0]!,\n });\n return;\n }\n const kindItems = this.validatePolicyKinds(kind, ['read', 'update', 'all'], attr, accept);\n\n const expr = attr.args[1]?.value;\n if (expr && AstUtils.streamAst(expr).some((node) => isFutureExpr(node))) {\n accept('error', `\"future()\" is not allowed in field-level policy rules`, { node: expr });\n }\n\n // 'update' rules are not allowed for relation fields\n if (kindItems.includes('update') || kindItems.includes('all')) {\n const field = attr.$container as DataField;\n if (isRelationshipField(field)) {\n accept(\n 'error',\n `Field-level policy rules with \"update\" or \"all\" kind are not allowed for relation fields. Put rules on foreign-key fields instead.`,\n { node: attr },\n );\n }\n }\n\n // @encrypted fields cannot be used in policy rules\n this.rejectEncryptedFields(attr, accept);\n }\n\n @check('@@validate')\n // @ts-expect-error\n private _checkValidate(attr: AttributeApplication, accept: ValidationAcceptor) {\n const condition = attr.args[0]?.value;\n if (\n condition &&\n AstUtils.streamAst(condition).some(\n (node) => isDataFieldReference(node) && isDataModel(node.$resolvedType?.decl),\n )\n ) {\n accept('error', `\\`@@validate\\` condition cannot use relation fields`, { node: condition });\n }\n }\n\n @check('@@unique')\n @check('@@id')\n // @ts-expect-error\n private _checkUnique(attr: AttributeApplication, accept: ValidationAcceptor) {\n const fields = attr.args[0]?.value;\n if (!fields) {\n accept('error', `expects an array of field references`, {\n node: attr.args[0]!,\n });\n return;\n }\n if (isArrayExpr(fields)) {\n if (fields.items.length === 0) {\n accept('error', `\\`@@unique\\` expects at least one field reference`, { node: fields });\n return;\n }\n fields.items.forEach((item) => {\n if (!isReferenceExpr(item)) {\n accept('error', `Expecting a field reference`, {\n node: item,\n });\n return;\n }\n if (!isDataField(item.target.ref)) {\n accept('error', `Expecting a field reference`, {\n node: item,\n });\n return;\n }\n\n if (item.target.ref.$container !== attr.$container && isDelegateModel(item.target.ref.$container)) {\n accept('error', `Cannot use fields inherited from a polymorphic base model in \\`@@unique\\``, {\n node: item,\n });\n }\n });\n } else {\n accept('error', `Expected an array of field references`, {\n node: fields,\n });\n }\n }\n\n private rejectEncryptedFields(attr: AttributeApplication, accept: ValidationAcceptor) {\n AstUtils.streamAllContents(attr).forEach((node) => {\n if (isDataFieldReference(node) && hasAttribute(node.target.ref as DataField, '@encrypted')) {\n accept('error', `Encrypted fields cannot be used in policy rules`, { node });\n }\n });\n }\n\n private validatePolicyKinds(\n kind: string,\n candidates: string[],\n attr: AttributeApplication,\n accept: ValidationAcceptor,\n ) {\n const items = kind.split(',').map((x) => x.trim());\n items.forEach((item) => {\n if (!candidates.includes(item)) {\n accept(\n 'error',\n `Invalid policy rule kind: \"${item}\", allowed: ${candidates.map((c) => '\"' + c + '\"').join(', ')}`,\n { node: attr },\n );\n }\n });\n return items;\n }\n}\n\nfunction assignableToAttributeParam(arg: AttributeArg, param: AttributeParam, attr: AttributeApplication): boolean {\n const argResolvedType = arg.$resolvedType;\n if (!argResolvedType) {\n return false;\n }\n\n let dstType = param.type.type;\n let dstIsArray = param.type.array;\n\n if (dstType === 'ContextType') {\n // ContextType is inferred from the attribute's container's type\n if (isDataField(attr.$container)) {\n dstIsArray = attr.$container.type.array;\n }\n }\n\n const dstRef = param.type.reference;\n\n if (dstType === 'Any' && !dstIsArray) {\n return true;\n }\n\n if (argResolvedType.decl === 'Any') {\n // arg is any type\n if (!argResolvedType.array) {\n // if it's not an array, it's assignable to any type\n return true;\n } else {\n // otherwise it's assignable to any array type\n return argResolvedType.array === dstIsArray;\n }\n }\n\n // destination is field reference or transitive field reference, check if\n // argument is reference or array or reference\n if (dstType === 'FieldReference' || dstType === 'TransitiveFieldReference') {\n if (dstIsArray) {\n return (\n isArrayExpr(arg.value) &&\n !arg.value.items.find((item) => !isReferenceExpr(item) || !isDataField(item.target.ref))\n );\n } else {\n return isReferenceExpr(arg.value) && isDataField(arg.value.target.ref);\n }\n }\n\n if (isEnum(argResolvedType.decl)) {\n // enum type\n\n let attrArgDeclType = dstRef?.ref;\n if (dstType === 'ContextType' && isDataField(attr.$container) && attr.$container?.type?.reference) {\n // attribute parameter type is ContextType, need to infer type from\n // the attribute's container\n attrArgDeclType = resolved(attr.$container.type.reference);\n dstIsArray = attr.$container.type.array;\n }\n return attrArgDeclType === argResolvedType.decl && dstIsArray === argResolvedType.array;\n } else if (dstType) {\n // scalar type\n\n if (typeof argResolvedType?.decl !== 'string') {\n // destination type is not a reference, so argument type must be a plain expression\n return false;\n }\n\n if (dstType === 'ContextType') {\n // attribute parameter type is ContextType, need to infer type from\n // the attribute's container\n if (isDataField(attr.$container)) {\n if (!attr.$container?.type?.type) {\n return false;\n }\n dstType = mapBuiltinTypeToExpressionType(attr.$container.type.type);\n dstIsArray = attr.$container.type.array;\n } else {\n dstType = 'Any';\n }\n }\n\n return typeAssignable(dstType, argResolvedType.decl, arg.value) && dstIsArray === argResolvedType.array;\n } else {\n // reference type\n return (dstRef?.ref === argResolvedType.decl || dstType === 'Any') && dstIsArray === argResolvedType.array;\n }\n}\n\nfunction isValidAttributeTarget(attrDecl: Attribute, targetDecl: DataField) {\n const targetField = attrDecl.attributes.find((attr) => attr.decl.ref?.name === '@@@targetField');\n if (!targetField?.args[0]) {\n // no field type constraint\n return true;\n }\n\n const fieldTypes = (targetField.args[0].value as ArrayExpr).items.map(\n (item) => (item as ReferenceExpr).target.ref?.name,\n );\n\n let allowed = false;\n for (const allowedType of fieldTypes) {\n switch (allowedType) {\n case 'StringField':\n allowed = allowed || targetDecl.type.type === 'String';\n break;\n case 'IntField':\n allowed = allowed || targetDecl.type.type === 'Int';\n break;\n case 'BigIntField':\n allowed = allowed || targetDecl.type.type === 'BigInt';\n break;\n case 'FloatField':\n allowed = allowed || targetDecl.type.type === 'Float';\n break;\n case 'DecimalField':\n allowed = allowed || targetDecl.type.type === 'Decimal';\n break;\n case 'BooleanField':\n allowed = allowed || targetDecl.type.type === 'Boolean';\n break;\n case 'DateTimeField':\n allowed = allowed || targetDecl.type.type === 'DateTime';\n break;\n case 'JsonField':\n allowed = allowed || targetDecl.type.type === 'Json';\n break;\n case 'BytesField':\n allowed = allowed || targetDecl.type.type === 'Bytes';\n break;\n case 'ModelField':\n allowed = allowed || isDataModel(targetDecl.type.reference?.ref);\n break;\n case 'TypeDefField':\n allowed = allowed || isTypeDef(targetDecl.type.reference?.ref);\n break;\n default:\n break;\n }\n if (allowed) {\n break;\n }\n }\n\n return allowed;\n}\n\nexport function validateAttributeApplication(\n attr: AttributeApplication,\n accept: ValidationAcceptor,\n contextDataModel?: DataModel,\n) {\n new AttributeApplicationValidator().validate(attr, accept, contextDataModel);\n}\n","import { invariant } from '@zenstackhq/common-helpers';\nimport { AstUtils, URI, type AstNode, type LangiumDocument, type LangiumDocuments, type Reference } from 'langium';\nimport fs from 'node:fs';\nimport path from 'path';\nimport { STD_LIB_MODULE_NAME, type ExpressionContext } from './constants';\nimport {\n BinaryExpr,\n ConfigExpr,\n isArrayExpr,\n isBinaryExpr,\n isConfigArrayExpr,\n isDataField,\n isDataModel,\n isEnumField,\n isExpression,\n isInvocationExpr,\n isLiteralExpr,\n isMemberAccessExpr,\n isModel,\n isObjectExpr,\n isReferenceExpr,\n isStringLiteral,\n isTypeDef,\n Model,\n ModelImport,\n ReferenceExpr,\n type Attribute,\n type AttributeParam,\n type BuiltinType,\n type DataField,\n type DataFieldAttribute,\n type DataModel,\n type DataModelAttribute,\n type Enum,\n type EnumField,\n type Expression,\n type ExpressionType,\n type FunctionDecl,\n type TypeDef,\n} from './generated/ast';\n\nexport type AttributeTarget =\n | DataModel\n | TypeDef\n | DataField\n | Enum\n | EnumField\n | FunctionDecl\n | Attribute\n | AttributeParam;\n\nexport function hasAttribute(decl: AttributeTarget, name: string) {\n return !!getAttribute(decl, name);\n}\n\nexport function getAttribute(decl: AttributeTarget, name: string) {\n return (decl.attributes as (DataModelAttribute | DataFieldAttribute)[]).find((attr) => attr.decl.$refText === name);\n}\n\nexport function isFromStdlib(node: AstNode) {\n const model = AstUtils.getContainerOfType(node, isModel);\n return !!model && !!model.$document && model.$document.uri.path.endsWith(STD_LIB_MODULE_NAME);\n}\n\nexport function isAuthInvocation(node: AstNode) {\n return isInvocationExpr(node) && node.function.ref?.name === 'auth' && isFromStdlib(node.function.ref);\n}\n\n/**\n * Try getting string value from a potential string literal expression\n */\nexport function getStringLiteral(node: AstNode | undefined): string | undefined {\n return isStringLiteral(node) ? node.value : undefined;\n}\n\nconst isoDateTimeRegex = /^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$/i;\n\n/**\n * Determines if the given sourceType is assignable to a destination of destType\n */\nexport function typeAssignable(destType: ExpressionType, sourceType: ExpressionType, sourceExpr?: Expression): boolean {\n // implicit conversion from ISO datetime string to datetime\n if (destType === 'DateTime' && sourceType === 'String' && sourceExpr && isStringLiteral(sourceExpr)) {\n const literal = getStringLiteral(sourceExpr);\n if (literal && isoDateTimeRegex.test(literal)) {\n // implicitly convert to DateTime\n sourceType = 'DateTime';\n }\n }\n\n switch (destType) {\n case 'Any':\n return true;\n case 'Float':\n return sourceType === 'Any' || sourceType === 'Int' || sourceType === 'Float';\n default:\n return sourceType === 'Any' || sourceType === destType;\n }\n}\n\n/**\n * Maps a ZModel builtin type to expression type\n */\nexport function mapBuiltinTypeToExpressionType(\n type: BuiltinType | 'Any' | 'Object' | 'Null' | 'Unsupported',\n): ExpressionType | 'Any' {\n switch (type) {\n case 'Any':\n case 'Boolean':\n case 'String':\n case 'DateTime':\n case 'Int':\n case 'Float':\n case 'Null':\n return type;\n case 'BigInt':\n return 'Int';\n case 'Decimal':\n return 'Float';\n case 'Json':\n case 'Bytes':\n return 'Any';\n case 'Object':\n return 'Object';\n case 'Unsupported':\n return 'Unsupported';\n }\n}\n\nexport function isAuthOrAuthMemberAccess(expr: Expression): boolean {\n return isAuthInvocation(expr) || (isMemberAccessExpr(expr) && isAuthOrAuthMemberAccess(expr.operand));\n}\n\nexport function isEnumFieldReference(node: AstNode): node is ReferenceExpr {\n return isReferenceExpr(node) && isEnumField(node.target.ref);\n}\n\nexport function isDataFieldReference(node: AstNode): node is ReferenceExpr {\n return isReferenceExpr(node) && isDataField(node.target.ref);\n}\n\n/**\n * Returns if the given field is a relation field.\n */\nexport function isRelationshipField(field: DataField) {\n return isDataModel(field.type.reference?.ref);\n}\n\nexport function isFutureExpr(node: AstNode) {\n return isInvocationExpr(node) && node.function.ref?.name === 'future' && isFromStdlib(node.function.ref);\n}\n\nexport function isDelegateModel(node: AstNode) {\n return isDataModel(node) && hasAttribute(node, '@@delegate');\n}\n\nexport function resolved<T extends AstNode>(ref: Reference<T>): T {\n if (!ref.ref) {\n throw new Error(`Reference not resolved: ${ref.$refText}`);\n }\n return ref.ref;\n}\n\nexport function getRecursiveBases(\n decl: DataModel | TypeDef,\n includeDelegate = true,\n seen = new Set<DataModel | TypeDef>(),\n): (TypeDef | DataModel)[] {\n const result: (TypeDef | DataModel)[] = [];\n if (seen.has(decl)) {\n return result;\n }\n seen.add(decl);\n decl.mixins.forEach((mixin) => {\n const baseDecl = mixin.ref;\n if (baseDecl) {\n if (!includeDelegate && isDelegateModel(baseDecl)) {\n return;\n }\n result.push(baseDecl);\n result.push(...getRecursiveBases(baseDecl, includeDelegate, seen));\n }\n });\n return result;\n}\n\n/**\n * Gets `@@id` fields declared at the data model level (including search in base models)\n */\nexport function getModelIdFields(model: DataModel) {\n const modelsToCheck = [model, ...getRecursiveBases(model)];\n\n for (const modelToCheck of modelsToCheck) {\n const allAttributes = getAllAttributes(modelToCheck);\n const idAttr = allAttributes.find((attr) => attr.decl.$refText === '@@id');\n if (!idAttr) {\n continue;\n }\n const fieldsArg = idAttr.args.find((a) => a.$resolvedParam?.name === 'fields');\n if (!fieldsArg || !isArrayExpr(fieldsArg.value)) {\n continue;\n }\n\n return fieldsArg.value.items\n .filter((item): item is ReferenceExpr => isReferenceExpr(item))\n .map((item) => resolved(item.target) as DataField);\n }\n\n return [];\n}\n\n/**\n * Gets `@@unique` fields declared at the data model level (including search in base models)\n */\nexport function getModelUniqueFields(model: DataModel) {\n const modelsToCheck = [model, ...getRecursiveBases(model)];\n\n for (const modelToCheck of modelsToCheck) {\n const allAttributes = getAllAttributes(modelToCheck);\n const uniqueAttr = allAttributes.find((attr) => attr.decl.$refText === '@@unique');\n if (!uniqueAttr) {\n continue;\n }\n const fieldsArg = uniqueAttr.args.find((a) => a.$resolvedParam?.name === 'fields');\n if (!fieldsArg || !isArrayExpr(fieldsArg.value)) {\n continue;\n }\n\n return fieldsArg.value.items\n .filter((item): item is ReferenceExpr => isReferenceExpr(item))\n .map((item) => resolved(item.target) as DataField);\n }\n\n return [];\n}\n\n/**\n * Gets lists of unique fields declared at the data model level\n *\n * TODO: merge this with {@link getModelUniqueFields}\n */\nexport function getUniqueFields(model: DataModel) {\n const uniqueAttrs = model.attributes.filter(\n (attr) => attr.decl.ref?.name === '@@unique' || attr.decl.ref?.name === '@@id',\n );\n return uniqueAttrs.map((uniqueAttr) => {\n const fieldsArg = uniqueAttr.args.find((a) => a.$resolvedParam?.name === 'fields');\n if (!fieldsArg || !isArrayExpr(fieldsArg.value)) {\n return [];\n }\n\n return fieldsArg.value.items\n .filter((item): item is ReferenceExpr => isReferenceExpr(item))\n .map((item) => resolved(item.target) as DataField);\n });\n}\n\nexport function findUpAst(node: AstNode, predicate: (node: AstNode) => boolean): AstNode | undefined {\n let curr: AstNode | undefined = node;\n while (curr) {\n if (predicate(curr)) {\n return curr;\n }\n curr = curr.$container;\n }\n return undefined;\n}\n\nexport function getLiteral<T extends string | number | boolean | any = any>(\n expr: Expression | ConfigExpr | undefined,\n): T | undefined {\n switch (expr?.$type) {\n case 'ObjectExpr':\n return getObjectLiteral<T>(expr);\n case 'StringLiteral':\n case 'BooleanLiteral':\n return expr.value as T;\n case 'NumberLiteral':\n return parseFloat(expr.value) as T;\n default:\n return undefined;\n }\n}\n\nexport function getObjectLiteral<T>(expr: Expression | ConfigExpr | undefined): T | undefined {\n if (!expr || !isObjectExpr(expr)) {\n return undefined;\n }\n const result: Record<string, unknown> = {};\n for (const field of expr.fields) {\n let fieldValue: unknown;\n if (isLiteralExpr(field.value)) {\n fieldValue = getLiteral(field.value);\n } else if (isArrayExpr(field.value)) {\n fieldValue = getLiteralArray(field.value);\n } else if (isObjectExpr(field.value)) {\n fieldValue = getObjectLiteral(field.value);\n }\n if (fieldValue === undefined) {\n return undefined;\n } else {\n result[field.name] = fieldValue;\n }\n }\n return result as T;\n}\n\nexport function getLiteralArray<T extends string | number | boolean | any = any>(\n expr: Expression | ConfigExpr | undefined,\n): T[] | undefined {\n const arr = getArray(expr);\n if (!arr) {\n return undefined;\n }\n return arr.map((item) => isExpression(item) && getLiteral<T>(item)).filter((v): v is T => v !== undefined);\n}\n\nfunction getArray(expr: Expression | ConfigExpr | undefined) {\n return isArrayExpr(expr) || isConfigArrayExpr(expr) ? expr.items : undefined;\n}\n\nexport function getAttributeArgLiteral<T extends string | number | boolean>(\n attr: DataModelAttribute | DataFieldAttribute,\n name: string,\n): T | undefined {\n for (const arg of attr.args) {\n if (arg.$resolvedParam?.name === name) {\n return getLiteral<T>(arg.value);\n }\n }\n return undefined;\n}\n\nexport function getFunctionExpressionContext(funcDecl: FunctionDecl) {\n const funcAllowedContext: ExpressionContext[] = [];\n const funcAttr = funcDecl.attributes.find((attr) => attr.decl.$refText === '@@@expressionContext');\n if (funcAttr) {\n const contextArg = funcAttr.args[0]?.value;\n if (isArrayExpr(contextArg)) {\n contextArg.items.forEach((item) => {\n if (isEnumFieldReference(item)) {\n funcAllowedContext.push(item.target.$refText as ExpressionContext);\n }\n });\n }\n }\n return funcAllowedContext;\n}\n\nexport function getFieldReference(expr: Expression): DataField | undefined {\n if (isReferenceExpr(expr) && isDataField(expr.target.ref)) {\n return expr.target.ref;\n } else if (isMemberAccessExpr(expr) && isDataField(expr.member.ref)) {\n return expr.member.ref;\n } else {\n return undefined;\n }\n}\n\nexport function isCheckInvocation(node: AstNode) {\n return isInvocationExpr(node) && node.function.ref?.name === 'check' && isFromStdlib(node.function.ref);\n}\n\nexport function resolveTransitiveImports(documents: LangiumDocuments, model: Model) {\n return resolveTransitiveImportsInternal(documents, model);\n}\n\nfunction resolveTransitiveImportsInternal(\n documents: LangiumDocuments,\n model: Model,\n initialModel = model,\n visited: Set<string> = new Set(),\n models: Set<Model> = new Set(),\n) {\n const doc = AstUtils.getDocument(model);\n const initialDoc = AstUtils.getDocument(initialModel);\n\n if (initialDoc.uri.fsPath.toLowerCase() !== doc.uri.fsPath.toLowerCase()) {\n models.add(model);\n }\n\n const normalizedPath = doc.uri.fsPath.toLowerCase();\n if (!visited.has(normalizedPath)) {\n visited.add(normalizedPath);\n for (const imp of model.imports) {\n const importedModel = resolveImport(documents, imp);\n if (importedModel) {\n resolveTransitiveImportsInternal(documents, importedModel, initialModel, visited, models);\n }\n }\n }\n return Array.from(models);\n}\n\nexport function resolveImport(documents: LangiumDocuments, imp: ModelImport) {\n const resolvedUri = resolveImportUri(imp);\n try {\n if (resolvedUri) {\n let resolvedDocument = documents.getDocument(resolvedUri);\n if (!resolvedDocument) {\n const content = fs.readFileSync(resolvedUri.fsPath, 'utf-8');\n resolvedDocument = documents.createDocument(resolvedUri, content);\n }\n const node = resolvedDocument.parseResult.value;\n if (isModel(node)) {\n return node;\n }\n }\n } catch {\n // NOOP\n }\n return undefined;\n}\n\nexport function resolveImportUri(imp: ModelImport) {\n if (!imp.path) {\n return undefined;\n }\n const doc = AstUtils.getDocument(imp);\n const dir = path.dirname(doc.uri.fsPath);\n const importPath = imp.path.endsWith('.zmodel') ? imp.path : `${imp.path}.zmodel`;\n return URI.file(path.resolve(dir, importPath));\n}\n\n/**\n * Gets data models and type defs in the ZModel schema.\n */\nexport function getDataModelAndTypeDefs(model: Model, includeIgnored = false) {\n const r = model.declarations.filter((d): d is DataModel | TypeDef => isDataModel(d) || isTypeDef(d));\n if (includeIgnored) {\n return r;\n } else {\n return r.filter((model) => !hasAttribute(model, '@@ignore'));\n }\n}\n\nexport function getAllDeclarationsIncludingImports(documents: LangiumDocuments, model: Model) {\n const imports = resolveTransitiveImports(documents, model);\n return model.declarations.concat(...imports.map((imp) => imp.declarations));\n}\n\nexport function getAuthDecl(decls: (DataModel | TypeDef)[]) {\n let authModel = decls.find((m) => hasAttribute(m, '@@auth'));\n if (!authModel) {\n authModel = decls.find((m) => m.name === 'User');\n }\n return authModel;\n}\n\nexport function isFutureInvocation(node: AstNode) {\n return isInvocationExpr(node) && node.function.ref?.name === 'future' && isFromStdlib(node.function.ref);\n}\n\nexport function isCollectionPredicate(node: AstNode): node is BinaryExpr {\n return isBinaryExpr(node) && ['?', '!', '^'].includes(node.operator);\n}\n\nexport function getAllLoadedDataModelsAndTypeDefs(langiumDocuments: LangiumDocuments) {\n return langiumDocuments.all\n .map((doc) => doc.parseResult.value as Model)\n .flatMap((model) => model.declarations.filter((d): d is DataModel | TypeDef => isDataModel(d) || isTypeDef(d)))\n .toArray();\n}\n\nexport function getAllDataModelsIncludingImports(documents: LangiumDocuments, model: Model) {\n return getAllDeclarationsIncludingImports(documents, model).filter(isDataModel);\n}\n\nexport function getAllLoadedAndReachableDataModelsAndTypeDefs(\n langiumDocuments: LangiumDocuments,\n fromModel?: DataModel,\n) {\n // get all data models from loaded documents\n const allDataModels = getAllLoadedDataModelsAndTypeDefs(langiumDocuments);\n\n if (fromModel) {\n // merge data models transitively reached from the current model\n const model = AstUtils.getContainerOfType(fromModel, isModel);\n if (model) {\n const transitiveDataModels = getAllDataModelsIncludingImports(langiumDocuments, model);\n transitiveDataModels.forEach((dm) => {\n if (!allDataModels.includes(dm)) {\n allDataModels.push(dm);\n }\n });\n }\n }\n\n return allDataModels;\n}\n\nexport function getContainingDataModel(node: Expression): DataModel | undefined {\n let curr: AstNode | undefined = node.$container;\n while (curr) {\n if (isDataModel(curr)) {\n return curr;\n }\n curr = curr.$container;\n }\n return undefined;\n}\n\nexport function isMemberContainer(node: unknown): node is DataModel | TypeDef {\n return isDataModel(node) || isTypeDef(node);\n}\n\nexport function getAllFields(\n decl: DataModel | TypeDef,\n includeIgnored = false,\n seen: Set<DataModel | TypeDef> = new Set(),\n): DataField[] {\n if (seen.has(decl)) {\n return [];\n }\n seen.add(decl);\n\n const fields: DataField[] = [];\n for (const mixin of decl.mixins) {\n invariant(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);\n fields.push(...getAllFields(mixin.ref, includeIgnored, seen));\n }\n\n if (isDataModel(decl) && decl.baseModel) {\n invariant(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);\n fields.push(...getAllFields(decl.baseModel.ref, includeIgnored, seen));\n }\n\n fields.push(...decl.fields.filter((f) => includeIgnored || !hasAttribute(f, '@ignore')));\n return fields;\n}\n\nexport function getAllAttributes(\n decl: DataModel | TypeDef,\n seen: Set<DataModel | TypeDef> = new Set(),\n): DataModelAttribute[] {\n if (seen.has(decl)) {\n return [];\n }\n seen.add(decl);\n\n const attributes: DataModelAttribute[] = [];\n for (const mixin of decl.mixins) {\n invariant(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);\n attributes.push(...getAllAttributes(mixin.ref, seen));\n }\n\n if (isDataModel(decl) && decl.baseModel) {\n invariant(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);\n attributes.push(...getAllAttributes(decl.baseModel.ref, seen));\n }\n\n attributes.push(...decl.attributes);\n return attributes;\n}\n\n/**\n * Retrieve the document in which the given AST node is contained. A reference to the document is\n * usually held by the root node of the AST.\n *\n * @throws an error if the node is not contained in a document.\n */\nexport function getDocument<T extends AstNode = AstNode>(node: AstNode): LangiumDocument<T> {\n const rootNode = findRootNode(node);\n const result = rootNode.$document;\n if (!result) {\n throw new Error('AST node has no document.');\n }\n return result as LangiumDocument<T>;\n}\n\n/**\n * Returns the root node of the given AST node by following the `$container` references.\n */\nexport function findRootNode(node: AstNode): AstNode {\n while (node.$container) {\n node = node.$container;\n }\n return node;\n}\n","import type { ValidationAcceptor } from 'langium';\nimport { Attribute } from '../generated/ast';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport type { AstValidator } from './common';\n\n/**\n * Validates attribute declarations.\n */\nexport default class AttributeValidator implements AstValidator<Attribute> {\n validate(attr: Attribute, accept: ValidationAcceptor): void {\n attr.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n}\n","import { invariant } from '@zenstackhq/common-helpers';\nimport { AstUtils, type AstNode, type DiagnosticInfo, type ValidationAcceptor } from 'langium';\nimport { IssueCodes, SCALAR_TYPES } from '../constants';\nimport {\n ArrayExpr,\n DataField,\n DataModel,\n Model,\n ReferenceExpr,\n TypeDef,\n isDataModel,\n isDataSource,\n isEnum,\n isModel,\n isStringLiteral,\n isTypeDef,\n} from '../generated/ast';\nimport {\n getAllAttributes,\n getAllFields,\n getLiteral,\n getModelIdFields,\n getModelUniqueFields,\n getUniqueFields,\n hasAttribute,\n isDelegateModel,\n} from '../utils';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates data model declarations.\n */\nexport default class DataModelValidator implements AstValidator<DataModel> {\n validate(dm: DataModel, accept: ValidationAcceptor): void {\n validateDuplicatedDeclarations(dm, getAllFields(dm), accept);\n this.validateAttributes(dm, accept);\n this.validateFields(dm, accept);\n if (dm.mixins.length > 0) {\n this.validateMixins(dm, accept);\n }\n this.validateInherits(dm, accept);\n }\n\n private validateFields(dm: DataModel, accept: ValidationAcceptor) {\n const allFields = getAllFields(dm);\n const idFields = allFields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === '@id'));\n const uniqueFields = allFields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === '@unique'));\n const modelLevelIds = getModelIdFields(dm);\n const modelUniqueFields = getModelUniqueFields(dm);\n\n if (\n idFields.length === 0 &&\n modelLevelIds.length === 0 &&\n uniqueFields.length === 0 &&\n modelUniqueFields.length === 0\n ) {\n accept(\n 'error',\n '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.',\n {\n node: dm,\n },\n );\n } else if (idFields.length > 0 && modelLevelIds.length > 0) {\n accept('error', 'Model cannot have both field-level @id and model-level @@id attributes', {\n node: dm,\n });\n } else if (idFields.length > 1) {\n accept('error', 'Model can include at most one field with @id attribute', {\n node: dm,\n });\n } else {\n const fieldsToCheck = idFields.length > 0 ? idFields : modelLevelIds;\n fieldsToCheck.forEach((idField) => {\n if (idField.type.optional) {\n accept('error', 'Field with @id attribute must not be optional', { node: idField });\n }\n\n const isArray = idField.type.array;\n const isScalar = SCALAR_TYPES.includes(idField.type.type as (typeof SCALAR_TYPES)[number]);\n const isValidType = isScalar || isEnum(idField.type.reference?.ref);\n\n if (isArray || !isValidType) {\n accept('error', 'Field with @id attribute must be of scalar or enum type', { node: idField });\n }\n });\n }\n\n dm.fields.forEach((field) => this.validateField(field, accept));\n allFields\n .filter((x) => isDataModel(x.type.reference?.ref))\n .forEach((y) => {\n this.validateRelationField(dm, y, accept);\n });\n }\n\n private validateField(field: DataField, accept: ValidationAcceptor): void {\n if (field.type.array && field.type.optional) {\n accept('error', 'Optional lists are not supported. Use either `Type[]` or `Type?`', { node: field.type });\n }\n\n if (field.type.unsupported && !isStringLiteral(field.type.unsupported.value)) {\n accept('error', 'Unsupported type argument must be a string literal', { node: field.type.unsupported });\n }\n\n if (field.type.array && !isDataModel(field.type.reference?.ref)) {\n const provider = this.getDataSourceProvider(AstUtils.getContainerOfType(field, isModel)!);\n if (provider === 'sqlite') {\n accept('error', `Array type is not supported for \"${provider}\" provider.`, { node: field.type });\n }\n }\n\n field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n\n if (isTypeDef(field.type.reference?.ref)) {\n if (!hasAttribute(field, '@json')) {\n accept('error', 'Custom-typed field must have @json attribute', { node: field });\n }\n }\n }\n\n private getDataSourceProvider(model: Model) {\n const dataSource = model.declarations.find(isDataSource);\n if (!dataSource) {\n return undefined;\n }\n const provider = dataSource?.fields.find((f) => f.name === 'provider');\n if (!provider) {\n return undefined;\n }\n return getLiteral<string>(provider.value);\n }\n\n private validateAttributes(dm: DataModel, accept: ValidationAcceptor) {\n getAllAttributes(dm).forEach((attr) => validateAttributeApplication(attr, accept, dm));\n }\n\n private parseRelation(field: DataField, accept?: ValidationAcceptor) {\n const relAttr = field.attributes.find((attr) => attr.decl.ref?.name === '@relation');\n\n let name: string | undefined;\n let fields: ReferenceExpr[] | undefined;\n let references: ReferenceExpr[] | undefined;\n let valid = true;\n\n if (!relAttr) {\n return { attr: relAttr, name, fields, references, valid: true };\n }\n\n for (const arg of relAttr.args) {\n if (!arg.name || arg.name === 'name') {\n if (isStringLiteral(arg.value)) {\n name = arg.value.value as string;\n }\n } else if (arg.name === 'fields') {\n fields = (arg.value as ArrayExpr).items as ReferenceExpr[];\n if (fields.length === 0) {\n if (accept) {\n accept('error', `\"fields\" value cannot be empty`, {\n node: arg,\n });\n }\n valid = false;\n }\n } else if (arg.name === 'references') {\n references = (arg.value as ArrayExpr).items as ReferenceExpr[];\n if (references.length === 0) {\n if (accept) {\n accept('error', `\"references\" value cannot be empty`, {\n node: arg,\n });\n }\n valid = false;\n }\n }\n }\n\n if (!fields && !references) {\n return { attr: relAttr, name, fields, references, valid: true };\n }\n\n if (!fields || !references) {\n if (accept) {\n accept('error', `\"fields\" and \"references\" must be provided together`, { node: relAttr });\n }\n } else {\n // validate \"fields\" and \"references\" typing consistency\n if (fields.length !== references.length) {\n if (accept) {\n accept('error', `\"references\" and \"fields\" must have the same length`, { node: relAttr });\n }\n } else {\n for (let i = 0; i < fields.length; i++) {\n const fieldRef = fields[i];\n if (!fieldRef) {\n continue;\n }\n\n if (!field.type.optional && fieldRef.$resolvedType?.nullable) {\n // if relation is not optional, then fk field must not be nullable\n if (accept) {\n accept(\n 'error',\n `relation \"${field.name}\" is not optional, but field \"${fieldRef.target.$refText}\" is optional`,\n { node: fieldRef.target.ref! },\n );\n }\n }\n\n if (!fieldRef.$resolvedType) {\n if (accept) {\n accept('error', `field reference is unresolved`, {\n node: fieldRef,\n });\n }\n }\n if (!references[i]?.$resolvedType) {\n if (accept) {\n accept('error', `field reference is unresolved`, {\n node: references[i]!,\n });\n }\n }\n\n if (\n fieldRef.$resolvedType?.decl !== references[i]?.$resolvedType?.decl ||\n fieldRef.$resolvedType?.array !== references[i]?.$resolvedType?.array\n ) {\n if (accept) {\n accept('error', `values of \"references\" and \"fields\" must have the same type`, {\n node: relAttr,\n });\n }\n }\n }\n }\n }\n\n return { attr: relAttr, name, fields, references, valid };\n }\n\n private isSelfRelation(field: DataField) {\n return field.type.reference?.ref === field.$container;\n }\n\n private validateRelationField(contextModel: DataModel, field: DataField, accept: ValidationAcceptor) {\n const thisRelation = this.parseRelation(field, accept);\n if (!thisRelation.valid) {\n return;\n }\n\n if (this.isFieldInheritedFromDelegateModel(field)) {\n // relation fields inherited from delegate model don't need opposite relation\n return;\n }\n\n if (this.isSelfRelation(field)) {\n if (!thisRelation.name) {\n accept('error', 'Self-relation field must have a name in @relation attribute', {\n node: field,\n });\n return;\n }\n }\n\n const oppositeModel = field.type.reference!.ref! as DataModel;\n\n // Use name because the current document might be updated\n let oppositeFields = getAllFields(oppositeModel, false).filter(\n (f) =>\n f !== field && // exclude self in case of self relation\n f.type.reference?.ref?.name === contextModel.name,\n );\n oppositeFields = oppositeFields.filter((f) => {\n const fieldRel = this.parseRelation(f);\n return fieldRel.valid && fieldRel.name === thisRelation.name;\n });\n\n if (oppositeFields.length === 0) {\n const info: DiagnosticInfo<AstNode, string> = {\n node: field,\n code: IssueCodes.MissingOppositeRelation,\n };\n\n info.property = 'name';\n const container = field.$container;\n\n const relationFieldDocUri = AstUtils.getDocument(container).textDocument.uri;\n const relationDataModelName = container.name;\n\n const data: MissingOppositeRelationData = {\n relationFieldName: field.name,\n relationDataModelName,\n relationFieldDocUri,\n dataModelName: contextModel.name,\n };\n\n info.data = data;\n\n accept(\n 'error',\n `The relation field \"${field.name}\" on model \"${contextModel.name}\" is missing an opposite relation field on model \"${oppositeModel.name}\"`,\n info,\n );\n return;\n } else if (oppositeFields.length > 1) {\n oppositeFields\n .filter((f) => f.$container !== contextModel)\n .forEach((f) => {\n if (this.isSelfRelation(f)) {\n // self relations are partial\n // https://www.prisma.io/docs/concepts/components/prisma-schema/relations/self-relations\n } else {\n accept(\n 'error',\n `Fields ${oppositeFields.map((f) => '\"' + f.name + '\"').join(', ')} on model \"${\n oppositeModel.name\n }\" refer to the same relation to model \"${field.$container.name}\"`,\n { node: f },\n );\n }\n });\n return;\n }\n\n const oppositeField = oppositeFields[0]!;\n const oppositeRelation = this.parseRelation(oppositeField);\n\n let relationOwner: DataField;\n\n if (field.type.array && oppositeField.type.array) {\n // if both the field is array, then it's an implicit many-to-many relation,\n // neither side should have fields/references\n for (const r of [thisRelation, oppositeRelation]) {\n if (r.fields?.length || r.references?.length) {\n accept(\n 'error',\n 'Implicit many-to-many relation cannot have \"fields\" or \"references\" in @relation attribute',\n {\n node: r === thisRelation ? field : oppositeField,\n },\n );\n }\n }\n } else {\n if (thisRelation?.references?.length && thisRelation.fields?.length) {\n if (oppositeRelation?.references || oppositeRelation?.fields) {\n accept('error', '\"fields\" and \"references\" must be provided only on one side of relation field', {\n node: oppositeField,\n });\n return;\n } else {\n relationOwner = oppositeField;\n }\n } else if (oppositeRelation?.references?.length && oppositeRelation.fields?.length) {\n if (thisRelation?.references || thisRelation?.fields) {\n accept('error', '\"fields\" and \"references\" must be provided only on one side of relation field', {\n node: field,\n });\n return;\n } else {\n relationOwner = field;\n }\n } else {\n // for non-M2M relations, one side must have fields/references\n [field, oppositeField].forEach((f) => {\n if (!this.isSelfRelation(f)) {\n accept(\n 'error',\n 'Field for one side of relation must carry @relation attribute with both \"fields\" and \"references\"',\n { node: f },\n );\n }\n });\n return;\n }\n\n if (!relationOwner.type.array && !relationOwner.type.optional) {\n accept('error', 'Relation field needs to be list or optional', {\n node: relationOwner,\n });\n return;\n }\n\n if (relationOwner !== field && !relationOwner.type.array) {\n // one-to-one relation requires defining side's reference field to be @unique\n // e.g.:\n // model User {\n // id String @id @default(cuid())\n // data UserData?\n // }\n // model UserData {\n // id String @id @default(cuid())\n // user User @relation(fields: [userId], references: [id])\n // userId String\n // }\n //\n // UserData.userId field needs to be @unique\n\n const containingModel = field.$container as DataModel;\n const uniqueFieldList = getUniqueFields(containingModel);\n\n // field is defined in the abstract base model\n if (containingModel !== contextModel) {\n uniqueFieldList.push(...getUniqueFields(contextModel));\n }\n\n thisRelation.fields?.forEach((ref) => {\n const refField = ref.target.ref as DataField;\n if (refField) {\n if (\n refField.attributes.find(\n (a) => a.decl.ref?.name === '@id' || a.decl.ref?.name === '@unique',\n )\n ) {\n return;\n }\n if (uniqueFieldList.some((list) => list.includes(refField))) {\n return;\n }\n accept(\n 'error',\n `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`,\n { node: refField },\n );\n }\n });\n }\n }\n }\n\n // checks if the given field is inherited directly or indirectly from a delegate model\n private isFieldInheritedFromDelegateModel(field: DataField) {\n return isDelegateModel(field.$container);\n }\n\n private validateInherits(model: DataModel, accept: ValidationAcceptor) {\n if (!model.baseModel) {\n return;\n }\n\n invariant(model.baseModel.ref, 'baseModel must be resolved');\n\n // check if the base model is a delegate model\n if (!isDelegateModel(model.baseModel.ref)) {\n accept('error', `Model ${model.baseModel.$refText} cannot be extended because it's not a delegate model`, {\n node: model,\n property: 'baseModel',\n });\n return;\n }\n\n // check for cyclic inheritance\n const seen: DataModel[] = [];\n const todo = [model.baseModel.ref];\n while (todo.length > 0) {\n const current = todo.shift()!;\n if (seen.includes(current)) {\n accept(\n 'error',\n `Cyclic inheritance detected: ${seen.map((m) => m.name).join(' -> ')} -> ${current.name}`,\n {\n node: model,\n },\n );\n return;\n }\n seen.push(current);\n if (current.baseModel) {\n invariant(current.baseModel.ref, 'baseModel must be resolved');\n todo.push(current.baseModel.ref);\n }\n }\n }\n\n private validateMixins(dm: DataModel, accept: ValidationAcceptor) {\n const seen: TypeDef[] = [];\n const todo: TypeDef[] = dm.mixins.map((mixin) => mixin.ref!);\n while (todo.length > 0) {\n const current = todo.shift()!;\n if (seen.includes(current)) {\n accept('error', `Cyclic mixin detected: ${seen.map((m) => m.name).join(' -> ')} -> ${current.name}`, {\n node: dm,\n });\n return;\n }\n seen.push(current);\n todo.push(...current.mixins.map((mixin) => mixin.ref!));\n }\n }\n}\n\nexport interface MissingOppositeRelationData {\n relationDataModelName: string;\n relationFieldName: string;\n // it might be the abstract model in the imported document\n relationFieldDocUri: string;\n\n // the name of DataModel that the relation field belongs to.\n // the document is the same with the error node.\n dataModelName: string;\n}\n","import type { AstNode, MaybePromise, ValidationAcceptor } from 'langium';\nimport { isDataField } from '../generated/ast';\n\n/**\n * AST validator contract\n */\nexport interface AstValidator<T extends AstNode> {\n /**\n * Validates an AST node\n */\n validate(node: T, accept: ValidationAcceptor): MaybePromise<void>;\n}\n\n/**\n * Checks if the given declarations have duplicated names\n */\nexport function validateDuplicatedDeclarations(\n container: AstNode,\n decls: Array<AstNode & { name: string }>,\n accept: ValidationAcceptor,\n): void {\n const groupByName = decls.reduce<Record<string, Array<AstNode & { name: string }>>>((group, decl) => {\n group[decl.name] = group[decl.name] ?? [];\n group[decl.name]!.push(decl);\n return group;\n }, {});\n\n for (const [name, decls] of Object.entries<AstNode[]>(groupByName)) {\n if (decls.length > 1) {\n let errorField = decls[1]!;\n if (isDataField(decls[0])) {\n const nonInheritedFields = decls.filter((x) => !(isDataField(x) && x.$container !== container));\n if (nonInheritedFields.length > 0) {\n errorField = nonInheritedFields.slice(-1)[0]!;\n }\n }\n\n accept('error', `Duplicated declaration name \"${name}\"`, {\n node: errorField,\n });\n }\n }\n}\n","import type { ValidationAcceptor } from 'langium';\nimport { SUPPORTED_PROVIDERS } from '../constants';\nimport { DataSource, isInvocationExpr } from '../generated/ast';\nimport { getStringLiteral } from '../utils';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates data source declarations.\n */\nexport default class DataSourceValidator implements AstValidator<DataSource> {\n validate(ds: DataSource, accept: ValidationAcceptor): void {\n validateDuplicatedDeclarations(ds, ds.fields, accept);\n this.validateProvider(ds, accept);\n this.validateUrl(ds, accept);\n this.validateRelationMode(ds, accept);\n }\n\n private validateProvider(ds: DataSource, accept: ValidationAcceptor) {\n const provider = ds.fields.find((f) => f.name === 'provider');\n if (!provider) {\n accept('error', 'datasource must include a \"provider\" field', {\n node: ds,\n });\n return;\n }\n\n const value = getStringLiteral(provider.value);\n if (!value) {\n accept('error', '\"provider\" must be set to a string literal', {\n node: provider.value,\n });\n } else if (!SUPPORTED_PROVIDERS.includes(value)) {\n accept(\n 'error',\n `Provider \"${value}\" is not supported. Choose from ${SUPPORTED_PROVIDERS.map((p) => '\"' + p + '\"').join(\n ' | ',\n )}.`,\n { node: provider.value },\n );\n }\n }\n\n private validateUrl(ds: DataSource, accept: ValidationAcceptor) {\n const urlField = ds.fields.find((f) => f.name === 'url');\n if (!urlField) {\n return;\n }\n\n const value = getStringLiteral(urlField.value);\n if (!value && !(isInvocationExpr(urlField.value) && urlField.value.function.ref?.name === 'env')) {\n accept('error', `\"${urlField.name}\" must be set to a string literal or an invocation of \"env\" function`, {\n node: urlField.value,\n });\n }\n }\n\n private validateRelationMode(ds: DataSource, accept: ValidationAcceptor) {\n const field = ds.fields.find((f) => f.name === 'relationMode');\n if (field) {\n const val = getStringLiteral(field.value);\n if (!val || !['foreignKeys', 'prisma'].includes(val)) {\n accept('error', '\"relationMode\" must be set to \"foreignKeys\" or \"prisma\"', { node: field.value });\n }\n }\n }\n}\n","import type { ValidationAcceptor } from 'langium';\nimport { Enum, EnumField } from '../generated/ast';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates enum declarations.\n */\nexport default class EnumValidator implements AstValidator<Enum> {\n validate(_enum: Enum, accept: ValidationAcceptor) {\n validateDuplicatedDeclarations(_enum, _enum.fields, accept);\n this.validateAttributes(_enum, accept);\n _enum.fields.forEach((field) => {\n this.validateField(field, accept);\n });\n }\n\n private validateAttributes(_enum: Enum, accept: ValidationAcceptor) {\n _enum.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n\n private validateField(field: EnumField, accept: ValidationAcceptor) {\n field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n}\n","import { AstUtils, type AstNode, type ValidationAcceptor } from 'langium';\nimport {\n BinaryExpr,\n Expression,\n isArrayExpr,\n isDataModel,\n isDataModelAttribute,\n isEnum,\n isLiteralExpr,\n isMemberAccessExpr,\n isNullExpr,\n isReferenceExpr,\n isThisExpr,\n type ExpressionType,\n} from '../generated/ast';\n\nimport {\n findUpAst,\n isAuthInvocation,\n isAuthOrAuthMemberAccess,\n isDataFieldReference,\n isEnumFieldReference,\n typeAssignable,\n} from '../utils';\nimport type { AstValidator } from './common';\n\n/**\n * Validates expressions.\n */\nexport default class ExpressionValidator implements AstValidator<Expression> {\n validate(expr: Expression, accept: ValidationAcceptor): void {\n // deal with a few cases where reference resolution fail silently\n if (!expr.$resolvedType) {\n if (isAuthInvocation(expr)) {\n // check was done at link time\n accept(\n 'error',\n 'auth() cannot be resolved because no model marked with \"@@auth()\" or named \"User\" is found',\n { node: expr },\n );\n } else {\n const hasReferenceResolutionError = AstUtils.streamAst(expr).some((node) => {\n if (isMemberAccessExpr(node)) {\n return !!node.member.error;\n }\n if (isReferenceExpr(node)) {\n return !!node.target.error;\n }\n return false;\n });\n if (!hasReferenceResolutionError) {\n // report silent errors not involving linker errors\n accept('error', 'Expression cannot be resolved', {\n node: expr,\n });\n }\n }\n }\n\n // extra validations by expression type\n switch (expr.$type) {\n case 'BinaryExpr':\n this.validateBinaryExpr(expr, accept);\n break;\n }\n }\n\n private validateBinaryExpr(expr: BinaryExpr, accept: ValidationAcceptor) {\n switch (expr.operator) {\n case 'in': {\n if (typeof expr.left.$resolvedType?.decl !== 'string' && !isEnum(expr.left.$resolvedType?.decl)) {\n accept('error', 'left operand of \"in\" must be of scalar type', { node: expr.left });\n }\n\n if (!expr.right.$resolvedType?.array) {\n accept('error', 'right operand of \"in\" must be an array', {\n node: expr.right,\n });\n }\n\n break;\n }\n\n case '>':\n case '>=':\n case '<':\n case '<=':\n case '&&':\n case '||': {\n if (expr.left.$resolvedType?.array) {\n accept('error', 'operand cannot be an array', {\n node: expr.left,\n });\n break;\n }\n\n if (expr.right.$resolvedType?.array) {\n accept('error', 'operand cannot be an array', {\n node: expr.right,\n });\n break;\n }\n\n let supportedShapes: ExpressionType[];\n if (['>', '>=', '<', '<='].includes(expr.operator)) {\n supportedShapes = ['Int', 'Float', 'DateTime', 'Any'];\n } else {\n supportedShapes = ['Boolean', 'Any'];\n }\n\n if (\n typeof expr.left.$resolvedType?.decl !== 'string' ||\n !supportedShapes.includes(expr.left.$resolvedType.decl)\n ) {\n accept('error', `invalid operand type for \"${expr.operator}\" operator`, {\n node: expr.left,\n });\n return;\n }\n if (\n typeof expr.right.$resolvedType?.decl !== 'string' ||\n !supportedShapes.includes(expr.right.$resolvedType.decl)\n ) {\n accept('error', `invalid operand type for \"${expr.operator}\" operator`, {\n node: expr.right,\n });\n return;\n }\n\n // DateTime comparison is only allowed between two DateTime values\n if (expr.left.$resolvedType.decl === 'DateTime' && expr.right.$resolvedType.decl !== 'DateTime') {\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n } else if (\n expr.right.$resolvedType.decl === 'DateTime' &&\n expr.left.$resolvedType.decl !== 'DateTime'\n ) {\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n }\n break;\n }\n\n case '==':\n case '!=': {\n if (this.isInValidationContext(expr)) {\n // in validation context, all fields are optional, so we should allow\n // comparing any field against null\n if (\n (isDataFieldReference(expr.left) && isNullExpr(expr.right)) ||\n (isDataFieldReference(expr.right) && isNullExpr(expr.left))\n ) {\n return;\n }\n }\n\n if (!!expr.left.$resolvedType?.array !== !!expr.right.$resolvedType?.array) {\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n break;\n }\n\n if (\n (expr.left.$resolvedType?.nullable && isNullExpr(expr.right)) ||\n (expr.right.$resolvedType?.nullable && isNullExpr(expr.left))\n ) {\n // comparing nullable field with null\n return;\n }\n\n if (\n typeof expr.left.$resolvedType?.decl === 'string' &&\n typeof expr.right.$resolvedType?.decl === 'string'\n ) {\n // scalar types assignability\n if (\n !typeAssignable(expr.left.$resolvedType.decl, expr.right.$resolvedType.decl) &&\n !typeAssignable(expr.right.$resolvedType.decl, expr.left.$resolvedType.decl)\n ) {\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n }\n return;\n }\n\n // disallow comparing model type with scalar type or comparison between\n // incompatible model types\n const leftType = expr.left.$resolvedType?.decl;\n const rightType = expr.right.$resolvedType?.decl;\n if (isDataModel(leftType) && isDataModel(rightType)) {\n if (leftType != rightType) {\n // incompatible model types\n // TODO: inheritance case?\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n }\n\n // not supported:\n // - foo == bar\n // - foo == this\n if (\n isDataFieldReference(expr.left) &&\n (isThisExpr(expr.right) || isDataFieldReference(expr.right))\n ) {\n accept('error', 'comparison between model-typed fields are not supported', { node: expr });\n } else if (\n isDataFieldReference(expr.right) &&\n (isThisExpr(expr.left) || isDataFieldReference(expr.left))\n ) {\n accept('error', 'comparison between model-typed fields are not supported', { node: expr });\n }\n } else if (\n (isDataModel(leftType) && !isNullExpr(expr.right)) ||\n (isDataModel(rightType) && !isNullExpr(expr.left))\n ) {\n // comparing model against scalar (except null)\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n }\n break;\n }\n\n case '?':\n case '!':\n case '^':\n this.validateCollectionPredicate(expr, accept);\n break;\n }\n }\n\n private validateCollectionPredicate(expr: BinaryExpr, accept: ValidationAcceptor) {\n if (!expr.$resolvedType) {\n accept('error', 'collection predicate can only be used on an array of model type', { node: expr });\n return;\n }\n }\n\n private isInValidationContext(node: AstNode) {\n return findUpAst(node, (n) => isDataModelAttribute(n) && n.decl.$refText === '@@validate');\n }\n\n private isNotModelFieldExpr(expr: Expression): boolean {\n return (\n // literal\n isLiteralExpr(expr) ||\n // enum field\n isEnumFieldReference(expr) ||\n // null\n isNullExpr(expr) ||\n // `auth()` access\n isAuthOrAuthMemberAccess(expr) ||\n // array\n (isArrayExpr(expr) && expr.items.every((item) => this.isNotModelFieldExpr(item)))\n );\n }\n}\n","import type { ValidationAcceptor } from 'langium';\nimport { FunctionDecl } from '../generated/ast';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport type { AstValidator } from './common';\n\n/**\n * Validates function declarations.\n */\nexport default class FunctionDeclValidator implements AstValidator<FunctionDecl> {\n validate(funcDecl: FunctionDecl, accept: ValidationAcceptor) {\n funcDecl.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n}\n","import { AstUtils, type AstNode, type ValidationAcceptor } from 'langium';\nimport { match, P } from 'ts-pattern';\nimport { ExpressionContext } from '../constants';\nimport {\n Argument,\n DataFieldAttribute,\n DataModel,\n DataModelAttribute,\n Expression,\n FunctionDecl,\n FunctionParam,\n InvocationExpr,\n isDataFieldAttribute,\n isDataModel,\n isDataModelAttribute,\n} from '../generated/ast';\nimport {\n getFunctionExpressionContext,\n getLiteral,\n isCheckInvocation,\n isDataFieldReference,\n isFromStdlib,\n typeAssignable,\n} from '../utils';\nimport type { AstValidator } from './common';\n\n// a registry of function handlers marked with @func\nconst invocationCheckers = new Map<string, PropertyDescriptor>();\n\n// function handler decorator\nfunction func(name: string) {\n return function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) {\n if (!invocationCheckers.get(name)) {\n invocationCheckers.set(name, descriptor);\n }\n return descriptor;\n };\n}\n/**\n * InvocationExpr validation\n */\nexport default class FunctionInvocationValidator implements AstValidator<Expression> {\n validate(expr: InvocationExpr, accept: ValidationAcceptor): void {\n const funcDecl = expr.function.ref;\n if (!funcDecl) {\n accept('error', 'function cannot be resolved', { node: expr });\n return;\n }\n\n if (!this.validateArgs(funcDecl, expr.args, accept)) {\n return;\n }\n\n if (isFromStdlib(funcDecl)) {\n // validate standard library functions\n\n // find the containing attribute context for the invocation\n let curr: AstNode | undefined = expr.$container;\n let containerAttribute: DataModelAttribute | DataFieldAttribute | undefined;\n while (curr) {\n if (isDataModelAttribute(curr) || isDataFieldAttribute(curr)) {\n containerAttribute = curr;\n break;\n }\n curr = curr.$container;\n }\n\n // validate the context allowed for the function\n const exprContext = match(containerAttribute?.decl.$refText)\n .with('@default', () => ExpressionContext.DefaultValue)\n .with(P.union('@@allow', '@@deny', '@allow', '@deny'), () => ExpressionContext.AccessPolicy)\n .with('@@validate', () => ExpressionContext.ValidationRule)\n .with('@@index', () => ExpressionContext.Index)\n .otherwise(() => undefined);\n\n // get the context allowed for the function\n const funcAllowedContext = getFunctionExpressionContext(funcDecl);\n\n if (exprContext && !funcAllowedContext.includes(exprContext)) {\n accept('error', `function \"${funcDecl.name}\" is not allowed in the current context: ${exprContext}`, {\n node: expr,\n });\n return;\n }\n\n // TODO: express function validation rules declaratively in ZModel\n\n const allCasing = ['original', 'upper', 'lower', 'capitalize', 'uncapitalize'];\n if (['currentModel', 'currentOperation'].includes(funcDecl.name)) {\n const arg = getLiteral<string>(expr.args[0]?.value);\n if (arg && !allCasing.includes(arg)) {\n accept('error', `argument must be one of: ${allCasing.map((c) => '\"' + c + '\"').join(', ')}`, {\n node: expr.args[0]!,\n });\n }\n }\n }\n\n // run checkers for specific functions\n const checker = invocationCheckers.get(expr.function.$refText);\n if (checker) {\n checker.value.call(this, expr, accept);\n }\n }\n\n private validateArgs(funcDecl: FunctionDecl, args: Argument[], accept: ValidationAcceptor) {\n let success = true;\n for (let i = 0; i < funcDecl.params.length; i++) {\n const param = funcDecl.params[i];\n if (!param) {\n continue;\n }\n const arg = args[i];\n if (!arg) {\n if (!param.optional) {\n accept('error', `missing argument for parameter \"${param.name}\"`, { node: funcDecl });\n success = false;\n }\n } else {\n if (!this.validateInvocationArg(arg, param, accept)) {\n success = false;\n }\n }\n }\n // TODO: do we need to complain for extra arguments?\n return success;\n }\n\n private validateInvocationArg(arg: Argument, param: FunctionParam, accept: ValidationAcceptor) {\n const argResolvedType = arg?.value?.$resolvedType;\n if (!argResolvedType) {\n accept('error', 'argument type cannot be resolved', { node: arg });\n return false;\n }\n\n const dstType = param.type.type;\n if (!dstType) {\n accept('error', 'parameter type cannot be resolved', {\n node: param,\n });\n return false;\n }\n\n const dstIsArray = param.type.array;\n const dstRef = param.type.reference;\n\n if (dstType === 'Any' && !dstIsArray) {\n // scalar 'any' can be assigned with anything\n return true;\n }\n\n if (typeof argResolvedType.decl === 'string') {\n // scalar type\n if (!typeAssignable(dstType, argResolvedType.decl, arg.value) || dstIsArray !== argResolvedType.array) {\n accept('error', `argument is not assignable to parameter`, {\n node: arg,\n });\n return false;\n }\n } else {\n // enum or model type\n if ((dstRef?.ref !== argResolvedType.decl && dstType !== 'Any') || dstIsArray !== argResolvedType.array) {\n accept('error', `argument is not assignable to parameter`, {\n node: arg,\n });\n return false;\n }\n }\n\n return true;\n }\n\n @func('check')\n // @ts-expect-error\n private _checkCheck(expr: InvocationExpr, accept: ValidationAcceptor) {\n let valid = true;\n\n const fieldArg = expr.args[0]!.value;\n if (!isDataFieldReference(fieldArg) || !isDataModel(fieldArg.$resolvedType?.decl)) {\n accept('error', 'argument must be a relation field', {\n node: expr.args[0]!,\n });\n valid = false;\n }\n\n if (fieldArg.$resolvedType?.array) {\n accept('error', 'argument cannot be an array field', {\n node: expr.args[0]!,\n });\n valid = false;\n }\n\n const opArg = expr.args[1]?.value;\n if (opArg) {\n const operation = getLiteral<string>(opArg);\n if (!operation || !['read', 'create', 'update', 'delete'].includes(operation)) {\n accept('error', 'argument must be a \"read\", \"create\", \"update\", or \"delete\"', { node: expr.args[1]! });\n valid = false;\n }\n }\n\n if (!valid) {\n return;\n }\n\n // check for cyclic relation checking\n const start = fieldArg.$resolvedType?.decl as DataModel;\n const tasks = [expr];\n const seen = new Set<DataModel>();\n\n while (tasks.length > 0) {\n const currExpr = tasks.pop()!;\n const arg = currExpr.args[0]?.value;\n\n if (!isDataModel(arg?.$resolvedType?.decl)) {\n continue;\n }\n\n const currModel = arg!.$resolvedType!.decl;\n\n if (seen.has(currModel)) {\n if (currModel === start) {\n accept('error', 'cyclic dependency detected when following the `check()` call', { node: expr });\n } else {\n // a cycle is detected but it doesn't start from the invocation expression we're checking,\n // just break here and the cycle will be reported when we validate the start of it\n }\n break;\n } else {\n seen.add(currModel);\n }\n\n const policyAttrs = currModel.attributes.filter(\n (attr) => attr.decl.$refText === '@@allow' || attr.decl.$refText === '@@deny',\n );\n for (const attr of policyAttrs) {\n const rule = attr.args[1];\n if (!rule) {\n continue;\n }\n AstUtils.streamAst(rule).forEach((node) => {\n if (isCheckInvocation(node)) {\n tasks.push(node as InvocationExpr);\n }\n });\n }\n }\n }\n}\n","import type { LangiumDocuments, ValidationAcceptor } from 'langium';\nimport { PLUGIN_MODULE_NAME, STD_LIB_MODULE_NAME } from '../constants';\nimport { isDataSource, type Model } from '../generated/ast';\nimport { getAllDeclarationsIncludingImports, resolveImport, resolveTransitiveImports } from '../utils';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates toplevel schema.\n */\nexport default class SchemaValidator implements AstValidator<Model> {\n constructor(protected readonly documents: LangiumDocuments) {}\n\n validate(model: Model, accept: ValidationAcceptor) {\n this.validateImports(model, accept);\n validateDuplicatedDeclarations(model, model.declarations, accept);\n\n const importedModels = resolveTransitiveImports(this.documents, model);\n\n const importedNames = new Set(importedModels.flatMap((m) => m.declarations.map((d) => d.name)));\n\n for (const declaration of model.declarations) {\n if (importedNames.has(declaration.name)) {\n accept('error', `A ${declaration.name} already exists in an imported module`, {\n node: declaration,\n property: 'name',\n });\n }\n }\n\n if (\n !model.$document?.uri.path.endsWith(STD_LIB_MODULE_NAME) &&\n !model.$document?.uri.path.endsWith(PLUGIN_MODULE_NAME)\n ) {\n this.validateDataSources(model, accept);\n }\n }\n\n private async validateDataSources(model: Model, accept: ValidationAcceptor) {\n const dataSources = (await getAllDeclarationsIncludingImports(this.documents, model)).filter((d) =>\n isDataSource(d),\n );\n if (dataSources.length > 1) {\n accept('error', 'Multiple datasource declarations are not allowed', { node: dataSources[1]! });\n }\n }\n\n private validateImports(model: Model, accept: ValidationAcceptor) {\n model.imports.forEach((imp) => {\n const importedModel = resolveImport(this.documents, imp);\n if (!importedModel) {\n const importPath = imp.path.endsWith('.zmodel') ? imp.path : `${imp.path}.zmodel`;\n accept('error', `Cannot find model file ${importPath}`, {\n node: imp,\n });\n }\n });\n }\n}\n","import type { ValidationAcceptor } from 'langium';\nimport type { TypeDef, TypeDefField } from '../generated/ast';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates type def declarations.\n */\nexport default class TypeDefValidator implements AstValidator<TypeDef> {\n validate(typeDef: TypeDef, accept: ValidationAcceptor): void {\n validateDuplicatedDeclarations(typeDef, typeDef.fields, accept);\n this.validateAttributes(typeDef, accept);\n this.validateFields(typeDef, accept);\n }\n\n private validateAttributes(typeDef: TypeDef, accept: ValidationAcceptor) {\n typeDef.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n\n private validateFields(typeDef: TypeDef, accept: ValidationAcceptor) {\n typeDef.fields.forEach((field) => this.validateField(field, accept));\n }\n\n private validateField(field: TypeDefField, accept: ValidationAcceptor): void {\n field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n}\n","/* eslint-disable @typescript-eslint/no-unused-expressions */\n\nimport type { AstNode, LangiumDocument, ValidationAcceptor, ValidationChecks } from 'langium';\nimport type {\n Attribute,\n DataModel,\n DataSource,\n Enum,\n Expression,\n FunctionDecl,\n InvocationExpr,\n Model,\n TypeDef,\n ZModelAstType,\n} from './generated/ast';\nimport type { ZModelServices } from './module';\nimport AttributeValidator from './validators/attribute-validator';\nimport DataModelValidator from './validators/datamodel-validator';\nimport DataSourceValidator from './validators/datasource-validator';\nimport EnumValidator from './validators/enum-validator';\nimport ExpressionValidator from './validators/expression-validator';\nimport FunctionDeclValidator from './validators/function-decl-validator';\nimport FunctionInvocationValidator from './validators/function-invocation-validator';\nimport SchemaValidator from './validators/schema-validator';\nimport TypeDefValidator from './validators/typedef-validator';\n\n/**\n * Register custom validation checks.\n */\nexport function registerValidationChecks(services: ZModelServices) {\n const registry = services.validation.ValidationRegistry;\n const validator = services.validation.ZModelValidator;\n const checks: ValidationChecks<ZModelAstType> = {\n Model: validator.checkModel,\n DataSource: validator.checkDataSource,\n DataModel: validator.checkDataModel,\n TypeDef: validator.checkTypeDef,\n Enum: validator.checkEnum,\n Attribute: validator.checkAttribute,\n Expression: validator.checkExpression,\n InvocationExpr: validator.checkFunctionInvocation,\n FunctionDecl: validator.checkFunctionDecl,\n };\n registry.register(checks, validator);\n}\n\n/**\n * Implementation of custom validations.\n */\nexport class ZModelValidator {\n constructor(protected readonly services: ZModelServices) {}\n\n private shouldCheck(node: AstNode) {\n let doc: LangiumDocument | undefined;\n let currNode: AstNode | undefined = node;\n while (currNode) {\n if (currNode.$document) {\n doc = currNode.$document;\n break;\n }\n currNode = currNode.$container;\n }\n\n return doc?.parseResult.lexerErrors.length === 0 && doc?.parseResult.parserErrors.length === 0;\n }\n\n checkModel(node: Model, accept: ValidationAcceptor): void {\n this.shouldCheck(node) &&\n new SchemaValidator(this.services.shared.workspace.LangiumDocuments).validate(node, accept);\n }\n\n checkDataSource(node: DataSource, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new DataSourceValidator().validate(node, accept);\n }\n\n checkDataModel(node: DataModel, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new DataModelValidator().validate(node, accept);\n }\n\n checkTypeDef(node: TypeDef, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new TypeDefValidator().validate(node, accept);\n }\n\n checkEnum(node: Enum, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new EnumValidator().validate(node, accept);\n }\n\n checkAttribute(node: Attribute, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new AttributeValidator().validate(node, accept);\n }\n\n checkExpression(node: Expression, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new ExpressionValidator().validate(node, accept);\n }\n\n checkFunctionInvocation(node: InvocationExpr, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new FunctionInvocationValidator().validate(node, accept);\n }\n\n checkFunctionDecl(node: FunctionDecl, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new FunctionDeclValidator().validate(node, accept);\n }\n}\n","import {\n type AstNode,\n type AstNodeDescription,\n type AstNodeDescriptionProvider,\n AstUtils,\n Cancellation,\n DefaultLinker,\n DocumentState,\n type LangiumCoreServices,\n type LangiumDocument,\n type LinkingError,\n type Reference,\n interruptAndCheck,\n isReference,\n} from 'langium';\nimport { match } from 'ts-pattern';\nimport {\n ArrayExpr,\n AttributeArg,\n AttributeParam,\n BinaryExpr,\n BooleanLiteral,\n DataField,\n DataFieldType,\n DataModel,\n Enum,\n EnumField,\n type ExpressionType,\n FunctionDecl,\n FunctionParam,\n FunctionParamType,\n InvocationExpr,\n LiteralExpr,\n MemberAccessExpr,\n NullExpr,\n NumberLiteral,\n ObjectExpr,\n ReferenceExpr,\n ReferenceTarget,\n type ResolvedShape,\n StringLiteral,\n ThisExpr,\n UnaryExpr,\n isArrayExpr,\n isBooleanLiteral,\n isDataField,\n isDataFieldType,\n isDataModel,\n isEnum,\n isNumberLiteral,\n isReferenceExpr,\n isStringLiteral,\n} from './ast';\nimport {\n getAllFields,\n getAllLoadedAndReachableDataModelsAndTypeDefs,\n getAuthDecl,\n getContainingDataModel,\n isAuthInvocation,\n isFutureExpr,\n isMemberContainer,\n mapBuiltinTypeToExpressionType,\n} from './utils';\n\ninterface DefaultReference extends Reference {\n _ref?: AstNode | LinkingError;\n _nodeDescription?: AstNodeDescription;\n}\n\ntype ScopeProvider = (name: string) => ReferenceTarget | DataModel | undefined;\n\n/**\n * Langium linker implementation which links references and resolves expression types\n */\nexport class ZModelLinker extends DefaultLinker {\n private readonly descriptions: AstNodeDescriptionProvider;\n\n constructor(services: LangiumCoreServices) {\n super(services);\n this.descriptions = services.workspace.AstNodeDescriptionProvider;\n }\n\n //#region Reference linking\n\n override async link(document: LangiumDocument, cancelToken = Cancellation.CancellationToken.None): Promise<void> {\n if (document.parseResult.lexerErrors?.length > 0 || document.parseResult.parserErrors?.length > 0) {\n return;\n }\n\n for (const node of AstUtils.streamContents(document.parseResult.value)) {\n await interruptAndCheck(cancelToken);\n this.resolve(node, document);\n }\n document.state = DocumentState.Linked;\n }\n\n private linkReference(\n container: AstNode,\n property: string,\n document: LangiumDocument,\n extraScopes: ScopeProvider[],\n ) {\n if (this.resolveFromScopeProviders(container, property, document, extraScopes)) {\n return;\n }\n\n const reference: DefaultReference = (container as any)[property];\n this.doLink({ reference, container, property }, document);\n }\n\n //#endregion\n\n //#region Expression type resolving\n\n private resolveFromScopeProviders(\n node: AstNode,\n property: string,\n document: LangiumDocument,\n providers: ScopeProvider[],\n ) {\n const reference: DefaultReference = (node as any)[property];\n for (const provider of providers) {\n const target = provider(reference.$refText);\n if (target) {\n reference._ref = target;\n reference._nodeDescription = this.descriptions.createDescription(target, target.name, document);\n\n // Add the reference to the document's array of references\n document.references.push(reference);\n\n return target;\n }\n }\n return null;\n }\n\n private resolve(node: AstNode, document: LangiumDocument, extraScopes: ScopeProvider[] = []) {\n switch (node.$type) {\n case StringLiteral:\n case NumberLiteral:\n case BooleanLiteral:\n this.resolveLiteral(node as LiteralExpr);\n break;\n\n case InvocationExpr:\n this.resolveInvocation(node as InvocationExpr, document, extraScopes);\n break;\n\n case ArrayExpr:\n this.resolveArray(node as ArrayExpr, document, extraScopes);\n break;\n\n case ReferenceExpr:\n this.resolveReference(node as ReferenceExpr, document, extraScopes);\n break;\n\n case MemberAccessExpr:\n this.resolveMemberAccess(node as MemberAccessExpr, document, extraScopes);\n break;\n\n case UnaryExpr:\n this.resolveUnary(node as UnaryExpr, document, extraScopes);\n break;\n\n case BinaryExpr:\n this.resolveBinary(node as BinaryExpr, document, extraScopes);\n break;\n\n case ObjectExpr:\n this.resolveObject(node as ObjectExpr, document, extraScopes);\n break;\n\n case ThisExpr:\n this.resolveThis(node as ThisExpr, document, extraScopes);\n break;\n\n case NullExpr:\n this.resolveNull(node as NullExpr, document, extraScopes);\n break;\n\n case AttributeArg:\n this.resolveAttributeArg(node as AttributeArg, document, extraScopes);\n break;\n\n case DataModel:\n this.resolveDataModel(node as DataModel, document, extraScopes);\n break;\n\n case DataField:\n this.resolveDataField(node as DataField, document, extraScopes);\n break;\n\n default:\n this.resolveDefault(node, document, extraScopes);\n break;\n }\n }\n\n private resolveBinary(node: BinaryExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n switch (node.operator) {\n // TODO: support arithmetics?\n // case '+':\n // case '-':\n // case '*':\n // case '/':\n // this.resolve(node.left, document, extraScopes);\n // this.resolve(node.right, document, extraScopes);\n // this.resolveToBuiltinTypeOrDecl(node, 'Int');\n // break;\n\n case '>':\n case '>=':\n case '<':\n case '<=':\n case '==':\n case '!=':\n case '&&':\n case '||':\n case 'in':\n this.resolve(node.left, document, extraScopes);\n this.resolve(node.right, document, extraScopes);\n this.resolveToBuiltinTypeOrDecl(node, 'Boolean');\n break;\n\n case '?':\n case '!':\n case '^':\n this.resolveCollectionPredicate(node, document, extraScopes);\n break;\n\n default:\n throw Error(`Unsupported binary operator: ${node.operator}`);\n }\n }\n\n private resolveUnary(node: UnaryExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n this.resolve(node.operand, document, extraScopes);\n switch (node.operator) {\n case '!':\n this.resolveToBuiltinTypeOrDecl(node, 'Boolean');\n break;\n default:\n throw Error(`Unsupported unary operator: ${node.operator}`);\n }\n }\n\n private resolveObject(node: ObjectExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n node.fields.forEach((field) => this.resolve(field.value, document, extraScopes));\n this.resolveToBuiltinTypeOrDecl(node, 'Object');\n }\n\n private resolveReference(node: ReferenceExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n this.resolveDefault(node, document, extraScopes);\n\n if (node.target.ref) {\n // resolve type\n if (node.target.ref.$type === EnumField) {\n this.resolveToBuiltinTypeOrDecl(node, node.target.ref.$container);\n } else {\n this.resolveToDeclaredType(node, (node.target.ref as DataField | FunctionParam).type);\n }\n }\n }\n\n private resolveArray(node: ArrayExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n node.items.forEach((item) => this.resolve(item, document, extraScopes));\n\n if (node.items.length > 0) {\n const itemType = node.items[0]!.$resolvedType;\n if (itemType?.decl) {\n this.resolveToBuiltinTypeOrDecl(node, itemType.decl, true);\n }\n } else {\n this.resolveToBuiltinTypeOrDecl(node, 'Any', true);\n }\n }\n\n private resolveInvocation(node: InvocationExpr, document: LangiumDocument, extraScopes: ScopeProvider[]) {\n this.linkReference(node, 'function', document, extraScopes);\n node.args.forEach((arg) => this.resolve(arg, document, extraScopes));\n if (node.function.ref) {\n const funcDecl = node.function.ref as FunctionDecl;\n\n if (isAuthInvocation(node)) {\n // auth() function is resolved against all loaded and reachable documents\n\n // get all data models from loaded and reachable documents\n const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(\n this.langiumDocuments(),\n AstUtils.getContainerOfType(node, isDataModel),\n );\n\n const authDecl = getAuthDecl(allDecls);\n if (authDecl) {\n node.$resolvedType = { decl: authDecl, nullable: true };\n }\n } else if (isFutureExpr(node)) {\n // future() function is resolved to current model\n node.$resolvedType = { decl: getContainingDataModel(node) };\n } else {\n this.resolveToDeclaredType(node, funcDecl.returnType);\n }\n }\n }\n\n private resolveLiteral(node: LiteralExpr) {\n const type = match<LiteralExpr, ExpressionType>(node)\n .when(isStringLiteral, () => 'String')\n .when(isBooleanLiteral, () => 'Boolean')\n .when(isNumberLiteral, () => 'Int')\n .exhaustive();\n\n if (type) {\n this.resolveToBuiltinTypeOrDecl(node, type);\n }\n }\n\n private resolveMemberAccess(\n node: MemberAccessExpr,\n document: LangiumDocument<AstNode>,\n extraScopes: ScopeProvider[],\n ) {\n this.resolveDefault(node, document, extraScopes);\n const operandResolved = node.operand.$resolvedType;\n\n if (operandResolved && !operandResolved.array && isMemberContainer(operandResolved.decl)) {\n // member access is resolved only in the context of the operand type\n if (node.member.ref) {\n this.resolveToDeclaredType(node, node.member.ref.type);\n if (node.$resolvedType && isAuthInvocation(node.operand)) {\n // member access on auth() function is nullable\n // because user may not have provided all fields\n node.$resolvedType.nullable = true;\n }\n }\n }\n }\n\n private resolveCollectionPredicate(node: BinaryExpr, document: LangiumDocument, extraScopes: ScopeProvider[]) {\n this.resolveDefault(node, document, extraScopes);\n\n const resolvedType = node.left.$resolvedType;\n if (resolvedType && isMemberContainer(resolvedType.decl) && resolvedType.array) {\n this.resolveToBuiltinTypeOrDecl(node, 'Boolean');\n } else {\n // error is reported in validation pass\n }\n }\n\n private resolveThis(node: ThisExpr, _document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n // resolve from scopes first\n for (const scope of extraScopes) {\n const r = scope('this');\n if (isDataModel(r)) {\n this.resolveToBuiltinTypeOrDecl(node, r);\n return;\n }\n }\n\n let decl: AstNode | undefined = node.$container;\n\n while (decl && !isDataModel(decl)) {\n decl = decl.$container;\n }\n\n if (decl) {\n this.resolveToBuiltinTypeOrDecl(node, decl);\n }\n }\n\n private resolveNull(node: NullExpr, _document: LangiumDocument<AstNode>, _extraScopes: ScopeProvider[]) {\n // TODO: how to really resolve null?\n this.resolveToBuiltinTypeOrDecl(node, 'Null');\n }\n\n private resolveAttributeArg(node: AttributeArg, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n const attrParam = this.findAttrParamForArg(node);\n const attrAppliedOn = node.$container.$container;\n\n if (attrParam?.type.type === 'TransitiveFieldReference' && isDataField(attrAppliedOn)) {\n // \"TransitiveFieldReference\" is resolved in the context of the containing model of the field\n // where the attribute is applied\n //\n // E.g.:\n //\n // model A {\n // myId @id String\n // }\n //\n // model B {\n // id @id String\n // a A @relation(fields: [id], references: [myId])\n // }\n //\n // In model B, the attribute argument \"myId\" is resolved to the field \"myId\" in model A\n\n const transitiveDataModel = attrAppliedOn.type.reference?.ref as DataModel;\n if (transitiveDataModel) {\n // resolve references in the context of the transitive data model\n const scopeProvider = (name: string) => getAllFields(transitiveDataModel).find((f) => f.name === name);\n if (isArrayExpr(node.value)) {\n node.value.items.forEach((item) => {\n if (isReferenceExpr(item)) {\n const resolved = this.resolveFromScopeProviders(item, 'target', document, [scopeProvider]);\n if (resolved) {\n this.resolveToDeclaredType(item, (resolved as DataField).type);\n } else {\n // mark unresolvable\n this.unresolvableRefExpr(item);\n }\n }\n });\n if (node.value.items[0]?.$resolvedType?.decl) {\n this.resolveToBuiltinTypeOrDecl(node.value, node.value.items[0].$resolvedType.decl, true);\n }\n } else if (isReferenceExpr(node.value)) {\n const resolved = this.resolveFromScopeProviders(node.value, 'target', document, [scopeProvider]);\n if (resolved) {\n this.resolveToDeclaredType(node.value, (resolved as DataField).type);\n } else {\n // mark unresolvable\n this.unresolvableRefExpr(node.value);\n }\n }\n }\n } else {\n this.resolve(node.value, document, extraScopes);\n }\n node.$resolvedType = node.value.$resolvedType;\n }\n\n private unresolvableRefExpr(item: ReferenceExpr) {\n const ref = item.target as DefaultReference;\n ref._ref = this.createLinkingError({\n reference: ref,\n container: item,\n property: 'target',\n });\n }\n\n private findAttrParamForArg(arg: AttributeArg): AttributeParam | undefined {\n const attr = arg.$container.decl.ref;\n if (!attr) {\n return undefined;\n }\n if (arg.name) {\n return attr.params?.find((p) => p.name === arg.name);\n } else {\n const index = arg.$container.args.findIndex((a) => a === arg);\n return attr.params[index];\n }\n }\n\n private resolveDataModel(node: DataModel, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n return this.resolveDefault(node, document, extraScopes);\n }\n\n private resolveDataField(node: DataField, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n // Field declaration may contain enum references, and enum fields are pushed to the global\n // scope, so if there're enums with fields with the same name, an arbitrary one will be\n // used as resolution target. The correct behavior is to resolve to the enum that's used\n // as the declaration type of the field:\n //\n // enum FirstEnum {\n // E1\n // E2\n // }\n\n // enum SecondEnum {\n // E1\n // E3\n // E4\n // }\n\n // model M {\n // id Int @id\n // first SecondEnum @default(E1) <- should resolve to SecondEnum\n // second FirstEnum @default(E1) <- should resolve to FirstEnum\n // }\n //\n\n // make sure type is resolved first\n this.resolve(node.type, document, extraScopes);\n\n let scopes = extraScopes;\n\n // if the field has enum declaration type, resolve the rest with that enum's fields on top of the scopes\n if (node.type.reference?.ref && isEnum(node.type.reference.ref)) {\n const contextEnum = node.type.reference.ref as Enum;\n const enumScope: ScopeProvider = (name) => contextEnum.fields.find((f) => f.name === name);\n scopes = [enumScope, ...scopes];\n }\n\n this.resolveDefault(node, document, scopes);\n }\n\n private resolveDefault(node: AstNode, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n for (const [property, value] of Object.entries(node)) {\n if (!property.startsWith('$')) {\n if (isReference(value)) {\n this.linkReference(node, property, document, extraScopes);\n }\n }\n }\n for (const child of AstUtils.streamContents(node)) {\n this.resolve(child, document, extraScopes);\n }\n }\n\n //#endregion\n\n //#region Utils\n\n private resolveToDeclaredType(node: AstNode, type: FunctionParamType | DataFieldType) {\n let nullable = false;\n if (isDataFieldType(type)) {\n nullable = type.optional;\n\n // referencing a field of 'Unsupported' type\n if (type.unsupported) {\n node.$resolvedType = {\n decl: 'Unsupported',\n array: type.array,\n nullable,\n };\n return;\n }\n }\n\n if (type.type) {\n const mappedType = mapBuiltinTypeToExpressionType(type.type);\n node.$resolvedType = {\n decl: mappedType,\n array: type.array,\n nullable: nullable,\n };\n } else if (type.reference) {\n node.$resolvedType = {\n decl: type.reference.ref,\n array: type.array,\n nullable: nullable,\n };\n }\n }\n\n private resolveToBuiltinTypeOrDecl(node: AstNode, type: ResolvedShape, array = false, nullable = false) {\n node.$resolvedType = { decl: type, array, nullable };\n }\n\n //#endregion\n}\n","import {\n AstUtils,\n Cancellation,\n DefaultScopeComputation,\n DefaultScopeProvider,\n EMPTY_SCOPE,\n StreamScope,\n UriUtils,\n interruptAndCheck,\n type AstNode,\n type AstNodeDescription,\n type LangiumCoreServices,\n type LangiumDocument,\n type PrecomputedScopes,\n type ReferenceInfo,\n type Scope,\n} from 'langium';\nimport { match } from 'ts-pattern';\nimport {\n BinaryExpr,\n MemberAccessExpr,\n isDataField,\n isDataModel,\n isEnumField,\n isInvocationExpr,\n isMemberAccessExpr,\n isModel,\n isReferenceExpr,\n isThisExpr,\n isTypeDef,\n} from './ast';\nimport { PLUGIN_MODULE_NAME, STD_LIB_MODULE_NAME } from './constants';\nimport {\n getAllFields,\n getAllLoadedAndReachableDataModelsAndTypeDefs,\n getAuthDecl,\n getRecursiveBases,\n isAuthInvocation,\n isCollectionPredicate,\n isFutureInvocation,\n resolveImportUri,\n} from './utils';\n\n/**\n * Custom Langium ScopeComputation implementation which adds enum fields into global scope\n */\nexport class ZModelScopeComputation extends DefaultScopeComputation {\n constructor(private readonly services: LangiumCoreServices) {\n super(services);\n }\n\n override async computeExports(\n document: LangiumDocument<AstNode>,\n cancelToken?: Cancellation.CancellationToken | undefined,\n ): Promise<AstNodeDescription[]> {\n const result = await super.computeExports(document, cancelToken);\n\n // add enum fields so they can be globally resolved across modules\n for (const node of AstUtils.streamAllContents(document.parseResult.value)) {\n if (cancelToken) {\n await interruptAndCheck(cancelToken);\n }\n if (isEnumField(node)) {\n const desc = this.services.workspace.AstNodeDescriptionProvider.createDescription(\n node,\n node.name,\n document,\n );\n result.push(desc);\n }\n }\n\n return result;\n }\n\n override processNode(node: AstNode, document: LangiumDocument<AstNode>, scopes: PrecomputedScopes) {\n super.processNode(node, document, scopes);\n if (isDataModel(node)) {\n // add base fields to the scope recursively\n const bases = getRecursiveBases(node);\n for (const base of bases) {\n for (const field of base.fields) {\n scopes.add(node, this.descriptions.createDescription(field, this.nameProvider.getName(field)));\n }\n }\n }\n }\n}\n\nexport class ZModelScopeProvider extends DefaultScopeProvider {\n constructor(private readonly services: LangiumCoreServices) {\n super(services);\n }\n\n protected override getGlobalScope(referenceType: string, context: ReferenceInfo): Scope {\n const model = AstUtils.getContainerOfType(context.container, isModel);\n if (!model) {\n return EMPTY_SCOPE;\n }\n\n const importedUris = model.imports.map(resolveImportUri).filter((url) => !!url);\n\n const importedElements = this.indexManager.allElements(referenceType).filter(\n (des) =>\n // allow current document\n UriUtils.equals(des.documentUri, model.$document?.uri) ||\n // allow stdlib\n des.documentUri.path.endsWith(STD_LIB_MODULE_NAME) ||\n // allow plugin models\n des.documentUri.path.endsWith(PLUGIN_MODULE_NAME) ||\n // allow imported documents\n importedUris.some((importedUri) => UriUtils.equals(des.documentUri, importedUri)),\n );\n return new StreamScope(importedElements);\n }\n\n override getScope(context: ReferenceInfo): Scope {\n if (isMemberAccessExpr(context.container) && context.container.operand && context.property === 'member') {\n return this.getMemberAccessScope(context);\n }\n\n if (isReferenceExpr(context.container) && context.property === 'target') {\n // when reference expression is resolved inside a collection predicate, the scope is the collection\n const containerCollectionPredicate = getCollectionPredicateContext(context.container);\n if (containerCollectionPredicate) {\n return this.getCollectionPredicateScope(context, containerCollectionPredicate as BinaryExpr);\n }\n }\n\n return super.getScope(context);\n }\n\n private getMemberAccessScope(context: ReferenceInfo) {\n const referenceType = this.reflection.getReferenceType(context);\n const globalScope = this.getGlobalScope(referenceType, context);\n const node = context.container as MemberAccessExpr;\n\n // typedef's fields are only added to the scope if the access starts with `auth().`\n // or the member access resides inside a typedef\n const allowTypeDefScope =\n // isAuthOrAuthMemberAccess(node.operand) ||\n !!AstUtils.getContainerOfType(node, isTypeDef);\n\n return match(node.operand)\n .when(isReferenceExpr, (operand) => {\n // operand is a reference, it can only be a model/type-def field\n const ref = operand.target.ref;\n if (isDataField(ref)) {\n return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);\n }\n return EMPTY_SCOPE;\n })\n .when(isMemberAccessExpr, (operand) => {\n // operand is a member access, it must be resolved to a non-array model/typedef type\n const ref = operand.member.ref;\n if (isDataField(ref) && !ref.type.array) {\n return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);\n }\n return EMPTY_SCOPE;\n })\n .when(isThisExpr, () => {\n // operand is `this`, resolve to the containing model\n return this.createScopeForContainingModel(node, globalScope);\n })\n .when(isInvocationExpr, (operand) => {\n // deal with member access from `auth()` and `future()\n\n if (isAuthInvocation(operand)) {\n // resolve to `User` or `@@auth` decl\n return this.createScopeForAuth(node, globalScope);\n }\n\n if (isFutureInvocation(operand)) {\n // resolve `future()` to the containing model\n return this.createScopeForContainingModel(node, globalScope);\n }\n return EMPTY_SCOPE;\n })\n .otherwise(() => EMPTY_SCOPE);\n }\n\n private getCollectionPredicateScope(context: ReferenceInfo, collectionPredicate: BinaryExpr) {\n const referenceType = this.reflection.getReferenceType(context);\n const globalScope = this.getGlobalScope(referenceType, context);\n const collection = collectionPredicate.left;\n\n // TODO: generalize it\n // // typedef's fields are only added to the scope if the access starts with `auth().`\n // const allowTypeDefScope = isAuthOrAuthMemberAccess(collection);\n const allowTypeDefScope = false;\n\n return match(collection)\n .when(isReferenceExpr, (expr) => {\n // collection is a reference - model or typedef field\n const ref = expr.target.ref;\n if (isDataField(ref)) {\n return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);\n }\n return EMPTY_SCOPE;\n })\n .when(isMemberAccessExpr, (expr) => {\n // collection is a member access, it can only be resolved to a model or typedef field\n const ref = expr.member.ref;\n if (isDataField(ref)) {\n return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);\n }\n return EMPTY_SCOPE;\n })\n .when(isInvocationExpr, (expr) => {\n const returnTypeDecl = expr.function.ref?.returnType.reference?.ref;\n if (isDataModel(returnTypeDecl)) {\n return this.createScopeForContainer(returnTypeDecl, globalScope, allowTypeDefScope);\n } else {\n return EMPTY_SCOPE;\n }\n })\n .when(isAuthInvocation, (expr) => {\n return this.createScopeForAuth(expr, globalScope);\n })\n .otherwise(() => EMPTY_SCOPE);\n }\n\n private createScopeForContainingModel(node: AstNode, globalScope: Scope) {\n const model = AstUtils.getContainerOfType(node, isDataModel);\n if (model) {\n return this.createScopeForContainer(model, globalScope);\n } else {\n return EMPTY_SCOPE;\n }\n }\n\n private createScopeForContainer(node: AstNode | undefined, globalScope: Scope, includeTypeDefScope = false) {\n if (isDataModel(node)) {\n return this.createScopeForNodes(getAllFields(node), globalScope);\n } else if (includeTypeDefScope && isTypeDef(node)) {\n return this.createScopeForNodes(node.fields, globalScope);\n } else {\n return EMPTY_SCOPE;\n }\n }\n\n private createScopeForAuth(node: AstNode, globalScope: Scope) {\n // get all data models and type defs from loaded and reachable documents\n const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(\n this.services.shared.workspace.LangiumDocuments,\n AstUtils.getContainerOfType(node, isDataModel),\n );\n\n const authDecl = getAuthDecl(decls);\n if (authDecl) {\n return this.createScopeForContainer(authDecl, globalScope, true);\n } else {\n return EMPTY_SCOPE;\n }\n }\n}\n\nfunction getCollectionPredicateContext(node: AstNode) {\n let curr: AstNode | undefined = node;\n while (curr) {\n if (curr.$container && isCollectionPredicate(curr.$container) && curr.$containerProperty === 'right') {\n return curr.$container;\n }\n curr = curr.$container;\n }\n return undefined;\n}\n","import {\n DefaultWorkspaceManager,\n URI,\n UriUtils,\n type AstNode,\n type LangiumDocument,\n type LangiumDocumentFactory,\n type WorkspaceFolder,\n} from 'langium';\nimport type { LangiumSharedServices } from 'langium/lsp';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isPlugin, type Model } from './ast';\nimport { PLUGIN_MODULE_NAME, STD_LIB_MODULE_NAME } from './constants';\nimport { getLiteral } from './utils';\n\nexport class ZModelWorkspaceManager extends DefaultWorkspaceManager {\n private documentFactory: LangiumDocumentFactory;\n\n constructor(services: LangiumSharedServices) {\n super(services);\n this.documentFactory = services.workspace.LangiumDocumentFactory;\n }\n\n protected override async loadAdditionalDocuments(\n folders: WorkspaceFolder[],\n collector: (document: LangiumDocument<AstNode>) => void,\n ): Promise<void> {\n await super.loadAdditionalDocuments(folders, collector);\n\n // load stdlib.zmodel\n let stdLibPath: string;\n\n // First, try to find the stdlib from an installed zenstack package\n // in the project's node_modules\n let installedStdlibPath: string | undefined;\n for (const folder of folders) {\n const folderPath = this.getRootFolder(folder).fsPath;\n try {\n // Try to resolve zenstack from the workspace folder\n const languagePackagePath = require.resolve('@zenstackhq/language/package.json', {\n paths: [folderPath],\n });\n const languagePackageDir = path.dirname(languagePackagePath);\n const candidateStdlibPath = path.join(languagePackageDir, 'res', STD_LIB_MODULE_NAME);\n\n // Check if the stdlib file exists in the installed package\n if (fs.existsSync(candidateStdlibPath)) {\n installedStdlibPath = candidateStdlibPath;\n console.log(`Found installed zenstack package stdlib at: ${installedStdlibPath}`);\n break;\n }\n } catch {\n // Package not found or other error, continue to next folder\n continue;\n }\n }\n\n if (installedStdlibPath) {\n stdLibPath = installedStdlibPath;\n } else {\n // Fallback to bundled stdlib\n // isomorphic __dirname\n const _dirname =\n typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));\n\n stdLibPath = path.join(_dirname, '../res', STD_LIB_MODULE_NAME);\n console.log(`Using bundled stdlib in extension:`, stdLibPath);\n }\n\n const stdlib = await this.documentFactory.fromUri(URI.file(stdLibPath));\n collector(stdlib);\n\n const documents = this.langiumDocuments.all;\n const pluginModels = new Set<string>();\n\n // find plugin models\n documents.forEach((doc) => {\n const parsed = doc.parseResult.value as Model;\n parsed.declarations.forEach((decl) => {\n if (isPlugin(decl)) {\n const providerField = decl.fields.find((f) => f.name === 'provider');\n if (providerField) {\n const provider = getLiteral<string>(providerField.value);\n if (provider) {\n pluginModels.add(provider);\n }\n }\n }\n });\n });\n\n if (pluginModels.size > 0) {\n console.log(`Used plugin modules: ${Array.from(pluginModels)}`);\n\n // the loaded plugin models would be removed from the set\n const pendingPluginModules = new Set(pluginModels);\n\n await Promise.all(\n folders\n .map((wf) => [wf, this.getRootFolder(wf)] as [WorkspaceFolder, URI])\n .map(async (entry) => this.loadPluginModels(...entry, pendingPluginModules, collector)),\n );\n }\n }\n\n protected async loadPluginModels(\n workspaceFolder: WorkspaceFolder,\n folderPath: URI,\n pendingPluginModels: Set<string>,\n collector: (document: LangiumDocument) => void,\n ): Promise<void> {\n const content = (await this.fileSystemProvider.readDirectory(folderPath)).sort((a, b) => {\n // make sure the node_modules folder is always the first one to be checked\n // so we can exit early if the plugin is found\n if (a.isDirectory && b.isDirectory) {\n const aName = UriUtils.basename(a.uri);\n if (aName === 'node_modules') {\n return -1;\n } else {\n return 1;\n }\n } else {\n return 0;\n }\n });\n\n for (const entry of content) {\n if (entry.isDirectory) {\n const name = UriUtils.basename(entry.uri);\n if (name === 'node_modules') {\n for (const plugin of Array.from(pendingPluginModels)) {\n const path = UriUtils.joinPath(entry.uri, plugin, PLUGIN_MODULE_NAME);\n try {\n await this.fileSystemProvider.readFile(path);\n const document = await this.langiumDocuments.getOrCreateDocument(path);\n collector(document);\n console.log(`Adding plugin document from ${path.path}`);\n\n pendingPluginModels.delete(plugin);\n // early exit if all plugins are loaded\n if (pendingPluginModels.size === 0) {\n return;\n }\n } catch {\n // no-op. The module might be found in another node_modules folder\n // will show the warning message eventually if not found\n }\n }\n } else {\n await this.loadPluginModels(workspaceFolder, entry.uri, pendingPluginModels, collector);\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;IAAAA,mBAA0F;AAC1F,kBAA+B;AAC/B,IAAAC,kBAAe;AACf,IAAAC,oBAAiB;AACjB,IAAAC,mBAA8B;;;ACE9B,cAAyB;AAkFlB,IAAMC,sBAAsB;AAoB5B,IAAMC,aAAa;AAQnB,IAAMC,aAAa;AAEnB,SAASC,aAAaC,MAAa;AACtC,SAAOC,WAAWC,WAAWF,MAAMF,UAAAA;AACvC;AAFgBC;AAYT,IAAMI,cAAc;AAEpB,SAASC,cAAcC,MAAa;AACvC,SAAOC,WAAWC,WAAWF,MAAMF,WAAAA;AACvC;AAFgBC;AAMT,IAAMI,qBAAqB;AAQ3B,IAAMC,kBAAkB;AAoBxB,IAAMC,kBAAkB;AAYxB,IAAMC,WAAW;AAYjB,IAAMC,YAAY;AAElB,SAASC,YAAYC,MAAa;AACrC,SAAOC,WAAWC,WAAWF,MAAMF,SAAAA;AACvC;AAFgBC;AAaT,IAAMI,YAAY;AAElB,SAASC,YAAYJ,MAAa;AACrC,SAAOC,WAAWC,WAAWF,MAAMG,SAAAA;AACvC;AAFgBC;AAWT,IAAMC,eAAe;AAgBrB,IAAMC,iBAAiB;AAevB,IAAMC,qBAAqB;AAc3B,IAAMC,aAAa;AAEnB,SAASC,aAAaC,MAAa;AACtC,SAAOC,WAAWC,WAAWF,MAAMF,UAAAA;AACvC;AAFgBC;AAUT,IAAMI,iBAAiB;AAEvB,SAASC,iBAAiBJ,MAAa;AAC1C,SAAOC,WAAWC,WAAWF,MAAMG,cAAAA;AACvC;AAFgB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AACqC,MAAMC,UAAAA;AACjB,kBAAIC,4BAAUF,IAAAA,GAAO;AAChBA,iBAA0BG,aAAaT;AACvCM,iBAA0BI,qBAAqBT;AAC/CK,iBAA0BK,kBAAkBJ;UACjD;QACJ,CAAA;MACJ,eAAWC,4BAAU1C,KAAAA,GAAQ;AACxBA,cAA2B2C,aAAaT;AACxClC,cAA2B4C,qBAAqBT;MACrD;IACJ;EACJ;AACJ;AAjBSF;AAmBT,SAASxB,2BAA2BX,OAAY;AAC5C,QAAMlD,SAAmB,CAAA;AACzB,QAAMkG,cAAchD,MAAMkC,aAAa9C,OAAO,CAAC6D,MAAMC,aAAaD,CAAAA,CAAAA;AAClE,MAAID,YAAYzD,WAAW,GAAG;AAC1BzC,WAAO8B,KAAK,6DAAA;EAChB,OAAO;AACH,QAAIoE,YAAYzD,SAAS,GAAG;AACxBzC,aAAO8B,KAAK,oEAAA;IAChB;EACJ;AAGA,QAAMuE,QAAQC,wBAAwBpD,OAAO,IAAA;AAC7C,QAAMqD,YAAYF,MAAM/D,OAAO,CAAC6D,MAAMK,aAAaL,GAAG,QAAA,CAAA;AACtD,MAAII,UAAU9D,SAAS,GAAG;AACtBzC,WAAO8B,KAAK,kEAAA;EAChB;AACA,SAAO9B;AACX;AAlBS6D;","names":["import_langium","import_node_fs","import_node_path","import_node_url","AbstractDeclaration","ConfigExpr","Expression","isExpression","item","reflection","isInstance","LiteralExpr","isLiteralExpr","item","reflection","isInstance","MemberAccessTarget","ReferenceTarget","TypeDeclaration","Argument","ArrayExpr","isArrayExpr","item","reflection","isInstance","Attribute","isAttribute","AttributeArg","AttributeParam","AttributeParamType","BinaryExpr","isBinaryExpr","item","reflection","isInstance","BooleanLiteral","isBooleanLiteral","ConfigArrayExpr","isConfigArrayExpr","ConfigField","ConfigInvocationArg","ConfigInvocationExpr","DataField","isDataField","item","reflection","isInstance","DataFieldAttribute","isDataFieldAttribute","DataFieldType","isDataFieldType","DataModel","isDataModel","DataModelAttribute","isDataModelAttribute","DataSource","isDataSource","Enum","isEnum","EnumField","isEnumField","FieldInitializer","FunctionDecl","FunctionParam","FunctionParamType","GeneratorDecl","InternalAttribute","InvocationExpr","isInvocationExpr","item","reflection","isInstance","MemberAccessExpr","isMemberAccessExpr","Model","isModel","ModelImport","NullExpr","isNullExpr","item","reflection","isInstance","NumberLiteral","isNumberLiteral","ObjectExpr","isObjectExpr","Plugin","isPlugin","PluginField","Procedure","ProcedureParam","ReferenceArg","ReferenceExpr","isReferenceExpr","item","reflection","isInstance","StringLiteral","isStringLiteral","ThisExpr","isThisExpr","TypeDef","isTypeDef","UnaryExpr","UnsupportedFieldType","ZModelAstReflection","AbstractAstReflection","getAllTypes","AbstractDeclaration","Argument","ArrayExpr","Attribute","AttributeArg","AttributeParam","AttributeParamType","BinaryExpr","BooleanLiteral","ConfigArrayExpr","ConfigExpr","ConfigField","ConfigInvocationArg","ConfigInvocationExpr","DataField","DataFieldAttribute","DataFieldType","DataModel","DataModelAttribute","DataSource","Enum","EnumField","Expression","FieldInitializer","FunctionDecl","FunctionParam","FunctionParamType","GeneratorDecl","InternalAttribute","InvocationExpr","LiteralExpr","MemberAccessExpr","MemberAccessTarget","Model","ModelImport","NullExpr","NumberLiteral","ObjectExpr","Plugin","PluginField","Procedure","ProcedureParam","ReferenceArg","ReferenceExpr","ReferenceTarget","StringLiteral","ThisExpr","TypeDeclaration","TypeDef","UnaryExpr","UnsupportedFieldType","computeIsSubtype","subtype","supertype","isSubtype","getReferenceType","refInfo","referenceId","container","$type","property","Error","getTypeMetaData","type","name","properties","defaultValue","reflection","SUPPORTED_PROVIDERS","SCALAR_TYPES","STD_LIB_MODULE_NAME","PLUGIN_MODULE_NAME","IssueCodes","ExpressionContext","import_langium","loadedZModelGrammar","ZModelGrammar","loadGrammarFromJson","ZModelLanguageMetaData","languageId","fileExtensions","caseInsensitive","mode","ZModelGeneratedSharedModule","AstReflection","ZModelAstReflection","ZModelGeneratedModule","Grammar","ZModelGrammar","LanguageMetaData","parser","import_langium","import_langium","hasAttribute","decl","name","getAttribute","attributes","find","attr","$refText","isFromStdlib","node","model","AstUtils","getContainerOfType","isModel","$document","uri","path","endsWith","STD_LIB_MODULE_NAME","isAuthInvocation","isInvocationExpr","function","ref","getStringLiteral","isStringLiteral","value","undefined","isoDateTimeRegex","typeAssignable","destType","sourceType","sourceExpr","literal","test","mapBuiltinTypeToExpressionType","type","isAuthOrAuthMemberAccess","expr","isMemberAccessExpr","operand","isEnumFieldReference","isReferenceExpr","isEnumField","target","isDataFieldReference","isDataField","isRelationshipField","field","isDataModel","reference","isFutureExpr","isDelegateModel","resolved","Error","getRecursiveBases","includeDelegate","seen","Set","result","has","add","mixins","forEach","mixin","baseDecl","push","getModelIdFields","modelsToCheck","modelToCheck","allAttributes","getAllAttributes","idAttr","fieldsArg","args","a","$resolvedParam","isArrayExpr","items","filter","item","map","getModelUniqueFields","uniqueAttr","getUniqueFields","uniqueAttrs","findUpAst","predicate","curr","$container","getLiteral","$type","getObjectLiteral","parseFloat","isObjectExpr","fields","fieldValue","isLiteralExpr","getLiteralArray","arr","getArray","isExpression","v","isConfigArrayExpr","getFunctionExpressionContext","funcDecl","funcAllowedContext","funcAttr","attributes","find","attr","decl","$refText","contextArg","args","value","isArrayExpr","items","forEach","item","isEnumFieldReference","push","target","isCheckInvocation","node","isInvocationExpr","function","ref","name","isFromStdlib","resolveTransitiveImports","documents","model","resolveTransitiveImportsInternal","initialModel","visited","Set","models","doc","AstUtils","getDocument","initialDoc","uri","fsPath","toLowerCase","add","normalizedPath","has","imp","imports","importedModel","resolveImport","Array","from","resolvedUri","resolveImportUri","resolvedDocument","content","fs","readFileSync","createDocument","parseResult","value","isModel","undefined","path","dir","dirname","importPath","endsWith","URI","file","resolve","getDataModelAndTypeDefs","includeIgnored","r","declarations","filter","d","isDataModel","isTypeDef","hasAttribute","getAllDeclarationsIncludingImports","concat","map","getAuthDecl","decls","authModel","find","m","isFutureInvocation","isCollectionPredicate","isBinaryExpr","includes","operator","getAllLoadedDataModelsAndTypeDefs","langiumDocuments","all","flatMap","toArray","getAllDataModelsIncludingImports","getAllLoadedAndReachableDataModelsAndTypeDefs","fromModel","allDataModels","getContainerOfType","transitiveDataModels","forEach","dm","push","getContainingDataModel","curr","$container","isMemberContainer","getAllFields","decl","seen","fields","mixin","mixins","invariant","$refText","baseModel","f","getAllAttributes","attributes","rootNode","findRootNode","result","$document","Error","attributeCheckers","Map","check","name","_target","_propertyKey","descriptor","get","set","AttributeApplicationValidator","validate","attr","accept","contextDataModel","decl","ref","targetDecl","$container","isAttribute","node","isDataField","isValidAttributeTarget","checkDeprecation","checkDuplicatedAttributes","filledParams","Set","arg","args","paramDecl","params","find","p","default","has","assignableToAttributeParam","add","$resolvedParam","missingParams","filter","type","optional","length","pluralize","map","join","checker","value","call","deprecateAttr","attributes","a","message","getStringLiteral","attrDecl","some","allAttributes","getAllAttributes","duplicates","_checkModelLevelPolicy","kind","validatePolicyKinds","rejectEncryptedFields","_checkFieldLevelPolicy","kindItems","expr","AstUtils","streamAst","isFutureExpr","includes","field","isRelationshipField","_checkValidate","condition","isDataFieldReference","isDataModel","$resolvedType","_checkUnique","fields","isArrayExpr","items","forEach","item","isReferenceExpr","target","isDelegateModel","streamAllContents","hasAttribute","candidates","split","x","trim","c","param","argResolvedType","dstType","dstIsArray","array","dstRef","reference","isEnum","attrArgDeclType","resolved","mapBuiltinTypeToExpressionType","typeAssignable","targetField","fieldTypes","allowed","allowedType","isTypeDef","validateAttributeApplication","AttributeValidator","validate","attr","accept","attributes","forEach","validateAttributeApplication","import_common_helpers","import_langium","validateDuplicatedDeclarations","container","decls","accept","groupByName","reduce","group","decl","name","push","Object","entries","length","errorField","isDataField","nonInheritedFields","filter","x","$container","slice","node","DataModelValidator","validate","dm","accept","validateDuplicatedDeclarations","getAllFields","validateAttributes","validateFields","mixins","length","validateMixins","validateInherits","allFields","idFields","filter","f","attributes","find","attr","decl","ref","name","uniqueFields","modelLevelIds","getModelIdFields","modelUniqueFields","getModelUniqueFields","node","fieldsToCheck","forEach","idField","type","optional","isArray","array","isScalar","SCALAR_TYPES","includes","isValidType","isEnum","reference","fields","field","validateField","x","isDataModel","y","validateRelationField","unsupported","isStringLiteral","value","provider","getDataSourceProvider","AstUtils","getContainerOfType","isModel","validateAttributeApplication","isTypeDef","hasAttribute","model","dataSource","declarations","isDataSource","undefined","getLiteral","getAllAttributes","parseRelation","relAttr","references","valid","arg","args","items","i","fieldRef","$resolvedType","nullable","target","$refText","isSelfRelation","$container","contextModel","thisRelation","isFieldInheritedFromDelegateModel","oppositeModel","oppositeFields","fieldRel","info","code","IssueCodes","MissingOppositeRelation","property","container","relationFieldDocUri","getDocument","textDocument","uri","relationDataModelName","data","relationFieldName","dataModelName","map","join","oppositeField","oppositeRelation","relationOwner","r","containingModel","uniqueFieldList","getUniqueFields","push","refField","a","some","list","isDelegateModel","baseModel","invariant","seen","todo","current","shift","m","mixin","DataSourceValidator","validate","ds","accept","validateDuplicatedDeclarations","fields","validateProvider","validateUrl","validateRelationMode","provider","find","f","name","node","value","getStringLiteral","SUPPORTED_PROVIDERS","includes","map","p","join","urlField","isInvocationExpr","function","ref","field","val","EnumValidator","validate","_enum","accept","validateDuplicatedDeclarations","fields","validateAttributes","forEach","field","validateField","attributes","attr","validateAttributeApplication","import_langium","ExpressionValidator","validate","expr","accept","$resolvedType","isAuthInvocation","node","hasReferenceResolutionError","AstUtils","streamAst","some","isMemberAccessExpr","member","error","isReferenceExpr","target","$type","validateBinaryExpr","operator","left","decl","isEnum","right","array","supportedShapes","includes","isInValidationContext","isDataFieldReference","isNullExpr","nullable","typeAssignable","leftType","rightType","isDataModel","isThisExpr","validateCollectionPredicate","findUpAst","n","isDataModelAttribute","$refText","isNotModelFieldExpr","isLiteralExpr","isEnumFieldReference","isAuthOrAuthMemberAccess","isArrayExpr","items","every","item","FunctionDeclValidator","validate","funcDecl","accept","attributes","forEach","attr","validateAttributeApplication","import_langium","invocationCheckers","Map","func","name","_target","_propertyKey","descriptor","get","set","FunctionInvocationValidator","validate","expr","accept","funcDecl","function","ref","node","validateArgs","args","isFromStdlib","curr","$container","containerAttribute","isDataModelAttribute","isDataFieldAttribute","exprContext","match","decl","$refText","with","ExpressionContext","DefaultValue","P","union","AccessPolicy","ValidationRule","Index","otherwise","undefined","funcAllowedContext","getFunctionExpressionContext","includes","allCasing","arg","getLiteral","value","map","c","join","checker","call","success","i","params","length","param","optional","validateInvocationArg","argResolvedType","$resolvedType","dstType","type","dstIsArray","array","dstRef","reference","typeAssignable","_checkCheck","valid","fieldArg","isDataFieldReference","isDataModel","opArg","operation","start","tasks","seen","Set","currExpr","pop","currModel","has","add","policyAttrs","attributes","filter","attr","rule","AstUtils","streamAst","forEach","isCheckInvocation","push","SchemaValidator","documents","validate","model","accept","validateImports","validateDuplicatedDeclarations","declarations","importedModels","resolveTransitiveImports","importedNames","Set","flatMap","m","map","d","name","declaration","has","node","property","$document","uri","path","endsWith","STD_LIB_MODULE_NAME","PLUGIN_MODULE_NAME","validateDataSources","dataSources","getAllDeclarationsIncludingImports","filter","isDataSource","length","imports","forEach","imp","importedModel","resolveImport","importPath","TypeDefValidator","validate","typeDef","accept","validateDuplicatedDeclarations","fields","validateAttributes","validateFields","attributes","forEach","attr","validateAttributeApplication","field","validateField","registerValidationChecks","services","registry","validation","ValidationRegistry","validator","ZModelValidator","checks","Model","checkModel","DataSource","checkDataSource","DataModel","checkDataModel","TypeDef","checkTypeDef","Enum","checkEnum","Attribute","checkAttribute","Expression","checkExpression","InvocationExpr","checkFunctionInvocation","FunctionDecl","checkFunctionDecl","register","shouldCheck","node","doc","currNode","$document","$container","parseResult","lexerErrors","length","parserErrors","accept","SchemaValidator","shared","workspace","LangiumDocuments","validate","DataSourceValidator","DataModelValidator","TypeDefValidator","EnumValidator","AttributeValidator","ExpressionValidator","FunctionInvocationValidator","FunctionDeclValidator","import_langium","import_ts_pattern","ZModelLinker","DefaultLinker","descriptions","services","workspace","AstNodeDescriptionProvider","link","document","cancelToken","Cancellation","CancellationToken","None","parseResult","lexerErrors","length","parserErrors","node","AstUtils","streamContents","value","interruptAndCheck","resolve","state","DocumentState","Linked","linkReference","container","property","extraScopes","resolveFromScopeProviders","reference","doLink","providers","provider","target","$refText","_ref","_nodeDescription","createDescription","name","references","push","$type","StringLiteral","NumberLiteral","BooleanLiteral","resolveLiteral","InvocationExpr","resolveInvocation","ArrayExpr","resolveArray","ReferenceExpr","resolveReference","MemberAccessExpr","resolveMemberAccess","UnaryExpr","resolveUnary","BinaryExpr","resolveBinary","ObjectExpr","resolveObject","ThisExpr","resolveThis","NullExpr","resolveNull","AttributeArg","resolveAttributeArg","DataModel","resolveDataModel","DataField","resolveDataField","resolveDefault","operator","left","right","resolveToBuiltinTypeOrDecl","resolveCollectionPredicate","Error","operand","fields","forEach","field","ref","EnumField","$container","resolveToDeclaredType","type","items","item","itemType","$resolvedType","decl","args","arg","function","funcDecl","isAuthInvocation","allDecls","getAllLoadedAndReachableDataModelsAndTypeDefs","langiumDocuments","getContainerOfType","isDataModel","authDecl","getAuthDecl","nullable","isFutureExpr","getContainingDataModel","returnType","match","when","isStringLiteral","isBooleanLiteral","isNumberLiteral","exhaustive","operandResolved","array","isMemberContainer","member","resolvedType","_document","scope","r","_extraScopes","attrParam","findAttrParamForArg","attrAppliedOn","isDataField","transitiveDataModel","scopeProvider","getAllFields","find","f","isArrayExpr","isReferenceExpr","resolved","unresolvableRefExpr","createLinkingError","attr","undefined","params","p","index","findIndex","a","scopes","isEnum","contextEnum","enumScope","Object","entries","startsWith","isReference","child","isDataFieldType","optional","unsupported","mappedType","mapBuiltinTypeToExpressionType","import_langium","import_ts_pattern","ZModelScopeComputation","DefaultScopeComputation","services","computeExports","document","cancelToken","result","node","AstUtils","streamAllContents","parseResult","value","interruptAndCheck","isEnumField","desc","workspace","AstNodeDescriptionProvider","createDescription","name","push","processNode","scopes","isDataModel","bases","getRecursiveBases","base","field","fields","add","descriptions","nameProvider","getName","ZModelScopeProvider","DefaultScopeProvider","getGlobalScope","referenceType","context","model","getContainerOfType","container","isModel","EMPTY_SCOPE","importedUris","imports","map","resolveImportUri","filter","url","importedElements","indexManager","allElements","des","UriUtils","equals","documentUri","$document","uri","path","endsWith","STD_LIB_MODULE_NAME","PLUGIN_MODULE_NAME","some","importedUri","StreamScope","getScope","isMemberAccessExpr","operand","property","getMemberAccessScope","isReferenceExpr","containerCollectionPredicate","getCollectionPredicateContext","getCollectionPredicateScope","reflection","getReferenceType","globalScope","allowTypeDefScope","isTypeDef","match","when","ref","target","isDataField","createScopeForContainer","type","reference","member","array","isThisExpr","createScopeForContainingModel","isInvocationExpr","isAuthInvocation","createScopeForAuth","isFutureInvocation","otherwise","collectionPredicate","collection","left","expr","returnTypeDecl","function","returnType","includeTypeDefScope","createScopeForNodes","getAllFields","decls","getAllLoadedAndReachableDataModelsAndTypeDefs","shared","LangiumDocuments","authDecl","getAuthDecl","curr","$container","isCollectionPredicate","$containerProperty","undefined","import_langium","import_node_fs","ZModelWorkspaceManager","DefaultWorkspaceManager","documentFactory","services","workspace","LangiumDocumentFactory","loadAdditionalDocuments","folders","collector","stdLibPath","installedStdlibPath","folder","folderPath","getRootFolder","fsPath","languagePackagePath","require","resolve","paths","languagePackageDir","path","dirname","candidateStdlibPath","join","STD_LIB_MODULE_NAME","fs","existsSync","console","log","_dirname","__dirname","fileURLToPath","url","stdlib","fromUri","URI","file","documents","langiumDocuments","all","pluginModels","Set","forEach","doc","parsed","parseResult","value","declarations","decl","isPlugin","providerField","fields","find","f","name","provider","getLiteral","add","size","Array","from","pendingPluginModules","Promise","map","wf","entry","loadPluginModels","workspaceFolder","pendingPluginModels","content","fileSystemProvider","readDirectory","sort","a","b","isDirectory","aName","UriUtils","basename","uri","plugin","joinPath","PLUGIN_MODULE_NAME","readFile","document","getOrCreateDocument","delete","ZModelLanguageModule","references","ScopeComputation","services","ZModelScopeComputation","ScopeProvider","ZModelScopeProvider","Linker","ZModelLinker","validation","ZModelValidator","ZModelSharedModule","workspace","WorkspaceManager","ZModelWorkspaceManager","createZModelLanguageServices","context","shared","inject","createDefaultSharedModule","ZModelGeneratedSharedModule","ZModelLanguage","createDefaultModule","ZModelGeneratedModule","ServiceRegistry","register","registerValidationChecks","connection","ConfigurationProvider","initialized","import_meta","createZModelServices","createZModelLanguageServices","NodeFileSystem","DocumentLoadError","Error","message","loadDocument","fileName","pluginModelFiles","ZModelLanguage","services","extensions","LanguageMetaData","fileExtensions","includes","path","extname","success","errors","warnings","fs","existsSync","_dirname","__dirname","dirname","fileURLToPath","import_meta","url","stdLib","shared","workspace","LangiumDocuments","getOrCreateDocument","URI","file","resolve","join","STD_LIB_MODULE_NAME","pluginDocs","Promise","all","map","langiumDocuments","document","importedURIs","loadImports","importedDocuments","uri","push","DocumentBuilder","build","validation","diagnostics","flatMap","doc","diag","filter","severity","toArray","length","relative","process","cwd","fsPath","range","start","line","character","model","parseResult","value","imported","mergeImportsDeclarations","forEach","deleteDocument","$document","IndexManager","remove","additionalErrors","validationAfterImportMerge","documents","uris","Set","uriString","toString","has","add","imp","imports","importedModel","resolveImport","importedDoc","getDocument","Array","from","x","e","parse","importedModels","resolveTransitiveImports","importedDeclarations","m","declarations","linkContentToContainer","node","name","Object","entries","startsWith","isArray","item","index","isAstNode","$container","$containerProperty","$containerIndex","dataSources","d","isDataSource","decls","getDataModelAndTypeDefs","authDecls","hasAttribute"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/generated/ast.ts","../src/constants.ts","../src/module.ts","../src/generated/grammar.ts","../src/generated/module.ts","../src/validators/attribute-application-validator.ts","../src/utils.ts","../src/validators/attribute-validator.ts","../src/validators/datamodel-validator.ts","../src/validators/common.ts","../src/validators/datasource-validator.ts","../src/validators/enum-validator.ts","../src/validators/expression-validator.ts","../src/validators/function-decl-validator.ts","../src/validators/function-invocation-validator.ts","../src/validators/schema-validator.ts","../src/validators/typedef-validator.ts","../src/validator.ts","../src/zmodel-linker.ts","../src/zmodel-scope.ts","../src/zmodel-workspace-manager.ts"],"sourcesContent":["import { isAstNode, URI, type LangiumDocument, type LangiumDocuments, type Mutable } from 'langium';\nimport { NodeFileSystem } from 'langium/node';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isDataSource, type AstNode, type Model } from './ast';\nimport { STD_LIB_MODULE_NAME } from './constants';\nimport { createZModelLanguageServices } from './module';\nimport { getDataModelAndTypeDefs, getDocument, hasAttribute, resolveImport, resolveTransitiveImports } from './utils';\n\nexport function createZModelServices() {\n return createZModelLanguageServices(NodeFileSystem);\n}\n\nexport class DocumentLoadError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n\nexport async function loadDocument(\n fileName: string,\n pluginModelFiles: string[] = [],\n): Promise<\n { success: true; model: Model; warnings: string[] } | { success: false; errors: string[]; warnings: string[] }\n> {\n const { ZModelLanguage: services } = createZModelServices();\n const extensions = services.LanguageMetaData.fileExtensions;\n if (!extensions.includes(path.extname(fileName))) {\n return {\n success: false,\n errors: ['invalid schema file extension'],\n warnings: [],\n };\n }\n\n if (!fs.existsSync(fileName)) {\n return {\n success: false,\n errors: ['schema file does not exist'],\n warnings: [],\n };\n }\n\n // load standard library\n\n // isomorphic __dirname\n const _dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));\n const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(\n URI.file(path.resolve(path.join(_dirname, '../res', STD_LIB_MODULE_NAME))),\n );\n\n // load plugin model files\n const pluginDocs = await Promise.all(\n pluginModelFiles.map((file) =>\n services.shared.workspace.LangiumDocuments.getOrCreateDocument(URI.file(path.resolve(file))),\n ),\n );\n\n // load the document\n const langiumDocuments = services.shared.workspace.LangiumDocuments;\n const document = await langiumDocuments.getOrCreateDocument(URI.file(path.resolve(fileName)));\n\n // load imports\n const importedURIs = await loadImports(document, langiumDocuments);\n const importedDocuments: LangiumDocument[] = [];\n for (const uri of importedURIs) {\n importedDocuments.push(await langiumDocuments.getOrCreateDocument(uri));\n }\n\n // build the document together with standard library, plugin modules, and imported documents\n await services.shared.workspace.DocumentBuilder.build([stdLib, ...pluginDocs, document, ...importedDocuments], {\n validation: true,\n });\n\n const diagnostics = langiumDocuments.all\n .flatMap((doc) => (doc.diagnostics ?? []).map((diag) => ({ doc, diag })))\n .filter(({ diag }) => diag.severity === 1 || diag.severity === 2)\n .toArray();\n\n const errors: string[] = [];\n const warnings: string[] = [];\n\n if (diagnostics.length > 0) {\n for (const { doc, diag } of diagnostics) {\n const message = `${path.relative(process.cwd(), doc.uri.fsPath)}:${\n diag.range.start.line + 1\n }:${diag.range.start.character + 1} - ${diag.message}`;\n\n if (diag.severity === 1) {\n errors.push(message);\n } else {\n warnings.push(message);\n }\n }\n }\n\n if (errors.length > 0) {\n return {\n success: false,\n errors,\n warnings,\n };\n }\n\n const model = document.parseResult.value as Model;\n\n // merge all declarations into the main document\n const imported = mergeImportsDeclarations(langiumDocuments, model);\n\n // remove imported documents\n imported.forEach((model) => {\n langiumDocuments.deleteDocument(model.$document!.uri);\n services.shared.workspace.IndexManager.remove(model.$document!.uri);\n });\n\n // extra validation after merging imported declarations\n const additionalErrors = validationAfterImportMerge(model);\n if (additionalErrors.length > 0) {\n return {\n success: false,\n errors: additionalErrors,\n warnings,\n };\n }\n\n return {\n success: true,\n model: document.parseResult.value as Model,\n warnings,\n };\n}\n\nasync function loadImports(document: LangiumDocument, documents: LangiumDocuments, uris: Set<string> = new Set()) {\n const uriString = document.uri.toString();\n if (!uris.has(uriString)) {\n uris.add(uriString);\n const model = document.parseResult.value as Model;\n for (const imp of model.imports) {\n const importedModel = resolveImport(documents, imp);\n if (importedModel) {\n const importedDoc = getDocument(importedModel);\n await loadImports(importedDoc, documents, uris);\n }\n }\n }\n return Array.from(uris)\n .filter((x) => uriString != x)\n .map((e) => URI.parse(e));\n}\n\nfunction mergeImportsDeclarations(documents: LangiumDocuments, model: Model) {\n const importedModels = resolveTransitiveImports(documents, model);\n\n const importedDeclarations = importedModels.flatMap((m) => m.declarations);\n model.declarations.push(...importedDeclarations);\n\n // remove import directives\n model.imports = [];\n\n // fix $container, $containerIndex, and $containerProperty\n linkContentToContainer(model);\n\n return importedModels;\n}\n\nfunction linkContentToContainer(node: AstNode): void {\n for (const [name, value] of Object.entries(node)) {\n if (!name.startsWith('$')) {\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n if (isAstNode(item)) {\n (item as Mutable<AstNode>).$container = node;\n (item as Mutable<AstNode>).$containerProperty = name;\n (item as Mutable<AstNode>).$containerIndex = index;\n }\n });\n } else if (isAstNode(value)) {\n (value as Mutable<AstNode>).$container = node;\n (value as Mutable<AstNode>).$containerProperty = name;\n }\n }\n }\n}\n\nfunction validationAfterImportMerge(model: Model) {\n const errors: string[] = [];\n const dataSources = model.declarations.filter((d) => isDataSource(d));\n if (dataSources.length === 0) {\n errors.push('Validation error: schema must have a datasource declaration');\n } else {\n if (dataSources.length > 1) {\n errors.push('Validation error: multiple datasource declarations are not allowed');\n }\n }\n\n // at most one `@@auth` model\n const decls = getDataModelAndTypeDefs(model, true);\n const authDecls = decls.filter((d) => hasAttribute(d, '@@auth'));\n if (authDecls.length > 1) {\n errors.push('Validation error: Multiple `@@auth` declarations are not allowed');\n }\n return errors;\n}\n\nexport * from './module';\n","/******************************************************************************\n * This file was generated by langium-cli 3.5.0.\n * DO NOT EDIT MANUALLY!\n ******************************************************************************/\n\n/* eslint-disable */\nimport * as langium from 'langium';\n\nexport const ZModelTerminals = {\n WS: /\\s+/,\n INTERNAL_ATTRIBUTE_NAME: /@@@([_a-zA-Z][\\w_]*\\.)*[_a-zA-Z][\\w_]*/,\n MODEL_ATTRIBUTE_NAME: /@@([_a-zA-Z][\\w_]*\\.)*[_a-zA-Z][\\w_]*/,\n FIELD_ATTRIBUTE_NAME: /@([_a-zA-Z][\\w_]*\\.)*[_a-zA-Z][\\w_]*/,\n ID: /[_a-zA-Z][\\w_]*/,\n STRING: /\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'/,\n NUMBER: /[+-]?[0-9]+(\\.[0-9]+)?/,\n TRIPLE_SLASH_COMMENT: /\\/\\/\\/[^\\n\\r]*/,\n ML_COMMENT: /\\/\\*[\\s\\S]*?\\*\\//,\n SL_COMMENT: /\\/\\/[^\\n\\r]*/,\n};\n\nexport type ZModelTerminalNames = keyof typeof ZModelTerminals;\n\nexport type ZModelKeywordNames =\n | \"!\"\n | \"!=\"\n | \"&&\"\n | \"(\"\n | \")\"\n | \",\"\n | \".\"\n | \":\"\n | \";\"\n | \"<\"\n | \"<=\"\n | \"=\"\n | \"==\"\n | \">\"\n | \">=\"\n | \"?\"\n | \"Any\"\n | \"BigInt\"\n | \"Boolean\"\n | \"Bytes\"\n | \"ContextType\"\n | \"DateTime\"\n | \"Decimal\"\n | \"FieldReference\"\n | \"Float\"\n | \"Int\"\n | \"Json\"\n | \"Null\"\n | \"Object\"\n | \"String\"\n | \"TransitiveFieldReference\"\n | \"Unsupported\"\n | \"[\"\n | \"]\"\n | \"^\"\n | \"_\"\n | \"abstract\"\n | \"attribute\"\n | \"datasource\"\n | \"enum\"\n | \"extends\"\n | \"false\"\n | \"function\"\n | \"generator\"\n | \"import\"\n | \"in\"\n | \"model\"\n | \"mutation\"\n | \"null\"\n | \"plugin\"\n | \"procedure\"\n | \"this\"\n | \"true\"\n | \"type\"\n | \"view\"\n | \"with\"\n | \"{\"\n | \"||\"\n | \"}\";\n\nexport type ZModelTokenNames = ZModelTerminalNames | ZModelKeywordNames;\n\nexport type AbstractDeclaration = Attribute | DataModel | DataSource | Enum | FunctionDecl | GeneratorDecl | Plugin | Procedure | TypeDef;\n\nexport const AbstractDeclaration = 'AbstractDeclaration';\n\nexport function isAbstractDeclaration(item: unknown): item is AbstractDeclaration {\n return reflection.isInstance(item, AbstractDeclaration);\n}\n\nexport type Boolean = boolean;\n\nexport function isBoolean(item: unknown): item is Boolean {\n return typeof item === 'boolean';\n}\n\nexport type BuiltinType = 'BigInt' | 'Boolean' | 'Bytes' | 'DateTime' | 'Decimal' | 'Float' | 'Int' | 'Json' | 'String';\n\nexport function isBuiltinType(item: unknown): item is BuiltinType {\n return item === 'String' || item === 'Boolean' || item === 'Int' || item === 'BigInt' || item === 'Float' || item === 'Decimal' || item === 'DateTime' || item === 'Json' || item === 'Bytes';\n}\n\nexport type ConfigExpr = ConfigArrayExpr | InvocationExpr | LiteralExpr;\n\nexport const ConfigExpr = 'ConfigExpr';\n\nexport function isConfigExpr(item: unknown): item is ConfigExpr {\n return reflection.isInstance(item, ConfigExpr);\n}\n\nexport type Expression = ArrayExpr | BinaryExpr | InvocationExpr | LiteralExpr | MemberAccessExpr | NullExpr | ObjectExpr | ReferenceExpr | ThisExpr | UnaryExpr;\n\nexport const Expression = 'Expression';\n\nexport function isExpression(item: unknown): item is Expression {\n return reflection.isInstance(item, Expression);\n}\n\nexport type ExpressionType = 'Any' | 'Boolean' | 'DateTime' | 'Float' | 'Int' | 'Null' | 'Object' | 'String' | 'Unsupported';\n\nexport function isExpressionType(item: unknown): item is ExpressionType {\n return item === 'String' || item === 'Int' || item === 'Float' || item === 'Boolean' || item === 'DateTime' || item === 'Null' || item === 'Object' || item === 'Any' || item === 'Unsupported';\n}\n\nexport type LiteralExpr = BooleanLiteral | NumberLiteral | StringLiteral;\n\nexport const LiteralExpr = 'LiteralExpr';\n\nexport function isLiteralExpr(item: unknown): item is LiteralExpr {\n return reflection.isInstance(item, LiteralExpr);\n}\n\nexport type MemberAccessTarget = DataField;\n\nexport const MemberAccessTarget = 'MemberAccessTarget';\n\nexport function isMemberAccessTarget(item: unknown): item is MemberAccessTarget {\n return reflection.isInstance(item, MemberAccessTarget);\n}\n\nexport type ReferenceTarget = DataField | EnumField | FunctionParam;\n\nexport const ReferenceTarget = 'ReferenceTarget';\n\nexport function isReferenceTarget(item: unknown): item is ReferenceTarget {\n return reflection.isInstance(item, ReferenceTarget);\n}\n\nexport type RegularID = 'abstract' | 'attribute' | 'datasource' | 'enum' | 'import' | 'in' | 'model' | 'plugin' | 'type' | 'view' | string;\n\nexport function isRegularID(item: unknown): item is RegularID {\n return item === 'model' || item === 'enum' || item === 'attribute' || item === 'datasource' || item === 'plugin' || item === 'abstract' || item === 'in' || item === 'view' || item === 'import' || item === 'type' || (typeof item === 'string' && (/[_a-zA-Z][\\w_]*/.test(item)));\n}\n\nexport type RegularIDWithTypeNames = 'Any' | 'BigInt' | 'Boolean' | 'Bytes' | 'DateTime' | 'Decimal' | 'Float' | 'Int' | 'Json' | 'Null' | 'Object' | 'String' | 'Unsupported' | RegularID;\n\nexport function isRegularIDWithTypeNames(item: unknown): item is RegularIDWithTypeNames {\n return isRegularID(item) || item === 'String' || item === 'Boolean' || item === 'Int' || item === 'BigInt' || item === 'Float' || item === 'Decimal' || item === 'DateTime' || item === 'Json' || item === 'Bytes' || item === 'Null' || item === 'Object' || item === 'Any' || item === 'Unsupported';\n}\n\nexport type TypeDeclaration = DataModel | Enum | TypeDef;\n\nexport const TypeDeclaration = 'TypeDeclaration';\n\nexport function isTypeDeclaration(item: unknown): item is TypeDeclaration {\n return reflection.isInstance(item, TypeDeclaration);\n}\n\nexport interface Argument extends langium.AstNode {\n readonly $container: InvocationExpr;\n readonly $type: 'Argument';\n value: Expression;\n}\n\nexport const Argument = 'Argument';\n\nexport function isArgument(item: unknown): item is Argument {\n return reflection.isInstance(item, Argument);\n}\n\nexport interface ArrayExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr;\n readonly $type: 'ArrayExpr';\n items: Array<Expression>;\n}\n\nexport const ArrayExpr = 'ArrayExpr';\n\nexport function isArrayExpr(item: unknown): item is ArrayExpr {\n return reflection.isInstance(item, ArrayExpr);\n}\n\nexport interface Attribute extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'Attribute';\n attributes: Array<InternalAttribute>;\n comments: Array<string>;\n name: string;\n params: Array<AttributeParam>;\n}\n\nexport const Attribute = 'Attribute';\n\nexport function isAttribute(item: unknown): item is Attribute {\n return reflection.isInstance(item, Attribute);\n}\n\nexport interface AttributeArg extends langium.AstNode {\n readonly $container: DataFieldAttribute | DataModelAttribute | InternalAttribute;\n readonly $type: 'AttributeArg';\n name?: RegularID;\n value: Expression;\n}\n\nexport const AttributeArg = 'AttributeArg';\n\nexport function isAttributeArg(item: unknown): item is AttributeArg {\n return reflection.isInstance(item, AttributeArg);\n}\n\nexport interface AttributeParam extends langium.AstNode {\n readonly $container: Attribute;\n readonly $type: 'AttributeParam';\n attributes: Array<InternalAttribute>;\n comments: Array<string>;\n default: boolean;\n name: RegularID;\n type: AttributeParamType;\n}\n\nexport const AttributeParam = 'AttributeParam';\n\nexport function isAttributeParam(item: unknown): item is AttributeParam {\n return reflection.isInstance(item, AttributeParam);\n}\n\nexport interface AttributeParamType extends langium.AstNode {\n readonly $container: AttributeParam;\n readonly $type: 'AttributeParamType';\n array: boolean;\n optional: boolean;\n reference?: langium.Reference<TypeDeclaration>;\n type?: 'ContextType' | 'FieldReference' | 'TransitiveFieldReference' | ExpressionType;\n}\n\nexport const AttributeParamType = 'AttributeParamType';\n\nexport function isAttributeParamType(item: unknown): item is AttributeParamType {\n return reflection.isInstance(item, AttributeParamType);\n}\n\nexport interface BinaryExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'BinaryExpr';\n left: Expression;\n operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | 'in' | '||';\n right: Expression;\n}\n\nexport const BinaryExpr = 'BinaryExpr';\n\nexport function isBinaryExpr(item: unknown): item is BinaryExpr {\n return reflection.isInstance(item, BinaryExpr);\n}\n\nexport interface BooleanLiteral extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;\n readonly $type: 'BooleanLiteral';\n value: Boolean;\n}\n\nexport const BooleanLiteral = 'BooleanLiteral';\n\nexport function isBooleanLiteral(item: unknown): item is BooleanLiteral {\n return reflection.isInstance(item, BooleanLiteral);\n}\n\nexport interface ConfigArrayExpr extends langium.AstNode {\n readonly $container: ConfigField;\n readonly $type: 'ConfigArrayExpr';\n items: Array<ConfigInvocationExpr | LiteralExpr>;\n}\n\nexport const ConfigArrayExpr = 'ConfigArrayExpr';\n\nexport function isConfigArrayExpr(item: unknown): item is ConfigArrayExpr {\n return reflection.isInstance(item, ConfigArrayExpr);\n}\n\nexport interface ConfigField extends langium.AstNode {\n readonly $container: DataSource | GeneratorDecl;\n readonly $type: 'ConfigField';\n name: RegularID;\n value: ConfigExpr;\n}\n\nexport const ConfigField = 'ConfigField';\n\nexport function isConfigField(item: unknown): item is ConfigField {\n return reflection.isInstance(item, ConfigField);\n}\n\nexport interface ConfigInvocationArg extends langium.AstNode {\n readonly $container: ConfigInvocationExpr;\n readonly $type: 'ConfigInvocationArg';\n name: string;\n value: LiteralExpr;\n}\n\nexport const ConfigInvocationArg = 'ConfigInvocationArg';\n\nexport function isConfigInvocationArg(item: unknown): item is ConfigInvocationArg {\n return reflection.isInstance(item, ConfigInvocationArg);\n}\n\nexport interface ConfigInvocationExpr extends langium.AstNode {\n readonly $container: ConfigArrayExpr;\n readonly $type: 'ConfigInvocationExpr';\n args: Array<ConfigInvocationArg>;\n name: string;\n}\n\nexport const ConfigInvocationExpr = 'ConfigInvocationExpr';\n\nexport function isConfigInvocationExpr(item: unknown): item is ConfigInvocationExpr {\n return reflection.isInstance(item, ConfigInvocationExpr);\n}\n\nexport interface DataField extends langium.AstNode {\n readonly $container: DataModel | TypeDef;\n readonly $type: 'DataField';\n attributes: Array<DataFieldAttribute>;\n comments: Array<string>;\n name: RegularIDWithTypeNames;\n type: DataFieldType;\n}\n\nexport const DataField = 'DataField';\n\nexport function isDataField(item: unknown): item is DataField {\n return reflection.isInstance(item, DataField);\n}\n\nexport interface DataFieldAttribute extends langium.AstNode {\n readonly $container: DataField | EnumField;\n readonly $type: 'DataFieldAttribute';\n args: Array<AttributeArg>;\n decl: langium.Reference<Attribute>;\n}\n\nexport const DataFieldAttribute = 'DataFieldAttribute';\n\nexport function isDataFieldAttribute(item: unknown): item is DataFieldAttribute {\n return reflection.isInstance(item, DataFieldAttribute);\n}\n\nexport interface DataFieldType extends langium.AstNode {\n readonly $container: DataField;\n readonly $type: 'DataFieldType';\n array: boolean;\n optional: boolean;\n reference?: langium.Reference<TypeDeclaration>;\n type?: BuiltinType;\n unsupported?: UnsupportedFieldType;\n}\n\nexport const DataFieldType = 'DataFieldType';\n\nexport function isDataFieldType(item: unknown): item is DataFieldType {\n return reflection.isInstance(item, DataFieldType);\n}\n\nexport interface DataModel extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'DataModel';\n attributes: Array<DataModelAttribute>;\n baseModel?: langium.Reference<DataModel>;\n comments: Array<string>;\n fields: Array<DataField>;\n isView: boolean;\n mixins: Array<langium.Reference<TypeDef>>;\n name: RegularID;\n}\n\nexport const DataModel = 'DataModel';\n\nexport function isDataModel(item: unknown): item is DataModel {\n return reflection.isInstance(item, DataModel);\n}\n\nexport interface DataModelAttribute extends langium.AstNode {\n readonly $container: DataModel | Enum | TypeDef;\n readonly $type: 'DataModelAttribute';\n args: Array<AttributeArg>;\n decl: langium.Reference<Attribute>;\n}\n\nexport const DataModelAttribute = 'DataModelAttribute';\n\nexport function isDataModelAttribute(item: unknown): item is DataModelAttribute {\n return reflection.isInstance(item, DataModelAttribute);\n}\n\nexport interface DataSource extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'DataSource';\n fields: Array<ConfigField>;\n name: RegularID;\n}\n\nexport const DataSource = 'DataSource';\n\nexport function isDataSource(item: unknown): item is DataSource {\n return reflection.isInstance(item, DataSource);\n}\n\nexport interface Enum extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'Enum';\n attributes: Array<DataModelAttribute>;\n comments: Array<string>;\n fields: Array<EnumField>;\n name: RegularID;\n}\n\nexport const Enum = 'Enum';\n\nexport function isEnum(item: unknown): item is Enum {\n return reflection.isInstance(item, Enum);\n}\n\nexport interface EnumField extends langium.AstNode {\n readonly $container: Enum;\n readonly $type: 'EnumField';\n attributes: Array<DataFieldAttribute>;\n comments: Array<string>;\n name: RegularIDWithTypeNames;\n}\n\nexport const EnumField = 'EnumField';\n\nexport function isEnumField(item: unknown): item is EnumField {\n return reflection.isInstance(item, EnumField);\n}\n\nexport interface FieldInitializer extends langium.AstNode {\n readonly $container: ObjectExpr;\n readonly $type: 'FieldInitializer';\n name: RegularID | string;\n value: Expression;\n}\n\nexport const FieldInitializer = 'FieldInitializer';\n\nexport function isFieldInitializer(item: unknown): item is FieldInitializer {\n return reflection.isInstance(item, FieldInitializer);\n}\n\nexport interface FunctionDecl extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'FunctionDecl';\n attributes: Array<InternalAttribute>;\n expression?: Expression;\n name: RegularID;\n params: Array<FunctionParam>;\n returnType: FunctionParamType;\n}\n\nexport const FunctionDecl = 'FunctionDecl';\n\nexport function isFunctionDecl(item: unknown): item is FunctionDecl {\n return reflection.isInstance(item, FunctionDecl);\n}\n\nexport interface FunctionParam extends langium.AstNode {\n readonly $container: FunctionDecl | Procedure;\n readonly $type: 'FunctionParam';\n name: RegularID;\n optional: boolean;\n type: FunctionParamType;\n}\n\nexport const FunctionParam = 'FunctionParam';\n\nexport function isFunctionParam(item: unknown): item is FunctionParam {\n return reflection.isInstance(item, FunctionParam);\n}\n\nexport interface FunctionParamType extends langium.AstNode {\n readonly $container: FunctionDecl | FunctionParam | Procedure | ProcedureParam;\n readonly $type: 'FunctionParamType';\n array: boolean;\n reference?: langium.Reference<TypeDeclaration>;\n type?: ExpressionType;\n}\n\nexport const FunctionParamType = 'FunctionParamType';\n\nexport function isFunctionParamType(item: unknown): item is FunctionParamType {\n return reflection.isInstance(item, FunctionParamType);\n}\n\nexport interface GeneratorDecl extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'GeneratorDecl';\n fields: Array<ConfigField>;\n name: RegularID;\n}\n\nexport const GeneratorDecl = 'GeneratorDecl';\n\nexport function isGeneratorDecl(item: unknown): item is GeneratorDecl {\n return reflection.isInstance(item, GeneratorDecl);\n}\n\nexport interface InternalAttribute extends langium.AstNode {\n readonly $container: Attribute | AttributeParam | FunctionDecl | Procedure;\n readonly $type: 'InternalAttribute';\n args: Array<AttributeArg>;\n decl: langium.Reference<Attribute>;\n}\n\nexport const InternalAttribute = 'InternalAttribute';\n\nexport function isInternalAttribute(item: unknown): item is InternalAttribute {\n return reflection.isInstance(item, InternalAttribute);\n}\n\nexport interface InvocationExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigField | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'InvocationExpr';\n args: Array<Argument>;\n function: langium.Reference<FunctionDecl>;\n}\n\nexport const InvocationExpr = 'InvocationExpr';\n\nexport function isInvocationExpr(item: unknown): item is InvocationExpr {\n return reflection.isInstance(item, InvocationExpr);\n}\n\nexport interface MemberAccessExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'MemberAccessExpr';\n member: langium.Reference<MemberAccessTarget>;\n operand: Expression;\n}\n\nexport const MemberAccessExpr = 'MemberAccessExpr';\n\nexport function isMemberAccessExpr(item: unknown): item is MemberAccessExpr {\n return reflection.isInstance(item, MemberAccessExpr);\n}\n\nexport interface Model extends langium.AstNode {\n readonly $type: 'Model';\n declarations: Array<AbstractDeclaration>;\n imports: Array<ModelImport>;\n}\n\nexport const Model = 'Model';\n\nexport function isModel(item: unknown): item is Model {\n return reflection.isInstance(item, Model);\n}\n\nexport interface ModelImport extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'ModelImport';\n path: string;\n}\n\nexport const ModelImport = 'ModelImport';\n\nexport function isModelImport(item: unknown): item is ModelImport {\n return reflection.isInstance(item, ModelImport);\n}\n\nexport interface NullExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'NullExpr';\n value: 'null';\n}\n\nexport const NullExpr = 'NullExpr';\n\nexport function isNullExpr(item: unknown): item is NullExpr {\n return reflection.isInstance(item, NullExpr);\n}\n\nexport interface NumberLiteral extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;\n readonly $type: 'NumberLiteral';\n value: string;\n}\n\nexport const NumberLiteral = 'NumberLiteral';\n\nexport function isNumberLiteral(item: unknown): item is NumberLiteral {\n return reflection.isInstance(item, NumberLiteral);\n}\n\nexport interface ObjectExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr;\n readonly $type: 'ObjectExpr';\n fields: Array<FieldInitializer>;\n}\n\nexport const ObjectExpr = 'ObjectExpr';\n\nexport function isObjectExpr(item: unknown): item is ObjectExpr {\n return reflection.isInstance(item, ObjectExpr);\n}\n\nexport interface Plugin extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'Plugin';\n fields: Array<PluginField>;\n name: RegularID;\n}\n\nexport const Plugin = 'Plugin';\n\nexport function isPlugin(item: unknown): item is Plugin {\n return reflection.isInstance(item, Plugin);\n}\n\nexport interface PluginField extends langium.AstNode {\n readonly $container: Plugin;\n readonly $type: 'PluginField';\n name: RegularID;\n value: ArrayExpr | LiteralExpr | ObjectExpr;\n}\n\nexport const PluginField = 'PluginField';\n\nexport function isPluginField(item: unknown): item is PluginField {\n return reflection.isInstance(item, PluginField);\n}\n\nexport interface Procedure extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'Procedure';\n attributes: Array<InternalAttribute>;\n mutation: boolean;\n name: RegularID;\n params: Array<FunctionParam | ProcedureParam>;\n returnType: FunctionParamType;\n}\n\nexport const Procedure = 'Procedure';\n\nexport function isProcedure(item: unknown): item is Procedure {\n return reflection.isInstance(item, Procedure);\n}\n\nexport interface ProcedureParam extends langium.AstNode {\n readonly $container: Procedure;\n readonly $type: 'ProcedureParam';\n name: RegularID;\n optional: boolean;\n type: FunctionParamType;\n}\n\nexport const ProcedureParam = 'ProcedureParam';\n\nexport function isProcedureParam(item: unknown): item is ProcedureParam {\n return reflection.isInstance(item, ProcedureParam);\n}\n\nexport interface ReferenceArg extends langium.AstNode {\n readonly $container: ReferenceExpr;\n readonly $type: 'ReferenceArg';\n name: string;\n value: Expression;\n}\n\nexport const ReferenceArg = 'ReferenceArg';\n\nexport function isReferenceArg(item: unknown): item is ReferenceArg {\n return reflection.isInstance(item, ReferenceArg);\n}\n\nexport interface ReferenceExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'ReferenceExpr';\n args: Array<ReferenceArg>;\n target: langium.Reference<ReferenceTarget>;\n}\n\nexport const ReferenceExpr = 'ReferenceExpr';\n\nexport function isReferenceExpr(item: unknown): item is ReferenceExpr {\n return reflection.isInstance(item, ReferenceExpr);\n}\n\nexport interface StringLiteral extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;\n readonly $type: 'StringLiteral';\n value: string;\n}\n\nexport const StringLiteral = 'StringLiteral';\n\nexport function isStringLiteral(item: unknown): item is StringLiteral {\n return reflection.isInstance(item, StringLiteral);\n}\n\nexport interface ThisExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'ThisExpr';\n value: 'this';\n}\n\nexport const ThisExpr = 'ThisExpr';\n\nexport function isThisExpr(item: unknown): item is ThisExpr {\n return reflection.isInstance(item, ThisExpr);\n}\n\nexport interface TypeDef extends langium.AstNode {\n readonly $container: Model;\n readonly $type: 'TypeDef';\n attributes: Array<DataModelAttribute>;\n comments: Array<string>;\n fields: Array<DataField>;\n mixins: Array<langium.Reference<TypeDef>>;\n name: RegularID;\n}\n\nexport const TypeDef = 'TypeDef';\n\nexport function isTypeDef(item: unknown): item is TypeDef {\n return reflection.isInstance(item, TypeDef);\n}\n\nexport interface UnaryExpr extends langium.AstNode {\n readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;\n readonly $type: 'UnaryExpr';\n operand: Expression;\n operator: '!';\n}\n\nexport const UnaryExpr = 'UnaryExpr';\n\nexport function isUnaryExpr(item: unknown): item is UnaryExpr {\n return reflection.isInstance(item, UnaryExpr);\n}\n\nexport interface UnsupportedFieldType extends langium.AstNode {\n readonly $container: DataFieldType;\n readonly $type: 'UnsupportedFieldType';\n value: LiteralExpr;\n}\n\nexport const UnsupportedFieldType = 'UnsupportedFieldType';\n\nexport function isUnsupportedFieldType(item: unknown): item is UnsupportedFieldType {\n return reflection.isInstance(item, UnsupportedFieldType);\n}\n\nexport type ZModelAstType = {\n AbstractDeclaration: AbstractDeclaration\n Argument: Argument\n ArrayExpr: ArrayExpr\n Attribute: Attribute\n AttributeArg: AttributeArg\n AttributeParam: AttributeParam\n AttributeParamType: AttributeParamType\n BinaryExpr: BinaryExpr\n BooleanLiteral: BooleanLiteral\n ConfigArrayExpr: ConfigArrayExpr\n ConfigExpr: ConfigExpr\n ConfigField: ConfigField\n ConfigInvocationArg: ConfigInvocationArg\n ConfigInvocationExpr: ConfigInvocationExpr\n DataField: DataField\n DataFieldAttribute: DataFieldAttribute\n DataFieldType: DataFieldType\n DataModel: DataModel\n DataModelAttribute: DataModelAttribute\n DataSource: DataSource\n Enum: Enum\n EnumField: EnumField\n Expression: Expression\n FieldInitializer: FieldInitializer\n FunctionDecl: FunctionDecl\n FunctionParam: FunctionParam\n FunctionParamType: FunctionParamType\n GeneratorDecl: GeneratorDecl\n InternalAttribute: InternalAttribute\n InvocationExpr: InvocationExpr\n LiteralExpr: LiteralExpr\n MemberAccessExpr: MemberAccessExpr\n MemberAccessTarget: MemberAccessTarget\n Model: Model\n ModelImport: ModelImport\n NullExpr: NullExpr\n NumberLiteral: NumberLiteral\n ObjectExpr: ObjectExpr\n Plugin: Plugin\n PluginField: PluginField\n Procedure: Procedure\n ProcedureParam: ProcedureParam\n ReferenceArg: ReferenceArg\n ReferenceExpr: ReferenceExpr\n ReferenceTarget: ReferenceTarget\n StringLiteral: StringLiteral\n ThisExpr: ThisExpr\n TypeDeclaration: TypeDeclaration\n TypeDef: TypeDef\n UnaryExpr: UnaryExpr\n UnsupportedFieldType: UnsupportedFieldType\n}\n\nexport class ZModelAstReflection extends langium.AbstractAstReflection {\n\n getAllTypes(): string[] {\n return [AbstractDeclaration, Argument, ArrayExpr, Attribute, AttributeArg, AttributeParam, AttributeParamType, BinaryExpr, BooleanLiteral, ConfigArrayExpr, ConfigExpr, ConfigField, ConfigInvocationArg, ConfigInvocationExpr, DataField, DataFieldAttribute, DataFieldType, DataModel, DataModelAttribute, DataSource, Enum, EnumField, Expression, FieldInitializer, FunctionDecl, FunctionParam, FunctionParamType, GeneratorDecl, InternalAttribute, InvocationExpr, LiteralExpr, MemberAccessExpr, MemberAccessTarget, Model, ModelImport, NullExpr, NumberLiteral, ObjectExpr, Plugin, PluginField, Procedure, ProcedureParam, ReferenceArg, ReferenceExpr, ReferenceTarget, StringLiteral, ThisExpr, TypeDeclaration, TypeDef, UnaryExpr, UnsupportedFieldType];\n }\n\n protected override computeIsSubtype(subtype: string, supertype: string): boolean {\n switch (subtype) {\n case ArrayExpr:\n case BinaryExpr:\n case MemberAccessExpr:\n case NullExpr:\n case ObjectExpr:\n case ReferenceExpr:\n case ThisExpr:\n case UnaryExpr: {\n return this.isSubtype(Expression, supertype);\n }\n case Attribute:\n case DataSource:\n case FunctionDecl:\n case GeneratorDecl:\n case Plugin:\n case Procedure: {\n return this.isSubtype(AbstractDeclaration, supertype);\n }\n case BooleanLiteral:\n case NumberLiteral:\n case StringLiteral: {\n return this.isSubtype(LiteralExpr, supertype);\n }\n case ConfigArrayExpr: {\n return this.isSubtype(ConfigExpr, supertype);\n }\n case DataField: {\n return this.isSubtype(MemberAccessTarget, supertype) || this.isSubtype(ReferenceTarget, supertype);\n }\n case DataModel:\n case Enum:\n case TypeDef: {\n return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype);\n }\n case EnumField:\n case FunctionParam: {\n return this.isSubtype(ReferenceTarget, supertype);\n }\n case InvocationExpr:\n case LiteralExpr: {\n return this.isSubtype(ConfigExpr, supertype) || this.isSubtype(Expression, supertype);\n }\n default: {\n return false;\n }\n }\n }\n\n getReferenceType(refInfo: langium.ReferenceInfo): string {\n const referenceId = `${refInfo.container.$type}:${refInfo.property}`;\n switch (referenceId) {\n case 'AttributeParamType:reference':\n case 'DataFieldType:reference':\n case 'FunctionParamType:reference': {\n return TypeDeclaration;\n }\n case 'DataFieldAttribute:decl':\n case 'DataModelAttribute:decl':\n case 'InternalAttribute:decl': {\n return Attribute;\n }\n case 'DataModel:baseModel': {\n return DataModel;\n }\n case 'DataModel:mixins':\n case 'TypeDef:mixins': {\n return TypeDef;\n }\n case 'InvocationExpr:function': {\n return FunctionDecl;\n }\n case 'MemberAccessExpr:member': {\n return MemberAccessTarget;\n }\n case 'ReferenceExpr:target': {\n return ReferenceTarget;\n }\n default: {\n throw new Error(`${referenceId} is not a valid reference id.`);\n }\n }\n }\n\n getTypeMetaData(type: string): langium.TypeMetaData {\n switch (type) {\n case Argument: {\n return {\n name: Argument,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case ArrayExpr: {\n return {\n name: ArrayExpr,\n properties: [\n { name: 'items', defaultValue: [] }\n ]\n };\n }\n case Attribute: {\n return {\n name: Attribute,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'name' },\n { name: 'params', defaultValue: [] }\n ]\n };\n }\n case AttributeArg: {\n return {\n name: AttributeArg,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case AttributeParam: {\n return {\n name: AttributeParam,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'default', defaultValue: false },\n { name: 'name' },\n { name: 'type' }\n ]\n };\n }\n case AttributeParamType: {\n return {\n name: AttributeParamType,\n properties: [\n { name: 'array', defaultValue: false },\n { name: 'optional', defaultValue: false },\n { name: 'reference' },\n { name: 'type' }\n ]\n };\n }\n case BinaryExpr: {\n return {\n name: BinaryExpr,\n properties: [\n { name: 'left' },\n { name: 'operator' },\n { name: 'right' }\n ]\n };\n }\n case BooleanLiteral: {\n return {\n name: BooleanLiteral,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case ConfigArrayExpr: {\n return {\n name: ConfigArrayExpr,\n properties: [\n { name: 'items', defaultValue: [] }\n ]\n };\n }\n case ConfigField: {\n return {\n name: ConfigField,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case ConfigInvocationArg: {\n return {\n name: ConfigInvocationArg,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case ConfigInvocationExpr: {\n return {\n name: ConfigInvocationExpr,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case DataField: {\n return {\n name: DataField,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'name' },\n { name: 'type' }\n ]\n };\n }\n case DataFieldAttribute: {\n return {\n name: DataFieldAttribute,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'decl' }\n ]\n };\n }\n case DataFieldType: {\n return {\n name: DataFieldType,\n properties: [\n { name: 'array', defaultValue: false },\n { name: 'optional', defaultValue: false },\n { name: 'reference' },\n { name: 'type' },\n { name: 'unsupported' }\n ]\n };\n }\n case DataModel: {\n return {\n name: DataModel,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'baseModel' },\n { name: 'comments', defaultValue: [] },\n { name: 'fields', defaultValue: [] },\n { name: 'isView', defaultValue: false },\n { name: 'mixins', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case DataModelAttribute: {\n return {\n name: DataModelAttribute,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'decl' }\n ]\n };\n }\n case DataSource: {\n return {\n name: DataSource,\n properties: [\n { name: 'fields', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case Enum: {\n return {\n name: Enum,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'fields', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case EnumField: {\n return {\n name: EnumField,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case FieldInitializer: {\n return {\n name: FieldInitializer,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case FunctionDecl: {\n return {\n name: FunctionDecl,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'expression' },\n { name: 'name' },\n { name: 'params', defaultValue: [] },\n { name: 'returnType' }\n ]\n };\n }\n case FunctionParam: {\n return {\n name: FunctionParam,\n properties: [\n { name: 'name' },\n { name: 'optional', defaultValue: false },\n { name: 'type' }\n ]\n };\n }\n case FunctionParamType: {\n return {\n name: FunctionParamType,\n properties: [\n { name: 'array', defaultValue: false },\n { name: 'reference' },\n { name: 'type' }\n ]\n };\n }\n case GeneratorDecl: {\n return {\n name: GeneratorDecl,\n properties: [\n { name: 'fields', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case InternalAttribute: {\n return {\n name: InternalAttribute,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'decl' }\n ]\n };\n }\n case InvocationExpr: {\n return {\n name: InvocationExpr,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'function' }\n ]\n };\n }\n case MemberAccessExpr: {\n return {\n name: MemberAccessExpr,\n properties: [\n { name: 'member' },\n { name: 'operand' }\n ]\n };\n }\n case Model: {\n return {\n name: Model,\n properties: [\n { name: 'declarations', defaultValue: [] },\n { name: 'imports', defaultValue: [] }\n ]\n };\n }\n case ModelImport: {\n return {\n name: ModelImport,\n properties: [\n { name: 'path' }\n ]\n };\n }\n case NullExpr: {\n return {\n name: NullExpr,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case NumberLiteral: {\n return {\n name: NumberLiteral,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case ObjectExpr: {\n return {\n name: ObjectExpr,\n properties: [\n { name: 'fields', defaultValue: [] }\n ]\n };\n }\n case Plugin: {\n return {\n name: Plugin,\n properties: [\n { name: 'fields', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case PluginField: {\n return {\n name: PluginField,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case Procedure: {\n return {\n name: Procedure,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'mutation', defaultValue: false },\n { name: 'name' },\n { name: 'params', defaultValue: [] },\n { name: 'returnType' }\n ]\n };\n }\n case ProcedureParam: {\n return {\n name: ProcedureParam,\n properties: [\n { name: 'name' },\n { name: 'optional', defaultValue: false },\n { name: 'type' }\n ]\n };\n }\n case ReferenceArg: {\n return {\n name: ReferenceArg,\n properties: [\n { name: 'name' },\n { name: 'value' }\n ]\n };\n }\n case ReferenceExpr: {\n return {\n name: ReferenceExpr,\n properties: [\n { name: 'args', defaultValue: [] },\n { name: 'target' }\n ]\n };\n }\n case StringLiteral: {\n return {\n name: StringLiteral,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case ThisExpr: {\n return {\n name: ThisExpr,\n properties: [\n { name: 'value' }\n ]\n };\n }\n case TypeDef: {\n return {\n name: TypeDef,\n properties: [\n { name: 'attributes', defaultValue: [] },\n { name: 'comments', defaultValue: [] },\n { name: 'fields', defaultValue: [] },\n { name: 'mixins', defaultValue: [] },\n { name: 'name' }\n ]\n };\n }\n case UnaryExpr: {\n return {\n name: UnaryExpr,\n properties: [\n { name: 'operand' },\n { name: 'operator' }\n ]\n };\n }\n case UnsupportedFieldType: {\n return {\n name: UnsupportedFieldType,\n properties: [\n { name: 'value' }\n ]\n };\n }\n default: {\n return {\n name: type,\n properties: []\n };\n }\n }\n }\n}\n\nexport const reflection = new ZModelAstReflection();\n","/**\n * Supported Prisma db providers\n */\nexport const SUPPORTED_PROVIDERS = [\n 'sqlite',\n 'postgresql',\n // TODO: other providers\n // 'mysql',\n // 'sqlserver',\n // 'cockroachdb',\n];\n\n/**\n * All scalar types\n */\nexport const SCALAR_TYPES = ['String', 'Int', 'Float', 'Decimal', 'BigInt', 'Boolean', 'Bytes', 'DateTime'];\n\n/**\n * Name of standard library module\n */\nexport const STD_LIB_MODULE_NAME = 'stdlib.zmodel';\n\n/**\n * Name of module contributed by plugins\n */\nexport const PLUGIN_MODULE_NAME = 'plugin.zmodel';\n\n/**\n * Validation issues\n */\nexport enum IssueCodes {\n MissingOppositeRelation = 'miss-opposite-relation',\n}\n\n/**\n * Expression context\n */\nexport enum ExpressionContext {\n DefaultValue = 'DefaultValue',\n AccessPolicy = 'AccessPolicy',\n ValidationRule = 'ValidationRule',\n Index = 'Index',\n}\n","import { inject, type DeepPartial, type Module } from 'langium';\nimport {\n createDefaultModule,\n createDefaultSharedModule,\n type DefaultSharedModuleContext,\n type LangiumServices,\n type LangiumSharedServices,\n type PartialLangiumServices,\n} from 'langium/lsp';\nimport { ZModelGeneratedModule, ZModelGeneratedSharedModule, ZModelLanguageMetaData } from './generated/module';\nimport { ZModelValidator, registerValidationChecks } from './validator';\nimport { ZModelLinker } from './zmodel-linker';\nimport { ZModelScopeComputation, ZModelScopeProvider } from './zmodel-scope';\nimport { ZModelWorkspaceManager } from './zmodel-workspace-manager';\nexport { ZModelLanguageMetaData };\n\n/**\n * Declaration of custom services - add your own service classes here.\n */\nexport type ZModelAddedServices = {\n validation: {\n ZModelValidator: ZModelValidator;\n };\n};\n\n/**\n * Union of Langium default services and your custom services - use this as constructor parameter\n * of custom service classes.\n */\nexport type ZModelServices = LangiumServices & ZModelAddedServices;\n\n/**\n * Dependency injection module that overrides Langium default services and contributes the\n * declared custom services. The Langium defaults can be partially specified to override only\n * selected services, while the custom services must be fully specified.\n */\nexport const ZModelLanguageModule: Module<ZModelServices, PartialLangiumServices & ZModelAddedServices> = {\n references: {\n ScopeComputation: (services) => new ZModelScopeComputation(services),\n ScopeProvider: (services) => new ZModelScopeProvider(services),\n Linker: (services) => new ZModelLinker(services),\n },\n validation: {\n ZModelValidator: (services) => new ZModelValidator(services),\n },\n};\n\nexport type ZModelSharedServices = LangiumSharedServices;\n\nexport const ZModelSharedModule: Module<ZModelSharedServices, DeepPartial<ZModelSharedServices>> = {\n workspace: {\n WorkspaceManager: (services) => new ZModelWorkspaceManager(services),\n },\n};\n\n/**\n * Create the full set of services required by Langium.\n *\n * First inject the shared services by merging two modules:\n * - Langium default shared services\n * - Services generated by langium-cli\n *\n * Then inject the language-specific services by merging three modules:\n * - Langium default language-specific services\n * - Services generated by langium-cli\n * - Services specified in this file\n *\n * @param context Optional module context with the LSP connection\n * @returns An object wrapping the shared services and the language-specific services\n */\nexport function createZModelLanguageServices(context: DefaultSharedModuleContext): {\n shared: LangiumSharedServices;\n ZModelLanguage: ZModelServices;\n} {\n const shared = inject(createDefaultSharedModule(context), ZModelGeneratedSharedModule, ZModelSharedModule);\n const ZModelLanguage = inject(createDefaultModule({ shared }), ZModelGeneratedModule, ZModelLanguageModule);\n shared.ServiceRegistry.register(ZModelLanguage);\n registerValidationChecks(ZModelLanguage);\n if (!context.connection) {\n // We don't run inside a language server\n // Therefore, initialize the configuration provider instantly\n shared.workspace.ConfigurationProvider.initialized({});\n }\n return { shared, ZModelLanguage };\n}\n","/******************************************************************************\n * This file was generated by langium-cli 3.5.0.\n * DO NOT EDIT MANUALLY!\n ******************************************************************************/\n\nimport type { Grammar } from 'langium';\nimport { loadGrammarFromJson } from 'langium';\n\nlet loadedZModelGrammar: Grammar | undefined;\nexport const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModelGrammar = loadGrammarFromJson(`{\n \"$type\": \"Grammar\",\n \"isDeclared\": true,\n \"name\": \"ZModel\",\n \"rules\": [\n {\n \"$type\": \"ParserRule\",\n \"entry\": true,\n \"name\": \"Model\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"imports\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@1\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"declarations\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@2\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ModelImport\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"import\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"path\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@69\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \";\",\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"AbstractDeclaration\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@3\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@4\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@6\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@37\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@42\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@44\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@46\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@53\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@50\"\n },\n \"arguments\": []\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataSource\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"datasource\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@5\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"GeneratorDecl\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"generator\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@5\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigField\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@18\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Plugin\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"plugin\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@7\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"PluginField\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@13\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@24\"\n },\n \"arguments\": []\n }\n ]\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Expression\",\n \"definition\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@33\"\n },\n \"arguments\": []\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"NumberLiteral\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@70\"\n },\n \"arguments\": []\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"StringLiteral\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@69\"\n },\n \"arguments\": []\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"BooleanLiteral\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@63\"\n },\n \"arguments\": []\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"LiteralExpr\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@9\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@10\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@11\"\n },\n \"arguments\": []\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ArrayExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"items\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"items\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigInvocationExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@68\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@15\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"ConfigInvocationArgList\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@16\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@16\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigInvocationArg\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@68\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigArrayExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"items\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@14\"\n },\n \"arguments\": []\n }\n ]\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"items\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@14\"\n },\n \"arguments\": []\n }\n ]\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ConfigExpr\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@26\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@17\"\n },\n \"arguments\": []\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ThisExpr\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"this\"\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"NullExpr\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"null\"\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ReferenceExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"target\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@0\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@52\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@22\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"ReferenceArgList\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@23\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@23\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ReferenceArg\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@68\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ObjectExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@25\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@25\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \",\",\n \"cardinality\": \"?\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"FieldInitializer\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@69\"\n },\n \"arguments\": []\n }\n ]\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"InvocationExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"function\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@46\"\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@35\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"MemberAccessExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@34\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"MemberAccessExpr\"\n },\n \"feature\": \"operand\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \".\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"member\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@1\"\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"UnaryExpr\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"!\"\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operand\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@27\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"CollectionPredicateExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@27\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"!\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"^\"\n }\n ]\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"InExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@29\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"in\"\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@29\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ComparisonExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@30\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \">\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"<\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \">=\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"<=\"\n }\n ]\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@30\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"EqualityExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@31\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"==\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"!=\"\n }\n ]\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@31\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"LogicalExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@32\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Action\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"BinaryExpr\"\n },\n \"feature\": \"left\",\n \"operator\": \"=\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"operator\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"&&\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"||\"\n }\n ]\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"right\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@32\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"PrimaryExpr\",\n \"inferredType\": {\n \"$type\": \"InferredType\",\n \"name\": \"Expression\"\n },\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ]\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@19\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@20\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@28\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@26\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@13\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@21\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@24\"\n },\n \"arguments\": []\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"ArgumentList\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@36\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@36\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Argument\",\n \"definition\": {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataModel\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"model\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@38\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@39\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@39\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@38\"\n },\n \"arguments\": []\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@38\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@39\"\n },\n \"arguments\": []\n }\n ]\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"isView\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"view\"\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n }\n ]\n }\n ]\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@40\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@57\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"WithClause\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"with\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"mixins\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@42\"\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\",\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"mixins\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@42\"\n },\n \"deprecatedSyntax\": false\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"ExtendsClause\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"extends\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"baseModel\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@37\"\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataField\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@52\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@41\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@56\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataFieldType\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@62\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"unsupported\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@43\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"reference\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@2\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"array\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"optional\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"TypeDef\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"type\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@38\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@40\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@57\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"UnsupportedFieldType\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"Unsupported\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@12\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Enum\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"enum\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"fields\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@45\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@57\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"+\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"EnumField\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@52\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@56\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"FunctionDecl\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"function\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@47\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@47\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"returnType\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@48\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"{\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"expression\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"}\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@58\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"FunctionParam\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@48\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"optional\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"FunctionParamType\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@61\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"reference\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@2\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"array\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ProcedureParam\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@48\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"optional\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Procedure\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"mutation\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"mutation\"\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"procedure\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@49\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@47\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"returnType\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@48\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@58\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"RegularID\",\n \"dataType\": \"string\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@68\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"model\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"enum\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"attribute\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"datasource\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"plugin\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"abstract\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"in\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"view\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"import\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"type\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"RegularIDWithTypeNames\",\n \"dataType\": \"string\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"String\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Boolean\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Int\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"BigInt\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Float\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Decimal\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"DateTime\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Json\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Bytes\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Null\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Object\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Any\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Unsupported\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Attribute\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"attribute\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@65\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@66\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@67\"\n },\n \"arguments\": []\n }\n ]\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@54\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"params\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@54\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@58\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"AttributeParam\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"comments\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"default\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"_\"\n },\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@55\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"attributes\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@58\"\n },\n \"arguments\": []\n },\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"AttributeParamType\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"type\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@61\"\n },\n \"arguments\": []\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"FieldReference\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"TransitiveFieldReference\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"ContextType\"\n }\n ]\n }\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"reference\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/types@2\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n }\n ]\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"array\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"[\"\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"]\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"optional\",\n \"operator\": \"?=\",\n \"terminal\": {\n \"$type\": \"Keyword\",\n \"value\": \"?\"\n },\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataFieldAttribute\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"decl\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@53\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@67\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@59\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"DataModelAttribute\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@71\"\n },\n \"arguments\": [],\n \"cardinality\": \"*\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"decl\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@53\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@66\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@59\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"InternalAttribute\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"decl\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"CrossReference\",\n \"type\": {\n \"$ref\": \"#/rules@53\"\n },\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@65\"\n },\n \"arguments\": []\n },\n \"deprecatedSyntax\": false\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"(\"\n },\n {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@59\"\n },\n \"arguments\": [],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \")\"\n }\n ],\n \"cardinality\": \"?\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"fragment\": true,\n \"name\": \"AttributeArgList\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@60\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \",\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"args\",\n \"operator\": \"+=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@60\"\n },\n \"arguments\": []\n }\n }\n ],\n \"cardinality\": \"*\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"AttributeArg\",\n \"definition\": {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Group\",\n \"elements\": [\n {\n \"$type\": \"Assignment\",\n \"feature\": \"name\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@51\"\n },\n \"arguments\": []\n }\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \":\"\n }\n ],\n \"cardinality\": \"?\"\n },\n {\n \"$type\": \"Assignment\",\n \"feature\": \"value\",\n \"operator\": \"=\",\n \"terminal\": {\n \"$type\": \"RuleCall\",\n \"rule\": {\n \"$ref\": \"#/rules@8\"\n },\n \"arguments\": []\n }\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"ExpressionType\",\n \"dataType\": \"string\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"String\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Int\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Float\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Boolean\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"DateTime\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Null\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Object\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Any\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Unsupported\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"BuiltinType\",\n \"dataType\": \"string\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"String\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Boolean\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Int\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"BigInt\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Float\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Decimal\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"DateTime\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Json\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"Bytes\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"ParserRule\",\n \"name\": \"Boolean\",\n \"dataType\": \"boolean\",\n \"definition\": {\n \"$type\": \"Alternatives\",\n \"elements\": [\n {\n \"$type\": \"Keyword\",\n \"value\": \"true\"\n },\n {\n \"$type\": \"Keyword\",\n \"value\": \"false\"\n }\n ]\n },\n \"definesHiddenTokens\": false,\n \"entry\": false,\n \"fragment\": false,\n \"hiddenTokens\": [],\n \"parameters\": [],\n \"wildcard\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"hidden\": true,\n \"name\": \"WS\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\\\\s+/\"\n },\n \"fragment\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"INTERNAL_ATTRIBUTE_NAME\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/@@@([_a-zA-Z][\\\\\\\\w_]*\\\\\\\\.)*[_a-zA-Z][\\\\\\\\w_]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"MODEL_ATTRIBUTE_NAME\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/@@([_a-zA-Z][\\\\\\\\w_]*\\\\\\\\.)*[_a-zA-Z][\\\\\\\\w_]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"FIELD_ATTRIBUTE_NAME\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/@([_a-zA-Z][\\\\\\\\w_]*\\\\\\\\.)*[_a-zA-Z][\\\\\\\\w_]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"ID\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/[_a-zA-Z][\\\\\\\\w_]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"STRING\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\"(\\\\\\\\\\\\\\\\.|[^\\\\\"\\\\\\\\\\\\\\\\])*\\\\\"|'(\\\\\\\\\\\\\\\\.|[^'\\\\\\\\\\\\\\\\])*'/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"NUMBER\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/[+-]?[0-9]+(\\\\\\\\.[0-9]+)?/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"name\": \"TRIPLE_SLASH_COMMENT\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\\\\/\\\\\\\\/\\\\\\\\/[^\\\\\\\\n\\\\\\\\r]*/\"\n },\n \"fragment\": false,\n \"hidden\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"hidden\": true,\n \"name\": \"ML_COMMENT\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\\\\/\\\\\\\\*[\\\\\\\\s\\\\\\\\S]*?\\\\\\\\*\\\\\\\\//\"\n },\n \"fragment\": false\n },\n {\n \"$type\": \"TerminalRule\",\n \"hidden\": true,\n \"name\": \"SL_COMMENT\",\n \"definition\": {\n \"$type\": \"RegexToken\",\n \"regex\": \"/\\\\\\\\/\\\\\\\\/[^\\\\\\\\n\\\\\\\\r]*/\"\n },\n \"fragment\": false\n }\n ],\n \"types\": [\n {\n \"$type\": \"Type\",\n \"name\": \"ReferenceTarget\",\n \"type\": {\n \"$type\": \"UnionType\",\n \"types\": [\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@47\"\n }\n },\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@40\"\n }\n },\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@45\"\n }\n }\n ]\n }\n },\n {\n \"$type\": \"Type\",\n \"name\": \"MemberAccessTarget\",\n \"type\": {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@40\"\n }\n }\n },\n {\n \"$type\": \"Type\",\n \"name\": \"TypeDeclaration\",\n \"type\": {\n \"$type\": \"UnionType\",\n \"types\": [\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@37\"\n }\n },\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@42\"\n }\n },\n {\n \"$type\": \"SimpleType\",\n \"typeRef\": {\n \"$ref\": \"#/rules@44\"\n }\n }\n ]\n }\n }\n ],\n \"definesHiddenTokens\": false,\n \"hiddenTokens\": [],\n \"imports\": [],\n \"interfaces\": [],\n \"usedGrammars\": []\n}`));\n","/******************************************************************************\n * This file was generated by langium-cli 3.5.0.\n * DO NOT EDIT MANUALLY!\n ******************************************************************************/\n\nimport type { LangiumSharedCoreServices, LangiumCoreServices, LangiumGeneratedCoreServices, LangiumGeneratedSharedCoreServices, LanguageMetaData, Module } from 'langium';\nimport { ZModelAstReflection } from './ast.js';\nimport { ZModelGrammar } from './grammar.js';\n\nexport const ZModelLanguageMetaData = {\n languageId: 'zmodel',\n fileExtensions: ['.zmodel'],\n caseInsensitive: false,\n mode: 'development'\n} as const satisfies LanguageMetaData;\n\nexport const ZModelGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedCoreServices> = {\n AstReflection: () => new ZModelAstReflection()\n};\n\nexport const ZModelGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedCoreServices> = {\n Grammar: () => ZModelGrammar(),\n LanguageMetaData: () => ZModelLanguageMetaData,\n parser: {}\n};\n","import { AstUtils, type ValidationAcceptor } from 'langium';\nimport pluralize from 'pluralize';\nimport {\n ArrayExpr,\n Attribute,\n AttributeArg,\n AttributeParam,\n DataModelAttribute,\n DataField,\n DataFieldAttribute,\n InternalAttribute,\n ReferenceExpr,\n isArrayExpr,\n isAttribute,\n isDataModel,\n isDataField,\n isEnum,\n isReferenceExpr,\n isTypeDef,\n} from '../generated/ast';\nimport {\n getAllAttributes,\n getStringLiteral,\n hasAttribute,\n isDataFieldReference,\n isDelegateModel,\n isFutureExpr,\n isRelationshipField,\n mapBuiltinTypeToExpressionType,\n resolved,\n typeAssignable,\n} from '../utils';\nimport type { AstValidator } from './common';\nimport type { DataModel } from '../ast';\n\n// a registry of function handlers marked with @check\nconst attributeCheckers = new Map<string, PropertyDescriptor>();\n\n// function handler decorator\nfunction check(name: string) {\n return function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) {\n if (!attributeCheckers.get(name)) {\n attributeCheckers.set(name, descriptor);\n }\n return descriptor;\n };\n}\n\ntype AttributeApplication = DataModelAttribute | DataFieldAttribute | InternalAttribute;\n\n/**\n * Validates function declarations.\n */\nexport default class AttributeApplicationValidator implements AstValidator<AttributeApplication> {\n validate(attr: AttributeApplication, accept: ValidationAcceptor, contextDataModel?: DataModel) {\n const decl = attr.decl.ref;\n if (!decl) {\n return;\n }\n\n const targetDecl = attr.$container;\n if (decl.name === '@@@targetField' && !isAttribute(targetDecl)) {\n accept('error', `attribute \"${decl.name}\" can only be used on attribute declarations`, { node: attr });\n return;\n }\n\n if (isDataField(targetDecl) && !isValidAttributeTarget(decl, targetDecl)) {\n accept('error', `attribute \"${decl.name}\" cannot be used on this type of field`, { node: attr });\n }\n\n this.checkDeprecation(attr, accept);\n this.checkDuplicatedAttributes(attr, accept, contextDataModel);\n\n const filledParams = new Set<AttributeParam>();\n\n for (const arg of attr.args) {\n let paramDecl: AttributeParam | undefined;\n if (!arg.name) {\n paramDecl = decl.params.find((p) => p.default && !filledParams.has(p));\n if (!paramDecl) {\n accept('error', `Unexpected unnamed argument`, {\n node: arg,\n });\n return;\n }\n } else {\n paramDecl = decl.params.find((p) => p.name === arg.name);\n if (!paramDecl) {\n accept('error', `Attribute \"${decl.name}\" doesn't have a parameter named \"${arg.name}\"`, {\n node: arg,\n });\n return;\n }\n }\n\n if (!assignableToAttributeParam(arg, paramDecl, attr)) {\n accept('error', `Value is not assignable to parameter`, {\n node: arg,\n });\n return;\n }\n\n if (filledParams.has(paramDecl)) {\n accept('error', `Parameter \"${paramDecl.name}\" is already provided`, { node: arg });\n return;\n }\n filledParams.add(paramDecl);\n arg.$resolvedParam = paramDecl;\n }\n\n const missingParams = decl.params.filter((p) => !p.type.optional && !filledParams.has(p));\n if (missingParams.length > 0) {\n accept(\n 'error',\n `Required ${pluralize('parameter', missingParams.length)} not provided: ${missingParams\n .map((p) => p.name)\n .join(', ')}`,\n { node: attr },\n );\n return;\n }\n\n // run checkers for specific attributes\n const checker = attributeCheckers.get(decl.name);\n if (checker) {\n checker.value.call(this, attr, accept);\n }\n }\n\n private checkDeprecation(attr: AttributeApplication, accept: ValidationAcceptor) {\n const deprecateAttr = attr.decl.ref?.attributes.find((a) => a.decl.ref?.name === '@@@deprecated');\n if (deprecateAttr) {\n const message =\n getStringLiteral(deprecateAttr.args[0]?.value) ?? `Attribute \"${attr.decl.ref?.name}\" is deprecated`;\n accept('warning', message, { node: attr });\n }\n }\n\n private checkDuplicatedAttributes(\n attr: AttributeApplication,\n accept: ValidationAcceptor,\n contextDataModel?: DataModel,\n ) {\n const attrDecl = attr.decl.ref;\n if (!attrDecl?.attributes.some((a) => a.decl.ref?.name === '@@@once')) {\n return;\n }\n\n const allAttributes = contextDataModel ? getAllAttributes(contextDataModel) : attr.$container.attributes;\n const duplicates = allAttributes.filter((a) => a.decl.ref === attrDecl && a !== attr);\n if (duplicates.length > 0) {\n accept('error', `Attribute \"${attrDecl.name}\" can only be applied once`, { node: attr });\n }\n }\n\n @check('@@allow')\n @check('@@deny')\n // @ts-expect-error\n private _checkModelLevelPolicy(attr: AttributeApplication, accept: ValidationAcceptor) {\n const kind = getStringLiteral(attr.args[0]?.value);\n if (!kind) {\n accept('error', `expects a string literal`, {\n node: attr.args[0]!,\n });\n return;\n }\n this.validatePolicyKinds(kind, ['create', 'read', 'update', 'delete', 'all'], attr, accept);\n\n // @encrypted fields cannot be used in policy rules\n this.rejectEncryptedFields(attr, accept);\n }\n\n @check('@allow')\n @check('@deny')\n // @ts-expect-error\n private _checkFieldLevelPolicy(attr: AttributeApplication, accept: ValidationAcceptor) {\n const kind = getStringLiteral(attr.args[0]?.value);\n if (!kind) {\n accept('error', `expects a string literal`, {\n node: attr.args[0]!,\n });\n return;\n }\n const kindItems = this.validatePolicyKinds(kind, ['read', 'update', 'all'], attr, accept);\n\n const expr = attr.args[1]?.value;\n if (expr && AstUtils.streamAst(expr).some((node) => isFutureExpr(node))) {\n accept('error', `\"future()\" is not allowed in field-level policy rules`, { node: expr });\n }\n\n // 'update' rules are not allowed for relation fields\n if (kindItems.includes('update') || kindItems.includes('all')) {\n const field = attr.$container as DataField;\n if (isRelationshipField(field)) {\n accept(\n 'error',\n `Field-level policy rules with \"update\" or \"all\" kind are not allowed for relation fields. Put rules on foreign-key fields instead.`,\n { node: attr },\n );\n }\n }\n\n // @encrypted fields cannot be used in policy rules\n this.rejectEncryptedFields(attr, accept);\n }\n\n @check('@@validate')\n // @ts-expect-error\n private _checkValidate(attr: AttributeApplication, accept: ValidationAcceptor) {\n const condition = attr.args[0]?.value;\n if (\n condition &&\n AstUtils.streamAst(condition).some(\n (node) => isDataFieldReference(node) && isDataModel(node.$resolvedType?.decl),\n )\n ) {\n accept('error', `\\`@@validate\\` condition cannot use relation fields`, { node: condition });\n }\n }\n\n @check('@@unique')\n @check('@@id')\n // @ts-expect-error\n private _checkUnique(attr: AttributeApplication, accept: ValidationAcceptor) {\n const fields = attr.args[0]?.value;\n if (!fields) {\n accept('error', `expects an array of field references`, {\n node: attr.args[0]!,\n });\n return;\n }\n if (isArrayExpr(fields)) {\n if (fields.items.length === 0) {\n accept('error', `\\`@@unique\\` expects at least one field reference`, { node: fields });\n return;\n }\n fields.items.forEach((item) => {\n if (!isReferenceExpr(item)) {\n accept('error', `Expecting a field reference`, {\n node: item,\n });\n return;\n }\n if (!isDataField(item.target.ref)) {\n accept('error', `Expecting a field reference`, {\n node: item,\n });\n return;\n }\n\n if (item.target.ref.$container !== attr.$container && isDelegateModel(item.target.ref.$container)) {\n accept('error', `Cannot use fields inherited from a polymorphic base model in \\`@@unique\\``, {\n node: item,\n });\n }\n });\n } else {\n accept('error', `Expected an array of field references`, {\n node: fields,\n });\n }\n }\n\n private rejectEncryptedFields(attr: AttributeApplication, accept: ValidationAcceptor) {\n AstUtils.streamAllContents(attr).forEach((node) => {\n if (isDataFieldReference(node) && hasAttribute(node.target.ref as DataField, '@encrypted')) {\n accept('error', `Encrypted fields cannot be used in policy rules`, { node });\n }\n });\n }\n\n private validatePolicyKinds(\n kind: string,\n candidates: string[],\n attr: AttributeApplication,\n accept: ValidationAcceptor,\n ) {\n const items = kind.split(',').map((x) => x.trim());\n items.forEach((item) => {\n if (!candidates.includes(item)) {\n accept(\n 'error',\n `Invalid policy rule kind: \"${item}\", allowed: ${candidates.map((c) => '\"' + c + '\"').join(', ')}`,\n { node: attr },\n );\n }\n });\n return items;\n }\n}\n\nfunction assignableToAttributeParam(arg: AttributeArg, param: AttributeParam, attr: AttributeApplication): boolean {\n const argResolvedType = arg.$resolvedType;\n if (!argResolvedType) {\n return false;\n }\n\n let dstType = param.type.type;\n let dstIsArray = param.type.array;\n\n if (dstType === 'ContextType') {\n // ContextType is inferred from the attribute's container's type\n if (isDataField(attr.$container)) {\n dstIsArray = attr.$container.type.array;\n }\n }\n\n const dstRef = param.type.reference;\n\n if (dstType === 'Any' && !dstIsArray) {\n return true;\n }\n\n if (argResolvedType.decl === 'Any') {\n // arg is any type\n if (!argResolvedType.array) {\n // if it's not an array, it's assignable to any type\n return true;\n } else {\n // otherwise it's assignable to any array type\n return argResolvedType.array === dstIsArray;\n }\n }\n\n // destination is field reference or transitive field reference, check if\n // argument is reference or array or reference\n if (dstType === 'FieldReference' || dstType === 'TransitiveFieldReference') {\n if (dstIsArray) {\n return (\n isArrayExpr(arg.value) &&\n !arg.value.items.find((item) => !isReferenceExpr(item) || !isDataField(item.target.ref))\n );\n } else {\n return isReferenceExpr(arg.value) && isDataField(arg.value.target.ref);\n }\n }\n\n if (isEnum(argResolvedType.decl)) {\n // enum type\n\n let attrArgDeclType = dstRef?.ref;\n if (dstType === 'ContextType' && isDataField(attr.$container) && attr.$container?.type?.reference) {\n // attribute parameter type is ContextType, need to infer type from\n // the attribute's container\n attrArgDeclType = resolved(attr.$container.type.reference);\n dstIsArray = attr.$container.type.array;\n }\n return attrArgDeclType === argResolvedType.decl && dstIsArray === argResolvedType.array;\n } else if (dstType) {\n // scalar type\n\n if (typeof argResolvedType?.decl !== 'string') {\n // destination type is not a reference, so argument type must be a plain expression\n return false;\n }\n\n if (dstType === 'ContextType') {\n // attribute parameter type is ContextType, need to infer type from\n // the attribute's container\n if (isDataField(attr.$container)) {\n if (!attr.$container?.type?.type) {\n return false;\n }\n dstType = mapBuiltinTypeToExpressionType(attr.$container.type.type);\n dstIsArray = attr.$container.type.array;\n } else {\n dstType = 'Any';\n }\n }\n\n return typeAssignable(dstType, argResolvedType.decl, arg.value) && dstIsArray === argResolvedType.array;\n } else {\n // reference type\n return (dstRef?.ref === argResolvedType.decl || dstType === 'Any') && dstIsArray === argResolvedType.array;\n }\n}\n\nfunction isValidAttributeTarget(attrDecl: Attribute, targetDecl: DataField) {\n const targetField = attrDecl.attributes.find((attr) => attr.decl.ref?.name === '@@@targetField');\n if (!targetField?.args[0]) {\n // no field type constraint\n return true;\n }\n\n const fieldTypes = (targetField.args[0].value as ArrayExpr).items.map(\n (item) => (item as ReferenceExpr).target.ref?.name,\n );\n\n let allowed = false;\n for (const allowedType of fieldTypes) {\n switch (allowedType) {\n case 'StringField':\n allowed = allowed || targetDecl.type.type === 'String';\n break;\n case 'IntField':\n allowed = allowed || targetDecl.type.type === 'Int';\n break;\n case 'BigIntField':\n allowed = allowed || targetDecl.type.type === 'BigInt';\n break;\n case 'FloatField':\n allowed = allowed || targetDecl.type.type === 'Float';\n break;\n case 'DecimalField':\n allowed = allowed || targetDecl.type.type === 'Decimal';\n break;\n case 'BooleanField':\n allowed = allowed || targetDecl.type.type === 'Boolean';\n break;\n case 'DateTimeField':\n allowed = allowed || targetDecl.type.type === 'DateTime';\n break;\n case 'JsonField':\n allowed = allowed || targetDecl.type.type === 'Json';\n break;\n case 'BytesField':\n allowed = allowed || targetDecl.type.type === 'Bytes';\n break;\n case 'ModelField':\n allowed = allowed || isDataModel(targetDecl.type.reference?.ref);\n break;\n case 'TypeDefField':\n allowed = allowed || isTypeDef(targetDecl.type.reference?.ref);\n break;\n default:\n break;\n }\n if (allowed) {\n break;\n }\n }\n\n return allowed;\n}\n\nexport function validateAttributeApplication(\n attr: AttributeApplication,\n accept: ValidationAcceptor,\n contextDataModel?: DataModel,\n) {\n new AttributeApplicationValidator().validate(attr, accept, contextDataModel);\n}\n","import { invariant } from '@zenstackhq/common-helpers';\nimport { AstUtils, URI, type AstNode, type LangiumDocument, type LangiumDocuments, type Reference } from 'langium';\nimport fs from 'node:fs';\nimport path from 'path';\nimport { STD_LIB_MODULE_NAME, type ExpressionContext } from './constants';\nimport {\n BinaryExpr,\n ConfigExpr,\n isArrayExpr,\n isBinaryExpr,\n isConfigArrayExpr,\n isDataField,\n isDataModel,\n isEnumField,\n isExpression,\n isInvocationExpr,\n isLiteralExpr,\n isMemberAccessExpr,\n isModel,\n isObjectExpr,\n isReferenceExpr,\n isStringLiteral,\n isTypeDef,\n Model,\n ModelImport,\n ReferenceExpr,\n type Attribute,\n type AttributeParam,\n type BuiltinType,\n type DataField,\n type DataFieldAttribute,\n type DataModel,\n type DataModelAttribute,\n type Enum,\n type EnumField,\n type Expression,\n type ExpressionType,\n type FunctionDecl,\n type TypeDef,\n} from './generated/ast';\n\nexport type AttributeTarget =\n | DataModel\n | TypeDef\n | DataField\n | Enum\n | EnumField\n | FunctionDecl\n | Attribute\n | AttributeParam;\n\nexport function hasAttribute(decl: AttributeTarget, name: string) {\n return !!getAttribute(decl, name);\n}\n\nexport function getAttribute(decl: AttributeTarget, name: string) {\n return (decl.attributes as (DataModelAttribute | DataFieldAttribute)[]).find((attr) => attr.decl.$refText === name);\n}\n\nexport function isFromStdlib(node: AstNode) {\n const model = AstUtils.getContainerOfType(node, isModel);\n return !!model && !!model.$document && model.$document.uri.path.endsWith(STD_LIB_MODULE_NAME);\n}\n\nexport function isAuthInvocation(node: AstNode) {\n return isInvocationExpr(node) && node.function.ref?.name === 'auth' && isFromStdlib(node.function.ref);\n}\n\n/**\n * Try getting string value from a potential string literal expression\n */\nexport function getStringLiteral(node: AstNode | undefined): string | undefined {\n return isStringLiteral(node) ? node.value : undefined;\n}\n\nconst isoDateTimeRegex = /^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$/i;\n\n/**\n * Determines if the given sourceType is assignable to a destination of destType\n */\nexport function typeAssignable(destType: ExpressionType, sourceType: ExpressionType, sourceExpr?: Expression): boolean {\n // implicit conversion from ISO datetime string to datetime\n if (destType === 'DateTime' && sourceType === 'String' && sourceExpr && isStringLiteral(sourceExpr)) {\n const literal = getStringLiteral(sourceExpr);\n if (literal && isoDateTimeRegex.test(literal)) {\n // implicitly convert to DateTime\n sourceType = 'DateTime';\n }\n }\n\n switch (destType) {\n case 'Any':\n return true;\n case 'Float':\n return sourceType === 'Any' || sourceType === 'Int' || sourceType === 'Float';\n default:\n return sourceType === 'Any' || sourceType === destType;\n }\n}\n\n/**\n * Maps a ZModel builtin type to expression type\n */\nexport function mapBuiltinTypeToExpressionType(\n type: BuiltinType | 'Any' | 'Object' | 'Null' | 'Unsupported',\n): ExpressionType | 'Any' {\n switch (type) {\n case 'Any':\n case 'Boolean':\n case 'String':\n case 'DateTime':\n case 'Int':\n case 'Float':\n case 'Null':\n return type;\n case 'BigInt':\n return 'Int';\n case 'Decimal':\n return 'Float';\n case 'Json':\n case 'Bytes':\n return 'Any';\n case 'Object':\n return 'Object';\n case 'Unsupported':\n return 'Unsupported';\n }\n}\n\nexport function isAuthOrAuthMemberAccess(expr: Expression): boolean {\n return isAuthInvocation(expr) || (isMemberAccessExpr(expr) && isAuthOrAuthMemberAccess(expr.operand));\n}\n\nexport function isEnumFieldReference(node: AstNode): node is ReferenceExpr {\n return isReferenceExpr(node) && isEnumField(node.target.ref);\n}\n\nexport function isDataFieldReference(node: AstNode): node is ReferenceExpr {\n return isReferenceExpr(node) && isDataField(node.target.ref);\n}\n\n/**\n * Returns if the given field is a relation field.\n */\nexport function isRelationshipField(field: DataField) {\n return isDataModel(field.type.reference?.ref);\n}\n\nexport function isFutureExpr(node: AstNode) {\n return isInvocationExpr(node) && node.function.ref?.name === 'future' && isFromStdlib(node.function.ref);\n}\n\nexport function isDelegateModel(node: AstNode) {\n return isDataModel(node) && hasAttribute(node, '@@delegate');\n}\n\nexport function resolved<T extends AstNode>(ref: Reference<T>): T {\n if (!ref.ref) {\n throw new Error(`Reference not resolved: ${ref.$refText}`);\n }\n return ref.ref;\n}\n\nexport function getRecursiveBases(\n decl: DataModel | TypeDef,\n includeDelegate = true,\n seen = new Set<DataModel | TypeDef>(),\n): (TypeDef | DataModel)[] {\n const result: (TypeDef | DataModel)[] = [];\n if (seen.has(decl)) {\n return result;\n }\n seen.add(decl);\n decl.mixins.forEach((mixin) => {\n const baseDecl = mixin.ref;\n if (baseDecl) {\n if (!includeDelegate && isDelegateModel(baseDecl)) {\n return;\n }\n result.push(baseDecl);\n result.push(...getRecursiveBases(baseDecl, includeDelegate, seen));\n }\n });\n return result;\n}\n\n/**\n * Gets `@@id` fields declared at the data model level (including search in base models)\n */\nexport function getModelIdFields(model: DataModel) {\n const modelsToCheck = [model, ...getRecursiveBases(model)];\n\n for (const modelToCheck of modelsToCheck) {\n const allAttributes = getAllAttributes(modelToCheck);\n const idAttr = allAttributes.find((attr) => attr.decl.$refText === '@@id');\n if (!idAttr) {\n continue;\n }\n const fieldsArg = idAttr.args.find((a) => a.$resolvedParam?.name === 'fields');\n if (!fieldsArg || !isArrayExpr(fieldsArg.value)) {\n continue;\n }\n\n return fieldsArg.value.items\n .filter((item): item is ReferenceExpr => isReferenceExpr(item))\n .map((item) => resolved(item.target) as DataField);\n }\n\n return [];\n}\n\n/**\n * Gets `@@unique` fields declared at the data model level (including search in base models)\n */\nexport function getModelUniqueFields(model: DataModel) {\n const modelsToCheck = [model, ...getRecursiveBases(model)];\n\n for (const modelToCheck of modelsToCheck) {\n const allAttributes = getAllAttributes(modelToCheck);\n const uniqueAttr = allAttributes.find((attr) => attr.decl.$refText === '@@unique');\n if (!uniqueAttr) {\n continue;\n }\n const fieldsArg = uniqueAttr.args.find((a) => a.$resolvedParam?.name === 'fields');\n if (!fieldsArg || !isArrayExpr(fieldsArg.value)) {\n continue;\n }\n\n return fieldsArg.value.items\n .filter((item): item is ReferenceExpr => isReferenceExpr(item))\n .map((item) => resolved(item.target) as DataField);\n }\n\n return [];\n}\n\n/**\n * Gets lists of unique fields declared at the data model level\n *\n * TODO: merge this with {@link getModelUniqueFields}\n */\nexport function getUniqueFields(model: DataModel) {\n const uniqueAttrs = model.attributes.filter(\n (attr) => attr.decl.ref?.name === '@@unique' || attr.decl.ref?.name === '@@id',\n );\n return uniqueAttrs.map((uniqueAttr) => {\n const fieldsArg = uniqueAttr.args.find((a) => a.$resolvedParam?.name === 'fields');\n if (!fieldsArg || !isArrayExpr(fieldsArg.value)) {\n return [];\n }\n\n return fieldsArg.value.items\n .filter((item): item is ReferenceExpr => isReferenceExpr(item))\n .map((item) => resolved(item.target) as DataField);\n });\n}\n\nexport function findUpAst(node: AstNode, predicate: (node: AstNode) => boolean): AstNode | undefined {\n let curr: AstNode | undefined = node;\n while (curr) {\n if (predicate(curr)) {\n return curr;\n }\n curr = curr.$container;\n }\n return undefined;\n}\n\nexport function getLiteral<T extends string | number | boolean | any = any>(\n expr: Expression | ConfigExpr | undefined,\n): T | undefined {\n switch (expr?.$type) {\n case 'ObjectExpr':\n return getObjectLiteral<T>(expr);\n case 'StringLiteral':\n case 'BooleanLiteral':\n return expr.value as T;\n case 'NumberLiteral':\n return parseFloat(expr.value) as T;\n default:\n return undefined;\n }\n}\n\nexport function getObjectLiteral<T>(expr: Expression | ConfigExpr | undefined): T | undefined {\n if (!expr || !isObjectExpr(expr)) {\n return undefined;\n }\n const result: Record<string, unknown> = {};\n for (const field of expr.fields) {\n let fieldValue: unknown;\n if (isLiteralExpr(field.value)) {\n fieldValue = getLiteral(field.value);\n } else if (isArrayExpr(field.value)) {\n fieldValue = getLiteralArray(field.value);\n } else if (isObjectExpr(field.value)) {\n fieldValue = getObjectLiteral(field.value);\n }\n if (fieldValue === undefined) {\n return undefined;\n } else {\n result[field.name] = fieldValue;\n }\n }\n return result as T;\n}\n\nexport function getLiteralArray<T extends string | number | boolean | any = any>(\n expr: Expression | ConfigExpr | undefined,\n): T[] | undefined {\n const arr = getArray(expr);\n if (!arr) {\n return undefined;\n }\n return arr.map((item) => isExpression(item) && getLiteral<T>(item)).filter((v): v is T => v !== undefined);\n}\n\nfunction getArray(expr: Expression | ConfigExpr | undefined) {\n return isArrayExpr(expr) || isConfigArrayExpr(expr) ? expr.items : undefined;\n}\n\nexport function getAttributeArgLiteral<T extends string | number | boolean>(\n attr: DataModelAttribute | DataFieldAttribute,\n name: string,\n): T | undefined {\n for (const arg of attr.args) {\n if (arg.$resolvedParam?.name === name) {\n return getLiteral<T>(arg.value);\n }\n }\n return undefined;\n}\n\nexport function getFunctionExpressionContext(funcDecl: FunctionDecl) {\n const funcAllowedContext: ExpressionContext[] = [];\n const funcAttr = funcDecl.attributes.find((attr) => attr.decl.$refText === '@@@expressionContext');\n if (funcAttr) {\n const contextArg = funcAttr.args[0]?.value;\n if (isArrayExpr(contextArg)) {\n contextArg.items.forEach((item) => {\n if (isEnumFieldReference(item)) {\n funcAllowedContext.push(item.target.$refText as ExpressionContext);\n }\n });\n }\n }\n return funcAllowedContext;\n}\n\nexport function getFieldReference(expr: Expression): DataField | undefined {\n if (isReferenceExpr(expr) && isDataField(expr.target.ref)) {\n return expr.target.ref;\n } else if (isMemberAccessExpr(expr) && isDataField(expr.member.ref)) {\n return expr.member.ref;\n } else {\n return undefined;\n }\n}\n\nexport function isCheckInvocation(node: AstNode) {\n return isInvocationExpr(node) && node.function.ref?.name === 'check' && isFromStdlib(node.function.ref);\n}\n\nexport function resolveTransitiveImports(documents: LangiumDocuments, model: Model) {\n return resolveTransitiveImportsInternal(documents, model);\n}\n\nfunction resolveTransitiveImportsInternal(\n documents: LangiumDocuments,\n model: Model,\n initialModel = model,\n visited: Set<string> = new Set(),\n models: Set<Model> = new Set(),\n) {\n const doc = AstUtils.getDocument(model);\n const initialDoc = AstUtils.getDocument(initialModel);\n\n if (initialDoc.uri.fsPath.toLowerCase() !== doc.uri.fsPath.toLowerCase()) {\n models.add(model);\n }\n\n const normalizedPath = doc.uri.fsPath.toLowerCase();\n if (!visited.has(normalizedPath)) {\n visited.add(normalizedPath);\n for (const imp of model.imports) {\n const importedModel = resolveImport(documents, imp);\n if (importedModel) {\n resolveTransitiveImportsInternal(documents, importedModel, initialModel, visited, models);\n }\n }\n }\n return Array.from(models);\n}\n\nexport function resolveImport(documents: LangiumDocuments, imp: ModelImport) {\n const resolvedUri = resolveImportUri(imp);\n try {\n if (resolvedUri) {\n let resolvedDocument = documents.getDocument(resolvedUri);\n if (!resolvedDocument) {\n const content = fs.readFileSync(resolvedUri.fsPath, 'utf-8');\n resolvedDocument = documents.createDocument(resolvedUri, content);\n }\n const node = resolvedDocument.parseResult.value;\n if (isModel(node)) {\n return node;\n }\n }\n } catch {\n // NOOP\n }\n return undefined;\n}\n\nexport function resolveImportUri(imp: ModelImport) {\n if (!imp.path) {\n return undefined;\n }\n const doc = AstUtils.getDocument(imp);\n const dir = path.dirname(doc.uri.fsPath);\n const importPath = imp.path.endsWith('.zmodel') ? imp.path : `${imp.path}.zmodel`;\n return URI.file(path.resolve(dir, importPath));\n}\n\n/**\n * Gets data models and type defs in the ZModel schema.\n */\nexport function getDataModelAndTypeDefs(model: Model, includeIgnored = false) {\n const r = model.declarations.filter((d): d is DataModel | TypeDef => isDataModel(d) || isTypeDef(d));\n if (includeIgnored) {\n return r;\n } else {\n return r.filter((model) => !hasAttribute(model, '@@ignore'));\n }\n}\n\nexport function getAllDeclarationsIncludingImports(documents: LangiumDocuments, model: Model) {\n const imports = resolveTransitiveImports(documents, model);\n return model.declarations.concat(...imports.map((imp) => imp.declarations));\n}\n\nexport function getAuthDecl(decls: (DataModel | TypeDef)[]) {\n let authModel = decls.find((m) => hasAttribute(m, '@@auth'));\n if (!authModel) {\n authModel = decls.find((m) => m.name === 'User');\n }\n return authModel;\n}\n\nexport function isFutureInvocation(node: AstNode) {\n return isInvocationExpr(node) && node.function.ref?.name === 'future' && isFromStdlib(node.function.ref);\n}\n\nexport function isCollectionPredicate(node: AstNode): node is BinaryExpr {\n return isBinaryExpr(node) && ['?', '!', '^'].includes(node.operator);\n}\n\nexport function getAllLoadedDataModelsAndTypeDefs(langiumDocuments: LangiumDocuments) {\n return langiumDocuments.all\n .map((doc) => doc.parseResult.value as Model)\n .flatMap((model) => model.declarations.filter((d): d is DataModel | TypeDef => isDataModel(d) || isTypeDef(d)))\n .toArray();\n}\n\nexport function getAllDataModelsIncludingImports(documents: LangiumDocuments, model: Model) {\n return getAllDeclarationsIncludingImports(documents, model).filter(isDataModel);\n}\n\nexport function getAllLoadedAndReachableDataModelsAndTypeDefs(\n langiumDocuments: LangiumDocuments,\n fromModel?: DataModel,\n) {\n // get all data models from loaded documents\n const allDataModels = getAllLoadedDataModelsAndTypeDefs(langiumDocuments);\n\n if (fromModel) {\n // merge data models transitively reached from the current model\n const model = AstUtils.getContainerOfType(fromModel, isModel);\n if (model) {\n const transitiveDataModels = getAllDataModelsIncludingImports(langiumDocuments, model);\n transitiveDataModels.forEach((dm) => {\n if (!allDataModels.includes(dm)) {\n allDataModels.push(dm);\n }\n });\n }\n }\n\n return allDataModels;\n}\n\nexport function getContainingDataModel(node: Expression): DataModel | undefined {\n let curr: AstNode | undefined = node.$container;\n while (curr) {\n if (isDataModel(curr)) {\n return curr;\n }\n curr = curr.$container;\n }\n return undefined;\n}\n\nexport function isMemberContainer(node: unknown): node is DataModel | TypeDef {\n return isDataModel(node) || isTypeDef(node);\n}\n\nexport function getAllFields(\n decl: DataModel | TypeDef,\n includeIgnored = false,\n seen: Set<DataModel | TypeDef> = new Set(),\n): DataField[] {\n if (seen.has(decl)) {\n return [];\n }\n seen.add(decl);\n\n const fields: DataField[] = [];\n for (const mixin of decl.mixins) {\n invariant(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);\n fields.push(...getAllFields(mixin.ref, includeIgnored, seen));\n }\n\n if (isDataModel(decl) && decl.baseModel) {\n invariant(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);\n fields.push(...getAllFields(decl.baseModel.ref, includeIgnored, seen));\n }\n\n fields.push(...decl.fields.filter((f) => includeIgnored || !hasAttribute(f, '@ignore')));\n return fields;\n}\n\nexport function getAllAttributes(\n decl: DataModel | TypeDef,\n seen: Set<DataModel | TypeDef> = new Set(),\n): DataModelAttribute[] {\n if (seen.has(decl)) {\n return [];\n }\n seen.add(decl);\n\n const attributes: DataModelAttribute[] = [];\n for (const mixin of decl.mixins) {\n invariant(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);\n attributes.push(...getAllAttributes(mixin.ref, seen));\n }\n\n if (isDataModel(decl) && decl.baseModel) {\n invariant(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);\n attributes.push(...getAllAttributes(decl.baseModel.ref, seen));\n }\n\n attributes.push(...decl.attributes);\n return attributes;\n}\n\n/**\n * Retrieve the document in which the given AST node is contained. A reference to the document is\n * usually held by the root node of the AST.\n *\n * @throws an error if the node is not contained in a document.\n */\nexport function getDocument<T extends AstNode = AstNode>(node: AstNode): LangiumDocument<T> {\n const rootNode = findRootNode(node);\n const result = rootNode.$document;\n if (!result) {\n throw new Error('AST node has no document.');\n }\n return result as LangiumDocument<T>;\n}\n\n/**\n * Returns the root node of the given AST node by following the `$container` references.\n */\nexport function findRootNode(node: AstNode): AstNode {\n while (node.$container) {\n node = node.$container;\n }\n return node;\n}\n","import type { ValidationAcceptor } from 'langium';\nimport { Attribute } from '../generated/ast';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport type { AstValidator } from './common';\n\n/**\n * Validates attribute declarations.\n */\nexport default class AttributeValidator implements AstValidator<Attribute> {\n validate(attr: Attribute, accept: ValidationAcceptor): void {\n attr.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n}\n","import { invariant } from '@zenstackhq/common-helpers';\nimport { AstUtils, type AstNode, type DiagnosticInfo, type ValidationAcceptor } from 'langium';\nimport { IssueCodes, SCALAR_TYPES } from '../constants';\nimport {\n ArrayExpr,\n DataField,\n DataModel,\n Model,\n ReferenceExpr,\n TypeDef,\n isDataModel,\n isDataSource,\n isEnum,\n isModel,\n isStringLiteral,\n isTypeDef,\n} from '../generated/ast';\nimport {\n getAllAttributes,\n getAllFields,\n getLiteral,\n getModelIdFields,\n getModelUniqueFields,\n getUniqueFields,\n hasAttribute,\n isDelegateModel,\n} from '../utils';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates data model declarations.\n */\nexport default class DataModelValidator implements AstValidator<DataModel> {\n validate(dm: DataModel, accept: ValidationAcceptor): void {\n validateDuplicatedDeclarations(dm, getAllFields(dm), accept);\n this.validateAttributes(dm, accept);\n this.validateFields(dm, accept);\n if (dm.mixins.length > 0) {\n this.validateMixins(dm, accept);\n }\n this.validateInherits(dm, accept);\n }\n\n private validateFields(dm: DataModel, accept: ValidationAcceptor) {\n const allFields = getAllFields(dm);\n const idFields = allFields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === '@id'));\n const uniqueFields = allFields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === '@unique'));\n const modelLevelIds = getModelIdFields(dm);\n const modelUniqueFields = getModelUniqueFields(dm);\n\n if (\n idFields.length === 0 &&\n modelLevelIds.length === 0 &&\n uniqueFields.length === 0 &&\n modelUniqueFields.length === 0\n ) {\n accept(\n 'error',\n '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.',\n {\n node: dm,\n },\n );\n } else if (idFields.length > 0 && modelLevelIds.length > 0) {\n accept('error', 'Model cannot have both field-level @id and model-level @@id attributes', {\n node: dm,\n });\n } else if (idFields.length > 1) {\n accept('error', 'Model can include at most one field with @id attribute', {\n node: dm,\n });\n } else {\n const fieldsToCheck = idFields.length > 0 ? idFields : modelLevelIds;\n fieldsToCheck.forEach((idField) => {\n if (idField.type.optional) {\n accept('error', 'Field with @id attribute must not be optional', { node: idField });\n }\n\n const isArray = idField.type.array;\n const isScalar = SCALAR_TYPES.includes(idField.type.type as (typeof SCALAR_TYPES)[number]);\n const isValidType = isScalar || isEnum(idField.type.reference?.ref);\n\n if (isArray || !isValidType) {\n accept('error', 'Field with @id attribute must be of scalar or enum type', { node: idField });\n }\n });\n }\n\n dm.fields.forEach((field) => this.validateField(field, accept));\n allFields\n .filter((x) => isDataModel(x.type.reference?.ref))\n .forEach((y) => {\n this.validateRelationField(dm, y, accept);\n });\n }\n\n private validateField(field: DataField, accept: ValidationAcceptor): void {\n if (field.type.array && field.type.optional) {\n accept('error', 'Optional lists are not supported. Use either `Type[]` or `Type?`', { node: field.type });\n }\n\n if (field.type.unsupported && !isStringLiteral(field.type.unsupported.value)) {\n accept('error', 'Unsupported type argument must be a string literal', { node: field.type.unsupported });\n }\n\n if (field.type.array && !isDataModel(field.type.reference?.ref)) {\n const provider = this.getDataSourceProvider(AstUtils.getContainerOfType(field, isModel)!);\n if (provider === 'sqlite') {\n accept('error', `List type is not supported for \"${provider}\" provider.`, { node: field.type });\n }\n }\n\n field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n\n if (isTypeDef(field.type.reference?.ref)) {\n if (!hasAttribute(field, '@json')) {\n accept('error', 'Custom-typed field must have @json attribute', { node: field });\n }\n }\n }\n\n private getDataSourceProvider(model: Model) {\n const dataSource = model.declarations.find(isDataSource);\n if (!dataSource) {\n return undefined;\n }\n const provider = dataSource?.fields.find((f) => f.name === 'provider');\n if (!provider) {\n return undefined;\n }\n return getLiteral<string>(provider.value);\n }\n\n private validateAttributes(dm: DataModel, accept: ValidationAcceptor) {\n getAllAttributes(dm).forEach((attr) => validateAttributeApplication(attr, accept, dm));\n }\n\n private parseRelation(field: DataField, accept?: ValidationAcceptor) {\n const relAttr = field.attributes.find((attr) => attr.decl.ref?.name === '@relation');\n\n let name: string | undefined;\n let fields: ReferenceExpr[] | undefined;\n let references: ReferenceExpr[] | undefined;\n let valid = true;\n\n if (!relAttr) {\n return { attr: relAttr, name, fields, references, valid: true };\n }\n\n for (const arg of relAttr.args) {\n if (!arg.name || arg.name === 'name') {\n if (isStringLiteral(arg.value)) {\n name = arg.value.value as string;\n }\n } else if (arg.name === 'fields') {\n fields = (arg.value as ArrayExpr).items as ReferenceExpr[];\n if (fields.length === 0) {\n if (accept) {\n accept('error', `\"fields\" value cannot be empty`, {\n node: arg,\n });\n }\n valid = false;\n }\n } else if (arg.name === 'references') {\n references = (arg.value as ArrayExpr).items as ReferenceExpr[];\n if (references.length === 0) {\n if (accept) {\n accept('error', `\"references\" value cannot be empty`, {\n node: arg,\n });\n }\n valid = false;\n }\n }\n }\n\n if (!fields && !references) {\n return { attr: relAttr, name, fields, references, valid: true };\n }\n\n if (!fields || !references) {\n if (accept) {\n accept('error', `\"fields\" and \"references\" must be provided together`, { node: relAttr });\n }\n } else {\n // validate \"fields\" and \"references\" typing consistency\n if (fields.length !== references.length) {\n if (accept) {\n accept('error', `\"references\" and \"fields\" must have the same length`, { node: relAttr });\n }\n } else {\n for (let i = 0; i < fields.length; i++) {\n const fieldRef = fields[i];\n if (!fieldRef) {\n continue;\n }\n\n if (!field.type.optional && fieldRef.$resolvedType?.nullable) {\n // if relation is not optional, then fk field must not be nullable\n if (accept) {\n accept(\n 'error',\n `relation \"${field.name}\" is not optional, but field \"${fieldRef.target.$refText}\" is optional`,\n { node: fieldRef.target.ref! },\n );\n }\n }\n\n if (!fieldRef.$resolvedType) {\n if (accept) {\n accept('error', `field reference is unresolved`, {\n node: fieldRef,\n });\n }\n }\n if (!references[i]?.$resolvedType) {\n if (accept) {\n accept('error', `field reference is unresolved`, {\n node: references[i]!,\n });\n }\n }\n\n if (\n fieldRef.$resolvedType?.decl !== references[i]?.$resolvedType?.decl ||\n fieldRef.$resolvedType?.array !== references[i]?.$resolvedType?.array\n ) {\n if (accept) {\n accept('error', `values of \"references\" and \"fields\" must have the same type`, {\n node: relAttr,\n });\n }\n }\n }\n }\n }\n\n return { attr: relAttr, name, fields, references, valid };\n }\n\n private isSelfRelation(field: DataField) {\n return field.type.reference?.ref === field.$container;\n }\n\n private validateRelationField(contextModel: DataModel, field: DataField, accept: ValidationAcceptor) {\n const thisRelation = this.parseRelation(field, accept);\n if (!thisRelation.valid) {\n return;\n }\n\n if (this.isFieldInheritedFromDelegateModel(field)) {\n // relation fields inherited from delegate model don't need opposite relation\n return;\n }\n\n if (this.isSelfRelation(field)) {\n if (!thisRelation.name) {\n accept('error', 'Self-relation field must have a name in @relation attribute', {\n node: field,\n });\n return;\n }\n }\n\n const oppositeModel = field.type.reference!.ref! as DataModel;\n\n // Use name because the current document might be updated\n let oppositeFields = getAllFields(oppositeModel, false).filter(\n (f) =>\n f !== field && // exclude self in case of self relation\n f.type.reference?.ref?.name === contextModel.name,\n );\n oppositeFields = oppositeFields.filter((f) => {\n const fieldRel = this.parseRelation(f);\n return fieldRel.valid && fieldRel.name === thisRelation.name;\n });\n\n if (oppositeFields.length === 0) {\n const info: DiagnosticInfo<AstNode, string> = {\n node: field,\n code: IssueCodes.MissingOppositeRelation,\n };\n\n info.property = 'name';\n const container = field.$container;\n\n const relationFieldDocUri = AstUtils.getDocument(container).textDocument.uri;\n const relationDataModelName = container.name;\n\n const data: MissingOppositeRelationData = {\n relationFieldName: field.name,\n relationDataModelName,\n relationFieldDocUri,\n dataModelName: contextModel.name,\n };\n\n info.data = data;\n\n accept(\n 'error',\n `The relation field \"${field.name}\" on model \"${contextModel.name}\" is missing an opposite relation field on model \"${oppositeModel.name}\"`,\n info,\n );\n return;\n } else if (oppositeFields.length > 1) {\n oppositeFields\n .filter((f) => f.$container !== contextModel)\n .forEach((f) => {\n if (this.isSelfRelation(f)) {\n // self relations are partial\n // https://www.prisma.io/docs/concepts/components/prisma-schema/relations/self-relations\n } else {\n accept(\n 'error',\n `Fields ${oppositeFields.map((f) => '\"' + f.name + '\"').join(', ')} on model \"${\n oppositeModel.name\n }\" refer to the same relation to model \"${field.$container.name}\"`,\n { node: f },\n );\n }\n });\n return;\n }\n\n const oppositeField = oppositeFields[0]!;\n const oppositeRelation = this.parseRelation(oppositeField);\n\n let relationOwner: DataField;\n\n if (field.type.array && oppositeField.type.array) {\n // if both the field is array, then it's an implicit many-to-many relation,\n // neither side should have fields/references\n for (const r of [thisRelation, oppositeRelation]) {\n if (r.fields?.length || r.references?.length) {\n accept(\n 'error',\n 'Implicit many-to-many relation cannot have \"fields\" or \"references\" in @relation attribute',\n {\n node: r === thisRelation ? field : oppositeField,\n },\n );\n }\n }\n } else {\n if (thisRelation?.references?.length && thisRelation.fields?.length) {\n if (oppositeRelation?.references || oppositeRelation?.fields) {\n accept('error', '\"fields\" and \"references\" must be provided only on one side of relation field', {\n node: oppositeField,\n });\n return;\n } else {\n relationOwner = oppositeField;\n }\n } else if (oppositeRelation?.references?.length && oppositeRelation.fields?.length) {\n if (thisRelation?.references || thisRelation?.fields) {\n accept('error', '\"fields\" and \"references\" must be provided only on one side of relation field', {\n node: field,\n });\n return;\n } else {\n relationOwner = field;\n }\n } else {\n // for non-M2M relations, one side must have fields/references\n [field, oppositeField].forEach((f) => {\n if (!this.isSelfRelation(f)) {\n accept(\n 'error',\n 'Field for one side of relation must carry @relation attribute with both \"fields\" and \"references\"',\n { node: f },\n );\n }\n });\n return;\n }\n\n if (!relationOwner.type.array && !relationOwner.type.optional) {\n accept('error', 'Relation field needs to be list or optional', {\n node: relationOwner,\n });\n return;\n }\n\n if (relationOwner !== field && !relationOwner.type.array) {\n // one-to-one relation requires defining side's reference field to be @unique\n // e.g.:\n // model User {\n // id String @id @default(cuid())\n // data UserData?\n // }\n // model UserData {\n // id String @id @default(cuid())\n // user User @relation(fields: [userId], references: [id])\n // userId String\n // }\n //\n // UserData.userId field needs to be @unique\n\n const containingModel = field.$container as DataModel;\n const uniqueFieldList = getUniqueFields(containingModel);\n\n // field is defined in the abstract base model\n if (containingModel !== contextModel) {\n uniqueFieldList.push(...getUniqueFields(contextModel));\n }\n\n thisRelation.fields?.forEach((ref) => {\n const refField = ref.target.ref as DataField;\n if (refField) {\n if (\n refField.attributes.find(\n (a) => a.decl.ref?.name === '@id' || a.decl.ref?.name === '@unique',\n )\n ) {\n return;\n }\n if (uniqueFieldList.some((list) => list.includes(refField))) {\n return;\n }\n accept(\n 'error',\n `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`,\n { node: refField },\n );\n }\n });\n }\n }\n }\n\n // checks if the given field is inherited directly or indirectly from a delegate model\n private isFieldInheritedFromDelegateModel(field: DataField) {\n return isDelegateModel(field.$container);\n }\n\n private validateInherits(model: DataModel, accept: ValidationAcceptor) {\n if (!model.baseModel) {\n return;\n }\n\n invariant(model.baseModel.ref, 'baseModel must be resolved');\n\n // check if the base model is a delegate model\n if (!isDelegateModel(model.baseModel.ref)) {\n accept('error', `Model ${model.baseModel.$refText} cannot be extended because it's not a delegate model`, {\n node: model,\n property: 'baseModel',\n });\n return;\n }\n\n // check for cyclic inheritance\n const seen: DataModel[] = [];\n const todo = [model.baseModel.ref];\n while (todo.length > 0) {\n const current = todo.shift()!;\n if (seen.includes(current)) {\n accept(\n 'error',\n `Cyclic inheritance detected: ${seen.map((m) => m.name).join(' -> ')} -> ${current.name}`,\n {\n node: model,\n },\n );\n return;\n }\n seen.push(current);\n if (current.baseModel) {\n invariant(current.baseModel.ref, 'baseModel must be resolved');\n todo.push(current.baseModel.ref);\n }\n }\n }\n\n private validateMixins(dm: DataModel, accept: ValidationAcceptor) {\n const seen: TypeDef[] = [];\n const todo: TypeDef[] = dm.mixins.map((mixin) => mixin.ref!);\n while (todo.length > 0) {\n const current = todo.shift()!;\n if (seen.includes(current)) {\n accept('error', `Cyclic mixin detected: ${seen.map((m) => m.name).join(' -> ')} -> ${current.name}`, {\n node: dm,\n });\n return;\n }\n seen.push(current);\n todo.push(...current.mixins.map((mixin) => mixin.ref!));\n }\n }\n}\n\nexport interface MissingOppositeRelationData {\n relationDataModelName: string;\n relationFieldName: string;\n // it might be the abstract model in the imported document\n relationFieldDocUri: string;\n\n // the name of DataModel that the relation field belongs to.\n // the document is the same with the error node.\n dataModelName: string;\n}\n","import type { AstNode, MaybePromise, ValidationAcceptor } from 'langium';\nimport { isDataField } from '../generated/ast';\n\n/**\n * AST validator contract\n */\nexport interface AstValidator<T extends AstNode> {\n /**\n * Validates an AST node\n */\n validate(node: T, accept: ValidationAcceptor): MaybePromise<void>;\n}\n\n/**\n * Checks if the given declarations have duplicated names\n */\nexport function validateDuplicatedDeclarations(\n container: AstNode,\n decls: Array<AstNode & { name: string }>,\n accept: ValidationAcceptor,\n): void {\n const groupByName = decls.reduce<Record<string, Array<AstNode & { name: string }>>>((group, decl) => {\n group[decl.name] = group[decl.name] ?? [];\n group[decl.name]!.push(decl);\n return group;\n }, {});\n\n for (const [name, decls] of Object.entries<AstNode[]>(groupByName)) {\n if (decls.length > 1) {\n let errorField = decls[1]!;\n if (isDataField(decls[0])) {\n const nonInheritedFields = decls.filter((x) => !(isDataField(x) && x.$container !== container));\n if (nonInheritedFields.length > 0) {\n errorField = nonInheritedFields.slice(-1)[0]!;\n }\n }\n\n accept('error', `Duplicated declaration name \"${name}\"`, {\n node: errorField,\n });\n }\n }\n}\n","import type { ValidationAcceptor } from 'langium';\nimport { SUPPORTED_PROVIDERS } from '../constants';\nimport { DataSource, isInvocationExpr } from '../generated/ast';\nimport { getStringLiteral } from '../utils';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates data source declarations.\n */\nexport default class DataSourceValidator implements AstValidator<DataSource> {\n validate(ds: DataSource, accept: ValidationAcceptor): void {\n validateDuplicatedDeclarations(ds, ds.fields, accept);\n this.validateProvider(ds, accept);\n this.validateUrl(ds, accept);\n this.validateRelationMode(ds, accept);\n }\n\n private validateProvider(ds: DataSource, accept: ValidationAcceptor) {\n const provider = ds.fields.find((f) => f.name === 'provider');\n if (!provider) {\n accept('error', 'datasource must include a \"provider\" field', {\n node: ds,\n });\n return;\n }\n\n const value = getStringLiteral(provider.value);\n if (!value) {\n accept('error', '\"provider\" must be set to a string literal', {\n node: provider.value,\n });\n } else if (!SUPPORTED_PROVIDERS.includes(value)) {\n accept(\n 'error',\n `Provider \"${value}\" is not supported. Choose from ${SUPPORTED_PROVIDERS.map((p) => '\"' + p + '\"').join(\n ' | ',\n )}.`,\n { node: provider.value },\n );\n }\n }\n\n private validateUrl(ds: DataSource, accept: ValidationAcceptor) {\n const urlField = ds.fields.find((f) => f.name === 'url');\n if (!urlField) {\n return;\n }\n\n const value = getStringLiteral(urlField.value);\n if (!value && !(isInvocationExpr(urlField.value) && urlField.value.function.ref?.name === 'env')) {\n accept('error', `\"${urlField.name}\" must be set to a string literal or an invocation of \"env\" function`, {\n node: urlField.value,\n });\n }\n }\n\n private validateRelationMode(ds: DataSource, accept: ValidationAcceptor) {\n const field = ds.fields.find((f) => f.name === 'relationMode');\n if (field) {\n const val = getStringLiteral(field.value);\n if (!val || !['foreignKeys', 'prisma'].includes(val)) {\n accept('error', '\"relationMode\" must be set to \"foreignKeys\" or \"prisma\"', { node: field.value });\n }\n }\n }\n}\n","import type { ValidationAcceptor } from 'langium';\nimport { Enum, EnumField } from '../generated/ast';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates enum declarations.\n */\nexport default class EnumValidator implements AstValidator<Enum> {\n validate(_enum: Enum, accept: ValidationAcceptor) {\n validateDuplicatedDeclarations(_enum, _enum.fields, accept);\n this.validateAttributes(_enum, accept);\n _enum.fields.forEach((field) => {\n this.validateField(field, accept);\n });\n }\n\n private validateAttributes(_enum: Enum, accept: ValidationAcceptor) {\n _enum.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n\n private validateField(field: EnumField, accept: ValidationAcceptor) {\n field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n}\n","import { AstUtils, type AstNode, type ValidationAcceptor } from 'langium';\nimport {\n BinaryExpr,\n Expression,\n isArrayExpr,\n isDataModel,\n isDataModelAttribute,\n isEnum,\n isLiteralExpr,\n isMemberAccessExpr,\n isNullExpr,\n isReferenceExpr,\n isThisExpr,\n type ExpressionType,\n} from '../generated/ast';\n\nimport {\n findUpAst,\n isAuthInvocation,\n isAuthOrAuthMemberAccess,\n isDataFieldReference,\n isEnumFieldReference,\n typeAssignable,\n} from '../utils';\nimport type { AstValidator } from './common';\n\n/**\n * Validates expressions.\n */\nexport default class ExpressionValidator implements AstValidator<Expression> {\n validate(expr: Expression, accept: ValidationAcceptor): void {\n // deal with a few cases where reference resolution fail silently\n if (!expr.$resolvedType) {\n if (isAuthInvocation(expr)) {\n // check was done at link time\n accept(\n 'error',\n 'auth() cannot be resolved because no model marked with \"@@auth()\" or named \"User\" is found',\n { node: expr },\n );\n } else {\n const hasReferenceResolutionError = AstUtils.streamAst(expr).some((node) => {\n if (isMemberAccessExpr(node)) {\n return !!node.member.error;\n }\n if (isReferenceExpr(node)) {\n return !!node.target.error;\n }\n return false;\n });\n if (!hasReferenceResolutionError) {\n // report silent errors not involving linker errors\n accept('error', 'Expression cannot be resolved', {\n node: expr,\n });\n }\n }\n }\n\n // extra validations by expression type\n switch (expr.$type) {\n case 'BinaryExpr':\n this.validateBinaryExpr(expr, accept);\n break;\n }\n }\n\n private validateBinaryExpr(expr: BinaryExpr, accept: ValidationAcceptor) {\n switch (expr.operator) {\n case 'in': {\n if (typeof expr.left.$resolvedType?.decl !== 'string' && !isEnum(expr.left.$resolvedType?.decl)) {\n accept('error', 'left operand of \"in\" must be of scalar type', { node: expr.left });\n }\n\n if (!expr.right.$resolvedType?.array) {\n accept('error', 'right operand of \"in\" must be an array', {\n node: expr.right,\n });\n }\n\n break;\n }\n\n case '>':\n case '>=':\n case '<':\n case '<=':\n case '&&':\n case '||': {\n if (expr.left.$resolvedType?.array) {\n accept('error', 'operand cannot be an array', {\n node: expr.left,\n });\n break;\n }\n\n if (expr.right.$resolvedType?.array) {\n accept('error', 'operand cannot be an array', {\n node: expr.right,\n });\n break;\n }\n\n let supportedShapes: ExpressionType[];\n if (['>', '>=', '<', '<='].includes(expr.operator)) {\n supportedShapes = ['Int', 'Float', 'DateTime', 'Any'];\n } else {\n supportedShapes = ['Boolean', 'Any'];\n }\n\n if (\n typeof expr.left.$resolvedType?.decl !== 'string' ||\n !supportedShapes.includes(expr.left.$resolvedType.decl)\n ) {\n accept('error', `invalid operand type for \"${expr.operator}\" operator`, {\n node: expr.left,\n });\n return;\n }\n if (\n typeof expr.right.$resolvedType?.decl !== 'string' ||\n !supportedShapes.includes(expr.right.$resolvedType.decl)\n ) {\n accept('error', `invalid operand type for \"${expr.operator}\" operator`, {\n node: expr.right,\n });\n return;\n }\n\n // DateTime comparison is only allowed between two DateTime values\n if (expr.left.$resolvedType.decl === 'DateTime' && expr.right.$resolvedType.decl !== 'DateTime') {\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n } else if (\n expr.right.$resolvedType.decl === 'DateTime' &&\n expr.left.$resolvedType.decl !== 'DateTime'\n ) {\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n }\n break;\n }\n\n case '==':\n case '!=': {\n if (this.isInValidationContext(expr)) {\n // in validation context, all fields are optional, so we should allow\n // comparing any field against null\n if (\n (isDataFieldReference(expr.left) && isNullExpr(expr.right)) ||\n (isDataFieldReference(expr.right) && isNullExpr(expr.left))\n ) {\n return;\n }\n }\n\n if (!!expr.left.$resolvedType?.array !== !!expr.right.$resolvedType?.array) {\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n break;\n }\n\n if (\n (expr.left.$resolvedType?.nullable && isNullExpr(expr.right)) ||\n (expr.right.$resolvedType?.nullable && isNullExpr(expr.left))\n ) {\n // comparing nullable field with null\n return;\n }\n\n if (\n typeof expr.left.$resolvedType?.decl === 'string' &&\n typeof expr.right.$resolvedType?.decl === 'string'\n ) {\n // scalar types assignability\n if (\n !typeAssignable(expr.left.$resolvedType.decl, expr.right.$resolvedType.decl) &&\n !typeAssignable(expr.right.$resolvedType.decl, expr.left.$resolvedType.decl)\n ) {\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n }\n return;\n }\n\n // disallow comparing model type with scalar type or comparison between\n // incompatible model types\n const leftType = expr.left.$resolvedType?.decl;\n const rightType = expr.right.$resolvedType?.decl;\n if (isDataModel(leftType) && isDataModel(rightType)) {\n if (leftType != rightType) {\n // incompatible model types\n // TODO: inheritance case?\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n }\n\n // not supported:\n // - foo == bar\n // - foo == this\n if (\n isDataFieldReference(expr.left) &&\n (isThisExpr(expr.right) || isDataFieldReference(expr.right))\n ) {\n accept('error', 'comparison between model-typed fields are not supported', { node: expr });\n } else if (\n isDataFieldReference(expr.right) &&\n (isThisExpr(expr.left) || isDataFieldReference(expr.left))\n ) {\n accept('error', 'comparison between model-typed fields are not supported', { node: expr });\n }\n } else if (\n (isDataModel(leftType) && !isNullExpr(expr.right)) ||\n (isDataModel(rightType) && !isNullExpr(expr.left))\n ) {\n // comparing model against scalar (except null)\n accept('error', 'incompatible operand types', {\n node: expr,\n });\n }\n break;\n }\n\n case '?':\n case '!':\n case '^':\n this.validateCollectionPredicate(expr, accept);\n break;\n }\n }\n\n private validateCollectionPredicate(expr: BinaryExpr, accept: ValidationAcceptor) {\n if (!expr.$resolvedType) {\n accept('error', 'collection predicate can only be used on an array of model type', { node: expr });\n return;\n }\n }\n\n private isInValidationContext(node: AstNode) {\n return findUpAst(node, (n) => isDataModelAttribute(n) && n.decl.$refText === '@@validate');\n }\n\n private isNotModelFieldExpr(expr: Expression): boolean {\n return (\n // literal\n isLiteralExpr(expr) ||\n // enum field\n isEnumFieldReference(expr) ||\n // null\n isNullExpr(expr) ||\n // `auth()` access\n isAuthOrAuthMemberAccess(expr) ||\n // array\n (isArrayExpr(expr) && expr.items.every((item) => this.isNotModelFieldExpr(item)))\n );\n }\n}\n","import type { ValidationAcceptor } from 'langium';\nimport { FunctionDecl } from '../generated/ast';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport type { AstValidator } from './common';\n\n/**\n * Validates function declarations.\n */\nexport default class FunctionDeclValidator implements AstValidator<FunctionDecl> {\n validate(funcDecl: FunctionDecl, accept: ValidationAcceptor) {\n funcDecl.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n}\n","import { AstUtils, type AstNode, type ValidationAcceptor } from 'langium';\nimport { match, P } from 'ts-pattern';\nimport { ExpressionContext } from '../constants';\nimport {\n Argument,\n DataFieldAttribute,\n DataModel,\n DataModelAttribute,\n Expression,\n FunctionDecl,\n FunctionParam,\n InvocationExpr,\n isDataFieldAttribute,\n isDataModel,\n isDataModelAttribute,\n} from '../generated/ast';\nimport {\n getFunctionExpressionContext,\n getLiteral,\n isCheckInvocation,\n isDataFieldReference,\n isFromStdlib,\n typeAssignable,\n} from '../utils';\nimport type { AstValidator } from './common';\n\n// a registry of function handlers marked with @func\nconst invocationCheckers = new Map<string, PropertyDescriptor>();\n\n// function handler decorator\nfunction func(name: string) {\n return function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) {\n if (!invocationCheckers.get(name)) {\n invocationCheckers.set(name, descriptor);\n }\n return descriptor;\n };\n}\n/**\n * InvocationExpr validation\n */\nexport default class FunctionInvocationValidator implements AstValidator<Expression> {\n validate(expr: InvocationExpr, accept: ValidationAcceptor): void {\n const funcDecl = expr.function.ref;\n if (!funcDecl) {\n accept('error', 'function cannot be resolved', { node: expr });\n return;\n }\n\n if (!this.validateArgs(funcDecl, expr.args, accept)) {\n return;\n }\n\n if (isFromStdlib(funcDecl)) {\n // validate standard library functions\n\n // find the containing attribute context for the invocation\n let curr: AstNode | undefined = expr.$container;\n let containerAttribute: DataModelAttribute | DataFieldAttribute | undefined;\n while (curr) {\n if (isDataModelAttribute(curr) || isDataFieldAttribute(curr)) {\n containerAttribute = curr;\n break;\n }\n curr = curr.$container;\n }\n\n // validate the context allowed for the function\n const exprContext = match(containerAttribute?.decl.$refText)\n .with('@default', () => ExpressionContext.DefaultValue)\n .with(P.union('@@allow', '@@deny', '@allow', '@deny'), () => ExpressionContext.AccessPolicy)\n .with('@@validate', () => ExpressionContext.ValidationRule)\n .with('@@index', () => ExpressionContext.Index)\n .otherwise(() => undefined);\n\n // get the context allowed for the function\n const funcAllowedContext = getFunctionExpressionContext(funcDecl);\n\n if (exprContext && !funcAllowedContext.includes(exprContext)) {\n accept('error', `function \"${funcDecl.name}\" is not allowed in the current context: ${exprContext}`, {\n node: expr,\n });\n return;\n }\n\n // TODO: express function validation rules declaratively in ZModel\n\n const allCasing = ['original', 'upper', 'lower', 'capitalize', 'uncapitalize'];\n if (['currentModel', 'currentOperation'].includes(funcDecl.name)) {\n const arg = getLiteral<string>(expr.args[0]?.value);\n if (arg && !allCasing.includes(arg)) {\n accept('error', `argument must be one of: ${allCasing.map((c) => '\"' + c + '\"').join(', ')}`, {\n node: expr.args[0]!,\n });\n }\n }\n }\n\n // run checkers for specific functions\n const checker = invocationCheckers.get(expr.function.$refText);\n if (checker) {\n checker.value.call(this, expr, accept);\n }\n }\n\n private validateArgs(funcDecl: FunctionDecl, args: Argument[], accept: ValidationAcceptor) {\n let success = true;\n for (let i = 0; i < funcDecl.params.length; i++) {\n const param = funcDecl.params[i];\n if (!param) {\n continue;\n }\n const arg = args[i];\n if (!arg) {\n if (!param.optional) {\n accept('error', `missing argument for parameter \"${param.name}\"`, { node: funcDecl });\n success = false;\n }\n } else {\n if (!this.validateInvocationArg(arg, param, accept)) {\n success = false;\n }\n }\n }\n // TODO: do we need to complain for extra arguments?\n return success;\n }\n\n private validateInvocationArg(arg: Argument, param: FunctionParam, accept: ValidationAcceptor) {\n const argResolvedType = arg?.value?.$resolvedType;\n if (!argResolvedType) {\n accept('error', 'argument type cannot be resolved', { node: arg });\n return false;\n }\n\n const dstType = param.type.type;\n if (!dstType) {\n accept('error', 'parameter type cannot be resolved', {\n node: param,\n });\n return false;\n }\n\n const dstIsArray = param.type.array;\n const dstRef = param.type.reference;\n\n if (dstType === 'Any' && !dstIsArray) {\n // scalar 'any' can be assigned with anything\n return true;\n }\n\n if (typeof argResolvedType.decl === 'string') {\n // scalar type\n if (!typeAssignable(dstType, argResolvedType.decl, arg.value) || dstIsArray !== argResolvedType.array) {\n accept('error', `argument is not assignable to parameter`, {\n node: arg,\n });\n return false;\n }\n } else {\n // enum or model type\n if ((dstRef?.ref !== argResolvedType.decl && dstType !== 'Any') || dstIsArray !== argResolvedType.array) {\n accept('error', `argument is not assignable to parameter`, {\n node: arg,\n });\n return false;\n }\n }\n\n return true;\n }\n\n @func('check')\n // @ts-expect-error\n private _checkCheck(expr: InvocationExpr, accept: ValidationAcceptor) {\n let valid = true;\n\n const fieldArg = expr.args[0]!.value;\n if (!isDataFieldReference(fieldArg) || !isDataModel(fieldArg.$resolvedType?.decl)) {\n accept('error', 'argument must be a relation field', {\n node: expr.args[0]!,\n });\n valid = false;\n }\n\n if (fieldArg.$resolvedType?.array) {\n accept('error', 'argument cannot be an array field', {\n node: expr.args[0]!,\n });\n valid = false;\n }\n\n const opArg = expr.args[1]?.value;\n if (opArg) {\n const operation = getLiteral<string>(opArg);\n if (!operation || !['read', 'create', 'update', 'delete'].includes(operation)) {\n accept('error', 'argument must be a \"read\", \"create\", \"update\", or \"delete\"', { node: expr.args[1]! });\n valid = false;\n }\n }\n\n if (!valid) {\n return;\n }\n\n // check for cyclic relation checking\n const start = fieldArg.$resolvedType?.decl as DataModel;\n const tasks = [expr];\n const seen = new Set<DataModel>();\n\n while (tasks.length > 0) {\n const currExpr = tasks.pop()!;\n const arg = currExpr.args[0]?.value;\n\n if (!isDataModel(arg?.$resolvedType?.decl)) {\n continue;\n }\n\n const currModel = arg!.$resolvedType!.decl;\n\n if (seen.has(currModel)) {\n if (currModel === start) {\n accept('error', 'cyclic dependency detected when following the `check()` call', { node: expr });\n } else {\n // a cycle is detected but it doesn't start from the invocation expression we're checking,\n // just break here and the cycle will be reported when we validate the start of it\n }\n break;\n } else {\n seen.add(currModel);\n }\n\n const policyAttrs = currModel.attributes.filter(\n (attr) => attr.decl.$refText === '@@allow' || attr.decl.$refText === '@@deny',\n );\n for (const attr of policyAttrs) {\n const rule = attr.args[1];\n if (!rule) {\n continue;\n }\n AstUtils.streamAst(rule).forEach((node) => {\n if (isCheckInvocation(node)) {\n tasks.push(node as InvocationExpr);\n }\n });\n }\n }\n }\n}\n","import type { LangiumDocuments, ValidationAcceptor } from 'langium';\nimport { PLUGIN_MODULE_NAME, STD_LIB_MODULE_NAME } from '../constants';\nimport { isDataSource, type Model } from '../generated/ast';\nimport { getAllDeclarationsIncludingImports, resolveImport, resolveTransitiveImports } from '../utils';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates toplevel schema.\n */\nexport default class SchemaValidator implements AstValidator<Model> {\n constructor(protected readonly documents: LangiumDocuments) {}\n\n validate(model: Model, accept: ValidationAcceptor) {\n this.validateImports(model, accept);\n validateDuplicatedDeclarations(model, model.declarations, accept);\n\n const importedModels = resolveTransitiveImports(this.documents, model);\n\n const importedNames = new Set(importedModels.flatMap((m) => m.declarations.map((d) => d.name)));\n\n for (const declaration of model.declarations) {\n if (importedNames.has(declaration.name)) {\n accept('error', `A ${declaration.name} already exists in an imported module`, {\n node: declaration,\n property: 'name',\n });\n }\n }\n\n if (\n !model.$document?.uri.path.endsWith(STD_LIB_MODULE_NAME) &&\n !model.$document?.uri.path.endsWith(PLUGIN_MODULE_NAME)\n ) {\n this.validateDataSources(model, accept);\n }\n }\n\n private async validateDataSources(model: Model, accept: ValidationAcceptor) {\n const dataSources = (await getAllDeclarationsIncludingImports(this.documents, model)).filter((d) =>\n isDataSource(d),\n );\n if (dataSources.length > 1) {\n accept('error', 'Multiple datasource declarations are not allowed', { node: dataSources[1]! });\n }\n }\n\n private validateImports(model: Model, accept: ValidationAcceptor) {\n model.imports.forEach((imp) => {\n const importedModel = resolveImport(this.documents, imp);\n if (!importedModel) {\n const importPath = imp.path.endsWith('.zmodel') ? imp.path : `${imp.path}.zmodel`;\n accept('error', `Cannot find model file ${importPath}`, {\n node: imp,\n });\n }\n });\n }\n}\n","import type { ValidationAcceptor } from 'langium';\nimport type { TypeDef, TypeDefField } from '../generated/ast';\nimport { validateAttributeApplication } from './attribute-application-validator';\nimport { validateDuplicatedDeclarations, type AstValidator } from './common';\n\n/**\n * Validates type def declarations.\n */\nexport default class TypeDefValidator implements AstValidator<TypeDef> {\n validate(typeDef: TypeDef, accept: ValidationAcceptor): void {\n validateDuplicatedDeclarations(typeDef, typeDef.fields, accept);\n this.validateAttributes(typeDef, accept);\n this.validateFields(typeDef, accept);\n }\n\n private validateAttributes(typeDef: TypeDef, accept: ValidationAcceptor) {\n typeDef.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n\n private validateFields(typeDef: TypeDef, accept: ValidationAcceptor) {\n typeDef.fields.forEach((field) => this.validateField(field, accept));\n }\n\n private validateField(field: TypeDefField, accept: ValidationAcceptor): void {\n field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));\n }\n}\n","/* eslint-disable @typescript-eslint/no-unused-expressions */\n\nimport type { AstNode, LangiumDocument, ValidationAcceptor, ValidationChecks } from 'langium';\nimport type {\n Attribute,\n DataModel,\n DataSource,\n Enum,\n Expression,\n FunctionDecl,\n InvocationExpr,\n Model,\n TypeDef,\n ZModelAstType,\n} from './generated/ast';\nimport type { ZModelServices } from './module';\nimport AttributeValidator from './validators/attribute-validator';\nimport DataModelValidator from './validators/datamodel-validator';\nimport DataSourceValidator from './validators/datasource-validator';\nimport EnumValidator from './validators/enum-validator';\nimport ExpressionValidator from './validators/expression-validator';\nimport FunctionDeclValidator from './validators/function-decl-validator';\nimport FunctionInvocationValidator from './validators/function-invocation-validator';\nimport SchemaValidator from './validators/schema-validator';\nimport TypeDefValidator from './validators/typedef-validator';\n\n/**\n * Register custom validation checks.\n */\nexport function registerValidationChecks(services: ZModelServices) {\n const registry = services.validation.ValidationRegistry;\n const validator = services.validation.ZModelValidator;\n const checks: ValidationChecks<ZModelAstType> = {\n Model: validator.checkModel,\n DataSource: validator.checkDataSource,\n DataModel: validator.checkDataModel,\n TypeDef: validator.checkTypeDef,\n Enum: validator.checkEnum,\n Attribute: validator.checkAttribute,\n Expression: validator.checkExpression,\n InvocationExpr: validator.checkFunctionInvocation,\n FunctionDecl: validator.checkFunctionDecl,\n };\n registry.register(checks, validator);\n}\n\n/**\n * Implementation of custom validations.\n */\nexport class ZModelValidator {\n constructor(protected readonly services: ZModelServices) {}\n\n private shouldCheck(node: AstNode) {\n let doc: LangiumDocument | undefined;\n let currNode: AstNode | undefined = node;\n while (currNode) {\n if (currNode.$document) {\n doc = currNode.$document;\n break;\n }\n currNode = currNode.$container;\n }\n\n return doc?.parseResult.lexerErrors.length === 0 && doc?.parseResult.parserErrors.length === 0;\n }\n\n checkModel(node: Model, accept: ValidationAcceptor): void {\n this.shouldCheck(node) &&\n new SchemaValidator(this.services.shared.workspace.LangiumDocuments).validate(node, accept);\n }\n\n checkDataSource(node: DataSource, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new DataSourceValidator().validate(node, accept);\n }\n\n checkDataModel(node: DataModel, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new DataModelValidator().validate(node, accept);\n }\n\n checkTypeDef(node: TypeDef, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new TypeDefValidator().validate(node, accept);\n }\n\n checkEnum(node: Enum, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new EnumValidator().validate(node, accept);\n }\n\n checkAttribute(node: Attribute, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new AttributeValidator().validate(node, accept);\n }\n\n checkExpression(node: Expression, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new ExpressionValidator().validate(node, accept);\n }\n\n checkFunctionInvocation(node: InvocationExpr, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new FunctionInvocationValidator().validate(node, accept);\n }\n\n checkFunctionDecl(node: FunctionDecl, accept: ValidationAcceptor): void {\n this.shouldCheck(node) && new FunctionDeclValidator().validate(node, accept);\n }\n}\n","import {\n type AstNode,\n type AstNodeDescription,\n type AstNodeDescriptionProvider,\n AstUtils,\n Cancellation,\n DefaultLinker,\n DocumentState,\n type LangiumCoreServices,\n type LangiumDocument,\n type LinkingError,\n type Reference,\n interruptAndCheck,\n isReference,\n} from 'langium';\nimport { match } from 'ts-pattern';\nimport {\n ArrayExpr,\n AttributeArg,\n AttributeParam,\n BinaryExpr,\n BooleanLiteral,\n DataField,\n DataFieldType,\n DataModel,\n Enum,\n EnumField,\n type ExpressionType,\n FunctionDecl,\n FunctionParam,\n FunctionParamType,\n InvocationExpr,\n LiteralExpr,\n MemberAccessExpr,\n NullExpr,\n NumberLiteral,\n ObjectExpr,\n ReferenceExpr,\n ReferenceTarget,\n type ResolvedShape,\n StringLiteral,\n ThisExpr,\n UnaryExpr,\n isArrayExpr,\n isBooleanLiteral,\n isDataField,\n isDataFieldType,\n isDataModel,\n isEnum,\n isNumberLiteral,\n isReferenceExpr,\n isStringLiteral,\n} from './ast';\nimport {\n getAllFields,\n getAllLoadedAndReachableDataModelsAndTypeDefs,\n getAuthDecl,\n getContainingDataModel,\n isAuthInvocation,\n isFutureExpr,\n isMemberContainer,\n mapBuiltinTypeToExpressionType,\n} from './utils';\n\ninterface DefaultReference extends Reference {\n _ref?: AstNode | LinkingError;\n _nodeDescription?: AstNodeDescription;\n}\n\ntype ScopeProvider = (name: string) => ReferenceTarget | DataModel | undefined;\n\n/**\n * Langium linker implementation which links references and resolves expression types\n */\nexport class ZModelLinker extends DefaultLinker {\n private readonly descriptions: AstNodeDescriptionProvider;\n\n constructor(services: LangiumCoreServices) {\n super(services);\n this.descriptions = services.workspace.AstNodeDescriptionProvider;\n }\n\n //#region Reference linking\n\n override async link(document: LangiumDocument, cancelToken = Cancellation.CancellationToken.None): Promise<void> {\n if (document.parseResult.lexerErrors?.length > 0 || document.parseResult.parserErrors?.length > 0) {\n return;\n }\n\n for (const node of AstUtils.streamContents(document.parseResult.value)) {\n await interruptAndCheck(cancelToken);\n this.resolve(node, document);\n }\n document.state = DocumentState.Linked;\n }\n\n private linkReference(\n container: AstNode,\n property: string,\n document: LangiumDocument,\n extraScopes: ScopeProvider[],\n ) {\n if (this.resolveFromScopeProviders(container, property, document, extraScopes)) {\n return;\n }\n\n const reference: DefaultReference = (container as any)[property];\n this.doLink({ reference, container, property }, document);\n }\n\n //#endregion\n\n //#region Expression type resolving\n\n private resolveFromScopeProviders(\n node: AstNode,\n property: string,\n document: LangiumDocument,\n providers: ScopeProvider[],\n ) {\n const reference: DefaultReference = (node as any)[property];\n for (const provider of providers) {\n const target = provider(reference.$refText);\n if (target) {\n reference._ref = target;\n reference._nodeDescription = this.descriptions.createDescription(target, target.name, document);\n\n // Add the reference to the document's array of references\n document.references.push(reference);\n\n return target;\n }\n }\n return null;\n }\n\n private resolve(node: AstNode, document: LangiumDocument, extraScopes: ScopeProvider[] = []) {\n switch (node.$type) {\n case StringLiteral:\n case NumberLiteral:\n case BooleanLiteral:\n this.resolveLiteral(node as LiteralExpr);\n break;\n\n case InvocationExpr:\n this.resolveInvocation(node as InvocationExpr, document, extraScopes);\n break;\n\n case ArrayExpr:\n this.resolveArray(node as ArrayExpr, document, extraScopes);\n break;\n\n case ReferenceExpr:\n this.resolveReference(node as ReferenceExpr, document, extraScopes);\n break;\n\n case MemberAccessExpr:\n this.resolveMemberAccess(node as MemberAccessExpr, document, extraScopes);\n break;\n\n case UnaryExpr:\n this.resolveUnary(node as UnaryExpr, document, extraScopes);\n break;\n\n case BinaryExpr:\n this.resolveBinary(node as BinaryExpr, document, extraScopes);\n break;\n\n case ObjectExpr:\n this.resolveObject(node as ObjectExpr, document, extraScopes);\n break;\n\n case ThisExpr:\n this.resolveThis(node as ThisExpr, document, extraScopes);\n break;\n\n case NullExpr:\n this.resolveNull(node as NullExpr, document, extraScopes);\n break;\n\n case AttributeArg:\n this.resolveAttributeArg(node as AttributeArg, document, extraScopes);\n break;\n\n case DataModel:\n this.resolveDataModel(node as DataModel, document, extraScopes);\n break;\n\n case DataField:\n this.resolveDataField(node as DataField, document, extraScopes);\n break;\n\n default:\n this.resolveDefault(node, document, extraScopes);\n break;\n }\n }\n\n private resolveBinary(node: BinaryExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n switch (node.operator) {\n // TODO: support arithmetics?\n // case '+':\n // case '-':\n // case '*':\n // case '/':\n // this.resolve(node.left, document, extraScopes);\n // this.resolve(node.right, document, extraScopes);\n // this.resolveToBuiltinTypeOrDecl(node, 'Int');\n // break;\n\n case '>':\n case '>=':\n case '<':\n case '<=':\n case '==':\n case '!=':\n case '&&':\n case '||':\n case 'in':\n this.resolve(node.left, document, extraScopes);\n this.resolve(node.right, document, extraScopes);\n this.resolveToBuiltinTypeOrDecl(node, 'Boolean');\n break;\n\n case '?':\n case '!':\n case '^':\n this.resolveCollectionPredicate(node, document, extraScopes);\n break;\n\n default:\n throw Error(`Unsupported binary operator: ${node.operator}`);\n }\n }\n\n private resolveUnary(node: UnaryExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n this.resolve(node.operand, document, extraScopes);\n switch (node.operator) {\n case '!':\n this.resolveToBuiltinTypeOrDecl(node, 'Boolean');\n break;\n default:\n throw Error(`Unsupported unary operator: ${node.operator}`);\n }\n }\n\n private resolveObject(node: ObjectExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n node.fields.forEach((field) => this.resolve(field.value, document, extraScopes));\n this.resolveToBuiltinTypeOrDecl(node, 'Object');\n }\n\n private resolveReference(node: ReferenceExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n this.resolveDefault(node, document, extraScopes);\n\n if (node.target.ref) {\n // resolve type\n if (node.target.ref.$type === EnumField) {\n this.resolveToBuiltinTypeOrDecl(node, node.target.ref.$container);\n } else {\n this.resolveToDeclaredType(node, (node.target.ref as DataField | FunctionParam).type);\n }\n }\n }\n\n private resolveArray(node: ArrayExpr, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n node.items.forEach((item) => this.resolve(item, document, extraScopes));\n\n if (node.items.length > 0) {\n const itemType = node.items[0]!.$resolvedType;\n if (itemType?.decl) {\n this.resolveToBuiltinTypeOrDecl(node, itemType.decl, true);\n }\n } else {\n this.resolveToBuiltinTypeOrDecl(node, 'Any', true);\n }\n }\n\n private resolveInvocation(node: InvocationExpr, document: LangiumDocument, extraScopes: ScopeProvider[]) {\n this.linkReference(node, 'function', document, extraScopes);\n node.args.forEach((arg) => this.resolve(arg, document, extraScopes));\n if (node.function.ref) {\n const funcDecl = node.function.ref as FunctionDecl;\n\n if (isAuthInvocation(node)) {\n // auth() function is resolved against all loaded and reachable documents\n\n // get all data models from loaded and reachable documents\n const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(\n this.langiumDocuments(),\n AstUtils.getContainerOfType(node, isDataModel),\n );\n\n const authDecl = getAuthDecl(allDecls);\n if (authDecl) {\n node.$resolvedType = { decl: authDecl, nullable: true };\n }\n } else if (isFutureExpr(node)) {\n // future() function is resolved to current model\n node.$resolvedType = { decl: getContainingDataModel(node) };\n } else {\n this.resolveToDeclaredType(node, funcDecl.returnType);\n }\n }\n }\n\n private resolveLiteral(node: LiteralExpr) {\n const type = match<LiteralExpr, ExpressionType>(node)\n .when(isStringLiteral, () => 'String')\n .when(isBooleanLiteral, () => 'Boolean')\n .when(isNumberLiteral, () => 'Int')\n .exhaustive();\n\n if (type) {\n this.resolveToBuiltinTypeOrDecl(node, type);\n }\n }\n\n private resolveMemberAccess(\n node: MemberAccessExpr,\n document: LangiumDocument<AstNode>,\n extraScopes: ScopeProvider[],\n ) {\n this.resolveDefault(node, document, extraScopes);\n const operandResolved = node.operand.$resolvedType;\n\n if (operandResolved && !operandResolved.array && isMemberContainer(operandResolved.decl)) {\n // member access is resolved only in the context of the operand type\n if (node.member.ref) {\n this.resolveToDeclaredType(node, node.member.ref.type);\n if (node.$resolvedType && isAuthInvocation(node.operand)) {\n // member access on auth() function is nullable\n // because user may not have provided all fields\n node.$resolvedType.nullable = true;\n }\n }\n }\n }\n\n private resolveCollectionPredicate(node: BinaryExpr, document: LangiumDocument, extraScopes: ScopeProvider[]) {\n this.resolveDefault(node, document, extraScopes);\n\n const resolvedType = node.left.$resolvedType;\n if (resolvedType && isMemberContainer(resolvedType.decl) && resolvedType.array) {\n this.resolveToBuiltinTypeOrDecl(node, 'Boolean');\n } else {\n // error is reported in validation pass\n }\n }\n\n private resolveThis(node: ThisExpr, _document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n // resolve from scopes first\n for (const scope of extraScopes) {\n const r = scope('this');\n if (isDataModel(r)) {\n this.resolveToBuiltinTypeOrDecl(node, r);\n return;\n }\n }\n\n let decl: AstNode | undefined = node.$container;\n\n while (decl && !isDataModel(decl)) {\n decl = decl.$container;\n }\n\n if (decl) {\n this.resolveToBuiltinTypeOrDecl(node, decl);\n }\n }\n\n private resolveNull(node: NullExpr, _document: LangiumDocument<AstNode>, _extraScopes: ScopeProvider[]) {\n // TODO: how to really resolve null?\n this.resolveToBuiltinTypeOrDecl(node, 'Null');\n }\n\n private resolveAttributeArg(node: AttributeArg, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n const attrParam = this.findAttrParamForArg(node);\n const attrAppliedOn = node.$container.$container;\n\n if (attrParam?.type.type === 'TransitiveFieldReference' && isDataField(attrAppliedOn)) {\n // \"TransitiveFieldReference\" is resolved in the context of the containing model of the field\n // where the attribute is applied\n //\n // E.g.:\n //\n // model A {\n // myId @id String\n // }\n //\n // model B {\n // id @id String\n // a A @relation(fields: [id], references: [myId])\n // }\n //\n // In model B, the attribute argument \"myId\" is resolved to the field \"myId\" in model A\n\n const transitiveDataModel = attrAppliedOn.type.reference?.ref as DataModel;\n if (transitiveDataModel) {\n // resolve references in the context of the transitive data model\n const scopeProvider = (name: string) => getAllFields(transitiveDataModel).find((f) => f.name === name);\n if (isArrayExpr(node.value)) {\n node.value.items.forEach((item) => {\n if (isReferenceExpr(item)) {\n const resolved = this.resolveFromScopeProviders(item, 'target', document, [scopeProvider]);\n if (resolved) {\n this.resolveToDeclaredType(item, (resolved as DataField).type);\n } else {\n // mark unresolvable\n this.unresolvableRefExpr(item);\n }\n }\n });\n if (node.value.items[0]?.$resolvedType?.decl) {\n this.resolveToBuiltinTypeOrDecl(node.value, node.value.items[0].$resolvedType.decl, true);\n }\n } else if (isReferenceExpr(node.value)) {\n const resolved = this.resolveFromScopeProviders(node.value, 'target', document, [scopeProvider]);\n if (resolved) {\n this.resolveToDeclaredType(node.value, (resolved as DataField).type);\n } else {\n // mark unresolvable\n this.unresolvableRefExpr(node.value);\n }\n }\n }\n } else {\n this.resolve(node.value, document, extraScopes);\n }\n node.$resolvedType = node.value.$resolvedType;\n }\n\n private unresolvableRefExpr(item: ReferenceExpr) {\n const ref = item.target as DefaultReference;\n ref._ref = this.createLinkingError({\n reference: ref,\n container: item,\n property: 'target',\n });\n }\n\n private findAttrParamForArg(arg: AttributeArg): AttributeParam | undefined {\n const attr = arg.$container.decl.ref;\n if (!attr) {\n return undefined;\n }\n if (arg.name) {\n return attr.params?.find((p) => p.name === arg.name);\n } else {\n const index = arg.$container.args.findIndex((a) => a === arg);\n return attr.params[index];\n }\n }\n\n private resolveDataModel(node: DataModel, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n return this.resolveDefault(node, document, extraScopes);\n }\n\n private resolveDataField(node: DataField, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n // Field declaration may contain enum references, and enum fields are pushed to the global\n // scope, so if there're enums with fields with the same name, an arbitrary one will be\n // used as resolution target. The correct behavior is to resolve to the enum that's used\n // as the declaration type of the field:\n //\n // enum FirstEnum {\n // E1\n // E2\n // }\n\n // enum SecondEnum {\n // E1\n // E3\n // E4\n // }\n\n // model M {\n // id Int @id\n // first SecondEnum @default(E1) <- should resolve to SecondEnum\n // second FirstEnum @default(E1) <- should resolve to FirstEnum\n // }\n //\n\n // make sure type is resolved first\n this.resolve(node.type, document, extraScopes);\n\n let scopes = extraScopes;\n\n // if the field has enum declaration type, resolve the rest with that enum's fields on top of the scopes\n if (node.type.reference?.ref && isEnum(node.type.reference.ref)) {\n const contextEnum = node.type.reference.ref as Enum;\n const enumScope: ScopeProvider = (name) => contextEnum.fields.find((f) => f.name === name);\n scopes = [enumScope, ...scopes];\n }\n\n this.resolveDefault(node, document, scopes);\n }\n\n private resolveDefault(node: AstNode, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {\n for (const [property, value] of Object.entries(node)) {\n if (!property.startsWith('$')) {\n if (isReference(value)) {\n this.linkReference(node, property, document, extraScopes);\n }\n }\n }\n for (const child of AstUtils.streamContents(node)) {\n this.resolve(child, document, extraScopes);\n }\n }\n\n //#endregion\n\n //#region Utils\n\n private resolveToDeclaredType(node: AstNode, type: FunctionParamType | DataFieldType) {\n let nullable = false;\n if (isDataFieldType(type)) {\n nullable = type.optional;\n\n // referencing a field of 'Unsupported' type\n if (type.unsupported) {\n node.$resolvedType = {\n decl: 'Unsupported',\n array: type.array,\n nullable,\n };\n return;\n }\n }\n\n if (type.type) {\n const mappedType = mapBuiltinTypeToExpressionType(type.type);\n node.$resolvedType = {\n decl: mappedType,\n array: type.array,\n nullable: nullable,\n };\n } else if (type.reference) {\n node.$resolvedType = {\n decl: type.reference.ref,\n array: type.array,\n nullable: nullable,\n };\n }\n }\n\n private resolveToBuiltinTypeOrDecl(node: AstNode, type: ResolvedShape, array = false, nullable = false) {\n node.$resolvedType = { decl: type, array, nullable };\n }\n\n //#endregion\n}\n","import {\n AstUtils,\n Cancellation,\n DefaultScopeComputation,\n DefaultScopeProvider,\n EMPTY_SCOPE,\n StreamScope,\n UriUtils,\n interruptAndCheck,\n type AstNode,\n type AstNodeDescription,\n type LangiumCoreServices,\n type LangiumDocument,\n type PrecomputedScopes,\n type ReferenceInfo,\n type Scope,\n} from 'langium';\nimport { match } from 'ts-pattern';\nimport {\n BinaryExpr,\n MemberAccessExpr,\n isDataField,\n isDataModel,\n isEnumField,\n isInvocationExpr,\n isMemberAccessExpr,\n isModel,\n isReferenceExpr,\n isThisExpr,\n isTypeDef,\n} from './ast';\nimport { PLUGIN_MODULE_NAME, STD_LIB_MODULE_NAME } from './constants';\nimport {\n getAllFields,\n getAllLoadedAndReachableDataModelsAndTypeDefs,\n getAuthDecl,\n getRecursiveBases,\n isAuthInvocation,\n isCollectionPredicate,\n isFutureInvocation,\n resolveImportUri,\n} from './utils';\n\n/**\n * Custom Langium ScopeComputation implementation which adds enum fields into global scope\n */\nexport class ZModelScopeComputation extends DefaultScopeComputation {\n constructor(private readonly services: LangiumCoreServices) {\n super(services);\n }\n\n override async computeExports(\n document: LangiumDocument<AstNode>,\n cancelToken?: Cancellation.CancellationToken | undefined,\n ): Promise<AstNodeDescription[]> {\n const result = await super.computeExports(document, cancelToken);\n\n // add enum fields so they can be globally resolved across modules\n for (const node of AstUtils.streamAllContents(document.parseResult.value)) {\n if (cancelToken) {\n await interruptAndCheck(cancelToken);\n }\n if (isEnumField(node)) {\n const desc = this.services.workspace.AstNodeDescriptionProvider.createDescription(\n node,\n node.name,\n document,\n );\n result.push(desc);\n }\n }\n\n return result;\n }\n\n override processNode(node: AstNode, document: LangiumDocument<AstNode>, scopes: PrecomputedScopes) {\n super.processNode(node, document, scopes);\n if (isDataModel(node)) {\n // add base fields to the scope recursively\n const bases = getRecursiveBases(node);\n for (const base of bases) {\n for (const field of base.fields) {\n scopes.add(node, this.descriptions.createDescription(field, this.nameProvider.getName(field)));\n }\n }\n }\n }\n}\n\nexport class ZModelScopeProvider extends DefaultScopeProvider {\n constructor(private readonly services: LangiumCoreServices) {\n super(services);\n }\n\n protected override getGlobalScope(referenceType: string, context: ReferenceInfo): Scope {\n const model = AstUtils.getContainerOfType(context.container, isModel);\n if (!model) {\n return EMPTY_SCOPE;\n }\n\n const importedUris = model.imports.map(resolveImportUri).filter((url) => !!url);\n\n const importedElements = this.indexManager.allElements(referenceType).filter(\n (des) =>\n // allow current document\n UriUtils.equals(des.documentUri, model.$document?.uri) ||\n // allow stdlib\n des.documentUri.path.endsWith(STD_LIB_MODULE_NAME) ||\n // allow plugin models\n des.documentUri.path.endsWith(PLUGIN_MODULE_NAME) ||\n // allow imported documents\n importedUris.some((importedUri) => UriUtils.equals(des.documentUri, importedUri)),\n );\n return new StreamScope(importedElements);\n }\n\n override getScope(context: ReferenceInfo): Scope {\n if (isMemberAccessExpr(context.container) && context.container.operand && context.property === 'member') {\n return this.getMemberAccessScope(context);\n }\n\n if (isReferenceExpr(context.container) && context.property === 'target') {\n // when reference expression is resolved inside a collection predicate, the scope is the collection\n const containerCollectionPredicate = getCollectionPredicateContext(context.container);\n if (containerCollectionPredicate) {\n return this.getCollectionPredicateScope(context, containerCollectionPredicate as BinaryExpr);\n }\n }\n\n return super.getScope(context);\n }\n\n private getMemberAccessScope(context: ReferenceInfo) {\n const referenceType = this.reflection.getReferenceType(context);\n const globalScope = this.getGlobalScope(referenceType, context);\n const node = context.container as MemberAccessExpr;\n\n // typedef's fields are only added to the scope if the access starts with `auth().`\n // or the member access resides inside a typedef\n const allowTypeDefScope =\n // isAuthOrAuthMemberAccess(node.operand) ||\n !!AstUtils.getContainerOfType(node, isTypeDef);\n\n return match(node.operand)\n .when(isReferenceExpr, (operand) => {\n // operand is a reference, it can only be a model/type-def field\n const ref = operand.target.ref;\n if (isDataField(ref)) {\n return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);\n }\n return EMPTY_SCOPE;\n })\n .when(isMemberAccessExpr, (operand) => {\n // operand is a member access, it must be resolved to a non-array model/typedef type\n const ref = operand.member.ref;\n if (isDataField(ref) && !ref.type.array) {\n return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);\n }\n return EMPTY_SCOPE;\n })\n .when(isThisExpr, () => {\n // operand is `this`, resolve to the containing model\n return this.createScopeForContainingModel(node, globalScope);\n })\n .when(isInvocationExpr, (operand) => {\n // deal with member access from `auth()` and `future()\n\n if (isAuthInvocation(operand)) {\n // resolve to `User` or `@@auth` decl\n return this.createScopeForAuth(node, globalScope);\n }\n\n if (isFutureInvocation(operand)) {\n // resolve `future()` to the containing model\n return this.createScopeForContainingModel(node, globalScope);\n }\n return EMPTY_SCOPE;\n })\n .otherwise(() => EMPTY_SCOPE);\n }\n\n private getCollectionPredicateScope(context: ReferenceInfo, collectionPredicate: BinaryExpr) {\n const referenceType = this.reflection.getReferenceType(context);\n const globalScope = this.getGlobalScope(referenceType, context);\n const collection = collectionPredicate.left;\n\n // TODO: generalize it\n // // typedef's fields are only added to the scope if the access starts with `auth().`\n // const allowTypeDefScope = isAuthOrAuthMemberAccess(collection);\n const allowTypeDefScope = false;\n\n return match(collection)\n .when(isReferenceExpr, (expr) => {\n // collection is a reference - model or typedef field\n const ref = expr.target.ref;\n if (isDataField(ref)) {\n return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);\n }\n return EMPTY_SCOPE;\n })\n .when(isMemberAccessExpr, (expr) => {\n // collection is a member access, it can only be resolved to a model or typedef field\n const ref = expr.member.ref;\n if (isDataField(ref)) {\n return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);\n }\n return EMPTY_SCOPE;\n })\n .when(isInvocationExpr, (expr) => {\n const returnTypeDecl = expr.function.ref?.returnType.reference?.ref;\n if (isDataModel(returnTypeDecl)) {\n return this.createScopeForContainer(returnTypeDecl, globalScope, allowTypeDefScope);\n } else {\n return EMPTY_SCOPE;\n }\n })\n .when(isAuthInvocation, (expr) => {\n return this.createScopeForAuth(expr, globalScope);\n })\n .otherwise(() => EMPTY_SCOPE);\n }\n\n private createScopeForContainingModel(node: AstNode, globalScope: Scope) {\n const model = AstUtils.getContainerOfType(node, isDataModel);\n if (model) {\n return this.createScopeForContainer(model, globalScope);\n } else {\n return EMPTY_SCOPE;\n }\n }\n\n private createScopeForContainer(node: AstNode | undefined, globalScope: Scope, includeTypeDefScope = false) {\n if (isDataModel(node)) {\n return this.createScopeForNodes(getAllFields(node), globalScope);\n } else if (includeTypeDefScope && isTypeDef(node)) {\n return this.createScopeForNodes(node.fields, globalScope);\n } else {\n return EMPTY_SCOPE;\n }\n }\n\n private createScopeForAuth(node: AstNode, globalScope: Scope) {\n // get all data models and type defs from loaded and reachable documents\n const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(\n this.services.shared.workspace.LangiumDocuments,\n AstUtils.getContainerOfType(node, isDataModel),\n );\n\n const authDecl = getAuthDecl(decls);\n if (authDecl) {\n return this.createScopeForContainer(authDecl, globalScope, true);\n } else {\n return EMPTY_SCOPE;\n }\n }\n}\n\nfunction getCollectionPredicateContext(node: AstNode) {\n let curr: AstNode | undefined = node;\n while (curr) {\n if (curr.$container && isCollectionPredicate(curr.$container) && curr.$containerProperty === 'right') {\n return curr.$container;\n }\n curr = curr.$container;\n }\n return undefined;\n}\n","import {\n DefaultWorkspaceManager,\n URI,\n UriUtils,\n type AstNode,\n type LangiumDocument,\n type LangiumDocumentFactory,\n type WorkspaceFolder,\n} from 'langium';\nimport type { LangiumSharedServices } from 'langium/lsp';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isPlugin, type Model } from './ast';\nimport { PLUGIN_MODULE_NAME, STD_LIB_MODULE_NAME } from './constants';\nimport { getLiteral } from './utils';\n\nexport class ZModelWorkspaceManager extends DefaultWorkspaceManager {\n private documentFactory: LangiumDocumentFactory;\n\n constructor(services: LangiumSharedServices) {\n super(services);\n this.documentFactory = services.workspace.LangiumDocumentFactory;\n }\n\n protected override async loadAdditionalDocuments(\n folders: WorkspaceFolder[],\n collector: (document: LangiumDocument<AstNode>) => void,\n ): Promise<void> {\n await super.loadAdditionalDocuments(folders, collector);\n\n // load stdlib.zmodel\n let stdLibPath: string;\n\n // First, try to find the stdlib from an installed zenstack package\n // in the project's node_modules\n let installedStdlibPath: string | undefined;\n for (const folder of folders) {\n const folderPath = this.getRootFolder(folder).fsPath;\n try {\n // Try to resolve zenstack from the workspace folder\n const languagePackagePath = require.resolve('@zenstackhq/language/package.json', {\n paths: [folderPath],\n });\n const languagePackageDir = path.dirname(languagePackagePath);\n const candidateStdlibPath = path.join(languagePackageDir, 'res', STD_LIB_MODULE_NAME);\n\n // Check if the stdlib file exists in the installed package\n if (fs.existsSync(candidateStdlibPath)) {\n installedStdlibPath = candidateStdlibPath;\n console.log(`Found installed zenstack package stdlib at: ${installedStdlibPath}`);\n break;\n }\n } catch {\n // Package not found or other error, continue to next folder\n continue;\n }\n }\n\n if (installedStdlibPath) {\n stdLibPath = installedStdlibPath;\n } else {\n // Fallback to bundled stdlib\n // isomorphic __dirname\n const _dirname =\n typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));\n\n stdLibPath = path.join(_dirname, '../res', STD_LIB_MODULE_NAME);\n console.log(`Using bundled stdlib in extension:`, stdLibPath);\n }\n\n const stdlib = await this.documentFactory.fromUri(URI.file(stdLibPath));\n collector(stdlib);\n\n const documents = this.langiumDocuments.all;\n const pluginModels = new Set<string>();\n\n // find plugin models\n documents.forEach((doc) => {\n const parsed = doc.parseResult.value as Model;\n parsed.declarations.forEach((decl) => {\n if (isPlugin(decl)) {\n const providerField = decl.fields.find((f) => f.name === 'provider');\n if (providerField) {\n const provider = getLiteral<string>(providerField.value);\n if (provider) {\n pluginModels.add(provider);\n }\n }\n }\n });\n });\n\n if (pluginModels.size > 0) {\n console.log(`Used plugin modules: ${Array.from(pluginModels)}`);\n\n // the loaded plugin models would be removed from the set\n const pendingPluginModules = new Set(pluginModels);\n\n await Promise.all(\n folders\n .map((wf) => [wf, this.getRootFolder(wf)] as [WorkspaceFolder, URI])\n .map(async (entry) => this.loadPluginModels(...entry, pendingPluginModules, collector)),\n );\n }\n }\n\n protected async loadPluginModels(\n workspaceFolder: WorkspaceFolder,\n folderPath: URI,\n pendingPluginModels: Set<string>,\n collector: (document: LangiumDocument) => void,\n ): Promise<void> {\n const content = (await this.fileSystemProvider.readDirectory(folderPath)).sort((a, b) => {\n // make sure the node_modules folder is always the first one to be checked\n // so we can exit early if the plugin is found\n if (a.isDirectory && b.isDirectory) {\n const aName = UriUtils.basename(a.uri);\n if (aName === 'node_modules') {\n return -1;\n } else {\n return 1;\n }\n } else {\n return 0;\n }\n });\n\n for (const entry of content) {\n if (entry.isDirectory) {\n const name = UriUtils.basename(entry.uri);\n if (name === 'node_modules') {\n for (const plugin of Array.from(pendingPluginModels)) {\n const path = UriUtils.joinPath(entry.uri, plugin, PLUGIN_MODULE_NAME);\n try {\n await this.fileSystemProvider.readFile(path);\n const document = await this.langiumDocuments.getOrCreateDocument(path);\n collector(document);\n console.log(`Adding plugin document from ${path.path}`);\n\n pendingPluginModels.delete(plugin);\n // early exit if all plugins are loaded\n if (pendingPluginModels.size === 0) {\n return;\n }\n } catch {\n // no-op. The module might be found in another node_modules folder\n // will show the warning message eventually if not found\n }\n }\n } else {\n await this.loadPluginModels(workspaceFolder, entry.uri, pendingPluginModels, collector);\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;IAAAA,mBAA0F;AAC1F,kBAA+B;AAC/B,IAAAC,kBAAe;AACf,IAAAC,oBAAiB;AACjB,IAAAC,mBAA8B;;;ACE9B,cAAyB;AAkFlB,IAAMC,sBAAsB;AAoB5B,IAAMC,aAAa;AAQnB,IAAMC,aAAa;AAEnB,SAASC,aAAaC,MAAa;AACtC,SAAOC,WAAWC,WAAWF,MAAMF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O8B,KAAK,oEAAA;IAChB;EACJ;AAGA,QAAMuE,QAAQC,wBAAwBpD,OAAO,IAAA;AAC7C,QAAMqD,YAAYF,MAAM/D,OAAO,CAAC6D,MAAMK,aAAaL,GAAG,QAAA,CAAA;AACtD,MAAII,UAAU9D,SAAS,GAAG;AACtBzC,WAAO8B,KAAK,kEAAA;EAChB;AACA,SAAO9B;AACX;AAlBS6D;","names":["import_langium","import_node_fs","import_node_path","import_node_url","AbstractDeclaration","ConfigExpr","Expression","isExpression","item","reflection","isInstance","LiteralExpr","isLiteralExpr","item","reflection","isInstance","MemberAccessTarget","ReferenceTarget","TypeDeclaration","Argument","ArrayExpr","isArrayExpr","item","reflection","isInstance","Attribute","isAttribute","AttributeArg","AttributeParam","AttributeParamType","BinaryExpr","isBinaryExpr","item","reflection","isInstance","BooleanLiteral","isBooleanLiteral","ConfigArrayExpr","isConfigArrayExpr","ConfigField","ConfigInvocationArg","ConfigInvocationExpr","DataField","isDataField","item","reflection","isInstance","DataFieldAttribute","isDataFieldAttribute","DataFieldType","isDataFieldType","DataModel","isDataModel","DataModelAttribute","isDataModelAttribute","DataSource","isDataSource","Enum","isEnum","EnumField","isEnumField","FieldInitializer","FunctionDecl","FunctionParam","FunctionParamType","GeneratorDecl","InternalAttribute","InvocationExpr","isInvocationExpr","item","reflection","isInstance","MemberAccessExpr","isMemberAccessExpr","Model","isModel","ModelImport","NullExpr","isNullExpr","item","reflection","isInstance","NumberLiteral","isNumberLiteral","ObjectExpr","isObjectExpr","Plugin","isPlugin","PluginField","Procedure","ProcedureParam","ReferenceArg","ReferenceExpr","isReferenceExpr","item","reflection","isInstance","StringLiteral","isStringLiteral","ThisExpr","isThisExpr","TypeDef","isTypeDef","UnaryExpr","UnsupportedFieldType","ZModelAstReflection","AbstractAstReflection","getAllTypes","AbstractDeclaration","Argument","ArrayExpr","Attribute","AttributeArg","AttributeParam","AttributeParamType","BinaryExpr","BooleanLiteral","ConfigArrayExpr","ConfigExpr","ConfigField","ConfigInvocationArg","ConfigInvocationExpr","DataField","DataFieldAttribute","DataFieldType","DataModel","DataModelAttribute","DataSource","Enum","EnumField","Expression","FieldInitializer","FunctionDecl","FunctionParam","FunctionParamType","GeneratorDecl","InternalAttribute","InvocationExpr","LiteralExpr","MemberAccessExpr","MemberAccessTarget","Model","ModelImport","NullExpr","NumberLiteral","ObjectExpr","Plugin","PluginField","Procedure","ProcedureParam","ReferenceArg","ReferenceExpr","ReferenceTarget","StringLiteral","ThisExpr","TypeDeclaration","TypeDef","UnaryExpr","UnsupportedFieldType","computeIsSubtype","subtype","supertype","isSubtype","getReferenceType","refInfo","referenceId","container","$type","property","Error","getTypeMetaData","type","name","properties","defaultValue","reflection","SUPPORTED_PROVIDERS","SCALAR_TYPES","STD_LIB_MODULE_NAME","PLUGIN_MODULE_NAME","IssueCodes","ExpressionContext","import_langium","loadedZModelGrammar","ZModelGrammar","loadGrammarFromJson","ZModelLanguageMetaData","languageId","fileExtensions","caseInsensitive","mode","ZModelGeneratedSharedModule","AstReflection","ZModelAstReflection","ZModelGeneratedModule","Grammar","ZModelGrammar","LanguageMetaData","parser","import_langium","import_langium","hasAttribute","decl","name","getAttribute","attributes","find","attr","$refText","isFromStdlib","node","model","AstUtils","getContainerOfType","isModel","$document","uri","path","endsWith","STD_LIB_MODULE_NAME","isAuthInvocation","isInvocationExpr","function","ref","getStringLiteral","isStringLiteral","value","undefined","isoDateTimeRegex","typeAssignable","destType","sourceType","sourceExpr","literal","test","mapBuiltinTypeToExpressionType","type","isAuthOrAuthMemberAccess","expr","isMemberAccessExpr","operand","isEnumFieldReference","isReferenceExpr","isEnumField","target","isDataFieldReference","isDataField","isRelationshipField","field","isDataModel","reference","isFutureExpr","isDelegateModel","resolved","Error","getRecursiveBases","includeDelegate","seen","Set","result","has","add","mixins","forEach","mixin","baseDecl","push","getModelIdFields","modelsToCheck","modelToCheck","allAttributes","getAllAttributes","idAttr","fieldsArg","args","a","$resolvedParam","isArrayExpr","items","filter","item","map","getModelUniqueFields","uniqueAttr","getUniqueFields","uniqueAttrs","findUpAst","predicate","curr","$container","getLiteral","$type","getObjectLiteral","parseFloat","isObjectExpr","fields","fieldValue","isLiteralExpr","getLiteralArray","arr","getArray","isExpression","v","isConfigArrayExpr","getFunctionExpressionContext","funcDecl","funcAllowedContext","funcAttr","attributes","find","attr","decl","$refText","contextArg","args","value","isArrayExpr","items","forEach","item","isEnumFieldReference","push","target","isCheckInvocation","node","isInvocationExpr","function","ref","name","isFromStdlib","resolveTransitiveImports","documents","model","resolveTransitiveImportsInternal","initialModel","visited","Set","models","doc","AstUtils","getDocument","initialDoc","uri","fsPath","toLowerCase","add","normalizedPath","has","imp","imports","importedModel","resolveImport","Array","from","resolvedUri","resolveImportUri","resolvedDocument","content","fs","readFileSync","createDocument","parseResult","value","isModel","undefined","path","dir","dirname","importPath","endsWith","URI","file","resolve","getDataModelAndTypeDefs","includeIgnored","r","declarations","filter","d","isDataModel","isTypeDef","hasAttribute","getAllDeclarationsIncludingImports","concat","map","getAuthDecl","decls","authModel","find","m","isFutureInvocation","isCollectionPredicate","isBinaryExpr","includes","operator","getAllLoadedDataModelsAndTypeDefs","langiumDocuments","all","flatMap","toArray","getAllDataModelsIncludingImports","getAllLoadedAndReachableDataModelsAndTypeDefs","fromModel","allDataModels","getContainerOfType","transitiveDataModels","forEach","dm","push","getContainingDataModel","curr","$container","isMemberContainer","getAllFields","decl","seen","fields","mixin","mixins","invariant","$refText","baseModel","f","getAllAttributes","attributes","rootNode","findRootNode","result","$document","Error","attributeCheckers","Map","check","name","_target","_propertyKey","descriptor","get","set","AttributeApplicationValidator","validate","attr","accept","contextDataModel","decl","ref","targetDecl","$container","isAttribute","node","isDataField","isValidAttributeTarget","checkDeprecation","checkDuplicatedAttributes","filledParams","Set","arg","args","paramDecl","params","find","p","default","has","assignableToAttributeParam","add","$resolvedParam","missingParams","filter","type","optional","length","pluralize","map","join","checker","value","call","deprecateAttr","attributes","a","message","getStringLiteral","attrDecl","some","allAttributes","getAllAttributes","duplicates","_checkModelLevelPolicy","kind","validatePolicyKinds","rejectEncryptedFields","_checkFieldLevelPolicy","kindItems","expr","AstUtils","streamAst","isFutureExpr","includes","field","isRelationshipField","_checkValidate","condition","isDataFieldReference","isDataModel","$resolvedType","_checkUnique","fields","isArrayExpr","items","forEach","item","isReferenceExpr","target","isDelegateModel","streamAllContents","hasAttribute","candidates","split","x","trim","c","param","argResolvedType","dstType","dstIsArray","array","dstRef","reference","isEnum","attrArgDeclType","resolved","mapBuiltinTypeToExpressionType","typeAssignable","targetField","fieldTypes","allowed","allowedType","isTypeDef","validateAttributeApplication","AttributeValidator","validate","attr","accept","attributes","forEach","validateAttributeApplication","import_common_helpers","import_langium","validateDuplicatedDeclarations","container","decls","accept","groupByName","reduce","group","decl","name","push","Object","entries","length","errorField","isDataField","nonInheritedFields","filter","x","$container","slice","node","DataModelValidator","validate","dm","accept","validateDuplicatedDeclarations","getAllFields","validateAttributes","validateFields","mixins","length","validateMixins","validateInherits","allFields","idFields","filter","f","attributes","find","attr","decl","ref","name","uniqueFields","modelLevelIds","getModelIdFields","modelUniqueFields","getModelUniqueFields","node","fieldsToCheck","forEach","idField","type","optional","isArray","array","isScalar","SCALAR_TYPES","includes","isValidType","isEnum","reference","fields","field","validateField","x","isDataModel","y","validateRelationField","unsupported","isStringLiteral","value","provider","getDataSourceProvider","AstUtils","getContainerOfType","isModel","validateAttributeApplication","isTypeDef","hasAttribute","model","dataSource","declarations","isDataSource","undefined","getLiteral","getAllAttributes","parseRelation","relAttr","references","valid","arg","args","items","i","fieldRef","$resolvedType","nullable","target","$refText","isSelfRelation","$container","contextModel","thisRelation","isFieldInheritedFromDelegateModel","oppositeModel","oppositeFields","fieldRel","info","code","IssueCodes","MissingOppositeRelation","property","container","relationFieldDocUri","getDocument","textDocument","uri","relationDataModelName","data","relationFieldName","dataModelName","map","join","oppositeField","oppositeRelation","relationOwner","r","containingModel","uniqueFieldList","getUniqueFields","push","refField","a","some","list","isDelegateModel","baseModel","invariant","seen","todo","current","shift","m","mixin","DataSourceValidator","validate","ds","accept","validateDuplicatedDeclarations","fields","validateProvider","validateUrl","validateRelationMode","provider","find","f","name","node","value","getStringLiteral","SUPPORTED_PROVIDERS","includes","map","p","join","urlField","isInvocationExpr","function","ref","field","val","EnumValidator","validate","_enum","accept","validateDuplicatedDeclarations","fields","validateAttributes","forEach","field","validateField","attributes","attr","validateAttributeApplication","import_langium","ExpressionValidator","validate","expr","accept","$resolvedType","isAuthInvocation","node","hasReferenceResolutionError","AstUtils","streamAst","some","isMemberAccessExpr","member","error","isReferenceExpr","target","$type","validateBinaryExpr","operator","left","decl","isEnum","right","array","supportedShapes","includes","isInValidationContext","isDataFieldReference","isNullExpr","nullable","typeAssignable","leftType","rightType","isDataModel","isThisExpr","validateCollectionPredicate","findUpAst","n","isDataModelAttribute","$refText","isNotModelFieldExpr","isLiteralExpr","isEnumFieldReference","isAuthOrAuthMemberAccess","isArrayExpr","items","every","item","FunctionDeclValidator","validate","funcDecl","accept","attributes","forEach","attr","validateAttributeApplication","import_langium","invocationCheckers","Map","func","name","_target","_propertyKey","descriptor","get","set","FunctionInvocationValidator","validate","expr","accept","funcDecl","function","ref","node","validateArgs","args","isFromStdlib","curr","$container","containerAttribute","isDataModelAttribute","isDataFieldAttribute","exprContext","match","decl","$refText","with","ExpressionContext","DefaultValue","P","union","AccessPolicy","ValidationRule","Index","otherwise","undefined","funcAllowedContext","getFunctionExpressionContext","includes","allCasing","arg","getLiteral","value","map","c","join","checker","call","success","i","params","length","param","optional","validateInvocationArg","argResolvedType","$resolvedType","dstType","type","dstIsArray","array","dstRef","reference","typeAssignable","_checkCheck","valid","fieldArg","isDataFieldReference","isDataModel","opArg","operation","start","tasks","seen","Set","currExpr","pop","currModel","has","add","policyAttrs","attributes","filter","attr","rule","AstUtils","streamAst","forEach","isCheckInvocation","push","SchemaValidator","documents","validate","model","accept","validateImports","validateDuplicatedDeclarations","declarations","importedModels","resolveTransitiveImports","importedNames","Set","flatMap","m","map","d","name","declaration","has","node","property","$document","uri","path","endsWith","STD_LIB_MODULE_NAME","PLUGIN_MODULE_NAME","validateDataSources","dataSources","getAllDeclarationsIncludingImports","filter","isDataSource","length","imports","forEach","imp","importedModel","resolveImport","importPath","TypeDefValidator","validate","typeDef","accept","validateDuplicatedDeclarations","fields","validateAttributes","validateFields","attributes","forEach","attr","validateAttributeApplication","field","validateField","registerValidationChecks","services","registry","validation","ValidationRegistry","validator","ZModelValidator","checks","Model","checkModel","DataSource","checkDataSource","DataModel","checkDataModel","TypeDef","checkTypeDef","Enum","checkEnum","Attribute","checkAttribute","Expression","checkExpression","InvocationExpr","checkFunctionInvocation","FunctionDecl","checkFunctionDecl","register","shouldCheck","node","doc","currNode","$document","$container","parseResult","lexerErrors","length","parserErrors","accept","SchemaValidator","shared","workspace","LangiumDocuments","validate","DataSourceValidator","DataModelValidator","TypeDefValidator","EnumValidator","AttributeValidator","ExpressionValidator","FunctionInvocationValidator","FunctionDeclValidator","import_langium","import_ts_pattern","ZModelLinker","DefaultLinker","descriptions","services","workspace","AstNodeDescriptionProvider","link","document","cancelToken","Cancellation","CancellationToken","None","parseResult","lexerErrors","length","parserErrors","node","AstUtils","streamContents","value","interruptAndCheck","resolve","state","DocumentState","Linked","linkReference","container","property","extraScopes","resolveFromScopeProviders","reference","doLink","providers","provider","target","$refText","_ref","_nodeDescription","createDescription","name","references","push","$type","StringLiteral","NumberLiteral","BooleanLiteral","resolveLiteral","InvocationExpr","resolveInvocation","ArrayExpr","resolveArray","ReferenceExpr","resolveReference","MemberAccessExpr","resolveMemberAccess","UnaryExpr","resolveUnary","BinaryExpr","resolveBinary","ObjectExpr","resolveObject","ThisExpr","resolveThis","NullExpr","resolveNull","AttributeArg","resolveAttributeArg","DataModel","resolveDataModel","DataField","resolveDataField","resolveDefault","operator","left","right","resolveToBuiltinTypeOrDecl","resolveCollectionPredicate","Error","operand","fields","forEach","field","ref","EnumField","$container","resolveToDeclaredType","type","items","item","itemType","$resolvedType","decl","args","arg","function","funcDecl","isAuthInvocation","allDecls","getAllLoadedAndReachableDataModelsAndTypeDefs","langiumDocuments","getContainerOfType","isDataModel","authDecl","getAuthDecl","nullable","isFutureExpr","getContainingDataModel","returnType","match","when","isStringLiteral","isBooleanLiteral","isNumberLiteral","exhaustive","operandResolved","array","isMemberContainer","member","resolvedType","_document","scope","r","_extraScopes","attrParam","findAttrParamForArg","attrAppliedOn","isDataField","transitiveDataModel","scopeProvider","getAllFields","find","f","isArrayExpr","isReferenceExpr","resolved","unresolvableRefExpr","createLinkingError","attr","undefined","params","p","index","findIndex","a","scopes","isEnum","contextEnum","enumScope","Object","entries","startsWith","isReference","child","isDataFieldType","optional","unsupported","mappedType","mapBuiltinTypeToExpressionType","import_langium","import_ts_pattern","ZModelScopeComputation","DefaultScopeComputation","services","computeExports","document","cancelToken","result","node","AstUtils","streamAllContents","parseResult","value","interruptAndCheck","isEnumField","desc","workspace","AstNodeDescriptionProvider","createDescription","name","push","processNode","scopes","isDataModel","bases","getRecursiveBases","base","field","fields","add","descriptions","nameProvider","getName","ZModelScopeProvider","DefaultScopeProvider","getGlobalScope","referenceType","context","model","getContainerOfType","container","isModel","EMPTY_SCOPE","importedUris","imports","map","resolveImportUri","filter","url","importedElements","indexManager","allElements","des","UriUtils","equals","documentUri","$document","uri","path","endsWith","STD_LIB_MODULE_NAME","PLUGIN_MODULE_NAME","some","importedUri","StreamScope","getScope","isMemberAccessExpr","operand","property","getMemberAccessScope","isReferenceExpr","containerCollectionPredicate","getCollectionPredicateContext","getCollectionPredicateScope","reflection","getReferenceType","globalScope","allowTypeDefScope","isTypeDef","match","when","ref","target","isDataField","createScopeForContainer","type","reference","member","array","isThisExpr","createScopeForContainingModel","isInvocationExpr","isAuthInvocation","createScopeForAuth","isFutureInvocation","otherwise","collectionPredicate","collection","left","expr","returnTypeDecl","function","returnType","includeTypeDefScope","createScopeForNodes","getAllFields","decls","getAllLoadedAndReachableDataModelsAndTypeDefs","shared","LangiumDocuments","authDecl","getAuthDecl","curr","$container","isCollectionPredicate","$containerProperty","undefined","import_langium","import_node_fs","ZModelWorkspaceManager","DefaultWorkspaceManager","documentFactory","services","workspace","LangiumDocumentFactory","loadAdditionalDocuments","folders","collector","stdLibPath","installedStdlibPath","folder","folderPath","getRootFolder","fsPath","languagePackagePath","require","resolve","paths","languagePackageDir","path","dirname","candidateStdlibPath","join","STD_LIB_MODULE_NAME","fs","existsSync","console","log","_dirname","__dirname","fileURLToPath","url","stdlib","fromUri","URI","file","documents","langiumDocuments","all","pluginModels","Set","forEach","doc","parsed","parseResult","value","declarations","decl","isPlugin","providerField","fields","find","f","name","provider","getLiteral","add","size","Array","from","pendingPluginModules","Promise","map","wf","entry","loadPluginModels","workspaceFolder","pendingPluginModels","content","fileSystemProvider","readDirectory","sort","a","b","isDirectory","aName","UriUtils","basename","uri","plugin","joinPath","PLUGIN_MODULE_NAME","readFile","document","getOrCreateDocument","delete","ZModelLanguageModule","references","ScopeComputation","services","ZModelScopeComputation","ScopeProvider","ZModelScopeProvider","Linker","ZModelLinker","validation","ZModelValidator","ZModelSharedModule","workspace","WorkspaceManager","ZModelWorkspaceManager","createZModelLanguageServices","context","shared","inject","createDefaultSharedModule","ZModelGeneratedSharedModule","ZModelLanguage","createDefaultModule","ZModelGeneratedModule","ServiceRegistry","register","registerValidationChecks","connection","ConfigurationProvider","initialized","import_meta","createZModelServices","createZModelLanguageServices","NodeFileSystem","DocumentLoadError","Error","message","loadDocument","fileName","pluginModelFiles","ZModelLanguage","services","extensions","LanguageMetaData","fileExtensions","includes","path","extname","success","errors","warnings","fs","existsSync","_dirname","__dirname","dirname","fileURLToPath","import_meta","url","stdLib","shared","workspace","LangiumDocuments","getOrCreateDocument","URI","file","resolve","join","STD_LIB_MODULE_NAME","pluginDocs","Promise","all","map","langiumDocuments","document","importedURIs","loadImports","importedDocuments","uri","push","DocumentBuilder","build","validation","diagnostics","flatMap","doc","diag","filter","severity","toArray","length","relative","process","cwd","fsPath","range","start","line","character","model","parseResult","value","imported","mergeImportsDeclarations","forEach","deleteDocument","$document","IndexManager","remove","additionalErrors","validationAfterImportMerge","documents","uris","Set","uriString","toString","has","add","imp","imports","importedModel","resolveImport","importedDoc","getDocument","Array","from","x","e","parse","importedModels","resolveTransitiveImports","importedDeclarations","m","declarations","linkContentToContainer","node","name","Object","entries","startsWith","isArray","item","index","isAstNode","$container","$containerProperty","$containerIndex","dataSources","d","isDataSource","decls","getDataModelAndTypeDefs","authDecls","hasAttribute"]}