@cratis/screenplay-language 4.256.0 → 4.257.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/compiler/Authoring/QuickFixes.js +2 -2
- package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
- package/dist/bundles/compiler/Parsing/AuthorizeParser.js +1 -1
- package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
- package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
- package/dist/bundles/compiler/index.js +1 -1
- package/dist/bundles/validation.js +1 -1
- package/dist/bundles/validation.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectionParser.js","names":["header","pattern","eventSpecPattern","joinPattern","withPattern","childrenPattern","nestedPattern","removeWithPattern","removeViaJoinPattern","clearWithPattern","variantPattern","entersOnPattern","keywordMappingPattern","arithmeticPattern","setPattern","assignmentPattern","keywordMappings","match","line","context","DiagnosticCodes","locationOf","firstWord","name","sequence","description","autoMap","key","blocks","child","isFileDirective","keyword","parseDescription","block","validateProjectionEventScopes","variants","byName","variant","duplicate","group","entering","entry","location","includeChildren","nestedScope","events","spec","splitTopLevel","text","unescapeIdentifier","parseProjectionExpression","mappings","parentKey","withMatch","property","viaJoin","partsKey","parsed","entersOn","parts","expression","closing","extra","diagnosticText","arithmetic","assigned"],"sources":["../../../../../../Compiler/Parsing/ProjectionParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport {\n AutoMapMode, ChildrenSyntax, ClearWithSyntax, CompositeKeySyntax, EventSpecSyntax, FromSyntax, JoinEventSyntax, JoinSyntax, MappingKind, MappingSyntax, NestedSyntax,\n KeyPartSyntax, KeySyntax, ProjectionBlockSyntax, ProjectionEntersOnSyntax, ProjectionSyntax, ProjectionVariantSyntax,\n} from '../Syntax/Projections';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { pattern } from '../Text/patterns';\nimport { parseProjectionExpression } from './ProjectionExpressionParser';\nimport { validateProjectionEventScopes } from './ProjectionEventScopeValidator';\nimport { isFileDirective } from './FileReferences';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord, splitTopLevel, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^projection\\\\s+(@?[\\\\w.]+)\\\\s*(?:=>\\\\s*([\\\\w.]+))?$');\nconst eventSpecPattern = pattern('^(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst joinPattern = pattern('^join\\\\s+(@?[\\\\w.]+)\\\\s+on\\\\s+(@?[\\\\w.]+)$');\nconst withPattern = pattern('^with\\\\s+(@?[\\\\w.]+)$');\nconst childrenPattern = pattern('^children\\\\s+(@?[\\\\w.]+)\\\\s+identified\\\\s+by\\\\s+(.+)$');\nconst nestedPattern = pattern('^nested\\\\s+(@?[\\\\w.]+)$');\nconst removeWithPattern = pattern('^remove\\\\s+with\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst removeViaJoinPattern = pattern('^remove\\\\s+via\\\\s+join\\\\s+on\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst clearWithPattern = pattern('^clear\\\\s+with\\\\s+(@?[\\\\w.]+)$');\nconst variantPattern = pattern('^variant\\\\s+(@?[\\\\w.]+)\\\\s*$');\nconst entersOnPattern = pattern('^enters\\\\s+on\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst keywordMappingPattern = pattern('^(increment|decrement|count|clear)\\\\s+(@?[$\\\\w.]+)$');\nconst arithmeticPattern = pattern('^(add|subtract)\\\\s+(@?[$\\\\w.]+)\\\\s+by\\\\s+(.+?)(?:\\\\s+\\\\*\\\\s+(.+))?$');\nconst setPattern = pattern('^set\\\\s+(@?[$\\\\w.]+)\\\\s+(?:=|to)\\\\s+(.+)$');\nconst assignmentPattern = pattern('^(@?[$\\\\w.@]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst keywordMappings: Record<string, MappingKind> = {\n increment: 'IncrementMappingSyntax',\n decrement: 'DecrementMappingSyntax',\n clear: 'ClearMappingSyntax',\n count: 'CountMappingSyntax',\n};\n\n// Reads a projection's structure: its name, the read model it builds, the events each block consumes, the\n// properties each mapping sets and where automap is turned on or off. Keys, and where a mapping takes its\n// value from, are recognized and skipped.\nexport function parseProjection(context: ParserContext, line: SourceLine): ProjectionSyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidProjectionDeclaration, `Invalid projection declaration '${line.content}' - expected 'projection <Name> [=> <ReadModel>]'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionSyntax', sourceOptions: context.sourceOptions, name: firstWord(line.content), readModel: null, sequence: null, autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const name = match[1];\n let sequence: string | null = null;\n let description: string | null = null;\n let autoMap: AutoMapMode = 'Inherit';\n let key: KeySyntax | null = null;\n const blocks: ProjectionBlockSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (isFileDirective(child)) {\n continue;\n }\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Projection '${name}'`);\n } else if (keyword === 'sequence') {\n sequence = child.content.substring('sequence'.length).trim();\n } else if (keyword === 'automap') {\n autoMap = 'Enabled';\n } else if (child.content === 'no automap') {\n autoMap = 'Disabled';\n } else if (keyword === 'key') {\n key = parseKey(context, child);\n } else if (keyword === 'variant') {\n blocks.push(parseVariant(context, child));\n } else {\n const block = parseBlock(context, child, false);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n }\n reportVariantConflicts(context, blocks, name);\n validateProjectionEventScopes(context, name, blocks);\n if (blocks.length === 0) {\n context.error(DiagnosticCodes.EmptyProjection, `Projection '${name}' must contain at least one directive`, locationOf(line));\n }\n return { kind: 'ProjectionSyntax', sourceOptions: context.sourceOptions, name, readModel: match[2] ?? null, sequence, autoMap, key, blocks, description, location: locationOf(line) };\n}\n\nfunction reportVariantConflicts(context: ParserContext, blocks: readonly ProjectionBlockSyntax[], name: string): void {\n // Grouped by name in the order each name first appears, as the C# parser reports them.\n const variants = blocks.filter((block): block is ProjectionVariantSyntax => block.kind === 'ProjectionVariantSyntax');\n const byName = new Map<string, ProjectionVariantSyntax[]>();\n variants.forEach(variant => byName.set(variant.name, [...(byName.get(variant.name) ?? []), variant]));\n for (const duplicate of [...byName.values()].flatMap(group => group.slice(1))) {\n context.error(DiagnosticCodes.DuplicateProjectionVariant, `Duplicate variant '${duplicate.name}' - a variant name is declared once`, duplicate.location);\n }\n const entering = new Set<string>();\n for (const entry of blocks.flatMap(block => block.kind === 'ProjectionVariantSyntax' ? block.entersOn : [])) {\n if (entry.event.length > 0 && entering.has(entry.event)) {\n context.error(DiagnosticCodes.DuplicateVariantEnteringEvent, `Entering event '${entry.event}' is claimed more than once in projection '${name}'`, entry.location);\n }\n entering.add(entry.event);\n }\n}\n\nfunction parseBlock(context: ParserContext, line: SourceLine, nestedScope: boolean): ProjectionBlockSyntax | undefined {\n const location = locationOf(line);\n switch (firstWord(line.content)) {\n case 'from':\n return parseFrom(context, line);\n case 'every': {\n let includeChildren = true;\n const { autoMap, mappings } = parseMappingBlock(context, line, child => {\n if (child.content !== 'exclude children') {\n return false;\n }\n includeChildren = false;\n return true;\n });\n return { kind: 'EverySyntax', includeChildren, autoMap, mappings, location };\n }\n case 'all': {\n const { autoMap, mappings } = parseMappingBlock(context, line);\n return { kind: 'AllSyntax', autoMap, mappings, location };\n }\n case 'join':\n return parseJoin(context, line);\n case 'children':\n return parseChildren(context, line);\n case 'nested':\n return parseNested(context, line);\n case 'remove':\n return parseRemove(context, line);\n case 'clear':\n if (!nestedScope) {\n context.error(DiagnosticCodes.ClearWithOutsideNestedBlock, '\\'clear with\\' is only valid inside a nested block', location);\n }\n return parseClearWith(context, line);\n default:\n context.error(DiagnosticCodes.UnknownProjectionDirective, `Unexpected '${firstWord(line.content)}' in projection body`, location);\n context.skipBlock(line.indent);\n return undefined;\n }\n}\n\nfunction parseFrom(context: ParserContext, line: SourceLine): FromSyntax {\n const events: EventSpecSyntax[] = [];\n for (const spec of splitTopLevel(line.content.substring('from'.length), ',')) {\n const text = spec.trim();\n if (text.length === 0) {\n context.error(DiagnosticCodes.FromWithoutEvent, 'Expected an event type after \\'from\\'', locationOf(line));\n continue;\n }\n const match = eventSpecPattern.exec(text);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEventReference, `Invalid event reference '${text}'`, locationOf(line));\n continue;\n }\n events.push({ kind: 'EventSpecSyntax', event: unescapeIdentifier(match[1]), key: match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context), location: locationOf(line) });\n }\n const mappings: MappingSyntax[] = [];\n let key: KeySyntax | null = null;\n let parentKey: ExpressionSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'key') key = parseKey(context, child);\n else if (keyword === 'parent') parentKey = parseProjectionExpression(child.content.substring('parent'.length), locationOf(child), context);\n else pushMapping(context, child, mappings);\n }\n return { kind: 'FromSyntax', events, key, parentKey, mappings, location: locationOf(line) };\n}\n\nfunction parseJoin(context: ParserContext, line: SourceLine): JoinSyntax {\n const match = joinPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidJoinDeclaration, `Invalid join declaration '${line.content}' - expected 'join <property> on <key>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'JoinSyntax', property: '', on: '', events: [], location: locationOf(line) };\n }\n const events: JoinEventSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const withMatch = withPattern.exec(child.content);\n if (withMatch === null) {\n context.error(DiagnosticCodes.JoinWithoutEvent, `Expected 'with <EventType>' in join block, got '${child.content}'`, locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const { autoMap, mappings } = parseMappingBlock(context, child);\n events.push({ kind: 'JoinEventSyntax', event: unescapeIdentifier(withMatch[1]), autoMap, mappings, location: locationOf(child) });\n }\n return { kind: 'JoinSyntax', property: unescapeIdentifier(match[1]), on: unescapeIdentifier(match[2]), events, location: locationOf(line) };\n}\n\nfunction parseChildren(context: ParserContext, line: SourceLine): ChildrenSyntax {\n const match = childrenPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidChildrenDeclaration, `Invalid children declaration '${line.content}' - expected 'children <collection> identified by <key>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ChildrenSyntax', property: '', autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const { autoMap, blocks } = parseChildBlocks(context, line);\n return { kind: 'ChildrenSyntax', property: unescapeIdentifier(match[1]), identifiedBy: parseProjectionExpression(match[2], locationOf(line), context), autoMap, blocks, location: locationOf(line) };\n}\n\nfunction parseNested(context: ParserContext, line: SourceLine): NestedSyntax {\n const match = nestedPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidNestedDeclaration, `Invalid nested declaration '${line.content}' - expected 'nested <property>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'NestedSyntax', property: '', autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const property = unescapeIdentifier(match[1]);\n const { autoMap, blocks } = parseChildBlocks(context, line);\n if (!blocks.some(block => block.kind === 'FromSyntax')) {\n context.error(DiagnosticCodes.NestedBlockWithoutFrom, `Nested block '${property}' must contain at least one 'from' directive`, locationOf(line));\n }\n return { kind: 'NestedSyntax', property, autoMap, blocks, location: locationOf(line) };\n}\n\nfunction parseChildBlocks(context: ParserContext, line: SourceLine): { autoMap: AutoMapMode; blocks: ProjectionBlockSyntax[] } {\n const blocks: ProjectionBlockSyntax[] = [];\n let autoMap: AutoMapMode = 'Inherit';\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'automap') {\n autoMap = 'Enabled';\n continue;\n }\n if (child.content === 'no automap') {\n autoMap = 'Disabled';\n continue;\n }\n const block = parseBlock(context, child, true);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n return { autoMap, blocks };\n}\n\nfunction parseRemove(context: ParserContext, line: SourceLine): ProjectionBlockSyntax | undefined {\n const viaJoin = removeViaJoinPattern.exec(line.content);\n if (viaJoin !== null) {\n return { kind: 'RemoveViaJoinSyntax', event: unescapeIdentifier(viaJoin[1]), key: viaJoin[2] === undefined ? null : parseProjectionExpression(viaJoin[2], locationOf(line), context), location: locationOf(line) };\n }\n const match = removeWithPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidRemoveDeclaration, `Invalid remove declaration '${line.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n let key = match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context);\n let partsKey: CompositeKeySyntax | null = null;\n let parentKey: ExpressionSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'parent') {\n parentKey = parseProjectionExpression(child.content.substring('parent'.length), locationOf(child), context);\n } else if (firstWord(child.content) === 'key') {\n if (key !== null || partsKey !== null) context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A removal can only declare one key.', locationOf(child));\n const parsed = parseKey(context, child);\n if (parsed.kind === 'CompositeKeySyntax') partsKey = parsed;\n else key = parsed.expression;\n } else {\n context.error(DiagnosticCodes.UnknownRemoveDirective, `Unexpected '${child.content}' in remove block - only 'parent' or 'key' is allowed`, locationOf(child));\n }\n }\n return { kind: 'RemoveWithSyntax', event: unescapeIdentifier(match[1]), key, ...(partsKey === null ? {} : { partsKey }), parentKey, location: locationOf(line) };\n}\n\nfunction parseClearWith(context: ParserContext, line: SourceLine): ClearWithSyntax {\n const match = clearWithPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidClearDeclaration, `Invalid clear declaration '${line.content}' - expected 'clear with <EventType>'`, locationOf(line));\n return { kind: 'ClearWithSyntax', event: '', location: locationOf(line) };\n }\n return { kind: 'ClearWithSyntax', event: unescapeIdentifier(match[1]), location: locationOf(line) };\n}\n\nfunction parseVariant(context: ParserContext, line: SourceLine): ProjectionVariantSyntax {\n const match = variantPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidProjectionVariantDeclaration, `Invalid variant declaration '${line.content}' - expected 'variant <Name>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionVariantSyntax', name: firstWord(line.content), entersOn: [], blocks: [], location: locationOf(line) };\n }\n const name = unescapeIdentifier(match[1]);\n const entersOn: ProjectionEntersOnSyntax[] = [];\n const blocks: ProjectionBlockSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'enters') {\n entersOn.push(parseEntersOn(context, child));\n } else if (keyword === 'variant') {\n context.error(DiagnosticCodes.NestedProjectionVariantNotAllowed, 'A variant cannot be declared inside another variant', locationOf(child));\n context.skipBlock(child.indent);\n } else {\n const block = parseBlock(context, child, false);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n }\n if (entersOn.length === 0) {\n context.error(DiagnosticCodes.VariantRequiresEnteringEvent, `Variant '${name}' must declare at least one 'enters on' event`, locationOf(line));\n }\n return { kind: 'ProjectionVariantSyntax', name, entersOn, blocks, location: locationOf(line) };\n}\n\nfunction parseEntersOn(context: ParserContext, line: SourceLine): ProjectionEntersOnSyntax {\n const match = entersOnPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEntersOnDeclaration, `Invalid 'enters on' declaration '${line.content}' - expected 'enters on <EventType> [key <expression>]'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionEntersOnSyntax', event: '', key: null, location: locationOf(line) };\n }\n return { kind: 'ProjectionEntersOnSyntax', event: unescapeIdentifier(match[1]), key: match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context), location: locationOf(line) };\n}\n\n// A key with a body is a composite key: its parts, then a closing '}' at the key's own indent.\nfunction parseKey(context: ParserContext, line: SourceLine): KeySyntax {\n const text = line.content.substring('key'.length).trim();\n if (context.peekChild(line.indent) === undefined) return { kind: 'ExpressionKeySyntax', expression: parseProjectionExpression(text, locationOf(line), context), location: locationOf(line) };\n const parts: KeyPartSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === '}') continue;\n const match = assignmentPattern.exec(child.content);\n if (match === null) {\n if (context.sourceOptions.numericMode === 'exact') context.error(DiagnosticCodes.InvalidCompositeKeyPart, `Invalid composite key part '${child.content}' - expected '<property> = <expression>'`, locationOf(child));\n continue;\n }\n const expression = parseProjectionExpression(match[2], locationOf(child), context);\n if (context.sourceOptions.numericMode === 'exact' && text.replace(/\\{$/, '').trim().length > 0 && expression.kind === 'TemplateExpressionSyntax') context.error(DiagnosticCodes.TemplateInCompositeKey, 'Template expressions are not allowed in composite keys', locationOf(child));\n parts.push({ kind: 'KeyPartSyntax', property: unescapeIdentifier(match[1]), expression, location: locationOf(child) });\n }\n const closing = context.reader.peekSignificant();\n if (closing !== undefined && closing.indent === line.indent && closing.content === '}') context.reader.takeSignificant();\n if (context.sourceOptions.numericMode === 'exact' && parts.length === 0) context.error(DiagnosticCodes.EmptyCompositeKey, 'Composite keys must contain at least one part', locationOf(line));\n return { kind: 'CompositeKeySyntax', type: text.replace(/\\{$/, '').trim(), parts, location: locationOf(line) };\n}\n\n// Mapping lines carry no body, so a mapping block is its direct children. The last automap setting wins;\n// a line 'extra' claims is not a mapping.\nfunction parseMappingBlock(context: ParserContext, line: SourceLine, extra: (child: SourceLine) => boolean = () => false): { autoMap: AutoMapMode; mappings: MappingSyntax[] } {\n let autoMap: AutoMapMode = 'Inherit';\n const mappings: MappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'automap') {\n autoMap = 'Enabled';\n } else if (child.content === 'no automap') {\n autoMap = 'Disabled';\n } else if (!extra(child)) {\n pushMapping(context, child, mappings);\n }\n }\n return { autoMap, mappings };\n}\n\n// The property one mapping line sets, and how - the port of the C# ParseMappingLine. Exact reports\n// malformed mappings; Legacy keeps the existing skip behavior.\nfunction pushMapping(context: ParserContext, line: SourceLine, mappings: MappingSyntax[]): void {\n const location = locationOf(line);\n const keyword = keywordMappingPattern.exec(line.content);\n if (keyword !== null) {\n if (keyword[1] !== 'clear' || keyword[2] !== 'with') {\n mappings.push({ kind: keywordMappings[keyword[1]], property: unescapeIdentifier(keyword[2]), location });\n } else if (context.sourceOptions.numericMode === 'exact') {\n context.error(DiagnosticCodes.InvalidProjectionMapping, `Invalid mapping '${line.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`, location, diagnosticText('text', line.content));\n }\n return;\n }\n const arithmetic = arithmeticPattern.exec(line.content);\n if (arithmetic !== null) {\n mappings.push({ kind: arithmetic[1] === 'add' ? 'AddMappingSyntax' : 'SubtractMappingSyntax', property: unescapeIdentifier(arithmetic[2]), value: parseProjectionExpression(arithmetic[3], location, context), ...(arithmetic[4] === undefined ? {} : { factor: parseProjectionExpression(arithmetic[4], location, context) }), location });\n return;\n }\n const assigned = setPattern.exec(line.content) ?? assignmentPattern.exec(line.content);\n if (assigned !== null) {\n mappings.push({ kind: 'SetMappingSyntax', property: unescapeIdentifier(assigned[1]), source: parseProjectionExpression(assigned[2], location, context), location });\n } else if (context.sourceOptions.numericMode === 'exact') {\n context.error(DiagnosticCodes.InvalidProjectionMapping, `Invalid mapping '${line.content}'`, location, diagnosticText('text', line.content));\n }\n}\n"],"mappings":"8nBAmBA,MAAMA,EAASC,EAAQ,qDAAqD,EACtEC,EAAmBD,EAAQ,mCAAmC,EAC9DE,EAAcF,EAAQ,4CAA4C,EAClEG,EAAcH,EAAQ,uBAAuB,EAC7CI,EAAkBJ,EAAQ,uDAAuD,EACjFK,EAAgBL,EAAQ,yBAAyB,EACjDM,EAAoBN,EAAQ,qDAAqD,EACjFO,EAAuBP,EAAQ,kEAAkE,EACjGQ,EAAmBR,EAAQ,gCAAgC,EAC3DS,EAAiBT,EAAQ,8BAA8B,EACvDU,EAAkBV,EAAQ,mDAAmD,EAC7EW,EAAwBX,EAAQ,qDAAqD,EACrFY,EAAoBZ,EAAQ,qEAAqE,EACjGa,EAAab,EAAQ,2CAA2C,EAChEc,EAAoBd,EAAQ,qCAAqC,EACjEe,EAA+C,CACjD,UAAW,yBACX,UAAW,yBACX,MAAO,qBACP,MAAO,oBACX,EAKA,SAAgB,gBAAgB,EAAwB,EAAoC,CACxF,IAAMC,EAAQjB,EAAO,KAAKkB,EAAK,OAAO,EACtC,GAAID,IAAU,KAG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AAQ,EAAE,EAAG,UAAS,CAAC,EAChGZ,EAAQ,cAAc,cAAgB,SAC7CA,EAAQ,MAAMC,EAAgB,yBAA0B,oBAAoBF,EAAK,QAAQ,sHAAuHwB,EAAUqB,EAAe,OAAQ7C,EAAK,OAAO,CAAC,EAElQ,MACJ,CACA,IAAM8C,EAAanD,EAAkB,KAAKK,EAAK,OAAO,EACtD,GAAI8C,IAAe,KAAM,CACrBb,EAAS,KAAK,CAAE,KAAMa,EAAW,KAAO,MAAQ,mBAAqB,wBAAyB,SAAUf,EAAmBe,EAAW,EAAE,EAAG,MAAOd,EAA0Bc,EAAW,GAAItB,EAAUvB,CAAO,EAAG,GAAI6C,EAAW,KAAO,IAAA,GAAY,CAAC,EAAI,CAAE,OAAQd,EAA0Bc,EAAW,GAAItB,EAAUvB,CAAO,CAAE,EAAI,UAAS,CAAC,EAC1U,MACJ,CACA,IAAM8C,EAAWnD,EAAW,KAAKI,EAAK,OAAO,GAAKH,EAAkB,KAAKG,EAAK,OAAO,EACjF+C,IAAa,KAEN9C,EAAQ,cAAc,cAAgB,SAC7CA,EAAQ,MAAMC,EAAgB,yBAA0B,oBAAoBF,EAAK,QAAQ,GAAIwB,EAAUqB,EAAe,OAAQ7C,EAAK,OAAO,CAAC,EAF3IiC,EAAS,KAAK,CAAE,KAAM,mBAAoB,SAAUF,EAAmBgB,EAAS,EAAE,EAAG,OAAQf,EAA0Be,EAAS,GAAIvB,EAAUvB,CAAO,EAAG,UAAS,CAAC,CAI1K"}
|
|
1
|
+
{"version":3,"file":"ProjectionParser.js","names":["header","pattern","eventSpecPattern","joinPattern","withPattern","childrenPattern","nestedPattern","removeWithPattern","removeViaJoinPattern","clearWithPattern","variantPattern","entersOnPattern","keywordMappingPattern","arithmeticPattern","setPattern","assignmentPattern","keywordMappings","match","line","context","DiagnosticCodes","locationOf","firstWord","name","sequence","description","autoMap","key","blocks","child","isFileDirective","keyword","parseDescription","block","validateProjectionEventScopes","variants","byName","variant","duplicate","group","entering","entry","location","includeChildren","nestedScope","events","spec","splitTopLevel","text","unescapeIdentifier","parseProjectionExpression","mappings","parentKey","withMatch","property","viaJoin","partsKey","parsed","entersOn","parts","expression","closing","extra","diagnosticText","arithmetic","assigned"],"sources":["../../../../../../Compiler/Parsing/ProjectionParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport {\n AutoMapMode, ChildrenSyntax, ClearWithSyntax, CompositeKeySyntax, EventSpecSyntax, FromSyntax, JoinEventSyntax, JoinSyntax, MappingKind, MappingSyntax, NestedSyntax,\n KeyPartSyntax, KeySyntax, ProjectionBlockSyntax, ProjectionEntersOnSyntax, ProjectionSyntax, ProjectionVariantSyntax,\n} from '../Syntax/Projections';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { pattern } from '../Text/patterns';\nimport { parseProjectionExpression } from './ProjectionExpressionParser';\nimport { validateProjectionEventScopes } from './ProjectionEventScopeValidator';\nimport { isFileDirective } from './FileReferences';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord, splitTopLevel, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^projection\\\\s+(@?[\\\\w.]+)\\\\s*(?:=>\\\\s*([\\\\w.]+))?$');\nconst eventSpecPattern = pattern('^(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst joinPattern = pattern('^join\\\\s+(@?[\\\\w.]+)\\\\s+on\\\\s+(@?[\\\\w.]+)$');\nconst withPattern = pattern('^with\\\\s+(@?[\\\\w.]+)$');\nconst childrenPattern = pattern('^children\\\\s+(@?[\\\\w.]+)\\\\s+identified\\\\s+by\\\\s+(.+)$');\nconst nestedPattern = pattern('^nested\\\\s+(@?[\\\\w.]+)$');\nconst removeWithPattern = pattern('^remove\\\\s+with\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst removeViaJoinPattern = pattern('^remove\\\\s+via\\\\s+join\\\\s+on\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst clearWithPattern = pattern('^clear\\\\s+with\\\\s+(@?[\\\\w.]+)$');\nconst variantPattern = pattern('^variant\\\\s+(@?[\\\\w.]+)\\\\s*$');\nconst entersOnPattern = pattern('^enters\\\\s+on\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst keywordMappingPattern = pattern('^(increment|decrement|count|clear)\\\\s+(@?[$\\\\w.]+)$');\nconst arithmeticPattern = pattern('^(add|subtract)\\\\s+(@?[$\\\\w.]+)\\\\s+by\\\\s+(.+?)(?:\\\\s+\\\\*\\\\s+(.+))?$');\nconst setPattern = pattern('^set\\\\s+(@?[$\\\\w.]+)\\\\s+(?:=|to)\\\\s+(.+)$');\nconst assignmentPattern = pattern('^(@?[$\\\\w.@]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst keywordMappings: Record<string, MappingKind> = {\n increment: 'IncrementMappingSyntax',\n decrement: 'DecrementMappingSyntax',\n clear: 'ClearMappingSyntax',\n count: 'CountMappingSyntax',\n};\n\n// Reads a projection's structure: its name, the read model it builds, the events each block consumes, the\n// properties each mapping sets and where automap is turned on or off. Keys, and where a mapping takes its\n// value from, are recognized and skipped.\nexport function parseProjection(context: ParserContext, line: SourceLine): ProjectionSyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidProjectionDeclaration, `Invalid projection declaration '${line.content}' - expected 'projection <Name> [=> <ReadModel>]'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionSyntax', sourceOptions: context.sourceOptions, name: firstWord(line.content), readModel: null, sequence: null, autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const name = match[1];\n let sequence: string | null = null;\n let description: string | null = null;\n let autoMap: AutoMapMode = 'Inherit';\n let key: KeySyntax | null = null;\n const blocks: ProjectionBlockSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (isFileDirective(child)) {\n continue;\n }\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Projection '${name}'`);\n } else if (keyword === 'sequence') {\n sequence = child.content.substring('sequence'.length).trim();\n } else if (keyword === 'automap') {\n autoMap = 'Enabled';\n } else if (child.content === 'no automap') {\n autoMap = 'Disabled';\n } else if (keyword === 'key') {\n key = parseKey(context, child);\n } else if (keyword === 'variant') {\n blocks.push(parseVariant(context, child));\n } else {\n const block = parseBlock(context, child, false);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n }\n reportVariantConflicts(context, blocks, name);\n validateProjectionEventScopes(context, name, blocks);\n if (blocks.length === 0) {\n context.error(DiagnosticCodes.EmptyProjection, `Projection '${name}' must contain at least one directive`, locationOf(line));\n }\n return { kind: 'ProjectionSyntax', sourceOptions: context.sourceOptions, name, readModel: match[2] ?? null, sequence, autoMap, key, blocks, description, location: locationOf(line) };\n}\n\nfunction reportVariantConflicts(context: ParserContext, blocks: readonly ProjectionBlockSyntax[], name: string): void {\n // Grouped by name in the order each name first appears, as the C# parser reports them.\n const variants = blocks.filter((block): block is ProjectionVariantSyntax => block.kind === 'ProjectionVariantSyntax');\n const byName = new Map<string, ProjectionVariantSyntax[]>();\n variants.forEach(variant => byName.set(variant.name, [...(byName.get(variant.name) ?? []), variant]));\n for (const duplicate of [...byName.values()].flatMap(group => group.slice(1))) {\n context.error(DiagnosticCodes.DuplicateProjectionVariant, `Duplicate variant '${duplicate.name}' - a variant name is declared once`, duplicate.location);\n }\n const entering = new Set<string>();\n for (const entry of blocks.flatMap(block => block.kind === 'ProjectionVariantSyntax' ? block.entersOn : [])) {\n if (entry.event.length > 0 && entering.has(entry.event)) {\n context.error(DiagnosticCodes.DuplicateVariantEnteringEvent, `Entering event '${entry.event}' is claimed more than once in projection '${name}'`, entry.location);\n }\n entering.add(entry.event);\n }\n}\n\nfunction parseBlock(context: ParserContext, line: SourceLine, nestedScope: boolean): ProjectionBlockSyntax | undefined {\n const location = locationOf(line);\n switch (firstWord(line.content)) {\n case 'from':\n return parseFrom(context, line);\n case 'every': {\n let includeChildren = true;\n const { autoMap, mappings } = parseMappingBlock(context, line, child => {\n if (child.content !== 'exclude children') {\n return false;\n }\n includeChildren = false;\n return true;\n });\n return { kind: 'EverySyntax', includeChildren, autoMap, mappings, location };\n }\n case 'all': {\n const { autoMap, mappings } = parseMappingBlock(context, line);\n return { kind: 'AllSyntax', autoMap, mappings, location };\n }\n case 'join':\n return parseJoin(context, line);\n case 'children':\n return parseChildren(context, line);\n case 'nested':\n return parseNested(context, line);\n case 'remove':\n return parseRemove(context, line);\n case 'clear':\n if (!nestedScope) {\n context.error(DiagnosticCodes.ClearWithOutsideNestedBlock, '\\'clear with\\' is only valid inside a nested block', location);\n }\n return parseClearWith(context, line);\n default:\n context.error(DiagnosticCodes.UnknownProjectionDirective, `Unexpected '${firstWord(line.content)}' in projection body`, location);\n context.skipBlock(line.indent);\n return undefined;\n }\n}\n\nfunction parseFrom(context: ParserContext, line: SourceLine): FromSyntax {\n const events: EventSpecSyntax[] = [];\n for (const spec of splitTopLevel(line.content.substring('from'.length), ',')) {\n const text = spec.trim();\n if (text.length === 0) {\n context.error(DiagnosticCodes.FromWithoutEvent, 'Expected an event type after \\'from\\'', locationOf(line));\n continue;\n }\n const match = eventSpecPattern.exec(text);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEventReference, `Invalid event reference '${text}'`, locationOf(line));\n continue;\n }\n events.push({ kind: 'EventSpecSyntax', event: unescapeIdentifier(match[1]), key: match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context), location: locationOf(line) });\n }\n const mappings: MappingSyntax[] = [];\n let key: KeySyntax | null = null;\n let parentKey: ExpressionSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'key') key = parseKey(context, child);\n else if (keyword === 'parent') parentKey = parseProjectionExpression(child.content.substring('parent'.length), locationOf(child), context);\n else pushMapping(context, child, mappings);\n }\n return { kind: 'FromSyntax', events, key, parentKey, mappings, location: locationOf(line) };\n}\n\nfunction parseJoin(context: ParserContext, line: SourceLine): JoinSyntax {\n const match = joinPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidJoinDeclaration, `Invalid join declaration '${line.content}' - expected 'join <property> on <key>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'JoinSyntax', property: '', on: '', events: [], location: locationOf(line) };\n }\n const events: JoinEventSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const withMatch = withPattern.exec(child.content);\n if (withMatch === null) {\n context.error(DiagnosticCodes.JoinWithoutEvent, `Expected 'with <EventType>' in join block, got '${child.content}'`, locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const { autoMap, mappings } = parseMappingBlock(context, child);\n events.push({ kind: 'JoinEventSyntax', event: unescapeIdentifier(withMatch[1]), autoMap, mappings, location: locationOf(child) });\n }\n return { kind: 'JoinSyntax', property: unescapeIdentifier(match[1]), on: unescapeIdentifier(match[2]), events, location: locationOf(line) };\n}\n\nfunction parseChildren(context: ParserContext, line: SourceLine): ChildrenSyntax {\n const match = childrenPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidChildrenDeclaration, `Invalid children declaration '${line.content}' - expected 'children <collection> identified by <key>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ChildrenSyntax', property: '', autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const { autoMap, blocks } = parseChildBlocks(context, line);\n return { kind: 'ChildrenSyntax', property: unescapeIdentifier(match[1]), identifiedBy: parseProjectionExpression(match[2], locationOf(line), context), autoMap, blocks, location: locationOf(line) };\n}\n\nfunction parseNested(context: ParserContext, line: SourceLine): NestedSyntax {\n const match = nestedPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidNestedDeclaration, `Invalid nested declaration '${line.content}' - expected 'nested <property>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'NestedSyntax', property: '', autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const property = unescapeIdentifier(match[1]);\n const { autoMap, blocks } = parseChildBlocks(context, line);\n if (!blocks.some(block => block.kind === 'FromSyntax')) {\n context.error(DiagnosticCodes.NestedBlockWithoutFrom, `Nested block '${property}' must contain at least one 'from' directive`, locationOf(line));\n }\n return { kind: 'NestedSyntax', property, autoMap, blocks, location: locationOf(line) };\n}\n\nfunction parseChildBlocks(context: ParserContext, line: SourceLine): { autoMap: AutoMapMode; blocks: ProjectionBlockSyntax[] } {\n const blocks: ProjectionBlockSyntax[] = [];\n let autoMap: AutoMapMode = 'Inherit';\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'automap') {\n autoMap = 'Enabled';\n continue;\n }\n if (child.content === 'no automap') {\n autoMap = 'Disabled';\n continue;\n }\n const block = parseBlock(context, child, true);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n return { autoMap, blocks };\n}\n\nfunction parseRemove(context: ParserContext, line: SourceLine): ProjectionBlockSyntax | undefined {\n const viaJoin = removeViaJoinPattern.exec(line.content);\n if (viaJoin !== null) {\n return { kind: 'RemoveViaJoinSyntax', event: unescapeIdentifier(viaJoin[1]), key: viaJoin[2] === undefined ? null : parseProjectionExpression(viaJoin[2], locationOf(line), context), location: locationOf(line) };\n }\n const match = removeWithPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidRemoveDeclaration, `Invalid remove declaration '${line.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n let key = match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context);\n let partsKey: CompositeKeySyntax | null = null;\n let parentKey: ExpressionSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'parent') {\n parentKey = parseProjectionExpression(child.content.substring('parent'.length), locationOf(child), context);\n } else if (firstWord(child.content) === 'key') {\n if (key !== null || partsKey !== null) context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A removal can only declare one key.', locationOf(child));\n const parsed = parseKey(context, child);\n if (parsed.kind === 'CompositeKeySyntax') partsKey = parsed;\n else key = parsed.expression;\n } else {\n context.error(DiagnosticCodes.UnknownRemoveDirective, `Unexpected '${child.content}' in remove block - only 'parent' or 'key' is allowed`, locationOf(child));\n }\n }\n return { kind: 'RemoveWithSyntax', event: unescapeIdentifier(match[1]), key, ...(partsKey === null ? {} : { partsKey }), parentKey, location: locationOf(line) };\n}\n\nfunction parseClearWith(context: ParserContext, line: SourceLine): ClearWithSyntax {\n const match = clearWithPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidClearDeclaration, `Invalid clear declaration '${line.content}' - expected 'clear with <EventType>'`, locationOf(line));\n return { kind: 'ClearWithSyntax', event: '', location: locationOf(line) };\n }\n return { kind: 'ClearWithSyntax', event: unescapeIdentifier(match[1]), location: locationOf(line) };\n}\n\nfunction parseVariant(context: ParserContext, line: SourceLine): ProjectionVariantSyntax {\n const match = variantPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidProjectionVariantDeclaration, `Invalid variant declaration '${line.content}' - expected 'variant <Name>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionVariantSyntax', name: firstWord(line.content), entersOn: [], blocks: [], location: locationOf(line) };\n }\n const name = unescapeIdentifier(match[1]);\n const entersOn: ProjectionEntersOnSyntax[] = [];\n const blocks: ProjectionBlockSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'enters') {\n entersOn.push(parseEntersOn(context, child));\n } else if (keyword === 'variant') {\n context.error(DiagnosticCodes.NestedProjectionVariantNotAllowed, 'A variant cannot be declared inside another variant', locationOf(child));\n context.skipBlock(child.indent);\n } else {\n const block = parseBlock(context, child, false);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n }\n if (entersOn.length === 0) {\n context.error(DiagnosticCodes.VariantRequiresEnteringEvent, `Variant '${name}' must declare at least one 'enters on' event`, locationOf(line));\n }\n return { kind: 'ProjectionVariantSyntax', name, entersOn, blocks, location: locationOf(line) };\n}\n\nfunction parseEntersOn(context: ParserContext, line: SourceLine): ProjectionEntersOnSyntax {\n const match = entersOnPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEntersOnDeclaration, `Invalid 'enters on' declaration '${line.content}' - expected 'enters on <EventType> [key <expression>]'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionEntersOnSyntax', event: '', key: null, location: locationOf(line) };\n }\n return { kind: 'ProjectionEntersOnSyntax', event: unescapeIdentifier(match[1]), key: match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context), location: locationOf(line) };\n}\n\n// A key with a body is a composite key: its parts, then a closing '}' at the key's own indent.\nfunction parseKey(context: ParserContext, line: SourceLine): KeySyntax {\n const text = line.content.substring('key'.length).trim();\n if (context.peekChild(line.indent) === undefined) return { kind: 'ExpressionKeySyntax', expression: parseProjectionExpression(text, locationOf(line), context), location: locationOf(line) };\n if (text.endsWith('{')) context.information(DiagnosticCodes.RedundantCompositeKeyBraces, 'Write the composite key without braces; the indented parts already belong to the key.', locationOf(line));\n const parts: KeyPartSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === '}') continue;\n const match = assignmentPattern.exec(child.content);\n if (match === null) {\n if (context.sourceOptions.numericMode === 'exact') context.error(DiagnosticCodes.InvalidCompositeKeyPart, `Invalid composite key part '${child.content}' - expected '<property> = <expression>'`, locationOf(child));\n continue;\n }\n const expression = parseProjectionExpression(match[2], locationOf(child), context);\n if (context.sourceOptions.numericMode === 'exact' && text.replace(/\\{$/, '').trim().length > 0 && expression.kind === 'TemplateExpressionSyntax') context.error(DiagnosticCodes.TemplateInCompositeKey, 'Template expressions are not allowed in composite keys', locationOf(child));\n parts.push({ kind: 'KeyPartSyntax', property: unescapeIdentifier(match[1]), expression, location: locationOf(child) });\n }\n const closing = context.reader.peekSignificant();\n if (closing !== undefined && closing.indent === line.indent && closing.content === '}') context.reader.takeSignificant();\n if (context.sourceOptions.numericMode === 'exact' && parts.length === 0) context.error(DiagnosticCodes.EmptyCompositeKey, 'Composite keys must contain at least one part', locationOf(line));\n return { kind: 'CompositeKeySyntax', type: text.replace(/\\{$/, '').trim(), parts, location: locationOf(line) };\n}\n\n// Mapping lines carry no body, so a mapping block is its direct children. The last automap setting wins;\n// a line 'extra' claims is not a mapping.\nfunction parseMappingBlock(context: ParserContext, line: SourceLine, extra: (child: SourceLine) => boolean = () => false): { autoMap: AutoMapMode; mappings: MappingSyntax[] } {\n let autoMap: AutoMapMode = 'Inherit';\n const mappings: MappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'automap') {\n autoMap = 'Enabled';\n } else if (child.content === 'no automap') {\n autoMap = 'Disabled';\n } else if (!extra(child)) {\n pushMapping(context, child, mappings);\n }\n }\n return { autoMap, mappings };\n}\n\n// The property one mapping line sets, and how - the port of the C# ParseMappingLine. Exact reports\n// malformed mappings; Legacy keeps the existing skip behavior.\nfunction pushMapping(context: ParserContext, line: SourceLine, mappings: MappingSyntax[]): void {\n const location = locationOf(line);\n const keyword = keywordMappingPattern.exec(line.content);\n if (keyword !== null) {\n if (keyword[1] !== 'clear' || keyword[2] !== 'with') {\n mappings.push({ kind: keywordMappings[keyword[1]], property: unescapeIdentifier(keyword[2]), location });\n } else if (context.sourceOptions.numericMode === 'exact') {\n context.error(DiagnosticCodes.InvalidProjectionMapping, `Invalid mapping '${line.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`, location, diagnosticText('text', line.content));\n }\n return;\n }\n const arithmetic = arithmeticPattern.exec(line.content);\n if (arithmetic !== null) {\n mappings.push({ kind: arithmetic[1] === 'add' ? 'AddMappingSyntax' : 'SubtractMappingSyntax', property: unescapeIdentifier(arithmetic[2]), value: parseProjectionExpression(arithmetic[3], location, context), ...(arithmetic[4] === undefined ? {} : { factor: parseProjectionExpression(arithmetic[4], location, context) }), location });\n return;\n }\n const assigned = setPattern.exec(line.content) ?? assignmentPattern.exec(line.content);\n if (assigned !== null) {\n mappings.push({ kind: 'SetMappingSyntax', property: unescapeIdentifier(assigned[1]), source: parseProjectionExpression(assigned[2], location, context), location });\n } else if (context.sourceOptions.numericMode === 'exact') {\n context.error(DiagnosticCodes.InvalidProjectionMapping, `Invalid mapping '${line.content}'`, location, diagnosticText('text', line.content));\n }\n}\n"],"mappings":"8nBAmBA,MAAMA,EAASC,EAAQ,qDAAqD,EACtEC,EAAmBD,EAAQ,mCAAmC,EAC9DE,EAAcF,EAAQ,4CAA4C,EAClEG,EAAcH,EAAQ,uBAAuB,EAC7CI,EAAkBJ,EAAQ,uDAAuD,EACjFK,EAAgBL,EAAQ,yBAAyB,EACjDM,EAAoBN,EAAQ,qDAAqD,EACjFO,EAAuBP,EAAQ,kEAAkE,EACjGQ,EAAmBR,EAAQ,gCAAgC,EAC3DS,EAAiBT,EAAQ,8BAA8B,EACvDU,EAAkBV,EAAQ,mDAAmD,EAC7EW,EAAwBX,EAAQ,qDAAqD,EACrFY,EAAoBZ,EAAQ,qEAAqE,EACjGa,EAAab,EAAQ,2CAA2C,EAChEc,EAAoBd,EAAQ,qCAAqC,EACjE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"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{combineAuthorize as r,parseAuthorize as i}from"./AuthorizeParser.js";import{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s,reportLegacyOptionalSuffix as c}from"./PropertyLineParser.js";import{parseDescription as l}from"./DescriptionParser.js";const u=t(`^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`),d=t(`^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$`),f=t(`^scoped\\s+to\\s+([a-z_]\\w*)$`),p=/* @__PURE__ */ new Set([`performer`]);function parseQuery(t,a){let d=u.exec(a.content);if(d===null)return t.error(e.InvalidQueryDeclaration,`Invalid query declaration '${a.content}' - expected 'query <Name> => [observable] <ReadModel>'`,n(a)),t.skipBlock(a.indent),{kind:`QuerySyntax`,name:o(a.content),returnType:s(``,n(a)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:n(a)};let f=d[1],m=s(d[3],{...n(a),column:a.indent+1+d[0].length-d[3].length});(d[2]!==void 0||m.name!==`observable`||!m.isOptional||m.isCollection)&&c(t,m,a);let h=null,g=[],_=!1,v=[],y=null,b=null,x=null;for(let s=t.peekChild(a.indent);s!==void 0;s=t.peekChild(a.indent)){t.reader.takeSignificant();let a=o(s.content);if(a===`description`)y=l(t,s,y,`Query '${f}'`);else if(a===`by`){if(s.content===`by`){_&&t.error(e.InvalidReadModelKeyLookup,`A query cannot combine a by block with another by declaration.`,n(s)),h=null,g.length=0;for(let e=t.peekChild(s.indent);e!==void 0;e=t.peekChild(s.indent)){t.reader.takeSignificant();let n=parseParameter(t,e,``);n!==void 0&&g.push(n)}(g.length<2||new Set(g.map(e=>e.name)).size!==g.length)&&t.error(e.InvalidReadModelKeyLookup,`A query by block requires at least two distinct named key parts.`,n(s)),_=!0}else{let r=parseParameter(t,s,`by`);r!==void 0&&(_&&t.error(e.InvalidQueryParameter,`Query '${f}' already declares 'by' - a query can have at most one key parameter`,n(s)),g.length>0&&t.error(e.InvalidReadModelKeyLookup,`A query cannot combine a by block with a single by line.`,n(s)),g.length=0,h=r,_=!0)}}else if(a===`filter`){let e=parseParameter(t,s,`filter`);e!==void 0&&v.push(e)}else a===`authorize`?x=r(x,i(t,s)):a===`scoped`?b=parseScope(t,s,b,f)??b:p.has(a)?t.skipOpaqueBlock(s.indent):(t.error(e.UnknownQueryDirective,`Unexpected '${s.content}' in query body - expected description, by, filter, authorize, scoped or performer`,n(s)),t.skipBlock(s.indent))}return{kind:`QuerySyntax`,name:f,returnType:m,by:h,...g.length>0?{byParts:g}:{},filters:v,description:y,isObservable:d[2]!==void 0,scope:b,authorize:x,location:n(a)}}function parseParameter(t,r,i){let o=d.exec(r.content.substring(i.length).trim());if(o===null){t.error(e.InvalidQueryParameter,`Invalid '${i}' parameter '${r.content}' - expected '${i} <name> <Type> [from <source>]'`,n(r));return}let l=r.content.indexOf(o[1],i.length),u=s(o[2],{...n(r),column:r.indent+1+r.content.indexOf(o[2],l+o[1].length)});return c(t,u,r),{kind:`QueryParameterSyntax`,name:o[1],type:u,source:o[3]===void 0?null:a(o[3],n(r),t.valueContext),location:n(r)}}function parseScope(t,r,i,a){let o=f.exec(r.content);if(o===null)t.error(e.InvalidScopeDeclaration,`Invalid scope declaration '${r.content}' - expected 'scoped to <scope>'`,n(r));else if(i!==null)t.error(e.DuplicateScope,`Query '${a}' already declares a scope - results are narrowed one way`,n(r));else return o[1]}export{parseQuery};
|
|
2
2
|
//# sourceMappingURL=QueryParser.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s}from"./PropertyLineParser.js";import{parseAuthorize as c}from"./AuthorizeParser.js";import{parseFencedText as l}from"./CodeBlockParser.js";import{parseDescription as u}from"./DescriptionParser.js";import{parseGuardedAction as d}from"./GuardedActionParser.js";import{collectInputUses as f}from"./InputUses.js";import{isFileDirective as p}from"./FileReferences.js";import{parsePlainActionInput as m,parseSubjectClause as h}from"./ActionSubjectClause.js";import{isValidTemplateVersionRange as g,parseBlueprintReference as _,startsBlueprintReference as v}from"./TemplateReferenceText.js";import{parseFromClause as y}from"./UiBindingParser.js";const b=`(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,x=r(`^screen\\s+([A-Za-z_]\\w*)$`),S=r(`^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),C=r(`^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),w=r(`^label\\s+${b}$`),T=r(`^action\\s+${b}$`),E=r(`^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),D=r(`^route\\s+${b}$`),O=r(`^outlet\\s+([A-Za-z_]\\w*)$`),k=r(`^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$`),A=r(`^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),j=r(`^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$`),M=r(`^id\\s+(?:"(${t})"|(\\S+))$`),N=r(`^property\\s+([\\w.]+)\\s+from\\s+(.+)$`),P=r(`^property\\s+([\\w.]+)\\s*=\\s+(.+)$`),F=r(`^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),I=r(`^presentation\\s+([A-Za-z_]\\w*)\\s+${b}$`),L=r(`^confirm\\s+${b}$`),R=r(`^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),z=r(`^button\\s+(?:"(${t})"|([A-Za-z_][\\w-]*))(?:\\s+(.*))?$`),B=new RegExp(r(`\\s*(title|slice|emphasis|icon)\\s+(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*)|([A-Za-z_][\\w.-]*))(?=\\s|$)`).source,`uy`),V=r(`^[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$`),H=r(`^[a-z_]\\w*$`),U=r(`^title\\s+${b}$`),W=r(`^column\\s+([\\w.]+)(?:\\s+label\\s+${b})?$`),G=r(`^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$`),K=r(`^field\\s+([\\w.]+)\\s+label\\s+${b}$`),operandText=(e,t)=>e[t]===void 0?e[t+1]:n(e[t]),isInteraction=e=>[`on`,`uses`].includes(o(e.content)),isCodeLine=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseScreen(t,n){let r=x.exec(n.content);r===null&&t.error(e.InvalidScreenDeclaration,`Invalid screen declaration '${n.content}' - expected 'screen <Name>'`,i(n));let a=[],s=[],c=null;for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent))if(t.reader.takeSignificant(),o(e.content)===`contribute`){let n=parseScreenContribution(t,e);n!==void 0&&s.push(n)}else o(e.content)===`description`?c=u(t,e,c,`Screen '${r?.[1]??``}'`):p(e)||pushDirective(t,e,a);return{kind:`ScreenSyntax`,name:r?.[1]??``,directives:a,description:c,...s.length>0?{contributions:s}:{},location:i(n)}}function parseScreenContribution(t,n){let r=k.exec(n.content);if(r===null)t.error(e.UnknownScreenDirective,`Invalid screen contribution '${n.content}' - expected 'contribute to <Point> [order <n>]'`,i(n)),t.skipBlock(n.indent);else return{kind:`ScreenContributionSyntax`,contributionPoint:r[1],order:r[2]===void 0?null:Number(r[2]),directives:parseDirectives(t,n),location:i(n)}}function pushDirective(e,t,n){let r=parseDirective(e,t);r!==void 0&&n.push(r)}function parseDirectives(e,t){let n=[];for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),pushDirective(e,r,n);return n}function parseDirective(t,n){switch(validateNonActionSubjectClause(t,n),o(n.content)){case`data`:return parseData(t,n);case`action`:return parseAction(t,n);case`template`:return parseTemplateReference(t,n);case`section`:return parseSection(t,n);case`title`:return parseTitle(t,n);case`table`:return parseTable(t,n);case`summary`:return parseSummary(t,n);case`component`:return parseComponent(t,n);case`toolbar`:return parseToolbar(t,n);case`navigate`:return parseNavigate(t,n.content,n);case`on`:return f(t,n),{kind:`ScreenBehaviorSyntax`,location:i(n)};case`uses`:return f(t,n),{kind:`ScreenUsesBehaviorSyntax`,location:i(n)};default:if(isCodeLine(t,n))return parseCode(t,n);t.error(e.UnknownScreenDirective,`Unexpected '${n.content}' in screen body`,i(n)),t.skipBlock(n.indent);return}}function parseData(t,n){let r=S.exec(n.content);if(r===null)t.error(e.InvalidDataDirective,`Invalid data directive '${n.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,i(n));else return{kind:`ScreenDataSyntax`,type:s(r[1],i(n)),query:r[2],by:r[3]??null,location:i(n)}}function validateNonActionSubjectClause(e,t){let n=(/* @__PURE__ */ new Map([[`data`,S],[`navigate`,E],[`component`,j],[`title`,U]])).get(o(t.content));n!==void 0&&h(e,t,!1,e=>n.test(e))}function parseAction(e,t){let n=h(e,t,!0,e=>C.test(e)||T.test(e)),r=parseActionHeader(e,t,n);return r===void 0||n.subject===void 0?r:{...r,subject:n.subject}}function parseActionHeader(t,n,r){let a=T.exec(r.header);if(a!==null)return d(t,n,operandText(a,1),parseNavigate);let s=C.exec(r.header);if(s===null){t.error(e.InvalidActionDirective,`Invalid action directive '${n.content}' - expected 'action <Command>'`,i(n)),t.skipBlock(n.indent);return}let c=r.label??null,l=null,u=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=w.exec(r.content);n===null?o(r.content)===`navigate`?l=parseNavigate(t,r.content,r)??null:o(r.content)===`with`?addPlainActionInput(t,r,u):t.error(e.UnknownActionDirective,`Unexpected '${r.content}' in action - expected 'label "..."' or 'navigate to ...'`,i(r)):c=operandText(n,1)}return{kind:`ScreenActionSyntax`,command:s[1],label:c,navigate:l,...u.length===0?{}:{inputs:u},location:i(n)}}function addPlainActionInput(e,t,n){let r=m(e,t,n);r!==void 0&&n.push(r)}function parseNavigate(t,n,r){let a=E.exec(n);if(a===null){t.error(e.InvalidNavigation,`Invalid navigation '${n}' - expected 'navigate to <Screen> [by <param>]'`,i(r));return}let o=[],s=null,c=null;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){t.reader.takeSignificant();let r=A.exec(n.content);if(r!==null){o.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:y(t,r[2],i(n)),location:i(n)});continue}let a=D.exec(n.content);if(a!==null){s=operandText(a,1);continue}let l=O.exec(n.content);l===null?t.error(e.InvalidNavigation,`Unexpected '${n.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,i(n)):c=l[1]}return{kind:`ScreenNavigateSyntax`,screen:a[1],by:a[2]??null,route:s,...c===null?{}:{outlet:c},parameters:o,location:i(r)}}function parseTemplateReference(t,n){let r=n.content.substring(8).trim(),a=null,o=null;if(v(r)){let s=_(r);s===void 0?t.error(e.UnknownLayoutDirective,`Invalid template reference '${n.content}' - expected 'template <Name>' or 'template blueprint <Blueprint> <Name> [version "<range>"]'`,i(n)):({blueprint:a,name:r,version:o}=s,o!==null&&!g(o)&&t.error(e.InvalidTemplateVersionRange,`The template version range '${o}' is not one Scene understands - use '*', an exact version or a ^, ~, >=, >, <= or < range such as "^1.2"`,i(n)))}let s=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent))t.reader.takeSignificant(),H.test(a.content)?s.push({kind:`ScreenSlotSyntax`,name:a.content,directives:parseDirectives(t,a),location:i(a)}):(t.error(e.InvalidScreenLayoutSlot,`Expected a slot name in template '${r}', got '${a.content}'`,i(a)),t.skipBlock(a.indent));return{kind:`ScreenTemplateReferenceSyntax`,name:r,slots:s,...a===null?{}:{blueprint:a},...o===null?{}:{version:o},location:i(n)}}function parseSection(e,t){return{kind:`ScreenSectionSyntax`,name:t.content.substring(7).trim(),directives:parseDirectives(e,t),location:i(t)}}function parseTitle(t,n){let r=U.exec(n.content);return r===null?(t.error(e.InvalidTitleDirective,`Invalid title directive '${n.content}' - expected 'title "..."'`,i(n)),{kind:`ScreenTitleSyntax`,text:``,location:i(n)}):{kind:`ScreenTitleSyntax`,text:operandText(r,1),location:i(n)}}function parseTable(t,n){let r=n.content.substring(5).trim(),a=[],s=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=W.exec(r.content),c=G.exec(r.content);if(n!==null){let e=n[2]!==void 0||n[3]!==void 0;a.push({kind:`ScreenColumnSyntax`,property:n[1],label:e?operandText(n,2):null,location:i(r)})}else c===null?o(r.content)===`on`||isInteraction(r)?f(t,r):t.error(e.UnknownTableDirective,`Unexpected '${r.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,i(r)):s=parseNavigate(t,c[1],r)??null}return{kind:`ScreenTableSyntax`,target:r,columns:a,rowClick:s,location:i(n)}}function parseSummary(t,n){let r=n.content.substring(7).trim(),a=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=K.exec(r.content);n===null?t.error(e.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,i(r)):a.push({kind:`ScreenFieldSyntax`,property:n[1],label:operandText(n,2),location:i(r)})}return{kind:`ScreenSummarySyntax`,target:r,fields:a,location:i(n)}}function parseComponent(t,n){let r=j.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid component directive '${n.content}' - expected 'component <Package.Component> <name>'`,i(n)),t.skipBlock(n.indent);return}let a=null,s=null,c=null,l=[],u=[],d=[],p=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))switch(t.reader.takeSignificant(),o(r.content)){case`context`:a=parseUiContext(t,r);break;case`id`:s=parseStableId(t,r);break;case`property`:parseComponentProperty(t,r,l);break;case`icon`:c=r.content.substring(4).trim();break;case`presentation`:parsePresentationValue(t,r,d);break;case`exposes`:parseExposedValue(t,r,u);break;case`outlet`:p.push({kind:`ComponentOutletSyntax`,name:r.content.substring(6).trim(),directives:parseDirectives(t,r),location:i(r)});break;case`on`:f(t,r);break;case`uses`:f(t,r);break;default:t.error(e.UnknownScreenDirective,`Unexpected '${r.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,i(r)),t.skipBlock(r.indent)}return{kind:`ScreenComponentSyntax`,component:r[1],name:r[2],stableId:s,context:a,properties:l,exposes:u,presentation:d,icon:c,outlets:p,location:i(n)}}function parseUiContext(e,t){return parseUiBindingValue(e,t.content.substring(7).trim(),t)}function parseComponentProperty(t,n,r){let o=N.exec(n.content);if(o!==null){r.push({kind:`ComponentPropertySyntax`,property:o[1],binding:y(t,o[2],i(n)),value:null,location:i(n)});return}let s=P.exec(n.content);s===null?t.error(e.UnknownScreenDirective,`Invalid component property '${n.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,i(n)):r.push({kind:`ComponentPropertySyntax`,property:s[1],binding:null,value:a(s[2],i(n),t),location:i(n)})}function parseStableId(t,n){let r=M.exec(n.content);return r===null?(t.error(e.UnknownScreenDirective,`Invalid component id '${n.content}' - expected 'id "stable-id"'`,i(n)),null):operandText(r,1)}function parseExposedValue(t,n,r){let a=F.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid exposed value '${n.content}' - expected 'exposes <name> from <binding>'`,i(n)):r.push({kind:`ComponentExposedValueSyntax`,name:a[1],binding:y(t,a[2],i(n)),location:i(n)})}function parsePresentationValue(t,n,r){let a=I.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid presentation value '${n.content}' - expected 'presentation <key> "value"'`,i(n)):r.push({kind:`PresentationValueSyntax`,name:a[1],value:operandText(a,2),location:i(n)})}function parseToolbar(e,t){let n=t.content.substring(7).trim(),r=[],a=[];for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){if(e.reader.takeSignificant(),o(n.content)===`button`){let t=parseToolbarButton(e,n);t!==void 0&&a.push(t);continue}let t=parseToolbarItem(e,n);t!==void 0&&r.push(t)}return{kind:`ScreenToolbarSyntax`,name:n,items:r,...a.length>0?{buttons:a}:{},location:i(t)}}const q=`button <id> title "<text>" [slice <Module>.<Feature>.<Slice>] [emphasis primary|secondary|quiet] [icon <name>]`;function parseToolbarButton(t,r){let a=z.exec(r.content);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - expected ${q}`,i(r)),t.skipBlock(r.indent);return}let s=a[1]===void 0?a[2]:n(a[1]),l=a[3]??``,u,d,f,p,m=!0,h=0;for(;h<l.length;){B.lastIndex=h;let a=B.exec(l);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - unexpected '${l.substring(h).trim()}'; expected ${q}`,i(r)),m=!1;break}h=a.index+a[0].length;let o=a[1],c=a[2]!==void 0,g=a[3]!==void 0,_=c?n(a[2]):g?a[3]:a[4];(o===`title`?u!==void 0:o===`slice`?d!==void 0:o===`icon`?f!==void 0:p!==void 0)?t.error(e.InvalidToolbarButton,`Toolbar button '${s}' states '${o}' more than once`,i(r)):o===`title`?c||g?u=_:(t.error(e.InvalidToolbarButton,`Invalid title '${_}' on toolbar button '${s}' - expected a quoted string or a $strings.<key> token`,i(r)),m=!1):o===`slice`?!c&&!g&&V.test(_)?d=_:(t.error(e.InvalidToolbarButton,`Invalid slice '${_}' on toolbar button '${s}' - expected <Module>.<Feature>.<Slice>`,i(r)),m=!1):o===`emphasis`?!c&&!g&&[`primary`,`secondary`,`quiet`].includes(_)?p=_===`primary`?`Primary`:_===`secondary`?`Secondary`:`Quiet`:(t.error(e.InvalidToolbarButton,`Invalid emphasis '${_}' on toolbar button '${s}' - expected primary, secondary or quiet`,i(r)),m=!1):f=_}u===void 0&&m&&t.error(e.InvalidToolbarButton,`Toolbar button '${s}' has no title - expected 'button ${s} title "<text>"'`,i(r));let g=null,_;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){if(t.reader.takeSignificant(),o(n.content)===`authorize`&&g===null){g=c(t,n);continue}let r=_===void 0?L.exec(n.content):null;r===null?(t.error(e.InvalidToolbarButton,`Unexpected '${n.content}' under toolbar button '${s}' - a button takes one 'authorize' line, one 'confirm' line and nothing else`,i(n)),t.skipBlock(n.indent)):_=operandText(r,1)}return{kind:`ToolbarButtonSyntax`,id:s,title:u??``,...d===void 0?{}:{slice:d},...p===void 0?{}:{emphasis:p},...f===void 0?{}:{icon:f},...g===null?{}:{authorize:g},..._===void 0?{}:{confirm:_},location:i(r)}}function parseToolbarItem(t,n){let r=h(t,n,/^item\s+\S+\s+action\s/u.test(n.content),e=>R.test(e)),a=R.exec(r.header);if(a===null){t.error(e.UnknownScreenDirective,`Invalid toolbar item '${n.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>', 'item <name> dialog <DialogTemplate>' or 'button <id> title "<text>" slice <Slice>'`,i(n)),t.skipBlock(n.indent);return}let s=r.label??null,c=null,l,u=[],d=[];for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent)){t.reader.takeSignificant();let n=w.exec(e.content);if(n!==null){s=operandText(n,1);continue}let r=L.exec(e.content);if(r!==null){l=operandText(r,1);continue}let a=A.exec(e.content);a===null?o(e.content)===`icon`?c=e.content.substring(4).trim():parsePresentationValue(t,e,d):u.push({kind:`ScreenNavigationParameterSyntax`,name:a[1],binding:y(t,a[2],i(e)),location:i(e)})}let f=a[2]===`navigate`?`Navigate`:a[2]===`dialog`?`Dialog`:`Action`;return{kind:`ToolbarItemSyntax`,name:a[1],syntaxKind:f,target:a[3],label:s,icon:c,...r.subject===void 0?{}:{subject:r.subject},...l===void 0?{}:{confirm:l},parameters:u,presentation:d,location:i(n)}}function parseUiBindingValue(e,t,n){return y(e,t,i(n))}function parseCode(t,n){let r=n.content.startsWith("```")?n.content.substring(3):n.content;if(!t.languages.has(r)){t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${n.content}'`,i(n));return}n.content.startsWith("```")||t.warning(e.LegacyInlineCodeFence,`'${r}' on its own line is deprecated - use '\`\`\`${r}' instead`,i(n));let a=l(t,r,n);return a===null?void 0:{kind:`ScreenCodeSyntax`,code:{kind:`CodeBlockSyntax`,language:r,code:a,location:i(n)},location:i(n)}}export{parseScreen,parseToolbar};
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseAuthorize as a}from"./AuthorizeParser.js";import{parseMappingSource as o}from"./ExpressionParser.js";import{firstWord as s}from"./LineText.js";import{parseTypeRef as c}from"./PropertyLineParser.js";import{parseFencedText as l}from"./CodeBlockParser.js";import{parseDescription as u}from"./DescriptionParser.js";import{parseGuardedAction as d}from"./GuardedActionParser.js";import{collectInputUses as f}from"./InputUses.js";import{isFileDirective as p}from"./FileReferences.js";import{parsePlainActionInput as m,parseSubjectClause as h}from"./ActionSubjectClause.js";import{isValidTemplateVersionRange as g,parseBlueprintReference as _,startsBlueprintReference as v}from"./TemplateReferenceText.js";import{parseFromClause as y}from"./UiBindingParser.js";const b=`(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,x=r(`^screen\\s+([A-Za-z_]\\w*)$`),S=r(`^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),C=r(`^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),w=r(`^label\\s+${b}$`),T=r(`^action\\s+${b}$`),E=r(`^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),D=r(`^route\\s+${b}$`),O=r(`^outlet\\s+([A-Za-z_]\\w*)$`),k=r(`^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$`),A=r(`^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),j=r(`^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$`),M=r(`^id\\s+(?:"(${t})"|(\\S+))$`),N=r(`^property\\s+([\\w.]+)\\s+from\\s+(.+)$`),P=r(`^property\\s+([\\w.]+)\\s*=\\s+(.+)$`),F=r(`^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),I=r(`^presentation\\s+([A-Za-z_]\\w*)\\s+${b}$`),L=r(`^confirm\\s+${b}$`),R=r(`^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),z=r(`^button\\s+(?:"(${t})"|([A-Za-z_][\\w-]*))(?:\\s+(.*))?$`),B=new RegExp(r(`\\s*(title|slice|emphasis|icon)\\s+(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*)|([A-Za-z_][\\w.-]*))(?=\\s|$)`).source,`uy`),V=r(`^[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$`),H=r(`^[a-z_]\\w*$`),U=r(`^title\\s+${b}$`),W=r(`^column\\s+([\\w.]+)(?:\\s+label\\s+${b})?$`),G=r(`^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$`),K=r(`^field\\s+([\\w.]+)\\s+label\\s+${b}$`),operandText=(e,t)=>e[t]===void 0?e[t+1]:n(e[t]),isInteraction=e=>[`on`,`uses`].includes(s(e.content)),isCodeLine=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseScreen(t,n){let r=x.exec(n.content);r===null&&t.error(e.InvalidScreenDeclaration,`Invalid screen declaration '${n.content}' - expected 'screen <Name>'`,i(n));let a=[],o=[],c=null;for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent))if(t.reader.takeSignificant(),s(e.content)===`contribute`){let n=parseScreenContribution(t,e);n!==void 0&&o.push(n)}else s(e.content)===`description`?c=u(t,e,c,`Screen '${r?.[1]??``}'`):p(e)||pushDirective(t,e,a);return{kind:`ScreenSyntax`,name:r?.[1]??``,directives:a,description:c,...o.length>0?{contributions:o}:{},location:i(n)}}function parseScreenContribution(t,n){let r=k.exec(n.content);if(r===null)t.error(e.UnknownScreenDirective,`Invalid screen contribution '${n.content}' - expected 'contribute to <Point> [order <n>]'`,i(n)),t.skipBlock(n.indent);else return{kind:`ScreenContributionSyntax`,contributionPoint:r[1],order:r[2]===void 0?null:Number(r[2]),directives:parseDirectives(t,n),location:i(n)}}function pushDirective(e,t,n){let r=parseDirective(e,t);r!==void 0&&n.push(r)}function parseDirectives(e,t){let n=[];for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),pushDirective(e,r,n);return n}function parseDirective(t,n){switch(validateNonActionSubjectClause(t,n),s(n.content)){case`data`:return parseData(t,n);case`action`:return parseAction(t,n);case`template`:return parseTemplateReference(t,n);case`section`:return parseSection(t,n);case`title`:return parseTitle(t,n);case`table`:return parseTable(t,n);case`summary`:return parseSummary(t,n);case`component`:return parseComponent(t,n);case`toolbar`:return parseToolbar(t,n);case`navigate`:return parseNavigate(t,n.content,n);case`on`:return f(t,n),{kind:`ScreenBehaviorSyntax`,location:i(n)};case`uses`:return f(t,n),{kind:`ScreenUsesBehaviorSyntax`,location:i(n)};default:if(isCodeLine(t,n))return parseCode(t,n);t.error(e.UnknownScreenDirective,`Unexpected '${n.content}' in screen body`,i(n)),t.skipBlock(n.indent);return}}function parseData(t,n){let r=S.exec(n.content);if(r===null)t.error(e.InvalidDataDirective,`Invalid data directive '${n.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,i(n));else return{kind:`ScreenDataSyntax`,type:c(r[1],i(n)),query:r[2],by:r[3]??null,location:i(n)}}function validateNonActionSubjectClause(e,t){let n=(/* @__PURE__ */ new Map([[`data`,S],[`navigate`,E],[`component`,j],[`title`,U]])).get(s(t.content));n!==void 0&&h(e,t,!1,e=>n.test(e))}function parseAction(e,t){let n=h(e,t,!0,e=>C.test(e)||T.test(e)),r=parseActionHeader(e,t,n);return r===void 0||n.subject===void 0?r:{...r,subject:n.subject}}function parseActionHeader(t,n,r){let a=T.exec(r.header);if(a!==null)return d(t,n,operandText(a,1),parseNavigate);let o=C.exec(r.header);if(o===null){t.error(e.InvalidActionDirective,`Invalid action directive '${n.content}' - expected 'action <Command>'`,i(n)),t.skipBlock(n.indent);return}let c=r.label??null,l=null,u=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=w.exec(r.content);n===null?s(r.content)===`navigate`?l=parseNavigate(t,r.content,r)??null:s(r.content)===`with`?addPlainActionInput(t,r,u):t.error(e.UnknownActionDirective,`Unexpected '${r.content}' in action - expected 'label "..."' or 'navigate to ...'`,i(r)):c=operandText(n,1)}return{kind:`ScreenActionSyntax`,command:o[1],label:c,navigate:l,...u.length===0?{}:{inputs:u},location:i(n)}}function addPlainActionInput(e,t,n){let r=m(e,t,n);r!==void 0&&n.push(r)}function parseNavigate(t,n,r){let a=E.exec(n);if(a===null){t.error(e.InvalidNavigation,`Invalid navigation '${n}' - expected 'navigate to <Screen> [by <param>]'`,i(r));return}let o=[],s=null,c=null;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){t.reader.takeSignificant();let r=A.exec(n.content);if(r!==null){o.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:y(t,r[2],i(n)),location:i(n)});continue}let a=D.exec(n.content);if(a!==null){s=operandText(a,1);continue}let l=O.exec(n.content);l===null?t.error(e.InvalidNavigation,`Unexpected '${n.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,i(n)):c=l[1]}return{kind:`ScreenNavigateSyntax`,screen:a[1],by:a[2]??null,route:s,...c===null?{}:{outlet:c},parameters:o,location:i(r)}}function parseTemplateReference(t,n){let r=n.content.substring(8).trim(),a=null,o=null;if(v(r)){let s=_(r);s===void 0?t.error(e.UnknownLayoutDirective,`Invalid template reference '${n.content}' - expected 'template <Name>' or 'template blueprint <Blueprint> <Name> [version "<range>"]'`,i(n)):({blueprint:a,name:r,version:o}=s,o!==null&&!g(o)&&t.error(e.InvalidTemplateVersionRange,`The template version range '${o}' is not one Scene understands - use '*', an exact version or a ^, ~, >=, >, <= or < range such as "^1.2"`,i(n)))}let s=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent))t.reader.takeSignificant(),H.test(a.content)?s.push({kind:`ScreenSlotSyntax`,name:a.content,directives:parseDirectives(t,a),location:i(a)}):(t.error(e.InvalidScreenLayoutSlot,`Expected a slot name in template '${r}', got '${a.content}'`,i(a)),t.skipBlock(a.indent));return{kind:`ScreenTemplateReferenceSyntax`,name:r,slots:s,...a===null?{}:{blueprint:a},...o===null?{}:{version:o},location:i(n)}}function parseSection(e,t){return{kind:`ScreenSectionSyntax`,name:t.content.substring(7).trim(),directives:parseDirectives(e,t),location:i(t)}}function parseTitle(t,n){let r=U.exec(n.content);return r===null?(t.error(e.InvalidTitleDirective,`Invalid title directive '${n.content}' - expected 'title "..."'`,i(n)),{kind:`ScreenTitleSyntax`,text:``,location:i(n)}):{kind:`ScreenTitleSyntax`,text:operandText(r,1),location:i(n)}}function parseTable(t,n){let r=n.content.substring(5).trim(),a=[],o=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=W.exec(r.content),c=G.exec(r.content);if(n!==null){let e=n[2]!==void 0||n[3]!==void 0;a.push({kind:`ScreenColumnSyntax`,property:n[1],label:e?operandText(n,2):null,location:i(r)})}else c===null?s(r.content)===`on`||isInteraction(r)?f(t,r):t.error(e.UnknownTableDirective,`Unexpected '${r.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,i(r)):o=parseNavigate(t,c[1],r)??null}return{kind:`ScreenTableSyntax`,target:r,columns:a,rowClick:o,location:i(n)}}function parseSummary(t,n){let r=n.content.substring(7).trim(),a=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=K.exec(r.content);n===null?t.error(e.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,i(r)):a.push({kind:`ScreenFieldSyntax`,property:n[1],label:operandText(n,2),location:i(r)})}return{kind:`ScreenSummarySyntax`,target:r,fields:a,location:i(n)}}function parseComponent(t,n){let r=j.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid component directive '${n.content}' - expected 'component <Package.Component> <name>'`,i(n)),t.skipBlock(n.indent);return}let a=null,o=null,c=null,l=[],u=[],d=[],p=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))switch(t.reader.takeSignificant(),s(r.content)){case`context`:a=parseUiContext(t,r);break;case`id`:o=parseStableId(t,r);break;case`property`:parseComponentProperty(t,r,l);break;case`icon`:c=r.content.substring(4).trim();break;case`presentation`:parsePresentationValue(t,r,d);break;case`exposes`:parseExposedValue(t,r,u);break;case`outlet`:p.push({kind:`ComponentOutletSyntax`,name:r.content.substring(6).trim(),directives:parseDirectives(t,r),location:i(r)});break;case`on`:f(t,r);break;case`uses`:f(t,r);break;default:t.error(e.UnknownScreenDirective,`Unexpected '${r.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,i(r)),t.skipBlock(r.indent)}return{kind:`ScreenComponentSyntax`,component:r[1],name:r[2],stableId:o,context:a,properties:l,exposes:u,presentation:d,icon:c,outlets:p,location:i(n)}}function parseUiContext(e,t){return parseUiBindingValue(e,t.content.substring(7).trim(),t)}function parseComponentProperty(t,n,r){let a=N.exec(n.content);if(a!==null){r.push({kind:`ComponentPropertySyntax`,property:a[1],binding:y(t,a[2],i(n)),value:null,location:i(n)});return}let s=P.exec(n.content);s===null?t.error(e.UnknownScreenDirective,`Invalid component property '${n.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,i(n)):r.push({kind:`ComponentPropertySyntax`,property:s[1],binding:null,value:o(s[2],i(n),t),location:i(n)})}function parseStableId(t,n){let r=M.exec(n.content);return r===null?(t.error(e.UnknownScreenDirective,`Invalid component id '${n.content}' - expected 'id "stable-id"'`,i(n)),null):operandText(r,1)}function parseExposedValue(t,n,r){let a=F.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid exposed value '${n.content}' - expected 'exposes <name> from <binding>'`,i(n)):r.push({kind:`ComponentExposedValueSyntax`,name:a[1],binding:y(t,a[2],i(n)),location:i(n)})}function parsePresentationValue(t,n,r){let a=I.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid presentation value '${n.content}' - expected 'presentation <key> "value"'`,i(n)):r.push({kind:`PresentationValueSyntax`,name:a[1],value:operandText(a,2),location:i(n)})}function parseToolbar(e,t){let n=t.content.substring(7).trim(),r=[],a=[];for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){if(e.reader.takeSignificant(),s(n.content)===`button`){let t=parseToolbarButton(e,n);t!==void 0&&a.push(t);continue}let t=parseToolbarItem(e,n);t!==void 0&&r.push(t)}return{kind:`ScreenToolbarSyntax`,name:n,items:r,...a.length>0?{buttons:a}:{},location:i(t)}}const q=`button <id> title "<text>" [slice <Module>.<Feature>.<Slice>] [emphasis primary|secondary|quiet] [icon <name>]`;function parseToolbarButton(t,r){let o=z.exec(r.content);if(o===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - expected ${q}`,i(r)),t.skipBlock(r.indent);return}let c=o[1]===void 0?o[2]:n(o[1]),l=o[3]??``,u,d,f,p,m=!0,h=0;for(;h<l.length;){B.lastIndex=h;let a=B.exec(l);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - unexpected '${l.substring(h).trim()}'; expected ${q}`,i(r)),m=!1;break}h=a.index+a[0].length;let o=a[1],s=a[2]!==void 0,g=a[3]!==void 0,_=s?n(a[2]):g?a[3]:a[4];(o===`title`?u!==void 0:o===`slice`?d!==void 0:o===`icon`?f!==void 0:p!==void 0)?t.error(e.InvalidToolbarButton,`Toolbar button '${c}' states '${o}' more than once`,i(r)):o===`title`?s||g?u=_:(t.error(e.InvalidToolbarButton,`Invalid title '${_}' on toolbar button '${c}' - expected a quoted string or a $strings.<key> token`,i(r)),m=!1):o===`slice`?!s&&!g&&V.test(_)?d=_:(t.error(e.InvalidToolbarButton,`Invalid slice '${_}' on toolbar button '${c}' - expected <Module>.<Feature>.<Slice>`,i(r)),m=!1):o===`emphasis`?!s&&!g&&[`primary`,`secondary`,`quiet`].includes(_)?p=_===`primary`?`Primary`:_===`secondary`?`Secondary`:`Quiet`:(t.error(e.InvalidToolbarButton,`Invalid emphasis '${_}' on toolbar button '${c}' - expected primary, secondary or quiet`,i(r)),m=!1):f=_}u===void 0&&m&&t.error(e.InvalidToolbarButton,`Toolbar button '${c}' has no title - expected 'button ${c} title "<text>"'`,i(r));let g=null,_;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){if(t.reader.takeSignificant(),s(n.content)===`authorize`&&g===null){g=a(t,n);continue}let r=_===void 0?L.exec(n.content):null;r===null?(t.error(e.InvalidToolbarButton,`Unexpected '${n.content}' under toolbar button '${c}' - a button takes one 'authorize' line, one 'confirm' line and nothing else`,i(n)),t.skipBlock(n.indent)):_=operandText(r,1)}return{kind:`ToolbarButtonSyntax`,id:c,title:u??``,...d===void 0?{}:{slice:d},...p===void 0?{}:{emphasis:p},...f===void 0?{}:{icon:f},...g===null?{}:{authorize:g},..._===void 0?{}:{confirm:_},location:i(r)}}function parseToolbarItem(t,n){let r=h(t,n,/^item\s+\S+\s+action\s/u.test(n.content),e=>R.test(e)),a=R.exec(r.header);if(a===null){t.error(e.UnknownScreenDirective,`Invalid toolbar item '${n.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>', 'item <name> dialog <DialogTemplate>' or 'button <id> title "<text>" slice <Slice>'`,i(n)),t.skipBlock(n.indent);return}let o=r.label??null,c=null,l,u=[],d=[];for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent)){t.reader.takeSignificant();let n=w.exec(e.content);if(n!==null){o=operandText(n,1);continue}let r=L.exec(e.content);if(r!==null){l=operandText(r,1);continue}let a=A.exec(e.content);a===null?s(e.content)===`icon`?c=e.content.substring(4).trim():parsePresentationValue(t,e,d):u.push({kind:`ScreenNavigationParameterSyntax`,name:a[1],binding:y(t,a[2],i(e)),location:i(e)})}let f=a[2]===`navigate`?`Navigate`:a[2]===`dialog`?`Dialog`:`Action`;return{kind:`ToolbarItemSyntax`,name:a[1],syntaxKind:f,target:a[3],label:o,icon:c,...r.subject===void 0?{}:{subject:r.subject},...l===void 0?{}:{confirm:l},parameters:u,presentation:d,location:i(n)}}function parseUiBindingValue(e,t,n){return y(e,t,i(n))}function parseCode(t,n){let r=n.content.startsWith("```")?n.content.substring(3):n.content;if(!t.languages.has(r)){t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${n.content}'`,i(n));return}n.content.startsWith("```")||t.warning(e.LegacyInlineCodeFence,`'${r}' on its own line is deprecated - use '\`\`\`${r}' instead`,i(n));let a=l(t,r,n);return a===null?void 0:{kind:`ScreenCodeSyntax`,code:{kind:`CodeBlockSyntax`,language:r,code:a,location:i(n)},location:i(n)}}export{parseScreen,parseToolbar};
|
|
2
2
|
//# sourceMappingURL=ScreenParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DiagnosticCodes as e}from"./Diagnostics/DiagnosticCodes.js";import"./Parsing/checkPortableMatchPattern.js";import{unescapeString as t}from"./Text/StringLiteral.js";import{pattern as n}from"./Text/patterns.js";import{sourceLocation as r}from"./Diagnostics/SourceLocation.js";import{eventDeclarations as i}from"./Syntax/EventDeclarations.js";import{operationDeclarations as a}from"./Syntax/Operations.js";import{AuthoringProductionResolver as o}from"./Syntax/AuthoringProductionResolver.js";import{dependencySourcesOf as s}from"./Syntax/DependencySources.js";import{ScreenplaySyntaxWalker as c}from"./Syntax/ScreenplaySyntaxWalker.js";import{isExactNumberToken as l,parseExactNumber as u}from"./Syntax/ExactNumber.js";import{diagnosticKeyword as d,diagnosticText as f}from"./Diagnostics/DiagnosticArgument.js";import{EventSourceCatalog as p}from"./Syntax/EventSourceCatalog.js";import{implicitDestination as m,requiresExplicitDestinations as h}from"./Syntax/ProductionDestinations.js";import{InvalidExactNumber as g,canonicalExactText as _,exactIsIntegral as v}from"./Syntax/ExactMathFacts.js";import{responseCommandResolver as y}from"./Parsing/ResponseCommandResolver.js";import{synthesizePersonaCaller as b}from"./Syntax/PersonaCallers.js";import"./Syntax/SpecificationCaseOrigin.js";import"./Parsing/SpecificationCommandExamples.js";import{DeclaredDependencyTargets as x}from"./Dependencies/DeclaredDependencyTargets.js";import{describePlacement as S,documentPlacement as C,isDocumentPlacement as w,isWithinOrSame as T,samePlacement as E}from"./Files/PlayPlacement.js";import"./Syntax/InvalidSyntaxJson.js";import"./Syntax/SourceOptions.js";import{isSourceStreamName as D,isSourceStreamTypeName as O,sourceStreamPattern as k}from"./Text/SourceStreamNames.js";import{eventBodyReservedWords as A}from"./Text/ReservedWords.js";import{sliceTypes as j}from"./Syntax/Structure.js";import{consumedEvents as M,eventsSourceKind as N,fromSetting as P,isEventsSource as F}from"./Syntax/CaptureEventsSource.js";import{hasWildcard as I,matchesPlayPattern as L,normalizePlayPath as R,resolvePlayPattern as z,staticFolderOf as B}from"./Files/PlayGlob.js";import"./Files/AuthoredOrder.js";import{dependencyKinds as V}from"./Dependencies/DependencyKind.js";import{InvalidDependencyQuery as H}from"./Dependencies/InvalidDependencyQuery.js";import{SliceReferenceCollector as U,buildingReadModelReferences as W,referenceClassifications as G,sliceReferences as K}from"./Dependencies/SliceReferences.js";import{stronglyConnectedGroups as q}from"./Dependencies/StronglyConnectedGroups.js";import{DependencyGraph as J}from"./Dependencies/DependencyGraph.js";import{streamIdFailureMessage as Y,tryFormatInteger as X,tryFormatText as Z,tryFormatUuidText as Q}from"./Syntax/StreamIdFormatter.js";import"./ScreenActionSubjects.js";import{discoverImports as $,parseForAuthoring as ee}from"./ScreenplayCompiler.js";import{EventSourceReadConfidence as te}from"./Syntax/EventSourceReadConfidence.js";import"./Syntax/SyntaxJson.js";import{mergeDocuments as ne}from"./Files/PlayFolderMerge.js";import{inMemoryDocumentSource as re}from"./Files/PlayDocumentSource.js";import{resolveImports as ie}from"./Files/PlayImports.js";import"./Files/OrderingRoot.js";import{assembleApplication as ae,compileApplication as oe,parsePlacedDocuments as se}from"./Files/PlayApplicationAssembly.js";import{applyQuickFixEdits as ce,isQuickFixDiagnostic as le,legacyOptionalTypeLength as ue,prepareQuickFixes as de}from"./Authoring/QuickFixes.js";import"./Completeness/ModelCompleteness.js";import"./Dependencies/index.js";import"./Syntax/index.js";export{o as AuthoringProductionResolver,x as DeclaredDependencyTargets,J as DependencyGraph,e as DiagnosticCodes,p as EventSourceCatalog,te as EventSourceReadConfidence,H as InvalidDependencyQuery,g as InvalidExactNumber,c as ScreenplaySyntaxWalker,U as SliceReferenceCollector,ce as applyQuickFixEdits,ae as assembleApplication,W as buildingReadModelReferences,_ as canonicalExactText,oe as compileApplication,M as consumedEvents,V as dependencyKinds,s as dependencySourcesOf,S as describePlacement,d as diagnosticKeyword,f as diagnosticText,$ as discoverImports,C as documentPlacement,A as eventBodyReservedWords,i as eventDeclarations,N as eventsSourceKind,v as exactIsIntegral,P as fromSetting,I as hasWildcard,m as implicitDestination,re as inMemoryDocumentSource,w as isDocumentPlacement,F as isEventsSource,l as isExactNumberToken,le as isQuickFixDiagnostic,D as isSourceStreamName,O as isSourceStreamTypeName,T as isWithinOrSame,ue as legacyOptionalTypeLength,L as matchesPlayPattern,ne as mergeDocuments,R as normalizePlayPath,a as operationDeclarations,u as parseExactNumber,ee as parseForAuthoring,se as parsePlacedDocuments,n as pattern,de as prepareQuickFixes,G as referenceClassifications,h as requiresExplicitDestinations,ie as resolveImports,z as resolvePlayPattern,y as responseCommandResolver,E as samePlacement,K as sliceReferences,j as sliceTypes,r as sourceLocation,k as sourceStreamPattern,B as staticFolderOf,Y as streamIdFailureMessage,q as stronglyConnectedGroups,b as synthesizePersonaCaller,X as tryFormatInteger,Z as tryFormatText,Q as tryFormatUuidText,t as unescapeString};
|
|
1
|
+
import{DiagnosticCodes as e}from"./Diagnostics/DiagnosticCodes.js";import"./Parsing/checkPortableMatchPattern.js";import{unescapeString as t}from"./Text/StringLiteral.js";import{pattern as n}from"./Text/patterns.js";import{sourceLocation as r}from"./Diagnostics/SourceLocation.js";import{eventDeclarations as i}from"./Syntax/EventDeclarations.js";import{operationDeclarations as a}from"./Syntax/Operations.js";import{AuthoringProductionResolver as o}from"./Syntax/AuthoringProductionResolver.js";import{dependencySourcesOf as s}from"./Syntax/DependencySources.js";import{ScreenplaySyntaxWalker as c}from"./Syntax/ScreenplaySyntaxWalker.js";import{isExactNumberToken as l,parseExactNumber as u}from"./Syntax/ExactNumber.js";import{diagnosticKeyword as d,diagnosticText as f}from"./Diagnostics/DiagnosticArgument.js";import{EventSourceCatalog as p}from"./Syntax/EventSourceCatalog.js";import{implicitDestination as m,requiresExplicitDestinations as h}from"./Syntax/ProductionDestinations.js";import{InvalidExactNumber as g,canonicalExactText as _,exactIsIntegral as v}from"./Syntax/ExactMathFacts.js";import{responseCommandResolver as y}from"./Parsing/ResponseCommandResolver.js";import{synthesizePersonaCaller as b}from"./Syntax/PersonaCallers.js";import"./Syntax/SpecificationCaseOrigin.js";import"./Parsing/SpecificationCommandExamples.js";import{DeclaredDependencyTargets as x}from"./Dependencies/DeclaredDependencyTargets.js";import{describePlacement as S,documentPlacement as C,isDocumentPlacement as w,isWithinOrSame as T,samePlacement as E}from"./Files/PlayPlacement.js";import"./Syntax/InvalidSyntaxJson.js";import"./Syntax/SourceOptions.js";import{isSourceStreamName as D,isSourceStreamTypeName as O,sourceStreamPattern as k}from"./Text/SourceStreamNames.js";import{eventBodyReservedWords as A}from"./Text/ReservedWords.js";import{sliceTypes as j}from"./Syntax/Structure.js";import{consumedEvents as M,eventsSourceKind as N,fromSetting as P,isEventsSource as F}from"./Syntax/CaptureEventsSource.js";import{hasWildcard as I,matchesPlayPattern as L,normalizePlayPath as R,resolvePlayPattern as z,staticFolderOf as B}from"./Files/PlayGlob.js";import"./Files/AuthoredOrder.js";import{dependencyKinds as V}from"./Dependencies/DependencyKind.js";import{InvalidDependencyQuery as H}from"./Dependencies/InvalidDependencyQuery.js";import{SliceReferenceCollector as U,buildingReadModelReferences as W,referenceClassifications as G,sliceReferences as K}from"./Dependencies/SliceReferences.js";import{stronglyConnectedGroups as q}from"./Dependencies/StronglyConnectedGroups.js";import{DependencyGraph as J}from"./Dependencies/DependencyGraph.js";import{streamIdFailureMessage as Y,tryFormatInteger as X,tryFormatText as Z,tryFormatUuidText as Q}from"./Syntax/StreamIdFormatter.js";import"./ScreenActionSubjects.js";import"./Files/TimelineOrder.js";import{discoverImports as $,parseForAuthoring as ee}from"./ScreenplayCompiler.js";import{EventSourceReadConfidence as te}from"./Syntax/EventSourceReadConfidence.js";import"./Syntax/SyntaxJson.js";import{mergeDocuments as ne}from"./Files/PlayFolderMerge.js";import{inMemoryDocumentSource as re}from"./Files/PlayDocumentSource.js";import{resolveImports as ie}from"./Files/PlayImports.js";import"./Files/OrderingRoot.js";import{assembleApplication as ae,compileApplication as oe,parsePlacedDocuments as se}from"./Files/PlayApplicationAssembly.js";import{applyQuickFixEdits as ce,isQuickFixDiagnostic as le,legacyOptionalTypeLength as ue,prepareQuickFixes as de}from"./Authoring/QuickFixes.js";import"./Completeness/ModelCompleteness.js";import"./Dependencies/index.js";import"./Syntax/index.js";export{o as AuthoringProductionResolver,x as DeclaredDependencyTargets,J as DependencyGraph,e as DiagnosticCodes,p as EventSourceCatalog,te as EventSourceReadConfidence,H as InvalidDependencyQuery,g as InvalidExactNumber,c as ScreenplaySyntaxWalker,U as SliceReferenceCollector,ce as applyQuickFixEdits,ae as assembleApplication,W as buildingReadModelReferences,_ as canonicalExactText,oe as compileApplication,M as consumedEvents,V as dependencyKinds,s as dependencySourcesOf,S as describePlacement,d as diagnosticKeyword,f as diagnosticText,$ as discoverImports,C as documentPlacement,A as eventBodyReservedWords,i as eventDeclarations,N as eventsSourceKind,v as exactIsIntegral,P as fromSetting,I as hasWildcard,m as implicitDestination,re as inMemoryDocumentSource,w as isDocumentPlacement,F as isEventsSource,l as isExactNumberToken,le as isQuickFixDiagnostic,D as isSourceStreamName,O as isSourceStreamTypeName,T as isWithinOrSame,ue as legacyOptionalTypeLength,L as matchesPlayPattern,ne as mergeDocuments,R as normalizePlayPath,a as operationDeclarations,u as parseExactNumber,ee as parseForAuthoring,se as parsePlacedDocuments,n as pattern,de as prepareQuickFixes,G as referenceClassifications,h as requiresExplicitDestinations,ie as resolveImports,z as resolvePlayPattern,y as responseCommandResolver,E as samePlacement,K as sliceReferences,j as sliceTypes,r as sourceLocation,k as sourceStreamPattern,B as staticFolderOf,Y as streamIdFailureMessage,q as stronglyConnectedGroups,b as synthesizePersonaCaller,X as tryFormatInteger,Z as tryFormatText,Q as tryFormatUuidText,t as unescapeString};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import"./_virtual/_virtual/_rolldown/runtime.js";import{causedByProperties as e,contextRoots as t,identityProperties as n,primitiveTypes as r,sliceTypes as i}from"./language.js";import{DiagnosticCodes as a}from"./compiler/Diagnostics/DiagnosticCodes.js";import{legacyOptionalTypeLength as o}from"./compiler/Authoring/QuickFixes.js";import"./compiler/index.js";import{enclosingChain as s,fenceMap as c,indentOf as l}from"./document-context.js";import{eventAnalysisSource as u}from"./event-analysis-source.js";import{resolveEventContextPath as d}from"./event-context.js";import{responseAnalysis as f}from"./response-analysis.js";import{knownEventNames as p,knownTypeNames as m,mergeSymbols as h,propertyTypeReference as g,scanDocument as _,symbolsForBuffer as v}from"./symbols.js";import{diagnosticCodes as y}from"./diagnostic-codes.js";import{validateInlineEvents as b}from"./inline-event-validation.js";import{fileImportOn as x,isFileImportLine as S}from"./file-imports.js";function issue(e,t,n,r,i,a){return{severity:e,message:i,line:t,startColumn:n,endColumn:n+r,code:a}}function tokenIssue(e,t,n,r,i,a){return issue(e,t,n.indexOf(r)+1,r.length,i,a)}function validateDeclarations(e,t,n){let i=[],a=/* @__PURE__ */ new Set([...m(t,r),...m(n,[])]),checkProperties=(e,t)=>{for(let n of e.filter(e=>!a.has(g(e).name))){let e=g(n).name;i.push(issue(`warning`,n.line,n.sourceType.startColumn,n.sourceType.text.length,e===`optional`?`Unknown type 'optional' on '${n.name}' of ${t} — did you forget the type before 'optional'?`:`Unknown type '${e}' on '${n.name}' of ${t} — declare it with 'concept ${e} : <Primitive>' or 'type ${e}'.`,y.unknownType))}};for(let e of t.types)checkProperties(e.properties,`type '${e.name}'`);for(let e of t.events)checkProperties(e.properties,`event '${e.name}'`);for(let e of t.queries)checkProperties(e.parameters,`query '${e.name}'`);for(let n of t.commands){checkProperties(n.properties,`command '${n.name}'`);let t=n.properties.filter(e=>e.isIdentifier);for(let r of t.slice(1))i.push(tokenIssue(`error`,r.line,e[r.line],`identifier`,`Command '${n.name}' already marks '${t[0].name}' as identifier — only one property can be the identifier.`,y.duplicateCommandIdentifier))}let o=/* @__PURE__ */ new Map;for(let n of[...t.concepts,...t.types])o.get(n.name)===void 0?o.set(n.name,n.line):i.push(tokenIssue(`error`,n.line,e[n.line],n.name,`Duplicate declaration of '${n.name}' — concept and type names must be unique.`,y.duplicateDeclaration));return i}const C=/* @__PURE__ */ new Set([`and`,`or`,`not`]),w=/^(?:(?:and|or|not)\s+|\()*[A-Z]\w*\)*(?:\s+(?:(?:and|or|not)\s+|\()*[A-Z]\w*\)*)*$/;function policyNames(e){return(e.match(/[A-Za-z_]\w*/g)??[]).filter(e=>!C.has(e))}function validateLines(s,u={}){let d=c(s),m=_(s),g=u.application??h(),x=v(s,{...g,authoringPath:u.path??g.authoringPath,authoringPlacement:u.placement??g.authoringPlacement}),S=f(s,x.authoringDocuments??x.authoringSources?.filter(e=>e!==s.join(`
|
|
2
|
-
`)),x.authoringPlacement,x.authoringPath,x.authoringPlacementResolved),C=new Set(S.eventSources.routes.map(e=>e.location.line-1)),T={...m,commands:m.commands.map(e=>({...e,properties:e.properties.filter(e=>!C.has(e.line)),produces:e.produces?.filter(e=>!S.operationProductionLines?.has(e.line)),productionHeaders:e.productionHeaders?.filter(e=>!S.operationProductionLines?.has(e))}))},E=/* @__PURE__ */ new Set([...p(T),...p(g)]),D=new Set([...T.policies,...g.policies].map(e=>e.name)),O=validateDeclarations(s,T,g);O.push(...validateProductionDestinations(s,T));let k=/* @__PURE__ */ new Set([a.UnknownGenerationStrategy,a.InvalidGenerationArgument,a.InvalidGenerationModifier,a.DuplicateGenerationModifier,a.DuplicateGeneration,a.InvalidGenerationPrimitive,a.InvalidGenerationPrefix,a.InvalidGenerationAlphabet,a.InvalidTypeIdPrefix,a.GenerationSizeOutsideRange,a.ReservedSequenceGeneration,a.LowGenerationEntropy,a.LowGeneratedIdentifierEntropy,a.RefutedGeneratedConceptRule,a.UnprovenGeneratedConceptRule,a.GenerationSupportBudgetExceeded,a.EmptyGenerationSupport]),A=/* @__PURE__ */ new Set([a.MixedEnumerationNumbering,a.DuplicateEnumerationNumber,a.EnumerationNumberOutsideInt32,a.MalformedEnumerationNumber,a.UnpinnedStoredEnumeration]),j=/* @__PURE__ */ new Set([a.LegacyOptionalSuffix,a.InvalidOptionalModifierOrder,a.OptionalReadsNotSupported]),M=/* @__PURE__ */ new Set([a.UnexpectedTokenInPolicyCondition,a.ExpectedPolicyCondition,a.UnclosedPolicyConditionGroup,a.ExpectedRoleName,a.ExpectedClaimName,a.ExpectedClaimMatches,a.ExpectedClaimMatchTarget,a.AnonymousPolicyCombined,a.NegatedAnonymousPolicy]),N=/* @__PURE__ */ new Set([a.UnknownEvent,a.UnknownReadModelProperty,a.PiiNotSupportedOnIdentifier]),P=/* @__PURE__ */ new Set([a.EventFromLaterSlice,a.TimelineCycleGroup]),F=/* @__PURE__ */ new Set([a.UndeclaredDependency,a.UnusedDependencyDeclaration,a.InvalidDependencyTarget,a.RepeatedDependencyDeclaration,a.MutualDependencyDeclarations,a.AmbiguousReference]),I=/* @__PURE__ */ new Set([a.InvalidSpecificationInvocation,a.InvalidActionSubjectClause,a.InferredActionSubject,a.ChangedActionSubject,a.AmbiguousActionInputBinding,a.UnsupportedActionSubjectContext,a.InvalidTimeZoneDeclaration,a.InvalidCommandCalendar,a.InvalidSpecificationTimeZone,a.InvalidCommandReadsDeclaration,a.UnknownMatchPattern,a.InvalidMatchPattern,a.PatternOutsidePortableMatchDialect,a.AmbiguousMatchPattern,a.DeprecatedStudioTextRulePattern,a.MismatchedSpecificationQueryResult,a.DirectionlessTranslationReactsToOwnCapture,a.CaptureEventsFromSeveralOrigins,a.CaptureEventsKeyNotRequired,a.CaptureEventsRecordFixture,a.CaptureEventSourceKeyOutsideEvents,a.EventIdPinNotCarriedToRenderers,a.ResponseNameUsedOnFailure,a.InvalidEventDeclaration,a.InvalidImportDeclaration,a.InvalidSliceDeclaration,a.InvalidDescription,a.DuplicateDescription,a.EmptyDescription,a.DuplicateEventSubject,a.InvalidSubjectType,a.ProtectedSubjectType,a.InvalidSubjectOwner,a.ReadModelSubjectNotSupported,a.InvalidSubjectModifierOrder,a.UnsupportedInteractionAlternatives,a.MixedInteractionAlternatives,a.InteractionAlternativeWithoutActions,a.InlineInteractionAlternative,a.LegacyInteractionWhere,a.InvalidSpecificationParameter,a.InvalidSpecificationCase,a.DuplicateSpecificationParameter,a.DuplicateSpecificationCase,a.IncompleteSpecificationTable,a.InvalidSpecificationCaseAssignment,a.InvalidSpecificationCaseValue,a.InvalidSpecificationCaseReference,a.OptionalSpecificationParameterTarget,a.SpecificationCaseNameCollision,a.IncompatibleSpecificationParameterType,a.UnusedSpecificationParameter,a.SingularSpecificationTableExpansion,a.InvalidSpecificationCallerPersona,a.UnsynthesizablePersonaCaller,a.PersonaWithoutGate,a.GateWithoutPersona,a.AmbiguousPersonaCaller,a.InvalidDocumentation,a.ConflictingDocumentationAcrossFiles,a.InvalidAbsentReadModelStep,a.UnknownConstraintProperty,a.OmittedProductionDestination,a.InvalidSpecificationExample,a.DuplicateSpecificationAssignment,a.InvalidReactionBatchesDeclaration,a.DescribedCommandNotImplemented,a.DescribedCommandWithoutProductions,a.DescribedCommandCardinalityNotAdmitted,a.CommandHandlerRequiresAttachment,a.PendingIntentWithOtherHandler,a.DuplicateEventInProjectionScope,a.ReservedStoredName,a.ContextSourcedPerformedQueryArgument]),L=/* @__PURE__ */ new Set([a.InvalidPurposeDeclaration,a.InvalidPurposeVocabulary,a.DuplicatePurposeField,a.DuplicatePurposeDeclaration,a.UnknownPurpose,a.PurposeInterestMismatch,a.PersonalDataWithoutPurpose,a.SpecialDataWithoutCondition,a.CriminalDataWithoutAuthorization,a.PurposeWithoutBasis,a.UnusedPurpose,a.UnknownConceptDirective,a.AttributeReasonWithoutAttribute,a.DuplicateAttributeReason,a.LegacyComplianceMarker,a.DuplicateComplianceMarker,a.UnknownComplianceMarker,a.InvalidSecretScope,a.DuplicateSecretScope,a.SecretScopeIgnoredForPii,a.InvalidPersonalDataQualifier,a.DuplicateSpecialCategory]),R=/* @__PURE__ */ new Set,z=/* @__PURE__ */ new Set;for(let e of u.compilerDiagnostics??S.diagnostics){let t=e.code===a.UnknownType&&(S.identityDetails??[]).some(t=>t.line===e.location.line-1),n=e.code===a.InvalidSemanticBinding&&e.message.startsWith(`Read model '`)&&e.message.includes(`' references unsupported type '`);n&&z.add(e.location.line-1);let r=e.code===a.RepeatedSingularDeclarationAcrossFiles&&e.message.includes(`identity block`);if(!(e.code===a.DuplicateDeclaration&&e.message.startsWith(`Duplicate declaration of policy `))&&!t&&!n&&!r&&!k.has(e.code)&&!A.has(e.code)&&!L.has(e.code)&&!j.has(e.code)&&!M.has(e.code)&&!N.has(e.code)&&!P.has(e.code)&&!F.has(e.code)&&!I.has(e.code)&&e.code!==a.ReducerIdentityMismatch&&e.code!==a.InvalidSpecificationExampleBody&&e.code!==a.UnknownRuleImplementationDirective&&e.code!==a.InvalidValidationRule&&e.code!==a.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY054[7-9]$|^PLAY055[01]$|^PLAY048[2-9]$|^PLAY004[56]$|^PLAY053[0-9]$|^PLAY054[0-6]$|^PLAY034[1-8]$|^PLAY0557$|^PLAY060[7-9]$|^PLAY061[0-9]$|^PLAY0620$|^PLAY062[1-9]$|^PLAY063[0-9]$|^PLAY064[0-9]$|^PLAY065[0-2]$|^PLAY065[4-6]$|^PLAY066[0-6]$|^PLAY072[0-2]$/.test(e.code))continue;let i=e.location.line-1;if(e.code===a.OmittedProductionDestination&&O.some(t=>t.code===e.code&&t.line===i))continue;if(e.code===a.UnknownEvent){if(R.has(i))continue;R.add(i)}let c=o(s[i],e)||s[i].length-e.location.column+1;O.push(issue(e.severity,i,e.location.column,c,e.message,e.code))}let checkEvent=(e,t,n)=>{!E.has(n)&&!R.has(e)&&O.push(tokenIssue(`warning`,e,t,n,`Unknown event type '${n}' — declare it in a slice or import it.`,y.unknownEvent))},B=-1;for(let a=0;a<s.length;a++){let o=s[a],c=o.trim();if(d[a]||c.length===0)continue;let u=o.match(/^[ ]*(\t+)/);if(u&&O.push(issue(`warning`,a,u[0].length-u[1].length+1,u[1].length,`Screenplay is indentation-based — use spaces, not tabs.`,y.tabIndentation)),B>=0){if(l(o)>B&&w.test(c)){for(let e of policyNames(c))D.has(e)||O.push(tokenIssue(`warning`,a,o,e,`Unknown policy '${e}' — declare it with 'policy ${e}'.`,y.unknownPolicy));continue}B=-1}let f=validateImport(s,d,a);f&&O.push(f);let p=c.match(/^slice\s+(\w+)/);p&&!i.includes(p[1])&&O.push(tokenIssue(`error`,a,o,p[1],`Unknown slice type '${p[1]}' — expected ${i.join(`, `)}.`,y.unknownSliceType));let m=c.match(/^concept\s+\w+\s*:\s*(\w+)/);m&&m[1]!==`Enum`&&!r.includes(m[1])&&O.push(tokenIssue(`error`,a,o,m[1],`Unknown primitive type '${m[1]}' — expected ${r.join(`, `)} or Enum.`,y.unknownPrimitiveType));let h=c.match(/^authorize\s+(.*)$/);if(h){B=l(o);for(let e of policyNames(h[1]))D.has(e)||O.push(tokenIssue(`warning`,a,o,e,`Unknown policy '${e}' — declare it with 'policy ${e}'.`,y.unknownPolicy))}let g=c.match(/^on\s+([A-Z]\w*)\s*$/);g&&checkEvent(a,o,g[1]);let _=c.match(/^produces\s+([A-Z]\w*)\s*$/);if(_&&!S.operationProductionLines?.has(a)&&checkEvent(a,o,_[1]),/^produces\s+when\b/.test(c)&&!S.operationProductionLines?.has(a))for(let e=a+1;e<s.length;e++){let t=s[e];if(!(d[e]||t.trim().length===0)){if(l(t)>l(o)){let n=t.trim().match(/^([A-Z]\w*)\s*$/);n&&checkEvent(e,t,n[1])}break}}let v=c.match(/^unique\s+event\s+([A-Z]\w*)/);v&&checkEvent(a,o,v[1]);let b=c.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);b&&checkEvent(a,o,b[1]);for(let e of o.match(/\$identity\.[\w.]+/g)??[]){let t=e.substring(10).split(`.`)[0],r=[...n,...(S.identityDetails??[]).map(e=>e.name)];r.includes(t)||O.push(tokenIssue(`warning`,a,o,e,`Unknown $identity property '${t}' — expected ${r.join(`, `)}.`,y.unknownContextIdentityProperty))}for(let r of o.match(/\$context\.[\w.]+/g)??[]){let i=r.substring(9).split(`.`);t.includes(i[0])?i[0]===`causedBy`&&i.length>1&&!e.includes(i[1])?O.push(tokenIssue(`warning`,a,o,r,`Unknown $context.causedBy property '${i[1]}' — expected ${e.join(`, `)}.`,y.unknownContextCausedByProperty)):i[0]===`identity`&&i.length>1&&!n.includes(i[1])&&O.push(tokenIssue(`warning`,a,o,r,`Unknown $context.identity property '${i[1]}' — expected ${n.join(`, `)}.`,y.unknownContextIdentityProperty)):O.push(tokenIssue(`warning`,a,o,r,`Unknown $context path '${i.join(`.`)}' — expected one of ${t.join(`, `)}.`,y.unknownContextPath))}}O.push(...validateEventContextPaths(s,d)),O.push(...b(s,T,g,S.operationProductionLines));let V=s.map((e,t)=>({line:e,index:t})).filter(({line:e})=>/^\s*```(?:[a-z]+)?\s*$/.test(e));if(V.length%2==1){let e=V[V.length-1];O.push(issue(`error`,e.index,1,e.line.length+1,"Unclosed inline code block — expected a closing ``` line.",y.unclosedCodeBlock))}return O.filter(e=>e.code!==y.unknownType||!z.has(e.line))}function validateProductionDestinations(e,t){let n=[];e=u(e);for(let r of t.commands){let t=r.properties.filter(e=>e.isIdentifier&&!g(e).isOptional&&!g(e).isCollection);if(t.length===1)for(let i of r.produces??[]){if(i.inline||i.conditional||i.target!==void 0)continue;let r=i.line;n.push(issue(`information`,r,l(e[r])+1,e[r].trim().length,`Plain 'produces ${i.name}' omits its destination — use 'for ${t[0].name}' to explicitly select the command's identifier.`,y.omittedProductionDestination))}}return n}function validateImport(e,t,n){let r=e[n],i=r.trim().replace(/\s*\/\/.*$/,``);if(!/^import\b/.test(i)||x(r,n))return;let a=l(r);if(a>0&&[`module`,`feature`].includes(s(e,t,n,a)[0])||S(r))return issue(`error`,n,a+1,i.length,`Invalid import '${i}' — inside a module or feature, import names files: 'import "<path or glob>"'.`,y.invalidFileImport)}const T=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function validateEventContextPaths(e,t){let n=[],names=e=>e.map(e=>e.name).join(`, `);for(let r=0;r<e.length;r++){let i=e[r];if(t[r])continue;for(let e of i.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let t=e[0].substring(e[1]?.length??0),i=e[2];if(i.length===0){e[1]&&n.push(issue(`error`,r,(e.index??0)+2,t.length,`'$eventContext' names no member - expected one of ${names(d(``).expected)}.`,y.missingEventContextPath));continue}let a=i.substring(1),o=d(a),s=(e.index??0)+(e[1]?.length??0)+1;switch(o.status){case`missing`:n.push(issue(`error`,r,s,t.length,`'$eventContext.${a}' names no member - expected one of ${names(o.expected)}.`,y.missingEventContextPath));break;case`unknownMember`:n.push(issue(`warning`,r,s,t.length,`Unknown event context member '${o.segment}' in '$eventContext.${a}' - expected one of ${names(o.expected)}.`,y.unknownEventContextMember));break;case`unknownSubPath`:{let e=o.expected.length===0?`no members to address`:`members ${names(o.expected)}`;n.push(issue(`warning`,r,s,t.length,`Unknown event context path '$eventContext.${a}' - '${o.member?.name}' (${o.member?.type}) has ${e}.`,y.unknownEventContextPath));break}case`belowCollection`:n.push(issue(`error`,r,s,t.length,`'$eventContext.${a}' cannot resolve - '${o.member?.name}' is a collection (${o.member?.type}) and cannot be addressed below.`,y.eventContextPathBelowCollection))}}let a=i.trim().match(T)?.[1],o=a?.match(/\.\$(\w+)/)?.[1];a&&o&&o!==`eventContext`&&n.push(tokenIssue(`warning`,r,i,a,`Dynamic dictionary key '$${o}' in '${a}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${o}' becomes the key.`,y.unresolvedDynamicKeySource))}return n}export{validateEventContextPaths,validateLines};
|
|
2
|
+
`)),x.authoringPlacement,x.authoringPath,x.authoringPlacementResolved),C=new Set(S.eventSources.routes.map(e=>e.location.line-1)),T={...m,commands:m.commands.map(e=>({...e,properties:e.properties.filter(e=>!C.has(e.line)),produces:e.produces?.filter(e=>!S.operationProductionLines?.has(e.line)),productionHeaders:e.productionHeaders?.filter(e=>!S.operationProductionLines?.has(e))}))},E=/* @__PURE__ */ new Set([...p(T),...p(g)]),D=new Set([...T.policies,...g.policies].map(e=>e.name)),O=validateDeclarations(s,T,g);O.push(...validateProductionDestinations(s,T));let k=/* @__PURE__ */ new Set([a.UnknownGenerationStrategy,a.InvalidGenerationArgument,a.InvalidGenerationModifier,a.DuplicateGenerationModifier,a.DuplicateGeneration,a.InvalidGenerationPrimitive,a.InvalidGenerationPrefix,a.InvalidGenerationAlphabet,a.InvalidTypeIdPrefix,a.GenerationSizeOutsideRange,a.ReservedSequenceGeneration,a.LowGenerationEntropy,a.LowGeneratedIdentifierEntropy,a.RefutedGeneratedConceptRule,a.UnprovenGeneratedConceptRule,a.GenerationSupportBudgetExceeded,a.EmptyGenerationSupport]),A=/* @__PURE__ */ new Set([a.MixedEnumerationNumbering,a.DuplicateEnumerationNumber,a.EnumerationNumberOutsideInt32,a.MalformedEnumerationNumber,a.UnpinnedStoredEnumeration]),j=/* @__PURE__ */ new Set([a.LegacyOptionalSuffix,a.InvalidOptionalModifierOrder,a.OptionalReadsNotSupported]),M=/* @__PURE__ */ new Set([a.UnexpectedTokenInPolicyCondition,a.ExpectedPolicyCondition,a.UnclosedPolicyConditionGroup,a.ExpectedRoleName,a.ExpectedClaimName,a.ExpectedClaimMatches,a.ExpectedClaimMatchTarget,a.AnonymousPolicyCombined,a.NegatedAnonymousPolicy]),N=/* @__PURE__ */ new Set([a.UnknownEvent,a.UnknownReadModelProperty,a.PiiNotSupportedOnIdentifier]),P=/* @__PURE__ */ new Set([a.EventFromLaterSlice,a.TimelineCycleGroup]),F=/* @__PURE__ */ new Set([a.UndeclaredDependency,a.UnusedDependencyDeclaration,a.InvalidDependencyTarget,a.RepeatedDependencyDeclaration,a.MutualDependencyDeclarations,a.AmbiguousReference]),I=/* @__PURE__ */ new Set([a.InvalidSpecificationInvocation,a.InvalidActionSubjectClause,a.InferredActionSubject,a.ChangedActionSubject,a.AmbiguousActionInputBinding,a.UnsupportedActionSubjectContext,a.InvalidTimeZoneDeclaration,a.InvalidCommandCalendar,a.InvalidSpecificationTimeZone,a.InvalidCommandReadsDeclaration,a.UnknownMatchPattern,a.InvalidMatchPattern,a.PatternOutsidePortableMatchDialect,a.AmbiguousMatchPattern,a.DeprecatedStudioTextRulePattern,a.MismatchedSpecificationQueryResult,a.DirectionlessTranslationReactsToOwnCapture,a.CaptureEventsFromSeveralOrigins,a.CaptureEventsKeyNotRequired,a.CaptureEventsRecordFixture,a.CaptureEventSourceKeyOutsideEvents,a.EventIdPinNotCarriedToRenderers,a.ResponseNameUsedOnFailure,a.InvalidEventDeclaration,a.InvalidImportDeclaration,a.InvalidSliceDeclaration,a.InvalidDescription,a.DuplicateDescription,a.EmptyDescription,a.DuplicateEventSubject,a.InvalidSubjectType,a.ProtectedSubjectType,a.InvalidSubjectOwner,a.ReadModelSubjectNotSupported,a.InvalidSubjectModifierOrder,a.UnsupportedInteractionAlternatives,a.MixedInteractionAlternatives,a.InteractionAlternativeWithoutActions,a.InlineInteractionAlternative,a.LegacyInteractionWhere,a.InvalidSpecificationParameter,a.InvalidSpecificationCase,a.DuplicateSpecificationParameter,a.DuplicateSpecificationCase,a.IncompleteSpecificationTable,a.InvalidSpecificationCaseAssignment,a.InvalidSpecificationCaseValue,a.InvalidSpecificationCaseReference,a.OptionalSpecificationParameterTarget,a.SpecificationCaseNameCollision,a.IncompatibleSpecificationParameterType,a.UnusedSpecificationParameter,a.SingularSpecificationTableExpansion,a.InvalidSpecificationCallerPersona,a.UnsynthesizablePersonaCaller,a.PersonaWithoutGate,a.GateWithoutPersona,a.AmbiguousPersonaCaller,a.InvalidDocumentation,a.ConflictingDocumentationAcrossFiles,a.InvalidAbsentReadModelStep,a.UnknownConstraintProperty,a.OmittedProductionDestination,a.InvalidSpecificationExample,a.DuplicateSpecificationAssignment,a.InvalidReactionBatchesDeclaration,a.DescribedCommandNotImplemented,a.DescribedCommandWithoutProductions,a.DescribedCommandCardinalityNotAdmitted,a.CommandHandlerRequiresAttachment,a.PendingIntentWithOtherHandler,a.DuplicateEventInProjectionScope,a.ReservedStoredName,a.ContextSourcedPerformedQueryArgument,a.RedundantCompositeKeyBraces,a.ImplicitAuthorizationConjunction]),L=/* @__PURE__ */ new Set([a.InvalidPurposeDeclaration,a.InvalidPurposeVocabulary,a.DuplicatePurposeField,a.DuplicatePurposeDeclaration,a.UnknownPurpose,a.PurposeInterestMismatch,a.PersonalDataWithoutPurpose,a.SpecialDataWithoutCondition,a.CriminalDataWithoutAuthorization,a.PurposeWithoutBasis,a.UnusedPurpose,a.UnknownConceptDirective,a.AttributeReasonWithoutAttribute,a.DuplicateAttributeReason,a.LegacyComplianceMarker,a.DuplicateComplianceMarker,a.UnknownComplianceMarker,a.InvalidSecretScope,a.DuplicateSecretScope,a.SecretScopeIgnoredForPii,a.InvalidPersonalDataQualifier,a.DuplicateSpecialCategory]),R=/* @__PURE__ */ new Set,z=/* @__PURE__ */ new Set;for(let e of u.compilerDiagnostics??S.diagnostics){let t=e.code===a.UnknownType&&(S.identityDetails??[]).some(t=>t.line===e.location.line-1),n=e.code===a.InvalidSemanticBinding&&e.message.startsWith(`Read model '`)&&e.message.includes(`' references unsupported type '`);n&&z.add(e.location.line-1);let r=e.code===a.RepeatedSingularDeclarationAcrossFiles&&e.message.includes(`identity block`);if(!(e.code===a.DuplicateDeclaration&&e.message.startsWith(`Duplicate declaration of policy `))&&!t&&!n&&!r&&!k.has(e.code)&&!A.has(e.code)&&!L.has(e.code)&&!j.has(e.code)&&!M.has(e.code)&&!N.has(e.code)&&!P.has(e.code)&&!F.has(e.code)&&!I.has(e.code)&&e.code!==a.ReducerIdentityMismatch&&e.code!==a.InvalidSpecificationExampleBody&&e.code!==a.UnknownRuleImplementationDirective&&e.code!==a.InvalidValidationRule&&e.code!==a.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY054[7-9]$|^PLAY055[01]$|^PLAY048[2-9]$|^PLAY004[56]$|^PLAY053[0-9]$|^PLAY054[0-6]$|^PLAY034[1-8]$|^PLAY0557$|^PLAY060[7-9]$|^PLAY061[0-9]$|^PLAY0620$|^PLAY062[1-9]$|^PLAY063[0-9]$|^PLAY064[0-9]$|^PLAY065[0-2]$|^PLAY065[4-6]$|^PLAY066[0-6]$|^PLAY072[0-2]$/.test(e.code))continue;let i=e.location.line-1;if(e.code===a.OmittedProductionDestination&&O.some(t=>t.code===e.code&&t.line===i))continue;if(e.code===a.UnknownEvent){if(R.has(i))continue;R.add(i)}let c=o(s[i],e)||s[i].length-e.location.column+1;O.push(issue(e.severity,i,e.location.column,c,e.message,e.code))}let checkEvent=(e,t,n)=>{!E.has(n)&&!R.has(e)&&O.push(tokenIssue(`warning`,e,t,n,`Unknown event type '${n}' — declare it in a slice or import it.`,y.unknownEvent))},B=-1;for(let a=0;a<s.length;a++){let o=s[a],c=o.trim();if(d[a]||c.length===0)continue;let u=o.match(/^[ ]*(\t+)/);if(u&&O.push(issue(`warning`,a,u[0].length-u[1].length+1,u[1].length,`Screenplay is indentation-based — use spaces, not tabs.`,y.tabIndentation)),B>=0){if(l(o)>B&&w.test(c)){for(let e of policyNames(c))D.has(e)||O.push(tokenIssue(`warning`,a,o,e,`Unknown policy '${e}' — declare it with 'policy ${e}'.`,y.unknownPolicy));continue}B=-1}let f=validateImport(s,d,a);f&&O.push(f);let p=c.match(/^slice\s+(\w+)/);p&&!i.includes(p[1])&&O.push(tokenIssue(`error`,a,o,p[1],`Unknown slice type '${p[1]}' — expected ${i.join(`, `)}.`,y.unknownSliceType));let m=c.match(/^concept\s+\w+\s*:\s*(\w+)/);m&&m[1]!==`Enum`&&!r.includes(m[1])&&O.push(tokenIssue(`error`,a,o,m[1],`Unknown primitive type '${m[1]}' — expected ${r.join(`, `)} or Enum.`,y.unknownPrimitiveType));let h=c.match(/^authorize\s+(.*)$/);if(h){B=l(o);for(let e of policyNames(h[1]))D.has(e)||O.push(tokenIssue(`warning`,a,o,e,`Unknown policy '${e}' — declare it with 'policy ${e}'.`,y.unknownPolicy))}let g=c.match(/^on\s+([A-Z]\w*)\s*$/);g&&checkEvent(a,o,g[1]);let _=c.match(/^produces\s+([A-Z]\w*)\s*$/);if(_&&!S.operationProductionLines?.has(a)&&checkEvent(a,o,_[1]),/^produces\s+when\b/.test(c)&&!S.operationProductionLines?.has(a))for(let e=a+1;e<s.length;e++){let t=s[e];if(!(d[e]||t.trim().length===0)){if(l(t)>l(o)){let n=t.trim().match(/^([A-Z]\w*)\s*$/);n&&checkEvent(e,t,n[1])}break}}let v=c.match(/^unique\s+event\s+([A-Z]\w*)/);v&&checkEvent(a,o,v[1]);let b=c.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);b&&checkEvent(a,o,b[1]);for(let e of o.match(/\$identity\.[\w.]+/g)??[]){let t=e.substring(10).split(`.`)[0],r=[...n,...(S.identityDetails??[]).map(e=>e.name)];r.includes(t)||O.push(tokenIssue(`warning`,a,o,e,`Unknown $identity property '${t}' — expected ${r.join(`, `)}.`,y.unknownContextIdentityProperty))}for(let r of o.match(/\$context\.[\w.]+/g)??[]){let i=r.substring(9).split(`.`);t.includes(i[0])?i[0]===`causedBy`&&i.length>1&&!e.includes(i[1])?O.push(tokenIssue(`warning`,a,o,r,`Unknown $context.causedBy property '${i[1]}' — expected ${e.join(`, `)}.`,y.unknownContextCausedByProperty)):i[0]===`identity`&&i.length>1&&!n.includes(i[1])&&O.push(tokenIssue(`warning`,a,o,r,`Unknown $context.identity property '${i[1]}' — expected ${n.join(`, `)}.`,y.unknownContextIdentityProperty)):O.push(tokenIssue(`warning`,a,o,r,`Unknown $context path '${i.join(`.`)}' — expected one of ${t.join(`, `)}.`,y.unknownContextPath))}}O.push(...validateEventContextPaths(s,d)),O.push(...b(s,T,g,S.operationProductionLines));let V=s.map((e,t)=>({line:e,index:t})).filter(({line:e})=>/^\s*```(?:[a-z]+)?\s*$/.test(e));if(V.length%2==1){let e=V[V.length-1];O.push(issue(`error`,e.index,1,e.line.length+1,"Unclosed inline code block — expected a closing ``` line.",y.unclosedCodeBlock))}return O.filter(e=>e.code!==y.unknownType||!z.has(e.line))}function validateProductionDestinations(e,t){let n=[];e=u(e);for(let r of t.commands){let t=r.properties.filter(e=>e.isIdentifier&&!g(e).isOptional&&!g(e).isCollection);if(t.length===1)for(let i of r.produces??[]){if(i.inline||i.conditional||i.target!==void 0)continue;let r=i.line;n.push(issue(`information`,r,l(e[r])+1,e[r].trim().length,`Plain 'produces ${i.name}' omits its destination — use 'for ${t[0].name}' to explicitly select the command's identifier.`,y.omittedProductionDestination))}}return n}function validateImport(e,t,n){let r=e[n],i=r.trim().replace(/\s*\/\/.*$/,``);if(!/^import\b/.test(i)||x(r,n))return;let a=l(r);if(a>0&&[`module`,`feature`].includes(s(e,t,n,a)[0])||S(r))return issue(`error`,n,a+1,i.length,`Invalid import '${i}' — inside a module or feature, import names files: 'import "<path or glob>"'.`,y.invalidFileImport)}const T=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function validateEventContextPaths(e,t){let n=[],names=e=>e.map(e=>e.name).join(`, `);for(let r=0;r<e.length;r++){let i=e[r];if(t[r])continue;for(let e of i.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let t=e[0].substring(e[1]?.length??0),i=e[2];if(i.length===0){e[1]&&n.push(issue(`error`,r,(e.index??0)+2,t.length,`'$eventContext' names no member - expected one of ${names(d(``).expected)}.`,y.missingEventContextPath));continue}let a=i.substring(1),o=d(a),s=(e.index??0)+(e[1]?.length??0)+1;switch(o.status){case`missing`:n.push(issue(`error`,r,s,t.length,`'$eventContext.${a}' names no member - expected one of ${names(o.expected)}.`,y.missingEventContextPath));break;case`unknownMember`:n.push(issue(`warning`,r,s,t.length,`Unknown event context member '${o.segment}' in '$eventContext.${a}' - expected one of ${names(o.expected)}.`,y.unknownEventContextMember));break;case`unknownSubPath`:{let e=o.expected.length===0?`no members to address`:`members ${names(o.expected)}`;n.push(issue(`warning`,r,s,t.length,`Unknown event context path '$eventContext.${a}' - '${o.member?.name}' (${o.member?.type}) has ${e}.`,y.unknownEventContextPath));break}case`belowCollection`:n.push(issue(`error`,r,s,t.length,`'$eventContext.${a}' cannot resolve - '${o.member?.name}' is a collection (${o.member?.type}) and cannot be addressed below.`,y.eventContextPathBelowCollection))}}let a=i.trim().match(T)?.[1],o=a?.match(/\.\$(\w+)/)?.[1];a&&o&&o!==`eventContext`&&n.push(tokenIssue(`warning`,r,i,a,`Dynamic dictionary key '$${o}' in '${a}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${o}' becomes the key.`,y.unresolvedDynamicKeySource))}return n}export{validateEventContextPaths,validateLines};
|
|
3
3
|
//# sourceMappingURL=validation.js.map
|