@cratis/screenplay-language 5.3.0 → 5.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/dist/bundles/TypeReferenceSymbol.js.map +1 -1
  2. package/dist/bundles/action-subject-authoring.js.map +1 -1
  3. package/dist/bundles/bmp-word-characters.js.map +1 -1
  4. package/dist/bundles/case-authoring.js +1 -1
  5. package/dist/bundles/case-authoring.js.map +1 -1
  6. package/dist/bundles/code-actions.js.map +1 -1
  7. package/dist/bundles/command-read-completions.js.map +1 -1
  8. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js +3 -3
  9. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js.map +1 -1
  10. package/dist/bundles/compiler/Authoring/QuickFixes.js +4 -4
  11. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
  12. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js +1 -1
  13. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js.map +1 -1
  14. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js +4 -4
  15. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js.map +1 -1
  16. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js +2 -2
  17. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js.map +1 -1
  18. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js +1 -1
  19. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js.map +1 -1
  20. package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js.map +1 -1
  21. package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js.map +1 -1
  22. package/dist/bundles/compiler/Dependencies/DependencyGraph.js +1 -1
  23. package/dist/bundles/compiler/Dependencies/DependencyGraph.js.map +1 -1
  24. package/dist/bundles/compiler/Dependencies/DependencyKind.js.map +1 -1
  25. package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js.map +1 -1
  26. package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
  27. package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js.map +1 -1
  28. package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js.map +1 -1
  29. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  30. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  31. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js +1 -1
  32. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js.map +1 -1
  33. package/dist/bundles/compiler/Diagnostics/SourceLocation.js.map +1 -1
  34. package/dist/bundles/compiler/Files/AuthoredOrder.js +1 -1
  35. package/dist/bundles/compiler/Files/AuthoredOrder.js.map +1 -1
  36. package/dist/bundles/compiler/Files/OrderingRoot.js +1 -1
  37. package/dist/bundles/compiler/Files/OrderingRoot.js.map +1 -1
  38. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js +1 -1
  39. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js.map +1 -1
  40. package/dist/bundles/compiler/Files/PlayDocumentSource.js.map +1 -1
  41. package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
  42. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
  43. package/dist/bundles/compiler/Files/PlayGlob.js +2 -1
  44. package/dist/bundles/compiler/Files/PlayGlob.js.map +1 -1
  45. package/dist/bundles/compiler/Files/PlayImports.js +1 -1
  46. package/dist/bundles/compiler/Files/PlayImports.js.map +1 -1
  47. package/dist/bundles/compiler/Files/PlayPlacement.js.map +1 -1
  48. package/dist/bundles/compiler/Files/TimelineOrder.js +1 -1
  49. package/dist/bundles/compiler/Files/TimelineOrder.js.map +1 -1
  50. package/dist/bundles/compiler/Generation/FiniteGenerationRules.js +1 -1
  51. package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js.map +1 -1
  52. package/dist/bundles/compiler/Generation/GenerationChecksum.js.map +1 -1
  53. package/dist/bundles/compiler/Generation/GenerationPattern.js +1 -1
  54. package/dist/bundles/compiler/Generation/GenerationPattern.js.map +1 -1
  55. package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js.map +1 -1
  56. package/dist/bundles/compiler/Generation/GenerationPatternParser.js.map +1 -1
  57. package/dist/bundles/compiler/Generation/GenerationPatternToken.js.map +1 -1
  58. package/dist/bundles/compiler/Generation/GenerationRuleProof.js +1 -1
  59. package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js.map +1 -1
  60. package/dist/bundles/compiler/Generation/RegexCharacters.js.map +1 -1
  61. package/dist/bundles/compiler/Generation/RegexExpression.js.map +1 -1
  62. package/dist/bundles/compiler/Generation/RuleConsistency.js +1 -1
  63. package/dist/bundles/compiler/Parsing/ActionSubjectClause.js.map +1 -1
  64. package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js.map +1 -1
  65. package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js.map +1 -1
  66. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js +1 -1
  67. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js.map +1 -1
  68. package/dist/bundles/compiler/Parsing/AuthorizeParser.js +1 -1
  69. package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -1
  70. package/dist/bundles/compiler/Parsing/CanvasPlacement.js.map +1 -1
  71. package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js.map +1 -1
  72. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  73. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
  74. package/dist/bundles/compiler/Parsing/ClockOperandParser.js.map +1 -1
  75. package/dist/bundles/compiler/Parsing/CodeBlockParser.js.map +1 -1
  76. package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js.map +1 -1
  77. package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js.map +1 -1
  78. package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
  79. package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
  80. package/dist/bundles/compiler/Parsing/CommandReadSources.js.map +1 -1
  81. package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
  82. package/dist/bundles/compiler/Parsing/CommandResponseParser.js.map +1 -1
  83. package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js.map +1 -1
  84. package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js.map +1 -1
  85. package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
  86. package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -1
  87. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
  88. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
  89. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js +2 -0
  90. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js.map +1 -0
  91. package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
  92. package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -1
  93. package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
  94. package/dist/bundles/compiler/Parsing/ConstraintParser.js.map +1 -1
  95. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js +1 -1
  96. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js.map +1 -1
  97. package/dist/bundles/compiler/Parsing/ContinuationValues.js.map +1 -1
  98. package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
  99. package/dist/bundles/compiler/Parsing/DeclarationParsers.js.map +1 -1
  100. package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
  101. package/dist/bundles/compiler/Parsing/DependencySourceParser.js.map +1 -1
  102. package/dist/bundles/compiler/Parsing/DependsOnParser.js.map +1 -1
  103. package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
  104. package/dist/bundles/compiler/Parsing/DescriptionParser.js.map +1 -1
  105. package/dist/bundles/compiler/Parsing/DocumentationParser.js +1 -1
  106. package/dist/bundles/compiler/Parsing/DocumentationParser.js.map +1 -1
  107. package/dist/bundles/compiler/Parsing/EnumerationMembers.js +1 -1
  108. package/dist/bundles/compiler/Parsing/EnumerationMembers.js.map +1 -1
  109. package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
  110. package/dist/bundles/compiler/Parsing/EventMetadataParser.js.map +1 -1
  111. package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
  112. package/dist/bundles/compiler/Parsing/EventSourceParser.js.map +1 -1
  113. package/dist/bundles/compiler/Parsing/EventSourceValidator.js +1 -1
  114. package/dist/bundles/compiler/Parsing/EventSourceValidator.js.map +1 -1
  115. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js +1 -1
  116. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js.map +1 -1
  117. package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
  118. package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -1
  119. package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
  120. package/dist/bundles/compiler/Parsing/FeatureBody.js.map +1 -1
  121. package/dist/bundles/compiler/Parsing/FileImportParser.js.map +1 -1
  122. package/dist/bundles/compiler/Parsing/FileReferences.js.map +1 -1
  123. package/dist/bundles/compiler/Parsing/FoldedEventSources.js.map +1 -1
  124. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js +1 -1
  125. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js.map +1 -1
  126. package/dist/bundles/compiler/Parsing/GenerationParser.js +1 -1
  127. package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -1
  128. package/dist/bundles/compiler/Parsing/GuardedActionInputs.js.map +1 -1
  129. package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
  130. package/dist/bundles/compiler/Parsing/GuardedActionParser.js.map +1 -1
  131. package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js.map +1 -1
  132. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +1 -1
  133. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -1
  134. package/dist/bundles/compiler/Parsing/GuardedInteractions.js +1 -1
  135. package/dist/bundles/compiler/Parsing/GuardedInteractions.js.map +1 -1
  136. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js +1 -1
  137. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js.map +1 -1
  138. package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
  139. package/dist/bundles/compiler/Parsing/IdentityParser.js.map +1 -1
  140. package/dist/bundles/compiler/Parsing/IdentityValidator.js.map +1 -1
  141. package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
  142. package/dist/bundles/compiler/Parsing/ImplementationParser.js.map +1 -1
  143. package/dist/bundles/compiler/Parsing/ImportDiscovery.js +1 -1
  144. package/dist/bundles/compiler/Parsing/ImportDiscovery.js.map +1 -1
  145. package/dist/bundles/compiler/Parsing/InlineEventValidator.js.map +1 -1
  146. package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
  147. package/dist/bundles/compiler/Parsing/InputUses.js.map +1 -1
  148. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
  149. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js.map +1 -1
  150. package/dist/bundles/compiler/Parsing/InteractionExecutions.js +1 -1
  151. package/dist/bundles/compiler/Parsing/InteractionExecutions.js.map +1 -1
  152. package/dist/bundles/compiler/Parsing/LegacyTextRulePatterns.js.map +1 -1
  153. package/dist/bundles/compiler/Parsing/LineReader.js.map +1 -1
  154. package/dist/bundles/compiler/Parsing/LineText.js.map +1 -1
  155. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js +1 -1
  156. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js.map +1 -1
  157. package/dist/bundles/compiler/Parsing/MatchAmbiguityCharacters.js.map +1 -1
  158. package/dist/bundles/compiler/Parsing/MatchAmbiguityGraph.js.map +1 -1
  159. package/dist/bundles/compiler/Parsing/MatchAmbiguityParser.js.map +1 -1
  160. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js +1 -1
  161. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js.map +1 -1
  162. package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
  163. package/dist/bundles/compiler/Parsing/ModuleBody.js.map +1 -1
  164. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js +1 -1
  165. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js.map +1 -1
  166. package/dist/bundles/compiler/Parsing/ObserverFilterValidator.js.map +1 -1
  167. package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
  168. package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -1
  169. package/dist/bundles/compiler/Parsing/OperationValidator.js +1 -1
  170. package/dist/bundles/compiler/Parsing/OperationValidator.js.map +1 -1
  171. package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -1
  172. package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js.map +1 -1
  173. package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
  174. package/dist/bundles/compiler/Parsing/PolicyParser.js.map +1 -1
  175. package/dist/bundles/compiler/Parsing/PortableMatchGroupName.js.map +1 -1
  176. package/dist/bundles/compiler/Parsing/PortableMatchPattern.js.map +1 -1
  177. package/dist/bundles/compiler/Parsing/PortableMatchSuggestions.js.map +1 -1
  178. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js +1 -1
  179. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js.map +1 -1
  180. package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
  181. package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
  182. package/dist/bundles/compiler/Parsing/ProjectionEventScopeValidator.js.map +1 -1
  183. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js +1 -1
  184. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js.map +1 -1
  185. package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
  186. package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
  187. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +1 -1
  188. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -1
  189. package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
  190. package/dist/bundles/compiler/Parsing/PropertyLineParser.js.map +1 -1
  191. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js +1 -1
  192. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js.map +1 -1
  193. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js +1 -1
  194. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js.map +1 -1
  195. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +1 -1
  196. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -1
  197. package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
  198. package/dist/bundles/compiler/Parsing/PurposeParser.js.map +1 -1
  199. package/dist/bundles/compiler/Parsing/PurposeValidator.js.map +1 -1
  200. package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
  201. package/dist/bundles/compiler/Parsing/QueryParser.js.map +1 -1
  202. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
  203. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js.map +1 -1
  204. package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
  205. package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
  206. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js +1 -1
  207. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js.map +1 -1
  208. package/dist/bundles/compiler/Parsing/ReadModelKeyValidator.js.map +1 -1
  209. package/dist/bundles/compiler/Parsing/ReadModelMemberTypeValidator.js.map +1 -1
  210. package/dist/bundles/compiler/Parsing/ReadsParser.js +1 -1
  211. package/dist/bundles/compiler/Parsing/ReadsParser.js.map +1 -1
  212. package/dist/bundles/compiler/Parsing/RedeliveryValues.js.map +1 -1
  213. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js +1 -1
  214. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js.map +1 -1
  215. package/dist/bundles/compiler/Parsing/RefusalValueWalker.js.map +1 -1
  216. package/dist/bundles/compiler/Parsing/ResponseCommandResolver.js.map +1 -1
  217. package/dist/bundles/compiler/Parsing/ResponseDateValues.js.map +1 -1
  218. package/dist/bundles/compiler/Parsing/ResponseValidator.js +1 -1
  219. package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -1
  220. package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
  221. package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
  222. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  223. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  224. package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
  225. package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -1
  226. package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
  227. package/dist/bundles/compiler/Parsing/SliceParser.js.map +1 -1
  228. package/dist/bundles/compiler/Parsing/SourceLine.js.map +1 -1
  229. package/dist/bundles/compiler/Parsing/SourceLineSplitter.js.map +1 -1
  230. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
  231. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js.map +1 -1
  232. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
  233. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
  234. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
  235. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
  236. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +1 -1
  237. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -1
  238. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
  239. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
  240. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  241. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
  242. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js +1 -1
  243. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js.map +1 -1
  244. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
  245. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
  246. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js +1 -1
  247. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js.map +1 -1
  248. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +1 -1
  249. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -1
  250. package/dist/bundles/compiler/Parsing/StateMachineParser.js +1 -1
  251. package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -1
  252. package/dist/bundles/compiler/Parsing/StructuralInteractionSites.js.map +1 -1
  253. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js +1 -1
  254. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js.map +1 -1
  255. package/dist/bundles/compiler/Parsing/StructuredValueParser.js.map +1 -1
  256. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js +1 -1
  257. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js.map +1 -1
  258. package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
  259. package/dist/bundles/compiler/Parsing/TriggerDataParser.js.map +1 -1
  260. package/dist/bundles/compiler/Parsing/UiBindingParser.js +1 -1
  261. package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -1
  262. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js +1 -1
  263. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js.map +1 -1
  264. package/dist/bundles/compiler/Parsing/WorkflowParser.js +1 -1
  265. package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -1
  266. package/dist/bundles/compiler/Parsing/checkPortableMatchPattern.js.map +1 -1
  267. package/dist/bundles/compiler/Parsing/hasExponentialMatchAmbiguity.js.map +1 -1
  268. package/dist/bundles/compiler/Parsing/trimMatchAmbiguityGraph.js.map +1 -1
  269. package/dist/bundles/compiler/ScreenActionSubjects.js.map +1 -1
  270. package/dist/bundles/compiler/ScreenplayCompiler.js +1 -1
  271. package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -1
  272. package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js.map +1 -1
  273. package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js.map +1 -1
  274. package/dist/bundles/compiler/Syntax/CaptureEventsSource.js.map +1 -1
  275. package/dist/bundles/compiler/Syntax/DependencySources.js.map +1 -1
  276. package/dist/bundles/compiler/Syntax/EventDeclarations.js.map +1 -1
  277. package/dist/bundles/compiler/Syntax/EventSourceCatalog.js.map +1 -1
  278. package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js.map +1 -1
  279. package/dist/bundles/compiler/Syntax/ExactMathFacts.js.map +1 -1
  280. package/dist/bundles/compiler/Syntax/ExactNumber.js.map +1 -1
  281. package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js.map +1 -1
  282. package/dist/bundles/compiler/Syntax/LegacyWireProjection.js.map +1 -1
  283. package/dist/bundles/compiler/Syntax/Operations.js.map +1 -1
  284. package/dist/bundles/compiler/Syntax/PersonaCallers.js.map +1 -1
  285. package/dist/bundles/compiler/Syntax/ProductionDestinations.js.map +1 -1
  286. package/dist/bundles/compiler/Syntax/PublicEventInvariants.js.map +1 -1
  287. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  288. package/dist/bundles/compiler/Syntax/SourceOptions.js.map +1 -1
  289. package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js.map +1 -1
  290. package/dist/bundles/compiler/Syntax/StreamIdFormatter.js.map +1 -1
  291. package/dist/bundles/compiler/Syntax/StrictSyntaxJson.js +1 -1
  292. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
  293. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  294. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
  295. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
  296. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  297. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  298. package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js.map +1 -1
  299. package/dist/bundles/compiler/Syntax/index.js +1 -1
  300. package/dist/bundles/compiler/Text/ImplementationHintText.js.map +1 -1
  301. package/dist/bundles/compiler/Text/ReservedWords.js.map +1 -1
  302. package/dist/bundles/compiler/Text/SourceStreamNames.js.map +1 -1
  303. package/dist/bundles/compiler/Text/StringLiteral.js.map +1 -1
  304. package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js.map +1 -1
  305. package/dist/bundles/compiler/Text/patterns.js.map +1 -1
  306. package/dist/bundles/compiler/index.js +1 -1
  307. package/dist/bundles/completion-items.js +4 -4
  308. package/dist/bundles/completion-items.js.map +1 -1
  309. package/dist/bundles/completion-planner.js +2 -2
  310. package/dist/bundles/completion-planner.js.map +1 -1
  311. package/dist/bundles/completions.js +1 -1
  312. package/dist/bundles/completions.js.map +1 -1
  313. package/dist/bundles/continuation-responses.js +1 -1
  314. package/dist/bundles/continuation-responses.js.map +1 -1
  315. package/dist/bundles/declarations.js.map +1 -1
  316. package/dist/bundles/dependency-completions.js.map +1 -1
  317. package/dist/bundles/dependency-target-analysis.js.map +1 -1
  318. package/dist/bundles/diagnostic-codes.js +1 -1
  319. package/dist/bundles/diagnostic-codes.js.map +1 -1
  320. package/dist/bundles/diagnostics.js +1 -1
  321. package/dist/bundles/diagnostics.js.map +1 -1
  322. package/dist/bundles/document-context.js.map +1 -1
  323. package/dist/bundles/documentation-item.js.map +1 -1
  324. package/dist/bundles/event-analysis-source.js.map +1 -1
  325. package/dist/bundles/event-context-catalog.js.map +1 -1
  326. package/dist/bundles/event-context.js.map +1 -1
  327. package/dist/bundles/event-source-authoring.js +11 -11
  328. package/dist/bundles/event-source-authoring.js.map +1 -1
  329. package/dist/bundles/example-analysis.js +2 -2
  330. package/dist/bundles/example-analysis.js.map +1 -1
  331. package/dist/bundles/example-authoring.js +2 -2
  332. package/dist/bundles/example-authoring.js.map +1 -1
  333. package/dist/bundles/example-declaration-items.js.map +1 -1
  334. package/dist/bundles/example-values.js.map +1 -1
  335. package/dist/bundles/file-imports.js.map +1 -1
  336. package/dist/bundles/file-references.js.map +1 -1
  337. package/dist/bundles/generation-completions.js.map +1 -1
  338. package/dist/bundles/hover-content.js +5 -5
  339. package/dist/bundles/hover-content.js.map +1 -1
  340. package/dist/bundles/hover.js.map +1 -1
  341. package/dist/bundles/index.js +1 -1
  342. package/dist/bundles/index.js.map +1 -1
  343. package/dist/bundles/inlay-hints.js.map +1 -1
  344. package/dist/bundles/inline-completions.js +1 -1
  345. package/dist/bundles/inline-completions.js.map +1 -1
  346. package/dist/bundles/inline-event-validation.js +1 -1
  347. package/dist/bundles/inline-event-validation.js.map +1 -1
  348. package/dist/bundles/keyword-docs.js.map +1 -1
  349. package/dist/bundles/language.js.map +1 -1
  350. package/dist/bundles/named-rule-context.js.map +1 -1
  351. package/dist/bundles/operation-authoring.js +6 -6
  352. package/dist/bundles/operation-authoring.js.map +1 -1
  353. package/dist/bundles/persona-analysis.js +1 -1
  354. package/dist/bundles/persona-analysis.js.map +1 -1
  355. package/dist/bundles/production-destinations.js +1 -1
  356. package/dist/bundles/production-destinations.js.map +1 -1
  357. package/dist/bundles/purpose-items.js.map +1 -1
  358. package/dist/bundles/reaction-authoring.js +3 -3
  359. package/dist/bundles/reaction-authoring.js.map +1 -1
  360. package/dist/bundles/read-model-key-completions.js +1 -1
  361. package/dist/bundles/read-model-key-completions.js.map +1 -1
  362. package/dist/bundles/refusal-context.js.map +1 -1
  363. package/dist/bundles/response-analysis.js.map +1 -1
  364. package/dist/bundles/response-completions.js +1 -1
  365. package/dist/bundles/response-completions.js.map +1 -1
  366. package/dist/bundles/response-tokens.js +2 -2
  367. package/dist/bundles/response-tokens.js.map +1 -1
  368. package/dist/bundles/scope-items.js +3 -3
  369. package/dist/bundles/scope-items.js.map +1 -1
  370. package/dist/bundles/structure-completions.js.map +1 -1
  371. package/dist/bundles/sub-language-registry.js.map +1 -1
  372. package/dist/bundles/sub-languages/capture/CompletionProvider.js.map +1 -1
  373. package/dist/bundles/sub-languages/capture/HoverProvider.js.map +1 -1
  374. package/dist/bundles/sub-languages/capture/Validator.js.map +1 -1
  375. package/dist/bundles/sub-languages/capture/index.js.map +1 -1
  376. package/dist/bundles/sub-languages/capture/language.js.map +1 -1
  377. package/dist/bundles/sub-languages/cdl.js.map +1 -1
  378. package/dist/bundles/sub-languages/pdl.js.map +1 -1
  379. package/dist/bundles/sub-languages/projection/CodeActionProvider.js.map +1 -1
  380. package/dist/bundles/sub-languages/projection/CompletionProvider.js +1 -1
  381. package/dist/bundles/sub-languages/projection/CompletionProvider.js.map +1 -1
  382. package/dist/bundles/sub-languages/projection/HoverProvider.js.map +1 -1
  383. package/dist/bundles/sub-languages/projection/Validator.js.map +1 -1
  384. package/dist/bundles/sub-languages/projection/index.js.map +1 -1
  385. package/dist/bundles/sub-languages/projection/language.js.map +1 -1
  386. package/dist/bundles/symbols.js +2 -2
  387. package/dist/bundles/symbols.js.map +1 -1
  388. package/dist/bundles/themes/screenplay-dark.js.map +1 -1
  389. package/dist/bundles/themes/screenplay-light.js.map +1 -1
  390. package/dist/bundles/tokens.js.map +1 -1
  391. package/dist/bundles/validation.js +2 -2
  392. package/dist/bundles/validation.js.map +1 -1
  393. package/dist/diagnostic-codes.d.ts +1 -0
  394. package/dist/diagnostic-codes.d.ts.map +1 -1
  395. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"OperationValidator.js","names":["resolver","AuthoringProductionResolver","application","effectiveCommand","specificationCommandExamples","concepts","uniqueByName","composites","name","type","known","imported","entry","imports","byName","cache","entries","named","key","reference","from","segments","qualifiers","index","value","depth","visible","matches","result","view","slice","node","resolveCommand","command","systems","system","context","DiagnosticCodes","nested","path","properties","property","next","resolved","inheritOptionality","mappings","supplied","seen","item","member","names","allNames","mapping","suppliedPaths","target","operation","targetSegments","reads","commandReadSources","read","resolvedView","scope","source","compatibleValue","required","input","operations","operationDeclarations","eventDeclarations","event","production","resolution","reaction","trigger","specification","steps","duplicates","step","kinds","produced"],"sources":["../../../../../../Compiler/Parsing/OperationValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { AuthoringProductionKind, AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { CommandSyntax } from '../Syntax/Commands';\nimport { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { operationDeclarations, OperationSyntax } from '../Syntax/Operations';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { commandReadSources } from './CommandReadSources';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\nimport { specificationCommandExamples } from './SpecificationCommandExamples';\n\nexport function validateOperations(application: ApplicationSyntax, context: ParserContext): void {\n const resolver = new AuthoringProductionResolver(application);\n const effectiveCommand = specificationCommandExamples(application);\n const concepts = uniqueByName(application.concepts);\n const composites = new Map([...uniqueByName(application.types)].map(([name, type]) => [name, uniqueByName(type.properties)]));\n const known = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...concepts.keys(), ...composites.keys()]);\n const imported = new Set(application.imports.map(entry => entry.qualifiedName.split('.').at(-1)!));\n const imports = new Map<string, string[]>();\n for (const entry of application.imports) {\n const name = entry.qualifiedName.split('.').at(-1)!;\n imports.set(name, [...imports.get(name) ?? [], entry.qualifiedName]);\n }\n const scoped = <T>(entries: readonly { name: string; scope: readonly string[]; node: T }[]) => {\n const byName = new Map<string, typeof entries[number][]>();\n const cache = new Map<string, T | null>();\n for (const entry of entries) {\n const named = byName.get(entry.name) ?? [];\n named.push(entry);\n byName.set(entry.name, named);\n }\n return (reference: string, from: readonly string[]): T | null => {\n const key = JSON.stringify([reference, from]);\n if (cache.has(key)) return cache.get(key)!;\n const candidates = (name: string) => {\n const segments = name.split('.');\n const named = byName.get(segments.at(-1)!) ?? [];\n const qualifiers = segments.slice(0, -1);\n if (qualifiers.length > 0) return named.filter(entry => qualifiers.length <= entry.scope.length && qualifiers.every((value, index) => entry.scope[entry.scope.length - qualifiers.length + index] === value));\n for (let depth = from.length; depth >= 0; depth--) {\n const visible = named.filter(entry => depth <= entry.scope.length && from.slice(0, depth).every((value, index) => entry.scope[index] === value));\n if (visible.length > 0) return visible;\n }\n return [];\n };\n let matches = candidates(reference);\n const imported = imports.get(reference) ?? [];\n if (matches.length === 0 && imported.length === 1) matches = candidates(imported[0]);\n const result = matches.length === 1 ? matches[0].node : null;\n cache.set(key, result);\n return result;\n };\n };\n const view = scoped(resolver.slices.flatMap(({ slice, scope }) => slice.readModels.map(node => ({ name: node.name, scope, node }))));\n const resolveCommand = scoped(resolver.slices.flatMap(({ slice, scope }) => slice.commands.map(command => ({ name: command.name, scope, node: { command, slice } }))));\n const systems = new Map<string, number>();\n for (const system of application.systems ?? []) {\n if (systems.has(system.name)) context.error(DiagnosticCodes.InvalidSystemDeclaration, `System '${system.name}' is declared more than once.`, system.location);\n systems.set(system.name, (systems.get(system.name) ?? 0) + 1);\n }\n const pathType = (properties: readonly PropertySyntax[], path: string, inheritOptionality = true): { type: TypeRefSyntax | null; missing: boolean } => {\n const [name, ...nested] = path.split('.');\n const matches = properties.filter(property => property.name === name);\n if (matches.length !== 1) return { type: null, missing: matches.length === 0 };\n const type = matches[0].type;\n if (nested.length === 0) return { type, missing: false };\n const next = composites.get(type.name);\n if (next === undefined) return { type: null, missing: known.has(type.name) };\n const resolved = pathType([...next.values()], nested.join('.'), inheritOptionality);\n return resolved.type === null ? resolved : { type: { ...resolved.type, isOptional: inheritOptionality && type.isOptional || resolved.type.isOptional, isCollection: type.isCollection || resolved.type.isCollection }, missing: false };\n };\n const covered = (type: TypeRefSyntax, path: string, mappings: ReadonlySet<string>, supplied: ReadonlySet<string>, seen = new Set<string>()): boolean => {\n if (mappings.has(path) || type.isOptional && !supplied.has(path)) return true;\n if (type.isCollection || seen.has(type.name)) return false;\n const properties = composites.get(type.name);\n if (properties === undefined) return supplied.has(path) && !known.has(type.name);\n return [...properties.values()].every(property => covered(property.type, `${path}.${property.name}`, mappings, supplied, new Set([...seen, type.name])));\n };\n const completeValue = (value: PropertyMappingSyntax['source'], type: TypeRefSyntax): boolean => {\n if (value.kind === 'ListExpressionSyntax' && type.isCollection) return value.items.every(item => completeValue(item, { ...type, isCollection: false, isOptional: false }));\n const properties = composites.get(type.name);\n if (value.kind !== 'ObjectExpressionSyntax' || properties === undefined) return true;\n return [...properties.values()].every(property => (property.type.isOptional || value.members.some(member => member.name === property.name)) && value.members.filter(member => member.name === property.name).every(member => completeValue(member.value, property.type)));\n };\n const concrete = (value: PropertyMappingSyntax['source']): boolean => {\n if (value.kind === 'LiteralExpressionSyntax') return typeof value.value !== 'number' || Number.isFinite(value.value);\n if (value.kind === 'ObjectExpressionSyntax') return value.members.every(member => concrete(member.value));\n return value.kind === 'ListExpressionSyntax' && value.items.every(concrete);\n };\n const validateMappings = (mappings: readonly PropertyMappingSyntax[], operation: OperationSyntax, command: CommandSyntax | null, required: boolean, scope: readonly string[]): void => {\n const names = new Set<string>();\n const allNames = new Set(mappings.map(mapping => mapping.property));\n const suppliedPaths = new Set<string>();\n for (const mapping of mappings) {\n const segments = mapping.property.split('.');\n for (let depth = 1; depth <= segments.length; depth++) suppliedPaths.add(segments.slice(0, depth).join('.'));\n }\n for (const mapping of mappings) {\n if (names.has(mapping.property)) context.error(DiagnosticCodes.InvalidOperationMapping, `Duplicate operation input mapping '${mapping.property}'.`, mapping.location);\n names.add(mapping.property);\n const target = pathType(operation.inputs, mapping.property, false);\n if (target.missing) context.error(DiagnosticCodes.InvalidOperationMapping, `Operation '${operation.name}' declares no input '${mapping.property}'.`, mapping.location);\n if (target.type === null) continue;\n const targetSegments = mapping.property.split('.');\n for (let depth = 1; depth < targetSegments.length; depth++) if (allNames.has(targetSegments.slice(0, depth).join('.')))\n context.error(DiagnosticCodes.InvalidOperationMapping, `Operation input mapping '${mapping.property}' overlaps a whole input mapping.`, mapping.location);\n if (command !== null && mapping.source.kind === 'PathExpressionSyntax') {\n let supplied = pathType(command.properties, mapping.source.path);\n const segments = mapping.source.path.split('.');\n const reads = (commandReadSources.get(command) ?? []).filter(read => (read.alias ?? read.readModel) === segments[0]);\n if (supplied.missing && reads.length > 0) {\n supplied = { type: null, missing: false };\n const resolvedView = reads.length === 1 ? view(reads[0].readModel, scope) : null;\n if (segments.length > 1 && resolvedView !== null) supplied = pathType(resolvedView.properties, segments.slice(1).join('.'));\n }\n if (supplied.missing) context.error(DiagnosticCodes.InvalidOperationMapping, `Command '${command.name}' declares no source '${mapping.source.path}'.`, mapping.source.location);\n const source = supplied.type;\n const type = target.type;\n if (source !== null && known.has(source.name) && known.has(type.name) && (source.name !== type.name || source.isCollection !== type.isCollection || source.isOptional && !type.isOptional))\n context.error(DiagnosticCodes.InvalidOperationMapping, `Source '${mapping.source.path}' is incompatible with input '${mapping.property}' of operation '${operation.name}'.`, mapping.source.location);\n } else if (['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(mapping.source.kind)) {\n if (!compatibleValue(mapping.source, target.type, concepts, composites) || required && !completeValue(mapping.source, target.type)) context.error(DiagnosticCodes.InvalidOperationMapping, `Value is incompatible with input '${mapping.property}' of operation '${operation.name}'.`, mapping.source.location);\n }\n }\n if (required) for (const input of operation.inputs) {\n if (!covered(input.type, input.name, names, suppliedPaths)) context.error(DiagnosticCodes.InvalidOperationMapping, `Production of operation '${operation.name}' supplies no value for required input '${input.name}'.`, operation.location);\n }\n };\n for (const { slice, scope } of resolver.slices) {\n const operations = operationDeclarations(slice);\n const names = new Set(eventDeclarations(slice).map(event => event.name));\n for (const operation of operations) {\n if (names.has(operation.name)) context.error(DiagnosticCodes.ProductionDeclarationCollision, `Operation '${operation.name}' collides with another event or operation in slice '${slice.name}'.`, operation.location);\n names.add(operation.name);\n if (operation.uses.length > 0 && systems.get(operation.uses) !== 1) context.error(DiagnosticCodes.InvalidSystemReference, `Operation '${operation.name}' must use one declared system; '${operation.uses}' does not resolve uniquely.`, operation.usesLocation ?? operation.location);\n for (const input of operation.inputs) {\n if (!known.has(input.type.name) && !imported.has(input.type.name)) context.warning(DiagnosticCodes.UnknownType, `Unknown type '${input.type.name}' on input '${input.name}' of operation '${operation.name}'.`, input.type.location);\n }\n }\n for (const command of slice.commands) for (const production of command.produces) {\n const resolution = resolver.resolve(production.event, slice);\n if (resolution.kind === AuthoringProductionKind.Ambiguous && resolution.candidates.some(node => node.kind === AuthoringProductionKind.Operation)) context.error(DiagnosticCodes.InvalidProductionReference, `Production '${production.event}' is ambiguous.`, production.location);\n if (production.event.includes('.') && resolution.kind !== AuthoringProductionKind.Operation) context.error(DiagnosticCodes.InvalidProductionReference, 'Qualified productions are supported only for explicitly declared operations.', production.location);\n if (resolution.declaration?.node.kind !== 'OperationSyntax') continue;\n if (production.for !== null || production.tags.length > 0) context.error(DiagnosticCodes.InvalidOperationDeclaration, 'Operation productions cannot declare event destinations or tags.', production.location);\n validateMappings(production.mappings, resolution.declaration.node, command, true, scope);\n }\n for (const production of slice.reactions.flatMap(reaction => reaction.triggers).flatMap(trigger => trigger.produces)) {\n const resolution = resolver.resolve(production.event, slice);\n if (resolution.kind === AuthoringProductionKind.Ambiguous && resolution.candidates.some(node => node.kind === AuthoringProductionKind.Operation)) context.error(DiagnosticCodes.InvalidProductionReference, `Production '${production.event}' is ambiguous.`, production.location);\n if (production.event.includes('.') && resolver.resolve(production.event, slice).kind !== AuthoringProductionKind.Operation) context.error(DiagnosticCodes.InvalidProductionReference, 'Qualified productions are supported only for explicitly declared operations.', production.location);\n if (resolver.isOperation(production, slice)) context.error(DiagnosticCodes.OperationOutsideCommand, 'Operations can only be produced by commands.', production.location);\n }\n for (const specification of slice.specifications) {\n const steps = [...specification.givenOperationFailures ?? [], ...specification.thenOperations ?? [], ...specification.thenCompensated ?? []];\n if (steps.length === 0) continue;\n const command = resolveCommand(effectiveCommand(specification.when, scope)?.commandType ?? '', scope);\n if (command === null || specification.whenAppended !== null || specification.whenQuery !== null || specification.whenTrigger !== null || specification.whenClock !== null || specification.whenCapture !== null)\n context.error(DiagnosticCodes.InvalidOperationSpecification, 'Operation fixtures and assertions require a declared command action.', specification.location);\n const duplicates = new Map<SyntaxNode, Set<string>>();\n for (const step of steps) {\n if (step.kind === 'SpecificationOperationSyntax') for (const mapping of step.values) {\n if (!concrete(mapping.source)) context.error(DiagnosticCodes.InvalidOperationSpecification, 'Operation assertions require concrete input values.', mapping.source.location);\n }\n const node = resolver.resolve(step.operation, slice).declaration?.node;\n if (node?.kind !== 'OperationSyntax') {\n context.error(DiagnosticCodes.InvalidOperationSpecification, `'${step.operation}' does not resolve uniquely to a declared operation.`, step.location);\n continue;\n }\n const kinds = duplicates.get(node) ?? new Set<string>();\n if (kinds.has(step.kind)) context.error(DiagnosticCodes.InvalidOperationSpecification, `Duplicate operation step '${step.operation}'.`, step.location);\n kinds.add(step.kind);\n duplicates.set(node, kinds);\n if (step.kind === 'SpecificationCompensatedSyntax' && node.compensate === null) context.error(DiagnosticCodes.InvalidOperationSpecification, `Operation '${step.operation}' declares no compensation.`, step.location);\n if (command !== null && command.command.handler == null) {\n const produced = command.command.produces.map(production => resolver.resolve(production.event, command.slice));\n if (produced.every(result => result.kind === AuthoringProductionKind.Event || result.kind === AuthoringProductionKind.Operation) && !produced.some(result => result.declaration?.node === node))\n context.error(DiagnosticCodes.InvalidOperationSpecification, `Command '${command.command.name}' does not produce operation '${step.operation}'.`, step.location);\n }\n if (step.kind === 'SpecificationOperationSyntax') validateMappings(step.values, node, null, false, scope);\n }\n }\n }\n}\n"],"mappings":"4iBAiBA,SAAgB,mBAAmB,EAAgC,EAA8B,CAC7F,IAAMA,EAAW,IAAIC,EAA4BC,CAAW,EACtDC,EAAmBC,EAA6BF,CAAW,EAC3DG,EAAWC,EAAaJ,EAAY,QAAQ,EAC5CK,EAAa,IAAI,IAAI,CAAC,GAAGD,EAAaJ,EAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAACM,EAAMC,KAAU,CAACD,EAAMF,EAAaG,EAAK,UAAU,CAAC,CAAC,CAAC,EACtHC,kBAAQ,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,WAAY,GAAGL,EAAS,KAAK,EAAG,GAAGE,EAAW,KAAK,CAAC,CAAC,EAC1HI,EAAW,IAAI,IAAIT,EAAY,QAAQ,IAAI,GAASU,EAAM,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAC,EAC3FC,kBAAU,IAAI,IACpB,IAAK,IAAMD,KAASV,EAAY,QAAS,CACrC,IAAMM,EAAOI,EAAM,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,EACjDC,EAAQ,IAAIL,EAAM,CAAC,GAAGK,EAAQ,IAAIL,CAAI,GAAK,CAAC,EAAGI,EAAM,aAAa,CAAC,CACvE,CACA,IAAM,OAAa,GAA4E,CAC3F,IAAME,kBAAS,IAAI,IACbC,kBAAQ,IAAI,IAClB,IAAK,IAAMH,KAASI,EAAS,CACzB,IAAMC,EAAQH,EAAO,IAAIF,EAAM,IAAI,GAAK,CAAC,EACzCK,EAAM,KAAKL,CAAK,EAChBE,EAAO,IAAIF,EAAM,KA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,EAAO,OAAA,SAA0CA,EAAO,OAAA,WAA0C,GAAK,CAACmD,EAAS,KAAK,GAAUnD,EAAO,aAAa,OAASG,CAAI,GAC1LK,EAAQ,MAAMC,EAAgB,8BAA+B,YAAYJ,EAAQ,QAAQ,KAAK,gCAAgC4C,EAAK,UAAU,IAAKA,EAAK,QAAQ,CACvK,CACIA,EAAK,OAAS,gCAAgC,iBAAiBA,EAAK,OAAQ9C,EAAM,KAAM,GAAO8B,CAAK,CAC5G,CACJ,CACJ,CACJ"}
