@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{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{sourceStreamPattern as i}from"../Text/SourceStreamNames.js";import{parseCanvasPair as a}from"./CanvasPlacement.js";import{parseDescription as o}from"./DescriptionParser.js";import{parseMappingSource as s}from"./ExpressionParser.js";import{firstWord as c}from"./LineText.js";import{parseTypeRef as l,reportLegacyOptionalSuffix as u}from"./PropertyLineParser.js";import{locationOf as d}from"./SourceLine.js";const f=r(`^id\\s+"(${t})"$`),p=i(`^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`),m=i(`^eventsource\\s+([A-Za-z_]\\w*)$`),h=i(`^stream\\s+([A-Za-z_]\\w*)$`);function parseEventSource(e,t){let n=m.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'eventsource <Name>'.`);let r=[],i=null,s=null,l=null,u=null;for(let d=e.peekChild(t.indent);d!==void 0;d=e.peekChild(t.indent))switch(e.reader.takeSignificant(),c(d.content)){case`position`:u=a(e,d,`position`,`x`,`y`,u,!0)??u;break;case`stream`:r.push(parseEventStream(e,d));break;case`identifier`:i=parseType(e,d,`identifier`,i);break;case`description`:s=o(e,d,s,`Event source '${n}'`,!0);break;case`id`:l=parsePin(e,d,n,l);break;default:invalid(e,d,`An event source accepts description, id, identifier, position and stream declarations.`),e.skipBlock(d.indent)}return{kind:`EventSourceSyntax`,name:n,streams:r,identifier:i,description:s,id:l,...u===null?{}:{x:u[0],y:u[1]},location:d(t)}}function parseEventStream(e,t){let n=h.exec(t.content)?.[1]??``;n===``&&invalid(e,t,`Expected 'stream <Name>'.`);let r=null,i=[],a=!1,s={},l=null,u=null;for(let f=e.peekChild(t.indent);f!==void 0;f=e.peekChild(t.indent))switch(e.reader.takeSignificant(),c(f.content)){case`streamId`:a?(invalid(e,f,`Declare either one 'streamId <Type>' or one streamId part block.`),e.skipBlock(f.indent)):f.content===`streamId`?(a=!0,s.streamId=d(f),i=parseStreamIdParts(e,f)):(r=parseType(e,f,`streamId`,r),a=r!==null);break;case`description`:l=o(e,f,l,`Stream '${n}'`,!0);break;case`id`:u=parsePin(e,f,n,u);break;default:invalid(e,f,`A stream accepts description, id and streamId declarations.`),e.skipBlock(f.indent)}return{kind:`EventStreamSyntax`,name:n,streamId:r,streamIdParts:i,description:l,id:u,directiveLocations:s,location:d(t)}}function parseType(t,n,r,i){let a=p.exec(n.content);return a===null||i!==null?invalid(t,n,`Declare at most one '${r} <Type>'.`):(i=l(a[2],{...d(n),column:n.indent+1+n.content.indexOf(a[2],r.length)}),u(t,i,n)),rejectChildren(t,n,e.InvalidEventSourceDeclaration),i}function parsePin(t,r,i,a){let o=f.exec(r.content),s=o===null?null:n(o[1]);return s===null||s.trim()===``||a!==null?invalid(t,r,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(a=s,s===i&&t.information(e.RedundantSourceStreamId,`The rename pin repeats the current name; omit it for a new declaration.`,d(r))),rejectChildren(t,r,e.InvalidEventSourceDeclaration),a}function parseCommandStream(t,n,r,i){let[a,o]=r.type.name.split(`.`),c={kind:`CommandStreamSyntax`,eventSource:a,stream:o,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:r.type.location,referenceLength:r.type.name.length,location:d(n)};if(i)return t.error(e.AmbiguousCommandStream,`'${n.content}' has both a property type and a stream route interpretation; neither is selected.`,d(n)),{...c,propertyCandidate:r};let l=null,u=[],f=!1,p={};for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),r.content===`streamId`){l!==null||f?(t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,d(r)),t.skipBlock(r.indent)):(f=!0,p.streamId=d(r),u=parseRouteParts(t,r,e.InvalidCommandStream));continue}let n=/^streamId\s*=\s*(.+)$/.exec(r.content);if(n===null||l!==null||f)t.error(e.InvalidCommandStream,`Declare either one 'streamId = <source>' mapping or one streamId part block.`,d(r)),t.skipBlock(r.indent);else{let i={...d(r),column:r.indent+1+r.content.indexOf(n[1],r.content.indexOf(`=`)+1)};l={kind:`PropertyMappingSyntax`,property:`streamId`,source:s(n[1],i,t),location:d(r)},rejectChildren(t,r,e.InvalidCommandStream)}}return{...c,streamId:l,streamIdParts:u,directiveLocations:p}}function parseStreamIdParts(t,n){let r=[],a=i(`^([A-Za-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$`);for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent)){t.reader.takeSignificant();let n=a.exec(i.content);if(n===null){invalid(t,i,`Expected '<part> <Type>' without modifiers in a streamId part block.`),t.skipBlock(i.indent);continue}let o=l(n[2],{...d(i),column:i.indent+1+i.content.indexOf(n[2],n[1].length)});u(t,o,i),r.push({kind:`EventStreamIdPartSyntax`,name:n[1],type:o,location:d(i)}),rejectChildren(t,i,e.InvalidEventSourceDeclaration)}return r.length===0&&invalid(t,n,`A streamId part block cannot be empty.`),r}function parseRouteParts(e,t,n){let r=[],a=i(`^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$`);for(let i=e.peekChild(t.indent);i!==void 0;i=e.peekChild(t.indent)){e.reader.takeSignificant();let t=a.exec(i.content);if(t===null){e.error(n,`Expected '<part> = <source>' in a streamId part block.`,d(i)),e.skipBlock(i.indent);continue}let o={...d(i),column:i.indent+1+i.content.indexOf(t[2],i.content.indexOf(`=`)+1)};r.push({kind:`PropertyMappingSyntax`,property:t[1],source:s(t[2],o,e),location:d(i)}),rejectChildren(e,i,n)}return r.length===0&&e.error(n,`A streamId part block cannot be empty.`,d(t)),r}function rejectChildren(e,t,n){let r=e.peekChild(t.indent);r!==void 0&&(e.error(n,`This directive cannot have children.`,d(r)),e.skipBlock(t.indent))}function invalid(t,n,r){t.error(e.InvalidEventSourceDeclaration,r,d(n))}export{parseCommandStream,parseEventSource,parseRouteParts};
|
|
2
2
|
//# sourceMappingURL=EventSourceParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventSourceParser.js","names":["pinPattern","pattern","stringBodyPattern","typeDirective","sourceStreamPattern","sourceHeader","streamHeader","name","header","context","streams","identifier","description","id","position","child","firstWord","parseCanvasPair","parseDescription","locationOf","streamId","streamIdParts","declared","directiveLocations","match","line","previous","keyword","parseTypeRef","reportLegacyOptionalSuffix","DiagnosticCodes","value","unescapeString","eventSource","stream","candidate","route","ambiguous","block","location","parseMappingSource","parts","declaration","type","mapping","code","message"],"sources":["../../../../../../Compiler/Parsing/EventSourceParser.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 { TypeRefSyntax, PropertySyntax } from '../Syntax/Declarations';\nimport { CommandStreamSyntax, EventSourceSyntax, EventStreamSyntax, EventStreamIdPartSyntax } from '../Syntax/EventSources';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { parseCanvasPair } from './CanvasPlacement';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseTypeRef, reportLegacyOptionalSuffix } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst pinPattern = pattern(`^id\\\\s+\"(${stringBodyPattern})\"$`);\nconst typeDirective = sourceStreamPattern('^(identifier|streamId)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\nconst sourceHeader = sourceStreamPattern('^eventsource\\\\s+([A-Za-z_]\\\\w*)$');\nconst streamHeader = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*)$');\n\nexport function parseEventSource(context: ParserContext, header: SourceLine): EventSourceSyntax {\n const name = sourceHeader.exec(header.content)?.[1] ?? '';\n if (name === '') invalid(context, header, \"Expected 'eventsource <Name>'.\");\n const streams: EventStreamSyntax[] = [];\n let identifier: TypeRefSyntax | null = null;\n let description: string | null = null;\n let id: string | null = null;\n let position: readonly [number, number] | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'position': position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position; break;\n case 'stream': streams.push(parseEventStream(context, child)); break;\n case 'identifier': identifier = parseType(context, child, 'identifier', identifier); break;\n case 'description': description = parseDescription(context, child, description, `Event source '${name}'`, true); break;\n case 'id': id = parsePin(context, child, name, id); break;\n default: invalid(context, child, 'An event source accepts description, id, identifier, position and stream declarations.'); context.skipBlock(child.indent); break;\n }\n }\n return { kind: 'EventSourceSyntax', name, streams, identifier, description, id, ...(position === null ? {} : { x: position[0], y: position[1] }), location: locationOf(header) };\n}\n\nfunction parseEventStream(context: ParserContext, header: SourceLine): EventStreamSyntax {\n const name = streamHeader.exec(header.content)?.[1] ?? '';\n if (name === '') invalid(context, header, \"Expected 'stream <Name>'.\");\n let streamId: TypeRefSyntax | null = null;\n let streamIdParts: EventStreamIdPartSyntax[] = [];\n let declared = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n let description: string | null = null;\n let id: string | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'streamId':\n if (declared) {\n invalid(context, child, \"Declare either one 'streamId <Type>' or one streamId part block.\");\n context.skipBlock(child.indent);\n } else if (child.content === 'streamId') {\n declared = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseStreamIdParts(context, child);\n } else {\n streamId = parseType(context, child, 'streamId', streamId);\n declared = streamId !== null;\n }\n break;\n case 'description': description = parseDescription(context, child, description, `Stream '${name}'`, true); break;\n case 'id': id = parsePin(context, child, name, id); break;\n default: invalid(context, child, 'A stream accepts description, id and streamId declarations.'); context.skipBlock(child.indent); break;\n }\n }\n return { kind: 'EventStreamSyntax', name, streamId, streamIdParts, description, id, directiveLocations, location: locationOf(header) };\n}\n\nfunction parseType(context: ParserContext, line: SourceLine, keyword: string, previous: TypeRefSyntax | null): TypeRefSyntax | null {\n const match = typeDirective.exec(line.content);\n if (match === null || previous !== null) invalid(context, line, `Declare at most one '${keyword} <Type>'.`);\n else {\n previous = parseTypeRef(match[2], { ...locationOf(line), column: line.indent + 1 + line.content.indexOf(match[2], keyword.length) });\n reportLegacyOptionalSuffix(context, previous, line);\n }\n rejectChildren(context, line, DiagnosticCodes.InvalidEventSourceDeclaration);\n return previous;\n}\n\nfunction parsePin(context: ParserContext, line: SourceLine, name: string, previous: string | null): string | null {\n const match = pinPattern.exec(line.content);\n const value = match === null ? null : unescapeString(match[1]);\n if (value === null || value.trim() === '' || previous !== null) invalid(context, line, 'Declare at most one nonempty rename-only \\'id \"<old-name>\"\\'.');\n else {\n previous = value;\n if (value === name) context.information(DiagnosticCodes.RedundantSourceStreamId, 'The rename pin repeats the current name; omit it for a new declaration.', locationOf(line));\n }\n rejectChildren(context, line, DiagnosticCodes.InvalidEventSourceDeclaration);\n return previous;\n}\n\nexport function parseCommandStream(context: ParserContext, header: SourceLine, candidate: PropertySyntax, ambiguous: boolean): CommandStreamSyntax {\n const [eventSource, stream] = candidate.type.name.split('.');\n const route: CommandStreamSyntax = { kind: 'CommandStreamSyntax', eventSource, stream, streamId: null, streamIdParts: [], propertyCandidate: null, referenceLocation: candidate.type.location, referenceLength: candidate.type.name.length, location: locationOf(header) };\n if (ambiguous) {\n context.error(DiagnosticCodes.AmbiguousCommandStream, `'${header.content}' has both a property type and a stream route interpretation; neither is selected.`, locationOf(header));\n // Ordinary properties are leaves; preserve deeper legacy command members in this case.\n return { ...route, propertyCandidate: candidate };\n }\n let streamId: PropertyMappingSyntax | null = null;\n let streamIdParts: PropertyMappingSyntax[] = [];\n let block = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'streamId') {\n if (streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Declare either one 'streamId = <source>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n block = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseRouteParts(context, child, DiagnosticCodes.InvalidCommandStream);\n }\n continue;\n }\n const match = /^streamId\\s*=\\s*(.+)$/.exec(child.content);\n if (match === null || streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Declare either one 'streamId = <source>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[1], child.content.indexOf('=') + 1) };\n streamId = { kind: 'PropertyMappingSyntax', property: 'streamId', source: parseMappingSource(match[1], location, context), location: locationOf(child) };\n rejectChildren(context, child, DiagnosticCodes.InvalidCommandStream);\n }\n }\n return { ...route, streamId, streamIdParts, directiveLocations };\n}\n\nfunction parseStreamIdParts(context: ParserContext, header: SourceLine): EventStreamIdPartSyntax[] {\n const parts: EventStreamIdPartSyntax[] = [];\n const declaration = sourceStreamPattern('^([A-Za-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = declaration.exec(child.content);\n if (match === null) {\n invalid(context, child, \"Expected '<part> <Type>' without modifiers in a streamId part block.\");\n context.skipBlock(child.indent);\n continue;\n }\n const type = parseTypeRef(match[2], { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[2], match[1].length) });\n reportLegacyOptionalSuffix(context, type, child);\n parts.push({ kind: 'EventStreamIdPartSyntax', name: match[1], type, location: locationOf(child) });\n rejectChildren(context, child, DiagnosticCodes.InvalidEventSourceDeclaration);\n }\n if (parts.length === 0) invalid(context, header, 'A streamId part block cannot be empty.');\n return parts;\n}\n\nexport function parseRouteParts(context: ParserContext, header: SourceLine, code: string): PropertyMappingSyntax[] {\n const parts: PropertyMappingSyntax[] = [];\n const mapping = sourceStreamPattern('^([A-Za-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = mapping.exec(child.content);\n if (match === null) {\n context.error(code, \"Expected '<part> = <source>' in a streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[2], child.content.indexOf('=') + 1) };\n parts.push({ kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], location, context), location: locationOf(child) });\n rejectChildren(context, child, code);\n }\n if (parts.length === 0) context.error(code, 'A streamId part block cannot be empty.', locationOf(header));\n return parts;\n}\n\nfunction rejectChildren(context: ParserContext, line: SourceLine, code: string): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'This directive cannot have children.', locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n\nfunction invalid(context: ParserContext, line: SourceLine, message: string): void { context.error(DiagnosticCodes.InvalidEventSourceDeclaration, message, locationOf(line)); }\n"],"mappings":"qpBAkBA,MAAMA,EAAaC,EAAQ,YAAYC,EAAkB,IAAI,EACvDC,EAAgBC,EAAoB,sEAAsE,EAC1GC,EAAeD,EAAoB,kCAAkC,EACrEE,EAAeF,EAAoB,6BAA6B,EAEtE,SAAgB,iBAAiB,EAAwB,EAAuC,CAC5F,IAAMG,EAAOF,EAAa,KAAKG,EAAO,OAAO,CAAC,GAAG,IAAM,GACnDD,IAAS,IAAI,QAAQE,EAASD,EAAQ,gCAAgC,EAC1E,IAAME,EAA+B,CAAC,EAClCC,EAAmC,KACnCC,EAA6B,KAC7BC,EAAoB,KACpBC,EAA6C,KACjD,IAAK,IAAIC,EAAQN,EAAQ,UAAUD,EAAO,MAAM,EAAGO,IAAU,IAAA,GAAW,EAAQN,EAAQ,UAAUD,EAAO,MAAM,EAE3G,OADAC,EAAQ,OAAO,gBAAgB,EACvBO,EAAUD,EAAM,OAAO,EAA/B,CACI,IAAK,WAAY,EAAWE,EAAgBR,EAASM,EAAO,WAAY,IAAK,IAAKD,EAAU,EAAI,GAAKA,EAAU,MAC/G,IAAK,SAAUJ,EAAQ,KAAK,iBAAiBD,E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AM,EAAG,CAC9GC,EAAQ,OAAO,gBAAgB,EAC/B,IAAMe,EAAQoB,EAAQ,KAAK7B,EAAM,OAAO,EACxC,GAAIS,IAAU,KAAM,CAChBf,EAAQ,MAAMoC,EAAM,yDAA0D1B,EAAWJ,CAAK,CAAC,EAC/FN,EAAQ,UAAUM,EAAM,MAAM,EAC9B,QACJ,CACA,IAAMwB,EAAW,CAAE,GAAGpB,EAAWJ,CAAK,EAAG,OAAQA,EAAM,OAAS,EAAIA,EAAM,QAAQ,QAAQS,EAAM,GAAIT,EAAM,QAAQ,QAAQ,GAAG,EAAI,CAAC,CAAE,EACpI0B,EAAM,KAAK,CAAE,KAAM,wBAAyB,SAAUjB,EAAM,GAAI,OAAQgB,EAAmBhB,EAAM,GAAIe,EAAU9B,CAAO,EAAG,SAAUU,EAAWJ,CAAK,CAAE,CAAC,EACtJ,eAAeN,EAASM,EAAO8B,CAAI,CACvC,CAEA,OADIJ,EAAM,SAAW,GAAGhC,EAAQ,MAAMoC,EAAM,yCAA0C1B,EAAWX,CAAM,CAAC,EACjGiC,CACX,CAEA,SAAS,eAAe,EAAwB,EAAkB,EAAoB,CAClF,IAAM1B,EAAQN,EAAQ,UAAUgB,EAAK,MAAM,EACvCV,IAAU,IAAA,KACVN,EAAQ,MAAMoC,EAAM,uCAAwC1B,EAAWJ,CAAK,CAAC,EAC7EN,EAAQ,UAAUgB,EAAK,MAAM,EAErC,CAEA,SAAS,QAAQ,EAAwB,EAAkB,EAAuB,CAAEhB,EAAQ,MAAMqB,EAAgB,8BAA+BgB,EAAS3B,EAAWM,CAAI,CAAC,CAAG"}
|
|
1
|
+
{"version":3,"file":"EventSourceParser.js","names":["pinPattern","pattern","stringBodyPattern","typeDirective","sourceStreamPattern","sourceHeader","streamHeader","name","header","context","streams","identifier","description","id","position","child","firstWord","parseCanvasPair","parseDescription","locationOf","streamId","streamIdParts","declared","directiveLocations","match","line","previous","keyword","parseTypeRef","reportLegacyOptionalSuffix","DiagnosticCodes","value","unescapeString","eventSource","stream","candidate","route","ambiguous","block","location","parseMappingSource","parts","declaration","type","mapping","code","message"],"sources":["../../../../../../Compiler/Parsing/EventSourceParser.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 { TypeRefSyntax, PropertySyntax } from '../Syntax/Declarations';\nimport { CommandStreamSyntax, EventSourceSyntax, EventStreamSyntax, EventStreamIdPartSyntax } from '../Syntax/EventSources';\nimport { PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { sourceStreamPattern } from '../Text/SourceStreamNames';\nimport { parseCanvasPair } from './CanvasPlacement';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseTypeRef, reportLegacyOptionalSuffix } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst pinPattern = pattern(`^id\\\\s+\"(${stringBodyPattern})\"$`);\nconst typeDirective = sourceStreamPattern('^(identifier|streamId)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\nconst sourceHeader = sourceStreamPattern('^eventsource\\\\s+([A-Za-z_]\\\\w*)$');\nconst streamHeader = sourceStreamPattern('^stream\\\\s+([A-Za-z_]\\\\w*)$');\n\nexport function parseEventSource(context: ParserContext, header: SourceLine): EventSourceSyntax {\n const name = sourceHeader.exec(header.content)?.[1] ?? '';\n if (name === '') invalid(context, header, \"Expected 'eventsource <Name>'.\");\n const streams: EventStreamSyntax[] = [];\n let identifier: TypeRefSyntax | null = null;\n let description: string | null = null;\n let id: string | null = null;\n let position: readonly [number, number] | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'position': position = parseCanvasPair(context, child, 'position', 'x', 'y', position, true) ?? position; break;\n case 'stream': streams.push(parseEventStream(context, child)); break;\n case 'identifier': identifier = parseType(context, child, 'identifier', identifier); break;\n case 'description': description = parseDescription(context, child, description, `Event source '${name}'`, true); break;\n case 'id': id = parsePin(context, child, name, id); break;\n default: invalid(context, child, 'An event source accepts description, id, identifier, position and stream declarations.'); context.skipBlock(child.indent); break;\n }\n }\n return { kind: 'EventSourceSyntax', name, streams, identifier, description, id, ...(position === null ? {} : { x: position[0], y: position[1] }), location: locationOf(header) };\n}\n\nfunction parseEventStream(context: ParserContext, header: SourceLine): EventStreamSyntax {\n const name = streamHeader.exec(header.content)?.[1] ?? '';\n if (name === '') invalid(context, header, \"Expected 'stream <Name>'.\");\n let streamId: TypeRefSyntax | null = null;\n let streamIdParts: EventStreamIdPartSyntax[] = [];\n let declared = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n let description: string | null = null;\n let id: string | null = null;\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'streamId':\n if (declared) {\n invalid(context, child, \"Declare either one 'streamId <Type>' or one streamId part block.\");\n context.skipBlock(child.indent);\n } else if (child.content === 'streamId') {\n declared = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseStreamIdParts(context, child);\n } else {\n streamId = parseType(context, child, 'streamId', streamId);\n declared = streamId !== null;\n }\n break;\n case 'description': description = parseDescription(context, child, description, `Stream '${name}'`, true); break;\n case 'id': id = parsePin(context, child, name, id); break;\n default: invalid(context, child, 'A stream accepts description, id and streamId declarations.'); context.skipBlock(child.indent); break;\n }\n }\n return { kind: 'EventStreamSyntax', name, streamId, streamIdParts, description, id, directiveLocations, location: locationOf(header) };\n}\n\nfunction parseType(context: ParserContext, line: SourceLine, keyword: string, previous: TypeRefSyntax | null): TypeRefSyntax | null {\n const match = typeDirective.exec(line.content);\n if (match === null || previous !== null) invalid(context, line, `Declare at most one '${keyword} <Type>'.`);\n else {\n previous = parseTypeRef(match[2], { ...locationOf(line), column: line.indent + 1 + line.content.indexOf(match[2], keyword.length) });\n reportLegacyOptionalSuffix(context, previous, line);\n }\n rejectChildren(context, line, DiagnosticCodes.InvalidEventSourceDeclaration);\n return previous;\n}\n\nfunction parsePin(context: ParserContext, line: SourceLine, name: string, previous: string | null): string | null {\n const match = pinPattern.exec(line.content);\n const value = match === null ? null : unescapeString(match[1]);\n if (value === null || value.trim() === '' || previous !== null) invalid(context, line, 'Declare at most one nonempty rename-only \\'id \"<old-name>\"\\'.');\n else {\n previous = value;\n if (value === name) context.information(DiagnosticCodes.RedundantSourceStreamId, 'The rename pin repeats the current name; omit it for a new declaration.', locationOf(line));\n }\n rejectChildren(context, line, DiagnosticCodes.InvalidEventSourceDeclaration);\n return previous;\n}\n\nexport function parseCommandStream(context: ParserContext, header: SourceLine, candidate: PropertySyntax, ambiguous: boolean): CommandStreamSyntax {\n const [eventSource, stream] = candidate.type.name.split('.');\n const route: CommandStreamSyntax = { kind: 'CommandStreamSyntax', eventSource, stream, streamId: null, streamIdParts: [], propertyCandidate: null, referenceLocation: candidate.type.location, referenceLength: candidate.type.name.length, location: locationOf(header) };\n if (ambiguous) {\n context.error(DiagnosticCodes.AmbiguousCommandStream, `'${header.content}' has both a property type and a stream route interpretation; neither is selected.`, locationOf(header));\n // Ordinary properties are leaves; preserve deeper legacy command members in this case.\n return { ...route, propertyCandidate: candidate };\n }\n let streamId: PropertyMappingSyntax | null = null;\n let streamIdParts: PropertyMappingSyntax[] = [];\n let block = false;\n const directiveLocations: Record<string, ReturnType<typeof locationOf>> = {};\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (child.content === 'streamId') {\n if (streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Declare either one 'streamId = <source>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n block = true;\n directiveLocations.streamId = locationOf(child);\n streamIdParts = parseRouteParts(context, child, DiagnosticCodes.InvalidCommandStream);\n }\n continue;\n }\n const match = /^streamId\\s*=\\s*(.+)$/.exec(child.content);\n if (match === null || streamId !== null || block) {\n context.error(DiagnosticCodes.InvalidCommandStream, \"Declare either one 'streamId = <source>' mapping or one streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n } else {\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[1], child.content.indexOf('=') + 1) };\n streamId = { kind: 'PropertyMappingSyntax', property: 'streamId', source: parseMappingSource(match[1], location, context), location: locationOf(child) };\n rejectChildren(context, child, DiagnosticCodes.InvalidCommandStream);\n }\n }\n return { ...route, streamId, streamIdParts, directiveLocations };\n}\n\nfunction parseStreamIdParts(context: ParserContext, header: SourceLine): EventStreamIdPartSyntax[] {\n const parts: EventStreamIdPartSyntax[] = [];\n const declaration = sourceStreamPattern('^([A-Za-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)$');\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = declaration.exec(child.content);\n if (match === null) {\n invalid(context, child, \"Expected '<part> <Type>' without modifiers in a streamId part block.\");\n context.skipBlock(child.indent);\n continue;\n }\n const type = parseTypeRef(match[2], { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[2], match[1].length) });\n reportLegacyOptionalSuffix(context, type, child);\n parts.push({ kind: 'EventStreamIdPartSyntax', name: match[1], type, location: locationOf(child) });\n rejectChildren(context, child, DiagnosticCodes.InvalidEventSourceDeclaration);\n }\n if (parts.length === 0) invalid(context, header, 'A streamId part block cannot be empty.');\n return parts;\n}\n\nexport function parseRouteParts(context: ParserContext, header: SourceLine, code: string): PropertyMappingSyntax[] {\n const parts: PropertyMappingSyntax[] = [];\n const mapping = sourceStreamPattern('^([A-Za-z_]\\\\w*)\\\\s*=(?!=|>)\\\\s*(.+)$');\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n const match = mapping.exec(child.content);\n if (match === null) {\n context.error(code, \"Expected '<part> = <source>' in a streamId part block.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n const location = { ...locationOf(child), column: child.indent + 1 + child.content.indexOf(match[2], child.content.indexOf('=') + 1) };\n parts.push({ kind: 'PropertyMappingSyntax', property: match[1], source: parseMappingSource(match[2], location, context), location: locationOf(child) });\n rejectChildren(context, child, code);\n }\n if (parts.length === 0) context.error(code, 'A streamId part block cannot be empty.', locationOf(header));\n return parts;\n}\n\nfunction rejectChildren(context: ParserContext, line: SourceLine, code: string): void {\n const child = context.peekChild(line.indent);\n if (child !== undefined) {\n context.error(code, 'This directive cannot have children.', locationOf(child));\n context.skipBlock(line.indent);\n }\n}\n\nfunction invalid(context: ParserContext, line: SourceLine, message: string): void { context.error(DiagnosticCodes.InvalidEventSourceDeclaration, message, locationOf(line)); }\n"],"mappings":"A,qpBAkBA,MAAMA,EAAaC,EAAQ,YAAYC,EAAkB,IAAI,EACvDC,EAAgBC,EAAoB,sEAAsE,EAC1GC,EAAeD,EAAoB,kCAAkC,EACrEE,EAAeF,EAAoB,6BAA6B,EAEtE,SAAgB,iBAAiB,EAAwB,EAAuC,CAC5F,IAAMG,EAAOF,EAAa,KAAKG,EAAO,OAAO,CAAC,GAAG,IAAM,GACnDD,IAAS,IAAI,QAAQE,EAASD,EAAQ,gCAAgC,EAC1E,IAAME,EAA+B,CAAC,EAClCC,EAAmC,KACnCC,EAA6B,KAC7BC,EAAoB,KACpBC,EAA6C,KACjD,IAAK,IAAIC,EAAQN,EAAQ,UAAUD,EAAO,MAAM,EAAGO,IAAU,IAAA,GAAW,EAAQN,EAAQ,UAAUD,EAAO,MAAM,EAE3G,OADAC,EAAQ,OAAO,gBAAgB,EACvBO,EAAUD,EAAM,OAAO,EAA/B,CAC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iagnosticCodes.js";import{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.js";import{EventSourceCatalog as n}from"../Syntax/EventSourceCatalog.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.js";import{EventSourceCatalog as n}from"../Syntax/EventSourceCatalog.js";import{validateObserverFilters as r}from"./ObserverFilterValidator.js";import{streamIdFailureMessage as i,tryFormatInteger as a,tryFormatText as o,tryFormatUuidText as s}from"../Syntax/StreamIdFormatter.js";import{commandDestinationType as c}from"./CommandDestinationTypes.js";import{validateStreamIdParts as l}from"./CompositeStreamIdValidator.js";import{compatibleValue as u,uniqueByName as d}from"./ResponseValidator.js";import{validateSpecificationStreams as f}from"./SpecificationStreamValidator.js";const sameExpression=(e,t)=>e==null&&t==null||e?.kind===`PathExpressionSyntax`&&t?.kind===`PathExpressionSyntax`&&e.path===t.path||e?.kind===`LiteralExpressionSyntax`&&t?.kind===`LiteralExpressionSyntax`&&JSON.stringify(e.value)===JSON.stringify(t.value),sameRoute=(e,t)=>e.eventSource===t.eventSource&&e.stream===t.stream&&sameExpression(e.streamId?.source,t.streamId?.source)&&e.streamIdParts.length===t.streamIdParts.length&&e.streamIdParts.every(e=>t.streamIdParts.some(t=>e.property===t.property&&sameExpression(e.source,t.source))),p=/* @__PURE__ */ new Set([`String`,`Uuid`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`]);function supportsStreamIdentity(e,t){let n=t.concepts.filter(t=>t.name===e.name),r=n.length===1?n[0].type:n.length===0&&p.has(e.name)?e.name:null;return r===`String`||r===`Uuid`||r===`Int`&&n.length===1&&n[0].values.length===0}function formatStreamIdLiteral(e,t,n){if(e?.kind!==`LiteralExpressionSyntax`)return null;let r=e.value,i=t===null?null:d(n.concepts).get(t.name)?.type??t.name;return typeof r==`string`?i===`Uuid`?s(r):o(r):typeof r==`number`?a(r):typeof r==`object`&&r&&r.literalType===`ExactNumber`?r.value.includes(`.`)?a(NaN):a(BigInt(r.value),!1):null}function validateEventSources(a,o){let s=d(a.concepts),m=d(a.types),h=/* @__PURE__ */ new Set([...p,...s.keys(),...m.keys()]),g=new Map([...m].map(([e,t])=>[e,d(t.properties)])),compatible=(e,t)=>h.has(e.name)&&h.has(t.name)?e.name===t.name&&e.isCollection===t.isCollection&&(!e.isOptional||t.isOptional):null,validateType=(t,n)=>{if(t===null)return;if(t.isOptional||t.isCollection||a.types.some(e=>e.name===t.name)){o.error(e.InvalidEventSourceDeclaration,`Identifier and streamId declarations require a nonoptional scalar value type.`,t.location);return}let r=a.concepts.filter(e=>e.name===t.name),i=r.length===1?r[0].type:r.length===0&&p.has(t.name)?t.name:null;n&&i!==null&&!supportsStreamIdentity(t,a)&&o.error(e.UnsupportedStreamIdType,`Stream ids support text and UUID values and their nominal concepts, plus integer-backed concepts; other types need a future portable formatter.`,t.location),i===null&&!a.imports.some(e=>e.qualifiedName===t.name||e.qualifiedName.split(`.`).at(-1)===t.name)&&o.warning(e.UnknownType,`Unknown type '${t.name}' in event source declaration.`,t.location)},_=/* @__PURE__ */ new Set;for(let t of a.eventSources??[]){_.has(t.name)&&o.error(e.InvalidEventSourceDeclaration,`Event source '${t.name}' has multiple physical declarations.`,t.location),_.add(t.name),(t.id??t.name)===`Default`&&o.error(e.ReservedStoredName,`Event source '${t.name}' has the reserved stored name 'Default'; choose a stored name other than 'Default'.`,t.location),validateType(t.identifier,!1);let n=/* @__PURE__ */ new Set;for(let r of t.streams){n.has(r.name)&&o.error(e.InvalidEventSourceDeclaration,`Stream '${t.name}.${r.name}' has multiple declarations under this source.`,r.location),n.add(r.name),(r.id??r.name)===`All`&&o.error(e.ReservedStoredName,`Stream '${t.name}.${r.name}' has the reserved stored name 'All'; choose a stored name other than 'All'.`,r.location),validateType(r.streamId,!0);let i=r.streamIdParts;if(i.length>0){i.length<2&&o.error(e.InvalidEventSourceDeclaration,`A composite stream id requires at least two named parts.`,r.directiveLocations?.streamId??r.location);for(let t of new Set(i.map(e=>e.name)))for(let n of i.filter(e=>e.name===t).slice(1))o.error(e.InvalidEventSourceDeclaration,`Stream id part '${n.name}' is declared more than once.`,n.location);for(let e of i)validateType(e.type,!0)}}}let pathProperty=(e,t)=>{let[n,...r]=t.split(`.`);if(e===null)return{property:null,missing:!1};let i=e.filter(e=>e.name===n);if(i.length!==1)return{property:null,missing:i.length===0};let a=i[0];if(r.length===0)return{property:a,missing:!1};if(p.has(a.type.name)||s.has(a.type.name)&&!m.has(a.type.name))return{property:null,missing:!0};let o=pathProperty(m.get(a.type.name)?.properties??null,r.join(`.`));return o.property===null?o:{property:{...o.property,type:{...o.property.type,isCollection:a.type.isCollection||o.property.type.isCollection,isOptional:a.type.isOptional||o.property.type.isOptional}},missing:!1}},v=new n(a),y=new t(a);r(a,o,y);for(let{slice:t}of y.slices)for(let n of t.commands)for(let{route:r,production:d}of[...n.stream==null?[]:[{route:n.stream,production:null}],...n.produces.filter(e=>e.stream!=null).map(e=>({route:e.stream,production:e}))]){if(r.propertyCandidate!==null)continue;d!==null&&n.stream!=null&&sameRoute(r,n.stream)&&o.warning(e.RedundantProductionRoute,`The production route repeats its command route; omit the override.`,r.location);let f=v.resolve(r.eventSource,r.stream);if(f.kind!==`unique`){let t={ambiguous:`Ambiguous`,notFound:`NotFound`,wrongKind:`WrongKind`}[f.kind];o.error(e.InvalidCommandStream,`Stream '${r.eventSource}.${r.stream}' is ${t}; routing requires one physical source and stream.`,r.location);continue}let m=f.sources[0],h=f.streams[0],_=n.properties.filter(e=>e.isIdentifier);d===null&&m.identifier!==null&&_.length===1&&compatible(_[0].type,m.identifier)===!1&&o.error(e.InvalidCommandStream,`Command identifier '${_[0].name}' does not have the source's nominal identifier type '${m.identifier.name}'. The stream does not supply a destination.`,_[0].location);for(let r of n.produces.filter(e=>y.isEventProduction(e,t)&&(d===null?e.stream==null:e===d))){if(m.identifier===null)continue;let i=c(n,r,a,{resolver:y,slice:t});if(i===null||d===null&&r.for===null&&r.inlineEvent!==null&&_.length===1&&compatible(_[0].type,m.identifier)===!1)continue;let l=r.for===null&&r.inlineEvent===null&&!n.properties.some(e=>e.isGenerated&&e.isIdentifier),u=s.get(m.identifier.name)?.type??(p.has(m.identifier.name)?m.identifier.name:null);(l?u===null?null:u===`Uuid`:compatible(i,m.identifier))===!1&&o.error(e.InvalidCommandStream,`Command production destination does not have the source's nominal identifier type '${m.identifier.name}'. The stream does not supply a destination.`,d?.stream?.location??r.for?.location??r.location)}let validateMapping=(t,r)=>{let c=t.source;if(c.kind===`PathExpressionSyntax`){let t=pathProperty(n.properties,c.path);(t.missing||t.property!==null&&compatible(t.property.type,r)===!1)&&o.error(e.InvalidCommandStream,`Stream id source '${c.path}' is absent or incompatible with nominal type '${r.name}'.`,c.location)}else if(c.kind===`LiteralExpressionSyntax`&&c.value!==null){let t=formatStreamIdLiteral(c,r,a);t?.failure==null?u(c,r,s,g)||o.error(e.InvalidCommandStream,`Stream id value is incompatible with nominal type '${r.name}'.`,c.location):o.error(e.InvalidCommandStream,i(t.failure),c.location)}else([`RawExpressionSyntax`,`ObjectExpressionSyntax`,`ListExpressionSyntax`].includes(c.kind)||c.kind===`LiteralExpressionSyntax`&&c.value===null)&&o.error(e.InvalidCommandStream,`A stream id needs a scalar value source, not a raw expression, collection or absence.`,c.location)};h.streamIdParts.length>0?l(h,r.streamIdParts,r.streamId!==null,r.location,e.InvalidCommandStream,o,validateMapping):r.streamIdParts.length>0?o.error(e.InvalidCommandStream,`A streamId part block requires a composite stream.`,r.location):((h.streamId===null&&r.streamId!==null||h.streamId!==null&&r.streamId===null)&&o.error(e.InvalidCommandStream,h.streamId===null?`An unkeyed stream cannot take a streamId mapping.`:`This keyed stream requires a streamId mapping.`,r.location),h.streamId!==null&&r.streamId!==null&&validateMapping(r.streamId,h.streamId))}f(a,o)}export{formatStreamIdLiteral,supportsStreamIdentity,validateEventSources};
|
|
2
2
|
//# sourceMappingURL=EventSourceValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventSourceValidator.js","names":["left","right","part","other","primitives","concepts","application","concept","type","primitive","expression","value","uniqueByName","tryFormatUuidText","tryFormatText","tryFormatInteger","composites","known","compositeProperties","name","source","target","composite","context","DiagnosticCodes","named","streamId","imported","names","streams","stream","parts","duplicate","remaining","path","properties","matches","property","resolved","catalog","EventSourceCatalog","resolver","AuthoringProductionResolver","validateObserverFilters","command","slice","produced","route","production","resolution","state","identifiers","destination","commandDestinationType","allocated","mapping","formatted","compatibleValue","streamIdFailureMessage","validateStreamIdParts","validateSpecificationStreams"],"sources":["../../../../../../Compiler/Parsing/EventSourceValidator.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 { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { CommandStreamSyntax, EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { validateObserverFilters } from './ObserverFilterValidator';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { StreamIdFormatResult, streamIdFailureMessage, tryFormatInteger, tryFormatText, tryFormatUuidText } from '../Syntax/StreamIdFormatter';\nimport { commandDestinationType } from './CommandDestinationTypes';\nimport { validateStreamIdParts } from './CompositeStreamIdValidator';\nimport { ParserContext } from './ParserContext';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\nimport { validateSpecificationStreams } from './SpecificationStreamValidator';\n\nconst sameExpression = (left: ExpressionSyntax | null | undefined, right: ExpressionSyntax | null | undefined): boolean =>\n left == null && right == null || left?.kind === 'PathExpressionSyntax' && right?.kind === 'PathExpressionSyntax' && left.path === right.path ||\n left?.kind === 'LiteralExpressionSyntax' && right?.kind === 'LiteralExpressionSyntax' && JSON.stringify(left.value) === JSON.stringify(right.value);\nconst sameRoute = (left: CommandStreamSyntax, right: CommandStreamSyntax): boolean => left.eventSource === right.eventSource && left.stream === right.stream &&\n sameExpression(left.streamId?.source, right.streamId?.source) && left.streamIdParts.length === right.streamIdParts.length &&\n left.streamIdParts.every(part => right.streamIdParts.some(other => part.property === other.property && sameExpression(part.source, other.source)));\n\nconst primitives = new Set(['String', 'Uuid', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime']);\n\nexport function supportsStreamIdentity(type: TypeRefSyntax, application: ApplicationSyntax): boolean {\n const concepts = application.concepts.filter(concept => concept.name === type.name);\n const primitive = concepts.length === 1 ? concepts[0].type : concepts.length === 0 && primitives.has(type.name) ? type.name : null;\n return primitive === 'String' || primitive === 'Uuid' || primitive === 'Int' && concepts.length === 1 && concepts[0].values.length === 0;\n}\n\nexport function formatStreamIdLiteral(expression: ExpressionSyntax | null | undefined, type: TypeRefSyntax | null, application: ApplicationSyntax): StreamIdFormatResult | null {\n if (expression?.kind !== 'LiteralExpressionSyntax') return null;\n const value = expression.value;\n const primitive = type === null ? null : uniqueByName(application.concepts).get(type.name)?.type ?? type.name;\n if (typeof value === 'string') return primitive === 'Uuid' ? tryFormatUuidText(value) : tryFormatText(value);\n if (typeof value === 'number') return tryFormatInteger(value);\n if (typeof value === 'object' && value !== null && value.literalType === 'ExactNumber') {\n if (value.value.includes('.')) return tryFormatInteger(NaN);\n return tryFormatInteger(BigInt(value.value), false);\n }\n return null;\n}\n\nexport function validateEventSources(application: ApplicationSyntax, context: ParserContext): void {\n const concepts = uniqueByName(application.concepts);\n const composites = uniqueByName(application.types);\n const known = new Set([...primitives, ...concepts.keys(), ...composites.keys()]);\n const compositeProperties = new Map([...composites].map(([name, type]) => [name, uniqueByName(type.properties)]));\n const compatible = (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 validateType = (type: TypeRefSyntax | null, streamId: boolean): void => {\n if (type === null) return;\n if (type.isOptional || type.isCollection || application.types.some(composite => composite.name === type.name)) {\n context.error(DiagnosticCodes.InvalidEventSourceDeclaration, 'Identifier and streamId declarations require a nonoptional scalar value type.', type.location);\n return;\n }\n const named = application.concepts.filter(concept => concept.name === type.name);\n const primitive = named.length === 1 ? named[0].type : named.length === 0 && primitives.has(type.name) ? type.name : null;\n if (streamId && primitive !== null && !supportsStreamIdentity(type, application))\n context.error(DiagnosticCodes.UnsupportedStreamIdType, 'Stream ids support text and UUID values and their nominal concepts, plus integer-backed concepts; other types need a future portable formatter.', type.location);\n if (primitive === null && !application.imports.some(imported => imported.qualifiedName === type.name || imported.qualifiedName.split('.').at(-1) === type.name))\n context.warning(DiagnosticCodes.UnknownType, `Unknown type '${type.name}' in event source declaration.`, type.location);\n };\n const names = new Set<string>();\n for (const source of application.eventSources ?? []) {\n if (names.has(source.name)) context.error(DiagnosticCodes.InvalidEventSourceDeclaration, `Event source '${source.name}' has multiple physical declarations.`, source.location);\n names.add(source.name);\n if ((source.id ?? source.name) === 'Default')\n context.error(DiagnosticCodes.ReservedStoredName, `Event source '${source.name}' has the reserved stored name 'Default'; choose a stored name other than 'Default'.`, source.location);\n validateType(source.identifier, false);\n const streams = new Set<string>();\n for (const stream of source.streams) {\n if (streams.has(stream.name)) context.error(DiagnosticCodes.InvalidEventSourceDeclaration, `Stream '${source.name}.${stream.name}' has multiple declarations under this source.`, stream.location);\n streams.add(stream.name);\n if ((stream.id ?? stream.name) === 'All')\n context.error(DiagnosticCodes.ReservedStoredName, `Stream '${source.name}.${stream.name}' has the reserved stored name 'All'; choose a stored name other than 'All'.`, stream.location);\n validateType(stream.streamId, true);\n const parts = stream.streamIdParts;\n if (parts.length > 0) {\n if (parts.length < 2) context.error(DiagnosticCodes.InvalidEventSourceDeclaration, 'A composite stream id requires at least two named parts.', stream.directiveLocations?.streamId ?? stream.location);\n for (const name of new Set(parts.map(part => part.name))) {\n for (const duplicate of parts.filter(part => part.name === name).slice(1))\n context.error(DiagnosticCodes.InvalidEventSourceDeclaration, `Stream id part '${duplicate.name}' is declared more than once.`, duplicate.location);\n }\n for (const part of parts) validateType(part.type, true);\n }\n }\n }\n const pathProperty = (properties: readonly PropertySyntax[] | null, path: string): { property: PropertySyntax | null; missing: boolean } => {\n const [name, ...remaining] = path.split('.');\n if (properties === null) return { property: null, missing: false };\n const matches = properties.filter(property => property.name === name);\n if (matches.length !== 1) return { property: null, missing: matches.length === 0 };\n const property = matches[0];\n if (remaining.length === 0) return { property, missing: false };\n if (primitives.has(property.type.name) || concepts.has(property.type.name) && !composites.has(property.type.name)) return { property: null, missing: true };\n const resolved = pathProperty(composites.get(property.type.name)?.properties ?? null, remaining.join('.'));\n return resolved.property === null ? resolved : { property: { ...resolved.property, type: { ...resolved.property.type, isCollection: property.type.isCollection || resolved.property.type.isCollection, isOptional: property.type.isOptional || resolved.property.type.isOptional } }, missing: false };\n };\n const catalog = new EventSourceCatalog(application);\n const resolver = new AuthoringProductionResolver(application);\n validateObserverFilters(application, context, resolver);\n for (const { slice } of resolver.slices) for (const command of slice.commands) for (const { route, production } of [\n ...(command.stream == null ? [] : [{ route: command.stream, production: null }]),\n ...command.produces.filter(produced => produced.stream != null).map(produced => ({ route: produced.stream!, production: produced }))\n ]) {\n if (route.propertyCandidate !== null) continue;\n if (production !== null && command.stream != null && sameRoute(route, command.stream))\n context.warning(DiagnosticCodes.RedundantProductionRoute, 'The production route repeats its command route; omit the override.', route.location);\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 context.error(DiagnosticCodes.InvalidCommandStream, `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 identifiers = command.properties.filter(property => property.isIdentifier);\n if (production === null && source.identifier !== null && identifiers.length === 1 && compatible(identifiers[0].type, source.identifier) === false)\n context.error(DiagnosticCodes.InvalidCommandStream, `Command identifier '${identifiers[0].name}' does not have the source's nominal identifier type '${source.identifier.name}'. The stream does not supply a destination.`, identifiers[0].location);\n for (const produced of command.produces.filter(produced => resolver.isEventProduction(produced, slice) && (production === null ? produced.stream == null : produced === production))) {\n if (source.identifier === null) continue;\n const destination = commandDestinationType(command, produced, application, { resolver, slice });\n if (destination === null) continue;\n if (production === null && produced.for === null && produced.inlineEvent !== null && identifiers.length === 1 && compatible(identifiers[0].type, source.identifier) === false) continue;\n const allocated = produced.for === null && produced.inlineEvent === null && !command.properties.some(property => property.isGenerated && property.isIdentifier);\n const primitive = concepts.get(source.identifier.name)?.type ?? (primitives.has(source.identifier.name) ? source.identifier.name : null);\n const matches = allocated ? primitive === null ? null : primitive === 'Uuid' : compatible(destination, source.identifier);\n if (matches === false) context.error(DiagnosticCodes.InvalidCommandStream, `Command production destination does not have the source's nominal identifier type '${source.identifier.name}'. The stream does not supply a destination.`, production?.stream?.location ?? produced.for?.location ?? produced.location);\n }\n const validateMapping = (mapping: PropertyMappingSyntax, target: TypeRefSyntax): void => {\n const expression = mapping.source;\n if (expression.kind === 'PathExpressionSyntax') {\n const resolved = pathProperty(command.properties, expression.path);\n if (resolved.missing || resolved.property !== null && compatible(resolved.property.type, target) === false)\n context.error(DiagnosticCodes.InvalidCommandStream, `Stream id source '${expression.path}' is absent or incompatible with nominal type '${target.name}'.`, expression.location);\n } else if (expression.kind === 'LiteralExpressionSyntax' && expression.value !== null) {\n const formatted = formatStreamIdLiteral(expression, target, application);\n if (formatted?.failure != null) context.error(DiagnosticCodes.InvalidCommandStream, streamIdFailureMessage(formatted.failure), expression.location);\n else if (!compatibleValue(expression, target, concepts, compositeProperties)) context.error(DiagnosticCodes.InvalidCommandStream, `Stream id value is incompatible with nominal type '${target.name}'.`, expression.location);\n } else if (['RawExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(expression.kind) || expression.kind === 'LiteralExpressionSyntax' && expression.value === null)\n context.error(DiagnosticCodes.InvalidCommandStream, 'A stream id needs a scalar value source, not a raw expression, collection or absence.', expression.location);\n };\n if (stream.streamIdParts.length > 0) {\n validateStreamIdParts(stream, route.streamIdParts, route.streamId !== null, route.location, DiagnosticCodes.InvalidCommandStream, context, validateMapping);\n continue;\n }\n if (route.streamIdParts.length > 0) {\n context.error(DiagnosticCodes.InvalidCommandStream, 'A streamId part block requires a composite stream.', route.location);\n continue;\n }\n if (stream.streamId === null && route.streamId !== null || stream.streamId !== null && route.streamId === null)\n context.error(DiagnosticCodes.InvalidCommandStream, stream.streamId === null ? 'An unkeyed stream cannot take a streamId mapping.' : 'This keyed stream requires a streamId mapping.', route.location);\n if (stream.streamId === null || route.streamId === null) continue;\n validateMapping(route.streamId, stream.streamId);\n }\n validateSpecificationStreams(application, context);\n}\n"],"mappings":"8wBAkBA,MAAM,gBAAkB,EAA2C,IAC/DA,GAAQ,MAAQC,GAAS,MAAQD,GAAM,OAAS,wBAA0BC,GAAO,OAAS,wBAA0BD,EAAK,OAASC,EAAM,MACxID,GAAM,OAAS,2BAA6BC,GAAO,OAAS,2BAA6B,KAAK,UAAUD,EAAK,KAAK,IAAM,KAAK,UAAUC,EAAM,KAAK,EAChJ,WAAa,EAA2B,IAAwCD,EAAK,cAAgBC,EAAM,aAAeD,EAAK,SAAWC,EAAM,QAClJ,eAAeD,EAAK,UAAU,OAAQC,EAAM,UAAU,MAAM,GAAKD,EAAK,cAAc,SAAWC,EAAM,cAAc,QACnHD,EAAK,cAAc,MAAM,GAAQC,EAAM,cAAc,KAAK,GAASC,EAAK,WAAaC,EAAM,UAAY,eAAeD,EAAK,OAAQC,EAAM,MAAM,CAAC,CAAC,EAE/IC,kBAAa,IAAI,IAAI,CAAC,SAAU,OAAQ,MAAO,UAAW,OAAQ,OAAQ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xK,EACIoB,EAAO,cAAc,OAAS,EAC9B6B,EAAsB7B,EAAQiB,EAAM,cAAeA,EAAM,WAAa,KAAMA,EAAM,SAAUvB,EAAgB,qBAAsBD,EAAS,eAAe,EAG1JwB,EAAM,cAAc,OAAS,EAC7BxB,EAAQ,MAAMC,EAAgB,qBAAsB,qDAAsDuB,EAAM,QAAQ,IAGxHjB,EAAO,WAAa,MAAQiB,EAAM,WAAa,MAAQjB,EAAO,WAAa,MAAQiB,EAAM,WAAa,OACtGxB,EAAQ,MAAMC,EAAgB,qBAAsBM,EAAO,WAAa,KAAO,oDAAsD,iDAAkDiB,EAAM,QAAQ,EACrMjB,EAAO,WAAa,MAAQiB,EAAM,WAAa,MACnD,gBAAgBA,EAAM,SAAUjB,EAAO,QAAQ,EACnD,CACA8B,EAA6BtD,EAAaiB,CAAO,CACrD"}
|
|
1
|
+
{"version":3,"file":"EventSourceValidator.js","names":["left","right","part","other","primitives","concepts","application","concept","type","primitive","expression","value","uniqueByName","tryFormatUuidText","tryFormatText","tryFormatInteger","composites","known","compositeProperties","name","source","target","composite","context","DiagnosticCodes","named","streamId","imported","names","streams","stream","parts","duplicate","remaining","path","properties","matches","property","resolved","catalog","EventSourceCatalog","resolver","AuthoringProductionResolver","validateObserverFilters","command","slice","produced","route","production","resolution","state","identifiers","destination","commandDestinationType","allocated","mapping","formatted","compatibleValue","streamIdFailureMessage","validateStreamIdParts","validateSpecificationStreams"],"sources":["../../../../../../Compiler/Parsing/EventSourceValidator.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 { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { CommandStreamSyntax, EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { validateObserverFilters } from './ObserverFilterValidator';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { ExpressionSyntax, PropertyMappingSyntax } from '../Syntax/Expressions';\nimport { StreamIdFormatResult, streamIdFailureMessage, tryFormatInteger, tryFormatText, tryFormatUuidText } from '../Syntax/StreamIdFormatter';\nimport { commandDestinationType } from './CommandDestinationTypes';\nimport { validateStreamIdParts } from './CompositeStreamIdValidator';\nimport { ParserContext } from './ParserContext';\nimport { compatibleValue, uniqueByName } from './ResponseValidator';\nimport { validateSpecificationStreams } from './SpecificationStreamValidator';\n\nconst sameExpression = (left: ExpressionSyntax | null | undefined, right: ExpressionSyntax | null | undefined): boolean =>\n left == null && right == null || left?.kind === 'PathExpressionSyntax' && right?.kind === 'PathExpressionSyntax' && left.path === right.path ||\n left?.kind === 'LiteralExpressionSyntax' && right?.kind === 'LiteralExpressionSyntax' && JSON.stringify(left.value) === JSON.stringify(right.value);\nconst sameRoute = (left: CommandStreamSyntax, right: CommandStreamSyntax): boolean => left.eventSource === right.eventSource && left.stream === right.stream &&\n sameExpression(left.streamId?.source, right.streamId?.source) && left.streamIdParts.length === right.streamIdParts.length &&\n left.streamIdParts.every(part => right.streamIdParts.some(other => part.property === other.property && sameExpression(part.source, other.source)));\n\nconst primitives = new Set(['String', 'Uuid', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime']);\n\nexport function supportsStreamIdentity(type: TypeRefSyntax, application: ApplicationSyntax): boolean {\n const concepts = application.concepts.filter(concept => concept.name === type.name);\n const primitive = concepts.length === 1 ? concepts[0].type : concepts.length === 0 && primitives.has(type.name) ? type.name : null;\n return primitive === 'String' || primitive === 'Uuid' || primitive === 'Int' && concepts.length === 1 && concepts[0].values.length === 0;\n}\n\nexport function formatStreamIdLiteral(expression: ExpressionSyntax | null | undefined, type: TypeRefSyntax | null, application: ApplicationSyntax): StreamIdFormatResult | null {\n if (expression?.kind !== 'LiteralExpressionSyntax') return null;\n const value = expression.value;\n const primitive = type === null ? null : uniqueByName(application.concepts).get(type.name)?.type ?? type.name;\n if (typeof value === 'string') return primitive === 'Uuid' ? tryFormatUuidText(value) : tryFormatText(value);\n if (typeof value === 'number') return tryFormatInteger(value);\n if (typeof value === 'object' && value !== null && value.literalType === 'ExactNumber') {\n if (value.value.includes('.')) return tryFormatInteger(NaN);\n return tryFormatInteger(BigInt(value.value), false);\n }\n return null;\n}\n\nexport function validateEventSources(application: ApplicationSyntax, context: ParserContext): void {\n const concepts = uniqueByName(application.concepts);\n const composites = uniqueByName(application.types);\n const known = new Set([...primitives, ...concepts.keys(), ...composites.keys()]);\n const compositeProperties = new Map([...composites].map(([name, type]) => [name, uniqueByName(type.properties)]));\n const compatible = (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 validateType = (type: TypeRefSyntax | null, streamId: boolean): void => {\n if (type === null) return;\n if (type.isOptional || type.isCollection || application.types.some(composite => composite.name === type.name)) {\n context.error(DiagnosticCodes.InvalidEventSourceDeclaration, 'Identifier and streamId declarations require a nonoptional scalar value type.', type.location);\n return;\n }\n const named = application.concepts.filter(concept => concept.name === type.name);\n const primitive = named.length === 1 ? named[0].type : named.length === 0 && primitives.has(type.name) ? type.name : null;\n if (streamId && primitive !== null && !supportsStreamIdentity(type, application))\n context.error(DiagnosticCodes.UnsupportedStreamIdType, 'Stream ids support text and UUID values and their nominal concepts, plus integer-backed concepts; other types need a future portable formatter.', type.location);\n if (primitive === null && !application.imports.some(imported => imported.qualifiedName === type.name || imported.qualifiedName.split('.').at(-1) === type.name))\n context.warning(DiagnosticCodes.UnknownType, `Unknown type '${type.name}' in event source declaration.`, type.location);\n };\n const names = new Set<string>();\n for (const source of application.eventSources ?? []) {\n if (names.has(source.name)) context.error(DiagnosticCodes.InvalidEventSourceDeclaration, `Event source '${source.name}' has multiple physical declarations.`, source.location);\n names.add(source.name);\n if ((source.id ?? source.name) === 'Default')\n context.error(DiagnosticCodes.ReservedStoredName, `Event source '${source.name}' has the reserved stored name 'Default'; choose a stored name other than 'Default'.`, source.location);\n validateType(source.identifier, false);\n const streams = new Set<string>();\n for (const stream of source.streams) {\n if (streams.has(stream.name)) context.error(DiagnosticCodes.InvalidEventSourceDeclaration, `Stream '${source.name}.${stream.name}' has multiple declarations under this source.`, stream.location);\n streams.add(stream.name);\n if ((stream.id ?? stream.name) === 'All')\n context.error(DiagnosticCodes.ReservedStoredName, `Stream '${source.name}.${stream.name}' has the reserved stored name 'All'; choose a stored name other than 'All'.`, stream.location);\n validateType(stream.streamId, true);\n const parts = stream.streamIdParts;\n if (parts.length > 0) {\n if (parts.length < 2) context.error(DiagnosticCodes.InvalidEventSourceDeclaration, 'A composite stream id requires at least two named parts.', stream.directiveLocations?.streamId ?? stream.location);\n for (const name of new Set(parts.map(part => part.name))) {\n for (const duplicate of parts.filter(part => part.name === name).slice(1))\n context.error(DiagnosticCodes.InvalidEventSourceDeclaration, `Stream id part '${duplicate.name}' is declared more than once.`, duplicate.location);\n }\n for (const part of parts) validateType(part.type, true);\n }\n }\n }\n const pathProperty = (properties: readonly PropertySyntax[] | null, path: string): { property: PropertySyntax | null; missing: boolean } => {\n const [name, ...remaining] = path.split('.');\n if (properties === null) return { property: null, missing: false };\n const matches = properties.filter(property => property.name === name);\n if (matches.length !== 1) return { property: null, missing: matches.length === 0 };\n const property = matches[0];\n if (remaining.length === 0) return { property, missing: false };\n if (primitives.has(property.type.name) || concepts.has(property.type.name) && !composites.has(property.type.name)) return { property: null, missing: true };\n const resolved = pathProperty(composites.get(property.type.name)?.properties ?? null, remaining.join('.'));\n return resolved.property === null ? resolved : { property: { ...resolved.property, type: { ...resolved.property.type, isCollection: property.type.isCollection || resolved.property.type.isCollection, isOptional: property.type.isOptional || resolved.property.type.isOptional } }, missing: false };\n };\n const catalog = new EventSourceCatalog(application);\n const resolver = new AuthoringProductionResolver(application);\n validateObserverFilters(application, context, resolver);\n for (const { slice } of resolver.slices) for (const command of slice.commands) for (const { route, production } of [\n ...(command.stream == null ? [] : [{ route: command.stream, production: null }]),\n ...command.produces.filter(produced => produced.stream != null).map(produced => ({ route: produced.stream!, production: produced }))\n ]) {\n if (route.propertyCandidate !== null) continue;\n if (production !== null && command.stream != null && sameRoute(route, command.stream))\n context.warning(DiagnosticCodes.RedundantProductionRoute, 'The production route repeats its command route; omit the override.', route.location);\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 context.error(DiagnosticCodes.InvalidCommandStream, `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 identifiers = command.properties.filter(property => property.isIdentifier);\n if (production === null && source.identifier !== null && identifiers.length === 1 && compatible(identifiers[0].type, source.identifier) === false)\n context.error(DiagnosticCodes.InvalidCommandStream, `Command identifier '${identifiers[0].name}' does not have the source's nominal identifier type '${source.identifier.name}'. The stream does not supply a destination.`, identifiers[0].location);\n for (const produced of command.produces.filter(produced => resolver.isEventProduction(produced, slice) && (production === null ? produced.stream == null : produced === production))) {\n if (source.identifier === null) continue;\n const destination = commandDestinationType(command, produced, application, { resolver, slice });\n if (destination === null) continue;\n if (production === null && produced.for === null && produced.inlineEvent !== null && identifiers.length === 1 && compatible(identifiers[0].type, source.identifier) === false) continue;\n const allocated = produced.for === null && produced.inlineEvent === null && !command.properties.some(property => property.isGenerated && property.isIdentifier);\n const primitive = concepts.get(source.identifier.name)?.type ?? (primitives.has(source.identifier.name) ? source.identifier.name : null);\n const matches = allocated ? primitive === null ? null : primitive === 'Uuid' : compatible(destination, source.identifier);\n if (matches === false) context.error(DiagnosticCodes.InvalidCommandStream, `Command production destination does not have the source's nominal identifier type '${source.identifier.name}'. The stream does not supply a destination.`, production?.stream?.location ?? produced.for?.location ?? produced.location);\n }\n const validateMapping = (mapping: PropertyMappingSyntax, target: TypeRefSyntax): void => {\n const expression = mapping.source;\n if (expression.kind === 'PathExpressionSyntax') {\n const resolved = pathProperty(command.properties, expression.path);\n if (resolved.missing || resolved.property !== null && compatible(resolved.property.type, target) === false)\n context.error(DiagnosticCodes.InvalidCommandStream, `Stream id source '${expression.path}' is absent or incompatible with nominal type '${target.name}'.`, expression.location);\n } else if (expression.kind === 'LiteralExpressionSyntax' && expression.value !== null) {\n const formatted = formatStreamIdLiteral(expression, target, application);\n if (formatted?.failure != null) context.error(DiagnosticCodes.InvalidCommandStream, streamIdFailureMessage(formatted.failure), expression.location);\n else if (!compatibleValue(expression, target, concepts, compositeProperties)) context.error(DiagnosticCodes.InvalidCommandStream, `Stream id value is incompatible with nominal type '${target.name}'.`, expression.location);\n } else if (['RawExpressionSyntax', 'ObjectExpressionSyntax', 'ListExpressionSyntax'].includes(expression.kind) || expression.kind === 'LiteralExpressionSyntax' && expression.value === null)\n context.error(DiagnosticCodes.InvalidCommandStream, 'A stream id needs a scalar value source, not a raw expression, collection or absence.', expression.location);\n };\n if (stream.streamIdParts.length > 0) {\n validateStreamIdParts(stream, route.streamIdParts, route.streamId !== null, route.location, DiagnosticCodes.InvalidCommandStream, context, validateMapping);\n continue;\n }\n if (route.streamIdParts.length > 0) {\n context.error(DiagnosticCodes.InvalidCommandStream, 'A streamId part block requires a composite stream.', route.location);\n continue;\n }\n if (stream.streamId === null && route.streamId !== null || stream.streamId !== null && route.streamId === null)\n context.error(DiagnosticCodes.InvalidCommandStream, stream.streamId === null ? 'An unkeyed stream cannot take a streamId mapping.' : 'This keyed stream requires a streamId mapping.', route.location);\n if (stream.streamId === null || route.streamId === null) continue;\n validateMapping(route.streamId, stream.streamId);\n }\n validateSpecificationStreams(application, context);\n}\n"],"mappings":"A,8wBAkBA,MAAM,gBAAkB,EAA2C,IAC/DA,GAAQ,MAAQC,GAAS,MAAQD,GAAM,OAAS,wBAA0BC,GAAO,OAAS,wBAA0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AS,2BAA6BA,EAAW,QAAU,KAAM,CACnF,IAAM8C,EAAY,sBAAsB9C,EAAYW,EAAQf,CAAW,EACnEkD,GAAW,SAAW,KAChBC,EAAgB/C,EAAYW,EAAQhB,EAAUa,CAAmB,GAAGK,EAAQ,MAAMC,EAAgB,qBAAsB,sDAAsDH,EAAO,KAAK,IAAKX,EAAW,QAAQ,EAD5La,EAAQ,MAAMC,EAAgB,qBAAsBkC,EAAuBF,EAAU,OAAO,EAAG9C,EAAW,QAAQ,CAEtJ,MAAW,CAAC,sBAAuB,yBAA0B,sBAAsB,CAAC,CAAC,SAASA,EAAW,IAAI,GAAKA,EAAW,OAAS,2BAA6BA,EAAW,QAAU,OACpLa,EAAQ,MAAMC,EAAgB,qBAAsB,wFAAyFd,EAAW,QAAQ,CACxK,EACIoB,EAAO,cAAc,OAAS,EAC9B6B,EAAsB7B,EAAQiB,EAAM,cAAeA,EAAM,WAAa,KAAMA,EAAM,SAAUvB,EAAgB,qBAAsBD,EAAS,eAAe,EAG1JwB,EAAM,cAAc,OAAS,EAC7BxB,EAAQ,MAAMC,EAAgB,qBAAsB,qDAAsDuB,EAAM,QAAQ,IAGxHjB,EAAO,WAAa,MAAQiB,EAAM,WAAa,MAAQjB,EAAO,WAAa,MAAQiB,EAAM,WAAa,OACtGxB,EAAQ,MAAMC,EAAgB,qBAAsBM,EAAO,WAAa,KAAO,oDAAsD,iDAAkDiB,EAAM,QAAQ,EACrMjB,EAAO,WAAa,MAAQiB,EAAM,WAAa,MACnD,gBAAgBA,EAAM,SAAUjB,EAAO,QAAQ,EACnD,CACA8B,EAA6BtD,EAAaiB,CAAO,CACrD,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{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.js";import{eventDeclarations as n}from"../Syntax/EventDeclarations.js";import{supportsStreamIdentity as r}from"./EventSourceValidator.js";function validateEventSubjects(i,a){let refuse=(t,n)=>{for(let r of t.filter(e=>e.isSubject))a.error(e.InvalidSubjectOwner,`The subject modifier is only valid on event properties, not ${n} properties (decision 0008: one data subject per event).`,r.location)};for(let e of i.types)refuse(e.properties,`type`);for(let{slice:o}of new t(i).slices){for(let e of o.commands)refuse(e.properties,`command`);for(let t of o.readModels)for(let n of t.properties.filter(e=>e.isSubject))a.error(e.ReadModelSubjectNotSupported,`Read model subject marks are not yet supported. Chronicle resolves read model subjects and reserves _subject, __subject and __subjects; Screenplay support is tracked in #559.`,n.location);for(let t of n(o)){let n=t.properties.filter(e=>e.isSubject);for(let r of n.slice(1))a.error(e.DuplicateEventSubject,`Event '${t.name}' has one data subject (decision 0008); '${r.name}' is an extra mark after '${n[0].name}'. Choose one subject; no automatic repair is safe.`,r.location);for(let t of n){let n=t.type;if(n.isOptional){a.error(e.InvalidSubjectType,`A subject must be required: a null value silently falls back to the event source.`,t.location);continue}if(n.isCollection||i.types.some(e=>e.name===n.name)){a.error(e.InvalidSubjectType,`A subject must be a scalar identity, not a collection or composite type.`,t.location);continue}let o=i.concepts.filter(e=>e.name===n.name);o.some(e=>e.attributes.some(e=>[`pii`,`sensitive`].includes(e.name)))&&a.error(e.ProtectedSubjectType,`Subject concept '${n.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`,t.location);let s=o.length===1?o[0].type:o.length===0&&[`String`,`Uuid`,`Int`,`Decimal`,`Bool`,`Date`,`DateTime`].includes(n.name)?n.name:null;o.length===0&&s===null&&i.imports.some(e=>e.qualifiedName===n.name||e.qualifiedName.split(`.`).at(-1)===n.name)&&a.warning(e.UnknownType,`Unknown type shape '${n.name}' for subject property '${t.name}'; imported subject identity rules cannot be verified.`,t.location),(o.some(e=>e.type===`Enum`)||s!==null&&!r(n,i))&&a.error(e.InvalidSubjectType,`Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.`,t.location)}}}}export{validateEventSubjects};
|
|
2
2
|
//# sourceMappingURL=EventSubjectValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventSubjectValidator.js","names":["property","properties","context","DiagnosticCodes","owner","type","application","AuthoringProductionResolver","command","slice","model","event","eventDeclarations","subjects","extra","composite","concepts","concept","attribute","primitive","imported","supportsStreamIdentity"],"sources":["../../../../../../Compiler/Parsing/EventSubjectValidator.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 { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { supportsStreamIdentity } from './EventSourceValidator';\nimport { ParserContext } from './ParserContext';\n\nexport function validateEventSubjects(application: ApplicationSyntax, context: ParserContext): void {\n const refuse = (properties: readonly PropertySyntax[], owner: string): void => {\n for (const property of properties.filter(property => property.isSubject))\n context.error(DiagnosticCodes.InvalidSubjectOwner, `The subject modifier is only valid on event properties, not ${owner} properties (decision 0008: one data subject per event).`, property.location);\n };\n for (const type of application.types) refuse(type.properties, 'type');\n for (const { slice } of new AuthoringProductionResolver(application).slices) {\n for (const command of slice.commands) refuse(command.properties, 'command');\n for (const model of slice.readModels) for (const property of model.properties.filter(property => property.isSubject))\n context.error(DiagnosticCodes.ReadModelSubjectNotSupported, 'Read model subject marks are not yet supported. Chronicle resolves read model subjects and reserves _subject, __subject and __subjects; Screenplay support is tracked in #559.', property.location);\n for (const event of eventDeclarations(slice)) {\n const subjects = event.properties.filter(property => property.isSubject);\n for (const extra of subjects.slice(1))\n context.error(DiagnosticCodes.DuplicateEventSubject, `Event '${event.name}' has one data subject (decision 0008); '${extra.name}' is an extra mark after '${subjects[0].name}'. Choose one subject; no automatic repair is safe.`, extra.location);\n for (const property of subjects) {\n const type = property.type;\n if (type.isOptional) {\n context.error(DiagnosticCodes.InvalidSubjectType, 'A subject must be required: a null value silently falls back to the event source.', property.location);\n continue;\n }\n if (type.isCollection || application.types.some(composite => composite.name === type.name)) {\n context.error(DiagnosticCodes.InvalidSubjectType, 'A subject must be a scalar identity, not a collection or composite type.', property.location);\n continue;\n }\n const concepts = application.concepts.filter(concept => concept.name === type.name);\n if (concepts.some(concept => concept.attributes.some(attribute => ['pii', 'sensitive'].includes(attribute.name))))\n context.error(DiagnosticCodes.ProtectedSubjectType, `Subject concept '${type.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`, property.location);\n const primitive = concepts.length === 1 ? concepts[0].type : concepts.length === 0 && ['String', 'Uuid', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'].includes(type.name) ? type.name : null;\n if (concepts.length === 0 && primitive === null && application.imports.some(imported => imported.qualifiedName === type.name || imported.qualifiedName.split('.').at(-1) === type.name))\n context.warning(DiagnosticCodes.UnknownType, `Unknown type shape '${type.name}' for subject property '${property.name}'; imported subject identity rules cannot be verified.`, property.location);\n if (concepts.some(concept => concept.type === 'Enum') || primitive !== null && !supportsStreamIdentity(type, application))\n context.error(DiagnosticCodes.InvalidSubjectType, 'Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.', property.location);\n }\n }\n }\n}\n"],"mappings":"sVAWA,SAAgB,sBAAsB,EAAgC,EAA8B,CAChG,IAAM,QAAU,EAAuC,IAAwB,CAC3E,IAAK,IAAMA,KAAYC,EAAW,OAAO,GAAYD,EAAS,SAAS,EACnEE,EAAQ,MAAMC,EAAgB,oBAAqB,+DAA+DC,EAAM,0DAA2DJ,EAAS,QAAQ,CAC5M,EACA,IAAK,IAAMK,KAAQC,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AAIA,EAAS,EAAE,CAAC,KAAOA,EAAS,SAAW,GAAK,CAAC,SAAU,OAAQ,MAAO,UAAW,OAAQ,OAAQ,UAAU,CAAC,CAAC,SAASX,EAAK,IAAI,EAAIA,EAAK,KAAO,KACrLW,EAAS,SAAW,GAAKG,IAAc,MAAQb,EAAY,QAAQ,KAAK,GAAYc,EAAS,gBAAkBf,EAAK,MAAQe,EAAS,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,IAAMf,EAAK,IAAI,GAClLH,EAAQ,QAAQC,EAAgB,YAAa,uBAAuBE,EAAK,KAAK,0BAA0BL,EAAS,KAAK,wDAAyDA,EAAS,QAAQ,GAChMgB,EAAS,KAAK,GAAWC,EAAQ,OAAS,MAAM,GAAKE,IAAc,MAAQ,CAACE,EAAuBhB,EAAMC,CAAW,IACpHJ,EAAQ,MAAMC,EAAgB,mBAAoB,6IAA8IH,EAAS,QAAQ,CACzN,CACJ,CACJ,CACJ"}
|
|
1
|
+
{"version":3,"file":"EventSubjectValidator.js","names":["property","properties","context","DiagnosticCodes","owner","type","application","AuthoringProductionResolver","command","slice","model","event","eventDeclarations","subjects","extra","composite","concepts","concept","attribute","primitive","imported","supportsStreamIdentity"],"sources":["../../../../../../Compiler/Parsing/EventSubjectValidator.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 { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { supportsStreamIdentity } from './EventSourceValidator';\nimport { ParserContext } from './ParserContext';\n\nexport function validateEventSubjects(application: ApplicationSyntax, context: ParserContext): void {\n const refuse = (properties: readonly PropertySyntax[], owner: string): void => {\n for (const property of properties.filter(property => property.isSubject))\n context.error(DiagnosticCodes.InvalidSubjectOwner, `The subject modifier is only valid on event properties, not ${owner} properties (decision 0008: one data subject per event).`, property.location);\n };\n for (const type of application.types) refuse(type.properties, 'type');\n for (const { slice } of new AuthoringProductionResolver(application).slices) {\n for (const command of slice.commands) refuse(command.properties, 'command');\n for (const model of slice.readModels) for (const property of model.properties.filter(property => property.isSubject))\n context.error(DiagnosticCodes.ReadModelSubjectNotSupported, 'Read model subject marks are not yet supported. Chronicle resolves read model subjects and reserves _subject, __subject and __subjects; Screenplay support is tracked in #559.', property.location);\n for (const event of eventDeclarations(slice)) {\n const subjects = event.properties.filter(property => property.isSubject);\n for (const extra of subjects.slice(1))\n context.error(DiagnosticCodes.DuplicateEventSubject, `Event '${event.name}' has one data subject (decision 0008); '${extra.name}' is an extra mark after '${subjects[0].name}'. Choose one subject; no automatic repair is safe.`, extra.location);\n for (const property of subjects) {\n const type = property.type;\n if (type.isOptional) {\n context.error(DiagnosticCodes.InvalidSubjectType, 'A subject must be required: a null value silently falls back to the event source.', property.location);\n continue;\n }\n if (type.isCollection || application.types.some(composite => composite.name === type.name)) {\n context.error(DiagnosticCodes.InvalidSubjectType, 'A subject must be a scalar identity, not a collection or composite type.', property.location);\n continue;\n }\n const concepts = application.concepts.filter(concept => concept.name === type.name);\n if (concepts.some(concept => concept.attributes.some(attribute => ['pii', 'sensitive'].includes(attribute.name))))\n context.error(DiagnosticCodes.ProtectedSubjectType, `Subject concept '${type.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`, property.location);\n const primitive = concepts.length === 1 ? concepts[0].type : concepts.length === 0 && ['String', 'Uuid', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime'].includes(type.name) ? type.name : null;\n if (concepts.length === 0 && primitive === null && application.imports.some(imported => imported.qualifiedName === type.name || imported.qualifiedName.split('.').at(-1) === type.name))\n context.warning(DiagnosticCodes.UnknownType, `Unknown type shape '${type.name}' for subject property '${property.name}'; imported subject identity rules cannot be verified.`, property.location);\n if (concepts.some(concept => concept.type === 'Enum') || primitive !== null && !supportsStreamIdentity(type, application))\n context.error(DiagnosticCodes.InvalidSubjectType, 'Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.', property.location);\n }\n }\n }\n}\n"],"mappings":"A,sVAWA,SAAgB,sBAAsB,EAAgC,EAA8B,CAChG,IAAM,QAAU,EAAuC,IAAwB,CAC3E,IAAK,IAAMA,KAAYC,EAAW,OAAO,GAAYD,EAAS,SAAS,EACnEE,EAAQ,MAAMC,EAAgB,oBAAqB,+DAA+DC,EAAM,0DAA2DJ,EAAS,QAAQ,CAC5M,EACA,IAAK,IAAMK,KAAQC,EAAY,MAAO,OAAOD,EAAK,WAAY,MAAM,EACpE,IAAK,GAAM,CAAE,WAAW,IAAIE,EAA4BD,CAAW,CAAC,CAAC,OAAQ,CACzE,IAAK,IAAME,KAAWC,EAAM,SAAU,OAAOD,EAAQ,WAAY,SAAS,EAC1E,IAAK,IAAME,KAASD,EAAM,WAAY,IAAK,IAAMT,KAAYU,EAAM,WAAW,OAAO,GAAYV,EAAS,SAAS,EAC/GE,EAAQ,MAAMC,EAAgB,6BAA8B,iLAAkLH,EAAS,QAAQ,EACnQ,IAAK,IAAMW,KAASC,EAAkBH,CAAK,EAAG,CAC1C,IAAMI,EAAWF,EAAM,WAAW,OAAO,GAAYX,EAAS,SAAS,EACvE,IAAK,IAAMc,KAASD,EAAS,MAAM,CAAC,EAChCX,EAAQ,MAAMC,EAAgB,sBAAuB,UAAUQ,EAAM,KAAK,2CAA2CG,EAAM,KAAK,4BAA4BD,EAAS,EAAE,CAAC,KAAK,qDAAsDC,EAAM,QAAQ,EACrP,IAAK,IAAMd,KAAYa,EAAU,CAC7B,IAAMR,EAAOL,EAAS,KACtB,GAAIK,EAAK,WAAY,CACjBH,EAAQ,MAAMC,EAAgB,mBAAoB,oFAAqFH,EAAS,QAAQ,EACxJ,QACJ,CACA,GAAIK,EAAK,cAAgBC,EAAY,MAAM,KAAK,GAAaS,EAAU,OAASV,EAAK,IAAI,EAAG,CACxFH,EAAQ,MAAMC,EAAgB,mBAAoB,2EAA4EH,EAAS,QAAQ,EAC/I,QACJ,CACA,IAAMgB,EAAWV,EAAY,SAAS,OAAO,GAAWW,EAAQ,OAASZ,EAAK,IAAI,EAC9EW,EAAS,KAAK,GAAWC,EAAQ,WAAW,KAAK,GAAa,CAAC,MAAO,WAAW,CAAC,CAAC,SAASC,EAAU,IAAI,CAAC,CAAC,GAC5GhB,EAAQ,MAAMC,EAAgB,qBAAsB,oBAAoBE,EAAK,KAAK,iGAAkGL,EAAS,QAAQ,EACzM,IAAMmB,EAAYH,EAAS,SAAW,EAAIA,EAAS,EAAE,CAAC,KAAOA,EAAS,SAAW,GAAK,CAAC,SAAU,OAAQ,MAAO,UAAW,OAAQ,OAAQ,UAAU,CAAC,CAAC,SAASX,EAAK,IAAI,EAAIA,EAAK,KAAO,KACrLW,EAAS,SAAW,GAAKG,IAAc,MAAQb,EAAY,QAAQ,KAAK,GAAYc,EAAS,gBAAkBf,EAAK,MAAQe,EAAS,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,IAAMf,EAAK,IAAI,GAClLH,EAAQ,QAAQC,EAAgB,YAAa,uBAAuBE,EAAK,KAAK,0BAA0BL,EAAS,KAAK,wDAAyDA,EAAS,QAAQ,GAChMgB,EAAS,KAAK,GAAWC,EAAQ,OAAS,MAAM,GAAKE,IAAc,MAAQ,CAACE,EAAuBhB,EAAMC,CAAW,IACpHJ,EAAQ,MAAMC,EAAgB,mBAAoB,6IAA8IH,EAAS,QAAQ,CACzN,CACJ,CACJ,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{isExactNumberToken as t,parseExactNumber as n}from"../Syntax/ExactNumber.js";import{nativePattern as r,pattern as i}from"../Text/patterns.js";import{unescapeString as a}from"../Text/StringLiteral.js";import{InvalidStructuredValue as o,StructuredValueParser as s}from"./StructuredValueParser.js";const c=i(`^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$`),l=r(`^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$`),u=i(`^-?\\d+(\\.\\d+)?$`),d=[`command`,`arguments`,`tenant`,`causedBy`,`causation`,`occurred`,`identity`],f=[`subject`,`name`,`userName`],p=[`id`,`name`,`userName`,`isAuthenticated`,`roles`,`claims`],m=`Screenplay has no JSON values - write the object or list as an indented block: one 'member = value' line per member, one 'item' line per list element, and '<name> none' for an empty list`;function parseModeledMappingSource(e,t,n){return parseMappingSource(e,t,n,!0)}function parseMappingSource(t,n,r,i=!1){if(t=t.trim(),t===`$refusal`||t.startsWith(`$refusal.`))return{kind:`RefusalExpressionSyntax`,member:t===`$refusal`?``:t.substring(9),location:n};if(t===`$eventSourceId`)return{kind:`EventSourceIdExpressionSyntax`,location:n};if(t===`$eventContext.eventSourceId`)return{kind:`EventContextExpressionSyntax`,path:`eventSourceId`,location:n};if(t===`$identity`||t===`$identity.`)return r?.error(e.InvalidExpression,`Invalid expression '${t}'`,n),{kind:`RawExpressionSyntax`,text:t,location:n};if(t.startsWith(`$identity.`)){let e=t.substring(10);return r?.deferIdentityValidation!==!0&&warnOnUnknownIdentityProperty(e.split(`.`)[0],`$identity`,n,r),{kind:`IdentityExpressionSyntax`,path:e,location:n}}if(t.startsWith(`$context.`)){let e=t.substring(9);return warnOnUnknownContextPath(e,n,r),{kind:`ContextExpressionSyntax`,path:e,location:n}}if(t.startsWith(`$env.`))return{kind:`EnvironmentExpressionSyntax`,name:t.substring(5),location:n};if(t.startsWith(`$strings.`))return{kind:`StringsExpressionSyntax`,key:t.substring(9),location:n};if(t.startsWith(`$.`))return{kind:`SourceItemExpressionSyntax`,path:t.substring(2),location:n};if(t.startsWith(`{`)||t.startsWith(`[`)){r?.error(e.InlineJsonValue,m,n);try{return new s(t,n,r).parse()}catch(i){if(!(i instanceof o))throw i;return r?.error(e.InvalidStructuredValue,`Invalid inline structured value: ${i.message}`,n),{kind:`RawExpressionSyntax`,text:t,location:n}}}let a=r===void 0?parseLiteral(t,n):parseLiteral(t,n,r);return a===void 0?(i||r?.sourceOptions.numericMode===`exact`?l:c).test(t)?{kind:`PathExpressionSyntax`,path:t,location:n}:{kind:`RawExpressionSyntax`,text:t,location:n}:a}function warnOnUnknownContextPath(t,n,r){let[i,a]=t.split(`.`);d.includes(i)?a!==void 0&&i===`causedBy`&&!f.includes(a)?r?.warning(e.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${a}' - expected ${f.join(`, `)}`,n):a!==void 0&&i===`identity`&&warnOnUnknownIdentityProperty(a,`$context.identity`,n,r):r?.warning(e.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${d.join(`, `)}`,n)}function warnOnUnknownIdentityProperty(t,n,r,i){p.includes(t)||i?.warning(e.UnknownContextIdentityProperty,`Unknown ${n} property '${t}' - expected ${p.join(`, `)}`,r)}function parseLiteral(r,i,o){let literal=e=>({kind:`LiteralExpressionSyntax`,value:e,location:i});switch(r){case`true`:return literal(!0);case`false`:return literal(!1);case`null`:return literal(null)}if(r.length>=2&&(r.startsWith(`"`)&&r.endsWith(`"`)||r.startsWith(`'`)&&r.endsWith(`'`)))return literal(a(r.substring(1,r.length-1)));if(o?.sourceOptions.numericMode===`exact`){if(!t(r))return;let a=n(r);return a===void 0?(o.error(e.InexactNumericLiteral,`Numeric literal is not exactly representable in the bounded Decimal domain.`,i),{kind:`RawExpressionSyntax`,text:r,location:i}):literal(a)}if(u.test(r)&&!Number.isNaN(Number(r)))return literal(Number(r))}export{d as contextRoots,p as identityProperties,m as inlineJsonMessage,parseLiteral,parseMappingSource,parseModeledMappingSource};
|
|
2
2
|
//# sourceMappingURL=ExpressionParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionParser.js","names":["pathPattern","pattern","nativePathPattern","nativePattern","numberPattern","contextRoots","causedByProperties","identityProperties","inlineJsonMessage","text","location","context","DiagnosticCodes","path","StructuredValueParser","error","InvalidStructuredValue","literal","nativeIdentifiers","root","member","unescapeString","isExactNumberToken","number","parseExactNumber"],"sources":["../../../../../../Compiler/Parsing/ExpressionParser.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 { ExpressionSyntax, LiteralExpressionSyntax } from '../Syntax/Expressions';\nimport { ExactNumber, isExactNumberToken, parseExactNumber } from '../Syntax/ExactNumber';\nimport { nativePattern, pattern } from '../Text/patterns';\nimport { unescapeString } from '../Text/StringLiteral';\nimport { ParserContext } from './ParserContext';\nimport { InvalidStructuredValue, StructuredValueParser } from './StructuredValueParser';\n\nconst pathPattern = pattern('^@?[A-Za-z_]\\\\w*(\\\\.@?[A-Za-z_$]\\\\w*)*$');\nconst nativePathPattern = nativePattern('^@?[A-Za-z_]\\\\w*(\\\\.@?[A-Za-z_$]\\\\w*)*$');\nconst numberPattern = pattern('^-?\\\\d+(\\\\.\\\\d+)?$');\nconst contextRoots = ['command', 'arguments', 'tenant', 'causedBy', 'causation', 'occurred', 'identity'];\nconst causedByProperties = ['subject', 'name', 'userName'];\nexport const identityProperties = ['id', 'name', 'userName', 'isAuthenticated', 'roles', 'claims'];\n\n// Reads the right-hand side of a mapping or a rule operand - the port of the C# ExpressionParser's\n// ParseMappingSource. With a context it also reports what the C# compiler reports while reading one: an\n// unknown $context path, and an inline structured value that is not valid JSON.\nexport const inlineJsonMessage = \"Screenplay has no JSON values - write the object or list as an indented block: one 'member = value' line per member, one 'item' line per list element, and '<name> none' for an empty list\";\n\nexport function parseModeledMappingSource(text: string, location: SourceLocation, context: ParserContext): ExpressionSyntax {\n return parseMappingSource(text, location, context, true);\n}\n\nexport function parseMappingSource(text: string, location: SourceLocation, context?: ParserContext, nativeIdentifiers = false): ExpressionSyntax {\n text = text.trim();\n if (text === '$refusal' || text.startsWith('$refusal.')) {\n return { kind: 'RefusalExpressionSyntax', member: text === '$refusal' ? '' : text.substring('$refusal.'.length), location };\n }\n if (text === '$eventSourceId') {\n return { kind: 'EventSourceIdExpressionSyntax', location };\n }\n if (text === '$eventContext.eventSourceId') {\n return { kind: 'EventContextExpressionSyntax', path: 'eventSourceId', location };\n }\n if (text === '$identity' || text === '$identity.') {\n context?.error(DiagnosticCodes.InvalidExpression, `Invalid expression '${text}'`, location);\n return { kind: 'RawExpressionSyntax', text, location };\n }\n if (text.startsWith('$identity.')) {\n const path = text.substring('$identity.'.length);\n if (context?.deferIdentityValidation !== true) warnOnUnknownIdentityProperty(path.split('.')[0], '$identity', location, context);\n return { kind: 'IdentityExpressionSyntax', path, location };\n }\n if (text.startsWith('$context.')) {\n const path = text.substring('$context.'.length);\n warnOnUnknownContextPath(path, location, context);\n return { kind: 'ContextExpressionSyntax', path, location };\n }\n if (text.startsWith('$env.')) {\n return { kind: 'EnvironmentExpressionSyntax', name: text.substring('$env.'.length), location };\n }\n if (text.startsWith('$strings.')) {\n return { kind: 'StringsExpressionSyntax', key: text.substring('$strings.'.length), location };\n }\n if (text.startsWith('$.')) {\n return { kind: 'SourceItemExpressionSyntax', path: text.substring('$.'.length), location };\n }\n if (text.startsWith('{') || text.startsWith('[')) {\n // Screenplay has no JSON. The value is still read so the tree stays whole and printing it writes the block form.\n context?.error(DiagnosticCodes.InlineJsonValue, inlineJsonMessage, location);\n try {\n return new StructuredValueParser(text, location, context).parse();\n } catch (error) {\n if (!(error instanceof InvalidStructuredValue)) {\n throw error;\n }\n context?.error(DiagnosticCodes.InvalidStructuredValue, `Invalid inline structured value: ${error.message}`, location);\n return { kind: 'RawExpressionSyntax', text, location };\n }\n }\n const literal = context === undefined ? parseLiteral(text, location) : parseLiteral(text, location, context);\n if (literal !== undefined) {\n return literal;\n }\n if ((nativeIdentifiers || context?.sourceOptions.numericMode === 'exact' ? nativePathPattern : pathPattern).test(text)) {\n return { kind: 'PathExpressionSyntax', path: text, location };\n }\n return { kind: 'RawExpressionSyntax', text, location };\n}\n\nfunction warnOnUnknownContextPath(path: string, location: SourceLocation, context: ParserContext | undefined): void {\n const [root, member] = path.split('.');\n if (!contextRoots.includes(root)) {\n context?.warning(DiagnosticCodes.UnknownContextPath, `Unknown $context path '${path}' - expected one of ${contextRoots.join(', ')}`, location);\n } else if (member !== undefined && root === 'causedBy' && !causedByProperties.includes(member)) {\n context?.warning(DiagnosticCodes.UnknownContextCausedByProperty,\n `Unknown $context.causedBy property '${member}' - expected ${causedByProperties.join(', ')}`, location);\n } else if (member !== undefined && root === 'identity') {\n warnOnUnknownIdentityProperty(member, '$context.identity', location, context);\n }\n}\n\nfunction warnOnUnknownIdentityProperty(member: string, root: string, location: SourceLocation, context: ParserContext | undefined): void {\n if (!identityProperties.includes(member)) {\n context?.warning(DiagnosticCodes.UnknownContextIdentityProperty,\n `Unknown ${root} property '${member}' - expected ${identityProperties.join(', ')}`, location);\n }\n}\n\nexport function parseLiteral(text: string, location: SourceLocation): LiteralExpressionSyntax | undefined;\nexport function parseLiteral(text: string, location: SourceLocation, context: ParserContext): ExpressionSyntax | undefined;\nexport function parseLiteral(text: string, location: SourceLocation, context?: ParserContext): ExpressionSyntax | undefined {\n const literal = (value: string | number | boolean | null | ExactNumber): LiteralExpressionSyntax => ({ kind: 'LiteralExpressionSyntax', value, location });\n switch (text) {\n case 'true':\n return literal(true);\n case 'false':\n return literal(false);\n case 'null':\n return literal(null);\n }\n const quoted = text.length >= 2 && ((text.startsWith('\"') && text.endsWith('\"')) || (text.startsWith('\\'') && text.endsWith('\\'')));\n if (quoted) {\n return literal(unescapeString(text.substring(1, text.length - 1)));\n }\n if (context?.sourceOptions.numericMode === 'exact') {\n if (!isExactNumberToken(text)) return undefined;\n const number = parseExactNumber(text);\n if (number !== undefined) return literal(number);\n context.error(DiagnosticCodes.InexactNumericLiteral, 'Numeric literal is not exactly representable in the bounded Decimal domain.', location);\n return { kind: 'RawExpressionSyntax', text, location };\n }\n // .NET also parses digits from other scripts; JavaScript's Number does not, so such a number is left to\n // be read as raw text - a divergence no real document is expected to meet.\n if (numberPattern.test(text) && !Number.isNaN(Number(text))) {\n return literal(Number(text));\n }\n return undefined;\n}\n"],"mappings":"uaAYA,MAAMA,EAAcC,EAAQ,yCAAyC,EAC/DC,EAAoBC,EAAc,yCAAyC,EAC3EC,EAAgBH,EAAQ,oBAAoB,EAC5CI,EAAe,CAAC,UAAW,YAAa,SAAU,WAAY,YAAa,WAAY,UAAU,EACjGC,EAAqB,CAAC,UAAW,OAAQ,UAAU,EAC5CC,EAAqB,CAAC,KAAM,OAAQ,WAAY,kBAAmB,QAAS,QAAQ,EAKpFC,EAAoB,6LAEjC,SAAgB,0BAA0B,EAAc,EAA0B,EAA0C,CACxH,OAAO,mBAAmBC,EAAMC,EAAUC,EAAS,EAAI,CAC3D,CAEA,SAAgB,mBAAmB,EAAc,EAA0B,EAAyB,EAAoB,GAAyB,CAE7I,GADA,EAAOF,EAAK,KAAK,EACbA,IAAS,YAAcA,EAAK,WAAW,WAAW,EAClD,MAAO,CAAE,KAAM,0BAA2B,OAAQA,IAAS,WAAa,GAAKA,EAAK,UAAU,CAAkB,EAAG,UAAS,EAE9H,GAAIA,IAAS,iBACT,MAAO,CAAE,KAAM,gCAAiC,UAAS,EAE7D,GAAIA,IAAS,8BACT,MAAO,CAAE,KAAM,+BAAgC,KAAM,gBAAiB,UAAS,EAEnF,GAAIA,IAAS,aAAeA,IAAS,aAEjC,OADAE,GAAS,MAAMC,EAAgB,kBAAmB,uBAAuBH,EAAK,GAAIC,CAAQ,EACnF,CAAE,KAAM,sBAAuB,OAAM,UAAS,EAEzD,GAAID,EAAK,WAAW,YAAY,EAAG,CAC/B,IAAMI,EA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,EAAG,OAC/B,IAAMc,EAASC,EAAiBf,CAAI,EAGpC,OAFIc,IAAW,IAAA,IACfZ,EAAQ,MAAMC,EAAgB,sBAAuB,8EAA+EF,CAAQ,EACrI,CAAE,KAAM,sBAAuB,OAAM,UAAS,GAFpB,QAAQa,CAAM,CAGnD,CAGA,GAAInB,EAAc,KAAKK,CAAI,GAAK,CAAC,OAAO,MAAM,OAAOA,CAAI,CAAC,EACtD,OAAO,QAAQ,OAAOA,CAAI,CAAC,CAGnC"}
|
|
1
|
+
{"version":3,"file":"ExpressionParser.js","names":["pathPattern","pattern","nativePathPattern","nativePattern","numberPattern","contextRoots","causedByProperties","identityProperties","inlineJsonMessage","text","location","context","DiagnosticCodes","path","StructuredValueParser","error","InvalidStructuredValue","literal","nativeIdentifiers","root","member","unescapeString","isExactNumberToken","number","parseExactNumber"],"sources":["../../../../../../Compiler/Parsing/ExpressionParser.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 { ExpressionSyntax, LiteralExpressionSyntax } from '../Syntax/Expressions';\nimport { ExactNumber, isExactNumberToken, parseExactNumber } from '../Syntax/ExactNumber';\nimport { nativePattern, pattern } from '../Text/patterns';\nimport { unescapeString } from '../Text/StringLiteral';\nimport { ParserContext } from './ParserContext';\nimport { InvalidStructuredValue, StructuredValueParser } from './StructuredValueParser';\n\nconst pathPattern = pattern('^@?[A-Za-z_]\\\\w*(\\\\.@?[A-Za-z_$]\\\\w*)*$');\nconst nativePathPattern = nativePattern('^@?[A-Za-z_]\\\\w*(\\\\.@?[A-Za-z_$]\\\\w*)*$');\nconst numberPattern = pattern('^-?\\\\d+(\\\\.\\\\d+)?$');\nexport const contextRoots = ['command', 'arguments', 'tenant', 'causedBy', 'causation', 'occurred', 'identity'];\nconst causedByProperties = ['subject', 'name', 'userName'];\nexport const identityProperties = ['id', 'name', 'userName', 'isAuthenticated', 'roles', 'claims'];\n\n// Reads the right-hand side of a mapping or a rule operand - the port of the C# ExpressionParser's\n// ParseMappingSource. With a context it also reports what the C# compiler reports while reading one: an\n// unknown $context path, and an inline structured value that is not valid JSON.\nexport const inlineJsonMessage = \"Screenplay has no JSON values - write the object or list as an indented block: one 'member = value' line per member, one 'item' line per list element, and '<name> none' for an empty list\";\n\nexport function parseModeledMappingSource(text: string, location: SourceLocation, context: ParserContext): ExpressionSyntax {\n return parseMappingSource(text, location, context, true);\n}\n\nexport function parseMappingSource(text: string, location: SourceLocation, context?: ParserContext, nativeIdentifiers = false): ExpressionSyntax {\n text = text.trim();\n if (text === '$refusal' || text.startsWith('$refusal.')) {\n return { kind: 'RefusalExpressionSyntax', member: text === '$refusal' ? '' : text.substring('$refusal.'.length), location };\n }\n if (text === '$eventSourceId') {\n return { kind: 'EventSourceIdExpressionSyntax', location };\n }\n if (text === '$eventContext.eventSourceId') {\n return { kind: 'EventContextExpressionSyntax', path: 'eventSourceId', location };\n }\n if (text === '$identity' || text === '$identity.') {\n context?.error(DiagnosticCodes.InvalidExpression, `Invalid expression '${text}'`, location);\n return { kind: 'RawExpressionSyntax', text, location };\n }\n if (text.startsWith('$identity.')) {\n const path = text.substring('$identity.'.length);\n if (context?.deferIdentityValidation !== true) warnOnUnknownIdentityProperty(path.split('.')[0], '$identity', location, context);\n return { kind: 'IdentityExpressionSyntax', path, location };\n }\n if (text.startsWith('$context.')) {\n const path = text.substring('$context.'.length);\n warnOnUnknownContextPath(path, location, context);\n return { kind: 'ContextExpressionSyntax', path, location };\n }\n if (text.startsWith('$env.')) {\n return { kind: 'EnvironmentExpressionSyntax', name: text.substring('$env.'.length), location };\n }\n if (text.startsWith('$strings.')) {\n return { kind: 'StringsExpressionSyntax', key: text.substring('$strings.'.length), location };\n }\n if (text.startsWith('$.')) {\n return { kind: 'SourceItemExpressionSyntax', path: text.substring('$.'.length), location };\n }\n if (text.startsWith('{') || text.startsWith('[')) {\n // Screenplay has no JSON. The value is still read so the tree stays whole and printing it writes the block form.\n context?.error(DiagnosticCodes.InlineJsonValue, inlineJsonMessage, location);\n try {\n return new StructuredValueParser(text, location, context).parse();\n } catch (error) {\n if (!(error instanceof InvalidStructuredValue)) {\n throw error;\n }\n context?.error(DiagnosticCodes.InvalidStructuredValue, `Invalid inline structured value: ${error.message}`, location);\n return { kind: 'RawExpressionSyntax', text, location };\n }\n }\n const literal = context === undefined ? parseLiteral(text, location) : parseLiteral(text, location, context);\n if (literal !== undefined) {\n return literal;\n }\n if ((nativeIdentifiers || context?.sourceOptions.numericMode === 'exact' ? nativePathPattern : pathPattern).test(text)) {\n return { kind: 'PathExpressionSyntax', path: text, location };\n }\n return { kind: 'RawExpressionSyntax', text, location };\n}\n\nfunction warnOnUnknownContextPath(path: string, location: SourceLocation, context: ParserContext | undefined): void {\n const [root, member] = path.split('.');\n if (!contextRoots.includes(root)) {\n context?.warning(DiagnosticCodes.UnknownContextPath, `Unknown $context path '${path}' - expected one of ${contextRoots.join(', ')}`, location);\n } else if (member !== undefined && root === 'causedBy' && !causedByProperties.includes(member)) {\n context?.warning(DiagnosticCodes.UnknownContextCausedByProperty,\n `Unknown $context.causedBy property '${member}' - expected ${causedByProperties.join(', ')}`, location);\n } else if (member !== undefined && root === 'identity') {\n warnOnUnknownIdentityProperty(member, '$context.identity', location, context);\n }\n}\n\nfunction warnOnUnknownIdentityProperty(member: string, root: string, location: SourceLocation, context: ParserContext | undefined): void {\n if (!identityProperties.includes(member)) {\n context?.warning(DiagnosticCodes.UnknownContextIdentityProperty,\n `Unknown ${root} property '${member}' - expected ${identityProperties.join(', ')}`, location);\n }\n}\n\nexport function parseLiteral(text: string, location: SourceLocation): LiteralExpressionSyntax | undefined;\nexport function parseLiteral(text: string, location: SourceLocation, context: ParserContext): ExpressionSyntax | undefined;\nexport function parseLiteral(text: string, location: SourceLocation, context?: ParserContext): ExpressionSyntax | undefined {\n const literal = (value: string | number | boolean | null | ExactNumber): LiteralExpressionSyntax => ({ kind: 'LiteralExpressionSyntax', value, location });\n switch (text) {\n case 'true':\n return literal(true);\n case 'false':\n return literal(false);\n case 'null':\n return literal(null);\n }\n const quoted = text.length >= 2 && ((text.startsWith('\"') && text.endsWith('\"')) || (text.startsWith('\\'') && text.endsWith('\\'')));\n if (quoted) {\n return literal(unescapeString(text.substring(1, text.length - 1)));\n }\n if (context?.sourceOptions.numericMode === 'exact') {\n if (!isExactNumberToken(text)) return undefined;\n const number = parseExactNumber(text);\n if (number !== undefined) return literal(number);\n context.error(DiagnosticCodes.InexactNumericLiteral, 'Numeric literal is not exactly representable in the bounded Decimal domain.', location);\n return { kind: 'RawExpressionSyntax', text, location };\n }\n // .NET also parses digits from other scripts; JavaScript's Number does not, so such a number is left to\n // be read as raw text - a divergence no real document is expected to meet.\n if (numberPattern.test(text) && !Number.isNaN(Number(text))) {\n return literal(Number(text));\n }\n return undefined;\n}\n"],"mappings":"A,uaAYA,MAAMA,EAAcC,EAAQ,yCAAyC,EAC/DC,EAAoBC,EAAc,yCAAyC,EAC3EC,EAAgBH,EAAQ,oBAAoB,EACrCI,EAAe,CAAC,UAAW,YAAa,SAAU,WAAY,YAAa,WAAY,UAAU,EACxGC,EAAqB,CAAC,UAAW,OAAQ,UAAU,EAC5CC,EAAqB,CAAC,KAAM,OAAQ,WAAY,kBAAmB,QAAS,QAAQ,EAKpFC,EAAoB,6LAEjC,SAAgB,0BAA0B,EAAc,EAA0B,EAA0C,CACxH,OAAO,mBAAmBC,EAAMC,EAAUC,EAAS,EAAI,CAC3D,CAEA,SAAgB,mBAAmB,EAAc,EAA0B,EAAyB,EAAoB,GAAyB,CAE7I,GADA,EAAOF,EAAK,KAAK,EACbA,IAAS,YAAcA,EAAK,WAAW,WAAW,EAClD,MAAO,CAAE,KAAM,0BAA2B,OAAQA,IAAS,WAAa,GAAKA,EAAK,UAAU,CAAkB,EAAG,UAAS,EAE9H,GAAIA,IAAS,iBACT,MAAO,C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AO,QAAQ,IAAI,CAC3B,CAEA,GADeA,EAAK,QAAU,IAAOA,EAAK,WAAW,GAAG,GAAKA,EAAK,SAAS,GAAG,GAAOA,EAAK,WAAW,GAAI,GAAKA,EAAK,SAAS,GAAI,GAE5H,OAAO,QAAQY,EAAeZ,EAAK,UAAU,EAAGA,EAAK,OAAS,CAAC,CAAC,CAAC,EAErE,GAAIE,GAAS,cAAc,cAAgB,QAAS,CAChD,GAAI,CAACW,EAAmBb,CAAI,EAAG,OAC/B,IAAMc,EAASC,EAAiBf,CAAI,EAGpC,OAFIc,IAAW,IAAA,IACfZ,EAAQ,MAAMC,EAAgB,sBAAuB,8EAA+EF,CAAQ,EACrI,CAAE,KAAM,sBAAuB,OAAM,UAAS,GAFpB,QAAQa,CAAM,CAGnD,CAGA,GAAInB,EAAc,KAAKK,CAAI,GAAK,CAAC,OAAO,MAAM,OAAOA,CAAI,CAAC,EACtD,OAAO,QAAQ,OAAOA,CAAI,CAAC,CAGnC,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{combineAuthorize as n,parseAuthorize as r,recordAuthorizationRefusal as i}from"./AuthorizeParser.js";import{parseDescription as a}from"./DescriptionParser.js";import{parsePurposeReference as o}from"./PurposeParser.js";import{parseDocumentation as s}from"./DocumentationParser.js";import{parseDependsOn as c}from"./DependsOnParser.js";import{parseFileImport as l}from"./FileImportParser.js";import{collectInputUses as u}from"./InputUses.js";import{firstWord as d}from"./LineText.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseToolbar as m}from"./ScreenParser.js";import{parseSlice as h}from"./SliceParser.js";import{locationOf as g}from"./SourceLine.js";const _=t(`^feature\\s+([A-Za-z_]\\w*)$`),v=/* @__PURE__ */ new Set([`on`,`uses`,`contribute`,`template`]),y=`description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, toolbar, example, 'on <trigger>' or 'uses <Behavior>'`;var FeatureBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=[];#o=[];#s=null;#c=null;#l=null;#u=!1;constructor(e){this.name=e}tryParse(t,g){let _=d(g.content);switch(_){case`runs`:return f(t,g),!0;case`description`:return this.#s=a(t,g,this.#s,`Feature '${this.name}'`),!0;case`documentation`:return this.#c=s(t,g,this.#c,`Feature '${this.name}'`),!0;case`depends`:return c(t,g,this.#i,e.UnknownFeatureDirective),!0;case`purpose`:return o(t,g,this.#a),!0;case`authorize`:{let a=t.diagnostics.length,o=r(t,g);if(o===null&&t.diagnostics.slice(a).some(t=>t.code===e.ConditionDepthExceeded)&&(this.#l=null,this.#u=!0),!this.#u){let e=this.#l;this.#l=n(this.#l,o,t),this.#u=e!==null&&this.#l===null}return this.#u&&i(this.#r),!0}case`import`:return l(t,g,this.#r),!0;case`toolbar`:return this.#o.push(m(t,g)),!0;case`feature`:return this.#e.push(parseFeature(t,g)),!0;case`example`:return this.#n.push(p(t,g)),!0;case`slice`:return this.#t.push(h(t,g)),!0;default:return v.has(_)?(u(t,g),!0):!1}}build(e,t=!1){return{kind:`FeatureSyntax`,name:this.name,description:this.#s,documentation:this.#c,authorize:this.#l,dependsOn:this.#i,purposes:this.#a,...this.#o.length>0?{toolbars:this.#o}:{},features:this.#e,slices:this.#t,examples:this.#n,fileImports:this.#r,isPlacement:t,location:e}}};function parseFeature(t,n){let r=_.exec(n.content)?.[1]??``;r===``&&t.error(e.InvalidFeatureDeclaration,`Invalid feature declaration '${n.content}' - expected 'feature <Name>'`,g(n));let i=new FeatureBody(r),a=t.scope;t.scope=[...a,r];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))t.reader.takeSignificant(),i.tryParse(t,r)||(t.error(e.UnknownFeatureDirective,`Unexpected '${d(r.content)}' in feature body - expected ${y}`,g(r)),t.skipBlock(r.indent));return t.scope=a,i.build(g(n))}export{FeatureBody,y as featureBodyExpected,parseFeature};
|
|
2
2
|
//# sourceMappingURL=FeatureBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureBody.js","names":["featurePattern","pattern","opaqueFeatureMembers","featureBodyExpected","name","keyword","firstWord","line","misplacedReactionIdentity","context","#description","parseDescription","#documentation","parseDocumentation","parseDependsOn","#dependsOn","DiagnosticCodes","parsePurposeReference","#purposes","#authorize","combineAuthorize","parseAuthorize","parseFileImport","#fileImports","#toolbars","parseToolbar","#features","#examples","parseExample","#slices","parseSlice","collectInputUses","locationOf","body","previous","child"],"sources":["../../../../../../Compiler/Parsing/FeatureBody.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { DependsOnSyntax, FeatureSyntax, FileImportSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ScreenToolbarSyntax } from '../Syntax/Screens';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { parsePurposeReference } from './PurposeParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { parseDependsOn } from './DependsOnParser';\nimport { parseFileImport } from './FileImportParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseToolbar } from './ScreenParser';\nimport { parseSlice } from './SliceParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst featurePattern = pattern('^feature\\\\s+([A-Za-z_]\\\\w*)$');\n\n// Feature members the C# compiler knows that this compiler does not model. They are skipped whole, not reported.\nconst opaqueFeatureMembers = new Set(['on', 'uses', 'contribute', 'template']);\n\n// What a feature body may hold, as it reads in a diagnostic.\nexport const featureBodyExpected = 'description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, toolbar, example, \\'on <trigger>\\' or \\'uses <Behavior>\\'';\n\n// Collects the body of a feature - written beneath a 'feature' header, or at the top level of a file imported\n// into the feature. The port of the C# FeatureBody.\nexport class FeatureBody {\n readonly #features: FeatureSyntax[] = [];\n readonly #slices: SliceSyntax[] = [];\n readonly #examples: SpecificationExampleSyntax[] = [];\n readonly #fileImports: FileImportSyntax[] = [];\n readonly #dependsOn: DependsOnSyntax[] = [];\n readonly #purposes: PurposeReferenceSyntax[] = [];\n readonly #toolbars: ScreenToolbarSyntax[] = [];\n #description: string | null = null;\n #documentation: string | null = null;\n #authorize: AuthorizeSyntax | null = null;\n\n constructor(readonly name: string) {}\n\n // Parses one already consumed line of the body; false when the line does not belong to a feature body,\n // and nothing was reported.\n tryParse(context: ParserContext, line: SourceLine): boolean {\n const keyword = firstWord(line.content);\n switch (keyword) {\n case 'runs':\n misplacedReactionIdentity(context, line);\n return true;\n case 'description':\n this.#description = parseDescription(context, line, this.#description, `Feature '${this.name}'`);\n return true;\n case 'documentation':\n this.#documentation = parseDocumentation(context, line, this.#documentation, `Feature '${this.name}'`);\n return true;\n case 'depends':\n parseDependsOn(context, line, this.#dependsOn, DiagnosticCodes.UnknownFeatureDirective);\n return true;\n case 'purpose':\n parsePurposeReference(context, line, this.#purposes);\n return true;\n case 'authorize':\n this.#authorize = combineAuthorize(this.#authorize, parseAuthorize(context, line));\n return true;\n case 'import':\n parseFileImport(context, line, this.#fileImports);\n return true;\n case 'toolbar':\n this.#toolbars.push(parseToolbar(context, line));\n return true;\n case 'feature':\n this.#features.push(parseFeature(context, line));\n return true;\n case 'example':\n this.#examples.push(parseExample(context, line));\n return true;\n case 'slice':\n this.#slices.push(parseSlice(context, line));\n return true;\n default:\n if (opaqueFeatureMembers.has(keyword)) {\n collectInputUses(context, line);\n return true;\n }\n return false;\n }\n }\n\n // Builds the feature, located at its header or, when it only places an imported file, at that file.\n build(location: SourceLocation, isPlacement = false): FeatureSyntax {\n return {\n kind: 'FeatureSyntax',\n name: this.name,\n description: this.#description,\n documentation: this.#documentation,\n authorize: this.#authorize,\n dependsOn: this.#dependsOn,\n purposes: this.#purposes,\n ...(this.#toolbars.length > 0 ? { toolbars: this.#toolbars } : {}),\n features: this.#features,\n slices: this.#slices,\n examples: this.#examples,\n fileImports: this.#fileImports,\n isPlacement,\n location,\n };\n }\n}\n\n// Parses a feature from its already consumed header line.\nexport function parseFeature(context: ParserContext, line: SourceLine): FeatureSyntax {\n const name = featurePattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidFeatureDeclaration, `Invalid feature declaration '${line.content}' - expected 'feature <Name>'`, locationOf(line));\n }\n const body = new FeatureBody(name);\n const previous = context.scope;\n context.scope = [...previous, name];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!body.tryParse(context, child)) {\n context.error(DiagnosticCodes.UnknownFeatureDirective, `Unexpected '${firstWord(child.content)}' in feature body - expected ${featureBodyExpected}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n context.scope = previous;\n return body.build(locationOf(line));\n}\n"],"mappings":"m4BA0BA,MAAMA,EAAiBC,EAAQ,8BAA8B,EAGvDC,kBAAuB,IAAI,IAAI,CAAC,KAAM,OAAQ,aAAc,UAAU,CAAC,EAGhEC,EAAsB,sJAInC,IAAa,YAAb,KAAyB,CAYA,KAXrB,GAAsC,CAAC,EACvC,GAAkC,CAAC,EACnC,GAAmD,CAAC,EACpD,GAA4C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N,KAAM,KAAK,KACX,YAAa,KAAKG,GAClB,cAAe,KAAKE,GACpB,UAAW,KAAKO,GAChB,UAAW,KAAKJ,GAChB,SAAU,KAAKG,GACf,GAAI,KAAKM,GAAU,OAAS,EAAI,CAAE,SAAU,KAAKA,EAAU,EAAI,CAAC,EAChE,SAAU,KAAKE,GACf,OAAQ,KAAKG,GACb,SAAU,KAAKF,GACf,YAAa,KAAKJ,GAClB,cACA,UACJ,CACJ,CACJ,EAGA,SAAgB,aAAa,EAAwB,EAAiC,CAClF,IAAMnB,EAAOJ,EAAe,KAAKO,EAAK,OAAO,CAAC,GAAG,IAAM,GACnDH,IAAS,IACTK,EAAQ,MAAMO,EAAgB,0BAA2B,gCAAgCT,EAAK,QAAQ,+BAAgCyB,EAAWzB,CAAI,CAAC,EAE1J,IAAM0B,EAAO,IAAI,YAAY7B,CAAI,EAC3B8B,EAAWzB,EAAQ,MACzB,EAAQ,MAAQ,CAAC,GAAGyB,EAAU9B,CAAI,EAClC,IAAK,IAAI+B,EAAQ1B,EAAQ,UAAUF,EAAK,MAAM,EAAG4B,IAAU,IAAA,GAAW,EAAQ1B,EAAQ,UAAUF,EAAK,MAAM,EACvGE,EAAQ,OAAO,gBAAgB,EAC1BwB,EAAK,SAASxB,EAAS0B,CAAK,IAC7B1B,EAAQ,MAAMO,EAAgB,wBAAyB,eAAeV,EAAU6B,EAAM,OAAO,EAAE,+BAA+BhC,IAAuB6B,EAAWG,CAAK,CAAC,EACtK1B,EAAQ,UAAU0B,EAAM,MAAM,GAItC,MADA,GAAQ,MAAQD,EACTD,EAAK,MAAMD,EAAWzB,CAAI,CAAC,CACtC"}
|
|
1
|
+
{"version":3,"file":"FeatureBody.js","names":["featurePattern","pattern","opaqueFeatureMembers","featureBodyExpected","name","keyword","firstWord","line","misplacedReactionIdentity","context","#description","parseDescription","#documentation","parseDocumentation","parseDependsOn","#dependsOn","DiagnosticCodes","parsePurposeReference","#purposes","diagnosticCount","next","parseAuthorize","diagnostic","#authorize","#authorizationDepthExceeded","previous","combineAuthorize","recordAuthorizationRefusal","#fileImports","parseFileImport","#toolbars","parseToolbar","#features","#examples","parseExample","#slices","parseSlice","collectInputUses","locationOf","body","child"],"sources":["../../../../../../Compiler/Parsing/FeatureBody.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { DependsOnSyntax, FeatureSyntax, FileImportSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ScreenToolbarSyntax } from '../Syntax/Screens';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize, recordAuthorizationRefusal } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { parsePurposeReference } from './PurposeParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { parseDependsOn } from './DependsOnParser';\nimport { parseFileImport } from './FileImportParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseToolbar } from './ScreenParser';\nimport { parseSlice } from './SliceParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst featurePattern = pattern('^feature\\\\s+([A-Za-z_]\\\\w*)$');\n\n// Feature members the C# compiler knows that this compiler does not model. They are skipped whole, not reported.\nconst opaqueFeatureMembers = new Set(['on', 'uses', 'contribute', 'template']);\n\n// What a feature body may hold, as it reads in a diagnostic.\nexport const featureBodyExpected = 'description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, toolbar, example, \\'on <trigger>\\' or \\'uses <Behavior>\\'';\n\n// Collects the body of a feature - written beneath a 'feature' header, or at the top level of a file imported\n// into the feature. The port of the C# FeatureBody.\nexport class FeatureBody {\n readonly #features: FeatureSyntax[] = [];\n readonly #slices: SliceSyntax[] = [];\n readonly #examples: SpecificationExampleSyntax[] = [];\n readonly #fileImports: FileImportSyntax[] = [];\n readonly #dependsOn: DependsOnSyntax[] = [];\n readonly #purposes: PurposeReferenceSyntax[] = [];\n readonly #toolbars: ScreenToolbarSyntax[] = [];\n #description: string | null = null;\n #documentation: string | null = null;\n #authorize: AuthorizeSyntax | null = null;\n #authorizationDepthExceeded = false;\n\n constructor(readonly name: string) {}\n\n // Parses one already consumed line of the body; false when the line does not belong to a feature body,\n // and nothing was reported.\n tryParse(context: ParserContext, line: SourceLine): boolean {\n const keyword = firstWord(line.content);\n switch (keyword) {\n case 'runs':\n misplacedReactionIdentity(context, line);\n return true;\n case 'description':\n this.#description = parseDescription(context, line, this.#description, `Feature '${this.name}'`);\n return true;\n case 'documentation':\n this.#documentation = parseDocumentation(context, line, this.#documentation, `Feature '${this.name}'`);\n return true;\n case 'depends':\n parseDependsOn(context, line, this.#dependsOn, DiagnosticCodes.UnknownFeatureDirective);\n return true;\n case 'purpose':\n parsePurposeReference(context, line, this.#purposes);\n return true;\n case 'authorize': {\n const diagnosticCount = context.diagnostics.length;\n const next = parseAuthorize(context, line);\n if (next === null && context.diagnostics.slice(diagnosticCount).some(diagnostic => diagnostic.code === DiagnosticCodes.ConditionDepthExceeded)) {\n this.#authorize = null;\n this.#authorizationDepthExceeded = true;\n }\n if (!this.#authorizationDepthExceeded) {\n const previous = this.#authorize;\n this.#authorize = combineAuthorize(this.#authorize, next, context);\n this.#authorizationDepthExceeded = previous !== null && this.#authorize === null;\n }\n if (this.#authorizationDepthExceeded) recordAuthorizationRefusal(this.#fileImports);\n return true;\n }\n case 'import':\n parseFileImport(context, line, this.#fileImports);\n return true;\n case 'toolbar':\n this.#toolbars.push(parseToolbar(context, line));\n return true;\n case 'feature':\n this.#features.push(parseFeature(context, line));\n return true;\n case 'example':\n this.#examples.push(parseExample(context, line));\n return true;\n case 'slice':\n this.#slices.push(parseSlice(context, line));\n return true;\n default:\n if (opaqueFeatureMembers.has(keyword)) {\n collectInputUses(context, line);\n return true;\n }\n return false;\n }\n }\n\n // Builds the feature, located at its header or, when it only places an imported file, at that file.\n build(location: SourceLocation, isPlacement = false): FeatureSyntax {\n return {\n kind: 'FeatureSyntax',\n name: this.name,\n description: this.#description,\n documentation: this.#documentation,\n authorize: this.#authorize,\n dependsOn: this.#dependsOn,\n purposes: this.#purposes,\n ...(this.#toolbars.length > 0 ? { toolbars: this.#toolbars } : {}),\n features: this.#features,\n slices: this.#slices,\n examples: this.#examples,\n fileImports: this.#fileImports,\n isPlacement,\n location,\n };\n }\n}\n\n// Parses a feature from its already consumed header line.\nexport function parseFeature(context: ParserContext, line: SourceLine): FeatureSyntax {\n const name = featurePattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidFeatureDeclaration, `Invalid feature declaration '${line.content}' - expected 'feature <Name>'`, locationOf(line));\n }\n const body = new FeatureBody(name);\n const previous = context.scope;\n context.scope = [...previous, name];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!body.tryParse(context, child)) {\n context.error(DiagnosticCodes.UnknownFeatureDirective, `Unexpected '${firstWord(child.content)}' in feature body - expected ${featureBodyExpected}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n context.scope = previous;\n return body.build(locationOf(line));\n}\n"],"mappings":"A,m6BA0BA,MAAMA,EAAiBC,EAAQ,8BAA8B,EAGvDC,kBAAuB,IAAI,IAAI,CAAC,KAAM,OAAQ,aAAc,UAAU,CAAC,EAGhEC,EAAsB,sJAInC,IAAa,YAAb,KAAyB,CAaA,KAZrB,GAAsC,CAAC,EACvC,GAAkC,CAAC,EACnC,GAAmD,CAAC,EACpD,GAA4C,CAAC,EAC7C,GAAyC,CAAC,EAC1C,GAA+C,CAAC,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CAAC,EACtK/B,EAAQ,UAAU+B,EAAM,MAAM,GAItC,MADA,GAAQ,MAAQf,EACTc,EAAK,MAAMD,EAAW/B,CAAI,CAAC,CACtC,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileImportParser.js","names":["fileImportPattern","pattern","quotedPattern","content","match","line","locationOf","fileImport","context","DiagnosticCodes","imports"],"sources":["../../../../../../Compiler/Parsing/FileImportParser.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 { FileImportSyntax } from '../Syntax/Structure';\nimport { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst fileImportPattern = pattern('^import\\\\s+\"([^\"\\\\\\\\]+)\"$');\nconst quotedPattern = pattern('^import\\\\s+\"');\n\n// Whether an 'import' line names files rather than a qualified name - its operand is quoted.\nexport const isFileImport = (content: string): boolean => quotedPattern.test(content);\n\n// An 'import \"<pattern>\"' line, or undefined when the line does not import files - the port of the C#\n// FileImportParser.TryParse.\nexport function tryParseFileImport(line: SourceLine): FileImportSyntax | undefined {\n const match = fileImportPattern.exec(line.content);\n return match === null ? undefined : { kind: 'FileImportSyntax', pattern: match[1], location: locationOf(line) };\n}\n\n// Parses a consumed 'import' line inside a module or feature, where only files can be imported.\nexport function parseFileImport(context: ParserContext, line: SourceLine, imports: FileImportSyntax[]): void {\n const fileImport = tryParseFileImport(line);\n if (fileImport !== undefined) {\n imports.push(fileImport);\n return;\n }\n context.error(DiagnosticCodes.InvalidFileImport,\n `Invalid import '${line.content}' - inside a module or feature, import names files: 'import \"<path or glob>\"'`, locationOf(line));\n context.skipBlock(line.indent);\n}\n"],"mappings":"oNASA,MAAMA,EAAoBC,EAAQ,2BAA2B,EACvDC,EAAgBD,EAAQ,cAAc,EAG/B,aAAgB,GAA6BC,EAAc,KAAKC,CAAO,EAIpF,SAAgB,mBAAmB,EAAgD,CAC/E,IAAMC,EAAQJ,EAAkB,KAAKK,EAAK,OAAO,EACjD,OAAOD,IAAU,KAAO,IAAA,GAAY,CAAE,KAAM,mBAAoB,QAASA,EAAM,GAAI,SAAUE,EAAWD,CAAI,CAAE,CAClH,CAGA,SAAgB,gBAAgB,EAAwB,EAAkB,EAAmC,CACzG,IAAME,EAAa,mBAAmBF,CAAI,EACtCE,IAAe,IAAA,IAInBC,EAAQ,MAAMC,EAAgB,kBAC1B,mBAAmBJ,EAAK,QAAQ,+EAAgFC,EAAWD,CAAI,CAAC,EACpIG,EAAQ,UAAUH,EAAK,MAAM,GALzBK,EAAQ,KAAKH,CAAU,CAM/B"}
|
|
1
|
+
{"version":3,"file":"FileImportParser.js","names":["fileImportPattern","pattern","quotedPattern","content","match","line","locationOf","fileImport","context","DiagnosticCodes","imports"],"sources":["../../../../../../Compiler/Parsing/FileImportParser.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 { FileImportSyntax } from '../Syntax/Structure';\nimport { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst fileImportPattern = pattern('^import\\\\s+\"([^\"\\\\\\\\]+)\"$');\nconst quotedPattern = pattern('^import\\\\s+\"');\n\n// Whether an 'import' line names files rather than a qualified name - its operand is quoted.\nexport const isFileImport = (content: string): boolean => quotedPattern.test(content);\n\n// An 'import \"<pattern>\"' line, or undefined when the line does not import files - the port of the C#\n// FileImportParser.TryParse.\nexport function tryParseFileImport(line: SourceLine): FileImportSyntax | undefined {\n const match = fileImportPattern.exec(line.content);\n return match === null ? undefined : { kind: 'FileImportSyntax', pattern: match[1], location: locationOf(line) };\n}\n\n// Parses a consumed 'import' line inside a module or feature, where only files can be imported.\nexport function parseFileImport(context: ParserContext, line: SourceLine, imports: FileImportSyntax[]): void {\n const fileImport = tryParseFileImport(line);\n if (fileImport !== undefined) {\n imports.push(fileImport);\n return;\n }\n context.error(DiagnosticCodes.InvalidFileImport,\n `Invalid import '${line.content}' - inside a module or feature, import names files: 'import \"<path or glob>\"'`, locationOf(line));\n context.skipBlock(line.indent);\n}\n"],"mappings":"A,oNASA,MAAMA,EAAoBC,EAAQ,2BAA2B,EACvDC,EAAgBD,EAAQ,cAAc,EAG/B,aAAgB,GAA6BC,EAAc,KAAKC,CAAO,EAIpF,SAAgB,mBAAmB,EAAgD,CAC/E,IAAMC,EAAQJ,EAAkB,KAAKK,EAAK,OAAO,EACjD,OAAOD,IAAU,KAAO,IAAA,GAAY,CAAE,KAAM,mBAAoB,QAASA,EAAM,GAAI,SAAUE,EAAWD,CAAI,CAAE,CAClH,CAGA,SAAgB,gBAAgB,EAAwB,EAAkB,EAAmC,CACzG,IAAME,EAAa,mBAAmBF,CAAI,EACtCE,IAAe,IAAA,IAInBC,EAAQ,MAAMC,EAAgB,kBAC1B,mBAAmBJ,EAAK,QAAQ,+EAAgFC,EAAWD,CAAI,CAAC,EACpIG,EAAQ,UAAUH,EAAK,MAAM,GALzBK,EAAQ,KAAKH,CAAU,CAM/B,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileReferences.js","names":["typeReferencePattern","pattern","firstWord","line"],"sources":["../../../../../../Compiler/Parsing/FileReferences.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 { pattern } from '../Text/patterns';\nimport { firstWord } from './LineText';\nimport { SourceLine } from './SourceLine';\n\nconst typeReferencePattern = pattern('^[A-Za-z_]\\\\w*(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?$');\n\nconst pathOf = (line: SourceLine): string =>\n firstWord(line.content) === 'file' ? line.content.substring('file'.length).trim() : '';\n\n// A 'file <path>' directive. This compiler does not model file references; it only recognizes the line so\n// it is not misread as something else.\nexport const isFileDirective = (line: SourceLine): boolean => pathOf(line).length > 0;\n\n// Among properties 'file Path' is a property named file, so only a path that is not type-shaped counts.\nexport const isFileDirectiveAmongProperties = (line: SourceLine): boolean =>\n isFileDirective(line) && !typeReferencePattern.test(pathOf(line));\n"],"mappings":"6IAOA,MAAMA,EAAuBC,EAAQ,iDAAiD,EAEhF,OAAU,GACZC,EAAUC,EAAK,OAAO,IAAM,OAASA,EAAK,QAAQ,UAAU,CAAa,CAAC,CAAC,KAAK,EAAI,GAI3E,gBAAmB,GAA8B,OAAOA,CAAI,CAAC,CAAC,OAAS,EAGvE,+BAAkC,GAC3C,gBAAgBA,CAAI,GAAK,CAACH,EAAqB,KAAK,OAAOG,CAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"FileReferences.js","names":["typeReferencePattern","pattern","firstWord","line"],"sources":["../../../../../../Compiler/Parsing/FileReferences.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 { pattern } from '../Text/patterns';\nimport { firstWord } from './LineText';\nimport { SourceLine } from './SourceLine';\n\nconst typeReferencePattern = pattern('^[A-Za-z_]\\\\w*(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?$');\n\nconst pathOf = (line: SourceLine): string =>\n firstWord(line.content) === 'file' ? line.content.substring('file'.length).trim() : '';\n\n// A 'file <path>' directive. This compiler does not model file references; it only recognizes the line so\n// it is not misread as something else.\nexport const isFileDirective = (line: SourceLine): boolean => pathOf(line).length > 0;\n\n// Among properties 'file Path' is a property named file, so only a path that is not type-shaped counts.\nexport const isFileDirectiveAmongProperties = (line: SourceLine): boolean =>\n isFileDirective(line) && !typeReferencePattern.test(pathOf(line));\n"],"mappings":"A,6IAOA,MAAMA,EAAuBC,EAAQ,iDAAiD,EAEhF,OAAU,GACZC,EAAUC,EAAK,OAAO,IAAM,OAASA,EAAK,QAAQ,UAAU,CAAa,CAAC,CAAC,KAAK,EAAI,GAI3E,gBAAmB,GAA8B,OAAOA,CAAI,CAAC,CAAC,OAAS,EAGvE,+BAAkC,GAC3C,gBAAgBA,CAAI,GAAK,CAACH,EAAqB,KAAK,OAAOG,CAAI,CAAC,E"}
|