@cratis/screenplay-language 5.0.0 → 5.2.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/Dependencies/SliceReferences.js +1 -1
- package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
- package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FoldedEventSources.js +2 -0
- package/dist/bundles/compiler/Parsing/FoldedEventSources.js.map +1 -0
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StateMachineParser.js +2 -0
- package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -0
- package/dist/bundles/compiler/Parsing/WorkflowParser.js +2 -0
- package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -0
- package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js +1 -1
- package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
- package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxCollections.js +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
- package/dist/bundles/completion-items.js +22 -16
- package/dist/bundles/completion-items.js.map +1 -1
- package/dist/bundles/completion-planner.js +2 -2
- package/dist/bundles/completion-planner.js.map +1 -1
- package/dist/bundles/keyword-docs.js +1 -1
- package/dist/bundles/keyword-docs.js.map +1 -1
- package/dist/bundles/language.js +1 -1
- package/dist/bundles/language.js.map +1 -1
- package/dist/bundles/tokens.js +1 -1
- package/dist/bundles/tokens.js.map +1 -1
- package/dist/completion-items.d.ts +3 -0
- package/dist/completion-items.d.ts.map +1 -1
- package/dist/completion-planner.d.ts.map +1 -1
- package/dist/keyword-docs.d.ts.map +1 -1
- package/dist/language.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecificationParser.js","names":["parseMappingSource","operationStepPrefix","pattern","operationStep","header","callerPersonaPattern","nativePattern","prefix","exactly","dotNetWhitespace","givenPattern","whenAppendPattern","whenPattern","thenEventPattern","thenQueryPrefix","readModelPrefix","givenReadModelPattern","thenReadModelPattern","thenNoPrefix","thenErrorPattern","stringBodyPattern","mappingPattern","nativeMappingPattern","givenTimeZonePrefix","givenTimeZonePattern","givenClockPrefix","givenCapturePrefix","thenInvokesPrefix","thenInvokesPattern","givenGeneratedPrefix","givenGeneratedPattern","givenGeneratedBlockPattern","whenClockPrefix","whenTriggerPrefix","whenCapturePrefix","whenQueryPrefix","thenResultPrefix","noResultPrefix","whenRedeliveredPrefix","whenRedeliveredPattern","noEventsPrefix","clockPattern","whenTriggerPattern","capturePattern","whenQueryPattern","thenResultPattern","thenAbsentReadModelPattern","absentKeyStringPattern","thenQueryPattern","name","line","context","DiagnosticCodes","locationOf","description","parameters","cases","body","child","isFileDirective","keyword","firstWord","parameter","parseParameter","row","parseCase","parseDescription","_","_noEventsLine","members","specification","validateTable","action","query","outcome","match","values","value","parseConcreteMapping","rejectOperationChildren","unescapeString","pinned","capture","readModel","event","callerRolePattern","callerClaimPattern","authenticated","roles","claims","role","claim","containsCaseReference","appends","code","generatedValues","thenReturnsPrefix","expectation","parseReturn","invocation","caseValue","parseSpecificationValue","error","absent","parseStructuredValue","key","exact","at","message","args","results","hasArguments","keyText","concrete","hasChildren","indent","block","location","source","parseConcrete","regex","expected","create","queryArguments","specificationStream","sourceStreamPattern","specificationStreamId","addInlineValue","parent","inline","eventSource","stream","noStream","hasRoute","structured","generated","generatedFixturePrefix","fixture","generatedFixturePattern","mapping","addFixtureValue","eventKeyword","route","tryParseStructuredMapping","diagnosticText","streamId","streamIdParts","directiveLocations","parseRouteParts","part","nativeIdentifiers","queryArgumentsContext","existing"],"sources":["../../../../../../Compiler/Parsing/SpecificationParser.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 { parseRouteParts } from './EventSourceParser';\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport {\n SpecificationCaptureSyntax, SpecificationClockSyntax, SpecificationTimeZoneSyntax, SpecificationGeneratedValueSyntax, SpecificationCommandSyntax, SpecificationErrorSyntax, SpecificationEventSyntax, SpecificationStreamSyntax, SpecificationNoStreamSyntax,\n SpecificationNoResultSyntax, SpecificationQueryResultSyntax, SpecificationReadModelSyntax, SpecificationSyntax, SpecificationTriggerSyntax,\n SpecificationWhenQuerySyntax, SpecificationCallerPersonaSyntax, SpecificationOperationFailureSyntax, SpecificationOperationSyntax, SpecificationCompensatedSyntax, SpecificationRedeliverySyntax,\n} from '../Syntax/Specifications';\nimport { SpecificationDeniedSyntax, SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { dotNetWhitespace, nativePattern, pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { containsCaseReference, parseCase, parseParameter, parseSpecificationValue as parseMappingSource, validateTable } from './SpecificationCaseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { isFileDirective } from './FileReferences';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { addFixtureValue, addInlineValue } from './SpecificationExampleParser';\nimport { rejectOperationChildren } from './OperationParser';\nimport { generatedFixturePattern, generatedFixturePrefix, parseConcrete, parseConcreteMapping, parseReturn, thenReturnsPrefix } from './SpecificationResponseParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { SpecificationAbsentReadModelSyntax, SpecificationCallerClaimSyntax, SpecificationCallerSyntax, SpecificationInvocationSyntax, SpecificationQuerySyntax } from '../Syntax/Specifications';\nimport { parseStructuredValue, StructuredMarker, tryParseStructuredMapping } from './StructuredBlockParser';\n\nconst operationStepPrefix = pattern('^(?:given\\\\s+operation|then\\\\s+(?:operation|compensated))(?:\\\\s|$)');\nconst operationStep = pattern('^(given operation|then operation|then compensated)\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)(\\\\s+fails)?$');\nconst header = pattern('^specification\\\\s+([A-Za-z_]\\\\w*)$');\nconst callerPersonaPattern = pattern('^given caller as ([A-Za-z_]\\\\w*)$');\nconst stepName = '([A-Z]\\\\w*(?:\\\\.\\\\w+)*)';\nconst inlineAssignment = '(?:\\\\s+(?<property>[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(?<value>.+))?';\nconst stepPattern = (prefix: string, exactly = ''): RegExp => nativePattern(`^${prefix}\\\\s+${stepName}${exactly}${inlineAssignment}$`.replaceAll('\\\\s', dotNetWhitespace));\nconst givenPattern = stepPattern('given');\nconst whenAppendPattern = stepPattern('when\\\\s+append');\nconst whenPattern = stepPattern('when');\nconst thenEventPattern = stepPattern('then');\nconst thenQueryPrefix = pattern('^then\\\\s+query\\\\b');\nconst readModelPrefix = pattern('^(?:given|then)\\\\s+readmodel\\\\b');\nconst givenReadModelPattern = stepPattern('given\\\\s+readmodel');\nconst thenReadModelPattern = stepPattern('then\\\\s+readmodel', '(?<exactly>\\\\s+exactly)?');\nconst thenNoPrefix = pattern('^then\\\\s+no\\\\b');\nconst thenErrorPattern = pattern(`^then\\\\s+error\\\\s+\"(${stringBodyPattern})\"$`);\nconst mappingPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst nativeMappingPattern = nativePattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst givenTimeZonePrefix = pattern('^given\\\\s+time\\\\s+zone\\\\b');\nconst givenTimeZonePattern = pattern(`^given\\\\s+time\\\\s+zone\\\\s+\"(${stringBodyPattern})\"$`);\nconst givenClockPrefix = pattern('^given\\\\s+clock\\\\b');\nconst givenCapturePrefix = pattern('^given\\\\s+capture\\\\b');\nconst thenInvokesPrefix = pattern('^then\\\\s+invokes\\\\b');\nconst thenInvokesPattern = pattern('^then\\\\s+invokes\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst givenGeneratedPrefix = pattern('^given\\\\s+generated\\\\b');\nconst givenGeneratedPattern = pattern('^given\\\\s+generated\\\\s+([A-Z]\\\\w*)\\\\.([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst givenGeneratedBlockPattern = pattern('^given\\\\s+generated\\\\s+([A-Z]\\\\w*)\\\\.([a-z_]\\\\w*)(?:\\\\s+(none|empty))?$');\nconst whenClockPrefix = pattern('^when\\\\s+clock\\\\b');\nconst whenTriggerPrefix = pattern('^when\\\\s+trigger\\\\b');\nconst whenCapturePrefix = pattern('^when\\\\s+capture\\\\b');\nconst whenQueryPrefix = pattern('^when\\\\s+query\\\\b');\nconst thenResultPrefix = pattern('^then\\\\s+result\\\\b');\nconst noResultPrefix = pattern('^then\\\\s+no\\\\s+result\\\\b');\nconst whenRedeliveredPrefix = nativePattern('^when\\\\s+redelivered\\\\b');\nconst whenRedeliveredPattern = nativePattern('^when\\\\s+redelivered\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)\\\\s+to\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst noEventsPrefix = pattern('^then\\\\s+no\\\\s+events\\\\b');\n\n// An instant in ISO 8601 - a date, a time to the minute or finer, and an explicit offset or Z - so the same text\n// means the same moment wherever the specification runs.\nconst clockPattern = pattern('^(given|when)\\\\s+clock\\\\s+\"(\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}(?::\\\\d{2}(?:\\\\.\\\\d+)?)?(?:Z|[+-]\\\\d{2}:\\\\d{2}))\"$');\nconst whenTriggerPattern = pattern('^when\\\\s+trigger\\\\s+([A-Za-z_]\\\\w*)$');\nconst capturePattern = pattern('^(?:given|when)\\\\s+capture\\\\s+([A-Za-z_]\\\\w*)$');\nconst whenQueryPattern = pattern('^when\\\\s+query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst thenResultPattern = pattern('^then\\\\s+result(\\\\s+exactly)?$');\nconst thenAbsentReadModelPattern = nativePattern('^then\\\\s+no\\\\s+readmodel\\\\s+([A-Z]\\\\w*)\\\\s+for(?:\\\\s+(.+))?$');\nconst absentKeyStringPattern = nativePattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\nconst thenQueryPattern = nativePattern('^then\\\\s+query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)(\\\\s+exactly)?$');\n\ninterface SpecificationBody {\n given: SpecificationEventSyntax[];\n givenReadModels: SpecificationReadModelSyntax[];\n when: SpecificationCommandSyntax | null;\n whenAppended: SpecificationEventSyntax | null;\n whenRedelivered: SpecificationRedeliverySyntax | null;\n whenDeclared: boolean;\n thenEvents: SpecificationEventSyntax[];\n thenEventsInAnyOrder: boolean;\n thenNoEvents: boolean;\n noEventsLine?: SourceLine;\n thenReadModels: SpecificationReadModelSyntax[];\n thenErrors: SpecificationErrorSyntax[];\n thenAbsentReadModels: SpecificationAbsentReadModelSyntax[];\n thenQueries: SpecificationQuerySyntax[];\n givenClock: SpecificationClockSyntax | null;\n givenTimeZone: SpecificationTimeZoneSyntax | null;\n givenCaptures: SpecificationCaptureSyntax[];\n givenGenerated?: SpecificationGeneratedValueSyntax[];\n whenClock: SpecificationClockSyntax | null;\n whenTrigger: SpecificationTriggerSyntax | null;\n whenCapture: SpecificationCaptureSyntax | null;\n whenQuery: SpecificationWhenQuerySyntax | null;\n thenResults: SpecificationQueryResultSyntax[];\n thenNoResult: SpecificationNoResultSyntax | null;\n thenDenied: SpecificationDeniedSyntax | null;\n givenCaller: SpecificationCallerSyntax | null;\n givenCallerPersona?: SpecificationCallerPersonaSyntax;\n thenReturns: SpecificationReturnSyntax | null;\n givenOperationFailures: SpecificationOperationFailureSyntax[];\n thenOperations: SpecificationOperationSyntax[];\n thenCompensated: SpecificationCompensatedSyntax[];\n thenInvocations?: SpecificationInvocationSyntax[];\n}\n\nexport function parseSpecification(context: ParserContext, line: SourceLine): SpecificationSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidSpecificationDeclaration, `Invalid specification declaration '${line.content}' - expected 'specification <Name>'`, locationOf(line));\n }\n let description: string | null = null;\n const parameters: NonNullable<SpecificationSyntax['parameters']>[number][] = [];\n const cases: NonNullable<SpecificationSyntax['cases']>[number][] = [];\n const body: SpecificationBody = {\n givenOperationFailures: [], thenOperations: [], thenCompensated: [], thenAbsentReadModels: [], thenQueries: [],\n given: [], givenReadModels: [], when: null, whenAppended: null, whenRedelivered: null, whenDeclared: false,\n thenEvents: [], thenEventsInAnyOrder: false, thenNoEvents: false, thenReadModels: [], thenErrors: [],\n givenClock: null, givenTimeZone: null, givenCaptures: [], whenClock: null, whenTrigger: null, whenCapture: null, whenQuery: null, thenResults: [], thenNoResult: null, thenDenied: null, givenCaller: null, thenReturns: null,\n };\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (isFileDirective(child)) {\n continue;\n }\n if (parseOperationStep(context, child, body)) continue;\n // Absence assertions admit any whitespace after 'then'; every other directive keeps its first word.\n const keyword = thenNoPrefix.test(child.content) ? 'then' : firstWord(child.content);\n if (keyword === 'parameter') {\n const parameter = parseParameter(context, child);\n if (parameter !== null) parameters.push(parameter);\n } else if (keyword === 'case') {\n const row = parseCase(context, child);\n if (row !== null) cases.push(row);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Specification '${name}'`);\n } else if (keyword === 'given') {\n parseGiven(context, child, body);\n } else if (keyword === 'when') {\n parseWhen(context, child, body, name);\n } else if (keyword === 'then') {\n parseThen(context, child, body);\n } else {\n context.error(DiagnosticCodes.UnknownSpecificationDirective, `Unexpected '${firstWord(child.content)}' in specification body`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (body.noEventsLine !== undefined && (body.thenEvents.length > 0 || body.thenEventsInAnyOrder || body.thenErrors.length > 0 || body.thenDenied !== null)) {\n context.error(DiagnosticCodes.InvalidNoEventsExpectation,\n \"'then no events' cannot accompany event, event-order, error or denial expectations.\", locationOf(body.noEventsLine));\n }\n validateQueryRejection(context, line, body);\n const { whenDeclared: _, noEventsLine: _noEventsLine, ...members } = body;\n const specification: SpecificationSyntax = { kind: 'SpecificationSyntax', sourceOptions: context.sourceOptions, name, description, ...members,\n ...(parameters.length === 0 ? {} : { parameters }), ...(cases.length === 0 ? {} : { cases }), location: locationOf(line) };\n validateTable(specification, context);\n return specification;\n}\n\nfunction validateQueryRejection(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (!isQueryRejectionCandidate(body) || isWellFormedQueryRejection(body)) return;\n context.error(DiagnosticCodes.MismatchedSpecificationQueryResult,\n \"A query rejection requires exactly one query and one 'then error', no action, and no other outcomes\", locationOf(line));\n}\n\nfunction isQueryRejectionCandidate(body: SpecificationBody): boolean {\n return body.thenErrors.length > 0 && queriedCallCount(body) > 0 && (body.whenQuery !== null || !hasAction(body));\n}\n\nfunction isWellFormedQueryRejection(body: SpecificationBody): boolean {\n return !hasAction(body) && hasOneQueryAndOneError(body) && !hasOtherOutcome(body);\n}\n\nfunction hasOneQueryAndOneError(body: SpecificationBody): boolean {\n return queriedCallCount(body) === 1 && body.thenErrors.length === 1;\n}\n\nfunction hasAction(body: SpecificationBody): boolean {\n return [body.when, body.whenAppended, body.whenClock, body.whenTrigger, body.whenCapture, body.whenRedelivered].some(action => action !== null);\n}\n\nfunction queriedCallCount(body: SpecificationBody): number {\n return body.thenQueries.length + (body.whenQuery === null ? 0 : 1);\n}\n\nfunction hasOtherOutcome(body: SpecificationBody): boolean {\n return [\n body.thenResults.length > 0,\n body.thenNoResult !== null,\n body.thenDenied !== null,\n body.thenEvents.length > 0,\n body.thenNoEvents,\n body.thenEventsInAnyOrder,\n body.thenReadModels.length > 0,\n body.thenAbsentReadModels.length > 0,\n body.thenReturns !== null,\n body.thenQueries.some(query => query.results.length > 0)\n ].some(outcome => outcome);\n}\n\nfunction parseOperationStep(context: ParserContext, line: SourceLine, body: SpecificationBody): boolean {\n if (!operationStepPrefix.test(line.content)) return false;\n const match = operationStep.exec(line.content);\n if (match === null || (match[1] === 'given operation') !== (match[3] !== undefined)) {\n context.error(DiagnosticCodes.InvalidOperationSpecification, \"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.\", locationOf(line));\n skipBody(context, line.indent);\n } else if (match[1] === 'then operation') {\n const values: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const value = parseConcreteMapping(context, child, mappingPattern, DiagnosticCodes.InvalidOperationSpecification);\n if (value !== null) values.push(value);\n }\n body.thenOperations.push({ kind: 'SpecificationOperationSyntax', operation: match[2], values, location: locationOf(line) });\n } else {\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidOperationSpecification, 'Failure and compensation assertions cannot have children.');\n if (match[1] === 'given operation') body.givenOperationFailures.push({ kind: 'SpecificationOperationFailureSyntax', operation: match[2], location: locationOf(line) });\n else body.thenCompensated.push({ kind: 'SpecificationCompensatedSyntax', operation: match[2], location: locationOf(line) });\n }\n return true;\n}\n\nfunction parseGiven(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (givenClockPrefix.test(line.content)) {\n if (body.givenClock !== null) {\n context.error(DiagnosticCodes.InvalidSpecificationClock, 'A specification states its clock at most once.', locationOf(line));\n skipBody(context, line.indent);\n } else {\n body.givenClock = parseClock(context, line, 'given');\n }\n } else if (givenTimeZonePrefix.test(line.content)) {\n const match = givenTimeZonePattern.exec(line.content);\n skipBody(context, line.indent);\n if (body.givenTimeZone !== null || match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationTimeZone, \"A specification states its time zone at most once, as 'given time zone \\\"<id>\\\"'.\", locationOf(line));\n } else {\n body.givenTimeZone = { kind: 'SpecificationTimeZoneSyntax', id: unescapeString(match[1]), location: locationOf(line) };\n }\n } else if (givenGeneratedPrefix.test(line.content)) {\n const pinned = parseGivenGenerated(context, line);\n if (pinned !== null) {\n (body.givenGenerated ??= []).push(pinned);\n }\n } else if (givenCapturePrefix.test(line.content)) {\n const capture = parseCapture(context, line, 'given');\n if (capture !== null) {\n body.givenCaptures.push(capture);\n }\n } else if (line.content.startsWith('given caller')) {\n if (body.givenCaller !== null || body.givenCallerPersona !== undefined) {\n context.error(DiagnosticCodes.DuplicateSpecificationCallerOrDenied, \"A specification has at most one 'given caller' block.\", locationOf(line));\n context.skipBlock(line.indent);\n } else if (line.content.startsWith('given caller as')) {\n const match = callerPersonaPattern.exec(line.content);\n if (match === null) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, \"Expected 'given caller as <Persona>'.\", locationOf(line));\n const child = context.peekChild(line.indent);\n if (child !== undefined) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, \"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.\", locationOf(child));\n skipBody(context, line.indent);\n if (match !== null) body.givenCallerPersona = { kind: 'SpecificationCallerPersonaSyntax', name: match[1], location: locationOf(line) };\n } else {\n body.givenCaller = parseCaller(context, line);\n }\n } else if (readModelPrefix.test(line.content)) {\n const readModel = parseReadModelStep(context, line, givenReadModelPattern, 'given');\n if (readModel !== undefined) {\n body.givenReadModels.push(readModel);\n }\n } else {\n const event = parseEventStep(context, line, givenPattern, 'given');\n if (event !== undefined) {\n body.given.push(event);\n }\n }\n}\n\nconst callerRolePattern = pattern(`^role${dotNetWhitespace}+\"(${stringBodyPattern})\"$`);\nconst callerClaimPattern = pattern(`^claim${dotNetWhitespace}+\"(${stringBodyPattern})\"${dotNetWhitespace}*=${dotNetWhitespace}*\"(${stringBodyPattern})\"$`);\n\n// 'given caller' and the authenticated, role and claim lines under it.\nfunction parseCaller(context: ParserContext, line: SourceLine): SpecificationCallerSyntax | null {\n if (line.content !== 'given caller') {\n context.error(DiagnosticCodes.InvalidSpecificationCaller, \"Expected exactly 'given caller'.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n let authenticated = false;\n const roles: string[] = [];\n const claims: SpecificationCallerClaimSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const role = callerRolePattern.exec(child.content);\n const claim = callerClaimPattern.exec(child.content);\n if (child.content === 'authenticated' && !authenticated) {\n authenticated = true;\n } else if (role !== null) {\n roles.push(unescapeString(role[1]));\n } else if (claim !== null) {\n claims.push({ kind: 'SpecificationCallerClaimSyntax', type: unescapeString(claim[1]), value: unescapeString(claim[2]), location: locationOf(child) });\n } else {\n context.error(containsCaseReference(child.content) ? DiagnosticCodes.InvalidSpecificationCaseReference : DiagnosticCodes.InvalidSpecificationCaller, `Invalid caller fixture '${child.content}' - expected authenticated, role \"...\", or claim \"...\" = \"...\".`, locationOf(child));\n }\n }\n return { kind: 'SpecificationCallerSyntax', authenticated, roles, claims, location: locationOf(line) };\n}\n\nfunction parseWhen(context: ParserContext, line: SourceLine, body: SpecificationBody, name: string): void {\n const appends = line.content.startsWith('when append');\n if (body.whenDeclared) {\n const code = body.whenAppended !== null || appends ? DiagnosticCodes.ConflictingSpecificationActions : DiagnosticCodes.DuplicateSpecificationWhen;\n context.error(code, `Specification '${name}' already declares a 'when' - a specification can have at most one`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n body.whenDeclared = true;\n if (appends) {\n body.whenAppended = parseEventStep(context, line, whenAppendPattern, 'when append') ?? null;\n return;\n }\n if (whenRedeliveredPrefix.test(line.content)) {\n const match = whenRedeliveredPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnmatchedRedeliveredOccurrence, \"Expected 'when redelivered <Event> to <Reaction>'.\", locationOf(line));\n skipBody(context, line.indent);\n } else {\n body.whenRedelivered = { kind: 'SpecificationRedeliverySyntax', eventType: match[1], reaction: match[2], ...parseValuesWithEventSource(context, line, undefined, undefined, 'when redelivered'), location: locationOf(line) };\n }\n return;\n }\n if (whenClockPrefix.test(line.content)) {\n body.whenClock = parseClock(context, line, 'when');\n return;\n }\n if (whenTriggerPrefix.test(line.content)) {\n body.whenTrigger = parseNamedStep(context, line, whenTriggerPattern, DiagnosticCodes.InvalidSpecificationTrigger, 'when trigger', 'when trigger <Trigger>',\n (trigger, values) => ({ kind: 'SpecificationTriggerSyntax', trigger, values, location: locationOf(line) }));\n return;\n }\n if (whenCapturePrefix.test(line.content)) {\n body.whenCapture = parseCapture(context, line, 'when');\n return;\n }\n if (whenQueryPrefix.test(line.content)) {\n body.whenQuery = parseNamedStep(context, line, whenQueryPattern, DiagnosticCodes.InvalidSpecificationQueryAction, 'when query', 'when query <Query>',\n (query, values) => ({ kind: 'SpecificationWhenQuerySyntax', query, arguments: values, location: locationOf(line) }), true);\n return;\n }\n const match = whenPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationWhen, `Invalid 'when' declaration '${line.content}' - expected 'when <CommandType>' or 'when append <EventType>'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n const generatedValues: PropertyMappingSyntax[] = [];\n const values = parseValuesWithEventSource(context, line, generatedValues, match);\n body.when = { kind: 'SpecificationCommandSyntax', commandType: match[1], ...values, generatedValues, inlineProperty: match.groups?.property ?? null, location: locationOf(line) };\n}\n\nfunction parseThen(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (noEventsPrefix.test(line.content)) {\n if (line.content !== 'then no events' || body.thenNoEvents) {\n context.error(DiagnosticCodes.InvalidNoEventsExpectation, \"Expected one 'then no events' directive.\", locationOf(line));\n } else {\n body.thenNoEvents = true;\n body.noEventsLine = line;\n }\n const child = context.peekChild(line.indent);\n if (child !== undefined) context.error(DiagnosticCodes.InvalidNoEventsExpectation, \"'then no events' cannot have child mappings.\", locationOf(child));\n skipBody(context, line.indent);\n return;\n }\n if (thenReturnsPrefix.test(line.content)) {\n const expectation = parseReturn(context, line);\n if (body.thenReturns !== null) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A specification declares at most one return expectation.', locationOf(line));\n } else {\n body.thenReturns = expectation;\n }\n return;\n }\n if (line.content.startsWith('then events')) {\n if (line.content !== 'then events in any order' || body.thenEventsInAnyOrder) {\n context.error(DiagnosticCodes.InvalidSpecificationEventOrder, 'Expected one \\'then events in any order\\' directive.', locationOf(line));\n } else {\n body.thenEventsInAnyOrder = true;\n }\n skipBody(context, line.indent);\n return;\n }\n if (thenResultPrefix.test(line.content)) {\n parseResult(context, line, body);\n return;\n }\n if (noResultPrefix.test(line.content)) {\n if (line.content !== 'then no result' || body.thenNoResult !== null) {\n context.error(DiagnosticCodes.InvalidSpecificationQueryAction, 'Expected one \\'then no result\\' directive.', locationOf(line));\n } else {\n body.thenNoResult = { kind: 'SpecificationNoResultSyntax', location: locationOf(line) };\n }\n skipBody(context, line.indent);\n return;\n }\n if (thenInvokesPrefix.test(line.content)) {\n const invocation = parseNamedStep(context, line, thenInvokesPattern, DiagnosticCodes.InvalidSpecificationInvocation, 'then invokes', 'then invokes <Command>',\n (command, values): SpecificationInvocationSyntax => ({ kind: 'SpecificationInvocationSyntax', command, values, location: locationOf(line) }));\n if (invocation !== null) (body.thenInvocations ??= []).push(invocation);\n return;\n }\n if (line.content.startsWith('then denied')) {\n if (line.content !== 'then denied') {\n context.error(DiagnosticCodes.InvalidSpecificationDenied, 'Expected exactly \\'then denied\\'.', locationOf(line));\n skipBody(context, line.indent);\n } else if (body.thenDenied !== null) {\n context.error(DiagnosticCodes.DuplicateSpecificationCallerOrDenied, \"A specification has at most one 'then denied' outcome.\", locationOf(line));\n } else {\n body.thenDenied = { kind: 'SpecificationDeniedSyntax', location: locationOf(line) };\n }\n return;\n }\n if (line.content === 'then error') {\n body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: null, location: locationOf(line) });\n return;\n }\n if (line.content.startsWith('then error case.')) {\n const caseValue = parseMappingSource(line.content.substring(11), { ...locationOf(line), column: locationOf(line).column + 11 }, context);\n if (caseValue.kind === 'CaseValueExpressionSyntax') body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: null, caseValue, location: locationOf(line) });\n return;\n }\n const error = thenErrorPattern.exec(line.content);\n if (error !== null) {\n body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: unescapeString(error[1]), location: locationOf(line) });\n return;\n }\n if (firstWord(line.content.substring('then'.length).trim()) === 'error') {\n context.error(DiagnosticCodes.InvalidThenError, `Invalid 'then error' declaration '${line.content}' - expected 'then error' or 'then error \"<reason>\"'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n if (thenNoPrefix.test(line.content)) {\n // Legacy documents keep skipping these assertions silently; Exact mirrors the native diagnostics.\n if (context.sourceOptions.numericMode === 'exact') {\n const absent = parseAbsentReadModel(context, line);\n if (absent !== null) body.thenAbsentReadModels.push(absent);\n return;\n }\n const match = thenAbsentReadModelPattern.exec(line.content);\n if (match !== null && match[2] === undefined && context.peekChild(line.indent) !== undefined) {\n // 'for' ending the line opens the key's members as an indented block.\n body.thenAbsentReadModels.push({ kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key: parseStructuredValue(context.valueContext, line, undefined), location: locationOf(line) });\n return;\n }\n if (match !== null && match[2] !== undefined && !match[2].endsWith(' exactly')) {\n const key = parseMappingSource(match[2].trim(), locationOf(line), context.valueContext);\n if (key.kind === 'LiteralExpressionSyntax' || key.kind === 'ObjectExpressionSyntax' || key.kind === 'CaseValueExpressionSyntax') body.thenAbsentReadModels.push({ kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key, location: locationOf(line) });\n }\n context.skipOpaqueBlock(line.indent);\n return;\n }\n if (thenQueryPrefix.test(line.content)) {\n // Legacy documents keep skipping malformed query bodies silently; Exact reports what the native parser reports.\n const exact = context.sourceOptions.numericMode === 'exact';\n const reject = (code: string, message: string, at: SourceLine): void => {\n if (!exact) return context.skipOpaqueBlock(at.indent);\n context.error(code, message, locationOf(at));\n context.skipBlock(at.indent);\n };\n const match = thenQueryPattern.exec(line.content);\n if (match === null) return reject(DiagnosticCodes.InvalidSpecificationQuery, `Invalid 'then query' declaration '${line.content}' - expected 'then query <Query> [exactly]'`, line);\n const args: PropertyMappingSyntax[] = [];\n const results: SpecificationQueryResultSyntax[] = [];\n let hasArguments = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'arguments' && !hasArguments) args.push(...parseValues(context.valueContext, child, true, undefined, context));\n else if (child.content === 'arguments') reject(DiagnosticCodes.DuplicateSpecificationQueryArguments, `Query assertion '${match[1]}' already declares arguments`, child);\n else if (child.content === 'result') results.push({ kind: 'SpecificationQueryResultSyntax', properties: parseValues(context.valueContext, child, true), exactly: false, location: locationOf(child) });\n else reject(DiagnosticCodes.UnknownSpecificationQueryDirective, `Unexpected '${firstWord(child.content)}' in 'then query' body - expected arguments or result`, child);\n hasArguments ||= child.content === 'arguments';\n }\n body.thenQueries.push({ kind: 'SpecificationQuerySyntax', query: match[1], arguments: args, results, exactly: match[2] !== undefined, location: locationOf(line) });\n return;\n }\n if (readModelPrefix.test(line.content)) {\n const readModel = parseReadModelStep(context, line, thenReadModelPattern, 'then');\n if (readModel !== undefined) {\n body.thenReadModels.push(readModel);\n }\n return;\n }\n const event = parseEventStep(context, line, thenEventPattern, 'then');\n if (event !== undefined) {\n body.thenEvents.push(event);\n }\n}\n\n// The Exact port of C# ParseAbsentReadModel: every malformed part is reported rather than dropped.\nfunction parseAbsentReadModel(context: ParserContext, line: SourceLine): SpecificationAbsentReadModelSyntax | null {\n const match = thenAbsentReadModelPattern.exec(line.content);\n if (match !== null && match[2] === undefined && context.peekChild(line.indent) !== undefined) {\n return { kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key: parseStructuredValue(context, line, undefined), location: locationOf(line) } as SpecificationAbsentReadModelSyntax;\n }\n if (match === null || match[2] === undefined || match[2].endsWith(' exactly')) {\n context.error(DiagnosticCodes.InvalidAbsentReadModelStep, `Invalid absence assertion '${line.content}' - expected 'then no readmodel <ReadModelType> for <key>'`, locationOf(line));\n skipBody(context, line.indent);\n return null;\n }\n const keyText = match[2].trim();\n const validString = !(keyText.startsWith('\"') || keyText.startsWith(\"'\")) || absentKeyStringPattern.test(keyText);\n const key = validString ? parseMappingSource(keyText, locationOf(line), context.valueContext) : null;\n const concrete = key !== null && (key.kind === 'LiteralExpressionSyntax' || key.kind === 'ObjectExpressionSyntax' || key.kind === 'CaseValueExpressionSyntax');\n if (!concrete) context.error(DiagnosticCodes.InvalidAbsentReadModelStep, `Invalid absence key '${keyText}' - expected exactly one concrete value.`, locationOf(line));\n let hasChildren = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n context.error(DiagnosticCodes.InvalidAbsentReadModelStep, 'An absent read model assertion cannot have child mappings.', locationOf(child));\n hasChildren = true;\n }\n return hasChildren || !concrete ? null : { kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key, location: locationOf(line) } as SpecificationAbsentReadModelSyntax;\n}\n\nfunction skipBody(context: ParserContext, indent: number): void {\n if (context.sourceOptions.numericMode !== 'exact') return context.skipBlock(indent);\n context.skipOpaqueBlock(indent);\n}\n\nfunction parseClock(context: ParserContext, line: SourceLine, keyword: string): SpecificationClockSyntax | null {\n const match = clockPattern.exec(line.content);\n skipBody(context, line.indent);\n if (match === null || match[1] !== keyword) {\n context.error(containsCaseReference(line.content) ? DiagnosticCodes.InvalidSpecificationCaseReference : DiagnosticCodes.InvalidSpecificationClock,\n `Invalid '${keyword} clock' - expected '${keyword} clock \"<ISO 8601 instant>\"', such as '${keyword} clock \"2026-10-05T08:00:00Z\"'`, locationOf(line));\n return null;\n }\n return { kind: 'SpecificationClockSyntax', instant: match[2], location: locationOf(line) };\n}\n\nfunction parseGivenGenerated(context: ParserContext, line: SourceLine): SpecificationGeneratedValueSyntax | null {\n const match = givenGeneratedPattern.exec(line.content);\n const block = match === null ? givenGeneratedBlockPattern.exec(line.content) : null;\n if (block !== null) {\n return { kind: 'SpecificationGeneratedValueSyntax', command: block[1], property: block[2], source: parseStructuredValue(context, line, block[3] as StructuredMarker), location: locationOf(line) };\n }\n if (match === null) {\n context.error(DiagnosticCodes.InvalidGeneratedFixture, \"Expected 'given generated <Command>.<property> = <value>' with exactly one concrete value.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const location = locationOf(line);\n const source = parseConcrete(context, match[3], { ...location, column: location.column + line.content.indexOf(match[3], line.content.indexOf('=') + 1) }, DiagnosticCodes.InvalidGeneratedFixture);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidGeneratedFixture, 'A pinned generated value cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'SpecificationGeneratedValueSyntax', command: match[1], property: match[2], source, location };\n}\n\nfunction parseCapture(context: ParserContext, line: SourceLine, keyword: string): SpecificationCaptureSyntax | null {\n return parseNamedStep(context, line, capturePattern, DiagnosticCodes.InvalidSpecificationCapture, `${keyword} capture`, `${keyword} capture <Capture>`,\n (capture, record) => ({ kind: 'SpecificationCaptureSyntax', capture, record, location: locationOf(line) }));\n}\n\n// A step naming one thing on its header line, with '<field> = <value>' lines beneath it.\nfunction parseNamedStep<T>(\n context: ParserContext, line: SourceLine, regex: RegExp, code: string, keyword: string, expected: string,\n create: (name: string, values: PropertyMappingSyntax[]) => T, queryArguments = false): T | null {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(code, `Invalid '${keyword}' declaration '${line.content}' - expected '${expected}'`, locationOf(line));\n skipBody(context, line.indent);\n return null;\n }\n return create(match[1], parseValues(context, line, false, undefined, queryArguments ? context : undefined));\n}\n\nfunction parseResult(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n const match = thenResultPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationQueryAction, `Invalid 'then result' declaration '${line.content}' - expected 'then result [exactly]'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n body.thenResults.push({ kind: 'SpecificationQueryResultSyntax', properties: parseValues(context, line), exactly: match[1] !== undefined, location: locationOf(line) });\n}\n\nfunction parseReadModelStep(context: ParserContext, line: SourceLine, regex: RegExp, keyword: string): SpecificationReadModelSyntax | undefined {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidReadModelStep, `Invalid '${keyword} readmodel' declaration '${line.content}' - expected '${keyword} readmodel <ReadModelType>'`, locationOf(line));\n skipBody(context, line.indent);\n return undefined;\n }\n return {\n kind: 'SpecificationReadModelSyntax',\n name: match[1],\n properties: parseValues(context, line, false, match),\n exactly: keyword === 'then' && match.groups?.exactly !== undefined,\n inlineProperty: match.groups?.property ?? null,\n location: locationOf(line),\n };\n}\n\nfunction parseEventStep(context: ParserContext, line: SourceLine, regex: RegExp, keyword: string): SpecificationEventSyntax | undefined {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEventStep, `Invalid '${keyword}' declaration '${line.content}' - expected '${keyword} <EventType>'`, locationOf(line));\n skipBody(context, line.indent);\n return undefined;\n }\n return { kind: 'SpecificationEventSyntax', eventType: match[1], ...parseValuesWithEventSource(context, line, undefined, match, keyword), inlineProperty: match.groups?.property ?? null, location: locationOf(line) };\n}\n\nexport const specificationStream = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*)\\\\.([A-Za-z_]\\\\w*)$');\nconst specificationStreamId = pattern('^streamId\\\\s*=(?!=|>)\\\\s*(.+)$');\n\nfunction parseValuesWithEventSource(context: ParserContext, parent: SourceLine, generated?: PropertyMappingSyntax[], inline?: RegExpExecArray, eventKeyword?: string): { values: PropertyMappingSyntax[]; for: ExpressionSyntax | null; stream?: SpecificationStreamSyntax; noStream?: SpecificationNoStreamSyntax } {\n const values: PropertyMappingSyntax[] = [];\n addInlineValue(context, parent, inline, values);\n let eventSource: ExpressionSyntax | null = null;\n let stream: SpecificationStreamSyntax | undefined;\n let noStream: SpecificationNoStreamSyntax | undefined;\n let hasRoute = false;\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n let structured: PropertyMappingSyntax | undefined;\n if (generated !== undefined && generatedFixturePrefix.test(child.content)) {\n const fixture = parseConcreteMapping(context, child, generatedFixturePattern, DiagnosticCodes.InvalidGeneratedFixture);\n if (fixture !== null) generated.push(fixture);\n continue;\n }\n const mapping = mappingPattern.exec(child.content);\n if (mapping !== null) {\n addFixtureValue(context, values, mappingOf(context, child, mapping));\n } else if (firstWord(child.content) === 'stream' || child.content.startsWith('no stream')) {\n if (eventKeyword === undefined) {\n context.error(DiagnosticCodes.SpecificationStreamOnCommand, 'A command occurrence cannot declare a route; assert it on a then event.', locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n if (hasRoute) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'An event occurrence declares at most one stream or no stream directive.', locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const route = specificationStream.exec(child.content);\n if (child.content === 'no stream' && (eventKeyword === 'then' || eventKeyword === 'when redelivered')) {\n noStream = { kind: 'SpecificationNoStreamSyntax', location: locationOf(child) };\n hasRoute = true;\n rejectSpecificationRouteChildren(context, child);\n } else if (route !== null) {\n stream = parseSpecificationStream(context, child, route);\n hasRoute = true;\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Expected 'stream Source.Stream', or 'no stream' on a then event.\", locationOf(child));\n context.skipBlock(child.indent);\n }\n } else if (firstWord(child.content) === 'for') {\n const source = child.content.substring('for'.length).trim();\n if (source.length === 0) {\n context.error(DiagnosticCodes.InvalidSpecificationEventSource, 'Invalid event-source assertion \\'for\\' - expected \\'for <value>\\'', locationOf(child));\n } else if (eventSource !== null) {\n context.error(DiagnosticCodes.DuplicateSpecificationEventSource, 'A specification step can declare its event-source assertion only once', locationOf(child));\n } else {\n eventSource = parseMappingSource(source, locationOf(child), context);\n }\n } else if ((structured = tryParseStructuredMapping(context, child)) !== undefined) {\n addFixtureValue(context, values, structured);\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child), diagnosticText('text', child.content));\n }\n }\n return { values, for: eventSource, ...(stream === undefined ? {} : { stream }), ...(noStream === undefined ? {} : { noStream }) };\n}\n\nexport function parseSpecificationStream(context: ParserContext, header: SourceLine, route: RegExpExecArray): SpecificationStreamSyntax {\n let streamId: PropertyMappingSyntax | null = null;\n let streamIdParts: PropertyMappingSyntax[] = [];\n let block = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'streamId') {\n if (streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Declare either one 'streamId = <literal>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n block = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseRouteParts(context, child, DiagnosticCodes.InvalidSpecificationStream).map(part => part.source.kind === 'PathExpressionSyntax' && part.source.path.startsWith('case.')\n ? { ...part, source: parseMappingSource(part.source.path, part.source.location, context) } : part);\n }\n continue;\n }\n const mapping = specificationStreamId.exec(child.content);\n if (mapping === null || streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Declare either one 'streamId = <literal>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(mapping[1], child.content.indexOf('=') + 1) };\n streamId = { kind: 'PropertyMappingSyntax', property: 'streamId', source: parseMappingSource(mapping[1], location, context), location: locationOf(child) };\n rejectSpecificationRouteChildren(context, child);\n }\n return { kind: 'SpecificationStreamSyntax', eventSource: route[1], stream: route[2], streamId, streamIdParts, directiveLocations,\n referenceLocation: { ...locationOf(header), column: header.indent + 1 + header.content.indexOf(route[1], 'stream'.length) },\n referenceLength: route[1].length + 1 + route[2].length, location: locationOf(header) };\n}\n\nexport function rejectSpecificationRouteChildren(context: ParserContext, line: SourceLine): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'This directive cannot have children.', locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n\nfunction parseValues(context: ParserContext, parent: SourceLine, nativeIdentifiers = false, inline?: RegExpExecArray, queryArgumentsContext?: ParserContext): PropertyMappingSyntax[] {\n const values: PropertyMappingSyntax[] = [];\n addInlineValue(context, parent, inline, values);\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n const mapping = (nativeIdentifiers || context.sourceOptions.numericMode === 'exact' ? nativeMappingPattern : mappingPattern).exec(child.content);\n const structured = mapping === null ? tryParseStructuredMapping(context, child) : undefined;\n if (mapping === null && structured === undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child), diagnosticText('text', child.content));\n continue;\n }\n const value = structured ?? mappingOf(context, child, mapping!, nativeIdentifiers);\n if (queryArgumentsContext !== undefined) {\n if (values.some(existing => existing.property === value.property)) {\n queryArgumentsContext.error(DiagnosticCodes.UnknownSpecificationQueryArgument, `Query argument '${value.property}' is repeated.`, value.location, diagnosticText('argument', value.property));\n }\n values.push(value);\n } else {\n addFixtureValue(context, values, value);\n }\n }\n return values;\n}\n\nfunction mappingOf(context: ParserContext, line: SourceLine, match: RegExpExecArray, nativeIdentifiers = false): PropertyMappingSyntax {\n return { kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], locationOf(line), context, nativeIdentifiers), location: locationOf(line) };\n}\n"],"mappings":"uvCA4BA,MAAMC,EAAsBC,EAAQ,oEAAoE,EAClGC,EAAgBD,EAAQ,yGAAyG,EACjIE,EAASF,EAAQ,oCAAoC,EACrDG,EAAuBH,EAAQ,mCAAmC,EAGlE,aAAe,EAAgB,EAAU,KAAeI,EAAc,IAAIC,EAAO,6BAAiBC,8DAA8B,WAAW,MAAOC,CAAgB,CAAC,EACnKC,EAAe,YAAY,OAAO,EAClCC,EAAoB,YAAY,gBAAgB,EAChDC,EAAc,YAAY,MAAM,EAChCC,EAAmB,YAAY,MAAM,EACrCC,EAAkBZ,EAAQ,mBAAmB,EAC7Ca,EAAkBb,EAAQ,iCAAiC,EAC3Dc,EAAwB,YAAY,oBAAoB,EACxDC,EAAuB,YAAY,oBAAqB,0BAA0B,EAClFC,EAAehB,EAAQ,gBAAgB,EACvCiB,EAAmBjB,EAAQ,uBAAuBkB,EAAkB,IAAI,EACxEC,EAAiBnB,EAAQ,iCAAiC,EAC1DoB,EAAuBhB,EAAc,iCAAiC,EACtEiB,EAAsBrB,EAAQ,2BAA2B,EACzDsB,EAAuBtB,EAAQ,+BAA+BkB,EAAkB,IAAI,EACpFK,EAAmBvB,EAAQ,oBAAoB,EAC/CwB,GAAqBxB,EAAQ,sBAAsB,EACnDyB,EAAoBzB,EAAQ,qBAAqB,EACjD0B,EAAqB1B,EAAQ,2DAA2D,EACxF2B,EAAuB3B,EAAQ,wBAAwB,EACvD4B,EAAwB5B,EAAQ,wEAAwE,EACxG6B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,WAAa3E,EAAM,QAAQ,GAC5D0E,EAAsB,MAAMnG,EAAgB,kCAAmC,mBAAmByB,EAAM,SAAS,gBAAiBA,EAAM,SAAUmE,EAAe,WAAYnE,EAAM,QAAQ,CAAC,EAEhMD,EAAO,KAAKC,CAAK,EAIzB,CACA,OAAOD,CACX,CAEA,SAAS,UAAU,EAAwB,EAAkB,EAAwB,EAAoB,GAA8B,CACnI,MAAO,CAAE,KAAM,wBAAyB,SAAUD,EAAM,GAAI,OAAQ3E,EAAmB2E,EAAM,GAAItB,EAAWH,CAAI,EAAGC,EAASmG,CAAiB,EAAG,SAAUjG,EAAWH,CAAI,CAAE,CAC/K"}
|
|
1
|
+
{"version":3,"file":"SpecificationParser.js","names":["parseMappingSource","operationStepPrefix","pattern","operationStep","header","specificationHeader","callerPersonaPattern","nativePattern","prefix","exactly","dotNetWhitespace","givenPattern","whenAppendPattern","whenPattern","thenEventPattern","thenQueryPrefix","readModelPrefix","givenReadModelPattern","thenReadModelPattern","thenNoPrefix","thenErrorPattern","stringBodyPattern","mappingPattern","nativeMappingPattern","givenTimeZonePrefix","givenTimeZonePattern","givenClockPrefix","givenCapturePrefix","thenInvokesPrefix","thenInvokesPattern","givenGeneratedPrefix","givenGeneratedPattern","givenGeneratedBlockPattern","whenClockPrefix","whenTriggerPrefix","whenCapturePrefix","whenQueryPrefix","thenResultPrefix","noResultPrefix","whenRedeliveredPrefix","whenRedeliveredPattern","noEventsPrefix","clockPattern","whenTriggerPattern","capturePattern","whenQueryPattern","thenResultPattern","thenAbsentReadModelPattern","absentKeyStringPattern","thenQueryPattern","name","line","context","DiagnosticCodes","locationOf","description","parameters","cases","body","child","isFileDirective","keyword","firstWord","parameter","parseParameter","row","parseCase","parseDescription","_","_noEventsLine","members","specification","validateTable","action","query","outcome","match","values","value","parseConcreteMapping","rejectOperationChildren","unescapeString","pinned","capture","readModel","event","callerRolePattern","callerClaimPattern","authenticated","roles","claims","role","claim","containsCaseReference","appends","code","generatedValues","thenReturnsPrefix","expectation","parseReturn","invocation","caseValue","parseSpecificationValue","error","absent","parseStructuredValue","key","exact","at","message","args","results","hasArguments","keyText","concrete","hasChildren","indent","block","location","source","parseConcrete","regex","expected","create","queryArguments","specificationStream","sourceStreamPattern","specificationStreamId","addInlineValue","parent","inline","eventSource","stream","noStream","hasRoute","structured","generated","generatedFixturePrefix","fixture","generatedFixturePattern","mapping","addFixtureValue","eventKeyword","route","tryParseStructuredMapping","diagnosticText","streamId","streamIdParts","directiveLocations","parseRouteParts","part","nativeIdentifiers","queryArgumentsContext","existing","lifecycleWhenStart","lifecycleOutcome","lifecycleThen","word","given","whenAppended","whenStarted","whenDeclared","outcomes","then","fact","start","index","sourceLocation"],"sources":["../../../../../../Compiler/Parsing/SpecificationParser.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 { parseRouteParts } from './EventSourceParser';\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport {\n SpecificationCaptureSyntax, SpecificationClockSyntax, SpecificationTimeZoneSyntax, SpecificationGeneratedValueSyntax, SpecificationCommandSyntax, SpecificationErrorSyntax, SpecificationEventSyntax, SpecificationStreamSyntax, SpecificationNoStreamSyntax,\n SpecificationNoResultSyntax, SpecificationQueryResultSyntax, SpecificationReadModelSyntax, SpecificationSyntax, SpecificationTriggerSyntax,\n SpecificationWhenQuerySyntax, SpecificationCallerPersonaSyntax, SpecificationOperationFailureSyntax, SpecificationOperationSyntax, SpecificationCompensatedSyntax, SpecificationRedeliverySyntax,\n} from '../Syntax/Specifications';\nimport { SpecificationDeniedSyntax, SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { dotNetWhitespace, nativePattern, pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { containsCaseReference, parseCase, parseParameter, parseSpecificationValue as parseMappingSource, validateTable } from './SpecificationCaseParser';\nimport { parseDescription } from './DescriptionParser';\nimport { isFileDirective } from './FileReferences';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { addFixtureValue, addInlineValue } from './SpecificationExampleParser';\nimport { rejectOperationChildren } from './OperationParser';\nimport { generatedFixturePattern, generatedFixturePrefix, parseConcrete, parseConcreteMapping, parseReturn, thenReturnsPrefix } from './SpecificationResponseParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { SourceLocation, sourceLocation } from '../Diagnostics/SourceLocation';\nimport { LifecycleExpectationKind, LifecycleExpectationSyntax, LifecycleOutcomeSyntax, LifecycleSpecificationSyntax } from '../Syntax/Lifecycles';\nimport { SpecificationAbsentReadModelSyntax, SpecificationCallerClaimSyntax, SpecificationCallerSyntax, SpecificationInvocationSyntax, SpecificationQuerySyntax } from '../Syntax/Specifications';\nimport { parseStructuredValue, StructuredMarker, tryParseStructuredMapping } from './StructuredBlockParser';\n\nconst operationStepPrefix = pattern('^(?:given\\\\s+operation|then\\\\s+(?:operation|compensated))(?:\\\\s|$)');\nconst operationStep = pattern('^(given operation|then operation|then compensated)\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)(\\\\s+fails)?$');\nconst header = pattern('^specification\\\\s+([A-Za-z_]\\\\w*)$');\nconst specificationHeader = header;\nconst callerPersonaPattern = pattern('^given caller as ([A-Za-z_]\\\\w*)$');\nconst stepName = '([A-Z]\\\\w*(?:\\\\.\\\\w+)*)';\nconst inlineAssignment = '(?:\\\\s+(?<property>[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(?<value>.+))?';\nconst stepPattern = (prefix: string, exactly = ''): RegExp => nativePattern(`^${prefix}\\\\s+${stepName}${exactly}${inlineAssignment}$`.replaceAll('\\\\s', dotNetWhitespace));\nconst givenPattern = stepPattern('given');\nconst whenAppendPattern = stepPattern('when\\\\s+append');\nconst whenPattern = stepPattern('when');\nconst thenEventPattern = stepPattern('then');\nconst thenQueryPrefix = pattern('^then\\\\s+query\\\\b');\nconst readModelPrefix = pattern('^(?:given|then)\\\\s+readmodel\\\\b');\nconst givenReadModelPattern = stepPattern('given\\\\s+readmodel');\nconst thenReadModelPattern = stepPattern('then\\\\s+readmodel', '(?<exactly>\\\\s+exactly)?');\nconst thenNoPrefix = pattern('^then\\\\s+no\\\\b');\nconst thenErrorPattern = pattern(`^then\\\\s+error\\\\s+\"(${stringBodyPattern})\"$`);\nconst mappingPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst nativeMappingPattern = nativePattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst givenTimeZonePrefix = pattern('^given\\\\s+time\\\\s+zone\\\\b');\nconst givenTimeZonePattern = pattern(`^given\\\\s+time\\\\s+zone\\\\s+\"(${stringBodyPattern})\"$`);\nconst givenClockPrefix = pattern('^given\\\\s+clock\\\\b');\nconst givenCapturePrefix = pattern('^given\\\\s+capture\\\\b');\nconst thenInvokesPrefix = pattern('^then\\\\s+invokes\\\\b');\nconst thenInvokesPattern = pattern('^then\\\\s+invokes\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst givenGeneratedPrefix = pattern('^given\\\\s+generated\\\\b');\nconst givenGeneratedPattern = pattern('^given\\\\s+generated\\\\s+([A-Z]\\\\w*)\\\\.([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst givenGeneratedBlockPattern = pattern('^given\\\\s+generated\\\\s+([A-Z]\\\\w*)\\\\.([a-z_]\\\\w*)(?:\\\\s+(none|empty))?$');\nconst whenClockPrefix = pattern('^when\\\\s+clock\\\\b');\nconst whenTriggerPrefix = pattern('^when\\\\s+trigger\\\\b');\nconst whenCapturePrefix = pattern('^when\\\\s+capture\\\\b');\nconst whenQueryPrefix = pattern('^when\\\\s+query\\\\b');\nconst thenResultPrefix = pattern('^then\\\\s+result\\\\b');\nconst noResultPrefix = pattern('^then\\\\s+no\\\\s+result\\\\b');\nconst whenRedeliveredPrefix = nativePattern('^when\\\\s+redelivered\\\\b');\nconst whenRedeliveredPattern = nativePattern('^when\\\\s+redelivered\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)\\\\s+to\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst noEventsPrefix = pattern('^then\\\\s+no\\\\s+events\\\\b');\n\n// An instant in ISO 8601 - a date, a time to the minute or finer, and an explicit offset or Z - so the same text\n// means the same moment wherever the specification runs.\nconst clockPattern = pattern('^(given|when)\\\\s+clock\\\\s+\"(\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}(?::\\\\d{2}(?:\\\\.\\\\d+)?)?(?:Z|[+-]\\\\d{2}:\\\\d{2}))\"$');\nconst whenTriggerPattern = pattern('^when\\\\s+trigger\\\\s+([A-Za-z_]\\\\w*)$');\nconst capturePattern = pattern('^(?:given|when)\\\\s+capture\\\\s+([A-Za-z_]\\\\w*)$');\nconst whenQueryPattern = pattern('^when\\\\s+query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst thenResultPattern = pattern('^then\\\\s+result(\\\\s+exactly)?$');\nconst thenAbsentReadModelPattern = nativePattern('^then\\\\s+no\\\\s+readmodel\\\\s+([A-Z]\\\\w*)\\\\s+for(?:\\\\s+(.+))?$');\nconst absentKeyStringPattern = nativePattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\nconst thenQueryPattern = nativePattern('^then\\\\s+query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)(\\\\s+exactly)?$');\n\ninterface SpecificationBody {\n given: SpecificationEventSyntax[];\n givenReadModels: SpecificationReadModelSyntax[];\n when: SpecificationCommandSyntax | null;\n whenAppended: SpecificationEventSyntax | null;\n whenRedelivered: SpecificationRedeliverySyntax | null;\n whenDeclared: boolean;\n thenEvents: SpecificationEventSyntax[];\n thenEventsInAnyOrder: boolean;\n thenNoEvents: boolean;\n noEventsLine?: SourceLine;\n thenReadModels: SpecificationReadModelSyntax[];\n thenErrors: SpecificationErrorSyntax[];\n thenAbsentReadModels: SpecificationAbsentReadModelSyntax[];\n thenQueries: SpecificationQuerySyntax[];\n givenClock: SpecificationClockSyntax | null;\n givenTimeZone: SpecificationTimeZoneSyntax | null;\n givenCaptures: SpecificationCaptureSyntax[];\n givenGenerated?: SpecificationGeneratedValueSyntax[];\n whenClock: SpecificationClockSyntax | null;\n whenTrigger: SpecificationTriggerSyntax | null;\n whenCapture: SpecificationCaptureSyntax | null;\n whenQuery: SpecificationWhenQuerySyntax | null;\n thenResults: SpecificationQueryResultSyntax[];\n thenNoResult: SpecificationNoResultSyntax | null;\n thenDenied: SpecificationDeniedSyntax | null;\n givenCaller: SpecificationCallerSyntax | null;\n givenCallerPersona?: SpecificationCallerPersonaSyntax;\n thenReturns: SpecificationReturnSyntax | null;\n givenOperationFailures: SpecificationOperationFailureSyntax[];\n thenOperations: SpecificationOperationSyntax[];\n thenCompensated: SpecificationCompensatedSyntax[];\n thenInvocations?: SpecificationInvocationSyntax[];\n}\n\nexport function parseSpecification(context: ParserContext, line: SourceLine): SpecificationSyntax {\n const name = header.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidSpecificationDeclaration, `Invalid specification declaration '${line.content}' - expected 'specification <Name>'`, locationOf(line));\n }\n let description: string | null = null;\n const parameters: NonNullable<SpecificationSyntax['parameters']>[number][] = [];\n const cases: NonNullable<SpecificationSyntax['cases']>[number][] = [];\n const body: SpecificationBody = {\n givenOperationFailures: [], thenOperations: [], thenCompensated: [], thenAbsentReadModels: [], thenQueries: [],\n given: [], givenReadModels: [], when: null, whenAppended: null, whenRedelivered: null, whenDeclared: false,\n thenEvents: [], thenEventsInAnyOrder: false, thenNoEvents: false, thenReadModels: [], thenErrors: [],\n givenClock: null, givenTimeZone: null, givenCaptures: [], whenClock: null, whenTrigger: null, whenCapture: null, whenQuery: null, thenResults: [], thenNoResult: null, thenDenied: null, givenCaller: null, thenReturns: null,\n };\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (isFileDirective(child)) {\n continue;\n }\n if (parseOperationStep(context, child, body)) continue;\n // Absence assertions admit any whitespace after 'then'; every other directive keeps its first word.\n const keyword = thenNoPrefix.test(child.content) ? 'then' : firstWord(child.content);\n if (keyword === 'parameter') {\n const parameter = parseParameter(context, child);\n if (parameter !== null) parameters.push(parameter);\n } else if (keyword === 'case') {\n const row = parseCase(context, child);\n if (row !== null) cases.push(row);\n } else if (keyword === 'description') {\n description = parseDescription(context, child, description, `Specification '${name}'`);\n } else if (keyword === 'given') {\n parseGiven(context, child, body);\n } else if (keyword === 'when') {\n parseWhen(context, child, body, name);\n } else if (keyword === 'then') {\n parseThen(context, child, body);\n } else {\n context.error(DiagnosticCodes.UnknownSpecificationDirective, `Unexpected '${firstWord(child.content)}' in specification body`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (body.noEventsLine !== undefined && (body.thenEvents.length > 0 || body.thenEventsInAnyOrder || body.thenErrors.length > 0 || body.thenDenied !== null)) {\n context.error(DiagnosticCodes.InvalidNoEventsExpectation,\n \"'then no events' cannot accompany event, event-order, error or denial expectations.\", locationOf(body.noEventsLine));\n }\n validateQueryRejection(context, line, body);\n const { whenDeclared: _, noEventsLine: _noEventsLine, ...members } = body;\n const specification: SpecificationSyntax = { kind: 'SpecificationSyntax', sourceOptions: context.sourceOptions, name, description, ...members,\n ...(parameters.length === 0 ? {} : { parameters }), ...(cases.length === 0 ? {} : { cases }), location: locationOf(line) };\n validateTable(specification, context);\n return specification;\n}\n\nfunction validateQueryRejection(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (!isQueryRejectionCandidate(body) || isWellFormedQueryRejection(body)) return;\n context.error(DiagnosticCodes.MismatchedSpecificationQueryResult,\n \"A query rejection requires exactly one query and one 'then error', no action, and no other outcomes\", locationOf(line));\n}\n\nfunction isQueryRejectionCandidate(body: SpecificationBody): boolean {\n return body.thenErrors.length > 0 && queriedCallCount(body) > 0 && (body.whenQuery !== null || !hasAction(body));\n}\n\nfunction isWellFormedQueryRejection(body: SpecificationBody): boolean {\n return !hasAction(body) && hasOneQueryAndOneError(body) && !hasOtherOutcome(body);\n}\n\nfunction hasOneQueryAndOneError(body: SpecificationBody): boolean {\n return queriedCallCount(body) === 1 && body.thenErrors.length === 1;\n}\n\nfunction hasAction(body: SpecificationBody): boolean {\n return [body.when, body.whenAppended, body.whenClock, body.whenTrigger, body.whenCapture, body.whenRedelivered].some(action => action !== null);\n}\n\nfunction queriedCallCount(body: SpecificationBody): number {\n return body.thenQueries.length + (body.whenQuery === null ? 0 : 1);\n}\n\nfunction hasOtherOutcome(body: SpecificationBody): boolean {\n return [\n body.thenResults.length > 0,\n body.thenNoResult !== null,\n body.thenDenied !== null,\n body.thenEvents.length > 0,\n body.thenNoEvents,\n body.thenEventsInAnyOrder,\n body.thenReadModels.length > 0,\n body.thenAbsentReadModels.length > 0,\n body.thenReturns !== null,\n body.thenQueries.some(query => query.results.length > 0)\n ].some(outcome => outcome);\n}\n\nfunction parseOperationStep(context: ParserContext, line: SourceLine, body: SpecificationBody): boolean {\n if (!operationStepPrefix.test(line.content)) return false;\n const match = operationStep.exec(line.content);\n if (match === null || (match[1] === 'given operation') !== (match[3] !== undefined)) {\n context.error(DiagnosticCodes.InvalidOperationSpecification, \"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.\", locationOf(line));\n skipBody(context, line.indent);\n } else if (match[1] === 'then operation') {\n const values: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const value = parseConcreteMapping(context, child, mappingPattern, DiagnosticCodes.InvalidOperationSpecification);\n if (value !== null) values.push(value);\n }\n body.thenOperations.push({ kind: 'SpecificationOperationSyntax', operation: match[2], values, location: locationOf(line) });\n } else {\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidOperationSpecification, 'Failure and compensation assertions cannot have children.');\n if (match[1] === 'given operation') body.givenOperationFailures.push({ kind: 'SpecificationOperationFailureSyntax', operation: match[2], location: locationOf(line) });\n else body.thenCompensated.push({ kind: 'SpecificationCompensatedSyntax', operation: match[2], location: locationOf(line) });\n }\n return true;\n}\n\nfunction parseGiven(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (givenClockPrefix.test(line.content)) {\n if (body.givenClock !== null) {\n context.error(DiagnosticCodes.InvalidSpecificationClock, 'A specification states its clock at most once.', locationOf(line));\n skipBody(context, line.indent);\n } else {\n body.givenClock = parseClock(context, line, 'given');\n }\n } else if (givenTimeZonePrefix.test(line.content)) {\n const match = givenTimeZonePattern.exec(line.content);\n skipBody(context, line.indent);\n if (body.givenTimeZone !== null || match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationTimeZone, \"A specification states its time zone at most once, as 'given time zone \\\"<id>\\\"'.\", locationOf(line));\n } else {\n body.givenTimeZone = { kind: 'SpecificationTimeZoneSyntax', id: unescapeString(match[1]), location: locationOf(line) };\n }\n } else if (givenGeneratedPrefix.test(line.content)) {\n const pinned = parseGivenGenerated(context, line);\n if (pinned !== null) {\n (body.givenGenerated ??= []).push(pinned);\n }\n } else if (givenCapturePrefix.test(line.content)) {\n const capture = parseCapture(context, line, 'given');\n if (capture !== null) {\n body.givenCaptures.push(capture);\n }\n } else if (line.content.startsWith('given caller')) {\n if (body.givenCaller !== null || body.givenCallerPersona !== undefined) {\n context.error(DiagnosticCodes.DuplicateSpecificationCallerOrDenied, \"A specification has at most one 'given caller' block.\", locationOf(line));\n context.skipBlock(line.indent);\n } else if (line.content.startsWith('given caller as')) {\n const match = callerPersonaPattern.exec(line.content);\n if (match === null) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, \"Expected 'given caller as <Persona>'.\", locationOf(line));\n const child = context.peekChild(line.indent);\n if (child !== undefined) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, \"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.\", locationOf(child));\n skipBody(context, line.indent);\n if (match !== null) body.givenCallerPersona = { kind: 'SpecificationCallerPersonaSyntax', name: match[1], location: locationOf(line) };\n } else {\n body.givenCaller = parseCaller(context, line);\n }\n } else if (readModelPrefix.test(line.content)) {\n const readModel = parseReadModelStep(context, line, givenReadModelPattern, 'given');\n if (readModel !== undefined) {\n body.givenReadModels.push(readModel);\n }\n } else {\n const event = parseEventStep(context, line, givenPattern, 'given');\n if (event !== undefined) {\n body.given.push(event);\n }\n }\n}\n\nconst callerRolePattern = pattern(`^role${dotNetWhitespace}+\"(${stringBodyPattern})\"$`);\nconst callerClaimPattern = pattern(`^claim${dotNetWhitespace}+\"(${stringBodyPattern})\"${dotNetWhitespace}*=${dotNetWhitespace}*\"(${stringBodyPattern})\"$`);\n\n// 'given caller' and the authenticated, role and claim lines under it.\nfunction parseCaller(context: ParserContext, line: SourceLine): SpecificationCallerSyntax | null {\n if (line.content !== 'given caller') {\n context.error(DiagnosticCodes.InvalidSpecificationCaller, \"Expected exactly 'given caller'.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n let authenticated = false;\n const roles: string[] = [];\n const claims: SpecificationCallerClaimSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const role = callerRolePattern.exec(child.content);\n const claim = callerClaimPattern.exec(child.content);\n if (child.content === 'authenticated' && !authenticated) {\n authenticated = true;\n } else if (role !== null) {\n roles.push(unescapeString(role[1]));\n } else if (claim !== null) {\n claims.push({ kind: 'SpecificationCallerClaimSyntax', type: unescapeString(claim[1]), value: unescapeString(claim[2]), location: locationOf(child) });\n } else {\n context.error(containsCaseReference(child.content) ? DiagnosticCodes.InvalidSpecificationCaseReference : DiagnosticCodes.InvalidSpecificationCaller, `Invalid caller fixture '${child.content}' - expected authenticated, role \"...\", or claim \"...\" = \"...\".`, locationOf(child));\n }\n }\n return { kind: 'SpecificationCallerSyntax', authenticated, roles, claims, location: locationOf(line) };\n}\n\nfunction parseWhen(context: ParserContext, line: SourceLine, body: SpecificationBody, name: string): void {\n const appends = line.content.startsWith('when append');\n if (body.whenDeclared) {\n const code = body.whenAppended !== null || appends ? DiagnosticCodes.ConflictingSpecificationActions : DiagnosticCodes.DuplicateSpecificationWhen;\n context.error(code, `Specification '${name}' already declares a 'when' - a specification can have at most one`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n body.whenDeclared = true;\n if (appends) {\n body.whenAppended = parseEventStep(context, line, whenAppendPattern, 'when append') ?? null;\n return;\n }\n if (whenRedeliveredPrefix.test(line.content)) {\n const match = whenRedeliveredPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnmatchedRedeliveredOccurrence, \"Expected 'when redelivered <Event> to <Reaction>'.\", locationOf(line));\n skipBody(context, line.indent);\n } else {\n body.whenRedelivered = { kind: 'SpecificationRedeliverySyntax', eventType: match[1], reaction: match[2], ...parseValuesWithEventSource(context, line, undefined, undefined, 'when redelivered'), location: locationOf(line) };\n }\n return;\n }\n if (whenClockPrefix.test(line.content)) {\n body.whenClock = parseClock(context, line, 'when');\n return;\n }\n if (whenTriggerPrefix.test(line.content)) {\n body.whenTrigger = parseNamedStep(context, line, whenTriggerPattern, DiagnosticCodes.InvalidSpecificationTrigger, 'when trigger', 'when trigger <Trigger>',\n (trigger, values) => ({ kind: 'SpecificationTriggerSyntax', trigger, values, location: locationOf(line) }));\n return;\n }\n if (whenCapturePrefix.test(line.content)) {\n body.whenCapture = parseCapture(context, line, 'when');\n return;\n }\n if (whenQueryPrefix.test(line.content)) {\n body.whenQuery = parseNamedStep(context, line, whenQueryPattern, DiagnosticCodes.InvalidSpecificationQueryAction, 'when query', 'when query <Query>',\n (query, values) => ({ kind: 'SpecificationWhenQuerySyntax', query, arguments: values, location: locationOf(line) }), true);\n return;\n }\n const match = whenPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationWhen, `Invalid 'when' declaration '${line.content}' - expected 'when <CommandType>' or 'when append <EventType>'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n const generatedValues: PropertyMappingSyntax[] = [];\n const values = parseValuesWithEventSource(context, line, generatedValues, match);\n body.when = { kind: 'SpecificationCommandSyntax', commandType: match[1], ...values, generatedValues, inlineProperty: match.groups?.property ?? null, location: locationOf(line) };\n}\n\nfunction parseThen(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n if (noEventsPrefix.test(line.content)) {\n if (line.content !== 'then no events' || body.thenNoEvents) {\n context.error(DiagnosticCodes.InvalidNoEventsExpectation, \"Expected one 'then no events' directive.\", locationOf(line));\n } else {\n body.thenNoEvents = true;\n body.noEventsLine = line;\n }\n const child = context.peekChild(line.indent);\n if (child !== undefined) context.error(DiagnosticCodes.InvalidNoEventsExpectation, \"'then no events' cannot have child mappings.\", locationOf(child));\n skipBody(context, line.indent);\n return;\n }\n if (thenReturnsPrefix.test(line.content)) {\n const expectation = parseReturn(context, line);\n if (body.thenReturns !== null) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A specification declares at most one return expectation.', locationOf(line));\n } else {\n body.thenReturns = expectation;\n }\n return;\n }\n if (line.content.startsWith('then events')) {\n if (line.content !== 'then events in any order' || body.thenEventsInAnyOrder) {\n context.error(DiagnosticCodes.InvalidSpecificationEventOrder, 'Expected one \\'then events in any order\\' directive.', locationOf(line));\n } else {\n body.thenEventsInAnyOrder = true;\n }\n skipBody(context, line.indent);\n return;\n }\n if (thenResultPrefix.test(line.content)) {\n parseResult(context, line, body);\n return;\n }\n if (noResultPrefix.test(line.content)) {\n if (line.content !== 'then no result' || body.thenNoResult !== null) {\n context.error(DiagnosticCodes.InvalidSpecificationQueryAction, 'Expected one \\'then no result\\' directive.', locationOf(line));\n } else {\n body.thenNoResult = { kind: 'SpecificationNoResultSyntax', location: locationOf(line) };\n }\n skipBody(context, line.indent);\n return;\n }\n if (thenInvokesPrefix.test(line.content)) {\n const invocation = parseNamedStep(context, line, thenInvokesPattern, DiagnosticCodes.InvalidSpecificationInvocation, 'then invokes', 'then invokes <Command>',\n (command, values): SpecificationInvocationSyntax => ({ kind: 'SpecificationInvocationSyntax', command, values, location: locationOf(line) }));\n if (invocation !== null) (body.thenInvocations ??= []).push(invocation);\n return;\n }\n if (line.content.startsWith('then denied')) {\n if (line.content !== 'then denied') {\n context.error(DiagnosticCodes.InvalidSpecificationDenied, 'Expected exactly \\'then denied\\'.', locationOf(line));\n skipBody(context, line.indent);\n } else if (body.thenDenied !== null) {\n context.error(DiagnosticCodes.DuplicateSpecificationCallerOrDenied, \"A specification has at most one 'then denied' outcome.\", locationOf(line));\n } else {\n body.thenDenied = { kind: 'SpecificationDeniedSyntax', location: locationOf(line) };\n }\n return;\n }\n if (line.content === 'then error') {\n body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: null, location: locationOf(line) });\n return;\n }\n if (line.content.startsWith('then error case.')) {\n const caseValue = parseMappingSource(line.content.substring(11), { ...locationOf(line), column: locationOf(line).column + 11 }, context);\n if (caseValue.kind === 'CaseValueExpressionSyntax') body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: null, caseValue, location: locationOf(line) });\n return;\n }\n const error = thenErrorPattern.exec(line.content);\n if (error !== null) {\n body.thenErrors.push({ kind: 'SpecificationErrorSyntax', name: unescapeString(error[1]), location: locationOf(line) });\n return;\n }\n if (firstWord(line.content.substring('then'.length).trim()) === 'error') {\n context.error(DiagnosticCodes.InvalidThenError, `Invalid 'then error' declaration '${line.content}' - expected 'then error' or 'then error \"<reason>\"'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n if (thenNoPrefix.test(line.content)) {\n // Legacy documents keep skipping these assertions silently; Exact mirrors the native diagnostics.\n if (context.sourceOptions.numericMode === 'exact') {\n const absent = parseAbsentReadModel(context, line);\n if (absent !== null) body.thenAbsentReadModels.push(absent);\n return;\n }\n const match = thenAbsentReadModelPattern.exec(line.content);\n if (match !== null && match[2] === undefined && context.peekChild(line.indent) !== undefined) {\n // 'for' ending the line opens the key's members as an indented block.\n body.thenAbsentReadModels.push({ kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key: parseStructuredValue(context.valueContext, line, undefined), location: locationOf(line) });\n return;\n }\n if (match !== null && match[2] !== undefined && !match[2].endsWith(' exactly')) {\n const key = parseMappingSource(match[2].trim(), locationOf(line), context.valueContext);\n if (key.kind === 'LiteralExpressionSyntax' || key.kind === 'ObjectExpressionSyntax' || key.kind === 'CaseValueExpressionSyntax') body.thenAbsentReadModels.push({ kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key, location: locationOf(line) });\n }\n context.skipOpaqueBlock(line.indent);\n return;\n }\n if (thenQueryPrefix.test(line.content)) {\n // Legacy documents keep skipping malformed query bodies silently; Exact reports what the native parser reports.\n const exact = context.sourceOptions.numericMode === 'exact';\n const reject = (code: string, message: string, at: SourceLine): void => {\n if (!exact) return context.skipOpaqueBlock(at.indent);\n context.error(code, message, locationOf(at));\n context.skipBlock(at.indent);\n };\n const match = thenQueryPattern.exec(line.content);\n if (match === null) return reject(DiagnosticCodes.InvalidSpecificationQuery, `Invalid 'then query' declaration '${line.content}' - expected 'then query <Query> [exactly]'`, line);\n const args: PropertyMappingSyntax[] = [];\n const results: SpecificationQueryResultSyntax[] = [];\n let hasArguments = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'arguments' && !hasArguments) args.push(...parseValues(context.valueContext, child, true, undefined, context));\n else if (child.content === 'arguments') reject(DiagnosticCodes.DuplicateSpecificationQueryArguments, `Query assertion '${match[1]}' already declares arguments`, child);\n else if (child.content === 'result') results.push({ kind: 'SpecificationQueryResultSyntax', properties: parseValues(context.valueContext, child, true), exactly: false, location: locationOf(child) });\n else reject(DiagnosticCodes.UnknownSpecificationQueryDirective, `Unexpected '${firstWord(child.content)}' in 'then query' body - expected arguments or result`, child);\n hasArguments ||= child.content === 'arguments';\n }\n body.thenQueries.push({ kind: 'SpecificationQuerySyntax', query: match[1], arguments: args, results, exactly: match[2] !== undefined, location: locationOf(line) });\n return;\n }\n if (readModelPrefix.test(line.content)) {\n const readModel = parseReadModelStep(context, line, thenReadModelPattern, 'then');\n if (readModel !== undefined) {\n body.thenReadModels.push(readModel);\n }\n return;\n }\n const event = parseEventStep(context, line, thenEventPattern, 'then');\n if (event !== undefined) {\n body.thenEvents.push(event);\n }\n}\n\n// The Exact port of C# ParseAbsentReadModel: every malformed part is reported rather than dropped.\nfunction parseAbsentReadModel(context: ParserContext, line: SourceLine): SpecificationAbsentReadModelSyntax | null {\n const match = thenAbsentReadModelPattern.exec(line.content);\n if (match !== null && match[2] === undefined && context.peekChild(line.indent) !== undefined) {\n return { kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key: parseStructuredValue(context, line, undefined), location: locationOf(line) } as SpecificationAbsentReadModelSyntax;\n }\n if (match === null || match[2] === undefined || match[2].endsWith(' exactly')) {\n context.error(DiagnosticCodes.InvalidAbsentReadModelStep, `Invalid absence assertion '${line.content}' - expected 'then no readmodel <ReadModelType> for <key>'`, locationOf(line));\n skipBody(context, line.indent);\n return null;\n }\n const keyText = match[2].trim();\n const validString = !(keyText.startsWith('\"') || keyText.startsWith(\"'\")) || absentKeyStringPattern.test(keyText);\n const key = validString ? parseMappingSource(keyText, locationOf(line), context.valueContext) : null;\n const concrete = key !== null && (key.kind === 'LiteralExpressionSyntax' || key.kind === 'ObjectExpressionSyntax' || key.kind === 'CaseValueExpressionSyntax');\n if (!concrete) context.error(DiagnosticCodes.InvalidAbsentReadModelStep, `Invalid absence key '${keyText}' - expected exactly one concrete value.`, locationOf(line));\n let hasChildren = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n context.error(DiagnosticCodes.InvalidAbsentReadModelStep, 'An absent read model assertion cannot have child mappings.', locationOf(child));\n hasChildren = true;\n }\n return hasChildren || !concrete ? null : { kind: 'SpecificationAbsentReadModelSyntax', name: match[1], key, location: locationOf(line) } as SpecificationAbsentReadModelSyntax;\n}\n\nfunction skipBody(context: ParserContext, indent: number): void {\n if (context.sourceOptions.numericMode !== 'exact') return context.skipBlock(indent);\n context.skipOpaqueBlock(indent);\n}\n\nfunction parseClock(context: ParserContext, line: SourceLine, keyword: string): SpecificationClockSyntax | null {\n const match = clockPattern.exec(line.content);\n skipBody(context, line.indent);\n if (match === null || match[1] !== keyword) {\n context.error(containsCaseReference(line.content) ? DiagnosticCodes.InvalidSpecificationCaseReference : DiagnosticCodes.InvalidSpecificationClock,\n `Invalid '${keyword} clock' - expected '${keyword} clock \"<ISO 8601 instant>\"', such as '${keyword} clock \"2026-10-05T08:00:00Z\"'`, locationOf(line));\n return null;\n }\n return { kind: 'SpecificationClockSyntax', instant: match[2], location: locationOf(line) };\n}\n\nfunction parseGivenGenerated(context: ParserContext, line: SourceLine): SpecificationGeneratedValueSyntax | null {\n const match = givenGeneratedPattern.exec(line.content);\n const block = match === null ? givenGeneratedBlockPattern.exec(line.content) : null;\n if (block !== null) {\n return { kind: 'SpecificationGeneratedValueSyntax', command: block[1], property: block[2], source: parseStructuredValue(context, line, block[3] as StructuredMarker), location: locationOf(line) };\n }\n if (match === null) {\n context.error(DiagnosticCodes.InvalidGeneratedFixture, \"Expected 'given generated <Command>.<property> = <value>' with exactly one concrete value.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const location = locationOf(line);\n const source = parseConcrete(context, match[3], { ...location, column: location.column + line.content.indexOf(match[3], line.content.indexOf('=') + 1) }, DiagnosticCodes.InvalidGeneratedFixture);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidGeneratedFixture, 'A pinned generated value cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'SpecificationGeneratedValueSyntax', command: match[1], property: match[2], source, location };\n}\n\nfunction parseCapture(context: ParserContext, line: SourceLine, keyword: string): SpecificationCaptureSyntax | null {\n return parseNamedStep(context, line, capturePattern, DiagnosticCodes.InvalidSpecificationCapture, `${keyword} capture`, `${keyword} capture <Capture>`,\n (capture, record) => ({ kind: 'SpecificationCaptureSyntax', capture, record, location: locationOf(line) }));\n}\n\n// A step naming one thing on its header line, with '<field> = <value>' lines beneath it.\nfunction parseNamedStep<T>(\n context: ParserContext, line: SourceLine, regex: RegExp, code: string, keyword: string, expected: string,\n create: (name: string, values: PropertyMappingSyntax[]) => T, queryArguments = false): T | null {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(code, `Invalid '${keyword}' declaration '${line.content}' - expected '${expected}'`, locationOf(line));\n skipBody(context, line.indent);\n return null;\n }\n return create(match[1], parseValues(context, line, false, undefined, queryArguments ? context : undefined));\n}\n\nfunction parseResult(context: ParserContext, line: SourceLine, body: SpecificationBody): void {\n const match = thenResultPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationQueryAction, `Invalid 'then result' declaration '${line.content}' - expected 'then result [exactly]'`, locationOf(line));\n skipBody(context, line.indent);\n return;\n }\n body.thenResults.push({ kind: 'SpecificationQueryResultSyntax', properties: parseValues(context, line), exactly: match[1] !== undefined, location: locationOf(line) });\n}\n\nfunction parseReadModelStep(context: ParserContext, line: SourceLine, regex: RegExp, keyword: string): SpecificationReadModelSyntax | undefined {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidReadModelStep, `Invalid '${keyword} readmodel' declaration '${line.content}' - expected '${keyword} readmodel <ReadModelType>'`, locationOf(line));\n skipBody(context, line.indent);\n return undefined;\n }\n return {\n kind: 'SpecificationReadModelSyntax',\n name: match[1],\n properties: parseValues(context, line, false, match),\n exactly: keyword === 'then' && match.groups?.exactly !== undefined,\n inlineProperty: match.groups?.property ?? null,\n location: locationOf(line),\n };\n}\n\nfunction parseEventStep(context: ParserContext, line: SourceLine, regex: RegExp, keyword: string): SpecificationEventSyntax | undefined {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEventStep, `Invalid '${keyword}' declaration '${line.content}' - expected '${keyword} <EventType>'`, locationOf(line));\n skipBody(context, line.indent);\n return undefined;\n }\n return { kind: 'SpecificationEventSyntax', eventType: match[1], ...parseValuesWithEventSource(context, line, undefined, match, keyword), inlineProperty: match.groups?.property ?? null, location: locationOf(line) };\n}\n\nexport const specificationStream = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*)\\\\.([A-Za-z_]\\\\w*)$');\nconst specificationStreamId = pattern('^streamId\\\\s*=(?!=|>)\\\\s*(.+)$');\n\nfunction parseValuesWithEventSource(context: ParserContext, parent: SourceLine, generated?: PropertyMappingSyntax[], inline?: RegExpExecArray, eventKeyword?: string): { values: PropertyMappingSyntax[]; for: ExpressionSyntax | null; stream?: SpecificationStreamSyntax; noStream?: SpecificationNoStreamSyntax } {\n const values: PropertyMappingSyntax[] = [];\n addInlineValue(context, parent, inline, values);\n let eventSource: ExpressionSyntax | null = null;\n let stream: SpecificationStreamSyntax | undefined;\n let noStream: SpecificationNoStreamSyntax | undefined;\n let hasRoute = false;\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n let structured: PropertyMappingSyntax | undefined;\n if (generated !== undefined && generatedFixturePrefix.test(child.content)) {\n const fixture = parseConcreteMapping(context, child, generatedFixturePattern, DiagnosticCodes.InvalidGeneratedFixture);\n if (fixture !== null) generated.push(fixture);\n continue;\n }\n const mapping = mappingPattern.exec(child.content);\n if (mapping !== null) {\n addFixtureValue(context, values, mappingOf(context, child, mapping));\n } else if (firstWord(child.content) === 'stream' || child.content.startsWith('no stream')) {\n if (eventKeyword === undefined) {\n context.error(DiagnosticCodes.SpecificationStreamOnCommand, 'A command occurrence cannot declare a route; assert it on a then event.', locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n if (hasRoute) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'An event occurrence declares at most one stream or no stream directive.', locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const route = specificationStream.exec(child.content);\n if (child.content === 'no stream' && (eventKeyword === 'then' || eventKeyword === 'when redelivered')) {\n noStream = { kind: 'SpecificationNoStreamSyntax', location: locationOf(child) };\n hasRoute = true;\n rejectSpecificationRouteChildren(context, child);\n } else if (route !== null) {\n stream = parseSpecificationStream(context, child, route);\n hasRoute = true;\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Expected 'stream Source.Stream', or 'no stream' on a then event.\", locationOf(child));\n context.skipBlock(child.indent);\n }\n } else if (firstWord(child.content) === 'for') {\n const source = child.content.substring('for'.length).trim();\n if (source.length === 0) {\n context.error(DiagnosticCodes.InvalidSpecificationEventSource, 'Invalid event-source assertion \\'for\\' - expected \\'for <value>\\'', locationOf(child));\n } else if (eventSource !== null) {\n context.error(DiagnosticCodes.DuplicateSpecificationEventSource, 'A specification step can declare its event-source assertion only once', locationOf(child));\n } else {\n eventSource = parseMappingSource(source, locationOf(child), context);\n }\n } else if ((structured = tryParseStructuredMapping(context, child)) !== undefined) {\n addFixtureValue(context, values, structured);\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child), diagnosticText('text', child.content));\n }\n }\n return { values, for: eventSource, ...(stream === undefined ? {} : { stream }), ...(noStream === undefined ? {} : { noStream }) };\n}\n\nexport function parseSpecificationStream(context: ParserContext, header: SourceLine, route: RegExpExecArray): SpecificationStreamSyntax {\n let streamId: PropertyMappingSyntax | null = null;\n let streamIdParts: PropertyMappingSyntax[] = [];\n let block = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'streamId') {\n if (streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Declare either one 'streamId = <literal>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n block = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseRouteParts(context, child, DiagnosticCodes.InvalidSpecificationStream).map(part => part.source.kind === 'PathExpressionSyntax' && part.source.path.startsWith('case.')\n ? { ...part, source: parseMappingSource(part.source.path, part.source.location, context) } : part);\n }\n continue;\n }\n const mapping = specificationStreamId.exec(child.content);\n if (mapping === null || streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Declare either one 'streamId = <literal>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(mapping[1], child.content.indexOf('=') + 1) };\n streamId = { kind: 'PropertyMappingSyntax', property: 'streamId', source: parseMappingSource(mapping[1], location, context), location: locationOf(child) };\n rejectSpecificationRouteChildren(context, child);\n }\n return { kind: 'SpecificationStreamSyntax', eventSource: route[1], stream: route[2], streamId, streamIdParts, directiveLocations,\n referenceLocation: { ...locationOf(header), column: header.indent + 1 + header.content.indexOf(route[1], 'stream'.length) },\n referenceLength: route[1].length + 1 + route[2].length, location: locationOf(header) };\n}\n\nexport function rejectSpecificationRouteChildren(context: ParserContext, line: SourceLine): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'This directive cannot have children.', locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n\nfunction parseValues(context: ParserContext, parent: SourceLine, nativeIdentifiers = false, inline?: RegExpExecArray, queryArgumentsContext?: ParserContext): PropertyMappingSyntax[] {\n const values: PropertyMappingSyntax[] = [];\n addInlineValue(context, parent, inline, values);\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n const mapping = (nativeIdentifiers || context.sourceOptions.numericMode === 'exact' ? nativeMappingPattern : mappingPattern).exec(child.content);\n const structured = mapping === null ? tryParseStructuredMapping(context, child) : undefined;\n if (mapping === null && structured === undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child), diagnosticText('text', child.content));\n continue;\n }\n const value = structured ?? mappingOf(context, child, mapping!, nativeIdentifiers);\n if (queryArgumentsContext !== undefined) {\n if (values.some(existing => existing.property === value.property)) {\n queryArgumentsContext.error(DiagnosticCodes.UnknownSpecificationQueryArgument, `Query argument '${value.property}' is repeated.`, value.location, diagnosticText('argument', value.property));\n }\n values.push(value);\n } else {\n addFixtureValue(context, values, value);\n }\n }\n return values;\n}\n\nfunction mappingOf(context: ParserContext, line: SourceLine, match: RegExpExecArray, nativeIdentifiers = false): PropertyMappingSyntax {\n return { kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], locationOf(line), context, nativeIdentifiers), location: locationOf(line) };\n}\n\nconst lifecycleWhenStart = pattern('^when\\\\s+start\\\\s+(.+)$');\nconst lifecycleOutcome = pattern('^outcome\\\\s+([A-Za-z_]\\\\w*)\\\\s+([A-Za-z_]\\\\w*)$');\nconst lifecycleThen = pattern('^then\\\\s+(is|sends|starts|completes|fails\\\\s+at|waits\\\\s+at)(?:\\\\s+([A-Za-z_]\\\\w*))?$');\n\nfunction lifecycleExpectation(line: SourceLine): LifecycleExpectationSyntax | undefined {\n const match = lifecycleThen.exec(line.content);\n if (match === null) return undefined;\n const word = match[1].replace(/\\s+/g, ' ');\n const expectation: LifecycleExpectationKind = word === 'is' ? 'State' : word === 'sends' ? 'Sends' : word === 'starts' ? 'Starts' : word === 'completes' ? 'Completes' : word === 'fails at' ? 'Fails' : 'Waits';\n if ((match[2] !== undefined) === (expectation === 'Completes')) return undefined;\n return { kind: 'LifecycleExpectationSyntax', expectation, target: match[2] ?? null, location: locationOf(line) };\n}\n\n// A specification written inside a statemachine or a workflow - the port of C# SpecificationParser.ParseLifecycle.\nexport function parseLifecycleSpecification(context: ParserContext, header: SourceLine, code: string): LifecycleSpecificationSyntax {\n const match = specificationHeader.exec(header.content);\n if (match === null) {\n context.error(code, `Invalid specification '${header.content}' - expected 'specification <Name>'.`, locationOf(header));\n skipBody(context, header.indent);\n return { kind: 'LifecycleSpecificationSyntax', name: '', description: null, given: [], whenAppended: null, whenStarted: null, outcomes: [], then: [], location: locationOf(header) };\n }\n const name = match[1];\n let description: string | null = null;\n const given: SpecificationEventSyntax[] = [];\n let whenAppended: SpecificationEventSyntax | null = null;\n let whenStarted: ExpressionSyntax | null = null;\n let whenDeclared = false;\n const outcomes: LifecycleOutcomeSyntax[] = [];\n const then: LifecycleExpectationSyntax[] = [];\n const directiveLocations: Record<string, SourceLocation> = {};\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === 'description') {\n description = parseDescription(context, line, description, `Specification '${name}'`);\n directiveLocations.description ??= locationOf(line);\n } else if (keyword === 'given') {\n const fact = parseEventStep(context, line, givenPattern, 'given');\n if (fact !== undefined) given.push(fact);\n } else if (keyword === 'when') {\n if (whenDeclared) {\n context.error(code, `Specification '${name}' already declares a 'when'.`, locationOf(line));\n skipBody(context, line.indent);\n continue;\n }\n whenDeclared = true;\n const start = lifecycleWhenStart.exec(line.content);\n if (start !== null) {\n const index = line.content.indexOf(start[1], 'when start'.length);\n whenStarted = parseMappingSource(start[1].trim(), sourceLocation(line.number, line.indent + (line.contentOffset ?? 0) + 1 + index, line.path), context);\n } else if (line.content.startsWith('when append')) whenAppended = parseEventStep(context, line, whenAppendPattern, 'when append') ?? null;\n else {\n context.error(code, `Invalid '${line.content}' - expected 'when append <Event>' or 'when start <key>'.`, locationOf(line));\n skipBody(context, line.indent);\n }\n } else if (keyword === 'outcome') {\n const outcome = lifecycleOutcome.exec(line.content);\n if (outcome !== null) outcomes.push({ kind: 'LifecycleOutcomeSyntax', node: outcome[1], outlet: outcome[2], location: locationOf(line) });\n else context.error(code, `Invalid outcome '${line.content}' - expected 'outcome <Node> <outlet>'.`, locationOf(line));\n rejectOperationChildren(context, line, code, 'An outcome cannot have children.');\n } else if (keyword === 'then') {\n const expectation = lifecycleExpectation(line);\n if (expectation !== undefined) then.push(expectation);\n else context.error(code, `Invalid '${line.content}' - expected 'then is <State>', 'then sends <Command>', 'then starts <Workflow>', 'then completes', 'then fails at <Node>' or 'then waits at <Node>'.`, locationOf(line));\n rejectOperationChildren(context, line, code, 'A then line cannot have children.');\n } else {\n context.error(code, `Unexpected '${line.content}' in specification '${name}' - expected description, given, when, outcome or then.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n return { kind: 'LifecycleSpecificationSyntax', name, description, given, whenAppended, whenStarted, outcomes, then, location: locationOf(header), directiveLocations };\n}\n"],"mappings":"uzCA8BA,MAAMC,GAAsBC,EAAQ,oEAAoE,EAClGC,GAAgBD,EAAQ,yGAAyG,EACjIE,EAASF,EAAQ,oCAAoC,EACrDG,EAAsBD,EACtBE,EAAuBJ,EAAQ,mCAAmC,EAGlE,aAAe,EAAgB,EAAU,KAAeK,EAAc,IAAIC,EAAO,6BAAiBC,8DAA8B,WAAW,MAAOC,CAAgB,CAAC,EACnKC,EAAe,YAAY,OAAO,EAClCC,EAAoB,YAAY,gBAAgB,EAChDC,EAAc,YAAY,MAAM,EAChCC,EAAmB,YAAY,MAAM,EACrCC,EAAkBb,EAAQ,mBAAmB,EAC7Cc,EAAkBd,EAAQ,iCAAiC,EAC3De,EAAwB,YAAY,oBAAoB,EACxDC,EAAuB,YAAY,oBAAqB,0BAA0B,EAClFC,EAAejB,EAAQ,gBAAgB,EACvCkB,EAAmBlB,EAAQ,uBAAuBmB,EAAkB,IAAI,EACxEC,EAAiBpB,EAAQ,iCAAiC,EAC1DqB,EAAuBhB,EAAc,iCAAiC,EACtEiB,EAAsBtB,EAAQ,2BAA2B,EACzDuB,EAAu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AUG,EAAWlD,CAAM,EAAG,oBAAmB,CACzK"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{parseDescription as i}from"./DescriptionParser.js";import{parseCondition as a}from"./ConditionParser.js";import{rejectOperationChildren as o}from"./OperationParser.js";import{parseLifecycleSpecification as s}from"./SpecificationParser.js";const c=t(`^statemachine\\s+([A-Za-z_]\\w*)$`),l=t(`^follows\\s+([A-Za-z_]\\w*)$`),u=t(`^state\\s+([A-Za-z_]\\w*)((?:\\s+(?:initial|final))*)$`),d=t(`^entering\\s+(send|start)\\s+([A-Za-z_]\\w*)$`),f=t(`^on\\s+([A-Za-z_][\\w.]*)(?:\\s+when\\s+(.+?))?\\s*->\\s*([A-Za-z_]\\w*)$`);function parseStateMachine(t,a){let u=c.exec(a.content);if(u===null)return t.error(e.InvalidStateMachineDeclaration,`Invalid state machine declaration '${a.content}' - expected 'statemachine <Name>'.`,n(a)),t.skipBlock(a.indent),{kind:`StateMachineSyntax`,name:r(a.content),follows:``,description:null,states:[],specifications:[],location:n(a)};let d=u[1],f=null,p=null,m=[],h=[],g={};for(let c=t.peekChild(a.indent);c!==void 0;c=t.peekChild(a.indent))switch(t.reader.takeSignificant(),r(c.content)){case`description`:f=i(t,c,f,`State machine '${d}'`),g.description??=n(c);break;case`follows`:{let r=l.exec(c.content);r===null?t.error(e.InvalidStateMachineDeclaration,`Invalid follows '${c.content}' - expected 'follows <ReadModel>'.`,n(c)):p===null?(p=r[1],g.follows=n(c)):t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' follows more than one read model.`,n(c)),o(t,c,e.InvalidStateMachineDeclaration,`A follows line cannot have children.`);break}case`state`:m.push(parseState(t,c,d));break;case`specification`:h.push(s(t,c,e.InvalidStateMachineDeclaration));break;default:t.error(e.InvalidStateMachineDeclaration,`Unexpected '${c.content}' in state machine '${d}' - expected description, follows, state or specification.`,n(c)),t.skipBlock(c.indent)}p===null&&t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' must follow a read model: 'follows <ReadModel>'.`,n(a));let _=/* @__PURE__ */ new Set;for(let n of m)_.has(n.name)&&t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' declares state '${n.name}' more than once.`,n.location),_.add(n.name);return{kind:`StateMachineSyntax`,name:d,follows:p??``,description:f,states:m,specifications:h,location:n(a),directiveLocations:g}}function parseState(t,i,s){let c=u.exec(i.content);if(c===null)return t.error(e.InvalidStateMachineDeclaration,`Invalid state '${i.content}' - expected 'state <Name> [initial] [final]'.`,n(i)),t.skipBlock(i.indent),{kind:`StateSyntax`,name:``,isInitial:!1,isFinal:!1,entering:[],transitions:[],location:n(i)};let l=c[2].split(` `).filter(e=>e.length>0);l.length!==new Set(l).size&&t.error(e.InvalidStateMachineDeclaration,`State '${c[1]}' repeats a modifier.`,n(i));let p=[],m=[];for(let l=t.peekChild(i.indent);l!==void 0;l=t.peekChild(i.indent))switch(t.reader.takeSignificant(),r(l.content)){case`entering`:{let r=d.exec(l.content);r===null?t.error(e.InvalidStateMachineDeclaration,`Invalid entering '${l.content}' - expected 'entering send <Command>' or 'entering start <Workflow>'.`,n(l)):p.push({kind:`StateEntrySyntax`,entryKind:r[1]===`send`?`Send`:`Start`,target:r[2],location:n(l)}),o(t,l,e.InvalidStateMachineDeclaration,`An entering line cannot have children.`);break}case`on`:{let r=f.exec(l.content);if(r===null)t.error(e.InvalidStateMachineDeclaration,`Invalid transition '${l.content}' - expected 'on <Event> [when <condition>] -> <State>'.`,n(l));else{let e=null,i=!1;r[2]!==void 0&&(e=a(t,r[2],n(l)),i=e===null),i||m.push({kind:`StateTransitionSyntax`,event:r[1],when:e,target:r[3],location:n(l)})}o(t,l,e.InvalidStateMachineDeclaration,`A transition cannot have children.`);break}default:t.error(e.InvalidStateMachineDeclaration,`Unexpected '${l.content}' in state '${c[1]}' of '${s}' - expected entering or on.`,n(l)),t.skipBlock(l.indent)}return{kind:`StateSyntax`,name:c[1],isInitial:l.includes(`initial`),isFinal:l.includes(`final`),entering:p,transitions:m,location:n(i)}}export{parseStateMachine};
|
|
2
|
+
//# sourceMappingURL=StateMachineParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateMachineParser.js","names":["headerPattern","pattern","followsPattern","statePattern","enteringPattern","transitionPattern","match","header","context","DiagnosticCodes","locationOf","firstWord","name","description","follows","states","specifications","directiveLocations","line","parseDescription","followed","rejectOperationChildren","parseLifecycleSpecification","seen","state","modifiers","word","entering","transitions","entry","transition","when","failed","parseCondition","machine"],"sources":["../../../../../../Compiler/Parsing/StateMachineParser.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ConditionSyntax } from '../Syntax/Conditions';\nimport { LifecycleSpecificationSyntax, StateEntrySyntax, StateMachineSyntax, StateSyntax, StateTransitionSyntax } from '../Syntax/Lifecycles';\nimport { pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord } from './LineText';\nimport { rejectOperationChildren } from './OperationParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseLifecycleSpecification } from './SpecificationParser';\n\nconst headerPattern = pattern('^statemachine\\\\s+([A-Za-z_]\\\\w*)$');\nconst followsPattern = pattern('^follows\\\\s+([A-Za-z_]\\\\w*)$');\nconst statePattern = pattern('^state\\\\s+([A-Za-z_]\\\\w*)((?:\\\\s+(?:initial|final))*)$');\nconst enteringPattern = pattern('^entering\\\\s+(send|start)\\\\s+([A-Za-z_]\\\\w*)$');\nconst transitionPattern = pattern('^on\\\\s+([A-Za-z_][\\\\w.]*)(?:\\\\s+when\\\\s+(.+?))?\\\\s*->\\\\s*([A-Za-z_]\\\\w*)$');\n\n// The port of C# StateMachineParser.\nexport function parseStateMachine(context: ParserContext, header: SourceLine): StateMachineSyntax {\n const match = headerPattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid state machine declaration '${header.content}' - expected 'statemachine <Name>'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'StateMachineSyntax', name: firstWord(header.content), follows: '', description: null, states: [], specifications: [], location: locationOf(header) };\n }\n const name = match[1];\n let description: string | null = null;\n let follows: string | null = null;\n const states: StateSyntax[] = [];\n const specifications: LifecycleSpecificationSyntax[] = [];\n const directiveLocations: Record<string, SourceLocation> = {};\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(line.content)) {\n case 'description':\n description = parseDescription(context, line, description, `State machine '${name}'`);\n directiveLocations.description ??= locationOf(line);\n break;\n case 'follows': {\n const followed = followsPattern.exec(line.content);\n if (followed === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid follows '${line.content}' - expected 'follows <ReadModel>'.`, locationOf(line));\n else if (follows !== null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' follows more than one read model.`, locationOf(line));\n else {\n follows = followed[1];\n directiveLocations.follows = locationOf(line);\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'A follows line cannot have children.');\n break;\n }\n case 'state':\n states.push(parseState(context, line, name));\n break;\n case 'specification':\n specifications.push(parseLifecycleSpecification(context, line, DiagnosticCodes.InvalidStateMachineDeclaration));\n break;\n default:\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Unexpected '${line.content}' in state machine '${name}' - expected description, follows, state or specification.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n if (follows === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' must follow a read model: 'follows <ReadModel>'.`, locationOf(header));\n const seen = new Set<string>();\n for (const state of states) {\n if (seen.has(state.name)) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' declares state '${state.name}' more than once.`, state.location);\n seen.add(state.name);\n }\n return { kind: 'StateMachineSyntax', name, follows: follows ?? '', description, states, specifications, location: locationOf(header), directiveLocations };\n}\n\nfunction parseState(context: ParserContext, header: SourceLine, machine: string): StateSyntax {\n const match = statePattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid state '${header.content}' - expected 'state <Name> [initial] [final]'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'StateSyntax', name: '', isInitial: false, isFinal: false, entering: [], transitions: [], location: locationOf(header) };\n }\n const modifiers = match[2].split(' ').filter(word => word.length > 0);\n if (modifiers.length !== new Set(modifiers).size) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State '${match[1]}' repeats a modifier.`, locationOf(header));\n const entering: StateEntrySyntax[] = [];\n const transitions: StateTransitionSyntax[] = [];\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(line.content)) {\n case 'entering': {\n const entry = enteringPattern.exec(line.content);\n if (entry === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid entering '${line.content}' - expected 'entering send <Command>' or 'entering start <Workflow>'.`, locationOf(line));\n else entering.push({ kind: 'StateEntrySyntax', entryKind: entry[1] === 'send' ? 'Send' : 'Start', target: entry[2], location: locationOf(line) });\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'An entering line cannot have children.');\n break;\n }\n case 'on': {\n const transition = transitionPattern.exec(line.content);\n if (transition === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid transition '${line.content}' - expected 'on <Event> [when <condition>] -> <State>'.`, locationOf(line));\n else {\n let when: ConditionSyntax | null = null;\n let failed = false;\n if (transition[2] !== undefined) {\n when = parseCondition(context, transition[2], locationOf(line));\n failed = when === null;\n }\n if (!failed) transitions.push({ kind: 'StateTransitionSyntax', event: transition[1], when, target: transition[3], location: locationOf(line) });\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'A transition cannot have children.');\n break;\n }\n default:\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Unexpected '${line.content}' in state '${match[1]}' of '${machine}' - expected entering or on.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n return { kind: 'StateSyntax', name: match[1], isInitial: modifiers.includes('initial'), isFinal: modifiers.includes('final'), entering, transitions, location: locationOf(header) };\n}\n"],"mappings":"ofAgBA,MAAMA,EAAgBC,EAAQ,mCAAmC,EAC3DC,EAAiBD,EAAQ,8BAA8B,EACvDE,EAAeF,EAAQ,wDAAwD,EAC/EG,EAAkBH,EAAQ,+CAA+C,EACzEI,EAAoBJ,EAAQ,2EAA2E,EAG7G,SAAgB,kBAAkB,EAAwB,EAAwC,CAC9F,IAAMK,EAAQN,EAAc,KAAKO,EAAO,OAAO,EAC/C,GAAID,IAAU,KAGV,OAFAE,EAAQ,MAAMC,EAAgB,+BAAgC,sCAAsCF,EAAO,QAAQ,qCAAsCG,EAAWH,CAAM,CAAC,EAC3KC,EAAQ,UAAUD,EAAO,MAAM,EACxB,CAAE,KAAM,qBAAsB,KAAMI,EAAUJ,EAAO,OAAO,EAAG,QAAS,GAAI,YAAa,KAAM,OAAQ,CAAC,EAAG,eAAgB,CAAC,EAAG,SAAUG,EAAWH,CAAM,CAAE,EAEvK,IAAMK,EAAON,EAAM,GACfO,EAA6B,KAC7BC,EAAyB,KACvBC,EAAwB,CAAC,EACzBC,EAAiD,CAAC,EAClDC,EAAqD,CAAC,EAC5D,IAAK,IAAIC,EAAOV,EAAQ,UAAUD,EAAO,MAAM,EAAGW,IAAS,IAAA,GAAW,EAAOV,EAAQ,UAAUD,EAAO,MAAM,EAExG,OADAC,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AAwC,EAC/H,KACJ,CACA,IAAK,KAAM,CACP,IAAMqB,EAAazB,EAAkB,KAAKa,EAAK,OAAO,EACtD,GAAIY,IAAe,KAAMtB,EAAQ,MAAMC,EAAgB,+BAAgC,uBAAuBS,EAAK,QAAQ,0DAA2DR,EAAWQ,CAAI,CAAC,MACjM,CACD,IAAIa,EAA+B,KAC/BC,EAAS,GACTF,EAAW,KAAO,IAAA,KAClB,EAAOG,EAAezB,EAASsB,EAAW,GAAIpB,EAAWQ,CAAI,CAAC,EAC9D,EAASa,IAAS,MAEjBC,GAAQJ,EAAY,KAAK,CAAE,KAAM,wBAAyB,MAAOE,EAAW,GAAI,OAAM,OAAQA,EAAW,GAAI,SAAUpB,EAAWQ,CAAI,CAAE,CAAC,CAClJ,CACAG,EAAwBb,EAASU,EAAMT,EAAgB,+BAAgC,oCAAoC,EAC3H,KACJ,CACA,QACID,EAAQ,MAAMC,EAAgB,+BAAgC,eAAeS,EAAK,QAAQ,cAAcZ,EAAM,GAAG,QAAQ4B,EAAQ,8BAA+BxB,EAAWQ,CAAI,CAAC,EAChLV,EAAQ,UAAUU,EAAK,MAAM,CACrC,CAEJ,MAAO,CAAE,KAAM,cAAe,KAAMZ,EAAM,GAAI,UAAWmB,EAAU,SAAS,SAAS,EAAG,QAASA,EAAU,SAAS,OAAO,EAAG,WAAU,cAAa,SAAUf,EAAWH,CAAM,CAAE,CACtL"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{parseDescription as i}from"./DescriptionParser.js";import{parseCondition as a}from"./ConditionParser.js";import{rejectOperationChildren as o}from"./OperationParser.js";import{parseLifecycleSpecification as s}from"./SpecificationParser.js";import{parseTriggerSource as c}from"./ReactionParser.js";const l=`(seconds?|minutes?|hours?|days?)`,u=t(`^workflow\\s+([A-Za-z_]\\w*)$`),d=t(`^for\\s+([A-Za-z_]\\w*)$`),f=t(`^->\\s*([A-Za-z_]\\w*)$`),p=t(`^(?:"([^"]+)"|([A-Za-z_]\\w*))(?:\\s*->\\s*([A-Za-z_]\\w*))?$`),m=t(`^trigger(?:\\s+(?!(?:on|when|every|at|manual)\\b)([A-Za-z_]\\w*))?\\s+(.+)$`),h=t(`^on\\s+([A-Za-z_][\\w.]*)$`),g=t(`^when\\s+([A-Za-z_]\\w*)\\s+enters\\s+([A-Za-z_]\\w*)$`),_=t(`^action\\s+([A-Za-z_]\\w*)\\s+sends\\s+([A-Za-z_]\\w*)((?:\\s+(?:attempts\\s+\\d+|timeout\\s+\\d+\\s+\\w+|retry\\s+after\\s+\\d+\\s+\\w+))*)$`),v=/attempts\s+(\d+)|timeout\s+(\d+)\s+(\w+)|retry\s+after\s+(\d+)\s+(\w+)/g,y=t(`^decide\\s+([A-Za-z_]\\w*)\\s+when\\s+(.+)$`),b=t(`^wait\\s+([A-Za-z_]\\w*)\\s+for\\s+(?:(\\d+)\\s+${l}|([A-Za-z_][\\w.]*)(?:\\s+expires\\s+after\\s+(\\d+)\\s+${l})?)$`),x=t(`^approval\\s+([A-Za-z_]\\w*)\\s+by\\s+([A-Za-z_]\\w*)(?:\\s+expires\\s+after\\s+(\\d+)\\s+${l})?$`),S=t(`^foreach\\s+([A-Za-z_]\\w*)\\s+over\\s+([A-Za-z_][\\w.]*)(?:\\s+parallel\\s+(\\d+))?$`),C=t(`^join\\s+([A-Za-z_]\\w*)\\s+(all|any|at\\s+least\\s+(\\d+))$`),empty=(e,t,n,r)=>({kind:`WorkflowNodeSyntax`,nodeKind:e,name:t,edges:[],location:n,triggerKind:null,event:null,stateMachine:null,state:null,schedule:null,command:null,attempts:null,timeout:null,retryAfter:null,condition:null,duration:null,expiresAfter:null,by:null,items:null,parallel:null,joinMode:null,joinCount:null,...r});function parseWorkflow(t,a){let c=u.exec(a.content);if(c===null)return t.error(e.InvalidWorkflowDeclaration,`Invalid workflow declaration '${a.content}' - expected 'workflow <Name>'.`,n(a)),t.skipBlock(a.indent),{kind:`WorkflowSyntax`,name:r(a.content),subject:``,description:null,nodes:[],specifications:[],location:n(a)};let l=c[1],f=null,p=null,m=[],h=[],g={},_=0;for(let c=t.peekChild(a.indent);c!==void 0;c=t.peekChild(a.indent)){t.reader.takeSignificant();let a=r(c.content);if(a===`description`)f=i(t,c,f,`Workflow '${l}'`),g.description??=n(c);else if(a===`specification`)h.push(s(t,c,e.InvalidWorkflowDeclaration));else if(a===`for`){let r=d.exec(c.content);r===null?t.error(e.InvalidWorkflowDeclaration,`Invalid subject '${c.content}' - expected 'for <ReadModel>'.`,n(c)):p===null?(p=r[1],g.for=n(c)):t.error(e.InvalidWorkflowDeclaration,`Workflow '${l}' declares its subject more than once.`,n(c)),o(t,c,e.InvalidWorkflowDeclaration,`A for line cannot have children.`)}else{let e=parseNode(t,c,l,a===`trigger`?++_:_);e!==void 0&&m.push(e)}}p===null&&t.error(e.InvalidWorkflowDeclaration,`Workflow '${l}' must name its subject: 'for <ReadModel>'.`,n(a));let v=/* @__PURE__ */ new Set;for(let n of m)v.has(n.name)&&t.error(e.InvalidWorkflowDeclaration,`Workflow '${l}' declares node '${n.name}' more than once.`,n.location),v.add(n.name);return{kind:`WorkflowSyntax`,name:l,subject:p??``,description:f,nodes:m,specifications:h,location:n(a),directiveLocations:g}}function parseNode(t,i,a,o){let s=r(i.content),c;switch(s){case`trigger`:c=parseTrigger(t,i,o);break;case`action`:c=parseAction(t,i);break;case`decide`:c=parseDecide(t,i);break;case`wait`:c=parseWait(t,i);break;case`approval`:c=parseApproval(t,i);break;case`foreach`:c=parseForEach(t,i);break;case`join`:c=parseJoin(t,i);break;default:t.error(e.InvalidWorkflowDeclaration,`Unexpected '${i.content}' in workflow '${a}' - expected for, description, specification or a node: trigger, action, decide, wait, approval, foreach or join.`,n(i))}if(c===void 0)t.skipBlock(i.indent);else return{...c,edges:parseEdges(t,i)}}function parseEdges(t,r){let i=[];for(let a=t.peekChild(r.indent);a!==void 0;a=t.peekChild(r.indent)){t.reader.takeSignificant();let r=f.exec(a.content),s=p.exec(a.content);if(r!==null)i.push({kind:`WorkflowEdgeSyntax`,outlet:`next`,target:r[1],location:n(a)});else if(s!==null)i.push({kind:`WorkflowEdgeSyntax`,outlet:s[1]??s[2],target:s[3]??``,location:n(a)});else{t.error(e.InvalidWorkflowDeclaration,`Invalid edge '${a.content}' - expected '<outlet> -> <Node>'.`,n(a)),t.skipBlock(a.indent);continue}o(t,a,e.InvalidWorkflowDeclaration,`An edge cannot have children.`)}return i}function parseTrigger(t,r,i){let a=m.exec(r.content);if(a===null){t.error(e.InvalidWorkflowDeclaration,`Invalid trigger '${r.content}' - expected 'trigger [<Name>] on <Event>', 'when <StateMachine> enters <State>', 'every <n> <unit>', 'at <HH:mm>' or 'manual'.`,n(r));return}let o=a[1]??(i===1?`Trigger`:`Trigger${i}`),s=a[2],l=n(r);if(s===`manual`)return empty(`Trigger`,o,l,{triggerKind:`Manual`});let u=h.exec(s);if(u!==null)return empty(`Trigger`,o,l,{triggerKind:`Event`,event:u[1]});let d=g.exec(s);if(d!==null)return empty(`Trigger`,o,l,{triggerKind:`StateEntered`,stateMachine:d[1],state:d[2]});if(s.startsWith(`every `)||s.startsWith(`at `)){let e=c(t,{...r,content:s});return e===void 0?void 0:empty(`Trigger`,o,l,{triggerKind:`Schedule`,schedule:e})}t.error(e.InvalidWorkflowDeclaration,`Invalid trigger '${r.content}' - expected 'on <Event>', 'when <StateMachine> enters <State>', 'every <n> <unit>', 'at <HH:mm>' or 'manual'.`,n(r))}function parseAction(t,r){let i=_.exec(r.content);if(i===null){t.error(e.InvalidWorkflowDeclaration,`Invalid action '${r.content}' - expected 'action <Name> sends <Command> [attempts <n>] [timeout <n> <unit>] [retry after <n> <unit>]'.`,n(r));return}let a=null,o=null,s=null;for(let c of i[3].matchAll(v))if(c[1]!==void 0){let i=Number(c[1]);a!==null||!Number.isInteger(i)||i<1?t.error(e.InvalidWorkflowDeclaration,`Invalid or repeated attempts in '${r.content}'.`,n(r)):a=i}else if(c[2]!==void 0){let i=duration(t,c[2],c[3],r);o!==null||i===void 0?t.error(e.InvalidWorkflowDeclaration,`Invalid or repeated timeout in '${r.content}'.`,n(r)):o=i}else{let i=duration(t,c[4],c[5],r);s!==null||i===void 0?t.error(e.InvalidWorkflowDeclaration,`Invalid or repeated retry in '${r.content}'.`,n(r)):s=i}return empty(`Action`,i[1],n(r),{command:i[2],attempts:a,timeout:o,retryAfter:s})}function parseDecide(t,r){let i=y.exec(r.content);if(i===null){t.error(e.InvalidWorkflowDeclaration,`Invalid decide '${r.content}' - expected 'decide <Name> when <condition>'.`,n(r));return}let o=a(t,i[2],n(r));return o===null?void 0:empty(`Decide`,i[1],n(r),{condition:o})}function parseWait(t,r){let i=b.exec(r.content);if(i===null){t.error(e.InvalidWorkflowDeclaration,`Invalid wait '${r.content}' - expected 'wait <Name> for <Event> [expires after <n> <unit>]' or 'wait <Name> for <n> <unit>'.`,n(r));return}if(i[2]!==void 0){let e=duration(t,i[2],i[3],r);return e===void 0?void 0:empty(`Wait`,i[1],n(r),{duration:e})}let a=null;if(i[5]!==void 0){let e=duration(t,i[5],i[6],r);if(e===void 0)return;a=e}return empty(`Wait`,i[1],n(r),{event:i[4],expiresAfter:a})}function parseApproval(t,r){let i=x.exec(r.content);if(i===null){t.error(e.InvalidWorkflowDeclaration,`Invalid approval '${r.content}' - expected 'approval <Name> by <Persona or Policy> [expires after <n> <unit>]'.`,n(r));return}let a=null;if(i[3]!==void 0){let e=duration(t,i[3],i[4],r);if(e===void 0)return;a=e}return empty(`Approval`,i[1],n(r),{by:i[2],expiresAfter:a})}function parseForEach(t,r){let i=S.exec(r.content);if(i===null||i[3]!==void 0&&Number(i[3])<1)t.error(e.InvalidWorkflowDeclaration,`Invalid foreach '${r.content}' - expected 'foreach <Name> over <property> [parallel <n>]'.`,n(r));else return empty(`ForEach`,i[1],n(r),{items:i[2],parallel:i[3]===void 0?null:Number(i[3])})}function parseJoin(t,r){let i=C.exec(r.content);if(i===null||i[3]!==void 0&&Number(i[3])<1)t.error(e.InvalidWorkflowDeclaration,`Invalid join '${r.content}' - expected 'join <Name> all', 'join <Name> any' or 'join <Name> at least <n>'.`,n(r));else return empty(`Join`,i[1],n(r),{joinMode:i[2]===`all`?`All`:i[2]===`any`?`Any`:`AtLeast`,joinCount:i[3]===void 0?null:Number(i[3])})}function duration(t,r,i,a){let o=Number(r);if(!Number.isInteger(o)||o<1){t.error(e.InvalidWorkflowDeclaration,`Invalid duration '${r} ${i}' in '${a.content}' - an amount is at least 1.`,n(a));return}let s=i.replace(/s$/,``);return{kind:`WorkflowDurationSyntax`,amount:o,unit:s===`second`?`Seconds`:s===`minute`?`Minutes`:s===`hour`?`Hours`:`Days`,location:n(a)}}export{parseWorkflow};
|
|
2
|
+
//# sourceMappingURL=WorkflowParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkflowParser.js","names":["unit","headerPattern","pattern","forPattern","shorthandEdge","edgePattern","triggerPattern","onEventPattern","entersPattern","actionPattern","actionOption","decidePattern","waitPattern","approvalPattern","forEachPattern","joinPattern","parts","match","header","context","DiagnosticCodes","locationOf","firstWord","name","description","subject","nodes","specifications","directiveLocations","triggers","line","keyword","parseDescription","parseLifecycleSpecification","found","rejectOperationChildren","node","seen","ordinal","workflow","edges","shorthand","edge","rest","location","onEvent","enters","schedule","parseTriggerSource","attempts","timeout","retryAfter","option","count","parsed","condition","parseCondition","expiresAfter","amount","text","base"],"sources":["../../../../../../Compiler/Parsing/WorkflowParser.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { IntervalUnit } from '../Syntax/Reactions';\nimport { LifecycleSpecificationSyntax, WorkflowDurationSyntax, WorkflowEdgeSyntax, WorkflowNodeKind, WorkflowNodeSyntax, WorkflowSyntax } from '../Syntax/Lifecycles';\nimport { pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord } from './LineText';\nimport { rejectOperationChildren } from './OperationParser';\nimport { ParserContext } from './ParserContext';\nimport { parseTriggerSource } from './ReactionParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseLifecycleSpecification } from './SpecificationParser';\n\nconst unit = '(seconds?|minutes?|hours?|days?)';\nconst headerPattern = pattern('^workflow\\\\s+([A-Za-z_]\\\\w*)$');\nconst forPattern = pattern('^for\\\\s+([A-Za-z_]\\\\w*)$');\nconst shorthandEdge = pattern('^->\\\\s*([A-Za-z_]\\\\w*)$');\nconst edgePattern = pattern('^(?:\"([^\"]+)\"|([A-Za-z_]\\\\w*))(?:\\\\s*->\\\\s*([A-Za-z_]\\\\w*))?$');\nconst triggerPattern = pattern('^trigger(?:\\\\s+(?!(?:on|when|every|at|manual)\\\\b)([A-Za-z_]\\\\w*))?\\\\s+(.+)$');\nconst onEventPattern = pattern('^on\\\\s+([A-Za-z_][\\\\w.]*)$');\nconst entersPattern = pattern('^when\\\\s+([A-Za-z_]\\\\w*)\\\\s+enters\\\\s+([A-Za-z_]\\\\w*)$');\nconst actionPattern = pattern('^action\\\\s+([A-Za-z_]\\\\w*)\\\\s+sends\\\\s+([A-Za-z_]\\\\w*)((?:\\\\s+(?:attempts\\\\s+\\\\d+|timeout\\\\s+\\\\d+\\\\s+\\\\w+|retry\\\\s+after\\\\s+\\\\d+\\\\s+\\\\w+))*)$');\nconst actionOption = /attempts\\s+(\\d+)|timeout\\s+(\\d+)\\s+(\\w+)|retry\\s+after\\s+(\\d+)\\s+(\\w+)/g;\nconst decidePattern = pattern('^decide\\\\s+([A-Za-z_]\\\\w*)\\\\s+when\\\\s+(.+)$');\nconst waitPattern = pattern(`^wait\\\\s+([A-Za-z_]\\\\w*)\\\\s+for\\\\s+(?:(\\\\d+)\\\\s+${unit}|([A-Za-z_][\\\\w.]*)(?:\\\\s+expires\\\\s+after\\\\s+(\\\\d+)\\\\s+${unit})?)$`);\nconst approvalPattern = pattern(`^approval\\\\s+([A-Za-z_]\\\\w*)\\\\s+by\\\\s+([A-Za-z_]\\\\w*)(?:\\\\s+expires\\\\s+after\\\\s+(\\\\d+)\\\\s+${unit})?$`);\nconst forEachPattern = pattern('^foreach\\\\s+([A-Za-z_]\\\\w*)\\\\s+over\\\\s+([A-Za-z_][\\\\w.]*)(?:\\\\s+parallel\\\\s+(\\\\d+))?$');\nconst joinPattern = pattern('^join\\\\s+([A-Za-z_]\\\\w*)\\\\s+(all|any|at\\\\s+least\\\\s+(\\\\d+))$');\n\ntype NodeParts = Partial<Omit<WorkflowNodeSyntax, 'kind' | 'nodeKind' | 'name' | 'edges' | 'location'>>;\n\nconst empty = (nodeKind: WorkflowNodeKind, name: string, location: SourceLocation, parts: NodeParts): WorkflowNodeSyntax => ({\n kind: 'WorkflowNodeSyntax', nodeKind, name, edges: [], location,\n triggerKind: null, event: null, stateMachine: null, state: null, schedule: null, command: null, attempts: null, timeout: null, retryAfter: null,\n condition: null, duration: null, expiresAfter: null, by: null, items: null, parallel: null, joinMode: null, joinCount: null,\n ...parts,\n});\n\n// The port of C# WorkflowParser.\nexport function parseWorkflow(context: ParserContext, header: SourceLine): WorkflowSyntax {\n const match = headerPattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid workflow declaration '${header.content}' - expected 'workflow <Name>'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'WorkflowSyntax', name: firstWord(header.content), subject: '', description: null, nodes: [], specifications: [], location: locationOf(header) };\n }\n const name = match[1];\n let description: string | null = null;\n let subject: string | null = null;\n const nodes: WorkflowNodeSyntax[] = [];\n const specifications: LifecycleSpecificationSyntax[] = [];\n const directiveLocations: Record<string, SourceLocation> = {};\n let triggers = 0;\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n if (keyword === 'description') {\n description = parseDescription(context, line, description, `Workflow '${name}'`);\n directiveLocations.description ??= locationOf(line);\n } else if (keyword === 'specification') {\n specifications.push(parseLifecycleSpecification(context, line, DiagnosticCodes.InvalidWorkflowDeclaration));\n } else if (keyword === 'for') {\n const found = forPattern.exec(line.content);\n if (found === null) context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid subject '${line.content}' - expected 'for <ReadModel>'.`, locationOf(line));\n else if (subject !== null) context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Workflow '${name}' declares its subject more than once.`, locationOf(line));\n else {\n subject = found[1];\n directiveLocations.for = locationOf(line);\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidWorkflowDeclaration, 'A for line cannot have children.');\n } else {\n const node = parseNode(context, line, name, keyword === 'trigger' ? ++triggers : triggers);\n if (node !== undefined) nodes.push(node);\n }\n }\n if (subject === null) context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Workflow '${name}' must name its subject: 'for <ReadModel>'.`, locationOf(header));\n const seen = new Set<string>();\n for (const node of nodes) {\n if (seen.has(node.name)) context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Workflow '${name}' declares node '${node.name}' more than once.`, node.location);\n seen.add(node.name);\n }\n return { kind: 'WorkflowSyntax', name, subject: subject ?? '', description, nodes, specifications, location: locationOf(header), directiveLocations };\n}\n\nfunction parseNode(context: ParserContext, line: SourceLine, workflow: string, ordinal: number): WorkflowNodeSyntax | undefined {\n const keyword = firstWord(line.content);\n let node: WorkflowNodeSyntax | undefined;\n switch (keyword) {\n case 'trigger': node = parseTrigger(context, line, ordinal); break;\n case 'action': node = parseAction(context, line); break;\n case 'decide': node = parseDecide(context, line); break;\n case 'wait': node = parseWait(context, line); break;\n case 'approval': node = parseApproval(context, line); break;\n case 'foreach': node = parseForEach(context, line); break;\n case 'join': node = parseJoin(context, line); break;\n default:\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Unexpected '${line.content}' in workflow '${workflow}' - expected for, description, specification or a node: trigger, action, decide, wait, approval, foreach or join.`, locationOf(line));\n }\n if (node === undefined) {\n context.skipBlock(line.indent);\n return undefined;\n }\n return { ...node, edges: parseEdges(context, line) };\n}\n\nfunction parseEdges(context: ParserContext, header: SourceLine): WorkflowEdgeSyntax[] {\n const edges: WorkflowEdgeSyntax[] = [];\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const shorthand = shorthandEdge.exec(line.content);\n const edge = edgePattern.exec(line.content);\n if (shorthand !== null) edges.push({ kind: 'WorkflowEdgeSyntax', outlet: 'next', target: shorthand[1], location: locationOf(line) });\n else if (edge !== null) edges.push({ kind: 'WorkflowEdgeSyntax', outlet: edge[1] ?? edge[2], target: edge[3] ?? '', location: locationOf(line) });\n else {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid edge '${line.content}' - expected '<outlet> -> <Node>'.`, locationOf(line));\n context.skipBlock(line.indent);\n continue;\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidWorkflowDeclaration, 'An edge cannot have children.');\n }\n return edges;\n}\n\nfunction parseTrigger(context: ParserContext, line: SourceLine, ordinal: number): WorkflowNodeSyntax | undefined {\n const match = triggerPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid trigger '${line.content}' - expected 'trigger [<Name>] on <Event>', 'when <StateMachine> enters <State>', 'every <n> <unit>', 'at <HH:mm>' or 'manual'.`, locationOf(line));\n return undefined;\n }\n const name = match[1] ?? (ordinal === 1 ? 'Trigger' : `Trigger${ordinal}`);\n const rest = match[2];\n const location = locationOf(line);\n if (rest === 'manual') return empty('Trigger', name, location, { triggerKind: 'Manual' });\n const onEvent = onEventPattern.exec(rest);\n if (onEvent !== null) return empty('Trigger', name, location, { triggerKind: 'Event', event: onEvent[1] });\n const enters = entersPattern.exec(rest);\n if (enters !== null) return empty('Trigger', name, location, { triggerKind: 'StateEntered', stateMachine: enters[1], state: enters[2] });\n const scheduled = rest.startsWith('every ') || rest.startsWith('at ');\n if (scheduled) {\n const schedule = parseTriggerSource(context, { ...line, content: rest });\n return schedule === undefined ? undefined : empty('Trigger', name, location, { triggerKind: 'Schedule', schedule });\n }\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid trigger '${line.content}' - expected 'on <Event>', 'when <StateMachine> enters <State>', 'every <n> <unit>', 'at <HH:mm>' or 'manual'.`, locationOf(line));\n return undefined;\n}\n\nfunction parseAction(context: ParserContext, line: SourceLine): WorkflowNodeSyntax | undefined {\n const match = actionPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid action '${line.content}' - expected 'action <Name> sends <Command> [attempts <n>] [timeout <n> <unit>] [retry after <n> <unit>]'.`, locationOf(line));\n return undefined;\n }\n let attempts: number | null = null;\n let timeout: WorkflowDurationSyntax | null = null;\n let retryAfter: WorkflowDurationSyntax | null = null;\n for (const option of match[3].matchAll(actionOption)) {\n if (option[1] !== undefined) {\n const count = Number(option[1]);\n if (attempts !== null || !Number.isInteger(count) || count < 1) context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid or repeated attempts in '${line.content}'.`, locationOf(line));\n else attempts = count;\n } else if (option[2] !== undefined) {\n const parsed = duration(context, option[2], option[3], line);\n if (timeout !== null || parsed === undefined) context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid or repeated timeout in '${line.content}'.`, locationOf(line));\n else timeout = parsed;\n } else {\n const parsed = duration(context, option[4], option[5], line);\n if (retryAfter !== null || parsed === undefined) context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid or repeated retry in '${line.content}'.`, locationOf(line));\n else retryAfter = parsed;\n }\n }\n return empty('Action', match[1], locationOf(line), { command: match[2], attempts, timeout, retryAfter });\n}\n\nfunction parseDecide(context: ParserContext, line: SourceLine): WorkflowNodeSyntax | undefined {\n const match = decidePattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid decide '${line.content}' - expected 'decide <Name> when <condition>'.`, locationOf(line));\n return undefined;\n }\n const condition = parseCondition(context, match[2], locationOf(line));\n return condition === null ? undefined : empty('Decide', match[1], locationOf(line), { condition });\n}\n\nfunction parseWait(context: ParserContext, line: SourceLine): WorkflowNodeSyntax | undefined {\n const match = waitPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid wait '${line.content}' - expected 'wait <Name> for <Event> [expires after <n> <unit>]' or 'wait <Name> for <n> <unit>'.`, locationOf(line));\n return undefined;\n }\n if (match[2] !== undefined) {\n const parsed = duration(context, match[2], match[3], line);\n return parsed === undefined ? undefined : empty('Wait', match[1], locationOf(line), { duration: parsed });\n }\n let expiresAfter: WorkflowDurationSyntax | null = null;\n if (match[5] !== undefined) {\n const parsed = duration(context, match[5], match[6], line);\n if (parsed === undefined) return undefined;\n expiresAfter = parsed;\n }\n return empty('Wait', match[1], locationOf(line), { event: match[4], expiresAfter });\n}\n\nfunction parseApproval(context: ParserContext, line: SourceLine): WorkflowNodeSyntax | undefined {\n const match = approvalPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid approval '${line.content}' - expected 'approval <Name> by <Persona or Policy> [expires after <n> <unit>]'.`, locationOf(line));\n return undefined;\n }\n let expiresAfter: WorkflowDurationSyntax | null = null;\n if (match[3] !== undefined) {\n const parsed = duration(context, match[3], match[4], line);\n if (parsed === undefined) return undefined;\n expiresAfter = parsed;\n }\n return empty('Approval', match[1], locationOf(line), { by: match[2], expiresAfter });\n}\n\nfunction parseForEach(context: ParserContext, line: SourceLine): WorkflowNodeSyntax | undefined {\n const match = forEachPattern.exec(line.content);\n if (match === null || (match[3] !== undefined && Number(match[3]) < 1)) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid foreach '${line.content}' - expected 'foreach <Name> over <property> [parallel <n>]'.`, locationOf(line));\n return undefined;\n }\n return empty('ForEach', match[1], locationOf(line), { items: match[2], parallel: match[3] === undefined ? null : Number(match[3]) });\n}\n\nfunction parseJoin(context: ParserContext, line: SourceLine): WorkflowNodeSyntax | undefined {\n const match = joinPattern.exec(line.content);\n if (match === null || (match[3] !== undefined && Number(match[3]) < 1)) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid join '${line.content}' - expected 'join <Name> all', 'join <Name> any' or 'join <Name> at least <n>'.`, locationOf(line));\n return undefined;\n }\n return empty('Join', match[1], locationOf(line), { joinMode: match[2] === 'all' ? 'All' : match[2] === 'any' ? 'Any' : 'AtLeast', joinCount: match[3] === undefined ? null : Number(match[3]) });\n}\n\nfunction duration(context: ParserContext, amount: string, text: string, line: SourceLine): WorkflowDurationSyntax | undefined {\n const count = Number(amount);\n if (!Number.isInteger(count) || count < 1) {\n context.error(DiagnosticCodes.InvalidWorkflowDeclaration, `Invalid duration '${amount} ${text}' in '${line.content}' - an amount is at least 1.`, locationOf(line));\n return undefined;\n }\n const base = text.replace(/s$/, '');\n const parsed: IntervalUnit = base === 'second' ? 'Seconds' : base === 'minute' ? 'Minutes' : base === 'hour' ? 'Hours' : 'Days';\n return { kind: 'WorkflowDurationSyntax', amount: count, unit: parsed, location: locationOf(line) };\n}\n"],"mappings":"6iBAiBA,MAAMA,EAAO,mCACPC,EAAgBC,EAAQ,+BAA+B,EACvDC,EAAaD,EAAQ,0BAA0B,EAC/CE,EAAgBF,EAAQ,yBAAyB,EACjDG,EAAcH,EAAQ,+DAA+D,EACrFI,EAAiBJ,EAAQ,6EAA6E,EACtGK,EAAiBL,EAAQ,4BAA4B,EACrDM,EAAgBN,EAAQ,wDAAwD,EAChFO,EAAgBP,EAAQ,+IAA+I,EACvKQ,EAAe,0EACfC,EAAgBT,EAAQ,6CAA6C,EACrEU,E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