1
+ {"version":3,"file":"OperationValidator.js","names":["resolver","AuthoringProductionResolver","application","effectiveCommand","specificationCommandExamples","concepts","uniqueByName","composites","name","type","known","imported","entry","imports","byName","cache","entries","named","key","reference","from","segments","qualifiers","index","value","depth","visible","matches","result","view","slice","node","resolveCommand","command","systems","system","context","DiagnosticCodes","nested","path","properties","property","next","resolved","inheritOptionality","mappings","supplied","seen","item","member","names","allNames","mapping","suppliedPaths","target","operation","targetSegments","reads","commandReadSources","read","resolvedView","scope","source","compatibleValue","required","input","operations","operationDeclarations","eventDeclarations","event","production","resolution","reaction","trigger","specification","steps","duplicates","step","kinds","produced"],"sources":["../../../../../../Compiler/Parsing/OperationValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { AuthoringProductionKind, AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { CommandSyntax } from '../Syntax/Commands';\nimport { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { operationDeclarations, OperationSyntax } from '../Syntax/Operations';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { commandReadSources } from './CommandReadSources';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\nimport { specificationCommandExamples } from './SpecificationCommandExamples';\n\nexport function validateOperations(application: ApplicationSyntax, context: ParserContext): void {\n const resolver = new AuthoringProductionResolver(application);\n const effectiveCommand = specificationCommandExamples(application);\n const concepts = uniqueByName(application.concepts);\n const composites = new Map([...uniqueByName(application.types)].map(([name, type]) => [name, uniqueByName(type.properties)]));\n const known = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...concepts.keys(), ...composites.keys()]);\n const imported = new Set(application.imports.map(entry => entry.qualifiedName.split('.').at(-1)!));\n const imports = new Map<string, string[]>();\n for (const entry of application.imports) {\n const name = entry.qualifiedName.split('.').at(-1)!;\n imports.set(name, [...imports.get(name) ?? [], entry.qualifiedName]);\n }\n const scoped = <T>(entries: readonly { name: string; scope: readonly string[]; node: T }[]) => {\n const byName = new Map<string, typeof entries[number][]>();\n const cache = new Map<string, T | null>();\n for (const entry of entries) {\n const named = byName.get(entry.name) ?? [];\n named.push(entry);\n byName.set(entry.name, named);\n }\n return (reference: string, from: readonly string[]): T | null => {\n const key = JSON.stringify([reference, from]);\n if (cache.has(key)) return cache.get(key)!;\n const candidates = (name: string) => {\n const segments = name.split('.');\n const named = byName.get(segments.at(-1)!) ?? [];\n const qualifiers = segments.slice(0, -1);\n if (qualifiers.length > 0) return named.filter(entry => qualifiers.length <= entry.scope.length && qualifiers.every((value, index) => entry.scope[entry.scope.length - qualifiers.length + index] === value));\n for (let depth = from.length; depth >= 0; depth--) {\n const visible = named.filter(entry => depth <= entry.scope.length && from.slice(0, depth).every((value, index) => entry.scope[index] === value));\n if (visible.length > 0) return visible;\n }\n return [];\n };\n let matches = candidates(reference);\n const imported = imports.get(reference) ?? [];\n if (matches.length === 0 && imported.length === 1) matches = candidates(imported[0]);\n const result = matches.length === 1 ? matches[0].node : null;\n cache.set(key, result);\n return result;\n };\n };\n const view = scoped(resolver.slices.flatMap(({ slice, scope }) => slice.readModels.map(node => ({ name: node.name, scope, node }))));\n const resolveCommand = scoped(resolver.slices.flatMap(({ slice, scope }) => slice.commands.map(command => ({ name: command.name, scope, node: { command, slice } }))));\n const systems = new Map<string, number>();\n for (const system of application.systems ?? []) {\n if (systems.has(system.name)) context.error(DiagnosticCodes.InvalidSystemDeclaration, `System '${system.name}' is declared more than once.`, system.location);\n systems.set(system.name, (systems.get(system.name) ?? 0) + 1);\n }\n const pathType = (properties: readonly PropertySyntax[], path: string, inheritOptionality = true): { type: TypeRefSyntax | null; missing: boolean } => {\n const [name, ...nested] = path.split('.');\n const matches = properties.filter(property => property.name === name);\n if (matches.length !== 1) return { type: null, missing: matches.length === 0 };\n const type = matches[0].type;\n if (nested.length === 0) return { type, missing: false };\n const next = composites.get(type.name);\n if (next === undefined) return { type: null, missing: known.has(type.name) };\n const resolved = pathType([...next.values()], nested.join('.'), inheritOptionality);\n return resolved.type === null ? resolved : { type: { ...resolved.type, isOptional: inheritOptionality && type.isOptional || resolved.type.isOptional, isCollection: type.isCollection || resolved.type.isCollection }, missing: false };\n };\n const covered = (type: TypeRefSyntax, path: string, mappings: ReadonlySet<string>, supplied: ReadonlySet<string>, seen = new Set<string>()): boolean => {\n if (mappings.has(path) || type.isOptional && !supplied.has(path)) return true;\n if (type.isCollection || seen.has(type.name)) return false;\n const properties = composites.get(type.name);\n if (properties === undefined) return supplied.has(path) && !known.has(type.name);\n return [...properties.values()].every(property => covered(property.type, `${path}.${property.name}`, mappings, supplied, new Set([...seen, type.name])));\n };\n const completeValue = (value: PropertyMappingSyntax['source'], type: TypeRefSyntax): boolean => {\n if (value.kind === 'ListExpressionSyntax' && type.isCollection) return value.items.every(item => completeValue(item, { ...type, isCollection: false, isOptional: false }));\n const properties = composites.get(type.name);\n if (value.kind !== 'ObjectExpressionSyntax' || properties === undefined) return true;\n return [...properties.values()].every(property => (property.type.isOptional || value.members.some(member => member.name === property.name)) && value.members.filter(member => member.name === property.name).every(member => completeValue(member.value, property.type)));\n };\n const concrete = (value: PropertyMappingSyntax['source']): boolean => {\n if (value.kind === 'LiteralExpressionSyntax') return typeof value.value !== 'number' || Number.isFinite(value.value);\n if (value.kind === 'ObjectExpressionSyntax') return value.members.every(member => concrete(member.value));\n return value.kind === 'ListExpressionSyntax' && value.items.every(concrete);\n };\n const validateMappings = (mappings: readonly PropertyMappingSyntax[], operation: OperationSyntax, command: CommandSyntax | null, required: boolean, scope: readonly string[]): void => {\n const names = new Set<string>();\n const allNames = new Set(mappings.map(mapping => mapping.property));\n const suppliedPaths = new Set<string>();\n for (const mapping of mappings) {\n const segments = mapping.property.split('.');\n for (let depth = 1; depth <= segments.length; depth++) suppliedPaths.add(segments.slice(0, depth).join('.'));\n }\n for (const mapping of mappings) {\n if (names.has(mapping.property)) context.error(DiagnosticCodes.InvalidOperationMapping, `Duplicate operation input mapping '${mapping.property}'.`, mapping.location);\n names.add(mapping.property);\n const target = pathType(operation.inputs, mapping.property, false);\n if (target.missing) context.error(DiagnosticCodes.InvalidOperationMapping, `Operation '${operation.name}' declares no input '${mapping.property}'.`, mapping.location);\n if (target.type === null) continue;\n const targetSegments = mapping.property.split('.');\n for (let depth = 1; depth < targetSegments.length; depth++) if (allNames.has(targetSegments.slice(0, depth).join('.')))\n context.error(DiagnosticCodes.InvalidOperationMapping, `Operation input mapping '${mapping.property}' overlaps a whole input mapping.`, mapping.location);\n if (command !== null && mapping.source.kind === 'PathExpressionSyntax') {\n let supplied = pathType(command.properties, mapping.source.path);\n const segments = mapping.source.path.split('.');\n const reads = (commandReadSources.get(command) ?? []).filter(read => (read.alias ?? read.readModel) === segments[0]);\n if (supplied.missing && reads.length > 0) {\n supplied = { type: null, missing: false };\n const resolvedView = reads.length === 1 ? view(reads[0].readModel, scope) : null;\n if (segments.length > 1 && resolvedView !== null) supplied = pathType(resolvedView.properties, segments.slice(1).join('.'));\n }\n if (supplied.missing) context.error(DiagnosticCodes.InvalidOperationMapping, `Command '${command.name}' declares no source '${mapping.source.path}'.`, mapping.source.location);\n const source = supplied.type;\n const type = target.type;\n if (source !== null && known.has(source.name) && known.has(type.name) && (source.name !== type.name || source.isCollection !== type.isCollection || source.isOptional && !type.isOptional))\n context.error(DiagnosticCodes.InvalidOperationMapping, `Source '${mapping.source.path}' is incompatible with input '${mapping.property}' of operation '${operation.name}'.`, mapping.source.location);\n } else if (['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(mapping.source.kind)) {\n if (!compatibleValue(mapping.source, target.type, concepts, composites) || required && !completeValue(mapping.source, target.type)) context.error(DiagnosticCodes.InvalidOperationMapping, `Value is incompatible with input '${mapping.property}' of operation '${operation.name}'.`, mapping.source.location);\n }\n }\n if (required) for (const input of operation.inputs) {\n if (!covered(input.type, input.name, names, suppliedPaths)) context.error(DiagnosticCodes.InvalidOperationMapping, `Production of operation '${operation.name}' supplies no value for required input '${input.name}'.`, operation.location);\n }\n };\n for (const { slice, scope } of resolver.slices) {\n const operations = operationDeclarations(slice);\n const names = new Set(eventDeclarations(slice).map(event => event.name));\n for (const operation of operations) {\n if (names.has(operation.name)) context.error(DiagnosticCodes.ProductionDeclarationCollision, `Operation '${operation.name}' collides with another event or operation in slice '${slice.name}'.`, operation.location);\n names.add(operation.name);\n if (operation.uses.length > 0 && systems.get(operation.uses) !== 1) context.error(DiagnosticCodes.InvalidSystemReference, `Operation '${operation.name}' must use one declared system; '${operation.uses}' does not resolve uniquely.`, operation.usesLocation ?? operation.location);\n for (const input of operation.inputs) {\n if (!known.has(input.type.name) && !imported.has(input.type.name)) context.warning(DiagnosticCodes.UnknownType, `Unknown type '${input.type.name}' on input '${input.name}' of operation '${operation.name}'.`, input.type.location);\n }\n }\n for (const command of slice.commands) for (const production of command.produces) {\n const resolution = resolver.resolve(production.event, slice);\n if (resolution.kind === AuthoringProductionKind.Ambiguous && resolution.candidates.some(node => node.kind === AuthoringProductionKind.Operation)) context.error(DiagnosticCodes.InvalidProductionReference, `Production '${production.event}' is ambiguous.`, production.location);\n if (production.event.includes('.') && resolution.kind !== AuthoringProductionKind.Operation) context.error(DiagnosticCodes.InvalidProductionReference, 'Qualified productions are supported only for explicitly declared operations.', production.location);\n if (resolution.declaration?.node.kind !== 'OperationSyntax') continue;\n if (production.for !== null || production.tags.length > 0) context.error(DiagnosticCodes.InvalidOperationDeclaration, 'Operation productions cannot declare event destinations or tags.', production.location);\n validateMappings(production.mappings, resolution.declaration.node, command, true, scope);\n }\n for (const production of slice.reactions.flatMap(reaction => reaction.triggers).flatMap(trigger => trigger.produces)) {\n const resolution = resolver.resolve(production.event, slice);\n if (resolution.kind === AuthoringProductionKind.Ambiguous && resolution.candidates.some(node => node.kind === AuthoringProductionKind.Operation)) context.error(DiagnosticCodes.InvalidProductionReference, `Production '${production.event}' is ambiguous.`, production.location);\n if (production.event.includes('.') && resolver.resolve(production.event, slice).kind !== AuthoringProductionKind.Operation) context.error(DiagnosticCodes.InvalidProductionReference, 'Qualified productions are supported only for explicitly declared operations.', production.location);\n if (resolver.isOperation(production, slice)) context.error(DiagnosticCodes.OperationOutsideCommand, 'Operations can only be produced by commands.', production.location);\n }\n for (const specification of slice.specifications) {\n const steps = [...specification.givenOperationFailures ?? [], ...specification.thenOperations ?? [], ...specification.thenCompensated ?? []];\n if (steps.length === 0) continue;\n const command = resolveCommand(effectiveCommand(specification.when, scope)?.commandType ?? '', scope);\n if (command === null || specification.whenAppended !== null || specification.whenQuery !== null || specification.whenTrigger !== null || specification.whenClock !== null || specification.whenCapture !== null)\n context.error(DiagnosticCodes.InvalidOperationSpecification, 'Operation fixtures and assertions require a declared command action.', specification.location);\n const duplicates = new Map<SyntaxNode, Set<string>>();\n for (const step of steps) {\n if (step.kind === 'SpecificationOperationSyntax') for (const mapping of step.values) {\n if (!concrete(mapping.source)) context.error(DiagnosticCodes.InvalidOperationSpecification, 'Operation assertions require concrete input values.', mapping.source.location);\n }\n const node = resolver.resolve(step.operation, slice).declaration?.node;\n if (node?.kind !== 'OperationSyntax') {\n context.error(DiagnosticCodes.InvalidOperationSpecification, `'${step.operation}' does not resolve uniquely to a declared operation.`, step.location);\n continue;\n }\n const kinds = duplicates.get(node) ?? new Set<string>();\n if (kinds.has(step.kind)) context.error(DiagnosticCodes.InvalidOperationSpecification, `Duplicate operation step '${step.operation}'.`, step.location);\n kinds.add(step.kind);\n duplicates.set(node, kinds);\n if (step.kind === 'SpecificationCompensatedSyntax' && node.compensate === null) context.error(DiagnosticCodes.InvalidOperationSpecification, `Operation '${step.operation}' declares no compensation.`, step.location);\n if (command !== null && command.command.handler == null) {\n const produced = command.command.produces.map(production => resolver.resolve(production.event, command.slice));\n if (produced.every(result => result.kind === AuthoringProductionKind.Event || result.kind === AuthoringProductionKind.Operation) && !produced.some(result => result.declaration?.node === node))\n context.error(DiagnosticCodes.InvalidOperationSpecification, `Command '${command.command.name}' does not produce operation '${step.operation}'.`, step.location);\n }\n if (step.kind === 'SpecificationOperationSyntax') validateMappings(step.values, node, null, false, scope);\n }\n }\n }\n}\n"],"mappings":"A,4iBAiBA,SAAgB,mBAAmB,EAAgC,EAA8B,CAC7F,IAAMA,EAAW,IAAIC,EAA4BC,CAAW,EACtDC,EAAmBC,EAA6BF,CAAW,EAC3DG,EAAWC,EAAaJ,EAAY,QAAQ,EAC5CK,EAAa,IAAI,IAAI,CAAC,GAAGD,EAAaJ,EAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAACM,EAAMC,KAAU,CAACD,EAAMF,EAAaG,EAAK,UAAU,CAAC,CAAC,CAAC,EACtHC,kBAAQ,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,WAAY,GAAGL,EAAS,KAAK,EAAG,GAAGE,EAAW,KAAK,CAAC,CAAC,EAC1HI,EAAW,IAAI,IAAIT,EAAY,QAAQ,IAAI,GAASU,EAAM,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAC,EAC3FC,kBAAU,IAAI,IACpB,IAAK,IAAMD,KAASV,EAAY,QAAS,CACrC,IAAMM,EAAOI,EAAM,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AM,IAAID,EAAK,IAAI,EACnBD,EAAW,IAAI7C,EAAM+C,CAAK,EACtBD,EAAK,OAAS,kCAAoC9C,EAAK,aAAe,MAAMK,EAAQ,MAAMC,EAAgB,8BAA+B,cAAcwC,EAAK,UAAU,6BAA8BA,EAAK,QAAQ,EACjN5C,IAAY,MAAQA,EAAQ,QAAQ,SAAW,KAAM,CACrD,IAAM8C,EAAW9C,EAAQ,QAAQ,SAAS,IAAI,GAAcjC,EAAS,QAAQsE,EAAW,MAAOrC,EAAQ,KAAK,CAAC,EACzG8C,EAAS,MAAM,GAAUnD,EAAO,OAAA,SAA0CA,EAAO,OAAA,WAA0C,GAAK,CAACmD,EAAS,KAAK,GAAUnD,EAAO,aAAa,OAASG,CAAI,GAC1LK,EAAQ,MAAMC,EAAgB,8BAA+B,YAAYJ,EAAQ,QAAQ,KAAK,gCAAgC4C,EAAK,UAAU,IAAKA,EAAK,QAAQ,CACvK,CACIA,EAAK,OAAS,gCAAgC,iBAAiBA,EAAK,OAAQ9C,EAAM,KAAM,GAAO8B,CAAK,CAC5G,CACJ,CACJ,CACJ,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ParserContext.js","names":["ParserContext","legacySourceOptions","context","reader","path","languages","sourceLocation","#diagnostics","first","second","entry","line","arguments_","parentIndent","child"],"sources":["../../../../../../Compiler/Parsing/ParserContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticArgument } from '../Diagnostics/DiagnosticArgument';\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { CommandStreamCandidates } from './CommandStreamCandidates';\nimport { SourceLocation, sourceLocation } from '../Diagnostics/SourceLocation';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { legacySourceOptions, SourceOptions } from '../Syntax/SourceOptions';\nimport { InputUse } from './InputUses';\nimport { ContinuationValueUse } from './ContinuationValueUse';\nimport { GuardedInteractionBinding, InteractionAncestor } from './InteractionAlternatives';\nimport { InteractionBehavior } from './InteractionBehavior';\nimport { InteractionUse } from './InteractionUse';\nimport { LineReader } from './LineReader';\nimport { SourceLine } from './SourceLine';\n\n// What every parser shares while it reads one document: the line reader, the diagnostics found so far and\n// the file the document came from.\nexport class ParserContext {\n readonly #diagnostics: Diagnostic[] = [];\n // Authoring verification needs these committed values even though SyntaxJson omits them.\n readonly triggerData: PropertySyntax[] = [];\n readonly inputUses: InputUse[] = [];\n readonly continuationValues: ContinuationValueUse[] = [];\n readonly guardedInteractions: GuardedInteractionBinding[] = [];\n readonly interactionBehaviors: InteractionBehavior[] = [];\n readonly interactionUses: InteractionUse[] = [];\n interactionAncestors: ReadonlyMap<number, readonly InteractionAncestor[]> = new Map();\n scope: readonly string[] = [];\n readonly languages: ReadonlySet<string>;\n sourceOptions: SourceOptions = legacySourceOptions;\n authoredDeclarations = false;\n deferIdentityValidation = false;\n streamCandidates?: CommandStreamCandidates;\n\n // Structural enrichment of formerly opaque Legacy fields must not add diagnostics. Exact operands\n // use the owning context so representability failures cannot turn into successful opaque syntax.\n get valueContext(): ParserContext {\n if (this.sourceOptions.numericMode === 'exact') return this;\n const context = new ParserContext(this.reader, this.path, this.languages);\n context.sourceOptions = this.sourceOptions;\n return context;\n }\n\n constructor(readonly reader: LineReader, readonly path?: string, languages: ReadonlySet<string> = new Set(['csharp', 'java', 'typescript', 'react', 'html', 'sql'])) {\n this.languages = languages;\n }\n\n get start(): SourceLocation {\n return sourceLocation(1, 1, this.path);\n }\n\n get diagnostics(): readonly Diagnostic[] {\n // Directive-shaped lines nobody claimed as a field are errors, wherever they sit.\n if (this.nestedNumericDirectives.size > 0 && this.sourceOptions.numericMode !== 'legacy' && this.reader.atEnd) {\n this.#diagnostics.push(...[...this.nestedNumericDirectives].sort((first, second) => first[0] - second[0]).map(entry => entry[1]));\n this.nestedNumericDirectives.clear();\n }\n return this.#diagnostics;\n }\n\n // Directive-shaped lines below the top level, keyed by line number, still unclaimed as a field.\n nestedNumericDirectives = new Map<number, Diagnostic>();\n\n claimField(line: SourceLine): void {\n this.nestedNumericDirectives.delete(line.number);\n }\n\n information(code: string, message: string, location: SourceLocation, arguments_: Readonly<Record<string, DiagnosticArgument>> = {}): void {\n this.#diagnostics.push({ severity: 'information', code, message, location, arguments: arguments_ });\n }\n\n error(code: string, message: string, location: SourceLocation, arguments_: Readonly<Record<string, DiagnosticArgument>> = {}): void {\n this.#diagnostics.push({ severity: 'error', code, message, location, arguments: arguments_ });\n }\n\n warning(code: string, message: string, location: SourceLocation, arguments_: Readonly<Record<string, DiagnosticArgument>> = {}): void {\n this.#diagnostics.push({ severity: 'warning', code, message, location, arguments: arguments_ });\n }\n\n // The next significant line when it is indented deeper than its parent - that is, when it belongs to\n // the parent's body under the offside rule.\n peekChild(parentIndent: number): SourceLine | undefined {\n const line = this.reader.peekSignificant();\n return line !== undefined && line.indent > parentIndent ? line : undefined;\n }\n\n // Skips the body of a construct, the way the C# parser does after reporting it.\n skipBlock(parentIndent: number): void {\n while (this.peekChild(parentIndent) !== undefined) {\n this.reader.takeSignificant();\n }\n }\n\n // Skips the body of a construct this compiler deliberately does not model. Unlike skipBlock it steps\n // over fenced code blocks whole, because a fenced line may be indented less than the block it is in -\n // reading it as significant would end the skip early and misread the code as Screenplay.\n skipOpaqueBlock(parentIndent: number): void {\n let child = this.peekChild(parentIndent);\n while (child !== undefined) {\n this.reader.takeSignificant();\n if (child.content.startsWith('```')) {\n this.skipFencedBody();\n }\n child = this.peekChild(parentIndent);\n }\n }\n\n // Takes the raw lines of a fenced block up to and including its closing fence.\n skipFencedBody(): void {\n for (let line = this.reader.takeRaw(); line !== undefined; line = this.reader.takeRaw()) {\n if (line.raw.trim() === '```') {\n return;\n }\n }\n }\n}\n"],"mappings":"wLAmBA,IAAaA,EAAb,MAAa,aAAc,CA0BF,OAA6B,KAzBlD,GAAsC,CAAC,EAEvC,YAAyC,CAAC,EAC1C,UAAiC,CAAC,EAClC,mBAAsD,CAAC,EACvD,oBAA4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CAEA,QAAQ,EAAc,EAAiB,EAA0B,EAA2D,CAAC,EAAS,CAClI,KAAKL,GAAa,KAAK,CAAE,SAAU,UAAW,OAAM,UAAS,WAAU,UAAWK,CAAW,CAAC,CAClG,CAIA,UAAU,EAA8C,CACpD,IAAMD,EAAO,KAAK,OAAO,gBAAgB,EACzC,OAAOA,IAAS,IAAA,IAAaA,EAAK,OAASE,EAAeF,EAAO,IAAA,EACrE,CAGA,UAAU,EAA4B,CAClC,KAAO,KAAK,UAAUE,CAAY,IAAM,IAAA,IACpC,KAAK,OAAO,gBAAgB,CAEpC,CAKA,gBAAgB,EAA4B,CACxC,IAAIC,EAAQ,KAAK,UAAUD,CAAY,EACvC,KAAOC,IAAU,IAAA,IACb,KAAK,OAAO,gBAAgB,EACxBA,EAAM,QAAQ,WAAW,KAAK,GAC9B,KAAK,eAAe,EAExB,EAAQ,KAAK,UAAUD,CAAY,CAE3C,CAGA,gBAAuB,CACnB,IAAK,IAAIF,EAAO,KAAK,OAAO,QAAQ,EAAGA,IAAS,IAAA,GAAW,EAAO,KAAK,OAAO,QAAQ,EAClF,GAAIA,EAAK,IAAI,KAAK,IAAM,MACpB,MAGZ,CACJ"}
1
+ {"version":3,"file":"ParserContext.js","names":["ParserContext","legacySourceOptions","context","reader","path","languages","sourceLocation","#diagnostics","first","second","entry","line","arguments_","parentIndent","child"],"sources":["../../../../../../Compiler/Parsing/ParserContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticArgument } from '../Diagnostics/DiagnosticArgument';\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { CommandStreamCandidates } from './CommandStreamCandidates';\nimport { SourceLocation, sourceLocation } from '../Diagnostics/SourceLocation';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { legacySourceOptions, SourceOptions } from '../Syntax/SourceOptions';\nimport { InputUse } from './InputUses';\nimport { ContinuationValueUse } from './ContinuationValueUse';\nimport { GuardedInteractionBinding, InteractionAncestor } from './InteractionAlternatives';\nimport { InteractionBehavior } from './InteractionBehavior';\nimport { InteractionUse } from './InteractionUse';\nimport { LineReader } from './LineReader';\nimport { SourceLine } from './SourceLine';\n\n// What every parser shares while it reads one document: the line reader, the diagnostics found so far and\n// the file the document came from.\nexport class ParserContext {\n readonly #diagnostics: Diagnostic[] = [];\n // Authoring verification needs these committed values even though SyntaxJson omits them.\n readonly triggerData: PropertySyntax[] = [];\n readonly inputUses: InputUse[] = [];\n readonly continuationValues: ContinuationValueUse[] = [];\n readonly guardedInteractions: GuardedInteractionBinding[] = [];\n readonly interactionBehaviors: InteractionBehavior[] = [];\n readonly interactionUses: InteractionUse[] = [];\n interactionAncestors: ReadonlyMap<number, readonly InteractionAncestor[]> = new Map();\n scope: readonly string[] = [];\n readonly languages: ReadonlySet<string>;\n sourceOptions: SourceOptions = legacySourceOptions;\n authoredDeclarations = false;\n deferIdentityValidation = false;\n streamCandidates?: CommandStreamCandidates;\n\n // Structural enrichment of formerly opaque Legacy fields must not add diagnostics. Exact operands\n // use the owning context so representability failures cannot turn into successful opaque syntax.\n get valueContext(): ParserContext {\n if (this.sourceOptions.numericMode === 'exact') return this;\n const context = new ParserContext(this.reader, this.path, this.languages);\n context.sourceOptions = this.sourceOptions;\n return context;\n }\n\n constructor(readonly reader: LineReader, readonly path?: string, languages: ReadonlySet<string> = new Set(['csharp', 'java', 'typescript', 'react', 'html', 'sql'])) {\n this.languages = languages;\n }\n\n get start(): SourceLocation {\n return sourceLocation(1, 1, this.path);\n }\n\n get diagnostics(): readonly Diagnostic[] {\n // Directive-shaped lines nobody claimed as a field are errors, wherever they sit.\n if (this.nestedNumericDirectives.size > 0 && this.sourceOptions.numericMode !== 'legacy' && this.reader.atEnd) {\n this.#diagnostics.push(...[...this.nestedNumericDirectives].sort((first, second) => first[0] - second[0]).map(entry => entry[1]));\n this.nestedNumericDirectives.clear();\n }\n return this.#diagnostics;\n }\n\n // Directive-shaped lines below the top level, keyed by line number, still unclaimed as a field.\n nestedNumericDirectives = new Map<number, Diagnostic>();\n\n claimField(line: SourceLine): void {\n this.nestedNumericDirectives.delete(line.number);\n }\n\n information(code: string, message: string, location: SourceLocation, arguments_: Readonly<Record<string, DiagnosticArgument>> = {}): void {\n this.#diagnostics.push({ severity: 'information', code, message, location, arguments: arguments_ });\n }\n\n error(code: string, message: string, location: SourceLocation, arguments_: Readonly<Record<string, DiagnosticArgument>> = {}): void {\n this.#diagnostics.push({ severity: 'error', code, message, location, arguments: arguments_ });\n }\n\n warning(code: string, message: string, location: SourceLocation, arguments_: Readonly<Record<string, DiagnosticArgument>> = {}): void {\n this.#diagnostics.push({ severity: 'warning', code, message, location, arguments: arguments_ });\n }\n\n // The next significant line when it is indented deeper than its parent - that is, when it belongs to\n // the parent's body under the offside rule.\n peekChild(parentIndent: number): SourceLine | undefined {\n const line = this.reader.peekSignificant();\n return line !== undefined && line.indent > parentIndent ? line : undefined;\n }\n\n // Skips the body of a construct, the way the C# parser does after reporting it.\n skipBlock(parentIndent: number): void {\n while (this.peekChild(parentIndent) !== undefined) {\n this.reader.takeSignificant();\n }\n }\n\n // Skips the body of a construct this compiler deliberately does not model. Unlike skipBlock it steps\n // over fenced code blocks whole, because a fenced line may be indented less than the block it is in -\n // reading it as significant would end the skip early and misread the code as Screenplay.\n skipOpaqueBlock(parentIndent: number): void {\n let child = this.peekChild(parentIndent);\n while (child !== undefined) {\n this.reader.takeSignificant();\n if (child.content.startsWith('```')) {\n this.skipFencedBody();\n }\n child = this.peekChild(parentIndent);\n }\n }\n\n // Takes the raw lines of a fenced block up to and including its closing fence.\n skipFencedBody(): void {\n for (let line = this.reader.takeRaw(); line !== undefined; line = this.reader.takeRaw()) {\n if (line.raw.trim() === '```') {\n return;\n }\n }\n }\n}\n"],"mappings":"A,wLAmBA,IAAaA,EAAb,MAAa,aAAc,CA0BF,OAA6B,KAzBlD,GAAsC,CAAC,EAEvC,YAAyC,CAAC,EAC1C,UAAiC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M,UAAS,WAAU,UAAWK,CAAW,CAAC,CAChG,CAEA,QAAQ,EAAc,EAAiB,EAA0B,EAA2D,CAAC,EAAS,CAClI,KAAKL,GAAa,KAAK,CAAE,SAAU,UAAW,OAAM,UAAS,WAAU,UAAWK,CAAW,CAAC,CAClG,CAIA,UAAU,EAA8C,CACpD,IAAMD,EAAO,KAAK,OAAO,gBAAgB,EACzC,OAAOA,IAAS,IAAA,IAAaA,EAAK,OAASE,EAAeF,EAAO,IAAA,EACrE,CAGA,UAAU,EAA4B,CAClC,KAAO,KAAK,UAAUE,CAAY,IAAM,IAAA,IACpC,KAAK,OAAO,gBAAgB,CAEpC,CAKA,gBAAgB,EAA4B,CACxC,IAAIC,EAAQ,KAAK,UAAUD,CAAY,EACvC,KAAOC,IAAU,IAAA,IACb,KAAK,OAAO,gBAAgB,EACxBA,EAAM,QAAQ,WAAW,KAAK,GAC9B,KAAK,eAAe,EAExB,EAAQ,KAAK,UAAUD,CAAY,CAE3C,CAGA,gBAAuB,CACnB,IAAK,IAAIF,EAAO,KAAK,OAAO,QAAQ,EAAGA,IAAS,IAAA,GAAW,EAAO,KAAK,OAAO,QAAQ,EAClF,GAAIA,EAAK,IAAI,KAAK,IAAM,MACpB,MAGZ,CACJ,E"}
@@ -1 +1 @@
1
- {"version":3,"file":"PersonaCallerValidator.js","names":["personas","application","persona","feature","features","slice","specification","reference","count","name","context","DiagnosticCodes","module"],"sources":["../../../../../../Compiler/Parsing/PersonaCallerValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\n\nexport function validatePersonaCallers(application: ApplicationSyntax, context: ParserContext): void {\n const personas = application.personas.map(persona => persona.name);\n const visit = (features: readonly FeatureSyntax[]): void => {\n for (const feature of features) {\n visit(feature.features);\n for (const slice of feature.slices) {\n for (const specification of slice.specifications) {\n const reference = specification.givenCallerPersona;\n if (reference != null) {\n const count = personas.filter(name => name === reference.name).length;\n if (count !== 1) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, `${count === 0 ? 'Unknown' : 'Ambiguous'} persona '${reference.name}' - declared personas: ${personas.join(', ')}.`, reference.location);\n }\n }\n }\n }\n };\n for (const module of application.modules) visit(module.features);\n}\n"],"mappings":"yHAOA,SAAgB,uBAAuB,EAAgC,EAA8B,CACjG,IAAMA,EAAWC,EAAY,SAAS,IAAI,GAAWC,EAAQ,IAAI,EAC3D,MAAS,GAA6C,CACxD,IAAK,IAAMC,KAAWC,EAAU,CAC5B,MAAMD,EAAQ,QAAQ,EACtB,IAAK,IAAME,KAASF,EAAQ,OACxB,IAAK,IAAMG,KAAiBD,EAAM,eAAgB,CAC9C,IAAME,EAAYD,EAAc,mBAChC,GAAIC,GAAa,KAAM,CACnB,IAAMC,EAAQR,EAAS,OAAO,GAAQS,IAASF,EAAU,IAAI,CAAC,CAAC,OAC3DC,IAAU,GAAGE,EAAQ,MAAMC,EAAgB,kCAAmC,GAAGH,IAAU,EAAI,UAAY,YAAY,YAAYD,EAAU,KAAK,yBAAyBP,EAAS,KAAK,IAAI,EAAE,GAAIO,EAAU,QAAQ,CAC7N,CACJ,CAER,CACJ,EACA,IAAK,IAAMK,KAAUX,EAAY,QAAS,MAAMW,EAAO,QAAQ,CACnE"}
1
+ {"version":3,"file":"PersonaCallerValidator.js","names":["personas","application","persona","feature","features","slice","specification","reference","count","name","context","DiagnosticCodes","module"],"sources":["../../../../../../Compiler/Parsing/PersonaCallerValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\n\nexport function validatePersonaCallers(application: ApplicationSyntax, context: ParserContext): void {\n const personas = application.personas.map(persona => persona.name);\n const visit = (features: readonly FeatureSyntax[]): void => {\n for (const feature of features) {\n visit(feature.features);\n for (const slice of feature.slices) {\n for (const specification of slice.specifications) {\n const reference = specification.givenCallerPersona;\n if (reference != null) {\n const count = personas.filter(name => name === reference.name).length;\n if (count !== 1) context.error(DiagnosticCodes.InvalidSpecificationCallerPersona, `${count === 0 ? 'Unknown' : 'Ambiguous'} persona '${reference.name}' - declared personas: ${personas.join(', ')}.`, reference.location);\n }\n }\n }\n }\n };\n for (const module of application.modules) visit(module.features);\n}\n"],"mappings":"A,yHAOA,SAAgB,uBAAuB,EAAgC,EAA8B,CACjG,IAAMA,EAAWC,EAAY,SAAS,IAAI,GAAWC,EAAQ,IAAI,EAC3D,MAAS,GAA6C,CACxD,IAAK,IAAMC,KAAWC,EAAU,CAC5B,MAAMD,EAAQ,QAAQ,EACtB,IAAK,IAAME,KAASF,EAAQ,OACxB,IAAK,IAAMG,KAAiBD,EAAM,eAAgB,CAC9C,IAAME,EAAYD,EAAc,mBAChC,GAAIC,GAAa,KAAM,CACnB,IAAMC,EAAQR,EAAS,OAAO,GAAQS,IAASF,EAAU,IAAI,CAAC,CAAC,OAC3DC,IAAU,GAAGE,EAAQ,MAAMC,EAAgB,kCAAmC,GAAGH,IAAU,EAAI,UAAY,YAAY,YAAYD,EAAU,KAAK,yBAAyBP,EAAS,KAAK,IAAI,EAAE,GAAIO,EAAU,QAAQ,CAC7N,CACJ,CAER,CACJ,EACA,IAAK,IAAMK,KAAUX,EAAY,QAAS,MAAMW,EAAO,QAAQ,CACnE,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{unescapeString as t}from"../Text/StringLiteral.js";import{nativePattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{parseModeledMappingSource as i}from"./ExpressionParser.js";import{firstWord as a}from"./LineText.js";import{parseDescription as o}from"./DescriptionParser.js";import{parseCode as s,parseFile as c}from"./ImplementationParser.js";const l=n(`^policy\\s+([A-Za-z_]\\w*)$`);function parsePolicy(t,n){let i=t;t=t.valueContext;let u=l.exec(n.content)?.[1]??``;u===``&&t.error(e.InvalidPolicyDeclaration,`Invalid policy declaration '${n.content}' - expected 'policy <Name>'`,r(n));let d=null,f=null,p=null,m=!1,h=null;for(let l=t.peekChild(n.indent);l!==void 0;l=t.peekChild(n.indent))if(t.reader.takeSignificant(),a(l.content)===`description`)h=o(i,l,h,`Policy '${u}'`);else if(a(l.content)===`require`){let n=l.content.substring(7).trim();for(let e=t.peekChild(l.indent);e!==void 0;e=t.peekChild(l.indent))t.reader.takeSignificant(),n+=` ${e.content}`;let a=tokenizePolicyCondition(t,n);a.includes(`not`)&&(t=i);let o=parsePolicyCondition(t,a,r(l),i);validateAnonymous(i,o,u,r(l)),m?t.error(e.RepeatedPolicyRequirement,`Policy '${u}' has more than one require line; combine the conditions with and/or in one require`,r(l)):d=o,m=!0}else if(a(l.content)===`file`){let n=c(t,l);f===null&&p===null?p=n:t.error(e.UnknownPolicyDirective,`Policy '${u}' must have only one implementation - a file reference or an inline code block, not both`,r(l))}else if(l.content.startsWith("```")||t.languages.has(l.content)){let n=s(t,l);f===null&&p===null?f=n:t.error(e.UnknownPolicyDirective,`Policy '${u}' must have only one implementation - a file reference or an inline code block, not both`,r(l))}else t.error(e.UnknownPolicyDirective,`Unexpected '${l.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,r(l)),t.skipOpaqueBlock(l.indent);return d!==null&&(f!==null||p!==null)&&t.error(e.MixedPolicyImplementation,`Policy '${u}' cannot combine 'require' with a file or inline code block`,r(n)),d===null&&f===null&&p===null&&t.error(e.PolicyWithoutRequirement,`Policy '${u}' must declare a 'require' condition, a file reference or an inline code block`,r(n)),{kind:`PolicySyntax`,name:u,condition:d,code:f,file:p,description:h,location:r(n)}}function tokenizePolicyCondition(e,t){let r=e.sourceOptions.numericMode===`exact`?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]`:`[\\w.$]+`;return[...t.match(new RegExp(n(`"(?:[^"\\\\]|\\\\.)*"|\\(|\\)|${r}`).source,`gu`))??[]]}function parsePolicyCondition(n,r,a,o){let s=n.sourceOptions.numericMode===`exact`||r.includes(`not`),c=0,quoted=e=>e!==void 0&&e.startsWith(`"`)&&e.endsWith(`"`),unquote=e=>t(e.substring(1,e.length-1)),group=()=>{if(r[c]===`not`){c++;let e=group();return e===null?null:{kind:`NotPolicyConditionSyntax`,operand:e,location:a}}if(r[c]===`(`){c++;let t=or();return r[c]===`)`?c++:s&&n.error(e.UnclosedPolicyConditionGroup,`Expected ')' in policy condition`,a),t}let t=r[c++];if(t===`authenticated`)return{kind:`AuthenticatedConditionSyntax`,location:a};if(t===`anonymous`)return{kind:`AnonymousConditionSyntax`,location:a};if(t!==`role`&&t!==`claim`)return n.error(t===void 0?e.ExpectedPolicyCondition:e.UnexpectedTokenInPolicyCondition,t===void 0?`Expected a policy condition`:`Unexpected '${t}' in policy condition`,a),null;let l=r[c++];if(!quoted(l))return n.error(t===`role`?e.ExpectedRoleName:e.ExpectedClaimName,`Expected a quoted ${t} name after '${t}'`,a),null;if(t===`role`)return{kind:`RoleConditionSyntax`,role:unquote(l),location:a};if(r[c++]!==`matches`)return n.error(e.ExpectedClaimMatches,`Expected 'matches' after the claim name`,a),null;let u=r[c++];return u===void 0?(n.error(e.ExpectedClaimMatchTarget,`Expected 'subject' or a value after 'matches'`,a),null):{kind:`ClaimConditionSyntax`,claim:unquote(l),matchesSubject:u===`subject`,matches:u===`subject`?null:i(u,a,o),location:a}},and=()=>{let e=group();for(;e!==null&&r[c]===`and`;){c++;let t=group();if(t===null)return null;e={kind:`LogicalPolicyConditionSyntax`,left:e,operator:`And`,right:t,location:a}}return e},or=()=>{let e=and();for(;e!==null&&r[c]===`or`;){c++;let t=and();if(t===null)return null;e={kind:`LogicalPolicyConditionSyntax`,left:e,operator:`Or`,right:t,location:a}}return e},l=or();return s&&l!==null&&c<r.length&&n.error(e.UnexpectedTokenInPolicyCondition,`Unexpected '${r[c]}' in policy condition`,a),l}function validateAnonymous(t,n,r,i){n!==null&&n.kind!==`AnonymousConditionSyntax`&&containsAnonymous(n)&&(negatesAnonymous(n)?t.error(e.NegatedAnonymousPolicy,`Policy '${r}' negates 'anonymous'; a policy that refuses callers without an identity says 'require authenticated'`,i):t.error(e.AnonymousPolicyCombined,`Policy '${r}' combines 'anonymous' with another condition; 'anonymous' admits callers without an identity and must be the whole 'require' condition`,i))}function containsAnonymous(e){switch(e.kind){case`AnonymousConditionSyntax`:return!0;case`NotPolicyConditionSyntax`:return containsAnonymous(e.operand);case`LogicalPolicyConditionSyntax`:return containsAnonymous(e.left)||containsAnonymous(e.right);default:return!1}}function negatesAnonymous(e){switch(e.kind){case`NotPolicyConditionSyntax`:return containsAnonymous(e.operand);case`LogicalPolicyConditionSyntax`:return negatesAnonymous(e.left)||negatesAnonymous(e.right);default:return!1}}export{parsePolicy};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{unescapeString as t}from"../Text/StringLiteral.js";import{nativePattern as n}from"../Text/patterns.js";import{parseModeledMappingSource as r}from"./ExpressionParser.js";import{parseCode as i,parseFile as a}from"./ImplementationParser.js";import{firstWord as o}from"./LineText.js";import{parseDescription as s}from"./DescriptionParser.js";import{ConditionDepthBudget as c}from"./ConditionDepthBudget.js";import{locationOf as l}from"./SourceLine.js";const u=n(`^policy\\s+([A-Za-z_]\\w*)$`);function parsePolicy(t,n){let r=t;t=t.valueContext;let d=u.exec(n.content)?.[1]??``;d===``&&t.error(e.InvalidPolicyDeclaration,`Invalid policy declaration '${n.content}' - expected 'policy <Name>'`,l(n));let f=null,p=null,m=null,h=!1,g=!1,_=null;for(let u=t.peekChild(n.indent);u!==void 0;u=t.peekChild(n.indent))if(t.reader.takeSignificant(),o(u.content)===`description`)_=s(r,u,_,`Policy '${d}'`);else if(o(u.content)===`require`){let n=u.content.substring(7).trim();for(let e=t.peekChild(u.indent);e!==void 0;e=t.peekChild(u.indent))t.reader.takeSignificant(),n+=` ${e.content}`;let i=tokenizePolicyCondition(t,n);i.includes(`not`)&&(t=r);let a=new c(r,l(u)),o=parsePolicyCondition(t,i,l(u),r,a);g||=a.exceeded,validateAnonymous(r,o,d,l(u)),h?t.error(e.RepeatedPolicyRequirement,`Policy '${d}' has more than one require line; combine the conditions with and/or in one require`,l(u)):f=o,h=!0}else if(o(u.content)===`file`){let n=a(t,u);p===null&&m===null?m=n:t.error(e.UnknownPolicyDirective,`Policy '${d}' must have only one implementation - a file reference or an inline code block, not both`,l(u))}else if(u.content.startsWith("```")||t.languages.has(u.content)){let n=i(t,u);p===null&&m===null?p=n:t.error(e.UnknownPolicyDirective,`Policy '${d}' must have only one implementation - a file reference or an inline code block, not both`,l(u))}else t.error(e.UnknownPolicyDirective,`Unexpected '${u.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,l(u)),t.skipOpaqueBlock(u.indent);return f!==null&&(p!==null||m!==null)&&t.error(e.MixedPolicyImplementation,`Policy '${d}' cannot combine 'require' with a file or inline code block`,l(n)),f===null&&p===null&&m===null&&!g&&t.error(e.PolicyWithoutRequirement,`Policy '${d}' must declare a 'require' condition, a file reference or an inline code block`,l(n)),{kind:`PolicySyntax`,name:d,condition:f,code:p,file:m,description:_,location:l(n)}}function tokenizePolicyCondition(e,t){let r=e.sourceOptions.numericMode===`exact`?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]`:`[\\w.$]+`;return[...t.match(new RegExp(n(`"(?:[^"\\\\]|\\\\.)*"|\\(|\\)|${r}`).source,`gu`))??[]]}function parsePolicyCondition(n,i,a,o,s){let c=n.sourceOptions.numericMode===`exact`||i.includes(`not`),l=0,quoted=e=>e!==void 0&&e.startsWith(`"`)&&e.endsWith(`"`),unquote=e=>t(e.substring(1,e.length-1)),group=()=>{if(i[l]===`not`||i[l]===`(`){if(!s.enter())return null;let t=i[l++]===`not`;try{if(t){let e=group();return e===null?null:s.build([e],()=>({kind:`NotPolicyConditionSyntax`,operand:e,location:a}))}let r=or();return s.exceeded?null:(i[l]===`)`?l++:c&&n.error(e.UnclosedPolicyConditionGroup,`Expected ')' in policy condition`,a),r)}finally{s.leave()}}let t=i[l++];if(t===`authenticated`)return{kind:`AuthenticatedConditionSyntax`,location:a};if(t===`anonymous`)return{kind:`AnonymousConditionSyntax`,location:a};if(t!==`role`&&t!==`claim`)return n.error(t===void 0?e.ExpectedPolicyCondition:e.UnexpectedTokenInPolicyCondition,t===void 0?`Expected a policy condition`:`Unexpected '${t}' in policy condition`,a),null;let u=i[l++];if(!quoted(u))return n.error(t===`role`?e.ExpectedRoleName:e.ExpectedClaimName,`Expected a quoted ${t} name after '${t}'`,a),null;if(t===`role`)return{kind:`RoleConditionSyntax`,role:unquote(u),location:a};if(i[l++]!==`matches`)return n.error(e.ExpectedClaimMatches,`Expected 'matches' after the claim name`,a),null;let d=i[l++];return d===void 0?(n.error(e.ExpectedClaimMatchTarget,`Expected 'subject' or a value after 'matches'`,a),null):{kind:`ClaimConditionSyntax`,claim:unquote(u),matchesSubject:d===`subject`,matches:d===`subject`?null:r(d,a,o),location:a}},and=()=>{let e=group();for(;e!==null&&i[l]===`and`;){l++;let t=group();if(t===null)return null;let n=e;e=s.build([n,t],()=>({kind:`LogicalPolicyConditionSyntax`,left:n,operator:`And`,right:t,location:a}))}return e},or=()=>{let e=and();for(;e!==null&&i[l]===`or`;){l++;let t=and();if(t===null)return null;let n=e;e=s.build([n,t],()=>({kind:`LogicalPolicyConditionSyntax`,left:n,operator:`Or`,right:t,location:a}))}return e},u=or();return c&&u!==null&&l<i.length&&n.error(e.UnexpectedTokenInPolicyCondition,`Unexpected '${i[l]}' in policy condition`,a),u}function validateAnonymous(t,n,r,i){n!==null&&n.kind!==`AnonymousConditionSyntax`&&containsAnonymous(n)&&(negatesAnonymous(n)?t.error(e.NegatedAnonymousPolicy,`Policy '${r}' negates 'anonymous'; a policy that refuses callers without an identity says 'require authenticated'`,i):t.error(e.AnonymousPolicyCombined,`Policy '${r}' combines 'anonymous' with another condition; 'anonymous' admits callers without an identity and must be the whole 'require' condition`,i))}function containsAnonymous(e){switch(e.kind){case`AnonymousConditionSyntax`:return!0;case`NotPolicyConditionSyntax`:return containsAnonymous(e.operand);case`LogicalPolicyConditionSyntax`:return containsAnonymous(e.left)||containsAnonymous(e.right);default:return!1}}function negatesAnonymous(e){switch(e.kind){case`NotPolicyConditionSyntax`:return containsAnonymous(e.operand);case`LogicalPolicyConditionSyntax`:return negatesAnonymous(e.left)||negatesAnonymous(e.right);default:return!1}}export{parsePolicy};
2
2
  //# sourceMappingURL=PolicyParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PolicyParser.js","names":["pattern","parseMappingSource","headerPattern","nativePattern","diagnosticContext","context","name","header","DiagnosticCodes","locationOf","condition","code","file","hasRequire","description","line","firstWord","parseDescription","text","continuation","tokens","parsed","parseFile","parseCode","numeric","reportDiagnostics","position","token","unescapeString","operand","result","location","target","parseModeledMappingSource","expressionContext","left","right","policy"],"sources":["../../../../../../Compiler/Parsing/PolicyParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { CodeBlockSyntax, FileReferenceSyntax } from '../Syntax/Implementations';\nimport { PolicyConditionSyntax, PolicySyntax } from '../Syntax/Policies';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { nativePattern as pattern } from '../Text/patterns';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { parseCode, parseFile } from './ImplementationParser';\nimport { firstWord } from './LineText';\nimport { parseDescription } from './DescriptionParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst headerPattern = pattern('^policy\\\\s+([A-Za-z_]\\\\w*)$');\n\nexport function parsePolicy(context: ParserContext, header: SourceLine): PolicySyntax {\n const diagnosticContext = context;\n context = context.valueContext;\n const name = headerPattern.exec(header.content)?.[1] ?? '';\n if (name === '') context.error(DiagnosticCodes.InvalidPolicyDeclaration, `Invalid policy declaration '${header.content}' - expected 'policy <Name>'`, locationOf(header));\n let condition: PolicyConditionSyntax | null = null;\n let code: CodeBlockSyntax | null = null;\n let file: FileReferenceSyntax | null = null;\n let hasRequire = false;\n let description: string | null = null;\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (firstWord(line.content) === 'description') {\n description = parseDescription(diagnosticContext, line, description, `Policy '${name}'`);\n } else if (firstWord(line.content) === 'require') {\n let text = line.content.substring('require'.length).trim();\n for (let continuation = context.peekChild(line.indent); continuation !== undefined; continuation = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n text += ` ${continuation.content}`;\n }\n const tokens = tokenizePolicyCondition(context, text);\n // Negation is newly admitted syntax, not diagnostic-free enrichment of legacy fields.\n if (tokens.includes('not')) context = diagnosticContext;\n const parsed = parsePolicyCondition(context, tokens, locationOf(line), diagnosticContext);\n validateAnonymous(diagnosticContext, parsed, name, locationOf(line));\n if (hasRequire) context.error(DiagnosticCodes.RepeatedPolicyRequirement, `Policy '${name}' has more than one require line; combine the conditions with and/or in one require`, locationOf(line));\n else condition = parsed;\n hasRequire = true;\n } else if (firstWord(line.content) === 'file') {\n const parsed = parseFile(context, line);\n if (code === null && file === null) file = parsed;\n else context.error(DiagnosticCodes.UnknownPolicyDirective, `Policy '${name}' must have only one implementation - a file reference or an inline code block, not both`, locationOf(line));\n } else if (line.content.startsWith('```') || context.languages.has(line.content)) {\n const parsed = parseCode(context, line);\n if (code === null && file === null) code = parsed;\n else context.error(DiagnosticCodes.UnknownPolicyDirective, `Policy '${name}' must have only one implementation - a file reference or an inline code block, not both`, locationOf(line));\n } else {\n context.error(DiagnosticCodes.UnknownPolicyDirective, `Unexpected '${line.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`, locationOf(line));\n context.skipOpaqueBlock(line.indent);\n }\n }\n if (condition !== null && (code !== null || file !== null)) context.error(DiagnosticCodes.MixedPolicyImplementation, `Policy '${name}' cannot combine 'require' with a file or inline code block`, locationOf(header));\n if (condition === null && code === null && file === null) context.error(DiagnosticCodes.PolicyWithoutRequirement, `Policy '${name}' must declare a 'require' condition, a file reference or an inline code block`, locationOf(header));\n return { kind: 'PolicySyntax', name, condition, code, file, description, location: locationOf(header) };\n}\n\nfunction tokenizePolicyCondition(context: ParserContext, text: string): string[] {\n const numeric = context.sourceOptions.numericMode === 'exact' ? '-?[0-9]+(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\\\s()])|[\\\\w.$-]+|[^\\\\s]' : '[\\\\w.$]+';\n return [...(text.match(new RegExp(pattern(`\"${stringBodyPattern}\"|\\\\(|\\\\)|${numeric}`).source, 'gu')) ?? [])];\n}\n\nfunction parsePolicyCondition(context: ParserContext, tokens: string[], location: SourceLocation, expressionContext: ParserContext): PolicyConditionSyntax | null {\n const reportDiagnostics = context.sourceOptions.numericMode === 'exact' || tokens.includes('not');\n let position = 0;\n const quoted = (token: string | undefined): token is string => token !== undefined && token.startsWith('\"') && token.endsWith('\"');\n const unquote = (token: string): string => unescapeString(token.substring(1, token.length - 1));\n const group = (): PolicyConditionSyntax | null => {\n if (tokens[position] === 'not') {\n position++;\n const operand = group();\n return operand === null ? null : { kind: 'NotPolicyConditionSyntax', operand, location };\n }\n if (tokens[position] === '(') {\n position++;\n const result = or();\n if (tokens[position] === ')') position++;\n else if (reportDiagnostics) context.error(DiagnosticCodes.UnclosedPolicyConditionGroup, \"Expected ')' in policy condition\", location);\n return result;\n }\n const token = tokens[position++];\n if (token === 'authenticated') return { kind: 'AuthenticatedConditionSyntax', location };\n if (token === 'anonymous') return { kind: 'AnonymousConditionSyntax', location };\n if (token !== 'role' && token !== 'claim') {\n context.error(token === undefined ? DiagnosticCodes.ExpectedPolicyCondition : DiagnosticCodes.UnexpectedTokenInPolicyCondition, token === undefined ? 'Expected a policy condition' : `Unexpected '${token}' in policy condition`, location);\n return null;\n }\n const name = tokens[position++];\n if (!quoted(name)) {\n context.error(token === 'role' ? DiagnosticCodes.ExpectedRoleName : DiagnosticCodes.ExpectedClaimName, `Expected a quoted ${token} name after '${token}'`, location);\n return null;\n }\n if (token === 'role') return { kind: 'RoleConditionSyntax', role: unquote(name), location };\n if (tokens[position++] !== 'matches') {\n context.error(DiagnosticCodes.ExpectedClaimMatches, \"Expected 'matches' after the claim name\", location);\n return null;\n }\n const target = tokens[position++];\n if (target === undefined) {\n context.error(DiagnosticCodes.ExpectedClaimMatchTarget, \"Expected 'subject' or a value after 'matches'\", location);\n return null;\n }\n return { kind: 'ClaimConditionSyntax', claim: unquote(name), matchesSubject: target === 'subject', matches: target === 'subject' ? null : parseMappingSource(target, location, expressionContext), location };\n };\n const and = (): PolicyConditionSyntax | null => {\n let left = group();\n while (left !== null && tokens[position] === 'and') { position++; const right = group(); if (right === null) return null; left = { kind: 'LogicalPolicyConditionSyntax', left, operator: 'And', right, location }; }\n return left;\n };\n const or = (): PolicyConditionSyntax | null => {\n let left = and();\n while (left !== null && tokens[position] === 'or') { position++; const right = and(); if (right === null) return null; left = { kind: 'LogicalPolicyConditionSyntax', left, operator: 'Or', right, location }; }\n return left;\n };\n const condition = or();\n if (reportDiagnostics) {\n if (condition !== null && position < tokens.length) context.error(DiagnosticCodes.UnexpectedTokenInPolicyCondition, `Unexpected '${tokens[position]}' in policy condition`, location);\n }\n return condition;\n}\n\nfunction validateAnonymous(context: ParserContext, condition: PolicyConditionSyntax | null, policy: string, location: SourceLocation): void {\n if (condition === null || condition.kind === 'AnonymousConditionSyntax' || !containsAnonymous(condition)) return;\n if (negatesAnonymous(condition)) {\n context.error(DiagnosticCodes.NegatedAnonymousPolicy, `Policy '${policy}' negates 'anonymous'; a policy that refuses callers without an identity says 'require authenticated'`, location);\n return;\n }\n context.error(DiagnosticCodes.AnonymousPolicyCombined, `Policy '${policy}' combines 'anonymous' with another condition; 'anonymous' admits callers without an identity and must be the whole 'require' condition`, location);\n}\n\nfunction containsAnonymous(condition: PolicyConditionSyntax): boolean {\n switch (condition.kind) {\n case 'AnonymousConditionSyntax': return true;\n case 'NotPolicyConditionSyntax': return containsAnonymous(condition.operand);\n case 'LogicalPolicyConditionSyntax': return containsAnonymous(condition.left) || containsAnonymous(condition.right);\n default: return false;\n }\n}\n\nfunction negatesAnonymous(condition: PolicyConditionSyntax): boolean {\n switch (condition.kind) {\n case 'NotPolicyConditionSyntax': return containsAnonymous(condition.operand);\n case 'LogicalPolicyConditionSyntax': return negatesAnonymous(condition.left) || negatesAnonymous(condition.right);\n default: return false;\n }\n}\n"],"mappings":"+fAgBA,MAAME,EAAgBF,EAAQ,6BAA6B,EAE3D,SAAgB,YAAY,EAAwB,EAAkC,CAClF,IAAMI,EAAoBC,EAC1B,EAAUA,EAAQ,aAClB,IAAMC,EAAOJ,EAAc,KAAKK,EAAO,OAAO,CAAC,GAAG,IAAM,GACpDD,IAAS,IAAID,EAAQ,MAAMG,EAAgB,yBAA0B,+BAA+BD,EAAO,QAAQ,8BAA+BE,EAAWF,CAAM,CAAC,EACxK,IAAIG,EAA0C,KAC1CC,EAA+B,KAC/BC,EAAmC,KACnCC,EAAa,GACbC,EAA6B,KACjC,IAAK,IAAIC,EAAOV,EAAQ,UAAUE,EAAO,MAAM,EAAGQ,IAAS,IAAA,GAAW,EAAOV,EAAQ,UAAUE,EAAO,MAAM,EAExG,GADAF,EAAQ,OAAO,gBAAgB,EAC3BW,EAAUD,EAAK,OAAO,IAAM,cAC5B,EAAcE,EAAiBb,EAAmBW,EAAMD,EAAa,WAAWR,EAAK,EAA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IAAU,KAAM,OAAO,KAAM,EAAO,CAAE,KAAM,+BAAgC,OAAM,SAAU,KAAM,QAAO,UAAS,CAAG,CAC/M,OAAOD,CACX,EACMzB,EAAY,GAAG,EAIrB,OAHIe,GACIf,IAAc,MAAQgB,EAAWN,EAAO,QAAQf,EAAQ,MAAMG,EAAgB,iCAAkC,eAAeY,EAAOM,GAAU,uBAAwBK,CAAQ,EAEjLrB,CACX,CAEA,SAAS,kBAAkB,EAAwB,EAAyC,EAAgB,EAAgC,CACpIA,IAAc,MAAQA,EAAU,OAAS,4BAA+B,kBAAkBA,CAAS,IACnG,iBAAiBA,CAAS,EAC1BL,EAAQ,MAAMG,EAAgB,uBAAwB,WAAW6B,EAAO,uGAAwGN,CAAQ,EAG5L1B,EAAQ,MAAMG,EAAgB,wBAAyB,WAAW6B,EAAO,yIAA0IN,CAAQ,EAC/N,CAEA,SAAS,kBAAkB,EAA2C,CAClE,OAAQrB,EAAU,KAAlB,CACI,IAAK,2BAA4B,MAAO,GACxC,IAAK,2BAA4B,OAAO,kBAAkBA,EAAU,OAAO,EAC3E,IAAK,+BAAgC,OAAO,kBAAkBA,EAAU,IAAI,GAAK,kBAAkBA,EAAU,KAAK,EAClH,QAAS,MAAO,EACpB,CACJ,CAEA,SAAS,iBAAiB,EAA2C,CACjE,OAAQA,EAAU,KAAlB,CACI,IAAK,2BAA4B,OAAO,kBAAkBA,EAAU,OAAO,EAC3E,IAAK,+BAAgC,OAAO,iBAAiBA,EAAU,IAAI,GAAK,iBAAiBA,EAAU,KAAK,EAChH,QAAS,MAAO,EACpB,CACJ"}
