@cratis/screenplay-language 5.3.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/TypeReferenceSymbol.js.map +1 -1
- package/dist/bundles/action-subject-authoring.js.map +1 -1
- package/dist/bundles/bmp-word-characters.js.map +1 -1
- package/dist/bundles/case-authoring.js +1 -1
- package/dist/bundles/case-authoring.js.map +1 -1
- package/dist/bundles/code-actions.js.map +1 -1
- package/dist/bundles/command-read-completions.js.map +1 -1
- package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js +3 -3
- package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js.map +1 -1
- package/dist/bundles/compiler/Authoring/QuickFixes.js +4 -4
- package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
- package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js +1 -1
- package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js.map +1 -1
- package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js +4 -4
- package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js.map +1 -1
- package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js +2 -2
- package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js.map +1 -1
- package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js +1 -1
- package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/DependencyGraph.js +1 -1
- package/dist/bundles/compiler/Dependencies/DependencyGraph.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/DependencyKind.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js +1 -1
- package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/SourceLocation.js.map +1 -1
- package/dist/bundles/compiler/Files/AuthoredOrder.js +1 -1
- package/dist/bundles/compiler/Files/AuthoredOrder.js.map +1 -1
- package/dist/bundles/compiler/Files/OrderingRoot.js +1 -1
- package/dist/bundles/compiler/Files/OrderingRoot.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayApplicationAssembly.js +1 -1
- package/dist/bundles/compiler/Files/PlayApplicationAssembly.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayDocumentSource.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
- package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayGlob.js +2 -1
- package/dist/bundles/compiler/Files/PlayGlob.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayImports.js +1 -1
- package/dist/bundles/compiler/Files/PlayImports.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayPlacement.js.map +1 -1
- package/dist/bundles/compiler/Files/TimelineOrder.js +1 -1
- package/dist/bundles/compiler/Files/TimelineOrder.js.map +1 -1
- package/dist/bundles/compiler/Generation/FiniteGenerationRules.js +1 -1
- package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationChecksum.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationPattern.js +1 -1
- package/dist/bundles/compiler/Generation/GenerationPattern.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationPatternParser.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationPatternToken.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationRuleProof.js +1 -1
- package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js.map +1 -1
- package/dist/bundles/compiler/Generation/RegexCharacters.js.map +1 -1
- package/dist/bundles/compiler/Generation/RegexExpression.js.map +1 -1
- package/dist/bundles/compiler/Generation/RuleConsistency.js +1 -1
- package/dist/bundles/compiler/Parsing/ActionSubjectClause.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ApplicationContextParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ApplicationContextParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/AuthorizeParser.js +1 -1
- package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CanvasPlacement.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ClockOperandParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CodeBlockParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandReadSources.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandResponseParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js +2 -0
- package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js.map +1 -0
- package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ContinuationValues.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
- package/dist/bundles/compiler/Parsing/DeclarationParsers.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/DependencySourceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DependsOnParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/DescriptionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DocumentationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/DocumentationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EnumerationMembers.js +1 -1
- package/dist/bundles/compiler/Parsing/EnumerationMembers.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
- package/dist/bundles/compiler/Parsing/EventMetadataParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EventSubjectValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/EventSubjectValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
- package/dist/bundles/compiler/Parsing/FeatureBody.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FileImportParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FileReferences.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FoldedEventSources.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GenerationBodyParser.js +1 -1
- package/dist/bundles/compiler/Parsing/GenerationBodyParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GenerationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionInputs.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedInteractions.js +1 -1
- package/dist/bundles/compiler/Parsing/GuardedInteractions.js.map +1 -1
- package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
- package/dist/bundles/compiler/Parsing/IdentityParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/IdentityValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
- package/dist/bundles/compiler/Parsing/ImplementationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ImportDiscovery.js +1 -1
- package/dist/bundles/compiler/Parsing/ImportDiscovery.js.map +1 -1
- package/dist/bundles/compiler/Parsing/InlineEventValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
- package/dist/bundles/compiler/Parsing/InputUses.js.map +1 -1
- package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
- package/dist/bundles/compiler/Parsing/InteractionAlternatives.js.map +1 -1
- package/dist/bundles/compiler/Parsing/InteractionExecutions.js +1 -1
- package/dist/bundles/compiler/Parsing/InteractionExecutions.js.map +1 -1
- package/dist/bundles/compiler/Parsing/LegacyTextRulePatterns.js.map +1 -1
- package/dist/bundles/compiler/Parsing/LineReader.js.map +1 -1
- package/dist/bundles/compiler/Parsing/LineText.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguity.js +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguity.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguityCharacters.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguityGraph.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguityParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchOperandValidation.js +1 -1
- package/dist/bundles/compiler/Parsing/MatchOperandValidation.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
- package/dist/bundles/compiler/Parsing/ModuleBody.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ObserverFilterParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ObserverFilterParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ObserverFilterValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/OperationValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/OperationValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PolicyParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PortableMatchGroupName.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PortableMatchPattern.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PortableMatchSuggestions.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PossibleEventsParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PossibleEventsParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionEventScopeValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PropertyLineParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PurposeParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PurposeValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
- package/dist/bundles/compiler/Parsing/QueryParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReadModelKeyValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReadModelMemberTypeValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReadsParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ReadsParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/RedeliveryValues.js.map +1 -1
- package/dist/bundles/compiler/Parsing/RefusalDeclarations.js +1 -1
- package/dist/bundles/compiler/Parsing/RefusalDeclarations.js.map +1 -1
- package/dist/bundles/compiler/Parsing/RefusalValueWalker.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ResponseCommandResolver.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ResponseDateValues.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ResponseValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SliceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SourceLine.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SourceLineSplitter.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SourceOptionsParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StateMachineParser.js +1 -1
- package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StructuralInteractionSites.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StructuredBlockParser.js +1 -1
- package/dist/bundles/compiler/Parsing/StructuredBlockParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StructuredValueParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/TemplateReferenceText.js +1 -1
- package/dist/bundles/compiler/Parsing/TemplateReferenceText.js.map +1 -1
- package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
- package/dist/bundles/compiler/Parsing/TriggerDataParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/UiBindingParser.js +1 -1
- package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js +1 -1
- package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js.map +1 -1
- package/dist/bundles/compiler/Parsing/WorkflowParser.js +1 -1
- package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/checkPortableMatchPattern.js.map +1 -1
- package/dist/bundles/compiler/Parsing/hasExponentialMatchAmbiguity.js.map +1 -1
- package/dist/bundles/compiler/Parsing/trimMatchAmbiguityGraph.js.map +1 -1
- package/dist/bundles/compiler/ScreenActionSubjects.js.map +1 -1
- package/dist/bundles/compiler/ScreenplayCompiler.js +1 -1
- package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js.map +1 -1
- package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js.map +1 -1
- package/dist/bundles/compiler/Syntax/CaptureEventsSource.js.map +1 -1
- package/dist/bundles/compiler/Syntax/DependencySources.js.map +1 -1
- package/dist/bundles/compiler/Syntax/EventDeclarations.js.map +1 -1
- package/dist/bundles/compiler/Syntax/EventSourceCatalog.js.map +1 -1
- package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ExactMathFacts.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ExactNumber.js.map +1 -1
- package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js.map +1 -1
- package/dist/bundles/compiler/Syntax/LegacyWireProjection.js.map +1 -1
- package/dist/bundles/compiler/Syntax/Operations.js.map +1 -1
- package/dist/bundles/compiler/Syntax/PersonaCallers.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ProductionDestinations.js.map +1 -1
- package/dist/bundles/compiler/Syntax/PublicEventInvariants.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SourceOptions.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js.map +1 -1
- package/dist/bundles/compiler/Syntax/StreamIdFormatter.js.map +1 -1
- package/dist/bundles/compiler/Syntax/StrictSyntaxJson.js +1 -1
- package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js.map +1 -1
- package/dist/bundles/compiler/Syntax/index.js +1 -1
- package/dist/bundles/compiler/Text/ImplementationHintText.js.map +1 -1
- package/dist/bundles/compiler/Text/ReservedWords.js.map +1 -1
- package/dist/bundles/compiler/Text/SourceStreamNames.js.map +1 -1
- package/dist/bundles/compiler/Text/StringLiteral.js.map +1 -1
- package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js.map +1 -1
- package/dist/bundles/compiler/Text/patterns.js.map +1 -1
- package/dist/bundles/compiler/index.js +1 -1
- package/dist/bundles/completion-items.js +4 -4
- package/dist/bundles/completion-items.js.map +1 -1
- package/dist/bundles/completion-planner.js +2 -2
- package/dist/bundles/completion-planner.js.map +1 -1
- package/dist/bundles/completions.js +1 -1
- package/dist/bundles/completions.js.map +1 -1
- package/dist/bundles/continuation-responses.js +1 -1
- package/dist/bundles/continuation-responses.js.map +1 -1
- package/dist/bundles/declarations.js.map +1 -1
- package/dist/bundles/dependency-completions.js.map +1 -1
- package/dist/bundles/dependency-target-analysis.js.map +1 -1
- package/dist/bundles/diagnostic-codes.js +1 -1
- package/dist/bundles/diagnostic-codes.js.map +1 -1
- package/dist/bundles/diagnostics.js +1 -1
- package/dist/bundles/diagnostics.js.map +1 -1
- package/dist/bundles/document-context.js.map +1 -1
- package/dist/bundles/documentation-item.js.map +1 -1
- package/dist/bundles/event-analysis-source.js.map +1 -1
- package/dist/bundles/event-context-catalog.js.map +1 -1
- package/dist/bundles/event-context.js.map +1 -1
- package/dist/bundles/event-source-authoring.js +11 -11
- package/dist/bundles/event-source-authoring.js.map +1 -1
- package/dist/bundles/example-analysis.js +2 -2
- package/dist/bundles/example-analysis.js.map +1 -1
- package/dist/bundles/example-authoring.js +2 -2
- package/dist/bundles/example-authoring.js.map +1 -1
- package/dist/bundles/example-declaration-items.js.map +1 -1
- package/dist/bundles/example-values.js.map +1 -1
- package/dist/bundles/file-imports.js.map +1 -1
- package/dist/bundles/file-references.js.map +1 -1
- package/dist/bundles/generation-completions.js.map +1 -1
- package/dist/bundles/hover-content.js +5 -5
- package/dist/bundles/hover-content.js.map +1 -1
- package/dist/bundles/hover.js.map +1 -1
- package/dist/bundles/index.js +1 -1
- package/dist/bundles/index.js.map +1 -1
- package/dist/bundles/inlay-hints.js.map +1 -1
- package/dist/bundles/inline-completions.js +1 -1
- package/dist/bundles/inline-completions.js.map +1 -1
- package/dist/bundles/inline-event-validation.js +1 -1
- package/dist/bundles/inline-event-validation.js.map +1 -1
- package/dist/bundles/keyword-docs.js.map +1 -1
- package/dist/bundles/language.js.map +1 -1
- package/dist/bundles/named-rule-context.js.map +1 -1
- package/dist/bundles/operation-authoring.js +6 -6
- package/dist/bundles/operation-authoring.js.map +1 -1
- package/dist/bundles/persona-analysis.js +1 -1
- package/dist/bundles/persona-analysis.js.map +1 -1
- package/dist/bundles/production-destinations.js +1 -1
- package/dist/bundles/production-destinations.js.map +1 -1
- package/dist/bundles/purpose-items.js.map +1 -1
- package/dist/bundles/reaction-authoring.js +3 -3
- package/dist/bundles/reaction-authoring.js.map +1 -1
- package/dist/bundles/read-model-key-completions.js +1 -1
- package/dist/bundles/read-model-key-completions.js.map +1 -1
- package/dist/bundles/refusal-context.js.map +1 -1
- package/dist/bundles/response-analysis.js.map +1 -1
- package/dist/bundles/response-completions.js +1 -1
- package/dist/bundles/response-completions.js.map +1 -1
- package/dist/bundles/response-tokens.js +2 -2
- package/dist/bundles/response-tokens.js.map +1 -1
- package/dist/bundles/scope-items.js +3 -3
- package/dist/bundles/scope-items.js.map +1 -1
- package/dist/bundles/structure-completions.js.map +1 -1
- package/dist/bundles/sub-language-registry.js.map +1 -1
- package/dist/bundles/sub-languages/capture/CompletionProvider.js.map +1 -1
- package/dist/bundles/sub-languages/capture/HoverProvider.js.map +1 -1
- package/dist/bundles/sub-languages/capture/Validator.js.map +1 -1
- package/dist/bundles/sub-languages/capture/index.js.map +1 -1
- package/dist/bundles/sub-languages/capture/language.js.map +1 -1
- package/dist/bundles/sub-languages/cdl.js.map +1 -1
- package/dist/bundles/sub-languages/pdl.js.map +1 -1
- package/dist/bundles/sub-languages/projection/CodeActionProvider.js.map +1 -1
- package/dist/bundles/sub-languages/projection/CompletionProvider.js +1 -1
- package/dist/bundles/sub-languages/projection/CompletionProvider.js.map +1 -1
- package/dist/bundles/sub-languages/projection/HoverProvider.js.map +1 -1
- package/dist/bundles/sub-languages/projection/Validator.js.map +1 -1
- package/dist/bundles/sub-languages/projection/index.js.map +1 -1
- package/dist/bundles/sub-languages/projection/language.js.map +1 -1
- package/dist/bundles/symbols.js +2 -2
- package/dist/bundles/symbols.js.map +1 -1
- package/dist/bundles/themes/screenplay-dark.js.map +1 -1
- package/dist/bundles/themes/screenplay-light.js.map +1 -1
- package/dist/bundles/tokens.js.map +1 -1
- package/dist/bundles/validation.js +2 -2
- package/dist/bundles/validation.js.map +1 -1
- package/dist/diagnostic-codes.d.ts +1 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{publicEventMetadataError as t}from"../Syntax/PublicEventInvariants.js";import{ScreenplaySyntaxWalker as n}from"../Syntax/ScreenplaySyntaxWalker.js";var PublicEventMetadataValidator=class extends n{context;constructor(e){super(),this.context=e}visitNode(n){let r=t(n);if(r===void 0)return;let i=n.kind===`EventSyntax`?e.InvalidEventDeclaration:n.kind===`ImportSyntax`?e.InvalidImportDeclaration:e.InvalidSliceDeclaration;this.context.error(i,r,n.location)}};function validatePublicEventMetadata(e,t){new PublicEventMetadataValidator(t).visitApplication(e)}export{validatePublicEventMetadata};
|
|
2
2
|
//# sourceMappingURL=PublicEventMetadataValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicEventMetadataValidator.js","names":["ScreenplaySyntaxWalker","context","error","publicEventMetadataError","node","code","DiagnosticCodes","application"],"sources":["../../../../../../Compiler/Parsing/PublicEventMetadataValidator.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 { publicEventMetadataError } from '../Syntax/PublicEventInvariants';\nimport { ScreenplaySyntaxWalker } from '../Syntax/ScreenplaySyntaxWalker';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { ParserContext } from './ParserContext';\n\nclass PublicEventMetadataValidator extends ScreenplaySyntaxWalker {\n constructor(private readonly context: ParserContext) { super(); }\n\n override visitNode(node: SyntaxNode): void {\n const error = publicEventMetadataError(node);\n if (error === undefined) return;\n const code = node.kind === 'EventSyntax' ? DiagnosticCodes.InvalidEventDeclaration\n : node.kind === 'ImportSyntax' ? DiagnosticCodes.InvalidImportDeclaration : DiagnosticCodes.InvalidSliceDeclaration;\n this.context.error(code, error, node.location);\n }\n}\n\nexport function validatePublicEventMetadata(application: ApplicationSyntax, context: ParserContext): void {\n new PublicEventMetadataValidator(context).visitApplication(application);\n}\n"],"mappings":"oRAUA,IAAM,6BAAN,cAA2CA,CAAuB,CACjC,QAA7B,YAAY,EAAyC,CAAE,MAAM,EAAhC,KAAA,QAAAC,CAAmC,CAEhE,UAAmB,EAAwB,CACvC,IAAMC,EAAQC,EAAyBC,CAAI,EAC3C,GAAIF,IAAU,IAAA,GAAW,OACzB,IAAMG,EAAOD,EAAK,OAAS,cAAgBE,EAAgB,wBACrDF,EAAK,OAAS,eAAiBE,EAAgB,yBAA2BA,EAAgB,wBAChG,KAAK,QAAQ,MAAMD,EAAMH,EAAOE,EAAK,QAAQ,CACjD,CACJ,EAEA,SAAgB,4BAA4B,EAAgC,EAA8B,CACtG,IAAI,6BAA6BH,CAAO,CAAC,CAAC,iBAAiBM,CAAW,CAC1E"}
|
|
1
|
+
{"version":3,"file":"PublicEventMetadataValidator.js","names":["ScreenplaySyntaxWalker","context","error","publicEventMetadataError","node","code","DiagnosticCodes","application"],"sources":["../../../../../../Compiler/Parsing/PublicEventMetadataValidator.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 { publicEventMetadataError } from '../Syntax/PublicEventInvariants';\nimport { ScreenplaySyntaxWalker } from '../Syntax/ScreenplaySyntaxWalker';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { ParserContext } from './ParserContext';\n\nclass PublicEventMetadataValidator extends ScreenplaySyntaxWalker {\n constructor(private readonly context: ParserContext) { super(); }\n\n override visitNode(node: SyntaxNode): void {\n const error = publicEventMetadataError(node);\n if (error === undefined) return;\n const code = node.kind === 'EventSyntax' ? DiagnosticCodes.InvalidEventDeclaration\n : node.kind === 'ImportSyntax' ? DiagnosticCodes.InvalidImportDeclaration : DiagnosticCodes.InvalidSliceDeclaration;\n this.context.error(code, error, node.location);\n }\n}\n\nexport function validatePublicEventMetadata(application: ApplicationSyntax, context: ParserContext): void {\n new PublicEventMetadataValidator(context).visitApplication(application);\n}\n"],"mappings":"A,oRAUA,IAAM,6BAAN,cAA2CA,CAAuB,CACjC,QAA7B,YAAY,EAAyC,CAAE,MAAM,EAAhC,KAAA,QAAAC,CAAmC,CAEhE,UAAmB,EAAwB,CACvC,IAAMC,EAAQC,EAAyBC,CAAI,EAC3C,GAAIF,IAAU,IAAA,GAAW,OACzB,IAAMG,EAAOD,EAAK,OAAS,cAAgBE,EAAgB,wBACrDF,EAAK,OAAS,eAAiBE,EAAgB,yBAA2BA,EAAgB,wBAChG,KAAK,QAAQ,MAAMD,EAAMH,EAAOE,EAAK,QAAQ,CACjD,CACJ,EAEA,SAAgB,4BAA4B,EAAgC,EAA8B,CACtG,IAAI,6BAA6BH,CAAO,CAAC,CAAC,iBAAiBM,CAAW,CAC1E,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{dependencySourcesOf as e}from"../Syntax/DependencySources.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{dependencySourcesOf as e}from"../Syntax/DependencySources.js";import{consumedEvents as t,isEventsSource as n}from"../Syntax/CaptureEventsSource.js";import{ScreenplaySyntaxWalker as r}from"../Syntax/ScreenplaySyntaxWalker.js";var PublicEventUsageCollector=class extends r{command=!1;uses=[];allEvents=[];projectionTargets=[];eventSources=[];visitProjection(e){e.readModel!=null&&this.projectionTargets.push({target:e.readModel,node:e}),super.visitProjection(e)}visitReducer(e){this.projectionTargets.push({target:e.readModel,node:e}),super.visitReducer(e)}visitCaptureSource(e){n(e)&&(this.eventSources.push(e),t(e).forEach(e=>this.uses.push({name:e.value,node:e,output:!1,command:!1}))),super.visitCaptureSource(e)}visitSlice(t){super.visitSlice(t),e(t).reducers?.forEach(e=>this.visitReducer(e))}visitCommand(e){this.command=!0,super.visitCommand(e),this.command=!1}visitProduces(e){e.inlineOperation??this.uses.push({name:e.event,node:e,output:!0,command:this.command})}visitCaptureAppend(e){this.inputOrOutput(e.event,e,!0)}visitJoinEvent(e){this.inputOrOutput(e.event,e)}visitReducerRule(e){this.inputOrOutput(e.event,e)}visitConstraint(e){e.releasedBy.forEach(t=>this.inputOrOutput(t,e)),e.kind!==`FileConstraintSyntax`&&this.inputOrOutput(e.event,e),super.visitConstraint(e)}visitProjectionBlock(e){switch(e.kind){case`FromSyntax`:e.events.forEach(e=>this.inputOrOutput(e.event,e));break;case`ClearWithSyntax`:case`RemoveWithSyntax`:case`RemoveViaJoinSyntax`:this.inputOrOutput(e.event,e);break;case`AllSyntax`:this.allEvents.push(e)}super.visitProjectionBlock(e)}visitReactionTrigger(e){e.source.kind===`NamedTriggerSourceSyntax`&&this.inputOrOutput(e.source.name,e.source),super.visitReactionTrigger(e)}visitSpecification(e){}inputOrOutput(e,t,n=!1){this.uses.push({name:e,node:t,output:n,command:!1})}};export{PublicEventUsageCollector};
|
|
2
2
|
//# sourceMappingURL=PublicEventUsageCollector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicEventUsageCollector.js","names":["ScreenplaySyntaxWalker","syntax","isEventsSource","consumedEvents","setting","dependencySourcesOf","reducer","name","event"],"sources":["../../../../../../Compiler/Parsing/PublicEventUsageCollector.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 { CommandSyntax } from '../Syntax/Commands';\nimport { CaptureAppendSyntax, CaptureSourceSyntax } from '../Syntax/Captures';\nimport { ConstraintSyntax } from '../Syntax/Constraints';\nimport { dependencySourcesOf, ReducerRuleSyntax } from '../Syntax/DependencySources';\nimport { ReducerSyntax } from '../Syntax/ReducerSyntax';\nimport { consumedEvents, isEventsSource } from '../Syntax/CaptureEventsSource';\nimport { AllSyntax, JoinEventSyntax, ProjectionBlockSyntax, ProjectionSyntax } from '../Syntax/Projections';\nimport { ProducesSyntax, ReactionTriggerSyntax } from '../Syntax/Reactions';\nimport { ScreenplaySyntaxWalker } from '../Syntax/ScreenplaySyntaxWalker';\nimport { SpecificationSyntax } from '../Syntax/Specifications';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\n\n/** Operational event edges only: fixtures and assertions are not subscriptions or appends. */\nexport class PublicEventUsageCollector extends ScreenplaySyntaxWalker {\n private command = false;\n readonly uses: { name: string; node: SyntaxNode; output: boolean; command: boolean }[] = [];\n readonly allEvents: AllSyntax[] = [];\n /** The '=> Name' of each projection and reducer: a read model, or an event in an outbound translation. */\n readonly projectionTargets: { target: string; node: SyntaxNode }[] = [];\n readonly eventSources: CaptureSourceSyntax[] = [];\n\n override visitProjection(syntax: ProjectionSyntax): void {\n if (syntax.readModel != null) this.projectionTargets.push({ target: syntax.readModel, node: syntax });\n super.visitProjection(syntax);\n }\n override visitReducer(syntax: ReducerSyntax): void {\n this.projectionTargets.push({ target: syntax.readModel, node: syntax });\n super.visitReducer(syntax);\n }\n override visitCaptureSource(syntax: CaptureSourceSyntax): void {\n if (isEventsSource(syntax)) {\n this.eventSources.push(syntax);\n consumedEvents(syntax).forEach(setting => this.uses.push({ name: setting.value, node: setting, output: false, command: false }));\n }\n super.visitCaptureSource(syntax);\n }\n\n override visitSlice(syntax: SliceSyntax): void {\n super.visitSlice(syntax);\n dependencySourcesOf(syntax).reducers?.forEach(reducer => this.visitReducer(reducer));\n }\n override visitCommand(syntax: CommandSyntax): void {\n this.command = true;\n super.visitCommand(syntax);\n this.command = false;\n }\n override visitProduces(syntax: ProducesSyntax): void {\n if (syntax.inlineOperation == null) this.uses.push({ name: syntax.event, node: syntax, output: true, command: this.command });\n }\n override visitCaptureAppend(syntax: CaptureAppendSyntax): void { this.inputOrOutput(syntax.event, syntax, true); }\n override visitJoinEvent(syntax: JoinEventSyntax): void { this.inputOrOutput(syntax.event, syntax); }\n override visitReducerRule(syntax: ReducerRuleSyntax): void { this.inputOrOutput(syntax.event, syntax); }\n override visitConstraint(syntax: ConstraintSyntax): void {\n syntax.releasedBy.forEach(name => this.inputOrOutput(name, syntax));\n if (syntax.kind !== 'FileConstraintSyntax') this.inputOrOutput(syntax.event, syntax);\n super.visitConstraint(syntax);\n }\n override visitProjectionBlock(syntax: ProjectionBlockSyntax): void {\n switch (syntax.kind) {\n case 'FromSyntax': syntax.events.forEach(event => this.inputOrOutput(event.event, event)); break;\n case 'ClearWithSyntax':\n case 'RemoveWithSyntax':\n case 'RemoveViaJoinSyntax': this.inputOrOutput(syntax.event, syntax); break;\n case 'AllSyntax': this.allEvents.push(syntax); break;\n }\n super.visitProjectionBlock(syntax);\n }\n override visitReactionTrigger(syntax: ReactionTriggerSyntax): void {\n if (syntax.source.kind === 'NamedTriggerSourceSyntax') this.inputOrOutput(syntax.source.name, syntax.source);\n super.visitReactionTrigger(syntax);\n }\n override visitSpecification(_syntax: SpecificationSyntax): void {}\n\n private inputOrOutput(name: string, node: SyntaxNode, output = false): void {\n this.uses.push({ name, node, output, command: false });\n }\n}\n"],"mappings":"6RAiBA,IAAa,0BAAb,cAA+CA,CAAuB,CAClE,QAAkB,GAClB,KAAyF,CAAC,EAC1F,UAAkC,CAAC,EAEnC,kBAAqE,CAAC,EACtE,aAA+C,CAAC,EAEhD,gBAAyB,EAAgC,CACjDC,EAAO,WAAa,MAAM,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B,EAAqC,CAC/D,OAAQA,EAAO,KAAf,CACI,IAAK,aAAcA,EAAO,OAAO,QAAQ,GAAS,KAAK,cAAcO,EAAM,MAAOA,CAAK,CAAC,EAAG,MAC3F,IAAK,kBACL,IAAK,mBACL,IAAK,sBAAuB,KAAK,cAAcP,EAAO,MAAOA,CAAM,EAAG,MACtE,IAAK,YAAa,KAAK,UAAU,KAAKA,CAAM,CAChD,CACA,MAAM,qBAAqBA,CAAM,CACrC,CACA,qBAA8B,EAAqC,CAC3DA,EAAO,OAAO,OAAS,4BAA4B,KAAK,cAAcA,EAAO,OAAO,KAAMA,EAAO,MAAM,EAC3G,MAAM,qBAAqBA,CAAM,CACrC,CACA,mBAA4B,EAAoC,CAAC,CAEjE,cAAsB,EAAc,EAAkB,EAAS,GAAa,CACxE,KAAK,KAAK,KAAK,CAAE,OAAM,OAAM,SAAQ,QAAS,EAAM,CAAC,CACzD,CACJ"}
|
|
1
|
+
{"version":3,"file":"PublicEventUsageCollector.js","names":["ScreenplaySyntaxWalker","syntax","isEventsSource","consumedEvents","setting","dependencySourcesOf","reducer","name","event"],"sources":["../../../../../../Compiler/Parsing/PublicEventUsageCollector.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 { CommandSyntax } from '../Syntax/Commands';\nimport { CaptureAppendSyntax, CaptureSourceSyntax } from '../Syntax/Captures';\nimport { ConstraintSyntax } from '../Syntax/Constraints';\nimport { dependencySourcesOf, ReducerRuleSyntax } from '../Syntax/DependencySources';\nimport { ReducerSyntax } from '../Syntax/ReducerSyntax';\nimport { consumedEvents, isEventsSource } from '../Syntax/CaptureEventsSource';\nimport { AllSyntax, JoinEventSyntax, ProjectionBlockSyntax, ProjectionSyntax } from '../Syntax/Projections';\nimport { ProducesSyntax, ReactionTriggerSyntax } from '../Syntax/Reactions';\nimport { ScreenplaySyntaxWalker } from '../Syntax/ScreenplaySyntaxWalker';\nimport { SpecificationSyntax } from '../Syntax/Specifications';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\n\n/** Operational event edges only: fixtures and assertions are not subscriptions or appends. */\nexport class PublicEventUsageCollector extends ScreenplaySyntaxWalker {\n private command = false;\n readonly uses: { name: string; node: SyntaxNode; output: boolean; command: boolean }[] = [];\n readonly allEvents: AllSyntax[] = [];\n /** The '=> Name' of each projection and reducer: a read model, or an event in an outbound translation. */\n readonly projectionTargets: { target: string; node: SyntaxNode }[] = [];\n readonly eventSources: CaptureSourceSyntax[] = [];\n\n override visitProjection(syntax: ProjectionSyntax): void {\n if (syntax.readModel != null) this.projectionTargets.push({ target: syntax.readModel, node: syntax });\n super.visitProjection(syntax);\n }\n override visitReducer(syntax: ReducerSyntax): void {\n this.projectionTargets.push({ target: syntax.readModel, node: syntax });\n super.visitReducer(syntax);\n }\n override visitCaptureSource(syntax: CaptureSourceSyntax): void {\n if (isEventsSource(syntax)) {\n this.eventSources.push(syntax);\n consumedEvents(syntax).forEach(setting => this.uses.push({ name: setting.value, node: setting, output: false, command: false }));\n }\n super.visitCaptureSource(syntax);\n }\n\n override visitSlice(syntax: SliceSyntax): void {\n super.visitSlice(syntax);\n dependencySourcesOf(syntax).reducers?.forEach(reducer => this.visitReducer(reducer));\n }\n override visitCommand(syntax: CommandSyntax): void {\n this.command = true;\n super.visitCommand(syntax);\n this.command = false;\n }\n override visitProduces(syntax: ProducesSyntax): void {\n if (syntax.inlineOperation == null) this.uses.push({ name: syntax.event, node: syntax, output: true, command: this.command });\n }\n override visitCaptureAppend(syntax: CaptureAppendSyntax): void { this.inputOrOutput(syntax.event, syntax, true); }\n override visitJoinEvent(syntax: JoinEventSyntax): void { this.inputOrOutput(syntax.event, syntax); }\n override visitReducerRule(syntax: ReducerRuleSyntax): void { this.inputOrOutput(syntax.event, syntax); }\n override visitConstraint(syntax: ConstraintSyntax): void {\n syntax.releasedBy.forEach(name => this.inputOrOutput(name, syntax));\n if (syntax.kind !== 'FileConstraintSyntax') this.inputOrOutput(syntax.event, syntax);\n super.visitConstraint(syntax);\n }\n override visitProjectionBlock(syntax: ProjectionBlockSyntax): void {\n switch (syntax.kind) {\n case 'FromSyntax': syntax.events.forEach(event => this.inputOrOutput(event.event, event)); break;\n case 'ClearWithSyntax':\n case 'RemoveWithSyntax':\n case 'RemoveViaJoinSyntax': this.inputOrOutput(syntax.event, syntax); break;\n case 'AllSyntax': this.allEvents.push(syntax); break;\n }\n super.visitProjectionBlock(syntax);\n }\n override visitReactionTrigger(syntax: ReactionTriggerSyntax): void {\n if (syntax.source.kind === 'NamedTriggerSourceSyntax') this.inputOrOutput(syntax.source.name, syntax.source);\n super.visitReactionTrigger(syntax);\n }\n override visitSpecification(_syntax: SpecificationSyntax): void {}\n\n private inputOrOutput(name: string, node: SyntaxNode, output = false): void {\n this.uses.push({ name, node, output, command: false });\n }\n}\n"],"mappings":"A,6RAiBA,IAAa,0BAAb,cAA+CA,CAAuB,CAClE,QAAkB,GAClB,KAAyF,CAAC,EAC1F,UAAkC,CAAC,EAEnC,kBAAqE,CAAC,EACtE,aAA+C,CAAC,EAEhD,gBAAyB,EAAgC,CACjDC,EAAO,WAAa,MAAM,KAAK,kBAAkB,KAAK,CAAE,OAAQA,EAAO,UAAW,KAAMA,CAAO,CAAC,EACpG,MAAM,gBAAgBA,CAAM,CAChC,CACA,aAAsB,EAA6B,CAC/C,KAAK,kBAAkB,KAAK,CAAE,OAAQA,EAAO,UAAW,KAAMA,CAAO,CAAC,EACtE,MAAM,aAAaA,CAAM,CAC7B,CACA,mBAA4B,EAAmC,CACvDC,EAAeD,CAAM,IACrB,KAAK,aAAa,KAAKA,CAAM,EAC7BE,EAAeF,CAAM,CAAC,CAAC,QAAQ,GAAW,KAAK,KAAK,KAAK,CAAE,KAAMG,EAAQ,MAAO,KAAMA,EAAS,OAAQ,GAAO,QAAS,EAAM,CAAC,CAAC,GAEnI,MAAM,mBAAmBH,CAAM,CACnC,CAEA,WAAoB,E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AAa,CACxE,KAAK,KAAK,KAAK,CAAE,OAAM,OAAM,SAAQ,QAAS,EAAM,CAAC,CACzD,CACJ,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.js";import{eventDeclarations as n}from"../Syntax/EventDeclarations.js";import{consumedEvents as r,isEventsSource as i}from"../Syntax/CaptureEventsSource.js";import{dependencySourcesOf as a}from"../Syntax/DependencySources.js";import{ParserContext as o}from"./ParserContext.js";import{PublicEventUsageCollector as s}from"./PublicEventUsageCollector.js";import{validatePublicEventMetadata as c}from"./PublicEventMetadataValidator.js";import{validateCaptureEventFixtures as l,validateEventSourceKeys as u}from"./CaptureEventFixturesValidator.js";function validatePublicEventUsage(n,r){c(n,r);let i=new t(n),a=new t(n,i.declarations.filter(e=>e.kind===`event`));for(let{slice:e,scope:t}of i.slices)validateOwnCaptureReactions(n,e,t,a,r),u(e,r);if(i.declarations.some(e=>e.node.kind===`EventSyntax`&&(e.node.visibility===`Public`||e.node.origin!=null))||n.imports.some(e=>e.visibility===`Public`||e.origin!=null)||i.slices.some(({slice:e})=>e.direction!=null||usesEventSource(e)||targetsEvent(e,i))){for(let{slice:e,scope:t}of i.slices)validateSlice(n,e,t,i,a,r);for(let t of n.seeds?.flatMap(e=>e.groups.flatMap(e=>e.events))??[]){let i=resolve(n,a,[],t.event,t,!0,r);if(i?.visibility!==`Public`)continue;let o=i.origin==null?e.PublicEventRequiresOutboundTranslation:e.ForeignPublicEventProduced;r.error(o,`Seed cannot append public event '${t.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`,t.location)}}}function validateSlice(t,r,i,a,o,c){let u=new s;u.visitSlice(r);let d=[],f=r.type===`Translate`&&r.direction===`Outbound`,p=new Set(r.readModels.map(e=>e.name));for(let{target:n,node:a}of u.projectionTargets){let s=p.has(n)?void 0:resolve(t,o,i,n,a,!1,c);s!==void 0&&(f?(d.push({node:s,output:!0}),validateUse(r,n,a,!0,!1,s,c)):c.error(e.EventTargetOutsideOutboundTranslation,`'${n}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`,a.location))}if((r.type!==`Translate`||r.direction!==`Inbound`)&&!f)for(let t of u.eventSources)c.error(e.EventsSourceOutsideInboundTranslation,`'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${r.name}'.`,t.location);let m=/* @__PURE__ */ new Map;for(let e of u.uses){let n=resolve(t,e.node.kind===`ProducesSyntax`?a:o,i,e.name,e.node,e.output,c);n!==void 0&&(d.push({node:n,output:e.output}),validateUse(r,e.name,e.node,e.output,e.command,n,c),recordCaptureOrigin(e.node,n,m))}validateCaptureOrigins(r,m,c),l(r,i,o,c);for(let e of u.allEvents){let n=a.declarations.filter(e=>e.kind===`event`).map(e=>e.node);for(let i of[...n,...t.imports.filter(e=>e.visibility===`Public`)])d.push({node:i,output:!1}),validateUse(r,i.kind===`ImportSyntax`?i.qualifiedName:i.name,e,!1,!1,i,c)}if(r.type!==`Translate`||(r.direction==null&&(n(r).some(e=>e.visibility===`Public`)||d.some(e=>e.node.visibility===`Public`))&&c.error(e.PublicTranslationRequiresDirection,`A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.`,r.location),r.direction!==`Outbound`))return;let h=new Set(d.filter(e=>e.output&&e.node.visibility===`Public`&&e.node.origin==null).map(e=>e.node)).size;h!==1&&c.error(e.OutboundPublicEventCount,`Outbound Translate slice '${r.name}' must produce exactly one local public event type; found ${h}.`,r.location);for(let t of r.captures)c.error(e.TranslationConstructDirection,`An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.`,t.location)}function validateOwnCaptureReactions(t,n,r,i,a){if(n.type!==`Translate`||n.direction!=null)return;let c=new s;c.visitSlice(n);let l=new o(a.reader,a.path),u=new Set(c.uses.filter(e=>e.node.kind===`CaptureAppendSyntax`).map(e=>resolve(t,i,r,e.name,e.node,!0,l)).filter(e=>e!==void 0));for(let o of n.reactions.filter(e=>e.from==null)){let n=/* @__PURE__ */ new Map;for(let e of o.triggers){if(e.source.kind!==`NamedTriggerSourceSyntax`)continue;let a=e.source,o=resolve(t,i,r,a.name,a,!1,l);o!==void 0&&u.has(o)&&!n.has(o)&&n.set(o,a.name)}n.size!==0&&a.warning(e.DirectionlessTranslationReactsToOwnCapture,`Reaction '${o.name}' reacts to events appended by a capture in the same directionless Translate slice (${[...n.values()].join(`, `)}); keep the capture in this Translate slice and move the reaction to an Automation slice.`,o.location)}}function recordCaptureOrigin(e,t,n){if(e.kind!==`CaptureSourceSettingSyntax`)return;let r=publicOrigin(t);r!==void 0&&n.set(e,r)}function publicOrigin(e){if(e.visibility!==`Public`)return;let t=e.origin??``;return t.trim().length>0?t:void 0}function validateCaptureOrigins(t,n,a){for(let o of t.captures){let t=o.source;if(t==null||!i(t))continue;let s=[...new Set(r(t).flatMap(e=>{let t=n.get(e);return t==null?[]:[t]}))].sort();s.length<2||a.error(e.CaptureEventsFromSeveralOrigins,`The 'from' events of capture '${o.name}' originate from several event stores (${s.join(`, `)}); a capture reads one event store - split it into one capture per origin.`,t.location)}}function validateUse(t,n,r,i,a,o,s){let c=o.origin!=null,l=o.visibility===`Public`,error=(e,t)=>s.error(e,t,r.location);i?(a&&l&&error(e.CommandProducesPublicEvent,`Command cannot produce public event '${n}'; publish through an outbound Translate slice.`),t.type===`Translate`&&t.direction===`Outbound`&&!l&&error(e.OutboundTranslationOutput,`Outbound translation must produce its one local public event, not private event '${n}'.`),c&&error(e.ForeignPublicEventProduced,`Foreign public event '${n}' cannot be produced locally; translate it into a private local event.`),l&&!c&&(t.type!==`Translate`||t.direction!==`Outbound`)&&error(e.PublicEventRequiresOutboundTranslation,`Local public event '${n}' may only be produced by an explicitly outbound Translate slice.`),t.type===`Translate`&&(t.direction??`Inbound`)===`Inbound`&&(l||c)&&error(e.InboundTranslationOutput,`Inbound translation must produce private local events, not '${n}'.`)):(c&&(t.type!==`Translate`||t.direction!==`Inbound`)&&error(e.ForeignPublicEventConsumer,`Foreign public event '${n}' may only be consumed by an explicitly inbound Translate slice.`),t.type===`Translate`&&t.direction===`Outbound`&&(l||c)&&error(e.OutboundTranslationInput,`Outbound translation must consume private local events, not '${n}'.`),t.type!==`Translate`||t.direction!==`Inbound`||l&&c||error(e.InboundTranslationInput,`Explicitly inbound translation must consume foreign public events, not '${n}'.`))}function resolve(t,n,r,i,a,o,s){let c=n.resolveFromScope(i,r);if(c.declaration?.node.kind===`EventSyntax`)return c.declaration.node;if(c.kind===`operation`)return;if(c.kind===`ambiguous`){s.warning(e.AmbiguousReference,`Ambiguous event reference '${i}'; qualify it with its owning module, feature and slice.`,a.location);return}let l=t.imports.filter(e=>e.qualifiedName.split(`.`).at(-1)===i||e.qualifiedName===i);if(l.length===1){let t=l[0],o=n.resolveFromScope(t.qualifiedName,r);if(o.declaration?.node.kind===`EventSyntax`)return o.declaration.node;if(o.kind===`ambiguous`){s.warning(e.AmbiguousReference,`Ambiguous imported event reference '${i}'; qualify its declaration.`,a.location);return}return t.visibility===`Public`?t:void 0}l.length>1?s.warning(e.AmbiguousReference,`Ambiguous imported event reference '${i}'; use its qualified name.`,a.location):(o&&a.kind!==`CaptureAppendSyntax`||a.kind===`CaptureSourceSettingSyntax`)&&!s.diagnostics.some(t=>t.code===e.UnknownEvent&&t.location.path===a.location.path&&t.location.line===a.location.line&&t.location.column===a.location.column)&&s.warning(e.UnknownEvent,`Unknown event '${i}' - declare its contract before classifying its usage.`,a.location)}function usesEventSource(e){return e.captures.some(e=>e.source!=null&&i(e.source))}function targetsEvent(e,t){return[...e.projections.map(e=>e.readModel),...(a(e).reducers??[]).map(e=>e.readModel)].some(e=>e!=null&&t.declarations.some(t=>t.kind===`event`&&t.name===e))}export{validatePublicEventUsage};
|
|
2
2
|
//# sourceMappingURL=PublicEventUsageValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicEventUsageValidator.js","names":["validatePublicEventMetadata","application","context","resolver","AuthoringProductionResolver","events","declaration","slice","scope","validateEventSourceKeys","imported","seed","group","contract","code","DiagnosticCodes","collector","PublicEventUsageCollector","contracts","explicitOutbound","readModels","readModel","target","node","source","captureOrigins","use","validateCaptureEventFixtures","all","declarations","eventDeclarations","event","outputs","capture","resolutionContext","ParserContext","appended","reaction","matching","trigger","origin","isEventsSource","origins","consumedEvents","setting","foreign","publicEvent","message","output","command","name","resolution","imports","local","diagnostic","projection","dependencySourcesOf","reducer"],"sources":["../../../../../../Compiler/Parsing/PublicEventUsageValidator.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 { EventSyntax, ImportSyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { EventVisibility } from '../Syntax/EventVisibility';\nimport { consumedEvents, isEventsSource } from '../Syntax/CaptureEventsSource';\nimport { dependencySourcesOf } from '../Syntax/DependencySources';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { TranslationDirection } from '../Syntax/TranslationDirection';\nimport { ParserContext } from './ParserContext';\nimport { PublicEventUsageCollector } from './PublicEventUsageCollector';\nimport { validatePublicEventMetadata } from './PublicEventMetadataValidator';\nimport { validateCaptureEventFixtures, validateEventSourceKeys } from './CaptureEventFixturesValidator';\n\n/** Validates public contract boundaries against the complete assembled declaration inventory. */\nexport function validatePublicEventUsage(application: ApplicationSyntax, context: ParserContext): void {\n validatePublicEventMetadata(application, context);\n const resolver = new AuthoringProductionResolver(application);\n const events = new AuthoringProductionResolver(application, resolver.declarations.filter(declaration => declaration.kind === AuthoringProductionKind.Event));\n for (const { slice, scope } of resolver.slices) {\n validateOwnCaptureReactions(application, slice, scope, events, context);\n validateEventSourceKeys(slice, context);\n }\n if (!resolver.declarations.some(declaration => declaration.node.kind === 'EventSyntax' && ((declaration.node as EventSyntax).visibility === EventVisibility.Public || (declaration.node as EventSyntax).origin != null)) &&\n !application.imports.some(imported => imported.visibility === EventVisibility.Public || imported.origin != null) &&\n !resolver.slices.some(({ slice }) => slice.direction != null || usesEventSource(slice) || targetsEvent(slice, resolver))) return;\n for (const { slice, scope } of resolver.slices) validateSlice(application, slice, scope, resolver, events, context);\n for (const seed of application.seeds?.flatMap(seed => seed.groups.flatMap(group => group.events)) ?? []) {\n const contract = resolve(application, events, [], seed.event, seed, true, context);\n if (contract?.visibility !== EventVisibility.Public) continue;\n const code = contract.origin == null ? DiagnosticCodes.PublicEventRequiresOutboundTranslation : DiagnosticCodes.ForeignPublicEventProduced;\n context.error(code, `Seed cannot append public event '${seed.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`, seed.location);\n }\n}\n\nfunction validateSlice(application: ApplicationSyntax, slice: SliceSyntax, scope: readonly string[], resolver: AuthoringProductionResolver, events: AuthoringProductionResolver, context: ParserContext): void {\n const collector = new PublicEventUsageCollector();\n collector.visitSlice(slice);\n const contracts: { node: EventSyntax | ImportSyntax; output: boolean }[] = [];\n const explicitOutbound = slice.type === 'Translate' && slice.direction === TranslationDirection.Outbound;\n const readModels = new Set(slice.readModels.map(readModel => readModel.name));\n for (const { target, node } of collector.projectionTargets) {\n // '=> Name' names a read model unless it resolves to an event: then the projection or reducer publishes that event.\n const contract = readModels.has(target) ? undefined : resolve(application, events, scope, target, node, false, context);\n if (contract === undefined) continue;\n if (!explicitOutbound) {\n context.error(DiagnosticCodes.EventTargetOutsideOutboundTranslation, `'${target}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`, node.location);\n continue;\n }\n contracts.push({ node: contract, output: true });\n validateUse(slice, target, node, true, false, contract, context);\n }\n // An outbound slice with a capture is already refused as a whole by the translation-direction check below.\n if (!(slice.type === 'Translate' && slice.direction === TranslationDirection.Inbound) && !explicitOutbound) {\n for (const source of collector.eventSources) context.error(DiagnosticCodes.EventsSourceOutsideInboundTranslation, `'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${slice.name}'.`, source.location);\n }\n const captureOrigins = new Map<SyntaxNode, string>();\n for (const use of collector.uses) {\n const contract = resolve(application, use.node.kind === 'ProducesSyntax' ? resolver : events, scope, use.name, use.node, use.output, context);\n if (contract === undefined) continue;\n contracts.push({ node: contract, output: use.output });\n validateUse(slice, use.name, use.node, use.output, use.command, contract, context);\n recordCaptureOrigin(use.node, contract, captureOrigins);\n }\n validateCaptureOrigins(slice, captureOrigins, context);\n validateCaptureEventFixtures(slice, scope, events, context);\n // 'all' subscribes to every event type; 'every' maps only the projection's existing inputs.\n for (const all of collector.allEvents) {\n const declarations = resolver.declarations.filter(declaration => declaration.kind === AuthoringProductionKind.Event).map(declaration => declaration.node as EventSyntax);\n for (const contract of [...declarations, ...application.imports.filter(imported => imported.visibility === EventVisibility.Public)]) {\n contracts.push({ node: contract, output: false });\n validateUse(slice, contract.kind === 'ImportSyntax' ? contract.qualifiedName : contract.name, all, false, false, contract, context);\n }\n }\n if (slice.type !== 'Translate') return;\n if (slice.direction == null && (eventDeclarations(slice).some(event => event.visibility === EventVisibility.Public) || contracts.some(contract => contract.node.visibility === EventVisibility.Public))) {\n context.error(DiagnosticCodes.PublicTranslationRequiresDirection, \"A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.\", slice.location);\n }\n if (slice.direction !== TranslationDirection.Outbound) return;\n const outputs = new Set(contracts.filter(contract => contract.output && contract.node.visibility === EventVisibility.Public && contract.node.origin == null).map(contract => contract.node)).size;\n if (outputs !== 1) context.error(DiagnosticCodes.OutboundPublicEventCount, `Outbound Translate slice '${slice.name}' must produce exactly one local public event type; found ${outputs}.`, slice.location);\n for (const capture of slice.captures) context.error(DiagnosticCodes.TranslationConstructDirection, 'An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.', capture.location);\n}\n\nfunction validateOwnCaptureReactions(application: ApplicationSyntax, slice: SliceSyntax, scope: readonly string[], events: AuthoringProductionResolver, context: ParserContext): void {\n if (slice.type !== 'Translate' || slice.direction != null) return;\n const collector = new PublicEventUsageCollector();\n collector.visitSlice(slice);\n // Resolution diagnostics belong to the existing reference validators, not this co-location warning.\n const resolutionContext = new ParserContext(context.reader, context.path);\n const appended = new Set(collector.uses.filter(use => use.node.kind === 'CaptureAppendSyntax')\n .map(use => resolve(application, events, scope, use.name, use.node, true, resolutionContext)).filter(node => node !== undefined));\n for (const reaction of slice.reactions.filter(reaction => reaction.from == null)) {\n const matching = new Map<EventSyntax | ImportSyntax, string>();\n for (const trigger of reaction.triggers) {\n if (trigger.source.kind !== 'NamedTriggerSourceSyntax') continue;\n const source = trigger.source;\n const node = resolve(application, events, scope, source.name, source, false, resolutionContext);\n if (node !== undefined && appended.has(node) && !matching.has(node)) matching.set(node, source.name);\n }\n if (matching.size === 0) continue;\n context.warning(DiagnosticCodes.DirectionlessTranslationReactsToOwnCapture,\n `Reaction '${reaction.name}' reacts to events appended by a capture in the same directionless Translate slice (${[...matching.values()].join(', ')}); keep the capture in this Translate slice and move the reaction to an Automation slice.`, reaction.location);\n }\n}\n\nfunction recordCaptureOrigin(node: SyntaxNode, contract: EventSyntax | ImportSyntax, captureOrigins: Map<SyntaxNode, string>): void {\n if (node.kind !== 'CaptureSourceSettingSyntax') return;\n const origin = publicOrigin(contract);\n if (origin !== undefined) captureOrigins.set(node, origin);\n}\n\nfunction publicOrigin(contract: EventSyntax | ImportSyntax): string | undefined {\n if (contract.visibility !== EventVisibility.Public) return undefined;\n const origin = contract.origin ?? '';\n return origin.trim().length > 0 ? origin : undefined;\n}\n\nfunction validateCaptureOrigins(slice: SliceSyntax, captureOrigins: Map<SyntaxNode, string>, context: ParserContext): void {\n for (const capture of slice.captures) {\n const source = capture.source;\n if (source == null || !isEventsSource(source)) continue;\n const origins = [...new Set(consumedEvents(source).flatMap(setting => {\n const origin = captureOrigins.get(setting);\n return origin == null ? [] : [origin];\n }))].sort();\n if (origins.length < 2) continue;\n context.error(DiagnosticCodes.CaptureEventsFromSeveralOrigins, `The 'from' events of capture '${capture.name}' originate from several event stores (${origins.join(', ')}); a capture reads one event store - split it into one capture per origin.`, source.location);\n }\n}\n\nfunction validateUse(slice: SliceSyntax, name: string, node: SyntaxNode, output: boolean, command: boolean, contract: EventSyntax | ImportSyntax, context: ParserContext): void {\n const foreign = contract.origin != null;\n const publicEvent = contract.visibility === EventVisibility.Public;\n const error = (code: string, message: string) => context.error(code, message, node.location);\n if (output) {\n if (command && publicEvent) error(DiagnosticCodes.CommandProducesPublicEvent, `Command cannot produce public event '${name}'; publish through an outbound Translate slice.`);\n if (slice.type === 'Translate' && slice.direction === TranslationDirection.Outbound && !publicEvent) error(DiagnosticCodes.OutboundTranslationOutput, `Outbound translation must produce its one local public event, not private event '${name}'.`);\n if (foreign) error(DiagnosticCodes.ForeignPublicEventProduced, `Foreign public event '${name}' cannot be produced locally; translate it into a private local event.`);\n if (publicEvent && !foreign && (slice.type !== 'Translate' || slice.direction !== TranslationDirection.Outbound)) error(DiagnosticCodes.PublicEventRequiresOutboundTranslation, `Local public event '${name}' may only be produced by an explicitly outbound Translate slice.`);\n if (slice.type === 'Translate' && (slice.direction ?? TranslationDirection.Inbound) === TranslationDirection.Inbound && (publicEvent || foreign)) error(DiagnosticCodes.InboundTranslationOutput, `Inbound translation must produce private local events, not '${name}'.`);\n } else {\n if (foreign && (slice.type !== 'Translate' || slice.direction !== TranslationDirection.Inbound)) error(DiagnosticCodes.ForeignPublicEventConsumer, `Foreign public event '${name}' may only be consumed by an explicitly inbound Translate slice.`);\n if (slice.type === 'Translate' && slice.direction === TranslationDirection.Outbound && (publicEvent || foreign)) error(DiagnosticCodes.OutboundTranslationInput, `Outbound translation must consume private local events, not '${name}'.`);\n if (slice.type === 'Translate' && slice.direction === TranslationDirection.Inbound && (!publicEvent || !foreign)) error(DiagnosticCodes.InboundTranslationInput, `Explicitly inbound translation must consume foreign public events, not '${name}'.`);\n }\n}\n\nfunction resolve(application: ApplicationSyntax, resolver: AuthoringProductionResolver, scope: readonly string[], name: string, use: SyntaxNode, output: boolean, context: ParserContext): EventSyntax | ImportSyntax | undefined {\n const resolution = resolver.resolveFromScope(name, scope);\n if (resolution.declaration?.node.kind === 'EventSyntax') return resolution.declaration.node as EventSyntax;\n if (resolution.kind === AuthoringProductionKind.Operation) return undefined;\n if (resolution.kind === AuthoringProductionKind.Ambiguous) {\n context.warning(DiagnosticCodes.AmbiguousReference, `Ambiguous event reference '${name}'; qualify it with its owning module, feature and slice.`, use.location);\n return undefined;\n }\n const imports = application.imports.filter(imported => imported.qualifiedName.split('.').at(-1) === name || imported.qualifiedName === name);\n if (imports.length === 1) {\n const imported = imports[0];\n const local = resolver.resolveFromScope(imported.qualifiedName, scope);\n if (local.declaration?.node.kind === 'EventSyntax') return local.declaration.node as EventSyntax;\n if (local.kind === AuthoringProductionKind.Ambiguous) {\n context.warning(DiagnosticCodes.AmbiguousReference, `Ambiguous imported event reference '${name}'; qualify its declaration.`, use.location);\n return undefined;\n }\n return imported.visibility === EventVisibility.Public ? imported : undefined;\n }\n if (imports.length > 1) context.warning(DiagnosticCodes.AmbiguousReference, `Ambiguous imported event reference '${name}'; use its qualified name.`, use.location);\n else if (((output && use.kind !== 'CaptureAppendSyntax') || use.kind === 'CaptureSourceSettingSyntax') && !context.diagnostics.some(diagnostic => diagnostic.code === DiagnosticCodes.UnknownEvent && diagnostic.location.path === use.location.path && diagnostic.location.line === use.location.line && diagnostic.location.column === use.location.column)) {\n context.warning(DiagnosticCodes.UnknownEvent, `Unknown event '${name}' - declare its contract before classifying its usage.`, use.location);\n }\n return undefined;\n}\n\nfunction usesEventSource(slice: SliceSyntax): boolean {\n return slice.captures.some(capture => capture.source != null && isEventsSource(capture.source));\n}\n\nfunction targetsEvent(slice: SliceSyntax, resolver: AuthoringProductionResolver): boolean {\n const targets = [...slice.projections.map(projection => projection.readModel), ...(dependencySourcesOf(slice).reducers ?? []).map(reducer => reducer.readModel)];\n return targets.some(target => target != null && resolver.declarations.some(declaration => declaration.kind === AuthoringProductionKind.Event && declaration.name === target));\n}\n"],"mappings":"2uBAmBA,SAAgB,yBAAyB,EAAgC,EAA8B,CACnGA,EAA4BC,EAAaC,CAAO,EAChD,IAAMC,EAAW,IAAIC,EAA4BH,CAAW,EACtDI,EAAS,IAAID,EAA4BH,EAAaE,EAAS,aAAa,OAAO,GAAeG,EAAY,OAAA,OAAsC,CAAC,EAC3J,IAAK,GAAM,CAAE,QAAO,WAAWH,EAAS,OACpC,4BAA4BF,EAAaM,EAAOC,EAAOH,EAAQH,CAAO,EACtEO,EAAwBF,EAAOL,CAAO,EAE1C,GAAKC,EAAS,aAAa,KAAK,GAAeG,EAAY,KAAK,OAAS,gBAAmBA,EAAY,KAAqB,aAAA,UAA0CA,EAAY,KAAqB,QAAU,KAAK,GAClNL,EAAY,QAAQ,KAAK,GAAYS,EAAS,aAAA,UAAyCA,EAAS,QAAU,IAAI,GAC9GP,EAAS,OAAO,MAAM,CAAE,WAAYI,EAAM,WAAa,MAAQ,gBAAgBA,CAAK,GAAK,aAAaA,EAAOJ,CAAQ,CAAC,EAC3H,KAAK,GAAM,CAAE,QAAO,WAAWA,EAAS,OAAQ,cAAcF,EAAaM,EAAOC,EAAOL,EAAUE,EAAQH,CAAO,EAClH,IAAK,IAAMS,KAAQV,EAAY,OAAO,QAAQ,GAAQU,EAAK,OAAO,QAAQ,GAASC,EAAM,MAAM,CAAC,GAAK,CAAC,EAAG,CACrG,IAAMC,EAAW,QAAQZ,EAAaI,EAAQ,CAAC,EAAGM,EAAK,MAAOA,EAAM,GAAMT,CAAO,EACjF,GAAIW,GAAU,a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e,OAAOA,EAAM,YAAY,KAC7E,GAAIA,EAAM,OAAA,YAA4C,CAClDnD,EAAQ,QAAQa,EAAgB,mBAAoB,uCAAuCmC,EAAK,6BAA8BxB,EAAI,QAAQ,EAC1I,MACJ,CACA,OAAOhB,EAAS,aAAA,SAAwCA,EAAW,IAAA,EACvE,CACI0C,EAAQ,OAAS,EAAGlD,EAAQ,QAAQa,EAAgB,mBAAoB,uCAAuCmC,EAAK,4BAA6BxB,EAAI,QAAQ,GACtJsB,GAAUtB,EAAI,OAAS,uBAA0BA,EAAI,OAAS,+BAAiC,CAACxB,EAAQ,YAAY,KAAK,GAAcoD,EAAW,OAASvC,EAAgB,cAAgBuC,EAAW,SAAS,OAAS5B,EAAI,SAAS,MAAQ4B,EAAW,SAAS,OAAS5B,EAAI,SAAS,MAAQ4B,EAAW,SAAS,SAAW5B,EAAI,SAAS,MAAM,GACxVxB,EAAQ,QAAQa,EAAgB,aAAc,kBAAkBmC,EAAK,wDAAyDxB,EAAI,QAAQ,CAGlJ,CAEA,SAAS,gBAAgB,EAA6B,CAClD,OAAOnB,EAAM,SAAS,KAAK,GAAW0B,EAAQ,QAAU,MAAQQ,EAAeR,EAAQ,MAAM,CAAC,CAClG,CAEA,SAAS,aAAa,EAAoB,EAAgD,CAEtF,MAAO,CADU,GAAG1B,EAAM,YAAY,IAAI,GAAcgD,EAAW,SAAS,EAAG,IAAIC,EAAoBjD,CAAK,CAAC,CAAC,UAAY,CAAC,EAAA,CAAG,IAAI,GAAWkD,EAAQ,SAAS,CACjJ,CAAC,CAAC,KAAK,GAAUnC,GAAU,MAAQnB,EAAS,aAAa,KAAK,GAAeG,EAAY,OAAA,SAA0CA,EAAY,OAASgB,CAAM,CAAC,CAChL"}
|
|
1
|
+
{"version":3,"file":"PublicEventUsageValidator.js","names":["validatePublicEventMetadata","application","context","resolver","AuthoringProductionResolver","events","declaration","slice","scope","validateEventSourceKeys","imported","seed","group","contract","code","DiagnosticCodes","collector","PublicEventUsageCollector","contracts","explicitOutbound","readModels","readModel","target","node","source","captureOrigins","use","validateCaptureEventFixtures","all","declarations","eventDeclarations","event","outputs","capture","resolutionContext","ParserContext","appended","reaction","matching","trigger","origin","isEventsSource","origins","consumedEvents","setting","foreign","publicEvent","message","output","command","name","resolution","imports","local","diagnostic","projection","dependencySourcesOf","reducer"],"sources":["../../../../../../Compiler/Parsing/PublicEventUsageValidator.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 { EventSyntax, ImportSyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { EventVisibility } from '../Syntax/EventVisibility';\nimport { consumedEvents, isEventsSource } from '../Syntax/CaptureEventsSource';\nimport { dependencySourcesOf } from '../Syntax/DependencySources';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { TranslationDirection } from '../Syntax/TranslationDirection';\nimport { ParserContext } from './ParserContext';\nimport { PublicEventUsageCollector } from './PublicEventUsageCollector';\nimport { validatePublicEventMetadata } from './PublicEventMetadataValidator';\nimport { validateCaptureEventFixtures, validateEventSourceKeys } from './CaptureEventFixturesValidator';\n\n/** Validates public contract boundaries against the complete assembled declaration inventory. */\nexport function validatePublicEventUsage(application: ApplicationSyntax, context: ParserContext): void {\n validatePublicEventMetadata(application, context);\n const resolver = new AuthoringProductionResolver(application);\n const events = new AuthoringProductionResolver(application, resolver.declarations.filter(declaration => declaration.kind === AuthoringProductionKind.Event));\n for (const { slice, scope } of resolver.slices) {\n validateOwnCaptureReactions(application, slice, scope, events, context);\n validateEventSourceKeys(slice, context);\n }\n if (!resolver.declarations.some(declaration => declaration.node.kind === 'EventSyntax' && ((declaration.node as EventSyntax).visibility === EventVisibility.Public || (declaration.node as EventSyntax).origin != null)) &&\n !application.imports.some(imported => imported.visibility === EventVisibility.Public || imported.origin != null) &&\n !resolver.slices.some(({ slice }) => slice.direction != null || usesEventSource(slice) || targetsEvent(slice, resolver))) return;\n for (const { slice, scope } of resolver.slices) validateSlice(application, slice, scope, resolver, events, context);\n for (const seed of application.seeds?.flatMap(seed => seed.groups.flatMap(group => group.events)) ?? []) {\n const contract = resolve(application, events, [], seed.event, seed, true, context);\n if (contract?.visibility !== EventVisibility.Public) continue;\n const code = contract.origin == null ? DiagnosticCodes.PublicEventRequiresOutboundTranslation : DiagnosticCodes.ForeignPublicEventProduced;\n context.error(code, `Seed cannot append public event '${seed.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`, seed.location);\n }\n}\n\nfunction validateSlice(application: ApplicationSyntax, slice: SliceSyntax, scope: readonly string[], resolver: AuthoringProductionResolver, events: AuthoringProductionResolver, context: ParserContext): void {\n const collector = new PublicEventUsageCollector();\n collector.visitSlice(slice);\n const contracts: { node: EventSyntax | ImportSyntax; output: boolean }[] = [];\n const explicitOutbound = slice.type === 'Translate' && slice.direction === TranslationDirection.Outbound;\n const readModels = new Set(slice.readModels.map(readModel => readModel.name));\n for (const { target, node } of collector.projectionTargets) {\n // '=> Name' names a read model unless it resolves to an event: then the projection or reducer publishes that event.\n const contract = readModels.has(target) ? undefined : resolve(application, events, scope, target, node, false, context);\n if (contract === undefined) continue;\n if (!explicitOutbound) {\n context.error(DiagnosticCodes.EventTargetOutsideOutboundTranslation, `'${target}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`, node.location);\n continue;\n }\n contracts.push({ node: contract, output: true });\n validateUse(slice, target, node, true, false, contract, context);\n }\n // An outbound slice with a capture is already refused as a whole by the translation-direction check below.\n if (!(slice.type === 'Translate' && slice.direction === TranslationDirection.Inbound) && !explicitOutbound) {\n for (const source of collector.eventSources) context.error(DiagnosticCodes.EventsSourceOutsideInboundTranslation, `'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${slice.name}'.`, source.location);\n }\n const captureOrigins = new Map<SyntaxNode, string>();\n for (const use of collector.uses) {\n const contract = resolve(application, use.node.kind === 'ProducesSyntax' ? resolver : events, scope, use.name, use.node, use.output, context);\n if (contract === undefined) continue;\n contracts.push({ node: contract, output: use.output });\n validateUse(slice, use.name, use.node, use.output, use.command, contract, context);\n recordCaptureOrigin(use.node, contract, captureOrigins);\n }\n validateCaptureOrigins(slice, captureOrigins, context);\n validateCaptureEventFixtures(slice, scope, events, context);\n // 'all' subscribes to every event type; 'every' maps only the projection's existing inputs.\n for (const all of collector.allEvents) {\n const declarations = resolver.declarations.filter(declaration => declaration.kind === AuthoringProductionKind.Event).map(declaration => declaration.node as EventSyntax);\n for (const contract of [...declarations, ...application.imports.filter(imported => imported.visibility === EventVisibility.Public)]) {\n contracts.push({ node: contract, output: false });\n validateUse(slice, contract.kind === 'ImportSyntax' ? contract.qualifiedName : contract.name, all, false, false, contract, context);\n }\n }\n if (slice.type !== 'Translate') return;\n if (slice.direction == null && (eventDeclarations(slice).some(event => event.visibility === EventVisibility.Public) || contracts.some(contract => contract.node.visibility === EventVisibility.Public))) {\n context.error(DiagnosticCodes.PublicTranslationRequiresDirection, \"A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.\", slice.location);\n }\n if (slice.direction !== TranslationDirection.Outbound) return;\n const outputs = new Set(contracts.filter(contract => contract.output && contract.node.visibility === EventVisibility.Public && contract.node.origin == null).map(contract => contract.node)).size;\n if (outputs !== 1) context.error(DiagnosticCodes.OutboundPublicEventCount, `Outbound Translate slice '${slice.name}' must produce exactly one local public event type; found ${outputs}.`, slice.location);\n for (const capture of slice.captures) context.error(DiagnosticCodes.TranslationConstructDirection, 'An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.', capture.location);\n}\n\nfunction validateOwnCaptureReactions(application: ApplicationSyntax, slice: SliceSyntax, scope: readonly string[], events: AuthoringProductionResolver, context: ParserContext): void {\n if (slice.type !== 'Translate' || slice.direction != null) return;\n const collector = new PublicEventUsageCollector();\n collector.visitSlice(slice);\n // Resolution diagnostics belong to the existing reference validators, not this co-location warning.\n const resolutionContext = new ParserContext(context.reader, context.path);\n const appended = new Set(collector.uses.filter(use => use.node.kind === 'CaptureAppendSyntax')\n .map(use => resolve(application, events, scope, use.name, use.node, true, resolutionContext)).filter(node => node !== undefined));\n for (const reaction of slice.reactions.filter(reaction => reaction.from == null)) {\n const matching = new Map<EventSyntax | ImportSyntax, string>();\n for (const trigger of reaction.triggers) {\n if (trigger.source.kind !== 'NamedTriggerSourceSyntax') continue;\n const source = trigger.source;\n const node = resolve(application, events, scope, source.name, source, false, resolutionContext);\n if (node !== undefined && appended.has(node) && !matching.has(node)) matching.set(node, source.name);\n }\n if (matching.size === 0) continue;\n context.warning(DiagnosticCodes.DirectionlessTranslationReactsToOwnCapture,\n `Reaction '${reaction.name}' reacts to events appended by a capture in the same directionless Translate slice (${[...matching.values()].join(', ')}); keep the capture in this Translate slice and move the reaction to an Automation slice.`, reaction.location);\n }\n}\n\nfunction recordCaptureOrigin(node: SyntaxNode, contract: EventSyntax | ImportSyntax, captureOrigins: Map<SyntaxNode, string>): void {\n if (node.kind !== 'CaptureSourceSettingSyntax') return;\n const origin = publicOrigin(contract);\n if (origin !== undefined) captureOrigins.set(node, origin);\n}\n\nfunction publicOrigin(contract: EventSyntax | ImportSyntax): string | undefined {\n if (contract.visibility !== EventVisibility.Public) return undefined;\n const origin = contract.origin ?? '';\n return origin.trim().length > 0 ? origin : undefined;\n}\n\nfunction validateCaptureOrigins(slice: SliceSyntax, captureOrigins: Map<SyntaxNode, string>, context: ParserContext): void {\n for (const capture of slice.captures) {\n const source = capture.source;\n if (source == null || !isEventsSource(source)) continue;\n const origins = [...new Set(consumedEvents(source).flatMap(setting => {\n const origin = captureOrigins.get(setting);\n return origin == null ? [] : [origin];\n }))].sort();\n if (origins.length < 2) continue;\n context.error(DiagnosticCodes.CaptureEventsFromSeveralOrigins, `The 'from' events of capture '${capture.name}' originate from several event stores (${origins.join(', ')}); a capture reads one event store - split it into one capture per origin.`, source.location);\n }\n}\n\nfunction validateUse(slice: SliceSyntax, name: string, node: SyntaxNode, output: boolean, command: boolean, contract: EventSyntax | ImportSyntax, context: ParserContext): void {\n const foreign = contract.origin != null;\n const publicEvent = contract.visibility === EventVisibility.Public;\n const error = (code: string, message: string) => context.error(code, message, node.location);\n if (output) {\n if (command && publicEvent) error(DiagnosticCodes.CommandProducesPublicEvent, `Command cannot produce public event '${name}'; publish through an outbound Translate slice.`);\n if (slice.type === 'Translate' && slice.direction === TranslationDirection.Outbound && !publicEvent) error(DiagnosticCodes.OutboundTranslationOutput, `Outbound translation must produce its one local public event, not private event '${name}'.`);\n if (foreign) error(DiagnosticCodes.ForeignPublicEventProduced, `Foreign public event '${name}' cannot be produced locally; translate it into a private local event.`);\n if (publicEvent && !foreign && (slice.type !== 'Translate' || slice.direction !== TranslationDirection.Outbound)) error(DiagnosticCodes.PublicEventRequiresOutboundTranslation, `Local public event '${name}' may only be produced by an explicitly outbound Translate slice.`);\n if (slice.type === 'Translate' && (slice.direction ?? TranslationDirection.Inbound) === TranslationDirection.Inbound && (publicEvent || foreign)) error(DiagnosticCodes.InboundTranslationOutput, `Inbound translation must produce private local events, not '${name}'.`);\n } else {\n if (foreign && (slice.type !== 'Translate' || slice.direction !== TranslationDirection.Inbound)) error(DiagnosticCodes.ForeignPublicEventConsumer, `Foreign public event '${name}' may only be consumed by an explicitly inbound Translate slice.`);\n if (slice.type === 'Translate' && slice.direction === TranslationDirection.Outbound && (publicEvent || foreign)) error(DiagnosticCodes.OutboundTranslationInput, `Outbound translation must consume private local events, not '${name}'.`);\n if (slice.type === 'Translate' && slice.direction === TranslationDirection.Inbound && (!publicEvent || !foreign)) error(DiagnosticCodes.InboundTranslationInput, `Explicitly inbound translation must consume foreign public events, not '${name}'.`);\n }\n}\n\nfunction resolve(application: ApplicationSyntax, resolver: AuthoringProductionResolver, scope: readonly string[], name: string, use: SyntaxNode, output: boolean, context: ParserContext): EventSyntax | ImportSyntax | undefined {\n const resolution = resolver.resolveFromScope(name, scope);\n if (resolution.declaration?.node.kind === 'EventSyntax') return resolution.declaration.node as EventSyntax;\n if (resolution.kind === AuthoringProductionKind.Operation) return undefined;\n if (resolution.kind === AuthoringProductionKind.Ambiguous) {\n context.warning(DiagnosticCodes.AmbiguousReference, `Ambiguous event reference '${name}'; qualify it with its owning module, feature and slice.`, use.location);\n return undefined;\n }\n const imports = application.imports.filter(imported => imported.qualifiedName.split('.').at(-1) === name || imported.qualifiedName === name);\n if (imports.length === 1) {\n const imported = imports[0];\n const local = resolver.resolveFromScope(imported.qualifiedName, scope);\n if (local.declaration?.node.kind === 'EventSyntax') return local.declaration.node as EventSyntax;\n if (local.kind === AuthoringProductionKind.Ambiguous) {\n context.warning(DiagnosticCodes.AmbiguousReference, `Ambiguous imported event reference '${name}'; qualify its declaration.`, use.location);\n return undefined;\n }\n return imported.visibility === EventVisibility.Public ? imported : undefined;\n }\n if (imports.length > 1) context.warning(DiagnosticCodes.AmbiguousReference, `Ambiguous imported event reference '${name}'; use its qualified name.`, use.location);\n else if (((output && use.kind !== 'CaptureAppendSyntax') || use.kind === 'CaptureSourceSettingSyntax') && !context.diagnostics.some(diagnostic => diagnostic.code === DiagnosticCodes.UnknownEvent && diagnostic.location.path === use.location.path && diagnostic.location.line === use.location.line && diagnostic.location.column === use.location.column)) {\n context.warning(DiagnosticCodes.UnknownEvent, `Unknown event '${name}' - declare its contract before classifying its usage.`, use.location);\n }\n return undefined;\n}\n\nfunction usesEventSource(slice: SliceSyntax): boolean {\n return slice.captures.some(capture => capture.source != null && isEventsSource(capture.source));\n}\n\nfunction targetsEvent(slice: SliceSyntax, resolver: AuthoringProductionResolver): boolean {\n const targets = [...slice.projections.map(projection => projection.readModel), ...(dependencySourcesOf(slice).reducers ?? []).map(reducer => reducer.readModel)];\n return targets.some(target => target != null && resolver.declarations.some(declaration => declaration.kind ===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BAAoB,uCAAuCmC,EAAK,4BAA6BxB,EAAI,QAAQ,GACtJsB,GAAUtB,EAAI,OAAS,uBAA0BA,EAAI,OAAS,+BAAiC,CAACxB,EAAQ,YAAY,KAAK,GAAcoD,EAAW,OAASvC,EAAgB,cAAgBuC,EAAW,SAAS,OAAS5B,EAAI,SAAS,MAAQ4B,EAAW,SAAS,OAAS5B,EAAI,SAAS,MAAQ4B,EAAW,SAAS,SAAW5B,EAAI,SAAS,MAAM,GACxVxB,EAAQ,QAAQa,EAAgB,aAAc,kBAAkBmC,EAAK,wDAAyDxB,EAAI,QAAQ,CAGlJ,CAEA,SAAS,gBAAgB,EAA6B,CAClD,OAAOnB,EAAM,SAAS,KAAK,GAAW0B,EAAQ,QAAU,MAAQQ,EAAeR,EAAQ,MAAM,CAAC,CAClG,CAEA,SAAS,aAAa,EAAoB,EAAgD,CAEtF,MAAO,CADU,GAAG1B,EAAM,YAAY,IAAI,GAAcgD,EAAW,SAAS,EAAG,IAAIC,EAAoBjD,CAAK,CAAC,CAAC,UAAY,CAAC,EAAA,CAAG,IAAI,GAAWkD,EAAQ,SAAS,CACjJ,CAAC,CAAC,KAAK,GAAUnC,GAAU,MAAQnB,EAAS,aAAa,KAAK,GAAeG,EAAY,OAAA,SAA0CA,EAAY,OAASgB,CAAM,CAAC,CAChL,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{parseDescription as i}from"./DescriptionParser.js";import{firstWord as a}from"./LineText.js";import{locationOf as o}from"./SourceLine.js";const s=r(`^purpose\\s+([A-Za-z_]\\w*)$`),c=r(`^(basis|condition)\\s+(\\w+)(?:\\s+"(${t})")?$`),l=r(`^(interest|authorization|retention|recipient)\\s+"(${t})"$`),u=r(`^transfer\\s+"(${t})"\\s+safeguard\\s+"(${t})"$`),d=r(`^[A-Za-z_]\\w*$`),f=r(`^erasure\\s+exception\\s+(\\w+)$`),p=[`consent`,`contract`,`legalObligation`,`vitalInterests`,`publicTask`,`legitimateInterests`],m=[`explicitConsent`,`employmentLaw`,`vitalInterests`,`notForProfit`,`madePublic`,`legalClaims`,`substantialPublicInterest`,`healthCare`,`publicHealth`,`research`],h=[`expression`,`legalObligation`,`publicTask`,`publicHealth`,`archiving`,`legalClaims`];function parsePurpose(t,r){let s=purposeName(t,r),g={kind:`PurposeSyntax`,name:s,description:null,basis:null,basisReference:null,interest:null,condition:null,conditionReference:null,authorization:null,subjects:[],retention:null,recipients:[],transfers:[],erasureException:null,location:o(r)},_=/* @__PURE__ */ new Set,v=[],y=[];for(let b=t.peekChild(r.indent);b!==void 0;b=t.peekChild(r.indent)){t.reader.takeSignificant();let r=a(b.content);if(r!==`recipient`&&r!==`transfer`&&_.has(r))t.error(e.DuplicatePurposeField,`Purpose '${s}' already declares '${r}' - at most one is allowed`,o(b)),t.skipBlock(b.indent);else if(_.add(r),r===`description`)g={...g,description:i(t,b,g.description,`Purpose '${s}'`)};else if(r===`basis`||r===`condition`){let i=c.exec(b.content),a=r===`basis`?p:m;if(i===null||!a.includes(i[2]))t.error(e.InvalidPurposeVocabulary,`Invalid ${r} in purpose '${s}' - expected ${a.join(`, `)} with an optional quoted reference`,o(b));else{let e=i[3]===void 0?null:n(i[3]);g=r===`basis`?{...g,basis:i[2],basisReference:e}:{...g,condition:i[2],conditionReference:e}}}else if(r===`interest`||r===`authorization`||r===`retention`||r===`recipient`){let i=l.exec(b.content);i===null?t.error(e.InvalidPurposeDeclaration,`Invalid purpose field '${b.content}' - expected '${r} "<text>"'`,o(b)):r===`recipient`?v.push(n(i[2])):g={...g,[r]:n(i[2])}}else if(r===`subjects`){let n=b.content.slice(8).split(`,`).map(e=>e.trim());n.every(e=>d.test(e))?g={...g,subjects:[...new Set(n)]}:t.error(e.InvalidPurposeDeclaration,`Invalid purpose subjects '${b.content}' - expected comma-separated identifiers`,o(b))}else if(r===`erasure`){let n=f.exec(b.content);n!==null&&h.includes(n[1])?g={...g,erasureException:n[1]}:t.error(e.InvalidPurposeVocabulary,`Invalid erasure exception '${b.content}' - expected 'erasure exception ${h.join(`|`)}'`,o(b))}else if(r===`transfer`){let r=u.exec(b.content);r===null?t.error(e.InvalidPurposeDeclaration,`Invalid transfer '${b.content}' - expected 'transfer "<destination>" safeguard "<text>"'`,o(b)):y.push({kind:`PurposeTransferSyntax`,destination:n(r[1]),safeguard:n(r[2]),location:o(b)})}else t.error(e.InvalidPurposeDeclaration,`Unexpected '${b.content}' in purpose '${s}'`,o(b)),t.skipBlock(b.indent)}return{...g,recipients:v,transfers:y}}function parsePurposeReference(e,t,n){let r=purposeName(e,t);r.length>0&&!n.some(e=>e.name===r)&&n.push({kind:`PurposeReferenceSyntax`,name:r,location:o(t)})}function purposeName(t,n){let r=s.exec(n.content);return r===null?(t.error(e.InvalidPurposeDeclaration,`Invalid purpose declaration '${n.content}' - expected 'purpose <Name>'`,o(n)),``):r[1]}export{parsePurpose,parsePurposeReference};
|
|
2
2
|
//# sourceMappingURL=PurposeParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PurposeParser.js","names":["header","pattern","vocabulary","stringBodyPattern","textField","transfer","identifier","erasure","bases","conditions","exceptions","name","context","line","purpose","locationOf","seen","recipients","transfers","child","keyword","firstWord","DiagnosticCodes","parseDescription","match","values","reference","unescapeString","subjects","value","references"],"sources":["../../../../../../Compiler/Parsing/PurposeParser.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 { PurposeReferenceSyntax, PurposeSyntax, PurposeTransferSyntax } from '../Syntax/Purposes';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^purpose\\\\s+([A-Za-z_]\\\\w*)$');\nconst vocabulary = pattern(`^(basis|condition)\\\\s+(\\\\w+)(?:\\\\s+\"(${stringBodyPattern})\")?$`);\nconst textField = pattern(`^(interest|authorization|retention|recipient)\\\\s+\"(${stringBodyPattern})\"$`);\nconst transfer = pattern(`^transfer\\\\s+\"(${stringBodyPattern})\"\\\\s+safeguard\\\\s+\"(${stringBodyPattern})\"$`);\nconst identifier = pattern('^[A-Za-z_]\\\\w*$');\nconst erasure = pattern('^erasure\\\\s+exception\\\\s+(\\\\w+)$');\nconst bases = ['consent', 'contract', 'legalObligation', 'vitalInterests', 'publicTask', 'legitimateInterests'];\nconst conditions = ['explicitConsent', 'employmentLaw', 'vitalInterests', 'notForProfit', 'madePublic', 'legalClaims', 'substantialPublicInterest', 'healthCare', 'publicHealth', 'research'];\nconst exceptions = ['expression', 'legalObligation', 'publicTask', 'publicHealth', 'archiving', 'legalClaims'];\n\nexport function parsePurpose(context: ParserContext, line: SourceLine): PurposeSyntax {\n const name = purposeName(context, line);\n let purpose: PurposeSyntax = { kind: 'PurposeSyntax', name, description: null, basis: null, basisReference: null, interest: null, condition: null, conditionReference: null, authorization: null, subjects: [], retention: null, recipients: [], transfers: [], erasureException: null, location: locationOf(line) };\n const seen = new Set<string>();\n const recipients: string[] = [];\n const transfers: PurposeTransferSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword !== 'recipient' && keyword !== 'transfer' && seen.has(keyword)) {\n context.error(DiagnosticCodes.DuplicatePurposeField, `Purpose '${name}' already declares '${keyword}' - at most one is allowed`, locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n seen.add(keyword);\n if (keyword === 'description') purpose = { ...purpose, description: parseDescription(context, child, purpose.description, `Purpose '${name}'`) };\n else if (keyword === 'basis' || keyword === 'condition') {\n const match = vocabulary.exec(child.content);\n const values = keyword === 'basis' ? bases : conditions;\n if (match === null || !values.includes(match[2])) {\n context.error(DiagnosticCodes.InvalidPurposeVocabulary, `Invalid ${keyword} in purpose '${name}' - expected ${values.join(', ')} with an optional quoted reference`, locationOf(child));\n } else {\n const reference = match[3] === undefined ? null : unescapeString(match[3]);\n purpose = keyword === 'basis' ? { ...purpose, basis: match[2], basisReference: reference } : { ...purpose, condition: match[2], conditionReference: reference };\n }\n } else if (keyword === 'interest' || keyword === 'authorization' || keyword === 'retention' || keyword === 'recipient') {\n const match = textField.exec(child.content);\n if (match === null) context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Invalid purpose field '${child.content}' - expected '${keyword} \"<text>\"'`, locationOf(child));\n else if (keyword === 'recipient') recipients.push(unescapeString(match[2]));\n else purpose = { ...purpose, [keyword]: unescapeString(match[2]) };\n } else if (keyword === 'subjects') {\n const subjects = child.content.slice('subjects'.length).split(',').map(value => value.trim());\n if (subjects.every(value => identifier.test(value))) purpose = { ...purpose, subjects: [...new Set(subjects)] };\n else context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Invalid purpose subjects '${child.content}' - expected comma-separated identifiers`, locationOf(child));\n } else if (keyword === 'erasure') {\n const match = erasure.exec(child.content);\n if (match !== null && exceptions.includes(match[1])) purpose = { ...purpose, erasureException: match[1] };\n else context.error(DiagnosticCodes.InvalidPurposeVocabulary, `Invalid erasure exception '${child.content}' - expected 'erasure exception ${exceptions.join('|')}'`, locationOf(child));\n } else if (keyword === 'transfer') {\n const match = transfer.exec(child.content);\n if (match === null) context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Invalid transfer '${child.content}' - expected 'transfer \"<destination>\" safeguard \"<text>\"'`, locationOf(child));\n else transfers.push({ kind: 'PurposeTransferSyntax', destination: unescapeString(match[1]), safeguard: unescapeString(match[2]), location: locationOf(child) });\n } else {\n context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Unexpected '${child.content}' in purpose '${name}'`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { ...purpose, recipients, transfers };\n}\n\nexport function parsePurposeReference(context: ParserContext, line: SourceLine, references: PurposeReferenceSyntax[]): void {\n const name = purposeName(context, line);\n if (name.length > 0 && !references.some(reference => reference.name === name)) references.push({ kind: 'PurposeReferenceSyntax', name, location: locationOf(line) });\n}\n\nfunction purposeName(context: ParserContext, line: SourceLine): string {\n const match = header.exec(line.content);\n if (match !== null) return match[1];\n context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Invalid purpose declaration '${line.content}' - expected 'purpose <Name>'`, locationOf(line));\n return '';\n}\n"],"mappings":"yYAYA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAaD,EAAQ,wCAAwCE,EAAkB,MAAM,EACrFC,EAAYH,EAAQ,sDAAsDE,EAAkB,IAAI,EAChGE,EAAWJ,EAAQ,kBAAkBE,EAAkB,uBAAuBA,EAAkB,IAAI,EACpGG,EAAaL,EAAQ,iBAAiB,EACtCM,EAAUN,EAAQ,kCAAkC,EACpDO,EAAQ,CAAC,UAAW,WAAY,kBAAmB,iBAAkB,aAAc,qBAAqB,EACxGC,EAAa,CAAC,kBAAmB,gBAAiB,iBAAkB,eAAgB,aAAc,cAAe,4BAA6B,aAAc,eAAgB,UAAU,EACtLC,EAAa,CAAC,aAAc,kBAAmB,aAAc,eAAgB,YAAa,aAAa,EAE7G,SAAgB,aAAa,EAAwB,EAAiC,CAClF,IAAMC,EAAO,YAAYC,EAASC,CAAI,EAClCC,EAAyB,CAAE,KAAM,gBAAiB,OAAM,YAAa,KAAM,MAAO,KAAM,eAAgB,KAAM,SAAU,KAAM,UAAW,KAAM,mBA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zLD,EAAU,KAAK,CAAE,KAAM,wBAAyB,YAAaS,EAAeH,EAAM,EAAE,EAAG,UAAWG,EAAeH,EAAM,EAAE,EAAG,SAAUT,EAAWI,CAAK,CAAE,CAAC,CAClK,MACIP,EAAQ,MAAMU,EAAgB,0BAA2B,eAAeH,EAAM,QAAQ,gBAAgBR,EAAK,GAAII,EAAWI,CAAK,CAAC,EAChIP,EAAQ,UAAUO,EAAM,MAAM,CAEtC,CACA,MAAO,CAAE,GAAGL,EAAS,aAAY,WAAU,CAC/C,CAEA,SAAgB,sBAAsB,EAAwB,EAAkB,EAA4C,CACxH,IAAMH,EAAO,YAAYC,EAASC,CAAI,EAClCF,EAAK,OAAS,GAAK,CAACmB,EAAW,KAAK,GAAaJ,EAAU,OAASf,CAAI,GAAGmB,EAAW,KAAK,CAAE,KAAM,yBAA0B,OAAM,SAAUf,EAAWF,CAAI,CAAE,CAAC,CACvK,CAEA,SAAS,YAAY,EAAwB,EAA0B,CACnE,IAAMW,EAAQxB,EAAO,KAAKa,EAAK,OAAO,EAGtC,OAFIW,IAAU,MACdZ,EAAQ,MAAMU,EAAgB,0BAA2B,gCAAgCT,EAAK,QAAQ,+BAAgCE,EAAWF,CAAI,CAAC,EAC/I,IAFoBW,EAAM,EAGrC"}
|
|
1
|
+
{"version":3,"file":"PurposeParser.js","names":["header","pattern","vocabulary","stringBodyPattern","textField","transfer","identifier","erasure","bases","conditions","exceptions","name","context","line","purpose","locationOf","seen","recipients","transfers","child","keyword","firstWord","DiagnosticCodes","parseDescription","match","values","reference","unescapeString","subjects","value","references"],"sources":["../../../../../../Compiler/Parsing/PurposeParser.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 { PurposeReferenceSyntax, PurposeSyntax, PurposeTransferSyntax } from '../Syntax/Purposes';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^purpose\\\\s+([A-Za-z_]\\\\w*)$');\nconst vocabulary = pattern(`^(basis|condition)\\\\s+(\\\\w+)(?:\\\\s+\"(${stringBodyPattern})\")?$`);\nconst textField = pattern(`^(interest|authorization|retention|recipient)\\\\s+\"(${stringBodyPattern})\"$`);\nconst transfer = pattern(`^transfer\\\\s+\"(${stringBodyPattern})\"\\\\s+safeguard\\\\s+\"(${stringBodyPattern})\"$`);\nconst identifier = pattern('^[A-Za-z_]\\\\w*$');\nconst erasure = pattern('^erasure\\\\s+exception\\\\s+(\\\\w+)$');\nconst bases = ['consent', 'contract', 'legalObligation', 'vitalInterests', 'publicTask', 'legitimateInterests'];\nconst conditions = ['explicitConsent', 'employmentLaw', 'vitalInterests', 'notForProfit', 'madePublic', 'legalClaims', 'substantialPublicInterest', 'healthCare', 'publicHealth', 'research'];\nconst exceptions = ['expression', 'legalObligation', 'publicTask', 'publicHealth', 'archiving', 'legalClaims'];\n\nexport function parsePurpose(context: ParserContext, line: SourceLine): PurposeSyntax {\n const name = purposeName(context, line);\n let purpose: PurposeSyntax = { kind: 'PurposeSyntax', name, description: null, basis: null, basisReference: null, interest: null, condition: null, conditionReference: null, authorization: null, subjects: [], retention: null, recipients: [], transfers: [], erasureException: null, location: locationOf(line) };\n const seen = new Set<string>();\n const recipients: string[] = [];\n const transfers: PurposeTransferSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword !== 'recipient' && keyword !== 'transfer' && seen.has(keyword)) {\n context.error(DiagnosticCodes.DuplicatePurposeField, `Purpose '${name}' already declares '${keyword}' - at most one is allowed`, locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n seen.add(keyword);\n if (keyword === 'description') purpose = { ...purpose, description: parseDescription(context, child, purpose.description, `Purpose '${name}'`) };\n else if (keyword === 'basis' || keyword === 'condition') {\n const match = vocabulary.exec(child.content);\n const values = keyword === 'basis' ? bases : conditions;\n if (match === null || !values.includes(match[2])) {\n context.error(DiagnosticCodes.InvalidPurposeVocabulary, `Invalid ${keyword} in purpose '${name}' - expected ${values.join(', ')} with an optional quoted reference`, locationOf(child));\n } else {\n const reference = match[3] === undefined ? null : unescapeString(match[3]);\n purpose = keyword === 'basis' ? { ...purpose, basis: match[2], basisReference: reference } : { ...purpose, condition: match[2], conditionReference: reference };\n }\n } else if (keyword === 'interest' || keyword === 'authorization' || keyword === 'retention' || keyword === 'recipient') {\n const match = textField.exec(child.content);\n if (match === null) context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Invalid purpose field '${child.content}' - expected '${keyword} \"<text>\"'`, locationOf(child));\n else if (keyword === 'recipient') recipients.push(unescapeString(match[2]));\n else purpose = { ...purpose, [keyword]: unescapeString(match[2]) };\n } else if (keyword === 'subjects') {\n const subjects = child.content.slice('subjects'.length).split(',').map(value => value.trim());\n if (subjects.every(value => identifier.test(value))) purpose = { ...purpose, subjects: [...new Set(subjects)] };\n else context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Invalid purpose subjects '${child.content}' - expected comma-separated identifiers`, locationOf(child));\n } else if (keyword === 'erasure') {\n const match = erasure.exec(child.content);\n if (match !== null && exceptions.includes(match[1])) purpose = { ...purpose, erasureException: match[1] };\n else context.error(DiagnosticCodes.InvalidPurposeVocabulary, `Invalid erasure exception '${child.content}' - expected 'erasure exception ${exceptions.join('|')}'`, locationOf(child));\n } else if (keyword === 'transfer') {\n const match = transfer.exec(child.content);\n if (match === null) context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Invalid transfer '${child.content}' - expected 'transfer \"<destination>\" safeguard \"<text>\"'`, locationOf(child));\n else transfers.push({ kind: 'PurposeTransferSyntax', destination: unescapeString(match[1]), safeguard: unescapeString(match[2]), location: locationOf(child) });\n } else {\n context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Unexpected '${child.content}' in purpose '${name}'`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { ...purpose, recipients, transfers };\n}\n\nexport function parsePurposeReference(context: ParserContext, line: SourceLine, references: PurposeReferenceSyntax[]): void {\n const name = purposeName(context, line);\n if (name.length > 0 && !references.some(reference => reference.name === name)) references.push({ kind: 'PurposeReferenceSyntax', name, location: locationOf(line) });\n}\n\nfunction purposeName(context: ParserContext, line: SourceLine): string {\n const match = header.exec(line.content);\n if (match !== null) return match[1];\n context.error(DiagnosticCodes.InvalidPurposeDeclaration, `Invalid purpose declaration '${line.content}' - expected 'purpose <Name>'`, locationOf(line));\n return '';\n}\n"],"mappings":"A,yYAYA,MAAMA,EAASC,EAAQ,8BAA8B,EAC/CC,EAAaD,EAAQ,wCAAwCE,EAAkB,MAAM,EACrFC,EAAYH,EAAQ,sDAAsDE,EAAkB,IAAI,EAChGE,EAAWJ,EAAQ,kBAAkBE,EAAkB,uBAAuBA,EAAkB,IAAI,EACpGG,EAAaL,EAAQ,iBAAiB,EACtCM,EAAUN,EAAQ,kCAAkC,EACpDO,EAAQ,CAAC,UAAW,WAAY,kBAAmB,iBAAkB,aAAc,qBAAqB,EACxGC,EAAa,CAAC,kBAAmB,gBAAiB,iBAAkB,eAAgB,aAAc,cAAe,4BAA6B,aAAc,eAAgB,UAAU,EACtLC,EAAa,CAAC,aAAc,kBAAmB,aAAc,eAAgB,YAAa,aAAa,EAE7G,SAAgB,aAAa,EAAwB,EAAiC,CAClF,IAAMC,EAAO,YAAYC,EAASC,CAAI,EAClCC,EAAyB,CAAE,KAAM,gBAAiB,OAAM,YAAa,KAAM,MAAO,KAAM,eAAgB,KAAM,SAAU,KAAM,UAAW,KAAM,mBAAoB,KAAM,cAAe,KAAM,SAAU,CAAC,EAAG,UAAW,KAAM,WAAY,CAAC,EAAG,UAAW,CAAC,EAAG,iBAAkB,KAAM,SAAUC,EAAWF,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AAK,CAAE,CAAC,CAClK,MACIP,EAAQ,MAAMU,EAAgB,0BAA2B,eAAeH,EAAM,QAAQ,gBAAgBR,EAAK,GAAII,EAAWI,CAAK,CAAC,EAChIP,EAAQ,UAAUO,EAAM,MAAM,CAEtC,CACA,MAAO,CAAE,GAAGL,EAAS,aAAY,WAAU,CAC/C,CAEA,SAAgB,sBAAsB,EAAwB,EAAkB,EAA4C,CACxH,IAAMH,EAAO,YAAYC,EAASC,CAAI,EAClCF,EAAK,OAAS,GAAK,CAACmB,EAAW,KAAK,GAAaJ,EAAU,OAASf,CAAI,GAAGmB,EAAW,KAAK,CAAE,KAAM,yBAA0B,OAAM,SAAUf,EAAWF,CAAI,CAAE,CAAC,CACvK,CAEA,SAAS,YAAY,EAAwB,EAA0B,CACnE,IAAMW,EAAQxB,EAAO,KAAKa,EAAK,OAAO,EAGtC,OAFIW,IAAU,MACdZ,EAAQ,MAAMU,EAAgB,0BAA2B,gCAAgCT,EAAK,QAAQ,+BAAgCE,EAAWF,CAAI,CAAC,EAC/I,IAFoBW,EAAM,EAGrC,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PurposeValidator.js","names":["known","purpose","application","context","DiagnosticCodes","references","feature","slice","module","reference"],"sources":["../../../../../../Compiler/Parsing/PurposeValidator.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 { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\n\nexport function validatePurposes(application: ApplicationSyntax, context: ParserContext): void {\n const known = new Set<string>();\n for (const purpose of application.purposes ?? []) {\n if (known.has(purpose.name)) context.error(DiagnosticCodes.DuplicatePurposeDeclaration, `Duplicate purpose '${purpose.name}' - a purpose is declared once`, purpose.location);\n known.add(purpose.name);\n }\n for (const purpose of application.purposes ?? []) {\n if (purpose.interest !== null && purpose.basis !== 'legitimateInterests') context.warning(DiagnosticCodes.PurposeInterestMismatch, `Purpose '${purpose.name}' declares an interest without basis legitimateInterests`, purpose.location);\n else if (purpose.basis === 'legitimateInterests' && !purpose.interest?.trim()) context.warning(DiagnosticCodes.PurposeInterestMismatch, `Purpose '${purpose.name}' with basis legitimateInterests has no interest statement (Art. 13(1)(d))`, purpose.location);\n }\n const references: PurposeReferenceSyntax[] = [];\n const collect = (feature: FeatureSyntax): void => {\n references.push(...feature.purposes ?? [], ...feature.slices.flatMap(slice => slice.purposes ?? []));\n feature.features.forEach(collect);\n };\n for (const module of application.modules) {\n references.push(...module.purposes ?? []);\n module.features.forEach(collect);\n }\n for (const reference of references) {\n if (!known.has(reference.name)) context.warning(DiagnosticCodes.UnknownPurpose, `Unknown purpose '${reference.name}' - declare it with 'purpose ${reference.name}'`, reference.location);\n }\n}\n"],"mappings":"yHAQA,SAAgB,iBAAiB,EAAgC,EAA8B,CAC3F,IAAMA,kBAAQ,IAAI,IAClB,IAAK,IAAMC,KAAWC,EAAY,UAAY,CAAC,EACvCF,EAAM,IAAIC,EAAQ,IAAI,GAAGE,EAAQ,MAAMC,EAAgB,4BAA6B,sBAAsBH,EAAQ,KAAK,gCAAiCA,EAAQ,QAAQ,EAC5KD,EAAM,IAAIC,EAAQ,IAAI,EAE1B,IAAK,IAAMA,KAAWC,EAAY,UAAY,CAAC,EACvCD,EAAQ,WAAa,MAAQA,EAAQ,QAAU,sBAAuBE,EAAQ,QAAQC,EAAgB,wBAAyB,YAAYH,EAAQ,KAAK,0DAA2DA,EAAQ,QAAQ,EAC9NA,EAAQ,QAAU,uBAAyB,CAACA,EAAQ,UAAU,KAAK,GAAGE,EAAQ,QAAQC,EAAgB,wBAAyB,YAAYH,EAAQ,KAAK,4EAA6EA,EAAQ,QAAQ,EAElQ,IAAMI,EAAuC,CAAC,EACxC,QAAW,GAAiC,CAC9CA,EAAW,KAAK,GAAGC,EAAQ,UAAY,CAAC,EAAG,GAAGA,EAAQ,OAAO,QAAQ,GAASC,EAAM,UAAY,CAAC,CAAC,CAAC,EACnGD,EAAQ,SAAS,QAAQ,OAAO,CACpC,EACA,IAAK,IAAME,KAAUN,EAAY,QAC7BG,EAAW,KAAK,GAAGG,EAAO,UAAY,CAAC,CAAC,EACxCA,EAAO,SAAS,QAAQ,OAAO,EAEnC,IAAK,IAAMC,KAAaJ,EACfL,EAAM,IAAIS,EAAU,IAAI,GAAGN,EAAQ,QAAQC,EAAgB,eAAgB,oBAAoBK,EAAU,KAAK,+BAA+BA,EAAU,KAAK,GAAIA,EAAU,QAAQ,CAE/L"}
|
|
1
|
+
{"version":3,"file":"PurposeValidator.js","names":["known","purpose","application","context","DiagnosticCodes","references","feature","slice","module","reference"],"sources":["../../../../../../Compiler/Parsing/PurposeValidator.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 { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\n\nexport function validatePurposes(application: ApplicationSyntax, context: ParserContext): void {\n const known = new Set<string>();\n for (const purpose of application.purposes ?? []) {\n if (known.has(purpose.name)) context.error(DiagnosticCodes.DuplicatePurposeDeclaration, `Duplicate purpose '${purpose.name}' - a purpose is declared once`, purpose.location);\n known.add(purpose.name);\n }\n for (const purpose of application.purposes ?? []) {\n if (purpose.interest !== null && purpose.basis !== 'legitimateInterests') context.warning(DiagnosticCodes.PurposeInterestMismatch, `Purpose '${purpose.name}' declares an interest without basis legitimateInterests`, purpose.location);\n else if (purpose.basis === 'legitimateInterests' && !purpose.interest?.trim()) context.warning(DiagnosticCodes.PurposeInterestMismatch, `Purpose '${purpose.name}' with basis legitimateInterests has no interest statement (Art. 13(1)(d))`, purpose.location);\n }\n const references: PurposeReferenceSyntax[] = [];\n const collect = (feature: FeatureSyntax): void => {\n references.push(...feature.purposes ?? [], ...feature.slices.flatMap(slice => slice.purposes ?? []));\n feature.features.forEach(collect);\n };\n for (const module of application.modules) {\n references.push(...module.purposes ?? []);\n module.features.forEach(collect);\n }\n for (const reference of references) {\n if (!known.has(reference.name)) context.warning(DiagnosticCodes.UnknownPurpose, `Unknown purpose '${reference.name}' - declare it with 'purpose ${reference.name}'`, reference.location);\n }\n}\n"],"mappings":"A,yHAQA,SAAgB,iBAAiB,EAAgC,EAA8B,CAC3F,IAAMA,kBAAQ,IAAI,IAClB,IAAK,IAAMC,KAAWC,EAAY,UAAY,CAAC,EACvCF,EAAM,IAAIC,EAAQ,IAAI,GAAGE,EAAQ,MAAMC,EAAgB,4BAA6B,sBAAsBH,EAAQ,KAAK,gCAAiCA,EAAQ,QAAQ,EAC5KD,EAAM,IAAIC,EAAQ,IAAI,EAE1B,IAAK,IAAMA,KAAWC,EAAY,UAAY,CAAC,EACvCD,EAAQ,WAAa,MAAQA,EAAQ,QAAU,sBAAuBE,EAAQ,QAAQC,EAAgB,wBAAyB,YAAYH,EAAQ,KAAK,0DAA2DA,EAAQ,QAAQ,EAC9NA,EAAQ,QAAU,uBAAyB,CAACA,EAAQ,UAAU,KAAK,GAAGE,EAAQ,QAAQC,EAAgB,wBAAyB,YAAYH,EAAQ,KAAK,4EAA6EA,EAAQ,QAAQ,EAElQ,IAAMI,EAAuC,CAAC,EACxC,QAAW,GAAiC,CAC9CA,EAAW,KAAK,GAAGC,EAAQ,UAAY,CAAC,EAAG,GAAGA,EAAQ,OAAO,QAAQ,GAASC,EAAM,UAAY,CAAC,CAAC,CAAC,EACnGD,EAAQ,SAAS,QAAQ,OAAO,CACpC,EACA,IAAK,IAAME,KAAUN,EAAY,QAC7BG,EAAW,KAAK,GAAGG,EAAO,UAAY,CAAC,CAAC,EACxCA,EAAO,SAAS,QAAQ,OAAO,EAEnC,IAAK,IAAMC,KAAaJ,EACfL,EAAM,IAAIS,EAAU,IAAI,GAAGN,EAAQ,QAAQC,EAAgB,eAAgB,oBAAoBK,EAAU,KAAK,+BAA+BA,EAAU,KAAK,GAAIA,EAAU,QAAQ,CAE/L,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{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{combineAuthorize as n,parseAuthorize as r}from"./AuthorizeParser.js";import{parseDescription as i}from"./DescriptionParser.js";import{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s,reportLegacyOptionalSuffix as c}from"./PropertyLineParser.js";import{locationOf as l}from"./SourceLine.js";const u=t(`^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`),d=t(`^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$`),f=t(`^scoped\\s+to\\s+([a-z_]\\w*)$`),p=/* @__PURE__ */ new Set([`performer`]);function parseQuery(t,a){let d=u.exec(a.content);if(d===null)return t.error(e.InvalidQueryDeclaration,`Invalid query declaration '${a.content}' - expected 'query <Name> => [observable] <ReadModel>'`,l(a)),t.skipBlock(a.indent),{kind:`QuerySyntax`,name:o(a.content),returnType:s(``,l(a)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:l(a)};let f=d[1],m=s(d[3],{...l(a),column:a.indent+1+d[0].length-d[3].length});(d[2]!==void 0||m.name!==`observable`||!m.isOptional||m.isCollection)&&c(t,m,a);let h=null,g=[],_=!1,v=[],y=null,b=null,x=null,S=!1;for(let s=t.peekChild(a.indent);s!==void 0;s=t.peekChild(a.indent)){t.reader.takeSignificant();let a=o(s.content);if(a===`description`)y=i(t,s,y,`Query '${f}'`);else if(a===`by`){if(s.content===`by`){_&&t.error(e.InvalidReadModelKeyLookup,`A query cannot combine a by block with another by declaration.`,l(s)),h=null,g.length=0;for(let e=t.peekChild(s.indent);e!==void 0;e=t.peekChild(s.indent)){t.reader.takeSignificant();let n=parseParameter(t,e,``);n!==void 0&&g.push(n)}(g.length<2||new Set(g.map(e=>e.name)).size!==g.length)&&t.error(e.InvalidReadModelKeyLookup,`A query by block requires at least two distinct named key parts.`,l(s)),_=!0}else{let n=parseParameter(t,s,`by`);n!==void 0&&(_&&t.error(e.InvalidQueryParameter,`Query '${f}' already declares 'by' - a query can have at most one key parameter`,l(s)),g.length>0&&t.error(e.InvalidReadModelKeyLookup,`A query cannot combine a by block with a single by line.`,l(s)),g.length=0,h=n,_=!0)}}else if(a===`filter`){let e=parseParameter(t,s,`filter`);e!==void 0&&v.push(e)}else if(a===`authorize`){let e=r(t,s);if(!S){let r=x;x=n(x,e,t),S=r!==null&&x===null}}else a===`scoped`?b=parseScope(t,s,b,f)??b:p.has(a)?t.skipOpaqueBlock(s.indent):(t.error(e.UnknownQueryDirective,`Unexpected '${s.content}' in query body - expected description, by, filter, authorize, scoped or performer`,l(s)),t.skipBlock(s.indent))}return{kind:`QuerySyntax`,name:f,returnType:m,by:h,...g.length>0?{byParts:g}:{},filters:v,description:y,isObservable:d[2]!==void 0,scope:b,authorize:x,location:l(a)}}function parseParameter(t,n,r){let i=d.exec(n.content.substring(r.length).trim());if(i===null){t.error(e.InvalidQueryParameter,`Invalid '${r}' parameter '${n.content}' - expected '${r} <name> <Type> [from <source>]'`,l(n));return}let o=n.content.indexOf(i[1],r.length),u=s(i[2],{...l(n),column:n.indent+1+n.content.indexOf(i[2],o+i[1].length)});return c(t,u,n),{kind:`QueryParameterSyntax`,name:i[1],type:u,source:i[3]===void 0?null:a(i[3],l(n),t.valueContext),location:l(n)}}function parseScope(t,n,r,i){let a=f.exec(n.content);if(a===null)t.error(e.InvalidScopeDeclaration,`Invalid scope declaration '${n.content}' - expected 'scoped to <scope>'`,l(n));else if(r!==null)t.error(e.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,l(n));else return a[1]}export{parseQuery};
|
|
2
2
|
//# sourceMappingURL=QueryParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryParser.js","names":["header","pattern","parameterPattern","scopePattern","opaqueDirectives","match","line","context","DiagnosticCodes","locationOf","firstWord","parseTypeRef","name","returnType","reportLegacyOptionalSuffix","by","byParts","hasBy","filters","description","scope","authorize","child","keyword","parseDescription","part","parsed","parameter","filter","combineAuthorize","parseAuthorize","nameOffset","type","parseMappingSource","existing","queryName"],"sources":["../../../../../../Compiler/Parsing/QueryParser.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 { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { QueryParameterSyntax, QuerySyntax } from '../Syntax/Queries';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseTypeRef, reportLegacyOptionalSuffix } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^query\\\\s+([A-Za-z_]\\\\w*)\\\\s*=>\\\\s*(observable\\\\s+)?([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\nconst parameterPattern = pattern('^([a-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)(?:\\\\s+from\\\\s+(.+))?$');\nconst scopePattern = pattern('^scoped\\\\s+to\\\\s+([a-z_]\\\\w*)$');\n\n// Query directives this compiler does not model. They are skipped whole.\nconst opaqueDirectives = new Set(['performer']);\n\nexport function parseQuery(context: ParserContext, line: SourceLine): QuerySyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidQueryDeclaration, `Invalid query declaration '${line.content}' - expected 'query <Name> => [observable] <ReadModel>'`, locationOf(line));\n context.skipBlock(line.indent);\n return {\n kind: 'QuerySyntax', name: firstWord(line.content), returnType: parseTypeRef('', locationOf(line)), by: null, filters: [],\n description: null, isObservable: false, scope: null, authorize: null, location: locationOf(line),\n };\n }\n const name = match[1];\n const returnType = parseTypeRef(match[3], { ...locationOf(line), column: line.indent + 1 + match[0].length - match[3].length });\n // This one '?' has no equivalent keyword spelling: 'observable optional' is a live query\n // returning the type named 'optional'. It is neither deprecated nor a migration occurrence.\n if (!(match[2] === undefined && returnType.name === 'observable' && returnType.isOptional && !returnType.isCollection)) {\n reportLegacyOptionalSuffix(context, returnType, line);\n }\n let by: QueryParameterSyntax | null = null;\n const byParts: QueryParameterSyntax[] = [];\n let hasBy = false;\n const filters: QueryParameterSyntax[] = [];\n let description: string | null = null;\n let scope: string | null = null;\n let authorize: AuthorizeSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Query '${name}'`);\n } else if (keyword === 'by') {\n if (child.content === 'by') {\n if (hasBy) context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A query cannot combine a by block with another by declaration.', locationOf(child));\n by = null;\n byParts.length = 0;\n for (let part = context.peekChild(child.indent); part !== undefined; part = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const parsed = parseParameter(context, part, '');\n if (parsed !== undefined) byParts.push(parsed);\n }\n if (byParts.length < 2 || new Set(byParts.map(part => part.name)).size !== byParts.length) {\n context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A query by block requires at least two distinct named key parts.', locationOf(child));\n }\n hasBy = true;\n } else {\n const parameter = parseParameter(context, child, 'by');\n if (parameter !== undefined) {\n if (hasBy) context.error(DiagnosticCodes.InvalidQueryParameter, `Query '${name}' already declares 'by' - a query can have at most one key parameter`, locationOf(child));\n if (byParts.length > 0) context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A query cannot combine a by block with a single by line.', locationOf(child));\n byParts.length = 0;\n by = parameter;\n hasBy = true;\n }\n }\n } else if (keyword === 'filter') {\n const filter = parseParameter(context, child, 'filter');\n if (filter !== undefined) {\n filters.push(filter);\n }\n } else if (keyword === 'authorize') {\n authorize = combineAuthorize(authorize, parseAuthorize(context, child));\n } else if (keyword === 'scoped') {\n scope = parseScope(context, child, scope, name) ?? scope;\n } else if (opaqueDirectives.has(keyword)) {\n context.skipOpaqueBlock(child.indent);\n } else {\n context.error(DiagnosticCodes.UnknownQueryDirective, `Unexpected '${child.content}' in query body - expected description, by, filter, authorize, scoped or performer`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return {\n kind: 'QuerySyntax',\n name,\n returnType,\n by,\n ...(byParts.length > 0 ? { byParts } : {}),\n filters,\n description,\n isObservable: match[2] !== undefined,\n scope,\n authorize,\n location: locationOf(line),\n };\n}\n\nfunction parseParameter(context: ParserContext, line: SourceLine, keyword: string): QueryParameterSyntax | undefined {\n const match = parameterPattern.exec(line.content.substring(keyword.length).trim());\n if (match === null) {\n context.error(DiagnosticCodes.InvalidQueryParameter, `Invalid '${keyword}' parameter '${line.content}' - expected '${keyword} <name> <Type> [from <source>]'`, locationOf(line));\n return undefined;\n }\n const nameOffset = line.content.indexOf(match[1], keyword.length);\n const type = parseTypeRef(match[2], { ...locationOf(line), column: line.indent + 1 + line.content.indexOf(match[2], nameOffset + match[1].length) });\n reportLegacyOptionalSuffix(context, type, line);\n return { kind: 'QueryParameterSyntax', name: match[1], type, source: match[3] === undefined ? null : parseMappingSource(match[3], locationOf(line), context.valueContext), location: locationOf(line) };\n}\n\nfunction parseScope(context: ParserContext, line: SourceLine, existing: string | null, queryName: string): string | undefined {\n const match = scopePattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidScopeDeclaration, `Invalid scope declaration '${line.content}' - expected 'scoped to <scope>'`, locationOf(line));\n return undefined;\n }\n if (existing !== null) {\n context.error(DiagnosticCodes.DuplicateScope, `Query '${queryName}' already declares a scope - results are narrowed one way`, locationOf(line));\n return undefined;\n }\n return match[1];\n}\n"],"mappings":"shBAeA,MAAMA,EAASC,EAAQ,gGAAgG,EACjHC,EAAmBD,EAAQ,kFAAkF,EAC7GE,EAAeF,EAAQ,gCAAgC,EAGvDG,kBAAmB,IAAI,IAAI,CAAC,WAAW,CAAC,EAE9C,SAAgB,WAAW,EAAwB,EAA+B,CAC9E,IAAMC,EAAQL,EAAO,KAAKM,EAAK,OAAO,EACtC,GAAID,IAAU,KAGV,OAFAE,EAAQ,MAAMC,EAAgB,wBAAyB,8BAA8BF,EAAK,QAAQ,yDAA0DG,EAAWH,CAAI,CAAC,EAC5KC,EAAQ,UAAUD,EAAK,MAAM,EACtB,CACH,KAAM,cAAe,KAAMI,EAAUJ,EAAK,OAAO,EAAG,WAAYK,EAAa,GAAIF,EAAWH,CAAI,CAAC,EAAG,GAAI,KAAM,QAAS,CAAC,EACxH,YAAa,KAAM,aAAc,GAAO,MAAO,KAAM,UAAW,KAAM,SAAUG,EAAWH,CAAI,CACnG,EAEJ,IAAMM,EAAOP,EAAM,GACbQ,EAAaF,EAAaN,EAAM,GAAI,CAAE,GAAGI,EAAWH,CAAI,EAAG,OAAQA,EAAK,OAAS,EAAID,EAAM,EAAE,CAAC,OAASA,EAAM,EAAE,CAAC,MAAO,CAAC,GAGxHA,EAAM,KAAO,IAAA,IAAaQ,EAAW,OAAS,cAAgB,GAAW,YAAeA,EAAW,eACrGC,EAA2BP,EAASM,EAAYP,CAAI,EAExD,IAAIS,EAAkC,KAChCC,EAAkC,CAAC,EACrCC,EAAQ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ACvC,CAAE,KAAM,uBAAwB,KAAMD,EAAM,GAAI,OAAM,OAAQA,EAAM,KAAO,IAAA,GAAY,KAAO4B,EAAmB5B,EAAM,GAAII,EAAWH,CAAI,EAAGC,EAAQ,YAAY,EAAG,SAAUE,EAAWH,CAAI,CAAE,CAC1M,CAEA,SAAS,WAAW,EAAwB,EAAkB,EAAyB,EAAuC,CAC1H,IAAMD,EAAQF,EAAa,KAAKG,EAAK,OAAO,EAC5C,GAAID,IAAU,KACVE,EAAQ,MAAMC,EAAgB,wBAAyB,8BAA8BF,EAAK,QAAQ,kCAAmCG,EAAWH,CAAI,CAAC,OAGzJ,GAAI4B,IAAa,KACb3B,EAAQ,MAAMC,EAAgB,eAAgB,UAAU2B,EAAU,2DAA4D1B,EAAWH,CAAI,CAAC,OAGlJ,OAAOD,EAAM,EACjB"}
|
|
1
|
+
{"version":3,"file":"QueryParser.js","names":["header","pattern","parameterPattern","scopePattern","opaqueDirectives","match","line","context","DiagnosticCodes","locationOf","firstWord","parseTypeRef","name","returnType","reportLegacyOptionalSuffix","by","byParts","hasBy","filters","description","scope","authorize","authorizationDepthExceeded","child","keyword","parseDescription","part","parsed","parameter","filter","next","parseAuthorize","previous","combineAuthorize","nameOffset","type","parseMappingSource","existing","queryName"],"sources":["../../../../../../Compiler/Parsing/QueryParser.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 { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { QueryParameterSyntax, QuerySyntax } from '../Syntax/Queries';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseTypeRef, reportLegacyOptionalSuffix } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst header = pattern('^query\\\\s+([A-Za-z_]\\\\w*)\\\\s*=>\\\\s*(observable\\\\s+)?([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\nconst parameterPattern = pattern('^([a-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)(?:\\\\s+from\\\\s+(.+))?$');\nconst scopePattern = pattern('^scoped\\\\s+to\\\\s+([a-z_]\\\\w*)$');\n\n// Query directives this compiler does not model. They are skipped whole.\nconst opaqueDirectives = new Set(['performer']);\n\nexport function parseQuery(context: ParserContext, line: SourceLine): QuerySyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidQueryDeclaration, `Invalid query declaration '${line.content}' - expected 'query <Name> => [observable] <ReadModel>'`, locationOf(line));\n context.skipBlock(line.indent);\n return {\n kind: 'QuerySyntax', name: firstWord(line.content), returnType: parseTypeRef('', locationOf(line)), by: null, filters: [],\n description: null, isObservable: false, scope: null, authorize: null, location: locationOf(line),\n };\n }\n const name = match[1];\n const returnType = parseTypeRef(match[3], { ...locationOf(line), column: line.indent + 1 + match[0].length - match[3].length });\n // This one '?' has no equivalent keyword spelling: 'observable optional' is a live query\n // returning the type named 'optional'. It is neither deprecated nor a migration occurrence.\n if (!(match[2] === undefined && returnType.name === 'observable' && returnType.isOptional && !returnType.isCollection)) {\n reportLegacyOptionalSuffix(context, returnType, line);\n }\n let by: QueryParameterSyntax | null = null;\n const byParts: QueryParameterSyntax[] = [];\n let hasBy = false;\n const filters: QueryParameterSyntax[] = [];\n let description: string | null = null;\n let scope: string | null = null;\n let authorize: AuthorizeSyntax | null = null;\n let authorizationDepthExceeded = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const keyword = firstWord(child.content);\n if (keyword === 'description') {\n description = parseDescription(context, child, description, `Query '${name}'`);\n } else if (keyword === 'by') {\n if (child.content === 'by') {\n if (hasBy) context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A query cannot combine a by block with another by declaration.', locationOf(child));\n by = null;\n byParts.length = 0;\n for (let part = context.peekChild(child.indent); part !== undefined; part = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n const parsed = parseParameter(context, part, '');\n if (parsed !== undefined) byParts.push(parsed);\n }\n if (byParts.length < 2 || new Set(byParts.map(part => part.name)).size !== byParts.length) {\n context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A query by block requires at least two distinct named key parts.', locationOf(child));\n }\n hasBy = true;\n } else {\n const parameter = parseParameter(context, child, 'by');\n if (parameter !== undefined) {\n if (hasBy) context.error(DiagnosticCodes.InvalidQueryParameter, `Query '${name}' already declares 'by' - a query can have at most one key parameter`, locationOf(child));\n if (byParts.length > 0) context.error(DiagnosticCodes.InvalidReadModelKeyLookup, 'A query cannot combine a by block with a single by line.', locationOf(child));\n byParts.length = 0;\n by = parameter;\n hasBy = true;\n }\n }\n } else if (keyword === 'filter') {\n const filter = parseParameter(context, child, 'filter');\n if (filter !== undefined) {\n filters.push(filter);\n }\n } else if (keyword === 'authorize') {\n const next = parseAuthorize(context, child);\n if (!authorizationDepthExceeded) {\n const previous = authorize;\n authorize = combineAuthorize(authorize, next, context);\n authorizationDepthExceeded = previous !== null && authorize === null;\n }\n } else if (keyword === 'scoped') {\n scope = parseScope(context, child, scope, name) ?? scope;\n } else if (opaqueDirectives.has(keyword)) {\n context.skipOpaqueBlock(child.indent);\n } else {\n context.error(DiagnosticCodes.UnknownQueryDirective, `Unexpected '${child.content}' in query body - expected description, by, filter, authorize, scoped or performer`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return {\n kind: 'QuerySyntax',\n name,\n returnType,\n by,\n ...(byParts.length > 0 ? { byParts } : {}),\n filters,\n description,\n isObservable: match[2] !== undefined,\n scope,\n authorize,\n location: locationOf(line),\n };\n}\n\nfunction parseParameter(context: ParserContext, line: SourceLine, keyword: string): QueryParameterSyntax | undefined {\n const match = parameterPattern.exec(line.content.substring(keyword.length).trim());\n if (match === null) {\n context.error(DiagnosticCodes.InvalidQueryParameter, `Invalid '${keyword}' parameter '${line.content}' - expected '${keyword} <name> <Type> [from <source>]'`, locationOf(line));\n return undefined;\n }\n const nameOffset = line.content.indexOf(match[1], keyword.length);\n const type = parseTypeRef(match[2], { ...locationOf(line), column: line.indent + 1 + line.content.indexOf(match[2], nameOffset + match[1].length) });\n reportLegacyOptionalSuffix(context, type, line);\n return { kind: 'QueryParameterSyntax', name: match[1], type, source: match[3] === undefined ? null : parseMappingSource(match[3], locationOf(line), context.valueContext), location: locationOf(line) };\n}\n\nfunction parseScope(context: ParserContext, line: SourceLine, existing: string | null, queryName: string): string | undefined {\n const match = scopePattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidScopeDeclaration, `Invalid scope declaration '${line.content}' - expected 'scoped to <scope>'`, locationOf(line));\n return undefined;\n }\n if (existing !== null) {\n context.error(DiagnosticCodes.DuplicateScope, `Query '${queryName}' already declares a scope - results are narrowed one way`, locationOf(line));\n return undefined;\n }\n return match[1];\n}\n"],"mappings":"A,shBAeA,MAAMA,EAASC,EAAQ,gGAAgG,EACjHC,EAAmBD,EAAQ,kFAAkF,EAC7GE,EAAeF,EAAQ,gCAAgC,EAGvDG,kBAAmB,IAAI,IAAI,CAAC,WAAW,CAAC,EAE9C,SAAgB,WAAW,EAAwB,EAA+B,CAC9E,IAAMC,EAAQL,EAAO,KAAKM,EAAK,OAAO,EACtC,GAAID,IAAU,KAGV,OAFAE,EAAQ,MAAMC,EAAgB,wBAAyB,8BAA8BF,EAAK,QAAQ,yDAA0DG,EAAWH,CAAI,CAAC,EAC5KC,EAAQ,UAAUD,EAAK,MAAM,EACtB,CACH,KAAM,cAAe,KAAMI,EAAUJ,EAAK,OAAO,EAAG,WAAYK,EAAa,GAAIF,EAAWH,CAAI,CAAC,EAAG,GAAI,KAAM,QAAS,CAAC,EACxH,YAAa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virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{locationOf as i}from"./SourceLine.js";const a=RegExp(`^runs${t}+as${t}+system(?:${t}+role${t}+"${n}"(?:${t}+and${t}+role${t}+"${n}")*)?$`,`u`),o=RegExp(`"(${n})"`,`gu`),s=RegExp(`^runs${t}+as\\b`,`u`),isReactionIdentityLine=e=>s.test(e.content);function parseReactionIdentity(t,n,s){if(s)return t.error(e.InvalidReactionIdentity,`A reaction may declare 'runs as' only once.`,i(n)),t.skipBlock(n.indent),null;if(!a.test(n.content)||t.peekChild(n.indent)!==void 0)return t.error(e.InvalidReactionIdentity,`Expected one reaction-level line: 'runs as system [role "<Role>" and role "<Role>"]'.`,i(n)),t.skipBlock(n.indent),null;let c=[...n.content.matchAll(o)].map(e=>r(e[1]));return c.some(e=>e.length===0)||new Set(c).size!==c.length?(t.error(e.InvalidReactionIdentity,`Reaction identity roles must be nonempty and distinct quoted literals.`,i(n)),null):{kind:`ReactionIdentitySyntax`,syntaxKind:`system`,roles:c,location:i(n)}}function misplacedReactionIdentity(t,n){t.error(e.InvalidReactionIdentity,`'runs as' belongs directly in a reaction body, not under a trigger or invocation.`,i(n)),t.skipBlock(n.indent)}export{isReactionIdentityLine,misplacedReactionIdentity,parseReactionIdentity};
|
|
2
2
|
//# sourceMappingURL=ReactionIdentityParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactionIdentityParser.js","names":["identityPattern","dotNetWhitespace","stringBodyPattern","rolePattern","identityPrefix","line","repeated","context","DiagnosticCodes","locationOf","roles","unescapeString","match","role"],"sources":["../../../../../../Compiler/Parsing/ReactionIdentityParser.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 { ReactionIdentitySyntax } from '../Syntax/ReactionIdentitySyntax';\nimport { dotNetWhitespace } from '../Text/patterns';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst identityPattern = new RegExp(`^runs${dotNetWhitespace}+as${dotNetWhitespace}+system(?:${dotNetWhitespace}+role${dotNetWhitespace}+\"${stringBodyPattern}\"(?:${dotNetWhitespace}+and${dotNetWhitespace}+role${dotNetWhitespace}+\"${stringBodyPattern}\")*)?$`, 'u');\nconst rolePattern = new RegExp(`\"(${stringBodyPattern})\"`, 'gu');\n\nconst identityPrefix = new RegExp(`^runs${dotNetWhitespace}+as\\\\b`, 'u');\nexport const isReactionIdentityLine = (line: SourceLine): boolean => identityPrefix.test(line.content);\n\nexport function parseReactionIdentity(context: ParserContext, line: SourceLine, repeated: boolean): ReactionIdentitySyntax | null {\n if (repeated) {\n context.error(DiagnosticCodes.InvalidReactionIdentity, \"A reaction may declare 'runs as' only once.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n if (!identityPattern.test(line.content) || context.peekChild(line.indent) !== undefined) {\n context.error(DiagnosticCodes.InvalidReactionIdentity, 'Expected one reaction-level line: \\'runs as system [role \"<Role>\" and role \"<Role>\"]\\'.', locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const roles = [...line.content.matchAll(rolePattern)].map(match => unescapeString(match[1]));\n if (roles.some(role => role.length === 0) || new Set(roles).size !== roles.length) {\n context.error(DiagnosticCodes.InvalidReactionIdentity, 'Reaction identity roles must be nonempty and distinct quoted literals.', locationOf(line));\n return null;\n }\n return { kind: 'ReactionIdentitySyntax', syntaxKind: 'system', roles, location: locationOf(line) };\n}\n\nexport function misplacedReactionIdentity(context: ParserContext, line: SourceLine): void {\n context.error(DiagnosticCodes.InvalidReactionIdentity, \"'runs as' belongs directly in a reaction body, not under a trigger or invocation.\", locationOf(line));\n context.skipBl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|
|
1
|
+
{"version":3,"file":"ReactionIdentityParser.js","names":["identityPattern","dotNetWhitespace","stringBodyPattern","rolePattern","identityPrefix","line","repeated","context","DiagnosticCodes","locationOf","roles","unescapeString","match","role"],"sources":["../../../../../../Compiler/Parsing/ReactionIdentityParser.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 { ReactionIdentitySyntax } from '../Syntax/ReactionIdentitySyntax';\nimport { dotNetWhitespace } from '../Text/patterns';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst identityPattern = new RegExp(`^runs${dotNetWhitespace}+as${dotNetWhitespace}+system(?:${dotNetWhitespace}+role${dotNetWhitespace}+\"${stringBodyPattern}\"(?:${dotNetWhitespace}+and${dotNetWhitespace}+role${dotNetWhitespace}+\"${stringBodyPattern}\")*)?$`, 'u');\nconst rolePattern = new RegExp(`\"(${stringBodyPattern})\"`, 'gu');\n\nconst identityPrefix = new RegExp(`^runs${dotNetWhitespace}+as\\\\b`, 'u');\nexport const isReactionIdentityLine = (line: SourceLine): boolean => identityPrefix.test(line.content);\n\nexport function parseReactionIdentity(context: ParserContext, line: SourceLine, repeated: boolean): ReactionIdentitySyntax | null {\n if (repeated) {\n context.error(DiagnosticCodes.InvalidReactionIdentity, \"A reaction may declare 'runs as' only once.\", locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n if (!identityPattern.test(line.content) || context.peekChild(line.indent) !== undefined) {\n context.error(DiagnosticCodes.InvalidReactionIdentity, 'Expected one reaction-level line: \\'runs as system [role \"<Role>\" and role \"<Role>\"]\\'.', locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const roles = [...line.content.matchAll(rolePattern)].map(match => unescapeString(match[1]));\n if (roles.some(role => role.length === 0) || new Set(roles).size !== roles.length) {\n context.error(DiagnosticCodes.InvalidReactionIdentity, 'Reaction identity roles must be nonempty and distinct quoted literals.', locationOf(line));\n return null;\n }\n return { kind: 'ReactionIdentitySyntax', syntaxKind: 'system', roles, location: locationOf(line) };\n}\n\nexport function misplacedReactionIdentity(context: ParserContext, line: SourceLine): void {\n context.error(DiagnosticCodes.InvalidReactionIdentity, \"'runs as' belongs directly in a reaction body, not under a trigger or invocation.\", locationOf(line));\n context.skipBlock(line.indent);\n}\n"],"mappings":"A,8SAUA,MAAMA,EAAsB,OAAO,QAAQC,EAAiB,KAAKA,EAAiB,YAAYA,EAAiB,OAAOA,EAAiB,IAAIC,EAAkB,MAAMD,EAAiB,MAAMA,EAAiB,OAAOA,EAAiB,IAAIC,EAAkB,QAAS,GAAG,EAC/PC,EAAkB,OAAO,KAAKD,EAAkB,IAAK,IAAI,EAEzDE,EAAqB,OAAO,QAAQH,EAAiB,QAAS,GAAG,EAC1D,uBAA0B,GAA8BG,EAAe,KAAKC,EAAK,OAAO,EAErG,SAAgB,sBAAsB,EAAwB,EAAkB,EAAkD,CAC9H,GAAIC,EAGA,OAFAC,EAAQ,MAAMC,EAAgB,wBAAyB,8CAA+CC,EAAWJ,CAAI,CAAC,EACtHE,EAAQ,UAAUF,EAAK,MAAM,EACtB,KAEX,GAAI,CAACL,EAAgB,KAAKK,EAAK,OAAO,GAAKE,EAAQ,UAAUF,EAAK,MAAM,IAAM,IAAA,GAG1E,OAFAE,EAAQ,MAAMC,EAAgB,wBAAyB,wFAA2FC,EAAWJ,CAAI,CAAC,EAClKE,EAAQ,UAAUF,EAAK,MAAM,EACtB,KAEX,IAAMK,EAAQ,CAAC,GAAGL,EAAK,QAAQ,SAASF,CAAW,CAAC,CAAC,CAAC,IAAI,GAASQ,EAAeC,EAAM,EAAE,CAAC,EAK3F,OAJIF,EAAM,KAAK,GAAQG,EAAK,SAAW,CAAC,GAAK,IAAI,IAAIH,CAAK,CAAC,CAAC,OAASA,EAAM,QACvEH,EAAQ,MAAMC,EAAgB,wBAAyB,yEAA0EC,EAAWJ,CAAI,CAAC,EAC1I,MAEJ,CAAE,KAAM,yBAA0B,WAAY,SAAU,QAAO,SAAUI,EAAWJ,CAAI,CAAE,CACrG,CAEA,SAAgB,0BAA0B,EAAwB,EAAwB,CACtFE,EAAQ,MAAMC,EAAgB,wBAAyB,oFAAqFC,EAAWJ,CAAI,CAAC,EAC5JE,EAAQ,UAAUF,EAAK,MAAM,CACjC,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{diagnosticText as e}from"../Diagnostics/DiagnosticArgument.js";import{DiagnosticCodes as t}from"../Diagnostics/DiagnosticCodes.js";import{parseCondition as n}from"./ConditionParser.js";import{parseObserverFilter as r}from"./ObserverFilterParser.js";import{parseModeledMappingSource as i}from"./ExpressionParser.js";import{nativePattern as a,pattern as o}from"../Text/patterns.js";import{isReactionIdentityLine as s,misplacedReactionIdentity as c,parseReactionIdentity as l}from"./ReactionIdentityParser.js";import{parseDescription as u}from"./DescriptionParser.js";import{parseDocumentation as d}from"./DocumentationParser.js";import{collectInputUses as f}from"./InputUses.js";import{firstWord as p}from"./LineText.js";import{ParserContext as m}from"./ParserContext.js";import{parseTriggerData as h}from"./TriggerDataParser.js";import{dependencySources as g}from"../Syntax/DependencySources.js";import{parseReads as _}from"./ReadsParser.js";import{parseProduces as v}from"./ProducesParser.js";import{locationOf as y}from"./SourceLine.js";import{tryParseStructuredMapping as b}from"./StructuredBlockParser.js";const x=o(`^reaction\\s+([A-Za-z_]\\w*)$`),S=o(`^when\\s+([A-Za-z_]\\w*)$`),C=o(`^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$`),w=o(`^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$`),T=/* @__PURE__ */ new Set([`when`,`every`,`at`]),E=o(`^invokes\\s+([A-Z]\\w*)$`),D=a(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),O=a(`^on\\s+refused\\b(?=$|\\s+by\\b)`),k=a(`^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$`),A=o(`^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)`);function parseReaction(e,i){let a=x.exec(i.content)?.[1]??``;a===``&&e.error(t.InvalidReactionDeclaration,`Invalid reaction declaration '${i.content}' - expected 'reaction <Name>'`,y(i));let o=null,s=null,c=null,f=null,m=null,h=!1,g=[],_=/* @__PURE__ */ new Set,v=!1;for(let b=e.peekChild(i.indent);b!==void 0;b=e.peekChild(i.indent)){e.reader.takeSignificant();let i=p(b.content);if(i===`description`){o=u(e,b,o,`Reaction '${a}'`);continue}if(i===`documentation`){s=d(e,b,s,`Reaction '${a}'`);continue}if(i===`from`){f=r(e,b,f);continue}if(i===`runs`){m=l(e,b,h)??m,h=!0;continue}if(i===`where`){c=n(e,b.content.substring(5).trim(),y(b));continue}if(O.test(b.content)){e.error(t.InvalidRefusalBranch,`A refusal branch belongs inside 'invokes <Command>'.`,y(b)),e.skipBlock(b.indent),v=!0;continue}if(!T.has(i)){e.error(t.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${b.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,y(b)),e.skipBlock(b.indent),v=!0;continue}let x=parseTriggerSource(e,b);if(x===void 0){v=!0;continue}let S=sourceKey(x);_.has(S)?(e.error(t.DuplicateReactionTrigger,`Reaction '${a}' already declares '${b.content}' - a second says nothing the first did not`,y(b)),e.skipBlock(b.indent)):(_.add(S),g.push(parseTrigger(e,b,x)))}return g.length===0&&!v&&e.error(t.ReactionWithoutTrigger,`Reaction '${a}' must declare at least one trigger - nothing sets it off`,y(i)),{kind:`ReactionSyntax`,name:a,description:o,documentation:s,from:f,runsAs:m,where:c,triggers:g,location:y(i)}}function parseTrigger(n,r,a){let o=null,l=[],d=[],x=[],S=[],C=!1;for(let a=n.peekChild(r.indent);a!==void 0;a=n.peekChild(r.indent)){n.reader.takeSignificant();let r=p(a.content);if(r===`runs`&&s(a))c(n,a);else if(r===`description`)o=u(n,a,o,`Trigger '${a.content}'`);else if(r===`produces`){let e=v(n,a);e!==void 0&&l.push(e)}else if(r===`invokes`){let r=E.exec(a.content);if(r===null)n.error(t.InvalidInvokesDeclaration,`Invalid invokes declaration '${a.content}' - expected 'invokes <Command>'`,y(a)),n.skipBlock(a.indent);else{let o=new m(n.reader.fork(),n.path,n.languages);o.scope=n.scope,o.sourceOptions=n.sourceOptions,f(o,a),n.inputUses.push(...o.inputUses);let l=[],u=[];for(let r=n.peekChild(a.indent);r!==void 0;r=n.peekChild(a.indent)){if(n.reader.takeSignificant(),s(r)){c(n,r);continue}if(O.test(r.content)){let e=parseRefusal(n,r);e!==void 0&&u.push(e);continue}let a=D.exec(r.content),o=a===null?b(n.valueContext,r):void 0;a===null?o===void 0?n.error(t.InvalidPropertyMapping,`Invalid property mapping '${r.content}' - expected '<property> = <source>'`,y(r),e(`text`,r.content)):l.push(o):l.push({kind:`PropertyMappingSyntax`,property:a[1].replaceAll(`@`,``),source:i(a[2],y(r),n.valueContext),location:y(r)})}d.push({kind:`InvokesSyntax`,command:r[1],mappings:l,onRefused:u,location:y(a)})}}else if(O.test(a.content))n.error(t.InvalidRefusalBranch,`A refusal branch belongs inside 'invokes <Command>'.`,y(a)),n.skipBlock(a.indent);else if(r===`reads`||r===`file`||a.content===`csharp`||a.content.startsWith("```")){C||=r===`file`||a.content===`csharp`||a.content.startsWith("```");let e=r===`reads`?_(n,a):void 0;e!==void 0&&x.push(e),A.test(a.content)&&n.error(t.OptionalReadsNotSupported,`Optional reads are not yet supported (see #308).`,y(a)),a.content.startsWith("```")&&n.skipFencedBody(),n.skipOpaqueBlock(a.indent)}else{let e=n.triggerData.length;h(n,a);for(let t of n.triggerData.slice(e))S.push({kind:`TriggerDataSyntax`,name:t.name,type:t.type,location:t.location})}}let w={kind:`ReactionTriggerSyntax`,source:a,description:o,produces:l,invokes:d,location:y(r)};return g.set(w,{reads:x,data:S,implementation:C}),w}function parseRefusal(e,n){let r=k.exec(n.content);if(r===null||r[2]!==void 0&&r[1]!==`constraint`){e.error(t.InvalidRefusalBranch,`Expected 'on refused [by validation | by constraint [<Name>] | by authorization]'.`,y(n)),e.skipBlock(n.indent);return}let i=[],a=!1,o=!1;for(let r=e.peekChild(n.indent);r!==void 0;r=e.peekChild(n.indent))if(e.reader.takeSignificant(),s(r))c(e,r),o=!0;else if(r.content===`acknowledge`)(a||i.length>0||e.peekChild(r.indent)!==void 0)&&(e.error(t.InvalidRefusalBranchBody,`A refusal branch contains 'acknowledge' alone or one or more 'produces' blocks.`,y(r)),o=!0),a=!0,e.skipBlock(r.indent);else if(p(r.content)===`produces`){a&&(e.error(t.InvalidRefusalBranchBody,`A refusal branch cannot combine 'acknowledge' and 'produces'.`,y(r)),o=!0);let n=v(e,r);n===void 0?o=!0:i.push(n)}else e.error(t.InvalidRefusalBranchBody,`Expected 'acknowledge' or 'produces <Event>' in a refusal branch.`,y(r)),e.skipBlock(r.indent),o=!0;return!a&&i.length===0&&!o&&e.error(t.InvalidRefusalBranchBody,`A refusal branch must acknowledge or produce an event.`,y(n)),{kind:`InvocationRefusalSyntax`,selector:r[1]??`any`,constraint:r[2]??null,acknowledge:a,produces:i,location:y(n)}}function sourceKey(e){switch(e.kind){case`NamedTriggerSourceSyntax`:return JSON.stringify([e.kind,e.name]);case`IntervalTriggerSourceSyntax`:return JSON.stringify([e.kind,e.amount,e.unit]);case`ScheduleTriggerSourceSyntax`:return JSON.stringify([e.kind,e.time,e.dayOfWeek,e.dayOfMonth])}}function parseTriggerSource(e,n){let r=y(n);switch(p(n.content)){case`when`:{let i=S.exec(n.content);if(i===null){e.error(t.InvalidReactionTrigger,`Invalid trigger '${n.content}' - expected 'when <Name>'`,r),e.skipBlock(n.indent);return}return{kind:`NamedTriggerSourceSyntax`,name:i[1],location:r}}case`every`:{let i=C.exec(n.content),a=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(a)||a<1||a>2147483647){e.error(t.InvalidIntervalTrigger,`Invalid interval '${n.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,r),e.skipBlock(n.indent);return}return{kind:`IntervalTriggerSourceSyntax`,amount:a,unit:unitOf(i[2]),location:r}}default:return parseSchedule(e,n)}}function parseSchedule(e,n){let r=y(n),i=w.exec(n.content),a=i===null?void 0:timeOf(i[1]);if(i===null||a===void 0)e.error(t.InvalidScheduleTrigger,`Invalid schedule '${n.content}' - expected 'at <HH:mm>', optionally followed by 'on <Weekday>' or 'on day <n>'`,r),e.skipBlock(n.indent);else{if(i[3]!==void 0){let o=Number(i[3]);if(o<1||o>31){e.error(t.InvalidScheduleTrigger,`Invalid day of month '${o}' in '${n.content}' - a day of the month is between 1 and 31`,r),e.skipBlock(n.indent);return}return{kind:`ScheduleTriggerSourceSyntax`,time:a,dayOfWeek:null,dayOfMonth:o,location:r}}return{kind:`ScheduleTriggerSourceSyntax`,time:a,dayOfWeek:i[2]??null,dayOfMonth:null,location:r}}}function timeOf(e){let[t,n]=e.split(`:`).map(Number);if(t>=0&&t<=23&&n>=0&&n<=59)return`${e}:00.0000000`}function unitOf(e){switch(e.replace(/s+$/,``)){case`second`:return`Seconds`;case`minute`:return`Minutes`;case`hour`:return`Hours`;default:return`Days`}}export{parseReaction,parseTriggerSource};
|
|
2
2
|
//# sourceMappingURL=ReactionParser.js.map
|