@cratis/screenplay-language 4.181.0 → 4.182.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/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/Files/PlayFolderMerge.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js +2 -0
- package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js.map +1 -0
- package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
- package/dist/bundles/compiler/ScreenplayCompiler.js +1 -1
- package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -1
- package/dist/bundles/completion-planner.js +1 -1
- package/dist/bundles/completion-planner.js.map +1 -1
- package/dist/bundles/diagnostic-codes.js +1 -1
- package/dist/bundles/diagnostic-codes.js.map +1 -1
- package/dist/bundles/hover-content.js +1 -1
- package/dist/bundles/hover-content.js.map +1 -1
- package/dist/bundles/validation.js +1 -1
- package/dist/bundles/validation.js.map +1 -1
- package/dist/diagnostic-codes.d.ts +4 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandParser.js","names":["header","pattern","routeHeader","sourceStreamPattern","severityPattern","messagePattern","stringBodyPattern","rulePattern","operandPattern","ruleNamePattern","optionalReads","operandKinds","severities","opaqueDirectives","propertyShapedDirectives","names","lookahead","ParserContext","context","line","name","DiagnosticCodes","locationOf","properties","responses","identifier","validations","produces","reads","referenceReads","concurrency","description","documentation","authorize","handler","stream","streamCandidates","child","keyword","firstWord","asProperty","tryParseProperty","scalar","scalarResponsePattern","responseNames","parseCommandResponse","reportInvalidModifierOrder","source","streamName","ambiguous","route","parseCommandStream","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","combineAuthorize","parseAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","candidates","entry","property","discoveredNames","response","removed","parsed","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","unescapeString","rule","checksum","valueContext","withSeverity","match","body","wrapped","commandOwner","parseImplementationWrapper","isFile","parseFile","isCode","extra","content","text","algorithm","operand","parseMappingSource"],"sources":["../../../../../../Compiler/Parsing/CommandParser.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 { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { parseCondition } from './ConditionParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { CommandStreamSyntax } from '../Syntax/EventSources';\nimport { parseCommandStream } from './EventSourceParser';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { ProducesSyntax } from '../Syntax/Reactions';\nimport { CommandResponseSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseCommandResponse, scalarResponsePattern } from './CommandResponseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { isCode, isFile, parseCode, parseFile, parseHandler, parseImplementationWrapper } from './ImplementationParser';\nimport { CodeBlockSyntax, FileReferenceSyntax, HandlerSyntax, ImplementationSyntax } from '../Syntax/Implementations';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { isReactionIdentityLine, misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { commandReadSources } from './CommandReadSources';\nimport { dependencySources, ReadsSyntax, ConcurrencySyntax } from '../Syntax/DependencySources';\nimport { captureConcurrency } from './DependencySourceParser';\nimport { parseReads } from './ReadsParser';\nimport { parseProduces } from './ProducesParser';\nimport { reportInvalidModifierOrder, reportLegacyOptionalSuffix, tryParseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\\\s*(.*)$');\nconst ruleNamePattern = sourceStreamPattern('^[A-Za-z_]\\\\w*$');\nconst optionalReads = pattern('^reads\\\\s+[A-Z]\\\\w*\\\\s+optional(?:\\\\s|$)');\n\n// Every operand the pattern matches has a kind, so an operand never goes unrecognized here.\nconst operandKinds: Record<string, ValidationRuleKind> = {\n max: 'Max',\n min: 'Min',\n '>': 'GreaterThan',\n '>=': 'GreaterThanOrEqual',\n '<': 'LessThan',\n '<=': 'LessThanOrEqual',\n '==': 'Equal',\n '!=': 'NotEqual',\n 'length ==': 'Length',\n matches: 'Matches',\n 'all >': 'AllGreaterThan',\n 'all >=': 'AllGreaterThanOrEqual',\n};\n\nconst severities: Record<string, ValidationSeverity> = { information: 'Information', warning: 'Warning', error: 'Error' };\n\n// Command directives this compiler does not model. They are skipped whole.\nconst opaqueDirectives = new Set(['reads', 'concurrency']);\n\n// The bare directives cannot take a type reference, so a line with property shape is a property whatever\n// keyword it starts with - 'description String' declares a property called description.\nconst propertyShapedDirectives = new Set(['description', 'documentation', 'handler', 'concurrency']);\n\nexport function parseCommand(context: ParserContext, line: SourceLine): CommandSyntax {\n // Properties are leaves, not indentation owners. Resolve ambiguous returns spelling\n // before the committed pass decides whether its deeper lines belong to a response.\n const names = new Set<string>();\n const lookahead = new ParserContext(context.reader.fork(), context.path, context.languages);\n lookahead.sourceOptions = context.sourceOptions;\n lookahead.streamCandidates = context.streamCandidates;\n parseCommandBody(lookahead, line, undefined, names);\n return parseCommandBody(context, line, names);\n}\n\nfunction parseCommandBody(context: ParserContext, line: SourceLine, responseNames?: ReadonlySet<string>, discoveredNames?: Set<string>): CommandSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidCommandDeclaration, `Invalid command declaration '${line.content}' - expected 'command <Name>'`, locationOf(line));\n }\n const properties: PropertySyntax[] = [];\n const responses: { line: SourceLine; candidate: PropertySyntax | null; response: CommandResponseSyntax | null }[] = [];\n let identifier: PropertySyntax | undefined;\n const validations: ValidateSyntax[] = [];\n const produces: ProducesSyntax[] = [];\n const reads: { readModel: string; alias: string | null }[] = [];\n const referenceReads: ReadsSyntax[] = [];\n let concurrency: ConcurrencySyntax | undefined;\n let description: string | null = null;\n let documentation: string | null = null;\n let authorize: AuthorizeSyntax | null = null;\n let handler: HandlerSyntax | null = null;\n let stream: CommandStreamSyntax | null = null;\n const streamCandidates: CommandStreamSyntax[] = [];\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 const asProperty = tryParseProperty(child);\n if (asProperty !== undefined && (propertyShapedDirectives.has(keyword) || (keyword === 'validate' && child.content !== 'validate csharp'))) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (keyword === 'returns') {\n const scalar = scalarResponsePattern.exec(child.content);\n if (scalar !== null && !scalar[1].startsWith('@') && asProperty !== undefined) {\n if (responseNames === undefined) {\n properties.push(asProperty);\n responses.push({ line: child, candidate: asProperty, response: null });\n } else if (responseNames.has(asProperty.type.name)) {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n } else {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n }\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (reportInvalidModifierOrder(context, child)) {\n context.skipBlock(child.indent);\n } else {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n }\n } else if (keyword === 'stream' && routeHeader.test(child.content) && asProperty !== undefined && context.streamCandidates?.hasSource(asProperty.type.name.split('.')[0]) === true) {\n const [source, streamName] = asProperty.type.name.split('.');\n const ambiguous = context.streamCandidates.hasPropertyType(asProperty.type.name) && context.streamCandidates.hasUniqueStream(source, streamName);\n const route = parseCommandStream(context, child, asProperty, ambiguous);\n if (stream !== null || streamCandidates.length > 0) context.error(DiagnosticCodes.InvalidCommandStream, 'A command declares at most one stream route.', locationOf(child));\n if (ambiguous || stream !== null) streamCandidates.push(route);\n else stream = route;\n } else if (keyword === 'runs' && isReactionIdentityLine(child)) {\n misplacedReactionIdentity(context, child);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Command '${name}'`);\n } else if (keyword === 'documentation') {\n documentation = parseDocumentation(context, child, documentation, `Command '${name}'`);\n } else if (keyword === 'authorize') {\n authorize = combineAuthorize(authorize, parseAuthorize(context, child));\n } else if (keyword === 'validate') {\n const validate = parseValidate(context, child, 'command');\n if (validate !== undefined) {\n validations.push(validate);\n }\n } else if (keyword === 'produces') {\n const production = parseProduces(context, child, true);\n if (production !== undefined) produces.push(production);\n } else if (keyword === 'handler') {\n handler = parseHandler(context, child);\n } else if (opaqueDirectives.has(keyword)) {\n const reference = keyword === 'reads' ? parseReads(context, child) : undefined;\n if (reference !== undefined) referenceReads.push(reference);\n if (keyword === 'concurrency' && concurrency === undefined) concurrency = captureConcurrency(context, child);\n const read = /^reads\\s+([A-Z]\\w*)(?:\\s+as\\s+([a-z_]\\w*))?(?:\\s+by\\s+([a-z_]\\w*))?$/.exec(child.content);\n if (read !== null) reads.push({ readModel: read[1], alias: read[2] ?? null });\n if (optionalReads.test(child.content)) {\n context.error(DiagnosticCodes.OptionalReadsNotSupported, 'Optional reads are not yet supported (see #308).', locationOf(child));\n }\n context.skipOpaqueBlock(child.indent);\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else {\n reportInvalidModifierOrder(context, child);\n context.error(DiagnosticCodes.UnknownCommandDirective, `Unexpected '${child.content}' in command body`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n const candidates = new Set(responses.flatMap(entry => entry.candidate === null ? [] : [entry.candidate]));\n const names = new Set(properties.filter(property => !candidates.has(property)).map(property => property.name));\n if (responses.some(entry => entry.candidate !== null && !names.has(entry.candidate.type.name) && entry.candidate.type.name !== 'returns')) names.add('returns');\n for (const name of names) discoveredNames?.add(name);\n let response: CommandResponseSyntax | null = null;\n const removed = new Set<PropertySyntax>();\n for (const entry of responses) {\n let parsed = entry.response;\n if (entry.candidate !== null) {\n if (!names.has(entry.candidate.type.name)) continue;\n removed.add(entry.candidate);\n parsed = { kind: 'ScalarCommandResponseSyntax', source: { kind: 'PropertyResponseSourceSyntax', property: entry.candidate.type.name, location: entry.candidate.type.location }, location: locationOf(entry.line) };\n }\n if (parsed === null) continue;\n if (response !== null) {\n context.error(DiagnosticCodes.InvalidCommandResponse, 'A command declares at most one unconditional response.', locationOf(entry.line));\n } else {\n response = parsed;\n }\n }\n if (handler !== null && produces.length > 0) {\n context.error(DiagnosticCodes.CommandWithProducesAndHandler, `Command '${name}' cannot declare both 'produces' and 'handler'`, locationOf(line));\n }\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, location: locationOf(line) };\n commandReadSources.set(syntax, reads);\n dependencySources.set(syntax, { reads: referenceReads, concurrency });\n return syntax;\n}\n\nfunction addProperty(context: ParserContext, properties: PropertySyntax[], property: PropertySyntax, commandName: string, line: SourceLine, identifier: PropertySyntax | undefined): PropertySyntax | undefined {\n reportLegacyOptionalSuffix(context, property.type, line);\n if (property.isIdentifier && identifier !== undefined) {\n context.error(DiagnosticCodes.DuplicateCommandIdentifier, `Command '${commandName}' already marks '${identifier.name}' as identifier - only one property can be the identifier`, property.location);\n property = { ...property, isIdentifier: false };\n }\n properties.push(property);\n return identifier ?? (property.isIdentifier ? property : undefined);\n}\n\n// Reads a 'validate' block: declarative rules, or code - which is recognized but not modeled.\nexport function parseValidate(context: ParserContext, line: SourceLine, owner: 'command' | 'concept'): ValidateSyntax | undefined {\n if (line.content === 'validate') {\n const fence = context.peekChild(line.indent);\n if (fence !== undefined && fence.content.startsWith('```')) {\n context.reader.takeSignificant();\n const code = parseCode(context.valueContext, fence);\n if (code === null) context.skipFencedBody();\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n const rules: ValidationRuleSyntax[] = [];\n const requirements: RequirementSyntax[] = [];\n let wrapperIndent: number | undefined;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (owner === 'concept') {\n if (context.sourceOptions.numericMode === 'legacy' && child.content.startsWith('```')) { context.skipFencedBody(); continue; }\n if (wrapperIndent !== undefined && child.indent <= wrapperIndent) wrapperIndent = undefined;\n if (wrapperIndent !== undefined || firstWord(child.content) === 'implementation') {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${child.content}'`, locationOf(child));\n wrapperIndent ??= child.indent;\n continue;\n }\n }\n if (firstWord(child.content) === 'require') {\n const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child));\n let message: string | null = null;\n let severity: ValidationSeverity = 'Error';\n let hasSeverity = false;\n for (let directive = context.peekChild(child.indent); directive !== undefined; directive = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const matched = messagePattern.exec(directive.content);\n if (matched !== null && matched.index === 0) message = matched[1] !== undefined ? unescapeString(matched[1]) : matched[2];\n else if (firstWord(directive.content) === 'severity') {\n if (!hasSeverity) severity = severities[directive.content.substring('severity'.length).trim()] ?? 'Error';\n hasSeverity = true;\n } else context.skipOpaqueBlock(directive.indent);\n }\n if (condition !== null) requirements.push({ kind: 'RequirementSyntax', condition, message, severity, location: locationOf(child) });\n continue;\n }\n const rule = parseValidationRule(context, owner === 'concept' ? { ...child, content: `value ${child.content}` } : child, owner);\n if (rule !== undefined) {\n rules.push(rule);\n }\n }\n return { kind: 'DeclarativeValidateSyntax', rules, requirements, location: locationOf(line) };\n }\n if (owner === 'concept' && firstWord(line.content.substring('validate'.length).trimStart()) === 'checksum') {\n const ruleLine = { ...line, content: `value ${line.content.substring('validate'.length).trimStart()}` };\n const rule = parseValidationRule(context, ruleLine, owner);\n return rule === undefined ? undefined : { kind: 'DeclarativeValidateSyntax', rules: [rule], requirements: [], location: locationOf(line) };\n }\n if (line.content === 'validate csharp') {\n const code = parseCode(context.valueContext, { ...line, content: 'csharp' });\n if (code === null) context.skipOpaqueBlock(line.indent);\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n context.error(DiagnosticCodes.InvalidValidateDeclaration, `Invalid validate declaration '${line.content}' - expected 'validate' or 'validate csharp'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n}\n\nfunction parseValidationRule(context: ParserContext, line: SourceLine, owner: 'command' | 'concept'): ValidationRuleSyntax | undefined {\n // Checksum is a new declaration, not enrichment of a formerly opaque Legacy rule.\n const checksum = firstWord(rulePattern.exec(line.content)?.[2] ?? '') === 'checksum';\n const valueContext = owner === 'concept' && !checksum ? context.valueContext : context;\n const { content: withSeverity, message } = splitMessage(line.content);\n const severity = splitSeverity(valueContext, line, withSeverity);\n if (severity === undefined) {\n return undefined;\n }\n const match = rulePattern.exec(severity.content);\n if (match === null) {\n valueContext.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const parsed = parseRule(valueContext, match[2], line);\n if (parsed === undefined) {\n return undefined;\n }\n const source = parsed.kind === 'Rule' ? parseRuleImplementation(context, line, owner === 'command') : { file: null, code: null, implementation: null };\n return {\n kind: 'ValidationRuleSyntax',\n property: match[1],\n rule: parsed.kind,\n value: parsed.value,\n message,\n severity: severity.severity,\n ...source,\n location: locationOf(line),\n };\n}\n\nfunction parseRuleImplementation(context: ParserContext, rule: SourceLine, commandOwner: boolean): { file: FileReferenceSyntax | null; code: CodeBlockSyntax | null; implementation: ImplementationSyntax | null } {\n const body = context.peekChild(rule.indent);\n if (body === undefined) return { file: null, code: null, implementation: null };\n context.reader.takeSignificant();\n const wrapped = commandOwner && firstWord(body.content) === 'implementation';\n const source = wrapped ? parseImplementationWrapper(context, body) : {\n file: isFile(body) ? parseFile(context, body) : null,\n code: !isFile(body) && isCode(context, body) ? parseCode(context, body) : null,\n implementation: null,\n };\n if (!wrapped && source.file === null && source.code === null) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, `Unexpected '${body.content}' in rule implementation - expected 'file <path>' or an inline code block`, locationOf(body));\n context.skipBlock(body.indent);\n }\n for (let extra = context.peekChild(rule.indent); extra !== undefined && (wrapped || (commandOwner && firstWord(extra.content) === 'implementation')); extra = context.peekChild(rule.indent)) {\n context.reader.takeSignificant();\n context.error(wrapped && firstWord(extra.content) === 'implementation' ? DiagnosticCodes.InvalidImplementationBlock : DiagnosticCodes.ConflictingImplementationSources,\n 'A named rule has one implementation wrapper and cannot mix wrapped and direct sources.', locationOf(extra));\n if (isCode(context, extra)) parseCode(context, extra);\n else context.skipBlock(extra.indent);\n }\n return source;\n}\n\nfunction splitMessage(content: string): { content: string; message: string | null } {\n const match = messagePattern.exec(content);\n if (match === null) {\n return { content, message: null };\n }\n const message = match[1] !== undefined ? unescapeString(match[1]) : match[2];\n return { content: content.substring(0, match.index).trimEnd(), message };\n}\n\nfunction splitSeverity(context: ParserContext, line: SourceLine, text: string): { content: string; severity: ValidationSeverity } | undefined {\n const match = severityPattern.exec(text);\n if (match === null) {\n return { content: text, severity: 'Error' };\n }\n const severity = severities[match[1]];\n if (severity === undefined) {\n context.error(DiagnosticCodes.InvalidValidationSeverity, `Unknown validation severity '${match[1]}' - expected information, warning or error`, locationOf(line));\n return undefined;\n }\n return { content: text.substring(0, match.index).trimEnd(), severity };\n}\n\nfunction parseRule(context: ParserContext, rule: string, line: SourceLine): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n if (rule === 'not empty') {\n return { kind: 'NotEmpty', value: null };\n }\n if (firstWord(rule) === 'checksum') {\n const algorithm = rule.substring('checksum'.length).trim();\n if (algorithm !== 'luhn' && algorithm !== 'mod11' && algorithm !== 'mod97') {\n context.error(DiagnosticCodes.InvalidGenerationArgument, 'Checksum validation requires luhn, mod11 or mod97.', locationOf(line));\n return undefined;\n }\n return { kind: 'Checksum', value: { kind: 'LiteralExpressionSyntax', value: algorithm, location: locationOf(line) } };\n }\n const operand = operandPattern.exec(rule);\n if (operand === null) {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n if (operand[1] === 'rule') {\n const name = operand[2].trim();\n if (!ruleNamePattern.test(name)) {\n context.error(DiagnosticCodes.InvalidRuleName, `Invalid rule name '${name}' in '${line.content}' - expected 'rule <Name>' with an identifier`, locationOf(line));\n return undefined;\n }\n return { kind: 'Rule', value: { kind: 'PathExpressionSyntax', path: name, location: locationOf(line) } };\n }\n return { kind: operandKinds[operand[1]], value: parseMappingSource(operand[2], locationOf(line), context) };\n}\n"],"mappings":"oiDAmCA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAkBH,EAAQ,wBAAwB,EA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,GAAI,CAACpG,EAAgB,KAAKW,CAAI,EAAG,CAC7BF,EAAQ,MAAMG,EAAgB,gBAAiB,sBAAsBD,EAAK,QAAQD,EAAK,QAAQ,+CAAgDG,EAAWH,CAAI,CAAC,EAC/J,MACJ,CACA,MAAO,CAAE,KAAM,OAAQ,MAAO,CAAE,KAAM,uBAAwB,KAAMC,EAAM,SAAUE,EAAWH,CAAI,CAAE,CAAE,CAC3G,CACA,MAAO,CAAE,KAAMR,EAAakG,EAAQ,IAAK,MAAOC,EAAmBD,EAAQ,GAAIvF,EAAWH,CAAI,EAAGD,CAAO,CAAE,CAD1G,CAEJ"}
|
|
1
|
+
{"version":3,"file":"CommandParser.js","names":["header","pattern","routeHeader","sourceStreamPattern","severityPattern","messagePattern","stringBodyPattern","rulePattern","operandPattern","ruleNamePattern","optionalReads","operandKinds","severities","opaqueDirectives","propertyShapedDirectives","names","lookahead","ParserContext","context","line","name","DiagnosticCodes","locationOf","properties","responses","identifier","validations","produces","reads","referenceReads","concurrency","description","documentation","authorize","handler","handlers","stream","streamCandidates","child","keyword","firstWord","asProperty","tryParseProperty","scalar","scalarResponsePattern","responseNames","parseCommandResponse","reportInvalidModifierOrder","source","streamName","ambiguous","route","parseCommandStream","isReactionIdentityLine","misplacedReactionIdentity","parseDescription","parseDocumentation","combineAuthorize","parseAuthorize","validate","production","parseProduces","parseHandler","reference","parseReads","captureConcurrency","read","candidates","entry","property","discoveredNames","response","removed","parsed","validateHandlerOccurrences","isPendingHandler","syntax","commandReadSources","dependencySources","reportLegacyOptionalSuffix","commandName","fence","code","parseCode","rules","requirements","wrapperIndent","owner","condition","parseCondition","message","severity","hasSeverity","directive","matched","unescapeString","rule","checksum","valueContext","withSeverity","match","body","wrapped","commandOwner","parseImplementationWrapper","isFile","parseFile","isCode","extra","content","text","algorithm","operand","parseMappingSource"],"sources":["../../../../../../Compiler/Parsing/CommandParser.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 { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { isPendingHandler, validateHandlerOccurrences } from './CommandHandlerValidator';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { RequirementSyntax } from '../Syntax/Conditions';\nimport { parseCondition } from './ConditionParser';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { CommandSyntax, ValidateSyntax, ValidationRuleKind, ValidationRuleSyntax, ValidationSeverity } from '../Syntax/Commands';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { CommandStreamSyntax } from '../Syntax/EventSources';\nimport { parseCommandStream } from './EventSourceParser';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { ProducesSyntax } from '../Syntax/Reactions';\nimport { CommandResponseSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseCommandResponse, scalarResponsePattern } from './CommandResponseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { isCode, isFile, parseCode, parseFile, parseHandler, parseImplementationWrapper } from './ImplementationParser';\nimport { CodeBlockSyntax, FileReferenceSyntax, HandlerSyntax, ImplementationSyntax } from '../Syntax/Implementations';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { isReactionIdentityLine, misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { commandReadSources } from './CommandReadSources';\nimport { dependencySources, ReadsSyntax, ConcurrencySyntax } from '../Syntax/DependencySources';\nimport { captureConcurrency } from './DependencySourceParser';\nimport { parseReads } from './ReadsParser';\nimport { parseProduces } from './ProducesParser';\nimport { reportInvalidModifierOrder, reportLegacyOptionalSuffix, tryParseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^command\\\\s+([A-Za-z_]\\\\w*)$');\nconst routeHeader = sourceStreamPattern('^stream\\\\s+[A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*$');\nconst severityPattern = pattern('\\\\bseverity\\\\s+(\\\\S+)$');\nconst messagePattern = pattern(`\\\\bmessage\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\S*))$`);\nconst rulePattern = pattern('^([\\\\w.]+)\\\\s+(.+)$');\nconst operandPattern = pattern('^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\\\s*(.*)$');\nconst ruleNamePattern = sourceStreamPattern('^[A-Za-z_]\\\\w*$');\nconst optionalReads = pattern('^reads\\\\s+[A-Z]\\\\w*\\\\s+optional(?:\\\\s|$)');\n\n// Every operand the pattern matches has a kind, so an operand never goes unrecognized here.\nconst operandKinds: Record<string, ValidationRuleKind> = {\n max: 'Max',\n min: 'Min',\n '>': 'GreaterThan',\n '>=': 'GreaterThanOrEqual',\n '<': 'LessThan',\n '<=': 'LessThanOrEqual',\n '==': 'Equal',\n '!=': 'NotEqual',\n 'length ==': 'Length',\n matches: 'Matches',\n 'all >': 'AllGreaterThan',\n 'all >=': 'AllGreaterThanOrEqual',\n};\n\nconst severities: Record<string, ValidationSeverity> = { information: 'Information', warning: 'Warning', error: 'Error' };\n\n// Command directives this compiler does not model. They are skipped whole.\nconst opaqueDirectives = new Set(['reads', 'concurrency']);\n\n// The bare directives cannot take a type reference, so a line with property shape is a property whatever\n// keyword it starts with - 'description String' declares a property called description.\nconst propertyShapedDirectives = new Set(['description', 'documentation', 'handler', 'concurrency']);\n\nexport function parseCommand(context: ParserContext, line: SourceLine): CommandSyntax {\n // Properties are leaves, not indentation owners. Resolve ambiguous returns spelling\n // before the committed pass decides whether its deeper lines belong to a response.\n const names = new Set<string>();\n const lookahead = new ParserContext(context.reader.fork(), context.path, context.languages);\n lookahead.sourceOptions = context.sourceOptions;\n lookahead.streamCandidates = context.streamCandidates;\n parseCommandBody(lookahead, line, undefined, names);\n return parseCommandBody(context, line, names);\n}\n\nfunction parseCommandBody(context: ParserContext, line: SourceLine, responseNames?: ReadonlySet<string>, discoveredNames?: Set<string>): CommandSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidCommandDeclaration, `Invalid command declaration '${line.content}' - expected 'command <Name>'`, locationOf(line));\n }\n const properties: PropertySyntax[] = [];\n const responses: { line: SourceLine; candidate: PropertySyntax | null; response: CommandResponseSyntax | null }[] = [];\n let identifier: PropertySyntax | undefined;\n const validations: ValidateSyntax[] = [];\n const produces: ProducesSyntax[] = [];\n const reads: { readModel: string; alias: string | null }[] = [];\n const referenceReads: ReadsSyntax[] = [];\n let concurrency: ConcurrencySyntax | undefined;\n let description: string | null = null;\n let documentation: string | null = null;\n let authorize: AuthorizeSyntax | null = null;\n let handler: HandlerSyntax | null = null;\n const handlers: { handler: HandlerSyntax | null; location: SourceLocation }[] = [];\n let stream: CommandStreamSyntax | null = null;\n const streamCandidates: CommandStreamSyntax[] = [];\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 const asProperty = tryParseProperty(child);\n if (asProperty !== undefined && (propertyShapedDirectives.has(keyword) || (keyword === 'validate' && child.content !== 'validate csharp'))) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (keyword === 'returns') {\n const scalar = scalarResponsePattern.exec(child.content);\n if (scalar !== null && !scalar[1].startsWith('@') && asProperty !== undefined) {\n if (responseNames === undefined) {\n properties.push(asProperty);\n responses.push({ line: child, candidate: asProperty, response: null });\n } else if (responseNames.has(asProperty.type.name)) {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n } else {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n }\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else if (reportInvalidModifierOrder(context, child)) {\n context.skipBlock(child.indent);\n } else {\n responses.push({ line: child, candidate: null, response: parseCommandResponse(context, child) });\n }\n } else if (keyword === 'stream' && routeHeader.test(child.content) && asProperty !== undefined && context.streamCandidates?.hasSource(asProperty.type.name.split('.')[0]) === true) {\n const [source, streamName] = asProperty.type.name.split('.');\n const ambiguous = context.streamCandidates.hasPropertyType(asProperty.type.name) && context.streamCandidates.hasUniqueStream(source, streamName);\n const route = parseCommandStream(context, child, asProperty, ambiguous);\n if (stream !== null || streamCandidates.length > 0) context.error(DiagnosticCodes.InvalidCommandStream, 'A command declares at most one stream route.', locationOf(child));\n if (ambiguous || stream !== null) streamCandidates.push(route);\n else stream = route;\n } else if (keyword === 'runs' && isReactionIdentityLine(child)) {\n misplacedReactionIdentity(context, child);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Command '${name}'`);\n } else if (keyword === 'documentation') {\n documentation = parseDocumentation(context, child, documentation, `Command '${name}'`);\n } else if (keyword === 'authorize') {\n authorize = combineAuthorize(authorize, parseAuthorize(context, child));\n } else if (keyword === 'validate') {\n const validate = parseValidate(context, child, 'command');\n if (validate !== undefined) {\n validations.push(validate);\n }\n } else if (keyword === 'produces') {\n const production = parseProduces(context, child, true);\n if (production !== undefined) produces.push(production);\n } else if (keyword === 'handler') {\n handler = parseHandler(context, child);\n handlers.push({ handler, location: locationOf(child) });\n } else if (opaqueDirectives.has(keyword)) {\n const reference = keyword === 'reads' ? parseReads(context, child) : undefined;\n if (reference !== undefined) referenceReads.push(reference);\n if (keyword === 'concurrency' && concurrency === undefined) concurrency = captureConcurrency(context, child);\n const read = /^reads\\s+([A-Z]\\w*)(?:\\s+as\\s+([a-z_]\\w*))?(?:\\s+by\\s+([a-z_]\\w*))?$/.exec(child.content);\n if (read !== null) reads.push({ readModel: read[1], alias: read[2] ?? null });\n if (optionalReads.test(child.content)) {\n context.error(DiagnosticCodes.OptionalReadsNotSupported, 'Optional reads are not yet supported (see #308).', locationOf(child));\n }\n context.skipOpaqueBlock(child.indent);\n } else if (asProperty !== undefined) {\n identifier = addProperty(context, properties, asProperty, name, child, identifier);\n } else {\n reportInvalidModifierOrder(context, child);\n context.error(DiagnosticCodes.UnknownCommandDirective, `Unexpected '${child.content}' in command body`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n const candidates = new Set(responses.flatMap(entry => entry.candidate === null ? [] : [entry.candidate]));\n const names = new Set(properties.filter(property => !candidates.has(property)).map(property => property.name));\n if (responses.some(entry => entry.candidate !== null && !names.has(entry.candidate.type.name) && entry.candidate.type.name !== 'returns')) names.add('returns');\n for (const name of names) discoveredNames?.add(name);\n let response: CommandResponseSyntax | null = null;\n const removed = new Set<PropertySyntax>();\n for (const entry of responses) {\n let parsed = entry.response;\n if (entry.candidate !== null) {\n if (!names.has(entry.candidate.type.name)) continue;\n removed.add(entry.candidate);\n parsed = { kind: 'ScalarCommandResponseSyntax', source: { kind: 'PropertyResponseSourceSyntax', property: entry.candidate.type.name, location: entry.candidate.type.location }, location: locationOf(entry.line) };\n }\n if (parsed === null) continue;\n if (response !== null) {\n context.error(DiagnosticCodes.InvalidCommandResponse, 'A command declares at most one unconditional response.', locationOf(entry.line));\n } else {\n response = parsed;\n }\n }\n validateHandlerOccurrences(handlers, context);\n if (handler !== null && !isPendingHandler(handler) && produces.length > 0) {\n context.error(DiagnosticCodes.CommandWithProducesAndHandler, `Command '${name}' cannot declare both 'produces' and 'handler'`, locationOf(line));\n }\n const syntax: CommandSyntax = { kind: 'CommandSyntax', name, description, documentation, authorize, properties: properties.filter(property => !removed.has(property)), validations, produces, handler, response, stream, streamCandidates, location: locationOf(line) };\n commandReadSources.set(syntax, reads);\n dependencySources.set(syntax, { reads: referenceReads, concurrency });\n return syntax;\n}\n\nfunction addProperty(context: ParserContext, properties: PropertySyntax[], property: PropertySyntax, commandName: string, line: SourceLine, identifier: PropertySyntax | undefined): PropertySyntax | undefined {\n reportLegacyOptionalSuffix(context, property.type, line);\n if (property.isIdentifier && identifier !== undefined) {\n context.error(DiagnosticCodes.DuplicateCommandIdentifier, `Command '${commandName}' already marks '${identifier.name}' as identifier - only one property can be the identifier`, property.location);\n property = { ...property, isIdentifier: false };\n }\n properties.push(property);\n return identifier ?? (property.isIdentifier ? property : undefined);\n}\n\n// Reads a 'validate' block: declarative rules, or code - which is recognized but not modeled.\nexport function parseValidate(context: ParserContext, line: SourceLine, owner: 'command' | 'concept'): ValidateSyntax | undefined {\n if (line.content === 'validate') {\n const fence = context.peekChild(line.indent);\n if (fence !== undefined && fence.content.startsWith('```')) {\n context.reader.takeSignificant();\n const code = parseCode(context.valueContext, fence);\n if (code === null) context.skipFencedBody();\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n const rules: ValidationRuleSyntax[] = [];\n const requirements: RequirementSyntax[] = [];\n let wrapperIndent: number | undefined;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (owner === 'concept') {\n if (context.sourceOptions.numericMode === 'legacy' && child.content.startsWith('```')) { context.skipFencedBody(); continue; }\n if (wrapperIndent !== undefined && child.indent <= wrapperIndent) wrapperIndent = undefined;\n if (wrapperIndent !== undefined || firstWord(child.content) === 'implementation') {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${child.content}'`, locationOf(child));\n wrapperIndent ??= child.indent;\n continue;\n }\n }\n if (firstWord(child.content) === 'require') {\n const condition = parseCondition(owner === 'concept' ? context.valueContext : context, child.content.substring('require'.length).trim(), locationOf(child));\n let message: string | null = null;\n let severity: ValidationSeverity = 'Error';\n let hasSeverity = false;\n for (let directive = context.peekChild(child.indent); directive !== undefined; directive = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const matched = messagePattern.exec(directive.content);\n if (matched !== null && matched.index === 0) message = matched[1] !== undefined ? unescapeString(matched[1]) : matched[2];\n else if (firstWord(directive.content) === 'severity') {\n if (!hasSeverity) severity = severities[directive.content.substring('severity'.length).trim()] ?? 'Error';\n hasSeverity = true;\n } else context.skipOpaqueBlock(directive.indent);\n }\n if (condition !== null) requirements.push({ kind: 'RequirementSyntax', condition, message, severity, location: locationOf(child) });\n continue;\n }\n const rule = parseValidationRule(context, owner === 'concept' ? { ...child, content: `value ${child.content}` } : child, owner);\n if (rule !== undefined) {\n rules.push(rule);\n }\n }\n return { kind: 'DeclarativeValidateSyntax', rules, requirements, location: locationOf(line) };\n }\n if (owner === 'concept' && firstWord(line.content.substring('validate'.length).trimStart()) === 'checksum') {\n const ruleLine = { ...line, content: `value ${line.content.substring('validate'.length).trimStart()}` };\n const rule = parseValidationRule(context, ruleLine, owner);\n return rule === undefined ? undefined : { kind: 'DeclarativeValidateSyntax', rules: [rule], requirements: [], location: locationOf(line) };\n }\n if (line.content === 'validate csharp') {\n const code = parseCode(context.valueContext, { ...line, content: 'csharp' });\n if (code === null) context.skipOpaqueBlock(line.indent);\n return { kind: 'CodeValidateSyntax', code, location: locationOf(line) };\n }\n context.error(DiagnosticCodes.InvalidValidateDeclaration, `Invalid validate declaration '${line.content}' - expected 'validate' or 'validate csharp'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n}\n\nfunction parseValidationRule(context: ParserContext, line: SourceLine, owner: 'command' | 'concept'): ValidationRuleSyntax | undefined {\n // Checksum is a new declaration, not enrichment of a formerly opaque Legacy rule.\n const checksum = firstWord(rulePattern.exec(line.content)?.[2] ?? '') === 'checksum';\n const valueContext = owner === 'concept' && !checksum ? context.valueContext : context;\n const { content: withSeverity, message } = splitMessage(line.content);\n const severity = splitSeverity(valueContext, line, withSeverity);\n if (severity === undefined) {\n return undefined;\n }\n const match = rulePattern.exec(severity.content);\n if (match === null) {\n valueContext.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n const parsed = parseRule(valueContext, match[2], line);\n if (parsed === undefined) {\n return undefined;\n }\n const source = parsed.kind === 'Rule' ? parseRuleImplementation(context, line, owner === 'command') : { file: null, code: null, implementation: null };\n return {\n kind: 'ValidationRuleSyntax',\n property: match[1],\n rule: parsed.kind,\n value: parsed.value,\n message,\n severity: severity.severity,\n ...source,\n location: locationOf(line),\n };\n}\n\nfunction parseRuleImplementation(context: ParserContext, rule: SourceLine, commandOwner: boolean): { file: FileReferenceSyntax | null; code: CodeBlockSyntax | null; implementation: ImplementationSyntax | null } {\n const body = context.peekChild(rule.indent);\n if (body === undefined) return { file: null, code: null, implementation: null };\n context.reader.takeSignificant();\n const wrapped = commandOwner && firstWord(body.content) === 'implementation';\n const source = wrapped ? parseImplementationWrapper(context, body) : {\n file: isFile(body) ? parseFile(context, body) : null,\n code: !isFile(body) && isCode(context, body) ? parseCode(context, body) : null,\n implementation: null,\n };\n if (!wrapped && source.file === null && source.code === null) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, `Unexpected '${body.content}' in rule implementation - expected 'file <path>' or an inline code block`, locationOf(body));\n context.skipBlock(body.indent);\n }\n for (let extra = context.peekChild(rule.indent); extra !== undefined && (wrapped || (commandOwner && firstWord(extra.content) === 'implementation')); extra = context.peekChild(rule.indent)) {\n context.reader.takeSignificant();\n context.error(wrapped && firstWord(extra.content) === 'implementation' ? DiagnosticCodes.InvalidImplementationBlock : DiagnosticCodes.ConflictingImplementationSources,\n 'A named rule has one implementation wrapper and cannot mix wrapped and direct sources.', locationOf(extra));\n if (isCode(context, extra)) parseCode(context, extra);\n else context.skipBlock(extra.indent);\n }\n return source;\n}\n\nfunction splitMessage(content: string): { content: string; message: string | null } {\n const match = messagePattern.exec(content);\n if (match === null) {\n return { content, message: null };\n }\n const message = match[1] !== undefined ? unescapeString(match[1]) : match[2];\n return { content: content.substring(0, match.index).trimEnd(), message };\n}\n\nfunction splitSeverity(context: ParserContext, line: SourceLine, text: string): { content: string; severity: ValidationSeverity } | undefined {\n const match = severityPattern.exec(text);\n if (match === null) {\n return { content: text, severity: 'Error' };\n }\n const severity = severities[match[1]];\n if (severity === undefined) {\n context.error(DiagnosticCodes.InvalidValidationSeverity, `Unknown validation severity '${match[1]}' - expected information, warning or error`, locationOf(line));\n return undefined;\n }\n return { content: text.substring(0, match.index).trimEnd(), severity };\n}\n\nfunction parseRule(context: ParserContext, rule: string, line: SourceLine): { kind: ValidationRuleKind; value: ExpressionSyntax | null } | undefined {\n if (rule === 'not empty') {\n return { kind: 'NotEmpty', value: null };\n }\n if (firstWord(rule) === 'checksum') {\n const algorithm = rule.substring('checksum'.length).trim();\n if (algorithm !== 'luhn' && algorithm !== 'mod11' && algorithm !== 'mod97') {\n context.error(DiagnosticCodes.InvalidGenerationArgument, 'Checksum validation requires luhn, mod11 or mod97.', locationOf(line));\n return undefined;\n }\n return { kind: 'Checksum', value: { kind: 'LiteralExpressionSyntax', value: algorithm, location: locationOf(line) } };\n }\n const operand = operandPattern.exec(rule);\n if (operand === null) {\n context.error(DiagnosticCodes.InvalidValidationRule, `Invalid validation rule '${line.content}'`, locationOf(line));\n return undefined;\n }\n if (operand[1] === 'rule') {\n const name = operand[2].trim();\n if (!ruleNamePattern.test(name)) {\n context.error(DiagnosticCodes.InvalidRuleName, `Invalid rule name '${name}' in '${line.content}' - expected 'rule <Name>' with an identifier`, locationOf(line));\n return undefined;\n }\n return { kind: 'Rule', value: { kind: 'PathExpressionSyntax', path: name, location: locationOf(line) } };\n }\n return { kind: operandKinds[operand[1]], value: parseMappingSource(operand[2], locationOf(line), context) };\n}\n"],"mappings":"ooDAqCA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAcC,EAAoB,2CAA2C,EAC7EC,EAAkBH,EAAQ,wBAAwB,EAClDI,EAAiBJ,EAAQ,sBAAsBK,EAAkB,yBAAyB,EAC1FC,EAAcN,EAAQ,qBAAqB,EAC3CO,EAAiBP,EAAQ,mFAAmF,EAC5GQ,EAAkBN,EAAoB,iBAAiB,EACvDO,EAAgBT,EAAQ,0CAA0C,EAGlEU,EAAmD,CACrD,IAAK,MACL,IAAK,MACL,IAAK,cACL,KAAM,qBACN,IAAK,WACL,KAA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AK,QAAQ,+CAAgDG,EAAWH,CAAI,CAAC,EAC/J,MACJ,CACA,MAAO,CAAE,KAAM,OAAQ,MAAO,CAAE,KAAM,uBAAwB,KAAMC,EAAM,SAAUE,EAAWH,CAAI,CAAE,CAAE,CAC3G,CACA,MAAO,CAAE,KAAMR,EAAaqG,EAAQ,IAAK,MAAOC,EAAmBD,EAAQ,GAAI1F,EAAWH,CAAI,EAAGD,CAAO,CAAE,CAD1G,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../_virtual/_virtual/_rolldown/runtime.js";import{splitLines as e}from"./Parsing/SourceLineSplitter.js";import{validateIdentity as t}from"./Parsing/IdentityValidator.js";import{expandSpecificationExamples as
|
|
1
|
+
import"../_virtual/_virtual/_rolldown/runtime.js";import{splitLines as e}from"./Parsing/SourceLineSplitter.js";import{validateIdentity as t}from"./Parsing/IdentityValidator.js";import{validateApplicationHandlers as n}from"./Parsing/CommandHandlerValidator.js";import{expandSpecificationExamples as r,validateSpecificationExampleTypes as i}from"./Parsing/SpecificationCommandExamples.js";import{validateResponses as a}from"./Parsing/ResponseValidator.js";import{validateSpecificationCases as o}from"./Parsing/SpecificationCaseValidator.js";import{productionDestinationDiagnostics as s}from"./Diagnostics/ProductionDestinationDiagnostics.js";import{validateConstraintProperties as c}from"./Parsing/ConstraintPropertyValidator.js";import{validateDependencyDeclarations as l}from"./Dependencies/DeclaredDependencyTargets.js";import{documentPlacement as u}from"./Files/PlayPlacement.js";import{interactionAncestry as d}from"./Parsing/InteractionAlternatives.js";import"./Parsing/SpecificationParser.js";import"./Parsing/SpecificationExampleParser.js";import"./Parsing/CaptureParser.js";import"./Parsing/ProjectionParser.js";import"./Parsing/ImportDiscovery.js";import{DeclaredDependencies as f}from"./Dependencies/DeclaredDependencies.js";import{validatePublicEventUsage as p}from"./Parsing/PublicEventUsageValidator.js";import{sourceContext as m}from"./Parsing/SourceOptionsParser.js";import{validateInlineEvents as h}from"./Parsing/InlineEventValidator.js";import{validateOperations as g}from"./Parsing/OperationValidator.js";import{parseApplication as _}from"./Parsing/ScreenplayParser.js";import{CommandStreamCandidates as v}from"./Parsing/CommandStreamCandidates.js";import{validateEventSources as y}from"./Parsing/EventSourceValidator.js";import{validateProjectionTargets as b}from"./Parsing/ProjectionTargetValidator.js";import{validateIdentifierCompliance as x}from"./Parsing/IdentifierComplianceValidator.js";import{validateEventSubjects as S}from"./Parsing/EventSubjectValidator.js";import{validateReadModelKeys as C}from"./Parsing/ReadModelKeyValidator.js";import{validateReactionRefusals as w}from"./Parsing/ReactionRefusalValidator.js";import{validateSpecificationRedelivery as T}from"./Parsing/SpecificationRedeliveryValidator.js";import{validateGuardedActions as E}from"./Parsing/GuardedActionValidator.js";import{validatePersonaCallers as D}from"./Parsing/PersonaCallerValidator.js";import{validatePurposes as O}from"./Parsing/PurposeValidator.js";import{timelineOrderDiagnostics as k}from"./Files/TimelineOrder.js";function parseForAuthoring(A,j,M=u,N=!0,P,F){let I=e(A,!1,j),L=m(I,j,F);L.scope=M,L.interactionAncestors=d(I),L.streamCandidates=P??v.capture([I],M,F);let R=_(L,I,M);if(N){n(R,L),t(R,L),O(R,L),h(R,L),c(R,L),g(R,L),p(R,L),o(R,L),i(R,L,!0);let e=r(R);a(e,L),y(R,L),b(R,L),x(e,L),S(R,L),C(R,L),w(R,L),T(R,L),E(R,L),D(R,L),R=l(R,L),f.validate(R,L);for(let e of s(R))L.information(e.code,e.message,e.location);for(let e of k(R))L.information(e.code,e.message,e.location)}return{value:R,diagnostics:L.diagnostics,triggerData:L.triggerData,inputUses:L.inputUses,continuationValues:L.continuationValues,guardedInteractions:L.guardedInteractions,success:!L.diagnostics.some(e=>e.severity===`error`)}}export{parseForAuthoring};
|
|
2
2
|
//# sourceMappingURL=ScreenplayCompiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScreenplayCompiler.js","names":["documentPlacement","lines","splitLines","source","path","context","sourceContext","languages","placement","interactionAncestry","streamCandidates","CommandStreamCandidates","value","parseApplication","validateResponseContracts","validateIdentity","validatePurposes","validateInlineEvents","validateConstraintProperties","validateOperations","validatePublicEventUsage","validateSpecificationCases","validateSpecificationExampleTypes","effective","expandSpecificationExamples","validateResponses","validateEventSources","validateProjectionTargets","validateIdentifierCompliance","validateEventSubjects","validateReadModelKeys","validateReactionRefusals","validateSpecificationRedelivery","validateGuardedActions","validatePersonaCallers","validateDependencyDeclarations","DeclaredDependencies","diagnostic","productionDestinationDiagnostics","timelineOrderDiagnostics"],"sources":["../../../../../Compiler/ScreenplayCompiler.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 { validateIdentity } from './Parsing/IdentityValidator';\nimport { Diagnostic } from './Diagnostics/Diagnostic';\nimport { validateSpecificationCases } from './Parsing/SpecificationCaseValidator';\nimport { expandSpecificationExamples, validateSpecificationExampleTypes } from './Parsing/SpecificationCommandExamples';\nimport { productionDestinationDiagnostics } from './Diagnostics/ProductionDestinationDiagnostics';\nimport { validateConstraintProperties } from './Parsing/ConstraintPropertyValidator';\nimport { validateDependencyDeclarations } from './Dependencies/DeclaredDependencyTargets';\nimport { DeclaredDependencies } from './Dependencies/DeclaredDependencies';\nimport { documentPlacement, PlayPlacement } from './Files/PlayPlacement';\nimport { DiscoveredImport, discoverImports as discoverImportsIn } from './Parsing/ImportDiscovery';\nimport { ContinuationValueUse } from './Parsing/ContinuationValueUse';\nimport { InputUse } from './Parsing/InputUses';\nimport { GuardedInteractionBinding, interactionAncestry } from './Parsing/InteractionAlternatives';\nimport { validateResponses } from './Parsing/ResponseValidator';\nimport { validatePublicEventUsage } from './Parsing/PublicEventUsageValidator';\nimport { sourceContext } from './Parsing/SourceOptionsParser';\nimport { validateInlineEvents } from './Parsing/InlineEventValidator';\nimport { validateOperations } from './Parsing/OperationValidator';\nimport { CommandStreamCandidates } from './Parsing/CommandStreamCandidates';\nimport { validateEventSources } from './Parsing/EventSourceValidator';\nimport { validateProjectionTargets } from './Parsing/ProjectionTargetValidator';\nimport { validateIdentifierCompliance } from './Parsing/IdentifierComplianceValidator';\nimport { validateEventSubjects } from './Parsing/EventSubjectValidator';\nimport { validateReadModelKeys } from './Parsing/ReadModelKeyValidator';\nimport { validateReactionRefusals } from './Parsing/ReactionRefusalValidator';\nimport { validateSpecificationRedelivery } from './Parsing/SpecificationRedeliveryValidator';\nimport { validateGuardedActions } from './Parsing/GuardedActionValidator';\nimport { validatePersonaCallers } from './Parsing/PersonaCallerValidator';\nimport { validatePurposes } from './Parsing/PurposeValidator';\nimport { parseApplication } from './Parsing/ScreenplayParser';\nimport { splitLines } from './Parsing/SourceLineSplitter';\nimport { PropertySyntax } from './Syntax/Declarations';\nimport { ApplicationSyntax } from './Syntax/Structure';\nimport { ApplicationSyntaxVisitor } from './Syntax/Visitors';\nimport { ProjectionSyntax } from './Syntax/Projections';\nimport { CaptureSyntax } from './Syntax/Captures';\nimport { SpecificationExampleSyntax, SpecificationSyntax } from './Syntax/Specifications';\nimport { SyntaxNode } from './Syntax/SyntaxNode';\nimport { ParserContext } from './Parsing/ParserContext';\nimport { parseProjection } from './Parsing/ProjectionParser';\nimport { parseCapture } from './Parsing/CaptureParser';\nimport { parseSpecification } from './Parsing/SpecificationParser';\nimport { parseExample } from './Parsing/SpecificationExampleParser';\nimport { firstWord } from './Parsing/LineText';\nimport { SourceLine, locationOf } from './Parsing/SourceLine';\nimport { DiagnosticCodes } from './Diagnostics/DiagnosticCodes';\nimport { timelineOrderDiagnostics } from './Files/TimelineOrder';\n\n// What compiling produced: the syntax tree, and the diagnostics found on the way. A tree is always\n// produced, so a document with errors still shows everything that could be read.\nexport interface CompilationResult<T> {\n readonly value: T;\n readonly diagnostics: readonly Diagnostic[];\n readonly success: boolean;\n}\n\n// Parses one .play document - the TypeScript counterpart of the C# ScreenplayCompiler.Parse. The path, when\n// given, is carried on every source location so a folder of documents can be merged and still point back\n// at the file each node came from. A placement says the document's top level belongs to the module or\n// feature an import placed it in: that module and feature are in the tree, marked as placements, holding what\n// the document declares at its top level.\nexport function parse(source: string, path?: string, placement: PlayPlacement = documentPlacement): CompilationResult<ApplicationSyntax> {\n const { value, diagnostics, success } = parseForAuthoring(source, path, placement);\n return { value, diagnostics, success };\n}\n\n// Additive authoring view: do not widen TypeRefSyntax or the cross-compiler SyntaxJson projection.\nexport function parseForAuthoring(source: string, path?: string, placement: PlayPlacement = documentPlacement, validateResponseContracts = true, streamCandidates?: CommandStreamCandidates, languages?: ReadonlySet<string>): CompilationResult<ApplicationSyntax> & { readonly triggerData: readonly PropertySyntax[]; readonly inputUses: readonly InputUse[]; readonly continuationValues: readonly ContinuationValueUse[]; readonly guardedInteractions: readonly GuardedInteractionBinding[] } {\n const lines = splitLines(source, false, path);\n const context = sourceContext(lines, path, languages);\n context.scope = placement;\n context.interactionAncestors = interactionAncestry(lines);\n context.streamCandidates = streamCandidates ?? CommandStreamCandidates.capture([lines], placement, languages);\n let value = parseApplication(context, lines, placement);\n // Folder assembly validates declaration-dependent contracts once against the merged inventory.\n if (validateResponseContracts) {\n validateIdentity(value, context);\n validatePurposes(value, context);\n validateInlineEvents(value, context);\n validateConstraintProperties(value, context);\n validateOperations(value, context);\n validatePublicEventUsage(value, context);\n validateSpecificationCases(value, context);\n validateSpecificationExampleTypes(value, context, true);\n const effective = expandSpecificationExamples(value);\n validateResponses(effective, context);\n validateEventSources(value, context);\n validateProjectionTargets(value, context);\n validateIdentifierCompliance(effective, context);\n validateEventSubjects(value, context);\n validateReadModelKeys(value, context);\n validateReactionRefusals(value, context);\n validateSpecificationRedelivery(value, context);\n validateGuardedActions(value, context);\n validatePersonaCallers(value, context);\n value = validateDependencyDeclarations(value, context);\n DeclaredDependencies.validate(value, context);\n for (const diagnostic of productionDestinationDiagnostics(value)) context.information(diagnostic.code, diagnostic.message, diagnostic.location);\n for (const diagnostic of timelineOrderDiagnostics(value)) context.information(diagnostic.code, diagnostic.message, diagnostic.location);\n }\n return {\n value,\n diagnostics: context.diagnostics,\n triggerData: context.triggerData,\n inputUses: context.inputUses,\n continuationValues: context.continuationValues,\n guardedInteractions: context.guardedInteractions,\n success: !context.diagnostics.some(diagnostic => diagnostic.severity === 'error'),\n };\n}\n\n/** Checks public boundaries on programmatically authored or decoded assembled syntax. */\nexport function publicEventDiagnostics(application: ApplicationSyntax): readonly Diagnostic[] {\n const context = sourceContext([], application.location.path);\n validatePublicEventUsage(application, context);\n return context.diagnostics;\n}\n\n// Parses a document and hands its syntax tree to a visitor - the counterpart of the C#\n// ScreenplayCompiler.Compile<T>(source, visitor). The visitor runs even when there are errors, over\n// everything that could be read.\nexport function compile<T>(source: string, visitor: ApplicationSyntaxVisitor<T>, path?: string): CompilationResult<T> {\n const parsed = parse(source, path);\n return { value: visitor.visit(parsed.value), diagnostics: parsed.diagnostics, success: parsed.success };\n}\n\n// Finds the files a document imports and where in it each import is written - each import with the module\n// and feature names around it, outermost first. Diagnostics are not collected; parsing the document reports them.\nexport function discoverImports(source: string, path?: string, languages?: ReadonlySet<string>): DiscoveredImport[] {\n const lines = splitLines(source, false, path);\n return discoverImportsIn(sourceContext(lines, path, languages));\n}\n\n// Additive entry points preserve the caller's registry; none can select numeric mode externally.\nexport function parseWithLanguages(source: string, languages: ReadonlySet<string>, path?: string, placement: PlayPlacement = documentPlacement): CompilationResult<ApplicationSyntax> {\n const { value, diagnostics, success } = parseForAuthoring(source, path, placement, true, undefined, languages);\n return { value, diagnostics, success };\n}\n\nexport function parseProjectionSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly ProjectionSyntax[]> {\n return parseSourceFamily(source, 'projection', parseProjection, path, languages);\n}\n\nexport function parseCaptureSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly CaptureSyntax[]> {\n return parseSourceFamily(source, 'capture', parseCapture, path, languages);\n}\n\nexport function parseSpecificationSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly SpecificationSyntax[]> {\n return parseSourceFamily(source, 'specification', parseSpecification, path, languages);\n}\n\nfunction parseSourceFamily<T extends SyntaxNode>(source: string, keyword: string, read: (context: ParserContext, line: SourceLine) => T, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly T[]> {\n const context = sourceContext(splitLines(source, true, path), path, languages, true);\n const value: T[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n if (keyword === 'specification' && firstWord(line.content) === 'example') examples.push(parseExample(context, line));\n else if (line.content.startsWith(keyword)) value.push(read(context, line));\n else {\n context.error(DiagnosticCodes.UnknownTopLevelConstruct, `Expected '${keyword}', got '${line.content}'`, locationOf(line));\n context.skipOpaqueBlock(line.indent);\n }\n }\n if (context.sourceOptions.numericMode === 'exact' && value.length === 0 && context.diagnostics.length === 0) {\n const code = keyword === 'projection' ? DiagnosticCodes.ProjectionDocumentWithoutProjection : keyword === 'capture' ? DiagnosticCodes.CaptureDocumentWithoutCapture : DiagnosticCodes.SpecificationDocumentWithoutSpecification;\n context.error(code, `Document must contain at least one ${keyword}`, context.start);\n }\n const roots = keyword === 'specification' && examples.length > 0 ? value.map(node => ({ ...node, examples })) : value;\n if (keyword === 'specification') {\n const application = parseApplication(sourceContext([], path, languages), [], documentPlacement);\n validateSpecificationCases({ ...application, examples }, context, roots as unknown as SpecificationSyntax[]);\n }\n return { value: roots, diagnostics: context.diagnostics, success: !context.diagnostics.some(diagnostic => diagnostic.severity === 'error') };\n}\n"],"mappings":"44EAsEA,SAAgB,kBAAkB,EAAgB,EAAe,EAA2BA,EAAmB,EAA4B,GAAM,EAA4C,EAAwS,CACje,IAAMC,EAAQC,EAAWC,EAAQ,GAAOC,CAAI,EACtCC,EAAUC,EAAcL,EAAOG,EAAMG,CAAS,EACpD,EAAQ,MAAQC,EAChB,EAAQ,qBAAuBC,EAAoBR,CAAK,EACxD,EAAQ,iBAAmBS,GAAoBC,EAAwB,QAAQ,CAACV,CAAK,EAAG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","lines","splitLines","source","path","context","sourceContext","languages","placement","interactionAncestry","streamCandidates","CommandStreamCandidates","value","parseApplication","validateResponseContracts","validateApplicationHandlers","validateIdentity","validatePurposes","validateInlineEvents","validateConstraintProperties","validateOperations","validatePublicEventUsage","validateSpecificationCases","validateSpecificationExampleTypes","effective","expandSpecificationExamples","validateResponses","validateEventSources","validateProjectionTargets","validateIdentifierCompliance","validateEventSubjects","validateReadModelKeys","validateReactionRefusals","validateSpecificationRedelivery","validateGuardedActions","validatePersonaCallers","validateDependencyDeclarations","DeclaredDependencies","diagnostic","productionDestinationDiagnostics","timelineOrderDiagnostics"],"sources":["../../../../../Compiler/ScreenplayCompiler.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 { validateIdentity } from './Parsing/IdentityValidator';\nimport { validateApplicationHandlers } from './Parsing/CommandHandlerValidator';\nimport { Diagnostic } from './Diagnostics/Diagnostic';\nimport { validateSpecificationCases } from './Parsing/SpecificationCaseValidator';\nimport { expandSpecificationExamples, validateSpecificationExampleTypes } from './Parsing/SpecificationCommandExamples';\nimport { productionDestinationDiagnostics } from './Diagnostics/ProductionDestinationDiagnostics';\nimport { validateConstraintProperties } from './Parsing/ConstraintPropertyValidator';\nimport { validateDependencyDeclarations } from './Dependencies/DeclaredDependencyTargets';\nimport { DeclaredDependencies } from './Dependencies/DeclaredDependencies';\nimport { documentPlacement, PlayPlacement } from './Files/PlayPlacement';\nimport { DiscoveredImport, discoverImports as discoverImportsIn } from './Parsing/ImportDiscovery';\nimport { ContinuationValueUse } from './Parsing/ContinuationValueUse';\nimport { InputUse } from './Parsing/InputUses';\nimport { GuardedInteractionBinding, interactionAncestry } from './Parsing/InteractionAlternatives';\nimport { validateResponses } from './Parsing/ResponseValidator';\nimport { validatePublicEventUsage } from './Parsing/PublicEventUsageValidator';\nimport { sourceContext } from './Parsing/SourceOptionsParser';\nimport { validateInlineEvents } from './Parsing/InlineEventValidator';\nimport { validateOperations } from './Parsing/OperationValidator';\nimport { CommandStreamCandidates } from './Parsing/CommandStreamCandidates';\nimport { validateEventSources } from './Parsing/EventSourceValidator';\nimport { validateProjectionTargets } from './Parsing/ProjectionTargetValidator';\nimport { validateIdentifierCompliance } from './Parsing/IdentifierComplianceValidator';\nimport { validateEventSubjects } from './Parsing/EventSubjectValidator';\nimport { validateReadModelKeys } from './Parsing/ReadModelKeyValidator';\nimport { validateReactionRefusals } from './Parsing/ReactionRefusalValidator';\nimport { validateSpecificationRedelivery } from './Parsing/SpecificationRedeliveryValidator';\nimport { validateGuardedActions } from './Parsing/GuardedActionValidator';\nimport { validatePersonaCallers } from './Parsing/PersonaCallerValidator';\nimport { validatePurposes } from './Parsing/PurposeValidator';\nimport { parseApplication } from './Parsing/ScreenplayParser';\nimport { splitLines } from './Parsing/SourceLineSplitter';\nimport { PropertySyntax } from './Syntax/Declarations';\nimport { ApplicationSyntax } from './Syntax/Structure';\nimport { ApplicationSyntaxVisitor } from './Syntax/Visitors';\nimport { ProjectionSyntax } from './Syntax/Projections';\nimport { CaptureSyntax } from './Syntax/Captures';\nimport { SpecificationExampleSyntax, SpecificationSyntax } from './Syntax/Specifications';\nimport { SyntaxNode } from './Syntax/SyntaxNode';\nimport { ParserContext } from './Parsing/ParserContext';\nimport { parseProjection } from './Parsing/ProjectionParser';\nimport { parseCapture } from './Parsing/CaptureParser';\nimport { parseSpecification } from './Parsing/SpecificationParser';\nimport { parseExample } from './Parsing/SpecificationExampleParser';\nimport { firstWord } from './Parsing/LineText';\nimport { SourceLine, locationOf } from './Parsing/SourceLine';\nimport { DiagnosticCodes } from './Diagnostics/DiagnosticCodes';\nimport { timelineOrderDiagnostics } from './Files/TimelineOrder';\n\n// What compiling produced: the syntax tree, and the diagnostics found on the way. A tree is always\n// produced, so a document with errors still shows everything that could be read.\nexport interface CompilationResult<T> {\n readonly value: T;\n readonly diagnostics: readonly Diagnostic[];\n readonly success: boolean;\n}\n\n// Parses one .play document - the TypeScript counterpart of the C# ScreenplayCompiler.Parse. The path, when\n// given, is carried on every source location so a folder of documents can be merged and still point back\n// at the file each node came from. A placement says the document's top level belongs to the module or\n// feature an import placed it in: that module and feature are in the tree, marked as placements, holding what\n// the document declares at its top level.\nexport function parse(source: string, path?: string, placement: PlayPlacement = documentPlacement): CompilationResult<ApplicationSyntax> {\n const { value, diagnostics, success } = parseForAuthoring(source, path, placement);\n return { value, diagnostics, success };\n}\n\n// Additive authoring view: do not widen TypeRefSyntax or the cross-compiler SyntaxJson projection.\nexport function parseForAuthoring(source: string, path?: string, placement: PlayPlacement = documentPlacement, validateResponseContracts = true, streamCandidates?: CommandStreamCandidates, languages?: ReadonlySet<string>): CompilationResult<ApplicationSyntax> & { readonly triggerData: readonly PropertySyntax[]; readonly inputUses: readonly InputUse[]; readonly continuationValues: readonly ContinuationValueUse[]; readonly guardedInteractions: readonly GuardedInteractionBinding[] } {\n const lines = splitLines(source, false, path);\n const context = sourceContext(lines, path, languages);\n context.scope = placement;\n context.interactionAncestors = interactionAncestry(lines);\n context.streamCandidates = streamCandidates ?? CommandStreamCandidates.capture([lines], placement, languages);\n let value = parseApplication(context, lines, placement);\n // Folder assembly validates declaration-dependent contracts once against the merged inventory.\n if (validateResponseContracts) {\n validateApplicationHandlers(value, context);\n validateIdentity(value, context);\n validatePurposes(value, context);\n validateInlineEvents(value, context);\n validateConstraintProperties(value, context);\n validateOperations(value, context);\n validatePublicEventUsage(value, context);\n validateSpecificationCases(value, context);\n validateSpecificationExampleTypes(value, context, true);\n const effective = expandSpecificationExamples(value);\n validateResponses(effective, context);\n validateEventSources(value, context);\n validateProjectionTargets(value, context);\n validateIdentifierCompliance(effective, context);\n validateEventSubjects(value, context);\n validateReadModelKeys(value, context);\n validateReactionRefusals(value, context);\n validateSpecificationRedelivery(value, context);\n validateGuardedActions(value, context);\n validatePersonaCallers(value, context);\n value = validateDependencyDeclarations(value, context);\n DeclaredDependencies.validate(value, context);\n for (const diagnostic of productionDestinationDiagnostics(value)) context.information(diagnostic.code, diagnostic.message, diagnostic.location);\n for (const diagnostic of timelineOrderDiagnostics(value)) context.information(diagnostic.code, diagnostic.message, diagnostic.location);\n }\n return {\n value,\n diagnostics: context.diagnostics,\n triggerData: context.triggerData,\n inputUses: context.inputUses,\n continuationValues: context.continuationValues,\n guardedInteractions: context.guardedInteractions,\n success: !context.diagnostics.some(diagnostic => diagnostic.severity === 'error'),\n };\n}\n\n/** Checks public boundaries on programmatically authored or decoded assembled syntax. */\nexport function publicEventDiagnostics(application: ApplicationSyntax): readonly Diagnostic[] {\n const context = sourceContext([], application.location.path);\n validatePublicEventUsage(application, context);\n return context.diagnostics;\n}\n\n// Parses a document and hands its syntax tree to a visitor - the counterpart of the C#\n// ScreenplayCompiler.Compile<T>(source, visitor). The visitor runs even when there are errors, over\n// everything that could be read.\nexport function compile<T>(source: string, visitor: ApplicationSyntaxVisitor<T>, path?: string): CompilationResult<T> {\n const parsed = parse(source, path);\n return { value: visitor.visit(parsed.value), diagnostics: parsed.diagnostics, success: parsed.success };\n}\n\n// Finds the files a document imports and where in it each import is written - each import with the module\n// and feature names around it, outermost first. Diagnostics are not collected; parsing the document reports them.\nexport function discoverImports(source: string, path?: string, languages?: ReadonlySet<string>): DiscoveredImport[] {\n const lines = splitLines(source, false, path);\n return discoverImportsIn(sourceContext(lines, path, languages));\n}\n\n// Additive entry points preserve the caller's registry; none can select numeric mode externally.\nexport function parseWithLanguages(source: string, languages: ReadonlySet<string>, path?: string, placement: PlayPlacement = documentPlacement): CompilationResult<ApplicationSyntax> {\n const { value, diagnostics, success } = parseForAuthoring(source, path, placement, true, undefined, languages);\n return { value, diagnostics, success };\n}\n\nexport function parseProjectionSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly ProjectionSyntax[]> {\n return parseSourceFamily(source, 'projection', parseProjection, path, languages);\n}\n\nexport function parseCaptureSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly CaptureSyntax[]> {\n return parseSourceFamily(source, 'capture', parseCapture, path, languages);\n}\n\nexport function parseSpecificationSource(source: string, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly SpecificationSyntax[]> {\n return parseSourceFamily(source, 'specification', parseSpecification, path, languages);\n}\n\nfunction parseSourceFamily<T extends SyntaxNode>(source: string, keyword: string, read: (context: ParserContext, line: SourceLine) => T, path?: string, languages?: ReadonlySet<string>): CompilationResult<readonly T[]> {\n const context = sourceContext(splitLines(source, true, path), path, languages, true);\n const value: T[] = [];\n const examples: SpecificationExampleSyntax[] = [];\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n if (keyword === 'specification' && firstWord(line.content) === 'example') examples.push(parseExample(context, line));\n else if (line.content.startsWith(keyword)) value.push(read(context, line));\n else {\n context.error(DiagnosticCodes.UnknownTopLevelConstruct, `Expected '${keyword}', got '${line.content}'`, locationOf(line));\n context.skipOpaqueBlock(line.indent);\n }\n }\n if (context.sourceOptions.numericMode === 'exact' && value.length === 0 && context.diagnostics.length === 0) {\n const code = keyword === 'projection' ? DiagnosticCodes.ProjectionDocumentWithoutProjection : keyword === 'capture' ? DiagnosticCodes.CaptureDocumentWithoutCapture : DiagnosticCodes.SpecificationDocumentWithoutSpecification;\n context.error(code, `Document must contain at least one ${keyword}`, context.start);\n }\n const roots = keyword === 'specification' && examples.length > 0 ? value.map(node => ({ ...node, examples })) : value;\n if (keyword === 'specification') {\n const application = parseApplication(sourceContext([], path, languages), [], documentPlacement);\n validateSpecificationCases({ ...application, examples }, context, roots as unknown as SpecificationSyntax[]);\n }\n return { value: roots, diagnostics: context.diagnostics, success: !context.diagnostics.some(diagnostic => diagnostic.severity === 'error') };\n}\n"],"mappings":"+9EAuEA,SAAgB,kBAAkB,EAAgB,EAAe,EAA2BA,EAAmB,EAA4B,GAAM,EAA4C,EAAwS,CACje,IAAMC,EAAQC,EAAWC,EAAQ,GAAOC,CAAI,EACtCC,EAAUC,EAAcL,EAAOG,EAAMG,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,mBAC5B,oBAAqBA,EAAQ,oBAC7B,QAAS,CAACA,EAAQ,YAAY,KAAK,GAAciC,EAAW,WAAa,OAAO,CACpF,CACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import"./_virtual/_virtual/_rolldown/runtime.js";import{enclosingChain as e,enclosingHeaders as t,fenceMap as n,indentOf as r,nearestEnclosingLine as i,withoutComment as a}from"./document-context.js";import{purposeItems as o}from"./purpose-items.js";import{authenticationItems as s,behaviorItems as c,contributeItems as l,featureScopeItems as u,formItems as d,layoutItems as f,moduleScopeItems as p,navigationItems as m,outcomeItems as h,personaItems as g,profileSampleDataItems as _,readModelItems as v,reducerItems as y,sampleDataItems as b,sampleShapeItems as x,seedItems as S,templateItems as C,themeItems as w,toolbarItems as T,uiProfileItems as E}from"./scope-items.js";import{actionArgumentItems as ee,actionItems as D,commandItems as O,commandRuleItems as k,conceptItems as A,constraintItems as j,eventItems as M,guardedActionItems as te,handlerItems as N,identityItems as P,implementationItems as F,inlineEventItems as I,interactionActionItems as L,interactionChoiceItems as ne,invocationItems as R,namedRuleImplementationItems as re,operationImplementationItems as z,operationItems as B,operationPhaseItems as V,optionalTypeItems as ie,performerItems as H,policyItems as U,producesItems as W,queryItems as G,reactionItems as K,reactionTriggerItems as q,refusalItems as J,ruleItems as ae,screenItems as Y,sliceItemsFor as oe,specificationItems as se,specificationStepItems as ce,tableItems as le,topLevelItems as ue,triggerItems as de,typeItems as fe,validateItems as X}from"./completion-items.js";import{scanDocument as Z}from"./symbols.js";import{responseCompletions as pe}from"./response-completions.js";import{exampleCompletions as Q}from"./example-authoring.js";import{refusalContext as me}from"./refusal-context.js";import{generationCompletions as he}from"./generation-completions.js";import{namedRuleContext as ge}from"./named-rule-context.js";import{continuationResponseCompletions as _e}from"./continuation-responses.js";import{dependencyTargetCompletions as ve}from"./dependency-completions.js";import{structureCompletion as ye}from"./structure-completions.js";import{getSubLanguage as be}from"./sub-language-registry.js";import{readModelKeyCompletions as xe}from"./read-model-key-completions.js";const $={label:`stream`,insertText:"stream ${1:Source.Stream}",documentation:`Replace the whole command route for this event production. ESM v10.`},Se=/(?:^|\s)rule\s+[A-Za-z_]\w*(?:\s+severity\s+(?:information|warning|error))?(?:\s+message\s+.*)?$/,declaredIn=(e,t)=>e.some(e=>RegExp(`^${t}\\b`).test(e));function topLevelEntries(e){return ue.filter(t=>!(t.label===`domain`&&declaredIn(e,`domain`))&&!(t.label===`authentication`&&declaredIn(e,`authentication`))&&!(t.label===`identity`&&declaredIn(e,`identity`)))}const isTemplate=e=>/^(?:screen|dialog)\s+template\b/.test(e??``);function expansionEntry(e,t){let n=e.split(`
|
|
2
2
|
`).map((e,n)=>n===0?e:e.slice(Math.min(t,r(e)))).join(`
|
|
3
3
|
`);return{label:e.split(`
|
|
4
|
-
`)[0].trim(),insertText:n.replace(/[$}\\]/g,`\\$&`),documentation:`Expands the whole block from what the command and its events declare.`}}function completionEntriesFor(e,t={headers:[],document:[]}){let n=e[0];if(n===void 0||n===`domain`)return topLevelEntries(t.document);let r=be(n);if(r)return r.completions??[];let i=t.headers[0];switch(n){case`purpose`:return o;case`module`:return p;case`feature`:return u;case`slice`:return oe(i?.split(/\s+/)[1]);case`concept`:return/:\s*Enum\b/.test(i??``)?[...A.filter(e=>e.label!==`validate checksum`),{label:`enum member (numbered)`,insertText:"${1:value} = ${2:0}",documentation:`Every member must declare a unique int32 number. Keep published numbers unchanged; specifications name members, not numbers.`}]:A.filter(e=>e.label!==`validate checksum`||/:\s*String\b/.test(i??``));case`type`:return fe;case`command`:return O;case`public`:case`event`:return M;case`readmodel`:return v;case`reducer`:return y;case`form`:return d;case`contribute`:return l;case`behavior`:return c;case`persona`:return g;case`identity`:return P;case`authentication`:return s;case`seed`:return S;case`theme`:return w;case`ui`:return E;case`sample`:return e.includes(`ui`)?_:b;case`shape`:return e[1]===`sample`?x:[];case`on`:case`success`:case`failure`:case`confirm`:return h;case`layout`:return f;case`navigation`:return m;case`toolbar`:return T;case`system`:return B.filter(e=>e.label===`description`);case`operation`:return B;case`execute`:case`compensate`:return V;case`produces`:return e.includes(`command`)?[...W,$]:W;case`handler`:return N;case`implementation`:return e[1]===`handler`?F:[`execute`,`compensate`].includes(e[1])?z:[];case`reads`:return[{label:`by parts`,insertText:"by\n ${1:part} = ${2:source}\n ${3:part} = ${4:source}",documentation:`Supply every composite read-model key part by name.`}];case`query`:return G;case`performer`:return H;case`constraint`:return j;case`reaction`:return K;case`invokes`:return e.includes(`reaction`)?R:[];case`trigger`:return de;case`when`:case`every`:case`at`:return e.includes(`reaction`)?q:[];case`specification`:return se;case`policy`:return U;case`validate`:return e.includes(`concept`)&&/:\s*String\b/.test(t.headers.find(e=>/^concept\s/.test(e))??``)?[...X,{label:`checksum`,insertText:"checksum ${1|luhn,mod11,mod97|}",documentation:`Exact trailing check digits over preceding ASCII digits. String concepts only; also validates inputs and stored values.`}]:X;case`action`:return D;case`table`:case`summary`:return le;case`screen`:return isTemplate(i)?C:Y;case`dialog`:return C;default:return isTemplate(t.headers.find(e=>isTemplate(e)))?C:e.includes(`screen`)||n===`section`?Y:e.includes(`produces`)?e.includes(`command`)?[...W,$]:W:[]}}function planCompletions(o,s,c,l=Z(o)){let u=n(o);if(u[s]||a(c).length<c.length)return{kind:`none`};if(/^\s*concept\s+[\p{L}\p{Mn}\p{Nd}\p{Pc}]+\s*:\s*\w+\s+(?:(?:pii|personal|secret)\s+)*\w*$/u.test(c))return{kind:`entries`,entries:[`pii`,`secret`].filter(e=>!RegExp(`\\b${e}\\b`).test(c)).map(e=>({label:e,insertText:e,documentation:e===`pii`?`personal data (GDPR Art. 4(1)); renders Chronicle [PII]`:`Operational secret; renders [Encrypted] + [NotAudited].`}))};let d=e(o,u,s,r(c)),f=d[0]===`concept`;if(d[0]===`generate`&&d[1]===`concept`&&/^generate\s+rule\s+/.test((i(o,u,s,r(c))??``).trim()))return{kind:`entries`,entries:[{label:`file`,insertText:"file ${1:Generator.cs}",documentation:`The sole ValueGeneration source. Receives GenerationContext
|
|
4
|
+
`)[0].trim(),insertText:n.replace(/[$}\\]/g,`\\$&`),documentation:`Expands the whole block from what the command and its events declare.`}}function completionEntriesFor(e,t={headers:[],document:[]}){let n=e[0];if(n===void 0||n===`domain`)return topLevelEntries(t.document);let r=be(n);if(r)return r.completions??[];let i=t.headers[0];switch(n){case`purpose`:return o;case`module`:return p;case`feature`:return u;case`slice`:return oe(i?.split(/\s+/)[1]);case`concept`:return/:\s*Enum\b/.test(i??``)?[...A.filter(e=>e.label!==`validate checksum`),{label:`enum member (numbered)`,insertText:"${1:value} = ${2:0}",documentation:`Every member must declare a unique int32 number. Keep published numbers unchanged; specifications name members, not numbers.`}]:A.filter(e=>e.label!==`validate checksum`||/:\s*String\b/.test(i??``));case`type`:return fe;case`command`:return O;case`public`:case`event`:return M;case`readmodel`:return v;case`reducer`:return y;case`form`:return d;case`contribute`:return l;case`behavior`:return c;case`persona`:return g;case`identity`:return P;case`authentication`:return s;case`seed`:return S;case`theme`:return w;case`ui`:return E;case`sample`:return e.includes(`ui`)?_:b;case`shape`:return e[1]===`sample`?x:[];case`on`:case`success`:case`failure`:case`confirm`:return h;case`layout`:return f;case`navigation`:return m;case`toolbar`:return T;case`system`:return B.filter(e=>e.label===`description`);case`operation`:return B;case`execute`:case`compensate`:return V;case`produces`:return e.includes(`command`)?[...W,$]:W;case`handler`:return N;case`implementation`:return e[1]===`handler`?F:[`execute`,`compensate`].includes(e[1])?z:[];case`reads`:return[{label:`by parts`,insertText:"by\n ${1:part} = ${2:source}\n ${3:part} = ${4:source}",documentation:`Supply every composite read-model key part by name.`}];case`query`:return G;case`performer`:return H;case`constraint`:return j;case`reaction`:return K;case`invokes`:return e.includes(`reaction`)?R:[];case`trigger`:return de;case`when`:case`every`:case`at`:return e.includes(`reaction`)?q:[];case`specification`:return se;case`policy`:return U;case`validate`:return e.includes(`concept`)&&/:\s*String\b/.test(t.headers.find(e=>/^concept\s/.test(e))??``)?[...X,{label:`checksum`,insertText:"checksum ${1|luhn,mod11,mod97|}",documentation:`Exact trailing check digits over preceding ASCII digits. String concepts only; also validates inputs and stored values.`}]:X;case`action`:return D;case`table`:case`summary`:return le;case`screen`:return isTemplate(i)?C:Y;case`dialog`:return C;default:return isTemplate(t.headers.find(e=>isTemplate(e)))?C:e.includes(`screen`)||n===`section`?Y:e.includes(`produces`)?e.includes(`command`)?[...W,$]:W:[]}}function planCompletions(o,s,c,l=Z(o)){let u=n(o);if(u[s]||a(c).length<c.length)return{kind:`none`};if(/^\s*concept\s+[\p{L}\p{Mn}\p{Nd}\p{Pc}]+\s*:\s*\w+\s+(?:(?:pii|personal|secret)\s+)*\w*$/u.test(c))return{kind:`entries`,entries:[`pii`,`secret`].filter(e=>!RegExp(`\\b${e}\\b`).test(c)).map(e=>({label:e,insertText:e,documentation:e===`pii`?`personal data (GDPR Art. 4(1)); renders Chronicle [PII]`:`Operational secret; renders [Encrypted] + [NotAudited].`}))};let d=e(o,u,s,r(c)),f=d[0]===`concept`;if(d[0]===`generate`&&d[1]===`concept`&&/^generate\s+rule\s+/.test((i(o,u,s,r(c))??``).trim()))return{kind:`entries`,entries:[{label:`file`,insertText:"file ${1:Generator.cs}",documentation:`The sole ValueGeneration source. Receives the provider-bound GenerationContext (Now, Tenant); returns String.`},{label:`csharp`,insertText:"```csharp\n${1:return value;}\n```",documentation:`The sole ValueGeneration body. Reference execution requires fixtures; it never invokes this code.`}]};let p=f||d[0]===`validate`&&d[1]===`concept`?he(o,s,c):null;if(p!==null)return{kind:`entries`,entries:p};if(f&&/^\s*(?:secret|sensitive|@sensitive)\s+scope\s+\w*$/.test(c))return{kind:`entries`,entries:[`subject`,`namespace`,`global`].map(e=>({label:e,insertText:e,documentation:`Explicit secret encryption scope.`}))};if(f&&/^\s*(?:pii|personal|@pii)\s+special\s+\w*$/.test(c))return{kind:`entries`,entries:[`racialOrEthnicOrigin`,`politicalOpinions`,`religiousOrPhilosophicalBeliefs`,`tradeUnionMembership`,`genetic`,`biometric`,`health`,`sexLifeOrSexualOrientation`].map(e=>({label:e,insertText:e,documentation:`GDPR Art. 9(1) special category.`}))};let m=_e(o,s,c,l);if(m!==null)return{kind:`entries`,entries:m};let h=Q(o,s,c)??pe(o,s,c,Z(o));if(h!==null)return{kind:`entries`,entries:h};let g=xe(o,s,c,l);if(g!==null)return{kind:`entries`,entries:g};let _=ve(o,s,c,l);if(_!==null)return{kind:`entries`,entries:_};let v=c.match(/^\s*import\s+"([^"]*)$/);if(v)return{kind:`playFiles`,replaceLength:v[1].length};if(/["/]$/.test(c))return{kind:`none`};let y=me(o,s,r(o[s]??c));if(/\$refusal\.\w*$/.test(c))return{kind:`entries`,entries:y===void 0?[]:[`reason`,`message`,.../^on\s+refused\s+by\s+constraint(?:\s|$)/.test(y)?[`constraint`]:[]].map(e=>({label:e,insertText:e,documentation:`String refusal value in branch event mappings; executable from ESM v19. Constraint is available only in a by constraint branch.`}))};let b=c.match(/\$[\w.]*$/);if(b)return{kind:`contextVariables`,replaceLength:b[0].length};let x=o[s]??``,S=c.trim().length===0?c.length:r(x),C=e(o,u,s,S);if(C.includes(`screen`)){let e=S,t=!1;for(let n=s-1;n>=0;n--){if(u[n])continue;let i=a(o[n]);if(!(i.trim().length===0||r(i)>=e)){if(e=r(i),/^\s*action\s+(?:"|\$strings\.)/.test(i)){t=!0;break}if(/^\s*screen\b/.test(i))break}}if(t){if(/^\s*(?:when\b.*|otherwise)\s+execute\s+[\w.]*$/.test(c))return{kind:`commands`};if(C[0]===`action`)return{kind:`entries`,entries:te};if([`when`,`otherwise`].includes(C[0])){let e=i(o,u,s,S)??``;return{kind:`entries`,entries:/\bexecute\s+[\w.]+$/.test(e)?ee:[]}}}}if([`on`,`when`,`otherwise`].includes(C[0])){let e=S;for(let t=s-1;t>=0;t--){if(u[t])continue;let n=a(o[t]);if(!(n.trim().length===0||r(n)>=e)){if(e=r(n),/^\s*on\s+(?:click|double click|select)\s*$/.test(n))return{kind:`entries`,entries:C[0]===`on`?ne:L};if(/^\s*(?:screen|behavior|specification|reaction)\b/.test(n))break}}}if(C[0]===`on`&&y!==void 0)return{kind:`entries`,entries:J};let w=ge(o,s,S);if(w===`implementation`)return{kind:`entries`,entries:re};if(w===`rule`)return{kind:`entries`,entries:k};let T=[`public`,`event`,`command`,`type`,`readmodel`,`trigger`,`when`,`every`,`at`].includes(C[0])||C[0]===`produces`&&/^produces\s+event\b/.test(i(o,u,s,S)??``),E=c.trimStart().split(/\s+/)[0],D=C[0]===`command`&&[`reads`,`authorize`,`produces`].includes(E)||C[0]===`event`&&E===`tag`||[`trigger`,`when`,`every`,`at`].includes(C[0])&&[`description`,`file`,`reads`,`produces`,`invokes`].includes(E),optionalPrefix=e=>e!==null&&`optional`.startsWith(e[1]),O=T&&!D&&optionalPrefix(c.match(/^\s*@?[a-z_]\w*\s+[\w.]+(?:\[\])?\s+(\w*)$/)),A=C[0]===`query`&&optionalPrefix(c.match(/^\s*(?:by|filter)\s+[a-z_]\w*\s+[\w.]+(?:\[\])?\s+(\w*)$/))||optionalPrefix(c.match(/^\s*query\s+[A-Za-z_]\w*\s*=>\s*(?:observable\s+)?[\w.]+(?:\[\])?\s+(\w*)$/)),j=(C[0]===`event`||C[0]===`produces`&&/^produces\s+event\b/.test(i(o,u,s,S)??``))&&!D?c.match(/^\s*@?[a-z_]\w*\s+([\w.]+)\s+(\w*)$/):null,M=l.concepts.find(e=>e.name===j?.[1]),N=M?.primitive??j?.[1],P=(N===`String`||N===`Uuid`||N===`Int`&&M!==void 0)&&!M?.attributes.some(e=>[`pii`,`personal`,`secret`,`sensitive`].includes(e.replace(/^@/,``))),F=j!==null&&P&&`subject`.startsWith(j[2]),R=C[0]===`readmodel`?c.match(/^\s*@?[a-z_]\w*\s+[\w.]+\s+(\w*)$/):null,z=[...R&&`key`.startsWith(R[1])?[{label:`key`,insertText:`key`,documentation:`Declares a required read-model key part. Explicit keys replace inference. Composite keys are authoring-only (#599).`}]:[],...(O||A)&&!/=>\s*observable\s+$/.test(c)?ie:[],...F?[{label:`subject`,insertText:`subject`,documentation:`One required scalar event data-subject identity; not pii or secret. Report-only lineage metadata (PLAY0270), no ESM or provider output yet.`}]:[]];if(z.length>0)return{kind:`entries`,entries:z};if(/\bauthorize\s+[\w\s]*$/.test(c)||C[0]===`authorize`)return{kind:`policies`};if(/\bwhen\s+\w*$/.test(c)&&C.includes(`reaction`))return{kind:`triggers`};if(/\bon\s+\w*$/.test(c)&&C.includes(`constraint`))return{kind:`events`};if(/\binvokes\s+\w*$/.test(c)&&C.includes(`reaction`))return{kind:`commands`};if(/\b(?:on|unique\s+event)\s+\w*$/.test(c)&&C[0]===`constraint`)return{kind:`events`};if(/\bproduces\s+\w*$/.test(c))return{kind:`producesTargets`};if(/\bnavigate\s+to\s+\w*$/.test(c))return{kind:`screens`};if(C[0]===`specification`){if(/^\s*when\s+query\s+[\w.]*$/.test(c))return{kind:`queries`};let e=c.match(/^\s*(given|when|then)\s+\w*$/);if(e)return{kind:`entries`,entries:ce[e[1]]}}if(/\b(?:via|then)\s+query\s+[\w.]*$/.test(c))return{kind:`queries`};if((C[0]===`event`||C[0]===`command`||C[0]===`type`)&&/^\s+[a-z_]\w*\s+[\w[\]?]*$/.test(c)||C[0]===`query`&&/^\s+(?:by|filter)\s+[a-z_]\w*\s+[\w[\]?]*$/.test(c))return{kind:`types`};let V=i(o,u,s,S);if(V&&/^produces\s+operation\b/.test(V))return{kind:`entries`,entries:B};if(V&&/^produces\s+event\b/.test(V))return/^\s+@?[a-z_]\w*\s+[\w[\]?]*$/.test(c)?{kind:`types`}:{kind:`entries`,entries:C.includes(`command`)?[...I,$]:I};if(V&&Se.test(V))return{kind:`entries`,entries:ae};let H=t(o,u,s,S);if(C[0]===`for`&&C.includes(`seed`))return{kind:`events`};let U=completionEntriesFor(C,{headers:H,document:o}),W=C[0]===`command`?ye(o,s,` `.repeat(S),``,l):null;return{kind:`entries`,entries:W?[expansionEntry(W.text,S),...U]:U}}export{completionEntriesFor,planCompletions};
|
|
5
5
|
//# sourceMappingURL=completion-planner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion-planner.js","names":["items.moduleItems","items.featureItems","items.sliceItemsFor","items.typeItems","items.commandItems","items.eventItems","scope.readModelItems","scope.reducerItems","scope.formItems","scope.contributeItems","scope.behaviorItems","scope.personaItems","items.identityItems","scope.authenticationItems","scope.seedItems","scope.themeItems","scope.uiProfileItems","scope.profileSampleDataItems","scope.sampleDataItems","scope.sampleShapeItems","scope.outcomeItems","scope.layoutItems","scope.navigationItems","scope.toolbarItems","items.operationItems","items.operationPhaseItems","items.producesItems","items.handlerItems","items.implementationItems","items.operationImplementationItems","items.queryItems","items.performerItems","items.constraintItems","items.reactionItems","items.invocationItems","items.triggerItems","items.reactionTriggerItems","items.specificationItems","items.policyItems","items.validateItems","items.actionItems","items.tableItems","scope.templateItems","items.screenItems","items.guardedActionItems","items.actionArgumentItems","items.interactionChoiceItems","items.interactionActionItems","items.refusalItems","items.namedRuleImplementationItems","items.commandRuleItems","items.optionalTypeItems","items.specificationStepItems","items.inlineEventItems","items.ruleItems","productionRouteItem","RULE_LINE_PATTERN","document","keyword","line","topLevelItems","item","header","relative","text","index","indent","indentOf","construct","chain","where","subLanguage","getSubLanguage","purposeItems","moduleScopeItems","featureScopeItems","sliceItemsFor","conceptItems","typeItems","commandItems","eventItems","readModelItems","reducerItems","formItems","contributeItems","behaviorItems","personaItems","identityItems","authenticationItems","seedItems","themeItems","uiProfileItems","profileSampleDataItems","sampleDataItems","sampleShapeItems","outcomeItems","layoutItems","navigationItems","toolbarItems","operationItems","operationPhaseItems","producesItems","handlerItems","implementationItems","operationImplementationItems","queryItems","performerItems","constraintItems","reactionItems","invocationItems","triggerItems","reactionTriggerItems","specificationItems","policyItems","validateItems","actionItems","tableItems","templateItems","screenItems","candidate","scanDocument","lines","fences","fenceMap","lineIndex","withoutComment","textBefore","marker","generationChain","enclosingChain","inConcept","nearestEnclosingLine","generationEntries","generationCompletions","scope","category","continuationEntries","continuationResponseCompletions","symbols","responseEntries","exampleCompletions","responseCompletions","keyEntries","readModelKeyCompletions","dependencyEntries","dependencyTargetCompletions","importPath","refusal","refusalContext","member","contextVariableMatch","currentLine","effectiveIndent","parentIndent","guarded","parent","guardedActionItems","actionArgumentItems","interactionChoiceItems","interactionActionItems","refusalItems","ruleContext","namedRuleContext","namedRuleImplementationItems","commandRuleItems","propertyOwner","propertyName","reservedProperty","match","afterPropertyType","afterQueryType","subjectModifier","subjectConcept","concept","subjectType","subjectTarget","attribute","afterSubjectType","keyModifier","modifierEntries","optionalTypeItems","step","specificationStepItems","enclosingLine","inlineEventItems","ruleItems","headers","enclosingHeaders","entries","expansion","structureCompletion"],"sources":["../../completion-planner.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 { enclosingChain, enclosingHeaders, fenceMap, indentOf, nearestEnclosingLine, withoutComment } from './document-context';\nimport { refusalContext } from './refusal-context';\nimport { generationCompletions } from './generation-completions';\nimport { namedRuleContext } from './named-rule-context';\nimport { continuationResponseCompletions } from './continuation-responses';\nimport { responseCompletions } from './response-completions';\nimport { dependencyTargetCompletions } from './dependency-completions';\nimport { exampleCompletions } from './example-authoring';\nimport { DocumentSymbols, scanDocument } from './symbols';\nimport { structureCompletion } from './structure-completions';\nimport { getSubLanguage } from './sub-language-registry';\nimport * as items from './completion-items';\nimport * as scope from './scope-items';\nimport { CompletionEntry } from './completion-items';\nimport { purposeItems } from './purpose-items';\nimport { readModelKeyCompletions } from './read-model-key-completions';\n\n// Matches a validation rule line ending in \"rule <Name>\" (optionally followed by a\n// message clause) - both the command form (\"<property> rule <Name>\") and the\n// concept implied-subject form (\"rule <Name>\"). Its first word is the property\n// name, not \"rule\", so it can't be recognized through the chain[0] keyword switch\n// the way \"on <EventType>\" or \"handler\" are - hence the dedicated regex check.\nconst productionRouteItem = { label: 'stream', insertText: 'stream ${1:Source.Stream}', documentation: 'Replace the whole command route for this event production. ESM v10.' };\n\nconst RULE_LINE_PATTERN = /(?:^|\\s)rule\\s+[A-Za-z_]\\w*(?:\\s+severity\\s+(?:information|warning|error))?(?:\\s+message\\s+.*)?$/;\n\nexport type CompletionPlan =\n | { kind: 'none' }\n | { kind: 'entries'; entries: CompletionEntry[] }\n | { kind: 'contextVariables'; replaceLength: number }\n | { kind: 'playFiles'; replaceLength: number }\n | { kind: 'policies' }\n | { kind: 'events' }\n | { kind: 'triggers' }\n | { kind: 'commands' }\n | { kind: 'producesTargets' }\n | { kind: 'screens' }\n | { kind: 'queries' }\n | { kind: 'types' };\n\n// What the position sits inside, beyond the keyword chain: the whole header of each enclosing block, so a\n// slice's type and a template's kind are known, and the document's own lines, so a declaration that may\n// appear once is not offered again.\nexport interface CompletionScope {\n headers: readonly string[];\n document: readonly string[];\n}\n\nconst declaredIn = (document: readonly string[], keyword: string) => document.some(line => new RegExp(`^${keyword}\\\\b`).test(line));\n\nfunction topLevelEntries(document: readonly string[]): CompletionEntry[] {\n return items.topLevelItems.filter(item => !(item.label === 'domain' && declaredIn(document, 'domain')) && !(item.label === 'authentication' && declaredIn(document, 'authentication')) && !(item.label === 'identity' && declaredIn(document, 'identity')));\n}\n\nconst isTemplate = (header: string | undefined) => /^(?:screen|dialog)\\s+template\\b/.test(header ?? '');\n\n// A whole block as one completion entry. Continuation lines are indented relative to the line it is inserted on,\n// which is how the editors indent a multi-line snippet.\nfunction expansionEntry(text: string, indent: number): CompletionEntry {\n const relative = text.split('\\n').map((line, index) => (index === 0 ? line : line.slice(Math.min(indent, indentOf(line))))).join('\\n');\n const label = text.split('\\n')[0].trim();\n return { label, insertText: relative.replace(/[$}\\\\]/g, '\\\\$&'), documentation: 'Expands the whole block from what the command and its events declare.' };\n}\n\nexport function completionEntriesFor(chain: string[], where: CompletionScope = { headers: [], document: [] }): CompletionEntry[] {\n const construct = chain[0];\n if (construct === undefined || construct === 'domain') return topLevelEntries(where.document);\n const subLanguage = getSubLanguage(construct);\n if (subLanguage) return subLanguage.completions ?? [];\n const header = where.headers[0];\n switch (construct) {\n case 'purpose':\n return purposeItems;\n case 'module':\n return items.moduleItems;\n case 'feature':\n return items.featureItems;\n case 'slice':\n return items.sliceItemsFor(header?.split(/\\s+/)[1]);\n case 'concept':\n return /:\\s*Enum\\b/.test(header ?? '') ? [...items.conceptItems.filter(item => item.label !== 'validate checksum'), { label: 'enum member (numbered)', insertText: '${1:value} = ${2:0}', documentation: 'Every member must declare a unique int32 number. Keep published numbers unchanged; specifications name members, not numbers.' }] : items.conceptItems.filter(item => item.label !== 'validate checksum' || /:\\s*String\\b/.test(header ?? ''));\n case 'type':\n return items.typeItems;\n case 'command':\n return items.commandItems;\n case 'public':\n case 'event':\n return items.eventItems;\n case 'readmodel':\n return scope.readModelItems;\n case 'reducer':\n return scope.reducerItems;\n case 'form':\n return scope.formItems;\n case 'contribute':\n return scope.contributeItems;\n case 'behavior':\n return scope.behaviorItems;\n case 'persona':\n return scope.personaItems;\n case 'identity':\n return items.identityItems;\n case 'authentication':\n return scope.authenticationItems;\n case 'seed':\n return scope.seedItems;\n case 'theme':\n return scope.themeItems;\n case 'ui':\n return scope.uiProfileItems;\n case 'sample':\n return chain.includes('ui') ? scope.profileSampleDataItems : scope.sampleDataItems;\n case 'shape':\n return chain[1] === 'sample' ? scope.sampleShapeItems : [];\n case 'on':\n case 'success':\n case 'failure':\n case 'confirm':\n return scope.outcomeItems;\n case 'layout':\n return scope.layoutItems;\n case 'navigation':\n return scope.navigationItems;\n case 'toolbar':\n return scope.toolbarItems;\n case 'system':\n return items.operationItems.filter(item => item.label === 'description');\n case 'operation':\n return items.operationItems;\n case 'execute':\n case 'compensate':\n return items.operationPhaseItems;\n case 'produces':\n return chain.includes('command') ? [...items.producesItems, productionRouteItem] : items.producesItems;\n case 'handler':\n return items.handlerItems;\n case 'implementation':\n return chain[1] === 'handler' ? items.implementationItems : ['execute', 'compensate'].includes(chain[1]) ? items.operationImplementationItems : [];\n case 'reads':\n return [{ label: 'by parts', insertText: 'by\\n ${1:part} = ${2:source}\\n ${3:part} = ${4:source}', documentation: 'Supply every composite read-model key part by name.' }];\n case 'query':\n return items.queryItems;\n case 'performer':\n return items.performerItems;\n case 'constraint':\n return items.constraintItems;\n case 'reaction':\n return items.reactionItems;\n case 'invokes':\n return chain.includes('reaction') ? items.invocationItems : [];\n case 'trigger':\n return items.triggerItems;\n case 'when':\n case 'every':\n case 'at':\n return chain.includes('reaction') ? items.reactionTriggerItems : [];\n case 'specification':\n return items.specificationItems;\n case 'policy':\n return items.policyItems;\n case 'validate':\n return chain.includes('concept') && /:\\s*String\\b/.test(where.headers.find(header => /^concept\\s/.test(header)) ?? '')\n ? [...items.validateItems, { label: 'checksum', insertText: 'checksum ${1|luhn,mod11,mod97|}', documentation: 'Exact trailing check digits over preceding ASCII digits. String concepts only; also validates inputs and stored values.' }]\n : items.validateItems;\n case 'action':\n return items.actionItems;\n case 'table':\n case 'summary':\n return items.tableItems;\n case 'screen':\n return isTemplate(header) ? scope.templateItems : items.screenItems;\n case 'dialog':\n return scope.templateItems;\n default:\n if (isTemplate(where.headers.find(candidate => isTemplate(candidate)))) return scope.templateItems;\n // Sections inside a screen expose the screen vocabulary.\n if (chain.includes('screen') || construct === 'section') return items.screenItems;\n if (chain.includes('produces')) return chain.includes('command') ? [...items.producesItems, productionRouteItem] : items.producesItems;\n return [];\n }\n}\n\n// Decides what to complete at a position, without any editor dependency — the\n// Monaco service and the VSCode extension both materialize the plan into items.\nexport function planCompletions(\n lines: string[],\n lineIndex: number,\n textBefore: string,\n symbols: DocumentSymbols = scanDocument(lines),\n): CompletionPlan {\n const fences = fenceMap(lines);\n if (fences[lineIndex] || withoutComment(textBefore).length < textBefore.length) return { kind: 'none' };\n if (/^\\s*concept\\s+[\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}]+\\s*:\\s*\\w+\\s+(?:(?:pii|personal|secret)\\s+)*\\w*$/u.test(textBefore)) {\n return { kind: 'entries', entries: ['pii', 'secret'].filter(marker => !new RegExp(`\\\\b${marker}\\\\b`).test(textBefore)).map(marker => ({ label: marker, insertText: marker, documentation: marker === 'pii' ? 'personal data (GDPR Art. 4(1)); renders Chronicle [PII]' : 'Operational secret; renders [Encrypted] + [NotAudited].' })) };\n }\n const generationChain = enclosingChain(lines, fences, lineIndex, indentOf(textBefore));\n const inConcept = generationChain[0] === 'concept';\n if (generationChain[0] === 'generate' && generationChain[1] === 'concept' && /^generate\\s+rule\\s+/.test((nearestEnclosingLine(lines, fences, lineIndex, indentOf(textBefore)) ?? '').trim())) {\n return { kind: 'entries', entries: [\n { label: 'file', insertText: 'file ${1:Generator.cs}', documentation: 'The sole ValueGeneration source. Receives GenerationContext with Now and Tenant; returns String.' },\n { label: 'csharp', insertText: '```csharp\\n${1:return value;}\\n```', documentation: 'The sole ValueGeneration body. Reference execution requires fixtures; it never invokes this code.' },\n ] };\n }\n const generationEntries = inConcept || (generationChain[0] === 'validate' && generationChain[1] === 'concept') ? generationCompletions(lines, lineIndex, textBefore) : null;\n if (generationEntries !== null) return { kind: 'entries', entries: generationEntries };\n if (inConcept && /^\\s*(?:secret|sensitive|@sensitive)\\s+scope\\s+\\w*$/.test(textBefore)) {\n return { kind: 'entries', entries: ['subject', 'namespace', 'global'].map(scope => ({ label: scope, insertText: scope, documentation: 'Explicit secret encryption scope.' })) };\n }\n if (inConcept && /^\\s*(?:pii|personal|@pii)\\s+special\\s+\\w*$/.test(textBefore)) {\n return { kind: 'entries', entries: ['racialOrEthnicOrigin', 'politicalOpinions', 'religiousOrPhilosophicalBeliefs', 'tradeUnionMembership', 'genetic', 'biometric', 'health', 'sexLifeOrSexualOrientation'].map(category => ({ label: category, insertText: category, documentation: 'GDPR Art. 9(1) special category.' })) };\n }\n const continuationEntries = continuationResponseCompletions(lines, lineIndex, textBefore, symbols);\n if (continuationEntries !== null) return { kind: 'entries', entries: continuationEntries };\n const responseEntries = exampleCompletions(lines, lineIndex, textBefore) ?? responseCompletions(lines, lineIndex, textBefore, scanDocument(lines));\n if (responseEntries !== null) return { kind: 'entries', entries: responseEntries };\n const keyEntries = readModelKeyCompletions(lines, lineIndex, textBefore, symbols);\n if (keyEntries !== null) return { kind: 'entries', entries: keyEntries };\n const dependencyEntries = dependencyTargetCompletions(lines, lineIndex, textBefore, symbols);\n if (dependencyEntries !== null) return { kind: 'entries', entries: dependencyEntries };\n\n // Inside the quotes of a file import, what is wanted is a path - replacing what has been typed so far.\n const importPath = textBefore.match(/^\\s*import\\s+\"([^\"]*)$/);\n if (importPath) {\n return { kind: 'playFiles', replaceLength: importPath[1].length };\n }\n\n // A quote or a slash only asks for a completion inside an import path.\n if (/[\"/]$/.test(textBefore)) return { kind: 'none' };\n\n const refusal = refusalContext(lines, lineIndex, indentOf(lines[lineIndex] ?? textBefore));\n if (/\\$refusal\\.\\w*$/.test(textBefore)) {\n return { kind: 'entries', entries: refusal === undefined ? [] : ['reason', 'message', ...(/^on\\s+refused\\s+by\\s+constraint(?:\\s|$)/.test(refusal) ? ['constraint'] : [])].map(member => ({ label: member, insertText: member, documentation: 'String refusal value in branch event mappings; executable from ESM v19. Constraint is available only in a by constraint branch.' })) };\n }\n const contextVariableMatch = textBefore.match(/\\$[\\w.]*$/);\n if (contextVariableMatch) {\n return { kind: 'contextVariables', replaceLength: contextVariableMatch[0].length };\n }\n\n const currentLine = lines[lineIndex] ?? '';\n const effectiveIndent =\n textBefore.trim().length === 0 ? textBefore.length : indentOf(currentLine);\n const chain = enclosingChain(lines, fences, lineIndex, effectiveIndent);\n if (chain.includes('screen')) {\n let parentIndent = effectiveIndent;\n let guarded = false;\n for (let index = lineIndex - 1; index >= 0; index--) {\n if (fences[index]) continue;\n const parent = withoutComment(lines[index]);\n if (parent.trim().length === 0 || indentOf(parent) >= parentIndent) continue;\n parentIndent = indentOf(parent);\n if (/^\\s*action\\s+(?:\"|\\$strings\\.)/.test(parent)) { guarded = true; break; }\n if (/^\\s*screen\\b/.test(parent)) break;\n }\n if (guarded) {\n if (/^\\s*(?:when\\b.*|otherwise)\\s+execute\\s+[\\w.]*$/.test(textBefore)) return { kind: 'commands' };\n if (chain[0] === 'action') return { kind: 'entries', entries: items.guardedActionItems };\n if (['when', 'otherwise'].includes(chain[0])) {\n const parent = nearestEnclosingLine(lines, fences, lineIndex, effectiveIndent) ?? '';\n return { kind: 'entries', entries: /\\bexecute\\s+[\\w.]+$/.test(parent) ? items.actionArgumentItems : [] };\n }\n }\n }\n if (['on', 'when', 'otherwise'].includes(chain[0])) {\n let parentIndent = effectiveIndent;\n for (let index = lineIndex - 1; index >= 0; index--) {\n if (fences[index]) continue;\n const parent = withoutComment(lines[index]);\n if (parent.trim().length === 0 || indentOf(parent) >= parentIndent) continue;\n parentIndent = indentOf(parent);\n if (/^\\s*on\\s+(?:click|double click|select)\\s*$/.test(parent)) {\n return { kind: 'entries', entries: chain[0] === 'on' ? items.interactionChoiceItems : items.interactionActionItems };\n }\n if (/^\\s*(?:screen|behavior|specification|reaction)\\b/.test(parent)) break;\n }\n }\n if (chain[0] === 'on' && refusal !== undefined) return { kind: 'entries', entries: items.refusalItems };\n const ruleContext = namedRuleContext(lines, lineIndex, effectiveIndent);\n if (ruleContext === 'implementation') return { kind: 'entries', entries: items.namedRuleImplementationItems };\n if (ruleContext === 'rule') return { kind: 'entries', entries: items.commandRuleItems };\n\n const propertyOwner = ['public', 'event', 'command', 'type', 'readmodel', 'trigger', 'when', 'every', 'at'].includes(chain[0]) ||\n (chain[0] === 'produces' && /^produces\\s+event\\b/.test(nearestEnclosingLine(lines, fences, lineIndex, effectiveIndent) ?? ''));\n const propertyName = textBefore.trimStart().split(/\\s+/)[0];\n const reservedProperty = (chain[0] === 'command' && ['reads', 'authorize', 'produces'].includes(propertyName)) ||\n (chain[0] === 'event' && propertyName === 'tag') ||\n (['trigger', 'when', 'every', 'at'].includes(chain[0]) && ['description', 'file', 'reads', 'produces', 'invokes'].includes(propertyName));\n const optionalPrefix = (match: RegExpMatchArray | null) => match !== null && 'optional'.startsWith(match[1]);\n const afterPropertyType = propertyOwner && !reservedProperty && optionalPrefix(textBefore.match(/^\\s*@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+(\\w*)$/));\n const afterQueryType = (chain[0] === 'query' && optionalPrefix(textBefore.match(/^\\s*(?:by|filter)\\s+[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+(\\w*)$/))) ||\n optionalPrefix(textBefore.match(/^\\s*query\\s+[A-Za-z_]\\w*\\s*=>\\s*(?:observable\\s+)?[\\w.]+(?:\\[\\])?\\s+(\\w*)$/));\n const eventPropertyOwner = chain[0] === 'event' || (chain[0] === 'produces' && /^produces\\s+event\\b/.test(nearestEnclosingLine(lines, fences, lineIndex, effectiveIndent) ?? ''));\n const subjectModifier = eventPropertyOwner && !reservedProperty ? textBefore.match(/^\\s*@?[a-z_]\\w*\\s+([\\w.]+)\\s+(\\w*)$/) : null;\n const subjectConcept = symbols.concepts.find(concept => concept.name === subjectModifier?.[1]);\n const subjectType = subjectConcept?.primitive ?? subjectModifier?.[1];\n const subjectTarget = (subjectType === 'String' || subjectType === 'Uuid' || (subjectType === 'Int' && subjectConcept !== undefined)) &&\n !subjectConcept?.attributes.some(attribute => ['pii', 'personal', 'secret', 'sensitive'].includes(attribute.replace(/^@/, '')));\n const afterSubjectType = subjectModifier !== null && subjectTarget && 'subject'.startsWith(subjectModifier[2]);\n const keyModifier = chain[0] === 'readmodel' ? textBefore.match(/^\\s*@?[a-z_]\\w*\\s+[\\w.]+\\s+(\\w*)$/) : null;\n const modifierEntries = [\n ...(keyModifier && 'key'.startsWith(keyModifier[1]) ? [{ label: 'key', insertText: 'key', documentation: 'Declares a required read-model key part. Explicit keys replace inference. Composite keys are authoring-only (#599).' }] : []),\n ...((afterPropertyType || afterQueryType) && !/=>\\s*observable\\s+$/.test(textBefore) ? items.optionalTypeItems : []),\n ...(afterSubjectType ? [{ label: 'subject', insertText: 'subject', documentation: 'One required scalar event data-subject identity; not pii or secret. Report-only lineage metadata (PLAY0270), no ESM or provider output yet.' }] : []),\n ];\n if (modifierEntries.length > 0) return { kind: 'entries', entries: modifierEntries };\n\n if (/\\bauthorize\\s+[\\w\\s]*$/.test(textBefore) || chain[0] === 'authorize') {\n return { kind: 'policies' };\n }\n if (/\\bwhen\\s+\\w*$/.test(textBefore) && chain.includes('reaction')) {\n return { kind: 'triggers' };\n }\n if (/\\bon\\s+\\w*$/.test(textBefore) && chain.includes('constraint')) {\n return { kind: 'events' };\n }\n if (/\\binvokes\\s+\\w*$/.test(textBefore) && chain.includes('reaction')) {\n return { kind: 'commands' };\n }\n if (/\\b(?:on|unique\\s+event)\\s+\\w*$/.test(textBefore) && chain[0] === 'constraint') {\n return { kind: 'events' };\n }\n if (/\\bproduces\\s+\\w*$/.test(textBefore)) {\n return { kind: 'producesTargets' };\n }\n if (/\\bnavigate\\s+to\\s+\\w*$/.test(textBefore)) {\n return { kind: 'screens' };\n }\n if (chain[0] === 'specification') {\n if (/^\\s*when\\s+query\\s+[\\w.]*$/.test(textBefore)) return { kind: 'queries' };\n const step = textBefore.match(/^\\s*(given|when|then)\\s+\\w*$/);\n if (step) return { kind: 'entries', entries: items.specificationStepItems[step[1] as 'given' | 'when' | 'then'] };\n }\n if (/\\b(?:via|then)\\s+query\\s+[\\w.]*$/.test(textBefore)) {\n return { kind: 'queries' };\n }\n if (\n (chain[0] === 'event' || chain[0] === 'command' || chain[0] === 'type') &&\n /^\\s+[a-z_]\\w*\\s+[\\w[\\]?]*$/.test(textBefore)\n ) {\n return { kind: 'types' };\n }\n if (chain[0] === 'query' && /^\\s+(?:by|filter)\\s+[a-z_]\\w*\\s+[\\w[\\]?]*$/.test(textBefore)) {\n return { kind: 'types' };\n }\n\n const enclosingLine = nearestEnclosingLine(lines, fences, lineIndex, effectiveIndent);\n if (enclosingLine && /^produces\\s+operation\\b/.test(enclosingLine)) return { kind: 'entries', entries: items.operationItems };\n if (enclosingLine && /^produces\\s+event\\b/.test(enclosingLine)) {\n if (/^\\s+@?[a-z_]\\w*\\s+[\\w[\\]?]*$/.test(textBefore)) return { kind: 'types' };\n return { kind: 'entries', entries: chain.includes('command') ? [...items.inlineEventItems, productionRouteItem] : items.inlineEventItems };\n }\n if (enclosingLine && RULE_LINE_PATTERN.test(enclosingLine)) {\n return { kind: 'entries', entries: items.ruleItems };\n }\n\n const headers = enclosingHeaders(lines, fences, lineIndex, effectiveIndent);\n if (chain[0] === 'for' && chain.includes('seed')) return { kind: 'events' };\n const entries = completionEntriesFor(chain, { headers, document: lines });\n const expansion = chain[0] === 'command' ? structureCompletion(lines, lineIndex, ' '.repeat(effectiveIndent), '', symbols) : null;\n return { kind: 'entries', entries: expansion ? [expansionEntry(expansion.text, effectiveIndent), ...entries] : entries };\n}\n"],"mappings":"wqEAyBA,MAAMuD,EAAsB,CAAE,MAAO,SAAU,WAAY,4BAA6B,cAAe,qEAAsE,EAEvKC,GAAoB,mGAwBpB,YAAc,EAA6B,IAAoBC,EAAS,KAAK,GAAY,OAAO,IAAIC,EAAQ,IAAI,CAAC,CAAC,KAAKC,CAAI,CAAC,EAElI,SAAS,gBAAgB,EAAgD,CACrE,OAAAC,GAA2B,OAAO,GAAQ,EAAEC,EAAK,QAAU,UAAY,WAAWJ,EAAU,QAAQ,IAAM,EAAEI,EAAK,QAAU,kBAAoB,WAAWJ,EAAU,gBAAgB,IAAM,EAAEI,EAAK,QAAU,YAAc,WAAWJ,EAAU,UAAU,EAAE,CAC9P,CAEA,MAAM,WAAc,GAA+B,kCAAkC,KAAKK,GAAU,EAAE,EAItG,SAAS,eAAe,EAAc,EAAiC,CACnE,IAAMC,EAAWC,EAAK,MAAM;CAAI,CAAC,CAAC,KAAK,EAAM,IAAWC,IAAU,EAAIN,EAAOA,EAAK,MAAM,KAAK,IAAIO,EAAQC,EAASR,CAAI,CAAC,CAAC,CAAE,CAAC,CAAC,KAAK;CAAI,EAErI,MAAO,CAAE,MADKK,EAAK,MAAM;CAAI,CAAC,CAAC,EAAE,CAAC,KACrB,EAAG,WAAYD,EAAS,QAAQ,UAAW,MA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I5CzD,EAAM,KAAO,SAAW,6CAA6C,KAAKyD,CAAU,EACpF,MAAO,CAAE,KAAM,OAAQ,EAG3B,IAAMyD,EAAgBpD,EAAqBV,EAAOC,EAAQE,EAAW4B,CAAe,EACpF,GAAI+B,GAAiB,0BAA0B,KAAKA,CAAa,EAAG,MAAO,CAAE,KAAM,UAAW,QAAS/J,CAAqB,EAC5H,GAAI+J,GAAiB,sBAAsB,KAAKA,CAAa,EAEzD,MADI,+BAA+B,KAAKzD,CAAU,EAAU,CAAE,KAAM,OAAQ,EACrE,CAAE,KAAM,UAAW,QAASzD,EAAM,SAAS,SAAS,EAAI,CAAC,GAAGhB,EAAwBE,CAAmB,EAAIF,CAAuB,EAE7I,GAAIkI,GAAiB/H,GAAkB,KAAK+H,CAAa,EACrD,MAAO,CAAE,KAAM,UAAW,QAASjI,EAAgB,EAGvD,IAAMoI,EAAUC,EAAiBlE,EAAOC,EAAQE,EAAW4B,CAAe,EAC1E,GAAInF,EAAM,KAAO,OAASA,EAAM,SAAS,MAAM,EAAG,MAAO,CAAE,KAAM,QAAS,EAC1E,IAAMuH,EAAU,qBAAqBvH,EAAO,CAAE,UAAS,SAAUoD,CAAM,CAAC,EAClEoE,EAAYxH,EAAM,KAAO,UAAYyH,GAAoBrE,EAAOG,EAAW,IAAI,OAAO4B,CAAe,EAAG,GAAId,CAAO,EAAI,KAC7H,MAAO,CAAE,KAAM,UAAW,QAASmD,EAAY,CAAC,eAAeA,EAAU,KAAMrC,CAAe,EAAG,GAAGoC,CAAO,EAAIA,CAAQ,CAC3H"}
|
|
1
|
+
{"version":3,"file":"completion-planner.js","names":["items.moduleItems","items.featureItems","items.sliceItemsFor","items.typeItems","items.commandItems","items.eventItems","scope.readModelItems","scope.reducerItems","scope.formItems","scope.contributeItems","scope.behaviorItems","scope.personaItems","items.identityItems","scope.authenticationItems","scope.seedItems","scope.themeItems","scope.uiProfileItems","scope.profileSampleDataItems","scope.sampleDataItems","scope.sampleShapeItems","scope.outcomeItems","scope.layoutItems","scope.navigationItems","scope.toolbarItems","items.operationItems","items.operationPhaseItems","items.producesItems","items.handlerItems","items.implementationItems","items.operationImplementationItems","items.queryItems","items.performerItems","items.constraintItems","items.reactionItems","items.invocationItems","items.triggerItems","items.reactionTriggerItems","items.specificationItems","items.policyItems","items.validateItems","items.actionItems","items.tableItems","scope.templateItems","items.screenItems","items.guardedActionItems","items.actionArgumentItems","items.interactionChoiceItems","items.interactionActionItems","items.refusalItems","items.namedRuleImplementationItems","items.commandRuleItems","items.optionalTypeItems","items.specificationStepItems","items.inlineEventItems","items.ruleItems","productionRouteItem","RULE_LINE_PATTERN","document","keyword","line","topLevelItems","item","header","relative","text","index","indent","indentOf","construct","chain","where","subLanguage","getSubLanguage","purposeItems","moduleScopeItems","featureScopeItems","sliceItemsFor","conceptItems","typeItems","commandItems","eventItems","readModelItems","reducerItems","formItems","contributeItems","behaviorItems","personaItems","identityItems","authenticationItems","seedItems","themeItems","uiProfileItems","profileSampleDataItems","sampleDataItems","sampleShapeItems","outcomeItems","layoutItems","navigationItems","toolbarItems","operationItems","operationPhaseItems","producesItems","handlerItems","implementationItems","operationImplementationItems","queryItems","performerItems","constraintItems","reactionItems","invocationItems","triggerItems","reactionTriggerItems","specificationItems","policyItems","validateItems","actionItems","tableItems","templateItems","screenItems","candidate","scanDocument","lines","fences","fenceMap","lineIndex","withoutComment","textBefore","marker","generationChain","enclosingChain","inConcept","nearestEnclosingLine","generationEntries","generationCompletions","scope","category","continuationEntries","continuationResponseCompletions","symbols","responseEntries","exampleCompletions","responseCompletions","keyEntries","readModelKeyCompletions","dependencyEntries","dependencyTargetCompletions","importPath","refusal","refusalContext","member","contextVariableMatch","currentLine","effectiveIndent","parentIndent","guarded","parent","guardedActionItems","actionArgumentItems","interactionChoiceItems","interactionActionItems","refusalItems","ruleContext","namedRuleContext","namedRuleImplementationItems","commandRuleItems","propertyOwner","propertyName","reservedProperty","match","afterPropertyType","afterQueryType","subjectModifier","subjectConcept","concept","subjectType","subjectTarget","attribute","afterSubjectType","keyModifier","modifierEntries","optionalTypeItems","step","specificationStepItems","enclosingLine","inlineEventItems","ruleItems","headers","enclosingHeaders","entries","expansion","structureCompletion"],"sources":["../../completion-planner.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 { enclosingChain, enclosingHeaders, fenceMap, indentOf, nearestEnclosingLine, withoutComment } from './document-context';\nimport { refusalContext } from './refusal-context';\nimport { generationCompletions } from './generation-completions';\nimport { namedRuleContext } from './named-rule-context';\nimport { continuationResponseCompletions } from './continuation-responses';\nimport { responseCompletions } from './response-completions';\nimport { dependencyTargetCompletions } from './dependency-completions';\nimport { exampleCompletions } from './example-authoring';\nimport { DocumentSymbols, scanDocument } from './symbols';\nimport { structureCompletion } from './structure-completions';\nimport { getSubLanguage } from './sub-language-registry';\nimport * as items from './completion-items';\nimport * as scope from './scope-items';\nimport { CompletionEntry } from './completion-items';\nimport { purposeItems } from './purpose-items';\nimport { readModelKeyCompletions } from './read-model-key-completions';\n\n// Matches a validation rule line ending in \"rule <Name>\" (optionally followed by a\n// message clause) - both the command form (\"<property> rule <Name>\") and the\n// concept implied-subject form (\"rule <Name>\"). Its first word is the property\n// name, not \"rule\", so it can't be recognized through the chain[0] keyword switch\n// the way \"on <EventType>\" or \"handler\" are - hence the dedicated regex check.\nconst productionRouteItem = { label: 'stream', insertText: 'stream ${1:Source.Stream}', documentation: 'Replace the whole command route for this event production. ESM v10.' };\n\nconst RULE_LINE_PATTERN = /(?:^|\\s)rule\\s+[A-Za-z_]\\w*(?:\\s+severity\\s+(?:information|warning|error))?(?:\\s+message\\s+.*)?$/;\n\nexport type CompletionPlan =\n | { kind: 'none' }\n | { kind: 'entries'; entries: CompletionEntry[] }\n | { kind: 'contextVariables'; replaceLength: number }\n | { kind: 'playFiles'; replaceLength: number }\n | { kind: 'policies' }\n | { kind: 'events' }\n | { kind: 'triggers' }\n | { kind: 'commands' }\n | { kind: 'producesTargets' }\n | { kind: 'screens' }\n | { kind: 'queries' }\n | { kind: 'types' };\n\n// What the position sits inside, beyond the keyword chain: the whole header of each enclosing block, so a\n// slice's type and a template's kind are known, and the document's own lines, so a declaration that may\n// appear once is not offered again.\nexport interface CompletionScope {\n headers: readonly string[];\n document: readonly string[];\n}\n\nconst declaredIn = (document: readonly string[], keyword: string) => document.some(line => new RegExp(`^${keyword}\\\\b`).test(line));\n\nfunction topLevelEntries(document: readonly string[]): CompletionEntry[] {\n return items.topLevelItems.filter(item => !(item.label === 'domain' && declaredIn(document, 'domain')) && !(item.label === 'authentication' && declaredIn(document, 'authentication')) && !(item.label === 'identity' && declaredIn(document, 'identity')));\n}\n\nconst isTemplate = (header: string | undefined) => /^(?:screen|dialog)\\s+template\\b/.test(header ?? '');\n\n// A whole block as one completion entry. Continuation lines are indented relative to the line it is inserted on,\n// which is how the editors indent a multi-line snippet.\nfunction expansionEntry(text: string, indent: number): CompletionEntry {\n const relative = text.split('\\n').map((line, index) => (index === 0 ? line : line.slice(Math.min(indent, indentOf(line))))).join('\\n');\n const label = text.split('\\n')[0].trim();\n return { label, insertText: relative.replace(/[$}\\\\]/g, '\\\\$&'), documentation: 'Expands the whole block from what the command and its events declare.' };\n}\n\nexport function completionEntriesFor(chain: string[], where: CompletionScope = { headers: [], document: [] }): CompletionEntry[] {\n const construct = chain[0];\n if (construct === undefined || construct === 'domain') return topLevelEntries(where.document);\n const subLanguage = getSubLanguage(construct);\n if (subLanguage) return subLanguage.completions ?? [];\n const header = where.headers[0];\n switch (construct) {\n case 'purpose':\n return purposeItems;\n case 'module':\n return items.moduleItems;\n case 'feature':\n return items.featureItems;\n case 'slice':\n return items.sliceItemsFor(header?.split(/\\s+/)[1]);\n case 'concept':\n return /:\\s*Enum\\b/.test(header ?? '') ? [...items.conceptItems.filter(item => item.label !== 'validate checksum'), { label: 'enum member (numbered)', insertText: '${1:value} = ${2:0}', documentation: 'Every member must declare a unique int32 number. Keep published numbers unchanged; specifications name members, not numbers.' }] : items.conceptItems.filter(item => item.label !== 'validate checksum' || /:\\s*String\\b/.test(header ?? ''));\n case 'type':\n return items.typeItems;\n case 'command':\n return items.commandItems;\n case 'public':\n case 'event':\n return items.eventItems;\n case 'readmodel':\n return scope.readModelItems;\n case 'reducer':\n return scope.reducerItems;\n case 'form':\n return scope.formItems;\n case 'contribute':\n return scope.contributeItems;\n case 'behavior':\n return scope.behaviorItems;\n case 'persona':\n return scope.personaItems;\n case 'identity':\n return items.identityItems;\n case 'authentication':\n return scope.authenticationItems;\n case 'seed':\n return scope.seedItems;\n case 'theme':\n return scope.themeItems;\n case 'ui':\n return scope.uiProfileItems;\n case 'sample':\n return chain.includes('ui') ? scope.profileSampleDataItems : scope.sampleDataItems;\n case 'shape':\n return chain[1] === 'sample' ? scope.sampleShapeItems : [];\n case 'on':\n case 'success':\n case 'failure':\n case 'confirm':\n return scope.outcomeItems;\n case 'layout':\n return scope.layoutItems;\n case 'navigation':\n return scope.navigationItems;\n case 'toolbar':\n return scope.toolbarItems;\n case 'system':\n return items.operationItems.filter(item => item.label === 'description');\n case 'operation':\n return items.operationItems;\n case 'execute':\n case 'compensate':\n return items.operationPhaseItems;\n case 'produces':\n return chain.includes('command') ? [...items.producesItems, productionRouteItem] : items.producesItems;\n case 'handler':\n return items.handlerItems;\n case 'implementation':\n return chain[1] === 'handler' ? items.implementationItems : ['execute', 'compensate'].includes(chain[1]) ? items.operationImplementationItems : [];\n case 'reads':\n return [{ label: 'by parts', insertText: 'by\\n ${1:part} = ${2:source}\\n ${3:part} = ${4:source}', documentation: 'Supply every composite read-model key part by name.' }];\n case 'query':\n return items.queryItems;\n case 'performer':\n return items.performerItems;\n case 'constraint':\n return items.constraintItems;\n case 'reaction':\n return items.reactionItems;\n case 'invokes':\n return chain.includes('reaction') ? items.invocationItems : [];\n case 'trigger':\n return items.triggerItems;\n case 'when':\n case 'every':\n case 'at':\n return chain.includes('reaction') ? items.reactionTriggerItems : [];\n case 'specification':\n return items.specificationItems;\n case 'policy':\n return items.policyItems;\n case 'validate':\n return chain.includes('concept') && /:\\s*String\\b/.test(where.headers.find(header => /^concept\\s/.test(header)) ?? '')\n ? [...items.validateItems, { label: 'checksum', insertText: 'checksum ${1|luhn,mod11,mod97|}', documentation: 'Exact trailing check digits over preceding ASCII digits. String concepts only; also validates inputs and stored values.' }]\n : items.validateItems;\n case 'action':\n return items.actionItems;\n case 'table':\n case 'summary':\n return items.tableItems;\n case 'screen':\n return isTemplate(header) ? scope.templateItems : items.screenItems;\n case 'dialog':\n return scope.templateItems;\n default:\n if (isTemplate(where.headers.find(candidate => isTemplate(candidate)))) return scope.templateItems;\n // Sections inside a screen expose the screen vocabulary.\n if (chain.includes('screen') || construct === 'section') return items.screenItems;\n if (chain.includes('produces')) return chain.includes('command') ? [...items.producesItems, productionRouteItem] : items.producesItems;\n return [];\n }\n}\n\n// Decides what to complete at a position, without any editor dependency — the\n// Monaco service and the VSCode extension both materialize the plan into items.\nexport function planCompletions(\n lines: string[],\n lineIndex: number,\n textBefore: string,\n symbols: DocumentSymbols = scanDocument(lines),\n): CompletionPlan {\n const fences = fenceMap(lines);\n if (fences[lineIndex] || withoutComment(textBefore).length < textBefore.length) return { kind: 'none' };\n if (/^\\s*concept\\s+[\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}]+\\s*:\\s*\\w+\\s+(?:(?:pii|personal|secret)\\s+)*\\w*$/u.test(textBefore)) {\n return { kind: 'entries', entries: ['pii', 'secret'].filter(marker => !new RegExp(`\\\\b${marker}\\\\b`).test(textBefore)).map(marker => ({ label: marker, insertText: marker, documentation: marker === 'pii' ? 'personal data (GDPR Art. 4(1)); renders Chronicle [PII]' : 'Operational secret; renders [Encrypted] + [NotAudited].' })) };\n }\n const generationChain = enclosingChain(lines, fences, lineIndex, indentOf(textBefore));\n const inConcept = generationChain[0] === 'concept';\n if (generationChain[0] === 'generate' && generationChain[1] === 'concept' && /^generate\\s+rule\\s+/.test((nearestEnclosingLine(lines, fences, lineIndex, indentOf(textBefore)) ?? '').trim())) {\n return { kind: 'entries', entries: [\n { label: 'file', insertText: 'file ${1:Generator.cs}', documentation: 'The sole ValueGeneration source. Receives the provider-bound GenerationContext (Now, Tenant); returns String.' },\n { label: 'csharp', insertText: '```csharp\\n${1:return value;}\\n```', documentation: 'The sole ValueGeneration body. Reference execution requires fixtures; it never invokes this code.' },\n ] };\n }\n const generationEntries = inConcept || (generationChain[0] === 'validate' && generationChain[1] === 'concept') ? generationCompletions(lines, lineIndex, textBefore) : null;\n if (generationEntries !== null) return { kind: 'entries', entries: generationEntries };\n if (inConcept && /^\\s*(?:secret|sensitive|@sensitive)\\s+scope\\s+\\w*$/.test(textBefore)) {\n return { kind: 'entries', entries: ['subject', 'namespace', 'global'].map(scope => ({ label: scope, insertText: scope, documentation: 'Explicit secret encryption scope.' })) };\n }\n if (inConcept && /^\\s*(?:pii|personal|@pii)\\s+special\\s+\\w*$/.test(textBefore)) {\n return { kind: 'entries', entries: ['racialOrEthnicOrigin', 'politicalOpinions', 'religiousOrPhilosophicalBeliefs', 'tradeUnionMembership', 'genetic', 'biometric', 'health', 'sexLifeOrSexualOrientation'].map(category => ({ label: category, insertText: category, documentation: 'GDPR Art. 9(1) special category.' })) };\n }\n const continuationEntries = continuationResponseCompletions(lines, lineIndex, textBefore, symbols);\n if (continuationEntries !== null) return { kind: 'entries', entries: continuationEntries };\n const responseEntries = exampleCompletions(lines, lineIndex, textBefore) ?? responseCompletions(lines, lineIndex, textBefore, scanDocument(lines));\n if (responseEntries !== null) return { kind: 'entries', entries: responseEntries };\n const keyEntries = readModelKeyCompletions(lines, lineIndex, textBefore, symbols);\n if (keyEntries !== null) return { kind: 'entries', entries: keyEntries };\n const dependencyEntries = dependencyTargetCompletions(lines, lineIndex, textBefore, symbols);\n if (dependencyEntries !== null) return { kind: 'entries', entries: dependencyEntries };\n\n // Inside the quotes of a file import, what is wanted is a path - replacing what has been typed so far.\n const importPath = textBefore.match(/^\\s*import\\s+\"([^\"]*)$/);\n if (importPath) {\n return { kind: 'playFiles', replaceLength: importPath[1].length };\n }\n\n // A quote or a slash only asks for a completion inside an import path.\n if (/[\"/]$/.test(textBefore)) return { kind: 'none' };\n\n const refusal = refusalContext(lines, lineIndex, indentOf(lines[lineIndex] ?? textBefore));\n if (/\\$refusal\\.\\w*$/.test(textBefore)) {\n return { kind: 'entries', entries: refusal === undefined ? [] : ['reason', 'message', ...(/^on\\s+refused\\s+by\\s+constraint(?:\\s|$)/.test(refusal) ? ['constraint'] : [])].map(member => ({ label: member, insertText: member, documentation: 'String refusal value in branch event mappings; executable from ESM v19. Constraint is available only in a by constraint branch.' })) };\n }\n const contextVariableMatch = textBefore.match(/\\$[\\w.]*$/);\n if (contextVariableMatch) {\n return { kind: 'contextVariables', replaceLength: contextVariableMatch[0].length };\n }\n\n const currentLine = lines[lineIndex] ?? '';\n const effectiveIndent =\n textBefore.trim().length === 0 ? textBefore.length : indentOf(currentLine);\n const chain = enclosingChain(lines, fences, lineIndex, effectiveIndent);\n if (chain.includes('screen')) {\n let parentIndent = effectiveIndent;\n let guarded = false;\n for (let index = lineIndex - 1; index >= 0; index--) {\n if (fences[index]) continue;\n const parent = withoutComment(lines[index]);\n if (parent.trim().length === 0 || indentOf(parent) >= parentIndent) continue;\n parentIndent = indentOf(parent);\n if (/^\\s*action\\s+(?:\"|\\$strings\\.)/.test(parent)) { guarded = true; break; }\n if (/^\\s*screen\\b/.test(parent)) break;\n }\n if (guarded) {\n if (/^\\s*(?:when\\b.*|otherwise)\\s+execute\\s+[\\w.]*$/.test(textBefore)) return { kind: 'commands' };\n if (chain[0] === 'action') return { kind: 'entries', entries: items.guardedActionItems };\n if (['when', 'otherwise'].includes(chain[0])) {\n const parent = nearestEnclosingLine(lines, fences, lineIndex, effectiveIndent) ?? '';\n return { kind: 'entries', entries: /\\bexecute\\s+[\\w.]+$/.test(parent) ? items.actionArgumentItems : [] };\n }\n }\n }\n if (['on', 'when', 'otherwise'].includes(chain[0])) {\n let parentIndent = effectiveIndent;\n for (let index = lineIndex - 1; index >= 0; index--) {\n if (fences[index]) continue;\n const parent = withoutComment(lines[index]);\n if (parent.trim().length === 0 || indentOf(parent) >= parentIndent) continue;\n parentIndent = indentOf(parent);\n if (/^\\s*on\\s+(?:click|double click|select)\\s*$/.test(parent)) {\n return { kind: 'entries', entries: chain[0] === 'on' ? items.interactionChoiceItems : items.interactionActionItems };\n }\n if (/^\\s*(?:screen|behavior|specification|reaction)\\b/.test(parent)) break;\n }\n }\n if (chain[0] === 'on' && refusal !== undefined) return { kind: 'entries', entries: items.refusalItems };\n const ruleContext = namedRuleContext(lines, lineIndex, effectiveIndent);\n if (ruleContext === 'implementation') return { kind: 'entries', entries: items.namedRuleImplementationItems };\n if (ruleContext === 'rule') return { kind: 'entries', entries: items.commandRuleItems };\n\n const propertyOwner = ['public', 'event', 'command', 'type', 'readmodel', 'trigger', 'when', 'every', 'at'].includes(chain[0]) ||\n (chain[0] === 'produces' && /^produces\\s+event\\b/.test(nearestEnclosingLine(lines, fences, lineIndex, effectiveIndent) ?? ''));\n const propertyName = textBefore.trimStart().split(/\\s+/)[0];\n const reservedProperty = (chain[0] === 'command' && ['reads', 'authorize', 'produces'].includes(propertyName)) ||\n (chain[0] === 'event' && propertyName === 'tag') ||\n (['trigger', 'when', 'every', 'at'].includes(chain[0]) && ['description', 'file', 'reads', 'produces', 'invokes'].includes(propertyName));\n const optionalPrefix = (match: RegExpMatchArray | null) => match !== null && 'optional'.startsWith(match[1]);\n const afterPropertyType = propertyOwner && !reservedProperty && optionalPrefix(textBefore.match(/^\\s*@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+(\\w*)$/));\n const afterQueryType = (chain[0] === 'query' && optionalPrefix(textBefore.match(/^\\s*(?:by|filter)\\s+[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+(\\w*)$/))) ||\n optionalPrefix(textBefore.match(/^\\s*query\\s+[A-Za-z_]\\w*\\s*=>\\s*(?:observable\\s+)?[\\w.]+(?:\\[\\])?\\s+(\\w*)$/));\n const eventPropertyOwner = chain[0] === 'event' || (chain[0] === 'produces' && /^produces\\s+event\\b/.test(nearestEnclosingLine(lines, fences, lineIndex, effectiveIndent) ?? ''));\n const subjectModifier = eventPropertyOwner && !reservedProperty ? textBefore.match(/^\\s*@?[a-z_]\\w*\\s+([\\w.]+)\\s+(\\w*)$/) : null;\n const subjectConcept = symbols.concepts.find(concept => concept.name === subjectModifier?.[1]);\n const subjectType = subjectConcept?.primitive ?? subjectModifier?.[1];\n const subjectTarget = (subjectType === 'String' || subjectType === 'Uuid' || (subjectType === 'Int' && subjectConcept !== undefined)) &&\n !subjectConcept?.attributes.some(attribute => ['pii', 'personal', 'secret', 'sensitive'].includes(attribute.replace(/^@/, '')));\n const afterSubjectType = subjectModifier !== null && subjectTarget && 'subject'.startsWith(subjectModifier[2]);\n const keyModifier = chain[0] === 'readmodel' ? textBefore.match(/^\\s*@?[a-z_]\\w*\\s+[\\w.]+\\s+(\\w*)$/) : null;\n const modifierEntries = [\n ...(keyModifier && 'key'.startsWith(keyModifier[1]) ? [{ label: 'key', insertText: 'key', documentation: 'Declares a required read-model key part. Explicit keys replace inference. Composite keys are authoring-only (#599).' }] : []),\n ...((afterPropertyType || afterQueryType) && !/=>\\s*observable\\s+$/.test(textBefore) ? items.optionalTypeItems : []),\n ...(afterSubjectType ? [{ label: 'subject', insertText: 'subject', documentation: 'One required scalar event data-subject identity; not pii or secret. Report-only lineage metadata (PLAY0270), no ESM or provider output yet.' }] : []),\n ];\n if (modifierEntries.length > 0) return { kind: 'entries', entries: modifierEntries };\n\n if (/\\bauthorize\\s+[\\w\\s]*$/.test(textBefore) || chain[0] === 'authorize') {\n return { kind: 'policies' };\n }\n if (/\\bwhen\\s+\\w*$/.test(textBefore) && chain.includes('reaction')) {\n return { kind: 'triggers' };\n }\n if (/\\bon\\s+\\w*$/.test(textBefore) && chain.includes('constraint')) {\n return { kind: 'events' };\n }\n if (/\\binvokes\\s+\\w*$/.test(textBefore) && chain.includes('reaction')) {\n return { kind: 'commands' };\n }\n if (/\\b(?:on|unique\\s+event)\\s+\\w*$/.test(textBefore) && chain[0] === 'constraint') {\n return { kind: 'events' };\n }\n if (/\\bproduces\\s+\\w*$/.test(textBefore)) {\n return { kind: 'producesTargets' };\n }\n if (/\\bnavigate\\s+to\\s+\\w*$/.test(textBefore)) {\n return { kind: 'screens' };\n }\n if (chain[0] === 'specification') {\n if (/^\\s*when\\s+query\\s+[\\w.]*$/.test(textBefore)) return { kind: 'queries' };\n const step = textBefore.match(/^\\s*(given|when|then)\\s+\\w*$/);\n if (step) return { kind: 'entries', entries: items.specificationStepItems[step[1] as 'given' | 'when' | 'then'] };\n }\n if (/\\b(?:via|then)\\s+query\\s+[\\w.]*$/.test(textBefore)) {\n return { kind: 'queries' };\n }\n if (\n (chain[0] === 'event' || chain[0] === 'command' || chain[0] === 'type') &&\n /^\\s+[a-z_]\\w*\\s+[\\w[\\]?]*$/.test(textBefore)\n ) {\n return { kind: 'types' };\n }\n if (chain[0] === 'query' && /^\\s+(?:by|filter)\\s+[a-z_]\\w*\\s+[\\w[\\]?]*$/.test(textBefore)) {\n return { kind: 'types' };\n }\n\n const enclosingLine = nearestEnclosingLine(lines, fences, lineIndex, effectiveIndent);\n if (enclosingLine && /^produces\\s+operation\\b/.test(enclosingLine)) return { kind: 'entries', entries: items.operationItems };\n if (enclosingLine && /^produces\\s+event\\b/.test(enclosingLine)) {\n if (/^\\s+@?[a-z_]\\w*\\s+[\\w[\\]?]*$/.test(textBefore)) return { kind: 'types' };\n return { kind: 'entries', entries: chain.includes('command') ? [...items.inlineEventItems, productionRouteItem] : items.inlineEventItems };\n }\n if (enclosingLine && RULE_LINE_PATTERN.test(enclosingLine)) {\n return { kind: 'entries', entries: items.ruleItems };\n }\n\n const headers = enclosingHeaders(lines, fences, lineIndex, effectiveIndent);\n if (chain[0] === 'for' && chain.includes('seed')) return { kind: 'events' };\n const entries = completionEntriesFor(chain, { headers, document: lines });\n const expansion = chain[0] === 'command' ? structureCompletion(lines, lineIndex, ' '.repeat(effectiveIndent), '', symbols) : null;\n return { kind: 'entries', entries: expansion ? [expansionEntry(expansion.text, effectiveIndent), ...entries] : entries };\n}\n"],"mappings":"wqEAyBA,MAAMuD,EAAsB,CAAE,MAAO,SAAU,WAAY,4BAA6B,cAAe,qEAAsE,EAEvKC,GAAoB,mGAwBpB,YAAc,EAA6B,IAAoBC,EAAS,KAAK,GAAY,OAAO,IAAIC,EAAQ,IAAI,CAAC,CAAC,KAAKC,CAAI,CAAC,EAElI,SAAS,gBAAgB,EAAgD,CACrE,OAAAC,GAA2B,OAAO,GAAQ,EAAEC,EAAK,QAAU,UAAY,WAAWJ,EAAU,QAAQ,IAAM,EAAEI,EAAK,QAAU,kBAAoB,WAAWJ,EAAU,gBAAgB,IAAM,EAAEI,EAAK,QAAU,YAAc,WAAWJ,EAAU,UAAU,EAAE,CAC9P,CAEA,MAAM,WAAc,GAA+B,kCAAkC,KAAKK,GAAU,EAAE,EAItG,SAAS,eAAe,EAAc,EAAiC,CACnE,IAAMC,EAAWC,EAAK,MAAM;CAAI,CAAC,CAAC,KAAK,EAAM,IAAWC,IAAU,EAAIN,EAAOA,EAAK,MAAM,KAAK,IAAIO,EAAQC,EAASR,CAAI,CAAC,CAAC,CAAE,CAAC,CAAC,KAAK;CAAI,EAErI,MAAO,CAAE,MADKK,EAAK,MAAM;CAAI,CAAC,CAAC,EAAE,CAAC,KACrB,EAAG,WAAYD,EAAS,QAAQ,UAAW,MAAM,EAAG,cAAe,uEAAwE,CAC5J,CAEA,SAAgB,qBAAqB,EAAiB,EAAyB,CAAE,QAAS,CAAC,EAAG,SAAU,CAAC,CAAE,EAAsB,CAC7H,IAAMK,EAAYC,EAAM,GACxB,GAAID,IAAc,IAAA,IAAaA,IAAc,SAAU,OAAO,gBAAgBE,EAAM,QAAQ,EAC5F,IAAMC,EAAcC,GAAeJ,CAAS,EAC5C,GAAIG,EAAa,OAAOA,EAAY,aAA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