@cratis/screenplay-language 4.123.0 → 4.124.1

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 (402) hide show
  1. package/README.md +50 -0
  2. package/dist/bundles/TypeReferenceSymbol.js +2 -0
  3. package/dist/bundles/TypeReferenceSymbol.js.map +1 -0
  4. package/dist/bundles/_virtual/_virtual/_rolldown/runtime.js +1 -0
  5. package/dist/bundles/bmp-word-characters.js +2 -0
  6. package/dist/bundles/bmp-word-characters.js.map +1 -0
  7. package/dist/bundles/case-authoring.js +3 -0
  8. package/dist/bundles/case-authoring.js.map +1 -0
  9. package/dist/bundles/code-actions.js +2 -0
  10. package/dist/bundles/code-actions.js.map +1 -0
  11. package/dist/bundles/compiler/Authoring/QuickFixes.js +5 -0
  12. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -0
  13. package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js +2 -0
  14. package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js.map +1 -0
  15. package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js +2 -0
  16. package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js.map +1 -0
  17. package/dist/bundles/compiler/Dependencies/DependencyGraph.js +2 -0
  18. package/dist/bundles/compiler/Dependencies/DependencyGraph.js.map +1 -0
  19. package/dist/bundles/compiler/Dependencies/DependencyKind.js +2 -0
  20. package/dist/bundles/compiler/Dependencies/DependencyKind.js.map +1 -0
  21. package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js +2 -0
  22. package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js.map +1 -0
  23. package/dist/bundles/compiler/Dependencies/SliceReferences.js +2 -0
  24. package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -0
  25. package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js +2 -0
  26. package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js.map +1 -0
  27. package/dist/bundles/compiler/Dependencies/index.js +1 -0
  28. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +2 -0
  29. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -0
  30. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js +2 -0
  31. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js.map +1 -0
  32. package/dist/bundles/compiler/Diagnostics/SourceLocation.js +2 -0
  33. package/dist/bundles/compiler/Diagnostics/SourceLocation.js.map +1 -0
  34. package/dist/bundles/compiler/Files/AuthoredOrder.js +2 -0
  35. package/dist/bundles/compiler/Files/AuthoredOrder.js.map +1 -0
  36. package/dist/bundles/compiler/Files/OrderingRoot.js +1 -0
  37. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js +2 -0
  38. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js.map +1 -0
  39. package/dist/bundles/compiler/Files/PlayFolderMerge.js +2 -0
  40. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -0
  41. package/dist/bundles/compiler/Files/PlayImports.js +1 -0
  42. package/dist/bundles/compiler/Files/PlayPlacement.js +2 -0
  43. package/dist/bundles/compiler/Files/PlayPlacement.js.map +1 -0
  44. package/dist/bundles/compiler/Files/TimelineOrder.js +2 -0
  45. package/dist/bundles/compiler/Files/TimelineOrder.js.map +1 -0
  46. package/dist/bundles/compiler/Parsing/AuthorizeParser.js +2 -0
  47. package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -0
  48. package/dist/bundles/compiler/Parsing/CaptureParser.js +2 -0
  49. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -0
  50. package/dist/bundles/compiler/Parsing/CodeBlockParser.js +3 -0
  51. package/dist/bundles/compiler/Parsing/CodeBlockParser.js.map +1 -0
  52. package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js +2 -0
  53. package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js.map +1 -0
  54. package/dist/bundles/compiler/Parsing/CommandParser.js +2 -0
  55. package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -0
  56. package/dist/bundles/compiler/Parsing/CommandReadSources.js +2 -0
  57. package/dist/bundles/compiler/Parsing/CommandReadSources.js.map +1 -0
  58. package/dist/bundles/compiler/Parsing/CommandResponseParser.js +2 -0
  59. package/dist/bundles/compiler/Parsing/CommandResponseParser.js.map +1 -0
  60. package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js +2 -0
  61. package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js.map +1 -0
  62. package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js +2 -0
  63. package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js.map +1 -0
  64. package/dist/bundles/compiler/Parsing/CompositionParser.js +2 -0
  65. package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -0
  66. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +2 -0
  67. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -0
  68. package/dist/bundles/compiler/Parsing/ConditionParser.js +2 -0
  69. package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -0
  70. package/dist/bundles/compiler/Parsing/ConstraintParser.js +2 -0
  71. package/dist/bundles/compiler/Parsing/ConstraintParser.js.map +1 -0
  72. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js +2 -0
  73. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js.map +1 -0
  74. package/dist/bundles/compiler/Parsing/DeclarationParsers.js +2 -0
  75. package/dist/bundles/compiler/Parsing/DeclarationParsers.js.map +1 -0
  76. package/dist/bundles/compiler/Parsing/DependencySourceParser.js +2 -0
  77. package/dist/bundles/compiler/Parsing/DependencySourceParser.js.map +1 -0
  78. package/dist/bundles/compiler/Parsing/DependsOnParser.js +2 -0
  79. package/dist/bundles/compiler/Parsing/DependsOnParser.js.map +1 -0
  80. package/dist/bundles/compiler/Parsing/DescriptionParser.js +2 -0
  81. package/dist/bundles/compiler/Parsing/DescriptionParser.js.map +1 -0
  82. package/dist/bundles/compiler/Parsing/DocumentationParser.js +2 -0
  83. package/dist/bundles/compiler/Parsing/DocumentationParser.js.map +1 -0
  84. package/dist/bundles/compiler/Parsing/EventMetadataParser.js +2 -0
  85. package/dist/bundles/compiler/Parsing/EventMetadataParser.js.map +1 -0
  86. package/dist/bundles/compiler/Parsing/EventSourceParser.js +2 -0
  87. package/dist/bundles/compiler/Parsing/EventSourceParser.js.map +1 -0
  88. package/dist/bundles/compiler/Parsing/EventSourceValidator.js +2 -0
  89. package/dist/bundles/compiler/Parsing/EventSourceValidator.js.map +1 -0
  90. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js +2 -0
  91. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js.map +1 -0
  92. package/dist/bundles/compiler/Parsing/ExpressionParser.js +2 -0
  93. package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -0
  94. package/dist/bundles/compiler/Parsing/FeatureBody.js +2 -0
  95. package/dist/bundles/compiler/Parsing/FeatureBody.js.map +1 -0
  96. package/dist/bundles/compiler/Parsing/FileImportParser.js +2 -0
  97. package/dist/bundles/compiler/Parsing/FileImportParser.js.map +1 -0
  98. package/dist/bundles/compiler/Parsing/FileReferences.js +2 -0
  99. package/dist/bundles/compiler/Parsing/FileReferences.js.map +1 -0
  100. package/dist/bundles/compiler/Parsing/GuardedActionParser.js +2 -0
  101. package/dist/bundles/compiler/Parsing/GuardedActionParser.js.map +1 -0
  102. package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js +2 -0
  103. package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js.map +1 -0
  104. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +2 -0
  105. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -0
  106. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js +2 -0
  107. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js.map +1 -0
  108. package/dist/bundles/compiler/Parsing/IdentityParser.js +2 -0
  109. package/dist/bundles/compiler/Parsing/IdentityParser.js.map +1 -0
  110. package/dist/bundles/compiler/Parsing/IdentityValidator.js +2 -0
  111. package/dist/bundles/compiler/Parsing/IdentityValidator.js.map +1 -0
  112. package/dist/bundles/compiler/Parsing/ImplementationParser.js +3 -0
  113. package/dist/bundles/compiler/Parsing/ImplementationParser.js.map +1 -0
  114. package/dist/bundles/compiler/Parsing/ImportDiscovery.js +1 -0
  115. package/dist/bundles/compiler/Parsing/InlineEventValidator.js +2 -0
  116. package/dist/bundles/compiler/Parsing/InlineEventValidator.js.map +1 -0
  117. package/dist/bundles/compiler/Parsing/InputUses.js +2 -0
  118. package/dist/bundles/compiler/Parsing/InputUses.js.map +1 -0
  119. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +2 -0
  120. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js.map +1 -0
  121. package/dist/bundles/compiler/Parsing/LineReader.js +2 -0
  122. package/dist/bundles/compiler/Parsing/LineReader.js.map +1 -0
  123. package/dist/bundles/compiler/Parsing/LineText.js +2 -0
  124. package/dist/bundles/compiler/Parsing/LineText.js.map +1 -0
  125. package/dist/bundles/compiler/Parsing/ModuleBody.js +2 -0
  126. package/dist/bundles/compiler/Parsing/ModuleBody.js.map +1 -0
  127. package/dist/bundles/compiler/Parsing/OperationParser.js +2 -0
  128. package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -0
  129. package/dist/bundles/compiler/Parsing/OperationValidator.js +2 -0
  130. package/dist/bundles/compiler/Parsing/OperationValidator.js.map +1 -0
  131. package/dist/bundles/compiler/Parsing/ParserContext.js +2 -0
  132. package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -0
  133. package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js +2 -0
  134. package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js.map +1 -0
  135. package/dist/bundles/compiler/Parsing/PolicyParser.js +2 -0
  136. package/dist/bundles/compiler/Parsing/PolicyParser.js.map +1 -0
  137. package/dist/bundles/compiler/Parsing/ProducesParser.js +2 -0
  138. package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -0
  139. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js +2 -0
  140. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js.map +1 -0
  141. package/dist/bundles/compiler/Parsing/ProjectionParser.js +2 -0
  142. package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -0
  143. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +2 -0
  144. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -0
  145. package/dist/bundles/compiler/Parsing/PropertyLineParser.js +2 -0
  146. package/dist/bundles/compiler/Parsing/PropertyLineParser.js.map +1 -0
  147. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js +2 -0
  148. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js.map +1 -0
  149. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js +2 -0
  150. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js.map +1 -0
  151. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +2 -0
  152. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -0
  153. package/dist/bundles/compiler/Parsing/PurposeParser.js +2 -0
  154. package/dist/bundles/compiler/Parsing/PurposeParser.js.map +1 -0
  155. package/dist/bundles/compiler/Parsing/PurposeValidator.js +2 -0
  156. package/dist/bundles/compiler/Parsing/PurposeValidator.js.map +1 -0
  157. package/dist/bundles/compiler/Parsing/QueryParser.js +2 -0
  158. package/dist/bundles/compiler/Parsing/QueryParser.js.map +1 -0
  159. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +2 -0
  160. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js.map +1 -0
  161. package/dist/bundles/compiler/Parsing/ReactionParser.js +2 -0
  162. package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -0
  163. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js +2 -0
  164. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js.map +1 -0
  165. package/dist/bundles/compiler/Parsing/RedeliveryValues.js +2 -0
  166. package/dist/bundles/compiler/Parsing/RedeliveryValues.js.map +1 -0
  167. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js +2 -0
  168. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js.map +1 -0
  169. package/dist/bundles/compiler/Parsing/RefusalValueWalker.js +2 -0
  170. package/dist/bundles/compiler/Parsing/RefusalValueWalker.js.map +1 -0
  171. package/dist/bundles/compiler/Parsing/ResponseDateValues.js +2 -0
  172. package/dist/bundles/compiler/Parsing/ResponseDateValues.js.map +1 -0
  173. package/dist/bundles/compiler/Parsing/ResponseValidator.js +2 -0
  174. package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -0
  175. package/dist/bundles/compiler/Parsing/ScreenParser.js +2 -0
  176. package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -0
  177. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +2 -0
  178. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -0
  179. package/dist/bundles/compiler/Parsing/SeedParser.js +2 -0
  180. package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -0
  181. package/dist/bundles/compiler/Parsing/SliceParser.js +2 -0
  182. package/dist/bundles/compiler/Parsing/SliceParser.js.map +1 -0
  183. package/dist/bundles/compiler/Parsing/SourceLine.js +2 -0
  184. package/dist/bundles/compiler/Parsing/SourceLine.js.map +1 -0
  185. package/dist/bundles/compiler/Parsing/SourceLineSplitter.js +3 -0
  186. package/dist/bundles/compiler/Parsing/SourceLineSplitter.js.map +1 -0
  187. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +2 -0
  188. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js.map +1 -0
  189. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +2 -0
  190. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -0
  191. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +2 -0
  192. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -0
  193. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +2 -0
  194. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -0
  195. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +2 -0
  196. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -0
  197. package/dist/bundles/compiler/Parsing/SpecificationParser.js +2 -0
  198. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -0
  199. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js +2 -0
  200. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js.map +1 -0
  201. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +2 -0
  202. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -0
  203. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js +2 -0
  204. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js.map +1 -0
  205. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +2 -0
  206. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -0
  207. package/dist/bundles/compiler/Parsing/StructuredValueParser.js +3 -0
  208. package/dist/bundles/compiler/Parsing/StructuredValueParser.js.map +1 -0
  209. package/dist/bundles/compiler/Parsing/TriggerDataParser.js +2 -0
  210. package/dist/bundles/compiler/Parsing/TriggerDataParser.js.map +1 -0
  211. package/dist/bundles/compiler/Parsing/UiBindingParser.js +2 -0
  212. package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -0
  213. package/dist/bundles/compiler/ScreenplayCompiler.js +2 -0
  214. package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -0
  215. package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js +2 -0
  216. package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js.map +1 -0
  217. package/dist/bundles/compiler/Syntax/CaptureEventsSource.js +2 -0
  218. package/dist/bundles/compiler/Syntax/CaptureEventsSource.js.map +1 -0
  219. package/dist/bundles/compiler/Syntax/DependencySources.js +2 -0
  220. package/dist/bundles/compiler/Syntax/DependencySources.js.map +1 -0
  221. package/dist/bundles/compiler/Syntax/EventDeclarations.js +2 -0
  222. package/dist/bundles/compiler/Syntax/EventDeclarations.js.map +1 -0
  223. package/dist/bundles/compiler/Syntax/EventSourceCatalog.js +2 -0
  224. package/dist/bundles/compiler/Syntax/EventSourceCatalog.js.map +1 -0
  225. package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js +2 -0
  226. package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js.map +1 -0
  227. package/dist/bundles/compiler/Syntax/ExactMathFacts.js +2 -0
  228. package/dist/bundles/compiler/Syntax/ExactMathFacts.js.map +1 -0
  229. package/dist/bundles/compiler/Syntax/ExactNumber.js +2 -0
  230. package/dist/bundles/compiler/Syntax/ExactNumber.js.map +1 -0
  231. package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js +2 -0
  232. package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js.map +1 -0
  233. package/dist/bundles/compiler/Syntax/LegacyWireProjection.js +2 -0
  234. package/dist/bundles/compiler/Syntax/LegacyWireProjection.js.map +1 -0
  235. package/dist/bundles/compiler/Syntax/Operations.js +2 -0
  236. package/dist/bundles/compiler/Syntax/Operations.js.map +1 -0
  237. package/dist/bundles/compiler/Syntax/PersonaCallers.js +2 -0
  238. package/dist/bundles/compiler/Syntax/PersonaCallers.js.map +1 -0
  239. package/dist/bundles/compiler/Syntax/ProductionDestinations.js +2 -0
  240. package/dist/bundles/compiler/Syntax/ProductionDestinations.js.map +1 -0
  241. package/dist/bundles/compiler/Syntax/PublicEventInvariants.js +2 -0
  242. package/dist/bundles/compiler/Syntax/PublicEventInvariants.js.map +1 -0
  243. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js +2 -0
  244. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -0
  245. package/dist/bundles/compiler/Syntax/SourceOptions.js +2 -0
  246. package/dist/bundles/compiler/Syntax/SourceOptions.js.map +1 -0
  247. package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js +2 -0
  248. package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js.map +1 -0
  249. package/dist/bundles/compiler/Syntax/StreamIdFormatter.js +2 -0
  250. package/dist/bundles/compiler/Syntax/StreamIdFormatter.js.map +1 -0
  251. package/dist/bundles/compiler/Syntax/StrictSyntaxJson.js +1 -0
  252. package/dist/bundles/compiler/Syntax/Structure.js +2 -0
  253. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -0
  254. package/dist/bundles/compiler/Syntax/SyntaxCollections.js +2 -0
  255. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -0
  256. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +2 -0
  257. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -0
  258. package/dist/bundles/compiler/Syntax/SyntaxJson.js +2 -0
  259. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -0
  260. package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js +2 -0
  261. package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js.map +1 -0
  262. package/dist/bundles/compiler/Syntax/index.js +1 -0
  263. package/dist/bundles/compiler/Text/ImplementationHintText.js +2 -0
  264. package/dist/bundles/compiler/Text/ImplementationHintText.js.map +1 -0
  265. package/dist/bundles/compiler/Text/ReservedWords.js +2 -0
  266. package/dist/bundles/compiler/Text/ReservedWords.js.map +1 -0
  267. package/dist/bundles/compiler/Text/SourceStreamNames.js +2 -0
  268. package/dist/bundles/compiler/Text/SourceStreamNames.js.map +1 -0
  269. package/dist/bundles/compiler/Text/StringLiteral.js +3 -0
  270. package/dist/bundles/compiler/Text/StringLiteral.js.map +1 -0
  271. package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js +2 -0
  272. package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js.map +1 -0
  273. package/dist/bundles/compiler/Text/patterns.js +2 -0
  274. package/dist/bundles/compiler/Text/patterns.js.map +1 -0
  275. package/dist/bundles/compiler/index.js +1 -0
  276. package/dist/bundles/completion-items.js +21 -0
  277. package/dist/bundles/completion-items.js.map +1 -0
  278. package/dist/bundles/completion-planner.js +5 -0
  279. package/dist/bundles/completion-planner.js.map +1 -0
  280. package/dist/bundles/completions.js +2 -0
  281. package/dist/bundles/completions.js.map +1 -0
  282. package/dist/bundles/dependency-completions.js +3 -0
  283. package/dist/bundles/dependency-completions.js.map +1 -0
  284. package/dist/bundles/dependency-target-analysis.js +2 -0
  285. package/dist/bundles/dependency-target-analysis.js.map +1 -0
  286. package/dist/bundles/diagnostic-codes.js +2 -0
  287. package/dist/bundles/diagnostic-codes.js.map +1 -0
  288. package/dist/bundles/diagnostics.js +2 -0
  289. package/dist/bundles/diagnostics.js.map +1 -0
  290. package/dist/bundles/document-context.js +2 -0
  291. package/dist/bundles/document-context.js.map +1 -0
  292. package/dist/bundles/documentation-item.js +2 -0
  293. package/dist/bundles/documentation-item.js.map +1 -0
  294. package/dist/bundles/event-analysis-source.js +2 -0
  295. package/dist/bundles/event-analysis-source.js.map +1 -0
  296. package/dist/bundles/event-context-catalog.js +2 -0
  297. package/dist/bundles/event-context-catalog.js.map +1 -0
  298. package/dist/bundles/event-context.js +4 -0
  299. package/dist/bundles/event-context.js.map +1 -0
  300. package/dist/bundles/event-source-authoring.js +13 -0
  301. package/dist/bundles/event-source-authoring.js.map +1 -0
  302. package/dist/bundles/example-analysis.js +3 -0
  303. package/dist/bundles/example-analysis.js.map +1 -0
  304. package/dist/bundles/example-authoring.js +3 -0
  305. package/dist/bundles/example-authoring.js.map +1 -0
  306. package/dist/bundles/example-declaration-items.js +2 -0
  307. package/dist/bundles/example-declaration-items.js.map +1 -0
  308. package/dist/bundles/example-values.js +2 -0
  309. package/dist/bundles/example-values.js.map +1 -0
  310. package/dist/bundles/file-imports.js +2 -0
  311. package/dist/bundles/file-imports.js.map +1 -0
  312. package/dist/bundles/file-references.js +2 -0
  313. package/dist/bundles/file-references.js.map +1 -0
  314. package/dist/bundles/hover-content.js +6 -0
  315. package/dist/bundles/hover-content.js.map +1 -0
  316. package/dist/bundles/hover.js +2 -0
  317. package/dist/bundles/hover.js.map +1 -0
  318. package/dist/bundles/index.js +2 -104
  319. package/dist/bundles/index.js.map +1 -7
  320. package/dist/bundles/inlay-hints.js +2 -0
  321. package/dist/bundles/inlay-hints.js.map +1 -0
  322. package/dist/bundles/inline-completions.js +2 -0
  323. package/dist/bundles/inline-completions.js.map +1 -0
  324. package/dist/bundles/inline-event-validation.js +2 -0
  325. package/dist/bundles/inline-event-validation.js.map +1 -0
  326. package/dist/bundles/keyword-docs.js +2 -0
  327. package/dist/bundles/keyword-docs.js.map +1 -0
  328. package/dist/bundles/language.js +2 -0
  329. package/dist/bundles/language.js.map +1 -0
  330. package/dist/bundles/named-rule-context.js +2 -0
  331. package/dist/bundles/named-rule-context.js.map +1 -0
  332. package/dist/bundles/operation-authoring.js +7 -0
  333. package/dist/bundles/operation-authoring.js.map +1 -0
  334. package/dist/bundles/persona-analysis.js +2 -0
  335. package/dist/bundles/persona-analysis.js.map +1 -0
  336. package/dist/bundles/production-destinations.js +2 -0
  337. package/dist/bundles/production-destinations.js.map +1 -0
  338. package/dist/bundles/purpose-items.js +2 -0
  339. package/dist/bundles/purpose-items.js.map +1 -0
  340. package/dist/bundles/reaction-authoring.js +5 -0
  341. package/dist/bundles/reaction-authoring.js.map +1 -0
  342. package/dist/bundles/refusal-context.js +2 -0
  343. package/dist/bundles/refusal-context.js.map +1 -0
  344. package/dist/bundles/response-analysis.js +7 -0
  345. package/dist/bundles/response-analysis.js.map +1 -0
  346. package/dist/bundles/response-completions.js +2 -0
  347. package/dist/bundles/response-completions.js.map +1 -0
  348. package/dist/bundles/response-tokens.js +3 -0
  349. package/dist/bundles/response-tokens.js.map +1 -0
  350. package/dist/bundles/scope-items.js +18 -0
  351. package/dist/bundles/scope-items.js.map +1 -0
  352. package/dist/bundles/structure-completions.js +7 -0
  353. package/dist/bundles/structure-completions.js.map +1 -0
  354. package/dist/bundles/sub-language-registry.js +2 -0
  355. package/dist/bundles/sub-language-registry.js.map +1 -0
  356. package/dist/bundles/sub-languages/capture/CompletionProvider.js +2 -0
  357. package/dist/bundles/sub-languages/capture/CompletionProvider.js.map +1 -0
  358. package/dist/bundles/sub-languages/capture/HoverProvider.js +60 -0
  359. package/dist/bundles/sub-languages/capture/HoverProvider.js.map +1 -0
  360. package/dist/bundles/sub-languages/capture/Validator.js +2 -0
  361. package/dist/bundles/sub-languages/capture/Validator.js.map +1 -0
  362. package/dist/bundles/sub-languages/capture/index.js +2 -40
  363. package/dist/bundles/sub-languages/capture/index.js.map +1 -7
  364. package/dist/bundles/sub-languages/capture/language.js +2 -0
  365. package/dist/bundles/sub-languages/capture/language.js.map +1 -0
  366. package/dist/bundles/sub-languages/cdl.js +2 -0
  367. package/dist/bundles/sub-languages/cdl.js.map +1 -0
  368. package/dist/bundles/sub-languages/pdl.js +2 -0
  369. package/dist/bundles/sub-languages/pdl.js.map +1 -0
  370. package/dist/bundles/sub-languages/projection/CodeActionProvider.js +2 -0
  371. package/dist/bundles/sub-languages/projection/CodeActionProvider.js.map +1 -0
  372. package/dist/bundles/sub-languages/projection/CompletionProvider.js +2 -0
  373. package/dist/bundles/sub-languages/projection/CompletionProvider.js.map +1 -0
  374. package/dist/bundles/sub-languages/projection/HoverProvider.js +43 -0
  375. package/dist/bundles/sub-languages/projection/HoverProvider.js.map +1 -0
  376. package/dist/bundles/sub-languages/projection/Validator.js +5 -0
  377. package/dist/bundles/sub-languages/projection/Validator.js.map +1 -0
  378. package/dist/bundles/sub-languages/projection/index.js +3 -75
  379. package/dist/bundles/sub-languages/projection/index.js.map +1 -7
  380. package/dist/bundles/sub-languages/projection/language.js +2 -0
  381. package/dist/bundles/sub-languages/projection/language.js.map +1 -0
  382. package/dist/bundles/symbols.js +3 -0
  383. package/dist/bundles/symbols.js.map +1 -0
  384. package/dist/bundles/themes/screenplay-dark.js +2 -0
  385. package/dist/bundles/themes/screenplay-dark.js.map +1 -0
  386. package/dist/bundles/themes/screenplay-light.js +2 -0
  387. package/dist/bundles/themes/screenplay-light.js.map +1 -0
  388. package/dist/bundles/tokens.js +2 -0
  389. package/dist/bundles/tokens.js.map +1 -0
  390. package/dist/bundles/validation.js +3 -0
  391. package/dist/bundles/validation.js.map +1 -0
  392. package/dist/completion-items.d.ts.map +1 -1
  393. package/dist/diagnostic-codes.d.ts +6 -0
  394. package/dist/diagnostic-codes.d.ts.map +1 -1
  395. package/dist/keyword-docs.d.ts.map +1 -1
  396. package/dist/language.d.ts.map +1 -1
  397. package/dist/tokens.d.ts.map +1 -1
  398. package/package.json +4 -3
  399. package/dist/bundles/chunk-4CLLEMBX.js +0 -42
  400. package/dist/bundles/chunk-4CLLEMBX.js.map +0 -7
  401. package/dist/bundles/chunk-AYDF3IFZ.js +0 -2
  402. package/dist/bundles/chunk-AYDF3IFZ.js.map +0 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractionAlternatives.js","names":["inline","pattern","dotNetWhitespace","trigger","where","actions","index","lines","header","on","body","child","children","line","branches","firstWord","supported","guards","sawOtherwise","branch","isWhen","match","context","DiagnosticCodes","locationOf","condition","parseCondition","validateCondition","nested","guard","probe","ParserContext","LineReader","message"],"sources":["../../../../../../Compiler/Parsing/InteractionAlternatives.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { dotNetWhitespace, pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { validateCondition } from './GuardedActionParser';\nimport { firstWord } from './LineText';\nimport { LineReader } from './LineReader';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst inline = pattern(`^when${dotNetWhitespace}+([^\\\\n]+)${dotNetWhitespace}+execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst trigger = pattern(`^on${dotNetWhitespace}+([^\\\\n]+)$`);\nconst where = pattern(`^where${dotNetWhitespace}+([^\\\\n]+)$`);\nconst actions = new Set(['execute', 'navigate', 'open', 'close', 'refresh', 'set', 'notify', 'confirm', 'raise']);\n\n// Interaction bodies remain opaque in the TS AST. Check their structure instead of silently accepting\n// alternatives the C# compiler refuses. Input collection supplies only significant, non-fenced lines.\nexport function validateInteractionBodies(context: ParserContext, lines: readonly SourceLine[]): void {\n for (let index = 0; index < lines.length; index++) {\n const header = lines[index];\n const on = trigger.exec(header.content);\n if (on === null || on[1].startsWith('row-click ')) continue;\n const body: SourceLine[] = [];\n for (let child = index + 1; child < lines.length && lines[child].indent > header.indent; child++) body.push(lines[child]);\n const children = body.filter(line => line.indent === body[0]?.indent);\n const branches = children.filter(line => ['when', 'otherwise'].includes(firstWord(line.content)));\n const supported = ['click', 'double click', 'select'].includes(on[1].trim());\n const guards = children.filter(line => where.test(line.content));\n let sawOtherwise = false;\n for (const branch of branches) {\n const isWhen = firstWord(branch.content) === 'when';\n const match = isWhen ? inline.exec(branch.content) : null;\n if (isWhen) {\n if (sawOtherwise) context.error(DiagnosticCodes.MisplacedActionOtherwise, \"A 'when' alternative must precede 'otherwise'\", locationOf(branch));\n const condition = parseCondition(context, match?.[1] ?? branch.content.slice(4).trim(), locationOf(branch), true);\n if (condition !== null) validateCondition(context, condition);\n if (match !== null) context.error(DiagnosticCodes.InlineInteractionAlternative, \"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'\", locationOf(branch));\n } else {\n if (sawOtherwise || branch.content !== 'otherwise') context.error(DiagnosticCodes.MisplacedActionOtherwise, \"An interaction permits one final block-form 'otherwise'\", locationOf(branch));\n sawOtherwise = true;\n }\n const position = body.indexOf(branch);\n const nested = body[position + 1];\n if (match === null && (nested === undefined || nested.indent <= branch.indent || !actions.has(firstWord(nested.content)))) {\n context.error(DiagnosticCodes.InteractionAlternativeWithoutActions, 'An interaction alternative requires a non-empty action list', locationOf(branch));\n }\n }\n if (branches.length > 0) {\n if (!supported) context.error(DiagnosticCodes.UnsupportedInteractionAlternatives, 'Interaction alternatives are only supported on click, double click and select', locationOf(header));\n if (guards.length > 0 || children.some(line => actions.has(firstWord(line.content)))) {\n context.error(DiagnosticCodes.MixedInteractionAlternatives, \"Interaction alternatives cannot mix with plain actions or 'where'\", locationOf(header));\n }\n if (!branches.some(line => firstWord(line.content) === 'when')) context.error(DiagnosticCodes.GuardedActionWithoutAlternatives, \"A guarded interaction requires at least one 'when' alternative\", locationOf(header));\n }\n if (supported) for (const guard of guards) deprecateWhere(context, guard);\n }\n}\n\nfunction deprecateWhere(context: ParserContext, line: SourceLine): void {\n const probe = new ParserContext(new LineReader([]));\n probe.sourceOptions = context.sourceOptions;\n const condition = parseCondition(probe, where.exec(line.content)![1].trim(), locationOf(line), true);\n if (condition !== null) validateCondition(probe, condition);\n const message = \"Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions\";\n if (condition !== null && probe.diagnostics.length === 0) context.warning(DiagnosticCodes.LegacyInteractionWhere, message, locationOf(line));\n else context.information(DiagnosticCodes.LegacyInteractionWhere, message, locationOf(line));\n}\n"],"mappings":"ueAYA,MAAMA,EAASC,EAAQ,QAAQC,EAAiB,YAAYA,EAAiB,UAAUA,EAAiB,8BAA8B,EAChIC,EAAUF,EAAQ,MAAMC,EAAiB,YAAY,EACrDE,EAAQH,EAAQ,SAASC,EAAiB,YAAY,EACtDG,kBAAU,IAAI,IAAI,CAAC,UAAW,WAAY,OAAQ,QAAS,UAAW,MAAO,SAAU,UAAW,OAAO,CAAC,EAIhH,SAAgB,0BAA0B,EAAwB,EAAoC,CAClG,IAAK,IAAIC,EAAQ,EAAGA,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../_virtual/_virtual/_rolldown/runtime.js";import{isBlank as e}from"./SourceLine.js";var t=class LineReader{lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every(e)}fork(){let e=new LineReader(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&e(this.lines[this.#e]);)this.#e++;return this.#e<this.lines.length?this.lines[this.#e]:void 0}takeSignificant(){let e=this.peekSignificant();if(e===void 0)throw Error(`There is no significant line left to take`);return this.#e++,e}takeRaw(){return this.#e<this.lines.length?this.lines[this.#e++]:void 0}};export{t as LineReader};
2
+ //# sourceMappingURL=LineReader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineReader.js","names":["LineReader","lines","#index","isBlank","reader","line"],"sources":["../../../../../../Compiler/Parsing/LineReader.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 { isBlank, SourceLine } from './SourceLine';\n\n// Walks the lines of a document forward. Significant reads skip blank lines; a raw read takes the next line\n// as it is, which is how a fenced code block keeps its blank lines.\nexport class LineReader {\n #index = 0;\n\n constructor(private readonly lines: readonly SourceLine[]) {}\n\n get atEnd(): boolean {\n return this.lines.slice(this.#index).every(isBlank);\n }\n\n // Independent lookahead must not consume the committed parser's source.\n fork(): LineReader {\n const reader = new LineReader(this.lines);\n reader.#index = this.#index;\n return reader;\n }\n\n peekSignificant(): SourceLine | undefined {\n while (this.#index < this.lines.length && isBlank(this.lines[this.#index])) {\n this.#index++;\n }\n return this.#index < this.lines.length ? this.lines[this.#index] : undefined;\n }\n\n takeSignificant(): SourceLine {\n const line = this.peekSignificant();\n if (line === undefined) {\n throw new Error('There is no significant line left to take');\n }\n this.#index++;\n return line;\n }\n\n takeRaw(): SourceLine | undefined {\n return this.#index < this.lines.length ? this.lines[this.#index++] : undefined;\n }\n}\n"],"mappings":"+FAOA,IAAaA,EAAb,MAAa,UAAW,CAGS,MAF7B,GAAS,EAET,YAAY,EAA+C,CAA9B,KAAA,MAAAC,CAA+B,CAE5D,IAAI,OAAiB,CACjB,OAAO,KAAK,MAAM,MAAM,KAAKC,EAAM,CAAC,CAAC,MAAMC,CAAO,CACtD,CAGA,MAAmB,CACf,IAAMC,EAAS,IAAI,WAAW,KAAK,KAAK,EAExC,MADA,GAAOF,GAAS,KAAKA,GACdE,CACX,CAEA,iBAA0C,CACtC,KAAO,KAAKF,GAAS,KAAK,MAAM,QAAUC,EAAQ,KAAK,MAAM,KAAKD,GAAO,GACrE,KAAKA,KAET,OAAO,KAAKA,GAAS,KAAK,MAAM,OAAS,KAAK,MAAM,KAAKA,IAAU,IAAA,EACvE,CAEA,iBAA8B,CAC1B,IAAMG,EAAO,KAAK,gBAAgB,EAClC,GAAIA,IAAS,IAAA,GACT,MAAU,MAAM,2CAA2C,EAG/D,MADA,MAAKH,KACEG,CACX,CAEA,SAAkC,CAC9B,OAAO,KAAKH,GAAS,KAAK,MAAM,OAAS,KAAK,MAAM,KAAKA,MAAY,IAAA,EACzE,CACJ"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";const firstWord=e=>{let t=e.indexOf(` `);return t===-1?e:e.substring(0,t)},unescapeIdentifier=e=>e.replaceAll(`@`,``);function splitTopLevel(e,t){let n=[],r=0,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];s===`\\`&&i&&o+1<e.length?o++:s===`"`&&!a?i=!i:s==="`"&&!i?a=!a:s===t&&!i&&!a&&(n.push(e.substring(r,o)),r=o+1)}return n.push(e.substring(r)),n}export{firstWord,splitTopLevel,unescapeIdentifier};
2
+ //# sourceMappingURL=LineText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineText.js","names":["space","content","identifier","parts","start","inString","inTemplate","index","text","current","separator"],"sources":["../../../../../../Compiler/Parsing/LineText.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\n// The first space-separated word of a line's content - the keyword every construct is recognized by.\nexport const firstWord = (content: string): string => {\n const space = content.indexOf(' ');\n return space === -1 ? content : content.substring(0, space);\n};\n\n// Removes the '@' that lets an identifier read as a keyword ('@validate' names a property called validate).\nexport const unescapeIdentifier = (identifier: string): string => identifier.replaceAll('@', '');\n\n// Splits text on a separator that is not inside a string or a template literal.\nexport function splitTopLevel(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let inString = false;\n let inTemplate = false;\n for (let index = 0; index < text.length; index++) {\n const current = text[index];\n if (current === '\\\\' && inString && index + 1 < text.length) {\n index++;\n } else if (current === '\"' && !inTemplate) {\n inString = !inString;\n } else if (current === '`' && !inString) {\n inTemplate = !inTemplate;\n } else if (current === separator && !inString && !inTemplate) {\n parts.push(text.substring(start, index));\n start = index + 1;\n }\n }\n parts.push(text.substring(start));\n return parts;\n}\n"],"mappings":"qDAIA,MAAa,UAAa,GAA4B,CAClD,IAAMA,EAAQC,EAAQ,QAAQ,GAAG,EACjC,OAAOD,IAAU,GAAKC,EAAUA,EAAQ,UAAU,EAAGD,CAAK,CAC9D,EAGa,mBAAsB,GAA+BE,EAAW,WAAW,IAAK,EAAE,EAG/F,SAAgB,cAAc,EAAc,EAA6B,CACrE,IAAMC,EAAkB,CAAC,EACrBC,EAAQ,EACRC,EAAW,GACXC,EAAa,GACjB,IAAK,IAAIC,EAAQ,EAAGA,EAAQC,EAAK,OAAQ,IAAS,CAC9C,IAAMC,EAAUD,EAAKD,GACjBE,IAAY,MAAQJ,GAAYE,EAAQ,EAAIC,EAAK,OACjD,IACOC,IAAY,KAAO,CAACH,EAC3B,EAAW,CAACD,EACLI,IAAY,KAAO,CAACJ,EAC3B,EAAa,CAACC,EACPG,IAAYC,GAAa,CAACL,GAAY,CAACC,IAC9CH,EAAM,KAAKK,EAAK,UAAUJ,EAAOG,CAAK,CAAC,EACvC,EAAQA,EAAQ,EAExB,CAEA,OADAJ,EAAM,KAAKK,EAAK,UAAUJ,CAAK,CAAC,EACzBD,CACX"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{firstWord as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseFeature as m}from"./FeatureBody.js";const h=t(`^module\\s+([A-Za-z_]\\w*)$`),g=/* @__PURE__ */ new Set([`on`,`uses`,`screen`,`dialog`,`form`,`contribute`]),_=`description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'`;var ModuleBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=null;#o=null;#s=null;constructor(e){this.name=e}tryParse(t,r){let h=n(r.content);switch(h){case`runs`:return f(t,r),!0;case`description`:return this.#a=o(t,r,this.#a,`Module '${this.name}'`),!0;case`documentation`:return this.#o=c(t,r,this.#o,`Module '${this.name}'`),!0;case`depends`:return l(t,r,this.#r,e.UnknownModuleDirective),!0;case`purpose`:return s(t,r,this.#i),!0;case`authorize`:return this.#s=i(this.#s,a(t,r)),!0;case`import`:return u(t,r,this.#n),!0;case`example`:return this.#t.push(p(t,r)),!0;case`feature`:return this.#e.push(m(t,r)),!0;default:return g.has(h)?(d(t,r),!0):!1}}parseChildren(t,i){for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),this.tryParse(t,a)||(t.error(e.UnknownModuleDirective,`Unexpected '${n(a.content)}' in module body - expected ${_}`,r(a)),t.skipBlock(a.indent))}build(e,t=!1){return{kind:`ModuleSyntax`,name:this.name,description:this.#a,documentation:this.#o,authorize:this.#s,dependsOn:this.#r,purposes:this.#i,features:this.#e,examples:this.#t,fileImports:this.#n,isPlacement:t,location:e}}};function parseModule(t,n){let i=h.exec(n.content)?.[1]??``;i===``&&t.error(e.InvalidModuleDeclaration,`Invalid module declaration '${n.content}' - expected 'module <Name>'`,r(n));let a=new ModuleBody(i),o=t.scope;return t.scope=[i],a.parseChildren(t,n),t.scope=o,a.build(r(n))}export{ModuleBody,_ as moduleBodyExpected,h as modulePattern,parseModule};
2
+ //# sourceMappingURL=ModuleBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModuleBody.js","names":["modulePattern","pattern","opaqueModuleMembers","moduleBodyExpected","name","keyword","firstWord","line","misplacedReactionIdentity","context","#description","parseDescription","#documentation","parseDocumentation","parseDependsOn","#dependsOn","DiagnosticCodes","parsePurposeReference","#purposes","#authorize","combineAuthorize","parseAuthorize","parseFileImport","#fileImports","#examples","parseExample","#features","parseFeature","collectInputUses","child","locationOf","body","previous"],"sources":["../../../../../../Compiler/Parsing/ModuleBody.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { DependsOnSyntax, FeatureSyntax, FileImportSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { parsePurposeReference } from './PurposeParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { parseDependsOn } from './DependsOnParser';\nimport { parseFeature } from './FeatureBody';\nimport { parseFileImport } from './FileImportParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { parseExample } from './SpecificationExampleParser';\nimport { ParserContext } from './ParserContext';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport const modulePattern = pattern('^module\\\\s+([A-Za-z_]\\\\w*)$');\n\n// Module members the C# compiler knows that this compiler does not model. They are skipped whole, not reported.\nconst opaqueModuleMembers = new Set(['on', 'uses', 'screen', 'dialog', 'form', 'contribute']);\n\n// What a module body may hold, as it reads in a diagnostic.\nexport const moduleBodyExpected = 'description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, \\'on <trigger>\\' or \\'uses <Behavior>\\'';\n\n// Collects the body of a module - written beneath a 'module' header, or at the top level of a file imported\n// into the module. The port of the C# ModuleBody.\nexport class ModuleBody {\n readonly #features: FeatureSyntax[] = [];\n readonly #examples: SpecificationExampleSyntax[] = [];\n readonly #fileImports: FileImportSyntax[] = [];\n readonly #dependsOn: DependsOnSyntax[] = [];\n readonly #purposes: PurposeReferenceSyntax[] = [];\n #description: string | null = null;\n #documentation: string | null = null;\n #authorize: AuthorizeSyntax | null = null;\n\n constructor(readonly name: string) {}\n\n // Parses one already consumed line of the body; false when the line does not belong to a module body,\n // and nothing was reported.\n tryParse(context: ParserContext, line: SourceLine): boolean {\n const keyword = firstWord(line.content);\n switch (keyword) {\n case 'runs':\n misplacedReactionIdentity(context, line);\n return true;\n case 'description':\n this.#description = parseDescription(context, line, this.#description, `Module '${this.name}'`);\n return true;\n case 'documentation':\n this.#documentation = parseDocumentation(context, line, this.#documentation, `Module '${this.name}'`);\n return true;\n case 'depends':\n parseDependsOn(context, line, this.#dependsOn, DiagnosticCodes.UnknownModuleDirective);\n return true;\n case 'purpose':\n parsePurposeReference(context, line, this.#purposes);\n return true;\n case 'authorize':\n this.#authorize = combineAuthorize(this.#authorize, parseAuthorize(context, line));\n return true;\n case 'import':\n parseFileImport(context, line, this.#fileImports);\n return true;\n case 'example':\n this.#examples.push(parseExample(context, line));\n return true;\n case 'feature':\n this.#features.push(parseFeature(context, line));\n return true;\n default:\n if (opaqueModuleMembers.has(keyword)) {\n collectInputUses(context, line);\n return true;\n }\n return false;\n }\n }\n\n // Parses the children of a header line into this body, reporting what does not belong in a module.\n parseChildren(context: ParserContext, line: SourceLine): void {\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!this.tryParse(context, child)) {\n context.error(DiagnosticCodes.UnknownModuleDirective, `Unexpected '${firstWord(child.content)}' in module body - expected ${moduleBodyExpected}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n }\n\n // Builds the module, located at its header or, when it only places an imported file, at that file.\n build(location: SourceLocation, isPlacement = false): ModuleSyntax {\n return {\n kind: 'ModuleSyntax',\n name: this.name,\n description: this.#description,\n documentation: this.#documentation,\n authorize: this.#authorize,\n dependsOn: this.#dependsOn,\n purposes: this.#purposes,\n features: this.#features,\n examples: this.#examples,\n fileImports: this.#fileImports,\n isPlacement,\n location,\n };\n }\n}\n\n// Parses a module from its already consumed header line.\nexport function parseModule(context: ParserContext, line: SourceLine): ModuleSyntax {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidModuleDeclaration, `Invalid module declaration '${line.content}' - expected 'module <Name>'`, locationOf(line));\n }\n const body = new ModuleBody(name);\n const previous = context.scope;\n context.scope = [name];\n body.parseChildren(context, line);\n context.scope = previous;\n return body.build(locationOf(line));\n}\n"],"mappings":"o1BAwBA,MAAaA,EAAgBC,EAAQ,6BAA6B,EAG5DC,kBAAsB,IAAI,IAAI,CAAC,KAAM,OAAQ,SAAU,SAAU,OAAQ,YAAY,CAAC,EAG/EC,EAAqB,8KAIlC,IAAa,WAAb,KAAwB,CAUC,KATrB,GAAsC,CAAC,EACvC,GAAmD,CAAC,EACpD,GAA4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AMO,EAAgB,uBAAwB,eAAeV,EAAUuB,EAAM,OAAO,EAAE,8BAA8B1B,IAAsB2B,EAAWD,CAAK,CAAC,EACnKpB,EAAQ,UAAUoB,EAAM,MAAM,EAG1C,CAGA,MAAM,EAA0B,EAAc,GAAqB,CAC/D,MAAO,CACH,KAAM,eACN,KAAM,KAAK,KACX,YAAa,KAAKnB,GAClB,cAAe,KAAKE,GACpB,UAAW,KAAKO,GAChB,UAAW,KAAKJ,GAChB,SAAU,KAAKG,GACf,SAAU,KAAKQ,GACf,SAAU,KAAKF,GACf,YAAa,KAAKD,GAClB,cACA,UACJ,CACJ,CACJ,EAGA,SAAgB,YAAY,EAAwB,EAAgC,CAChF,IAAMnB,EAAOJ,EAAc,KAAKO,EAAK,OAAO,CAAC,GAAG,IAAM,GAClDH,IAAS,IACTK,EAAQ,MAAMO,EAAgB,yBAA0B,+BAA+BT,EAAK,QAAQ,8BAA+BuB,EAAWvB,CAAI,CAAC,EAEvJ,IAAMwB,EAAO,IAAI,WAAW3B,CAAI,EAC1B4B,EAAWvB,EAAQ,MAIzB,MAHA,GAAQ,MAAQ,CAACL,CAAI,EACrB2B,EAAK,cAActB,EAASF,CAAI,EAChC,EAAQ,MAAQyB,EACTD,EAAK,MAAMD,EAAWvB,CAAI,CAAC,CACtC"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{parseMappingSource as n}from"./ExpressionParser.js";import{firstWord as r}from"./LineText.js";import{locationOf as i}from"./SourceLine.js";import{parseProperty as a,tryParseProperty as o}from"./PropertyLineParser.js";import{parseDescription as s}from"./DescriptionParser.js";import{isFileDirective as c}from"./FileReferences.js";import{parseCode as l,parseFile as u,parseImplementationWrapper as d}from"./ImplementationParser.js";const f=t(`^system\\s+([A-Za-z_]\\w*)$`),p=t(`^operation\\s+([A-Za-z_]\\w*)$`),m=t(`^produces\\s+operation\\s+([A-Za-z_]\\w*)$`),h=t(`^uses\\s+([A-Za-z_]\\w*)$`),g=t(`^(.+?)\\s*=(?!=|>)\\s*(.+)$`),_=/* @__PURE__ */ new Set([`for`,`tag`,`generation`,`origin`,`documentation`,`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`]);function rejectOperationChildren(e,t,n,r){let a=e.peekChild(t.indent);a!==void 0&&(e.error(n,r,i(a)),e.skipBlock(t.indent))}function parseSystem(t,n){let a=f.exec(n.content);a===null&&t.error(e.InvalidSystemDeclaration,`Expected 'system <Name>'.`,i(n));let o=null;for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent))t.reader.takeSignificant(),r(c.content)===`description`?o=s(t,c,o,`System '${a?.[1]??``}'`):(t.error(e.InvalidSystemDeclaration,`A system accepts only a description; abilities are not supported.`,i(c)),t.skipBlock(c.indent));return{kind:`SystemSyntax`,name:a?.[1]??``,description:o,location:i(n)}}function parseOperation(t,c,l=!1){let u=(l?m:p).exec(c.content),d=u?.[1]??``;u===null&&t.error(e.InvalidOperationDeclaration,`Expected an operation declaration with one name.`,i(c));let f=null,v=null,y=i(c),b=null,x=null,S=[],C=[],w=/* @__PURE__ */ new Set;for(let u=t.peekChild(c.indent);u!==void 0;u=t.peekChild(c.indent)){t.reader.takeSignificant();let c=g.exec(u.content),p=l&&c!==null?{...u,content:c[1].trimEnd()}:u;if(c===null&&_.has(r(u.content)))t.error(e.InvalidOperationDeclaration,`Operations cannot declare event routing or metadata; escape a keyword-named input with @.`,i(u)),t.skipBlock(u.indent);else if(!h.test(u.content)&&o(p)!==void 0){let r=a(t,p);l&&c===null&&t.error(e.InvalidOperationMapping,`An inline operation input requires '<property> <Type> = <source>'.`,i(u)),r.isSubject&&t.error(e.InvalidSubjectOwner,`The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).`,i(u)),(r.isIdentifier||r.isGenerated)&&t.error(e.InvalidOperationDeclaration,`Operation inputs cannot be identifier or generated properties.`,i(u)),w.has(r.name)&&t.error(e.DuplicateDeclaration,`Operation '${d}' already declares input '${r.name}'.`,i(u)),w.add(r.name),S.push(r),l&&c!==null&&C.push({kind:`PropertyMappingSyntax`,property:r.name,source:n(c[2],{...i(u),column:u.indent+u.content.length-c[2].length+1},t),location:i(u)}),rejectOperationChildren(t,u,e.InvalidOperationDeclaration,`An operation input cannot have children.`)}else if(r(u.content)===`description`)f=s(t,u,f,`Operation '${d}'`);else if(h.test(u.content))v===null?(v=h.exec(u.content)[1],y={...i(u),column:i(u).column+u.content.indexOf(v,4)}):t.error(e.InvalidSystemReference,`An operation declares exactly one 'uses <System>'.`,i(u)),rejectOperationChildren(t,u,e.InvalidSystemReference,`A system reference cannot have children.`);else if(u.content===`execute`||u.content===`compensate`){let n=parseOperationPhase(t,u);u.content===`execute`?b===null?b=n:t.error(e.InvalidOperationDeclaration,`An operation declares execute at most once.`,i(u)):x===null?x=n:t.error(e.InvalidOperationDeclaration,`An operation declares compensate at most once.`,i(u))}else t.error(e.InvalidOperationDeclaration,`Unexpected '${u.content}' in operation - expected uses, an input, description, execute or compensate.`,i(u)),t.skipBlock(u.indent)}return v===null&&t.error(e.InvalidSystemReference,`An operation requires exactly one 'uses <System>'.`,i(c)),{operation:{kind:`OperationSyntax`,name:d,uses:v??``,usesLocation:y,inputs:S,description:f,execute:b,compensate:x,location:i(c)},mappings:C}}function parseOperationPhase(t,n){let a=null,o=null,f=null,p=null,m=!1;for(let h=t.peekChild(n.indent);h!==void 0;h=t.peekChild(n.indent))if(t.reader.takeSignificant(),r(h.content)===`description`)a=s(t,h,a,`Operation phase '${n.content}'`);else if(r(h.content)===`implementation`){m&&t.error(e.ConflictingImplementationSources,`A phase cannot mix wrapped and direct sources or repeat its wrapper.`,i(h));let n=d(t,h);m||(o=n.file,f=n.code,p=n.implementation),m=!0}else if(c(h)||h.content.startsWith("```")){m&&t.error(e.ConflictingImplementationSources,`A phase has at most one file or inline payload.`,i(h));let n=c(h)?u(t,h):null,r=n===null?l(t,h):null;m||(o=n,f=r),m=!0,n!==null&&rejectOperationChildren(t,h,e.InvalidImplementationBlock,`A file directive cannot have children.`)}else t.error(e.InvalidOperationDeclaration,`A phase accepts description, file, a tagged fence or implementation.`,i(h)),t.skipBlock(h.indent);return{kind:`OperationPhaseSyntax`,description:a,file:o,code:f,implementation:p,location:i(n)}}export{parseOperation,parseSystem,rejectOperationChildren};
2
+ //# sourceMappingURL=OperationParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OperationParser.js","names":["systemHeader","pattern","operationHeader","inlineHeader","usesPattern","typedMapping","eventMetadata","child","context","line","code","message","locationOf","match","header","DiagnosticCodes","description","firstWord","parseDescription","inline","name","uses","usesLocation","execute","compensate","inputs","mappings","names","typed","propertyLine","tryParseProperty","property","parseProperty","parseMappingSource","phase","file","implementation","sourceSelected","source","parseImplementationWrapper","isFileDirective","parsedFile","parseFile","parsedCode","parseCode"],"sources":["../../../../../../Compiler/Parsing/OperationParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { pattern } from '../Text/patterns';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { OperationPhaseSyntax, OperationSyntax, SystemSyntax } from '../Syntax/Operations';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { isFileDirective } from './FileReferences';\nimport { parseCode, parseFile, parseImplementationWrapper } from './ImplementationParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseProperty, tryParseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst systemHeader = pattern('^system\\\\s+([A-Za-z_]\\\\w*)$');\nconst operationHeader = pattern('^operation\\\\s+([A-Za-z_]\\\\w*)$');\nconst inlineHeader = pattern('^produces\\\\s+operation\\\\s+([A-Za-z_]\\\\w*)$');\nconst usesPattern = pattern('^uses\\\\s+([A-Za-z_]\\\\w*)$');\nconst typedMapping = pattern('^(.+?)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst eventMetadata = new Set(['for', 'tag', 'generation', 'origin', 'documentation', 'namespace', 'sequence', 'correlation', 'causation', 'causedBy', 'occurred']);\n\nexport function rejectOperationChildren(context: ParserContext, line: SourceLine, code: string, message: string): void {\n const child = context.peekChild(line.indent);\n if (child === undefined) return;\n context.error(code, message, locationOf(child));\n context.skipBlock(line.indent);\n}\n\nexport function parseSystem(context: ParserContext, header: SourceLine): SystemSyntax {\n const match = systemHeader.exec(header.content);\n if (match === null) context.error(DiagnosticCodes.InvalidSystemDeclaration, \"Expected 'system <Name>'.\", locationOf(header));\n let description: string | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'description') description = parseDescription(context, child, description, `System '${match?.[1] ?? ''}'`);\n else {\n context.error(DiagnosticCodes.InvalidSystemDeclaration, 'A system accepts only a description; abilities are not supported.', locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { kind: 'SystemSyntax', name: match?.[1] ?? '', description, location: locationOf(header) };\n}\n\nexport function parseOperation(context: ParserContext, header: SourceLine, inline = false): { operation: OperationSyntax; mappings: PropertyMappingSyntax[] } {\n const match = (inline ? inlineHeader : operationHeader).exec(header.content);\n const name = match?.[1] ?? '';\n if (match === null) context.error(DiagnosticCodes.InvalidOperationDeclaration, 'Expected an operation declaration with one name.', locationOf(header));\n let description: string | null = null;\n let uses: string | null = null;\n let usesLocation = locationOf(header);\n let execute: OperationPhaseSyntax | null = null;\n let compensate: OperationPhaseSyntax | null = null;\n const inputs: PropertySyntax[] = [];\n const mappings: PropertyMappingSyntax[] = [];\n const names = new Set<string>();\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const typed = typedMapping.exec(line.content);\n const propertyLine = inline && typed !== null ? { ...line, content: typed[1].trimEnd() } : line;\n if (typed === null && eventMetadata.has(firstWord(line.content))) {\n context.error(DiagnosticCodes.InvalidOperationDeclaration, 'Operations cannot declare event routing or metadata; escape a keyword-named input with @.', locationOf(line));\n context.skipBlock(line.indent);\n continue;\n }\n if (!usesPattern.test(line.content) && tryParseProperty(propertyLine) !== undefined) {\n const property = parseProperty(context, propertyLine)!;\n if (inline && typed === null) context.error(DiagnosticCodes.InvalidOperationMapping, \"An inline operation input requires '<property> <Type> = <source>'.\", locationOf(line));\n if (property.isSubject) context.error(DiagnosticCodes.InvalidSubjectOwner, 'The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).', locationOf(line));\n if (property.isIdentifier || property.isGenerated) context.error(DiagnosticCodes.InvalidOperationDeclaration, 'Operation inputs cannot be identifier or generated properties.', locationOf(line));\n if (names.has(property.name)) context.error(DiagnosticCodes.DuplicateDeclaration, `Operation '${name}' already declares input '${property.name}'.`, locationOf(line));\n names.add(property.name);\n inputs.push(property);\n if (inline && typed !== null) mappings.push({ kind: 'PropertyMappingSyntax', property: property.name, source: parseMappingSource(typed[2], { ...locationOf(line), column: line.indent + line.content.length - typed[2].length + 1 }, context), location: locationOf(line) });\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidOperationDeclaration, 'An operation input cannot have children.');\n } else if (firstWord(line.content) === 'description') description = parseDescription(context, line, description, `Operation '${name}'`);\n else if (usesPattern.test(line.content)) {\n if (uses !== null) context.error(DiagnosticCodes.InvalidSystemReference, \"An operation declares exactly one 'uses <System>'.\", locationOf(line));\n else {\n uses = usesPattern.exec(line.content)![1];\n usesLocation = { ...locationOf(line), column: locationOf(line).column + line.content.indexOf(uses, 4) };\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidSystemReference, 'A system reference cannot have children.');\n } else if (line.content === 'execute' || line.content === 'compensate') {\n const phase = parseOperationPhase(context, line);\n if (line.content === 'execute') {\n if (execute !== null) context.error(DiagnosticCodes.InvalidOperationDeclaration, 'An operation declares execute at most once.', locationOf(line));\n else execute = phase;\n } else {\n if (compensate !== null) context.error(DiagnosticCodes.InvalidOperationDeclaration, 'An operation declares compensate at most once.', locationOf(line));\n else compensate = phase;\n }\n } else {\n context.error(DiagnosticCodes.InvalidOperationDeclaration, `Unexpected '${line.content}' in operation - expected uses, an input, description, execute or compensate.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n if (uses === null) context.error(DiagnosticCodes.InvalidSystemReference, \"An operation requires exactly one 'uses <System>'.\", locationOf(header));\n return { operation: { kind: 'OperationSyntax', name, uses: uses ?? '', usesLocation, inputs, description, execute, compensate, location: locationOf(header) }, mappings };\n}\n\nfunction parseOperationPhase(context: ParserContext, header: SourceLine): OperationPhaseSyntax {\n let description: string | null = null;\n let file: OperationPhaseSyntax['file'] = null;\n let code: OperationPhaseSyntax['code'] = null;\n let implementation: OperationPhaseSyntax['implementation'] = null;\n let sourceSelected = false;\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (firstWord(line.content) === 'description') {\n description = parseDescription(context, line, description, `Operation phase '${header.content}'`);\n continue;\n }\n if (firstWord(line.content) === 'implementation') {\n if (sourceSelected) context.error(DiagnosticCodes.ConflictingImplementationSources, 'A phase cannot mix wrapped and direct sources or repeat its wrapper.', locationOf(line));\n const source = parseImplementationWrapper(context, line);\n if (!sourceSelected) { file = source.file; code = source.code; implementation = source.implementation; }\n sourceSelected = true;\n } else if (isFileDirective(line) || line.content.startsWith('```')) {\n if (sourceSelected) context.error(DiagnosticCodes.ConflictingImplementationSources, 'A phase has at most one file or inline payload.', locationOf(line));\n const parsedFile = isFileDirective(line) ? parseFile(context, line) : null;\n const parsedCode = parsedFile === null ? parseCode(context, line) : null;\n if (!sourceSelected) { file = parsedFile; code = parsedCode; }\n sourceSelected = true;\n if (parsedFile !== null) rejectOperationChildren(context, line, DiagnosticCodes.InvalidImplementationBlock, 'A file directive cannot have children.');\n } else {\n context.error(DiagnosticCodes.InvalidOperationDeclaration, 'A phase accepts description, file, a tagged fence or implementation.', locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n return { kind: 'OperationPhaseSyntax', description, file, code, implementation, location: locationOf(header) };\n}\n"],"mappings":"4lBAiBA,MAAMA,EAAeC,EAAQ,6BAA6B,EACpDC,EAAkBD,EAAQ,gCAAgC,EAC1DE,EAAeF,EAAQ,4CAA4C,EACnEG,EAAcH,EAAQ,2BAA2B,EACjDI,EAAeJ,EAAQ,6BAA6B,EACpDK,kBAAgB,IAAI,IAAI,CAAC,MAAO,MAAO,aAAc,SAAU,gBAAiB,YAAa,WAAY,cAAe,YAAa,WAAY,UAAU,CAAC,EAElK,SAAgB,wBAAwB,EAAwB,EAAkB,EAAc,EAAuB,CACnH,IAAMC,EAAQC,EAAQ,UAAUC,EAAK,MAAM,EACvCF,IAAU,IAAA,KACdC,EAAQ,MAAME,EAAMC,EAASC,EAAWL,CAAK,CAAC,EAC9CC,EAAQ,UAAUC,EAAK,MAAM,EACjC,CAEA,SAAgB,YAAY,EAAwB,EAAkC,CAClF,IAAMI,EAAQb,EAAa,KAAKc,EAAO,OAAO,EAC1CD,IAAU,MAAML,EAAQ,MAAMO,EAAgB,yBAA0B,4BAA6BH,EAAWE,CAAM,CAAC,EAC3H,IAAIE,EAA6B,KACjC,IAAK,IAAIT,EAAQC,EAAQ,UAAUM,EAAO,MAAM,EAAGP,IAAU,IAAA,GAAW,EAAQC,EAAQ,UAAUM,EAAO,MAAM,EAC3GN,EAAQ,OAAO,gBAAgB,EAC3BS,EAAUV,EAAM,OAAO,IAAM,cAAe,EAAcW,EAAiBV,EAASD,EAAOS,EAAa,WAAWH,IAAQ,IAAM,GAAG,EAAE,GAEtIL,EAAQ,MAAMO,EAAgB,yBAA0B,oEAAqEH,EAAWL,CAAK,CAAC,EAC9IC,EAAQ,UAAUD,EAAM,MAAM,GAGtC,MAAO,CAAE,KAAM,eAAgB,KAAMM,I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vJ,IAAMgC,EAAaD,EAAgB/B,CAAI,EAAIiC,EAAUlC,EAASC,CAAI,EAAI,KAChEkC,EAAaF,IAAe,KAAOG,EAAUpC,EAASC,CAAI,EAAI,KAC/D4B,IAAkB,EAAOI,EAAY,EAAOE,GACjD,EAAiB,GACbF,IAAe,MAAM,wBAAwBjC,EAASC,EAAMM,EAAgB,2BAA4B,wCAAwC,CACxJ,MACIP,EAAQ,MAAMO,EAAgB,4BAA6B,uEAAwEH,EAAWH,CAAI,CAAC,EACnJD,EAAQ,UAAUC,EAAK,MAAM,EAGrC,MAAO,CAAE,KAAM,uBAAwB,cAAa,OAAM,OAAM,iBAAgB,SAAUG,EAAWE,CAAM,CAAE,CACjH"}
@@ -0,0 +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{operationDeclarations as n}from"../Syntax/Operations.js";import{AuthoringProductionResolver as r}from"../Syntax/AuthoringProductionResolver.js";import{specificationCommandExamples as i}from"./SpecificationCommandExamples.js";import{compatibleValue as a,uniqueByName as o}from"./ResponseValidator.js";import{commandReadSources as s}from"./CommandReadSources.js";function validateOperations(c,l){let u=new r(c),d=i(c),f=o(c.concepts),p=new Map([...o(c.types)].map(([e,t])=>[e,o(t.properties)])),m=/* @__PURE__ */ new Set([`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`,...f.keys(),...p.keys()]),h=new Set(c.imports.map(e=>e.qualifiedName.split(`.`).at(-1))),g=/* @__PURE__ */ new Map;for(let e of c.imports){let t=e.qualifiedName.split(`.`).at(-1);g.set(t,[...g.get(t)??[],e.qualifiedName])}let scoped=e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.name)??[];e.push(n),t.set(n.name,e)}return(e,r)=>{let i=JSON.stringify([e,r]);if(n.has(i))return n.get(i);let candidates=e=>{let n=e.split(`.`),i=t.get(n.at(-1))??[],a=n.slice(0,-1);if(a.length>0)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=r.length;e>=0;e--){let t=i.filter(t=>e<=t.scope.length&&r.slice(0,e).every((e,n)=>t.scope[n]===e));if(t.length>0)return t}return[]},a=candidates(e),o=g.get(e)??[];a.length===0&&o.length===1&&(a=candidates(o[0]));let s=a.length===1?a[0].node:null;return n.set(i,s),s}},_=scoped(u.slices.flatMap(({slice:e,scope:t})=>e.readModels.map(e=>({name:e.name,scope:t,node:e})))),v=scoped(u.slices.flatMap(({slice:e,scope:t})=>e.commands.map(n=>({name:n.name,scope:t,node:{command:n,slice:e}})))),y=/* @__PURE__ */ new Map;for(let t of c.systems??[])y.has(t.name)&&l.error(e.InvalidSystemDeclaration,`System '${t.name}' is declared more than once.`,t.location),y.set(t.name,(y.get(t.name)??0)+1);let pathType=(e,t,n=!0)=>{let[r,...i]=t.split(`.`),a=e.filter(e=>e.name===r);if(a.length!==1)return{type:null,missing:a.length===0};let o=a[0].type;if(i.length===0)return{type:o,missing:!1};let s=p.get(o.name);if(s===void 0)return{type:null,missing:m.has(o.name)};let c=pathType([...s.values()],i.join(`.`),n);return c.type===null?c:{type:{...c.type,isOptional:n&&o.isOptional||c.type.isOptional,isCollection:o.isCollection||c.type.isCollection},missing:!1}},covered=(e,t,n,r,i=/* @__PURE__ */ new Set)=>{if(n.has(t)||e.isOptional&&!r.has(t))return!0;if(e.isCollection||i.has(e.name))return!1;let a=p.get(e.name);return a===void 0?r.has(t)&&!m.has(e.name):[...a.values()].every(a=>covered(a.type,`${t}.${a.name}`,n,r,/* @__PURE__ */ new Set([...i,e.name])))},completeValue=(e,t)=>{if(e.kind===`ListExpressionSyntax`&&t.isCollection)return e.items.every(e=>completeValue(e,{...t,isCollection:!1,isOptional:!1}));let n=p.get(t.name);return e.kind!==`ObjectExpressionSyntax`||n===void 0||[...n.values()].every(t=>(t.type.isOptional||e.members.some(e=>e.name===t.name))&&e.members.filter(e=>e.name===t.name).every(e=>completeValue(e.value,t.type)))},concrete=e=>e.kind===`LiteralExpressionSyntax`?typeof e.value!=`number`||Number.isFinite(e.value):e.kind===`ObjectExpressionSyntax`?e.members.every(e=>concrete(e.value)):e.kind===`ListExpressionSyntax`&&e.items.every(concrete),validateMappings=(t,n,r,i,o)=>{let c=/* @__PURE__ */ new Set,u=new Set(t.map(e=>e.property)),d=/* @__PURE__ */ new Set;for(let e of t){let t=e.property.split(`.`);for(let e=1;e<=t.length;e++)d.add(t.slice(0,e).join(`.`))}for(let d of t){c.has(d.property)&&l.error(e.InvalidOperationMapping,`Duplicate operation input mapping '${d.property}'.`,d.location),c.add(d.property);let t=pathType(n.inputs,d.property,!1);if(t.missing&&l.error(e.InvalidOperationMapping,`Operation '${n.name}' declares no input '${d.property}'.`,d.location),t.type===null)continue;let h=d.property.split(`.`);for(let t=1;t<h.length;t++)u.has(h.slice(0,t).join(`.`))&&l.error(e.InvalidOperationMapping,`Operation input mapping '${d.property}' overlaps a whole input mapping.`,d.location);if(r!==null&&d.source.kind===`PathExpressionSyntax`){let i=pathType(r.properties,d.source.path),a=d.source.path.split(`.`),c=(s.get(r)??[]).filter(e=>(e.alias??e.readModel)===a[0]);if(i.missing&&c.length>0){i={type:null,missing:!1};let e=c.length===1?_(c[0].readModel,o):null;a.length>1&&e!==null&&(i=pathType(e.properties,a.slice(1).join(`.`)))}i.missing&&l.error(e.InvalidOperationMapping,`Command '${r.name}' declares no source '${d.source.path}'.`,d.source.location);let u=i.type,f=t.type;u!==null&&m.has(u.name)&&m.has(f.name)&&(u.name!==f.name||u.isCollection!==f.isCollection||u.isOptional&&!f.isOptional)&&l.error(e.InvalidOperationMapping,`Source '${d.source.path}' is incompatible with input '${d.property}' of operation '${n.name}'.`,d.source.location)}else[`LiteralExpressionSyntax`,`ObjectExpressionSyntax`,`ListExpressionSyntax`].includes(d.source.kind)&&(!a(d.source,t.type,f,p)||i&&!completeValue(d.source,t.type))&&l.error(e.InvalidOperationMapping,`Value is incompatible with input '${d.property}' of operation '${n.name}'.`,d.source.location)}if(i)for(let t of n.inputs)covered(t.type,t.name,c,d)||l.error(e.InvalidOperationMapping,`Production of operation '${n.name}' supplies no value for required input '${t.name}'.`,n.location)};for(let{slice:r,scope:i}of u.slices){let a=n(r),o=new Set(t(r).map(e=>e.name));for(let t of a){o.has(t.name)&&l.error(e.ProductionDeclarationCollision,`Operation '${t.name}' collides with another event or operation in slice '${r.name}'.`,t.location),o.add(t.name),t.uses.length>0&&y.get(t.uses)!==1&&l.error(e.InvalidSystemReference,`Operation '${t.name}' must use one declared system; '${t.uses}' does not resolve uniquely.`,t.usesLocation??t.location);for(let n of t.inputs)!m.has(n.type.name)&&!h.has(n.type.name)&&l.warning(e.UnknownType,`Unknown type '${n.type.name}' on input '${n.name}' of operation '${t.name}'.`,n.type.location)}for(let t of r.commands)for(let n of t.produces){let a=u.resolve(n.event,r);a.kind===`ambiguous`&&a.candidates.some(e=>e.kind===`operation`)&&l.error(e.InvalidProductionReference,`Production '${n.event}' is ambiguous.`,n.location),n.event.includes(`.`)&&a.kind!==`operation`&&l.error(e.InvalidProductionReference,`Qualified productions are supported only for explicitly declared operations.`,n.location),a.declaration?.node.kind===`OperationSyntax`&&((n.for!==null||n.tags.length>0)&&l.error(e.InvalidOperationDeclaration,`Operation productions cannot declare event destinations or tags.`,n.location),validateMappings(n.mappings,a.declaration.node,t,!0,i))}for(let t of r.reactions.flatMap(e=>e.triggers).flatMap(e=>e.produces)){let n=u.resolve(t.event,r);n.kind===`ambiguous`&&n.candidates.some(e=>e.kind===`operation`)&&l.error(e.InvalidProductionReference,`Production '${t.event}' is ambiguous.`,t.location),t.event.includes(`.`)&&u.resolve(t.event,r).kind!==`operation`&&l.error(e.InvalidProductionReference,`Qualified productions are supported only for explicitly declared operations.`,t.location),u.isOperation(t,r)&&l.error(e.OperationOutsideCommand,`Operations can only be produced by commands.`,t.location)}for(let t of r.specifications){let n=[...t.givenOperationFailures??[],...t.thenOperations??[],...t.thenCompensated??[]];if(n.length===0)continue;let a=v(d(t.when,i)?.commandType??``,i);(a===null||t.whenAppended!==null||t.whenQuery!==null||t.whenTrigger!==null||t.whenClock!==null||t.whenCapture!==null)&&l.error(e.InvalidOperationSpecification,`Operation fixtures and assertions require a declared command action.`,t.location);let o=/* @__PURE__ */ new Map;for(let t of n){if(t.kind===`SpecificationOperationSyntax`)for(let n of t.values)concrete(n.source)||l.error(e.InvalidOperationSpecification,`Operation assertions require concrete input values.`,n.source.location);let n=u.resolve(t.operation,r).declaration?.node;if(n?.kind!==`OperationSyntax`){l.error(e.InvalidOperationSpecification,`'${t.operation}' does not resolve uniquely to a declared operation.`,t.location);continue}let s=o.get(n)??/* @__PURE__ */ new Set;if(s.has(t.kind)&&l.error(e.InvalidOperationSpecification,`Duplicate operation step '${t.operation}'.`,t.location),s.add(t.kind),o.set(n,s),t.kind===`SpecificationCompensatedSyntax`&&n.compensate===null&&l.error(e.InvalidOperationSpecification,`Operation '${t.operation}' declares no compensation.`,t.location),a!==null&&a.command.handler==null){let r=a.command.produces.map(e=>u.resolve(e.event,a.slice));r.every(e=>e.kind===`event`||e.kind===`operation`)&&!r.some(e=>e.declaration?.node===n)&&l.error(e.InvalidOperationSpecification,`Command '${a.command.name}' does not produce operation '${t.operation}'.`,t.location)}t.kind===`SpecificationOperationSyntax`&&validateMappings(t.values,n,null,!1,i)}}}}export{validateOperations};
2
+ //# sourceMappingURL=OperationValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OperationValidator.js","names":["resolver","AuthoringProductionResolver","application","effectiveCommand","specificationCommandExamples","concepts","uniqueByName","composites","name","type","known","imported","entry","imports","byName","cache","entries","named","key","reference","from","segments","qualifiers","index","value","depth","visible","matches","result","view","slice","node","resolveCommand","command","systems","system","context","DiagnosticCodes","nested","path","properties","property","next","resolved","inheritOptionality","mappings","supplied","seen","item","member","names","allNames","mapping","suppliedPaths","target","operation","targetSegments","reads","commandReadSources","read","resolvedView","scope","source","compatibleValue","required","input","operations","operationDeclarations","eventDeclarations","event","production","resolution","reaction","trigger","specification","steps","duplicates","step","kinds","produced"],"sources":["../../../../../../Compiler/Parsing/OperationValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { AuthoringProductionKind, AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { CommandSyntax } from '../Syntax/Commands';\nimport { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { operationDeclarations, OperationSyntax } from '../Syntax/Operations';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { commandReadSources } from './CommandReadSources';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\nimport { specificationCommandExamples } from './SpecificationCommandExamples';\n\nexport function validateOperations(application: ApplicationSyntax, context: ParserContext): void {\n const resolver = new AuthoringProductionResolver(application);\n const effectiveCommand = specificationCommandExamples(application);\n const concepts = uniqueByName(application.concepts);\n const composites = new Map([...uniqueByName(application.types)].map(([name, type]) => [name, uniqueByName(type.properties)]));\n const known = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...concepts.keys(), ...composites.keys()]);\n const imported = new Set(application.imports.map(entry => entry.qualifiedName.split('.').at(-1)!));\n const imports = new Map<string, string[]>();\n for (const entry of application.imports) {\n const name = entry.qualifiedName.split('.').at(-1)!;\n imports.set(name, [...imports.get(name) ?? [], entry.qualifiedName]);\n }\n const scoped = <T>(entries: readonly { name: string; scope: readonly string[]; node: T }[]) => {\n const byName = new Map<string, typeof entries[number][]>();\n const cache = new Map<string, T | null>();\n for (const entry of entries) {\n const named = byName.get(entry.name) ?? [];\n named.push(entry);\n byName.set(entry.name, named);\n }\n return (reference: string, from: readonly string[]): T | null => {\n const key = JSON.stringify([reference, from]);\n if (cache.has(key)) return cache.get(key)!;\n const candidates = (name: string) => {\n const segments = name.split('.');\n const named = byName.get(segments.at(-1)!) ?? [];\n const qualifiers = segments.slice(0, -1);\n if (qualifiers.length > 0) return named.filter(entry => qualifiers.length <= entry.scope.length && qualifiers.every((value, index) => entry.scope[entry.scope.length - qualifiers.length + index] === value));\n for (let depth = from.length; depth >= 0; depth--) {\n const visible = named.filter(entry => depth <= entry.scope.length && from.slice(0, depth).every((value, index) => entry.scope[index] === value));\n if (visible.length > 0) return visible;\n }\n return [];\n };\n let matches = candidates(reference);\n const imported = imports.get(reference) ?? [];\n if (matches.length === 0 && imported.length === 1) matches = candidates(imported[0]);\n const result = matches.length === 1 ? matches[0].node : null;\n cache.set(key, result);\n return result;\n };\n };\n const view = scoped(resolver.slices.flatMap(({ slice, scope }) => slice.readModels.map(node => ({ name: node.name, scope, node }))));\n const resolveCommand = scoped(resolver.slices.flatMap(({ slice, scope }) => slice.commands.map(command => ({ name: command.name, scope, node: { command, slice } }))));\n const systems = new Map<string, number>();\n for (const system of application.systems ?? []) {\n if (systems.has(system.name)) context.error(DiagnosticCodes.InvalidSystemDeclaration, `System '${system.name}' is declared more than once.`, system.location);\n systems.set(system.name, (systems.get(system.name) ?? 0) + 1);\n }\n const pathType = (properties: readonly PropertySyntax[], path: string, inheritOptionality = true): { type: TypeRefSyntax | null; missing: boolean } => {\n const [name, ...nested] = path.split('.');\n const matches = properties.filter(property => property.name === name);\n if (matches.length !== 1) return { type: null, missing: matches.length === 0 };\n const type = matches[0].type;\n if (nested.length === 0) return { type, missing: false };\n const next = composites.get(type.name);\n if (next === undefined) return { type: null, missing: known.has(type.name) };\n const resolved = pathType([...next.values()], nested.join('.'), inheritOptionality);\n return resolved.type === null ? resolved : { type: { ...resolved.type, isOptional: inheritOptionality && type.isOptional || resolved.type.isOptional, isCollection: type.isCollection || resolved.type.isCollection }, missing: false };\n };\n const covered = (type: TypeRefSyntax, path: string, mappings: ReadonlySet<string>, supplied: ReadonlySet<string>, seen = new Set<string>()): boolean => {\n if (mappings.has(path) || type.isOptional && !supplied.has(path)) return true;\n if (type.isCollection || seen.has(type.name)) return false;\n const properties = composites.get(type.name);\n if (properties === undefined) return supplied.has(path) && !known.has(type.name);\n return [...properties.values()].every(property => covered(property.type, `${path}.${property.name}`, mappings, supplied, new Set([...seen, type.name])));\n };\n const completeValue = (value: PropertyMappingSyntax['source'], type: TypeRefSyntax): boolean => {\n if (value.kind === 'ListExpressionSyntax' && type.isCollection) return value.items.every(item => completeValue(item, { ...type, isCollection: false, isOptional: false }));\n const properties = composites.get(type.name);\n if (value.kind !== 'ObjectExpressionSyntax' || properties === undefined) return true;\n return [...properties.values()].every(property => (property.type.isOptional || value.members.some(member => member.name === property.name)) && value.members.filter(member => member.name === property.name).every(member => completeValue(member.value, property.type)));\n };\n const concrete = (value: PropertyMappingSyntax['source']): boolean => {\n if (value.kind === 'LiteralExpressionSyntax') return typeof value.value !== 'number' || Number.isFinite(value.value);\n if (value.kind === 'ObjectExpressionSyntax') return value.members.every(member => concrete(member.value));\n return value.kind === 'ListExpressionSyntax' && value.items.every(concrete);\n };\n const validateMappings = (mappings: readonly PropertyMappingSyntax[], operation: OperationSyntax, command: CommandSyntax | null, required: boolean, scope: readonly string[]): void => {\n const names = new Set<string>();\n const allNames = new Set(mappings.map(mapping => mapping.property));\n const suppliedPaths = new Set<string>();\n for (const mapping of mappings) {\n const segments = mapping.property.split('.');\n for (let depth = 1; depth <= segments.length; depth++) suppliedPaths.add(segments.slice(0, depth).join('.'));\n }\n for (const mapping of mappings) {\n if (names.has(mapping.property)) context.error(DiagnosticCodes.InvalidOperationMapping, `Duplicate operation input mapping '${mapping.property}'.`, mapping.location);\n names.add(mapping.property);\n const target = pathType(operation.inputs, mapping.property, false);\n if (target.missing) context.error(DiagnosticCodes.InvalidOperationMapping, `Operation '${operation.name}' declares no input '${mapping.property}'.`, mapping.location);\n if (target.type === null) continue;\n const targetSegments = mapping.property.split('.');\n for (let depth = 1; depth < targetSegments.length; depth++) if (allNames.has(targetSegments.slice(0, depth).join('.')))\n context.error(DiagnosticCodes.InvalidOperationMapping, `Operation input mapping '${mapping.property}' overlaps a whole input mapping.`, mapping.location);\n if (command !== null && mapping.source.kind === 'PathExpressionSyntax') {\n let supplied = pathType(command.properties, mapping.source.path);\n const segments = mapping.source.path.split('.');\n const reads = (commandReadSources.get(command) ?? []).filter(read => (read.alias ?? read.readModel) === segments[0]);\n if (supplied.missing && reads.length > 0) {\n supplied = { type: null, missing: false };\n const resolvedView = reads.length === 1 ? view(reads[0].readModel, scope) : null;\n if (segments.length > 1 && resolvedView !== null) supplied = pathType(resolvedView.properties, segments.slice(1).join('.'));\n }\n if (supplied.missing) context.error(DiagnosticCodes.InvalidOperationMapping, `Command '${command.name}' declares no source '${mapping.source.path}'.`, mapping.source.location);\n const source = supplied.type;\n const type = target.type;\n if (source !== null && known.has(source.name) && known.has(type.name) && (source.name !== type.name || source.isCollection !== type.isCollection || source.isOptional && !type.isOptional))\n context.error(DiagnosticCodes.InvalidOperationMapping, `Source '${mapping.source.path}' is incompatible with input '${mapping.property}' of operation '${operation.name}'.`, mapping.source.location);\n } else if (['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(mapping.source.kind)) {\n if (!compatibleValue(mapping.source, target.type, concepts, composites) || required && !completeValue(mapping.source, target.type)) context.error(DiagnosticCodes.InvalidOperationMapping, `Value is incompatible with input '${mapping.property}' of operation '${operation.name}'.`, mapping.source.location);\n }\n }\n if (required) for (const input of operation.inputs) {\n if (!covered(input.type, input.name, names, suppliedPaths)) context.error(DiagnosticCodes.InvalidOperationMapping, `Production of operation '${operation.name}' supplies no value for required input '${input.name}'.`, operation.location);\n }\n };\n for (const { slice, scope } of resolver.slices) {\n const operations = operationDeclarations(slice);\n const names = new Set(eventDeclarations(slice).map(event => event.name));\n for (const operation of operations) {\n if (names.has(operation.name)) context.error(DiagnosticCodes.ProductionDeclarationCollision, `Operation '${operation.name}' collides with another event or operation in slice '${slice.name}'.`, operation.location);\n names.add(operation.name);\n if (operation.uses.length > 0 && systems.get(operation.uses) !== 1) context.error(DiagnosticCodes.InvalidSystemReference, `Operation '${operation.name}' must use one declared system; '${operation.uses}' does not resolve uniquely.`, operation.usesLocation ?? operation.location);\n for (const input of operation.inputs) {\n if (!known.has(input.type.name) && !imported.has(input.type.name)) context.warning(DiagnosticCodes.UnknownType, `Unknown type '${input.type.name}' on input '${input.name}' of operation '${operation.name}'.`, input.type.location);\n }\n }\n for (const command of slice.commands) for (const production of command.produces) {\n const resolution = resolver.resolve(production.event, slice);\n if (resolution.kind === AuthoringProductionKind.Ambiguous && resolution.candidates.some(node => node.kind === AuthoringProductionKind.Operation)) context.error(DiagnosticCodes.InvalidProductionReference, `Production '${production.event}' is ambiguous.`, production.location);\n if (production.event.includes('.') && resolution.kind !== AuthoringProductionKind.Operation) context.error(DiagnosticCodes.InvalidProductionReference, 'Qualified productions are supported only for explicitly declared operations.', production.location);\n if (resolution.declaration?.node.kind !== 'OperationSyntax') continue;\n if (production.for !== null || production.tags.length > 0) context.error(DiagnosticCodes.InvalidOperationDeclaration, 'Operation productions cannot declare event destinations or tags.', production.location);\n validateMappings(production.mappings, resolution.declaration.node, command, true, scope);\n }\n for (const production of slice.reactions.flatMap(reaction => reaction.triggers).flatMap(trigger => trigger.produces)) {\n const resolution = resolver.resolve(production.event, slice);\n if (resolution.kind === AuthoringProductionKind.Ambiguous && resolution.candidates.some(node => node.kind === AuthoringProductionKind.Operation)) context.error(DiagnosticCodes.InvalidProductionReference, `Production '${production.event}' is ambiguous.`, production.location);\n if (production.event.includes('.') && resolver.resolve(production.event, slice).kind !== AuthoringProductionKind.Operation) context.error(DiagnosticCodes.InvalidProductionReference, 'Qualified productions are supported only for explicitly declared operations.', production.location);\n if (resolver.isOperation(production, slice)) context.error(DiagnosticCodes.OperationOutsideCommand, 'Operations can only be produced by commands.', production.location);\n }\n for (const specification of slice.specifications) {\n const steps = [...specification.givenOperationFailures ?? [], ...specification.thenOperations ?? [], ...specification.thenCompensated ?? []];\n if (steps.length === 0) continue;\n const command = resolveCommand(effectiveCommand(specification.when, scope)?.commandType ?? '', scope);\n if (command === null || specification.whenAppended !== null || specification.whenQuery !== null || specification.whenTrigger !== null || specification.whenClock !== null || specification.whenCapture !== null)\n context.error(DiagnosticCodes.InvalidOperationSpecification, 'Operation fixtures and assertions require a declared command action.', specification.location);\n const duplicates = new Map<SyntaxNode, Set<string>>();\n for (const step of steps) {\n if (step.kind === 'SpecificationOperationSyntax') for (const mapping of step.values) {\n if (!concrete(mapping.source)) context.error(DiagnosticCodes.InvalidOperationSpecification, 'Operation assertions require concrete input values.', mapping.source.location);\n }\n const node = resolver.resolve(step.operation, slice).declaration?.node;\n if (node?.kind !== 'OperationSyntax') {\n context.error(DiagnosticCodes.InvalidOperationSpecification, `'${step.operation}' does not resolve uniquely to a declared operation.`, step.location);\n continue;\n }\n const kinds = duplicates.get(node) ?? new Set<string>();\n if (kinds.has(step.kind)) context.error(DiagnosticCodes.InvalidOperationSpecification, `Duplicate operation step '${step.operation}'.`, step.location);\n kinds.add(step.kind);\n duplicates.set(node, kinds);\n if (step.kind === 'SpecificationCompensatedSyntax' && node.compensate === null) context.error(DiagnosticCodes.InvalidOperationSpecification, `Operation '${step.operation}' declares no compensation.`, step.location);\n if (command !== null && command.command.handler == null) {\n const produced = command.command.produces.map(production => resolver.resolve(production.event, command.slice));\n if (produced.every(result => result.kind === AuthoringProductionKind.Event || result.kind === AuthoringProductionKind.Operation) && !produced.some(result => result.declaration?.node === node))\n context.error(DiagnosticCodes.InvalidOperationSpecification, `Command '${command.command.name}' does not produce operation '${step.operation}'.`, step.location);\n }\n if (step.kind === 'SpecificationOperationSyntax') validateMappings(step.values, node, null, false, scope);\n }\n }\n }\n}\n"],"mappings":"4iBAiBA,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iBAAiBA,EAAK,OAAQ9C,EAAM,KAAM,GAAO8B,CAAK,CAC5G,CACJ,CACJ,CACJ"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{sourceLocation as e}from"../Diagnostics/SourceLocation.js";import{legacySourceOptions as t}from"../Syntax/SourceOptions.js";var n=class ParserContext{reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=t;authoredDeclarations=!1;deferIdentityValidation=!1;streamCandidates;get valueContext(){if(this.sourceOptions.numericMode===`exact`)return this;let e=new ParserContext(this.reader,this.path,this.languages);return e.sourceOptions=this.sourceOptions,e}constructor(e,t,n=/* @__PURE__ */ new Set([`csharp`,`typescript`,`react`,`html`,`sql`])){this.reader=e,this.path=t,this.languages=n}get start(){return e(1,1,this.path)}get diagnostics(){return this.nestedNumericDirectives.size>0&&this.sourceOptions.numericMode!==`legacy`&&this.reader.atEnd&&(this.#e.push(...[...this.nestedNumericDirectives].sort((e,t)=>e[0]-t[0]).map(e=>e[1])),this.nestedNumericDirectives.clear()),this.#e}nestedNumericDirectives=/* @__PURE__ */ new Map;claimField(e){this.nestedNumericDirectives.delete(e.number)}information(e,t,n){this.#e.push({severity:`information`,code:e,message:t,location:n})}error(e,t,n){this.#e.push({severity:`error`,code:e,message:t,location:n})}warning(e,t,n){this.#e.push({severity:`warning`,code:e,message:t,location:n})}peekChild(e){let t=this.reader.peekSignificant();return t!==void 0&&t.indent>e?t:void 0}skipBlock(e){for(;this.peekChild(e)!==void 0;)this.reader.takeSignificant()}skipOpaqueBlock(e){let t=this.peekChild(e);for(;t!==void 0;)this.reader.takeSignificant(),t.content.startsWith("```")&&this.skipFencedBody(),t=this.peekChild(e)}skipFencedBody(){for(let e=this.reader.takeRaw();e!==void 0;e=this.reader.takeRaw())if(e.raw.trim()==="```")return}};export{n as ParserContext};
2
+ //# sourceMappingURL=ParserContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParserContext.js","names":["ParserContext","legacySourceOptions","context","reader","path","languages","sourceLocation","#diagnostics","first","second","entry","line","parentIndent","child"],"sources":["../../../../../../Compiler/Parsing/ParserContext.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 { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { CommandStreamCandidates } from './CommandStreamCandidates';\nimport { SourceLocation, sourceLocation } from '../Diagnostics/SourceLocation';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { legacySourceOptions, SourceOptions } from '../Syntax/SourceOptions';\nimport { InputUse } from './InputUses';\nimport { LineReader } from './LineReader';\nimport { SourceLine } from './SourceLine';\n\n// What every parser shares while it reads one document: the line reader, the diagnostics found so far and\n// the file the document came from.\nexport class ParserContext {\n readonly #diagnostics: Diagnostic[] = [];\n // Authoring verification needs these committed values even though SyntaxJson omits them.\n readonly triggerData: PropertySyntax[] = [];\n readonly inputUses: InputUse[] = [];\n scope: readonly string[] = [];\n readonly languages: ReadonlySet<string>;\n sourceOptions: SourceOptions = legacySourceOptions;\n authoredDeclarations = false;\n deferIdentityValidation = false;\n streamCandidates?: CommandStreamCandidates;\n\n // Structural enrichment of formerly opaque Legacy fields must not add diagnostics. Exact operands\n // use the owning context so representability failures cannot turn into successful opaque syntax.\n get valueContext(): ParserContext {\n if (this.sourceOptions.numericMode === 'exact') return this;\n const context = new ParserContext(this.reader, this.path, this.languages);\n context.sourceOptions = this.sourceOptions;\n return context;\n }\n\n constructor(readonly reader: LineReader, readonly path?: string, languages: ReadonlySet<string> = new Set(['csharp', 'typescript', 'react', 'html', 'sql'])) {\n this.languages = languages;\n }\n\n get start(): SourceLocation {\n return sourceLocation(1, 1, this.path);\n }\n\n get diagnostics(): readonly Diagnostic[] {\n // Directive-shaped lines nobody claimed as a field are errors, wherever they sit.\n if (this.nestedNumericDirectives.size > 0 && this.sourceOptions.numericMode !== 'legacy' && this.reader.atEnd) {\n this.#diagnostics.push(...[...this.nestedNumericDirectives].sort((first, second) => first[0] - second[0]).map(entry => entry[1]));\n this.nestedNumericDirectives.clear();\n }\n return this.#diagnostics;\n }\n\n // Directive-shaped lines below the top level, keyed by line number, still unclaimed as a field.\n nestedNumericDirectives = new Map<number, Diagnostic>();\n\n claimField(line: SourceLine): void {\n this.nestedNumericDirectives.delete(line.number);\n }\n\n information(code: string, message: string, location: SourceLocation): void {\n this.#diagnostics.push({ severity: 'information', code, message, location });\n }\n\n error(code: string, message: string, location: SourceLocation): void {\n this.#diagnostics.push({ severity: 'error', code, message, location });\n }\n\n warning(code: string, message: string, location: SourceLocation): void {\n this.#diagnostics.push({ severity: 'warning', code, message, location });\n }\n\n // The next significant line when it is indented deeper than its parent - that is, when it belongs to\n // the parent's body under the offside rule.\n peekChild(parentIndent: number): SourceLine | undefined {\n const line = this.reader.peekSignificant();\n return line !== undefined && line.indent > parentIndent ? line : undefined;\n }\n\n // Skips the body of a construct, the way the C# parser does after reporting it.\n skipBlock(parentIndent: number): void {\n while (this.peekChild(parentIndent) !== undefined) {\n this.reader.takeSignificant();\n }\n }\n\n // Skips the body of a construct this compiler deliberately does not model. Unlike skipBlock it steps\n // over fenced code blocks whole, because a fenced line may be indented less than the block it is in -\n // reading it as significant would end the skip early and misread the code as Screenplay.\n skipOpaqueBlock(parentIndent: number): void {\n let child = this.peekChild(parentIndent);\n while (child !== undefined) {\n this.reader.takeSignificant();\n if (child.content.startsWith('```')) {\n this.skipFencedBody();\n }\n child = this.peekChild(parentIndent);\n }\n }\n\n // Takes the raw lines of a fenced block up to and including its closing fence.\n skipFencedBody(): void {\n for (let line = this.reader.takeRaw(); line !== undefined; line = this.reader.takeRaw()) {\n if (line.raw.trim() === '```') {\n return;\n }\n }\n }\n}\n"],"mappings":"wLAcA,IAAaA,EAAb,MAAa,aAAc,CAqBF,OAA6B,KApBlD,GAAsC,CAAC,EAEvC,YAAyC,CAAC,EAC1C,UAAiC,CAAC,EAClC,MAA2B,CAAC,EAC5B,UACA,cAA+BC,E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,IAAA,IAAaA,EAAK,OAASC,EAAeD,EAAO,IAAA,EACrE,CAGA,UAAU,EAA4B,CAClC,KAAO,KAAK,UAAUC,CAAY,IAAM,IAAA,IACpC,KAAK,OAAO,gBAAgB,CAEpC,CAKA,gBAAgB,EAA4B,CACxC,IAAIC,EAAQ,KAAK,UAAUD,CAAY,EACvC,KAAOC,IAAU,IAAA,IACb,KAAK,OAAO,gBAAgB,EACxBA,EAAM,QAAQ,WAAW,KAAK,GAC9B,KAAK,eAAe,EAExB,EAAQ,KAAK,UAAUD,CAAY,CAE3C,CAGA,gBAAuB,CACnB,IAAK,IAAID,EAAO,KAAK,OAAO,QAAQ,EAAGA,IAAS,IAAA,GAAW,EAAO,KAAK,OAAO,QAAQ,EAClF,GAAIA,EAAK,IAAI,KAAK,IAAM,MACpB,MAGZ,CACJ"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";function validatePersonaCallers(t,n){let r=t.personas.map(e=>e.name),visit=t=>{for(let i of t){visit(i.features);for(let t of i.slices)for(let i of t.specifications){let t=i.givenCallerPersona;if(t!=null){let i=r.filter(e=>e===t.name).length;i!==1&&n.error(e.InvalidSpecificationCallerPersona,`${i===0?`Unknown`:`Ambiguous`} persona '${t.name}' - declared personas: ${r.join(`, `)}.`,t.location)}}}};for(let e of t.modules)visit(e.features)}export{validatePersonaCallers};
2
+ //# sourceMappingURL=PersonaCallerValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersonaCallerValidator.js","names":["personas","application","persona","feature","features","slice","specification","reference","count","name","context","DiagnosticCodes","module"],"sources":["../../../../../../Compiler/Parsing/PersonaCallerValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\n\nexport function validatePersonaCallers(application: ApplicationSyntax, context: ParserContext): void {\n const personas = application.personas.map(persona => persona.name);\n const visit = (features: readonly FeatureSyntax[]): void => {\n for (const feature of features) {\n visit(feature.features);\n for (const slice of feature.slices) {\n for (const specification of slice.specifications) {\n const reference = specification.givenCallerPersona;\n if (reference != null) {\n const count = personas.filter(name => name === reference.name).length;\n if (count !== 1) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, `${count === 0 ? 'Unknown' : 'Ambiguous'} persona '${reference.name}' - declared personas: ${personas.join(', ')}.`, reference.location);\n }\n }\n }\n }\n };\n for (const module of application.modules) visit(module.features);\n}\n"],"mappings":"yHAOA,SAAgB,uBAAuB,EAAgC,EAA8B,CACjG,IAAMA,EAAWC,EAAY,SAAS,IAAI,GAAWC,EAAQ,IAAI,EAC3D,MAAS,GAA6C,CACxD,IAAK,IAAMC,KAAWC,EAAU,CAC5B,MAAMD,EAAQ,QAAQ,EACtB,IAAK,IAAME,KAASF,EAAQ,OACxB,IAAK,IAAMG,KAAiBD,EAAM,eAAgB,CAC9C,IAAME,EAAYD,EAAc,mBAChC,GAAIC,GAAa,KAAM,CACnB,IAAMC,EAAQR,EAAS,OAAO,GAAQS,IAASF,EAAU,IAAI,CAAC,CAAC,OAC3DC,IAAU,GAAGE,EAAQ,MAAMC,EAAgB,kCAAmC,GAAGH,IAAU,EAAI,UAAY,YAAY,YAAYD,EAAU,KAAK,yBAAyBP,EAAS,KAAK,IAAI,EAAE,GAAIO,EAAU,QAAQ,CAC7N,CACJ,CAER,CACJ,EACA,IAAK,IAAMK,KAAUX,EAAY,QAAS,MAAMW,EAAO,QAAQ,CACnE"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{nativePattern as t}from"../Text/patterns.js";import{unescapeString as n}from"../Text/StringLiteral.js";import{parseModeledMappingSource as r}from"./ExpressionParser.js";import{firstWord as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";import{parseDescription as o}from"./DescriptionParser.js";import{parseCode as s,parseFile as c}from"./ImplementationParser.js";const l=t(`^policy\\s+([A-Za-z_]\\w*)$`);function parsePolicy(t,n){let r=t;t=t.valueContext;let u=l.exec(n.content)?.[1]??``;u===``&&t.error(e.InvalidPolicyDeclaration,`Invalid policy declaration '${n.content}' - expected 'policy <Name>'`,a(n));let d=null,f=null,p=null,m=!1,h=null;for(let l=t.peekChild(n.indent);l!==void 0;l=t.peekChild(n.indent))if(t.reader.takeSignificant(),i(l.content)===`description`)h=o(r,l,h,`Policy '${u}'`);else if(i(l.content)===`require`){let n=l.content.substring(7).trim();for(let e=t.peekChild(l.indent);e!==void 0;e=t.peekChild(l.indent))t.reader.takeSignificant(),n+=` ${e.content}`;let i=tokenizePolicyCondition(t,n);i.includes(`not`)&&(t=r);let o=parsePolicyCondition(t,i,a(l));m?t.error(e.RepeatedPolicyRequirement,`Policy '${u}' has more than one require line; combine the conditions with and/or in one require`,a(l)):d=o,m=!0}else if(i(l.content)===`file`){let n=c(t,l);f===null&&p===null?p=n:t.error(e.UnknownPolicyDirective,`Policy '${u}' must have only one implementation - a file reference or an inline code block, not both`,a(l))}else if(l.content.startsWith("```")||t.languages.has(l.content)){let n=s(t,l);f===null&&p===null?f=n:t.error(e.UnknownPolicyDirective,`Policy '${u}' must have only one implementation - a file reference or an inline code block, not both`,a(l))}else t.error(e.UnknownPolicyDirective,`Unexpected '${l.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,a(l)),t.skipOpaqueBlock(l.indent);return d!==null&&(f!==null||p!==null)&&t.error(e.MixedPolicyImplementation,`Policy '${u}' cannot combine 'require' with a file or inline code block`,a(n)),d===null&&f===null&&p===null&&t.error(e.PolicyWithoutRequirement,`Policy '${u}' must declare a 'require' condition, a file reference or an inline code block`,a(n)),{kind:`PolicySyntax`,name:u,condition:d,code:f,file:p,description:h,location:a(n)}}function tokenizePolicyCondition(e,n){let r=e.sourceOptions.numericMode===`exact`?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]`:`[\\w.$]+`;return[...n.match(new RegExp(t(`"(?:[^"\\\\]|\\\\.)*"|\\(|\\)|${r}`).source,`gu`))??[]]}function parsePolicyCondition(t,i,a){let o=t.sourceOptions.numericMode===`exact`||i.includes(`not`),s=0,quoted=e=>e!==void 0&&e.startsWith(`"`)&&e.endsWith(`"`),unquote=e=>n(e.substring(1,e.length-1)),group=()=>{if(i[s]===`not`){s++;let e=group();return e===null?null:{kind:`NotPolicyConditionSyntax`,operand:e,location:a}}if(i[s]===`(`){s++;let n=or();return i[s]===`)`?s++:o&&t.error(e.UnclosedPolicyConditionGroup,`Expected ')' in policy condition`,a),n}let n=i[s++];if(n===`authenticated`)return{kind:`AuthenticatedConditionSyntax`,location:a};if(n!==`role`&&n!==`claim`)return t.error(n===void 0?e.ExpectedPolicyCondition:e.UnexpectedTokenInPolicyCondition,n===void 0?`Expected a policy condition`:`Unexpected '${n}' in policy condition`,a),null;let c=i[s++];if(!quoted(c))return t.error(n===`role`?e.ExpectedRoleName:e.ExpectedClaimName,`Expected a quoted ${n} name after '${n}'`,a),null;if(n===`role`)return{kind:`RoleConditionSyntax`,role:unquote(c),location:a};if(i[s++]!==`matches`)return t.error(e.ExpectedClaimMatches,`Expected 'matches' after the claim name`,a),null;let l=i[s++];return l===void 0?(t.error(e.ExpectedClaimMatchTarget,`Expected 'subject' or a value after 'matches'`,a),null):{kind:`ClaimConditionSyntax`,claim:unquote(c),matchesSubject:l===`subject`,matches:l===`subject`?null:r(l,a,t),location:a}},and=()=>{let e=group();for(;e!==null&&i[s]===`and`;){s++;let t=group();if(t===null)return null;e={kind:`LogicalPolicyConditionSyntax`,left:e,operator:`And`,right:t,location:a}}return e},or=()=>{let e=and();for(;e!==null&&i[s]===`or`;){s++;let t=and();if(t===null)return null;e={kind:`LogicalPolicyConditionSyntax`,left:e,operator:`Or`,right:t,location:a}}return e},c=or();return o&&c!==null&&s<i.length&&t.error(e.UnexpectedTokenInPolicyCondition,`Unexpected '${i[s]}' in policy condition`,a),c}export{parsePolicy};
2
+ //# sourceMappingURL=PolicyParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PolicyParser.js","names":["pattern","parseMappingSource","headerPattern","nativePattern","diagnosticContext","context","name","header","DiagnosticCodes","locationOf","condition","code","file","hasRequire","description","line","firstWord","parseDescription","text","continuation","tokens","parsed","parseFile","parseCode","numeric","reportDiagnostics","position","token","unescapeString","operand","result","location","target","parseModeledMappingSource","left","right"],"sources":["../../../../../../Compiler/Parsing/PolicyParser.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { CodeBlockSyntax, FileReferenceSyntax } from '../Syntax/Implementations';\nimport { PolicyConditionSyntax, PolicySyntax } from '../Syntax/Policies';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { nativePattern as pattern } from '../Text/patterns';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { parseCode, parseFile } from './ImplementationParser';\nimport { firstWord } from './LineText';\nimport { parseDescription } from './DescriptionParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst headerPattern = pattern('^policy\\\\s+([A-Za-z_]\\\\w*)$');\n\nexport function parsePolicy(context: ParserContext, header: SourceLine): PolicySyntax {\n const diagnosticContext = context;\n context = context.valueContext;\n const name = headerPattern.exec(header.content)?.[1] ?? '';\n if (name === '') context.error(DiagnosticCodes.InvalidPolicyDeclaration, `Invalid policy declaration '${header.content}' - expected 'policy <Name>'`, locationOf(header));\n let condition: PolicyConditionSyntax | null = null;\n let code: CodeBlockSyntax | null = null;\n let file: FileReferenceSyntax | null = null;\n let hasRequire = false;\n let description: string | null = null;\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (firstWord(line.content) === 'description') {\n description = parseDescription(diagnosticContext, line, description, `Policy '${name}'`);\n } else if (firstWord(line.content) === 'require') {\n let text = line.content.substring('require'.length).trim();\n for (let continuation = context.peekChild(line.indent); continuation !== undefined; continuation = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n text += ` ${continuation.content}`;\n }\n const tokens = tokenizePolicyCondition(context, text);\n // Negation is newly admitted syntax, not diagnostic-free enrichment of legacy fields.\n if (tokens.includes('not')) context = diagnosticContext;\n const parsed = parsePolicyCondition(context, tokens, locationOf(line));\n if (hasRequire) context.error(DiagnosticCodes.RepeatedPolicyRequirement, `Policy '${name}' has more than one require line; combine the conditions with and/or in one require`, locationOf(line));\n else condition = parsed;\n hasRequire = true;\n } else if (firstWord(line.content) === 'file') {\n const parsed = parseFile(context, line);\n if (code === null && file === null) file = parsed;\n else context.error(DiagnosticCodes.UnknownPolicyDirective, `Policy '${name}' must have only one implementation - a file reference or an inline code block, not both`, locationOf(line));\n } else if (line.content.startsWith('```') || context.languages.has(line.content)) {\n const parsed = parseCode(context, line);\n if (code === null && file === null) code = parsed;\n else context.error(DiagnosticCodes.UnknownPolicyDirective, `Policy '${name}' must have only one implementation - a file reference or an inline code block, not both`, locationOf(line));\n } else {\n context.error(DiagnosticCodes.UnknownPolicyDirective, `Unexpected '${line.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`, locationOf(line));\n context.skipOpaqueBlock(line.indent);\n }\n }\n if (condition !== null && (code !== null || file !== null)) context.error(DiagnosticCodes.MixedPolicyImplementation, `Policy '${name}' cannot combine 'require' with a file or inline code block`, locationOf(header));\n if (condition === null && code === null && file === null) context.error(DiagnosticCodes.PolicyWithoutRequirement, `Policy '${name}' must declare a 'require' condition, a file reference or an inline code block`, locationOf(header));\n return { kind: 'PolicySyntax', name, condition, code, file, description, location: locationOf(header) };\n}\n\nfunction tokenizePolicyCondition(context: ParserContext, text: string): string[] {\n const numeric = context.sourceOptions.numericMode === 'exact' ? '-?[0-9]+(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\\\s()])|[\\\\w.$-]+|[^\\\\s]' : '[\\\\w.$]+';\n return [...(text.match(new RegExp(pattern(`\"${stringBodyPattern}\"|\\\\(|\\\\)|${numeric}`).source, 'gu')) ?? [])];\n}\n\nfunction parsePolicyCondition(context: ParserContext, tokens: string[], location: SourceLocation): PolicyConditionSyntax | null {\n const reportDiagnostics = context.sourceOptions.numericMode === 'exact' || tokens.includes('not');\n let position = 0;\n const quoted = (token: string | undefined): token is string => token !== undefined && token.startsWith('\"') && token.endsWith('\"');\n const unquote = (token: string): string => unescapeString(token.substring(1, token.length - 1));\n const group = (): PolicyConditionSyntax | null => {\n if (tokens[position] === 'not') {\n position++;\n const operand = group();\n return operand === null ? null : { kind: 'NotPolicyConditionSyntax', operand, location };\n }\n if (tokens[position] === '(') {\n position++;\n const result = or();\n if (tokens[position] === ')') position++;\n else if (reportDiagnostics) context.error(DiagnosticCodes.UnclosedPolicyConditionGroup, \"Expected ')' in policy condition\", location);\n return result;\n }\n const token = tokens[position++];\n if (token === 'authenticated') return { kind: 'AuthenticatedConditionSyntax', location };\n if (token !== 'role' && token !== 'claim') {\n context.error(token === undefined ? DiagnosticCodes.ExpectedPolicyCondition : DiagnosticCodes.UnexpectedTokenInPolicyCondition, token === undefined ? 'Expected a policy condition' : `Unexpected '${token}' in policy condition`, location);\n return null;\n }\n const name = tokens[position++];\n if (!quoted(name)) {\n context.error(token === 'role' ? DiagnosticCodes.ExpectedRoleName : DiagnosticCodes.ExpectedClaimName, `Expected a quoted ${token} name after '${token}'`, location);\n return null;\n }\n if (token === 'role') return { kind: 'RoleConditionSyntax', role: unquote(name), location };\n if (tokens[position++] !== 'matches') {\n context.error(DiagnosticCodes.ExpectedClaimMatches, \"Expected 'matches' after the claim name\", location);\n return null;\n }\n const target = tokens[position++];\n if (target === undefined) {\n context.error(DiagnosticCodes.ExpectedClaimMatchTarget, \"Expected 'subject' or a value after 'matches'\", location);\n return null;\n }\n return { kind: 'ClaimConditionSyntax', claim: unquote(name), matchesSubject: target === 'subject', matches: target === 'subject' ? null : parseMappingSource(target, location, context), location };\n };\n const and = (): PolicyConditionSyntax | null => {\n let left = group();\n while (left !== null && tokens[position] === 'and') { position++; const right = group(); if (right === null) return null; left = { kind: 'LogicalPolicyConditionSyntax', left, operator: 'And', right, location }; }\n return left;\n };\n const or = (): PolicyConditionSyntax | null => {\n let left = and();\n while (left !== null && tokens[position] === 'or') { position++; const right = and(); if (right === null) return null; left = { kind: 'LogicalPolicyConditionSyntax', left, operator: 'Or', right, location }; }\n return left;\n };\n const condition = or();\n if (reportDiagnostics) {\n if (condition !== null && position < tokens.length) context.error(DiagnosticCodes.UnexpectedTokenInPolicyCondition, `Unexpected '${tokens[position]}' in policy condition`, location);\n }\n return condition;\n}\n"],"mappings":"+fAgBA,MAAME,EAAgBF,EAAQ,6BAA6B,EAE3D,SAAgB,YAAY,EAAwB,EAAkC,CAClF,IAAMI,EAAoBC,EAC1B,EAAUA,EAAQ,aAClB,IAAMC,EAAOJ,EAAc,KAAKK,EAAO,OAAO,CAAC,GAAG,IAAM,GACpDD,IAAS,IAAID,EAAQ,MAAMG,EAAgB,yBAA0B,+BAA+BD,EAAO,QAAQ,8BAA+BE,EAAWF,CAAM,CAAC,EACxK,IAAIG,EAA0C,KAC1CC,EAA+B,KAC/BC,EAAmC,KACnCC,EAAa,GACbC,EAA6B,KACjC,IAAK,IAAIC,EAAOV,EAAQ,UAAUE,EAAO,MAAM,EAAGQ,IAAS,IAAA,GAAW,EAAOV,EAAQ,UAAUE,EAAO,MAAM,EAExG,GADAF,EAAQ,OAAO,gBAAgB,EAC3BW,EAAUD,EAAK,OAAO,IAAM,cAC5B,EAAcE,EAAiBb,EAAmBW,EAAMD,EAAa,WAAWR,EAAK,E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,OAHIe,GACIf,IAAc,MAAQgB,EAAWN,EAAO,QAAQf,EAAQ,MAAMG,EAAgB,iCAAkC,eAAeY,EAAOM,GAAU,uBAAwBK,CAAQ,EAEjLrB,CACX"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{parseMappingSource as n}from"./ExpressionParser.js";import{firstWord as r,unescapeIdentifier as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";import{parseProperty as o}from"./PropertyLineParser.js";import{parseCondition as s}from"./ConditionParser.js";import{parseOperation as c}from"./OperationParser.js";import{EventMetadataParser as l}from"./EventMetadataParser.js";import{parseTag as u}from"./DeclarationParsers.js";const d=t(`^produces\\s+operation(?:\\s|$)`),f=t(`^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$`),p=t(`^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),m=t(`^produces\\s+when\\s+(.+)$`),h=t(`^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$`),g=t(`^for\\s+(\\S.*)$`),_=t(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),v=t(`^(.+?)\\s*=(?!=|>)\\s*(.+)$`),y=/* @__PURE__ */ new Set([`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`]);function parseProduces(t,b,x=!1){if(d.test(b.content)){if(!x){t.error(e.OperationOutsideCommand,`Operations can only be produced by commands.`,a(b)),t.skipOpaqueBlock(b.indent);return}let n=c(t,b,!0);return{kind:`ProducesSyntax`,when:null,event:n.operation.name,targetLocation:{...a(b),column:b.indent+b.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:n.operation,mappings:n.mappings,for:null,tags:[],location:a(b)}}let S=f.exec(b.content),C=b,w=null,T,E;if(S!==null){if(!x){t.error(e.InlineEventOutsideCommand,`Inline events can only be declared inside commands`,a(b)),t.skipOpaqueBlock(b.indent);return}S[2]!==void 0&&t.error(e.InlineEventGeneration,`Inline events are generation 1 - extract the event before declaring generations`,a(b)),T=S[1],E=b.indent+b.content.match(/^produces\s+event\s+/)[0].length+1}else if(m.test(b.content)){w=s(t,m.exec(b.content)[1],a(b));let n=t.peekChild(b.indent);if(n===void 0||!h.test(n.content)){t.error(e.ProducesWhenWithoutEvent,`Expected an event name on the line after 'produces when'`,a(b)),t.skipOpaqueBlock(b.indent);return}t.reader.takeSignificant(),C=n,T=n.content,E=n.indent+1}else{let n=p.exec(b.content);if(n===null){t.error(e.InvalidProducesDeclaration,`Invalid produces declaration '${b.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,a(b)),t.skipOpaqueBlock(b.indent);return}T=n[1],E=b.indent+b.content.match(/^produces\s+/)[0].length+1}let D=[],O=/* @__PURE__ */ new Set,k=[],A=[],j=new l(T),M=null;for(let s=t.peekChild(C.indent);s!==void 0;s=t.peekChild(C.indent)){t.reader.takeSignificant();let c=r(s.content),l=a(s);if(y.has(c)){t.error(e.ReservedProductionMetadata,`'${c}' is system-assigned production metadata and cannot be supplied here`,l),t.skipOpaqueBlock(s.indent);continue}if(S!==null&&(c===`generation`||c===`origin`)){t.error(c===`generation`?e.InlineEventGeneration:e.ReservedProductionMetadata,c===`generation`?`Inline events are generation 1 - extract the event before declaring generations`:`An inline event is local to its command and cannot declare origin`,l),t.skipOpaqueBlock(s.indent);continue}if(c===`tag`){let e=u(t,s,!1);e!==void 0&&A.push(e);continue}let d=g.exec(s.content);if(d!==null){M===null?M=n(d[1],l,t):t.error(e.DuplicateProducesTarget,`'${C.content}' already declares where it lands - an event is appended to one event source`,l);continue}let f=(S===null?_:v).exec(s.content),p=f===null||S===null?void 0:o(t,{...s,content:f[1].trimEnd()});if(f!==null&&(S===null||p!==void 0)){if(p!==void 0){p.isIdentifier&&(t.error(e.IdentifierOnEventProperty,`Property '${p.name}' of event '${T}' cannot be marked identifier - an event never carries its event source id`,l),p={...p,isIdentifier:!1});let n=p.name;O.has(n)&&t.error(e.DuplicateDeclaration,`Event '${T}' already declares property '${p.name}'`,l),O.add(n),D.push(p)}k.push({kind:`PropertyMappingSyntax`,property:p?.name??i(f[1]),source:n(f[2],{...l,column:s.indent+s.content.length-f[2].length+1},t),location:l})}else(S===null||!j.tryParse(t,s))&&t.error(e.InvalidPropertyMapping,`Invalid ${S===null?``:`inline `}property mapping '${s.content}' - expected '<property>${S===null?``:` <Type>`} = <source>'`,l)}return C!==b&&t.skipBlock(b.indent),{kind:`ProducesSyntax`,when:w,event:T,targetLocation:{...a(C),column:E},inlineOperation:null,mappings:k,for:M,tags:S===null?A:[],location:a(b),inlineEvent:S===null?null:{kind:`EventSyntax`,name:T,properties:D,tags:A,generation:1,hasGenerationMarker:!1,...j.value,location:a(b)}}}export{parseProduces};
2
+ //# sourceMappingURL=ProducesParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProducesParser.js","names":["inlineOperationPrefix","pattern","inlineHeader","plainHeader","conditional","eventName","targetPattern","mappingPattern","typedMappingPattern","reserved","header","inCommand","context","DiagnosticCodes","locationOf","parsed","parseOperation","inline","parent","when","name","targetColumn","parseCondition","child","plain","properties","propertyNames","mappings","tags","metadata","EventMetadataParser","target","line","keyword","firstWord","location","tag","parseTag","forMatch","parseMappingSource","match","property","parseProperty","propertyName","unescapeIdentifier"],"sources":["../../../../../../Compiler/Parsing/ProducesParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ConditionSyntax } from '../Syntax/Conditions';\nimport { parseCondition } from './ConditionParser';\nimport { PropertySyntax, TagSyntax } from '../Syntax/Declarations';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { ProducesSyntax } from '../Syntax/Reactions';\nimport { pattern } from '../Text/patterns';\nimport { parseTag } from './DeclarationParsers';\nimport { EventMetadataParser } from './EventMetadataParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseOperation } from './OperationParser';\nimport { parseProperty } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst inlineOperationPrefix = pattern('^produces\\\\s+operation(?:\\\\s|$)');\nconst inlineHeader = pattern('^produces\\\\s+event\\\\s+([A-Za-z_]\\\\w*)(?:\\\\s+(generation)(?:\\\\s+.*)?)?$');\nconst plainHeader = pattern('^produces\\\\s+([A-Z]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)$');\nconst conditional = pattern('^produces\\\\s+when\\\\s+(.+)$');\nconst eventName = pattern('^[A-Z]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*$');\nconst targetPattern = pattern('^for\\\\s+(\\\\S.*)$');\nconst mappingPattern = pattern('^(@?[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst typedMappingPattern = pattern('^(.+?)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst reserved = new Set(['namespace', 'sequence', 'correlation', 'causation', 'causedBy', 'occurred']);\n\nexport function parseProduces(context: ParserContext, header: SourceLine, inCommand = false): ProducesSyntax | undefined {\n if (inlineOperationPrefix.test(header.content)) {\n if (!inCommand) {\n context.error(DiagnosticCodes.OperationOutsideCommand, 'Operations can only be produced by commands.', locationOf(header));\n context.skipOpaqueBlock(header.indent);\n return undefined;\n }\n const parsed = parseOperation(context, header, true);\n return { kind: 'ProducesSyntax', when: null, event: parsed.operation.name, targetLocation: { ...locationOf(header), column: header.indent + header.content.match(/^produces\\s+operation(?:\\s+|$)/)![0].length + 1 }, inlineEvent: null, inlineOperation: parsed.operation, mappings: parsed.mappings, for: null, tags: [], location: locationOf(header) };\n }\n const inline = inlineHeader.exec(header.content);\n let parent = header;\n let when: ConditionSyntax | null = null;\n let name: string;\n let targetColumn: number;\n if (inline !== null) {\n if (!inCommand) {\n context.error(DiagnosticCodes.InlineEventOutsideCommand, 'Inline events can only be declared inside commands', locationOf(header));\n context.skipOpaqueBlock(header.indent);\n return undefined;\n }\n if (inline[2] !== undefined) {\n context.error(DiagnosticCodes.InlineEventGeneration, 'Inline events are generation 1 - extract the event before declaring generations', locationOf(header));\n }\n name = inline[1];\n targetColumn = header.indent + header.content.match(/^produces\\s+event\\s+/)![0].length + 1;\n } else if (conditional.test(header.content)) {\n when = parseCondition(context, conditional.exec(header.content)![1], locationOf(header));\n const child = context.peekChild(header.indent);\n if (child === undefined || !eventName.test(child.content)) {\n context.error(DiagnosticCodes.ProducesWhenWithoutEvent, \"Expected an event name on the line after 'produces when'\", locationOf(header));\n context.skipOpaqueBlock(header.indent);\n return undefined;\n }\n context.reader.takeSignificant();\n parent = child;\n name = child.content;\n targetColumn = child.indent + 1;\n } else {\n const plain = plainHeader.exec(header.content);\n if (plain === null) {\n context.error(DiagnosticCodes.InvalidProducesDeclaration, `Invalid produces declaration '${header.content}' - expected 'produces <EventType>' or 'produces when <condition>'`, locationOf(header));\n context.skipOpaqueBlock(header.indent);\n return undefined;\n }\n name = plain[1];\n targetColumn = header.indent + header.content.match(/^produces\\s+/)![0].length + 1;\n }\n const properties: PropertySyntax[] = [];\n const propertyNames = new Set<string>();\n const mappings: PropertyMappingSyntax[] = [];\n const tags: TagSyntax[] = [];\n const metadata = new EventMetadataParser(name);\n let target: ExpressionSyntax | null = null;\n for (let line = context.peekChild(parent.indent); line !== undefined; line = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n const location = locationOf(line);\n if (reserved.has(keyword)) {\n context.error(DiagnosticCodes.ReservedProductionMetadata, `'${keyword}' is system-assigned production metadata and cannot be supplied here`, location);\n context.skipOpaqueBlock(line.indent);\n continue;\n }\n if (inline !== null && (keyword === 'generation' || keyword === 'origin')) {\n context.error(keyword === 'generation' ? DiagnosticCodes.InlineEventGeneration : DiagnosticCodes.ReservedProductionMetadata,\n keyword === 'generation' ? 'Inline events are generation 1 - extract the event before declaring generations' : 'An inline event is local to its command and cannot declare origin', location);\n context.skipOpaqueBlock(line.indent);\n continue;\n }\n if (keyword === 'tag') {\n const tag = parseTag(context, line, false);\n if (tag !== undefined) tags.push(tag);\n continue;\n }\n const forMatch = targetPattern.exec(line.content);\n if (forMatch !== null) {\n if (target !== null) {\n context.error(DiagnosticCodes.DuplicateProducesTarget, `'${parent.content}' already declares where it lands - an event is appended to one event source`, location);\n } else {\n target = parseMappingSource(forMatch[1], location, context);\n }\n continue;\n }\n const match = (inline === null ? mappingPattern : typedMappingPattern).exec(line.content);\n let property = match === null || inline === null ? undefined : parseProperty(context, { ...line, content: match[1].trimEnd() });\n if (match !== null && (inline === null || property !== undefined)) {\n if (property !== undefined) {\n if (property.isIdentifier) {\n context.error(DiagnosticCodes.IdentifierOnEventProperty, `Property '${property.name}' of event '${name}' cannot be marked identifier - an event never carries its event source id`, location);\n property = { ...property, isIdentifier: false };\n }\n const propertyName = property.name;\n if (propertyNames.has(propertyName)) {\n context.error(DiagnosticCodes.DuplicateDeclaration, `Event '${name}' already declares property '${property.name}'`, location);\n }\n propertyNames.add(propertyName);\n properties.push(property);\n }\n mappings.push({ kind: 'PropertyMappingSyntax', property: property?.name ?? unescapeIdentifier(match[1]), source: parseMappingSource(match[2], { ...location, column: line.indent + line.content.length - match[2].length + 1 }, context), location });\n } else if (inline === null || !metadata.tryParse(context, line)) {\n context.error(DiagnosticCodes.InvalidPropertyMapping, `Invalid ${inline === null ? '' : 'inline '}property mapping '${line.content}' - expected '<property>${inline === null ? '' : ' <Type>'} = <source>'`, location);\n }\n }\n if (parent !== header) context.skipBlock(header.indent);\n return {\n kind: 'ProducesSyntax', when, event: name, targetLocation: { ...locationOf(parent), column: targetColumn }, inlineOperation: null, mappings, for: target, tags: inline === null ? tags : [], location: locationOf(header),\n inlineEvent: inline === null ? null : { kind: 'EventSyntax', name, properties, tags,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{nativePattern as t}from"../Text/patterns.js";import{parseLiteral as n,parseModeledMappingSource as r}from"./ExpressionParser.js";const i=t(`^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$`);function parseProjectionExpression(t,a,o){if(o=o.valueContext,t=t.trim(),t.startsWith("`")){let n=[];if(!t.endsWith("`")||t.length<2)return o.error(e.UnterminatedTemplateExpression,`Unterminated template expression - expected a closing backtick`,a),{kind:`TemplateExpressionSyntax`,parts:n,location:a};let r=t.substring(1,t.length-1),i=0;for(let t=0;t<r.length;t++){if(r[t]!==`$`||r[t+1]!==`{`)continue;t>i&&n.push({kind:`TemplateTextSyntax`,text:r.substring(i,t),location:a});let s=r.indexOf(`}`,t);if(s<0)return o.error(e.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",a),{kind:`TemplateExpressionSyntax`,parts:n,location:a};n.push({kind:`TemplateInterpolationSyntax`,expression:parseProjectionExpression(r.substring(t+2,s),a,o),location:a}),t=s,i=s+1}return i<r.length&&n.push({kind:`TemplateTextSyntax`,text:r.substring(i),location:a}),{kind:`TemplateExpressionSyntax`,parts:n,location:a}}let s=t.startsWith(`literal `)?t.substring(8).trim():t;if(o.sourceOptions.numericMode===`exact`&&(s.startsWith(`{`)||s.startsWith(`[`)))return r(s,a,o);if(t.startsWith(`literal `)){let r=n(t.substring(8).trim(),a,o);return r===void 0?(o.error(e.ExpectedLiteralValue,`Expected a literal value after 'literal', got '${t.substring(8).trim()}'`,a),{kind:`RawExpressionSyntax`,text:t,location:a}):r}if(t===`$refusal`||t.startsWith(`$refusal.`))return{kind:`RefusalExpressionSyntax`,member:t===`$refusal`?``:t.substring(9),location:a};if(t===`$eventSourceId`)return{kind:`EventSourceIdExpressionSyntax`,location:a};if(t.startsWith(`$eventContext.`))return{kind:`EventContextExpressionSyntax`,path:t.substring(14),location:a};if(t===`$causedBy`)return{kind:`CausedByExpressionSyntax`,property:null,location:a};if(t.startsWith(`$causedBy.`))return{kind:`CausedByExpressionSyntax`,property:t.substring(10),location:a};let c=n(t,a,o);return c===void 0?i.test(t)?{kind:`PathExpressionSyntax`,path:t.replaceAll(`@`,``),location:a}:(o.error(e.InvalidExpression,`Invalid expression '${t}'`,a),{kind:`RawExpressionSyntax`,text:t,location:a}):c}export{parseProjectionExpression};
2
+ //# sourceMappingURL=ProjectionExpressionParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectionExpressionParser.js","names":["pattern","parseMappingSource","exactPath","nativePattern","context","text","parts","DiagnosticCodes","location","inner","start","index","end","structured","parseModeledMappingSource","literal","parseLiteral"],"sources":["../../../../../../Compiler/Parsing/ProjectionExpressionParser.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ExpressionSyntax, TemplateInterpolationSyntax, TemplateTextSyntax } from '../Syntax/Expressions';\nimport { parseLiteral, parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\nimport { nativePattern as pattern } from '../Text/patterns';\n\nconst exactPath = pattern('^@?[A-Za-z_]\\\\w*(\\\\.@?[A-Za-z_$]\\\\w*)*$');\n\n// Mirrors C# ParseProjectionExpression, not a general expression or arithmetic parser. Diagnostics for\n// formerly omitted operands remain owned by C# on Legacy documents.\nexport function parseProjectionExpression(text: string, location: SourceLocation, context: ParserContext): ExpressionSyntax {\n context = context.valueContext;\n text = text.trim();\n if (text.startsWith('`')) {\n const parts: (TemplateTextSyntax | TemplateInterpolationSyntax)[] = [];\n if (!text.endsWith('`') || text.length < 2) {\n context.error(DiagnosticCodes.UnterminatedTemplateExpression, 'Unterminated template expression - expected a closing backtick', location);\n return { kind: 'TemplateExpressionSyntax', parts, location };\n }\n const inner = text.substring(1, text.length - 1);\n let start = 0;\n for (let index = 0; index < inner.length; index++) {\n if (inner[index] !== '$' || inner[index + 1] !== '{') continue;\n if (index > start) parts.push({ kind: 'TemplateTextSyntax', text: inner.substring(start, index), location });\n const end = inner.indexOf('}', index);\n if (end < 0) {\n context.error(DiagnosticCodes.UnterminatedInterpolation, 'Unterminated ${...} interpolation in template expression', location);\n return { kind: 'TemplateExpressionSyntax', parts, location };\n }\n parts.push({ kind: 'TemplateInterpolationSyntax', expression: parseProjectionExpression(inner.substring(index + 2, end), location, context), location });\n index = end;\n start = end + 1;\n }\n if (start < inner.length) parts.push({ kind: 'TemplateTextSyntax', text: inner.substring(start), location });\n return { kind: 'TemplateExpressionSyntax', parts, location };\n }\n const structured = text.startsWith('literal ') ? text.substring('literal '.length).trim() : text;\n if (context.sourceOptions.numericMode === 'exact' && (structured.startsWith('{') || structured.startsWith('['))) return parseMappingSource(structured, location, context);\n if (text.startsWith('literal ')) {\n const literal = parseLiteral(text.substring('literal '.length).trim(), location, context);\n if (literal !== undefined) return literal;\n context.error(DiagnosticCodes.ExpectedLiteralValue, `Expected a literal value after 'literal', got '${text.substring('literal '.length).trim()}'`, location);\n return { kind: 'RawExpressionSyntax', text, location };\n }\n if (text === '$refusal' || text.startsWith('$refusal.')) return { kind: 'RefusalExpressionSyntax', member: text === '$refusal' ? '' : text.substring('$refusal.'.length), location };\n if (text === '$eventSourceId') return { kind: 'EventSourceIdExpressionSyntax', location };\n if (text.startsWith('$eventContext.')) return { kind: 'EventContextExpressionSyntax', path: text.substring('$eventContext.'.length), location };\n if (text === '$causedBy') return { kind: 'CausedByExpressionSyntax', property: null, location };\n if (text.startsWith('$causedBy.')) return { kind: 'CausedByExpressionSyntax', property: text.substring('$causedBy.'.length), location };\n const literal = parseLiteral(text, location, context);\n if (literal !== undefined) return literal;\n if (exactPath.test(text)) return { kind: 'PathExpressionSyntax', path: text.replaceAll('@', ''), location };\n context.error(DiagnosticCodes.InvalidExpression, `Invalid expression '${text}'`, location);\n return { kind: 'RawExpressionSyntax', text, location };\n}\n"],"mappings":"iQAUA,MAAME,EAAYF,EAAQ,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nosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{firstWord as n,splitTopLevel as r,unescapeIdentifier as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";import{parseDescription as o}from"./DescriptionParser.js";import{isFileDirective as s}from"./FileReferences.js";import{parseProjectionExpression as c}from"./ProjectionExpressionParser.js";const l=t(`^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$`),u=t(`^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),d=t(`^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$`),f=t(`^with\\s+(@?[\\w.]+)$`),p=t(`^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$`),m=t(`^nested\\s+(@?[\\w.]+)$`),h=t(`^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),g=t(`^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),_=t(`^clear\\s+with\\s+(@?[\\w.]+)$`),v=t(`^variant\\s+(@?[\\w.]+)\\s*$`),y=t(`^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),b=t(`^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$`),x=t(`^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$`),S=t(`^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$`),C=t(`^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$`),w={increment:`IncrementMappingSyntax`,decrement:`DecrementMappingSyntax`,clear:`ClearMappingSyntax`,count:`CountMappingSyntax`};function parseProjection(t,r){let i=l.exec(r.content);if(i===null)return t.error(e.InvalidProjectionDeclaration,`Invalid projection declaration '${r.content}' - expected 'projection <Name> [=> <ReadModel>]'`,a(r)),t.skipBlock(r.indent),{kind:`ProjectionSyntax`,sourceOptions:t.sourceOptions,name:n(r.content),readModel:null,sequence:null,autoMap:`Inherit`,blocks:[],location:a(r)};let c=i[1],u=null,d=null,f=`Inherit`,p=null,m=[];for(let e=t.peekChild(r.indent);e!==void 0;e=t.peekChild(r.indent)){if(t.reader.takeSignificant(),s(e))continue;let r=n(e.content);if(r===`description`)d=o(t,e,d,`Projection '${c}'`);else if(r===`sequence`)u=e.content.substring(8).trim();else if(r===`automap`)f=`Enabled`;else if(e.content===`no automap`)f=`Disabled`;else if(r===`key`)p=parseKey(t,e);else if(r===`variant`)m.push(parseVariant(t,e));else{let n=parseBlock(t,e,!1);n!==void 0&&m.push(n)}}return reportVariantConflicts(t,m,c),m.length===0&&t.error(e.EmptyProjection,`Projection '${c}' must contain at least one directive`,a(r)),{kind:`ProjectionSyntax`,sourceOptions:t.sourceOptions,name:c,readModel:i[2]??null,sequence:u,autoMap:f,key:p,blocks:m,description:d,location:a(r)}}function reportVariantConflicts(t,n,r){let i=n.filter(e=>e.kind===`ProjectionVariantSyntax`),a=/* @__PURE__ */ new Map;i.forEach(e=>a.set(e.name,[...a.get(e.name)??[],e]));for(let n of[...a.values()].flatMap(e=>e.slice(1)))t.error(e.DuplicateProjectionVariant,`Duplicate variant '${n.name}' - a variant name is declared once`,n.location);let o=/* @__PURE__ */ new Set;for(let i of n.flatMap(e=>e.kind===`ProjectionVariantSyntax`?e.entersOn:[]))i.event.length>0&&o.has(i.event)&&t.error(e.DuplicateVariantEnteringEvent,`Entering event '${i.event}' is claimed more than once in projection '${r}'`,i.location),o.add(i.event)}function parseBlock(t,r,i){let o=a(r);switch(n(r.content)){case`from`:return parseFrom(t,r);case`every`:{let e=!0,{autoMap:n,mappings:i}=parseMappingBlock(t,r,t=>t.content===`exclude children`&&(e=!1,!0));return{kind:`EverySyntax`,includeChildren:e,autoMap:n,mappings:i,location:o}}case`all`:{let{autoMap:e,mappings:n}=parseMappingBlock(t,r);return{kind:`AllSyntax`,autoMap:e,mappings:n,location:o}}case`join`:return parseJoin(t,r);case`children`:return parseChildren(t,r);case`nested`:return parseNested(t,r);case`remove`:return parseRemove(t,r);case`clear`:return i||t.error(e.ClearWithOutsideNestedBlock,`'clear with' is only valid inside a nested block`,o),parseClearWith(t,r);default:t.error(e.UnknownProjectionDirective,`Unexpected '${n(r.content)}' in projection body`,o),t.skipBlock(r.indent);return}}function parseFrom(t,o){let s=[];for(let n of r(o.content.substring(4),`,`)){let r=n.trim();if(r.length===0){t.error(e.FromWithoutEvent,`Expected an event type after 'from'`,a(o));continue}let l=u.exec(r);l===null?t.error(e.InvalidEventReference,`Invalid event reference '${r}'`,a(o)):s.push({kind:`EventSpecSyntax`,event:i(l[1]),key:l[2]===void 0?null:c(l[2],a(o),t),location:a(o)})}let l=[],d=null,f=null;for(let e=t.peekChild(o.indent);e!==void 0;e=t.peekChild(o.indent)){t.reader.takeSignificant();let r=n(e.content);r===`key`?d=parseKey(t,e):r===`parent`?f=c(e.content.substring(6),a(e),t):pushMapping(t,e,l)}return{kind:`FromSyntax`,events:s,key:d,parentKey:f,mappings:l,location:a(o)}}function parseJoin(t,n){let r=d.exec(n.content);if(r===null)return t.error(e.InvalidJoinDeclaration,`Invalid join declaration '${n.content}' - expected 'join <property> on <key>'`,a(n)),t.skipBlock(n.indent),{kind:`JoinSyntax`,property:``,on:``,events:[],location:a(n)};let o=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=f.exec(r.content);if(n===null){t.error(e.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,a(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:c}=parseMappingBlock(t,r);o.push({kind:`JoinEventSyntax`,event:i(n[1]),autoMap:s,mappings:c,location:a(r)})}return{kind:`JoinSyntax`,property:i(r[1]),on:i(r[2]),events:o,location:a(n)}}function parseChildren(t,n){let r=p.exec(n.content);if(r===null)return t.error(e.InvalidChildrenDeclaration,`Invalid children declaration '${n.content}' - expected 'children <collection> identified by <key>'`,a(n)),t.skipBlock(n.indent),{kind:`ChildrenSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:a(n)};let{autoMap:o,blocks:s}=parseChildBlocks(t,n);return{kind:`ChildrenSyntax`,property:i(r[1]),identifiedBy:c(r[2],a(n),t),autoMap:o,blocks:s,location:a(n)}}function parseNested(t,n){let r=m.exec(n.content);if(r===null)return t.error(e.InvalidNestedDeclaration,`Invalid nested declaration '${n.content}' - expected 'nested <property>'`,a(n)),t.skipBlock(n.indent),{kind:`NestedSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:a(n)};let o=i(r[1]),{autoMap:s,blocks:c}=parseChildBlocks(t,n);return c.some(e=>e.kind===`FromSyntax`)||t.error(e.NestedBlockWithoutFrom,`Nested block '${o}' must contain at least one 'from' directive`,a(n)),{kind:`NestedSyntax`,property:o,autoMap:s,blocks:c,location:a(n)}}function parseChildBlocks(e,t){let n=[],r=`Inherit`;for(let i=e.peekChild(t.indent);i!==void 0;i=e.peekChild(t.indent)){if(e.reader.takeSignificant(),i.content===`automap`){r=`Enabled`;continue}if(i.content===`no automap`){r=`Disabled`;continue}let t=parseBlock(e,i,!0);t!==void 0&&n.push(t)}return{autoMap:r,blocks:n}}function parseRemove(t,r){let o=g.exec(r.content);if(o!==null)return{kind:`RemoveViaJoinSyntax`,event:i(o[1]),key:o[2]===void 0?null:c(o[2],a(r),t),location:a(r)};let s=h.exec(r.content);if(s===null){t.error(e.InvalidRemoveDeclaration,`Invalid remove declaration '${r.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,a(r)),t.skipBlock(r.indent);return}let l=null;for(let i=t.peekChild(r.indent);i!==void 0;i=t.peekChild(r.indent))t.reader.takeSignificant(),n(i.content)===`parent`?l=c(i.content.substring(6),a(i),t):t.error(e.UnknownRemoveDirective,`Unexpected '${i.content}' in remove block - only 'parent' is allowed`,a(i));return{kind:`RemoveWithSyntax`,event:i(s[1]),key:s[2]===void 0?null:c(s[2],a(r),t),parentKey:l,location:a(r)}}function parseClearWith(t,n){let r=_.exec(n.content);return r===null?(t.error(e.InvalidClearDeclaration,`Invalid clear declaration '${n.content}' - expected 'clear with <EventType>'`,a(n)),{kind:`ClearWithSyntax`,event:``,location:a(n)}):{kind:`ClearWithSyntax`,event:i(r[1]),location:a(n)}}function parseVariant(t,r){let o=v.exec(r.content);if(o===null)return t.error(e.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${r.content}' - expected 'variant <Name>'`,a(r)),t.skipBlock(r.indent),{kind:`ProjectionVariantSyntax`,name:n(r.content),entersOn:[],blocks:[],location:a(r)};let s=i(o[1]),c=[],l=[];for(let i=t.peekChild(r.indent);i!==void 0;i=t.peekChild(r.indent)){t.reader.takeSignificant();let r=n(i.content);if(r===`enters`)c.push(parseEntersOn(t,i));else if(r===`variant`)t.error(e.NestedProjectionVariantNotAllowed,`A variant cannot be declared inside another variant`,a(i)),t.skipBlock(i.indent);else{let e=parseBlock(t,i,!1);e!==void 0&&l.push(e)}}return c.length===0&&t.error(e.VariantRequiresEnteringEvent,`Variant '${s}' must declare at least one 'enters on' event`,a(r)),{kind:`ProjectionVariantSyntax`,name:s,entersOn:c,blocks:l,location:a(r)}}function parseEntersOn(t,n){let r=y.exec(n.content);return r===null?(t.error(e.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${n.content}' - expected 'enters on <EventType> [key <expression>]'`,a(n)),t.skipBlock(n.indent),{kind:`ProjectionEntersOnSyntax`,event:``,key:null,location:a(n)}):{kind:`ProjectionEntersOnSyntax`,event:i(r[1]),key:r[2]===void 0?null:c(r[2],a(n),t),location:a(n)}}function parseKey(t,n){let r=n.content.substring(3).trim();if(t.peekChild(n.indent)===void 0)return{kind:`ExpressionKeySyntax`,expression:c(r,a(n),t),location:a(n)};let o=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`}`)continue;let n=C.exec(r.content);if(n===null){t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidCompositeKeyPart,`Invalid composite key part '${r.content}' - expected '<property> = <expression>'`,a(r));continue}let s=c(n[2],a(r),t);t.sourceOptions.numericMode===`exact`&&s.kind===`TemplateExpressionSyntax`&&t.error(e.TemplateInCompositeKey,`Template expressions are not allowed in composite keys`,a(r)),o.push({kind:`KeyPartSyntax`,property:i(n[1]),expression:s,location:a(r)})}let s=t.reader.peekSignificant();return s!==void 0&&s.indent===n.indent&&s.content===`}`&&t.reader.takeSignificant(),t.sourceOptions.numericMode===`exact`&&o.length===0&&t.error(e.EmptyCompositeKey,`Composite keys must contain at least one part`,a(n)),{kind:`CompositeKeySyntax`,type:r.replace(/\{$/,``).trim(),parts:o,location:a(n)}}function parseMappingBlock(e,t,n=()=>!1){let r=`Inherit`,i=[];for(let a=e.peekChild(t.indent);a!==void 0;a=e.peekChild(t.indent))e.reader.takeSignificant(),a.content===`automap`?r=`Enabled`:a.content===`no automap`?r=`Disabled`:n(a)||pushMapping(e,a,i);return{autoMap:r,mappings:i}}function pushMapping(t,n,r){let o=a(n),s=b.exec(n.content);if(s!==null){s[1]!==`clear`||s[2]!==`with`?r.push({kind:w[s[1]],property:i(s[2]),location:o}):t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidProjectionMapping,`Invalid mapping '${n.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`,o);return}let l=x.exec(n.content);if(l!==null){r.push({kind:l[1]===`add`?`AddMappingSyntax`:`SubtractMappingSyntax`,property:i(l[2]),value:c(l[3],o,t),location:o});return}let u=S.exec(n.content)??C.exec(n.content);u===null?t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidProjectionMapping,`Invalid mapping '${n.content}'`,o):r.push({kind:`SetMappingSyntax`,property:i(u[1]),source:c(u[2],o,t),location:o})}export{parseProjection};
2
+ //# sourceMappingURL=ProjectionParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectionParser.js","names":["header","pattern","eventSpecPattern","joinPattern","withPattern","childrenPattern","nestedPattern","removeWithPattern","removeViaJoinPattern","clearWithPattern","variantPattern","entersOnPattern","keywordMappingPattern","arithmeticPattern","setPattern","assignmentPattern","keywordMappings","match","line","context","DiagnosticCodes","locationOf","firstWord","name","sequence","description","autoMap","key","blocks","child","isFileDirective","keyword","parseDescription","block","variants","byName","variant","duplicate","group","entering","entry","location","includeChildren","nestedScope","events","spec","splitTopLevel","text","unescapeIdentifier","parseProjectionExpression","mappings","parentKey","withMatch","property","viaJoin","entersOn","parts","expression","closing","extra","arithmetic","assigned"],"sources":["../../../../../../Compiler/Parsing/ProjectionParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport {\n AutoMapMode, ChildrenSyntax, ClearWithSyntax, EventSpecSyntax, FromSyntax, JoinEventSyntax, JoinSyntax, MappingKind, MappingSyntax, NestedSyntax,\n KeyPartSyntax, KeySyntax, ProjectionBlockSyntax, ProjectionEntersOnSyntax, ProjectionSyntax, ProjectionVariantSyntax,\n} from '../Syntax/Projections';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { pattern } from '../Text/patterns';\nimport { parseProjectionExpression } from './ProjectionExpressionParser';\nimport { isFileDirective } from './FileReferences';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord, splitTopLevel, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^projection\\\\s+(@?[\\\\w.]+)\\\\s*(?:=>\\\\s*([\\\\w.]+))?$');\nconst eventSpecPattern = pattern('^(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst joinPattern = pattern('^join\\\\s+(@?[\\\\w.]+)\\\\s+on\\\\s+(@?[\\\\w.]+)$');\nconst withPattern = pattern('^with\\\\s+(@?[\\\\w.]+)$');\nconst childrenPattern = pattern('^children\\\\s+(@?[\\\\w.]+)\\\\s+identified\\\\s+by\\\\s+(.+)$');\nconst nestedPattern = pattern('^nested\\\\s+(@?[\\\\w.]+)$');\nconst removeWithPattern = pattern('^remove\\\\s+with\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst removeViaJoinPattern = pattern('^remove\\\\s+via\\\\s+join\\\\s+on\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst clearWithPattern = pattern('^clear\\\\s+with\\\\s+(@?[\\\\w.]+)$');\nconst variantPattern = pattern('^variant\\\\s+(@?[\\\\w.]+)\\\\s*$');\nconst entersOnPattern = pattern('^enters\\\\s+on\\\\s+(@?[\\\\w.]+)(?:\\\\s+key\\\\s+(.+))?$');\nconst keywordMappingPattern = pattern('^(increment|decrement|count|clear)\\\\s+(@?[$\\\\w.]+)$');\nconst arithmeticPattern = pattern('^(add|subtract)\\\\s+(@?[$\\\\w.]+)\\\\s+by\\\\s+(.+)$');\nconst setPattern = pattern('^set\\\\s+(@?[$\\\\w.]+)\\\\s+(?:=|to)\\\\s+(.+)$');\nconst assignmentPattern = pattern('^(@?[$\\\\w.@]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst keywordMappings: Record<string, MappingKind> = {\n increment: 'IncrementMappingSyntax',\n decrement: 'DecrementMappingSyntax',\n clear: 'ClearMappingSyntax',\n count: 'CountMappingSyntax',\n};\n\n// Reads a projection's structure: its name, the read model it builds, the events each block consumes, the\n// properties each mapping sets and where automap is turned on or off. Keys, and where a mapping takes its\n// value from, are recognized and skipped.\nexport function parseProjection(context: ParserContext, line: SourceLine): ProjectionSyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidProjectionDeclaration, `Invalid projection declaration '${line.content}' - expected 'projection <Name> [=> <ReadModel>]'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionSyntax', sourceOptions: context.sourceOptions, name: firstWord(line.content), readModel: null, sequence: null, autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const name = match[1];\n let sequence: string | null = null;\n let description: string | null = null;\n let autoMap: AutoMapMode = 'Inherit';\n let key: KeySyntax | null = null;\n const blocks: ProjectionBlockSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (isFileDirective(child)) {\n continue;\n }\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Projection '${name}'`);\n } else if (keyword === 'sequence') {\n sequence = child.content.substring('sequence'.length).trim();\n } else if (keyword === 'automap') {\n autoMap = 'Enabled';\n } else if (child.content === 'no automap') {\n autoMap = 'Disabled';\n } else if (keyword === 'key') {\n key = parseKey(context, child);\n } else if (keyword === 'variant') {\n blocks.push(parseVariant(context, child));\n } else {\n const block = parseBlock(context, child, false);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n }\n reportVariantConflicts(context, blocks, name);\n if (blocks.length === 0) {\n context.error(DiagnosticCodes.EmptyProjection, `Projection '${name}' must contain at least one directive`, locationOf(line));\n }\n return { kind: 'ProjectionSyntax', sourceOptions: context.sourceOptions, name, readModel: match[2] ?? null, sequence, autoMap, key, blocks, description, location: locationOf(line) };\n}\n\nfunction reportVariantConflicts(context: ParserContext, blocks: readonly ProjectionBlockSyntax[], name: string): void {\n // Grouped by name in the order each name first appears, as the C# parser reports them.\n const variants = blocks.filter((block): block is ProjectionVariantSyntax => block.kind === 'ProjectionVariantSyntax');\n const byName = new Map<string, ProjectionVariantSyntax[]>();\n variants.forEach(variant => byName.set(variant.name, [...(byName.get(variant.name) ?? []), variant]));\n for (const duplicate of [...byName.values()].flatMap(group => group.slice(1))) {\n context.error(DiagnosticCodes.DuplicateProjectionVariant, `Duplicate variant '${duplicate.name}' - a variant name is declared once`, duplicate.location);\n }\n const entering = new Set<string>();\n for (const entry of blocks.flatMap(block => block.kind === 'ProjectionVariantSyntax' ? block.entersOn : [])) {\n if (entry.event.length > 0 && entering.has(entry.event)) {\n context.error(DiagnosticCodes.DuplicateVariantEnteringEvent, `Entering event '${entry.event}' is claimed more than once in projection '${name}'`, entry.location);\n }\n entering.add(entry.event);\n }\n}\n\nfunction parseBlock(context: ParserContext, line: SourceLine, nestedScope: boolean): ProjectionBlockSyntax | undefined {\n const location = locationOf(line);\n switch (firstWord(line.content)) {\n case 'from':\n return parseFrom(context, line);\n case 'every': {\n let includeChildren = true;\n const { autoMap, mappings } = parseMappingBlock(context, line, child => {\n if (child.content !== 'exclude children') {\n return false;\n }\n includeChildren = false;\n return true;\n });\n return { kind: 'EverySyntax', includeChildren, autoMap, mappings, location };\n }\n case 'all': {\n const { autoMap, mappings } = parseMappingBlock(context, line);\n return { kind: 'AllSyntax', autoMap, mappings, location };\n }\n case 'join':\n return parseJoin(context, line);\n case 'children':\n return parseChildren(context, line);\n case 'nested':\n return parseNested(context, line);\n case 'remove':\n return parseRemove(context, line);\n case 'clear':\n if (!nestedScope) {\n context.error(DiagnosticCodes.ClearWithOutsideNestedBlock, '\\'clear with\\' is only valid inside a nested block', location);\n }\n return parseClearWith(context, line);\n default:\n context.error(DiagnosticCodes.UnknownProjectionDirective, `Unexpected '${firstWord(line.content)}' in projection body`, location);\n context.skipBlock(line.indent);\n return undefined;\n }\n}\n\nfunction parseFrom(context: ParserContext, line: SourceLine): FromSyntax {\n const events: EventSpecSyntax[] = [];\n for (const spec of splitTopLevel(line.content.substring('from'.length), ',')) {\n const text = spec.trim();\n if (text.length === 0) {\n context.error(DiagnosticCodes.FromWithoutEvent, 'Expected an event type after \\'from\\'', locationOf(line));\n continue;\n }\n const match = eventSpecPattern.exec(text);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEventReference, `Invalid event reference '${text}'`, locationOf(line));\n continue;\n }\n events.push({ kind: 'EventSpecSyntax', event: unescapeIdentifier(match[1]), key: match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context), location: locationOf(line) });\n }\n const mappings: MappingSyntax[] = [];\n let key: KeySyntax | null = null;\n let parentKey: ExpressionSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'key') key = parseKey(context, child);\n else if (keyword === 'parent') parentKey = parseProjectionExpression(child.content.substring('parent'.length), locationOf(child), context);\n else pushMapping(context, child, mappings);\n }\n return { kind: 'FromSyntax', events, key, parentKey, mappings, location: locationOf(line) };\n}\n\nfunction parseJoin(context: ParserContext, line: SourceLine): JoinSyntax {\n const match = joinPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidJoinDeclaration, `Invalid join declaration '${line.content}' - expected 'join <property> on <key>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'JoinSyntax', property: '', on: '', events: [], location: locationOf(line) };\n }\n const events: JoinEventSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const withMatch = withPattern.exec(child.content);\n if (withMatch === null) {\n context.error(DiagnosticCodes.JoinWithoutEvent, `Expected 'with <EventType>' in join block, got '${child.content}'`, locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const { autoMap, mappings } = parseMappingBlock(context, child);\n events.push({ kind: 'JoinEventSyntax', event: unescapeIdentifier(withMatch[1]), autoMap, mappings, location: locationOf(child) });\n }\n return { kind: 'JoinSyntax', property: unescapeIdentifier(match[1]), on: unescapeIdentifier(match[2]), events, location: locationOf(line) };\n}\n\nfunction parseChildren(context: ParserContext, line: SourceLine): ChildrenSyntax {\n const match = childrenPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidChildrenDeclaration, `Invalid children declaration '${line.content}' - expected 'children <collection> identified by <key>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ChildrenSyntax', property: '', autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const { autoMap, blocks } = parseChildBlocks(context, line);\n return { kind: 'ChildrenSyntax', property: unescapeIdentifier(match[1]), identifiedBy: parseProjectionExpression(match[2], locationOf(line), context), autoMap, blocks, location: locationOf(line) };\n}\n\nfunction parseNested(context: ParserContext, line: SourceLine): NestedSyntax {\n const match = nestedPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidNestedDeclaration, `Invalid nested declaration '${line.content}' - expected 'nested <property>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'NestedSyntax', property: '', autoMap: 'Inherit', blocks: [], location: locationOf(line) };\n }\n const property = unescapeIdentifier(match[1]);\n const { autoMap, blocks } = parseChildBlocks(context, line);\n if (!blocks.some(block => block.kind === 'FromSyntax')) {\n context.error(DiagnosticCodes.NestedBlockWithoutFrom, `Nested block '${property}' must contain at least one 'from' directive`, locationOf(line));\n }\n return { kind: 'NestedSyntax', property, autoMap, blocks, location: locationOf(line) };\n}\n\nfunction parseChildBlocks(context: ParserContext, line: SourceLine): { autoMap: AutoMapMode; blocks: ProjectionBlockSyntax[] } {\n const blocks: ProjectionBlockSyntax[] = [];\n let autoMap: AutoMapMode = 'Inherit';\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'automap') {\n autoMap = 'Enabled';\n continue;\n }\n if (child.content === 'no automap') {\n autoMap = 'Disabled';\n continue;\n }\n const block = parseBlock(context, child, true);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n return { autoMap, blocks };\n}\n\nfunction parseRemove(context: ParserContext, line: SourceLine): ProjectionBlockSyntax | undefined {\n const viaJoin = removeViaJoinPattern.exec(line.content);\n if (viaJoin !== null) {\n return { kind: 'RemoveViaJoinSyntax', event: unescapeIdentifier(viaJoin[1]), key: viaJoin[2] === undefined ? null : parseProjectionExpression(viaJoin[2], locationOf(line), context), location: locationOf(line) };\n }\n const match = removeWithPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidRemoveDeclaration, `Invalid remove declaration '${line.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n let parentKey: ExpressionSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'parent') {\n parentKey = parseProjectionExpression(child.content.substring('parent'.length), locationOf(child), context);\n } else {\n context.error(DiagnosticCodes.UnknownRemoveDirective, `Unexpected '${child.content}' in remove block - only 'parent' is allowed`, locationOf(child));\n }\n }\n return { kind: 'RemoveWithSyntax', event: unescapeIdentifier(match[1]), key: match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context), parentKey, location: locationOf(line) };\n}\n\nfunction parseClearWith(context: ParserContext, line: SourceLine): ClearWithSyntax {\n const match = clearWithPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidClearDeclaration, `Invalid clear declaration '${line.content}' - expected 'clear with <EventType>'`, locationOf(line));\n return { kind: 'ClearWithSyntax', event: '', location: locationOf(line) };\n }\n return { kind: 'ClearWithSyntax', event: unescapeIdentifier(match[1]), location: locationOf(line) };\n}\n\nfunction parseVariant(context: ParserContext, line: SourceLine): ProjectionVariantSyntax {\n const match = variantPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidProjectionVariantDeclaration, `Invalid variant declaration '${line.content}' - expected 'variant <Name>'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionVariantSyntax', name: firstWord(line.content), entersOn: [], blocks: [], location: locationOf(line) };\n }\n const name = unescapeIdentifier(match[1]);\n const entersOn: ProjectionEntersOnSyntax[] = [];\n const blocks: ProjectionBlockSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'enters') {\n entersOn.push(parseEntersOn(context, child));\n } else if (keyword === 'variant') {\n context.error(DiagnosticCodes.NestedProjectionVariantNotAllowed, 'A variant cannot be declared inside another variant', locationOf(child));\n context.skipBlock(child.indent);\n } else {\n const block = parseBlock(context, child, false);\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n }\n if (entersOn.length === 0) {\n context.error(DiagnosticCodes.VariantRequiresEnteringEvent, `Variant '${name}' must declare at least one 'enters on' event`, locationOf(line));\n }\n return { kind: 'ProjectionVariantSyntax', name, entersOn, blocks, location: locationOf(line) };\n}\n\nfunction parseEntersOn(context: ParserContext, line: SourceLine): ProjectionEntersOnSyntax {\n const match = entersOnPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidEntersOnDeclaration, `Invalid 'enters on' declaration '${line.content}' - expected 'enters on <EventType> [key <expression>]'`, locationOf(line));\n context.skipBlock(line.indent);\n return { kind: 'ProjectionEntersOnSyntax', event: '', key: null, location: locationOf(line) };\n }\n return { kind: 'ProjectionEntersOnSyntax', event: unescapeIdentifier(match[1]), key: match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context), location: locationOf(line) };\n}\n\n// A key with a body is a composite key: its parts, then a closing '}' at the key's own indent.\nfunction parseKey(context: ParserContext, line: SourceLine): KeySyntax {\n const text = line.content.substring('key'.length).trim();\n if (context.peekChild(line.indent) === undefined) return { kind: 'ExpressionKeySyntax', expression: parseProjectionExpression(text, locationOf(line), context), location: locationOf(line) };\n const parts: KeyPartSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === '}') continue;\n const match = assignmentPattern.exec(child.content);\n if (match === null) {\n if (context.sourceOptions.numericMode === 'exact') context.error(DiagnosticCodes.InvalidCompositeKeyPart, `Invalid composite key part '${child.content}' - expected '<property> = <expression>'`, locationOf(child));\n continue;\n }\n const expression = parseProjectionExpression(match[2], locationOf(child), context);\n if (context.sourceOptions.numericMode === 'exact' && expression.kind === 'TemplateExpressionSyntax') context.error(DiagnosticCodes.TemplateInCompositeKey, 'Template expressions are not allowed in composite keys', locationOf(child));\n parts.push({ kind: 'KeyPartSyntax', property: unescapeIdentifier(match[1]), expression, location: locationOf(child) });\n }\n const closing = context.reader.peekSignificant();\n if (closing !== undefined && closing.indent === line.indent && closing.content === '}') context.reader.takeSignificant();\n if (context.sourceOptions.numericMode === 'exact' && parts.length === 0) context.error(DiagnosticCodes.EmptyCompositeKey, 'Composite keys must contain at least one part', locationOf(line));\n return { kind: 'CompositeKeySyntax', type: text.replace(/\\{$/, '').trim(), parts, location: locationOf(line) };\n}\n\n// Mapping lines carry no body, so a mapping block is its direct children. The last automap setting wins;\n// a line 'extra' claims is not a mapping.\nfunction parseMappingBlock(context: ParserContext, line: SourceLine, extra: (child: SourceLine) => boolean = () => false): { autoMap: AutoMapMode; mappings: MappingSyntax[] } {\n let autoMap: AutoMapMode = 'Inherit';\n const mappings: MappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'automap') {\n autoMap = 'Enabled';\n } else if (child.content === 'no automap') {\n autoMap = 'Disabled';\n } else if (!extra(child)) {\n pushMapping(context, child, mappings);\n }\n }\n return { autoMap, mappings };\n}\n\n// The property one mapping line sets, and how - the port of the C# ParseMappingLine. Exact reports\n// malformed mappings; Legacy keeps the existing skip behavior.\nfunction pushMapping(context: ParserContext, line: SourceLine, mappings: MappingSyntax[]): void {\n const location = locationOf(line);\n const keyword = keywordMappingPattern.exec(line.content);\n if (keyword !== null) {\n if (keyword[1] !== 'clear' || keyword[2] !== 'with') {\n mappings.push({ kind: keywordMappings[keyword[1]], property: unescapeIdentifier(keyword[2]), location });\n } else if (context.sourceOptions.numericMode === 'exact') {\n context.error(DiagnosticCodes.InvalidProjectionMapping, `Invalid mapping '${line.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`, location);\n }\n return;\n }\n const arithmetic = arithmeticPattern.exec(line.content);\n if (arithmetic !== null) {\n mappings.push({ kind: arithmetic[1] === 'add' ? 'AddMappingSyntax' : 'SubtractMappingSyntax', property: unescapeIdentifier(arithmetic[2]), value: parseProjectionExpression(arithmetic[3], location, context), location });\n return;\n }\n const assigned = setPattern.exec(line.content) ?? assignmentPattern.exec(line.content);\n if (assigned !== null) {\n mappings.push({ kind: 'SetMappingSyntax', property: unescapeIdentifier(assigned[1]), source: parseProjectionExpression(assigned[2], location, context), location });\n } else if (context.sourceOptions.numericMode === 'exact') {\n context.error(DiagnosticCodes.InvalidProjectionMapping, `Invalid mapping '${line.content}'`, location);\n }\n}\n"],"mappings":"qeAiBA,MAAMA,EAASC,EAAQ,qDAAqD,EACtEC,EAAmBD,EAAQ,mCAAmC,EAC9DE,EAAcF,EAAQ,4CAA4C,EAClEG,EAAcH,EAAQ,uBAAuB,EAC7CI,EAAkBJ,EAAQ,uDAAuD,EACjFK,EAAgBL,EAAQ,yBAAyB,EACjDM,EAAoBN,EAAQ,qDAAqD,EACjFO,EAAuBP,EAAQ,kEAAkE,EACjGQ,EAAmBR,EAAQ,gCAAgC,EAC3DS,EAAiBT,EAAQ,8BAA8B,EACvDU,EAAkBV,EAAQ,mDAAmD,EAC7EW,EAAwBX,EAAQ,qDAAqD,EACrFY,EAAoBZ,EAAQ,gDAAgD,EAC5Ea,EAAab,EAAQ,2CAA2C,EAChEc,EAAoBd,EAAQ,qCAAqC,EACjEe,EAA+C,CACjD,UAAW,yBACX,UAAW,yBACX,MAAO,qBACP,MAAO,oBACX,EAKA,SAAgB,gBAAgB,EAAwB,EAAoC,CACxF,IAAMC,EAAQjB,EAAO,KAAKkB,EAAK,OAAO,EACtC,GAAID,IAAU,KAGV,OAFAE,EAAQ,MAAMC,EAAgB,6BAA8B,mCAAmCF,EAAK,QAAQ,mDAAoDG,EAAWH,CAAI,CAAC,EAChLC,EAAQ,UAAUD,EAAK,MAAM,EACtB,CAAE,KAAM,mBAAoB,cAAeC,EAAQ,cAAe,KAAMG,EAAUJ,EAAK,OAAO,EAAG,UAAW,KAAM,SAAU,KAAM,QAAS,UAAW,OAAQ,CAAC,EAAG,SAAUG,EAAWH,CAAI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UtB,CAAO,EAAG,UAAS,CAAC,CAI1K"}
@@ -0,0 +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{AuthoringProductionResolver as n}from"../Syntax/AuthoringProductionResolver.js";import{uniqueByName as r}from"./ResponseValidator.js";function validateProjectionTargets(i,a){let o=new n(i),s=o.slices,c=new Set(i.imports.map(e=>e.qualifiedName)),l=/* @__PURE__ */ new Set([...s.flatMap(({slice:e})=>t(e).map(e=>e.name)),...i.imports.map(e=>e.qualifiedName.split(`.`).at(-1))]),u=r(i.types),d=new Set([`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`,...i.concepts.map(e=>e.name)].filter(e=>!u.has(e))),property=(e,t)=>{let[n,...r]=t.split(`.`);if(e===null)return{value:null,missing:!1};let i=e.filter(e=>e.name===n);if(i.length!==1)return{value:null,missing:i.length===0};let a=i[0];return r.length===0?{value:a,missing:!1}:d.has(a.type.name)?{value:null,missing:!0}:property(u.get(a.type.name)?.properties??null,r.join(`.`))},f=s.flatMap(({slice:e,scope:t})=>e.readModels.map(e=>({node:e,scope:t}))),viewProperties=(e,t)=>{let candidates=e=>{let n=e.split(`.`),r=f.filter(e=>e.node.name===n.at(-1)),i=n.slice(0,-1);if(i.length>0)return r.filter(e=>i.length<=e.scope.length&&i.every((t,n)=>e.scope[e.scope.length-i.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>0)return n}return[]},n=candidates(e),r=i.imports.filter(t=>t.qualifiedName.split(`.`).at(-1)===e);return n.length===0&&r.length===1&&(n=candidates(r[0].qualifiedName)),n.length===1?n[0].node.properties:null},unknownEvent=(t,n,r)=>{let i=o.resolve(t,r);l.has(t)||c.has(t)||i.declaration?.kind===`event`||i.candidates.some(e=>e.kind===`event`)||a.warning(e.UnknownEvent,`Unknown event '${t}' - declare it with 'event ${t}'`,n)},removals=(e,t)=>{for(let n of e)(n.kind===`RemoveWithSyntax`||n.kind===`RemoveViaJoinSyntax`)&&unknownEvent(n.event,n.location,t),`blocks`in n&&removals(n.blocks,t)},p=/* @__PURE__ */ new Set,walk=(t,n,r=!1,i=!1)=>{let validate=(t,i)=>{let o=property(n,t),s=JSON.stringify([i.path,i.line,i.column]);return o.missing&&!p.has(s)&&(p.add(s),a.warning(e.UnknownReadModelProperty,`Projection target '${t}' is not a declared ${r?`element`:`read-model`} property`,i)),o.value},o=i||t.some(e=>e.kind===`FromSyntax`||e.kind===`JoinSyntax`||e.kind===`AllSyntax`);for(let e of t){let t=e.kind===`EverySyntax`&&!o?[]:`mappings`in e?e.mappings:e.kind===`JoinSyntax`?e.events.flatMap(e=>e.mappings):[];for(let e of t)validate(e.property,e.location);if(e.kind===`ChildrenSyntax`||e.kind===`NestedSyntax`){let t=validate(e.property,e.location);walk(e.blocks,t===null?null:u.get(t.type.name)?.properties??null,!0)}}};for(let{slice:e}of s){for(let t of e.projections)removals(t.blocks,e);for(let t of e.captures)for(let n of[...t.appends,...t.children.flatMap(e=>e.appends),...t.nested.flatMap(e=>e.appends)])unknownEvent(n.event,n.location,e)}for(let{slice:e,scope:t}of s)for(let n of e.projections){let e=n.blocks.filter(e=>e.kind===`ProjectionVariantSyntax`);e.length===0&&walk(n.blocks,viewProperties(n.readModel??n.name,t));for(let r of e){let e=viewProperties(r.name,t);walk(n.blocks.filter(e=>e.kind===`ChildrenSyntax`||e.kind===`NestedSyntax`),e);let i=r.entersOn.length>0||n.blocks.some(e=>e.kind===`FromSyntax`||e.kind===`JoinSyntax`||e.kind===`AllSyntax`);walk(r.blocks,e,!1,i)}}}export{validateProjectionTargets};
2
+ //# sourceMappingURL=ProjectionTargetValidator.js.map