@cratis/screenplay-language 4.192.0 → 4.194.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/bundles/command-read-completions.js +5 -0
  2. package/dist/bundles/command-read-completions.js.map +1 -0
  3. package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js +2 -0
  4. package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js.map +1 -0
  5. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  6. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  7. package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
  8. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
  9. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  10. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
  11. package/dist/bundles/compiler/Parsing/ParserContext.js +1 -1
  12. package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -1
  13. package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
  14. package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
  15. package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
  16. package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
  17. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +1 -1
  18. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -1
  19. package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
  20. package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
  21. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  22. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  23. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
  24. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
  25. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
  26. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
  27. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +1 -1
  28. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -1
  29. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
  30. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
  31. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  32. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
  33. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
  34. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
  35. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +1 -1
  36. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -1
  37. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
  38. package/dist/bundles/compiler/Syntax/SyntaxCollections.js +1 -1
  39. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  40. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  41. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  42. package/dist/bundles/compiler/index.js +1 -1
  43. package/dist/bundles/completion-items.js +1 -1
  44. package/dist/bundles/completion-items.js.map +1 -1
  45. package/dist/bundles/completion-planner.js +2 -2
  46. package/dist/bundles/completion-planner.js.map +1 -1
  47. package/dist/bundles/diagnostic-codes.js +1 -1
  48. package/dist/bundles/diagnostic-codes.js.map +1 -1
  49. package/dist/bundles/keyword-docs.js +1 -1
  50. package/dist/bundles/keyword-docs.js.map +1 -1
  51. package/dist/bundles/language.js +1 -1
  52. package/dist/bundles/language.js.map +1 -1
  53. package/dist/bundles/response-analysis.js +2 -2
  54. package/dist/bundles/response-analysis.js.map +1 -1
  55. package/dist/bundles/tokens.js +1 -1
  56. package/dist/bundles/tokens.js.map +1 -1
  57. package/dist/bundles/validation.js +1 -1
  58. package/dist/bundles/validation.js.map +1 -1
  59. package/dist/command-read-completions.d.ts +4 -0
  60. package/dist/command-read-completions.d.ts.map +1 -0
  61. package/dist/completion-items.d.ts.map +1 -1
  62. package/dist/completion-planner.d.ts.map +1 -1
  63. package/dist/diagnostic-codes.d.ts +1 -0
  64. package/dist/diagnostic-codes.d.ts.map +1 -1
  65. package/dist/keyword-docs.d.ts.map +1 -1
  66. package/dist/language.d.ts.map +1 -1
  67. package/dist/tokens.d.ts.map +1 -1
  68. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{dotNetWhitespace as r,nativePattern as i,pattern as a}from"../Text/patterns.js";import{locationOf as o}from"./SourceLine.js";import{firstWord as s}from"./LineText.js";import{generatedFixturePattern as c,generatedFixturePrefix as l,parseConcreteMapping as u,parseReturn as d,thenReturnsPrefix as f}from"./SpecificationResponseParser.js";import{containsCaseReference as p,parseCase as m,parseParameter as h,parseSpecificationValue as g,validateTable as ee}from"./SpecificationCaseParser.js";import{parseDescription as te}from"./DescriptionParser.js";import{sourceStreamPattern as _}from"../Text/SourceStreamNames.js";import{parseRouteParts as v}from"./EventSourceParser.js";import{isFileDirective as y}from"./FileReferences.js";import{rejectOperationChildren as ne}from"./OperationParser.js";import{addFixtureValue as b,addInlineValue as x}from"./SpecificationExampleParser.js";const S=a(`^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)`),C=a(`^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$`),w=a(`^specification\\s+([A-Za-z_]\\w*)$`),T=a(`^given caller as ([A-Za-z_]\\w*)$`),stepPattern=(e,t=``)=>i(`^${e}\\s+([A-Z]\\w*(?:\\.\\w+)*)${t}(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?$`.replaceAll(`\\s`,r)),E=stepPattern(`given`),D=stepPattern(`when\\s+append`),O=stepPattern(`when`),k=stepPattern(`then`),A=a(`^then\\s+query\\b`),j=a(`^(?:given|then)\\s+readmodel\\b`),M=stepPattern(`given\\s+readmodel`),N=stepPattern(`then\\s+readmodel`,`(?<exactly>\\s+exactly)?`),P=a(`^then\\s+no\\b`),F=a(`^then\\s+error\\s+"(${t})"$`),I=a(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),L=i(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),re=a(`^given\\s+clock\\b`),R=a(`^given\\s+capture\\b`),z=a(`^when\\s+clock\\b`),B=a(`^when\\s+trigger\\b`),V=a(`^when\\s+capture\\b`),H=a(`^when\\s+query\\b`),U=a(`^then\\s+result\\b`),W=a(`^then\\s+no\\s+result\\b`),G=i(`^when\\s+redelivered\\b`),K=i(`^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),q=a(`^then\\s+no\\s+events\\b`),J=a(`^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$`),Y=a(`^when\\s+trigger\\s+([A-Za-z_]\\w*)$`),X=a(`^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$`),ie=a(`^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),ae=a(`^then\\s+result(\\s+exactly)?$`),Z=i(`^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$`),oe=i(`^(?:"${t}"|'(?:[^'\\\\]|\\\\.)*')$`),se=i(`^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$`);function parseSpecification(t,n){let r=w.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidSpecificationDeclaration,`Invalid specification declaration '${n.content}' - expected 'specification <Name>'`,o(n));let i=null,a=[],c=[],l={givenOperationFailures:[],thenOperations:[],thenCompensated:[],thenAbsentReadModels:[],thenQueries:[],given:[],givenReadModels:[],when:null,whenAppended:null,whenRedelivered:null,whenDeclared:!1,thenEvents:[],thenEventsInAnyOrder:!1,thenNoEvents:!1,thenReadModels:[],thenErrors:[],givenClock:null,givenCaptures:[],whenClock:null,whenTrigger:null,whenCapture:null,whenQuery:null,thenResults:[],thenNoResult:null,thenDenied:null,givenCaller:null,thenReturns:null};for(let u=t.peekChild(n.indent);u!==void 0;u=t.peekChild(n.indent)){if(t.reader.takeSignificant(),y(u)||parseOperationStep(t,u,l))continue;let n=P.test(u.content)?`then`:s(u.content);if(n===`parameter`){let e=h(t,u);e!==null&&a.push(e)}else if(n===`case`){let e=m(t,u);e!==null&&c.push(e)}else n===`description`?i=te(t,u,i,`Specification '${r}'`):n===`given`?parseGiven(t,u,l):n===`when`?parseWhen(t,u,l,r):n===`then`?parseThen(t,u,l):(t.error(e.UnknownSpecificationDirective,`Unexpected '${s(u.content)}' in specification body`,o(u)),t.skipBlock(u.indent))}l.noEventsLine!==void 0&&(l.thenEvents.length>0||l.thenEventsInAnyOrder||l.thenErrors.length>0||l.thenDenied!==null)&&t.error(e.InvalidNoEventsExpectation,`'then no events' cannot accompany event, event-order, error or denial expectations.`,o(l.noEventsLine)),validateQueryRejection(t,n,l);let{whenDeclared:u,noEventsLine:d,...f}=l,p={kind:`SpecificationSyntax`,sourceOptions:t.sourceOptions,name:r,description:i,...f,...a.length===0?{}:{parameters:a},...c.length===0?{}:{cases:c},location:o(n)};return ee(p,t),p}function validateQueryRejection(t,n,r){isQueryRejectionCandidate(r)&&!isWellFormedQueryRejection(r)&&t.error(e.MismatchedSpecificationQueryResult,`A query rejection requires exactly one query and one 'then error', no action, and no other outcomes`,o(n))}function isQueryRejectionCandidate(e){return e.thenErrors.length>0&&queriedCallCount(e)>0&&(e.whenQuery!==null||!hasAction(e))}function isWellFormedQueryRejection(e){return!hasAction(e)&&hasOneQueryAndOneError(e)&&!hasOtherOutcome(e)}function hasOneQueryAndOneError(e){return queriedCallCount(e)===1&&e.thenErrors.length===1}function hasAction(e){return[e.when,e.whenAppended,e.whenClock,e.whenTrigger,e.whenCapture,e.whenRedelivered].some(e=>e!==null)}function queriedCallCount(e){return e.thenQueries.length+(e.whenQuery===null?0:1)}function hasOtherOutcome(e){return[e.thenResults.length>0,e.thenNoResult!==null,e.thenDenied!==null,e.thenEvents.length>0,e.thenNoEvents,e.thenEventsInAnyOrder,e.thenReadModels.length>0,e.thenAbsentReadModels.length>0,e.thenReturns!==null,e.thenQueries.some(e=>e.results.length>0)].some(e=>e)}function parseOperationStep(t,n,r){if(!S.test(n.content))return!1;let i=C.exec(n.content);if(i===null||i[1]===`given operation`!=(i[3]!==void 0))t.error(e.InvalidOperationSpecification,`Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.`,o(n)),skipBody(t,n.indent);else if(i[1]===`then operation`){let a=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=u(t,r,I,e.InvalidOperationSpecification);n!==null&&a.push(n)}r.thenOperations.push({kind:`SpecificationOperationSyntax`,operation:i[2],values:a,location:o(n)})}else ne(t,n,e.InvalidOperationSpecification,`Failure and compensation assertions cannot have children.`),i[1]===`given operation`?r.givenOperationFailures.push({kind:`SpecificationOperationFailureSyntax`,operation:i[2],location:o(n)}):r.thenCompensated.push({kind:`SpecificationCompensatedSyntax`,operation:i[2],location:o(n)});return!0}function parseGiven(t,n,r){if(re.test(n.content))r.givenClock===null?r.givenClock=parseClock(t,n,`given`):(t.error(e.InvalidSpecificationClock,`A specification states its clock at most once.`,o(n)),skipBody(t,n.indent));else if(R.test(n.content)){let e=parseCapture(t,n,`given`);e!==null&&r.givenCaptures.push(e)}else if(n.content.startsWith(`given caller`)){if(r.givenCaller!==null||r.givenCallerPersona!==void 0)t.error(e.DuplicateSpecificationCallerOrDenied,`A specification has at most one 'given caller' block.`,o(n)),t.skipBlock(n.indent);else if(n.content.startsWith(`given caller as`)){let i=T.exec(n.content);i===null&&t.error(e.InvalidSpecificationCallerPersona,`Expected 'given caller as <Persona>'.`,o(n));let a=t.peekChild(n.indent);a!==void 0&&t.error(e.InvalidSpecificationCallerPersona,`'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.`,o(a)),skipBody(t,n.indent),i!==null&&(r.givenCallerPersona={kind:`SpecificationCallerPersonaSyntax`,name:i[1],location:o(n)})}else r.givenCaller=parseCaller(t,n)}else if(j.test(n.content)){let e=parseReadModelStep(t,n,M,`given`);e!==void 0&&r.givenReadModels.push(e)}else{let e=parseEventStep(t,n,E,`given`);e!==void 0&&r.given.push(e)}}const Q=a(`^role${r}+"(${t})"$`),ce=a(`^claim${r}+"(${t})"${r}*=${r}*"(${t})"$`);function parseCaller(t,r){if(r.content!==`given caller`)return t.error(e.InvalidSpecificationCaller,`Expected exactly 'given caller'.`,o(r)),t.skipBlock(r.indent),null;let i=!1,a=[],s=[];for(let c=t.peekChild(r.indent);c!==void 0;c=t.peekChild(r.indent)){t.reader.takeSignificant();let r=Q.exec(c.content),l=ce.exec(c.content);c.content===`authenticated`&&!i?i=!0:r===null?l===null?t.error(p(c.content)?e.InvalidSpecificationCaseReference:e.InvalidSpecificationCaller,`Invalid caller fixture '${c.content}' - expected authenticated, role "...", or claim "..." = "...".`,o(c)):s.push({kind:`SpecificationCallerClaimSyntax`,type:n(l[1]),value:n(l[2]),location:o(c)}):a.push(n(r[1]))}return{kind:`SpecificationCallerSyntax`,authenticated:i,roles:a,claims:s,location:o(r)}}function parseWhen(t,n,r,i){let a=n.content.startsWith(`when append`);if(r.whenDeclared){let s=r.whenAppended!==null||a?e.ConflictingSpecificationActions:e.DuplicateSpecificationWhen;t.error(s,`Specification '${i}' already declares a 'when' - a specification can have at most one`,o(n)),skipBody(t,n.indent);return}if(r.whenDeclared=!0,a){r.whenAppended=parseEventStep(t,n,D,`when append`)??null;return}if(G.test(n.content)){let i=K.exec(n.content);i===null?(t.error(e.UnmatchedRedeliveredOccurrence,`Expected 'when redelivered <Event> to <Reaction>'.`,o(n)),skipBody(t,n.indent)):r.whenRedelivered={kind:`SpecificationRedeliverySyntax`,eventType:i[1],reaction:i[2],...parseValuesWithEventSource(t,n,void 0,void 0,`when redelivered`),location:o(n)};return}if(z.test(n.content)){r.whenClock=parseClock(t,n,`when`);return}if(B.test(n.content)){r.whenTrigger=parseNamedStep(t,n,Y,e.InvalidSpecificationTrigger,`when trigger`,`when trigger <Trigger>`,(e,t)=>({kind:`SpecificationTriggerSyntax`,trigger:e,values:t,location:o(n)}));return}if(V.test(n.content)){r.whenCapture=parseCapture(t,n,`when`);return}if(H.test(n.content)){r.whenQuery=parseNamedStep(t,n,ie,e.InvalidSpecificationQueryAction,`when query`,`when query <Query>`,(e,t)=>({kind:`SpecificationWhenQuerySyntax`,query:e,arguments:t,location:o(n)}),!0);return}let s=O.exec(n.content);if(s===null){t.error(e.InvalidSpecificationWhen,`Invalid 'when' declaration '${n.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,o(n)),skipBody(t,n.indent);return}let c=[],l=parseValuesWithEventSource(t,n,c,s);r.when={kind:`SpecificationCommandSyntax`,commandType:s[1],...l,generatedValues:c,inlineProperty:s.groups?.property??null,location:o(n)}}function parseThen(t,r,i){if(q.test(r.content)){r.content!==`then no events`||i.thenNoEvents?t.error(e.InvalidNoEventsExpectation,`Expected one 'then no events' directive.`,o(r)):(i.thenNoEvents=!0,i.noEventsLine=r);let n=t.peekChild(r.indent);n!==void 0&&t.error(e.InvalidNoEventsExpectation,`'then no events' cannot have child mappings.`,o(n)),skipBody(t,r.indent);return}if(f.test(r.content)){let n=d(t,r);i.thenReturns===null?i.thenReturns=n:t.error(e.InvalidReturnExpectation,`A specification declares at most one return expectation.`,o(r));return}if(r.content.startsWith(`then events`)){r.content!==`then events in any order`||i.thenEventsInAnyOrder?t.error(e.InvalidSpecificationEventOrder,`Expected one 'then events in any order' directive.`,o(r)):i.thenEventsInAnyOrder=!0,skipBody(t,r.indent);return}if(U.test(r.content)){parseResult(t,r,i);return}if(W.test(r.content)){r.content!==`then no result`||i.thenNoResult!==null?t.error(e.InvalidSpecificationQueryAction,`Expected one 'then no result' directive.`,o(r)):i.thenNoResult={kind:`SpecificationNoResultSyntax`,location:o(r)},skipBody(t,r.indent);return}if(r.content.startsWith(`then denied`)){r.content===`then denied`?i.thenDenied===null?i.thenDenied={kind:`SpecificationDeniedSyntax`,location:o(r)}:t.error(e.DuplicateSpecificationCallerOrDenied,`A specification has at most one 'then denied' outcome.`,o(r)):(t.error(e.InvalidSpecificationDenied,`Expected exactly 'then denied'.`,o(r)),skipBody(t,r.indent));return}if(r.content===`then error`){i.thenErrors.push({kind:`SpecificationErrorSyntax`,name:null,location:o(r)});return}if(r.content.startsWith(`then error case.`)){let e=g(r.content.substring(11),{...o(r),column:o(r).column+11},t);e.kind===`CaseValueExpressionSyntax`&&i.thenErrors.push({kind:`SpecificationErrorSyntax`,name:null,caseValue:e,location:o(r)});return}let a=F.exec(r.content);if(a!==null){i.thenErrors.push({kind:`SpecificationErrorSyntax`,name:n(a[1]),location:o(r)});return}if(s(r.content.substring(4).trim())===`error`){t.error(e.InvalidThenError,`Invalid 'then error' declaration '${r.content}' - expected 'then error' or 'then error "<reason>"'`,o(r)),skipBody(t,r.indent);return}if(P.test(r.content)){if(t.sourceOptions.numericMode===`exact`){let e=parseAbsentReadModel(t,r);e!==null&&i.thenAbsentReadModels.push(e);return}let e=Z.exec(r.content);if(e!==null&&!e[2].endsWith(` exactly`)){let n=g(e[2].trim(),o(r),t.valueContext);(n.kind===`LiteralExpressionSyntax`||n.kind===`ObjectExpressionSyntax`||n.kind===`CaseValueExpressionSyntax`)&&i.thenAbsentReadModels.push({kind:`SpecificationAbsentReadModelSyntax`,name:e[1],key:n,location:o(r)})}t.skipOpaqueBlock(r.indent);return}if(A.test(r.content)){let n=t.sourceOptions.numericMode===`exact`,reject=(e,r,i)=>{if(!n)return t.skipOpaqueBlock(i.indent);t.error(e,r,o(i)),t.skipBlock(i.indent)},a=se.exec(r.content);if(a===null)return reject(e.InvalidSpecificationQuery,`Invalid 'then query' declaration '${r.content}' - expected 'then query <Query> [exactly]'`,r);let c=[],l=[],u=!1;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent))t.reader.takeSignificant(),n.content===`arguments`&&!u?c.push(...parseValues(t.valueContext,n,!0,void 0,t)):n.content===`arguments`?reject(e.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,n):n.content===`result`?l.push({kind:`SpecificationQueryResultSyntax`,properties:parseValues(t.valueContext,n,!0),exactly:!1,location:o(n)}):reject(e.UnknownSpecificationQueryDirective,`Unexpected '${s(n.content)}' in 'then query' body - expected arguments or result`,n),u||=n.content===`arguments`;i.thenQueries.push({kind:`SpecificationQuerySyntax`,query:a[1],arguments:c,results:l,exactly:a[2]!==void 0,location:o(r)});return}if(j.test(r.content)){let e=parseReadModelStep(t,r,N,`then`);e!==void 0&&i.thenReadModels.push(e);return}let c=parseEventStep(t,r,k,`then`);c!==void 0&&i.thenEvents.push(c)}function parseAbsentReadModel(t,n){let r=Z.exec(n.content);if(r===null||r[2].endsWith(` exactly`))return t.error(e.InvalidAbsentReadModelStep,`Invalid absence assertion '${n.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,o(n)),skipBody(t,n.indent),null;let i=r[2].trim(),a=!(i.startsWith(`"`)||i.startsWith(`'`))||oe.test(i)?g(i,o(n),t.valueContext):null,s=a!==null&&(a.kind===`LiteralExpressionSyntax`||a.kind===`ObjectExpressionSyntax`||a.kind===`CaseValueExpressionSyntax`);s||t.error(e.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,o(n));let c=!1;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(e.InvalidAbsentReadModelStep,`An absent read model assertion cannot have child mappings.`,o(r)),c=!0;return c||!s?null:{kind:`SpecificationAbsentReadModelSyntax`,name:r[1],key:a,location:o(n)}}function skipBody(e,t){if(e.sourceOptions.numericMode!==`exact`)return e.skipBlock(t);e.skipOpaqueBlock(t)}function parseClock(t,n,r){let i=J.exec(n.content);return skipBody(t,n.indent),i===null||i[1]!==r?(t.error(p(n.content)?e.InvalidSpecificationCaseReference:e.InvalidSpecificationClock,`Invalid '${r} clock' - expected '${r} clock "<ISO 8601 instant>"', such as '${r} clock "2026-10-05T08:00:00Z"'`,o(n)),null):{kind:`SpecificationClockSyntax`,instant:i[2],location:o(n)}}function parseCapture(t,n,r){return parseNamedStep(t,n,X,e.InvalidSpecificationCapture,`${r} capture`,`${r} capture <Capture>`,(e,t)=>({kind:`SpecificationCaptureSyntax`,capture:e,record:t,location:o(n)}))}function parseNamedStep(e,t,n,r,i,a,s,c=!1){let l=n.exec(t.content);return l===null?(e.error(r,`Invalid '${i}' declaration '${t.content}' - expected '${a}'`,o(t)),skipBody(e,t.indent),null):s(l[1],parseValues(e,t,!1,void 0,c?e:void 0))}function parseResult(t,n,r){let i=ae.exec(n.content);i===null?(t.error(e.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${n.content}' - expected 'then result [exactly]'`,o(n)),skipBody(t,n.indent)):r.thenResults.push({kind:`SpecificationQueryResultSyntax`,properties:parseValues(t,n),exactly:i[1]!==void 0,location:o(n)})}function parseReadModelStep(t,n,r,i){let a=r.exec(n.content);if(a===null)t.error(e.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${n.content}' - expected '${i} readmodel <ReadModelType>'`,o(n)),skipBody(t,n.indent);else return{kind:`SpecificationReadModelSyntax`,name:a[1],properties:parseValues(t,n,!1,a),exactly:i===`then`&&a.groups?.exactly!==void 0,inlineProperty:a.groups?.property??null,location:o(n)}}function parseEventStep(t,n,r,i){let a=r.exec(n.content);if(a===null)t.error(e.InvalidEventStep,`Invalid '${i}' declaration '${n.content}' - expected '${i} <EventType>'`,o(n)),skipBody(t,n.indent);else return{kind:`SpecificationEventSyntax`,eventType:a[1],...parseValuesWithEventSource(t,n,void 0,a,i),inlineProperty:a.groups?.property??null,location:o(n)}}const $=_(`^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$`),le=a(`^streamId\\s*=(?!=|>)\\s*(.+)$`);function parseValuesWithEventSource(t,n,r,i,a){let d=[];x(t,n,i,d);let f=null,p,m,h=!1;for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r!==void 0&&l.test(i.content)){let n=u(t,i,c,e.InvalidGeneratedFixture);n!==null&&r.push(n);continue}let n=I.exec(i.content);if(n!==null)b(t,d,mappingOf(t,i,n));else if(s(i.content)===`stream`||i.content.startsWith(`no stream`)){if(a===void 0){t.error(e.SpecificationStreamOnCommand,`A command occurrence cannot declare a route; assert it on a then event.`,o(i)),t.skipBlock(i.indent);continue}if(h){t.error(e.InvalidSpecificationStream,`An event occurrence declares at most one stream or no stream directive.`,o(i)),t.skipBlock(i.indent);continue}let n=$.exec(i.content);i.content===`no stream`&&(a===`then`||a===`when redelivered`)?(m={kind:`SpecificationNoStreamSyntax`,location:o(i)},h=!0,rejectSpecificationRouteChildren(t,i)):n===null?(t.error(e.InvalidSpecificationStream,`Expected 'stream Source.Stream', or 'no stream' on a then event.`,o(i)),t.skipBlock(i.indent)):(p=parseSpecificationStream(t,i,n),h=!0)}else if(s(i.content)===`for`){let n=i.content.substring(3).trim();n.length===0?t.error(e.InvalidSpecificationEventSource,`Invalid event-source assertion 'for' - expected 'for <value>'`,o(i)):f===null?f=g(n,o(i),t):t.error(e.DuplicateSpecificationEventSource,`A specification step can declare its event-source assertion only once`,o(i))}else t.error(e.InvalidSpecificationValue,`Invalid property mapping '${i.content}' - expected '<property> = <value>'`,o(i))}return{values:d,for:f,...p===void 0?{}:{stream:p},...m===void 0?{}:{noStream:m}}}function parseSpecificationStream(t,n,r){let i=null,a=[],s=!1,c={};for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`streamId`){i!==null||s?(t.error(e.InvalidSpecificationStream,`Declare either one 'streamId = <literal>' mapping or one streamId part block.`,o(r)),t.skipBlock(r.indent)):(s=!0,c.streamId=o(r),a=v(t,r,e.InvalidSpecificationStream).map(e=>e.source.kind===`PathExpressionSyntax`&&e.source.path.startsWith(`case.`)?{...e,source:g(e.source.path,e.source.location,t)}:e));continue}let n=le.exec(r.content);if(n===null||i!==null||s){t.error(e.InvalidSpecificationStream,`Declare either one 'streamId = <literal>' mapping or one streamId part block.`,o(r)),t.skipBlock(r.indent);continue}let l={...o(r),column:r.indent+1+r.content.indexOf(n[1],r.content.indexOf(`=`)+1)};i={kind:`PropertyMappingSyntax`,property:`streamId`,source:g(n[1],l,t),location:o(r)},rejectSpecificationRouteChildren(t,r)}return{kind:`SpecificationStreamSyntax`,eventSource:r[1],stream:r[2],streamId:i,streamIdParts:a,directiveLocations:c,referenceLocation:{...o(n),column:n.indent+1+n.content.indexOf(r[1],6)},referenceLength:r[1].length+1+r[2].length,location:o(n)}}function rejectSpecificationRouteChildren(t,n){let r=t.peekChild(n.indent);r!==void 0&&(t.error(e.InvalidSpecificationStream,`This directive cannot have children.`,o(r)),t.skipBlock(n.indent))}function parseValues(t,n,r=!1,i,a){let s=[];x(t,n,i,s);for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent)){t.reader.takeSignificant();let n=(r||t.sourceOptions.numericMode===`exact`?L:I).exec(i.content);if(n===null){t.error(e.InvalidSpecificationValue,`Invalid property mapping '${i.content}' - expected '<property> = <value>'`,o(i));continue}let c=mappingOf(t,i,n,r);a===void 0?b(t,s,c):(s.some(e=>e.property===c.property)&&a.error(e.UnknownSpecificationQueryArgument,`Query argument '${c.property}' is repeated.`,c.location),s.push(c))}return s}function mappingOf(e,t,n,r=!1){return{kind:`PropertyMappingSyntax`,property:n[1],source:g(n[2],o(t),e,r),location:o(t)}}export{parseSpecification,parseSpecificationStream,rejectSpecificationRouteChildren,$ as specificationStream};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{dotNetWhitespace as r,nativePattern as i,pattern as a}from"../Text/patterns.js";import{locationOf as o}from"./SourceLine.js";import{diagnosticText as s}from"../Diagnostics/DiagnosticArgument.js";import{firstWord as c}from"./LineText.js";import{generatedFixturePattern as l,generatedFixturePrefix as u,parseConcreteMapping as d,parseReturn as f,thenReturnsPrefix as p}from"./SpecificationResponseParser.js";import{containsCaseReference as m,parseCase as h,parseParameter as g,parseSpecificationValue as _,validateTable as ee}from"./SpecificationCaseParser.js";import{parseDescription as te}from"./DescriptionParser.js";import{sourceStreamPattern as v}from"../Text/SourceStreamNames.js";import{parseRouteParts as y}from"./EventSourceParser.js";import{isFileDirective as b}from"./FileReferences.js";import{rejectOperationChildren as ne}from"./OperationParser.js";import{addFixtureValue as x,addInlineValue as S}from"./SpecificationExampleParser.js";const C=a(`^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)`),w=a(`^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$`),T=a(`^specification\\s+([A-Za-z_]\\w*)$`),E=a(`^given caller as ([A-Za-z_]\\w*)$`),stepPattern=(e,t=``)=>i(`^${e}\\s+([A-Z]\\w*(?:\\.\\w+)*)${t}(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?$`.replaceAll(`\\s`,r)),D=stepPattern(`given`),O=stepPattern(`when\\s+append`),k=stepPattern(`when`),A=stepPattern(`then`),j=a(`^then\\s+query\\b`),M=a(`^(?:given|then)\\s+readmodel\\b`),N=stepPattern(`given\\s+readmodel`),P=stepPattern(`then\\s+readmodel`,`(?<exactly>\\s+exactly)?`),F=a(`^then\\s+no\\b`),I=a(`^then\\s+error\\s+"(${t})"$`),L=a(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),R=i(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),re=a(`^given\\s+clock\\b`),z=a(`^given\\s+capture\\b`),B=a(`^when\\s+clock\\b`),V=a(`^when\\s+trigger\\b`),H=a(`^when\\s+capture\\b`),U=a(`^when\\s+query\\b`),W=a(`^then\\s+result\\b`),G=a(`^then\\s+no\\s+result\\b`),K=i(`^when\\s+redelivered\\b`),q=i(`^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),J=a(`^then\\s+no\\s+events\\b`),Y=a(`^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$`),X=a(`^when\\s+trigger\\s+([A-Za-z_]\\w*)$`),ie=a(`^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$`),ae=a(`^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),oe=a(`^then\\s+result(\\s+exactly)?$`),Z=i(`^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$`),se=i(`^(?:"${t}"|'(?:[^'\\\\]|\\\\.)*')$`),Q=i(`^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$`);function parseSpecification(t,n){let r=T.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidSpecificationDeclaration,`Invalid specification declaration '${n.content}' - expected 'specification <Name>'`,o(n));let i=null,a=[],s=[],l={givenOperationFailures:[],thenOperations:[],thenCompensated:[],thenAbsentReadModels:[],thenQueries:[],given:[],givenReadModels:[],when:null,whenAppended:null,whenRedelivered:null,whenDeclared:!1,thenEvents:[],thenEventsInAnyOrder:!1,thenNoEvents:!1,thenReadModels:[],thenErrors:[],givenClock:null,givenCaptures:[],whenClock:null,whenTrigger:null,whenCapture:null,whenQuery:null,thenResults:[],thenNoResult:null,thenDenied:null,givenCaller:null,thenReturns:null};for(let u=t.peekChild(n.indent);u!==void 0;u=t.peekChild(n.indent)){if(t.reader.takeSignificant(),b(u)||parseOperationStep(t,u,l))continue;let n=F.test(u.content)?`then`:c(u.content);if(n===`parameter`){let e=g(t,u);e!==null&&a.push(e)}else if(n===`case`){let e=h(t,u);e!==null&&s.push(e)}else n===`description`?i=te(t,u,i,`Specification '${r}'`):n===`given`?parseGiven(t,u,l):n===`when`?parseWhen(t,u,l,r):n===`then`?parseThen(t,u,l):(t.error(e.UnknownSpecificationDirective,`Unexpected '${c(u.content)}' in specification body`,o(u)),t.skipBlock(u.indent))}l.noEventsLine!==void 0&&(l.thenEvents.length>0||l.thenEventsInAnyOrder||l.thenErrors.length>0||l.thenDenied!==null)&&t.error(e.InvalidNoEventsExpectation,`'then no events' cannot accompany event, event-order, error or denial expectations.`,o(l.noEventsLine)),validateQueryRejection(t,n,l);let{whenDeclared:u,noEventsLine:d,...f}=l,p={kind:`SpecificationSyntax`,sourceOptions:t.sourceOptions,name:r,description:i,...f,...a.length===0?{}:{parameters:a},...s.length===0?{}:{cases:s},location:o(n)};return ee(p,t),p}function validateQueryRejection(t,n,r){isQueryRejectionCandidate(r)&&!isWellFormedQueryRejection(r)&&t.error(e.MismatchedSpecificationQueryResult,`A query rejection requires exactly one query and one 'then error', no action, and no other outcomes`,o(n))}function isQueryRejectionCandidate(e){return e.thenErrors.length>0&&queriedCallCount(e)>0&&(e.whenQuery!==null||!hasAction(e))}function isWellFormedQueryRejection(e){return!hasAction(e)&&hasOneQueryAndOneError(e)&&!hasOtherOutcome(e)}function hasOneQueryAndOneError(e){return queriedCallCount(e)===1&&e.thenErrors.length===1}function hasAction(e){return[e.when,e.whenAppended,e.whenClock,e.whenTrigger,e.whenCapture,e.whenRedelivered].some(e=>e!==null)}function queriedCallCount(e){return e.thenQueries.length+(e.whenQuery===null?0:1)}function hasOtherOutcome(e){return[e.thenResults.length>0,e.thenNoResult!==null,e.thenDenied!==null,e.thenEvents.length>0,e.thenNoEvents,e.thenEventsInAnyOrder,e.thenReadModels.length>0,e.thenAbsentReadModels.length>0,e.thenReturns!==null,e.thenQueries.some(e=>e.results.length>0)].some(e=>e)}function parseOperationStep(t,n,r){if(!C.test(n.content))return!1;let i=w.exec(n.content);if(i===null||i[1]===`given operation`!=(i[3]!==void 0))t.error(e.InvalidOperationSpecification,`Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.`,o(n)),skipBody(t,n.indent);else if(i[1]===`then operation`){let a=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=d(t,r,L,e.InvalidOperationSpecification);n!==null&&a.push(n)}r.thenOperations.push({kind:`SpecificationOperationSyntax`,operation:i[2],values:a,location:o(n)})}else ne(t,n,e.InvalidOperationSpecification,`Failure and compensation assertions cannot have children.`),i[1]===`given operation`?r.givenOperationFailures.push({kind:`SpecificationOperationFailureSyntax`,operation:i[2],location:o(n)}):r.thenCompensated.push({kind:`SpecificationCompensatedSyntax`,operation:i[2],location:o(n)});return!0}function parseGiven(t,n,r){if(re.test(n.content))r.givenClock===null?r.givenClock=parseClock(t,n,`given`):(t.error(e.InvalidSpecificationClock,`A specification states its clock at most once.`,o(n)),skipBody(t,n.indent));else if(z.test(n.content)){let e=parseCapture(t,n,`given`);e!==null&&r.givenCaptures.push(e)}else if(n.content.startsWith(`given caller`)){if(r.givenCaller!==null||r.givenCallerPersona!==void 0)t.error(e.DuplicateSpecificationCallerOrDenied,`A specification has at most one 'given caller' block.`,o(n)),t.skipBlock(n.indent);else if(n.content.startsWith(`given caller as`)){let i=E.exec(n.content);i===null&&t.error(e.InvalidSpecificationCallerPersona,`Expected 'given caller as <Persona>'.`,o(n));let a=t.peekChild(n.indent);a!==void 0&&t.error(e.InvalidSpecificationCallerPersona,`'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.`,o(a)),skipBody(t,n.indent),i!==null&&(r.givenCallerPersona={kind:`SpecificationCallerPersonaSyntax`,name:i[1],location:o(n)})}else r.givenCaller=parseCaller(t,n)}else if(M.test(n.content)){let e=parseReadModelStep(t,n,N,`given`);e!==void 0&&r.givenReadModels.push(e)}else{let e=parseEventStep(t,n,D,`given`);e!==void 0&&r.given.push(e)}}const ce=a(`^role${r}+"(${t})"$`),le=a(`^claim${r}+"(${t})"${r}*=${r}*"(${t})"$`);function parseCaller(t,r){if(r.content!==`given caller`)return t.error(e.InvalidSpecificationCaller,`Expected exactly 'given caller'.`,o(r)),t.skipBlock(r.indent),null;let i=!1,a=[],s=[];for(let c=t.peekChild(r.indent);c!==void 0;c=t.peekChild(r.indent)){t.reader.takeSignificant();let r=ce.exec(c.content),l=le.exec(c.content);c.content===`authenticated`&&!i?i=!0:r===null?l===null?t.error(m(c.content)?e.InvalidSpecificationCaseReference:e.InvalidSpecificationCaller,`Invalid caller fixture '${c.content}' - expected authenticated, role "...", or claim "..." = "...".`,o(c)):s.push({kind:`SpecificationCallerClaimSyntax`,type:n(l[1]),value:n(l[2]),location:o(c)}):a.push(n(r[1]))}return{kind:`SpecificationCallerSyntax`,authenticated:i,roles:a,claims:s,location:o(r)}}function parseWhen(t,n,r,i){let a=n.content.startsWith(`when append`);if(r.whenDeclared){let s=r.whenAppended!==null||a?e.ConflictingSpecificationActions:e.DuplicateSpecificationWhen;t.error(s,`Specification '${i}' already declares a 'when' - a specification can have at most one`,o(n)),skipBody(t,n.indent);return}if(r.whenDeclared=!0,a){r.whenAppended=parseEventStep(t,n,O,`when append`)??null;return}if(K.test(n.content)){let i=q.exec(n.content);i===null?(t.error(e.UnmatchedRedeliveredOccurrence,`Expected 'when redelivered <Event> to <Reaction>'.`,o(n)),skipBody(t,n.indent)):r.whenRedelivered={kind:`SpecificationRedeliverySyntax`,eventType:i[1],reaction:i[2],...parseValuesWithEventSource(t,n,void 0,void 0,`when redelivered`),location:o(n)};return}if(B.test(n.content)){r.whenClock=parseClock(t,n,`when`);return}if(V.test(n.content)){r.whenTrigger=parseNamedStep(t,n,X,e.InvalidSpecificationTrigger,`when trigger`,`when trigger <Trigger>`,(e,t)=>({kind:`SpecificationTriggerSyntax`,trigger:e,values:t,location:o(n)}));return}if(H.test(n.content)){r.whenCapture=parseCapture(t,n,`when`);return}if(U.test(n.content)){r.whenQuery=parseNamedStep(t,n,ae,e.InvalidSpecificationQueryAction,`when query`,`when query <Query>`,(e,t)=>({kind:`SpecificationWhenQuerySyntax`,query:e,arguments:t,location:o(n)}),!0);return}let s=k.exec(n.content);if(s===null){t.error(e.InvalidSpecificationWhen,`Invalid 'when' declaration '${n.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,o(n)),skipBody(t,n.indent);return}let c=[],l=parseValuesWithEventSource(t,n,c,s);r.when={kind:`SpecificationCommandSyntax`,commandType:s[1],...l,generatedValues:c,inlineProperty:s.groups?.property??null,location:o(n)}}function parseThen(t,r,i){if(J.test(r.content)){r.content!==`then no events`||i.thenNoEvents?t.error(e.InvalidNoEventsExpectation,`Expected one 'then no events' directive.`,o(r)):(i.thenNoEvents=!0,i.noEventsLine=r);let n=t.peekChild(r.indent);n!==void 0&&t.error(e.InvalidNoEventsExpectation,`'then no events' cannot have child mappings.`,o(n)),skipBody(t,r.indent);return}if(p.test(r.content)){let n=f(t,r);i.thenReturns===null?i.thenReturns=n:t.error(e.InvalidReturnExpectation,`A specification declares at most one return expectation.`,o(r));return}if(r.content.startsWith(`then events`)){r.content!==`then events in any order`||i.thenEventsInAnyOrder?t.error(e.InvalidSpecificationEventOrder,`Expected one 'then events in any order' directive.`,o(r)):i.thenEventsInAnyOrder=!0,skipBody(t,r.indent);return}if(W.test(r.content)){parseResult(t,r,i);return}if(G.test(r.content)){r.content!==`then no result`||i.thenNoResult!==null?t.error(e.InvalidSpecificationQueryAction,`Expected one 'then no result' directive.`,o(r)):i.thenNoResult={kind:`SpecificationNoResultSyntax`,location:o(r)},skipBody(t,r.indent);return}if(r.content.startsWith(`then denied`)){r.content===`then denied`?i.thenDenied===null?i.thenDenied={kind:`SpecificationDeniedSyntax`,location:o(r)}:t.error(e.DuplicateSpecificationCallerOrDenied,`A specification has at most one 'then denied' outcome.`,o(r)):(t.error(e.InvalidSpecificationDenied,`Expected exactly 'then denied'.`,o(r)),skipBody(t,r.indent));return}if(r.content===`then error`){i.thenErrors.push({kind:`SpecificationErrorSyntax`,name:null,location:o(r)});return}if(r.content.startsWith(`then error case.`)){let e=_(r.content.substring(11),{...o(r),column:o(r).column+11},t);e.kind===`CaseValueExpressionSyntax`&&i.thenErrors.push({kind:`SpecificationErrorSyntax`,name:null,caseValue:e,location:o(r)});return}let a=I.exec(r.content);if(a!==null){i.thenErrors.push({kind:`SpecificationErrorSyntax`,name:n(a[1]),location:o(r)});return}if(c(r.content.substring(4).trim())===`error`){t.error(e.InvalidThenError,`Invalid 'then error' declaration '${r.content}' - expected 'then error' or 'then error "<reason>"'`,o(r)),skipBody(t,r.indent);return}if(F.test(r.content)){if(t.sourceOptions.numericMode===`exact`){let e=parseAbsentReadModel(t,r);e!==null&&i.thenAbsentReadModels.push(e);return}let e=Z.exec(r.content);if(e!==null&&!e[2].endsWith(` exactly`)){let n=_(e[2].trim(),o(r),t.valueContext);(n.kind===`LiteralExpressionSyntax`||n.kind===`ObjectExpressionSyntax`||n.kind===`CaseValueExpressionSyntax`)&&i.thenAbsentReadModels.push({kind:`SpecificationAbsentReadModelSyntax`,name:e[1],key:n,location:o(r)})}t.skipOpaqueBlock(r.indent);return}if(j.test(r.content)){let n=t.sourceOptions.numericMode===`exact`,reject=(e,r,i)=>{if(!n)return t.skipOpaqueBlock(i.indent);t.error(e,r,o(i)),t.skipBlock(i.indent)},a=Q.exec(r.content);if(a===null)return reject(e.InvalidSpecificationQuery,`Invalid 'then query' declaration '${r.content}' - expected 'then query <Query> [exactly]'`,r);let s=[],l=[],u=!1;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent))t.reader.takeSignificant(),n.content===`arguments`&&!u?s.push(...parseValues(t.valueContext,n,!0,void 0,t)):n.content===`arguments`?reject(e.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,n):n.content===`result`?l.push({kind:`SpecificationQueryResultSyntax`,properties:parseValues(t.valueContext,n,!0),exactly:!1,location:o(n)}):reject(e.UnknownSpecificationQueryDirective,`Unexpected '${c(n.content)}' in 'then query' body - expected arguments or result`,n),u||=n.content===`arguments`;i.thenQueries.push({kind:`SpecificationQuerySyntax`,query:a[1],arguments:s,results:l,exactly:a[2]!==void 0,location:o(r)});return}if(M.test(r.content)){let e=parseReadModelStep(t,r,P,`then`);e!==void 0&&i.thenReadModels.push(e);return}let s=parseEventStep(t,r,A,`then`);s!==void 0&&i.thenEvents.push(s)}function parseAbsentReadModel(t,n){let r=Z.exec(n.content);if(r===null||r[2].endsWith(` exactly`))return t.error(e.InvalidAbsentReadModelStep,`Invalid absence assertion '${n.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,o(n)),skipBody(t,n.indent),null;let i=r[2].trim(),a=!(i.startsWith(`"`)||i.startsWith(`'`))||se.test(i)?_(i,o(n),t.valueContext):null,s=a!==null&&(a.kind===`LiteralExpressionSyntax`||a.kind===`ObjectExpressionSyntax`||a.kind===`CaseValueExpressionSyntax`);s||t.error(e.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,o(n));let c=!1;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(e.InvalidAbsentReadModelStep,`An absent read model assertion cannot have child mappings.`,o(r)),c=!0;return c||!s?null:{kind:`SpecificationAbsentReadModelSyntax`,name:r[1],key:a,location:o(n)}}function skipBody(e,t){if(e.sourceOptions.numericMode!==`exact`)return e.skipBlock(t);e.skipOpaqueBlock(t)}function parseClock(t,n,r){let i=Y.exec(n.content);return skipBody(t,n.indent),i===null||i[1]!==r?(t.error(m(n.content)?e.InvalidSpecificationCaseReference:e.InvalidSpecificationClock,`Invalid '${r} clock' - expected '${r} clock "<ISO 8601 instant>"', such as '${r} clock "2026-10-05T08:00:00Z"'`,o(n)),null):{kind:`SpecificationClockSyntax`,instant:i[2],location:o(n)}}function parseCapture(t,n,r){return parseNamedStep(t,n,ie,e.InvalidSpecificationCapture,`${r} capture`,`${r} capture <Capture>`,(e,t)=>({kind:`SpecificationCaptureSyntax`,capture:e,record:t,location:o(n)}))}function parseNamedStep(e,t,n,r,i,a,s,c=!1){let l=n.exec(t.content);return l===null?(e.error(r,`Invalid '${i}' declaration '${t.content}' - expected '${a}'`,o(t)),skipBody(e,t.indent),null):s(l[1],parseValues(e,t,!1,void 0,c?e:void 0))}function parseResult(t,n,r){let i=oe.exec(n.content);i===null?(t.error(e.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${n.content}' - expected 'then result [exactly]'`,o(n)),skipBody(t,n.indent)):r.thenResults.push({kind:`SpecificationQueryResultSyntax`,properties:parseValues(t,n),exactly:i[1]!==void 0,location:o(n)})}function parseReadModelStep(t,n,r,i){let a=r.exec(n.content);if(a===null)t.error(e.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${n.content}' - expected '${i} readmodel <ReadModelType>'`,o(n)),skipBody(t,n.indent);else return{kind:`SpecificationReadModelSyntax`,name:a[1],properties:parseValues(t,n,!1,a),exactly:i===`then`&&a.groups?.exactly!==void 0,inlineProperty:a.groups?.property??null,location:o(n)}}function parseEventStep(t,n,r,i){let a=r.exec(n.content);if(a===null)t.error(e.InvalidEventStep,`Invalid '${i}' declaration '${n.content}' - expected '${i} <EventType>'`,o(n)),skipBody(t,n.indent);else return{kind:`SpecificationEventSyntax`,eventType:a[1],...parseValuesWithEventSource(t,n,void 0,a,i),inlineProperty:a.groups?.property??null,location:o(n)}}const $=v(`^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$`),ue=a(`^streamId\\s*=(?!=|>)\\s*(.+)$`);function parseValuesWithEventSource(t,n,r,i,a){let f=[];S(t,n,i,f);let p=null,m,h,g=!1;for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r!==void 0&&u.test(i.content)){let n=d(t,i,l,e.InvalidGeneratedFixture);n!==null&&r.push(n);continue}let n=L.exec(i.content);if(n!==null)x(t,f,mappingOf(t,i,n));else if(c(i.content)===`stream`||i.content.startsWith(`no stream`)){if(a===void 0){t.error(e.SpecificationStreamOnCommand,`A command occurrence cannot declare a route; assert it on a then event.`,o(i)),t.skipBlock(i.indent);continue}if(g){t.error(e.InvalidSpecificationStream,`An event occurrence declares at most one stream or no stream directive.`,o(i)),t.skipBlock(i.indent);continue}let n=$.exec(i.content);i.content===`no stream`&&(a===`then`||a===`when redelivered`)?(h={kind:`SpecificationNoStreamSyntax`,location:o(i)},g=!0,rejectSpecificationRouteChildren(t,i)):n===null?(t.error(e.InvalidSpecificationStream,`Expected 'stream Source.Stream', or 'no stream' on a then event.`,o(i)),t.skipBlock(i.indent)):(m=parseSpecificationStream(t,i,n),g=!0)}else if(c(i.content)===`for`){let n=i.content.substring(3).trim();n.length===0?t.error(e.InvalidSpecificationEventSource,`Invalid event-source assertion 'for' - expected 'for <value>'`,o(i)):p===null?p=_(n,o(i),t):t.error(e.DuplicateSpecificationEventSource,`A specification step can declare its event-source assertion only once`,o(i))}else t.error(e.InvalidSpecificationValue,`Invalid property mapping '${i.content}' - expected '<property> = <value>'`,o(i),s(`text`,i.content))}return{values:f,for:p,...m===void 0?{}:{stream:m},...h===void 0?{}:{noStream:h}}}function parseSpecificationStream(t,n,r){let i=null,a=[],s=!1,c={};for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`streamId`){i!==null||s?(t.error(e.InvalidSpecificationStream,`Declare either one 'streamId = <literal>' mapping or one streamId part block.`,o(r)),t.skipBlock(r.indent)):(s=!0,c.streamId=o(r),a=y(t,r,e.InvalidSpecificationStream).map(e=>e.source.kind===`PathExpressionSyntax`&&e.source.path.startsWith(`case.`)?{...e,source:_(e.source.path,e.source.location,t)}:e));continue}let n=ue.exec(r.content);if(n===null||i!==null||s){t.error(e.InvalidSpecificationStream,`Declare either one 'streamId = <literal>' mapping or one streamId part block.`,o(r)),t.skipBlock(r.indent);continue}let l={...o(r),column:r.indent+1+r.content.indexOf(n[1],r.content.indexOf(`=`)+1)};i={kind:`PropertyMappingSyntax`,property:`streamId`,source:_(n[1],l,t),location:o(r)},rejectSpecificationRouteChildren(t,r)}return{kind:`SpecificationStreamSyntax`,eventSource:r[1],stream:r[2],streamId:i,streamIdParts:a,directiveLocations:c,referenceLocation:{...o(n),column:n.indent+1+n.content.indexOf(r[1],6)},referenceLength:r[1].length+1+r[2].length,location:o(n)}}function rejectSpecificationRouteChildren(t,n){let r=t.peekChild(n.indent);r!==void 0&&(t.error(e.InvalidSpecificationStream,`This directive cannot have children.`,o(r)),t.skipBlock(n.indent))}function parseValues(t,n,r=!1,i,a){let c=[];S(t,n,i,c);for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent)){t.reader.takeSignificant();let n=(r||t.sourceOptions.numericMode===`exact`?R:L).exec(i.content);if(n===null){t.error(e.InvalidSpecificationValue,`Invalid property mapping '${i.content}' - expected '<property> = <value>'`,o(i),s(`text`,i.content));continue}let l=mappingOf(t,i,n,r);a===void 0?x(t,c,l):(c.some(e=>e.property===l.property)&&a.error(e.UnknownSpecificationQueryArgument,`Query argument '${l.property}' is repeated.`,l.location,s(`argument`,l.property)),c.push(l))}return c}function mappingOf(e,t,n,r=!1){return{kind:`PropertyMappingSyntax`,property:n[1],source:_(n[2],o(t),e,r),location:o(t)}}export{parseSpecification,parseSpecificationStream,rejectSpecificationRouteChildren,$ as specificationStream};
2
2
  //# sourceMappingURL=SpecificationParser.js.map
@@ -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","givenClockPrefix","givenCapturePrefix","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","capture","readModel","event","callerRolePattern","callerClaimPattern","authenticated","roles","claims","role","claim","containsCaseReference","unescapeString","appends","code","generatedValues","thenReturnsPrefix","expectation","parseReturn","caseValue","parseSpecificationValue","error","absent","key","exact","at","message","args","results","hasArguments","keyText","concrete","hasChildren","indent","regex","expected","create","queryArguments","specificationStream","sourceStreamPattern","specificationStreamId","addInlineValue","parent","inline","eventSource","stream","noStream","hasRoute","generated","generatedFixturePrefix","fixture","generatedFixturePattern","mapping","addFixtureValue","eventKeyword","route","source","streamId","streamIdParts","block","directiveLocations","parseRouteParts","part","location","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 { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport {\n SpecificationCaptureSyntax, SpecificationClockSyntax, 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, parseConcreteMapping, parseReturn, thenReturnsPrefix } from './SpecificationResponseParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { SpecificationAbsentReadModelSyntax, SpecificationCallerClaimSyntax, SpecificationCallerSyntax, SpecificationQuerySyntax } from '../Syntax/Specifications';\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 givenClockPrefix = pattern('^given\\\\s+clock\\\\b');\nconst givenCapturePrefix = pattern('^given\\\\s+capture\\\\b');\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 givenCaptures: SpecificationCaptureSyntax[];\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}\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, 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 (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 (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].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].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 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 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 {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child));\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 if (mapping === null) {\n context.error(DiagnosticCodes.InvalidSpecificationValue, `Invalid property mapping '${child.content}' - expected '<property> = <value>'`, locationOf(child));\n continue;\n }\n const value = 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);\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":"6jCA0BA,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,EACr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,qCAAsCL,EAAWK,CAAK,CAAC,EAC3J,QACJ,CACA,IAAMmB,EAAQ,UAAU1B,EAASO,EAAOyE,EAASY,CAAiB,EAC9DC,IAA0B,IAAA,GAM1BZ,EAAgBjF,EAASyB,EAAQC,CAAK,GALlCD,EAAO,KAAK,GAAYqE,EAAS,WAAapE,EAAM,QAAQ,GAC5DmE,EAAsB,MAAM5F,EAAgB,kCAAmC,mBAAmByB,EAAM,SAAS,gBAAiBA,EAAM,QAAQ,EAEpJD,EAAO,KAAKC,CAAK,EAIzB,CACA,OAAOD,CACX,CAEA,SAAS,UAAU,EAAwB,EAAkB,EAAwB,EAAoB,GAA8B,CACnI,MAAO,CAAE,KAAM,wBAAyB,SAAUD,EAAM,GAAI,OAAQpE,EAAmBoE,EAAM,GAAItB,EAAWH,CAAI,EAAGC,EAAS4F,CAAiB,EAAG,SAAU1F,EAAWH,CAAI,CAAE,CAC/K"}
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","givenClockPrefix","givenCapturePrefix","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","capture","readModel","event","callerRolePattern","callerClaimPattern","authenticated","roles","claims","role","claim","containsCaseReference","unescapeString","appends","code","generatedValues","thenReturnsPrefix","expectation","parseReturn","caseValue","parseSpecificationValue","error","absent","key","exact","at","message","args","results","hasArguments","keyText","concrete","hasChildren","indent","regex","expected","create","queryArguments","specificationStream","sourceStreamPattern","specificationStreamId","addInlineValue","parent","inline","eventSource","stream","noStream","hasRoute","generated","generatedFixturePrefix","fixture","generatedFixturePattern","mapping","addFixtureValue","eventKeyword","route","source","diagnosticText","streamId","streamIdParts","block","directiveLocations","parseRouteParts","part","location","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, 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, parseConcreteMapping, parseReturn, thenReturnsPrefix } from './SpecificationResponseParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { SpecificationAbsentReadModelSyntax, SpecificationCallerClaimSyntax, SpecificationCallerSyntax, SpecificationQuerySyntax } from '../Syntax/Specifications';\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 givenClockPrefix = pattern('^given\\\\s+clock\\\\b');\nconst givenCapturePrefix = pattern('^given\\\\s+capture\\\\b');\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 givenCaptures: SpecificationCaptureSyntax[];\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}\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, 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 (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 (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].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].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 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 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 {\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 if (mapping === null) {\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 = 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":"moCA2BA,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,GAAmBrB,EAAQ,oBAAoB,EAC/CsB,EAAqBtB,EAAQ,sBAAsB,EACnDuB,EAAkBvB,EAAQ,mBAAmB,EAC7CwB,EAAoBxB,EAAQ,qBAAqB,EACjDyB,EAAoBzB,EAAQ,qBAAqB,EACjD0B,EAAkB1B,EAAQ,mBAAmB,EAC7C2B,EAAmB3B,EAAQ,oBAAoB,EAC/C4B,E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CAAE,KAAM,wBAAyB,SAAUD,EAAM,GAAI,OAAQpE,EAAmBoE,EAAM,GAAItB,EAAWH,CAAI,EAAGC,EAAS6F,CAAiB,EAAG,SAAU3F,EAAWH,CAAI,CAAE,CAC/K"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t}from"../Text/StringLiteral.js";import{pattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{containsCaseReference as a,parseSpecificationValue as o}from"./SpecificationCaseParser.js";const s=n(`^then\\s+returns\\b`),c=n(`^generated\\s+(?=\\S)(?![=])`),l=n(`^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`),u=n(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),d=n(`^(?:"${t}"|'(?:[^'\\\\]|\\\\.)*')$`);function parseConcrete(t,n,r,s){if(n.startsWith(`case.`))return o(n,r,t);if(a(n)&&t.error(e.InvalidSpecificationCaseReference,`A case reference fills a whole value position; it cannot occur inside a structured value or expression.`,r),(n.startsWith(`"`)||n.startsWith(`'`))&&!d.test(n))return t.error(s,`Expected exactly one concrete value.`,r),null;let c=i(n,r,t);return![`LiteralExpressionSyntax`,`ObjectExpressionSyntax`,`ListExpressionSyntax`].includes(c.kind)||c.kind===`LiteralExpressionSyntax`&&typeof c.value==`number`&&!Number.isFinite(c.value)?(t.error(s,`Expected exactly one concrete literal or structured value, not an expression.`,r),null):c}function parseConcreteMapping(e,t,n,i){let a=n.exec(t.content);if(a===null)return e.error(i,`Expected a named fixture or assertion with exactly one concrete value.`,r(t)),e.skipBlock(t.indent),null;let o=r(t),s=parseConcrete(e,a[2],{...o,column:o.column+t.content.indexOf(a[2],t.content.indexOf(`=`)+1)},i),c=e.peekChild(t.indent);return c!==void 0&&(e.error(i,`A fixture or return field cannot have child directives.`,r(c)),e.skipBlock(t.indent)),s===null?null:{kind:`PropertyMappingSyntax`,property:a[1],source:s,location:o}}function parseReturn(t,n){let i=s.exec(n.content)[0].length,a=n.content.substring(i).trim(),o=r(n);if(a.length>0){let s=parseConcrete(t,a,{...o,column:o.column+n.content.indexOf(a,i)},e.InvalidReturnExpectation),c=t.peekChild(n.indent);return c!==void 0&&(t.error(e.InvalidReturnExpectation,`A scalar return expectation cannot have child assertions.`,r(c)),t.skipBlock(n.indent)),s===null?null:{kind:`ScalarSpecificationReturnSyntax`,value:s,location:o}}let c=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=parseConcreteMapping(t,r,u,e.InvalidReturnExpectation);n!==null&&c.push(n)}return{kind:`RecordSpecificationReturnSyntax`,fields:c,location:o}}export{l as generatedFixturePattern,c as generatedFixturePrefix,parseConcrete,parseConcreteMapping,parseReturn,s as thenReturnsPrefix};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t}from"../Text/StringLiteral.js";import{pattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{diagnosticText as a}from"../Diagnostics/DiagnosticArgument.js";import{containsCaseReference as o,parseSpecificationValue as s}from"./SpecificationCaseParser.js";const c=n(`^then\\s+returns\\b`),l=n(`^generated\\s+(?=\\S)(?![=])`),u=n(`^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`),d=n(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),f=n(`^(?:"${t}"|'(?:[^'\\\\]|\\\\.)*')$`);function parseConcrete(t,n,r,c){if(n.startsWith(`case.`))return s(n,r,t);o(n)&&t.error(e.InvalidSpecificationCaseReference,`A case reference fills a whole value position; it cannot occur inside a structured value or expression.`,r);let l=c===e.InvalidSpecificationValue||c===e.InvalidSpecificationCaseValue?a(`text`,n):{};if((n.startsWith(`"`)||n.startsWith(`'`))&&!f.test(n))return t.error(c,`Expected exactly one concrete value.`,r,l),null;let u=i(n,r,t);return![`LiteralExpressionSyntax`,`ObjectExpressionSyntax`,`ListExpressionSyntax`].includes(u.kind)||u.kind===`LiteralExpressionSyntax`&&typeof u.value==`number`&&!Number.isFinite(u.value)?(t.error(c,`Expected exactly one concrete literal or structured value, not an expression.`,r,l),null):u}function parseConcreteMapping(e,t,n,i){let a=n.exec(t.content);if(a===null)return e.error(i,`Expected a named fixture or assertion with exactly one concrete value.`,r(t)),e.skipBlock(t.indent),null;let o=r(t),s=parseConcrete(e,a[2],{...o,column:o.column+t.content.indexOf(a[2],t.content.indexOf(`=`)+1)},i),c=e.peekChild(t.indent);return c!==void 0&&(e.error(i,`A fixture or return field cannot have child directives.`,r(c)),e.skipBlock(t.indent)),s===null?null:{kind:`PropertyMappingSyntax`,property:a[1],source:s,location:o}}function parseReturn(t,n){let i=c.exec(n.content)[0].length,a=n.content.substring(i).trim(),o=r(n);if(a.length>0){let s=parseConcrete(t,a,{...o,column:o.column+n.content.indexOf(a,i)},e.InvalidReturnExpectation),c=t.peekChild(n.indent);return c!==void 0&&(t.error(e.InvalidReturnExpectation,`A scalar return expectation cannot have child assertions.`,r(c)),t.skipBlock(n.indent)),s===null?null:{kind:`ScalarSpecificationReturnSyntax`,value:s,location:o}}let s=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=parseConcreteMapping(t,r,d,e.InvalidReturnExpectation);n!==null&&s.push(n)}return{kind:`RecordSpecificationReturnSyntax`,fields:s,location:o}}export{u as generatedFixturePattern,l as generatedFixturePrefix,parseConcrete,parseConcreteMapping,parseReturn,c as thenReturnsPrefix};
2
2
  //# sourceMappingURL=SpecificationResponseParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpecificationResponseParser.js","names":["thenReturnsPrefix","pattern","generatedFixturePrefix","generatedFixturePattern","fieldPattern","quotedValue","stringBodyPattern","text","parseSpecificationValue","location","context","containsCaseReference","DiagnosticCodes","code","expression","parseMappingSource","match","regex","line","locationOf","source","child","prefix","value","concrete","fields","field"],"sources":["../../../../../../Compiler/Parsing/SpecificationResponseParser.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 { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { stringBodyPattern } from '../Text/StringLiteral';\nimport { parseMappingSource } from './ExpressionParser';\nimport { containsCaseReference, parseSpecificationValue } from './SpecificationCaseParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport const thenReturnsPrefix = pattern('^then\\\\s+returns\\\\b');\nexport const generatedFixturePrefix = pattern('^generated\\\\s+(?=\\\\S)(?![=])');\nexport const generatedFixturePattern = pattern('^generated\\\\s+([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst fieldPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst quotedValue = pattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\n\nexport function parseConcrete(context: ParserContext, text: string, location: SourceLocation, code: string): ExpressionSyntax | null {\n if (text.startsWith('case.')) return parseSpecificationValue(text, location, context);\n if (containsCaseReference(text)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'A case reference fills a whole value position; it cannot occur inside a structured value or expression.', location);\n if ((text.startsWith('\"') || text.startsWith(\"'\")) && !quotedValue.test(text)) {\n context.error(code, 'Expected exactly one concrete value.', location);\n return null;\n }\n const expression = parseMappingSource(text, location, context);\n if (!['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(expression.kind) || (expression.kind === 'LiteralExpressionSyntax' && typeof expression.value === 'number' && !Number.isFinite(expression.value))) {\n context.error(code, 'Expected exactly one concrete literal or structured value, not an expression.', location);\n return null;\n }\n return expression;\n}\n\nexport function parseConcreteMapping(context: ParserContext, line: SourceLine, regex: RegExp, code: string): PropertyMappingSyntax | null {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(code, 'Expected a named fixture or assertion 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[2], { ...location, column: location.column + line.content.indexOf(match[2], line.content.indexOf('=') + 1) }, code);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'A fixture or return field cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'PropertyMappingSyntax', property: match[1], source, location };\n}\n\nexport function parseReturn(context: ParserContext, line: SourceLine): SpecificationReturnSyntax | null {\n const prefix = thenReturnsPrefix.exec(line.content)![0].length;\n const value = line.content.substring(prefix).trim();\n const location = locationOf(line);\n if (value.length > 0) {\n const concrete = parseConcrete(context, value, { ...location, column: location.column + line.content.indexOf(value, prefix) }, DiagnosticCodes.InvalidReturnExpectation);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A scalar return expectation cannot have child assertions.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return concrete === null ? null : { kind: 'ScalarSpecificationReturnSyntax', value: concrete, location };\n }\n const fields: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const field = parseConcreteMapping(context, child, fieldPattern, DiagnosticCodes.InvalidReturnExpectation);\n if (field !== null) fields.push(field);\n }\n return { kind: 'RecordSpecificationReturnSyntax', fields, location };\n}\n"],"mappings":"8aAcA,MAAaA,EAAoBC,EAAQ,qBAAqB,EACjDC,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otedValue","stringBodyPattern","text","parseSpecificationValue","location","context","containsCaseReference","DiagnosticCodes","subjects","code","diagnosticText","expression","parseMappingSource","match","regex","line","locationOf","source","child","prefix","value","concrete","fields","field"],"sources":["../../../../../../Compiler/Parsing/SpecificationResponseParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { stringBodyPattern } from '../Text/StringLiteral';\nimport { parseMappingSource } from './ExpressionParser';\nimport { containsCaseReference, parseSpecificationValue } from './SpecificationCaseParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport const thenReturnsPrefix = pattern('^then\\\\s+returns\\\\b');\nexport const generatedFixturePrefix = pattern('^generated\\\\s+(?=\\\\S)(?![=])');\nexport const generatedFixturePattern = pattern('^generated\\\\s+([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst fieldPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst quotedValue = pattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\n\nexport function parseConcrete(context: ParserContext, text: string, location: SourceLocation, code: string): ExpressionSyntax | null {\n if (text.startsWith('case.')) return parseSpecificationValue(text, location, context);\n if (containsCaseReference(text)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'A case reference fills a whole value position; it cannot occur inside a structured value or expression.', location);\n const subjects = code === DiagnosticCodes.InvalidSpecificationValue || code === DiagnosticCodes.InvalidSpecificationCaseValue ? diagnosticText('text', text) : {};\n if ((text.startsWith('\"') || text.startsWith(\"'\")) && !quotedValue.test(text)) {\n context.error(code, 'Expected exactly one concrete value.', location, subjects);\n return null;\n }\n const expression = parseMappingSource(text, location, context);\n if (!['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(expression.kind) || (expression.kind === 'LiteralExpressionSyntax' && typeof expression.value === 'number' && !Number.isFinite(expression.value))) {\n context.error(code, 'Expected exactly one concrete literal or structured value, not an expression.', location, subjects);\n return null;\n }\n return expression;\n}\n\nexport function parseConcreteMapping(context: ParserContext, line: SourceLine, regex: RegExp, code: string): PropertyMappingSyntax | null {\n const match = regex.exec(line.content);\n if (match === null) {\n context.error(code, 'Expected a named fixture or assertion 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[2], { ...location, column: location.column + line.content.indexOf(match[2], line.content.indexOf('=') + 1) }, code);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'A fixture or return field cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'PropertyMappingSyntax', property: match[1], source, location };\n}\n\nexport function parseReturn(context: ParserContext, line: SourceLine): SpecificationReturnSyntax | null {\n const prefix = thenReturnsPrefix.exec(line.content)![0].length;\n const value = line.content.substring(prefix).trim();\n const location = locationOf(line);\n if (value.length > 0) {\n const concrete = parseConcrete(context, value, { ...location, column: location.column + line.content.indexOf(value, prefix) }, DiagnosticCodes.InvalidReturnExpectation);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A scalar return expectation cannot have child assertions.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return concrete === null ? null : { kind: 'ScalarSpecificationReturnSyntax', value: concrete, location };\n }\n const fields: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const field = parseConcreteMapping(context, child, fieldPattern, DiagnosticCodes.InvalidReturnExpectation);\n if (field !== null) fields.push(field);\n }\n return { kind: 'RecordSpecificationReturnSyntax', fields, location };\n}\n"],"mappings":"ofAeA,MAAaA,EAAoBC,EAAQ,qBAAqB,EACjDC,EAAyBD,EAAQ,8BAA8B,EAC/DE,EAA0BF,EAAQ,iDAAiD,EAC1FG,EAAeH,EAAQ,iCAAiC,EACxDI,EAAcJ,EAAQ,QAAQK,EAAkB,0BAA0B,EAEhF,SAAgB,cAAc,EAAwB,EAAc,EAA0B,EAAuC,CACjI,GAAIC,EAAK,WAAW,OAAO,EAAG,OAAOC,EAAwBD,EAAME,EAAUC,CAAO,EAChFC,EAAsBJ,CAAI,GAAGG,EAAQ,MAAME,EAAgB,kCAAmC,0GAA2GH,CAAQ,EACrN,IAAMI,EAAWC,IAASF,EAAgB,2BAA6BE,IAASF,EAAgB,8BAAgCG,EAAe,OAAQR,CAAI,EAAI,CAAC,EAChK,IAAKA,EAAK,WAAW,GAAG,GAAKA,EAAK,WAAW,GAAG,IAAM,CAACF,EAAY,KAAKE,CAAI,EAExE,OADAG,EAAQ,MAAMI,EAAM,uCAAwCL,EAAUI,CAAQ,EACvE,KAEX,IAAMG,EAAaC,EAAmBV,EAAME,EAAUC,CAAO,EAK7D,MAJI,CAAC,CAAC,0BAA2B,yBAA0B,sBAAsB,CAAC,CAAC,SAASM,EAAW,IAAI,GAAMA,EAAW,OAAS,2BAA6B,OAAOA,EAAW,OAAU,UAAY,CAAC,OAAO,SAASA,EAAW,KAAK,GACvON,EAAQ,MAAMI,EAAM,gFAAiFL,EAAUI,CAAQ,EAChH,MAEJG,CACX,CAEA,SAAgB,qBAAqB,EAAwB,EAAkB,EAAe,EAA4C,CACtI,IAAME,EAAQC,EAAM,KAAKC,EAAK,OAAO,EACrC,GAAIF,IAAU,KAGV,OAFAR,EAAQ,MAAMI,EAAM,yEAA0EO,EAAWD,CAAI,CAAC,EAC9GV,EAAQ,UAAUU,EAAK,MAAM,EACtB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EAC/B,IAAMkB,EAAQ,qBAAqBlB,EAASa,EAAOnB,EAAcQ,EAAgB,wBAAwB,EACrGgB,IAAU,MAAMD,EAAO,KAAKC,CAAK,CACzC,CACA,MAAO,CAAE,KAAM,kCAAmC,SAAQ,UAAS,CACvE"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.js";import{EventSourceCatalog as n}from"../Syntax/EventSourceCatalog.js";import{expandEffectiveSpecificationExamples as r,specificationExamples as i}from"./SpecificationCommandExamples.js";import{compatibleValue as a,uniqueByName as o}from"./ResponseValidator.js";import{commandDestinationType as s}from"./CommandDestinationTypes.js";import{LineReader as c}from"./LineReader.js";import{ParserContext as l}from"./ParserContext.js";import{streamIdFailureMessage as u}from"../Syntax/StreamIdFormatter.js";import{validateStreamIdParts as d}from"./CompositeStreamIdValidator.js";import{formatSpecificationStreamId as f}from"./SpecificationRouteComparison.js";import{formatStreamIdLiteral as p}from"./EventSourceValidator.js";function validateSpecificationStreams(n,r){let i=new t(n).slices.flatMap(({slice:e})=>e.specifications.flatMap(e=>e.cases??[]));if(i.length===0)return validateRoutes(n,r);let a=new l(new c([]));validateRoutes(n,a);let o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set;for(let t of a.diagnostics){let n=JSON.stringify([t.code,t.location.path,t.location.line,t.location.column,t.message]);if(s.has(n))continue;s.add(n);let a=t.code===e.InvalidSpecificationStreamRoute?i.find(e=>e.values.some(e=>e.source.location.line===t.location.line&&e.source.location.column===t.location.column&&e.source.location.path===t.location.path)):void 0;if(a===void 0)r.error(t.code,t.message,t.location);else{let e=JSON.stringify(t.location);o.has(e)||r.error(t.code,`Case '${a.name}': ${t.message}`,t.location),o.add(e)}}}function validateRoutes(c,l){let m=i(c).resolvedExamples,h=r(c);c=h.application;let g=new t(c),_=/* @__PURE__ */ new Set,v=m.flatMap(t=>{if(t.kind!==`event`)return(t.kind===`command`||t.kind===`readmodel`)&&(t.example.stream!=null||t.example.noStream!=null)&&l.error(e.InvalidSpecificationExampleBody,`only event examples carry routes; a command's route comes from its declaration, and read models have none`,(t.example.stream??t.example.noStream).location),[];let n={kind:`SpecificationEventSyntax`,eventType:t.name,values:t.example.values,for:t.example.for,stream:t.example.stream,noStream:t.example.noStream,location:t.example.location};return _.add(n),[{scope:t.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[n],whenRedelivered:null}}]}),y=new n(c),b=o(c.concepts),x=o(c.types),S=new Map([...x].map(([e,t])=>[e,o(t.properties)])),compatible=(e,t)=>a(e,t,b,S),C=/* @__PURE__ */ new Set([`String`,`Uuid`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`,...b.keys(),...x.keys()]),nominallyCompatible=(e,t)=>C.has(e.name)&&C.has(t.name)?e.name===t.name&&e.isCollection===t.isCollection&&(!e.isOptional||t.isOptional):null,formatStreamId=(e,t)=>f(e,t,c),eventOf=(e,t)=>{let n=g.resolve(e,t).declaration;return n?.node.kind===`EventSyntax`?n.node:null},w=[];for(let{slice:e}of g.slices){for(let t of e.commands)for(let n of t.produces){if(!g.isEventProduction(n,e))continue;let r=eventOf(n.event,e);if(r===null)continue;let i=s(t,n,c,{resolver:g,slice:e});w.push({event:r,command:t,type:i,route:n.stream??t.stream})}for(let t of e.reactions.flatMap(e=>e.triggers).flatMap(e=>e.produces)){let n=eventOf(t.event,e);n!==null&&w.push({event:n,command:null,type:null})}for(let t of e.captures)for(let n of[...t.appends,...t.children.flatMap(e=>e.appends),...t.nested.flatMap(e=>e.appends)]){let t=eventOf(n.event,e);t!==null&&w.push({event:t,command:null,type:null})}}let T=[...v.flatMap(e=>g.slices.filter(t=>t.scope.join(`.`)===e.scope.join(`.`)).map(({slice:t,scope:n})=>({slice:t,scope:n,specification:e.specification}))),...g.slices.flatMap(({slice:e,scope:t})=>e.specifications.map(n=>({slice:e,scope:t,specification:n})))];for(let{slice:t,scope:n,specification:r}of T){let i=g.slices.flatMap(e=>e.slice.commands.map(t=>({command:t,scope:e.scope}))),a=r.when?.commandType.split(`.`)??[],o=a.slice(0,-1),s=i.filter(e=>e.command.name===a.at(-1)&&o.every((t,n)=>e.scope[e.scope.length-o.length+n]===t)),f=o.length>0&&s.length===1?s[0].command:null;for(let e=n.length;o.length===0&&e>=0&&f===null;e--){let t=s.filter(t=>n.slice(0,e).every((e,n)=>t.scope[n]===e));if(t.length>0){f=t.length===1?t[0].command:null;break}}let m=[...r.given.map(e=>({node:e,required:!0,expected:!1})),...r.whenAppended===null?[]:[{node:r.whenAppended,required:!0,expected:!1}],...r.thenEvents.map(e=>({node:e,required:!1,expected:!_.has(e)})),...r.whenRedelivered==null?[]:[{node:{...r.whenRedelivered,kind:`SpecificationEventSyntax`},required:!1,expected:!1}]];for(let{node:n,required:r,expected:i}of m){let a=h.specifications.flatMap(e=>e.steps).find(e=>e.effective===n),o=a?.route?.origin!==`example`,s=o||n.for!==a?.example?.for,contextualError=(e,t,n)=>{l.error(e,a?.example==null?t:`${t} Example '${a.example.name}' is used here.`,a?.example==null?n:a.authored.location)};if(n.stream==null&&n.noStream==null)continue;r&&n.noStream!=null&&contextualError(e.InvalidSpecificationStream,`Expected 'stream Source.Stream', or 'no stream' on a then event.`,n.noStream.location);let m=null,g=eventOf(n.eventType,t),_=w.filter(e=>e.event===g);if(n.stream!=null){let t=n.stream,i=y.resolve(t.eventSource,t.stream);if(i.kind!==`unique`){let n={ambiguous:`Ambiguous`,notFound:`NotFound`,wrongKind:`WrongKind`}[i.kind];o&&l.error(e.InvalidSpecificationStreamRoute,`Stream '${t.eventSource}.${t.stream}' is ${n}; routing requires one physical source and stream.`,t.location);continue}let f=i.sources[0],h=i.streams[0],validateLiteral=(t,n)=>{let r=t.source,i=p(r,n,c);i?.failure==null?(r.kind!==`LiteralExpressionSyntax`||r.value===null||n!==null&&!compatible(r,n))&&l.error(e.InvalidSpecificationStreamRoute,`A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.`,r.location):l.error(e.InvalidSpecificationStreamRoute,u(i.failure),r.location)};if(o&&(h.streamIdParts.length>0?d(h,t.streamIdParts,t.streamId!==null,t.location,e.InvalidSpecificationStreamRoute,l,validateLiteral):t.streamIdParts.length>0?l.error(e.InvalidSpecificationStreamRoute,`A streamId part block requires a composite stream.`,t.location):(h.streamId===null!=(t.streamId===null)&&l.error(e.InvalidSpecificationStreamRoute,h.streamId===null?`An unkeyed stream cannot take a streamId mapping.`:`This keyed stream requires a streamId mapping.`,t.location),t.streamId!==null&&validateLiteral(t.streamId,h.streamId))),m=f.identifier,m===null){let n=_.map(e=>e.type),r=new Set(n.filter(e=>e!==null).map(e=>`${e.name}:${e.isOptional}:${e.isCollection}`));n.length===0||n.some(e=>e===null)||r.size!==1?o&&l.error(e.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${f.name}'; the event's producers do not supply one unambiguous destination type.`,t.location):m=n[0]}let g=!1;if(a?.example?.stream!=null&&n.for!==null&&n.for===a.example.for){let e=y.resolve(a.example.stream.eventSource,a.example.stream.stream);if(e.kind===`unique`){let t=_.map(e=>e.type),r=new Set(t.filter(e=>e!==null).map(e=>`${e.name}:${e.isOptional}:${e.isCollection}`)),i=e.sources[0].identifier??(t.length>0&&!t.some(e=>e===null)&&r.size===1?t[0]:null);i!==null&&(g=n.for.kind!==`LiteralExpressionSyntax`||n.for.value===null||i.isCollection||i.isOptional||!compatible(n.for,i))}}r&&n.for===null?contextualError(e.InvalidSpecificationStreamEventSource,`A routed given or when append event requires 'for <literal>'.`,t.location):s&&!g&&n.for!==null&&(n.for.kind!==`LiteralExpressionSyntax`||n.for.value===null||m!==null&&(m.isCollection||m.isOptional||!compatible(n.for,m)))&&contextualError(e.InvalidSpecificationStreamEventSource,`A routed event's for value must be a concrete literal compatible with the source's identifier type.`,n.for.location)}if(!i||f===null||_.length===0||_.some(e=>e.command!==f))continue;let v=_.every(e=>{let t=e.route?.propertyCandidate===null?e.route:null,r=n.noStream==null?t==null||t.eventSource!==n.stream.eventSource||t.stream!==n.stream.stream:t!=null;if(!r&&n.stream!=null&&t!=null){let e=y.resolve(n.stream.eventSource,n.stream.stream),i=e.kind===`unique`?e.streams[0]:null;if(i!==null&&i.streamIdParts.length>0){if(t.streamId===null&&n.stream.streamId===null&&t.streamIdParts.length>0&&n.stream.streamIdParts.length>0)for(let e of i.streamIdParts){let i=t.streamIdParts.filter(t=>t.property===e.name),a=n.stream.streamIdParts.filter(t=>t.property===e.name);if(i.length!==1||a.length!==1)continue;let o=formatStreamId(i[0].source,e.type),s=formatStreamId(a[0].source,e.type);o!==null&&s!==null&&o!==s&&(r=!0)}}else if(i?.streamId!=null&&t.streamIdParts.length===0&&n.stream.streamIdParts.length===0){let e=formatStreamId(t.streamId?.source,i.streamId),a=formatStreamId(n.stream.streamId?.source,i.streamId);e!==null&&a!==null&&e!==a&&(r=!0)}}return r});n.for?.kind===`LiteralExpressionSyntax`&&_.every(e=>e.type!==null&&(m===null?!compatible(n.for,e.type):nominallyCompatible(e.type,m)===!1))&&(v=!0),v&&contextualError(e.SpecificationStreamContradictsCommand,`The expected event route contradicts its only producer, the command under test.`,(n.stream??n.noStream).location)}}}export{validateSpecificationStreams};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.js";import{diagnosticText as n}from"../Diagnostics/DiagnosticArgument.js";import{EventSourceCatalog as r}from"../Syntax/EventSourceCatalog.js";import{expandEffectiveSpecificationExamples as i,specificationExamples as a}from"./SpecificationCommandExamples.js";import{compatibleValue as o,uniqueByName as s}from"./ResponseValidator.js";import{commandDestinationType as c}from"./CommandDestinationTypes.js";import{LineReader as l}from"./LineReader.js";import{ParserContext as u}from"./ParserContext.js";import{streamIdFailureMessage as d}from"../Syntax/StreamIdFormatter.js";import{validateStreamIdParts as f}from"./CompositeStreamIdValidator.js";import{formatSpecificationStreamId as p}from"./SpecificationRouteComparison.js";import{formatStreamIdLiteral as m}from"./EventSourceValidator.js";function validateSpecificationStreams(n,r){let i=new t(n).slices.flatMap(({slice:e})=>e.specifications.flatMap(e=>e.cases??[]));if(i.length===0)return validateRoutes(n,r);let a=new u(new l([]));validateRoutes(n,a);let o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set;for(let t of a.diagnostics){let n=JSON.stringify([t.code,t.location.path,t.location.line,t.location.column,t.message]);if(s.has(n))continue;s.add(n);let a=t.code===e.InvalidSpecificationStreamRoute?i.find(e=>e.values.some(e=>e.source.location.line===t.location.line&&e.source.location.column===t.location.column&&e.source.location.path===t.location.path)):void 0;if(a===void 0)r.error(t.code,t.message,t.location,t.arguments);else{let e=JSON.stringify(t.location);o.has(e)||r.error(t.code,`Case '${a.name}': ${t.message}`,t.location,t.arguments),o.add(e)}}}function validateRoutes(l,u){let h=a(l).resolvedExamples,g=i(l);l=g.application;let _=new t(l),v=/* @__PURE__ */ new Set,y=h.flatMap(t=>{if(t.kind!==`event`)return(t.kind===`command`||t.kind===`readmodel`)&&(t.example.stream!=null||t.example.noStream!=null)&&u.error(e.InvalidSpecificationExampleBody,`only event examples carry routes; a command's route comes from its declaration, and read models have none`,(t.example.stream??t.example.noStream).location,n(`example`,t.example.name)),[];let r={kind:`SpecificationEventSyntax`,eventType:t.name,values:t.example.values,for:t.example.for,stream:t.example.stream,noStream:t.example.noStream,location:t.example.location};return v.add(r),[{scope:t.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[r],whenRedelivered:null}}]}),b=new r(l),x=s(l.concepts),S=s(l.types),C=new Map([...S].map(([e,t])=>[e,s(t.properties)])),compatible=(e,t)=>o(e,t,x,C),w=/* @__PURE__ */ new Set([`String`,`Uuid`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`,...x.keys(),...S.keys()]),nominallyCompatible=(e,t)=>w.has(e.name)&&w.has(t.name)?e.name===t.name&&e.isCollection===t.isCollection&&(!e.isOptional||t.isOptional):null,formatStreamId=(e,t)=>p(e,t,l),eventOf=(e,t)=>{let n=_.resolve(e,t).declaration;return n?.node.kind===`EventSyntax`?n.node:null},T=[];for(let{slice:e}of _.slices){for(let t of e.commands)for(let n of t.produces){if(!_.isEventProduction(n,e))continue;let r=eventOf(n.event,e);if(r===null)continue;let i=c(t,n,l,{resolver:_,slice:e});T.push({event:r,command:t,type:i,route:n.stream??t.stream})}for(let t of e.reactions.flatMap(e=>e.triggers).flatMap(e=>e.produces)){let n=eventOf(t.event,e);n!==null&&T.push({event:n,command:null,type:null})}for(let t of e.captures)for(let n of[...t.appends,...t.children.flatMap(e=>e.appends),...t.nested.flatMap(e=>e.appends)]){let t=eventOf(n.event,e);t!==null&&T.push({event:t,command:null,type:null})}}let E=[...y.flatMap(e=>_.slices.filter(t=>t.scope.join(`.`)===e.scope.join(`.`)).map(({slice:t,scope:n})=>({slice:t,scope:n,specification:e.specification}))),..._.slices.flatMap(({slice:e,scope:t})=>e.specifications.map(n=>({slice:e,scope:t,specification:n})))];for(let{slice:t,scope:n,specification:r}of E){let i=_.slices.flatMap(e=>e.slice.commands.map(t=>({command:t,scope:e.scope}))),a=r.when?.commandType.split(`.`)??[],o=a.slice(0,-1),s=i.filter(e=>e.command.name===a.at(-1)&&o.every((t,n)=>e.scope[e.scope.length-o.length+n]===t)),c=o.length>0&&s.length===1?s[0].command:null;for(let e=n.length;o.length===0&&e>=0&&c===null;e--){let t=s.filter(t=>n.slice(0,e).every((e,n)=>t.scope[n]===e));if(t.length>0){c=t.length===1?t[0].command:null;break}}let p=[...r.given.map(e=>({node:e,required:!0,expected:!1})),...r.whenAppended===null?[]:[{node:r.whenAppended,required:!0,expected:!1}],...r.thenEvents.map(e=>({node:e,required:!1,expected:!v.has(e)})),...r.whenRedelivered==null?[]:[{node:{...r.whenRedelivered,kind:`SpecificationEventSyntax`},required:!1,expected:!1}]];for(let{node:n,required:r,expected:i}of p){let a=g.specifications.flatMap(e=>e.steps).find(e=>e.effective===n),o=a?.route?.origin!==`example`,s=o||n.for!==a?.example?.for,contextualError=(e,t,n)=>{u.error(e,a?.example==null?t:`${t} Example '${a.example.name}' is used here.`,a?.example==null?n:a.authored.location)};if(n.stream==null&&n.noStream==null)continue;r&&n.noStream!=null&&contextualError(e.InvalidSpecificationStream,`Expected 'stream Source.Stream', or 'no stream' on a then event.`,n.noStream.location);let p=null,h=eventOf(n.eventType,t),_=T.filter(e=>e.event===h);if(n.stream!=null){let t=n.stream,i=b.resolve(t.eventSource,t.stream);if(i.kind!==`unique`){let n={ambiguous:`Ambiguous`,notFound:`NotFound`,wrongKind:`WrongKind`}[i.kind];o&&u.error(e.InvalidSpecificationStreamRoute,`Stream '${t.eventSource}.${t.stream}' is ${n}; routing requires one physical source and stream.`,t.location);continue}let c=i.sources[0],h=i.streams[0],validateLiteral=(t,n)=>{let r=t.source,i=m(r,n,l);i?.failure==null?(r.kind!==`LiteralExpressionSyntax`||r.value===null||n!==null&&!compatible(r,n))&&u.error(e.InvalidSpecificationStreamRoute,`A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.`,r.location):u.error(e.InvalidSpecificationStreamRoute,d(i.failure),r.location)};if(o&&(h.streamIdParts.length>0?f(h,t.streamIdParts,t.streamId!==null,t.location,e.InvalidSpecificationStreamRoute,u,validateLiteral):t.streamIdParts.length>0?u.error(e.InvalidSpecificationStreamRoute,`A streamId part block requires a composite stream.`,t.location):(h.streamId===null!=(t.streamId===null)&&u.error(e.InvalidSpecificationStreamRoute,h.streamId===null?`An unkeyed stream cannot take a streamId mapping.`:`This keyed stream requires a streamId mapping.`,t.location),t.streamId!==null&&validateLiteral(t.streamId,h.streamId))),p=c.identifier,p===null){let n=_.map(e=>e.type),r=new Set(n.filter(e=>e!==null).map(e=>`${e.name}:${e.isOptional}:${e.isCollection}`));n.length===0||n.some(e=>e===null)||r.size!==1?o&&u.error(e.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${c.name}'; the event's producers do not supply one unambiguous destination type.`,t.location):p=n[0]}let g=!1;if(a?.example?.stream!=null&&n.for!==null&&n.for===a.example.for){let e=b.resolve(a.example.stream.eventSource,a.example.stream.stream);if(e.kind===`unique`){let t=_.map(e=>e.type),r=new Set(t.filter(e=>e!==null).map(e=>`${e.name}:${e.isOptional}:${e.isCollection}`)),i=e.sources[0].identifier??(t.length>0&&!t.some(e=>e===null)&&r.size===1?t[0]:null);i!==null&&(g=n.for.kind!==`LiteralExpressionSyntax`||n.for.value===null||i.isCollection||i.isOptional||!compatible(n.for,i))}}r&&n.for===null?contextualError(e.InvalidSpecificationStreamEventSource,`A routed given or when append event requires 'for <literal>'.`,t.location):s&&!g&&n.for!==null&&(n.for.kind!==`LiteralExpressionSyntax`||n.for.value===null||p!==null&&(p.isCollection||p.isOptional||!compatible(n.for,p)))&&contextualError(e.InvalidSpecificationStreamEventSource,`A routed event's for value must be a concrete literal compatible with the source's identifier type.`,n.for.location)}if(!i||c===null||_.length===0||_.some(e=>e.command!==c))continue;let v=_.every(e=>{let t=e.route?.propertyCandidate===null?e.route:null,r=n.noStream==null?t==null||t.eventSource!==n.stream.eventSource||t.stream!==n.stream.stream:t!=null;if(!r&&n.stream!=null&&t!=null){let e=b.resolve(n.stream.eventSource,n.stream.stream),i=e.kind===`unique`?e.streams[0]:null;if(i!==null&&i.streamIdParts.length>0){if(t.streamId===null&&n.stream.streamId===null&&t.streamIdParts.length>0&&n.stream.streamIdParts.length>0)for(let e of i.streamIdParts){let i=t.streamIdParts.filter(t=>t.property===e.name),a=n.stream.streamIdParts.filter(t=>t.property===e.name);if(i.length!==1||a.length!==1)continue;let o=formatStreamId(i[0].source,e.type),s=formatStreamId(a[0].source,e.type);o!==null&&s!==null&&o!==s&&(r=!0)}}else if(i?.streamId!=null&&t.streamIdParts.length===0&&n.stream.streamIdParts.length===0){let e=formatStreamId(t.streamId?.source,i.streamId),a=formatStreamId(n.stream.streamId?.source,i.streamId);e!==null&&a!==null&&e!==a&&(r=!0)}}return r});n.for?.kind===`LiteralExpressionSyntax`&&_.every(e=>e.type!==null&&(p===null?!compatible(n.for,e.type):nominallyCompatible(e.type,p)===!1))&&(v=!0),v&&contextualError(e.SpecificationStreamContradictsCommand,`The expected event route contradicts its only producer, the command under test.`,(n.stream??n.noStream).location)}}}export{validateSpecificationStreams};
2
2
  //# sourceMappingURL=SpecificationStreamValidator.js.map