@cratis/screenplay-language 5.3.0 → 5.3.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 (395) hide show
  1. package/dist/bundles/TypeReferenceSymbol.js.map +1 -1
  2. package/dist/bundles/action-subject-authoring.js.map +1 -1
  3. package/dist/bundles/bmp-word-characters.js.map +1 -1
  4. package/dist/bundles/case-authoring.js +1 -1
  5. package/dist/bundles/case-authoring.js.map +1 -1
  6. package/dist/bundles/code-actions.js.map +1 -1
  7. package/dist/bundles/command-read-completions.js.map +1 -1
  8. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js +3 -3
  9. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js.map +1 -1
  10. package/dist/bundles/compiler/Authoring/QuickFixes.js +4 -4
  11. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
  12. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js +1 -1
  13. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js.map +1 -1
  14. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js +4 -4
  15. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js.map +1 -1
  16. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js +2 -2
  17. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js.map +1 -1
  18. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js +1 -1
  19. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js.map +1 -1
  20. package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js.map +1 -1
  21. package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js.map +1 -1
  22. package/dist/bundles/compiler/Dependencies/DependencyGraph.js +1 -1
  23. package/dist/bundles/compiler/Dependencies/DependencyGraph.js.map +1 -1
  24. package/dist/bundles/compiler/Dependencies/DependencyKind.js.map +1 -1
  25. package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js.map +1 -1
  26. package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
  27. package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js.map +1 -1
  28. package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js.map +1 -1
  29. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  30. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  31. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js +1 -1
  32. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js.map +1 -1
  33. package/dist/bundles/compiler/Diagnostics/SourceLocation.js.map +1 -1
  34. package/dist/bundles/compiler/Files/AuthoredOrder.js +1 -1
  35. package/dist/bundles/compiler/Files/AuthoredOrder.js.map +1 -1
  36. package/dist/bundles/compiler/Files/OrderingRoot.js +1 -1
  37. package/dist/bundles/compiler/Files/OrderingRoot.js.map +1 -1
  38. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js +1 -1
  39. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js.map +1 -1
  40. package/dist/bundles/compiler/Files/PlayDocumentSource.js.map +1 -1
  41. package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
  42. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
  43. package/dist/bundles/compiler/Files/PlayGlob.js +2 -1
  44. package/dist/bundles/compiler/Files/PlayGlob.js.map +1 -1
  45. package/dist/bundles/compiler/Files/PlayImports.js +1 -1
  46. package/dist/bundles/compiler/Files/PlayImports.js.map +1 -1
  47. package/dist/bundles/compiler/Files/PlayPlacement.js.map +1 -1
  48. package/dist/bundles/compiler/Files/TimelineOrder.js +1 -1
  49. package/dist/bundles/compiler/Files/TimelineOrder.js.map +1 -1
  50. package/dist/bundles/compiler/Generation/FiniteGenerationRules.js +1 -1
  51. package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js.map +1 -1
  52. package/dist/bundles/compiler/Generation/GenerationChecksum.js.map +1 -1
  53. package/dist/bundles/compiler/Generation/GenerationPattern.js +1 -1
  54. package/dist/bundles/compiler/Generation/GenerationPattern.js.map +1 -1
  55. package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js.map +1 -1
  56. package/dist/bundles/compiler/Generation/GenerationPatternParser.js.map +1 -1
  57. package/dist/bundles/compiler/Generation/GenerationPatternToken.js.map +1 -1
  58. package/dist/bundles/compiler/Generation/GenerationRuleProof.js +1 -1
  59. package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js.map +1 -1
  60. package/dist/bundles/compiler/Generation/RegexCharacters.js.map +1 -1
  61. package/dist/bundles/compiler/Generation/RegexExpression.js.map +1 -1
  62. package/dist/bundles/compiler/Generation/RuleConsistency.js +1 -1
  63. package/dist/bundles/compiler/Parsing/ActionSubjectClause.js.map +1 -1
  64. package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js.map +1 -1
  65. package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js.map +1 -1
  66. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js +1 -1
  67. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js.map +1 -1
  68. package/dist/bundles/compiler/Parsing/AuthorizeParser.js +1 -1
  69. package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -1
  70. package/dist/bundles/compiler/Parsing/CanvasPlacement.js.map +1 -1
  71. package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js.map +1 -1
  72. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  73. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
  74. package/dist/bundles/compiler/Parsing/ClockOperandParser.js.map +1 -1
  75. package/dist/bundles/compiler/Parsing/CodeBlockParser.js.map +1 -1
  76. package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js.map +1 -1
  77. package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js.map +1 -1
  78. package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
  79. package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
  80. package/dist/bundles/compiler/Parsing/CommandReadSources.js.map +1 -1
  81. package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
  82. package/dist/bundles/compiler/Parsing/CommandResponseParser.js.map +1 -1
  83. package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js.map +1 -1
  84. package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js.map +1 -1
  85. package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
  86. package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -1
  87. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
  88. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
  89. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js +2 -0
  90. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js.map +1 -0
  91. package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
  92. package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -1
  93. package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
  94. package/dist/bundles/compiler/Parsing/ConstraintParser.js.map +1 -1
  95. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js +1 -1
  96. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js.map +1 -1
  97. package/dist/bundles/compiler/Parsing/ContinuationValues.js.map +1 -1
  98. package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
  99. package/dist/bundles/compiler/Parsing/DeclarationParsers.js.map +1 -1
  100. package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
  101. package/dist/bundles/compiler/Parsing/DependencySourceParser.js.map +1 -1
  102. package/dist/bundles/compiler/Parsing/DependsOnParser.js.map +1 -1
  103. package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
  104. package/dist/bundles/compiler/Parsing/DescriptionParser.js.map +1 -1
  105. package/dist/bundles/compiler/Parsing/DocumentationParser.js +1 -1
  106. package/dist/bundles/compiler/Parsing/DocumentationParser.js.map +1 -1
  107. package/dist/bundles/compiler/Parsing/EnumerationMembers.js +1 -1
  108. package/dist/bundles/compiler/Parsing/EnumerationMembers.js.map +1 -1
  109. package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
  110. package/dist/bundles/compiler/Parsing/EventMetadataParser.js.map +1 -1
  111. package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
  112. package/dist/bundles/compiler/Parsing/EventSourceParser.js.map +1 -1
  113. package/dist/bundles/compiler/Parsing/EventSourceValidator.js +1 -1
  114. package/dist/bundles/compiler/Parsing/EventSourceValidator.js.map +1 -1
  115. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js +1 -1
  116. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js.map +1 -1
  117. package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
  118. package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -1
  119. package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
  120. package/dist/bundles/compiler/Parsing/FeatureBody.js.map +1 -1
  121. package/dist/bundles/compiler/Parsing/FileImportParser.js.map +1 -1
  122. package/dist/bundles/compiler/Parsing/FileReferences.js.map +1 -1
  123. package/dist/bundles/compiler/Parsing/FoldedEventSources.js.map +1 -1
  124. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js +1 -1
  125. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js.map +1 -1
  126. package/dist/bundles/compiler/Parsing/GenerationParser.js +1 -1
  127. package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -1
  128. package/dist/bundles/compiler/Parsing/GuardedActionInputs.js.map +1 -1
  129. package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
  130. package/dist/bundles/compiler/Parsing/GuardedActionParser.js.map +1 -1
  131. package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js.map +1 -1
  132. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +1 -1
  133. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -1
  134. package/dist/bundles/compiler/Parsing/GuardedInteractions.js +1 -1
  135. package/dist/bundles/compiler/Parsing/GuardedInteractions.js.map +1 -1
  136. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js +1 -1
  137. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js.map +1 -1
  138. package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
  139. package/dist/bundles/compiler/Parsing/IdentityParser.js.map +1 -1
  140. package/dist/bundles/compiler/Parsing/IdentityValidator.js.map +1 -1
  141. package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
  142. package/dist/bundles/compiler/Parsing/ImplementationParser.js.map +1 -1
  143. package/dist/bundles/compiler/Parsing/ImportDiscovery.js +1 -1
  144. package/dist/bundles/compiler/Parsing/ImportDiscovery.js.map +1 -1
  145. package/dist/bundles/compiler/Parsing/InlineEventValidator.js.map +1 -1
  146. package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
  147. package/dist/bundles/compiler/Parsing/InputUses.js.map +1 -1
  148. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
  149. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js.map +1 -1
  150. package/dist/bundles/compiler/Parsing/InteractionExecutions.js +1 -1
  151. package/dist/bundles/compiler/Parsing/InteractionExecutions.js.map +1 -1
  152. package/dist/bundles/compiler/Parsing/LegacyTextRulePatterns.js.map +1 -1
  153. package/dist/bundles/compiler/Parsing/LineReader.js.map +1 -1
  154. package/dist/bundles/compiler/Parsing/LineText.js.map +1 -1
  155. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js +1 -1
  156. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js.map +1 -1
  157. package/dist/bundles/compiler/Parsing/MatchAmbiguityCharacters.js.map +1 -1
  158. package/dist/bundles/compiler/Parsing/MatchAmbiguityGraph.js.map +1 -1
  159. package/dist/bundles/compiler/Parsing/MatchAmbiguityParser.js.map +1 -1
  160. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js +1 -1
  161. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js.map +1 -1
  162. package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
  163. package/dist/bundles/compiler/Parsing/ModuleBody.js.map +1 -1
  164. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js +1 -1
  165. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js.map +1 -1
  166. package/dist/bundles/compiler/Parsing/ObserverFilterValidator.js.map +1 -1
  167. package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
  168. package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -1
  169. package/dist/bundles/compiler/Parsing/OperationValidator.js +1 -1
  170. package/dist/bundles/compiler/Parsing/OperationValidator.js.map +1 -1
  171. package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -1
  172. package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js.map +1 -1
  173. package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
  174. package/dist/bundles/compiler/Parsing/PolicyParser.js.map +1 -1
  175. package/dist/bundles/compiler/Parsing/PortableMatchGroupName.js.map +1 -1
  176. package/dist/bundles/compiler/Parsing/PortableMatchPattern.js.map +1 -1
  177. package/dist/bundles/compiler/Parsing/PortableMatchSuggestions.js.map +1 -1
  178. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js +1 -1
  179. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js.map +1 -1
  180. package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
  181. package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
  182. package/dist/bundles/compiler/Parsing/ProjectionEventScopeValidator.js.map +1 -1
  183. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js +1 -1
  184. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js.map +1 -1
  185. package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
  186. package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
  187. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +1 -1
  188. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -1
  189. package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
  190. package/dist/bundles/compiler/Parsing/PropertyLineParser.js.map +1 -1
  191. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js +1 -1
  192. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js.map +1 -1
  193. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js +1 -1
  194. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js.map +1 -1
  195. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +1 -1
  196. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -1
  197. package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
  198. package/dist/bundles/compiler/Parsing/PurposeParser.js.map +1 -1
  199. package/dist/bundles/compiler/Parsing/PurposeValidator.js.map +1 -1
  200. package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
  201. package/dist/bundles/compiler/Parsing/QueryParser.js.map +1 -1
  202. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
  203. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js.map +1 -1
  204. package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
  205. package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
  206. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js +1 -1
  207. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js.map +1 -1
  208. package/dist/bundles/compiler/Parsing/ReadModelKeyValidator.js.map +1 -1
  209. package/dist/bundles/compiler/Parsing/ReadModelMemberTypeValidator.js.map +1 -1
  210. package/dist/bundles/compiler/Parsing/ReadsParser.js +1 -1
  211. package/dist/bundles/compiler/Parsing/ReadsParser.js.map +1 -1
  212. package/dist/bundles/compiler/Parsing/RedeliveryValues.js.map +1 -1
  213. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js +1 -1
  214. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js.map +1 -1
  215. package/dist/bundles/compiler/Parsing/RefusalValueWalker.js.map +1 -1
  216. package/dist/bundles/compiler/Parsing/ResponseCommandResolver.js.map +1 -1
  217. package/dist/bundles/compiler/Parsing/ResponseDateValues.js.map +1 -1
  218. package/dist/bundles/compiler/Parsing/ResponseValidator.js +1 -1
  219. package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -1
  220. package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
  221. package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
  222. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  223. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  224. package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
  225. package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -1
  226. package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
  227. package/dist/bundles/compiler/Parsing/SliceParser.js.map +1 -1
  228. package/dist/bundles/compiler/Parsing/SourceLine.js.map +1 -1
  229. package/dist/bundles/compiler/Parsing/SourceLineSplitter.js.map +1 -1
  230. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
  231. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js.map +1 -1
  232. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
  233. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
  234. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
  235. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
  236. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +1 -1
  237. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -1
  238. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
  239. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
  240. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  241. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
  242. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js +1 -1
  243. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js.map +1 -1
  244. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
  245. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
  246. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js +1 -1
  247. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js.map +1 -1
  248. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +1 -1
  249. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -1
  250. package/dist/bundles/compiler/Parsing/StateMachineParser.js +1 -1
  251. package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -1
  252. package/dist/bundles/compiler/Parsing/StructuralInteractionSites.js.map +1 -1
  253. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js +1 -1
  254. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js.map +1 -1
  255. package/dist/bundles/compiler/Parsing/StructuredValueParser.js.map +1 -1
  256. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js +1 -1
  257. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js.map +1 -1
  258. package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
  259. package/dist/bundles/compiler/Parsing/TriggerDataParser.js.map +1 -1
  260. package/dist/bundles/compiler/Parsing/UiBindingParser.js +1 -1
  261. package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -1
  262. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js +1 -1
  263. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js.map +1 -1
  264. package/dist/bundles/compiler/Parsing/WorkflowParser.js +1 -1
  265. package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -1
  266. package/dist/bundles/compiler/Parsing/checkPortableMatchPattern.js.map +1 -1
  267. package/dist/bundles/compiler/Parsing/hasExponentialMatchAmbiguity.js.map +1 -1
  268. package/dist/bundles/compiler/Parsing/trimMatchAmbiguityGraph.js.map +1 -1
  269. package/dist/bundles/compiler/ScreenActionSubjects.js.map +1 -1
  270. package/dist/bundles/compiler/ScreenplayCompiler.js +1 -1
  271. package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -1
  272. package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js.map +1 -1
  273. package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js.map +1 -1
  274. package/dist/bundles/compiler/Syntax/CaptureEventsSource.js.map +1 -1
  275. package/dist/bundles/compiler/Syntax/DependencySources.js.map +1 -1
  276. package/dist/bundles/compiler/Syntax/EventDeclarations.js.map +1 -1
  277. package/dist/bundles/compiler/Syntax/EventSourceCatalog.js.map +1 -1
  278. package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js.map +1 -1
  279. package/dist/bundles/compiler/Syntax/ExactMathFacts.js.map +1 -1
  280. package/dist/bundles/compiler/Syntax/ExactNumber.js.map +1 -1
  281. package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js.map +1 -1
  282. package/dist/bundles/compiler/Syntax/LegacyWireProjection.js.map +1 -1
  283. package/dist/bundles/compiler/Syntax/Operations.js.map +1 -1
  284. package/dist/bundles/compiler/Syntax/PersonaCallers.js.map +1 -1
  285. package/dist/bundles/compiler/Syntax/ProductionDestinations.js.map +1 -1
  286. package/dist/bundles/compiler/Syntax/PublicEventInvariants.js.map +1 -1
  287. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  288. package/dist/bundles/compiler/Syntax/SourceOptions.js.map +1 -1
  289. package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js.map +1 -1
  290. package/dist/bundles/compiler/Syntax/StreamIdFormatter.js.map +1 -1
  291. package/dist/bundles/compiler/Syntax/StrictSyntaxJson.js +1 -1
  292. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
  293. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  294. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
  295. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
  296. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  297. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  298. package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js.map +1 -1
  299. package/dist/bundles/compiler/Syntax/index.js +1 -1
  300. package/dist/bundles/compiler/Text/ImplementationHintText.js.map +1 -1
  301. package/dist/bundles/compiler/Text/ReservedWords.js.map +1 -1
  302. package/dist/bundles/compiler/Text/SourceStreamNames.js.map +1 -1
  303. package/dist/bundles/compiler/Text/StringLiteral.js.map +1 -1
  304. package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js.map +1 -1
  305. package/dist/bundles/compiler/Text/patterns.js.map +1 -1
  306. package/dist/bundles/compiler/index.js +1 -1
  307. package/dist/bundles/completion-items.js +4 -4
  308. package/dist/bundles/completion-items.js.map +1 -1
  309. package/dist/bundles/completion-planner.js +2 -2
  310. package/dist/bundles/completion-planner.js.map +1 -1
  311. package/dist/bundles/completions.js +1 -1
  312. package/dist/bundles/completions.js.map +1 -1
  313. package/dist/bundles/continuation-responses.js +1 -1
  314. package/dist/bundles/continuation-responses.js.map +1 -1
  315. package/dist/bundles/declarations.js.map +1 -1
  316. package/dist/bundles/dependency-completions.js.map +1 -1
  317. package/dist/bundles/dependency-target-analysis.js.map +1 -1
  318. package/dist/bundles/diagnostic-codes.js +1 -1
  319. package/dist/bundles/diagnostic-codes.js.map +1 -1
  320. package/dist/bundles/diagnostics.js +1 -1
  321. package/dist/bundles/diagnostics.js.map +1 -1
  322. package/dist/bundles/document-context.js.map +1 -1
  323. package/dist/bundles/documentation-item.js.map +1 -1
  324. package/dist/bundles/event-analysis-source.js.map +1 -1
  325. package/dist/bundles/event-context-catalog.js.map +1 -1
  326. package/dist/bundles/event-context.js.map +1 -1
  327. package/dist/bundles/event-source-authoring.js +11 -11
  328. package/dist/bundles/event-source-authoring.js.map +1 -1
  329. package/dist/bundles/example-analysis.js +2 -2
  330. package/dist/bundles/example-analysis.js.map +1 -1
  331. package/dist/bundles/example-authoring.js +2 -2
  332. package/dist/bundles/example-authoring.js.map +1 -1
  333. package/dist/bundles/example-declaration-items.js.map +1 -1
  334. package/dist/bundles/example-values.js.map +1 -1
  335. package/dist/bundles/file-imports.js.map +1 -1
  336. package/dist/bundles/file-references.js.map +1 -1
  337. package/dist/bundles/generation-completions.js.map +1 -1
  338. package/dist/bundles/hover-content.js +5 -5
  339. package/dist/bundles/hover-content.js.map +1 -1
  340. package/dist/bundles/hover.js.map +1 -1
  341. package/dist/bundles/index.js +1 -1
  342. package/dist/bundles/index.js.map +1 -1
  343. package/dist/bundles/inlay-hints.js.map +1 -1
  344. package/dist/bundles/inline-completions.js +1 -1
  345. package/dist/bundles/inline-completions.js.map +1 -1
  346. package/dist/bundles/inline-event-validation.js +1 -1
  347. package/dist/bundles/inline-event-validation.js.map +1 -1
  348. package/dist/bundles/keyword-docs.js.map +1 -1
  349. package/dist/bundles/language.js.map +1 -1
  350. package/dist/bundles/named-rule-context.js.map +1 -1
  351. package/dist/bundles/operation-authoring.js +6 -6
  352. package/dist/bundles/operation-authoring.js.map +1 -1
  353. package/dist/bundles/persona-analysis.js +1 -1
  354. package/dist/bundles/persona-analysis.js.map +1 -1
  355. package/dist/bundles/production-destinations.js +1 -1
  356. package/dist/bundles/production-destinations.js.map +1 -1
  357. package/dist/bundles/purpose-items.js.map +1 -1
  358. package/dist/bundles/reaction-authoring.js +3 -3
  359. package/dist/bundles/reaction-authoring.js.map +1 -1
  360. package/dist/bundles/read-model-key-completions.js +1 -1
  361. package/dist/bundles/read-model-key-completions.js.map +1 -1
  362. package/dist/bundles/refusal-context.js.map +1 -1
  363. package/dist/bundles/response-analysis.js.map +1 -1
  364. package/dist/bundles/response-completions.js +1 -1
  365. package/dist/bundles/response-completions.js.map +1 -1
  366. package/dist/bundles/response-tokens.js +2 -2
  367. package/dist/bundles/response-tokens.js.map +1 -1
  368. package/dist/bundles/scope-items.js +3 -3
  369. package/dist/bundles/scope-items.js.map +1 -1
  370. package/dist/bundles/structure-completions.js.map +1 -1
  371. package/dist/bundles/sub-language-registry.js.map +1 -1
  372. package/dist/bundles/sub-languages/capture/CompletionProvider.js.map +1 -1
  373. package/dist/bundles/sub-languages/capture/HoverProvider.js.map +1 -1
  374. package/dist/bundles/sub-languages/capture/Validator.js.map +1 -1
  375. package/dist/bundles/sub-languages/capture/index.js.map +1 -1
  376. package/dist/bundles/sub-languages/capture/language.js.map +1 -1
  377. package/dist/bundles/sub-languages/cdl.js.map +1 -1
  378. package/dist/bundles/sub-languages/pdl.js.map +1 -1
  379. package/dist/bundles/sub-languages/projection/CodeActionProvider.js.map +1 -1
  380. package/dist/bundles/sub-languages/projection/CompletionProvider.js +1 -1
  381. package/dist/bundles/sub-languages/projection/CompletionProvider.js.map +1 -1
  382. package/dist/bundles/sub-languages/projection/HoverProvider.js.map +1 -1
  383. package/dist/bundles/sub-languages/projection/Validator.js.map +1 -1
  384. package/dist/bundles/sub-languages/projection/index.js.map +1 -1
  385. package/dist/bundles/sub-languages/projection/language.js.map +1 -1
  386. package/dist/bundles/symbols.js +2 -2
  387. package/dist/bundles/symbols.js.map +1 -1
  388. package/dist/bundles/themes/screenplay-dark.js.map +1 -1
  389. package/dist/bundles/themes/screenplay-light.js.map +1 -1
  390. package/dist/bundles/tokens.js.map +1 -1
  391. package/dist/bundles/validation.js +2 -2
  392. package/dist/bundles/validation.js.map +1 -1
  393. package/dist/diagnostic-codes.d.ts +1 -0
  394. package/dist/diagnostic-codes.d.ts.map +1 -1
  395. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"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","stream","line","keyword","firstWord","location","route","sourceStreamPattern","typeLocation","candidate","parseCommandStream","tag","parseTag","forMatch","parseMappingSource","match","structured","tryParseStructuredMapping","marker","trailingMarker","declaration","property","parseProperty","propertyName","parseStructuredValue","unescapeIdentifier","diagnosticText"],"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 { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { CommandStreamSyntax } from '../Syntax/CommandStreamSyntax';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { parseCommandStream } from './EventSourceParser';\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';\nimport { parseStructuredValue, trailingMarker, tryParseStructuredMapping } from './StructuredBlockParser';\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 let stream: CommandStreamSyntax | 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 === 'stream' && !line.content.includes('=')) {\n const route = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*)$').exec(line.content);\n if (!inCommand) {\n context.error(DiagnosticCodes.ProductionRouteOutsideCommand, 'Only command event productions can declare a stream route.', location);\n context.skipBlock(line.indent);\n } else if (stream !== null) {\n context.error(DiagnosticCodes.InvalidCommandStream, 'A production can declare at most one stream route.', location);\n context.skipBlock(line.indent);\n } else if (route === null) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Expected 'stream <Source>.<Stream>'.\", location);\n context.skipBlock(line.indent);\n } else {\n const typeLocation = { ...location, column: line.indent + line.content.indexOf(route[1]) + 1 };\n const candidate: PropertySyntax = { kind: 'PropertySyntax', name: 'stream', type: { kind: 'TypeRefSyntax', name: route[1], isCollection: false, isOptional: false, location: typeLocation }, isIdentifier: false, location };\n stream = parseCommandStream(context, line, candidate, false);\n }\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 if (match === null && inline === null) {\n const structured = tryParseStructuredMapping(context, line);\n if (structured !== undefined) {\n mappings.push(structured);\n continue;\n }\n }\n const marker = trailingMarker(line.content);\n const structured = match === null && inline !== null && !line.content.includes('=') && !['id', 'description', 'documentation'].includes(keyword) && line.content.includes(' ') && (marker !== undefined || context.peekChild(line.indent) !== undefined);\n const declaration = structured ? (marker === undefined ? line.content : line.content.substring(0, line.content.length - marker.length - 1)) : match?.[1].trimEnd();\n let property = declaration === undefined || inline === null ? undefined : parseProperty(context, { ...line, content: declaration });\n if ((match !== null || structured) && (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(match === null\n ? { kind: 'PropertyMappingSyntax', property: property!.name, source: parseStructuredValue(context, line, marker), location }\n : { 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, diagnosticText('text', line.content));\n }\n }\n if (parent !== header) context.skipBlock(header.indent);\n return {\n kind: 'ProducesSyntax', when, event: name, stream, 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, generation: 1, hasGenerationMarker: false, ...metadata.value, location: locationOf(header) },\n };\n}\n"],"mappings":"i6BAwBA,MAAMA,EAAwBC,EAAQ,iCAAiC,EACjEC,EAAeD,EAAQ,wEAAwE,EAC/FE,EAAcF,EAAQ,gDAAgD,EACtEG,EAAcH,EAAQ,4BAA4B,EAClDI,EAAYJ,EAAQ,kCAAkC,EACtDK,EAAgBL,EAAQ,kBAAkB,EAC1CM,EAAiBN,EAAQ,mCAAmC,EAC5DO,EAAsBP,EAAQ,6BAA6B,EAC3DQ,kBAAW,IAAI,IAAI,CAAC,YAAa,WAAY,cAAe,YAAa,WAAY,UAAU,CAAC,EAEtG,SAAgB,cAAc,EAAwB,EAAoB,EAAY,GAAmC,CACrH,GAAIT,EAAsB,KAAKU,EAAO,OAAO,EAAG,CAC5C,GAAI,CAACC,EAAW,CACZC,EAAQ,MAAMC,EAAgB,wBAAyB,+CAAgDC,EAAWJ,CAAM,CAAC,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AAyB,SAAUG,GAAU,MAAQI,EAAmBV,EAAM,EAAE,EAAG,OAAQD,EAAmBC,EAAM,GAAI,CAAE,GAAGV,EAAU,OAAQH,EAAK,OAASA,EAAK,QAAQ,OAASa,EAAM,EAAE,CAAC,OAAS,CAAE,EAAGlC,CAAO,EAAG,UAAS,CAAC,CAChP,MAAWK,IAAW,MAAQ,CAACY,EAAS,SAASjB,EAASqB,CAAI,IAC1DrB,EAAQ,MAAMC,EAAgB,uBAAwB,WAAWI,IAAW,KAAO,GAAK,UAAU,oBAAoBgB,EAAK,QAAQ,0BAA0BhB,IAAW,KAAO,GAAK,UAAU,cAAemB,EAAUqB,EAAe,OAAQxB,EAAK,OAAO,CAAC,CAEnQ,CAEA,OADIf,IAAWR,GAAQE,EAAQ,UAAUF,EAAO,MAAM,EAC/C,CACH,KAAM,iBAAkB,OAAM,MAAOU,EAAM,SAAQ,eAAgB,CAAE,GAAGN,EAAWI,CAAM,EAAG,OAAQG,CAAa,EAAG,gBAAiB,KAAM,WAAU,IAAKU,EAAQ,KAAMd,IAAW,KAAOW,EAAO,CAAC,EAAG,SAAUd,EAAWJ,CAAM,EAChO,YAAaO,IAAW,KAAO,KAAO,CAAE,KAAM,cAAe,OAAM,aAAY,OAAM,WAAY,EAAG,oBAAqB,GAAO,GAAGY,EAAS,MAAO,SAAUf,EAAWJ,CAAM,CAAE,CACpL,CACJ"}
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","stream","line","keyword","firstWord","location","route","sourceStreamPattern","typeLocation","candidate","parseCommandStream","tag","parseTag","forMatch","parseMappingSource","match","structured","tryParseStructuredMapping","marker","trailingMarker","declaration","property","parseProperty","propertyName","parseStructuredValue","unescapeIdentifier","diagnosticText"],"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 { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { CommandStreamSyntax } from '../Syntax/CommandStreamSyntax';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { parseCommandStream } from './EventSourceParser';\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';\nimport { parseStructuredValue, trailingMarker, tryParseStructuredMapping } from './StructuredBlockParser';\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 let stream: CommandStreamSyntax | 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 === 'stream' && !line.content.includes('=')) {\n const route = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*\\\\.[A-Za-z_]\\\\w*)$').exec(line.content);\n if (!inCommand) {\n context.error(DiagnosticCodes.ProductionRouteOutsideCommand, 'Only command event productions can declare a stream route.', location);\n context.skipBlock(line.indent);\n } else if (stream !== null) {\n context.error(DiagnosticCodes.InvalidCommandStream, 'A production can declare at most one stream route.', location);\n context.skipBlock(line.indent);\n } else if (route === null) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Expected 'stream <Source>.<Stream>'.\", location);\n context.skipBlock(line.indent);\n } else {\n const typeLocation = { ...location, column: line.indent + line.content.indexOf(route[1]) + 1 };\n const candidate: PropertySyntax = { kind: 'PropertySyntax', name: 'stream', type: { kind: 'TypeRefSyntax', name: route[1], isCollection: false, isOptional: false, location: typeLocation }, isIdentifier: false, location };\n stream = parseCommandStream(context, line, candidate, false);\n }\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 if (match === null && inline === null) {\n const structured = tryParseStructuredMapping(context, line);\n if (structured !== undefined) {\n mappings.push(structured);\n continue;\n }\n }\n const marker = trailingMarker(line.content);\n const structured = match === null && inline !== null && !line.content.includes('=') && !['id', 'description', 'documentation'].includes(keyword) && line.content.includes(' ') && (marker !== undefined || context.peekChild(line.indent) !== undefined);\n const declaration = structured ? (marker === undefined ? line.content : line.content.substring(0, line.content.length - marker.length - 1)) : match?.[1].trimEnd();\n let property = declaration === undefined || inline === null ? undefined : parseProperty(context, { ...line, content: declaration });\n if ((match !== null || structured) && (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(match === null\n ? { kind: 'PropertyMappingSyntax', property: property!.name, source: parseStructuredValue(context, line, marker), location }\n : { 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, diagnosticText('text', line.content));\n }\n }\n if (parent !== header) context.skipBlock(header.indent);\n return {\n kind: 'ProducesSyntax', when, event: name, stream, 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, generation: 1, hasGenerationMarker: false, ...metadata.value, location: locationOf(header) },\n };\n}\n"],"mappings":"A,i6BAwBA,MAAMA,EAAwBC,EAAQ,iCAAiC,EACjEC,EAAeD,EAAQ,wEAAwE,EAC/FE,EAAcF,EAAQ,gDAAgD,EACtEG,EAAcH,EAAQ,4BAA4B,EAClDI,EAAYJ,EAAQ,kCAAkC,EACtDK,EAAgBL,EAAQ,kBAAkB,EAC1CM,EAAiBN,EAAQ,mCAAmC,EAC5DO,EAAsBP,EAAQ,6BAA6B,EAC3DQ,kBAAW,IAAI,IAAI,CAAC,YAAa,WAAY,cAAe,YAAa,WAAY,UAAU,CAAC,EAEtG,SAAgB,cAAc,EAAwB,EAAoB,EAAY,GAAmC,CACrH,GAAIT,EAAsB,KAAKU,EAAO,OAAO,EAAG,CAC5C,GAAI,CAACC,EAAW,CACZC,EAAQ,MAAMC,EAAgB,wBAAyB,+CAAgDC,EAAWJ,CAAM,CAAC,EACzHE,EAAQ,gBAAgBF,EAAO,MAAM,EACrC,MACJ,CACA,IAAMK,EAASC,EAAeJ,EAASF,EAAQ,EAAI,EACnD,MAAO,CAAE,KAAM,iBAAkB,KAAM,KAAM,MAAOK,EAAO,UAAU,KAAM,eAAgB,CAAE,GAAGD,EAAWJ,CAAM,EAAG,OAAQA,EAAO,OAASA,EAAO,QAAQ,MAAM,gCAAgC,CAAC,CAAE,EAAE,CAAC,OAAS,CAAE,EAAG,YAAa,KAAM,gBAAiBK,EAAO,UAAW,SA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BgB,EAAK,QAAQ,0BAA0BhB,IAAW,KAAO,GAAK,UAAU,cAAemB,EAAUqB,EAAe,OAAQxB,EAAK,OAAO,CAAC,CAEnQ,CAEA,OADIf,IAAWR,GAAQE,EAAQ,UAAUF,EAAO,MAAM,EAC/C,CACH,KAAM,iBAAkB,OAAM,MAAOU,EAAM,SAAQ,eAAgB,CAAE,GAAGN,EAAWI,CAAM,EAAG,OAAQG,CAAa,EAAG,gBAAiB,KAAM,WAAU,IAAKU,EAAQ,KAAMd,IAAW,KAAOW,EAAO,CAAC,EAAG,SAAUd,EAAWJ,CAAM,EAChO,YAAaO,IAAW,KAAO,KAAO,CAAE,KAAM,cAAe,OAAM,aAAY,OAAM,WAAY,EAAG,oBAAqB,GAAO,GAAGY,EAAS,MAAO,SAAUf,EAAWJ,CAAM,CAAE,CACpL,CACJ,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectionEventScopeValidator.js","names":["levelEvents","joinEvents","seen","name","context","DiagnosticCodes","projection","scope","location","block","blocks","reference"],"sources":["../../../../../../Compiler/Parsing/ProjectionEventScopeValidator.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 { ProjectionBlockSyntax } from '../Syntax/Projections';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ParserContext } from './ParserContext';\n\n// Chronicle tracks authored names ordinally, with separate event and join sets at each level.\nexport function validateProjectionEventScopes(context: ParserContext, projection: string, blocks: readonly ProjectionBlockSyntax[], scope = 'the root level'): void {\n const levelEvents = new Set<string>();\n const joinEvents = new Set<string>();\n const check = (name: string, location: SourceLocation, seen: Set<string>): void => {\n if (seen.has(name)) {\n context.error(DiagnosticCodes.DuplicateEventInProjectionScope, `Event '${name}' is used more than once in projection '${projection}' at ${scope} (Chronicle allows one use of an event type per projection level)`, location);\n }\n seen.add(name);\n };\n for (const block of blocks) {\n switch (block.kind) {\n case 'FromSyntax':\n block.events.forEach(reference => check(reference.event, reference.location, levelEvents));\n break;\n case 'JoinSyntax':\n block.events.forEach(reference => check(reference.event, reference.location, joinEvents));\n break;\n case 'RemoveWithSyntax':\n case 'RemoveViaJoinSyntax':\n case 'ClearWithSyntax':\n check(block.event, block.location, levelEvents);\n break;\n case 'ChildrenSyntax':\n validateProjectionEventScopes(context, projection, block.blocks, `children '${block.property}'`);\n break;\n case 'NestedSyntax':\n validateProjectionEventScopes(context, projection, block.blocks, `nested '${block.property}'`);\n break;\n case 'ProjectionVariantSyntax':\n validateProjectionEventScopes(context, projection, block.blocks, `variant '${block.name}'`);\n break;\n }\n }\n}\n"],"mappings":"yHASA,SAAgB,8BAA8B,EAAwB,EAAoB,EAA0C,EAAQ,iBAAwB,CAChK,IAAMA,kBAAc,IAAI,IAClBC,kBAAa,IAAI,IACjB,OAAS,EAAc,EAA0B,IAA4B,CAC3EC,EAAK,IAAIC,CAAI,GACbC,EAAQ,MAAMC,EAAgB,gCAAiC,UAAUF,EAAK,0CAA0CG,EAAW,OAAOC,EAAM,mEAAoEC,CAAQ,EAEhON,EAAK,IAAIC,CAAI,CACjB,EACA,IAAK,IAAMM,KAASC,EAChB,OAAQD,EAAM,KAAd,CACI,IAAK,aACDA,EAAM,OAAO,QAAQ,GAAa,MAAME,EAAU,MAAOA,EAAU,SAAUX,CAAW,CAAC,EACzF,MACJ,IAAK,aACDS,EAAM,OAAO,QAAQ,GAAa,MAAME,EAAU,MAAOA,EAAU,SAAUV,CAAU,CAAC,EACxF,MACJ,IAAK,mBACL,IAAK,sBACL,IAAK,kBACD,MAAMQ,EAAM,MAAOA,EAAM,SAAUT,CAAW,EAC9C,MACJ,IAAK,iBACD,8BAA8BI,EAASE,EAAYG,EAAM,OAAQ,aAAaA,EAAM,SAAS,EAAE,EAC/F,MACJ,IAAK,eACD,8BAA8BL,EAASE,EAAYG,EAAM,OAAQ,WAAWA,EAAM,SAAS,EAAE,EAC7F,MACJ,IAAK,0BACD,8BAA8BL,EAASE,EAAYG,EAAM,OAAQ,YAAYA,EAAM,KAAK,EAAE,CAElG,CAER"}
1
+ {"version":3,"file":"ProjectionEventScopeValidator.js","names":["levelEvents","joinEvents","seen","name","context","DiagnosticCodes","projection","scope","location","block","blocks","reference"],"sources":["../../../../../../Compiler/Parsing/ProjectionEventScopeValidator.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 { ProjectionBlockSyntax } from '../Syntax/Projections';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ParserContext } from './ParserContext';\n\n// Chronicle tracks authored names ordinally, with separate event and join sets at each level.\nexport function validateProjectionEventScopes(context: ParserContext, projection: string, blocks: readonly ProjectionBlockSyntax[], scope = 'the root level'): void {\n const levelEvents = new Set<string>();\n const joinEvents = new Set<string>();\n const check = (name: string, location: SourceLocation, seen: Set<string>): void => {\n if (seen.has(name)) {\n context.error(DiagnosticCodes.DuplicateEventInProjectionScope, `Event '${name}' is used more than once in projection '${projection}' at ${scope} (Chronicle allows one use of an event type per projection level)`, location);\n }\n seen.add(name);\n };\n for (const block of blocks) {\n switch (block.kind) {\n case 'FromSyntax':\n block.events.forEach(reference => check(reference.event, reference.location, levelEvents));\n break;\n case 'JoinSyntax':\n block.events.forEach(reference => check(reference.event, reference.location, joinEvents));\n break;\n case 'RemoveWithSyntax':\n case 'RemoveViaJoinSyntax':\n case 'ClearWithSyntax':\n check(block.event, block.location, levelEvents);\n break;\n case 'ChildrenSyntax':\n validateProjectionEventScopes(context, projection, block.blocks, `children '${block.property}'`);\n break;\n case 'NestedSyntax':\n validateProjectionEventScopes(context, projection, block.blocks, `nested '${block.property}'`);\n break;\n case 'ProjectionVariantSyntax':\n validateProjectionEventScopes(context, projection, block.blocks, `variant '${block.name}'`);\n break;\n }\n }\n}\n"],"mappings":"A,yHASA,SAAgB,8BAA8B,EAAwB,EAAoB,EAA0C,EAAQ,iBAAwB,CAChK,IAAMA,kBAAc,IAAI,IAClBC,kBAAa,IAAI,IACjB,OAAS,EAAc,EAA0B,IAA4B,CAC3EC,EAAK,IAAIC,CAAI,GACbC,EAAQ,MAAMC,EAAgB,gCAAiC,UAAUF,EAAK,0CAA0CG,EAAW,OAAOC,EAAM,mEAAoEC,CAAQ,EAEhON,EAAK,IAAIC,CAAI,CACjB,EACA,IAAK,IAAMM,KAASC,EAChB,OAAQD,EAAM,KAAd,CACI,IAAK,aACDA,EAAM,OAAO,QAAQ,GAAa,MAAME,EAAU,MAAOA,EAAU,SAAUX,CAAW,CAAC,EACzF,MACJ,IAAK,aACDS,EAAM,OAAO,QAAQ,GAAa,MAAME,EAAU,MAAOA,EAAU,SAAUV,CAAU,CAAC,EACxF,MACJ,IAAK,mBACL,IAAK,sBACL,IAAK,kBACD,MAAMQ,EAAM,MAAOA,EAAM,SAAUT,CAAW,EAC9C,MACJ,IAAK,iBACD,8BAA8BI,EAASE,EAAYG,EAAM,OAAQ,aAAaA,EAAM,SAAS,EAAE,EAC/F,MACJ,IAAK,eACD,8BAA8BL,EAASE,EAAYG,EAAM,OAAQ,WAAWA,EAAM,SAAS,EAAE,EAC7F,MACJ,IAAK,0BACD,8BAA8BL,EAASE,EAAYG,EAAM,OAAQ,YAAYA,EAAM,KAAK,EAAE,CAElG,CAER,C"}
@@ -1,2 +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{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};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{parseLiteral as t,parseModeledMappingSource as n}from"./ExpressionParser.js";import{nativePattern as r}from"../Text/patterns.js";const i=r(`^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$`);function parseProjectionExpression(r,a,o){if(o=o.valueContext,r=r.trim(),r.startsWith("`")){let t=[];if(!r.endsWith("`")||r.length<2)return o.error(e.UnterminatedTemplateExpression,`Unterminated template expression - expected a closing backtick`,a),{kind:`TemplateExpressionSyntax`,parts:t,location:a};let n=r.substring(1,r.length-1),i=0;for(let r=0;r<n.length;r++){if(n[r]!==`$`||n[r+1]!==`{`)continue;r>i&&t.push({kind:`TemplateTextSyntax`,text:n.substring(i,r),location:a});let s=n.indexOf(`}`,r);if(s<0)return o.error(e.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",a),{kind:`TemplateExpressionSyntax`,parts:t,location:a};t.push({kind:`TemplateInterpolationSyntax`,expression:parseProjectionExpression(n.substring(r+2,s),a,o),location:a}),r=s,i=s+1}return i<n.length&&t.push({kind:`TemplateTextSyntax`,text:n.substring(i),location:a}),{kind:`TemplateExpressionSyntax`,parts:t,location:a}}let s=r.startsWith(`literal `)?r.substring(8).trim():r;if(o.sourceOptions.numericMode===`exact`&&(s.startsWith(`{`)||s.startsWith(`[`)))return n(s,a,o);if(r.startsWith(`literal `)){let n=t(r.substring(8).trim(),a,o);return n===void 0?(o.error(e.ExpectedLiteralValue,`Expected a literal value after 'literal', got '${r.substring(8).trim()}'`,a),{kind:`RawExpressionSyntax`,text:r,location:a}):n}if(r===`$refusal`||r.startsWith(`$refusal.`))return{kind:`RefusalExpressionSyntax`,member:r===`$refusal`?``:r.substring(9),location:a};if(r===`$eventSourceId`)return{kind:`EventSourceIdExpressionSyntax`,location:a};if(r.startsWith(`$eventContext.`))return{kind:`EventContextExpressionSyntax`,path:r.substring(14),location:a};if(r===`$causedBy`)return{kind:`CausedByExpressionSyntax`,property:null,location:a};if(r.startsWith(`$causedBy.`))return{kind:`CausedByExpressionSyntax`,property:r.substring(10),location:a};let c=t(r,a,o);return c===void 0?i.test(r)?{kind:`PathExpressionSyntax`,path:r.replaceAll(`@`,``),location:a}:(o.error(e.InvalidExpression,`Invalid expression '${r}'`,a),{kind:`RawExpressionSyntax`,text:r,location:a}):c}export{parseProjectionExpression};
2
2
  //# sourceMappingURL=ProjectionExpressionParser.js.map
@@ -1 +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,yC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","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":"A,iQAUA,MAAME,EAAYF,EAAQ,yCAAyC,EAInE,SAAgB,0BAA0B,EAAc,EAA0B,EAA0C,CAGxH,GAFA,EAAUI,EAAQ,aAClB,EAAOC,EAAK,KAAK,EACbA,EAAK,WAAW,GAAG,EAAG,CACtB,IAAMC,EAA8D,CAAC,EACrE,GAAI,CAACD,EAAK,SAAS,GAAG,GAAKA,EAAK,OAAS,EAErC,OADAD,EAAQ,MAAMG,EAAgB,+BAAgC,iEAAkEC,CAAQ,EACjI,CAAE,KAAM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AAK,UAAU,CAAiB,CAAC,CAAC,KAAK,EAAE,GAAIG,CAAQ,EACpJ,CAAE,KAAM,sBAAuB,OAAM,UAAS,GAFnBO,CAGtC,CACA,GAAIV,IAAS,YAAcA,EAAK,WAAW,WAAW,EAAG,MAAO,CAAE,KAAM,0BAA2B,OAAQA,IAAS,WAAa,GAAKA,EAAK,UAAU,CAAkB,EAAG,UAAS,EACnL,GAAIA,IAAS,iBAAkB,MAAO,CAAE,KAAM,gCAAiC,UAAS,EACxF,GAAIA,EAAK,WAAW,gBAAgB,EAAG,MAAO,CAAE,KAAM,+BAAgC,KAAMA,EAAK,UAAU,EAAuB,EAAG,UAAS,EAC9I,GAAIA,IAAS,YAAa,MAAO,CAAE,KAAM,2BAA4B,SAAU,KAAM,UAAS,EAC9F,GAAIA,EAAK,WAAW,YAAY,EAAG,MAAO,CAAE,KAAM,2BAA4B,SAAUA,EAAK,UAAU,EAAmB,EAAG,UAAS,EACtI,IAAMU,EAAUC,EAAaX,EAAMG,EAAUJ,CAAO,EAIpD,OAHIW,IAAY,IAAA,GACZb,EAAU,KAAKG,CAAI,EAAU,CAAE,KAAM,uBAAwB,KAAMA,EAAK,WAAW,IAAK,EAAE,EAAG,UAAS,GAC1GD,EAAQ,MAAMG,EAAgB,kBAAmB,uBAAuBF,EAAK,GAAIG,CAAQ,EAClF,CAAE,KAAM,sBAAuB,OAAM,UAAS,GAHnBO,CAItC,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{diagnosticText as r}from"../Diagnostics/DiagnosticArgument.js";import{firstWord as i,splitTopLevel as a,unescapeIdentifier as o}from"./LineText.js";import{tryParseStructuredMapping as s}from"./StructuredBlockParser.js";import{parseDescription as c}from"./DescriptionParser.js";import{isFileDirective as l}from"./FileReferences.js";import{parseProjectionExpression as u}from"./ProjectionExpressionParser.js";import{validateProjectionEventScopes as d}from"./ProjectionEventScopeValidator.js";const f=t(`^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$`),p=t(`^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),m=t(`^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$`),h=t(`^with\\s+(@?[\\w.]+)$`),g=t(`^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$`),_=t(`^nested\\s+(@?[\\w.]+)$`),v=t(`^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),y=t(`^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),b=t(`^clear\\s+with\\s+(@?[\\w.]+)$`),x=t(`^variant\\s+(@?[\\w.]+)\\s*$`),S=t(`^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),C=t(`^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$`),w=t(`^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+?)(?:\\s+\\*\\s+(.+))?$`),T=t(`^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$`),E=t(`^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$`),D={increment:`IncrementMappingSyntax`,decrement:`DecrementMappingSyntax`,clear:`ClearMappingSyntax`,count:`CountMappingSyntax`};function parseProjection(t,r){let a=f.exec(r.content);if(a===null)return t.error(e.InvalidProjectionDeclaration,`Invalid projection declaration '${r.content}' - expected 'projection <Name> [=> <ReadModel>]'`,n(r)),t.skipBlock(r.indent),{kind:`ProjectionSyntax`,sourceOptions:t.sourceOptions,name:i(r.content),readModel:null,sequence:null,autoMap:`Inherit`,blocks:[],location:n(r)};let o=a[1],s=null,u=null,p=`Inherit`,m=null,h=[];for(let e=t.peekChild(r.indent);e!==void 0;e=t.peekChild(r.indent)){if(t.reader.takeSignificant(),l(e))continue;let n=i(e.content);if(n===`description`)u=c(t,e,u,`Projection '${o}'`);else if(n===`sequence`)s=e.content.substring(8).trim();else if(n===`automap`)p=`Enabled`;else if(e.content===`no automap`)p=`Disabled`;else if(n===`key`)m=parseKey(t,e);else if(n===`variant`)h.push(parseVariant(t,e));else{let n=parseBlock(t,e,!1);n!==void 0&&h.push(n)}}return reportVariantConflicts(t,h,o),d(t,o,h),h.length===0&&t.error(e.EmptyProjection,`Projection '${o}' must contain at least one directive`,n(r)),{kind:`ProjectionSyntax`,sourceOptions:t.sourceOptions,name:o,readModel:a[2]??null,sequence:s,autoMap:p,key:m,blocks:h,description:u,location:n(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,a){let o=n(r);switch(i(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 a||t.error(e.ClearWithOutsideNestedBlock,`'clear with' is only valid inside a nested block`,o),parseClearWith(t,r);default:t.error(e.UnknownProjectionDirective,`Unexpected '${i(r.content)}' in projection body`,o),t.skipBlock(r.indent);return}}function parseFrom(t,r){let s=[];for(let i of a(r.content.substring(4),`,`)){let a=i.trim();if(a.length===0){t.error(e.FromWithoutEvent,`Expected an event type after 'from'`,n(r));continue}let c=p.exec(a);c===null?t.error(e.InvalidEventReference,`Invalid event reference '${a}'`,n(r)):s.push({kind:`EventSpecSyntax`,event:o(c[1]),key:c[2]===void 0?null:u(c[2],n(r),t),location:n(r)})}let c=[],l=null,d=null;for(let e=t.peekChild(r.indent);e!==void 0;e=t.peekChild(r.indent)){t.reader.takeSignificant();let r=i(e.content);r===`key`?l=parseKey(t,e):r===`parent`?d=u(e.content.substring(6),n(e),t):pushMapping(t,e,c)}return{kind:`FromSyntax`,events:s,key:l,parentKey:d,mappings:c,location:n(r)}}function parseJoin(t,r){let i=m.exec(r.content);if(i===null)return t.error(e.InvalidJoinDeclaration,`Invalid join declaration '${r.content}' - expected 'join <property> on <key>'`,n(r)),t.skipBlock(r.indent),{kind:`JoinSyntax`,property:``,on:``,events:[],location:n(r)};let a=[];for(let i=t.peekChild(r.indent);i!==void 0;i=t.peekChild(r.indent)){t.reader.takeSignificant();let r=h.exec(i.content);if(r===null){t.error(e.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${i.content}'`,n(i)),t.skipBlock(i.indent);continue}let{autoMap:s,mappings:c}=parseMappingBlock(t,i);a.push({kind:`JoinEventSyntax`,event:o(r[1]),autoMap:s,mappings:c,location:n(i)})}return{kind:`JoinSyntax`,property:o(i[1]),on:o(i[2]),events:a,location:n(r)}}function parseChildren(t,r){let i=g.exec(r.content);if(i===null)return t.error(e.InvalidChildrenDeclaration,`Invalid children declaration '${r.content}' - expected 'children <collection> identified by <key>'`,n(r)),t.skipBlock(r.indent),{kind:`ChildrenSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:n(r)};let{autoMap:a,blocks:s}=parseChildBlocks(t,r);return{kind:`ChildrenSyntax`,property:o(i[1]),identifiedBy:u(i[2],n(r),t),autoMap:a,blocks:s,location:n(r)}}function parseNested(t,r){let i=_.exec(r.content);if(i===null)return t.error(e.InvalidNestedDeclaration,`Invalid nested declaration '${r.content}' - expected 'nested <property>'`,n(r)),t.skipBlock(r.indent),{kind:`NestedSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:n(r)};let a=o(i[1]),{autoMap:s,blocks:c}=parseChildBlocks(t,r);return c.some(e=>e.kind===`FromSyntax`)||t.error(e.NestedBlockWithoutFrom,`Nested block '${a}' must contain at least one 'from' directive`,n(r)),{kind:`NestedSyntax`,property:a,autoMap:s,blocks:c,location:n(r)}}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 a=y.exec(r.content);if(a!==null)return{kind:`RemoveViaJoinSyntax`,event:o(a[1]),key:a[2]===void 0?null:u(a[2],n(r),t),location:n(r)};let s=v.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>'`,n(r)),t.skipBlock(r.indent);return}let c=s[2]===void 0?null:u(s[2],n(r),t),l=null,d=null;for(let a=t.peekChild(r.indent);a!==void 0;a=t.peekChild(r.indent))if(t.reader.takeSignificant(),i(a.content)===`parent`)d=u(a.content.substring(6),n(a),t);else if(i(a.content)===`key`){(c!==null||l!==null)&&t.error(e.InvalidReadModelKeyLookup,`A removal can only declare one key.`,n(a));let r=parseKey(t,a);r.kind===`CompositeKeySyntax`?l=r:c=r.expression}else t.error(e.UnknownRemoveDirective,`Unexpected '${a.content}' in remove block - only 'parent' or 'key' is allowed`,n(a));return{kind:`RemoveWithSyntax`,event:o(s[1]),key:c,...l===null?{}:{partsKey:l},parentKey:d,location:n(r)}}function parseClearWith(t,r){let i=b.exec(r.content);return i===null?(t.error(e.InvalidClearDeclaration,`Invalid clear declaration '${r.content}' - expected 'clear with <EventType>'`,n(r)),{kind:`ClearWithSyntax`,event:``,location:n(r)}):{kind:`ClearWithSyntax`,event:o(i[1]),location:n(r)}}function parseVariant(t,r){let a=x.exec(r.content);if(a===null)return t.error(e.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${r.content}' - expected 'variant <Name>'`,n(r)),t.skipBlock(r.indent),{kind:`ProjectionVariantSyntax`,name:i(r.content),entersOn:[],blocks:[],location:n(r)};let s=o(a[1]),c=[],l=[];for(let a=t.peekChild(r.indent);a!==void 0;a=t.peekChild(r.indent)){t.reader.takeSignificant();let r=i(a.content);if(r===`enters`)c.push(parseEntersOn(t,a));else if(r===`variant`)t.error(e.NestedProjectionVariantNotAllowed,`A variant cannot be declared inside another variant`,n(a)),t.skipBlock(a.indent);else{let e=parseBlock(t,a,!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`,n(r)),{kind:`ProjectionVariantSyntax`,name:s,entersOn:c,blocks:l,location:n(r)}}function parseEntersOn(t,r){let i=S.exec(r.content);return i===null?(t.error(e.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${r.content}' - expected 'enters on <EventType> [key <expression>]'`,n(r)),t.skipBlock(r.indent),{kind:`ProjectionEntersOnSyntax`,event:``,key:null,location:n(r)}):{kind:`ProjectionEntersOnSyntax`,event:o(i[1]),key:i[2]===void 0?null:u(i[2],n(r),t),location:n(r)}}function parseKey(t,r){let i=r.content.substring(3).trim();if(t.peekChild(r.indent)===void 0)return{kind:`ExpressionKeySyntax`,expression:u(i,n(r),t),location:n(r)};i.endsWith(`{`)&&t.information(e.RedundantCompositeKeyBraces,`Write the composite key without braces; the indented parts already belong to the key.`,n(r));let a=[];for(let s=t.peekChild(r.indent);s!==void 0;s=t.peekChild(r.indent)){if(t.reader.takeSignificant(),s.content===`}`)continue;let r=E.exec(s.content);if(r===null){t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidCompositeKeyPart,`Invalid composite key part '${s.content}' - expected '<property> = <expression>'`,n(s));continue}let c=u(r[2],n(s),t);t.sourceOptions.numericMode===`exact`&&i.replace(/\{$/,``).trim().length>0&&c.kind===`TemplateExpressionSyntax`&&t.error(e.TemplateInCompositeKey,`Template expressions are not allowed in composite keys`,n(s)),a.push({kind:`KeyPartSyntax`,property:o(r[1]),expression:c,location:n(s)})}let s=t.reader.peekSignificant();return s!==void 0&&s.indent===r.indent&&s.content===`}`&&t.reader.takeSignificant(),t.sourceOptions.numericMode===`exact`&&a.length===0&&t.error(e.EmptyCompositeKey,`Composite keys must contain at least one part`,n(r)),{kind:`CompositeKeySyntax`,type:i.replace(/\{$/,``).trim(),parts:a,location:n(r)}}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,i,a){let c=n(i),l=C.exec(i.content);if(l!==null){l[1]!==`clear`||l[2]!==`with`?a.push({kind:D[l[1]],property:o(l[2]),location:c}):t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidProjectionMapping,`Invalid mapping '${i.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`,c,r(`text`,i.content));return}let d=w.exec(i.content);if(d!==null){a.push({kind:d[1]===`add`?`AddMappingSyntax`:`SubtractMappingSyntax`,property:o(d[2]),value:u(d[3],c,t),...d[4]===void 0?{}:{factor:u(d[4],c,t)},location:c});return}let f=T.exec(i.content)??E.exec(i.content);if(f!==null){a.push({kind:`SetMappingSyntax`,property:o(f[1]),source:u(f[2],c,t),location:c});return}let p=t.sourceOptions.numericMode===`exact`?s(t,i):void 0;p===void 0?t.sourceOptions.numericMode===`exact`&&t.error(e.InvalidProjectionMapping,`Invalid mapping '${i.content}'`,c,r(`text`,i.content)):a.push({kind:`SetMappingSyntax`,property:p.property,source:p.source,location:c})}export{parseProjection};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{diagnosticText as e}from"../Diagnostics/DiagnosticArgument.js";import{DiagnosticCodes as t}from"../Diagnostics/DiagnosticCodes.js";import{pattern as n}from"../Text/patterns.js";import{parseProjectionExpression as r}from"./ProjectionExpressionParser.js";import{validateProjectionEventScopes as i}from"./ProjectionEventScopeValidator.js";import{isFileDirective as a}from"./FileReferences.js";import{parseDescription as o}from"./DescriptionParser.js";import{firstWord as s,splitTopLevel as c,unescapeIdentifier as l}from"./LineText.js";import{locationOf as u}from"./SourceLine.js";import{tryParseStructuredMapping as d}from"./StructuredBlockParser.js";const f=n(`^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$`),p=n(`^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),m=n(`^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$`),h=n(`^with\\s+(@?[\\w.]+)$`),g=n(`^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$`),_=n(`^nested\\s+(@?[\\w.]+)$`),v=n(`^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),y=n(`^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),b=n(`^clear\\s+with\\s+(@?[\\w.]+)$`),x=n(`^variant\\s+(@?[\\w.]+)\\s*$`),S=n(`^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$`),C=n(`^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$`),w=n(`^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+?)(?:\\s+\\*\\s+(.+))?$`),T=n(`^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$`),E=n(`^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$`),D={increment:`IncrementMappingSyntax`,decrement:`DecrementMappingSyntax`,clear:`ClearMappingSyntax`,count:`CountMappingSyntax`};function parseProjection(e,n){let r=f.exec(n.content);if(r===null)return e.error(t.InvalidProjectionDeclaration,`Invalid projection declaration '${n.content}' - expected 'projection <Name> [=> <ReadModel>]'`,u(n)),e.skipBlock(n.indent),{kind:`ProjectionSyntax`,sourceOptions:e.sourceOptions,name:s(n.content),readModel:null,sequence:null,autoMap:`Inherit`,blocks:[],location:u(n)};let c=r[1],l=null,d=null,p=`Inherit`,m=null,h=[];for(let t=e.peekChild(n.indent);t!==void 0;t=e.peekChild(n.indent)){if(e.reader.takeSignificant(),a(t))continue;let n=s(t.content);if(n===`description`)d=o(e,t,d,`Projection '${c}'`);else if(n===`sequence`)l=t.content.substring(8).trim();else if(n===`automap`)p=`Enabled`;else if(t.content===`no automap`)p=`Disabled`;else if(n===`key`)m=parseKey(e,t);else if(n===`variant`)h.push(parseVariant(e,t));else{let n=parseBlock(e,t,!1);n!==void 0&&h.push(n)}}return reportVariantConflicts(e,h,c),i(e,c,h),h.length===0&&e.error(t.EmptyProjection,`Projection '${c}' must contain at least one directive`,u(n)),{kind:`ProjectionSyntax`,sourceOptions:e.sourceOptions,name:c,readModel:r[2]??null,sequence:l,autoMap:p,key:m,blocks:h,description:d,location:u(n)}}function reportVariantConflicts(e,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)))e.error(t.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)&&e.error(t.DuplicateVariantEnteringEvent,`Entering event '${i.event}' is claimed more than once in projection '${r}'`,i.location),o.add(i.event)}function parseBlock(e,n,r){let i=u(n);switch(s(n.content)){case`from`:return parseFrom(e,n);case`every`:{let t=!0,{autoMap:r,mappings:a}=parseMappingBlock(e,n,e=>e.content===`exclude children`&&(t=!1,!0));return{kind:`EverySyntax`,includeChildren:t,autoMap:r,mappings:a,location:i}}case`all`:{let{autoMap:t,mappings:r}=parseMappingBlock(e,n);return{kind:`AllSyntax`,autoMap:t,mappings:r,location:i}}case`join`:return parseJoin(e,n);case`children`:return parseChildren(e,n);case`nested`:return parseNested(e,n);case`remove`:return parseRemove(e,n);case`clear`:return r||e.error(t.ClearWithOutsideNestedBlock,`'clear with' is only valid inside a nested block`,i),parseClearWith(e,n);default:e.error(t.UnknownProjectionDirective,`Unexpected '${s(n.content)}' in projection body`,i),e.skipBlock(n.indent);return}}function parseFrom(e,n){let i=[];for(let a of c(n.content.substring(4),`,`)){let o=a.trim();if(o.length===0){e.error(t.FromWithoutEvent,`Expected an event type after 'from'`,u(n));continue}let s=p.exec(o);s===null?e.error(t.InvalidEventReference,`Invalid event reference '${o}'`,u(n)):i.push({kind:`EventSpecSyntax`,event:l(s[1]),key:s[2]===void 0?null:r(s[2],u(n),e),location:u(n)})}let a=[],o=null,d=null;for(let t=e.peekChild(n.indent);t!==void 0;t=e.peekChild(n.indent)){e.reader.takeSignificant();let n=s(t.content);n===`key`?o=parseKey(e,t):n===`parent`?d=r(t.content.substring(6),u(t),e):pushMapping(e,t,a)}return{kind:`FromSyntax`,events:i,key:o,parentKey:d,mappings:a,location:u(n)}}function parseJoin(e,n){let r=m.exec(n.content);if(r===null)return e.error(t.InvalidJoinDeclaration,`Invalid join declaration '${n.content}' - expected 'join <property> on <key>'`,u(n)),e.skipBlock(n.indent),{kind:`JoinSyntax`,property:``,on:``,events:[],location:u(n)};let i=[];for(let r=e.peekChild(n.indent);r!==void 0;r=e.peekChild(n.indent)){e.reader.takeSignificant();let n=h.exec(r.content);if(n===null){e.error(t.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,u(r)),e.skipBlock(r.indent);continue}let{autoMap:a,mappings:o}=parseMappingBlock(e,r);i.push({kind:`JoinEventSyntax`,event:l(n[1]),autoMap:a,mappings:o,location:u(r)})}return{kind:`JoinSyntax`,property:l(r[1]),on:l(r[2]),events:i,location:u(n)}}function parseChildren(e,n){let i=g.exec(n.content);if(i===null)return e.error(t.InvalidChildrenDeclaration,`Invalid children declaration '${n.content}' - expected 'children <collection> identified by <key>'`,u(n)),e.skipBlock(n.indent),{kind:`ChildrenSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:u(n)};let{autoMap:a,blocks:o}=parseChildBlocks(e,n);return{kind:`ChildrenSyntax`,property:l(i[1]),identifiedBy:r(i[2],u(n),e),autoMap:a,blocks:o,location:u(n)}}function parseNested(e,n){let r=_.exec(n.content);if(r===null)return e.error(t.InvalidNestedDeclaration,`Invalid nested declaration '${n.content}' - expected 'nested <property>'`,u(n)),e.skipBlock(n.indent),{kind:`NestedSyntax`,property:``,autoMap:`Inherit`,blocks:[],location:u(n)};let i=l(r[1]),{autoMap:a,blocks:o}=parseChildBlocks(e,n);return o.some(e=>e.kind===`FromSyntax`)||e.error(t.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,u(n)),{kind:`NestedSyntax`,property:i,autoMap:a,blocks:o,location:u(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(e,n){let i=y.exec(n.content);if(i!==null)return{kind:`RemoveViaJoinSyntax`,event:l(i[1]),key:i[2]===void 0?null:r(i[2],u(n),e),location:u(n)};let a=v.exec(n.content);if(a===null){e.error(t.InvalidRemoveDeclaration,`Invalid remove declaration '${n.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,u(n)),e.skipBlock(n.indent);return}let o=a[2]===void 0?null:r(a[2],u(n),e),c=null,d=null;for(let i=e.peekChild(n.indent);i!==void 0;i=e.peekChild(n.indent))if(e.reader.takeSignificant(),s(i.content)===`parent`)d=r(i.content.substring(6),u(i),e);else if(s(i.content)===`key`){(o!==null||c!==null)&&e.error(t.InvalidReadModelKeyLookup,`A removal can only declare one key.`,u(i));let n=parseKey(e,i);n.kind===`CompositeKeySyntax`?c=n:o=n.expression}else e.error(t.UnknownRemoveDirective,`Unexpected '${i.content}' in remove block - only 'parent' or 'key' is allowed`,u(i));return{kind:`RemoveWithSyntax`,event:l(a[1]),key:o,...c===null?{}:{partsKey:c},parentKey:d,location:u(n)}}function parseClearWith(e,n){let r=b.exec(n.content);return r===null?(e.error(t.InvalidClearDeclaration,`Invalid clear declaration '${n.content}' - expected 'clear with <EventType>'`,u(n)),{kind:`ClearWithSyntax`,event:``,location:u(n)}):{kind:`ClearWithSyntax`,event:l(r[1]),location:u(n)}}function parseVariant(e,n){let r=x.exec(n.content);if(r===null)return e.error(t.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${n.content}' - expected 'variant <Name>'`,u(n)),e.skipBlock(n.indent),{kind:`ProjectionVariantSyntax`,name:s(n.content),entersOn:[],blocks:[],location:u(n)};let i=l(r[1]),a=[],o=[];for(let r=e.peekChild(n.indent);r!==void 0;r=e.peekChild(n.indent)){e.reader.takeSignificant();let n=s(r.content);if(n===`enters`)a.push(parseEntersOn(e,r));else if(n===`variant`)e.error(t.NestedProjectionVariantNotAllowed,`A variant cannot be declared inside another variant`,u(r)),e.skipBlock(r.indent);else{let t=parseBlock(e,r,!1);t!==void 0&&o.push(t)}}return a.length===0&&e.error(t.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,u(n)),{kind:`ProjectionVariantSyntax`,name:i,entersOn:a,blocks:o,location:u(n)}}function parseEntersOn(e,n){let i=S.exec(n.content);return i===null?(e.error(t.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${n.content}' - expected 'enters on <EventType> [key <expression>]'`,u(n)),e.skipBlock(n.indent),{kind:`ProjectionEntersOnSyntax`,event:``,key:null,location:u(n)}):{kind:`ProjectionEntersOnSyntax`,event:l(i[1]),key:i[2]===void 0?null:r(i[2],u(n),e),location:u(n)}}function parseKey(e,n){let i=n.content.substring(3).trim();if(e.peekChild(n.indent)===void 0)return{kind:`ExpressionKeySyntax`,expression:r(i,u(n),e),location:u(n)};i.endsWith(`{`)&&e.information(t.RedundantCompositeKeyBraces,`Write the composite key without braces; the indented parts already belong to the key.`,u(n));let a=[];for(let o=e.peekChild(n.indent);o!==void 0;o=e.peekChild(n.indent)){if(e.reader.takeSignificant(),o.content===`}`)continue;let n=E.exec(o.content);if(n===null){e.sourceOptions.numericMode===`exact`&&e.error(t.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,u(o));continue}let s=r(n[2],u(o),e);e.sourceOptions.numericMode===`exact`&&i.replace(/\{$/,``).trim().length>0&&s.kind===`TemplateExpressionSyntax`&&e.error(t.TemplateInCompositeKey,`Template expressions are not allowed in composite keys`,u(o)),a.push({kind:`KeyPartSyntax`,property:l(n[1]),expression:s,location:u(o)})}let o=e.reader.peekSignificant();return o!==void 0&&o.indent===n.indent&&o.content===`}`&&e.reader.takeSignificant(),e.sourceOptions.numericMode===`exact`&&a.length===0&&e.error(t.EmptyCompositeKey,`Composite keys must contain at least one part`,u(n)),{kind:`CompositeKeySyntax`,type:i.replace(/\{$/,``).trim(),parts:a,location:u(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(n,i,a){let o=u(i),s=C.exec(i.content);if(s!==null){s[1]!==`clear`||s[2]!==`with`?a.push({kind:D[s[1]],property:l(s[2]),location:o}):n.sourceOptions.numericMode===`exact`&&n.error(t.InvalidProjectionMapping,`Invalid mapping '${i.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`,o,e(`text`,i.content));return}let c=w.exec(i.content);if(c!==null){a.push({kind:c[1]===`add`?`AddMappingSyntax`:`SubtractMappingSyntax`,property:l(c[2]),value:r(c[3],o,n),...c[4]===void 0?{}:{factor:r(c[4],o,n)},location:o});return}let f=T.exec(i.content)??E.exec(i.content);if(f!==null){a.push({kind:`SetMappingSyntax`,property:l(f[1]),source:r(f[2],o,n),location:o});return}let p=n.sourceOptions.numericMode===`exact`?d(n,i):void 0;p===void 0?n.sourceOptions.numericMode===`exact`&&n.error(t.InvalidProjectionMapping,`Invalid mapping '${i.content}'`,o,e(`text`,i.content)):a.push({kind:`SetMappingSyntax`,property:p.property,source:p.source,location:o})}export{parseProjection};
2
2
  //# sourceMappingURL=ProjectionParser.js.map
@@ -1 +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","validateProjectionEventScopes","variants","byName","variant","duplicate","group","entering","entry","location","includeChildren","nestedScope","events","spec","splitTopLevel","text","unescapeIdentifier","parseProjectionExpression","mappings","parentKey","withMatch","property","viaJoin","partsKey","parsed","entersOn","parts","expression","closing","extra","diagnosticText","arithmetic","assigned","structured","tryParseStructuredMapping"],"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 { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport {\n AutoMapMode, ChildrenSyntax, ClearWithSyntax, CompositeKeySyntax, 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 { validateProjectionEventScopes } from './ProjectionEventScopeValidator';\nimport { isFileDirective } from './FileReferences';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord, splitTopLevel, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { tryParseStructuredMapping } from './StructuredBlockParser';\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+(.+?)(?:\\\\s+\\\\*\\\\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 validateProjectionEventScopes(context, name, blocks);\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 key = match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context);\n let partsKey: CompositeKeySyntax | 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 if (firstWord(child.content) === 'parent') {\n parentKey = parseProjectionExpression(child.content.substring('parent'.length), locationOf(child), context);\n } else if (firstWord(child.content) === 'key') {\n if (key !== null || partsKey !== null) context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A removal can only declare one key.', locationOf(child));\n const parsed = parseKey(context, child);\n if (parsed.kind === 'CompositeKeySyntax') partsKey = parsed;\n else key = parsed.expression;\n } else {\n context.error(DiagnosticCodes.UnknownRemoveDirective, `Unexpected '${child.content}' in remove block - only 'parent' or 'key' is allowed`, locationOf(child));\n }\n }\n return { kind: 'RemoveWithSyntax', event: unescapeIdentifier(match[1]), key, ...(partsKey === null ? {} : { partsKey }), 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 if (text.endsWith('{')) context.information(DiagnosticCodes.RedundantCompositeKeyBraces, 'Write the composite key without braces; the indented parts already belong to the key.', 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' && text.replace(/\\{$/, '').trim().length > 0 && 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, diagnosticText('text', line.content));\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), ...(arithmetic[4] === undefined ? {} : { factor: parseProjectionExpression(arithmetic[4], 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 return;\n }\n // Structured literals exist only in exact numeric mode, written as an indented block under the property.\n const structured = context.sourceOptions.numericMode === 'exact' ? tryParseStructuredMapping(context, line) : undefined;\n if (structured !== undefined) {\n mappings.push({ kind: 'SetMappingSyntax', property: structured.property, source: structured.source, location });\n } else if (context.sourceOptions.numericMode === 'exact') {\n context.error(DiagnosticCodes.InvalidProjectionMapping, `Invalid mapping '${line.content}'`, location, diagnosticText('text', line.content));\n }\n}\n"],"mappings":"qsBAoBA,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,qEAAqE,EACjGa,EAAab,EAAQ,2CAA2C,EAChEc,EAAoBd,EAAQ,qCAAqC,EACjEe,EAA+C,CACjD,UAAW,yBACX,UAAW,yBACX,MAAO,qBACP,MAAO,oBACX,EAKA,SAAgB,gBAAgB,EAAwB,EAAoC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,CAAE,KAAM,mBAAoB,SAAUe,EAAW,SAAU,OAAQA,EAAW,OAAQ,UAAS,CAAC,CAItH"}
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","validateProjectionEventScopes","variants","byName","variant","duplicate","group","entering","entry","location","includeChildren","nestedScope","events","spec","splitTopLevel","text","unescapeIdentifier","parseProjectionExpression","mappings","parentKey","withMatch","property","viaJoin","partsKey","parsed","entersOn","parts","expression","closing","extra","diagnosticText","arithmetic","assigned","structured","tryParseStructuredMapping"],"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 { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport {\n AutoMapMode, ChildrenSyntax, ClearWithSyntax, CompositeKeySyntax, 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 { validateProjectionEventScopes } from './ProjectionEventScopeValidator';\nimport { isFileDirective } from './FileReferences';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord, splitTopLevel, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { tryParseStructuredMapping } from './StructuredBlockParser';\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+(.+?)(?:\\\\s+\\\\*\\\\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 validateProjectionEventScopes(context, name, blocks);\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 key = match[2] === undefined ? null : parseProjectionExpression(match[2], locationOf(line), context);\n let partsKey: CompositeKeySyntax | 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 if (firstWord(child.content) === 'parent') {\n parentKey = parseProjectionExpression(child.content.substring('parent'.length), locationOf(child), context);\n } else if (firstWord(child.content) === 'key') {\n if (key !== null || partsKey !== null) context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A removal can only declare one key.', locationOf(child));\n const parsed = parseKey(context, child);\n if (parsed.kind === 'CompositeKeySyntax') partsKey = parsed;\n else key = parsed.expression;\n } else {\n context.error(DiagnosticCodes.UnknownRemoveDirective, `Unexpected '${child.content}' in remove block - only 'parent' or 'key' is allowed`, locationOf(child));\n }\n }\n return { kind: 'RemoveWithSyntax', event: unescapeIdentifier(match[1]), key, ...(partsKey === null ? {} : { partsKey }), 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 if (text.endsWith('{')) context.information(DiagnosticCodes.RedundantCompositeKeyBraces, 'Write the composite key without braces; the indented parts already belong to the key.', 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' && text.replace(/\\{$/, '').trim().length > 0 && 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, diagnosticText('text', line.content));\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), ...(arithmetic[4] === undefined ? {} : { factor: parseProjectionExpression(arithmetic[4], 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 return;\n }\n // Structured literals exist only in exact numeric mode, written as an indented block under the property.\n const structured = context.sourceOptions.numericMode === 'exact' ? tryParseStructuredMapping(context, line) : undefined;\n if (structured !== undefined) {\n mappings.push({ kind: 'SetMappingSyntax', property: structured.property, source: structured.source, location });\n } else if (context.sourceOptions.numericMode === 'exact') {\n context.error(DiagnosticCodes.InvalidProjectionMapping, `Invalid mapping '${line.content}'`, location, diagnosticText('text', line.content));\n }\n}\n"],"mappings":"A,qsBAoBA,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,qEAAqE,EACjGa,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,CAAE,EAExM,IAAMK,EAAON,EAAM,GACfO,EAA0B,KAC1BC,EAA6B,KAC7BC,EAAuB,UACvBC,EAAwB,KACtBC,EAAkC,CAAC,EACzC,IAAK,IAAIC,EAAQV,EAAQ,UAAUD,EAAK,MAAM,EAAGW,IAAU,IAAA,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A0Bc,EAAW,GAAItB,EAAUvB,CAAO,EAAG,GAAI6C,EAAW,KAAO,IAAA,GAAY,CAAC,EAAI,CAAE,OAAQd,EAA0Bc,EAAW,GAAItB,EAAUvB,CAAO,CAAE,EAAI,UAAS,CAAC,EAC1U,MACJ,CACA,IAAM8C,EAAWnD,EAAW,KAAKI,EAAK,OAAO,GAAKH,EAAkB,KAAKG,EAAK,OAAO,EACrF,GAAI+C,IAAa,KAAM,CACnBd,EAAS,KAAK,CAAE,KAAM,mBAAoB,SAAUF,EAAmBgB,EAAS,EAAE,EAAG,OAAQf,EAA0Be,EAAS,GAAIvB,EAAUvB,CAAO,EAAG,UAAS,CAAC,EAClK,MACJ,CAEA,IAAM+C,EAAa/C,EAAQ,cAAc,cAAgB,QAAUgD,EAA0BhD,EAASD,CAAI,EAAI,IAAA,GAC1GgD,IAAe,IAAA,GAER/C,EAAQ,cAAc,cAAgB,SAC7CA,EAAQ,MAAMC,EAAgB,yBAA0B,oBAAoBF,EAAK,QAAQ,GAAIwB,EAAUqB,EAAe,OAAQ7C,EAAK,OAAO,CAAC,EAF3IiC,EAAS,KAAK,CAAE,KAAM,mBAAoB,SAAUe,EAAW,SAAU,OAAQA,EAAW,OAAQ,UAAS,CAAC,CAItH,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{eventDeclarations as t}from"../Syntax/EventDeclarations.js";import{AuthoringProductionResolver as n}from"../Syntax/AuthoringProductionResolver.js";import{diagnosticText as r}from"../Diagnostics/DiagnosticArgument.js";import{uniqueByName as i}from"./ResponseValidator.js";function validateProjectionTargets(a,o){let s=new n(a),c=s.slices,l=new Set(a.imports.map(e=>e.qualifiedName)),u=/* @__PURE__ */ new Set([...c.flatMap(({slice:e})=>t(e).map(e=>e.name)),...a.imports.map(e=>e.qualifiedName.split(`.`).at(-1))]),d=i(a.types),f=new Set([`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`,...a.concepts.map(e=>e.name)].filter(e=>!d.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}:f.has(a.type.name)?{value:null,missing:!0}:property(d.get(a.type.name)?.properties??null,r.join(`.`))},p=c.flatMap(({slice:e,scope:t})=>e.readModels.map(e=>({node:e,scope:t}))),viewProperties=(e,t)=>{let candidates=e=>{let n=e.split(`.`),r=p.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=a.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=s.resolve(t,r);u.has(t)||l.has(t)||i.declaration?.kind===`event`||i.candidates.some(e=>e.kind===`event`)||o.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)},m=/* @__PURE__ */ new Set,walk=(t,n,i=!1,a=!1)=>{let validate=(t,a)=>{let s=property(n,t),c=JSON.stringify([a.path,a.line,a.column]);return s.missing&&!m.has(c)&&(m.add(c),o.warning(e.UnknownReadModelProperty,`Projection target '${t}' is not a declared ${i?`element`:`read-model`} property`,a,r(`property`,t))),s.value},s=a||t.some(e=>e.kind===`FromSyntax`||e.kind===`JoinSyntax`||e.kind===`AllSyntax`);for(let e of t){let t=e.kind===`EverySyntax`&&!s?[]:`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:d.get(t.type.name)?.properties??null,!0)}}};for(let{slice:e}of c){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 c)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};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{diagnosticText as e}from"../Diagnostics/DiagnosticArgument.js";import{DiagnosticCodes as t}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as n}from"../Syntax/AuthoringProductionResolver.js";import{eventDeclarations as r}from"../Syntax/EventDeclarations.js";import{uniqueByName as i}from"./ResponseValidator.js";function validateProjectionTargets(a,o){let s=new n(a),c=s.slices,l=new Set(a.imports.map(e=>e.qualifiedName)),u=/* @__PURE__ */ new Set([...c.flatMap(({slice:e})=>r(e).map(e=>e.name)),...a.imports.map(e=>e.qualifiedName.split(`.`).at(-1))]),d=i(a.types),f=new Set([`Uuid`,`String`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`,...a.concepts.map(e=>e.name)].filter(e=>!d.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}:f.has(a.type.name)?{value:null,missing:!0}:property(d.get(a.type.name)?.properties??null,r.join(`.`))},p=c.flatMap(({slice:e,scope:t})=>e.readModels.map(e=>({node:e,scope:t}))),viewProperties=(e,t)=>{let candidates=e=>{let n=e.split(`.`),r=p.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=a.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=(e,n,r)=>{let i=s.resolve(e,r);u.has(e)||l.has(e)||i.declaration?.kind===`event`||i.candidates.some(e=>e.kind===`event`)||o.warning(t.UnknownEvent,`Unknown event '${e}' - declare it with 'event ${e}'`,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)},m=/* @__PURE__ */ new Set,walk=(n,r,i=!1,a=!1)=>{let validate=(n,a)=>{let s=property(r,n),c=JSON.stringify([a.path,a.line,a.column]);return s.missing&&!m.has(c)&&(m.add(c),o.warning(t.UnknownReadModelProperty,`Projection target '${n}' is not a declared ${i?`element`:`read-model`} property`,a,e(`property`,n))),s.value},s=a||n.some(e=>e.kind===`FromSyntax`||e.kind===`JoinSyntax`||e.kind===`AllSyntax`);for(let e of n){let t=e.kind===`EverySyntax`&&!s?[]:`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:d.get(t.type.name)?.properties??null,!0)}}};for(let{slice:e}of c){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 c)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
2
  //# sourceMappingURL=ProjectionTargetValidator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectionTargetValidator.js","names":["resolver","AuthoringProductionResolver","application","slices","imported","entry","events","eventDeclarations","slice","event","types","uniqueByName","scalar","concept","name","rest","path","properties","matches","value","views","segments","named","qualifiers","index","depth","scope","visible","reference","imports","resolution","candidate","context","DiagnosticCodes","location","block","blocks","reported","resolved","key","element","diagnosticText","ownsEvents","effectiveHandlers","mappings","mapping","target","projection","capture","append","child","variants","variant"],"sources":["../../../../../../Compiler/Parsing/ProjectionTargetValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthoringProductionKind, AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ProjectionBlockSyntax } from '../Syntax/Projections';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { uniqueByName } from './ResponseValidator';\n\nexport function validateProjectionTargets(application: ApplicationSyntax, context: ParserContext): void {\n const resolver = new AuthoringProductionResolver(application);\n const slices = resolver.slices;\n const imported = new Set(application.imports.map(entry => entry.qualifiedName));\n const events = new Set([...slices.flatMap(({ slice }) => eventDeclarations(slice).map(event => event.name)), ...application.imports.map(entry => entry.qualifiedName.split('.').at(-1)!)]);\n const types = uniqueByName(application.types);\n const scalar = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...application.concepts.map(concept => concept.name)].filter(name => !types.has(name)));\n const property = (properties: readonly PropertySyntax[] | null, path: string): { value: PropertySyntax | null; missing: boolean } => {\n const [name, ...rest] = path.split('.');\n if (properties === null) return { value: null, missing: false };\n const matches = properties.filter(entry => entry.name === name);\n if (matches.length !== 1) return { value: null, missing: matches.length === 0 };\n const value = matches[0];\n if (rest.length === 0) return { value, missing: false };\n if (scalar.has(value.type.name)) return { value: null, missing: true };\n return property(types.get(value.type.name)?.properties ?? null, rest.join('.'));\n };\n const views = slices.flatMap(({ slice, scope }) => slice.readModels.map(node => ({ node, scope })));\n const viewProperties = (reference: string, scope: readonly string[]): readonly PropertySyntax[] | null => {\n const candidates = (name: string) => {\n const segments = name.split('.');\n const named = views.filter(entry => entry.node.name === 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 = scope.length; depth >= 0; depth--) {\n const visible = named.filter(entry => depth <= entry.scope.length && scope.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 imports = application.imports.filter(entry => entry.qualifiedName.split('.').at(-1) === reference);\n if (matches.length === 0 && imports.length === 1) matches = candidates(imports[0].qualifiedName);\n return matches.length === 1 ? matches[0].node.properties : null;\n };\n const unknownEvent = (name: string, location: SourceLocation, slice: SliceSyntax): void => {\n const resolution = resolver.resolve(name, slice);\n const declared = events.has(name) || imported.has(name) || resolution.declaration?.kind === AuthoringProductionKind.Event || resolution.candidates.some(candidate => candidate.kind === AuthoringProductionKind.Event);\n if (!declared) context.warning(DiagnosticCodes.UnknownEvent, `Unknown event '${name}' - declare it with 'event ${name}'`, location);\n };\n const removals = (blocks: readonly ProjectionBlockSyntax[], slice: SliceSyntax): void => {\n for (const block of blocks) {\n if (block.kind === 'RemoveWithSyntax' || block.kind === 'RemoveViaJoinSyntax') unknownEvent(block.event, block.location, slice);\n if ('blocks' in block) removals(block.blocks, slice);\n }\n };\n const reported = new Set<string>();\n const walk = (blocks: readonly ProjectionBlockSyntax[], properties: readonly PropertySyntax[] | null, element = false, effectiveHandlers = false): void => {\n const validate = (path: string, location: SourceLocation) => {\n const resolved = property(properties, path);\n const key = JSON.stringify([location.path, location.line, location.column]);\n if (resolved.missing && !reported.has(key)) {\n reported.add(key);\n context.warning(DiagnosticCodes.UnknownReadModelProperty, `Projection target '${path}' is not a declared ${element ? 'element' : 'read-model'} property`, location, diagnosticText('property', path));\n }\n return resolved.value;\n };\n // An 'every' without local handlers only cascades into the element scopes.\n const ownsEvents = effectiveHandlers || blocks.some(block => block.kind === 'FromSyntax' || block.kind === 'JoinSyntax' || block.kind === 'AllSyntax');\n for (const block of blocks) {\n const mappings = block.kind === 'EverySyntax' && !ownsEvents ? [] : 'mappings' in block ? block.mappings : block.kind === 'JoinSyntax' ? block.events.flatMap(event => event.mappings) : [];\n for (const mapping of mappings) validate(mapping.property, mapping.location);\n if (block.kind === 'ChildrenSyntax' || block.kind === 'NestedSyntax') {\n const target = validate(block.property, block.location);\n walk(block.blocks, target === null ? null : types.get(target.type.name)?.properties ?? null, true);\n }\n }\n };\n for (const { slice } of slices) {\n for (const projection of slice.projections) removals(projection.blocks, slice);\n for (const capture of slice.captures) {\n for (const append of [...capture.appends, ...capture.children.flatMap(child => child.appends), ...capture.nested.flatMap(child => child.appends)]) unknownEvent(append.event, append.location, slice);\n }\n }\n for (const { slice, scope } of slices) {\n for (const projection of slice.projections) {\n const variants = projection.blocks.filter(block => block.kind === 'ProjectionVariantSyntax');\n if (variants.length === 0) walk(projection.blocks, viewProperties(projection.readModel ?? projection.name, scope));\n for (const variant of variants) {\n const properties = viewProperties(variant.name, scope);\n walk(projection.blocks.filter(block => block.kind === 'ChildrenSyntax' || block.kind === 'NestedSyntax'), properties);\n // Lowering combines shared handlers and turns entering events into From handlers.\n const ownsEvents = variant.entersOn.length > 0 || projection.blocks.some(block => block.kind === 'FromSyntax' || block.kind === 'JoinSyntax' || block.kind === 'AllSyntax');\n walk(variant.blocks, properties, false, ownsEvents);\n }\n }\n }\n}\n"],"mappings":"+YAcA,SAAgB,0BAA0B,EAAgC,EAA8B,CACpG,IAAMA,EAAW,IAAIC,EAA4BC,CAAW,EACtDC,EAASH,EAAS,OAClBI,EAAW,IAAI,IAAIF,EAAY,QAAQ,IAAI,GAASG,EAAM,aAAa,CAAC,EACxEC,kBAAS,IAAI,IAAI,CAAC,GAAGH,EAAO,SAAS,CAAE,WAAYI,EAAkBC,CAAK,CAAC,CAAC,IAAI,GAASC,EAAM,IAAI,CAAC,EAAG,GAAGP,EAAY,QAAQ,IAAI,GAASG,EAAM,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAC,CAAC,EACnLK,EAAQC,EAAaT,EAAY,KAAK,EACtCU,EAAS,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,WAAY,GAAGV,EAAY,SAAS,IAAI,GAAWW,EAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,GAAQ,CAACH,EAAM,IAAII,CAAI,CAAC,CAAC,EACxK,UAAY,EAA8C,IAAqE,CACjI,GAAM,CAACA,EAAM,GAAGC,GAAQC,EAAK,MAAM,GAAG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AAWD,EAAU,CAC5B,IAAMlC,EAAa,eAAemC,EAAQ,KAAM1B,CAAK,EACrD,KAAKqB,EAAW,OAAO,OAAO,GAASZ,EAAM,OAAS,kBAAoBA,EAAM,OAAS,cAAc,EAAGlB,CAAU,EAEpH,IAAMyB,EAAaU,EAAQ,SAAS,OAAS,GAAKL,EAAW,OAAO,KAAK,GAASZ,EAAM,OAAS,cAAgBA,EAAM,OAAS,cAAgBA,EAAM,OAAS,WAAW,EAC1K,KAAKiB,EAAQ,OAAQnC,EAAY,GAAOyB,CAAU,CACtD,CACJ,CAER"}
1
+ {"version":3,"file":"ProjectionTargetValidator.js","names":["resolver","AuthoringProductionResolver","application","slices","imported","entry","events","eventDeclarations","slice","event","types","uniqueByName","scalar","concept","name","rest","path","properties","matches","value","views","segments","named","qualifiers","index","depth","scope","visible","reference","imports","resolution","candidate","context","DiagnosticCodes","location","block","blocks","reported","resolved","key","element","diagnosticText","ownsEvents","effectiveHandlers","mappings","mapping","target","projection","capture","append","child","variants","variant"],"sources":["../../../../../../Compiler/Parsing/ProjectionTargetValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthoringProductionKind, AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ProjectionBlockSyntax } from '../Syntax/Projections';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { uniqueByName } from './ResponseValidator';\n\nexport function validateProjectionTargets(application: ApplicationSyntax, context: ParserContext): void {\n const resolver = new AuthoringProductionResolver(application);\n const slices = resolver.slices;\n const imported = new Set(application.imports.map(entry => entry.qualifiedName));\n const events = new Set([...slices.flatMap(({ slice }) => eventDeclarations(slice).map(event => event.name)), ...application.imports.map(entry => entry.qualifiedName.split('.').at(-1)!)]);\n const types = uniqueByName(application.types);\n const scalar = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...application.concepts.map(concept => concept.name)].filter(name => !types.has(name)));\n const property = (properties: readonly PropertySyntax[] | null, path: string): { value: PropertySyntax | null; missing: boolean } => {\n const [name, ...rest] = path.split('.');\n if (properties === null) return { value: null, missing: false };\n const matches = properties.filter(entry => entry.name === name);\n if (matches.length !== 1) return { value: null, missing: matches.length === 0 };\n const value = matches[0];\n if (rest.length === 0) return { value, missing: false };\n if (scalar.has(value.type.name)) return { value: null, missing: true };\n return property(types.get(value.type.name)?.properties ?? null, rest.join('.'));\n };\n const views = slices.flatMap(({ slice, scope }) => slice.readModels.map(node => ({ node, scope })));\n const viewProperties = (reference: string, scope: readonly string[]): readonly PropertySyntax[] | null => {\n const candidates = (name: string) => {\n const segments = name.split('.');\n const named = views.filter(entry => entry.node.name === 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 = scope.length; depth >= 0; depth--) {\n const visible = named.filter(entry => depth <= entry.scope.length && scope.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 imports = application.imports.filter(entry => entry.qualifiedName.split('.').at(-1) === reference);\n if (matches.length === 0 && imports.length === 1) matches = candidates(imports[0].qualifiedName);\n return matches.length === 1 ? matches[0].node.properties : null;\n };\n const unknownEvent = (name: string, location: SourceLocation, slice: SliceSyntax): void => {\n const resolution = resolver.resolve(name, slice);\n const declared = events.has(name) || imported.has(name) || resolution.declaration?.kind === AuthoringProductionKind.Event || resolution.candidates.some(candidate => candidate.kind === AuthoringProductionKind.Event);\n if (!declared) context.warning(DiagnosticCodes.UnknownEvent, `Unknown event '${name}' - declare it with 'event ${name}'`, location);\n };\n const removals = (blocks: readonly ProjectionBlockSyntax[], slice: SliceSyntax): void => {\n for (const block of blocks) {\n if (block.kind === 'RemoveWithSyntax' || block.kind === 'RemoveViaJoinSyntax') unknownEvent(block.event, block.location, slice);\n if ('blocks' in block) removals(block.blocks, slice);\n }\n };\n const reported = new Set<string>();\n const walk = (blocks: readonly ProjectionBlockSyntax[], properties: readonly PropertySyntax[] | null, element = false, effectiveHandlers = false): void => {\n const validate = (path: string, location: SourceLocation) => {\n const resolved = property(properties, path);\n const key = JSON.stringify([location.path, location.line, location.column]);\n if (resolved.missing && !reported.has(key)) {\n reported.add(key);\n context.warning(DiagnosticCodes.UnknownReadModelProperty, `Projection target '${path}' is not a declared ${element ? 'element' : 'read-model'} property`, location, diagnosticText('property', path));\n }\n return resolved.value;\n };\n // An 'every' without local handlers only cascades into the element scopes.\n const ownsEvents = effectiveHandlers || blocks.some(block => block.kind === 'FromSyntax' || block.kind === 'JoinSyntax' || block.kind === 'AllSyntax');\n for (const block of blocks) {\n const mappings = block.kind === 'EverySyntax' && !ownsEvents ? [] : 'mappings' in block ? block.mappings : block.kind === 'JoinSyntax' ? block.events.flatMap(event => event.mappings) : [];\n for (const mapping of mappings) validate(mapping.property, mapping.location);\n if (block.kind === 'ChildrenSyntax' || block.kind === 'NestedSyntax') {\n const target = validate(block.property, block.location);\n walk(block.blocks, target === null ? null : types.get(target.type.name)?.properties ?? null, true);\n }\n }\n };\n for (const { slice } of slices) {\n for (const projection of slice.projections) removals(projection.blocks, slice);\n for (const capture of slice.captures) {\n for (const append of [...capture.appends, ...capture.children.flatMap(child => child.appends), ...capture.nested.flatMap(child => child.appends)]) unknownEvent(append.event, append.location, slice);\n }\n }\n for (const { slice, scope } of slices) {\n for (const projection of slice.projections) {\n const variants = projection.blocks.filter(block => block.kind === 'ProjectionVariantSyntax');\n if (variants.length === 0) walk(projection.blocks, viewProperties(projection.readModel ?? projection.name, scope));\n for (const variant of variants) {\n const properties = viewProperties(variant.name, scope);\n walk(projection.blocks.filter(block => block.kind === 'ChildrenSyntax' || block.kind === 'NestedSyntax'), properties);\n // Lowering combines shared handlers and turns entering events into From handlers.\n const ownsEvents = variant.entersOn.length > 0 || projection.blocks.some(block => block.kind === 'FromSyntax' || block.kind === 'JoinSyntax' || block.kind === 'AllSyntax');\n walk(variant.blocks, properties, false, ownsEvents);\n }\n }\n }\n}\n"],"mappings":"A,+YAcA,SAAgB,0BAA0B,EAAgC,EAA8B,CACpG,IAAMA,EAAW,IAAIC,EAA4BC,CAAW,EACtDC,EAASH,EAAS,OAClBI,EAAW,IAAI,IAAIF,EAAY,QAAQ,IAAI,GAASG,EAAM,aAAa,CAAC,EACxEC,kBAAS,IAAI,IAAI,CAAC,GAAGH,EAAO,SAAS,CAAE,WAAYI,EAAkBC,CAAK,CAAC,CAAC,IAAI,GAASC,EAAM,IAAI,CAAC,EAAG,GAAGP,EAAY,QAAQ,IAAI,GAASG,EAAM,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAC,CAAC,EACnLK,EAAQC,EAAaT,EAAY,KAAK,EACtCU,EAAS,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,WAAY,GAAGV,EAAY,SAAS,IAAI,GAAWW,EAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,GAAQ,CAACH,EAAM,IAAII,CAAI,CAAC,CAAC,EACxK,UAAY,EAA8C,IAAqE,CACjI,GAAM,CAACA,EAAM,GAAGC,GAAQC,EAAK,MAAM,GAAG,EACtC,GAAIC,IAAe,KAAM,MAAO,CAAE,MAAO,KAAM,QAAS,EAAM,EAC9D,IAAMC,EAAUD,EAAW,OAAO,GAASZ,EAAM,OAASS,CAAI,EAC9D,GAAII,EAAQ,SAAW,EAAG,MAAO,CAAE,MAAO,KAAM,QAASA,EAAQ,SAAW,CAAE,EAC9E,IAAM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O,KAAK,GAASZ,EAAM,OAAS,cAAgBA,EAAM,OAAS,cAAgBA,EAAM,OAAS,WAAW,EAC1K,KAAKiB,EAAQ,OAAQnC,EAAY,GAAOyB,CAAU,CACtD,CACJ,CAER,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{unescapeIdentifier as r}from"./LineText.js";const i=t(`^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?(?:\\s+(key))?$`),a=t(`^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject|key)(?:\\s+(?:optional|generated|identifier|subject|key))*)$`),o=t(`^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$`);function tryParseProperty(e){let t=i.exec(e.content);if(t===null)return;let a=n(e);return{kind:`PropertySyntax`,name:r(t[1]),type:parseTypeRef(t[2],{...a,column:a.column+e.content.indexOf(t[2],t[1].length)}),isGenerated:t[3]!==void 0,nameWasEscaped:t[1].startsWith(`@`),isIdentifier:t[4]!==void 0,...t[5]===void 0?{}:{isSubject:!0},...t[6]===void 0?{}:{isKey:!0},location:a}}function parseTypeRef(e,t){let n=e.endsWith(`?`),r=/\soptional$/.test(e),i=n||r;i&&(e=e.substring(0,e.length-(n?1:8)).trimEnd());let a=e.endsWith(`[]`);return a&&(e=e.substring(0,e.length-2)),{kind:`TypeRefSyntax`,name:e,isCollection:a,isOptional:i,location:t}}function parseProperty(t,r){let i=tryParseProperty(r);return i===void 0?reportInvalidModifierOrder(t,r):(reportLegacyOptionalSuffix(t,i.type,r),i.isKey&&(i.type.isOptional||i.type.isCollection||i.isGenerated||i.isIdentifier||i.isSubject)&&t.error(e.InvalidReadModelKey,`A read-model key part must be required, not a collection, and cannot combine key with generated, identifier or subject.`,n(r))),i}function reportLegacyOptionalSuffix(t,n,r){t.claimField(r);let i=n.name.length+(n.isCollection?2:0),a=n.location.column-r.indent-1+i;if(n.isOptional&&r.content[a]===`?`){let r=n.name+(n.isCollection?`[]`:``);t.information(e.LegacyOptionalSuffix,`Write '${r} optional' instead of '${r}?'.`,n.location)}}function reportInvalidModifierOrder(t,r){let i=a.exec(r.content);if(i!==null&&i[1].split(/\s+/).includes(`key`))return t.error(e.InvalidReadModelKey,`Write 'key' once, without other modifiers: '<name> <Type> key'.`,n(r)),!0;let s=a.exec(r.content);if(s!==null&&s[1].split(/\s+/).includes(`subject`))return t.error(e.InvalidSubjectModifierOrder,`Write each modifier once in order: '<name> <Type> optional generated identifier subject'.`,n(r)),!0;if(o.test(r.content))return t.error(e.InvalidOptionalModifierOrder,`Write 'optional' before 'identifier': '<name> <Type> optional identifier'.`,n(r)),!0;{let i=a.exec(r.content);if(i!==null&&i[1].split(/\s+/).some(e=>e===`generated`||e===`identifier`))return t.error(e.InvalidGeneratedModifierOrder,`Write each modifier once in order: '<name> <Type> optional generated identifier'.`,n(r)),!0}return!1}export{parseProperty,parseTypeRef,reportInvalidModifierOrder,reportLegacyOptionalSuffix,tryParseProperty};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{unescapeIdentifier as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";const i=t(`^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?(?:\\s+(key))?$`),a=t(`^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject|key)(?:\\s+(?:optional|generated|identifier|subject|key))*)$`),o=t(`^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$`);function tryParseProperty(e){let t=i.exec(e.content);if(t===null)return;let a=r(e);return{kind:`PropertySyntax`,name:n(t[1]),type:parseTypeRef(t[2],{...a,column:a.column+e.content.indexOf(t[2],t[1].length)}),isGenerated:t[3]!==void 0,nameWasEscaped:t[1].startsWith(`@`),isIdentifier:t[4]!==void 0,...t[5]===void 0?{}:{isSubject:!0},...t[6]===void 0?{}:{isKey:!0},location:a}}function parseTypeRef(e,t){let n=e.endsWith(`?`),r=/\soptional$/.test(e),i=n||r;i&&(e=e.substring(0,e.length-(n?1:8)).trimEnd());let a=e.endsWith(`[]`);return a&&(e=e.substring(0,e.length-2)),{kind:`TypeRefSyntax`,name:e,isCollection:a,isOptional:i,location:t}}function parseProperty(t,n){let i=tryParseProperty(n);return i===void 0?reportInvalidModifierOrder(t,n):(reportLegacyOptionalSuffix(t,i.type,n),i.isKey&&(i.type.isOptional||i.type.isCollection||i.isGenerated||i.isIdentifier||i.isSubject)&&t.error(e.InvalidReadModelKey,`A read-model key part must be required, not a collection, and cannot combine key with generated, identifier or subject.`,r(n))),i}function reportLegacyOptionalSuffix(t,n,r){t.claimField(r);let i=n.name.length+(n.isCollection?2:0),a=n.location.column-r.indent-1+i;if(n.isOptional&&r.content[a]===`?`){let r=n.name+(n.isCollection?`[]`:``);t.information(e.LegacyOptionalSuffix,`Write '${r} optional' instead of '${r}?'.`,n.location)}}function reportInvalidModifierOrder(t,n){let i=a.exec(n.content);if(i!==null&&i[1].split(/\s+/).includes(`key`))return t.error(e.InvalidReadModelKey,`Write 'key' once, without other modifiers: '<name> <Type> key'.`,r(n)),!0;let s=a.exec(n.content);if(s!==null&&s[1].split(/\s+/).includes(`subject`))return t.error(e.InvalidSubjectModifierOrder,`Write each modifier once in order: '<name> <Type> optional generated identifier subject'.`,r(n)),!0;if(o.test(n.content))return t.error(e.InvalidOptionalModifierOrder,`Write 'optional' before 'identifier': '<name> <Type> optional identifier'.`,r(n)),!0;{let i=a.exec(n.content);if(i!==null&&i[1].split(/\s+/).some(e=>e===`generated`||e===`identifier`))return t.error(e.InvalidGeneratedModifierOrder,`Write each modifier once in order: '<name> <Type> optional generated identifier'.`,r(n)),!0}return!1}export{parseProperty,parseTypeRef,reportInvalidModifierOrder,reportLegacyOptionalSuffix,tryParseProperty};
2
2
  //# sourceMappingURL=PropertyLineParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyLineParser.js","names":["propertyPattern","pattern","invalidGeneratedModifiers","reversedModifiers","match","line","location","locationOf","unescapeIdentifier","legacy","text","canonical","isOptional","isCollection","property","context","DiagnosticCodes","length","type","offset","name","keyModifiers","subjectModifiers","modifiers","modifier"],"sources":["../../../../../../Compiler/Parsing/PropertyLineParser.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 { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { unescapeIdentifier } from './LineText';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst propertyPattern = pattern('^(@?[a-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)(?:\\\\s+(generated))?(?:\\\\s+(identifier))?(?:\\\\s+(subject))?(?:\\\\s+(key))?$');\nconst invalidGeneratedModifiers = pattern('^@?[a-z_]\\\\w*\\\\s+[\\\\w.]+(?:\\\\[\\\\])?\\\\??\\\\s+((?:optional|generated|identifier|subject|key)(?:\\\\s+(?:optional|generated|identifier|subject|key))*)$');\nconst reversedModifiers = pattern('^@?[a-z_]\\\\w*\\\\s+[\\\\w.]+(?:\\\\[\\\\])?\\\\s+identifier\\\\s+optional(?:\\\\s*=.*)?$');\n\n// A '<name> <Type>[[]][?] [identifier]' line, or undefined when the line does not have that shape.\nexport function tryParseProperty(line: SourceLine): PropertySyntax | undefined {\n const match = propertyPattern.exec(line.content);\n if (match === null) {\n return undefined;\n }\n const location = locationOf(line);\n return {\n kind: 'PropertySyntax',\n name: unescapeIdentifier(match[1]),\n type: parseTypeRef(match[2], { ...location, column: location.column + line.content.indexOf(match[2], match[1].length) }),\n isGenerated: match[3] !== undefined,\n nameWasEscaped: match[1].startsWith('@'),\n isIdentifier: match[4] !== undefined,\n ...(match[5] !== undefined ? { isSubject: true } : {}),\n ...(match[6] !== undefined ? { isKey: true } : {}),\n location,\n };\n}\n\nexport function parseTypeRef(text: string, location: SourceLocation): TypeRefSyntax {\n const legacy = text.endsWith('?');\n const canonical = /\\soptional$/.test(text);\n const isOptional = legacy || canonical;\n if (isOptional) {\n text = text.substring(0, text.length - (legacy ? 1 : 'optional'.length)).trimEnd();\n }\n const isCollection = text.endsWith('[]');\n if (isCollection) {\n text = text.substring(0, text.length - 2);\n }\n return { kind: 'TypeRefSyntax', name: text, isCollection, isOptional, location };\n}\n\n// Unlike tryParseProperty, this is only called once the owner commits to a property position.\nexport function parseProperty(context: ParserContext, line: SourceLine): PropertySyntax | undefined {\n const property = tryParseProperty(line);\n if (property !== undefined) {\n reportLegacyOptionalSuffix(context, property.type, line);\n if (property.isKey && (property.type.isOptional || property.type.isCollection || property.isGenerated || property.isIdentifier || property.isSubject)) {\n context.error(DiagnosticCodes.InvalidReadModelKey, 'A read-model key part must be required, not a collection, and cannot combine key with generated, identifier or subject.', locationOf(line));\n }\n } else {\n reportInvalidModifierOrder(context, line);\n }\n return property;\n}\n\nexport function reportLegacyOptionalSuffix(context: ParserContext, type: TypeRefSyntax, line: SourceLine): void {\n context.claimField(line);\n const length = type.name.length + (type.isCollection ? 2 : 0);\n const offset = type.location.column - line.indent - 1 + length;\n if (type.isOptional && line.content[offset] === '?') {\n const name = type.name + (type.isCollection ? '[]' : '');\n context.information(DiagnosticCodes.LegacyOptionalSuffix, `Write '${name} optional' instead of '${name}?'.`, type.location);\n }\n}\n\nexport function reportInvalidModifierOrder(context: ParserContext, line: SourceLine): boolean {\n const keyModifiers = invalidGeneratedModifiers.exec(line.content);\n if (keyModifiers !== null && keyModifiers[1].split(/\\s+/).includes('key')) {\n context.error(DiagnosticCodes.InvalidReadModelKey, \"Write 'key' once, without other modifiers: '<name> <Type> key'.\", locationOf(line));\n return true;\n }\n const subjectModifiers = invalidGeneratedModifiers.exec(line.content);\n if (subjectModifiers !== null && subjectModifiers[1].split(/\\s+/).includes('subject')) {\n context.error(DiagnosticCodes.InvalidSubjectModifierOrder, \"Write each modifier once in order: '<name> <Type> optional generated identifier subject'.\", locationOf(line));\n return true;\n }\n if (reversedModifiers.test(line.content)) {\n context.error(DiagnosticCodes.InvalidOptionalModifierOrder, \"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.\", locationOf(line));\n return true;\n } else {\n const modifiers = invalidGeneratedModifiers.exec(line.content);\n if (modifiers !== null && modifiers[1].split(/\\s+/).some(modifier => modifier === 'generated' || modifier === 'identifier')) {\n context.error(DiagnosticCodes.InvalidGeneratedModifierOrder, \"Write each modifier once in order: '<name> <Type> optional generated identifier'.\", locationOf(line));\n return true;\n }\n }\n return false;\n}\n"],"mappings":"uQAWA,MAAMA,EAAkBC,EAAQ,wIAAwI,EAClKC,EAA4BD,EAAQ,mJAAmJ,EACvLE,EAAoBF,EAAQ,4EAA4E,EAG9G,SAAgB,iBAAiB,EAA8C,CAC3E,IAAMG,EAAQJ,EAAgB,KAAKK,EAAK,OAAO,EAC/C,GAAID,IAAU,KACV,OAEJ,IAAME,EAAWC,EAAWF,CAAI,EAChC,MAAO,CACH,KAAM,iBACN,KAAMG,EAAmBJ,EAAM,EAAE,EACjC,KAAM,aAAaA,EAAM,GAAI,CAAE,GAAGE,EAAU,OAAQA,EAAS,OAASD,EAAK,QAAQ,QAAQD,EAAM,GAAIA,EAAM,EAAE,CAAC,MAAM,CAAE,CAAC,EACvH,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AAK,MAAQA,EAAK,aAAe,KAAO,IACrDH,EAAQ,YAAYC,EAAgB,qBAAsB,UAAUI,EAAK,yBAAyBA,EAAK,KAAMF,EAAK,QAAQ,CAC9H,CACJ,CAEA,SAAgB,2BAA2B,EAAwB,EAA2B,CAC1F,IAAMG,EAAenB,EAA0B,KAAKG,EAAK,OAAO,EAChE,GAAIgB,IAAiB,MAAQA,EAAa,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,SAAS,KAAK,EAEpE,OADAN,EAAQ,MAAMC,EAAgB,oBAAqB,kEAAmET,EAAWF,CAAI,CAAC,EAC/H,GAEX,IAAMiB,EAAmBpB,EAA0B,KAAKG,EAAK,OAAO,EACpE,GAAIiB,IAAqB,MAAQA,EAAiB,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,SAAS,SAAS,EAEhF,OADAP,EAAQ,MAAMC,EAAgB,4BAA6B,4FAA6FT,EAAWF,CAAI,CAAC,EACjK,GAEX,GAAIF,EAAkB,KAAKE,EAAK,OAAO,EAEnC,OADAU,EAAQ,MAAMC,EAAgB,6BAA8B,6EAA8ET,EAAWF,CAAI,CAAC,EACnJ,GACJ,CACH,IAAMkB,EAAYrB,EAA0B,KAAKG,EAAK,OAAO,EAC7D,GAAIkB,IAAc,MAAQA,EAAU,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,KAAK,GAAYC,IAAa,aAAeA,IAAa,YAAY,EAEtH,OADAT,EAAQ,MAAMC,EAAgB,8BAA+B,oFAAqFT,EAAWF,CAAI,CAAC,EAC3J,EAEf,CACA,MAAO,EACX"}
1
+ {"version":3,"file":"PropertyLineParser.js","names":["propertyPattern","pattern","invalidGeneratedModifiers","reversedModifiers","match","line","location","locationOf","unescapeIdentifier","legacy","text","canonical","isOptional","isCollection","property","context","DiagnosticCodes","length","type","offset","name","keyModifiers","subjectModifiers","modifiers","modifier"],"sources":["../../../../../../Compiler/Parsing/PropertyLineParser.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 { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { unescapeIdentifier } from './LineText';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst propertyPattern = pattern('^(@?[a-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)(?:\\\\s+(generated))?(?:\\\\s+(identifier))?(?:\\\\s+(subject))?(?:\\\\s+(key))?$');\nconst invalidGeneratedModifiers = pattern('^@?[a-z_]\\\\w*\\\\s+[\\\\w.]+(?:\\\\[\\\\])?\\\\??\\\\s+((?:optional|generated|identifier|subject|key)(?:\\\\s+(?:optional|generated|identifier|subject|key))*)$');\nconst reversedModifiers = pattern('^@?[a-z_]\\\\w*\\\\s+[\\\\w.]+(?:\\\\[\\\\])?\\\\s+identifier\\\\s+optional(?:\\\\s*=.*)?$');\n\n// A '<name> <Type>[[]][?] [identifier]' line, or undefined when the line does not have that shape.\nexport function tryParseProperty(line: SourceLine): PropertySyntax | undefined {\n const match = propertyPattern.exec(line.content);\n if (match === null) {\n return undefined;\n }\n const location = locationOf(line);\n return {\n kind: 'PropertySyntax',\n name: unescapeIdentifier(match[1]),\n type: parseTypeRef(match[2], { ...location, column: location.column + line.content.indexOf(match[2], match[1].length) }),\n isGenerated: match[3] !== undefined,\n nameWasEscaped: match[1].startsWith('@'),\n isIdentifier: match[4] !== undefined,\n ...(match[5] !== undefined ? { isSubject: true } : {}),\n ...(match[6] !== undefined ? { isKey: true } : {}),\n location,\n };\n}\n\nexport function parseTypeRef(text: string, location: SourceLocation): TypeRefSyntax {\n const legacy = text.endsWith('?');\n const canonical = /\\soptional$/.test(text);\n const isOptional = legacy || canonical;\n if (isOptional) {\n text = text.substring(0, text.length - (legacy ? 1 : 'optional'.length)).trimEnd();\n }\n const isCollection = text.endsWith('[]');\n if (isCollection) {\n text = text.substring(0, text.length - 2);\n }\n return { kind: 'TypeRefSyntax', name: text, isCollection, isOptional, location };\n}\n\n// Unlike tryParseProperty, this is only called once the owner commits to a property position.\nexport function parseProperty(context: ParserContext, line: SourceLine): PropertySyntax | undefined {\n const property = tryParseProperty(line);\n if (property !== undefined) {\n reportLegacyOptionalSuffix(context, property.type, line);\n if (property.isKey && (property.type.isOptional || property.type.isCollection || property.isGenerated || property.isIdentifier || property.isSubject)) {\n context.error(DiagnosticCodes.InvalidReadModelKey, 'A read-model key part must be required, not a collection, and cannot combine key with generated, identifier or subject.', locationOf(line));\n }\n } else {\n reportInvalidModifierOrder(context, line);\n }\n return property;\n}\n\nexport function reportLegacyOptionalSuffix(context: ParserContext, type: TypeRefSyntax, line: SourceLine): void {\n context.claimField(line);\n const length = type.name.length + (type.isCollection ? 2 : 0);\n const offset = type.location.column - line.indent - 1 + length;\n if (type.isOptional && line.content[offset] === '?') {\n const name = type.name + (type.isCollection ? '[]' : '');\n context.information(DiagnosticCodes.LegacyOptionalSuffix, `Write '${name} optional' instead of '${name}?'.`, type.location);\n }\n}\n\nexport function reportInvalidModifierOrder(context: ParserContext, line: SourceLine): boolean {\n const keyModifiers = invalidGeneratedModifiers.exec(line.content);\n if (keyModifiers !== null && keyModifiers[1].split(/\\s+/).includes('key')) {\n context.error(DiagnosticCodes.InvalidReadModelKey, \"Write 'key' once, without other modifiers: '<name> <Type> key'.\", locationOf(line));\n return true;\n }\n const subjectModifiers = invalidGeneratedModifiers.exec(line.content);\n if (subjectModifiers !== null && subjectModifiers[1].split(/\\s+/).includes('subject')) {\n context.error(DiagnosticCodes.InvalidSubjectModifierOrder, \"Write each modifier once in order: '<name> <Type> optional generated identifier subject'.\", locationOf(line));\n return true;\n }\n if (reversedModifiers.test(line.content)) {\n context.error(DiagnosticCodes.InvalidOptionalModifierOrder, \"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.\", locationOf(line));\n return true;\n } else {\n const modifiers = invalidGeneratedModifiers.exec(line.content);\n if (modifiers !== null && modifiers[1].split(/\\s+/).some(modifier => modifier === 'generated' || modifier === 'identifier')) {\n context.error(DiagnosticCodes.InvalidGeneratedModifierOrder, \"Write each modifier once in order: '<name> <Type> optional generated identifier'.\", locationOf(line));\n return true;\n }\n }\n return false;\n}\n"],"mappings":"A,uQAWA,MAAMA,EAAkBC,EAAQ,wIAAwI,EAClKC,EAA4BD,EAAQ,mJAAmJ,EACvLE,EAAoBF,EAAQ,4EAA4E,EAG9G,SAAgB,iBAAiB,EAA8C,CAC3E,IAAMG,EAAQJ,EAAgB,KAAKK,EAAK,OAAO,EAC/C,GAAID,IAAU,KACV,OAEJ,IAAME,EAAWC,EAAWF,CAAI,EAChC,MAAO,CACH,KAAM,iBACN,KAAMG,EAAmBJ,EAAM,EAAE,EACjC,KAAM,aAAaA,EAAM,GAAI,CAAE,GAAGE,EAAU,OAAQA,EAAS,OAASD,EAAK,QAAQ,QAAQD,EAAM,GAAIA,EAAM,EAAE,CAAC,MAAM,CAAE,CAAC,EACvH,YAAaA,EAAM,KAAO,IAAA,GAC1B,eAAgBA,EAAM,EAAE,CAAC,WAAW,GAAG,EACvC,aAAcA,EAAM,KAAO,IAAA,GAC3B,GAAIA,EAAM,KAAO,IAAA,GAAkC,CAAC,EAAvB,CAAE,UAAW,EAAK,EAC/C,GAAIA,EAAM,KAAO,IAAA,GAA8B,CAAC,EAAnB,CAAE,MAAO,EAAK,EAC3C,UACJ,CACJ,CAEA,SAAgB,aAAa,EAAc,EAAyC,CAChF,IAAMK,EAASC,EAAK,SAAS,GAAG,EAC1BC,EAAY,cAAc,KAAKD,CAAI,EACnCE,EAAaH,GAAUE,EACzBC,IACA,EAAOF,EAAK,UAAU,EAAGA,EAAK,QAAUD,EAAS,EAAI,EAAkB,CAAC,CAAC,QAAQ,GAErF,IAAMI,EAAeH,EAAK,SAAS,IAAI,EAIvC,OAHI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