1
+ {"version":3,"file":"PolicyParser.js","names":["pattern","parseMappingSource","headerPattern","nativePattern","diagnosticContext","context","name","header","DiagnosticCodes","locationOf","condition","code","file","hasRequire","depthExceeded","description","line","firstWord","parseDescription","text","continuation","tokens","budget","ConditionDepthBudget","parsed","parseFile","parseCode","numeric","reportDiagnostics","position","token","unescapeString","negated","operand","result","location","target","parseModeledMappingSource","expressionContext","left","right","previous","policy"],"sources":["../../../../../../Compiler/Parsing/PolicyParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { CodeBlockSyntax, FileReferenceSyntax } from '../Syntax/Implementations';\nimport { PolicyConditionSyntax, PolicySyntax } from '../Syntax/Policies';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { nativePattern as pattern } from '../Text/patterns';\nimport { parseModeledMappingSource as parseMappingSource } from './ExpressionParser';\nimport { parseCode, parseFile } from './ImplementationParser';\nimport { firstWord } from './LineText';\nimport { parseDescription } from './DescriptionParser';\nimport { ParserContext } from './ParserContext';\nimport { ConditionDepthBudget } from './ConditionDepthBudget';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst headerPattern = pattern('^policy\\\\s+([A-Za-z_]\\\\w*)$');\n\nexport function parsePolicy(context: ParserContext, header: SourceLine): PolicySyntax {\n const diagnosticContext = context;\n context = context.valueContext;\n const name = headerPattern.exec(header.content)?.[1] ?? '';\n if (name === '') context.error(DiagnosticCodes.InvalidPolicyDeclaration, `Invalid policy declaration '${header.content}' - expected 'policy <Name>'`, locationOf(header));\n let condition: PolicyConditionSyntax | null = null;\n let code: CodeBlockSyntax | null = null;\n let file: FileReferenceSyntax | null = null;\n let hasRequire = false;\n let depthExceeded = false;\n let description: string | null = null;\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (firstWord(line.content) === 'description') {\n description = parseDescription(diagnosticContext, line, description, `Policy '${name}'`);\n } else if (firstWord(line.content) === 'require') {\n let text = line.content.substring('require'.length).trim();\n for (let continuation = context.peekChild(line.indent); continuation !== undefined; continuation = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n text += ` ${continuation.content}`;\n }\n const tokens = tokenizePolicyCondition(context, text);\n // Negation is newly admitted syntax, not diagnostic-free enrichment of legacy fields.\n if (tokens.includes('not')) context = diagnosticContext;\n const budget = new ConditionDepthBudget(diagnosticContext, locationOf(line));\n const parsed = parsePolicyCondition(context, tokens, locationOf(line), diagnosticContext, budget);\n depthExceeded ||= budget.exceeded;\n validateAnonymous(diagnosticContext, parsed, name, locationOf(line));\n if (hasRequire) context.error(DiagnosticCodes.RepeatedPolicyRequirement, `Policy '${name}' has more than one require line; combine the conditions with and/or in one require`, locationOf(line));\n else condition = parsed;\n hasRequire = true;\n } else if (firstWord(line.content) === 'file') {\n const parsed = parseFile(context, line);\n if (code === null && file === null) file = parsed;\n else context.error(DiagnosticCodes.UnknownPolicyDirective, `Policy '${name}' must have only one implementation - a file reference or an inline code block, not both`, locationOf(line));\n } else if (line.content.startsWith('```') || context.languages.has(line.content)) {\n const parsed = parseCode(context, line);\n if (code === null && file === null) code = parsed;\n else context.error(DiagnosticCodes.UnknownPolicyDirective, `Policy '${name}' must have only one implementation - a file reference or an inline code block, not both`, locationOf(line));\n } else {\n context.error(DiagnosticCodes.UnknownPolicyDirective, `Unexpected '${line.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`, locationOf(line));\n context.skipOpaqueBlock(line.indent);\n }\n }\n if (condition !== null && (code !== null || file !== null)) context.error(DiagnosticCodes.MixedPolicyImplementation, `Policy '${name}' cannot combine 'require' with a file or inline code block`, locationOf(header));\n if (condition === null && code === null && file === null && !depthExceeded) context.error(DiagnosticCodes.PolicyWithoutRequirement, `Policy '${name}' must declare a 'require' condition, a file reference or an inline code block`, locationOf(header));\n return { kind: 'PolicySyntax', name, condition, code, file, description, location: locationOf(header) };\n}\n\nfunction tokenizePolicyCondition(context: ParserContext, text: string): string[] {\n const numeric = context.sourceOptions.numericMode === 'exact' ? '-?[0-9]+(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\\\s()])|[\\\\w.$-]+|[^\\\\s]' : '[\\\\w.$]+';\n return [...(text.match(new RegExp(pattern(`\"${stringBodyPattern}\"|\\\\(|\\\\)|${numeric}`).source, 'gu')) ?? [])];\n}\n\nfunction parsePolicyCondition(context: ParserContext, tokens: string[], location: SourceLocation, expressionContext: ParserContext, budget: ConditionDepthBudget): PolicyConditionSyntax | null {\n const reportDiagnostics = context.sourceOptions.numericMode === 'exact' || tokens.includes('not');\n let position = 0;\n const quoted = (token: string | undefined): token is string => token !== undefined && token.startsWith('\"') && token.endsWith('\"');\n const unquote = (token: string): string => unescapeString(token.substring(1, token.length - 1));\n const group = (): PolicyConditionSyntax | null => {\n if (tokens[position] === 'not' || tokens[position] === '(') {\n if (!budget.enter()) return null;\n const negated = tokens[position++] === 'not';\n try {\n if (negated) {\n const operand = group();\n return operand === null ? null : budget.build<PolicyConditionSyntax>([operand], () => ({ kind: 'NotPolicyConditionSyntax', operand, location }));\n }\n const result = or();\n if (budget.exceeded) return null;\n if (tokens[position] === ')') position++;\n else if (reportDiagnostics) context.error(DiagnosticCodes.UnclosedPolicyConditionGroup, \"Expected ')' in policy condition\", location);\n return result;\n } finally { budget.leave(); }\n }\n const token = tokens[position++];\n if (token === 'authenticated') return { kind: 'AuthenticatedConditionSyntax', location };\n if (token === 'anonymous') return { kind: 'AnonymousConditionSyntax', location };\n if (token !== 'role' && token !== 'claim') {\n context.error(token === undefined ? DiagnosticCodes.ExpectedPolicyCondition : DiagnosticCodes.UnexpectedTokenInPolicyCondition, token === undefined ? 'Expected a policy condition' : `Unexpected '${token}' in policy condition`, location);\n return null;\n }\n const name = tokens[position++];\n if (!quoted(name)) {\n context.error(token === 'role' ? DiagnosticCodes.ExpectedRoleName : DiagnosticCodes.ExpectedClaimName, `Expected a quoted ${token} name after '${token}'`, location);\n return null;\n }\n if (token === 'role') return { kind: 'RoleConditionSyntax', role: unquote(name), location };\n if (tokens[position++] !== 'matches') {\n context.error(DiagnosticCodes.ExpectedClaimMatches, \"Expected 'matches' after the claim name\", location);\n return null;\n }\n const target = tokens[position++];\n if (target === undefined) {\n context.error(DiagnosticCodes.ExpectedClaimMatchTarget, \"Expected 'subject' or a value after 'matches'\", location);\n return null;\n }\n return { kind: 'ClaimConditionSyntax', claim: unquote(name), matchesSubject: target === 'subject', matches: target === 'subject' ? null : parseMappingSource(target, location, expressionContext), location };\n };\n const and = (): PolicyConditionSyntax | null => {\n let left = group();\n while (left !== null && tokens[position] === 'and') {\n position++; const right = group(); if (right === null) return null;\n const previous: PolicyConditionSyntax = left;\n left = budget.build<PolicyConditionSyntax>([previous, right], () => ({ kind: 'LogicalPolicyConditionSyntax', left: previous, operator: 'And', right, location }));\n }\n return left;\n };\n const or = (): PolicyConditionSyntax | null => {\n let left = and();\n while (left !== null && tokens[position] === 'or') {\n position++; const right = and(); if (right === null) return null;\n const previous: PolicyConditionSyntax = left;\n left = budget.build<PolicyConditionSyntax>([previous, right], () => ({ kind: 'LogicalPolicyConditionSyntax', left: previous, operator: 'Or', right, location }));\n }\n return left;\n };\n const condition = or();\n if (reportDiagnostics) {\n if (condition !== null && position < tokens.length) context.error(DiagnosticCodes.UnexpectedTokenInPolicyCondition, `Unexpected '${tokens[position]}' in policy condition`, location);\n }\n return condition;\n}\n\nfunction validateAnonymous(context: ParserContext, condition: PolicyConditionSyntax | null, policy: string, location: SourceLocation): void {\n if (condition === null || condition.kind === 'AnonymousConditionSyntax' || !containsAnonymous(condition)) return;\n if (negatesAnonymous(condition)) {\n context.error(DiagnosticCodes.NegatedAnonymousPolicy, `Policy '${policy}' negates 'anonymous'; a policy that refuses callers without an identity says 'require authenticated'`, location);\n return;\n }\n context.error(DiagnosticCodes.AnonymousPolicyCombined, `Policy '${policy}' combines 'anonymous' with another condition; 'anonymous' admits callers without an identity and must be the whole 'require' condition`, location);\n}\n\nfunction containsAnonymous(condition: PolicyConditionSyntax): boolean {\n switch (condition.kind) {\n case 'AnonymousConditionSyntax': return true;\n case 'NotPolicyConditionSyntax': return containsAnonymous(condition.operand);\n case 'LogicalPolicyConditionSyntax': return containsAnonymous(condition.left) || containsAnonymous(condition.right);\n default: return false;\n }\n}\n\nfunction negatesAnonymous(condition: PolicyConditionSyntax): boolean {\n switch (condition.kind) {\n case 'NotPolicyConditionSyntax': return containsAnonymous(condition.operand);\n case 'LogicalPolicyConditionSyntax': return negatesAnonymous(condition.left) || negatesAnonymous(condition.right);\n default: return false;\n }\n}\n"],"mappings":"A,gkBAiBA,MAAME,EAAgBF,EAAQ,6BAA6B,EAE3D,SAAgB,YAAY,EAAwB,EAAkC,CAClF,IAAMI,EAAoBC,EAC1B,EAAUA,EAAQ,aAClB,IAAMC,EAAOJ,EAAc,KAAKK,EAAO,OAAO,CAAC,GAAG,IAAM,GACpDD,IAAS,IAAID,EAAQ,MAAMG,EAAgB,yBAA0B,+BAA+BD,EAAO,QAAQ,8BAA+BE,EAAWF,CAAM,CAAC,EACxK,IAAIG,EAA0C,KAC1CC,EAA+B,KAC/BC,EAAmC,KACnCC,EAAa,GACbC,EAAgB,GAChBC,EAA6B,KACjC,IAAK,IAAIC,EAAOX,EAAQ,UAAUE,EAAO,MAAM,EAAGS,IAAS,IAAA,GAAW,EAAOX,EAAQ,UAAUE,EAAO,MAAM,EAExG,GADAF,EAAQ,OAAO,gBAAgB,EAC3BY,EAAUD,EAAK,OAAO,IAAM,cAC5B,EAAcE,EAAiBd,EAAmBY,EAAMD,EAAa,WAAWT,EAAK,EAAE,OACpF,GAAIW,EAAUD,EAAK,OAAO,IAAM,UAAW,CAC9C,IAAIG,EAAOH,EAAK,QAAQ,UAAU,CAAgB,CAAC,CAAC,KAAK,EACzD,IAAK,IAAII,EAAef,EAAQ,UAAUW,EAAK,MAAM,EAAGI,IAAiB,IAAA,GAAW,EAAef,EAAQ,UAAUW,EAAK,MAAM,EAC5HX,EAAQ,OAAO,gBAAgB,EAC/B,GAAQ,IAAIe,EAAa,UAE7B,IAAMC,EAAS,wBAAwBhB,EAASc,CAAI,EAEhDE,EAAO,SAAS,KAAK,IAAG,EAAUjB,GACtC,IAAMkB,EAAS,IAAIC,EAAqB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AM,OAAO,KAC5D,IAAMC,EAAkCF,EACxC,EAAOjB,EAAO,MAA6B,CAACmB,EAAUD,CAAK,OAAU,CAAE,KAAM,+BAAgC,KAAMC,EAAU,SAAU,KAAM,QAAO,UAAS,EAAE,CACnK,CACA,OAAOF,CACX,EACM7B,EAAY,GAAG,EAIrB,OAHIkB,GACIlB,IAAc,MAAQmB,EAAWR,EAAO,QAAQhB,EAAQ,MAAMG,EAAgB,iCAAkC,eAAea,EAAOQ,GAAU,uBAAwBM,CAAQ,EAEjLzB,CACX,CAEA,SAAS,kBAAkB,EAAwB,EAAyC,EAAgB,EAAgC,CACpIA,IAAc,MAAQA,EAAU,OAAS,4BAA+B,kBAAkBA,CAAS,IACnG,iBAAiBA,CAAS,EAC1BL,EAAQ,MAAMG,EAAgB,uBAAwB,WAAWkC,EAAO,uGAAwGP,CAAQ,EAG5L9B,EAAQ,MAAMG,EAAgB,wBAAyB,WAAWkC,EAAO,yIAA0IP,CAAQ,EAC/N,CAEA,SAAS,kBAAkB,EAA2C,CAClE,OAAQzB,EAAU,KAAlB,CACI,IAAK,2BAA4B,MAAO,GACxC,IAAK,2BAA4B,OAAO,kBAAkBA,EAAU,OAAO,EAC3E,IAAK,+BAAgC,OAAO,kBAAkBA,EAAU,IAAI,GAAK,kBAAkBA,EAAU,KAAK,EAClH,QAAS,MAAO,EACpB,CACJ,CAEA,SAAS,iBAAiB,EAA2C,CACjE,OAAQA,EAAU,KAAlB,CACI,IAAK,2BAA4B,OAAO,kBAAkBA,EAAU,OAAO,EAC3E,IAAK,+BAAgC,OAAO,iBAAiBA,EAAU,IAAI,GAAK,iBAAiBA,EAAU,KAAK,EAChH,QAAS,MAAO,EACpB,CACJ,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"PortableMatchGroupName.js","names":["decoded","name","value","braced","fixed"],"sources":["../../../../../../Compiler/Parsing/PortableMatchGroupName.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** RegExpIdentifierName uses Unicode identifiers, even in flagless JavaScript. */\nexport function isJavaScriptGroupName(name: string): boolean {\n const decoded = name.replace(/\\\\u(?:\\{([0-9a-fA-F]+)\\}|([0-9a-fA-F]{4}))/g, (_, braced: string | undefined, fixed: string | undefined) => {\n const value = parseInt(braced ?? fixed!, 16);\n return value <= 0x10ffff ? String.fromCodePoint(value) : '\\\\';\n });\n return /^[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*$/u.test(decoded);\n}\n"],"mappings":"qDAIA,SAAgB,sBAAsB,EAAuB,CACzD,IAAMA,EAAUC,EAAK,QAAQ,+CAAgD,EAAG,EAA4B,IAA8B,CACtI,IAAMC,EAAQ,SAASC,GAAUC,EAAQ,EAAE,EAC3C,OAAOF,GAAS,QAAW,OAAO,cAAcA,CAAK,EAAI,IAC7D,CAAC,EACD,MAAO,qDAAqD,KAAKF,CAAO,CAC5E"}
1
+ {"version":3,"file":"PortableMatchGroupName.js","names":["decoded","name","value","braced","fixed"],"sources":["../../../../../../Compiler/Parsing/PortableMatchGroupName.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** RegExpIdentifierName uses Unicode identifiers, even in flagless JavaScript. */\nexport function isJavaScriptGroupName(name: string): boolean {\n const decoded = name.replace(/\\\\u(?:\\{([0-9a-fA-F]+)\\}|([0-9a-fA-F]{4}))/g, (_, braced: string | undefined, fixed: string | undefined) => {\n const value = parseInt(braced ?? fixed!, 16);\n return value <= 0x10ffff ? String.fromCodePoint(value) : '\\\\';\n });\n return /^[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*$/u.test(decoded);\n}\n"],"mappings":"A,qDAIA,SAAgB,sBAAsB,EAAuB,CACzD,IAAMA,EAAUC,EAAK,QAAQ,+CAAgD,EAAG,EAA4B,IAA8B,CACtI,IAAMC,EAAQ,SAASC,GAAUC,EAAQ,EAAE,EAC3C,OAAOF,GAAS,QAAW,OAAO,cAAcA,CAAK,EAAI,IAC7D,CAAC,EACD,MAAO,qDAAqD,KAAKF,CAAO,CAC5E,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"PortableMatchPattern.js","names":["emailMatchPattern","sizeLimit","pattern","expression","size","budgetOffset","branch","start","atom","character","nameStart","name","isJavaScriptGroupName","body","negated","left","rangeOffset","right","escape","width","hex","inClass","count","choices","minimum","maximum","expanded","value","occurrences","previous","current","invalid","portableMatchSuggestions","construct"],"sources":["../../../../../../Compiler/Parsing/PortableMatchPattern.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 { isJavaScriptGroupName } from './PortableMatchGroupName';\nimport { portableMatchSuggestions } from './PortableMatchSuggestions';\n\nexport const emailMatchPattern = '^[^\\\\s@]+@[^\\\\s@.]+(?:\\\\.[^\\\\s@.]+)+$';\nexport interface MatchPatternIssue { construct: string; offset: number; invalid: boolean; suggestion?: string }\ninterface Fragment { size: number; quantifiable: boolean; budgetOffset?: number }\ninterface Branch { scope: number; alternative: number }\nconst sizeLimit = 3000;\n\n/** Decision 0084. This validates syntax without invoking a browser's backtracking engine. */\nexport function validateMatchPattern(pattern: string): MatchPatternIssue | undefined {\n return new PortableMatchParser(pattern).parse();\n}\n\nclass PortableMatchParser {\n private offset = 0;\n private issue: MatchPatternIssue | undefined;\n private readonly names = new Map<string, Branch[][]>();\n private readonly branches: Branch[] = [];\n private scope = 0;\n constructor(private readonly pattern: string) { }\n\n parse(): MatchPatternIssue | undefined {\n if (this.pattern.length > 1000) this.fail('pattern length', 1000);\n const expression = this.expression();\n if (this.issue === undefined && this.offset !== this.pattern.length) this.fail('unmatched closing group', this.offset, true);\n if (expression.size > sizeLimit) this.fail('expanded pattern size', expression.budgetOffset ?? this.offset);\n return this.issue;\n }\n\n private expression(): Fragment {\n let size = 0;\n let budgetOffset: number | undefined;\n const branch: Branch = { scope: this.scope++, alternative: 0 };\n this.branches.push(branch);\n while (this.issue === undefined && this.offset < this.pattern.length && !this.at(')')) {\n if (this.at('|')) {\n size = Math.min(sizeLimit + 1, size + 1);\n if (size > sizeLimit) budgetOffset ??= this.offset;\n this.offset++;\n branch.alternative++;\n continue;\n }\n const start = this.offset;\n const atom = this.quantify(this.atom());\n size = Math.min(sizeLimit + 1, size + atom.size);\n if (size > sizeLimit) budgetOffset ??= atom.budgetOffset ?? start;\n }\n this.branches.pop();\n return { size, quantifiable: true, budgetOffset };\n }\n\n private atom(): Fragment {\n const start = this.offset;\n const character = this.pattern[this.offset++];\n if (character === '(') return this.group(start);\n if (character === '[') this.characterClass(start);\n else if (character === '\\\\') this.escape(start, false);\n else if (character === ']') this.fail('unescaped closing bracket', start);\n else if (character === '{' && /^\\{[0-9]+(?:,[0-9]*)?\\}/.test(this.pattern.slice(start))) this.fail('quantifier without an atom', start, true);\n else if (character === '{' || character === '}') this.fail('unescaped brace', start);\n else if ('*+?'.includes(character)) this.fail('quantifier without an atom', start, true);\n return { size: 1, quantifiable: character !== '^' && character !== '$' };\n }\n\n private group(start: number): Fragment {\n if (this.take('?')) {\n if (this.take(':')) { /* Non-capturing group. */ }\n else if (this.at('=') || this.at('!') || (this.at('<') && '=!'.includes(this.pattern[this.offset + 1] ?? ' '))) this.fail('lookaround', start);\n else if (this.take('<')) {\n const nameStart = this.offset;\n while (this.offset < this.pattern.length && !this.at('>')) this.offset++;\n const name = this.pattern.slice(nameStart, this.offset);\n if (!this.take('>')) this.fail('unterminated group name', nameStart, true);\n else if (!isJavaScriptGroupName(name)) this.fail('group name', nameStart, true);\n else if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) this.fail('group name', nameStart);\n else this.registerName(name, nameStart);\n } else this.fail('ims-'.includes(this.pattern[this.offset] ?? ' ') ? 'inline options' : 'group extension', start);\n }\n const body = this.expression();\n if (!this.take(')')) this.fail('unterminated group', start, true);\n return body;\n }\n\n private characterClass(start: number): void {\n const negated = this.take('^');\n if (this.at(']')) this.fail(negated ? 'negated empty character class' : 'empty character class', start);\n while (this.issue === undefined && this.offset < this.pattern.length && !this.at(']')) {\n if (this.at('-') && this.offset + 1 < this.pattern.length && this.pattern[this.offset + 1] === '[') this.fail('class subtraction', this.offset);\n const left = this.classItem();\n if (this.at('-') && this.offset + 1 < this.pattern.length && this.pattern[this.offset + 1] !== ']') {\n const rangeOffset = this.offset++;\n if (this.at('[')) this.fail('class subtraction', rangeOffset);\n const right = this.classItem();\n if (left === undefined || right === undefined) this.fail('class escape range endpoint', rangeOffset);\n else if (left > right) this.fail('reversed character range', rangeOffset, true);\n }\n }\n if (!this.take(']')) this.fail('unterminated character class', start, true);\n }\n\n private classItem(): number | undefined {\n if (this.offset >= this.pattern.length) { this.fail('unterminated character class', this.offset, true); return undefined; }\n const start = this.offset;\n const character = this.pattern[this.offset++];\n return character === '\\\\' ? this.escape(start, true) : character.charCodeAt(0);\n }\n\n private escape(start: number, inClass: boolean): number | undefined {\n if (this.offset === this.pattern.length) { this.fail('trailing backslash', start, true); return undefined; }\n const escape = this.pattern[this.offset++];\n if ('dDwWsS'.includes(escape)) return undefined;\n if (escape === '0' && /[0-9]/.test(this.pattern[this.offset] ?? ' ')) this.fail('octal escape', start);\n else if ('tnrfv0'.includes(escape)) return ({ t: 9, n: 10, r: 13, f: 12, v: 11, '0': 0 } as Record<string, number>)[escape];\n else if (escape === 'x' || (escape === 'u' && !this.at('{'))) {\n const width = escape === 'x' ? 2 : 4;\n const hex = this.pattern.slice(this.offset, this.offset + width);\n if (hex.length !== width || !/^[0-9a-fA-F]+$/.test(hex)) this.fail('invalid hexadecimal escape', start, true);\n else { this.offset += width; return parseInt(hex, 16); }\n } else if ('^$\\\\.*+?()[]{}|/'.includes(escape) || (inClass && escape === '-')) return escape.charCodeAt(0);\n else this.fail(escapeConstruct(escape, inClass), start);\n return undefined;\n }\n\n private quantify(atom: Fragment): Fragment {\n if (this.issue !== undefined || this.offset >= this.pattern.length) return atom;\n const start = this.offset;\n let count = 1n;\n let choices = 1n;\n if (this.at('*') || this.at('+') || this.at('?')) this.offset++;\n else if (this.take('{')) {\n const minimum = this.digits();\n if (minimum === undefined) { this.fail('unescaped brace', start); return atom; }\n count = minimum;\n choices = 0n;\n if (this.take(',')) {\n if (this.at('}')) { count = minimum + 1n; choices = 1n; }\n else {\n const maximum = this.digits();\n if (maximum === undefined) { this.fail('unescaped brace', start); return atom; }\n count = maximum;\n choices = maximum - minimum;\n if (count < minimum) this.fail('reversed counted repeat', start, true);\n }\n }\n if (!this.take('}')) this.fail('unescaped brace', start);\n } else return atom;\n if (!atom.quantifiable) this.fail('quantified assertion', start, true);\n this.take('?');\n const expanded = BigInt(atom.size) * count + choices;\n const size = Number(expanded > BigInt(sizeLimit + 1) ? BigInt(sizeLimit + 1) : expanded);\n return { size, quantifiable: false, budgetOffset: size > sizeLimit ? atom.budgetOffset ?? start : undefined };\n }\n\n private digits(): bigint | undefined {\n const start = this.offset;\n let value = 0n;\n while (this.offset < this.pattern.length && /[0-9]/.test(this.pattern[this.offset])) value = value * 10n + BigInt(this.pattern[this.offset++]);\n return this.offset === start ? undefined : value;\n }\n\n private registerName(name: string, start: number): void {\n const occurrences = this.names.get(name) ?? [];\n const disjoint = (previous: Branch[]) => previous.some(branch => this.branches.some(current => current.scope === branch.scope && current.alternative !== branch.alternative));\n if (occurrences.some(previous => !disjoint(previous))) this.fail('duplicate group name', start, true);\n occurrences.push(this.branches.map(branch => ({ ...branch })));\n this.names.set(name, occurrences);\n }\n\n private at(character: string): boolean { return this.offset < this.pattern.length && this.pattern[this.offset] === character; }\n private take(character: string): boolean { if (!this.at(character)) return false; this.offset++; return true; }\n private fail(construct: string, offset: number, invalid = false): void {\n this.issue ??= { construct, offset, invalid, suggestion: invalid ? undefined : portableMatchSuggestions[construct] };\n }\n}\n\nfunction escapeConstruct(escape: string, inClass: boolean): string {\n if ('123456789k'.includes(escape)) return 'backreference';\n if (escape === 'b' && inClass) return 'class backspace escape';\n if ('bB'.includes(escape)) return 'word boundary';\n if ('pP'.includes(escape)) return 'Unicode property escape';\n if (escape === 'u') return 'Unicode code point escape';\n if (escape === 'c') return 'control escape';\n if (escape === 'A') return 'start of input escape';\n if ('zZ'.includes(escape)) return 'end of input escape';\n return 'identity escape';\n}\n"],"mappings":"kMAMA,MAAaA,EAAoB,wCAI3BC,EAAY,IAGlB,SAAgB,qBAAqB,EAAgD,CACjF,OAAO,IAAI,oBAAoBC,CAAO,CAAC,CAAC,MAAM,CAClD,CAEA,IAAM,oBAAN,KAA0B,CAMO,QAL7B,OAAiB,EACjB,MACA,sBAAyB,IAAI,IAC7B,SAAsC,CAAC,EACvC,MAAgB,EAChB,YAAY,EAAkC,CAAjB,KAAA,QAAAA,CAAmB,CAEhD,OAAuC,CAC/B,KAAK,QAAQ,OAAS,KAAM,KAAK,KAAK,iBAAkB,GAAI,EAChE,IAAMC,EAAa,KAAK,WAAW,EAGnC,OAFI,KAAK,QAAU,IAAA,IAAa,KAAK,SAAW,KAAK,QAAQ,QAAQ,KAAK,KAAK,0BAA2B,KAAK,OAAQ,EAAI,EACvHA,EAAW,KAAOF,GAAW,KAAK,KAAK,wBAAyBE,EAAW,cAAgB,KAAK,MAAM,EACnG,KAAK,KAChB,CAEA,YAA+B,CAC3B,IAAIC,EAAO,EACPC,EACEC,EAAiB,CAAE,MAAO,KAAK,QAAS,YAAa,CAAE,EAE7D,IADA,KAAK,SAAS,KAAKA,CAAM,EAClB,KAAK,QAAU,IAAA,IAAa,KAAK,OAAS,KAAK,QAAQ,QAAU,CAAC,KAAK,GAAG,GAAG,GAAG,CACnF,GAAI,KAAK,GAAG,GAAG,EAAG,CACd,EAAO,KAAK,IAAI,KAAeF,EAAO,CAAC,EACnCA,EAAOH,IAAW,IAAiB,KAAK,QAC5C,KAAK,SACL,EAAO,cACP,QACJ,CACA,IAAMM,EAAQ,KAAK,OACbC,EAAO,KAAK,SAAS,KAAK,KAAK,CAAC,EACtC,EAAO,KAAK,IAAI,KAAeJ,EAAO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B,CACpD,IAAMC,EAAc,KAAK,MAAM,IAAIjB,CAAI,GAAK,CAAC,EACvC,SAAY,GAAuBkB,EAAS,KAAK,GAAU,KAAK,SAAS,KAAK,GAAWC,EAAQ,QAAUxB,EAAO,OAASwB,EAAQ,cAAgBxB,EAAO,WAAW,CAAC,EACxKsB,EAAY,KAAK,GAAY,CAAC,SAASC,CAAQ,CAAC,GAAG,KAAK,KAAK,uBAAwBtB,EAAO,EAAI,EACpGqB,EAAY,KAAK,KAAK,SAAS,IAAI,IAAW,CAAE,GAAGtB,CAAO,EAAE,CAAC,EAC7D,KAAK,MAAM,IAAIK,EAAMiB,CAAW,CACpC,CAEA,GAAW,EAA4B,CAAE,OAAO,KAAK,OAAS,KAAK,QAAQ,QAAU,KAAK,QAAQ,KAAK,UAAYnB,CAAW,CAC9H,KAAa,EAA4B,CAAwD,OAAjD,KAAK,GAAGA,CAAS,GAAiB,KAAK,SAAiB,IAA7B,EAAmC,CAC9G,KAAa,EAAmB,EAAgB,EAAU,GAAa,CACnE,KAAK,QAAU,CAAE,YAAW,SAAQ,UAAS,WAAYsB,EAAU,IAAA,GAAYC,EAAyBC,EAAW,CACvH,CACJ,EAEA,SAAS,gBAAgB,EAAgB,EAA0B,CAS/D,MARI,aAAa,SAASf,CAAM,EAAU,gBACtCA,IAAW,KAAOG,EAAgB,yBAClC,KAAK,SAASH,CAAM,EAAU,gBAC9B,KAAK,SAASA,CAAM,EAAU,0BAC9BA,IAAW,IAAY,4BACvBA,IAAW,IAAY,iBACvBA,IAAW,IAAY,wBACvB,KAAK,SAASA,CAAM,EAAU,sBAC3B,iBACX"}
1
+ {"version":3,"file":"PortableMatchPattern.js","names":["emailMatchPattern","sizeLimit","pattern","expression","size","budgetOffset","branch","start","atom","character","nameStart","name","isJavaScriptGroupName","body","negated","left","rangeOffset","right","escape","width","hex","inClass","count","choices","minimum","maximum","expanded","value","occurrences","previous","current","invalid","portableMatchSuggestions","construct"],"sources":["../../../../../../Compiler/Parsing/PortableMatchPattern.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 { isJavaScriptGroupName } from './PortableMatchGroupName';\nimport { portableMatchSuggestions } from './PortableMatchSuggestions';\n\nexport const emailMatchPattern = '^[^\\\\s@]+@[^\\\\s@.]+(?:\\\\.[^\\\\s@.]+)+$';\nexport interface MatchPatternIssue { construct: string; offset: number; invalid: boolean; suggestion?: string }\ninterface Fragment { size: number; quantifiable: boolean; budgetOffset?: number }\ninterface Branch { scope: number; alternative: number }\nconst sizeLimit = 3000;\n\n/** Decision 0084. This validates syntax without invoking a browser's backtracking engine. */\nexport function validateMatchPattern(pattern: string): MatchPatternIssue | undefined {\n return new PortableMatchParser(pattern).parse();\n}\n\nclass PortableMatchParser {\n private offset = 0;\n private issue: MatchPatternIssue | undefined;\n private readonly names = new Map<string, Branch[][]>();\n private readonly branches: Branch[] = [];\n private scope = 0;\n constructor(private readonly pattern: string) { }\n\n parse(): MatchPatternIssue | undefined {\n if (this.pattern.length > 1000) this.fail('pattern length', 1000);\n const expression = this.expression();\n if (this.issue === undefined && this.offset !== this.pattern.length) this.fail('unmatched closing group', this.offset, true);\n if (expression.size > sizeLimit) this.fail('expanded pattern size', expression.budgetOffset ?? this.offset);\n return this.issue;\n }\n\n private expression(): Fragment {\n let size = 0;\n let budgetOffset: number | undefined;\n const branch: Branch = { scope: this.scope++, alternative: 0 };\n this.branches.push(branch);\n while (this.issue === undefined && this.offset < this.pattern.length && !this.at(')')) {\n if (this.at('|')) {\n size = Math.min(sizeLimit + 1, size + 1);\n if (size > sizeLimit) budgetOffset ??= this.offset;\n this.offset++;\n branch.alternative++;\n continue;\n }\n const start = this.offset;\n const atom = this.quantify(this.atom());\n size = Math.min(sizeLimit + 1, size + atom.size);\n if (size > sizeLimit) budgetOffset ??= atom.budgetOffset ?? start;\n }\n this.branches.pop();\n return { size, quantifiable: true, budgetOffset };\n }\n\n private atom(): Fragment {\n const start = this.offset;\n const character = this.pattern[this.offset++];\n if (character === '(') return this.group(start);\n if (character === '[') this.characterClass(start);\n else if (character === '\\\\') this.escape(start, false);\n else if (character === ']') this.fail('unescaped closing bracket', start);\n else if (character === '{' && /^\\{[0-9]+(?:,[0-9]*)?\\}/.test(this.pattern.slice(start))) this.fail('quantifier without an atom', start, true);\n else if (character === '{' || character === '}') this.fail('unescaped brace', start);\n else if ('*+?'.includes(character)) this.fail('quantifier without an atom', start, true);\n return { size: 1, quantifiable: character !== '^' && character !== '$' };\n }\n\n private group(start: number): Fragment {\n if (this.take('?')) {\n if (this.take(':')) { /* Non-capturing group. */ }\n else if (this.at('=') || this.at('!') || (this.at('<') && '=!'.includes(this.pattern[this.offset + 1] ?? ' '))) this.fail('lookaround', start);\n else if (this.take('<')) {\n const nameStart = this.offset;\n while (this.offset < this.pattern.length && !this.at('>')) this.offset++;\n const name = this.pattern.slice(nameStart, this.offset);\n if (!this.take('>')) this.fail('unterminated group name', nameStart, true);\n else if (!isJavaScriptGroupName(name)) this.fail('group name', nameStart, true);\n else if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) this.fail('group name', nameStart);\n else this.registerName(name, nameStart);\n } else this.fail('ims-'.includes(this.pattern[this.offset] ?? ' ') ? 'inline options' : 'group extension', start);\n }\n const body = this.expression();\n if (!this.take(')')) this.fail('unterminated group', start, true);\n return body;\n }\n\n private characterClass(start: number): void {\n const negated = this.take('^');\n if (this.at(']')) this.fail(negated ? 'negated empty character class' : 'empty character class', start);\n while (this.issue === undefined && this.offset < this.pattern.length && !this.at(']')) {\n if (this.at('-') && this.offset + 1 < this.pattern.length && this.pattern[this.offset + 1] === '[') this.fail('class subtraction', this.offset);\n const left = this.classItem();\n if (this.at('-') && this.offset + 1 < this.pattern.length && this.pattern[this.offset + 1] !== ']') {\n const rangeOffset = this.offset++;\n if (this.at('[')) this.fail('class subtraction', rangeOffset);\n const right = this.classItem();\n if (left === undefined || right === undefined) this.fail('class escape range endpoint', rangeOffset);\n else if (left > right) this.fail('reversed character range', rangeOffset, true);\n }\n }\n if (!this.take(']')) this.fail('unterminated character class', start, true);\n }\n\n private classItem(): number | undefined {\n if (this.offset >= this.pattern.length) { this.fail('unterminated character class', this.offset, true); return undefined; }\n const start = this.offset;\n const character = this.pattern[this.offset++];\n return character === '\\\\' ? this.escape(start, true) : character.charCodeAt(0);\n }\n\n private escape(start: number, inClass: boolean): number | undefined {\n if (this.offset === this.pattern.length) { this.fail('trailing backslash', start, true); return undefined; }\n const escape = this.pattern[this.offset++];\n if ('dDwWsS'.includes(escape)) return undefined;\n if (escape === '0' && /[0-9]/.test(this.pattern[this.offset] ?? ' ')) this.fail('octal escape', start);\n else if ('tnrfv0'.includes(escape)) return ({ t: 9, n: 10, r: 13, f: 12, v: 11, '0': 0 } as Record<string, number>)[escape];\n else if (escape === 'x' || (escape === 'u' && !this.at('{'))) {\n const width = escape === 'x' ? 2 : 4;\n const hex = this.pattern.slice(this.offset, this.offset + width);\n if (hex.length !== width || !/^[0-9a-fA-F]+$/.test(hex)) this.fail('invalid hexadecimal escape', start, true);\n else { this.offset += width; return parseInt(hex, 16); }\n } else if ('^$\\\\.*+?()[]{}|/'.includes(escape) || (inClass && escape === '-')) return escape.charCodeAt(0);\n else this.fail(escapeConstruct(escape, inClass), start);\n return undefined;\n }\n\n private quantify(atom: Fragment): Fragment {\n if (this.issue !== undefined || this.offset >= this.pattern.length) return atom;\n const start = this.offset;\n let count = 1n;\n let choices = 1n;\n if (this.at('*') || this.at('+') || this.at('?')) this.offset++;\n else if (this.take('{')) {\n const minimum = this.digits();\n if (minimum === undefined) { this.fail('unescaped brace', start); return atom; }\n count = minimum;\n choices = 0n;\n if (this.take(',')) {\n if (this.at('}')) { count = minimum + 1n; choices = 1n; }\n else {\n const maximum = this.digits();\n if (maximum === undefined) { this.fail('unescaped brace', start); return atom; }\n count = maximum;\n choices = maximum - minimum;\n if (count < minimum) this.fail('reversed counted repeat', start, true);\n }\n }\n if (!this.take('}')) this.fail('unescaped brace', start);\n } else return atom;\n if (!atom.quantifiable) this.fail('quantified assertion', start, true);\n this.take('?');\n const expanded = BigInt(atom.size) * count + choices;\n const size = Number(expanded > BigInt(sizeLimit + 1) ? BigInt(sizeLimit + 1) : expanded);\n return { size, quantifiable: false, budgetOffset: size > sizeLimit ? atom.budgetOffset ?? start : undefined };\n }\n\n private digits(): bigint | undefined {\n const start = this.offset;\n let value = 0n;\n while (this.offset < this.pattern.length && /[0-9]/.test(this.pattern[this.offset])) value = value * 10n + BigInt(this.pattern[this.offset++]);\n return this.offset === start ? undefined : value;\n }\n\n private registerName(name: string, start: number): void {\n const occurrences = this.names.get(name) ?? [];\n const disjoint = (previous: Branch[]) => previous.some(branch => this.branches.some(current => current.scope === branch.scope && current.alternative !== branch.alternative));\n if (occurrences.some(previous => !disjoint(previous))) this.fail('duplicate group name', start, true);\n occurrences.push(this.branches.map(branch => ({ ...branch })));\n this.names.set(name, occurrences);\n }\n\n private at(character: string): boolean { return this.offset < this.pattern.length && this.pattern[this.offset] === character; }\n private take(character: string): boolean { if (!this.at(character)) return false; this.offset++; return true; }\n private fail(construct: string, offset: number, invalid = false): void {\n this.issue ??= { construct, offset, invalid, suggestion: invalid ? undefined : portableMatchSuggestions[construct] };\n }\n}\n\nfunction escapeConstruct(escape: string, inClass: boolean): string {\n if ('123456789k'.includes(escape)) return 'backreference';\n if (escape === 'b' && inClass) return 'class backspace escape';\n if ('bB'.includes(escape)) return 'word boundary';\n if ('pP'.includes(escape)) return 'Unicode property escape';\n if (escape === 'u') return 'Unicode code point escape';\n if (escape === 'c') return 'control escape';\n if (escape === 'A') return 'start of input escape';\n if ('zZ'.includes(escape)) return 'end of input escape';\n return 'identity escape';\n}\n"],"mappings":"A,kMAMA,MAAaA,EAAoB,wCAI3BC,EAAY,IAGlB,SAAgB,qBAAqB,EAAgD,CACjF,OAAO,IAAI,oBAAoBC,CAAO,CAAC,CAAC,MAAM,CAClD,CAEA,IAAM,oBAAN,KAA0B,CAMO,QAL7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AAO,EAAE,CAAC,EAC7D,KAAK,MAAM,IAAIK,EAAMiB,CAAW,CACpC,CAEA,GAAW,EAA4B,CAAE,OAAO,KAAK,OAAS,KAAK,QAAQ,QAAU,KAAK,QAAQ,KAAK,UAAYnB,CAAW,CAC9H,KAAa,EAA4B,CAAwD,OAAjD,KAAK,GAAGA,CAAS,GAAiB,KAAK,SAAiB,IAA7B,EAAmC,CAC9G,KAAa,EAAmB,EAAgB,EAAU,GAAa,CACnE,KAAK,QAAU,CAAE,YAAW,SAAQ,UAAS,WAAYsB,EAAU,IAAA,GAAYC,EAAyBC,EAAW,CACvH,CACJ,EAEA,SAAS,gBAAgB,EAAgB,EAA0B,CAS/D,MARI,aAAa,SAASf,CAAM,EAAU,gBACtCA,IAAW,KAAOG,EAAgB,yBAClC,KAAK,SAASH,CAAM,EAAU,gBAC9B,KAAK,SAASA,CAAM,EAAU,0BAC9BA,IAAW,IAAY,4BACvBA,IAAW,IAAY,iBACvBA,IAAW,IAAY,wBACvB,KAAK,SAASA,CAAM,EAAU,sBAC3B,iBACX,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"PortableMatchSuggestions.js","names":["portableMatchSuggestions","\"lookaround\"","\"backreference\""],"sources":["../../../../../../Compiler/Parsing/PortableMatchSuggestions.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n// Held equal to the C# table by the shared portable-match conformance vectors.\nexport const portableMatchSuggestions: Readonly<Record<string, string>> = {\n 'lookaround': 'There is no general equivalent; a length-only lookahead can be replaced with a {n} counted repeat.',\n 'backreference': 'There is no equivalent in the portable match dialect.',\n 'word boundary': 'There is no equivalent word-boundary assertion in the portable match dialect.',\n 'Unicode property escape': 'Use an explicit character class where the required set is known; there is no general equivalent.',\n 'Unicode code point escape': 'Use \\\\uHHHH escapes for UTF-16 code units.',\n 'control escape': 'Use an explicit hexadecimal escape such as \\\\x01.',\n 'class backspace escape': 'Use \\\\x08.',\n 'start of input escape': 'Use ^.',\n 'end of input escape': 'Use $.',\n 'inline options': 'Use explicit case classes such as [aA] for case-insensitive matching; there is no general equivalent for other options.',\n 'empty character class': 'Use [^\\\\s\\\\S] to match no UTF-16 code unit.',\n 'negated empty character class': 'Use [\\\\s\\\\S].',\n 'class subtraction': 'Use an explicit character class containing the resulting ranges.',\n 'class escape range endpoint': 'Write single-character range endpoints or a union of classes.',\n 'unescaped closing bracket': 'Escape a literal closing bracket as \\\\].',\n 'unescaped brace': 'Escape a literal brace as \\\\{ or \\\\}.',\n 'identity escape': 'Write the literal character without a backslash, or use \\\\xHH or \\\\uHHHH.',\n 'octal escape': 'Use \\\\xHH or \\\\uHHHH.',\n 'group name': 'Use a name matching [A-Za-z_][A-Za-z0-9_]*.',\n 'group extension': 'Use an ordinary group or a (?:...) non-capturing group.',\n 'pattern length': 'Shorten the pattern to at most 1000 UTF-16 code units.',\n 'expanded pattern size': 'Reduce repeats and alternatives to at most 3000 expanded nodes, including choice points.',\n};\n"],"mappings":"AAIA,MAAaA,EAA6D,CACtEC,WAAc,qGACdC,cAAiB,wDACjB,gBAAiB,gFACjB,0BAA2B,mGAC3B,4BAA6B,6CAC7B,iBAAkB,oDAClB,yBAA0B,aAC1B,wBAAyB,SACzB,sBAAuB,SACvB,iBAAkB,0HAClB,wBAAyB,8CACzB,gCAAiC,gBACjC,oBAAqB,mEACrB,8BAA+B,gEAC/B,4BAA6B,2CAC7B,kBAAmB,wCACnB,kBAAmB,4EACnB,eAAgB,wBAChB,aAAc,8CACd,kBAAmB,0DACnB,iBAAkB,yDAClB,wBAAyB,0FAC7B"}
1
+ {"version":3,"file":"PortableMatchSuggestions.js","names":["portableMatchSuggestions","\"lookaround\"","\"backreference\""],"sources":["../../../../../../Compiler/Parsing/PortableMatchSuggestions.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n// Held equal to the C# table by the shared portable-match conformance vectors.\nexport const portableMatchSuggestions: Readonly<Record<string, string>> = {\n 'lookaround': 'There is no general equivalent; a length-only lookahead can be replaced with a {n} counted repeat.',\n 'backreference': 'There is no equivalent in the portable match dialect.',\n 'word boundary': 'There is no equivalent word-boundary assertion in the portable match dialect.',\n 'Unicode property escape': 'Use an explicit character class where the required set is known; there is no general equivalent.',\n 'Unicode code point escape': 'Use \\\\uHHHH escapes for UTF-16 code units.',\n 'control escape': 'Use an explicit hexadecimal escape such as \\\\x01.',\n 'class backspace escape': 'Use \\\\x08.',\n 'start of input escape': 'Use ^.',\n 'end of input escape': 'Use $.',\n 'inline options': 'Use explicit case classes such as [aA] for case-insensitive matching; there is no general equivalent for other options.',\n 'empty character class': 'Use [^\\\\s\\\\S] to match no UTF-16 code unit.',\n 'negated empty character class': 'Use [\\\\s\\\\S].',\n 'class subtraction': 'Use an explicit character class containing the resulting ranges.',\n 'class escape range endpoint': 'Write single-character range endpoints or a union of classes.',\n 'unescaped closing bracket': 'Escape a literal closing bracket as \\\\].',\n 'unescaped brace': 'Escape a literal brace as \\\\{ or \\\\}.',\n 'identity escape': 'Write the literal character without a backslash, or use \\\\xHH or \\\\uHHHH.',\n 'octal escape': 'Use \\\\xHH or \\\\uHHHH.',\n 'group name': 'Use a name matching [A-Za-z_][A-Za-z0-9_]*.',\n 'group extension': 'Use an ordinary group or a (?:...) non-capturing group.',\n 'pattern length': 'Shorten the pattern to at most 1000 UTF-16 code units.',\n 'expanded pattern size': 'Reduce repeats and alternatives to at most 3000 expanded nodes, including choice points.',\n};\n"],"mappings":"AAIA,MAAaA,EAA6D,CACtEC,WAAc,qGACdC,cAAiB,wDACjB,gBAAiB,gFACjB,0BAA2B,mGAC3B,4BAA6B,6CAC7B,iBAAkB,oDAClB,yBAA0B,aAC1B,wBAAyB,SACzB,sBAAuB,SACvB,iBAAkB,0HAClB,wBAAyB,8CACzB,gCAAiC,gBACjC,oBAAqB,mEACrB,8BAA+B,gEAC/B,4BAA6B,2CAC7B,kBAAmB,wCACnB,kBAAmB,4EACnB,eAAgB,wBAChB,aAAc,8CACd,kBAAmB,0DACnB,iBAAkB,yDAClB,wBAAyB,0FAC7B,E"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{locationOf as t}from"./SourceLine.js";import{firstWord as n}from"./LineText.js";import{parseCommandStream as r}from"./EventSourceParser.js";import{parseTag as i}from"./DeclarationParsers.js";function parsePossibleEvents(n,r){let i=[],a=/* @__PURE__ */ new Set;for(;n.peekChild(r.indent)!==void 0;){let r=n.reader.takeSignificant(),o=/^([A-Z]\w*(?:\.[A-Za-z_]\w*)*)(?:\s+for\s+(?:(one\s+of)\s+)?([A-Za-z_]\w*))?$/.exec(r.content);if(o===null){invalid(n,r);continue}if(a.has(o[1])){n.error(e.InvalidPossibleEventsDeclaration,`Possible event '${o[1]}' is declared more than once; one destination rule is allowed per event type.`,t(r)),n.skipBlock(r.indent);continue}a.add(o[1]);let[s,c]=parseMetadata(n,r);i.push({kind:`PossibleEventSyntax`,event:o[1],property:o[3]??null,oneOf:o[2]!==void 0,stream:s,tags:c,location:t(r)})}return{kind:`PossibleEventsSyntax`,events:i,location:t(r)}}function parseMetadata(e,t){let r=null,i=[];for(;e.peekChild(t.indent)!==void 0;){let t=e.reader.takeSignificant();n(t.content)===`stream`?r=parseRoute(e,t,r):n(t.content)===`tag`?collectTag(e,t,i):invalid(e,t)}return[r,i]}function collectTag(e,t,n){let r=i(e,t,!1);r!==void 0&&n.push(r)}function parseRoute(n,i,a){let o=/^stream\s+([A-Za-z_]\w*\.[A-Za-z_]\w*)$/.exec(i.content);if(a!==null||o===null)return n.error(e.InvalidCommandStream,a===null?`Expected 'stream <Source>.<Stream>'.`:`A production can declare at most one stream route.`,t(i)),n.skipBlock(i.indent),a;let s=t(i),c={kind:`PropertySyntax`,name:`stream`,type:{kind:`TypeRefSyntax`,name:o[1],isCollection:!1,isOptional:!1,location:{...s,column:i.indent+i.content.indexOf(o[1])+1}},isIdentifier:!1,location:s};return r(n,i,c,!1)}function invalid(n,r){n.error(e.InvalidPossibleEventsDeclaration,`Expected an event name, optionally followed by 'for <property>' or 'for one of <collection property>'; entries accept only stream and tag children.`,t(r)),n.skipBlock(r.indent)}export{parsePossibleEvents};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{parseCommandStream as t}from"./EventSourceParser.js";import{firstWord as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";import{parseTag as i}from"./DeclarationParsers.js";function parsePossibleEvents(t,n){let i=[],a=/* @__PURE__ */ new Set;for(;t.peekChild(n.indent)!==void 0;){let n=t.reader.takeSignificant(),o=/^([A-Z]\w*(?:\.[A-Za-z_]\w*)*)(?:\s+for\s+(?:(one\s+of)\s+)?([A-Za-z_]\w*))?$/.exec(n.content);if(o===null){invalid(t,n);continue}if(a.has(o[1])){t.error(e.InvalidPossibleEventsDeclaration,`Possible event '${o[1]}' is declared more than once; one destination rule is allowed per event type.`,r(n)),t.skipBlock(n.indent);continue}a.add(o[1]);let[s,c]=parseMetadata(t,n);i.push({kind:`PossibleEventSyntax`,event:o[1],property:o[3]??null,oneOf:o[2]!==void 0,stream:s,tags:c,location:r(n)})}return{kind:`PossibleEventsSyntax`,events:i,location:r(n)}}function parseMetadata(e,t){let r=null,i=[];for(;e.peekChild(t.indent)!==void 0;){let t=e.reader.takeSignificant();n(t.content)===`stream`?r=parseRoute(e,t,r):n(t.content)===`tag`?collectTag(e,t,i):invalid(e,t)}return[r,i]}function collectTag(e,t,n){let r=i(e,t,!1);r!==void 0&&n.push(r)}function parseRoute(n,i,a){let o=/^stream\s+([A-Za-z_]\w*\.[A-Za-z_]\w*)$/.exec(i.content);if(a!==null||o===null)return n.error(e.InvalidCommandStream,a===null?`Expected 'stream <Source>.<Stream>'.`:`A production can declare at most one stream route.`,r(i)),n.skipBlock(i.indent),a;let s=r(i),c={kind:`PropertySyntax`,name:`stream`,type:{kind:`TypeRefSyntax`,name:o[1],isCollection:!1,isOptional:!1,location:{...s,column:i.indent+i.content.indexOf(o[1])+1}},isIdentifier:!1,location:s};return t(n,i,c,!1)}function invalid(t,n){t.error(e.InvalidPossibleEventsDeclaration,`Expected an event name, optionally followed by 'for <property>' or 'for one of <collection property>'; entries accept only stream and tag children.`,r(n)),t.skipBlock(n.indent)}export{parsePossibleEvents};
2
2
  //# sourceMappingURL=PossibleEventsParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PossibleEventsParser.js","names":["events","names","context","header","line","match","DiagnosticCodes","locationOf","stream","tags","child","firstWord","tag","parseTag","previous","location","candidate","parseCommandStream"],"sources":["../../../../../../Compiler/Parsing/PossibleEventsParser.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 { CommandStreamSyntax } from '../Syntax/CommandStreamSyntax';\nimport { PropertySyntax, TagSyntax } from '../Syntax/Declarations';\nimport { PossibleEventSyntax } from '../Syntax/PossibleEventSyntax';\nimport { PossibleEventsSyntax } from '../Syntax/PossibleEventsSyntax';\nimport { parseCommandStream } from './EventSourceParser';\nimport { ParserContext } from './ParserContext';\nimport { firstWord } from './LineText';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseTag } from './DeclarationParsers';\n\nexport function parsePossibleEvents(context: ParserContext, header: SourceLine): PossibleEventsSyntax {\n const events: PossibleEventSyntax[] = [];\n const names = new Set<string>();\n while (context.peekChild(header.indent) !== undefined) {\n const line = context.reader.takeSignificant()!;\n const match = /^([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)(?:\\s+for\\s+(?:(one\\s+of)\\s+)?([A-Za-z_]\\w*))?$/.exec(line.content);\n if (match === null) {\n invalid(context, line);\n continue;\n }\n if (names.has(match[1])) {\n context.error(DiagnosticCodes.InvalidPossibleEventsDeclaration, `Possible event '${match[1]}' is declared more than once; one destination rule is allowed per event type.`, locationOf(line));\n context.skipBlock(line.indent);\n continue;\n }\n names.add(match[1]);\n const [stream, tags] = parseMetadata(context, line);\n events.push({ kind: 'PossibleEventSyntax', event: match[1], property: match[3] ?? null, oneOf: match[2] !== undefined, stream, tags, location: locationOf(line) });\n }\n return { kind: 'PossibleEventsSyntax', events, location: locationOf(header) };\n}\n\nfunction parseMetadata(context: ParserContext, line: SourceLine): [CommandStreamSyntax | null, TagSyntax[]] {\n let stream: CommandStreamSyntax | null = null;\n const tags: TagSyntax[] = [];\n while (context.peekChild(line.indent) !== undefined) {\n const child = context.reader.takeSignificant()!;\n if (firstWord(child.content) === 'stream') {\n stream = parseRoute(context, child, stream);\n } else if (firstWord(child.content) === 'tag') {\n collectTag(context, child, tags);\n } else {\n invalid(context, child);\n }\n }\n return [stream, tags];\n}\n\nfunction collectTag(context: ParserContext, line: SourceLine, tags: TagSyntax[]): void {\n const tag = parseTag(context, line, false);\n if (tag !== undefined) tags.push(tag);\n}\n\nfunction parseRoute(context: ParserContext, line: SourceLine, previous: CommandStreamSyntax | null): CommandStreamSyntax | null {\n const match = /^stream\\s+([A-Za-z_]\\w*\\.[A-Za-z_]\\w*)$/.exec(line.content);\n if (previous !== null || match === null) {\n context.error(DiagnosticCodes.InvalidCommandStream, previous !== null ? 'A production can declare at most one stream route.' : \"Expected 'stream <Source>.<Stream>'.\", locationOf(line));\n context.skipBlock(line.indent);\n return previous;\n }\n const location = locationOf(line);\n const candidate: PropertySyntax = { kind: 'PropertySyntax', name: 'stream', type: { kind: 'TypeRefSyntax', name: match[1], isCollection: false, isOptional: false, location: { ...location, column: line.indent + line.content.indexOf(match[1]) + 1 } }, isIdentifier: false, location };\n return parseCommandStream(context, line, candidate, false);\n}\n\nfunction invalid(context: ParserContext, line: SourceLine): void {\n context.error(DiagnosticCodes.InvalidPossibleEventsDeclaration, \"Expected an event name, optionally followed by 'for <property>' or 'for one of <collection property>'; entries accept only stream and tag children.\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WAAW,EAAwB,EAAkB,EAAyB,CACnF,IAAMG,EAAMC,EAASX,EAASE,EAAM,EAAK,EACrCQ,IAAQ,IAAA,IAAWH,EAAK,KAAKG,CAAG,CACxC,CAEA,SAAS,WAAW,EAAwB,EAAkB,EAAkE,CAC5H,IAAMP,EAAQ,0CAA0C,KAAKD,EAAK,OAAO,EACzE,GAAIU,IAAa,MAAQT,IAAU,KAG/B,OAFAH,EAAQ,MAAMI,EAAgB,qBAAsBQ,IAAa,KAA8D,uCAAvD,qDAA+FP,EAAWH,CAAI,CAAC,EACvLF,EAAQ,UAAUE,EAAK,MAAM,EACtBU,EAEX,IAAMC,EAAWR,EAAWH,CAAI,EAC1BY,EAA4B,CAAE,KAAM,iBAAkB,KAAM,SAAU,KAAM,CAAE,KAAM,gBAAiB,KAAMX,EAAM,GAAI,aAAc,GAAO,WAAY,GAAO,SAAU,CAAE,GAAGU,EAAU,OAAQX,EAAK,OAASA,EAAK,QAAQ,QAAQC,EAAM,EAAE,EAAI,CAAE,CAAE,EAAG,aAAc,GAAO,UAAS,EACxR,OAAOY,EAAmBf,EAASE,EAAMY,EAAW,EAAK,CAC7D,CAEA,SAAS,QAAQ,EAAwB,EAAwB,CAC7Dd,EAAQ,MAAMI,EAAgB,iCAAkC,sJAAuJC,EAAWH,CAAI,CAAC,EACvOF,EAAQ,UAAUE,EAAK,MAAM,CACjC"}
1
+ {"version":3,"file":"PossibleEventsParser.js","names":["events","names","context","header","line","match","DiagnosticCodes","locationOf","stream","tags","child","firstWord","tag","parseTag","previous","location","candidate","parseCommandStream"],"sources":["../../../../../../Compiler/Parsing/PossibleEventsParser.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 { CommandStreamSyntax } from '../Syntax/CommandStreamSyntax';\nimport { PropertySyntax, TagSyntax } from '../Syntax/Declarations';\nimport { PossibleEventSyntax } from '../Syntax/PossibleEventSyntax';\nimport { PossibleEventsSyntax } from '../Syntax/PossibleEventsSyntax';\nimport { parseCommandStream } from './EventSourceParser';\nimport { ParserContext } from './ParserContext';\nimport { firstWord } from './LineText';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseTag } from './DeclarationParsers';\n\nexport function parsePossibleEvents(context: ParserContext, header: SourceLine): PossibleEventsSyntax {\n const events: PossibleEventSyntax[] = [];\n const names = new Set<string>();\n while (context.peekChild(header.indent) !== undefined) {\n const line = context.reader.takeSignificant()!;\n const match = /^([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)(?:\\s+for\\s+(?:(one\\s+of)\\s+)?([A-Za-z_]\\w*))?$/.exec(line.content);\n if (match === null) {\n invalid(context, line);\n continue;\n }\n if (names.has(match[1])) {\n context.error(DiagnosticCodes.InvalidPossibleEventsDeclaration, `Possible event '${match[1]}' is declared more than once; one destination rule is allowed per event type.`, locationOf(line));\n context.skipBlock(line.indent);\n continue;\n }\n names.add(match[1]);\n const [stream, tags] = parseMetadata(context, line);\n events.push({ kind: 'PossibleEventSyntax', event: match[1], property: match[3] ?? null, oneOf: match[2] !== undefined, stream, tags, location: locationOf(line) });\n }\n return { kind: 'PossibleEventsSyntax', events, location: locationOf(header) };\n}\n\nfunction parseMetadata(context: ParserContext, line: SourceLine): [CommandStreamSyntax | null, TagSyntax[]] {\n let stream: CommandStreamSyntax | null = null;\n const tags: TagSyntax[] = [];\n while (context.peekChild(line.indent) !== undefined) {\n const child = context.reader.takeSignificant()!;\n if (firstWord(child.content) === 'stream') {\n stream = parseRoute(context, child, stream);\n } else if (firstWord(child.content) === 'tag') {\n collectTag(context, child, tags);\n } else {\n invalid(context, child);\n }\n }\n return [stream, tags];\n}\n\nfunction collectTag(context: ParserContext, line: SourceLine, tags: TagSyntax[]): void {\n const tag = parseTag(context, line, false);\n if (tag !== undefined) tags.push(tag);\n}\n\nfunction parseRoute(context: ParserContext, line: SourceLine, previous: CommandStreamSyntax | null): CommandStreamSyntax | null {\n const match = /^stream\\s+([A-Za-z_]\\w*\\.[A-Za-z_]\\w*)$/.exec(line.content);\n if (previous !== null || match === null) {\n context.error(DiagnosticCodes.InvalidCommandStream, previous !== null ? 'A production can declare at most one stream route.' : \"Expected 'stream <Source>.<Stream>'.\", locationOf(line));\n context.skipBlock(line.indent);\n return previous;\n }\n const location = locationOf(line);\n const candidate: PropertySyntax = { kind: 'PropertySyntax', name: 'stream', type: { kind: 'TypeRefSyntax', name: match[1], isCollection: false, isOptional: false, location: { ...location, column: line.indent + line.content.indexOf(match[1]) + 1 } }, isIdentifier: false, location };\n return parseCommandStream(context, line, candidate, false);\n}\n\nfunction invalid(context: ParserContext, line: SourceLine): void {\n context.error(DiagnosticCodes.InvalidPossibleEventsDeclaration, \"Expected an event name, optionally followed by 'for <property>' or 'for one of <collection property>'; entries accept only stream and tag children.\", locationOf(line));\n context.skipBlock(line.indent);\n}\n"],"mappings":"A,+TAcA,SAAgB,oBAAoB,EAAwB,EAA0C,CAClG,IAAMA,EAAgC,CAAC,EACjCC,kBAAQ,IAAI,IAClB,KAAOC,EAAQ,UAAUC,EAAO,MAAM,IAAM,IAAA,IAAW,CACnD,IAAMC,EAAOF,EAAQ,OAAO,gBAAgB,EACtCG,EAAQ,gFAAgF,KAAKD,EAAK,OAAO,EAC/G,GAAIC,IAAU,KAAM,CAChB,QAAQH,EAASE,CAAI,EACrB,QACJ,CACA,GAAIH,EAAM,IAAII,EAAM,EAAE,EAAG,CACrBH,EAAQ,MAAMI,EAAgB,iCAAkC,mBAAmBD,EAAM,GAAG,+EAAgFE,EAAWH,CAAI,CAAC,EAC5LF,EAAQ,UAAUE,EAAK,MAAM,EAC7B,QACJ,CACAH,EAAM,IAAII,EAAM,EAAE,EAClB,GAAM,CAACG,EAAQC,GAAQ,cAAcP,EAASE,CAAI,EAClDJ,EAAO,KAAK,CAAE,KAAM,sBAAuB,MAAOK,EAAM,GAAI,SAAUA,EAAM,IAAM,KAAM,MAAOA,EAAM,K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AW,EAAK,CAC7D,CAEA,SAAS,QAAQ,EAAwB,EAAwB,CAC7Dd,EAAQ,MAAMI,EAAgB,iCAAkC,sJAAuJC,EAAWH,CAAI,CAAC,EACvOF,EAAQ,UAAUE,EAAK,MAAM,CACjC,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{parseMappingSource as r}from"./ExpressionParser.js";import{diagnosticText as i}from"../Diagnostics/DiagnosticArgument.js";import{firstWord as a,unescapeIdentifier as o}from"./LineText.js";import{parseProperty as s}from"./PropertyLineParser.js";import{parseStructuredValue as c,trailingMarker as l,tryParseStructuredMapping as u}from"./StructuredBlockParser.js";import{parseCondition as d}from"./ConditionParser.js";import{sourceStreamPattern as f}from"../Text/SourceStreamNames.js";import{parseCommandStream as p}from"./EventSourceParser.js";import{EventMetadataParser as m}from"./EventMetadataParser.js";import{parseTag as h}from"./DeclarationParsers.js";import{parseOperation as g}from"./OperationParser.js";const _=t(`^produces\\s+operation(?:\\s|$)`),v=t(`^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$`),y=t(`^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),b=t(`^produces\\s+when\\s+(.+)$`),x=t(`^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$`),S=t(`^for\\s+(\\S.*)$`),C=t(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),w=t(`^(.+?)\\s*=(?!=|>)\\s*(.+)$`),T=/* @__PURE__ */ new Set([`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`]);function parseProduces(t,E,D=!1){if(_.test(E.content)){if(!D){t.error(e.OperationOutsideCommand,`Operations can only be produced by commands.`,n(E)),t.skipOpaqueBlock(E.indent);return}let r=g(t,E,!0);return{kind:`ProducesSyntax`,when:null,event:r.operation.name,targetLocation:{...n(E),column:E.indent+E.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:r.operation,mappings:r.mappings,for:null,tags:[],location:n(E)}}let O=v.exec(E.content),k=E,A=null,j,M;if(O!==null){if(!D){t.error(e.InlineEventOutsideCommand,`Inline events can only be declared inside commands`,n(E)),t.skipOpaqueBlock(E.indent);return}O[2]!==void 0&&t.error(e.InlineEventGeneration,`Inline events are generation 1 - extract the event before declaring generations`,n(E)),j=O[1],M=E.indent+E.content.match(/^produces\s+event\s+/)[0].length+1}else if(b.test(E.content)){A=d(t,b.exec(E.content)[1],n(E));let r=t.peekChild(E.indent);if(r===void 0||!x.test(r.content)){t.error(e.ProducesWhenWithoutEvent,`Expected an event name on the line after 'produces when'`,n(E)),t.skipOpaqueBlock(E.indent);return}t.reader.takeSignificant(),k=r,j=r.content,M=r.indent+1}else{let r=y.exec(E.content);if(r===null){t.error(e.InvalidProducesDeclaration,`Invalid produces declaration '${E.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,n(E)),t.skipOpaqueBlock(E.indent);return}j=r[1],M=E.indent+E.content.match(/^produces\s+/)[0].length+1}let N=[],P=/* @__PURE__ */ new Set,F=[],I=[],L=new m(j),R=null,z=null;for(let d=t.peekChild(k.indent);d!==void 0;d=t.peekChild(k.indent)){t.reader.takeSignificant();let m=a(d.content),g=n(d);if(T.has(m)){t.error(e.ReservedProductionMetadata,`'${m}' is system-assigned production metadata and cannot be supplied here`,g),t.skipOpaqueBlock(d.indent);continue}if(O!==null&&(m===`generation`||m===`origin`)){t.error(m===`generation`?e.InlineEventGeneration:e.ReservedProductionMetadata,m===`generation`?`Inline events are generation 1 - extract the event before declaring generations`:`An inline event is local to its command and cannot declare origin`,g),t.skipOpaqueBlock(d.indent);continue}if(m===`stream`&&!d.content.includes(`=`)){let n=f(`^stream\\s+([A-Za-z_]\\w*\\.[A-Za-z_]\\w*)$`).exec(d.content);if(!D)t.error(e.ProductionRouteOutsideCommand,`Only command event productions can declare a stream route.`,g),t.skipBlock(d.indent);else if(z!==null)t.error(e.InvalidCommandStream,`A production can declare at most one stream route.`,g),t.skipBlock(d.indent);else if(n===null)t.error(e.InvalidCommandStream,`Expected 'stream <Source>.<Stream>'.`,g),t.skipBlock(d.indent);else{let e={...g,column:d.indent+d.content.indexOf(n[1])+1},r={kind:`PropertySyntax`,name:`stream`,type:{kind:`TypeRefSyntax`,name:n[1],isCollection:!1,isOptional:!1,location:e},isIdentifier:!1,location:g};z=p(t,d,r,!1)}continue}if(m===`tag`){let e=h(t,d,!1);e!==void 0&&I.push(e);continue}let _=S.exec(d.content);if(_!==null){R===null?R=r(_[1],g,t):t.error(e.DuplicateProducesTarget,`'${k.content}' already declares where it lands - an event is appended to one event source`,g);continue}let v=(O===null?C:w).exec(d.content);if(v===null&&O===null){let e=u(t,d);if(e!==void 0){F.push(e);continue}}let y=l(d.content),b=v===null&&O!==null&&!d.content.includes(`=`)&&![`id`,`description`,`documentation`].includes(m)&&d.content.includes(` `)&&(y!==void 0||t.peekChild(d.indent)!==void 0),x=b?y===void 0?d.content:d.content.substring(0,d.content.length-y.length-1):v?.[1].trimEnd(),E=x===void 0||O===null?void 0:s(t,{...d,content:x});if((v!==null||b)&&(O===null||E!==void 0)){if(E!==void 0){E.isIdentifier&&(t.error(e.IdentifierOnEventProperty,`Property '${E.name}' of event '${j}' cannot be marked identifier - an event never carries its event source id`,g),E={...E,isIdentifier:!1});let n=E.name;P.has(n)&&t.error(e.DuplicateDeclaration,`Event '${j}' already declares property '${E.name}'`,g),P.add(n),N.push(E)}F.push(v===null?{kind:`PropertyMappingSyntax`,property:E.name,source:c(t,d,y),location:g}:{kind:`PropertyMappingSyntax`,property:E?.name??o(v[1]),source:r(v[2],{...g,column:d.indent+d.content.length-v[2].length+1},t),location:g})}else(O===null||!L.tryParse(t,d))&&t.error(e.InvalidPropertyMapping,`Invalid ${O===null?``:`inline `}property mapping '${d.content}' - expected '<property>${O===null?``:` <Type>`} = <source>'`,g,i(`text`,d.content))}return k!==E&&t.skipBlock(E.indent),{kind:`ProducesSyntax`,when:A,event:j,stream:z,targetLocation:{...n(k),column:M},inlineOperation:null,mappings:F,for:R,tags:O===null?I:[],location:n(E),inlineEvent:O===null?null:{kind:`EventSyntax`,name:j,properties:N,tags:I,generation:1,hasGenerationMarker:!1,...L.value,location:n(E)}}}export{parseProduces};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{diagnosticText as e}from"../Diagnostics/DiagnosticArgument.js";import{DiagnosticCodes as t}from"../Diagnostics/DiagnosticCodes.js";import{sourceStreamPattern as n}from"../Text/SourceStreamNames.js";import{parseCommandStream as r}from"./EventSourceParser.js";import{parseCondition as i}from"./ConditionParser.js";import{pattern as a}from"../Text/patterns.js";import{parseTag as o}from"./DeclarationParsers.js";import{EventMetadataParser as s}from"./EventMetadataParser.js";import{parseMappingSource as c}from"./ExpressionParser.js";import{firstWord as l,unescapeIdentifier as u}from"./LineText.js";import{parseOperation as d}from"./OperationParser.js";import{parseProperty as f}from"./PropertyLineParser.js";import{locationOf as p}from"./SourceLine.js";import{parseStructuredValue as m,trailingMarker as h,tryParseStructuredMapping as g}from"./StructuredBlockParser.js";const _=a(`^produces\\s+operation(?:\\s|$)`),v=a(`^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$`),y=a(`^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$`),b=a(`^produces\\s+when\\s+(.+)$`),x=a(`^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$`),S=a(`^for\\s+(\\S.*)$`),C=a(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),w=a(`^(.+?)\\s*=(?!=|>)\\s*(.+)$`),T=/* @__PURE__ */ new Set([`namespace`,`sequence`,`correlation`,`causation`,`causedBy`,`occurred`]);function parseProduces(a,E,D=!1){if(_.test(E.content)){if(!D){a.error(t.OperationOutsideCommand,`Operations can only be produced by commands.`,p(E)),a.skipOpaqueBlock(E.indent);return}let e=d(a,E,!0);return{kind:`ProducesSyntax`,when:null,event:e.operation.name,targetLocation:{...p(E),column:E.indent+E.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:e.operation,mappings:e.mappings,for:null,tags:[],location:p(E)}}let O=v.exec(E.content),k=E,A=null,j,M;if(O!==null){if(!D){a.error(t.InlineEventOutsideCommand,`Inline events can only be declared inside commands`,p(E)),a.skipOpaqueBlock(E.indent);return}O[2]!==void 0&&a.error(t.InlineEventGeneration,`Inline events are generation 1 - extract the event before declaring generations`,p(E)),j=O[1],M=E.indent+E.content.match(/^produces\s+event\s+/)[0].length+1}else if(b.test(E.content)){A=i(a,b.exec(E.content)[1],p(E));let e=a.peekChild(E.indent);if(e===void 0||!x.test(e.content)){a.error(t.ProducesWhenWithoutEvent,`Expected an event name on the line after 'produces when'`,p(E)),a.skipOpaqueBlock(E.indent);return}a.reader.takeSignificant(),k=e,j=e.content,M=e.indent+1}else{let e=y.exec(E.content);if(e===null){a.error(t.InvalidProducesDeclaration,`Invalid produces declaration '${E.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,p(E)),a.skipOpaqueBlock(E.indent);return}j=e[1],M=E.indent+E.content.match(/^produces\s+/)[0].length+1}let N=[],P=/* @__PURE__ */ new Set,F=[],I=[],L=new s(j),R=null,z=null;for(let i=a.peekChild(k.indent);i!==void 0;i=a.peekChild(k.indent)){a.reader.takeSignificant();let s=l(i.content),d=p(i);if(T.has(s)){a.error(t.ReservedProductionMetadata,`'${s}' is system-assigned production metadata and cannot be supplied here`,d),a.skipOpaqueBlock(i.indent);continue}if(O!==null&&(s===`generation`||s===`origin`)){a.error(s===`generation`?t.InlineEventGeneration:t.ReservedProductionMetadata,s===`generation`?`Inline events are generation 1 - extract the event before declaring generations`:`An inline event is local to its command and cannot declare origin`,d),a.skipOpaqueBlock(i.indent);continue}if(s===`stream`&&!i.content.includes(`=`)){let e=n(`^stream\\s+([A-Za-z_]\\w*\\.[A-Za-z_]\\w*)$`).exec(i.content);if(!D)a.error(t.ProductionRouteOutsideCommand,`Only command event productions can declare a stream route.`,d),a.skipBlock(i.indent);else if(z!==null)a.error(t.InvalidCommandStream,`A production can declare at most one stream route.`,d),a.skipBlock(i.indent);else if(e===null)a.error(t.InvalidCommandStream,`Expected 'stream <Source>.<Stream>'.`,d),a.skipBlock(i.indent);else{let t={...d,column:i.indent+i.content.indexOf(e[1])+1},n={kind:`PropertySyntax`,name:`stream`,type:{kind:`TypeRefSyntax`,name:e[1],isCollection:!1,isOptional:!1,location:t},isIdentifier:!1,location:d};z=r(a,i,n,!1)}continue}if(s===`tag`){let e=o(a,i,!1);e!==void 0&&I.push(e);continue}let _=S.exec(i.content);if(_!==null){R===null?R=c(_[1],d,a):a.error(t.DuplicateProducesTarget,`'${k.content}' already declares where it lands - an event is appended to one event source`,d);continue}let v=(O===null?C:w).exec(i.content);if(v===null&&O===null){let e=g(a,i);if(e!==void 0){F.push(e);continue}}let y=h(i.content),b=v===null&&O!==null&&!i.content.includes(`=`)&&![`id`,`description`,`documentation`].includes(s)&&i.content.includes(` `)&&(y!==void 0||a.peekChild(i.indent)!==void 0),x=b?y===void 0?i.content:i.content.substring(0,i.content.length-y.length-1):v?.[1].trimEnd(),E=x===void 0||O===null?void 0:f(a,{...i,content:x});if((v!==null||b)&&(O===null||E!==void 0)){if(E!==void 0){E.isIdentifier&&(a.error(t.IdentifierOnEventProperty,`Property '${E.name}' of event '${j}' cannot be marked identifier - an event never carries its event source id`,d),E={...E,isIdentifier:!1});let e=E.name;P.has(e)&&a.error(t.DuplicateDeclaration,`Event '${j}' already declares property '${E.name}'`,d),P.add(e),N.push(E)}F.push(v===null?{kind:`PropertyMappingSyntax`,property:E.name,source:m(a,i,y),location:d}:{kind:`PropertyMappingSyntax`,property:E?.name??u(v[1]),source:c(v[2],{...d,column:i.indent+i.content.length-v[2].length+1},a),location:d})}else O!==null&&L.tryParse(a,i)||a.error(t.InvalidPropertyMapping,`Invalid ${O===null?``:`inline `}property mapping '${i.content}' - expected '<property>${O===null?``:` <Type>`} = <source>'`,d,e(`text`,i.content))}return k!==E&&a.skipBlock(E.indent),{kind:`ProducesSyntax`,when:A,event:j,stream:z,targetLocation:{...p(k),column:M},inlineOperation:null,mappings:F,for:R,tags:O===null?I:[],location:p(E),inlineEvent:O===null?null:{kind:`EventSyntax`,name:j,properties:N,tags:I,generation:1,hasGenerationMarker:!1,...L.value,location:p(E)}}}export{parseProduces};
2
2
  //# sourceMappingURL=ProducesParser.js.map