@cratis/screenplay-language 5.2.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 +2 -0
- package/dist/bundles/compiler/Parsing/ApplicationContextParser.js.map +1 -0
- 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 +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 +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 +18 -17
- 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 +1 -1
- package/dist/bundles/keyword-docs.js.map +1 -1
- package/dist/bundles/language.js +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 +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 +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/completion-items.d.ts +1 -0
- package/dist/completion-items.d.ts.map +1 -1
- package/dist/completion-planner.d.ts.map +1 -1
- package/dist/diagnostic-codes.d.ts +6 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/dist/keyword-docs.d.ts.map +1 -1
- package/dist/language.d.ts.map +1 -1
- package/dist/scope-items.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -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{pattern as n}from"../Text/patterns.js";import{stringBodyPattern as r}from"../Text/StringLiteral.js";import{parseMappingSource as i}from"./ExpressionParser.js";import{containsCaseReference as a,parseSpecificationValue as o}from"./SpecificationCaseParser.js";import{locationOf as s}from"./SourceLine.js";import{parseStructuredValue as c,tryParseStructuredMapping as l}from"./StructuredBlockParser.js";const u=`value`,d=n(`^then\\s+returns\\b`),f=n(`^generated\\s+(?=\\S)(?![=])`),p=n(`^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`),m=n(`^generated\\s+([a-z_]\\w*)(?:\\s+(none|empty))?$`),h=n(`^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$`),g=n(`^(?:"${r}"|'(?:[^'\\\\]|\\\\.)*')$`);function parseConcrete(n,r,s,c){if(r.startsWith(`case.`))return o(r,s,n);a(r)&&n.error(t.InvalidSpecificationCaseReference,`A case reference fills a whole value position; it cannot occur inside a structured value or expression.`,s);let l=c===t.InvalidSpecificationValue||c===t.InvalidSpecificationCaseValue?e(`text`,r):{};if((r.startsWith(`"`)||r.startsWith(`'`))&&!g.test(r))return n.error(c,`Expected exactly one concrete value.`,s,l),null;let u=i(r,s,n);return![`LiteralExpressionSyntax`,`ObjectExpressionSyntax`,`ListExpressionSyntax`].includes(u.kind)||u.kind===`LiteralExpressionSyntax`&&typeof u.value==`number`&&!Number.isFinite(u.value)?(n.error(c,`Expected exactly one concrete literal or structured value, not an expression.`,s,l),null):u}function parseConcreteMapping(e,t,n,r){let i=n.exec(t.content),a=i===null?m.exec(t.content):null;if(a!==null)return{kind:`PropertyMappingSyntax`,property:a[1],source:c(e,t,a[2]),location:s(t)};let o=i===null?l(e,t):void 0;if(o!==void 0)return o;if(i===null)return e.error(r,`Expected a named fixture or assertion with exactly one concrete value.`,s(t)),e.skipBlock(t.indent),null;let u=s(t),d=parseConcrete(e,i[2],{...u,column:u.column+t.content.indexOf(i[2],t.content.indexOf(`=`)+1)},r),f=e.peekChild(t.indent);return f!==void 0&&(e.error(r,`A fixture or return field cannot have child directives.`,s(f)),e.skipBlock(t.indent)),d===null?null:{kind:`PropertyMappingSyntax`,property:i[1],source:d,location:u}}function parseReturn(e,n){let r=d.exec(n.content)[0].length,i=n.content.substring(r).trim(),a=s(n);if(i===`value`||i===`value none`||i===`value empty`)return{kind:`ScalarSpecificationReturnSyntax`,value:c(e,n,i.substring(6)||void 0),location:a};if(i.length>0){let o=parseConcrete(e,i,{...a,column:a.column+n.content.indexOf(i,r)},t.InvalidReturnExpectation),c=e.peekChild(n.indent);return c!==void 0&&(e.error(t.InvalidReturnExpectation,`A scalar return expectation cannot have child assertions.`,s(c)),e.skipBlock(n.indent)),o===null?null:{kind:`ScalarSpecificationReturnSyntax`,value:o,location:a}}let o=[];for(let r=e.peekChild(n.indent);r!==void 0;r=e.peekChild(n.indent)){e.reader.takeSignificant();let n=parseConcreteMapping(e,r,h,t.InvalidReturnExpectation);n!==null&&o.push(n)}return{kind:`RecordSpecificationReturnSyntax`,fields:o,location:a}}export{p as generatedFixturePattern,f as generatedFixturePrefix,parseConcrete,parseConcreteMapping,parseReturn,u as structuredReturnKeyword,d as thenReturnsPrefix};
|
|
2
2
|
//# sourceMappingURL=SpecificationResponseParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecificationResponseParser.js","names":["structuredReturnKeyword","thenReturnsPrefix","pattern","generatedFixturePrefix","generatedFixturePattern","generatedFixtureBlockPattern","fieldPattern","quotedValue","stringBodyPattern","text","parseSpecificationValue","location","context","containsCaseReference","DiagnosticCodes","subjects","code","diagnosticText","expression","parseMappingSource","match","regex","line","generated","parseStructuredValue","locationOf","structured","tryParseStructuredMapping","source","child","prefix","value","concrete","fields","field"],"sources":["../../../../../../Compiler/Parsing/SpecificationResponseParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { stringBodyPattern } from '../Text/StringLiteral';\nimport { parseMappingSource } from './ExpressionParser';\nimport { containsCaseReference, parseSpecificationValue } from './SpecificationCaseParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { emptyKeyword, noneKeyword, parseStructuredValue, StructuredMarker, tryParseStructuredMapping } from './StructuredBlockParser';\n\n// The word after 'then returns' that opens a structured scalar response as an indented block.\nexport const structuredReturnKeyword = 'value';\nexport const thenReturnsPrefix = pattern('^then\\\\s+returns\\\\b');\nexport const generatedFixturePrefix = pattern('^generated\\\\s+(?=\\\\S)(?![=])');\nexport const generatedFixturePattern = pattern('^generated\\\\s+([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst generatedFixtureBlockPattern = pattern('^generated\\\\s+([a-z_]\\\\w*)(?:\\\\s+(none|empty))?$');\nconst fieldPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst quotedValue = pattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\n\nexport function parseConcrete(context: ParserContext, text: string, location: SourceLocation, code: string): ExpressionSyntax | null {\n if (text.startsWith('case.')) return parseSpecificationValue(text, location, context);\n if (containsCaseReference(text)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'A case reference fills a whole value position; it cannot occur inside a structured value or expression.', location);\n const subjects = code === DiagnosticCodes.InvalidSpecificationValue || code === DiagnosticCodes.InvalidSpecificationCaseValue ? diagnosticText('text', text) : {};\n if ((text.startsWith('\"') || text.startsWith(\"'\")) && !quotedValue.test(text)) {\n context.error(code, 'Expected exactly one concrete value.', location, subjects);\n return null;\n }\n const expression = parseMappingSource(text, location, context);\n if (!['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(expression.kind) || (expression.kind === 'LiteralExpressionSyntax' && typeof expression.value === 'number' && !Number.isFinite(expression.value))) {\n context.error(code, 'Expected exactly one concrete literal or structured value, not an expression.', location, subjects);\n return null;\n }\n return expression;\n}\n\nexport function parseConcreteMapping(context: ParserContext, line: SourceLine, regex: RegExp, code: string): PropertyMappingSyntax | null {\n const match = regex.exec(line.content);\n const generated = match === null ? generatedFixtureBlockPattern.exec(line.content) : null;\n if (generated !== null) return { kind: 'PropertyMappingSyntax', property: generated[1], source: parseStructuredValue(context, line, generated[2] as StructuredMarker), location: locationOf(line) };\n const structured = match === null ? tryParseStructuredMapping(context, line) : undefined;\n if (structured !== undefined) return structured;\n if (match === null) {\n context.error(code, 'Expected a named fixture or assertion with exactly one concrete value.', locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const location = locationOf(line);\n const source = parseConcrete(context, match[2], { ...location, column: location.column + line.content.indexOf(match[2], line.content.indexOf('=') + 1) }, code);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'A fixture or return field cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'PropertyMappingSyntax', property: match[1], source, location };\n}\n\nexport function parseReturn(context: ParserContext, line: SourceLine): SpecificationReturnSyntax | null {\n const prefix = thenReturnsPrefix.exec(line.content)![0].length;\n const value = line.content.substring(prefix).trim();\n const location = locationOf(line);\n // 'then returns value' opens a structured scalar - an object or a list - as an indented block.\n if (value === structuredReturnKeyword || value === `${structuredReturnKeyword} ${noneKeyword}` || value === `${structuredReturnKeyword} ${emptyKeyword}`) {\n return { kind: 'ScalarSpecificationReturnSyntax', value: parseStructuredValue(context, line, value.substring(structuredReturnKeyword.length + 1) as StructuredMarker || undefined), location };\n }\n if (value.length > 0) {\n const concrete = parseConcrete(context, value, { ...location, column: location.column + line.content.indexOf(value, prefix) }, DiagnosticCodes.InvalidReturnExpectation);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A scalar return expectation cannot have child assertions.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return concrete === null ? null : { kind: 'ScalarSpecificationReturnSyntax', value: concrete, location };\n }\n const fields: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const field = parseConcreteMapping(context, child, fieldPattern, DiagnosticCodes.InvalidReturnExpectation);\n if (field !== null) fields.push(field);\n }\n return { kind: 'RecordSpecificationReturnSyntax', fields, location };\n}\n"],"mappings":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,wBAAwB,EACjKe,EAAQjB,EAAQ,UAAUU,EAAK,MAAM,EAK3C,OAJIO,IAAU,IAAA,KACVjB,EAAQ,MAAME,EAAgB,yBAA0B,4DAA6DW,EAAWI,CAAK,CAAC,EACtIjB,EAAQ,UAAUU,EAAK,MAAM,GAE1BU,IAAa,KAAO,KAAO,CAAE,KAAM,kCAAmC,MAAOA,EAAU,UAAS,CAC3G,CACA,IAAMC,EAAkC,CAAC,EACzC,IAAK,IAAIJ,EAAQjB,EAAQ,UAAUU,EAAK,MAAM,EAAGO,IAAU,IAAA,GAAW,EAAQjB,EAAQ,UAAUU,EAAK,MAAM,EAAG,CAC1GV,EAAQ,OAAO,gBAAgB,EAC/B,IAAMsB,EAAQ,qBAAqBtB,EAASiB,EAAOvB,EAAcQ,EAAgB,wBAAwB,EACrGoB,IAAU,MAAMD,EAAO,KAAKC,CAAK,CACzC,CACA,MAAO,CAAE,KAAM,kCAAmC,SAAQ,UAAS,CACvE"}
|
|
1
|
+
{"version":3,"file":"SpecificationResponseParser.js","names":["structuredReturnKeyword","thenReturnsPrefix","pattern","generatedFixturePrefix","generatedFixturePattern","generatedFixtureBlockPattern","fieldPattern","quotedValue","stringBodyPattern","text","parseSpecificationValue","location","context","containsCaseReference","DiagnosticCodes","subjects","code","diagnosticText","expression","parseMappingSource","match","regex","line","generated","parseStructuredValue","locationOf","structured","tryParseStructuredMapping","source","child","prefix","value","concrete","fields","field"],"sources":["../../../../../../Compiler/Parsing/SpecificationResponseParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { SpecificationReturnSyntax } from '../Syntax/Responses';\nimport { pattern } from '../Text/patterns';\nimport { stringBodyPattern } from '../Text/StringLiteral';\nimport { parseMappingSource } from './ExpressionParser';\nimport { containsCaseReference, parseSpecificationValue } from './SpecificationCaseParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { emptyKeyword, noneKeyword, parseStructuredValue, StructuredMarker, tryParseStructuredMapping } from './StructuredBlockParser';\n\n// The word after 'then returns' that opens a structured scalar response as an indented block.\nexport const structuredReturnKeyword = 'value';\nexport const thenReturnsPrefix = pattern('^then\\\\s+returns\\\\b');\nexport const generatedFixturePrefix = pattern('^generated\\\\s+(?=\\\\S)(?![=])');\nexport const generatedFixturePattern = pattern('^generated\\\\s+([a-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst generatedFixtureBlockPattern = pattern('^generated\\\\s+([a-z_]\\\\w*)(?:\\\\s+(none|empty))?$');\nconst fieldPattern = pattern('^([\\\\w.]+)\\\\s*=(?!=|>)\\\\s*(.+)$');\nconst quotedValue = pattern(`^(?:\"${stringBodyPattern}\"|'(?:[^'\\\\\\\\]|\\\\\\\\.)*')$`);\n\nexport function parseConcrete(context: ParserContext, text: string, location: SourceLocation, code: string): ExpressionSyntax | null {\n if (text.startsWith('case.')) return parseSpecificationValue(text, location, context);\n if (containsCaseReference(text)) context.error(DiagnosticCodes.InvalidSpecificationCaseReference, 'A case reference fills a whole value position; it cannot occur inside a structured value or expression.', location);\n const subjects = code === DiagnosticCodes.InvalidSpecificationValue || code === DiagnosticCodes.InvalidSpecificationCaseValue ? diagnosticText('text', text) : {};\n if ((text.startsWith('\"') || text.startsWith(\"'\")) && !quotedValue.test(text)) {\n context.error(code, 'Expected exactly one concrete value.', location, subjects);\n return null;\n }\n const expression = parseMappingSource(text, location, context);\n if (!['LiteralExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(expression.kind) || (expression.kind === 'LiteralExpressionSyntax' && typeof expression.value === 'number' && !Number.isFinite(expression.value))) {\n context.error(code, 'Expected exactly one concrete literal or structured value, not an expression.', location, subjects);\n return null;\n }\n return expression;\n}\n\nexport function parseConcreteMapping(context: ParserContext, line: SourceLine, regex: RegExp, code: string): PropertyMappingSyntax | null {\n const match = regex.exec(line.content);\n const generated = match === null ? generatedFixtureBlockPattern.exec(line.content) : null;\n if (generated !== null) return { kind: 'PropertyMappingSyntax', property: generated[1], source: parseStructuredValue(context, line, generated[2] as StructuredMarker), location: locationOf(line) };\n const structured = match === null ? tryParseStructuredMapping(context, line) : undefined;\n if (structured !== undefined) return structured;\n if (match === null) {\n context.error(code, 'Expected a named fixture or assertion with exactly one concrete value.', locationOf(line));\n context.skipBlock(line.indent);\n return null;\n }\n const location = locationOf(line);\n const source = parseConcrete(context, match[2], { ...location, column: location.column + line.content.indexOf(match[2], line.content.indexOf('=') + 1) }, code);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'A fixture or return field cannot have child directives.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return source === null ? null : { kind: 'PropertyMappingSyntax', property: match[1], source, location };\n}\n\nexport function parseReturn(context: ParserContext, line: SourceLine): SpecificationReturnSyntax | null {\n const prefix = thenReturnsPrefix.exec(line.content)![0].length;\n const value = line.content.substring(prefix).trim();\n const location = locationOf(line);\n // 'then returns value' opens a structured scalar - an object or a list - as an indented block.\n if (value === structuredReturnKeyword || value === `${structuredReturnKeyword} ${noneKeyword}` || value === `${structuredReturnKeyword} ${emptyKeyword}`) {\n return { kind: 'ScalarSpecificationReturnSyntax', value: parseStructuredValue(context, line, value.substring(structuredReturnKeyword.length + 1) as StructuredMarker || undefined), location };\n }\n if (value.length > 0) {\n const concrete = parseConcrete(context, value, { ...location, column: location.column + line.content.indexOf(value, prefix) }, DiagnosticCodes.InvalidReturnExpectation);\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(DiagnosticCodes.InvalidReturnExpectation, 'A scalar return expectation cannot have child assertions.', locationOf(child));\n context.skipBlock(line.indent);\n }\n return concrete === null ? null : { kind: 'ScalarSpecificationReturnSyntax', value: concrete, location };\n }\n const fields: PropertyMappingSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const field = parseConcreteMapping(context, child, fieldPattern, DiagnosticCodes.InvalidReturnExpectation);\n if (field !== null) fields.push(field);\n }\n return { kind: 'RecordSpecificationReturnSyntax', fields, location };\n}\n"],"mappings":"A,qlBAiBA,MAAaA,EAA0B,QAC1BC,EAAoBC,EAAQ,qBAAqB,EACjDC,EAAyBD,EAAQ,8BAA8B,EAC/DE,EAA0BF,EAAQ,iDAAiD,EAC1FG,EAA+BH,EAAQ,kDAAkD,EACzFI,EAAeJ,EAAQ,iCAAiC,EACxDK,EAAcL,EAAQ,QAAQM,EAAkB,0BAA0B,EAEhF,SAAgB,cAAc,EAAwB,EAAc,EAA0B,EAAuC,CACjI,GAAIC,EAAK,WAAW,OAAO,EAAG,OAAOC,EAAwBD,EAAME,EAAUC,CAAO,EAChFC,EAAsBJ,CAAI,GAAGG,EAAQ,MAAME,EAAgB,kCAAmC,0GAA2GH,CAAQ,EACrN,IAAMI,EAAWC,IAASF,EAAgB,2BAA6BE,IAASF,EAAgB,8BAAgCG,EAAe,OAAQR,CAAI,EAAI,CAAC,EAChK,IAAKA,EAAK,WAAW,GAAG,GAAKA,EAAK,WAAW,GAAG,IAAM,CAACF,EAAY,KAAKE,CAAI,EAExE,OADAG,EAAQ,MAAMI,EAAM,uCAAwCL,EAAUI,CAAQ,EACvE,KAEX,IAAMG,EAAaC,EAAmBV,EAAME,EAAUC,CAAO,EAK7D,MAJI,CAAC,CAAC,0BAA2B,yBAA0B,sBAAsB,CAAC,CAAC,SAASM,EAAW,IAAI,GAAMA,EAAW,OAAS,2BAA6B,OAAOA,EAAW,OAAU,UAAY,CAAC,OAAO,SAASA,EAAW,KAAK,GACvON,EAAQ,MAAMI,EAAM,gFAAiFL,EAAUI,CAAQ,EAChH,MAEJG,CACX,CAEA,SAAgB,qBAAqB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,kCAAmC,MAAOP,EAAqBZ,EAASU,EAAMS,EAAM,UAAU,CAAkC,GAAyB,IAAA,EAAS,EAAG,UAAS,EAEjM,GAAIA,EAAM,OAAS,EAAG,CAClB,IAAMC,EAAW,cAAcpB,EAASmB,EAAO,CAAE,GAAGpB,EAAU,OAAQA,EAAS,OAASW,EAAK,QAAQ,QAAQS,EAAOD,CAAM,CAAE,EAAGhB,EAAgB,wBAAwB,EACjKe,EAAQjB,EAAQ,UAAUU,EAAK,MAAM,EAK3C,OAJIO,IAAU,IAAA,KACVjB,EAAQ,MAAME,EAAgB,yBAA0B,4DAA6DW,EAAWI,CAAK,CAAC,EACtIjB,EAAQ,UAAUU,EAAK,MAAM,GAE1BU,IAAa,KAAO,KAAO,CAAE,KAAM,kCAAmC,MAAOA,EAAU,UAAS,CAC3G,CACA,IAAMC,EAAkC,CAAC,EACzC,IAAK,IAAIJ,EAAQjB,EAAQ,UAAUU,EAAK,MAAM,EAAGO,IAAU,IAAA,GAAW,EAAQjB,EAAQ,UAAUU,EAAK,MAAM,EAAG,CAC1GV,EAAQ,OAAO,gBAAgB,EAC/B,IAAMsB,EAAQ,qBAAqBtB,EAASiB,EAAOvB,EAAcQ,EAAgB,wBAAwB,EACrGoB,IAAU,MAAMD,EAAO,KAAKC,CAAK,CACzC,CACA,MAAO,CAAE,KAAM,kCAAmC,SAAQ,UAAS,CACvE,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{EventSourceCatalog as e}from"../Syntax/EventSourceCatalog.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{EventSourceCatalog as e}from"../Syntax/EventSourceCatalog.js";import{formatStreamIdLiteral as t}from"./EventSourceValidator.js";import{compatibleValue as n,uniqueByName as r}from"./ResponseValidator.js";function formatSpecificationStreamId(e,i,a){let o=r(a.concepts),s=r(a.types),c=new Map([...s].map(([e,t])=>[e,r(t.properties)]));if(e?.kind!==`LiteralExpressionSyntax`||!n(e,i,o,c))return null;let l=o.get(i.name)?.type??i.name;return[`String`,`Uuid`,`Int`].includes(l)?t(e,i,a)?.value??null:null}function matchesSpecificationRoute(t,n,r,i){if(r!=null)return t==null;if(n==null)return!0;if(t==null)return!1;let a=new e(i),o=a.resolve(t.eventSource,t.stream),s=a.resolve(n.eventSource,n.stream);if(o.kind!==`unique`||s.kind!==`unique`)return null;if(o.sources[0]!==s.sources[0]||o.streams[0]!==s.streams[0])return!1;let c=s.streams[0],compare=(e,t,n)=>{let r=formatSpecificationStreamId(e,n,i),a=formatSpecificationStreamId(t,n,i);return r===null||a===null?null:r===a};if(c.streamIdParts.length>0){if(t.streamId!==null||n.streamId!==null||t.streamIdParts.length!==c.streamIdParts.length||n.streamIdParts.length!==c.streamIdParts.length)return null;let e=c.streamIdParts.map(e=>{let r=t.streamIdParts.filter(t=>t.property===e.name),i=n.streamIdParts.filter(t=>t.property===e.name);return r.length===1&&i.length===1?compare(r[0].source,i[0].source,e.type):null});return e.includes(!1)?!1:!e.includes(null)||null}return t.streamIdParts.length>0||n.streamIdParts.length>0?null:c.streamId===null?t.streamId===null&&n.streamId===null||null:compare(t.streamId?.source,n.streamId?.source,c.streamId)}export{formatSpecificationStreamId,matchesSpecificationRoute};
|
|
2
2
|
//# sourceMappingURL=SpecificationRouteComparison.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecificationRouteComparison.js","names":["concepts","uniqueByName","application","composites","properties","name","type","expression","compatibleValue","primitive","formatStreamIdLiteral","noStream","given","expected","catalog","EventSourceCatalog","actual","target","stream","first","left","second","right","comparisons","mapping","part"],"sources":["../../../../../../Compiler/Parsing/SpecificationRouteComparison.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 { TypeRefSyntax } from '../Syntax/Declarations';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { formatStreamIdLiteral } from './EventSourceValidator';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { SpecificationStreamSyntax, SpecificationNoStreamSyntax } from '../Syntax/Specifications';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\n\nexport function formatSpecificationStreamId(expression: ExpressionSyntax | null | undefined, type: TypeRefSyntax, application: ApplicationSyntax): string | null {\n const concepts = uniqueByName(application.concepts);\n const composites = uniqueByName(application.types);\n const properties = new Map([...composites].map(([name, type]) => [name, uniqueByName(type.properties)]));\n if (expression?.kind !== 'LiteralExpressionSyntax' || !compatibleValue(expression, type, concepts, properties)) return null;\n const primitive = concepts.get(type.name)?.type ?? type.name;\n return ['String', 'Uuid', 'Int'].includes(primitive) ? formatStreamIdLiteral(expression, type, application)?.value ?? null : null;\n}\n\nexport function matchesSpecificationRoute(given: SpecificationStreamSyntax | null | undefined, expected: SpecificationStreamSyntax | null | undefined, noStream: SpecificationNoStreamSyntax | null | undefined, application: ApplicationSyntax): boolean | null {\n if (noStream != null) return given == null;\n if (expected == null) return true;\n if (given == null) return false;\n const catalog = new EventSourceCatalog(application);\n const actual = catalog.resolve(given.eventSource, given.stream);\n const target = catalog.resolve(expected.eventSource, expected.stream);\n if (actual.kind !== EventSourceResolutionKind.Unique || target.kind !== EventSourceResolutionKind.Unique) return null;\n if (actual.sources[0] !== target.sources[0] || actual.streams[0] !== target.streams[0]) return false;\n const stream = target.streams[0];\n const compare = (left: ExpressionSyntax | null | undefined, right: ExpressionSyntax | null | undefined, type: TypeRefSyntax): boolean | null => {\n const first = formatSpecificationStreamId(left, type, application);\n const second = formatSpecificationStreamId(right, type, application);\n return first === null || second === null ? null : first === second;\n };\n if (stream.streamIdParts.length > 0) {\n if (given.streamId !== null || expected.streamId !== null || given.streamIdParts.length !== stream.streamIdParts.length || expected.streamIdParts.length !== stream.streamIdParts.length) return null;\n const comparisons = stream.streamIdParts.map(part => {\n const left = given.streamIdParts.filter(mapping => mapping.property === part.name);\n const right = expected.streamIdParts.filter(mapping => mapping.property === part.name);\n return left.length === 1 && right.length === 1 ? compare(left[0].source, right[0].source, part.type) : null;\n });\n return comparisons.includes(false) ? false : comparisons.includes(null) ? null : true;\n }\n if (given.streamIdParts.length > 0 || expected.streamIdParts.length > 0) return null;\n if (stream.streamId === null) return given.streamId === null && expected.streamId === null ? true : null;\n return compare(given.streamId?.source, expected.streamId?.source, stream.streamId);\n}\n"],"mappings":"uQAYA,SAAgB,4BAA4B,EAAiD,EAAqB,EAA+C,CAC7J,IAAMA,EAAWC,EAAaC,EAAY,QAAQ,EAC5CC,EAAaF,EAAaC,EAAY,KAAK,EAC3CE,EAAa,IAAI,IAAI,CAAC,GAAGD,CAAU,CAAC,CAAC,KAAK,CAACE,EAAMC,KAAU,CAACD,EAAMJ,EAAaK,EAAK,UAAU,CAAC,CAAC,CAAC,EACvG,GAAIC,GAAY,OAAS,2BAA6B,CAACC,EAAgBD,EAAYD,EAAMN,EAAUI,CAAU,EAAG,OAAO,KACvH,IAAMK,EAAYT,EAAS,IAAIM,EAAK,IAAI,CAAC,EAAE,MAAQA,EAAK,KACxD,MAAO,CAAC,SAAU,OAAQ,KAAK,CAAC,CAAC,SAASG,CAAS,EAAIC,EAAsBH,EAAYD,EAAMJ,CAAW,CAAC,EAAE,OAAS,KAAO,IACjI,CAEA,SAAgB,0BAA0B,EAAqD,EAAwD,EAA0D,EAAgD,CAC7P,GAAIS,GAAY,KAAM,OAAOC,GAAS,KACtC,GAAIC,GAAY,KAAM,MAAO,GAC7B,GAAID,GAAS,KAAM,MAAO,GAC1B,IAAME,EAAU,IAAIC,EAAmBb,CAAW,EAC5Cc,EAASF,EAAQ,QAAQF,EAAM,YAAaA,EAAM,MAAM,EACxDK,EAASH,EAAQ,QAAQD,EAAS,YAAaA,EAAS,MAAM,EACpE,GAAIG,EAAO,OAAA,UAA6CC,EAAO,OAAA,SAA2C,OAAO,KACjH,GAAID,EAAO,QAAQ,KAAOC,EAAO,QAAQ,IAAMD,EAAO,QAAQ,KAAOC,EAAO,QAAQ,GAAI,MAAO,GAC/F,IAAMC,EAASD,EAAO,QAAQ,GACxB,SAAW,EAA2C,EAA4C,IAAwC,CAC5I,IAAME,EAAQ,4BAA4BC,EAAMd,EAAMJ,CAAW,EAC3DmB,EAAS,4BAA4BC,EAAOhB,EAAMJ,CAAW,EACnE,OAAOiB,IAAU,MAAQE,IAAW,KAAO,KAAOF,IAAUE,CAChE,EACA,GAAIH,EAAO,cAAc,OAAS,EAAG,CACjC,GAAIN,EAAM,WAAa,MAAQC,EAAS,WAAa,MAAQD,EAAM,cAAc,SAAWM,EAAO,cAAc,QAAUL,EAAS,cAAc,SAAWK,EAAO,cAAc,OAAQ,OAAO,KACjM,IAAMK,EAAcL,EAAO,cAAc,IAAI,GAAQ,CACjD,IAAME,EAAOR,EAAM,cAAc,OAAO,GAAWY,EAAQ,WAAaC,EAAK,IAAI,EAC3EH,EAAQT,EAAS,cAAc,OAAO,GAAWW,EAAQ,WAAaC,EAAK,IAAI,EACrF,OAAOL,EAAK,SAAW,GAAKE,EAAM,SAAW,EAAI,QAAQF,EAAK,EAAE,CAAC,OAAQE,EAAM,EAAE,CAAC,OAAQG,EAAK,IAAI,EAAI,IAC3G,CAAC,EACD,OAAOF,EAAY,SAAS,EAAK,EAAI,GAAQ,GAAY,SAAS,IAAI,GAAI,IAC9E,CAGA,OAFIX,EAAM,cAAc,OAAS,GAAKC,EAAS,cAAc,OAAS,EAAU,KAC5EK,EAAO,WAAa,KAAaN,EAAM,WAAa,MAAQC,EAAS,WAAa,MAAc,KAC7F,QAAQD,EAAM,UAAU,OAAQC,EAAS,UAAU,OAAQK,EAAO,QAAQ,CACrF"}
|
|
1
|
+
{"version":3,"file":"SpecificationRouteComparison.js","names":["concepts","uniqueByName","application","composites","properties","name","type","expression","compatibleValue","primitive","formatStreamIdLiteral","noStream","given","expected","catalog","EventSourceCatalog","actual","target","stream","first","left","second","right","comparisons","mapping","part"],"sources":["../../../../../../Compiler/Parsing/SpecificationRouteComparison.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 { TypeRefSyntax } from '../Syntax/Declarations';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { formatStreamIdLiteral } from './EventSourceValidator';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { SpecificationStreamSyntax, SpecificationNoStreamSyntax } from '../Syntax/Specifications';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\n\nexport function formatSpecificationStreamId(expression: ExpressionSyntax | null | undefined, type: TypeRefSyntax, application: ApplicationSyntax): string | null {\n const concepts = uniqueByName(application.concepts);\n const composites = uniqueByName(application.types);\n const properties = new Map([...composites].map(([name, type]) => [name, uniqueByName(type.properties)]));\n if (expression?.kind !== 'LiteralExpressionSyntax' || !compatibleValue(expression, type, concepts, properties)) return null;\n const primitive = concepts.get(type.name)?.type ?? type.name;\n return ['String', 'Uuid', 'Int'].includes(primitive) ? formatStreamIdLiteral(expression, type, application)?.value ?? null : null;\n}\n\nexport function matchesSpecificationRoute(given: SpecificationStreamSyntax | null | undefined, expected: SpecificationStreamSyntax | null | undefined, noStream: SpecificationNoStreamSyntax | null | undefined, application: ApplicationSyntax): boolean | null {\n if (noStream != null) return given == null;\n if (expected == null) return true;\n if (given == null) return false;\n const catalog = new EventSourceCatalog(application);\n const actual = catalog.resolve(given.eventSource, given.stream);\n const target = catalog.resolve(expected.eventSource, expected.stream);\n if (actual.kind !== EventSourceResolutionKind.Unique || target.kind !== EventSourceResolutionKind.Unique) return null;\n if (actual.sources[0] !== target.sources[0] || actual.streams[0] !== target.streams[0]) return false;\n const stream = target.streams[0];\n const compare = (left: ExpressionSyntax | null | undefined, right: ExpressionSyntax | null | undefined, type: TypeRefSyntax): boolean | null => {\n const first = formatSpecificationStreamId(left, type, application);\n const second = formatSpecificationStreamId(right, type, application);\n return first === null || second === null ? null : first === second;\n };\n if (stream.streamIdParts.length > 0) {\n if (given.streamId !== null || expected.streamId !== null || given.streamIdParts.length !== stream.streamIdParts.length || expected.streamIdParts.length !== stream.streamIdParts.length) return null;\n const comparisons = stream.streamIdParts.map(part => {\n const left = given.streamIdParts.filter(mapping => mapping.property === part.name);\n const right = expected.streamIdParts.filter(mapping => mapping.property === part.name);\n return left.length === 1 && right.length === 1 ? compare(left[0].source, right[0].source, part.type) : null;\n });\n return comparisons.includes(false) ? false : comparisons.includes(null) ? null : true;\n }\n if (given.streamIdParts.length > 0 || expected.streamIdParts.length > 0) return null;\n if (stream.streamId === null) return given.streamId === null && expected.streamId === null ? true : null;\n return compare(given.streamId?.source, expected.streamId?.source, stream.streamId);\n}\n"],"mappings":"A,uQAYA,SAAgB,4BAA4B,EAAiD,EAAqB,EAA+C,CAC7J,IAAMA,EAAWC,EAAaC,EAAY,QAAQ,EAC5CC,EAAaF,EAAaC,EAAY,KAAK,EAC3CE,EAAa,IAAI,IAAI,CAAC,GAAGD,CAAU,CAAC,CAAC,KAAK,CAACE,EAAMC,KAAU,CAACD,EAAMJ,EAAaK,EAAK,UAAU,CAAC,CAAC,CAAC,EACvG,GAAIC,GAAY,OAAS,2BAA6B,CAACC,EAAgBD,EAAYD,EAAMN,EAAUI,CAAU,EAAG,OAAO,KACvH,IAAMK,EAAYT,EAAS,IAAIM,EAAK,IAAI,CAAC,EAAE,MAAQA,EAAK,KACxD,MAAO,CAAC,SAAU,OAAQ,KAAK,CAAC,CAAC,SAASG,CAAS,EAAIC,EAAsBH,EAAYD,EAAMJ,CAAW,CAAC,EAAE,OAAS,KAAO,IACjI,CAEA,SAAgB,0BAA0B,EAAqD,EAAwD,EAA0D,EAAgD,CAC7P,GAAIS,GAAY,KAAM,OAAOC,GAAS,KACtC,GAAIC,GAAY,KAAM,MAAO,GAC7B,GAAID,GAAS,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AAa,MAAc,KAC7F,QAAQD,EAAM,UAAU,OAAQC,EAAS,UAAU,OAAQK,EAAO,QAAQ,CACrF,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{AuthoringProductionResolver as n}from"../Syntax/AuthoringProductionResolver.js";import{EventSourceCatalog as r}from"../Syntax/EventSourceCatalog.js";import{formatSpecificationStreamId as i}from"./SpecificationRouteComparison.js";import{streamIdFailureMessage as a}from"../Syntax/StreamIdFormatter.js";import{commandDestinationType as o}from"./CommandDestinationTypes.js";import{formatStreamIdLiteral as s}from"./EventSourceValidator.js";import{validateStreamIdParts as c}from"./CompositeStreamIdValidator.js";import{ParserContext as l}from"./ParserContext.js";import{LineReader as u}from"./LineReader.js";import{compatibleValue as d,uniqueByName as f}from"./ResponseValidator.js";import{expandEffectiveSpecificationExamples as p,specificationExamples as m}from"./SpecificationCommandExamples.js";function validateSpecificationStreams(e,r){let i=new n(e).slices.flatMap(({slice:e})=>e.specifications.flatMap(e=>e.cases??[]));if(i.length===0)return validateRoutes(e,r);let a=new l(new u([]));validateRoutes(e,a);let o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set;for(let e of a.diagnostics){let n=JSON.stringify([e.code,e.location.path,e.location.line,e.location.column,e.message]);if(s.has(n))continue;s.add(n);let a=e.code===t.InvalidSpecificationStreamRoute?i.find(t=>t.values.some(t=>t.source.location.line===e.location.line&&t.source.location.column===e.location.column&&t.source.location.path===e.location.path)):void 0;if(a===void 0)r.error(e.code,e.message,e.location,e.arguments);else{let t=JSON.stringify(e.location);o.has(t)||r.error(e.code,`Case '${a.name}': ${e.message}`,e.location,e.arguments),o.add(t)}}}function validateRoutes(l,u){let h=m(l).resolvedExamples,g=p(l);l=g.application;let _=new n(l),v=/* @__PURE__ */ new Set,y=h.flatMap(n=>{if(n.kind!==`event`)return n.kind!==`command`&&n.kind!==`readmodel`||n.example.stream==null&&n.example.noStream==null||u.error(t.InvalidSpecificationExampleBody,`only event examples carry routes; a command's route comes from its declaration, and read models have none`,(n.example.stream??n.example.noStream).location,e(`example`,n.example.name)),[];let r={kind:`SpecificationEventSyntax`,eventType:n.name,values:n.example.values,for:n.example.for,stream:n.example.stream,noStream:n.example.noStream,location:n.example.location};return v.add(r),[{scope:n.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[r],whenRedelivered:null}}]}),b=new r(l),x=f(l.concepts),S=f(l.types),C=new Map([...S].map(([e,t])=>[e,f(t.properties)])),compatible=(e,t)=>d(e,t,x,C),w=/* @__PURE__ */ new Set([`String`,`Uuid`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`,...x.keys(),...S.keys()]),nominallyCompatible=(e,t)=>w.has(e.name)&&w.has(t.name)?e.name===t.name&&e.isCollection===t.isCollection&&(!e.isOptional||t.isOptional):null,formatStreamId=(e,t)=>i(e,t,l),eventOf=(e,t)=>{let n=_.resolve(e,t).declaration;return n?.node.kind===`EventSyntax`?n.node:null},T=[];for(let{slice:e}of _.slices){for(let t of e.commands)for(let n of t.produces){if(!_.isEventProduction(n,e))continue;let r=eventOf(n.event,e);if(r===null)continue;let i=o(t,n,l,{resolver:_,slice:e});T.push({event:r,command:t,type:i,route:n.stream??t.stream})}for(let t of e.reactions.flatMap(e=>e.triggers).flatMap(e=>[...e.produces,...e.invokes.flatMap(e=>e.onRefused??[]).flatMap(e=>e.produces)])){let n=eventOf(t.event,e);n!==null&&T.push({event:n,command:null,type:null})}for(let t of e.captures)for(let n of[...t.appends,...t.children.flatMap(e=>e.appends),...t.nested.flatMap(e=>e.appends)]){let t=eventOf(n.event,e);t!==null&&T.push({event:t,command:null,type:null})}}let E=[...y.flatMap(e=>_.slices.filter(t=>t.scope.join(`.`)===e.scope.join(`.`)).map(({slice:t,scope:n})=>({slice:t,scope:n,specification:e.specification}))),..._.slices.flatMap(({slice:e,scope:t})=>e.specifications.map(n=>({slice:e,scope:t,specification:n})))];for(let{slice:e,scope:n,specification:r}of E){let i=_.slices.flatMap(e=>e.slice.commands.map(t=>({command:t,scope:e.scope}))),o=r.when?.commandType.split(`.`)??[],d=o.slice(0,-1),f=i.filter(e=>e.command.name===o.at(-1)&&d.every((t,n)=>e.scope[e.scope.length-d.length+n]===t)),p=d.length>0&&f.length===1?f[0].command:null;for(let e=n.length;d.length===0&&e>=0&&p===null;e--){let t=f.filter(t=>n.slice(0,e).every((e,n)=>t.scope[n]===e));if(t.length>0){p=t.length===1?t[0].command:null;break}}let m=[...r.given.map(e=>({node:e,required:!0,expected:!1})),...r.whenAppended===null?[]:[{node:r.whenAppended,required:!0,expected:!1}],...r.thenEvents.map(e=>({node:e,required:!1,expected:!v.has(e)})),...r.whenRedelivered==null?[]:[{node:{...r.whenRedelivered,kind:`SpecificationEventSyntax`},required:!1,expected:!1}]];for(let{node:n,required:r,expected:i}of m){let o=g.specifications.flatMap(e=>e.steps).find(e=>e.effective===n),d=o?.route?.origin!==`example`,f=d||n.for!==o?.example?.for,contextualError=(e,t,n)=>{u.error(e,o?.example==null?t:`${t} Example '${o.example.name}' is used here.`,o?.example==null?n:o.authored.location)};if(n.stream==null&&n.noStream==null)continue;r&&n.noStream!=null&&contextualError(t.InvalidSpecificationStream,`Expected 'stream Source.Stream', or 'no stream' on a then event.`,n.noStream.location);let m=null,h=eventOf(n.eventType,e),_=T.filter(e=>e.event===h);if(n.stream!=null){let e=n.stream,i=b.resolve(e.eventSource,e.stream);if(i.kind!==`unique`){let n={ambiguous:`Ambiguous`,notFound:`NotFound`,wrongKind:`WrongKind`}[i.kind];d&&u.error(t.InvalidSpecificationStreamRoute,`Stream '${e.eventSource}.${e.stream}' is ${n}; routing requires one physical source and stream.`,e.location);continue}let p=i.sources[0],h=i.streams[0],validateLiteral=(e,n)=>{let r=e.source,i=s(r,n,l);i?.failure==null?(r.kind!==`LiteralExpressionSyntax`||r.value===null||n!==null&&!compatible(r,n))&&u.error(t.InvalidSpecificationStreamRoute,`A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.`,r.location):u.error(t.InvalidSpecificationStreamRoute,a(i.failure),r.location)};if(d&&(h.streamIdParts.length>0?c(h,e.streamIdParts,e.streamId!==null,e.location,t.InvalidSpecificationStreamRoute,u,validateLiteral):e.streamIdParts.length>0?u.error(t.InvalidSpecificationStreamRoute,`A streamId part block requires a composite stream.`,e.location):(h.streamId===null!=(e.streamId===null)&&u.error(t.InvalidSpecificationStreamRoute,h.streamId===null?`An unkeyed stream cannot take a streamId mapping.`:`This keyed stream requires a streamId mapping.`,e.location),e.streamId!==null&&validateLiteral(e.streamId,h.streamId))),m=p.identifier,m===null){let n=_.map(e=>e.type),r=new Set(n.filter(e=>e!==null).map(e=>`${e.name}:${e.isOptional}:${e.isCollection}`));n.length===0||n.some(e=>e===null)||r.size!==1?d&&u.error(t.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${p.name}'; the event's producers do not supply one unambiguous destination type.`,e.location):m=n[0]}let g=!1;if(o?.example?.stream!=null&&n.for!==null&&n.for===o.example.for){let e=b.resolve(o.example.stream.eventSource,o.example.stream.stream);if(e.kind===`unique`){let t=_.map(e=>e.type),r=new Set(t.filter(e=>e!==null).map(e=>`${e.name}:${e.isOptional}:${e.isCollection}`)),i=e.sources[0].identifier??(t.length>0&&!t.some(e=>e===null)&&r.size===1?t[0]:null);i!==null&&(g=n.for.kind!==`LiteralExpressionSyntax`||n.for.value===null||i.isCollection||i.isOptional||!compatible(n.for,i))}}r&&n.for===null?contextualError(t.InvalidSpecificationStreamEventSource,`A routed given or when append event requires 'for <literal>'.`,e.location):f&&!g&&n.for!==null&&(n.for.kind!==`LiteralExpressionSyntax`||n.for.value===null||m!==null&&(m.isCollection||m.isOptional||!compatible(n.for,m)))&&contextualError(t.InvalidSpecificationStreamEventSource,`A routed event's for value must be a concrete literal compatible with the source's identifier type.`,n.for.location)}if(!i||p===null||_.length===0||_.some(e=>e.command!==p))continue;let v=_.every(e=>{let t=e.route?.propertyCandidate===null?e.route:null,r=n.noStream==null?t==null||t.eventSource!==n.stream.eventSource||t.stream!==n.stream.stream:t!=null;if(!r&&n.stream!=null&&t!=null){let e=b.resolve(n.stream.eventSource,n.stream.stream),i=e.kind===`unique`?e.streams[0]:null;if(i!==null&&i.streamIdParts.length>0){if(t.streamId===null&&n.stream.streamId===null&&t.streamIdParts.length>0&&n.stream.streamIdParts.length>0)for(let e of i.streamIdParts){let i=t.streamIdParts.filter(t=>t.property===e.name),a=n.stream.streamIdParts.filter(t=>t.property===e.name);if(i.length!==1||a.length!==1)continue;let o=formatStreamId(i[0].source,e.type),s=formatStreamId(a[0].source,e.type);o!==null&&s!==null&&o!==s&&(r=!0)}}else if(i?.streamId!=null&&t.streamIdParts.length===0&&n.stream.streamIdParts.length===0){let e=formatStreamId(t.streamId?.source,i.streamId),a=formatStreamId(n.stream.streamId?.source,i.streamId);e!==null&&a!==null&&e!==a&&(r=!0)}}return r});n.for?.kind===`LiteralExpressionSyntax`&&_.every(e=>e.type!==null&&(m===null?!compatible(n.for,e.type):nominallyCompatible(e.type,m)===!1))&&(v=!0),v&&contextualError(t.SpecificationStreamContradictsCommand,`The expected event route contradicts its only producer, the command under test.`,(n.stream??n.noStream).location)}}}export{validateSpecificationStreams};
|
|
2
2
|
//# sourceMappingURL=SpecificationStreamValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecificationStreamValidator.js","names":["rows","AuthoringProductionResolver","application","slice","specification","context","sink","ParserContext","LineReader","reported","distinct","diagnostic","key","row","DiagnosticCodes","value","examples","specificationExamples","expansion","expandEffectiveSpecificationExamples","resolver","declarationSteps","exampleSpecifications","entry","diagnosticText","node","catalog","EventSourceCatalog","concepts","uniqueByName","composites","properties","name","type","compatibleValue","known","source","target","formatSpecificationStreamId","expression","declared","reference","producers","command","produced","event","commandDestinationType","reaction","trigger","invocation","branch","capture","appended","child","nested","validationSpecifications","owner","commands","parts","qualifiers","candidates","index","segment","depth","scope","visible","occurrences","step","pair","validateRoute","validateFor","code","message","location","required","identifier","eventProducers","producer","route","resolution","state","stream","mapping","formatted","formatStreamIdLiteral","streamIdFailureMessage","validateStreamIdParts","types","inheritedIdentityIsInvalid","prior","priorIdentifier","expected","contradicts","commandRoute","differs","part","actual","actualId","expectedId"],"sources":["../../../../../../Compiler/Parsing/SpecificationStreamValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { CommandSyntax } from '../Syntax/Commands';\nimport { EventSyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { CommandStreamSyntax, EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { formatSpecificationStreamId } from './SpecificationRouteComparison';\nimport { streamIdFailureMessage } from '../Syntax/StreamIdFormatter';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { commandDestinationType } from './CommandDestinationTypes';\nimport { formatStreamIdLiteral } from './EventSourceValidator';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { validateStreamIdParts } from './CompositeStreamIdValidator';\nimport { ParserContext } from './ParserContext';\nimport { LineReader } from './LineReader';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\nimport { expandEffectiveSpecificationExamples, specificationExamples } from './SpecificationCommandExamples';\nimport { SpecificationEventSyntax } from '../Syntax/Specifications';\n\ninterface Producer { event: EventSyntax; command: CommandSyntax | null; type: TypeRefSyntax | null; route?: CommandStreamSyntax | null }\n\nexport function validateSpecificationStreams(application: ApplicationSyntax, context: ParserContext): void {\n const rows = new AuthoringProductionResolver(application).slices.flatMap(({ slice }) => slice.specifications.flatMap(specification => specification.cases ?? []));\n if (rows.length === 0) return validateRoutes(application, context);\n const sink = new ParserContext(new LineReader([]));\n validateRoutes(application, sink);\n const reported = new Set<string>();\n const distinct = new Set<string>();\n for (const diagnostic of sink.diagnostics) {\n const key = JSON.stringify([diagnostic.code, diagnostic.location.path, diagnostic.location.line, diagnostic.location.column, diagnostic.message]);\n if (distinct.has(key)) continue;\n distinct.add(key);\n const row = diagnostic.code === DiagnosticCodes.InvalidSpecificationStreamRoute ? rows.find(row => row.values.some(value => value.source.location.line === diagnostic.location.line && value.source.location.column === diagnostic.location.column && value.source.location.path === diagnostic.location.path)) : undefined;\n if (row === undefined) context.error(diagnostic.code, diagnostic.message, diagnostic.location, diagnostic.arguments);\n else {\n const key = JSON.stringify(diagnostic.location);\n if (!reported.has(key)) context.error(diagnostic.code, `Case '${row.name}': ${diagnostic.message}`, diagnostic.location, diagnostic.arguments);\n reported.add(key);\n }\n }\n}\n\nfunction validateRoutes(application: ApplicationSyntax, context: ParserContext): void {\n const examples = specificationExamples(application).resolvedExamples;\n const expansion = expandEffectiveSpecificationExamples(application);\n application = expansion.application;\n const resolver = new AuthoringProductionResolver(application);\n const declarationSteps = new Set<SpecificationEventSyntax>();\n const exampleSpecifications = examples.flatMap(entry => {\n if (entry.kind !== 'event') {\n if ((entry.kind === 'command' || entry.kind === 'readmodel') && (entry.example.stream != null || entry.example.noStream != null))\n context.error(DiagnosticCodes.InvalidSpecificationExampleBody, \"only event examples carry routes; a command's route comes from its declaration, and read models have none\", (entry.example.stream ?? entry.example.noStream)!.location, diagnosticText('example', entry.example.name));\n return [];\n }\n const node: SpecificationEventSyntax = { kind: 'SpecificationEventSyntax', eventType: entry.name, values: entry.example.values, for: entry.example.for, stream: entry.example.stream, noStream: entry.example.noStream, location: entry.example.location };\n declarationSteps.add(node);\n return [{ scope: entry.scope, specification: { when: null, given: [], whenAppended: null, thenEvents: [node], whenRedelivered: null } }];\n });\n const catalog = new EventSourceCatalog(application);\n const concepts = uniqueByName(application.concepts);\n const composites = uniqueByName(application.types);\n const properties = new Map([...composites].map(([name, type]) => [name, uniqueByName(type.properties)]));\n const compatible = (value: Parameters<typeof compatibleValue>[0], type: TypeRefSyntax): boolean => compatibleValue(value, type, concepts, properties);\n const known = new Set(['String', 'Uuid', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...concepts.keys(), ...composites.keys()]);\n const nominallyCompatible = (source: TypeRefSyntax, target: TypeRefSyntax): boolean | null => known.has(source.name) && known.has(target.name)\n ? source.name === target.name && source.isCollection === target.isCollection && (!source.isOptional || target.isOptional) : null;\n const formatStreamId = (expression: ExpressionSyntax | null | undefined, type: TypeRefSyntax): string | null => formatSpecificationStreamId(expression, type, application);\n const eventOf = (reference: string, slice: typeof resolver.slices[number]['slice']): EventSyntax | null => {\n const declared = resolver.resolve(reference, slice).declaration;\n return declared?.node.kind === 'EventSyntax' ? declared.node : null;\n };\n const producers: Producer[] = [];\n for (const { slice } of resolver.slices) {\n for (const command of slice.commands) for (const produced of command.produces) {\n if (!resolver.isEventProduction(produced, slice)) continue;\n const event = eventOf(produced.event, slice);\n if (event === null) continue;\n const type = commandDestinationType(command, produced, application, { resolver, slice });\n producers.push({ event, command, type, route: produced.stream ?? command.stream });\n }\n for (const produced of slice.reactions.flatMap(reaction => reaction.triggers).flatMap(trigger => [...trigger.produces, ...trigger.invokes.flatMap(invocation => invocation.onRefused ?? []).flatMap(branch => branch.produces)])) {\n const event = eventOf(produced.event, slice);\n if (event !== null) producers.push({ event, command: null, type: null });\n }\n for (const capture of slice.captures) for (const appended of [...capture.appends, ...capture.children.flatMap(child => child.appends), ...capture.nested.flatMap(nested => nested.appends)]) {\n const event = eventOf(appended.event, slice);\n if (event !== null) producers.push({ event, command: null, type: null });\n }\n }\n const validationSpecifications = [\n ...exampleSpecifications.flatMap(entry => resolver.slices.filter(owner => owner.scope.join('.') === entry.scope.join('.')).map(({ slice, scope }) => ({ slice, scope, specification: entry.specification }))),\n ...resolver.slices.flatMap(({ slice, scope }) => slice.specifications.map(specification => ({ slice, scope, specification })))\n ];\n for (const { slice, scope, specification } of validationSpecifications) {\n const commands = resolver.slices.flatMap(entry => entry.slice.commands.map(command => ({ command, scope: entry.scope })));\n const parts = specification.when?.commandType.split('.') ?? [];\n const qualifiers = parts.slice(0, -1);\n const candidates = commands.filter(entry => entry.command.name === parts.at(-1) && qualifiers.every((segment, index) => entry.scope[entry.scope.length - qualifiers.length + index] === segment));\n let command: CommandSyntax | null = qualifiers.length > 0 && candidates.length === 1 ? candidates[0].command : null;\n for (let depth = scope.length; qualifiers.length === 0 && depth >= 0 && command === null; depth--) {\n const visible = candidates.filter(entry => scope.slice(0, depth).every((segment, index) => entry.scope[index] === segment));\n if (visible.length > 0) { command = visible.length === 1 ? visible[0].command : null; break; }\n }\n const occurrences = [...specification.given.map(node => ({ node, required: true, expected: false })),\n ...(specification.whenAppended === null ? [] : [{ node: specification.whenAppended, required: true, expected: false }]),\n ...specification.thenEvents.map(node => ({ node, required: false, expected: !declarationSteps.has(node) })),\n ...(specification.whenRedelivered == null ? [] : [{ node: { ...specification.whenRedelivered, kind: 'SpecificationEventSyntax' as const }, required: false, expected: false }])];\n for (const { node, required, expected } of occurrences) {\n const step = expansion.specifications.flatMap(pair => pair.steps).find(step => step.effective === node);\n const validateRoute = step?.route?.origin !== 'example';\n const validateFor = validateRoute || node.for !== step?.example?.for;\n const contextualError = (code: string, message: string, location: typeof node.location): void => {\n context.error(code, step?.example == null ? message : `${message} Example '${step.example.name}' is used here.`, step?.example == null ? location : step.authored.location);\n };\n if (node.stream == null && node.noStream == null) continue;\n if (required && node.noStream != null)\n contextualError(DiagnosticCodes.InvalidSpecificationStream, \"Expected 'stream Source.Stream', or 'no stream' on a then event.\", node.noStream.location);\n let identifier: TypeRefSyntax | null = null;\n const event = eventOf(node.eventType, slice);\n const eventProducers = producers.filter(producer => producer.event === event);\n if (node.stream != null) {\n const route = node.stream;\n const resolution = catalog.resolve(route.eventSource, route.stream);\n if (resolution.kind !== EventSourceResolutionKind.Unique) {\n const state = { ambiguous: 'Ambiguous', notFound: 'NotFound', wrongKind: 'WrongKind' }[resolution.kind];\n if (validateRoute) context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, `Stream '${route.eventSource}.${route.stream}' is ${state}; routing requires one physical source and stream.`, route.location);\n continue;\n }\n const source = resolution.sources[0];\n const stream = resolution.streams[0];\n const validateLiteral = (mapping: PropertyMappingSyntax, target: TypeRefSyntax | null): void => {\n const value = mapping.source;\n const formatted = formatStreamIdLiteral(value, target, application);\n if (formatted?.failure != null) context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, streamIdFailureMessage(formatted.failure), value.location);\n else if (value.kind !== 'LiteralExpressionSyntax' || value.value === null || target !== null && !compatible(value, target))\n context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, \"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.\", value.location);\n };\n if (!validateRoute) { /* The authored example's route is checked once at its declaration. */ }\n else if (stream.streamIdParts.length > 0)\n validateStreamIdParts(stream, route.streamIdParts, route.streamId !== null, route.location, DiagnosticCodes.InvalidSpecificationStreamRoute, context, validateLiteral);\n else if (route.streamIdParts.length > 0)\n context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, 'A streamId part block requires a composite stream.', route.location);\n else {\n if ((stream.streamId === null) !== (route.streamId === null))\n context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, stream.streamId === null ? 'An unkeyed stream cannot take a streamId mapping.' : 'This keyed stream requires a streamId mapping.', route.location);\n if (route.streamId !== null) validateLiteral(route.streamId, stream.streamId);\n }\n identifier = source.identifier;\n if (identifier === null) {\n const types = eventProducers.map(producer => producer.type);\n const distinct = new Set(types.filter(type => type !== null).map(type => `${type.name}:${type.isOptional}:${type.isCollection}`));\n if (types.length === 0 || types.some(type => type === null) || distinct.size !== 1) {\n if (validateRoute) context.error(DiagnosticCodes.InvalidSpecificationStreamEventSource, `Declare an identifier on source '${source.name}'; the event's producers do not supply one unambiguous destination type.`, route.location);\n } else identifier = types[0];\n }\n let inheritedIdentityIsInvalid = false;\n if (step?.example?.stream != null && node.for !== null && node.for === step.example.for) {\n const prior = catalog.resolve(step.example.stream.eventSource, step.example.stream.stream);\n if (prior.kind === EventSourceResolutionKind.Unique) {\n const types = eventProducers.map(producer => producer.type);\n const distinct = new Set(types.filter(type => type !== null).map(type => `${type.name}:${type.isOptional}:${type.isCollection}`));\n const priorIdentifier = prior.sources[0].identifier ?? (types.length > 0 && !types.some(type => type === null) && distinct.size === 1 ? types[0] : null);\n if (priorIdentifier !== null)\n inheritedIdentityIsInvalid = node.for.kind !== 'LiteralExpressionSyntax' || node.for.value === null || priorIdentifier.isCollection || priorIdentifier.isOptional || !compatible(node.for, priorIdentifier);\n }\n }\n if (required && node.for === null)\n contextualError(DiagnosticCodes.InvalidSpecificationStreamEventSource, \"A routed given or when append event requires 'for <literal>'.\", route.location);\n else if (validateFor && !inheritedIdentityIsInvalid && node.for !== null && (node.for.kind !== 'LiteralExpressionSyntax' || node.for.value === null || identifier !== null && (identifier.isCollection || identifier.isOptional || !compatible(node.for, identifier))))\n contextualError(DiagnosticCodes.InvalidSpecificationStreamEventSource, \"A routed event's for value must be a concrete literal compatible with the source's identifier type.\", node.for.location);\n }\n if (!expected || command === null || eventProducers.length === 0 || eventProducers.some(producer => producer.command !== command)) continue;\n let contradicts = eventProducers.every(producer => {\n const commandRoute = producer.route?.propertyCandidate === null ? producer.route : null;\n let differs = node.noStream != null ? commandRoute != null : commandRoute == null || commandRoute.eventSource !== node.stream!.eventSource || commandRoute.stream !== node.stream!.stream;\n if (!differs && node.stream != null && commandRoute != null) {\n const resolution = catalog.resolve(node.stream.eventSource, node.stream.stream);\n const stream = resolution.kind === EventSourceResolutionKind.Unique ? resolution.streams[0] : null;\n if (stream !== null && stream.streamIdParts.length > 0) {\n if (commandRoute.streamId === null && node.stream.streamId === null && commandRoute.streamIdParts.length > 0 && node.stream.streamIdParts.length > 0) {\n for (const part of stream.streamIdParts) {\n const actual = commandRoute.streamIdParts.filter(mapping => mapping.property === part.name);\n const expected = node.stream.streamIdParts.filter(mapping => mapping.property === part.name);\n if (actual.length !== 1 || expected.length !== 1) continue;\n const actualId = formatStreamId(actual[0].source, part.type);\n const expectedId = formatStreamId(expected[0].source, part.type);\n if (actualId !== null && expectedId !== null && actualId !== expectedId) differs = true;\n }\n }\n } else if (stream?.streamId != null && commandRoute.streamIdParts.length === 0 && node.stream.streamIdParts.length === 0) {\n const actualId = formatStreamId(commandRoute.streamId?.source, stream.streamId);\n const expectedId = formatStreamId(node.stream.streamId?.source, stream.streamId);\n if (actualId !== null && expectedId !== null && actualId !== expectedId) differs = true;\n }\n }\n return differs;\n });\n if (node.for?.kind === 'LiteralExpressionSyntax' && eventProducers.every(producer => producer.type !== null &&\n (identifier !== null ? nominallyCompatible(producer.type, identifier) === false : !compatible(node.for!, producer.type)))) contradicts = true;\n if (contradicts) contextualError(DiagnosticCodes.SpecificationStreamContradictsCommand, 'The expected event route contradicts its only producer, the command under test.', (node.stream ?? node.noStream)!.location);\n }\n }\n}\n"],"mappings":"k+BA0BA,SAAgB,6BAA6B,EAAgC,EAA8B,CACvG,IAAMA,EAAO,IAAIC,EAA4BC,CAAW,CAAC,CAAC,OAAO,SAAS,CAAE,WAAYC,EAAM,eAAe,QAAQ,GAAiBC,EAAc,OAAS,CAAC,CAAC,CAAC,EAChK,GAAIJ,EAAK,SAAW,EAAG,OAAO,eAAeE,EAAaG,CAAO,EACjE,IAAMC,EAAO,IAAIC,EAAc,IAAIC,EAAW,CAAC,CAAC,CAAC,EACjD,eAAeN,EAAaI,CAAI,EAChC,IAAMG,kBAAW,IAAI,IACfC,kBAAW,IAAI,IACrB,IAAK,IAAMC,KAAcL,EAAK,YAAa,CACvC,IAAMM,EAAM,KAAK,UAAU,CAACD,EAAW,KAAMA,EAAW,SAAS,KAAMA,EAAW,SAAS,KAA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EAAG,CACtH,IAAMwE,EAAW,eAAeJ,EAAa,UAAU,OAAQZ,EAAO,QAAQ,EACxEiB,EAAa,eAAezE,EAAK,OAAO,UAAU,OAAQwD,EAAO,QAAQ,EAC3EgB,IAAa,MAAQC,IAAe,MAAQD,IAAaC,IAAY,EAAU,GACvF,CACJ,CACA,OAAOJ,CACX,CAAC,EACGrE,EAAK,KAAK,OAAS,2BAA6BmD,EAAe,MAAM,GAAYC,EAAS,OAAS,OAClGF,IAAe,KAAkE,CAAC,WAAWlD,EAAK,IAAMoD,EAAS,IAAI,EAA/F,oBAAoBA,EAAS,KAAMF,CAAU,IAAM,GAA8C,IAAG,EAAc,IACzIiB,GAAa,gBAAgB9E,EAAgB,sCAAuC,mFAAoFW,EAAK,QAAUA,EAAK,SAAA,CAAW,QAAQ,CACvN,CACJ,CACJ"}
|
|
1
|
+
{"version":3,"file":"SpecificationStreamValidator.js","names":["rows","AuthoringProductionResolver","application","slice","specification","context","sink","ParserContext","LineReader","reported","distinct","diagnostic","key","row","DiagnosticCodes","value","examples","specificationExamples","expansion","expandEffectiveSpecificationExamples","resolver","declarationSteps","exampleSpecifications","entry","diagnosticText","node","catalog","EventSourceCatalog","concepts","uniqueByName","composites","properties","name","type","compatibleValue","known","source","target","formatSpecificationStreamId","expression","declared","reference","producers","command","produced","event","commandDestinationType","reaction","trigger","invocation","branch","capture","appended","child","nested","validationSpecifications","owner","commands","parts","qualifiers","candidates","index","segment","depth","scope","visible","occurrences","step","pair","validateRoute","validateFor","code","message","location","required","identifier","eventProducers","producer","route","resolution","state","stream","mapping","formatted","formatStreamIdLiteral","streamIdFailureMessage","validateStreamIdParts","types","inheritedIdentityIsInvalid","prior","priorIdentifier","expected","contradicts","commandRoute","differs","part","actual","actualId","expectedId"],"sources":["../../../../../../Compiler/Parsing/SpecificationStreamValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { diagnosticText } from '../Diagnostics/DiagnosticArgument';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { CommandSyntax } from '../Syntax/Commands';\nimport { EventSyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { CommandStreamSyntax, EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { formatSpecificationStreamId } from './SpecificationRouteComparison';\nimport { streamIdFailureMessage } from '../Syntax/StreamIdFormatter';\nimport { ExpressionSyntax } from '../Syntax/Expressions';\nimport { commandDestinationType } from './CommandDestinationTypes';\nimport { formatStreamIdLiteral } from './EventSourceValidator';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { validateStreamIdParts } from './CompositeStreamIdValidator';\nimport { ParserContext } from './ParserContext';\nimport { LineReader } from './LineReader';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\nimport { expandEffectiveSpecificationExamples, specificationExamples } from './SpecificationCommandExamples';\nimport { SpecificationEventSyntax } from '../Syntax/Specifications';\n\ninterface Producer { event: EventSyntax; command: CommandSyntax | null; type: TypeRefSyntax | null; route?: CommandStreamSyntax | null }\n\nexport function validateSpecificationStreams(application: ApplicationSyntax, context: ParserContext): void {\n const rows = new AuthoringProductionResolver(application).slices.flatMap(({ slice }) => slice.specifications.flatMap(specification => specification.cases ?? []));\n if (rows.length === 0) return validateRoutes(application, context);\n const sink = new ParserContext(new LineReader([]));\n validateRoutes(application, sink);\n const reported = new Set<string>();\n const distinct = new Set<string>();\n for (const diagnostic of sink.diagnostics) {\n const key = JSON.stringify([diagnostic.code, diagnostic.location.path, diagnostic.location.line, diagnostic.location.column, diagnostic.message]);\n if (distinct.has(key)) continue;\n distinct.add(key);\n const row = diagnostic.code === DiagnosticCodes.InvalidSpecificationStreamRoute ? rows.find(row => row.values.some(value => value.source.location.line === diagnostic.location.line && value.source.location.column === diagnostic.location.column && value.source.location.path === diagnostic.location.path)) : undefined;\n if (row === undefined) context.error(diagnostic.code, diagnostic.message, diagnostic.location, diagnostic.arguments);\n else {\n const key = JSON.stringify(diagnostic.location);\n if (!reported.has(key)) context.error(diagnostic.code, `Case '${row.name}': ${diagnostic.message}`, diagnostic.location, diagnostic.arguments);\n reported.add(key);\n }\n }\n}\n\nfunction validateRoutes(application: ApplicationSyntax, context: ParserContext): void {\n const examples = specificationExamples(application).resolvedExamples;\n const expansion = expandEffectiveSpecificationExamples(application);\n application = expansion.application;\n const resolver = new AuthoringProductionResolver(application);\n const declarationSteps = new Set<SpecificationEventSyntax>();\n const exampleSpecifications = examples.flatMap(entry => {\n if (entry.kind !== 'event') {\n if ((entry.kind === 'command' || entry.kind === 'readmodel') && (entry.example.stream != null || entry.example.noStream != null))\n context.error(DiagnosticCodes.InvalidSpecificationExampleBody, \"only event examples carry routes; a command's route comes from its declaration, and read models have none\", (entry.example.stream ?? entry.example.noStream)!.location, diagnosticText('example', entry.example.name));\n return [];\n }\n const node: SpecificationEventSyntax = { kind: 'SpecificationEventSyntax', eventType: entry.name, values: entry.example.values, for: entry.example.for, stream: entry.example.stream, noStream: entry.example.noStream, location: entry.example.location };\n declarationSteps.add(node);\n return [{ scope: entry.scope, specification: { when: null, given: [], whenAppended: null, thenEvents: [node], whenRedelivered: null } }];\n });\n const catalog = new EventSourceCatalog(application);\n const concepts = uniqueByName(application.concepts);\n const composites = uniqueByName(application.types);\n const properties = new Map([...composites].map(([name, type]) => [name, uniqueByName(type.properties)]));\n const compatible = (value: Parameters<typeof compatibleValue>[0], type: TypeRefSyntax): boolean => compatibleValue(value, type, concepts, properties);\n const known = new Set(['String', 'Uuid', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...concepts.keys(), ...composites.keys()]);\n const nominallyCompatible = (source: TypeRefSyntax, target: TypeRefSyntax): boolean | null => known.has(source.name) && known.has(target.name)\n ? source.name === target.name && source.isCollection === target.isCollection && (!source.isOptional || target.isOptional) : null;\n const formatStreamId = (expression: ExpressionSyntax | null | undefined, type: TypeRefSyntax): string | null => formatSpecificationStreamId(expression, type, application);\n const eventOf = (reference: string, slice: typeof resolver.slices[number]['slice']): EventSyntax | null => {\n const declared = resolver.resolve(reference, slice).declaration;\n return declared?.node.kind === 'EventSyntax' ? declared.node : null;\n };\n const producers: Producer[] = [];\n for (const { slice } of resolver.slices) {\n for (const command of slice.commands) for (const produced of command.produces) {\n if (!resolver.isEventProduction(produced, slice)) continue;\n const event = eventOf(produced.event, slice);\n if (event === null) continue;\n const type = commandDestinationType(command, produced, application, { resolver, slice });\n producers.push({ event, command, type, route: produced.stream ?? command.stream });\n }\n for (const produced of slice.reactions.flatMap(reaction => reaction.triggers).flatMap(trigger => [...trigger.produces, ...trigger.invokes.flatMap(invocation => invocation.onRefused ?? []).flatMap(branch => branch.produces)])) {\n const event = eventOf(produced.event, slice);\n if (event !== null) producers.push({ event, command: null, type: null });\n }\n for (const capture of slice.captures) for (const appended of [...capture.appends, ...capture.children.flatMap(child => child.appends), ...capture.nested.flatMap(nested => nested.appends)]) {\n const event = eventOf(appended.event, slice);\n if (event !== null) producers.push({ event, command: null, type: null });\n }\n }\n const validationSpecifications = [\n ...exampleSpecifications.flatMap(entry => resolver.slices.filter(owner => owner.scope.join('.') === entry.scope.join('.')).map(({ slice, scope }) => ({ slice, scope, specification: entry.specification }))),\n ...resolver.slices.flatMap(({ slice, scope }) => slice.specifications.map(specification => ({ slice, scope, specification })))\n ];\n for (const { slice, scope, specification } of validationSpecifications) {\n const commands = resolver.slices.flatMap(entry => entry.slice.commands.map(command => ({ command, scope: entry.scope })));\n const parts = specification.when?.commandType.split('.') ?? [];\n const qualifiers = parts.slice(0, -1);\n const candidates = commands.filter(entry => entry.command.name === parts.at(-1) && qualifiers.every((segment, index) => entry.scope[entry.scope.length - qualifiers.length + index] === segment));\n let command: CommandSyntax | null = qualifiers.length > 0 && candidates.length === 1 ? candidates[0].command : null;\n for (let depth = scope.length; qualifiers.length === 0 && depth >= 0 && command === null; depth--) {\n const visible = candidates.filter(entry => scope.slice(0, depth).every((segment, index) => entry.scope[index] === segment));\n if (visible.length > 0) { command = visible.length === 1 ? visible[0].command : null; break; }\n }\n const occurrences = [...specification.given.map(node => ({ node, required: true, expected: false })),\n ...(specification.whenAppended === null ? [] : [{ node: specification.whenAppended, required: true, expected: false }]),\n ...specification.thenEvents.map(node => ({ node, required: false, expected: !declarationSteps.has(node) })),\n ...(specification.whenRedelivered == null ? [] : [{ node: { ...specification.whenRedelivered, kind: 'SpecificationEventSyntax' as const }, required: false, expected: false }])];\n for (const { node, required, expected } of occurrences) {\n const step = expansion.specifications.flatMap(pair => pair.steps).find(step => step.effective === node);\n const validateRoute = step?.route?.origin !== 'example';\n const validateFor = validateRoute || node.for !== step?.example?.for;\n const contextualError = (code: string, message: string, location: typeof node.location): void => {\n context.error(code, step?.example == null ? message : `${message} Example '${step.example.name}' is used here.`, step?.example == null ? location : step.authored.location);\n };\n if (node.stream == null && node.noStream == null) continue;\n if (required && node.noStream != null)\n contextualError(DiagnosticCodes.InvalidSpecificationStream, \"Expected 'stream Source.Stream', or 'no stream' on a then event.\", node.noStream.location);\n let identifier: TypeRefSyntax | null = null;\n const event = eventOf(node.eventType, slice);\n const eventProducers = producers.filter(producer => producer.event === event);\n if (node.stream != null) {\n const route = node.stream;\n const resolution = catalog.resolve(route.eventSource, route.stream);\n if (resolution.kind !== EventSourceResolutionKind.Unique) {\n const state = { ambiguous: 'Ambiguous', notFound: 'NotFound', wrongKind: 'WrongKind' }[resolution.kind];\n if (validateRoute) context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, `Stream '${route.eventSource}.${route.stream}' is ${state}; routing requires one physical source and stream.`, route.location);\n continue;\n }\n const source = resolution.sources[0];\n const stream = resolution.streams[0];\n const validateLiteral = (mapping: PropertyMappingSyntax, target: TypeRefSyntax | null): void => {\n const value = mapping.source;\n const formatted = formatStreamIdLiteral(value, target, application);\n if (formatted?.failure != null) context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, streamIdFailureMessage(formatted.failure), value.location);\n else if (value.kind !== 'LiteralExpressionSyntax' || value.value === null || target !== null && !compatible(value, target))\n context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, \"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.\", value.location);\n };\n if (!validateRoute) { /* The authored example's route is checked once at its declaration. */ }\n else if (stream.streamIdParts.length > 0)\n validateStreamIdParts(stream, route.streamIdParts, route.streamId !== null, route.location, DiagnosticCodes.InvalidSpecificationStreamRoute, context, validateLiteral);\n else if (route.streamIdParts.length > 0)\n context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, 'A streamId part block requires a composite stream.', route.location);\n else {\n if ((stream.streamId === null) !== (route.streamId === null))\n context.error(DiagnosticCodes.InvalidSpecificationStreamRoute, stream.streamId === null ? 'An unkeyed stream cannot take a streamId mapping.' : 'This keyed stream requires a streamId mapping.', route.location);\n if (route.streamId !== null) validateLiteral(route.streamId, stream.streamId);\n }\n identifier = source.identifier;\n if (identifier === null) {\n const types = eventProducers.map(producer => producer.type);\n const distinct = new Set(types.filter(type => type !== null).map(type => `${type.name}:${type.isOptional}:${type.isCollection}`));\n if (types.length === 0 || types.some(type => type === null) || distinct.size !== 1) {\n if (validateRoute) context.error(DiagnosticCodes.InvalidSpecificationStreamEventSource, `Declare an identifier on source '${source.name}'; the event's producers do not supply one unambiguous destination type.`, route.location);\n } else identifier = types[0];\n }\n let inheritedIdentityIsInvalid = false;\n if (step?.example?.stream != null && node.for !== null && node.for === step.example.for) {\n const prior = catalog.resolve(step.example.stream.eventSource, step.example.stream.stream);\n if (prior.kind === EventSourceResolutionKind.Unique) {\n const types = eventProducers.map(producer => producer.type);\n const distinct = new Set(types.filter(type => type !== null).map(type => `${type.name}:${type.isOptional}:${type.isCollection}`));\n const priorIdentifier = prior.sources[0].identifier ?? (types.length > 0 && !types.some(type => type === null) && distinct.size === 1 ? types[0] : null);\n if (priorIdentifier !== null)\n inheritedIdentityIsInvalid = node.for.kind !== 'LiteralExpressionSyntax' || node.for.value === null || priorIdentifier.isCollection || priorIdentifier.isOptional || !compatible(node.for, priorIdentifier);\n }\n }\n if (required && node.for === null)\n contextualError(DiagnosticCodes.InvalidSpecificationStreamEventSource, \"A routed given or when append event requires 'for <literal>'.\", route.location);\n else if (validateFor && !inheritedIdentityIsInvalid && node.for !== null && (node.for.kind !== 'LiteralExpressionSyntax' || node.for.value === null || identifier !== null && (identifier.isCollection || identifier.isOptional || !compatible(node.for, identifier))))\n contextualError(DiagnosticCodes.InvalidSpecificationStreamEventSource, \"A routed event's for value must be a concrete literal compatible with the source's identifier type.\", node.for.location);\n }\n if (!expected || command === null || eventProducers.length === 0 || eventProducers.some(producer => producer.command !== command)) continue;\n let contradicts = eventProducers.every(producer => {\n const commandRoute = producer.route?.propertyCandidate === null ? producer.route : null;\n let differs = node.noStream != null ? commandRoute != null : commandRoute == null || commandRoute.eventSource !== node.stream!.eventSource || commandRoute.stream !== node.stream!.stream;\n if (!differs && node.stream != null && commandRoute != null) {\n const resolution = catalog.resolve(node.stream.eventSource, node.stream.stream);\n const stream = resolution.kind === EventSourceResolutionKind.Unique ? resolution.streams[0] : null;\n if (stream !== null && stream.streamIdParts.length > 0) {\n if (commandRoute.streamId === null && node.stream.streamId === null && commandRoute.streamIdParts.length > 0 && node.stream.streamIdParts.length > 0) {\n for (const part of stream.streamIdParts) {\n const actual = commandRoute.streamIdParts.filter(mapping => mapping.property === part.name);\n const expected = node.stream.streamIdParts.filter(mapping => mapping.property === part.name);\n if (actual.length !== 1 || expected.length !== 1) continue;\n const actualId = formatStreamId(actual[0].source, part.type);\n const expectedId = formatStreamId(expected[0].source, part.type);\n if (actualId !== null && expectedId !== null && actualId !== expectedId) differs = true;\n }\n }\n } else if (stream?.streamId != null && commandRoute.streamIdParts.length === 0 && node.stream.streamIdParts.length === 0) {\n const actualId = formatStreamId(commandRoute.streamId?.source, stream.streamId);\n const expectedId = formatStreamId(node.stream.streamId?.source, stream.streamId);\n if (actualId !== null && expectedId !== null && actualId !== expectedId) differs = true;\n }\n }\n return differs;\n });\n if (node.for?.kind === 'LiteralExpressionSyntax' && eventProducers.every(producer => producer.type !== null &&\n (identifier !== null ? nominallyCompatible(producer.type, identifier) === false : !compatible(node.for!, producer.type)))) contradicts = true;\n if (contradicts) contextualError(DiagnosticCodes.SpecificationStreamContradictsCommand, 'The expected event route contradicts its only producer, the command under test.', (node.stream ?? node.noStream)!.location);\n }\n }\n}\n"],"mappings":"A,k+BA0BA,SAAgB,6BAA6B,EAAgC,EAA8B,CACvG,IAAMA,EAAO,IAAIC,EAA4BC,CAAW,CAAC,CAAC,OAAO,SAAS,CAAE,WAAYC,EAAM,eAAe,QAAQ,GAAiBC,EAAc,OAAS,CAAC,CAAC,CAAC,EAChK,GAAIJ,EAAK,SAAW,EAAG,OAAO,eAAeE,EAAaG,CAAO,EACjE,IAAMC,EAAO,IAAIC,EAAc,IAAIC,EAAW,CAAC,CAAC,CAAC,EACjD,eAAeN,EAAaI,CAAI,EAChC,IAAMG,kBAAW,IAAI,IACfC,kBAAW,IAAI,IACrB,IAAK,IAAMC,KAAcL,EAAK,YAAa,CACvC,IAAMM,EAAM,KAAK,UAAU,CAACD,EAAW,KAAMA,EAAW,SAAS,KAAMA,EAAW,SAAS,KAAMA,EAAW,SAAS,OAAQA,EAAW,OAAO,CAAC,EAChJ,GAAID,EAAS,IAAIE,CAAG,EAAG,SACvBF,EAAS,IAAIE,CAAG,EAChB,IAAMC,EAAMF,EAAW,OAASG,EAAgB,gCAAkCd,EAAK,KAAK,GAAOa,EAAI,OAAO,KAAK,GAASE,EAAM,OAAO,SAAS,OAASJ,EAAW,SAAS,MAAQI,EAAM,OAAO,SAAS,SAAWJ,EAAW,SAAS,QAAUI,EAAM,OAAO,SAAS,OAASJ,EAAW,SAAS,IAAI,CAAC,EAAI,IAAA,GAClT,GAAIE,IAAQ,IAAA,GAAWR,EAAQ,MAAMM,EAAW,KAA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Ac,IACzIiB,GAAa,gBAAgB9E,EAAgB,sCAAuC,mFAAoFW,EAAK,QAAUA,EAAK,SAAA,CAAW,QAAQ,CACvN,CACJ,CACJ,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{parseCondition as n}from"./ConditionParser.js";import{parseDescription as r}from"./DescriptionParser.js";import{firstWord as i}from"./LineText.js";import{rejectOperationChildren as a}from"./OperationParser.js";import{locationOf as o}from"./SourceLine.js";import{parseLifecycleSpecification as s}from"./SpecificationParser.js";const c=t(`^statemachine\\s+([A-Za-z_]\\w*)$`),l=t(`^follows\\s+([A-Za-z_]\\w*)$`),u=t(`^state\\s+([A-Za-z_]\\w*)((?:\\s+(?:initial|final))*)$`),d=t(`^entering\\s+(send|start)\\s+([A-Za-z_]\\w*)$`),f=t(`^on\\s+([A-Za-z_][\\w.]*)(?:\\s+when\\s+(.+?))?\\s*->\\s*([A-Za-z_]\\w*)$`);function parseStateMachine(t,n){let u=c.exec(n.content);if(u===null)return t.error(e.InvalidStateMachineDeclaration,`Invalid state machine declaration '${n.content}' - expected 'statemachine <Name>'.`,o(n)),t.skipBlock(n.indent),{kind:`StateMachineSyntax`,name:i(n.content),follows:``,description:null,states:[],specifications:[],location:o(n)};let d=u[1],f=null,p=null,m=[],h=[],g={};for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent))switch(t.reader.takeSignificant(),i(c.content)){case`description`:f=r(t,c,f,`State machine '${d}'`),g.description??=o(c);break;case`follows`:{let n=l.exec(c.content);n===null?t.error(e.InvalidStateMachineDeclaration,`Invalid follows '${c.content}' - expected 'follows <ReadModel>'.`,o(c)):p===null?(p=n[1],g.follows=o(c)):t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' follows more than one read model.`,o(c)),a(t,c,e.InvalidStateMachineDeclaration,`A follows line cannot have children.`);break}case`state`:m.push(parseState(t,c,d));break;case`specification`:h.push(s(t,c,e.InvalidStateMachineDeclaration));break;default:t.error(e.InvalidStateMachineDeclaration,`Unexpected '${c.content}' in state machine '${d}' - expected description, follows, state or specification.`,o(c)),t.skipBlock(c.indent)}p===null&&t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' must follow a read model: 'follows <ReadModel>'.`,o(n));let _=/* @__PURE__ */ new Set;for(let n of m)_.has(n.name)&&t.error(e.InvalidStateMachineDeclaration,`State machine '${d}' declares state '${n.name}' more than once.`,n.location),_.add(n.name);return{kind:`StateMachineSyntax`,name:d,follows:p??``,description:f,states:m,specifications:h,location:o(n),directiveLocations:g}}function parseState(t,r,s){let c=u.exec(r.content);if(c===null)return t.error(e.InvalidStateMachineDeclaration,`Invalid state '${r.content}' - expected 'state <Name> [initial] [final]'.`,o(r)),t.skipBlock(r.indent),{kind:`StateSyntax`,name:``,isInitial:!1,isFinal:!1,entering:[],transitions:[],location:o(r)};let l=c[2].split(` `).filter(e=>e.length>0);l.length!==new Set(l).size&&t.error(e.InvalidStateMachineDeclaration,`State '${c[1]}' repeats a modifier.`,o(r));let p=[],m=[];for(let l=t.peekChild(r.indent);l!==void 0;l=t.peekChild(r.indent))switch(t.reader.takeSignificant(),i(l.content)){case`entering`:{let n=d.exec(l.content);n===null?t.error(e.InvalidStateMachineDeclaration,`Invalid entering '${l.content}' - expected 'entering send <Command>' or 'entering start <Workflow>'.`,o(l)):p.push({kind:`StateEntrySyntax`,entryKind:n[1]===`send`?`Send`:`Start`,target:n[2],location:o(l)}),a(t,l,e.InvalidStateMachineDeclaration,`An entering line cannot have children.`);break}case`on`:{let r=f.exec(l.content);if(r===null)t.error(e.InvalidStateMachineDeclaration,`Invalid transition '${l.content}' - expected 'on <Event> [when <condition>] -> <State>'.`,o(l));else{let e=null,i=!1;r[2]!==void 0&&(e=n(t,r[2],o(l)),i=e===null),i||m.push({kind:`StateTransitionSyntax`,event:r[1],when:e,target:r[3],location:o(l)})}a(t,l,e.InvalidStateMachineDeclaration,`A transition cannot have children.`);break}default:t.error(e.InvalidStateMachineDeclaration,`Unexpected '${l.content}' in state '${c[1]}' of '${s}' - expected entering or on.`,o(l)),t.skipBlock(l.indent)}return{kind:`StateSyntax`,name:c[1],isInitial:l.includes(`initial`),isFinal:l.includes(`final`),entering:p,transitions:m,location:o(r)}}export{parseStateMachine};
|
|
2
2
|
//# sourceMappingURL=StateMachineParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateMachineParser.js","names":["headerPattern","pattern","followsPattern","statePattern","enteringPattern","transitionPattern","match","header","context","DiagnosticCodes","locationOf","firstWord","name","description","follows","states","specifications","directiveLocations","line","parseDescription","followed","rejectOperationChildren","parseLifecycleSpecification","seen","state","modifiers","word","entering","transitions","entry","transition","when","failed","parseCondition","machine"],"sources":["../../../../../../Compiler/Parsing/StateMachineParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ConditionSyntax } from '../Syntax/Conditions';\nimport { LifecycleSpecificationSyntax, StateEntrySyntax, StateMachineSyntax, StateSyntax, StateTransitionSyntax } from '../Syntax/Lifecycles';\nimport { pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord } from './LineText';\nimport { rejectOperationChildren } from './OperationParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseLifecycleSpecification } from './SpecificationParser';\n\nconst headerPattern = pattern('^statemachine\\\\s+([A-Za-z_]\\\\w*)$');\nconst followsPattern = pattern('^follows\\\\s+([A-Za-z_]\\\\w*)$');\nconst statePattern = pattern('^state\\\\s+([A-Za-z_]\\\\w*)((?:\\\\s+(?:initial|final))*)$');\nconst enteringPattern = pattern('^entering\\\\s+(send|start)\\\\s+([A-Za-z_]\\\\w*)$');\nconst transitionPattern = pattern('^on\\\\s+([A-Za-z_][\\\\w.]*)(?:\\\\s+when\\\\s+(.+?))?\\\\s*->\\\\s*([A-Za-z_]\\\\w*)$');\n\n// The port of C# StateMachineParser.\nexport function parseStateMachine(context: ParserContext, header: SourceLine): StateMachineSyntax {\n const match = headerPattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid state machine declaration '${header.content}' - expected 'statemachine <Name>'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'StateMachineSyntax', name: firstWord(header.content), follows: '', description: null, states: [], specifications: [], location: locationOf(header) };\n }\n const name = match[1];\n let description: string | null = null;\n let follows: string | null = null;\n const states: StateSyntax[] = [];\n const specifications: LifecycleSpecificationSyntax[] = [];\n const directiveLocations: Record<string, SourceLocation> = {};\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(line.content)) {\n case 'description':\n description = parseDescription(context, line, description, `State machine '${name}'`);\n directiveLocations.description ??= locationOf(line);\n break;\n case 'follows': {\n const followed = followsPattern.exec(line.content);\n if (followed === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid follows '${line.content}' - expected 'follows <ReadModel>'.`, locationOf(line));\n else if (follows !== null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' follows more than one read model.`, locationOf(line));\n else {\n follows = followed[1];\n directiveLocations.follows = locationOf(line);\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'A follows line cannot have children.');\n break;\n }\n case 'state':\n states.push(parseState(context, line, name));\n break;\n case 'specification':\n specifications.push(parseLifecycleSpecification(context, line, DiagnosticCodes.InvalidStateMachineDeclaration));\n break;\n default:\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Unexpected '${line.content}' in state machine '${name}' - expected description, follows, state or specification.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n if (follows === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' must follow a read model: 'follows <ReadModel>'.`, locationOf(header));\n const seen = new Set<string>();\n for (const state of states) {\n if (seen.has(state.name)) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' declares state '${state.name}' more than once.`, state.location);\n seen.add(state.name);\n }\n return { kind: 'StateMachineSyntax', name, follows: follows ?? '', description, states, specifications, location: locationOf(header), directiveLocations };\n}\n\nfunction parseState(context: ParserContext, header: SourceLine, machine: string): StateSyntax {\n const match = statePattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid state '${header.content}' - expected 'state <Name> [initial] [final]'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'StateSyntax', name: '', isInitial: false, isFinal: false, entering: [], transitions: [], location: locationOf(header) };\n }\n const modifiers = match[2].split(' ').filter(word => word.length > 0);\n if (modifiers.length !== new Set(modifiers).size) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State '${match[1]}' repeats a modifier.`, locationOf(header));\n const entering: StateEntrySyntax[] = [];\n const transitions: StateTransitionSyntax[] = [];\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(line.content)) {\n case 'entering': {\n const entry = enteringPattern.exec(line.content);\n if (entry === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid entering '${line.content}' - expected 'entering send <Command>' or 'entering start <Workflow>'.`, locationOf(line));\n else entering.push({ kind: 'StateEntrySyntax', entryKind: entry[1] === 'send' ? 'Send' : 'Start', target: entry[2], location: locationOf(line) });\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'An entering line cannot have children.');\n break;\n }\n case 'on': {\n const transition = transitionPattern.exec(line.content);\n if (transition === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid transition '${line.content}' - expected 'on <Event> [when <condition>] -> <State>'.`, locationOf(line));\n else {\n let when: ConditionSyntax | null = null;\n let failed = false;\n if (transition[2] !== undefined) {\n when = parseCondition(context, transition[2], locationOf(line));\n failed = when === null;\n }\n if (!failed) transitions.push({ kind: 'StateTransitionSyntax', event: transition[1], when, target: transition[3], location: locationOf(line) });\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'A transition cannot have children.');\n break;\n }\n default:\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Unexpected '${line.content}' in state '${match[1]}' of '${machine}' - expected entering or on.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n return { kind: 'StateSyntax', name: match[1], isInitial: modifiers.includes('initial'), isFinal: modifiers.includes('final'), entering, transitions, location: locationOf(header) };\n}\n"],"mappings":"ofAgBA,MAAMA,EAAgBC,EAAQ,mCAAmC,EAC3DC,EAAiBD,EAAQ,8BAA8B,EACvDE,EAAeF,EAAQ,wDAAwD,EAC/EG,EAAkBH,EAAQ,+CAA+C,EACzEI,EAAoBJ,EAAQ,2EAA2E,EAG7G,SAAgB,kBAAkB,EAAwB,EAAwC,CAC9F,IAAMK,EAAQN,EAAc,KAAKO,EAAO,OAAO,EAC/C,GAAID,IAAU,KAGV,OAFAE,EAAQ,MAAMC,EAAgB,+BAAgC,sCAAsCF,EAAO,QAAQ,qCAAsCG,EAAWH,CAAM,CAAC,EAC3KC,EAAQ,UAAUD,EAAO,MAAM,EACxB,CAAE,KAAM,qBAAsB,KAAMI,EAAUJ,EAAO,OAAO,EAAG,QAAS,GAAI,YAAa,KAAM,OAAQ,CAAC,EAAG,eAAgB,CAAC,EAAG,SAAUG,EAAWH,CAAM,CAAE,EAEvK,IAAMK,EAAON,EAAM,GACfO,EAA6B,KAC7BC,EAAyB,K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,CAAC,EACxMS,EAAS,KAAK,CAAE,KAAM,mBAAoB,UAAWE,EAAM,KAAO,OAAS,OAAS,QAAS,OAAQA,EAAM,GAAI,SAAUnB,EAAWQ,CAAI,CAAE,CAAC,EAChJG,EAAwBb,EAASU,EAAMT,EAAgB,+BAAgC,wCAAwC,EAC/H,KACJ,CACA,IAAK,KAAM,CACP,IAAMqB,EAAazB,EAAkB,KAAKa,EAAK,OAAO,EACtD,GAAIY,IAAe,KAAMtB,EAAQ,MAAMC,EAAgB,+BAAgC,uBAAuBS,EAAK,QAAQ,0DAA2DR,EAAWQ,CAAI,CAAC,MACjM,CACD,IAAIa,EAA+B,KAC/BC,EAAS,GACTF,EAAW,KAAO,IAAA,KAClB,EAAOG,EAAezB,EAASsB,EAAW,GAAIpB,EAAWQ,CAAI,CAAC,EAC9D,EAASa,IAAS,MAEjBC,GAAQJ,EAAY,KAAK,CAAE,KAAM,wBAAyB,MAAOE,EAAW,GAAI,OAAM,OAAQA,EAAW,GAAI,SAAUpB,EAAWQ,CAAI,CAAE,CAAC,CAClJ,CACAG,EAAwBb,EAASU,EAAMT,EAAgB,+BAAgC,oCAAoC,EAC3H,KACJ,CACA,QACID,EAAQ,MAAMC,EAAgB,+BAAgC,eAAeS,EAAK,QAAQ,cAAcZ,EAAM,GAAG,QAAQ4B,EAAQ,8BAA+BxB,EAAWQ,CAAI,CAAC,EAChLV,EAAQ,UAAUU,EAAK,MAAM,CACrC,CAEJ,MAAO,CAAE,KAAM,cAAe,KAAMZ,EAAM,GAAI,UAAWmB,EAAU,SAAS,SAAS,EAAG,QAASA,EAAU,SAAS,OAAO,EAAG,WAAU,cAAa,SAAUf,EAAWH,CAAM,CAAE,CACtL"}
|
|
1
|
+
{"version":3,"file":"StateMachineParser.js","names":["headerPattern","pattern","followsPattern","statePattern","enteringPattern","transitionPattern","match","header","context","DiagnosticCodes","locationOf","firstWord","name","description","follows","states","specifications","directiveLocations","line","parseDescription","followed","rejectOperationChildren","parseLifecycleSpecification","seen","state","modifiers","word","entering","transitions","entry","transition","when","failed","parseCondition","machine"],"sources":["../../../../../../Compiler/Parsing/StateMachineParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ConditionSyntax } from '../Syntax/Conditions';\nimport { LifecycleSpecificationSyntax, StateEntrySyntax, StateMachineSyntax, StateSyntax, StateTransitionSyntax } from '../Syntax/Lifecycles';\nimport { pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { parseDescription } from './DescriptionParser';\nimport { firstWord } from './LineText';\nimport { rejectOperationChildren } from './OperationParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\nimport { parseLifecycleSpecification } from './SpecificationParser';\n\nconst headerPattern = pattern('^statemachine\\\\s+([A-Za-z_]\\\\w*)$');\nconst followsPattern = pattern('^follows\\\\s+([A-Za-z_]\\\\w*)$');\nconst statePattern = pattern('^state\\\\s+([A-Za-z_]\\\\w*)((?:\\\\s+(?:initial|final))*)$');\nconst enteringPattern = pattern('^entering\\\\s+(send|start)\\\\s+([A-Za-z_]\\\\w*)$');\nconst transitionPattern = pattern('^on\\\\s+([A-Za-z_][\\\\w.]*)(?:\\\\s+when\\\\s+(.+?))?\\\\s*->\\\\s*([A-Za-z_]\\\\w*)$');\n\n// The port of C# StateMachineParser.\nexport function parseStateMachine(context: ParserContext, header: SourceLine): StateMachineSyntax {\n const match = headerPattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid state machine declaration '${header.content}' - expected 'statemachine <Name>'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'StateMachineSyntax', name: firstWord(header.content), follows: '', description: null, states: [], specifications: [], location: locationOf(header) };\n }\n const name = match[1];\n let description: string | null = null;\n let follows: string | null = null;\n const states: StateSyntax[] = [];\n const specifications: LifecycleSpecificationSyntax[] = [];\n const directiveLocations: Record<string, SourceLocation> = {};\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(line.content)) {\n case 'description':\n description = parseDescription(context, line, description, `State machine '${name}'`);\n directiveLocations.description ??= locationOf(line);\n break;\n case 'follows': {\n const followed = followsPattern.exec(line.content);\n if (followed === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid follows '${line.content}' - expected 'follows <ReadModel>'.`, locationOf(line));\n else if (follows !== null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' follows more than one read model.`, locationOf(line));\n else {\n follows = followed[1];\n directiveLocations.follows = locationOf(line);\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'A follows line cannot have children.');\n break;\n }\n case 'state':\n states.push(parseState(context, line, name));\n break;\n case 'specification':\n specifications.push(parseLifecycleSpecification(context, line, DiagnosticCodes.InvalidStateMachineDeclaration));\n break;\n default:\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Unexpected '${line.content}' in state machine '${name}' - expected description, follows, state or specification.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n if (follows === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' must follow a read model: 'follows <ReadModel>'.`, locationOf(header));\n const seen = new Set<string>();\n for (const state of states) {\n if (seen.has(state.name)) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State machine '${name}' declares state '${state.name}' more than once.`, state.location);\n seen.add(state.name);\n }\n return { kind: 'StateMachineSyntax', name, follows: follows ?? '', description, states, specifications, location: locationOf(header), directiveLocations };\n}\n\nfunction parseState(context: ParserContext, header: SourceLine, machine: string): StateSyntax {\n const match = statePattern.exec(header.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid state '${header.content}' - expected 'state <Name> [initial] [final]'.`, locationOf(header));\n context.skipBlock(header.indent);\n return { kind: 'StateSyntax', name: '', isInitial: false, isFinal: false, entering: [], transitions: [], location: locationOf(header) };\n }\n const modifiers = match[2].split(' ').filter(word => word.length > 0);\n if (modifiers.length !== new Set(modifiers).size) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `State '${match[1]}' repeats a modifier.`, locationOf(header));\n const entering: StateEntrySyntax[] = [];\n const transitions: StateTransitionSyntax[] = [];\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(line.content)) {\n case 'entering': {\n const entry = enteringPattern.exec(line.content);\n if (entry === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid entering '${line.content}' - expected 'entering send <Command>' or 'entering start <Workflow>'.`, locationOf(line));\n else entering.push({ kind: 'StateEntrySyntax', entryKind: entry[1] === 'send' ? 'Send' : 'Start', target: entry[2], location: locationOf(line) });\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'An entering line cannot have children.');\n break;\n }\n case 'on': {\n const transition = transitionPattern.exec(line.content);\n if (transition === null) context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Invalid transition '${line.content}' - expected 'on <Event> [when <condition>] -> <State>'.`, locationOf(line));\n else {\n let when: ConditionSyntax | null = null;\n let failed = false;\n if (transition[2] !== undefined) {\n when = parseCondition(context, transition[2], locationOf(line));\n failed = when === null;\n }\n if (!failed) transitions.push({ kind: 'StateTransitionSyntax', event: transition[1], when, target: transition[3], location: locationOf(line) });\n }\n rejectOperationChildren(context, line, DiagnosticCodes.InvalidStateMachineDeclaration, 'A transition cannot have children.');\n break;\n }\n default:\n context.error(DiagnosticCodes.InvalidStateMachineDeclaration, `Unexpected '${line.content}' in state '${match[1]}' of '${machine}' - expected entering or on.`, locationOf(line));\n context.skipBlock(line.indent);\n }\n }\n return { kind: 'StateSyntax', name: match[1], isInitial: modifiers.includes('initial'), isFinal: modifiers.includes('final'),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GAAI,OAAM,OAAQA,EAAW,GAAI,SAAUpB,EAAWQ,CAAI,CAAE,CAAC,CAClJ,CACAG,EAAwBb,EAASU,EAAMT,EAAgB,+BAAgC,oCAAoC,EAC3H,KACJ,CACA,QACID,EAAQ,MAAMC,EAAgB,+BAAgC,eAAeS,EAAK,QAAQ,cAAcZ,EAAM,GAAG,QAAQ4B,EAAQ,8BAA+BxB,EAAWQ,CAAI,CAAC,EAChLV,EAAQ,UAAUU,EAAK,MAAM,CACrC,CAEJ,MAAO,CAAE,KAAM,cAAe,KAAMZ,EAAM,GAAI,UAAWmB,EAAU,SAAS,SAAS,EAAG,QAASA,EAAU,SAAS,OAAO,EAAG,WAAU,cAAa,SAAUf,EAAWH,CAAM,CAAE,CACtL,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuralInteractionSites.js","names":["sites","first","second","owners","application","node","module","placed","owner","grouped","physical","context","site","ancestor","index","kept","parts","part","duplicate","earlier","diagnostics","DiagnosticCodes","merged","uses","argument","structuralChildren","groups","group","depth","key","order","parent","keyword","entry"],"sources":["../../../../../../Compiler/Parsing/StructuralInteractionSites.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { InteractionAncestor } from './InteractionAlternatives';\nimport { InteractionUse } from './InteractionUse';\nimport { ParserContext } from './ParserContext';\n\nimport { StructuralInteractionOwner } from './StructuralInteractionOwner';\nimport { StructuralInteractionSite } from './StructuralInteractionSite';\n\n// Opaque attachments belong to effective syntax owners, not the physical document inventory.\nconst sites = new WeakMap<StructuralInteractionOwner, readonly StructuralInteractionSite[]>();\nexport const sameInteractionLocation = (first: SourceLocation, second: SourceLocation): boolean =>\n first.path === second.path && first.line === second.line && first.column === second.column;\n\nexport function recordStructuralInteractions(application: ApplicationSyntax, context: ParserContext): void {\n const owners: StructuralInteractionOwner[] = [application];\n const feature = (node: FeatureSyntax) => { owners.push(node); node.features.forEach(feature); };\n application.modules.forEach(module => { owners.push(module); module.features.forEach(feature); });\n const placed = owners.filter(owner => owner.kind !== 'ApplicationSyntax' && owner.isPlacement).at(-1) ?? application;\n const grouped = new Map<StructuralInteractionOwner, StructuralInteractionSite[]>();\n const physical = [...context.guardedInteractions, ...context.interactionUses].sort((first, second) => first.location.line - second.location.line || first.location.column - second.location.column);\n for (const site of physical) {\n const ancestor = [...site.ancestors].reverse().find(ancestor => ['module', 'feature'].includes(ancestor.keyword));\n const index = ancestor === undefined ? -1 : site.ancestors.indexOf(ancestor);\n const owner = ancestor === undefined\n ? ['behavior', 'layout'].includes(site.ancestors[0]?.keyword) ? application : placed\n : owners.find(owner => owner.kind !== 'ApplicationSyntax' && !owner.isPlacement && sameInteractionLocation(owner.location, ancestor.location)) ?? placed;\n if (!grouped.has(owner)) grouped.set(owner, []);\n grouped.get(owner)!.push({ ...site, ancestors: site.ancestors.slice(index + 1) });\n }\n for (const owner of owners) sites.set(owner, grouped.get(owner) ?? []);\n}\n\n// Called by the syntax merge with the same authored-before-placement parts it merges for each owner.\nexport function mergeStructuralInteractions<T extends StructuralInteractionOwner>(merged: T, parts: readonly T[], diagnostics?: Diagnostic[]): T {\n const kept: StructuralInteractionSite[] = [];\n for (const site of parts.flatMap(part => sites.get(part) ?? [])) {\n const duplicate = 'behavior' in site && site.ancestors.length === 0 && kept.find(earlier =>\n 'behavior' in earlier && earlier.ancestors.length === 0 && earlier.location.path !== site.location.path && useSignature(earlier) === useSignature(site));\n if (duplicate) {\n diagnostics?.push({ code: DiagnosticCodes.DuplicateBehaviorAttachment, severity: 'warning', location: site.location,\n message: `Behavior '${site.behavior}' is already attached to the ${merged.kind === 'ModuleSyntax' ? 'module' : 'feature'} '${'name' in merged ? merged.name : ''}' in '${duplicate.location.path ?? 'another file'}' - this repeated attachment is ignored` });\n } else kept.push(site);\n }\n sites.set(merged, kept);\n return merged;\n}\n\nfunction useSignature(uses: InteractionUse): string {\n return [uses.behavior, ...[...uses.arguments].sort((first, second) => first.name < second.name ? -1 : first.name > second.name ? 1 : 0).map(argument => `${argument.name}=${argument.value}`)].join('\\n');\n}\n\n// C# visits child collections, then inline bindings before uses within each owning declaration.\nconst structuralChildren: Readonly<Record<string, readonly string[]>> = {\n application: ['behavior', 'layout'],\n module: ['screen template', 'dialog', 'form', 'contribute', 'on', 'uses'],\n feature: ['contribute', 'on', 'uses'],\n layout: ['slot', 'arrangement', 'on', 'uses'],\n 'screen template': ['slot', 'arrangement', 'on', 'uses'],\n dialog: ['slot', 'arrangement', 'on', 'uses'],\n};\n\nfunction structuralOrder(group: readonly StructuralInteractionSite[], parent: string, depth = 0): readonly StructuralInteractionSite[] {\n const groups = new Map<string, { ancestor: InteractionAncestor; sites: StructuralInteractionSite[] }>();\n for (const site of group) {\n const ancestor = site.ancestors[depth] ?? { keyword: 'behavior' in site ? 'uses' : 'on', location: site.location };\n const key = JSON.stringify(ancestor.location);\n if (!groups.has(key)) groups.set(key, { ancestor, sites: [] });\n groups.get(key)!.sites.push(site);\n }\n const order = structuralChildren[parent] ?? [];\n const rank = (keyword: string) => order.includes(keyword) ? order.indexOf(keyword) : order.length;\n return [...groups.values()].sort((first, second) => rank(first.ancestor.keyword) - rank(second.ancestor.keyword))\n .flatMap(entry => ['on', 'uses'].includes(entry.ancestor.keyword) ? entry.sites : structuralOrder(entry.sites, entry.ancestor.keyword, depth + 1));\n}\n\nexport function effectiveStructuralInteractions(application: ApplicationSyntax): readonly StructuralInteractionSite[] {\n const own = (owner: StructuralInteractionOwner) => (sites.get(owner) ?? []).filter(site => !site.ancestors.some(ancestor => ancestor.keyword === 'screen'));\n const attached = (site: StructuralInteractionSite) => site.ancestors.length === 0;\n const feature = (node: FeatureSyntax): readonly StructuralInteractionSite[] => [\n ...node.features.flatMap(feature), ...structuralOrder(own(node), 'feature'),\n ];\n return [\n ...structuralOrder(own(application), 'application'),\n ...application.modules.flatMap(module => [\n ...structuralOrder(own(module).filter(site => !attached(site)), 'module'),\n ...module.features.flatMap(feature),\n ...structuralOrder(own(module).filter(attached), 'module'),\n ]),\n ];\n}\n"],"mappings":"yHAeA,MAAMA,kBAAQ,IAAI,QACL,yBAA2B,EAAuB,IAC3DC,EAAM,OAASC,EAAO,MAAQD,EAAM,OAASC,EAAO,MAAQD,EAAM,SAAWC,EAAO,OAExF,SAAgB,6BAA6B,EAAgC,EAA8B,CACvG,IAAMC,EAAuC,CAACC,CAAW,EACnD,QAAW,GAAwB,CAAED,EAAO,KAAKE,CAAI,EAAGA,EAAK,SAAS,QAAQ,OAAO,CAAG,EAC9FD,EAAY,QAAQ,QAAQ,GAAU,CAAED,EAAO,KAAKG,CAAM,EAAGA,EAAO,SAAS,QAAQ,OAAO,CAAG,CAAC,EAChG,IAAMC,EAASJ,EAAO,OAAO,GAASK,EAAM,OAAS,qBAAuBA,EAAM,WAAW,CAAC,CAAC,GAAG,EAAE,GAAKJ,EACnGK,kBAAU,IAAI,IACdC,EAAW,CAAC,GAAGC,EAAQ,oBAAqB,GAAGA,EAAQ,eAAe,CAAC,CAAC,MAAM,EAAO,IAAWV,EAAM,SAAS,KAAOC,EAAO,SAAS,MAAQD,EAAM,SAAS,OAASC,EAAO,SAAS,MAAM,EAClM,IAAK,IAAMU,KAAQF,EAAU,CACzB,IAAMG,EAAW,CAAC,GAAGD,EAAK,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,GAAY,CAAC,SAAU,SAAS,CAAC,CAAC,SAASC,EAAS,OAAO,CAAC,EAC1GC,EAAQD,IAAa,IAAA,GAAY,GAAKD,EAAK,UAAU,QAAQC,CAAQ,EACrEL,EAAQK,IAAa,IAAA,GACrB,CAAC,WAAY,QAAQ,CAAC,CAAC,SAASD,EAAK,UAAU,EAAE,EAAE,OAAO,EA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ASL,EAAQ,CAAC,CAAC,CACzJ,CAEA,SAAgB,gCAAgC,EAAsE,CAClH,IAAM,IAAO,IAAuC5B,EAAM,IAAIQ,CAAK,GAAK,CAAC,EAAA,CAAG,OAAO,GAAQ,CAACI,EAAK,UAAU,KAAK,GAAYC,EAAS,UAAY,QAAQ,CAAC,EACpJ,SAAY,GAAoCD,EAAK,UAAU,SAAW,EAC1E,QAAW,GAA8D,CAC3E,GAAGP,EAAK,SAAS,QAAQ,OAAO,EAAG,GAAG,gBAAgB,IAAIA,CAAI,EAAG,SAAS,CAC9E,EACA,MAAO,CACH,GAAG,gBAAgB,IAAID,CAAW,EAAG,aAAa,EAClD,GAAGA,EAAY,QAAQ,QAAQ,GAAU,CACrC,GAAG,gBAAgB,IAAIE,CAAM,CAAC,CAAC,OAAO,GAAQ,CAAC,SAASM,CAAI,CAAC,EAAG,QAAQ,EACxE,GAAGN,EAAO,SAAS,QAAQ,OAAO,EAClC,GAAG,gBAAgB,IAAIA,CAAM,CAAC,CAAC,OAAO,QAAQ,EAAG,QAAQ,CAC7D,CAAC,CACL,CACJ"}
|
|
1
|
+
{"version":3,"file":"StructuralInteractionSites.js","names":["sites","first","second","owners","application","node","module","placed","owner","grouped","physical","context","site","ancestor","index","kept","parts","part","duplicate","earlier","diagnostics","DiagnosticCodes","merged","uses","argument","structuralChildren","groups","group","depth","key","order","parent","keyword","entry"],"sources":["../../../../../../Compiler/Parsing/StructuralInteractionSites.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { InteractionAncestor } from './InteractionAlternatives';\nimport { InteractionUse } from './InteractionUse';\nimport { ParserContext } from './ParserContext';\n\nimport { StructuralInteractionOwner } from './StructuralInteractionOwner';\nimport { StructuralInteractionSite } from './StructuralInteractionSite';\n\n// Opaque attachments belong to effective syntax owners, not the physical document inventory.\nconst sites = new WeakMap<StructuralInteractionOwner, readonly StructuralInteractionSite[]>();\nexport const sameInteractionLocation = (first: SourceLocation, second: SourceLocation): boolean =>\n first.path === second.path && first.line === second.line && first.column === second.column;\n\nexport function recordStructuralInteractions(application: ApplicationSyntax, context: ParserContext): void {\n const owners: StructuralInteractionOwner[] = [application];\n const feature = (node: FeatureSyntax) => { owners.push(node); node.features.forEach(feature); };\n application.modules.forEach(module => { owners.push(module); module.features.forEach(feature); });\n const placed = owners.filter(owner => owner.kind !== 'ApplicationSyntax' && owner.isPlacement).at(-1) ?? application;\n const grouped = new Map<StructuralInteractionOwner, StructuralInteractionSite[]>();\n const physical = [...context.guardedInteractions, ...context.interactionUses].sort((first, second) => first.location.line - second.location.line || first.location.column - second.location.column);\n for (const site of physical) {\n const ancestor = [...site.ancestors].reverse().find(ancestor => ['module', 'feature'].includes(ancestor.keyword));\n const index = ancestor === undefined ? -1 : site.ancestors.indexOf(ancestor);\n const owner = ancestor === undefined\n ? ['behavior', 'layout'].includes(site.ancestors[0]?.keyword) ? application : placed\n : owners.find(owner => owner.kind !== 'ApplicationSyntax' && !owner.isPlacement && sameInteractionLocation(owner.location, ancestor.location)) ?? placed;\n if (!grouped.has(owner)) grouped.set(owner, []);\n grouped.get(owner)!.push({ ...site, ancestors: site.ancestors.slice(index + 1) });\n }\n for (const owner of owners) sites.set(owner, grouped.get(owner) ?? []);\n}\n\n// Called by the syntax merge with the same authored-before-placement parts it merges for each owner.\nexport function mergeStructuralInteractions<T extends StructuralInteractionOwner>(merged: T, parts: readonly T[], diagnostics?: Diagnostic[]): T {\n const kept: StructuralInteractionSite[] = [];\n for (const site of parts.flatMap(part => sites.get(part) ?? [])) {\n const duplicate = 'behavior' in site && site.ancestors.length === 0 && kept.find(earlier =>\n 'behavior' in earlier && earlier.ancestors.length === 0 && earlier.location.path !== site.location.path && useSignature(earlier) === useSignature(site));\n if (duplicate) {\n diagnostics?.push({ code: DiagnosticCodes.DuplicateBehaviorAttachment, severity: 'warning', location: site.location,\n message: `Behavior '${site.behavior}' is already attached to the ${merged.kind === 'ModuleSyntax' ? 'module' : 'feature'} '${'name' in merged ? merged.name : ''}' in '${duplicate.location.path ?? 'another file'}' - this repeated attachment is ignored` });\n } else kept.push(site);\n }\n sites.set(merged, kept);\n return merged;\n}\n\nfunction useSignature(uses: InteractionUse): string {\n return [uses.behavior, ...[...uses.arguments].sort((first, second) => first.name < second.name ? -1 : first.name > second.name ? 1 : 0).map(argument => `${argument.name}=${argument.value}`)].join('\\n');\n}\n\n// C# visits child collections, then inline bindings before uses within each owning declaration.\nconst structuralChildren: Readonly<Record<string, readonly string[]>> = {\n application: ['behavior', 'layout'],\n module: ['screen template', 'dialog', 'form', 'contribute', 'on', 'uses'],\n feature: ['contribute', 'on', 'uses'],\n layout: ['slot', 'arrangement', 'on', 'uses'],\n 'screen template': ['slot', 'arrangement', 'on', 'uses'],\n dialog: ['slot', 'arrangement', 'on', 'uses'],\n};\n\nfunction structuralOrder(group: readonly StructuralInteractionSite[], parent: string, depth = 0): readonly StructuralInteractionSite[] {\n const groups = new Map<string, { ancestor: InteractionAncestor; sites: StructuralInteractionSite[] }>();\n for (const site of group) {\n const ancestor = site.ancestors[depth] ?? { keyword: 'behavior' in site ? 'uses' : 'on', location: site.location };\n const key = JSON.stringify(ancestor.location);\n if (!groups.has(key)) groups.set(key, { ancestor, sites: [] });\n groups.get(key)!.sites.push(site);\n }\n const order = structuralChildren[parent] ?? [];\n const rank = (keyword: string) => order.includes(keyword) ? order.indexOf(keyword) : order.length;\n return [...groups.values()].sort((first, second) => rank(first.ancestor.keyword) - rank(second.ancestor.keyword))\n .flatMap(entry => ['on', 'uses'].includes(entry.ancestor.keyword) ? entry.sites : structuralOrder(entry.sites, entry.ancestor.keyword, depth + 1));\n}\n\nexport function effectiveStructuralInteractions(application: ApplicationSyntax): readonly StructuralInteractionSite[] {\n const own = (owner: StructuralInteractionOwner) => (sites.get(owner) ?? []).filter(site => !site.ancestors.some(ancestor => ancestor.keyword === 'screen'));\n const attached = (site: StructuralInteractionSite) => site.ancestors.length === 0;\n const feature = (node: FeatureSyntax): readonly StructuralInteractionSite[] => [\n ...node.features.flatMap(feature), ...structuralOrder(own(node), 'feature'),\n ];\n return [\n ...structuralOrder(own(application), 'application'),\n ...application.modules.flatMap(module => [\n ...structuralOrder(own(module).filter(site => !attached(site)), 'module'),\n ...module.features.flatMap(feature),\n ...structuralOrder(own(module).filter(attached), 'module'),\n ]),\n ];\n}\n"],"mappings":"A,yHAeA,MAAMA,kBAAQ,IAAI,QACL,yBAA2B,EAAuB,IAC3DC,EAAM,OAASC,EAAO,MAAQD,EAAM,OAASC,EAAO,MAAQD,EAAM,SAAWC,EAAO,OAExF,SAAgB,6BAA6B,EAAgC,EAA8B,CACvG,IAAMC,EAAuC,CAACC,CAAW,EACnD,QAAW,GAAwB,CAAED,EAAO,KAAKE,CAAI,EAAGA,EAAK,SAAS,QAAQ,OAAO,CAAG,EAC9FD,EAAY,QAAQ,QAAQ,GAAU,CAAED,EAAO,KAAKG,CAAM,EAAGA,EAAO,SAAS,QAAQ,OAAO,CAAG,CAAC,EAChG,IAAMC,EAASJ,EAAO,OAAO,GAASK,EAAM,OAAS,qBAAuBA,EAAM,WAAW,CAAC,CAAC,GAAG,EAAE,GAAKJ,EACnGK,kBAAU,IAAI,IACdC,EAAW,CAAC,GAAGC,EAAQ,oBAAqB,GAAGA,EAAQ,eAAe,CAAC,CAAC,MAAM,EAAO,IAAWV,EAAM,SAAS,KAAOC,EAAO,SAAS,MAAQD,EAAM,SAAS,OAASC,EAAO,SAAS,MAAM,EAClM,IAAK,IAAMU,KAAQF,EAAU,CACzB,IAAMG,EAAW,CAAC,GAAGD,EAAK,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,GAAY,CAAC,SAAU,SAAS,CAAC,CAAC,SA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,SAAS,OAAO,EAAI,KAAKC,EAAO,SAAS,OAAO,CAAC,CAAC,CAC5G,QAAQ,GAAS,CAAC,KAAM,MAAM,CAAC,CAAC,SAAS+B,EAAM,SAAS,OAAO,EAAIA,EAAM,MAAQ,gBAAgBA,EAAM,MAAOA,EAAM,SAAS,QAASL,EAAQ,CAAC,CAAC,CACzJ,CAEA,SAAgB,gCAAgC,EAAsE,CAClH,IAAM,IAAO,IAAuC5B,EAAM,IAAIQ,CAAK,GAAK,CAAC,EAAA,CAAG,OAAO,GAAQ,CAACI,EAAK,UAAU,KAAK,GAAYC,EAAS,UAAY,QAAQ,CAAC,EACpJ,SAAY,GAAoCD,EAAK,UAAU,SAAW,EAC1E,QAAW,GAA8D,CAC3E,GAAGP,EAAK,SAAS,QAAQ,OAAO,EAAG,GAAG,gBAAgB,IAAIA,CAAI,EAAG,SAAS,CAC9E,EACA,MAAO,CACH,GAAG,gBAAgB,IAAID,CAAW,EAAG,aAAa,EAClD,GAAGA,EAAY,QAAQ,QAAQ,GAAU,CACrC,GAAG,gBAAgB,IAAIE,CAAM,CAAC,CAAC,OAAO,GAAQ,CAAC,SAASM,CAAI,CAAC,EAAG,QAAQ,EACxE,GAAGN,EAAO,SAAS,QAAQ,OAAO,EAClC,GAAG,gBAAgB,IAAIA,CAAM,CAAC,CAAC,OAAO,QAAQ,EAAG,QAAQ,CAC7D,CAAC,CACL,CACJ,C"}
|
|
@@ -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{dotNetWhitespace as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{parseLiteral as i,parseMappingSource as a}from"./ExpressionParser.js";import{unescapeIdentifier as o}from"./LineText.js";import{locationOf as s}from"./SourceLine.js";const c=`item`,l=`none`,u=`empty`,d=`@?[\\p{L}_][\\p{L}\\p{N}_]*`,f=RegExp(`^(?<name>${d}(?:\\.${d})*)(?:${t}+(?<marker>none|empty))?$`,`u`),p=RegExp(`^(?<name>${d}|"${n}")(?:${t}*=${t}*(?<value>\\S.*)|(?:${t}+(?<marker>none|empty))?)$`,`u`),markerOf=e=>e.groups?.marker;function trailingMarker(e){return e.endsWith(` none`)?l:e.endsWith(` empty`)?u:void 0}function tryParseStructuredMapping(e,t){let n=f.exec(t.content);if(!(n===null||n.groups.name===`streamId`||markerOf(n)===void 0&&e.peekChild(t.indent)===void 0))return{kind:`PropertyMappingSyntax`,property:o(n.groups.name),source:parseStructuredValue(e,t,markerOf(n)),location:s(t)}}function parseStructuredValue(t,n,r){let i=s(n);if(r===`none`)return rejectChildren(t,n,`An empty list ('none') has no lines under it.`),{kind:`ListExpressionSyntax`,items:[],location:i};if(r===`empty`)return rejectChildren(t,n,`An object without members ('empty') has no lines under it.`),{kind:`ObjectExpressionSyntax`,members:[],location:i};let a=t.peekChild(n.indent);return a===void 0?(t.error(e.InvalidStructuredValue,`'${n.content}' opens a structured value - indent its 'member = value' lines or 'item' lines under it, or end it in 'none' for an empty list or 'empty' for an object without members`,i),{kind:`ObjectExpressionSyntax`,members:[],location:i}):isItem(a.content)?parseList(t,n):parseObject(t,n)}function parseStructuredScalar(t,n,r){if(n.startsWith(`{`)||n.startsWith(`[`))return a(n,r,t);if(n.startsWith(`case.`))return t.error(e.InvalidSpecificationCaseReference,`A case reference fills a whole value position; it cannot occur inside a structured value or expression.`,r),{kind:`RawExpressionSyntax`,text:n,location:r};let o=i(n,r,t);return o===void 0?(t.error(e.InvalidStructuredValue,`Expected a string, number, true, false or null in a structured value, got '${n}'`,r),{kind:`RawExpressionSyntax`,text:n,location:r}):o}const isItem=e=>e===`item`||e.startsWith(`item `)&&!e.substring(4).trimStart().startsWith(`=`),at=(e,t)=>({...s(e),column:s(e).column+t});function parseList(t,n){let r=[];for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent)){if(t.reader.takeSignificant(),!isItem(i.content)){t.error(e.InvalidStructuredValue,`A list holds one 'item' line per element, got '${i.content}'`,s(i)),t.skipBlock(i.indent);continue}let n=i.content.substring(4).trimStart();n.length===0?r.push(parseStructuredValue(t,i,void 0)):n===`none`||n===`empty`?r.push(parseStructuredValue(t,i,n)):(r.push(parseStructuredScalar(t,n,at(i,i.content.length-n.length))),rejectChildren(t,i,`An 'item' with a value has no lines under it.`))}return{kind:`ListExpressionSyntax`,items:r,location:s(n)}}function parseObject(t,n){let i=[],a=/* @__PURE__ */ new Set;for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent)){t.reader.takeSignificant();let n=p.exec(c.content);if(n===null){t.error(e.InvalidStructuredValue,isItem(c.content)?`An object holds 'member = value' lines; an 'item' line belongs in a list, got '${c.content}'`:`Expected 'member = value', a member opening an indented block, 'member none' or 'member empty', got '${c.content}'`,s(c)),t.skipBlock(c.indent);continue}let l=n.groups.name,u=l.startsWith(`"`)?r(l.substring(1,l.length-1)):o(l),d;n.groups.value===void 0?d=parseStructuredValue(t,c,markerOf(n)):(d=parseStructuredScalar(t,n.groups.value,at(c,c.content.length-n.groups.value.length)),rejectChildren(t,c,`A member with a value has no lines under it.`)),a.has(u)?t.error(e.DuplicateStructuredValueMember,`Duplicate property '${u}' in structured value`,s(c)):(a.add(u),i.push({kind:`ObjectMemberSyntax`,name:u,value:d,location:s(c)}))}return{kind:`ObjectExpressionSyntax`,members:i,location:s(n)}}function rejectChildren(t,n,r){let i=t.peekChild(n.indent);i!==void 0&&(t.error(e.InvalidStructuredValue,r,s(i)),t.skipBlock(n.indent))}export{u as emptyKeyword,c as itemKeyword,markerOf,l as noneKeyword,parseStructuredScalar,parseStructuredValue,trailingMarker,tryParseStructuredMapping};
|
|
2
2
|
//# sourceMappingURL=StructuredBlockParser.js.map
|