@cratis/screenplay-language 5.3.0 → 5.3.2

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 (395) hide show
  1. package/dist/bundles/TypeReferenceSymbol.js.map +1 -1
  2. package/dist/bundles/action-subject-authoring.js.map +1 -1
  3. package/dist/bundles/bmp-word-characters.js.map +1 -1
  4. package/dist/bundles/case-authoring.js +1 -1
  5. package/dist/bundles/case-authoring.js.map +1 -1
  6. package/dist/bundles/code-actions.js.map +1 -1
  7. package/dist/bundles/command-read-completions.js.map +1 -1
  8. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js +3 -3
  9. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js.map +1 -1
  10. package/dist/bundles/compiler/Authoring/QuickFixes.js +4 -4
  11. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
  12. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js +1 -1
  13. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js.map +1 -1
  14. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js +4 -4
  15. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js.map +1 -1
  16. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js +2 -2
  17. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js.map +1 -1
  18. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js +1 -1
  19. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js.map +1 -1
  20. package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js.map +1 -1
  21. package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js.map +1 -1
  22. package/dist/bundles/compiler/Dependencies/DependencyGraph.js +1 -1
  23. package/dist/bundles/compiler/Dependencies/DependencyGraph.js.map +1 -1
  24. package/dist/bundles/compiler/Dependencies/DependencyKind.js.map +1 -1
  25. package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js.map +1 -1
  26. package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
  27. package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js.map +1 -1
  28. package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js.map +1 -1
  29. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  30. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  31. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js +1 -1
  32. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js.map +1 -1
  33. package/dist/bundles/compiler/Diagnostics/SourceLocation.js.map +1 -1
  34. package/dist/bundles/compiler/Files/AuthoredOrder.js +1 -1
  35. package/dist/bundles/compiler/Files/AuthoredOrder.js.map +1 -1
  36. package/dist/bundles/compiler/Files/OrderingRoot.js +1 -1
  37. package/dist/bundles/compiler/Files/OrderingRoot.js.map +1 -1
  38. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js +1 -1
  39. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js.map +1 -1
  40. package/dist/bundles/compiler/Files/PlayDocumentSource.js.map +1 -1
  41. package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
  42. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
  43. package/dist/bundles/compiler/Files/PlayGlob.js +2 -1
  44. package/dist/bundles/compiler/Files/PlayGlob.js.map +1 -1
  45. package/dist/bundles/compiler/Files/PlayImports.js +1 -1
  46. package/dist/bundles/compiler/Files/PlayImports.js.map +1 -1
  47. package/dist/bundles/compiler/Files/PlayPlacement.js.map +1 -1
  48. package/dist/bundles/compiler/Files/TimelineOrder.js +1 -1
  49. package/dist/bundles/compiler/Files/TimelineOrder.js.map +1 -1
  50. package/dist/bundles/compiler/Generation/FiniteGenerationRules.js +1 -1
  51. package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js.map +1 -1
  52. package/dist/bundles/compiler/Generation/GenerationChecksum.js.map +1 -1
  53. package/dist/bundles/compiler/Generation/GenerationPattern.js +1 -1
  54. package/dist/bundles/compiler/Generation/GenerationPattern.js.map +1 -1
  55. package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js.map +1 -1
  56. package/dist/bundles/compiler/Generation/GenerationPatternParser.js.map +1 -1
  57. package/dist/bundles/compiler/Generation/GenerationPatternToken.js.map +1 -1
  58. package/dist/bundles/compiler/Generation/GenerationRuleProof.js +1 -1
  59. package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js.map +1 -1
  60. package/dist/bundles/compiler/Generation/RegexCharacters.js.map +1 -1
  61. package/dist/bundles/compiler/Generation/RegexExpression.js.map +1 -1
  62. package/dist/bundles/compiler/Generation/RuleConsistency.js +1 -1
  63. package/dist/bundles/compiler/Parsing/ActionSubjectClause.js.map +1 -1
  64. package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js.map +1 -1
  65. package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js.map +1 -1
  66. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js +1 -1
  67. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js.map +1 -1
  68. package/dist/bundles/compiler/Parsing/AuthorizeParser.js +1 -1
  69. package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -1
  70. package/dist/bundles/compiler/Parsing/CanvasPlacement.js.map +1 -1
  71. package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js.map +1 -1
  72. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  73. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
  74. package/dist/bundles/compiler/Parsing/ClockOperandParser.js.map +1 -1
  75. package/dist/bundles/compiler/Parsing/CodeBlockParser.js.map +1 -1
  76. package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js.map +1 -1
  77. package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js.map +1 -1
  78. package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
  79. package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
  80. package/dist/bundles/compiler/Parsing/CommandReadSources.js.map +1 -1
  81. package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
  82. package/dist/bundles/compiler/Parsing/CommandResponseParser.js.map +1 -1
  83. package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js.map +1 -1
  84. package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js.map +1 -1
  85. package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
  86. package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -1
  87. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
  88. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
  89. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js +2 -0
  90. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js.map +1 -0
  91. package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
  92. package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -1
  93. package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
  94. package/dist/bundles/compiler/Parsing/ConstraintParser.js.map +1 -1
  95. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js +1 -1
  96. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js.map +1 -1
  97. package/dist/bundles/compiler/Parsing/ContinuationValues.js.map +1 -1
  98. package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
  99. package/dist/bundles/compiler/Parsing/DeclarationParsers.js.map +1 -1
  100. package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
  101. package/dist/bundles/compiler/Parsing/DependencySourceParser.js.map +1 -1
  102. package/dist/bundles/compiler/Parsing/DependsOnParser.js.map +1 -1
  103. package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
  104. package/dist/bundles/compiler/Parsing/DescriptionParser.js.map +1 -1
  105. package/dist/bundles/compiler/Parsing/DocumentationParser.js +1 -1
  106. package/dist/bundles/compiler/Parsing/DocumentationParser.js.map +1 -1
  107. package/dist/bundles/compiler/Parsing/EnumerationMembers.js +1 -1
  108. package/dist/bundles/compiler/Parsing/EnumerationMembers.js.map +1 -1
  109. package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
  110. package/dist/bundles/compiler/Parsing/EventMetadataParser.js.map +1 -1
  111. package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
  112. package/dist/bundles/compiler/Parsing/EventSourceParser.js.map +1 -1
  113. package/dist/bundles/compiler/Parsing/EventSourceValidator.js +1 -1
  114. package/dist/bundles/compiler/Parsing/EventSourceValidator.js.map +1 -1
  115. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js +1 -1
  116. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js.map +1 -1
  117. package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
  118. package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -1
  119. package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
  120. package/dist/bundles/compiler/Parsing/FeatureBody.js.map +1 -1
  121. package/dist/bundles/compiler/Parsing/FileImportParser.js.map +1 -1
  122. package/dist/bundles/compiler/Parsing/FileReferences.js.map +1 -1
  123. package/dist/bundles/compiler/Parsing/FoldedEventSources.js.map +1 -1
  124. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js +1 -1
  125. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js.map +1 -1
  126. package/dist/bundles/compiler/Parsing/GenerationParser.js +1 -1
  127. package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -1
  128. package/dist/bundles/compiler/Parsing/GuardedActionInputs.js.map +1 -1
  129. package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
  130. package/dist/bundles/compiler/Parsing/GuardedActionParser.js.map +1 -1
  131. package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js.map +1 -1
  132. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +1 -1
  133. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -1
  134. package/dist/bundles/compiler/Parsing/GuardedInteractions.js +1 -1
  135. package/dist/bundles/compiler/Parsing/GuardedInteractions.js.map +1 -1
  136. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js +1 -1
  137. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js.map +1 -1
  138. package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
  139. package/dist/bundles/compiler/Parsing/IdentityParser.js.map +1 -1
  140. package/dist/bundles/compiler/Parsing/IdentityValidator.js.map +1 -1
  141. package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
  142. package/dist/bundles/compiler/Parsing/ImplementationParser.js.map +1 -1
  143. package/dist/bundles/compiler/Parsing/ImportDiscovery.js +1 -1
  144. package/dist/bundles/compiler/Parsing/ImportDiscovery.js.map +1 -1
  145. package/dist/bundles/compiler/Parsing/InlineEventValidator.js.map +1 -1
  146. package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
  147. package/dist/bundles/compiler/Parsing/InputUses.js.map +1 -1
  148. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
  149. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js.map +1 -1
  150. package/dist/bundles/compiler/Parsing/InteractionExecutions.js +1 -1
  151. package/dist/bundles/compiler/Parsing/InteractionExecutions.js.map +1 -1
  152. package/dist/bundles/compiler/Parsing/LegacyTextRulePatterns.js.map +1 -1
  153. package/dist/bundles/compiler/Parsing/LineReader.js.map +1 -1
  154. package/dist/bundles/compiler/Parsing/LineText.js.map +1 -1
  155. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js +1 -1
  156. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js.map +1 -1
  157. package/dist/bundles/compiler/Parsing/MatchAmbiguityCharacters.js.map +1 -1
  158. package/dist/bundles/compiler/Parsing/MatchAmbiguityGraph.js.map +1 -1
  159. package/dist/bundles/compiler/Parsing/MatchAmbiguityParser.js.map +1 -1
  160. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js +1 -1
  161. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js.map +1 -1
  162. package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
  163. package/dist/bundles/compiler/Parsing/ModuleBody.js.map +1 -1
  164. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js +1 -1
  165. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js.map +1 -1
  166. package/dist/bundles/compiler/Parsing/ObserverFilterValidator.js.map +1 -1
  167. package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
  168. package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -1
  169. package/dist/bundles/compiler/Parsing/OperationValidator.js +1 -1
  170. package/dist/bundles/compiler/Parsing/OperationValidator.js.map +1 -1
  171. package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -1
  172. package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js.map +1 -1
  173. package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
  174. package/dist/bundles/compiler/Parsing/PolicyParser.js.map +1 -1
  175. package/dist/bundles/compiler/Parsing/PortableMatchGroupName.js.map +1 -1
  176. package/dist/bundles/compiler/Parsing/PortableMatchPattern.js.map +1 -1
  177. package/dist/bundles/compiler/Parsing/PortableMatchSuggestions.js.map +1 -1
  178. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js +1 -1
  179. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js.map +1 -1
  180. package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
  181. package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
  182. package/dist/bundles/compiler/Parsing/ProjectionEventScopeValidator.js.map +1 -1
  183. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js +1 -1
  184. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js.map +1 -1
  185. package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
  186. package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
  187. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +1 -1
  188. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -1
  189. package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
  190. package/dist/bundles/compiler/Parsing/PropertyLineParser.js.map +1 -1
  191. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js +1 -1
  192. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js.map +1 -1
  193. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js +1 -1
  194. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js.map +1 -1
  195. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +1 -1
  196. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -1
  197. package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
  198. package/dist/bundles/compiler/Parsing/PurposeParser.js.map +1 -1
  199. package/dist/bundles/compiler/Parsing/PurposeValidator.js.map +1 -1
  200. package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
  201. package/dist/bundles/compiler/Parsing/QueryParser.js.map +1 -1
  202. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
  203. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js.map +1 -1
  204. package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
  205. package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
  206. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js +1 -1
  207. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js.map +1 -1
  208. package/dist/bundles/compiler/Parsing/ReadModelKeyValidator.js.map +1 -1
  209. package/dist/bundles/compiler/Parsing/ReadModelMemberTypeValidator.js.map +1 -1
  210. package/dist/bundles/compiler/Parsing/ReadsParser.js +1 -1
  211. package/dist/bundles/compiler/Parsing/ReadsParser.js.map +1 -1
  212. package/dist/bundles/compiler/Parsing/RedeliveryValues.js.map +1 -1
  213. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js +1 -1
  214. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js.map +1 -1
  215. package/dist/bundles/compiler/Parsing/RefusalValueWalker.js.map +1 -1
  216. package/dist/bundles/compiler/Parsing/ResponseCommandResolver.js.map +1 -1
  217. package/dist/bundles/compiler/Parsing/ResponseDateValues.js.map +1 -1
  218. package/dist/bundles/compiler/Parsing/ResponseValidator.js +1 -1
  219. package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -1
  220. package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
  221. package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
  222. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  223. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  224. package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
  225. package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -1
  226. package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
  227. package/dist/bundles/compiler/Parsing/SliceParser.js.map +1 -1
  228. package/dist/bundles/compiler/Parsing/SourceLine.js.map +1 -1
  229. package/dist/bundles/compiler/Parsing/SourceLineSplitter.js.map +1 -1
  230. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
  231. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js.map +1 -1
  232. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
  233. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
  234. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
  235. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
  236. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +1 -1
  237. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -1
  238. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
  239. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
  240. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  241. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
  242. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js +1 -1
  243. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js.map +1 -1
  244. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
  245. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
  246. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js +1 -1
  247. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js.map +1 -1
  248. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +1 -1
  249. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -1
  250. package/dist/bundles/compiler/Parsing/StateMachineParser.js +1 -1
  251. package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -1
  252. package/dist/bundles/compiler/Parsing/StructuralInteractionSites.js.map +1 -1
  253. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js +1 -1
  254. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js.map +1 -1
  255. package/dist/bundles/compiler/Parsing/StructuredValueParser.js.map +1 -1
  256. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js +1 -1
  257. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js.map +1 -1
  258. package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
  259. package/dist/bundles/compiler/Parsing/TriggerDataParser.js.map +1 -1
  260. package/dist/bundles/compiler/Parsing/UiBindingParser.js +1 -1
  261. package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -1
  262. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js +1 -1
  263. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js.map +1 -1
  264. package/dist/bundles/compiler/Parsing/WorkflowParser.js +1 -1
  265. package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -1
  266. package/dist/bundles/compiler/Parsing/checkPortableMatchPattern.js.map +1 -1
  267. package/dist/bundles/compiler/Parsing/hasExponentialMatchAmbiguity.js.map +1 -1
  268. package/dist/bundles/compiler/Parsing/trimMatchAmbiguityGraph.js.map +1 -1
  269. package/dist/bundles/compiler/ScreenActionSubjects.js.map +1 -1
  270. package/dist/bundles/compiler/ScreenplayCompiler.js +1 -1
  271. package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -1
  272. package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js.map +1 -1
  273. package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js.map +1 -1
  274. package/dist/bundles/compiler/Syntax/CaptureEventsSource.js.map +1 -1
  275. package/dist/bundles/compiler/Syntax/DependencySources.js.map +1 -1
  276. package/dist/bundles/compiler/Syntax/EventDeclarations.js.map +1 -1
  277. package/dist/bundles/compiler/Syntax/EventSourceCatalog.js.map +1 -1
  278. package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js.map +1 -1
  279. package/dist/bundles/compiler/Syntax/ExactMathFacts.js.map +1 -1
  280. package/dist/bundles/compiler/Syntax/ExactNumber.js.map +1 -1
  281. package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js.map +1 -1
  282. package/dist/bundles/compiler/Syntax/LegacyWireProjection.js.map +1 -1
  283. package/dist/bundles/compiler/Syntax/Operations.js.map +1 -1
  284. package/dist/bundles/compiler/Syntax/PersonaCallers.js.map +1 -1
  285. package/dist/bundles/compiler/Syntax/ProductionDestinations.js.map +1 -1
  286. package/dist/bundles/compiler/Syntax/PublicEventInvariants.js.map +1 -1
  287. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  288. package/dist/bundles/compiler/Syntax/SourceOptions.js.map +1 -1
  289. package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js.map +1 -1
  290. package/dist/bundles/compiler/Syntax/StreamIdFormatter.js.map +1 -1
  291. package/dist/bundles/compiler/Syntax/StrictSyntaxJson.js +1 -1
  292. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
  293. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  294. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
  295. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
  296. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  297. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  298. package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js.map +1 -1
  299. package/dist/bundles/compiler/Syntax/index.js +1 -1
  300. package/dist/bundles/compiler/Text/ImplementationHintText.js.map +1 -1
  301. package/dist/bundles/compiler/Text/ReservedWords.js.map +1 -1
  302. package/dist/bundles/compiler/Text/SourceStreamNames.js.map +1 -1
  303. package/dist/bundles/compiler/Text/StringLiteral.js.map +1 -1
  304. package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js.map +1 -1
  305. package/dist/bundles/compiler/Text/patterns.js.map +1 -1
  306. package/dist/bundles/compiler/index.js +1 -1
  307. package/dist/bundles/completion-items.js +4 -4
  308. package/dist/bundles/completion-items.js.map +1 -1
  309. package/dist/bundles/completion-planner.js +2 -2
  310. package/dist/bundles/completion-planner.js.map +1 -1
  311. package/dist/bundles/completions.js +1 -1
  312. package/dist/bundles/completions.js.map +1 -1
  313. package/dist/bundles/continuation-responses.js +1 -1
  314. package/dist/bundles/continuation-responses.js.map +1 -1
  315. package/dist/bundles/declarations.js.map +1 -1
  316. package/dist/bundles/dependency-completions.js.map +1 -1
  317. package/dist/bundles/dependency-target-analysis.js.map +1 -1
  318. package/dist/bundles/diagnostic-codes.js +1 -1
  319. package/dist/bundles/diagnostic-codes.js.map +1 -1
  320. package/dist/bundles/diagnostics.js +1 -1
  321. package/dist/bundles/diagnostics.js.map +1 -1
  322. package/dist/bundles/document-context.js.map +1 -1
  323. package/dist/bundles/documentation-item.js.map +1 -1
  324. package/dist/bundles/event-analysis-source.js.map +1 -1
  325. package/dist/bundles/event-context-catalog.js.map +1 -1
  326. package/dist/bundles/event-context.js.map +1 -1
  327. package/dist/bundles/event-source-authoring.js +11 -11
  328. package/dist/bundles/event-source-authoring.js.map +1 -1
  329. package/dist/bundles/example-analysis.js +2 -2
  330. package/dist/bundles/example-analysis.js.map +1 -1
  331. package/dist/bundles/example-authoring.js +2 -2
  332. package/dist/bundles/example-authoring.js.map +1 -1
  333. package/dist/bundles/example-declaration-items.js.map +1 -1
  334. package/dist/bundles/example-values.js.map +1 -1
  335. package/dist/bundles/file-imports.js.map +1 -1
  336. package/dist/bundles/file-references.js.map +1 -1
  337. package/dist/bundles/generation-completions.js.map +1 -1
  338. package/dist/bundles/hover-content.js +5 -5
  339. package/dist/bundles/hover-content.js.map +1 -1
  340. package/dist/bundles/hover.js.map +1 -1
  341. package/dist/bundles/index.js +1 -1
  342. package/dist/bundles/index.js.map +1 -1
  343. package/dist/bundles/inlay-hints.js.map +1 -1
  344. package/dist/bundles/inline-completions.js +1 -1
  345. package/dist/bundles/inline-completions.js.map +1 -1
  346. package/dist/bundles/inline-event-validation.js +1 -1
  347. package/dist/bundles/inline-event-validation.js.map +1 -1
  348. package/dist/bundles/keyword-docs.js.map +1 -1
  349. package/dist/bundles/language.js.map +1 -1
  350. package/dist/bundles/named-rule-context.js.map +1 -1
  351. package/dist/bundles/operation-authoring.js +6 -6
  352. package/dist/bundles/operation-authoring.js.map +1 -1
  353. package/dist/bundles/persona-analysis.js +1 -1
  354. package/dist/bundles/persona-analysis.js.map +1 -1
  355. package/dist/bundles/production-destinations.js +1 -1
  356. package/dist/bundles/production-destinations.js.map +1 -1
  357. package/dist/bundles/purpose-items.js.map +1 -1
  358. package/dist/bundles/reaction-authoring.js +3 -3
  359. package/dist/bundles/reaction-authoring.js.map +1 -1
  360. package/dist/bundles/read-model-key-completions.js +1 -1
  361. package/dist/bundles/read-model-key-completions.js.map +1 -1
  362. package/dist/bundles/refusal-context.js.map +1 -1
  363. package/dist/bundles/response-analysis.js.map +1 -1
  364. package/dist/bundles/response-completions.js +1 -1
  365. package/dist/bundles/response-completions.js.map +1 -1
  366. package/dist/bundles/response-tokens.js +2 -2
  367. package/dist/bundles/response-tokens.js.map +1 -1
  368. package/dist/bundles/scope-items.js +3 -3
  369. package/dist/bundles/scope-items.js.map +1 -1
  370. package/dist/bundles/structure-completions.js.map +1 -1
  371. package/dist/bundles/sub-language-registry.js.map +1 -1
  372. package/dist/bundles/sub-languages/capture/CompletionProvider.js.map +1 -1
  373. package/dist/bundles/sub-languages/capture/HoverProvider.js.map +1 -1
  374. package/dist/bundles/sub-languages/capture/Validator.js.map +1 -1
  375. package/dist/bundles/sub-languages/capture/index.js.map +1 -1
  376. package/dist/bundles/sub-languages/capture/language.js.map +1 -1
  377. package/dist/bundles/sub-languages/cdl.js.map +1 -1
  378. package/dist/bundles/sub-languages/pdl.js.map +1 -1
  379. package/dist/bundles/sub-languages/projection/CodeActionProvider.js.map +1 -1
  380. package/dist/bundles/sub-languages/projection/CompletionProvider.js +1 -1
  381. package/dist/bundles/sub-languages/projection/CompletionProvider.js.map +1 -1
  382. package/dist/bundles/sub-languages/projection/HoverProvider.js.map +1 -1
  383. package/dist/bundles/sub-languages/projection/Validator.js.map +1 -1
  384. package/dist/bundles/sub-languages/projection/index.js.map +1 -1
  385. package/dist/bundles/sub-languages/projection/language.js.map +1 -1
  386. package/dist/bundles/symbols.js +2 -2
  387. package/dist/bundles/symbols.js.map +1 -1
  388. package/dist/bundles/themes/screenplay-dark.js.map +1 -1
  389. package/dist/bundles/themes/screenplay-light.js.map +1 -1
  390. package/dist/bundles/tokens.js.map +1 -1
  391. package/dist/bundles/validation.js +2 -2
  392. package/dist/bundles/validation.js.map +1 -1
  393. package/dist/diagnostic-codes.d.ts +1 -0
  394. package/dist/diagnostic-codes.d.ts.map +1 -1
  395. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"SpecificationCaseParser.js","names":["caseHeader","pattern","assignment","reference","text","context","DiagnosticCodes","location","parseMappingSource","nativeIdentifiers","match","offset","line","property","parseProperty","locationOf","child","values","inlinePropertyColumn","owner","valueLocation","diagnosticText","source","parseConcrete","value","structured","tryParseStructuredMapping","nested","parameters","specification","cases","index","prior","parameter","row","references","copies","result","item","key"],"sources":["../../../../../../Compiler/Parsing/SpecificationCaseParser.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 { CaseValueExpressionSyntax, ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationCaseSyntax, SpecificationParameterSyntax, SpecificationSyntax } from '../Syntax/Specifications';\nimport { pattern } from '../Text/patterns';\nimport { parseMappingSource } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\nimport { parseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseConcrete } from './SpecificationResponseParser';\nimport { tryParseStructuredMapping } from './StructuredBlockParser';\n\n// No 'd' (hasIndices) flag: another extension in the shared VS Code extension host can patch RegExp and fail on it.\nconst caseHeader = pattern('^case\\\\s+([A-Za-z_]\\\\w*)(?:\\\\s+(?<property>[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(?<value>.+))?$');\nconst assignment = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst reference = pattern('^case\\\\.([a-z_]\\\\w*)$');\n\nexport function containsCaseReference(text: string): boolean {\n return /\\bcase\\.[a-z_]\\w*/.test(text.replace(/\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*'/g, ''));\n}\n\nexport function parseSpecificationValue(text: string, location: SourceLocation, context: ParserContext, nativeIdentifiers = false): ExpressionSyntax {\n if (!text.startsWith('case.')) {\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 return parseMappingSource(text, location, context, nativeIdentifiers);\n }\n const match = reference.exec(text);\n if (match === null) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, \"A case reference fills a whole value position: 'case.<parameter>'.\", location);\n return { kind: 'CaseValueExpressionSyntax', parameter: match?.[1] ?? text.substring(5), location };\n}\n\nexport function parseParameter(context: ParserContext, line: SourceLine): SpecificationParameterSyntax | null {\n const offset = line.content.indexOf(' ') + 1;\n const property = offset > 0 ? parseProperty(context, { ...line, content: line.content.substring(offset), indent: line.indent + offset }) : undefined;\n if (property === undefined || property.isGenerated || property.isIdentifier) {\n context.error(DiagnosticCodes.InvalidSpecificationParameter, \"Expected 'parameter <name> <Type>', with optional collection and optional modifiers.\", locationOf(line));\n context.skipOpaqueBlock(line.indent);\n return null;\n }\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationParameter, 'A parameter has no body or default.', locationOf(child));\n context.skipOpaqueBlock(line.indent);\n }\n return { kind: 'SpecificationParameterSyntax', name: property.name, type: property.type, location: locationOf(line) };\n}\n\nexport function parseCase(context: ParserContext, line: SourceLine): SpecificationCaseSyntax | null {\n const match = caseHeader.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationCase, \"Expected 'case <Name>' with at most one inline parameter assignment.\", locationOf(line));\n context.skipOpaqueBlock(line.indent);\n return null;\n }\n const values: PropertyMappingSyntax[] = [];\n const inlinePropertyColumn = line.content.indexOf(match.groups?.property ?? '', line.content.indexOf(match[1], 'case'.length) + match[1].length);\n const add = (property: string, text: string, owner: SourceLine) => {\n const location = locationOf(owner);\n const valueLocation = { ...location, column: location.column + owner.content.indexOf(text, owner.content.indexOf('=') + 1) };\n if (text.startsWith('case.')) {\n context.error(DiagnosticCodes.InvalidSpecificationCaseValue, 'A case assigns concrete values, not case references.', valueLocation, diagnosticText('text', text));\n return;\n }\n const source = parseConcrete(context, text, valueLocation, DiagnosticCodes.InvalidSpecificationCaseValue);\n if (source !== null) values.push({ kind: 'PropertyMappingSyntax', property, source, location: owner === line ? { ...location, column: location.column + inlinePropertyColumn } : location });\n };\n if (match.groups?.property !== undefined) add(match.groups.property, match.groups.value, line);\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const value = assignment.exec(child.content);\n const structured = value === null ? tryParseStructuredMapping(context, child) : undefined;\n if (structured !== undefined) {\n values.push(structured);\n continue;\n }\n if (value === null) {\n context.error(DiagnosticCodes.InvalidSpecificationCaseAssignment, \"Expected '<parameter> = <concrete value>' in a case.\", locationOf(child));\n context.skipOpaqueBlock(child.indent);\n continue;\n }\n add(value[1], value[2], child);\n const nested = context.peekChild(child.indent);\n if (nested !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationCaseValue, 'A case value must fit on one line.', locationOf(nested), { ...diagnosticText('case', match[1]), ...diagnosticText('parameter', value[1]), ...diagnosticText('text', nested.content) });\n context.skipOpaqueBlock(child.indent);\n }\n }\n return { kind: 'SpecificationCaseSyntax', name: match[1], values, location: locationOf(line) };\n}\n\nexport function caseReferences(value: unknown): CaseValueExpressionSyntax[] {\n if (Array.isArray(value)) return value.flatMap(caseReferences);\n if (value === null || typeof value !== 'object') return [];\n if ('kind' in value && value.kind === 'CaseValueExpressionSyntax') return [value as CaseValueExpressionSyntax];\n return Object.values(value).flatMap(caseReferences);\n}\n\nexport function validateTable(specification: SpecificationSyntax, context: ParserContext): void {\n const parameters = specification.parameters ?? [];\n const cases = specification.cases ?? [];\n if ((parameters.length === 0) !== (cases.length === 0)) context.error(DiagnosticCodes.IncompleteSpecificationTable, 'A specification table requires parameters and at least one case.', specification.location);\n parameters.forEach((parameter, index) => {\n if (parameters.slice(0, index).some(prior => prior.name === parameter.name)) context.error(DiagnosticCodes.DuplicateSpecificationParameter, `Parameter '${parameter.name}' is declared more than once.`, parameter.location);\n });\n cases.forEach((row, index) => {\n if (cases.slice(0, index).some(prior => prior.name === row.name)) context.error(DiagnosticCodes.DuplicateSpecificationCase, `Case '${row.name}' is declared more than once.`, row.location);\n for (const value of row.values.filter(value => !parameters.some(parameter => parameter.name === value.property))) context.error(DiagnosticCodes.InvalidSpecificationCaseAssignment, `Case '${row.name}' assigns undeclared parameter '${value.property}'.`, value.location);\n for (const parameter of parameters.filter(parameter => row.values.filter(value => value.property === parameter.name).length !== 1)) context.error(DiagnosticCodes.InvalidSpecificationCaseAssignment, `Case '${row.name}' must assign parameter '${parameter.name}' exactly once.`, row.location);\n });\n const references = caseReferences(specification);\n for (const value of references) {\n if (cases.length === 0 || !parameters.some(parameter => parameter.name === value.parameter)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, `Case reference '${value.parameter}' requires a declared parameter in a specification table.`, value.location);\n }\n for (const parameter of parameters.filter(parameter => !references.some(value => value.parameter === parameter.name))) context.warning(DiagnosticCodes.UnusedSpecificationParameter, `Parameter '${parameter.name}' is never referenced.`, parameter.location);\n for (const value of caseReferences(specification.whenRedelivered)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'Case references are not permitted in redelivery locators.', value.location);\n}\n\nexport function substituteCase<T>(value: T, row: SpecificationCaseSyntax, copies = new WeakMap<object, unknown>()): T {\n if (value !== null && typeof value === 'object' && copies.has(value)) return copies.get(value) as T;\n if (Array.isArray(value)) {\n const result = value.map(item => substituteCase(item, row, copies));\n copies.set(value, result);\n return result as T;\n }\n if (value === null || typeof value !== 'object' || !('kind' in value)) return value;\n if (value.kind === 'CaseValueExpressionSyntax') {\n const parameter = (value as unknown as CaseValueExpressionSyntax).parameter;\n return (row.values.find(value => value.property === parameter)?.source ?? value) as T;\n }\n const result = Object.fromEntries(Object.entries(value).map(([key, item]) => [key, substituteCase(item, row, copies)]));\n if (value.kind === 'SpecificationErrorSyntax' && 'caseValue' in value && value.caseValue !== undefined) {\n const source = result.caseValue as ExpressionSyntax;\n result.name = source.kind === 'LiteralExpressionSyntax' ? source.value : null;\n delete result.caseValue;\n }\n copies.set(value, result);\n return result as T;\n}\n"],"mappings":"qhBAiBA,MAAMA,EAAaC,EAAQ,oFAAoF,EACzGC,EAAaD,EAAQ,iCAAiC,EACtDE,EAAYF,EAAQ,uBAAuB,EAEjD,SAAgB,sBAAsB,EAAuB,CACzD,MAAO,oBAAoB,KAAKG,EAAK,QAAQ,uCAAwC,EAAE,CAAC,CAC5F,CAEA,SAAgB,wBAAwB,EAAc,EAA0B,EAAwB,EAAoB,GAAyB,CACjJ,GAAI,CAACA,EAAK,WAAW,OAAO,EAExB,OADI,sBAAsBA,CAAI,GAAGC,EAAQ,MAAMC,EAAgB,kCAAmC,0GAA2GC,CAAQ,EAC9MC,EAAmBJ,EAAMG,EAAUF,EAASI,CAAiB,EAExE,IAAMC,EAAQP,EAAU,KAAKC,CAAI,EAEjC,OADIM,IAAU,MAAML,EAAQ,MAAMC,EAAgB,kCAAmC,qEAAsEC,CAAQ,EAC5J,CAAE,KAAM,4BAA6B,UAAWG,IAAQ,IAAMN,EAAK,UAAU,CAAC,EAAG,UAAS,CACrG,CAEA,SAAgB,eAAe,EAAwB,EAAuD,CAC1G,IAAMO,EAASC,EAAK,QAAQ,QAAQ,GAAG,EAAI,EACrCC,EAAWF,EAAS,EAAIG,EAAcT,EAAS,CAAE,GAAGO,EAAM,QAASA,EAAK,QAAQ,UAAUD,CAAM,EAAG,OAAQC,EAAK,OAASD,CAAO,CAAC,EAAI,IAAA,GAC3I,GAAIE,IAAa,IAAA,IAAaA,EAAS,aAAeA,EAAS,aAG3D,OAFAR,EAAQ,MAAMC,EAAgB,8BAA+B,uFAAwFS,EAAWH,CAAI,CAAC,EACrKP,EAAQ,gBAAgBO,EAAK,MAAM,EAC5B,KAEX,IAAMI,EAAQX,EAAQ,UAAUO,EAAK,MAAM,EAK3C,OAJII,IAAU,IAAA,KACVX,EAAQ,MAAMC,EAAgB,8BAA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EAAG5B,EAAQ,QAAQC,EAAgB,6BAA8B,cAAc2B,EAAU,KAAK,wBAAyBA,EAAU,QAAQ,EAC7P,IAAK,IAAMT,KAAS,eAAeK,EAAc,eAAe,EAAGxB,EAAQ,MAAMC,EAAgB,kCAAmC,4DAA6DkB,EAAM,QAAQ,CACnN,CAEA,SAAgB,eAAkB,EAAU,EAA8B,kBAAS,IAAI,QAA+B,CAClH,GAAsB,OAAOA,GAAU,UAAnCA,GAA+CY,EAAO,IAAIZ,CAAK,EAAG,OAAOY,EAAO,IAAIZ,CAAK,EAC7F,GAAI,MAAM,QAAQA,CAAK,EAAG,CACtB,IAAMa,EAASb,EAAM,IAAI,GAAQ,eAAec,EAAMJ,EAAKE,CAAM,CAAC,EAElE,OADAA,EAAO,IAAIZ,EAAOa,CAAM,EACjBA,CACX,CACA,GAAsB,OAAOb,GAAU,WAAnCA,GAA+C,EAAE,SAAUA,GAAQ,OAAOA,EAC9E,GAAIA,EAAM,OAAS,4BAA6B,CAC5C,IAAMS,EAAaT,EAA+C,UAClE,OAAQU,EAAI,OAAO,KAAK,GAASV,EAAM,WAAaS,CAAS,CAAC,EAAE,QAAUT,CAC9E,CACA,IAAMa,EAAS,OAAO,YAAY,OAAO,QAAQb,CAAK,CAAC,CAAC,KAAK,CAACe,EAAKD,KAAU,CAACC,EAAK,eAAeD,EAAMJ,EAAKE,CAAM,CAAC,CAAC,CAAC,EACtH,GAAIZ,EAAM,OAAS,4BAA8B,cAAeA,GAASA,EAAM,YAAc,IAAA,GAAW,CACpG,IAAMF,EAASe,EAAO,UACtB,EAAO,KAAOf,EAAO,OAAS,0BAA4BA,EAAO,MAAQ,KACzE,OAAOe,EAAO,SAClB,CAEA,OADAD,EAAO,IAAIZ,EAAOa,CAAM,EACjBA,CACX"}
1
+ {"version":3,"file":"SpecificationCaseParser.js","names":["caseHeader","pattern","assignment","reference","text","context","DiagnosticCodes","location","parseMappingSource","nativeIdentifiers","match","offset","line","property","parseProperty","locationOf","child","values","inlinePropertyColumn","owner","valueLocation","diagnosticText","source","parseConcrete","value","structured","tryParseStructuredMapping","nested","parameters","specification","cases","index","prior","parameter","row","references","copies","result","item","key"],"sources":["../../../../../../Compiler/Parsing/SpecificationCaseParser.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 { CaseValueExpressionSyntax, ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationCaseSyntax, SpecificationParameterSyntax, SpecificationSyntax } from '../Syntax/Specifications';\nimport { pattern } from '../Text/patterns';\nimport { parseMappingSource } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\nimport { parseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseConcrete } from './SpecificationResponseParser';\nimport { tryParseStructuredMapping } from './StructuredBlockParser';\n\n// No 'd' (hasIndices) flag: another extension in the shared VS Code extension host can patch RegExp and fail on it.\nconst caseHeader = pattern('^case\\\\s+([A-Za-z_]\\\\w*)(?:\\\\s+(?<property>[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(?<value>.+))?$');\nconst assignment = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst reference = pattern('^case\\\\.([a-z_]\\\\w*)$');\n\nexport function containsCaseReference(text: string): boolean {\n return /\\bcase\\.[a-z_]\\w*/.test(text.replace(/\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*'/g, ''));\n}\n\nexport function parseSpecificationValue(text: string, location: SourceLocation, context: ParserContext, nativeIdentifiers = false): ExpressionSyntax {\n if (!text.startsWith('case.')) {\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 return parseMappingSource(text, location, context, nativeIdentifiers);\n }\n const match = reference.exec(text);\n if (match === null) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, \"A case reference fills a whole value position: 'case.<parameter>'.\", location);\n return { kind: 'CaseValueExpressionSyntax', parameter: match?.[1] ?? text.substring(5), location };\n}\n\nexport function parseParameter(context: ParserContext, line: SourceLine): SpecificationParameterSyntax | null {\n const offset = line.content.indexOf(' ') + 1;\n const property = offset > 0 ? parseProperty(context, { ...line, content: line.content.substring(offset), indent: line.indent + offset }) : undefined;\n if (property === undefined || property.isGenerated || property.isIdentifier) {\n context.error(DiagnosticCodes.InvalidSpecificationParameter, \"Expected 'parameter <name> <Type>', with optional collection and optional modifiers.\", locationOf(line));\n context.skipOpaqueBlock(line.indent);\n return null;\n }\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationParameter, 'A parameter has no body or default.', locationOf(child));\n context.skipOpaqueBlock(line.indent);\n }\n return { kind: 'SpecificationParameterSyntax', name: property.name, type: property.type, location: locationOf(line) };\n}\n\nexport function parseCase(context: ParserContext, line: SourceLine): SpecificationCaseSyntax | null {\n const match = caseHeader.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationCase, \"Expected 'case <Name>' with at most one inline parameter assignment.\", locationOf(line));\n context.skipOpaqueBlock(line.indent);\n return null;\n }\n const values: PropertyMappingSyntax[] = [];\n const inlinePropertyColumn = line.content.indexOf(match.groups?.property ?? '', line.content.indexOf(match[1], 'case'.length) + match[1].length);\n const add = (property: string, text: string, owner: SourceLine) => {\n const location = locationOf(owner);\n const valueLocation = { ...location, column: location.column + owner.content.indexOf(text, owner.content.indexOf('=') + 1) };\n if (text.startsWith('case.')) {\n context.error(DiagnosticCodes.InvalidSpecificationCaseValue, 'A case assigns concrete values, not case references.', valueLocation, diagnosticText('text', text));\n return;\n }\n const source = parseConcrete(context, text, valueLocation, DiagnosticCodes.InvalidSpecificationCaseValue);\n if (source !== null) values.push({ kind: 'PropertyMappingSyntax', property, source, location: owner === line ? { ...location, column: location.column + inlinePropertyColumn } : location });\n };\n if (match.groups?.property !== undefined) add(match.groups.property, match.groups.value, line);\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const value = assignment.exec(child.content);\n const structured = value === null ? tryParseStructuredMapping(context, child) : undefined;\n if (structured !== undefined) {\n values.push(structured);\n continue;\n }\n if (value === null) {\n context.error(DiagnosticCodes.InvalidSpecificationCaseAssignment, \"Expected '<parameter> = <concrete value>' in a case.\", locationOf(child));\n context.skipOpaqueBlock(child.indent);\n continue;\n }\n add(value[1], value[2], child);\n const nested = context.peekChild(child.indent);\n if (nested !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationCaseValue, 'A case value must fit on one line.', locationOf(nested), { ...diagnosticText('case', match[1]), ...diagnosticText('parameter', value[1]), ...diagnosticText('text', nested.content) });\n context.skipOpaqueBlock(child.indent);\n }\n }\n return { kind: 'SpecificationCaseSyntax', name: match[1], values, location: locationOf(line) };\n}\n\nexport function caseReferences(value: unknown): CaseValueExpressionSyntax[] {\n if (Array.isArray(value)) return value.flatMap(caseReferences);\n if (value === null || typeof value !== 'object') return [];\n if ('kind' in value && value.kind === 'CaseValueExpressionSyntax') return [value as CaseValueExpressionSyntax];\n return Object.values(value).flatMap(caseReferences);\n}\n\nexport function validateTable(specification: SpecificationSyntax, context: ParserContext): void {\n const parameters = specification.parameters ?? [];\n const cases = specification.cases ?? [];\n if ((parameters.length === 0) !== (cases.length === 0)) context.error(DiagnosticCodes.IncompleteSpecificationTable, 'A specification table requires parameters and at least one case.', specification.location);\n parameters.forEach((parameter, index) => {\n if (parameters.slice(0, index).some(prior => prior.name === parameter.name)) context.error(DiagnosticCodes.DuplicateSpecificationParameter, `Parameter '${parameter.name}' is declared more than once.`, parameter.location);\n });\n cases.forEach((row, index) => {\n if (cases.slice(0, index).some(prior => prior.name === row.name)) context.error(DiagnosticCodes.DuplicateSpecificationCase, `Case '${row.name}' is declared more than once.`, row.location);\n for (const value of row.values.filter(value => !parameters.some(parameter => parameter.name === value.property))) context.error(DiagnosticCodes.InvalidSpecificationCaseAssignment, `Case '${row.name}' assigns undeclared parameter '${value.property}'.`, value.location);\n for (const parameter of parameters.filter(parameter => row.values.filter(value => value.property === parameter.name).length !== 1)) context.error(DiagnosticCodes.InvalidSpecificationCaseAssignment, `Case '${row.name}' must assign parameter '${parameter.name}' exactly once.`, row.location);\n });\n const references = caseReferences(specification);\n for (const value of references) {\n if (cases.length === 0 || !parameters.some(parameter => parameter.name === value.parameter)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, `Case reference '${value.parameter}' requires a declared parameter in a specification table.`, value.location);\n }\n for (const parameter of parameters.filter(parameter => !references.some(value => value.parameter === parameter.name))) context.warning(DiagnosticCodes.UnusedSpecificationParameter, `Parameter '${parameter.name}' is never referenced.`, parameter.location);\n for (const value of caseReferences(specification.whenRedelivered)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'Case references are not permitted in redelivery locators.', value.location);\n}\n\nexport function substituteCase<T>(value: T, row: SpecificationCaseSyntax, copies = new WeakMap<object, unknown>()): T {\n if (value !== null && typeof value === 'object' && copies.has(value)) return copies.get(value) as T;\n if (Array.isArray(value)) {\n const result = value.map(item => substituteCase(item, row, copies));\n copies.set(value, result);\n return result as T;\n }\n if (value === null || typeof value !== 'object' || !('kind' in value)) return value;\n if (value.kind === 'CaseValueExpressionSyntax') {\n const parameter = (value as unknown as CaseValueExpressionSyntax).parameter;\n return (row.values.find(value => value.property === parameter)?.source ?? value) as T;\n }\n const result = Object.fromEntries(Object.entries(value).map(([key, item]) => [key, substituteCase(item, row, copies)]));\n if (value.kind === 'SpecificationErrorSyntax' && 'caseValue' in value && value.caseValue !== undefined) {\n const source = result.caseValue as ExpressionSyntax;\n result.name = source.kind === 'LiteralExpressionSyntax' ? source.value : null;\n delete result.caseValue;\n }\n copies.set(value, result);\n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,IAAMT,KAAS,eAAeK,EAAc,eAAe,EAAGxB,EAAQ,MAAMC,EAAgB,kCAAmC,4DAA6DkB,EAAM,QAAQ,CACnN,CAEA,SAAgB,eAAkB,EAAU,EAA8B,kBAAS,IAAI,QAA+B,CAClH,GAAsB,OAAOA,GAAU,UAAnCA,GAA+CY,EAAO,IAAIZ,CAAK,EAAG,OAAOY,EAAO,IAAIZ,CAAK,EAC7F,GAAI,MAAM,QAAQA,CAAK,EAAG,CACtB,IAAMa,EAASb,EAAM,IAAI,GAAQ,eAAec,EAAMJ,EAAKE,CAAM,CAAC,EAElE,OADAA,EAAO,IAAIZ,EAAOa,CAAM,EACjBA,CACX,CACA,GAAsB,OAAOb,GAAU,WAAnCA,GAA+C,EAAE,SAAUA,GAAQ,OAAOA,EAC9E,GAAIA,EAAM,OAAS,4BAA6B,CAC5C,IAAMS,EAAaT,EAA+C,UAClE,OAAQU,EAAI,OAAO,KAAK,GAASV,EAAM,WAAaS,CAAS,CAAC,EAAE,QAAUT,CAC9E,CACA,IAAMa,EAAS,OAAO,YAAY,OAAO,QAAQb,CAAK,CAAC,CAAC,KAAK,CAACe,EAAKD,KAAU,CAACC,EAAK,eAAeD,EAAMJ,EAAKE,CAAM,CAAC,CAAC,CAAC,EACtH,GAAIZ,EAAM,OAAS,4BAA8B,cAAeA,GAASA,EAAM,YAAc,IAAA,GAAW,CACpG,IAAMF,EAASe,EAAO,UACtB,EAAO,KAAOf,EAAO,OAAS,0BAA4BA,EAAO,MAAQ,KACzE,OAAOe,EAAO,SAClB,CAEA,OADAD,EAAO,IAAIZ,EAAOa,CAAM,EACjBA,CACX,C"}
@@ -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{diagnosticText as n}from"../Diagnostics/DiagnosticArgument.js";import{EventSourceCatalog as r}from"../Syntax/EventSourceCatalog.js";import{specificationExamples as i}from"./SpecificationCommandExamples.js";import{compatibleValue as a}from"./ResponseValidator.js";import{commandDestinationType as o}from"./CommandDestinationTypes.js";import{RefusalDeclarations as s}from"./RefusalDeclarations.js";import{foldedSources as c}from"./FoldedEventSources.js";const l=/* @__PURE__ */ new Set([`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`]);function validateSpecificationCases(t,o,c){let u=new s(t),d=i(t),f=eventDestinationTypes(t,u),knownType=e=>l.has(e)||u.concepts.has(e)||u.types.has(e),p=new Map([...u.types].map(([e,t])=>[e,new Map(t.properties.map(e=>[e.name,e]))])),m=c===void 0?u.slices:[{scope:[],slice:{kind:`SliceSyntax`,type:`StateChange`,name:``,description:null,location:t.location,events:[],commands:[],queries:[],projections:[],captures:[],reactions:[],constraints:[],readModels:[],screens:[],specifications:c}}];for(let{slice:i,scope:s}of m){let l=/* @__PURE__ */ new Map;for(let e of i.specifications){let t=(e.cases?.length??0)===0?[e.name]:e.cases.map(t=>`${e.name}_${t.name}`);for(let e of t)l.set(e,(l.get(e)??0)+1);(e.cases?.length??0)>0&&l.set(e.name,(l.get(e.name)??0)+1)}for(let m of i.specifications){for(let t of m.cases??[])(l.get(`${m.name}_${t.name}`)??0)>1&&o.error(e.SpecificationCaseNameCollision,`Case '${t.name}' derives specification '${m.name}_${t.name}', which collides in this ${c===void 0?`slice`:`document`}.`,t.location);for(let t of m.parameters??[]){c===void 0&&!knownType(t.type.name)&&o.error(e.IncompatibleSpecificationParameterType,`Parameter '${t.name}' has unknown type '${t.type.name}'.`,t.type.location);for(let r of m.cases??[])for(let i of r.values.filter(e=>e.property===t.name))a(i.source,t.type,u.concepts,p)||o.error(e.InvalidSpecificationCaseValue,`Case '${r.name}' parameter '${t.name}' requires a concrete value of type '${t.type.name}'.`,i.source.location,{...n(`case`,r.name),...n(`parameter`,t.name),...n(`type`,t.type.name)})}let check=(t,n,r)=>{if(t?.kind!==`CaseValueExpressionSyntax`||n===void 0)return;let i=m.parameters?.find(e=>e.name===t.parameter);if(i===void 0||(i.type.isOptional&&!n.isOptional&&o.error(e.OptionalSpecificationParameterTarget,`Optional parameter '${i.name}' cannot supply required target '${r}'.`,t.location),c!==void 0&&(!knownType(i.type.name)||!knownType(n.name))))return;let a=u.concepts.get(i.type.name),s=u.concepts.get(n.name);(!(i.type.name===n.name||a?.type!==`Enum`&&a?.type===n.name||s?.type!==`Enum`&&s?.type===i.type.name)||i.type.isCollection!==n.isCollection)&&o.error(e.IncompatibleSpecificationParameterType,`Parameter '${i.name}' type '${i.type.name}' is incompatible with target '${r}' type '${n.name}'.`,t.location)},assignments=(e,t)=>{for(let n of e)check(n.source,u.property(t,n.property)?.type,n.property)},h=d.command(m.when,s);if(h!==null){let e=u.resolve(h.commandType,i,e=>e.commands)?.node.properties??null;assignments(h.values,e),assignments(h.generatedValues??[],e),check(h.for,e?.find(e=>e.isIdentifier)?.type,`for`)}if(h!==null&&m.thenReturns!=null){let e=u.resolve(h.commandType,i,e=>e.commands)?.node,t=e?.response;if(m.thenReturns.kind===`ScalarSpecificationReturnSyntax`&&t?.kind===`ScalarCommandResponseSyntax`&&check(m.thenReturns.value,e?.properties.find(e=>e.name===t.source.property)?.type,`value`),m.thenReturns.kind===`RecordSpecificationReturnSyntax`&&t?.kind===`RecordCommandResponseSyntax`)for(let n of m.thenReturns.fields){let r=t.fields.find(e=>e.name===n.property);check(n.source,r?.type??e?.properties.find(e=>e.name===r?.source.property)?.type,n.property)}}for(let e of[...m.given,...m.thenEvents,...m.whenAppended===null?[]:[m.whenAppended]]){let n=d.eventStep(e,`given`,s).effective;assignments(n.values,u.event(n.eventType,i)?.properties??null);let a=n.stream==null?null:new r(t).resolve(n.stream.eventSource,n.stream.stream),o=a?.kind===`unique`?a.sources[0]:void 0,c=a?.kind===`unique`?a.streams[0]:void 0;check(n.for,n.stream!=null&&o===void 0?void 0:o?.identifier??f(n.eventType,i),`for`),n.stream?.streamId!=null&&check(n.stream.streamId.source,c?.streamId??void 0,`streamId`);for(let e of n.stream?.streamIdParts??[])check(e.source,c?.streamIdParts.find(t=>t.name===e.property)?.type,e.property)}for(let e of[...m.givenReadModels,...m.thenReadModels]){let t=d.readModel(e,s);assignments(t.properties,u.resolve(t.name,i,e=>e.readModels)?.node.properties??null)}if(m.whenTrigger!=null){let e=(t.declaredTriggers??[]).find(e=>e.name===m.whenTrigger.trigger);for(let t of m.whenTrigger.values)check(t.source,e?.data.find(e=>e.name===t.property)?.type,t.property)}for(let e of m.thenErrors)check(e.caseValue??null,{kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:e.location},`message`);for(let e of m.thenAbsentReadModels??[]){let t=u.resolve(e.name,i,e=>e.readModels)?.node,n=u.slices.flatMap(({slice:e})=>e.queries.filter(n=>n.by!==null&&u.resolve(n.returnType.name,e,e=>e.readModels)?.node===t));check(e.key,t!==void 0&&n.length===1?n[0].by.type:void 0,`for`)}for(let e of[...m.thenQueries??[],...m.whenQuery===null?[]:[m.whenQuery]]){let t=u.resolve(e.query,i,e=>e.queries),n=t===null?[]:[...t.node.by===null?[]:[t.node.by],...t.node.filters].map(e=>({...e,kind:`PropertySyntax`,isIdentifier:!1}));assignments(e.arguments,n);let r=t===null?null:u.resolve(t.node.returnType.name,t.slice,e=>e.readModels)?.node.properties??null,a=e.kind===`SpecificationQuerySyntax`?e.results:m.thenResults;for(let e of a)assignments(e.properties,r)}}}}function uniqueDestinationType(e){let t=new Map(e.map(e=>[JSON.stringify([e.name,e.isOptional,e.isCollection]),e]));return t.size===1?[...t.values()][0]:void 0}function eventDestinationTypes(e,t){let n=/* @__PURE__ */ new Map;return(r,i)=>{let a=t.event(r,i);if(a===null)return;let o=n.get(i);return o===void 0&&n.set(i,o=/* @__PURE__ */ new Map),o.has(a)||o.set(a,producedDestinationType(a,i,e,t)),o.get(a)}}function producedDestinationType(e,n,r,i){let a=new t(r),commandTypes=(e,t=i.slices)=>t.flatMap(({slice:t})=>t.commands.flatMap(n=>n.produces.filter(n=>a.isEventProduction(n,t)&&i.event(n.event,t)===e).map(e=>o(n,e,r,{resolver:a,slice:t})).filter(e=>e!==null))),producerTypes=(e,t)=>{if(t.has(e))return[];t.add(e);let n=commandTypes(e);for(let{slice:a}of i.slices){for(let o of a.reactions.flatMap(e=>e.triggers)){let s=o.source.kind===`NamedTriggerSourceSyntax`?o.source.name:void 0,c=s===void 0?null:i.event(s,a);for(let l of o.produces.filter(t=>i.event(t.event,a)===e))if(l.for?.kind===`PathExpressionSyntax`){let e=l.for.path,t=i.property(c?.properties??null,e)?.type??(s===void 0?void 0:(r.declaredTriggers??[]).find(e=>e.name===s)?.data.find(t=>t.name===e)?.type);t!==void 0&&n.push(t)}else l.for?.kind===`LiteralExpressionSyntax`?n.push({kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:l.location}):l.for===null&&c!==null&&n.push(...producerTypes(c,t))}a.captures.flatMap(e=>[...e.appends,...e.children.flatMap(e=>e.appends),...e.nested.flatMap(e=>e.appends)]).some(t=>i.event(t.event,a)===e)&&n.push(uniqueDestinationType(commandTypes(e))??{kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:e.location}),n.push(...c(i,a,e).flatMap(e=>producerTypes(e,t)))}return n};return uniqueDestinationType(commandTypes(e,i.slices.filter(e=>e.slice===n)))??uniqueDestinationType(commandTypes(e))??uniqueDestinationType(producerTypes(e,/* @__PURE__ */ new Set))}export{validateSpecificationCases};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{diagnosticText as e}from"../Diagnostics/DiagnosticArgument.js";import{DiagnosticCodes as t}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as n}from"../Syntax/AuthoringProductionResolver.js";import{EventSourceCatalog as r}from"../Syntax/EventSourceCatalog.js";import{commandDestinationType as i}from"./CommandDestinationTypes.js";import{RefusalDeclarations as a}from"./RefusalDeclarations.js";import{compatibleValue as o}from"./ResponseValidator.js";import{foldedSources as s}from"./FoldedEventSources.js";import{specificationExamples as c}from"./SpecificationCommandExamples.js";const l=/* @__PURE__ */ new Set([`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`]);function validateSpecificationCases(n,i,s){let u=new a(n),d=c(n),f=eventDestinationTypes(n,u),knownType=e=>l.has(e)||u.concepts.has(e)||u.types.has(e),p=new Map([...u.types].map(([e,t])=>[e,new Map(t.properties.map(e=>[e.name,e]))])),m=s===void 0?u.slices:[{scope:[],slice:{kind:`SliceSyntax`,type:`StateChange`,name:``,description:null,location:n.location,events:[],commands:[],queries:[],projections:[],captures:[],reactions:[],constraints:[],readModels:[],screens:[],specifications:s}}];for(let{slice:a,scope:c}of m){let l=/* @__PURE__ */ new Map;for(let e of a.specifications){let t=(e.cases?.length??0)===0?[e.name]:e.cases.map(t=>`${e.name}_${t.name}`);for(let e of t)l.set(e,(l.get(e)??0)+1);(e.cases?.length??0)>0&&l.set(e.name,(l.get(e.name)??0)+1)}for(let m of a.specifications){for(let e of m.cases??[])(l.get(`${m.name}_${e.name}`)??0)>1&&i.error(t.SpecificationCaseNameCollision,`Case '${e.name}' derives specification '${m.name}_${e.name}', which collides in this ${s===void 0?`slice`:`document`}.`,e.location);for(let n of m.parameters??[]){s===void 0&&!knownType(n.type.name)&&i.error(t.IncompatibleSpecificationParameterType,`Parameter '${n.name}' has unknown type '${n.type.name}'.`,n.type.location);for(let r of m.cases??[])for(let a of r.values.filter(e=>e.property===n.name))o(a.source,n.type,u.concepts,p)||i.error(t.InvalidSpecificationCaseValue,`Case '${r.name}' parameter '${n.name}' requires a concrete value of type '${n.type.name}'.`,a.source.location,{...e(`case`,r.name),...e(`parameter`,n.name),...e(`type`,n.type.name)})}let check=(e,n,r)=>{if(e?.kind!==`CaseValueExpressionSyntax`||n===void 0)return;let a=m.parameters?.find(t=>t.name===e.parameter);if(a===void 0||(a.type.isOptional&&!n.isOptional&&i.error(t.OptionalSpecificationParameterTarget,`Optional parameter '${a.name}' cannot supply required target '${r}'.`,e.location),s!==void 0&&(!knownType(a.type.name)||!knownType(n.name))))return;let o=u.concepts.get(a.type.name),c=u.concepts.get(n.name);(a.type.name===n.name||o?.type!==`Enum`&&o?.type===n.name||c?.type!==`Enum`&&c?.type===a.type.name)&&a.type.isCollection===n.isCollection||i.error(t.IncompatibleSpecificationParameterType,`Parameter '${a.name}' type '${a.type.name}' is incompatible with target '${r}' type '${n.name}'.`,e.location)},assignments=(e,t)=>{for(let n of e)check(n.source,u.property(t,n.property)?.type,n.property)},h=d.command(m.when,c);if(h!==null){let e=u.resolve(h.commandType,a,e=>e.commands)?.node.properties??null;assignments(h.values,e),assignments(h.generatedValues??[],e),check(h.for,e?.find(e=>e.isIdentifier)?.type,`for`)}if(h!==null&&m.thenReturns!=null){let e=u.resolve(h.commandType,a,e=>e.commands)?.node,t=e?.response;if(m.thenReturns.kind===`ScalarSpecificationReturnSyntax`&&t?.kind===`ScalarCommandResponseSyntax`&&check(m.thenReturns.value,e?.properties.find(e=>e.name===t.source.property)?.type,`value`),m.thenReturns.kind===`RecordSpecificationReturnSyntax`&&t?.kind===`RecordCommandResponseSyntax`)for(let n of m.thenReturns.fields){let r=t.fields.find(e=>e.name===n.property);check(n.source,r?.type??e?.properties.find(e=>e.name===r?.source.property)?.type,n.property)}}for(let e of[...m.given,...m.thenEvents,...m.whenAppended===null?[]:[m.whenAppended]]){let t=d.eventStep(e,`given`,c).effective;assignments(t.values,u.event(t.eventType,a)?.properties??null);let i=t.stream==null?null:new r(n).resolve(t.stream.eventSource,t.stream.stream),o=i?.kind===`unique`?i.sources[0]:void 0,s=i?.kind===`unique`?i.streams[0]:void 0;check(t.for,t.stream!=null&&o===void 0?void 0:o?.identifier??f(t.eventType,a),`for`),t.stream?.streamId!=null&&check(t.stream.streamId.source,s?.streamId??void 0,`streamId`);for(let e of t.stream?.streamIdParts??[])check(e.source,s?.streamIdParts.find(t=>t.name===e.property)?.type,e.property)}for(let e of[...m.givenReadModels,...m.thenReadModels]){let t=d.readModel(e,c);assignments(t.properties,u.resolve(t.name,a,e=>e.readModels)?.node.properties??null)}if(m.whenTrigger!=null){let e=(n.declaredTriggers??[]).find(e=>e.name===m.whenTrigger.trigger);for(let t of m.whenTrigger.values)check(t.source,e?.data.find(e=>e.name===t.property)?.type,t.property)}for(let e of m.thenErrors)check(e.caseValue??null,{kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:e.location},`message`);for(let e of m.thenAbsentReadModels??[]){let t=u.resolve(e.name,a,e=>e.readModels)?.node,n=u.slices.flatMap(({slice:e})=>e.queries.filter(n=>n.by!==null&&u.resolve(n.returnType.name,e,e=>e.readModels)?.node===t));check(e.key,t!==void 0&&n.length===1?n[0].by.type:void 0,`for`)}for(let e of[...m.thenQueries??[],...m.whenQuery===null?[]:[m.whenQuery]]){let t=u.resolve(e.query,a,e=>e.queries),n=t===null?[]:[...t.node.by===null?[]:[t.node.by],...t.node.filters].map(e=>({...e,kind:`PropertySyntax`,isIdentifier:!1}));assignments(e.arguments,n);let r=t===null?null:u.resolve(t.node.returnType.name,t.slice,e=>e.readModels)?.node.properties??null,i=e.kind===`SpecificationQuerySyntax`?e.results:m.thenResults;for(let e of i)assignments(e.properties,r)}}}}function uniqueDestinationType(e){let t=new Map(e.map(e=>[JSON.stringify([e.name,e.isOptional,e.isCollection]),e]));return t.size===1?[...t.values()][0]:void 0}function eventDestinationTypes(e,t){let n=/* @__PURE__ */ new Map;return(r,i)=>{let a=t.event(r,i);if(a===null)return;let o=n.get(i);return o===void 0&&n.set(i,o=/* @__PURE__ */ new Map),o.has(a)||o.set(a,producedDestinationType(a,i,e,t)),o.get(a)}}function producedDestinationType(e,t,r,a){let o=new n(r),commandTypes=(e,t=a.slices)=>t.flatMap(({slice:t})=>t.commands.flatMap(n=>n.produces.filter(n=>o.isEventProduction(n,t)&&a.event(n.event,t)===e).map(e=>i(n,e,r,{resolver:o,slice:t})).filter(e=>e!==null))),producerTypes=(e,t)=>{if(t.has(e))return[];t.add(e);let n=commandTypes(e);for(let{slice:i}of a.slices){for(let o of i.reactions.flatMap(e=>e.triggers)){let s=o.source.kind===`NamedTriggerSourceSyntax`?o.source.name:void 0,c=s===void 0?null:a.event(s,i);for(let l of o.produces.filter(t=>a.event(t.event,i)===e))if(l.for?.kind===`PathExpressionSyntax`){let e=l.for.path,t=a.property(c?.properties??null,e)?.type??(s===void 0?void 0:(r.declaredTriggers??[]).find(e=>e.name===s)?.data.find(t=>t.name===e)?.type);t!==void 0&&n.push(t)}else l.for?.kind===`LiteralExpressionSyntax`?n.push({kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:l.location}):l.for===null&&c!==null&&n.push(...producerTypes(c,t))}i.captures.flatMap(e=>[...e.appends,...e.children.flatMap(e=>e.appends),...e.nested.flatMap(e=>e.appends)]).some(t=>a.event(t.event,i)===e)&&n.push(uniqueDestinationType(commandTypes(e))??{kind:`TypeRefSyntax`,name:`String`,isOptional:!1,isCollection:!1,location:e.location}),n.push(...s(a,i,e).flatMap(e=>producerTypes(e,t)))}return n};return uniqueDestinationType(commandTypes(e,a.slices.filter(e=>e.slice===t)))??uniqueDestinationType(commandTypes(e))??uniqueDestinationType(producerTypes(e,/* @__PURE__ */ new Set))}export{validateSpecificationCases};
2
2
  //# sourceMappingURL=SpecificationCaseValidator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpecificationCaseValidator.js","names":["primitives","declarations","RefusalDeclarations","application","examples","specificationExamples","destinationType","name","composites","type","property","owners","standaloneSpecifications","names","specification","slice","expandedNames","row","context","DiagnosticCodes","parameter","assignment","value","compatibleValue","diagnosticText","expression","target","sourceConcept","targetConcept","values","properties","command","scope","declaration","response","field","authored","event","route","EventSourceCatalog","source","stream","part","model","trigger","error","absent","keyed","owner","query","parameters","results","result","distinct","types","memo","reference","local","events","resolver","AuthoringProductionResolver","produced","commandDestinationType","visited","reaction","sourceName","path","declared","capture","child","nested","append","foldedSources"],"sources":["../../../../../../Compiler/Parsing/SpecificationCaseValidator.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 { EventSyntax, PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { SpecificationSyntax } from '../Syntax/Specifications';\nimport { commandDestinationType } from './CommandDestinationTypes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\nimport { compatibleValue } from './ResponseValidator';\nimport { foldedSources } from './FoldedEventSources';\nimport { specificationExamples } from './SpecificationCommandExamples';\n\nconst primitives = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime']);\n\nexport function validateSpecificationCases(application: ApplicationSyntax, context: ParserContext, standaloneSpecifications?: readonly SpecificationSyntax[]): void {\n const declarations = new RefusalDeclarations(application);\n const examples = specificationExamples(application), destinationType = eventDestinationTypes(application, declarations);\n const knownType = (name: string) => primitives.has(name) || declarations.concepts.has(name) || declarations.types.has(name);\n const composites = new Map([...declarations.types].map(([name, type]) => [name, new Map(type.properties.map(property => [property.name, property]))]));\n const owners = standaloneSpecifications === undefined ? declarations.slices : [{ scope: [], slice: {\n kind: 'SliceSyntax' as const, type: 'StateChange' as const, name: '', description: null, location: application.location,\n events: [], commands: [], queries: [], projections: [], captures: [], reactions: [], constraints: [], readModels: [], screens: [], specifications: standaloneSpecifications,\n } }];\n for (const { slice, scope } of owners) {\n const names = new Map<string, number>();\n for (const specification of slice.specifications) {\n const expandedNames = (specification.cases?.length ?? 0) === 0 ? [specification.name] : specification.cases!.map(row => `${specification.name}_${row.name}`);\n for (const name of expandedNames) names.set(name, (names.get(name) ?? 0) + 1);\n if ((specification.cases?.length ?? 0) > 0) names.set(specification.name, (names.get(specification.name) ?? 0) + 1);\n }\n for (const specification of slice.specifications) {\n for (const row of specification.cases ?? []) {\n if ((names.get(`${specification.name}_${row.name}`) ?? 0) > 1) context.error(DiagnosticCodes.SpecificationCaseNameCollision, `Case '${row.name}' derives specification '${specification.name}_${row.name}', which collides in this ${standaloneSpecifications === undefined ? 'slice' : 'document'}.`, row.location);\n }\n for (const parameter of specification.parameters ?? []) {\n if (standaloneSpecifications === undefined && !knownType(parameter.type.name)) context.error(DiagnosticCodes.IncompatibleSpecificationParameterType, `Parameter '${parameter.name}' has unknown type '${parameter.type.name}'.`, parameter.type.location);\n for (const row of specification.cases ?? []) {\n for (const assignment of row.values.filter(value => value.property === parameter.name)) {\n if (!compatibleValue(assignment.source, parameter.type, declarations.concepts, composites)) context.error(DiagnosticCodes.InvalidSpecificationCaseValue, `Case '${row.name}' parameter '${parameter.name}' requires a concrete value of type '${parameter.type.name}'.`, assignment.source.location, { ...diagnosticText('case', row.name), ...diagnosticText('parameter', parameter.name), ...diagnosticText('type', parameter.type.name) });\n }\n }\n }\n const check = (expression: ExpressionSyntax | null, target: TypeRefSyntax | undefined, property: string) => {\n if (expression?.kind !== 'CaseValueExpressionSyntax' || target === undefined) return;\n const parameter = specification.parameters?.find(parameter => parameter.name === expression.parameter);\n if (parameter === undefined) return;\n if (parameter.type.isOptional && !target.isOptional) context.error(DiagnosticCodes.OptionalSpecificationParameterTarget, `Optional parameter '${parameter.name}' cannot supply required target '${property}'.`, expression.location);\n if (standaloneSpecifications !== undefined && (!knownType(parameter.type.name) || !knownType(target.name))) return;\n const sourceConcept = declarations.concepts.get(parameter.type.name);\n const targetConcept = declarations.concepts.get(target.name);\n const compatible = parameter.type.name === target.name || sourceConcept?.type !== 'Enum' && sourceConcept?.type === target.name || targetConcept?.type !== 'Enum' && targetConcept?.type === parameter.type.name;\n if (!compatible || parameter.type.isCollection !== target.isCollection) context.error(DiagnosticCodes.IncompatibleSpecificationParameterType, `Parameter '${parameter.name}' type '${parameter.type.name}' is incompatible with target '${property}' type '${target.name}'.`, expression.location);\n };\n const assignments = (values: readonly PropertyMappingSyntax[], properties: readonly PropertySyntax[] | null) => {\n for (const value of values) check(value.source, declarations.property(properties, value.property)?.type, value.property);\n };\n const command = examples.command(specification.when, scope);\n if (command !== null) {\n const properties = declarations.resolve(command.commandType, slice, slice => slice.commands)?.node.properties ?? null;\n assignments(command.values, properties);\n assignments(command.generatedValues ?? [], properties);\n check(command.for, properties?.find(property => property.isIdentifier)?.type, 'for');\n }\n if (command !== null && specification.thenReturns != null) {\n const declaration = declarations.resolve(command.commandType, slice, slice => slice.commands)?.node;\n const response = declaration?.response;\n if (specification.thenReturns.kind === 'ScalarSpecificationReturnSyntax' && response?.kind === 'ScalarCommandResponseSyntax') check(specification.thenReturns.value, declaration?.properties.find(property => property.name === response.source.property)?.type, 'value');\n if (specification.thenReturns.kind === 'RecordSpecificationReturnSyntax' && response?.kind === 'RecordCommandResponseSyntax') {\n for (const value of specification.thenReturns.fields) {\n const field = response.fields.find(field => field.name === value.property);\n check(value.source, field?.type ?? declaration?.properties.find(property => property.name === field?.source.property)?.type, value.property);\n }\n }\n }\n for (const authored of [...specification.given, ...specification.thenEvents, ...(specification.whenAppended === null ? [] : [specification.whenAppended])]) {\n const event = examples.eventStep(authored, 'given', scope).effective as typeof authored;\n assignments(event.values, declarations.event(event.eventType, slice)?.properties ?? null);\n const route = event.stream == null ? null : new EventSourceCatalog(application).resolve(event.stream.eventSource, event.stream.stream);\n const source = route?.kind === EventSourceResolutionKind.Unique ? route.sources[0] : undefined;\n const stream = route?.kind === EventSourceResolutionKind.Unique ? route.streams[0] : undefined;\n check(event.for, event.stream != null && source === undefined ? undefined : source?.identifier ?? destinationType(event.eventType, slice), 'for');\n if (event.stream?.streamId != null) check(event.stream.streamId.source, stream?.streamId ?? undefined, 'streamId');\n for (const part of event.stream?.streamIdParts ?? []) check(part.source, stream?.streamIdParts.find(declaration => declaration.name === part.property)?.type, part.property);\n }\n for (const authored of [...specification.givenReadModels, ...specification.thenReadModels]) {\n const model = examples.readModel(authored, scope);\n assignments(model.properties, declarations.resolve(model.name, slice, slice => slice.readModels)?.node.properties ?? null);\n }\n if (specification.whenTrigger != null) {\n const trigger = (application.declaredTriggers ?? []).find(trigger => trigger.name === specification.whenTrigger!.trigger);\n for (const value of specification.whenTrigger.values) check(value.source, trigger?.data.find(property => property.name === value.property)?.type, value.property);\n }\n for (const error of specification.thenErrors) check(error.caseValue ?? null, { kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: error.location }, 'message');\n for (const absent of specification.thenAbsentReadModels ?? []) {\n const model = declarations.resolve(absent.name, slice, slice => slice.readModels)?.node;\n const keyed = declarations.slices.flatMap(({ slice: owner }) => owner.queries.filter(query => query.by !== null && declarations.resolve(query.returnType.name, owner, slice => slice.readModels)?.node === model));\n check(absent.key, model !== undefined && keyed.length === 1 ? keyed[0].by!.type : undefined, 'for');\n }\n for (const query of [...(specification.thenQueries ?? []), ...(specification.whenQuery === null ? [] : [specification.whenQuery])]) {\n const declaration = declarations.resolve(query.query, slice, slice => slice.queries);\n const parameters = declaration === null ? [] : [...(declaration.node.by === null ? [] : [declaration.node.by]), ...declaration.node.filters].map(parameter => ({ ...parameter, kind: 'PropertySyntax' as const, isIdentifier: false }));\n assignments(query.arguments, parameters);\n const properties = declaration === null ? null : declarations.resolve(declaration.node.returnType.name, declaration.slice, slice => slice.readModels)?.node.properties ?? null;\n const results = query.kind === 'SpecificationQuerySyntax' ? query.results : specification.thenResults;\n for (const result of results) assignments(result.properties, properties);\n }\n }\n }\n}\n\nfunction uniqueDestinationType(types: readonly TypeRefSyntax[]): TypeRefSyntax | undefined {\n const distinct = new Map(types.map(type => [JSON.stringify([type.name, type.isOptional, type.isCollection]), type]));\n return distinct.size === 1 ? [...distinct.values()][0] : undefined;\n}\n\n// Memoized per validation pass by declaring slice and resolved event; unresolved and ambiguous (undefined) results are cached too.\nfunction eventDestinationTypes(application: ApplicationSyntax, declarations: RefusalDeclarations): (reference: string, local: SliceSyntax) => TypeRefSyntax | undefined {\n const memo = new Map<SliceSyntax, Map<EventSyntax, TypeRefSyntax | undefined>>();\n return (reference, local) => {\n const event = declarations.event(reference, local);\n if (event === null) return undefined;\n let events = memo.get(local);\n if (events === undefined) memo.set(local, events = new Map());\n if (!events.has(event)) events.set(event, producedDestinationType(event, local, application, declarations));\n return events.get(event);\n };\n}\n\nfunction producedDestinationType(event: EventSyntax, local: SliceSyntax, application: ApplicationSyntax, declarations: RefusalDeclarations): TypeRefSyntax | undefined {\n const resolver = new AuthoringProductionResolver(application);\n const commandTypes = (event: EventSyntax, owners = declarations.slices): TypeRefSyntax[] => owners.flatMap(({ slice }) => slice.commands.flatMap(command => command.produces\n .filter(produced => resolver.isEventProduction(produced, slice) && declarations.event(produced.event, slice) === event)\n .map(produced => commandDestinationType(command, produced, application, { resolver, slice })).filter((type): type is TypeRefSyntax => type !== null)));\n const producerTypes = (event: EventSyntax, visited: Set<EventSyntax>): TypeRefSyntax[] => {\n if (visited.has(event)) return [];\n visited.add(event);\n const types = commandTypes(event);\n for (const { slice } of declarations.slices) {\n for (const trigger of slice.reactions.flatMap(reaction => reaction.triggers)) {\n const sourceName = trigger.source.kind === 'NamedTriggerSourceSyntax' ? trigger.source.name : undefined;\n const source = sourceName === undefined ? null : declarations.event(sourceName, slice);\n for (const produced of trigger.produces.filter(produced => declarations.event(produced.event, slice) === event)) {\n if (produced.for?.kind === 'PathExpressionSyntax') {\n const path = produced.for.path;\n const type = declarations.property(source?.properties ?? null, path)?.type ?? (sourceName === undefined ? undefined\n : (application.declaredTriggers ?? []).find(declared => declared.name === sourceName)?.data.find(property => property.name === path)?.type);\n if (type !== undefined) types.push(type);\n } else if (produced.for?.kind === 'LiteralExpressionSyntax') types.push({ kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: produced.location });\n else if (produced.for === null && source !== null) types.push(...producerTypes(source, visited));\n }\n }\n if (slice.captures.flatMap(capture => [...capture.appends, ...capture.children.flatMap(child => child.appends), ...capture.nested.flatMap(nested => nested.appends)]).some(append => declarations.event(append.event, slice) === event))\n types.push(uniqueDestinationType(commandTypes(event)) ?? { kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: event.location });\n types.push(...foldedSources(declarations, slice, event).flatMap(source => producerTypes(source, visited)));\n }\n return types;\n };\n return uniqueDestinationType(commandTypes(event, declarations.slices.filter(owner => owner.slice === local))) ?? uniqueDestinationType(commandTypes(event)) ?? uniqueDestinationType(producerTypes(event, new Set()));\n}\n"],"mappings":"2pBAmBA,MAAMA,kBAAa,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,CAAC,EAE3F,SAAgB,2BAA2B,EAAgC,EAAwB,EAAiE,CAChK,IAAMC,EAAe,IAAIC,EAAoBC,CAAW,EAClDC,EAAWC,EAAsBF,CAAW,EAAGG,EAAkB,sBAAsBH,EAAaF,CAAY,EAChH,UAAa,GAAiBD,EAAW,IAAIO,CAAI,GAAKN,EAAa,SAAS,IAAIM,CAAI,GAAKN,EAAa,MAAM,IAAIM,CAAI,EACpHC,EAAa,IAAI,IAAI,CAAC,GAAGP,EAAa,KAAK,CAAC,CAAC,KAAK,CAACM,EAAME,KAAU,CAACF,EAAM,IAAI,IAAIE,EAAK,WAAW,IAAI,GAAY,CAACC,EAAS,KAAMA,CAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAC/IC,EAASC,IAA6B,IAAA,GAAYX,EAAa,OAAS,CAAC,CAAE,MAAO,CAAC,EAAG,MAAO,CAC/F,KAAM,cAAwB,KAAM,cAAwB,KAAM,GAAI,YAAa,KAAM,SAAUE,EAAY,SAC/G,OAAQ,CAAC,EAAG,SAAU,CAAC,EAAG,QAAS,CAAC,EAAG,YAAa,CAAC,EAAG,SAAU,CAA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AAC,CAEvG,CACIhD,EAAM,SAAS,QAAQ,GAAW,CAAC,GAAGqD,EAAQ,QAAS,GAAGA,EAAQ,SAAS,QAAQ,GAASC,EAAM,OAAO,EAAG,GAAGD,EAAQ,OAAO,QAAQ,GAAUE,EAAO,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,GAAUrE,EAAa,MAAMsE,EAAO,MAAOxD,CAAK,IAAMsB,CAAK,GAClOiB,EAAM,KAAK,sBAAsB,aAAajB,CAAK,CAAC,GAAK,CAAE,KAAM,gBAAiB,KAAM,SAAU,WAAY,GAAO,aAAc,GAAO,SAAUA,EAAM,QAAS,CAAC,EACxKiB,EAAM,KAAK,GAAGkB,EAAcvE,EAAcc,EAAOsB,CAAK,CAAC,CAAC,QAAQ,GAAU,cAAcG,EAAQuB,CAAO,CAAC,CAAC,CAC7G,CACA,OAAOT,CACX,EACA,OAAO,sBAAsB,aAAajB,EAAOpC,EAAa,OAAO,OAAO,GAAS+C,EAAM,QAAUS,CAAK,CAAC,CAAC,GAAK,sBAAsB,aAAapB,CAAK,CAAC,GAAK,sBAAsB,cAAcA,kBAAO,IAAI,GAAK,CAAC,CACxN"}
1
+ {"version":3,"file":"SpecificationCaseValidator.js","names":["primitives","declarations","RefusalDeclarations","application","examples","specificationExamples","destinationType","name","composites","type","property","owners","standaloneSpecifications","names","specification","slice","expandedNames","row","context","DiagnosticCodes","parameter","assignment","value","compatibleValue","diagnosticText","expression","target","sourceConcept","targetConcept","values","properties","command","scope","declaration","response","field","authored","event","route","EventSourceCatalog","source","stream","part","model","trigger","error","absent","keyed","owner","query","parameters","results","result","distinct","types","memo","reference","local","events","resolver","AuthoringProductionResolver","produced","commandDestinationType","visited","reaction","sourceName","path","declared","capture","child","nested","append","foldedSources"],"sources":["../../../../../../Compiler/Parsing/SpecificationCaseValidator.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 { EventSyntax, PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { SpecificationSyntax } from '../Syntax/Specifications';\nimport { commandDestinationType } from './CommandDestinationTypes';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\nimport { compatibleValue } from './ResponseValidator';\nimport { foldedSources } from './FoldedEventSources';\nimport { specificationExamples } from './SpecificationCommandExamples';\n\nconst primitives = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime']);\n\nexport function validateSpecificationCases(application: ApplicationSyntax, context: ParserContext, standaloneSpecifications?: readonly SpecificationSyntax[]): void {\n const declarations = new RefusalDeclarations(application);\n const examples = specificationExamples(application), destinationType = eventDestinationTypes(application, declarations);\n const knownType = (name: string) => primitives.has(name) || declarations.concepts.has(name) || declarations.types.has(name);\n const composites = new Map([...declarations.types].map(([name, type]) => [name, new Map(type.properties.map(property => [property.name, property]))]));\n const owners = standaloneSpecifications === undefined ? declarations.slices : [{ scope: [], slice: {\n kind: 'SliceSyntax' as const, type: 'StateChange' as const, name: '', description: null, location: application.location,\n events: [], commands: [], queries: [], projections: [], captures: [], reactions: [], constraints: [], readModels: [], screens: [], specifications: standaloneSpecifications,\n } }];\n for (const { slice, scope } of owners) {\n const names = new Map<string, number>();\n for (const specification of slice.specifications) {\n const expandedNames = (specification.cases?.length ?? 0) === 0 ? [specification.name] : specification.cases!.map(row => `${specification.name}_${row.name}`);\n for (const name of expandedNames) names.set(name, (names.get(name) ?? 0) + 1);\n if ((specification.cases?.length ?? 0) > 0) names.set(specification.name, (names.get(specification.name) ?? 0) + 1);\n }\n for (const specification of slice.specifications) {\n for (const row of specification.cases ?? []) {\n if ((names.get(`${specification.name}_${row.name}`) ?? 0) > 1) context.error(DiagnosticCodes.SpecificationCaseNameCollision, `Case '${row.name}' derives specification '${specification.name}_${row.name}', which collides in this ${standaloneSpecifications === undefined ? 'slice' : 'document'}.`, row.location);\n }\n for (const parameter of specification.parameters ?? []) {\n if (standaloneSpecifications === undefined && !knownType(parameter.type.name)) context.error(DiagnosticCodes.IncompatibleSpecificationParameterType, `Parameter '${parameter.name}' has unknown type '${parameter.type.name}'.`, parameter.type.location);\n for (const row of specification.cases ?? []) {\n for (const assignment of row.values.filter(value => value.property === parameter.name)) {\n if (!compatibleValue(assignment.source, parameter.type, declarations.concepts, composites)) context.error(DiagnosticCodes.InvalidSpecificationCaseValue, `Case '${row.name}' parameter '${parameter.name}' requires a concrete value of type '${parameter.type.name}'.`, assignment.source.location, { ...diagnosticText('case', row.name), ...diagnosticText('parameter', parameter.name), ...diagnosticText('type', parameter.type.name) });\n }\n }\n }\n const check = (expression: ExpressionSyntax | null, target: TypeRefSyntax | undefined, property: string) => {\n if (expression?.kind !== 'CaseValueExpressionSyntax' || target === undefined) return;\n const parameter = specification.parameters?.find(parameter => parameter.name === expression.parameter);\n if (parameter === undefined) return;\n if (parameter.type.isOptional && !target.isOptional) context.error(DiagnosticCodes.OptionalSpecificationParameterTarget, `Optional parameter '${parameter.name}' cannot supply required target '${property}'.`, expression.location);\n if (standaloneSpecifications !== undefined && (!knownType(parameter.type.name) || !knownType(target.name))) return;\n const sourceConcept = declarations.concepts.get(parameter.type.name);\n const targetConcept = declarations.concepts.get(target.name);\n const compatible = parameter.type.name === target.name || sourceConcept?.type !== 'Enum' && sourceConcept?.type === target.name || targetConcept?.type !== 'Enum' && targetConcept?.type === parameter.type.name;\n if (!compatible || parameter.type.isCollection !== target.isCollection) context.error(DiagnosticCodes.IncompatibleSpecificationParameterType, `Parameter '${parameter.name}' type '${parameter.type.name}' is incompatible with target '${property}' type '${target.name}'.`, expression.location);\n };\n const assignments = (values: readonly PropertyMappingSyntax[], properties: readonly PropertySyntax[] | null) => {\n for (const value of values) check(value.source, declarations.property(properties, value.property)?.type, value.property);\n };\n const command = examples.command(specification.when, scope);\n if (command !== null) {\n const properties = declarations.resolve(command.commandType, slice, slice => slice.commands)?.node.properties ?? null;\n assignments(command.values, properties);\n assignments(command.generatedValues ?? [], properties);\n check(command.for, properties?.find(property => property.isIdentifier)?.type, 'for');\n }\n if (command !== null && specification.thenReturns != null) {\n const declaration = declarations.resolve(command.commandType, slice, slice => slice.commands)?.node;\n const response = declaration?.response;\n if (specification.thenReturns.kind === 'ScalarSpecificationReturnSyntax' && response?.kind === 'ScalarCommandResponseSyntax') check(specification.thenReturns.value, declaration?.properties.find(property => property.name === response.source.property)?.type, 'value');\n if (specification.thenReturns.kind === 'RecordSpecificationReturnSyntax' && response?.kind === 'RecordCommandResponseSyntax') {\n for (const value of specification.thenReturns.fields) {\n const field = response.fields.find(field => field.name === value.property);\n check(value.source, field?.type ?? declaration?.properties.find(property => property.name === field?.source.property)?.type, value.property);\n }\n }\n }\n for (const authored of [...specification.given, ...specification.thenEvents, ...(specification.whenAppended === null ? [] : [specification.whenAppended])]) {\n const event = examples.eventStep(authored, 'given', scope).effective as typeof authored;\n assignments(event.values, declarations.event(event.eventType, slice)?.properties ?? null);\n const route = event.stream == null ? null : new EventSourceCatalog(application).resolve(event.stream.eventSource, event.stream.stream);\n const source = route?.kind === EventSourceResolutionKind.Unique ? route.sources[0] : undefined;\n const stream = route?.kind === EventSourceResolutionKind.Unique ? route.streams[0] : undefined;\n check(event.for, event.stream != null && source === undefined ? undefined : source?.identifier ?? destinationType(event.eventType, slice), 'for');\n if (event.stream?.streamId != null) check(event.stream.streamId.source, stream?.streamId ?? undefined, 'streamId');\n for (const part of event.stream?.streamIdParts ?? []) check(part.source, stream?.streamIdParts.find(declaration => declaration.name === part.property)?.type, part.property);\n }\n for (const authored of [...specification.givenReadModels, ...specification.thenReadModels]) {\n const model = examples.readModel(authored, scope);\n assignments(model.properties, declarations.resolve(model.name, slice, slice => slice.readModels)?.node.properties ?? null);\n }\n if (specification.whenTrigger != null) {\n const trigger = (application.declaredTriggers ?? []).find(trigger => trigger.name === specification.whenTrigger!.trigger);\n for (const value of specification.whenTrigger.values) check(value.source, trigger?.data.find(property => property.name === value.property)?.type, value.property);\n }\n for (const error of specification.thenErrors) check(error.caseValue ?? null, { kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: error.location }, 'message');\n for (const absent of specification.thenAbsentReadModels ?? []) {\n const model = declarations.resolve(absent.name, slice, slice => slice.readModels)?.node;\n const keyed = declarations.slices.flatMap(({ slice: owner }) => owner.queries.filter(query => query.by !== null && declarations.resolve(query.returnType.name, owner, slice => slice.readModels)?.node === model));\n check(absent.key, model !== undefined && keyed.length === 1 ? keyed[0].by!.type : undefined, 'for');\n }\n for (const query of [...(specification.thenQueries ?? []), ...(specification.whenQuery === null ? [] : [specification.whenQuery])]) {\n const declaration = declarations.resolve(query.query, slice, slice => slice.queries);\n const parameters = declaration === null ? [] : [...(declaration.node.by === null ? [] : [declaration.node.by]), ...declaration.node.filters].map(parameter => ({ ...parameter, kind: 'PropertySyntax' as const, isIdentifier: false }));\n assignments(query.arguments, parameters);\n const properties = declaration === null ? null : declarations.resolve(declaration.node.returnType.name, declaration.slice, slice => slice.readModels)?.node.properties ?? null;\n const results = query.kind === 'SpecificationQuerySyntax' ? query.results : specification.thenResults;\n for (const result of results) assignments(result.properties, properties);\n }\n }\n }\n}\n\nfunction uniqueDestinationType(types: readonly TypeRefSyntax[]): TypeRefSyntax | undefined {\n const distinct = new Map(types.map(type => [JSON.stringify([type.name, type.isOptional, type.isCollection]), type]));\n return distinct.size === 1 ? [...distinct.values()][0] : undefined;\n}\n\n// Memoized per validation pass by declaring slice and resolved event; unresolved and ambiguous (undefined) results are cached too.\nfunction eventDestinationTypes(application: ApplicationSyntax, declarations: RefusalDeclarations): (reference: string, local: SliceSyntax) => TypeRefSyntax | undefined {\n const memo = new Map<SliceSyntax, Map<EventSyntax, TypeRefSyntax | undefined>>();\n return (reference, local) => {\n const event = declarations.event(reference, local);\n if (event === null) return undefined;\n let events = memo.get(local);\n if (events === undefined) memo.set(local, events = new Map());\n if (!events.has(event)) events.set(event, producedDestinationType(event, local, application, declarations));\n return events.get(event);\n };\n}\n\nfunction producedDestinationType(event: EventSyntax, local: SliceSyntax, application: ApplicationSyntax, declarations: RefusalDeclarations): TypeRefSyntax | undefined {\n const resolver = new AuthoringProductionResolver(application);\n const commandTypes = (event: EventSyntax, owners = declarations.slices): TypeRefSyntax[] => owners.flatMap(({ slice }) => slice.commands.flatMap(command => command.produces\n .filter(produced => resolver.isEventProduction(produced, slice) && declarations.event(produced.event, slice) === event)\n .map(produced => commandDestinationType(command, produced, application, { resolver, slice })).filter((type): type is TypeRefSyntax => type !== null)));\n const producerTypes = (event: EventSyntax, visited: Set<EventSyntax>): TypeRefSyntax[] => {\n if (visited.has(event)) return [];\n visited.add(event);\n const types = commandTypes(event);\n for (const { slice } of declarations.slices) {\n for (const trigger of slice.reactions.flatMap(reaction => reaction.triggers)) {\n const sourceName = trigger.source.kind === 'NamedTriggerSourceSyntax' ? trigger.source.name : undefined;\n const source = sourceName === undefined ? null : declarations.event(sourceName, slice);\n for (const produced of trigger.produces.filter(produced => declarations.event(produced.event, slice) === event)) {\n if (produced.for?.kind === 'PathExpressionSyntax') {\n const path = produced.for.path;\n const type = declarations.property(source?.properties ?? null, path)?.type ?? (sourceName === undefined ? undefined\n : (application.declaredTriggers ?? []).find(declared => declared.name === sourceName)?.data.find(property => property.name === path)?.type);\n if (type !== undefined) types.push(type);\n } else if (produced.for?.kind === 'LiteralExpressionSyntax') types.push({ kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: produced.location });\n else if (produced.for === null && source !== null) types.push(...producerTypes(source, visited));\n }\n }\n if (slice.captures.flatMap(capture => [...capture.appends, ...capture.children.flatMap(child => child.appends), ...capture.nested.flatMap(nested => nested.appends)]).some(append => declarations.event(append.event, slice) === event))\n types.push(uniqueDestinationType(commandTypes(event)) ?? { kind: 'TypeRefSyntax', name: 'String', isOptional: false, isCollection: false, location: event.location });\n types.push(...foldedSources(declarations, slice, event).flatMap(source => producerTypes(source, visited)));\n }\n return types;\n };\n return uniqueDestinationType(commandTypes(event, declarations.slices.filter(owner => owner.slice === local))) ?? uniqueDestinationType(commandTypes(event)) ?? uniqueDestinationType(producerTypes(event, new Set()));\n}\n"],"mappings":"A,2pBAmBA,MAAMA,kBAAa,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,CAAC,EAE3F,SAAgB,2BAA2B,EAAgC,EAAwB,EAAiE,CAChK,IAAMC,EAAe,IAAIC,EAAoBC,CAAW,EAClDC,EAAWC,EAAsBF,CAAW,EAAGG,EAAkB,sBAAsBH,EAAaF,CAAY,EAChH,UAAa,GAAiBD,EAAW,IAAIO,CAAI,GAAKN,EAAa,SAAS,IAAIM,CAAI,GAAKN,EAAa,MAAM,IAAIM,CAAI,EACpHC,EAAa,IAAI,IAAI,CAAC,GAAGP,EAAa,KAAK,CAAC,CAAC,KAAK,CAACM,EAAME,KAAU,CAACF,EAAM,IAAI,IAAIE,EAAK,WAAW,IAAI,GAAY,CAACC,EAAS,KAAMA,CAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAC/IC,EAASC,IAA6B,IAAA,GAAYX,EAAa,OAAS,CAAC,CAAE,MAAO,CAAC,EAAG,MAAO,CAC/F,KAAM,cAAwB,KAAM,cAAwB,KAAM,GAAI,YAAa,KAAM,SAAUE,EAAY,SAC/G,OAAQ,CAAC,EAAG,SAAU,CAAC,EAAG,QAAS,CAAC,EAAG,YAAa,CAAC,EAAG,SAAU,CAAC,EAAG,UAAW,CAAC,EAAG,YAAa,CAAC,EAAG,WAAY,CAAC,EAAG,QAAS,CAAC,EAAG,eAAgBS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AAQ,GAASC,EAAM,OAAO,EAAG,GAAGD,EAAQ,OAAO,QAAQ,GAAUE,EAAO,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,GAAUrE,EAAa,MAAMsE,EAAO,MAAOxD,CAAK,IAAMsB,CAAK,GAClOiB,EAAM,KAAK,sBAAsB,aAAajB,CAAK,CAAC,GAAK,CAAE,KAAM,gBAAiB,KAAM,SAAU,WAAY,GAAO,aAAc,GAAO,SAAUA,EAAM,QAAS,CAAC,EACxKiB,EAAM,KAAK,GAAGkB,EAAcvE,EAAcc,EAAOsB,CAAK,CAAC,CAAC,QAAQ,GAAU,cAAcG,EAAQuB,CAAO,CAAC,CAAC,CAC7G,CACA,OAAOT,CACX,EACA,OAAO,sBAAsB,aAAajB,EAAOpC,EAAa,OAAO,OAAO,GAAS+C,EAAM,QAAUS,CAAK,CAAC,CAAC,GAAK,sBAAsB,aAAapB,CAAK,CAAC,GAAK,sBAAsB,cAAcA,kBAAO,IAAI,GAAK,CAAC,CACxN,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{eventDeclarations as t}from"../Syntax/EventDeclarations.js";import{dependencySources as n,dependencySourcesOf as r}from"../Syntax/DependencySources.js";import{diagnosticKeyword as i,diagnosticText as a}from"../Diagnostics/DiagnosticArgument.js";import{synthesizePersonaCaller as o}from"../Syntax/PersonaCallers.js";import{specificationCaseOrigins as s}from"../Syntax/SpecificationCaseOrigin.js";import{substituteCase as c}from"./SpecificationCaseParser.js";function specificationExamples(n){let r=[],examples=(e,t)=>{for(let n of e??[])r.push({name:n.name,scope:t,example:n})},features=(e,n)=>{for(let i of e){let e=[...n,i.name];examples(i.examples,e);for(let e of i.slices){let a=[...n,i.name,e.name];examples(e.examples,a);for(let n of new Set(t(e).map(e=>e.name)))r.push({name:n,scope:a,kind:`event`});for(let t of e.commands)r.push({name:t.name,scope:a,kind:`command`});for(let t of e.readModels)r.push({name:t.name,scope:a,kind:`readmodel`})}features(i.features,e)}};examples(n.examples,[]);for(let e of n.concepts)r.push({name:e.name,scope:[],kind:`concept`});for(let e of n.types)r.push({name:e.name,scope:[],kind:`type`});for(let e of n.modules)examples(e.examples,[e.name]),features(e.features,[e.name]);let resolveCandidates=(e,t)=>{let candidates=e=>{let n=e.split(`.`),i=r.filter(e=>e.name===n.at(-1)),a=n.slice(0,-1);if(a.length)return i.filter(e=>a.length<=e.scope.length&&a.every((t,n)=>e.scope[e.scope.length-a.length+n]===t));for(let e=t.length;e>=0;e--){let n=i.filter(n=>e<=n.scope.length&&t.slice(0,e).every((e,t)=>n.scope[t]===e));if(n.length)return n}return[]},i=candidates(e),a=n.imports.filter(t=>t.qualifiedName.split(`.`).at(-1)===e);return!i.length&&a.length===1&&(i=candidates(a[0].qualifiedName)),i},resolve=(e,t)=>{let n=resolveCandidates(e,t);return n.length===1?n[0]:void 0},fixture=(e,t,n)=>{let r=resolve(e,n),i=r?.example;if(!i)return null;let a=resolve(i.type,r.scope);return a?.kind===t?{example:i,name:[...a.scope,a.name].join(`.`)}:null},merge=(e,t)=>[...e.filter(e=>!t.some(t=>t.property===e.property)),...t];return{validateTypes:(t,o)=>{for(let s of r){let r=s.example;if(r===void 0||r.type===``)continue;let c=resolveCandidates(r.type,s.scope),l=c.length===1?c[0]:void 0;if(l===void 0){let i=n.imports.filter(e=>e.qualifiedName===r.type||e.qualifiedName.split(`.`).at(-1)===r.type);if(o&&c.length===0&&i.length===1&&resolveCandidates(i[0].qualifiedName,s.scope).length===0)continue;t.error(e.UnresolvedSpecificationExampleType,`Example '${r.name}' type '${r.type}' is unknown or ambiguous; qualify a declared event, command, or read model.`,r.location,{...a(`example`,r.name),...a(`type`,r.type)})}else l.kind!==`event`&&l.kind!==`command`&&l.kind!==`readmodel`&&t.error(e.UnresolvedSpecificationExampleType,`Example '${r.name}' must name an event, command, or read model, not a ${l.kind??`example`}; example inheritance is not supported.`,r.location,{...a(`example`,r.name),...a(`type`,r.type),...i(`kind`,l.kind??`example`)})}},resolvedExamples:r.filter(e=>e.example!==void 0).flatMap(e=>{let t=resolve(e.example.type,e.scope);return t?.kind===void 0?[]:[{example:e.example,kind:t.kind,name:[...t.scope,t.name].join(`.`),scope:t.scope}]}),eventStep:(e,t,n)=>{let r=fixture(e.eventType,`event`,n),i=r?.example??null,a=i?.stream??i?.noStream??null,o=e.stream??e.noStream??null,s=o??a,c=r===null?e:{...e,eventType:r.name,values:merge(i.values,e.values),for:e.for??i.for,stream:s?.kind===`SpecificationStreamSyntax`?s:null,noStream:s?.kind===`SpecificationNoStreamSyntax`?s:null},l=c.values.map(t=>{let n=i?.values.find(e=>e.property===t.property),r=e.values.includes(t);return{property:t.property,value:t.source,origin:r?n===void 0?`authored`:`override`:`example`,overriddenValue:r?n?.source??null:null}});return c.for!==null&&l.push({property:`for`,value:c.for,origin:e.for===null?`example`:i?.for==null?`authored`:`override`,overriddenValue:e.for===null?null:i?.for??null}),{role:t,authored:e,effective:c,example:i,values:l,route:s===null?null:{value:s,origin:o===null?`example`:a===null?`authored`:`override`,overriddenValue:o===null?null:a}}},command:(e,t)=>{if(!e)return e;let n=fixture(e.commandType,`command`,t);if(!n)return e;let{example:r,name:i}=n;return{...e,commandType:i,values:merge(r.values,e.values),generatedValues:merge(r.generatedValues,e.generatedValues??[]),for:e.for??r.for}},readModel:(e,t)=>{let n=fixture(e.name,`readmodel`,t);return n?{...e,name:n.name,properties:merge(n.example.values,e.properties)}:e}}}function validateSpecificationExampleTypes(e,t,n=!1){specificationExamples(e).validateTypes(t,n)}function specificationCommandExamples(e){return specificationExamples(e).command}function expandSpecificationExamples(e){return expandEffectiveSpecificationExamples(e).application}function expandEffectiveSpecificationExamples(e){let t=specificationExamples(e),i=[],features=(a,l)=>a.map(a=>{let u=[...l,a.name];return{...a,features:features(a.features,u),slices:a.slices.map(u=>{let d=[...l,a.name,u.name],f={...u,specifications:u.specifications.flatMap(n=>{let r=[],event=(e,n)=>{let i=t.eventStep(e,n,d);return r.push(i),i.effective},a=e.personas.find(e=>e.name===n.givenCallerPersona?.name),l=a===void 0?null:o(a,e),u=l?.caller==null?null:{...l.caller,location:n.givenCallerPersona.location};u!==null&&r.push({role:`given caller`,authored:n.givenCallerPersona,effective:u,example:null,route:null,values:l.contributions.map(e=>({property:e.type??e.kind,value:{kind:`LiteralExpressionSyntax`,value:e.kind===`authenticated`||e.value,location:e.location},origin:`persona`,overriddenValue:null,persona:a.name,policy:e.policy}))});let f={...n,...u===null?{}:{givenCaller:u,givenCallerPersona:void 0},given:n.given.map(e=>event(e,`given`)),givenReadModels:n.givenReadModels.map(e=>t.readModel(e,d)),when:t.command(n.when,d),whenAppended:n.whenAppended===null?null:event(n.whenAppended,`when append`),thenEvents:n.thenEvents.map(e=>event(e,`then`)),thenReadModels:n.thenReadModels.map(e=>t.readModel(e,d))};return(n.cases?.length??0)===0?(i.push({authored:n,effective:f,steps:r}),[f]):n.cases.map(e=>{let t=/* @__PURE__ */ new WeakMap,a={...c(f,e,t),name:`${n.name}_${e.name}`,parameters:[],cases:[]};return s.set(a,{table:n.name,case:e.name}),i.push({authored:n,effective:a,table:n.name,case:e.name,steps:r.map(n=>({...n,effective:c(n.effective,e,t),values:n.values.map(n=>n.value.kind===`CaseValueExpressionSyntax`?{...n,value:c(n.value,e,t),origin:`case`,caseParameter:n.value.parameter}:n),route:n.route===null?null:{...n.route,value:c(n.route.value,e,t)}}))}),a})})};return n.set(f,r(u)),f})}});return{application:{...e,modules:e.modules.map(e=>({...e,features:features(e.features,[e.name])}))},specifications:i}}export{expandEffectiveSpecificationExamples,expandSpecificationExamples,specificationCommandExamples,specificationExamples,validateSpecificationExampleTypes};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{diagnosticKeyword as e,diagnosticText as t}from"../Diagnostics/DiagnosticArgument.js";import{DiagnosticCodes as n}from"../Diagnostics/DiagnosticCodes.js";import{synthesizePersonaCaller as r}from"../Syntax/PersonaCallers.js";import{specificationCaseOrigins as i}from"../Syntax/SpecificationCaseOrigin.js";import{substituteCase as a}from"./SpecificationCaseParser.js";import{dependencySources as o,dependencySourcesOf as s}from"../Syntax/DependencySources.js";import{eventDeclarations as c}from"../Syntax/EventDeclarations.js";function specificationExamples(r){let i=[],examples=(e,t)=>{for(let n of e??[])i.push({name:n.name,scope:t,example:n})},features=(e,t)=>{for(let n of e){let e=[...t,n.name];examples(n.examples,e);for(let e of n.slices){let r=[...t,n.name,e.name];examples(e.examples,r);for(let t of new Set(c(e).map(e=>e.name)))i.push({name:t,scope:r,kind:`event`});for(let t of e.commands)i.push({name:t.name,scope:r,kind:`command`});for(let t of e.readModels)i.push({name:t.name,scope:r,kind:`readmodel`})}features(n.features,e)}};examples(r.examples,[]);for(let e of r.concepts)i.push({name:e.name,scope:[],kind:`concept`});for(let e of r.types)i.push({name:e.name,scope:[],kind:`type`});for(let e of r.modules)examples(e.examples,[e.name]),features(e.features,[e.name]);let resolveCandidates=(e,t)=>{let candidates=e=>{let n=e.split(`.`),r=i.filter(e=>e.name===n.at(-1)),a=n.slice(0,-1);if(a.length)return r.filter(e=>a.length<=e.scope.length&&a.every((t,n)=>e.scope[e.scope.length-a.length+n]===t));for(let e=t.length;e>=0;e--){let n=r.filter(n=>e<=n.scope.length&&t.slice(0,e).every((e,t)=>n.scope[t]===e));if(n.length)return n}return[]},n=candidates(e),a=r.imports.filter(t=>t.qualifiedName.split(`.`).at(-1)===e);return!n.length&&a.length===1&&(n=candidates(a[0].qualifiedName)),n},resolve=(e,t)=>{let n=resolveCandidates(e,t);return n.length===1?n[0]:void 0},fixture=(e,t,n)=>{let r=resolve(e,n),i=r?.example;if(!i)return null;let a=resolve(i.type,r.scope);return a?.kind===t?{example:i,name:[...a.scope,a.name].join(`.`)}:null},merge=(e,t)=>[...e.filter(e=>!t.some(t=>t.property===e.property)),...t];return{validateTypes:(a,o)=>{for(let s of i){let i=s.example;if(i===void 0||i.type===``)continue;let c=resolveCandidates(i.type,s.scope),l=c.length===1?c[0]:void 0;if(l===void 0){let e=r.imports.filter(e=>e.qualifiedName===i.type||e.qualifiedName.split(`.`).at(-1)===i.type);if(o&&c.length===0&&e.length===1&&resolveCandidates(e[0].qualifiedName,s.scope).length===0)continue;a.error(n.UnresolvedSpecificationExampleType,`Example '${i.name}' type '${i.type}' is unknown or ambiguous; qualify a declared event, command, or read model.`,i.location,{...t(`example`,i.name),...t(`type`,i.type)})}else l.kind!==`event`&&l.kind!==`command`&&l.kind!==`readmodel`&&a.error(n.UnresolvedSpecificationExampleType,`Example '${i.name}' must name an event, command, or read model, not a ${l.kind??`example`}; example inheritance is not supported.`,i.location,{...t(`example`,i.name),...t(`type`,i.type),...e(`kind`,l.kind??`example`)})}},resolvedExamples:i.filter(e=>e.example!==void 0).flatMap(e=>{let t=resolve(e.example.type,e.scope);return t?.kind===void 0?[]:[{example:e.example,kind:t.kind,name:[...t.scope,t.name].join(`.`),scope:t.scope}]}),eventStep:(e,t,n)=>{let r=fixture(e.eventType,`event`,n),i=r?.example??null,a=i?.stream??i?.noStream??null,o=e.stream??e.noStream??null,s=o??a,c=r===null?e:{...e,eventType:r.name,values:merge(i.values,e.values),for:e.for??i.for,stream:s?.kind===`SpecificationStreamSyntax`?s:null,noStream:s?.kind===`SpecificationNoStreamSyntax`?s:null},l=c.values.map(t=>{let n=i?.values.find(e=>e.property===t.property),r=e.values.includes(t);return{property:t.property,value:t.source,origin:r?n===void 0?`authored`:`override`:`example`,overriddenValue:r?n?.source??null:null}});return c.for!==null&&l.push({property:`for`,value:c.for,origin:e.for===null?`example`:i?.for==null?`authored`:`override`,overriddenValue:e.for===null?null:i?.for??null}),{role:t,authored:e,effective:c,example:i,values:l,route:s===null?null:{value:s,origin:o===null?`example`:a===null?`authored`:`override`,overriddenValue:o===null?null:a}}},command:(e,t)=>{if(!e)return e;let n=fixture(e.commandType,`command`,t);if(!n)return e;let{example:r,name:i}=n;return{...e,commandType:i,values:merge(r.values,e.values),generatedValues:merge(r.generatedValues,e.generatedValues??[]),for:e.for??r.for}},readModel:(e,t)=>{let n=fixture(e.name,`readmodel`,t);return n?{...e,name:n.name,properties:merge(n.example.values,e.properties)}:e}}}function validateSpecificationExampleTypes(e,t,n=!1){specificationExamples(e).validateTypes(t,n)}function specificationCommandExamples(e){return specificationExamples(e).command}function expandSpecificationExamples(e){return expandEffectiveSpecificationExamples(e).application}function expandEffectiveSpecificationExamples(e){let t=specificationExamples(e),n=[],features=(c,l)=>c.map(c=>{let u=[...l,c.name];return{...c,features:features(c.features,u),slices:c.slices.map(u=>{let d=[...l,c.name,u.name],f={...u,specifications:u.specifications.flatMap(o=>{let s=[],event=(e,n)=>{let r=t.eventStep(e,n,d);return s.push(r),r.effective},c=e.personas.find(e=>e.name===o.givenCallerPersona?.name),l=c===void 0?null:r(c,e),u=l?.caller==null?null:{...l.caller,location:o.givenCallerPersona.location};u!==null&&s.push({role:`given caller`,authored:o.givenCallerPersona,effective:u,example:null,route:null,values:l.contributions.map(e=>({property:e.type??e.kind,value:{kind:`LiteralExpressionSyntax`,value:e.kind===`authenticated`||e.value,location:e.location},origin:`persona`,overriddenValue:null,persona:c.name,policy:e.policy}))});let f={...o,...u===null?{}:{givenCaller:u,givenCallerPersona:void 0},given:o.given.map(e=>event(e,`given`)),givenReadModels:o.givenReadModels.map(e=>t.readModel(e,d)),when:t.command(o.when,d),whenAppended:o.whenAppended===null?null:event(o.whenAppended,`when append`),thenEvents:o.thenEvents.map(e=>event(e,`then`)),thenReadModels:o.thenReadModels.map(e=>t.readModel(e,d))};return(o.cases?.length??0)===0?(n.push({authored:o,effective:f,steps:s}),[f]):o.cases.map(e=>{let t=/* @__PURE__ */ new WeakMap,r={...a(f,e,t),name:`${o.name}_${e.name}`,parameters:[],cases:[]};return i.set(r,{table:o.name,case:e.name}),n.push({authored:o,effective:r,table:o.name,case:e.name,steps:s.map(n=>({...n,effective:a(n.effective,e,t),values:n.values.map(n=>n.value.kind===`CaseValueExpressionSyntax`?{...n,value:a(n.value,e,t),origin:`case`,caseParameter:n.value.parameter}:n),route:n.route===null?null:{...n.route,value:a(n.route.value,e,t)}}))}),r})})};return o.set(f,s(u)),f})}});return{application:{...e,modules:e.modules.map(e=>({...e,features:features(e.features,[e.name])}))},specifications:n}}export{expandEffectiveSpecificationExamples,expandSpecificationExamples,specificationCommandExamples,specificationExamples,validateSpecificationExampleTypes};
2
2
  //# sourceMappingURL=SpecificationCommandExamples.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpecificationCommandExamples.js","names":["entries","example","nodes","feature","scope","parent","slice","name","eventDeclarations","event","command","model","application","node","module","parts","reference","named","entry","qualifiers","index","part","depth","visible","matches","imported","declaration","type","kind","inherited","authored","replacement","value","deferImportedTypes","context","DiagnosticCodes","diagnosticText","diagnosticKeyword","resolved","step","route","effective","values","prior","action","specifications","expanded","steps","pair","role","persona","specification","caller","synthesizePersonaCaller","synthesizedCaller","atom","result","copies","substituteCase","row","specificationCaseOrigins","dependencySources","dependencySourcesOf"],"sources":["../../../../../../Compiler/Parsing/SpecificationCommandExamples.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 { diagnosticKeyword, diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ParserContext } from './ParserContext';\nimport { synthesizePersonaCaller } from '../Syntax/PersonaCallers';\nimport { specificationCaseOrigins } from '../Syntax/SpecificationCaseOrigin';\nimport { substituteCase } from './SpecificationCaseParser';\nimport { dependencySources, dependencySourcesOf } from '../Syntax/DependencySources';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { EffectiveSpecification, EffectiveSpecificationStep, EffectiveSpecificationValue, EffectiveSpecificationApplication } from '../Syntax/EffectiveSpecification';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationCommandSyntax, SpecificationEventSyntax, SpecificationReadModelSyntax } from '../Syntax/Specifications';\nimport { SpecificationExampleSyntax } from '../Syntax/SpecificationExampleSyntax';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\n\n// Validators consume effective fixtures without changing the authored syntax.\n// Resolve the example at its use site, then its type at the declaration site.\nexport function specificationExamples(application: ApplicationSyntax) {\n const entries: { name: string; scope: readonly string[]; example?: SpecificationExampleSyntax; kind?: string }[] = [];\n const examples = (nodes: readonly SpecificationExampleSyntax[] | undefined, scope: readonly string[]) => {\n for (const example of nodes ?? []) entries.push({ name: example.name, scope, example });\n };\n const features = (nodes: readonly FeatureSyntax[], parent: readonly string[]) => {\n for (const feature of nodes) {\n const scope = [...parent, feature.name];\n examples(feature.examples, scope);\n for (const slice of feature.slices) {\n const scope = [...parent, feature.name, slice.name];\n examples(slice.examples, scope);\n for (const name of new Set(eventDeclarations(slice).map(event => event.name))) entries.push({ name, scope, kind: 'event' });\n for (const command of slice.commands) entries.push({ name: command.name, scope, kind: 'command' });\n for (const model of slice.readModels) entries.push({ name: model.name, scope, kind: 'readmodel' });\n }\n features(feature.features, scope);\n }\n };\n examples(application.examples, []);\n for (const node of application.concepts) entries.push({ name: node.name, scope: [], kind: 'concept' });\n for (const node of application.types) entries.push({ name: node.name, scope: [], kind: 'type' });\n for (const module of application.modules) { examples(module.examples, [module.name]); features(module.features, [module.name]); }\n const resolveCandidates = (reference: string, scope: readonly string[]) => {\n const candidates = (reference: string) => {\n const parts = reference.split('.');\n const named = entries.filter(entry => entry.name === parts.at(-1));\n const qualifiers = parts.slice(0, -1);\n if (qualifiers.length) return named.filter(entry => qualifiers.length <= entry.scope.length && qualifiers.every((part, index) => entry.scope[entry.scope.length - qualifiers.length + index] === part));\n for (let depth = scope.length; depth >= 0; depth--) {\n const visible = named.filter(entry => depth <= entry.scope.length && scope.slice(0, depth).every((part, index) => entry.scope[index] === part));\n if (visible.length) return visible;\n }\n return [];\n };\n let matches = candidates(reference);\n const imported = application.imports.filter(entry => entry.qualifiedName.split('.').at(-1) === reference);\n if (!matches.length && imported.length === 1) matches = candidates(imported[0].qualifiedName);\n return matches;\n };\n const resolve = (reference: string, scope: readonly string[]) => {\n const matches = resolveCandidates(reference, scope);\n return matches.length === 1 ? matches[0] : undefined;\n };\n const fixture = (reference: string, kind: string, scope: readonly string[]) => {\n const declaration = resolve(reference, scope);\n const example = declaration?.example;\n if (!example) return null;\n const type = resolve(example.type, declaration.scope);\n return type?.kind === kind ? { example, name: [...type.scope, type.name].join('.') } : null;\n };\n const merge = (inherited: readonly PropertyMappingSyntax[], authored: readonly PropertyMappingSyntax[]) => [...inherited.filter(value => !authored.some(replacement => replacement.property === value.property)), ...authored];\n return {\n validateTypes: (context: ParserContext, deferImportedTypes: boolean) => {\n for (const entry of entries) {\n const example = entry.example;\n if (example === undefined || example.type === '') continue;\n const matches = resolveCandidates(example.type, entry.scope);\n const type = matches.length === 1 ? matches[0] : undefined;\n if (type === undefined) {\n const imported = application.imports.filter(imported => imported.qualifiedName === example.type || imported.qualifiedName.split('.').at(-1) === example.type);\n if (deferImportedTypes && matches.length === 0 && imported.length === 1 && resolveCandidates(imported[0].qualifiedName, entry.scope).length === 0) continue;\n context.error(DiagnosticCodes.UnresolvedSpecificationExampleType, `Example '${example.name}' type '${example.type}' is unknown or ambiguous; qualify a declared event, command, or read model.`, example.location, { ...diagnosticText('example', example.name), ...diagnosticText('type', example.type) });\n } else if (type.kind !== 'event' && type.kind !== 'command' && type.kind !== 'readmodel') {\n context.error(DiagnosticCodes.UnresolvedSpecificationExampleType, `Example '${example.name}' must name an event, command, or read model, not a ${type.kind ?? 'example'}; example inheritance is not supported.`, example.location, { ...diagnosticText('example', example.name), ...diagnosticText('type', example.type), ...diagnosticKeyword('kind', type.kind ?? 'example') });\n }\n }\n },\n resolvedExamples: entries.filter(entry => entry.example !== undefined).flatMap(entry => {\n const type = resolve(entry.example!.type, entry.scope);\n return type?.kind === undefined ? [] : [{ example: entry.example!, kind: type.kind, name: [...type.scope, type.name].join('.'), scope: type.scope }];\n }),\n eventStep: (step: SpecificationEventSyntax, role: string, scope: readonly string[]): EffectiveSpecificationStep => {\n const resolved = fixture(step.eventType, 'event', scope);\n const example = resolved?.example ?? null;\n const inherited = example?.stream ?? example?.noStream ?? null;\n const authored = step.stream ?? step.noStream ?? null;\n const route = authored ?? inherited;\n const effective = resolved === null ? step : { ...step, eventType: resolved.name, values: merge(example!.values, step.values), for: step.for ?? example!.for, stream: route?.kind === 'SpecificationStreamSyntax' ? route : null, noStream: route?.kind === 'SpecificationNoStreamSyntax' ? route : null };\n const values: EffectiveSpecificationValue[] = effective.values.map(value => {\n const prior = example?.values.find(prior => prior.property === value.property);\n const replacement = step.values.includes(value);\n return { property: value.property, value: value.source, origin: replacement ? prior === undefined ? 'authored' : 'override' : 'example', overriddenValue: replacement ? prior?.source ?? null : null };\n });\n if (effective.for !== null) values.push({ property: 'for', value: effective.for, origin: step.for === null ? 'example' : example?.for == null ? 'authored' : 'override', overriddenValue: step.for === null ? null : example?.for ?? null });\n return { role, authored: step, effective, example, values, route: route === null ? null : { value: route, origin: authored === null ? 'example' : inherited === null ? 'authored' : 'override', overriddenValue: authored === null ? null : inherited } };\n },\n command: (action: SpecificationCommandSyntax | null, scope: readonly string[]): SpecificationCommandSyntax | null => {\n if (!action) return action;\n const effective = fixture(action.commandType, 'command', scope);\n if (!effective) return action;\n const { example, name } = effective;\n return { ...action, commandType: name, values: merge(example.values, action.values), generatedValues: merge(example.generatedValues, action.generatedValues ?? []), for: action.for ?? example.for };\n },\n readModel: (step: SpecificationReadModelSyntax, scope: readonly string[]): SpecificationReadModelSyntax => {\n const effective = fixture(step.name, 'readmodel', scope);\n if (!effective) return step;\n return { ...step, name: effective.name, properties: merge(effective.example.values, step.properties) };\n },\n };\n}\n\nexport function validateSpecificationExampleTypes(application: ApplicationSyntax, context: ParserContext, deferImportedTypes = false): void {\n specificationExamples(application).validateTypes(context, deferImportedTypes);\n}\n\nexport function specificationCommandExamples(application: ApplicationSyntax): (action: SpecificationCommandSyntax | null, scope: readonly string[]) => SpecificationCommandSyntax | null {\n return specificationExamples(application).command;\n}\n\nexport function expandSpecificationExamples(application: ApplicationSyntax): ApplicationSyntax {\n return expandEffectiveSpecificationExamples(application).application;\n}\n\nexport function expandEffectiveSpecificationExamples(application: ApplicationSyntax): EffectiveSpecificationApplication {\n const effective = specificationExamples(application);\n const specifications: EffectiveSpecification[] = [];\n const features = (nodes: readonly FeatureSyntax[], parent: readonly string[]): FeatureSyntax[] => nodes.map(feature => {\n const scope = [...parent, feature.name];\n return {\n ...feature,\n features: features(feature.features, scope),\n slices: feature.slices.map(slice => {\n const scope = [...parent, feature.name, slice.name];\n const expanded = { ...slice, specifications: slice.specifications.flatMap(specification => {\n const steps: EffectiveSpecificationStep[] = [];\n const event = (step: SpecificationEventSyntax, role: string): SpecificationEventSyntax => {\n const pair = effective.eventStep(step, role, scope);\n steps.push(pair);\n return pair.effective as SpecificationEventSyntax;\n };\n const persona = application.personas.find(persona => persona.name === specification.givenCallerPersona?.name);\n const caller = persona === undefined ? null : synthesizePersonaCaller(persona, application);\n const synthesizedCaller = caller?.caller == null ? null : { ...caller.caller, location: specification.givenCallerPersona!.location };\n if (synthesizedCaller !== null) {\n steps.push({ role: 'given caller', authored: specification.givenCallerPersona!, effective: synthesizedCaller, example: null, route: null,\n values: caller!.contributions.map(atom => ({ property: atom.type ?? atom.kind, value: { kind: 'LiteralExpressionSyntax', value: atom.kind === 'authenticated' ? true : atom.value, location: atom.location }, origin: 'persona', overriddenValue: null, persona: persona!.name, policy: atom.policy })) });\n }\n const result = {\n ...specification,\n ...(synthesizedCaller === null ? {} : { givenCaller: synthesizedCaller, givenCallerPersona: undefined }),\n given: specification.given.map(step => event(step, 'given')),\n givenReadModels: specification.givenReadModels.map(step => effective.readModel(step, scope)),\n when: effective.command(specification.when, scope),\n whenAppended: specification.whenAppended === null ? null : event(specification.whenAppended, 'when append'),\n thenEvents: specification.thenEvents.map(step => event(step, 'then')),\n thenReadModels: specification.thenReadModels.map(step => effective.readModel(step, scope)),\n };\n if ((specification.cases?.length ?? 0) === 0) {\n specifications.push({ authored: specification, effective: result, steps });\n return [result];\n }\n return specification.cases!.map(row => {\n const copies = new WeakMap<object, unknown>();\n const expanded = { ...substituteCase(result, row, copies), name: `${specification.name}_${row.name}`, parameters: [], cases: [] };\n specificationCaseOrigins.set(expanded, { table: specification.name, case: row.name });\n specifications.push({ authored: specification, effective: expanded, table: specification.name, case: row.name,\n steps: steps.map(step => ({ ...step, effective: substituteCase(step.effective, row, copies),\n values: step.values.map(value => value.value.kind === 'CaseValueExpressionSyntax'\n ? { ...value, value: substituteCase(value.value, row, copies), origin: 'case', caseParameter: value.value.parameter } : value),\n route: step.route === null ? null : { ...step.route, value: substituteCase(step.route.value, row, copies) } })) });\n return expanded;\n });\n }) };\n dependencySources.set(expanded, dependencySourcesOf(slice));\n return expanded;\n }),\n };\n });\n return { application: { ...application, modules: application.modules.map(module => ({ ...module, features: features(module.features, [module.name]) })) }, specifications };\n}\n"],"mappings":"ykBAmBA,SAAgB,sBAAsB,EAAgC,CAClE,IAAMA,EAA6G,CAAC,EAC9G,UAAY,EAA0D,IAA6B,CACrG,IAAK,IAAMC,KAAWC,GAAS,CAAC,EAAGF,EAAQ,KAAK,CAAE,KAAMC,EAAQ,KAAM,QAAO,SAAQ,CAAC,CAC1F,EACM,UAAY,EAAiC,IAA8B,CAC7E,IAAK,IAAME,KAAWD,EAAO,CACzB,IAAME,EAAQ,CAAC,GAAGC,EAAQF,EAAQ,IAAI,EACtC,SAASA,EAAQ,SAAUC,CAAK,EAChC,IAAK,IAAME,KAASH,EAAQ,OAAQ,CAChC,IAAMC,EAAQ,CAAC,GAAGC,EAAQF,EAAQ,KAAMG,EAAM,IAAI,EAClD,SAASA,EAAM,SAAUF,CAAK,EAC9B,IAAK,IAAMG,KAAQ,IAAI,IAAIC,EAAkBF,CAAK,CAAC,CAAC,IAAI,GAASG,EAAM,IAAI,CAAC,EAAGT,EAAQ,KAAK,CAAE,OAAM,QAAO,KAAM,OAAQ,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ice","name","eventDeclarations","event","command","model","application","node","module","parts","reference","named","entry","qualifiers","index","part","depth","visible","matches","imported","declaration","type","kind","inherited","authored","replacement","value","deferImportedTypes","context","DiagnosticCodes","diagnosticText","diagnosticKeyword","resolved","step","route","effective","values","prior","action","specifications","expanded","steps","pair","role","persona","specification","caller","synthesizePersonaCaller","synthesizedCaller","atom","result","copies","substituteCase","row","specificationCaseOrigins","dependencySources","dependencySourcesOf"],"sources":["../../../../../../Compiler/Parsing/SpecificationCommandExamples.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 { diagnosticKeyword, diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ParserContext } from './ParserContext';\nimport { synthesizePersonaCaller } from '../Syntax/PersonaCallers';\nimport { specificationCaseOrigins } from '../Syntax/SpecificationCaseOrigin';\nimport { substituteCase } from './SpecificationCaseParser';\nimport { dependencySources, dependencySourcesOf } from '../Syntax/DependencySources';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { EffectiveSpecification, EffectiveSpecificationStep, EffectiveSpecificationValue, EffectiveSpecificationApplication } from '../Syntax/EffectiveSpecification';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationCommandSyntax, SpecificationEventSyntax, SpecificationReadModelSyntax } from '../Syntax/Specifications';\nimport { SpecificationExampleSyntax } from '../Syntax/SpecificationExampleSyntax';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\n\n// Validators consume effective fixtures without changing the authored syntax.\n// Resolve the example at its use site, then its type at the declaration site.\nexport function specificationExamples(application: ApplicationSyntax) {\n const entries: { name: string; scope: readonly string[]; example?: SpecificationExampleSyntax; kind?: string }[] = [];\n const examples = (nodes: readonly SpecificationExampleSyntax[] | undefined, scope: readonly string[]) => {\n for (const example of nodes ?? []) entries.push({ name: example.name, scope, example });\n };\n const features = (nodes: readonly FeatureSyntax[], parent: readonly string[]) => {\n for (const feature of nodes) {\n const scope = [...parent, feature.name];\n examples(feature.examples, scope);\n for (const slice of feature.slices) {\n const scope = [...parent, feature.name, slice.name];\n examples(slice.examples, scope);\n for (const name of new Set(eventDeclarations(slice).map(event => event.name))) entries.push({ name, scope, kind: 'event' });\n for (const command of slice.commands) entries.push({ name: command.name, scope, kind: 'command' });\n for (const model of slice.readModels) entries.push({ name: model.name, scope, kind: 'readmodel' });\n }\n features(feature.features, scope);\n }\n };\n examples(application.examples, []);\n for (const node of application.concepts) entries.push({ name: node.name, scope: [], kind: 'concept' });\n for (const node of application.types) entries.push({ name: node.name, scope: [], kind: 'type' });\n for (const module of application.modules) { examples(module.examples, [module.name]); features(module.features, [module.name]); }\n const resolveCandidates = (reference: string, scope: readonly string[]) => {\n const candidates = (reference: string) => {\n const parts = reference.split('.');\n const named = entries.filter(entry => entry.name === parts.at(-1));\n const qualifiers = parts.slice(0, -1);\n if (qualifiers.length) return named.filter(entry => qualifiers.length <= entry.scope.length && qualifiers.every((part, index) => entry.scope[entry.scope.length - qualifiers.length + index] === part));\n for (let depth = scope.length; depth >= 0; depth--) {\n const visible = named.filter(entry => depth <= entry.scope.length && scope.slice(0, depth).every((part, index) => entry.scope[index] === part));\n if (visible.length) return visible;\n }\n return [];\n };\n let matches = candidates(reference);\n const imported = application.imports.filter(entry => entry.qualifiedName.split('.').at(-1) === reference);\n if (!matches.length && imported.length === 1) matches = candidates(imported[0].qualifiedName);\n return matches;\n };\n const resolve = (reference: string, scope: readonly string[]) => {\n const matches = resolveCandidates(reference, scope);\n return matches.length === 1 ? matches[0] : undefined;\n };\n const fixture = (reference: string, kind: string, scope: readonly string[]) => {\n const declaration = resolve(reference, scope);\n const example = declaration?.example;\n if (!example) return null;\n const type = resolve(example.type, declaration.scope);\n return type?.kind === kind ? { example, name: [...type.scope, type.name].join('.') } : null;\n };\n const merge = (inherited: readonly PropertyMappingSyntax[], authored: readonly PropertyMappingSyntax[]) => [...inherited.filter(value => !authored.some(replacement => replacement.property === value.property)), ...authored];\n return {\n validateTypes: (context: ParserContext, deferImportedTypes: boolean) => {\n for (const entry of entries) {\n const example = entry.example;\n if (example === undefined || example.type === '') continue;\n const matches = resolveCandidates(example.type, entry.scope);\n const type = matches.length === 1 ? matches[0] : undefined;\n if (type === undefined) {\n const imported = application.imports.filter(imported => imported.qualifiedName === example.type || imported.qualifiedName.split('.').at(-1) === example.type);\n if (deferImportedTypes && matches.length === 0 && imported.length === 1 && resolveCandidates(imported[0].qualifiedName, entry.scope).length === 0) continue;\n context.error(DiagnosticCodes.UnresolvedSpecificationExampleType, `Example '${example.name}' type '${example.type}' is unknown or ambiguous; qualify a declared event, command, or read model.`, example.location, { ...diagnosticText('example', example.name), ...diagnosticText('type', example.type) });\n } else if (type.kind !== 'event' && type.kind !== 'command' && type.kind !== 'readmodel') {\n context.error(DiagnosticCodes.UnresolvedSpecificationExampleType, `Example '${example.name}' must name an event, command, or read model, not a ${type.kind ?? 'example'}; example inheritance is not supported.`, example.location, { ...diagnosticText('example', example.name), ...diagnosticText('type', example.type), ...diagnosticKeyword('kind', type.kind ?? 'example') });\n }\n }\n },\n resolvedExamples: entries.filter(entry => entry.example !== undefined).flatMap(entry => {\n const type = resolve(entry.example!.type, entry.scope);\n return type?.kind === undefined ? [] : [{ example: entry.example!, kind: type.kind, name: [...type.scope, type.name].join('.'), scope: type.scope }];\n }),\n eventStep: (step: SpecificationEventSyntax, role: string, scope: readonly string[]): EffectiveSpecificationStep => {\n const resolved = fixture(step.eventType, 'event', scope);\n const example = resolved?.example ?? null;\n const inherited = example?.stream ?? example?.noStream ?? null;\n const authored = step.stream ?? step.noStream ?? null;\n const route = authored ?? inherited;\n const effective = resolved === null ? step : { ...step, eventType: resolved.name, values: merge(example!.values, step.values), for: step.for ?? example!.for, stream: route?.kind === 'SpecificationStreamSyntax' ? route : null, noStream: route?.kind === 'SpecificationNoStreamSyntax' ? route : null };\n const values: EffectiveSpecificationValue[] = effective.values.map(value => {\n const prior = example?.values.find(prior => prior.property === value.property);\n const replacement = step.values.includes(value);\n return { property: value.property, value: value.source, origin: replacement ? prior === undefined ? 'authored' : 'override' : 'example', overriddenValue: replacement ? prior?.source ?? null : null };\n });\n if (effective.for !== null) values.push({ property: 'for', value: effective.for, origin: step.for === null ? 'example' : example?.for == null ? 'authored' : 'override', overriddenValue: step.for === null ? null : example?.for ?? null });\n return { role, authored: step, effective, example, values, route: route === null ? null : { value: route, origin: authored === null ? 'example' : inherited === null ? 'authored' : 'override', overriddenValue: authored === null ? null : inherited } };\n },\n command: (action: SpecificationCommandSyntax | null, scope: readonly string[]): SpecificationCommandSyntax | null => {\n if (!action) return action;\n const effective = fixture(action.commandType, 'command', scope);\n if (!effective) return action;\n const { example, name } = effective;\n return { ...action, commandType: name, values: merge(example.values, action.values), generatedValues: merge(example.generatedValues, action.generatedValues ?? []), for: action.for ?? example.for };\n },\n readModel: (step: SpecificationReadModelSyntax, scope: readonly string[]): SpecificationReadModelSyntax => {\n const effective = fixture(step.name, 'readmodel', scope);\n if (!effective) return step;\n return { ...step, name: effective.name, properties: merge(effective.example.values, step.properties) };\n },\n };\n}\n\nexport function validateSpecificationExampleTypes(application: ApplicationSyntax, context: ParserContext, deferImportedTypes = false): void {\n specificationExamples(application).validateTypes(context, deferImportedTypes);\n}\n\nexport function specificationCommandExamples(application: ApplicationSyntax): (action: SpecificationCommandSyntax | null, scope: readonly string[]) => SpecificationCommandSyntax | null {\n return specificationExamples(application).command;\n}\n\nexport function expandSpecificationExamples(application: ApplicationSyntax): ApplicationSyntax {\n return expandEffectiveSpecificationExamples(application).application;\n}\n\nexport function expandEffectiveSpecificationExamples(application: ApplicationSyntax): EffectiveSpecificationApplication {\n const effective = specificationExamples(application);\n const specifications: EffectiveSpecification[] = [];\n const features = (nodes: readonly FeatureSyntax[], parent: readonly string[]): FeatureSyntax[] => nodes.map(feature => {\n const scope = [...parent, feature.name];\n return {\n ...feature,\n features: features(feature.features, scope),\n slices: feature.slices.map(slice => {\n const scope = [...parent, feature.name, slice.name];\n const expanded = { ...slice, specifications: slice.specifications.flatMap(specification => {\n const steps: EffectiveSpecificationStep[] = [];\n const event = (step: SpecificationEventSyntax, role: string): SpecificationEventSyntax => {\n const pair = effective.eventStep(step, role, scope);\n steps.push(pair);\n return pair.effective as SpecificationEventSyntax;\n };\n const persona = application.personas.find(persona => persona.name === specification.givenCallerPersona?.name);\n const caller = persona === undefined ? null : synthesizePersonaCaller(persona, application);\n const synthesizedCaller = caller?.caller == null ? null : { ...caller.caller, location: specification.givenCallerPersona!.location };\n if (synthesizedCaller !== null) {\n steps.push({ role: 'given caller', authored: specification.givenCallerPersona!, effective: synthesizedCaller, example: null, route: null,\n values: caller!.contributions.map(atom => ({ property: atom.type ?? atom.kind, value: { kind: 'LiteralExpressionSyntax', value: atom.kind === 'authenticated' ? true : atom.value, location: atom.location }, origin: 'persona', overriddenValue: null, persona: persona!.name, policy: atom.policy })) });\n }\n const result = {\n ...specification,\n ...(synthesizedCaller === null ? {} : { givenCaller: synthesizedCaller, givenCallerPersona: undefined }),\n given: specification.given.map(step => event(step, 'given')),\n givenReadModels: specification.givenReadModels.map(step => effective.readModel(step, scope)),\n when: effective.command(specification.when, scope),\n whenAppended: specification.whenAppended === null ? null : event(specification.whenAppended, 'when append'),\n thenEvents: specification.thenEvents.map(step => event(step, 'then')),\n thenReadModels: specification.thenReadModels.map(step => effective.readModel(step, scope)),\n };\n if ((specification.cases?.length ?? 0) === 0) {\n specifications.push({ authored: specification, effective: result, steps });\n return [result];\n }\n return specification.cases!.map(row => {\n const copies = new WeakMap<object, unknown>();\n const expanded = { ...substituteCase(result, row, copies), name: `${specification.name}_${row.name}`, parameters: [], cases: [] };\n specificationCaseOrigins.set(expanded, { table: specification.name, case: row.name });\n specifications.push({ authored: specification, effective: expanded, table: specification.name, case: row.name,\n steps: steps.map(step => ({ ...step, effective: substituteCase(step.effective, row, copies),\n values: step.values.map(value => value.value.kind === 'CaseValueExpressionSyntax'\n ? { ...value, value: substituteCase(value.value, row, copies), origin: 'case', caseParameter: value.value.parameter } : value),\n route: step.route === null ? null : { ...step.route, value: substituteCase(step.route.value, row, copies) } })) });\n return expanded;\n });\n }) };\n dependencySources.set(expanded, dependencySourcesOf(slice));\n return expanded;\n }),\n };\n });\n return { application: { ...application, modules: application.modules.map(module => ({ ...module, features: features(module.features, [module.name]) })) }, specifications };\n}\n"],"mappings":"A,ykBAmBA,SAAgB,sBAAsB,EAAgC,CAClE,IAAMA,EAA6G,CAAC,EAC9G,UAAY,EAA0D,IAA6B,CACrG,IAAK,IAAMC,KAAWC,GAAS,CAAC,EAAGF,EAAQ,KAAK,CAAE,KAAMC,EAAQ,KAAM,QAAO,SAAQ,CAAC,CAC1F,EACM,UAAY,EAAiC,IAA8B,CAC7E,IAAK,IAAME,KAAWD,EAAO,CACzB,IAAME,EAAQ,CAAC,GAAGC,EAAQF,EAAQ,IAAI,EACtC,SAASA,EAAQ,SAAUC,CAAK,EAChC,IAAK,IAAME,KAASH,EAAQ,OAAQ,CAChC,IAAMC,EAAQ,CAAC,GAAGC,EAAQF,EAAQ,KAAMG,EAAM,IAAI,EAClD,SAASA,EAAM,SAAUF,CAAK,EAC9B,IAAK,IAAMG,KAAQ,IAAI,IAAIC,EAAkBF,CAAK,CAAC,CAAC,IAAI,GAASG,EAAM,IAAI,CAAC,EAAGT,EAAQ,KAAK,CAAE,OAAM,QAAO,KAAM,OAAQ,CAAC,EAC1H,IAAK,IAAMU,KAAWJ,EAAM,SAAUN,EAAQ,KAAK,CAAE,KAAMU,EAAQ,KAAM,QAAO,KAAM,SAAU,CAAC,EACjG,IAAK,IAAMC,KAASL,EAAM,WAAYN,EAAQ,KAAK,CAAE,KAAMW,EAAM,KAAM,QAAO,KAAM,WAAY,CAAC,CACrG,CACA,SAASR,EAAQ,SAAUC,CAAK,CACpC,CACJ,EACA,SAASQ,EAAY,SAAU,CAAC,CAAC,EACjC,IAAK,IAAMC,KAAQD,EAAY,SA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EAAI,IAAK,CAAC,EACpFd,EAAe,KAAK,CAAE,SAAUM,EAAe,UAAWL,EAAU,MAAOK,EAAc,KAAM,KAAMQ,EAAI,KACrG,MAAOZ,EAAM,IAAI,IAAS,CAAE,GAAGR,EAAM,UAAWmB,EAAenB,EAAK,UAAWoB,EAAKF,CAAM,EACtF,OAAQlB,EAAK,OAAO,IAAI,GAASP,EAAM,MAAM,OAAS,4BAChD,CAAE,GAAGA,EAAO,MAAO0B,EAAe1B,EAAM,MAAO2B,EAAKF,CAAM,EAAG,OAAQ,OAAQ,cAAezB,EAAM,MAAM,SAAU,EAAIA,CAAK,EACjI,MAAOO,EAAK,QAAU,KAAO,KAAO,CAAE,GAAGA,EAAK,MAAO,MAAOmB,EAAenB,EAAK,MAAM,MAAOoB,EAAKF,CAAM,CAAE,CAAE,EAAE,CAAE,CAAC,EAClHX,CACX,CAAC,CACL,CAAC,CAAE,EAEH,OADAe,EAAkB,IAAIf,EAAUgB,EAAoBxD,CAAK,CAAC,EACnDwC,CACX,CAAC,CACL,CACJ,CAAC,EACD,MAAO,CAAE,YAAa,CAAE,GAAGlC,EAAa,QAASA,EAAY,QAAQ,IAAI,IAAW,CAAE,GAAGE,EAAQ,SAAU,SAASA,EAAO,SAAU,CAACA,EAAO,IAAI,CAAC,CAAE,EAAE,CAAE,EAAG,gBAAe,CAC9K,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,nativePattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{diagnosticText as i}from"../Diagnostics/DiagnosticArgument.js";import{firstWord as a}from"./LineText.js";import{tryParseStructuredMapping as o}from"./StructuredBlockParser.js";import{generatedFixturePattern as s,generatedFixturePrefix as c,parseConcrete as l,parseConcreteMapping as u}from"./SpecificationResponseParser.js";import{caseReferences as d,parseSpecificationValue as f}from"./SpecificationCaseParser.js";import{parseDescription as p}from"./DescriptionParser.js";import{parseSpecificationStream as m,rejectSpecificationRouteChildren as h,specificationStream as g}from"./SpecificationParser.js";const _=n(`^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$`.replaceAll(`\\s`,t)),v=n(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`.replaceAll(`\\s`,t));function parseExample(t,n){let a=_.exec(n.content);if(a===null)return t.error(e.InvalidSpecificationExample,`Invalid example declaration '${n.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,r(n),i(`text`,n.content)),t.skipOpaqueBlock(n.indent),{kind:`SpecificationExampleSyntax`,name:``,type:``,values:[],generatedValues:[],for:null,description:null,location:r(n)};let o=parseFixtureBody(t,n,void 0,!0,a[1]);for(let n of d(o))t.error(e.InvalidSpecificationCaseReference,`Case references are not permitted in example bodies.`,n.location);return{kind:`SpecificationExampleSyntax`,name:a[1],type:a[2],...o,location:r(n)}}function addInlineValue(t,n,i,a){if(i?.groups?.property===void 0)return;let o=i.groups.property,s=i.groups.value,c=n.content.length-s.length,u=r(n),d=l(t,s,{...u,column:u.column+c},e.InvalidSpecificationValue);d!==null&&a.push({kind:`PropertyMappingSyntax`,property:o,source:d,location:{...u,column:u.column+n.content.lastIndexOf(o,n.content.indexOf(`=`))}})}function addFixtureValue(t,n,r,a=[]){[...n,...a].some(e=>e.property===r.property)?t.error(e.DuplicateSpecificationAssignment,`Property '${r.property}' is assigned more than once in this fixture - assign it only once, inline or indented`,r.location,i(`property`,r.property)):n.push(r)}function parseFixtureBody(t,n,l,d=!1,_){let y=[],b=[],x=null,S=null,C,w;addInlineValue(t,n,l,y);for(let l=t.peekChild(n.indent);l!==void 0;l=t.peekChild(n.indent)){t.reader.takeSignificant();let n;if(_!==void 0&&a(l.content)===`description`){S=p(t,l,S,`Example '${_}'`);continue}if(d&&c.test(l.content)){let n=u(t,l,s,e.InvalidGeneratedFixture);n!==null&&(_===void 0?b.push(n):addFixtureValue(t,b,n,y));continue}let T=v.exec(l.content);if(_!==void 0&&T===null&&(a(l.content)===`stream`||l.content.startsWith(`no stream`))){let n=g.exec(l.content);C!==void 0||w!==void 0?(t.error(e.InvalidSpecificationStream,`An event occurrence declares at most one stream or no stream directive.`,r(l)),t.skipOpaqueBlock(l.indent)):l.content===`no stream`?(w={kind:`SpecificationNoStreamSyntax`,location:r(l)},h(t,l)):n===null?(t.error(e.InvalidSpecificationStream,`Expected 'stream Source.Stream', or 'no stream' on an event example.`,r(l)),t.skipOpaqueBlock(l.indent)):C=m(t,l,n)}else if(T!==null)addFixtureValue(t,y,{kind:`PropertyMappingSyntax`,property:T[1],source:f(T[2],r(l),t),location:r(l)},b);else if(a(l.content)===`for`){let n=l.content.substring(3).trim();n.length===0?t.error(e.InvalidSpecificationEventSource,`Invalid event-source assertion 'for' - expected 'for <value>'`,r(l)):x===null?x=f(n,r(l),t):t.error(e.DuplicateSpecificationEventSource,`A specification step can declare its event-source assertion only once`,r(l))}else(n=o(t,l))===void 0?t.error(e.InvalidSpecificationValue,`Invalid property mapping '${l.content}' - expected '<property> = <value>'`,r(l),i(`text`,l.content)):addFixtureValue(t,y,n,b)}return{values:y,for:x,generatedValues:b,description:S,...C===void 0?{}:{stream:C},...w===void 0?{}:{noStream:w}}}export{addFixtureValue,addInlineValue,parseExample,parseFixtureBody};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{diagnosticText as e}from"../Diagnostics/DiagnosticArgument.js";import{DiagnosticCodes as t}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as n,nativePattern as r}from"../Text/patterns.js";import{parseSpecificationStream as i,rejectSpecificationRouteChildren as a,specificationStream as o}from"./SpecificationParser.js";import{parseDescription as s}from"./DescriptionParser.js";import{caseReferences as c,parseSpecificationValue as l}from"./SpecificationCaseParser.js";import{firstWord as u}from"./LineText.js";import{locationOf as d}from"./SourceLine.js";import{generatedFixturePattern as f,generatedFixturePrefix as p,parseConcrete as m,parseConcreteMapping as h}from"./SpecificationResponseParser.js";import{tryParseStructuredMapping as g}from"./StructuredBlockParser.js";const _=r(`^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$`.replaceAll(`\\s`,n)),v=r(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`.replaceAll(`\\s`,n));function parseExample(n,r){let i=_.exec(r.content);if(i===null)return n.error(t.InvalidSpecificationExample,`Invalid example declaration '${r.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,d(r),e(`text`,r.content)),n.skipOpaqueBlock(r.indent),{kind:`SpecificationExampleSyntax`,name:``,type:``,values:[],generatedValues:[],for:null,description:null,location:d(r)};let a=parseFixtureBody(n,r,void 0,!0,i[1]);for(let e of c(a))n.error(t.InvalidSpecificationCaseReference,`Case references are not permitted in example bodies.`,e.location);return{kind:`SpecificationExampleSyntax`,name:i[1],type:i[2],...a,location:d(r)}}function addInlineValue(e,n,r,i){if(r?.groups?.property===void 0)return;let a=r.groups.property,o=r.groups.value,s=n.content.length-o.length,c=d(n),l=m(e,o,{...c,column:c.column+s},t.InvalidSpecificationValue);l!==null&&i.push({kind:`PropertyMappingSyntax`,property:a,source:l,location:{...c,column:c.column+n.content.lastIndexOf(a,n.content.indexOf(`=`))}})}function addFixtureValue(n,r,i,a=[]){[...r,...a].some(e=>e.property===i.property)?n.error(t.DuplicateSpecificationAssignment,`Property '${i.property}' is assigned more than once in this fixture - assign it only once, inline or indented`,i.location,e(`property`,i.property)):r.push(i)}function parseFixtureBody(n,r,c,m=!1,_){let y=[],b=[],x=null,S=null,C,w;addInlineValue(n,r,c,y);for(let c=n.peekChild(r.indent);c!==void 0;c=n.peekChild(r.indent)){n.reader.takeSignificant();let r;if(_!==void 0&&u(c.content)===`description`){S=s(n,c,S,`Example '${_}'`);continue}if(m&&p.test(c.content)){let e=h(n,c,f,t.InvalidGeneratedFixture);e!==null&&(_===void 0?b.push(e):addFixtureValue(n,b,e,y));continue}let T=v.exec(c.content);if(_!==void 0&&T===null&&(u(c.content)===`stream`||c.content.startsWith(`no stream`))){let e=o.exec(c.content);C!==void 0||w!==void 0?(n.error(t.InvalidSpecificationStream,`An event occurrence declares at most one stream or no stream directive.`,d(c)),n.skipOpaqueBlock(c.indent)):c.content===`no stream`?(w={kind:`SpecificationNoStreamSyntax`,location:d(c)},a(n,c)):e===null?(n.error(t.InvalidSpecificationStream,`Expected 'stream Source.Stream', or 'no stream' on an event example.`,d(c)),n.skipOpaqueBlock(c.indent)):C=i(n,c,e)}else if(T!==null)addFixtureValue(n,y,{kind:`PropertyMappingSyntax`,property:T[1],source:l(T[2],d(c),n),location:d(c)},b);else if(u(c.content)===`for`){let e=c.content.substring(3).trim();e.length===0?n.error(t.InvalidSpecificationEventSource,`Invalid event-source assertion 'for' - expected 'for <value>'`,d(c)):x===null?x=l(e,d(c),n):n.error(t.DuplicateSpecificationEventSource,`A specification step can declare its event-source assertion only once`,d(c))}else(r=g(n,c))===void 0?n.error(t.InvalidSpecificationValue,`Invalid property mapping '${c.content}' - expected '<property> = <value>'`,d(c),e(`text`,c.content)):addFixtureValue(n,y,r,b)}return{values:y,for:x,generatedValues:b,description:S,...C===void 0?{}:{stream:C},...w===void 0?{}:{noStream:w}}}export{addFixtureValue,addInlineValue,parseExample,parseFixtureBody};
2
2
  //# sourceMappingURL=SpecificationExampleParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpecificationExampleParser.js","names":["parseMappingSource","header","nativePattern","dotNetWhitespace","mapping","match","line","context","DiagnosticCodes","locationOf","diagnosticText","body","reference","caseReferences","property","text","offset","location","source","parseConcrete","values","other","existing","value","generatedValues","eventSource","description","stream","noStream","parent","inline","child","structured","example","firstWord","parseDescription","allowGenerated","generatedFixturePrefix","fixture","parseConcreteMapping","generatedFixturePattern","route","specificationStream","rejectSpecificationRouteChildren","parseSpecificationStream","parseSpecificationValue","tryParseStructuredMapping"],"sources":["../../../../../../Compiler/Parsing/SpecificationExampleParser.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 { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationNoStreamSyntax, SpecificationStreamSyntax, SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { dotNetWhitespace, nativePattern } from '../Text/patterns';\nimport { parseSpecificationStream, rejectSpecificationRouteChildren, specificationStream } from './SpecificationParser';\nimport { parseDescription } from './DescriptionParser';\nimport { caseReferences, parseSpecificationValue as parseMappingSource } from './SpecificationCaseParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { generatedFixturePattern, generatedFixturePrefix, parseConcrete, parseConcreteMapping } from './SpecificationResponseParser';\nimport { tryParseStructuredMapping } from './StructuredBlockParser';\n\nconst header = nativePattern('^example\\\\s+([A-Z]\\\\w*)\\\\s*:\\\\s*([A-Z]\\\\w*(?:\\\\.\\\\w+)*)$'.replaceAll('\\\\s', dotNetWhitespace));\nconst mapping = nativePattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$'.replaceAll('\\\\s', dotNetWhitespace));\n\nexport function parseExample(context: ParserContext, line: SourceLine): SpecificationExampleSyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationExample, `Invalid example declaration '${line.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`, locationOf(line), diagnosticText('text', line.content));\n context.skipOpaqueBlock(line.indent);\n return { kind: 'SpecificationExampleSyntax', name: '', type: '', values: [], generatedValues: [], for: null, description: null, location: locationOf(line) };\n }\n const body = parseFixtureBody(context, line, undefined, true, match[1]);\n for (const reference of caseReferences(body)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'Case references are not permitted in example bodies.', reference.location);\n return { kind: 'SpecificationExampleSyntax', name: match[1], type: match[2], ...body, location: locationOf(line) };\n}\n\nexport function addInlineValue(context: ParserContext, line: SourceLine, match: RegExpExecArray | undefined, values: PropertyMappingSyntax[]): void {\n if (match?.groups?.property === undefined) return;\n const property = match.groups.property;\n const text = match.groups.value;\n const offset = line.content.length - text.length;\n const location = locationOf(line);\n const source = parseConcrete(context, text, { ...location, column: location.column + offset }, DiagnosticCodes.InvalidSpecificationValue);\n if (source !== null) values.push({ kind: 'PropertyMappingSyntax', property, source, location: { ...location, column: location.column + line.content.lastIndexOf(property, line.content.indexOf('=')) } });\n}\n\nexport function addFixtureValue(context: ParserContext, values: PropertyMappingSyntax[], value: PropertyMappingSyntax, other: readonly PropertyMappingSyntax[] = []): void {\n if ([...values, ...other].some(existing => existing.property === value.property)) {\n context.error(DiagnosticCodes.DuplicateSpecificationAssignment, `Property '${value.property}' is assigned more than once in this fixture - assign it only once, inline or indented`, value.location, diagnosticText('property', value.property));\n return;\n }\n values.push(value);\n}\n\nexport function parseFixtureBody(context: ParserContext, parent: SourceLine, inline?: RegExpExecArray, allowGenerated = false, example?: string): {\n values: PropertyMappingSyntax[]; for: ExpressionSyntax | null; generatedValues: PropertyMappingSyntax[]; description: string | null;\n stream?: SpecificationStreamSyntax; noStream?: SpecificationNoStreamSyntax;\n} {\n const values: PropertyMappingSyntax[] = [];\n const generatedValues: PropertyMappingSyntax[] = [];\n let eventSource: ExpressionSyntax | null = null;\n let description: string | null = null;\n let stream: SpecificationStreamSyntax | undefined;\n let noStream: SpecificationNoStreamSyntax | undefined;\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 let structured: PropertyMappingSyntax | undefined;\n if (example !== undefined && firstWord(child.content) === 'description') {\n description = parseDescription(context, child, description, `Example '${example}'`);\n continue;\n }\n if (allowGenerated && generatedFixturePrefix.test(child.content)) {\n const fixture = parseConcreteMapping(context, child, generatedFixturePattern, DiagnosticCodes.InvalidGeneratedFixture);\n if (fixture !== null) {\n // Preserve validator-owned PLAY0490 for existing generated step fixtures.\n if (example === undefined) generatedValues.push(fixture);\n else addFixtureValue(context, generatedValues, fixture, values);\n }\n continue;\n }\n const match = mapping.exec(child.content);\n if (example !== undefined && match === null && (firstWord(child.content) === 'stream' || child.content.startsWith('no stream'))) {\n const route = specificationStream.exec(child.content);\n if (stream !== undefined || noStream !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'An event occurrence declares at most one stream or no stream directive.', locationOf(child));\n context.skipOpaqueBlock(child.indent);\n } else if (child.content === 'no stream') {\n noStream = { kind: 'SpecificationNoStreamSyntax', location: locationOf(child) };\n rejectSpecificationRouteChildren(context, child);\n } else if (route !== null) {\n stream = parseSpecificationStream(context, child, route);\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Expected 'stream Source.Stream', or 'no stream' on an event example.\", locationOf(child));\n context.skipOpaqueBlock(child.indent);\n }\n continue;\n }\n if (match !== null) {\n addFixtureValue(context, values, { kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], locationOf(child), context), location: locationOf(child) }, generatedValues);\n } else if (firstWord(child.content) === 'for') {\n const source = child.content.substring('for'.length).trim();\n if (source.length === 0) context.error(DiagnosticCodes.InvalidSpecificationEventSource, \"Invalid event-source assertion 'for' - expected 'for <value>'\", locationOf(child));\n else if (eventSource !== null) context.error(DiagnosticCodes.DuplicateSpecificationEventSource, 'A specification step can declare its event-source assertion only once', locationOf(child));\n else eventSource = parseMappingSource(source, locationOf(child), context);\n } else if ((structured = tryParseStructuredMapping(context, child)) !== undefined) {\n addFixtureValue(context, values, structured, generatedValues);\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, generatedValues, description, ...(stream === undefined ? {} : { stream }), ...(noStream === undefined ? {} : { noStream }) };\n}\n"],"mappings":"m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rB,EAAe,OAAQqB,EAAM,OAAO,CAAC,EAFlM,gBAAgBxB,EAASa,EAAQY,EAAYR,CAAe,CAIpE,CACA,MAAO,CAAE,SAAQ,IAAKC,EAAa,kBAAiB,cAAa,GAAIE,IAAW,IAAA,GAAY,CAAC,EAAI,CAAE,QAAO,EAAI,GAAIC,IAAa,IAAA,GAAY,CAAC,EAAI,CAAE,UAAS,CAAG,CAClK"}
1
+ {"version":3,"file":"SpecificationExampleParser.js","names":["parseMappingSource","header","nativePattern","dotNetWhitespace","mapping","match","line","context","DiagnosticCodes","locationOf","diagnosticText","body","reference","caseReferences","property","text","offset","location","source","parseConcrete","values","other","existing","value","generatedValues","eventSource","description","stream","noStream","parent","inline","child","structured","example","firstWord","parseDescription","allowGenerated","generatedFixturePrefix","fixture","parseConcreteMapping","generatedFixturePattern","route","specificationStream","rejectSpecificationRouteChildren","parseSpecificationStream","parseSpecificationValue","tryParseStructuredMapping"],"sources":["../../../../../../Compiler/Parsing/SpecificationExampleParser.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 { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationNoStreamSyntax, SpecificationStreamSyntax, SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { dotNetWhitespace, nativePattern } from '../Text/patterns';\nimport { parseSpecificationStream, rejectSpecificationRouteChildren, specificationStream } from './SpecificationParser';\nimport { parseDescription } from './DescriptionParser';\nimport { caseReferences, parseSpecificationValue as parseMappingSource } from './SpecificationCaseParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { generatedFixturePattern, generatedFixturePrefix, parseConcrete, parseConcreteMapping } from './SpecificationResponseParser';\nimport { tryParseStructuredMapping } from './StructuredBlockParser';\n\nconst header = nativePattern('^example\\\\s+([A-Z]\\\\w*)\\\\s*:\\\\s*([A-Z]\\\\w*(?:\\\\.\\\\w+)*)$'.replaceAll('\\\\s', dotNetWhitespace));\nconst mapping = nativePattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$'.replaceAll('\\\\s', dotNetWhitespace));\n\nexport function parseExample(context: ParserContext, line: SourceLine): SpecificationExampleSyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidSpecificationExample, `Invalid example declaration '${line.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`, locationOf(line), diagnosticText('text', line.content));\n context.skipOpaqueBlock(line.indent);\n return { kind: 'SpecificationExampleSyntax', name: '', type: '', values: [], generatedValues: [], for: null, description: null, location: locationOf(line) };\n }\n const body = parseFixtureBody(context, line, undefined, true, match[1]);\n for (const reference of caseReferences(body)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'Case references are not permitted in example bodies.', reference.location);\n return { kind: 'SpecificationExampleSyntax', name: match[1], type: match[2], ...body, location: locationOf(line) };\n}\n\nexport function addInlineValue(context: ParserContext, line: SourceLine, match: RegExpExecArray | undefined, values: PropertyMappingSyntax[]): void {\n if (match?.groups?.property === undefined) return;\n const property = match.groups.property;\n const text = match.groups.value;\n const offset = line.content.length - text.length;\n const location = locationOf(line);\n const source = parseConcrete(context, text, { ...location, column: location.column + offset }, DiagnosticCodes.InvalidSpecificationValue);\n if (source !== null) values.push({ kind: 'PropertyMappingSyntax', property, source, location: { ...location, column: location.column + line.content.lastIndexOf(property, line.content.indexOf('=')) } });\n}\n\nexport function addFixtureValue(context: ParserContext, values: PropertyMappingSyntax[], value: PropertyMappingSyntax, other: readonly PropertyMappingSyntax[] = []): void {\n if ([...values, ...other].some(existing => existing.property === value.property)) {\n context.error(DiagnosticCodes.DuplicateSpecificationAssignment, `Property '${value.property}' is assigned more than once in this fixture - assign it only once, inline or indented`, value.location, diagnosticText('property', value.property));\n return;\n }\n values.push(value);\n}\n\nexport function parseFixtureBody(context: ParserContext, parent: SourceLine, inline?: RegExpExecArray, allowGenerated = false, example?: string): {\n values: PropertyMappingSyntax[]; for: ExpressionSyntax | null; generatedValues: PropertyMappingSyntax[]; description: string | null;\n stream?: SpecificationStreamSyntax; noStream?: SpecificationNoStreamSyntax;\n} {\n const values: PropertyMappingSyntax[] = [];\n const generatedValues: PropertyMappingSyntax[] = [];\n let eventSource: ExpressionSyntax | null = null;\n let description: string | null = null;\n let stream: SpecificationStreamSyntax | undefined;\n let noStream: SpecificationNoStreamSyntax | undefined;\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 let structured: PropertyMappingSyntax | undefined;\n if (example !== undefined && firstWord(child.content) === 'description') {\n description = parseDescription(context, child, description, `Example '${example}'`);\n continue;\n }\n if (allowGenerated && generatedFixturePrefix.test(child.content)) {\n const fixture = parseConcreteMapping(context, child, generatedFixturePattern, DiagnosticCodes.InvalidGeneratedFixture);\n if (fixture !== null) {\n // Preserve validator-owned PLAY0490 for existing generated step fixtures.\n if (example === undefined) generatedValues.push(fixture);\n else addFixtureValue(context, generatedValues, fixture, values);\n }\n continue;\n }\n const match = mapping.exec(child.content);\n if (example !== undefined && match === null && (firstWord(child.content) === 'stream' || child.content.startsWith('no stream'))) {\n const route = specificationStream.exec(child.content);\n if (stream !== undefined || noStream !== undefined) {\n context.error(DiagnosticCodes.InvalidSpecificationStream, 'An event occurrence declares at most one stream or no stream directive.', locationOf(child));\n context.skipOpaqueBlock(child.indent);\n } else if (child.content === 'no stream') {\n noStream = { kind: 'SpecificationNoStreamSyntax', location: locationOf(child) };\n rejectSpecificationRouteChildren(context, child);\n } else if (route !== null) {\n stream = parseSpecificationStream(context, child, route);\n } else {\n context.error(DiagnosticCodes.InvalidSpecificationStream, \"Expected 'stream Source.Stream', or 'no stream' on an event example.\", locationOf(child));\n context.skipOpaqueBlock(child.indent);\n }\n continue;\n }\n if (match !== null) {\n addFixtureValue(context, values, { kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], locationOf(child), context), location: locationOf(child) }, generatedValues);\n } else if (firstWord(child.content) === 'for') {\n const source = child.content.substring('for'.length).trim();\n if (source.length === 0) context.error(DiagnosticCodes.InvalidSpecificationEventSource, \"Invalid event-source assertion 'for' - expected 'for <value>'\", locationOf(child));\n else if (eventSource !== null) context.error(DiagnosticCodes.DuplicateSpecificationEventSource, 'A specification step can declare its event-source assertion only once', locationOf(child));\n else eventSource = parseMappingSource(source, locationOf(child), context);\n } else if ((structured = tryParseStructuredMapping(context, child)) !== undefined) {\n addFixtureValue(context, values, structured, generatedValues);\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, generatedValues, description, ...(stream === undefined ? {} : { stream }), ...(noStream === undefined ? {} : { noStream }) };\n}\n"],"mappings":"A,m1BAiBA,MAAMC,EAASC,EAAc,2DAA2D,WAAW,MAAOC,CAAgB,CAAC,EACrHC,EAAUF,EAAc,kCAAkC,WAAW,MAAOC,CAAgB,CAAC,EAEnG,SAAgB,aAAa,EAAwB,EAA8C,CAC/F,IAAME,EAAQJ,EAAO,KAAKK,EAAK,OAAO,EACtC,GAAID,IAAU,KAGV,OAFAE,EAAQ,MAAMC,EAAgB,4BAA6B,gCAAgCF,EAAK,QAAQ,6DAA8DG,EAAWH,CAAI,EAAGI,EAAe,OAAQJ,EAAK,OAAO,CAAC,EAC5NC,EAAQ,gBAAgBD,EAAK,MAAM,EAC5B,CAAE,KAAM,6BAA8B,KAAM,GAAI,KAAM,GAAI,OAAQ,CAAC,EAAG,gBAAiB,CAAC,EAAG,IAAK,KAAM,YAAa,KAAM,SAAUG,EAAWH,CAAI,CAAE,EAE/J,IAAMK,EAAO,iBAAiBJ,EAASD,EAAM,IAAA,GAAW,GA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