@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FoldedEventSources.js","names":["foldedEventsByPass","index","declarations","slice","event","declared","published","projection","target","folded","block","allEvents","owner","spec","eventDeclarations"],"sources":["../../../../../../Compiler/Parsing/FoldedEventSources.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 { EventSyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ProjectionBlockSyntax, ProjectionSyntax } from '../Syntax/Projections';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\ntype FoldedEvents = ReadonlyMap<SliceSyntax, ReadonlyMap<EventSyntax, readonly EventSyntax[]>>;\n\n// An outbound event projection publishes the facts it folds, so those facts' event-source types are the event's.\n// Indexed once per validation pass (one RefusalDeclarations), per declaring slice, rather than resolved again for every lookup.\nconst foldedEventsByPass = new WeakMap<RefusalDeclarations, FoldedEvents>();\n\nexport function foldedSources(declarations: RefusalDeclarations, slice: SliceSyntax, event: EventSyntax): readonly EventSyntax[] {\n let index = foldedEventsByPass.get(declarations);\n if (index === undefined) {\n index = foldedEvents(declarations);\n foldedEventsByPass.set(declarations, index);\n }\n return index.get(slice)?.get(event) ?? [];\n}\n\nfunction foldedEvents(declarations: RefusalDeclarations): FoldedEvents {\n let declared: readonly EventSyntax[] | undefined;\n const allEvents = () => declared ??= declaredEvents(declarations);\n return new Map<SliceSyntax, ReadonlyMap<EventSyntax, readonly EventSyntax[]>>(declarations.slices.map(({ slice }) => [slice, publishedEvents(slice, declarations, allEvents)]));\n}\n\nfunction publishedEvents(slice: SliceSyntax, declarations: RefusalDeclarations, allEvents: () => readonly EventSyntax[]): ReadonlyMap<EventSyntax, readonly EventSyntax[]> {\n const published = new Map<EventSyntax, EventSyntax[]>();\n for (const projection of slice.projections) {\n const target = publishedEvent(projection, slice, declarations);\n if (target === null) continue;\n const folded = published.get(target) ?? [];\n published.set(target, folded);\n for (const block of projection.blocks) folded.push(...blockEvents(block, slice, declarations, allEvents));\n }\n return published;\n}\n\nfunction publishedEvent(projection: ProjectionSyntax, slice: SliceSyntax, declarations: RefusalDeclarations): EventSyntax | null {\n if (projection.readModel === null || declarations.resolve(projection.readModel, slice, owner => owner.readModels) !== null) return null;\n return declarations.event(projection.readModel, slice);\n}\n\nfunction blockEvents(block: ProjectionBlockSyntax, slice: SliceSyntax, declarations: RefusalDeclarations, allEvents: () => readonly EventSyntax[]): readonly EventSyntax[] {\n if (block.kind === 'FromSyntax') return block.events.map(spec => declarations.event(spec.event, slice)).filter(isEvent);\n return block.kind === 'EverySyntax' || block.kind === 'AllSyntax' ? allEvents() : [];\n}\n\nfunction declaredEvents(declarations: RefusalDeclarations): readonly EventSyntax[] {\n return declarations.slices.flatMap(owner => eventDeclarations(owner.slice).map(event => declarations.event(event.name, owner.slice))).filter(isEvent);\n}\n\nfunction isEvent(event: EventSyntax | null): event is EventSyntax {\n return event !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EAAM,OAAS,eAAiBA,EAAM,OAAS,YAAcC,EAAU,EAAI,CAAC,CACvF,CAEA,SAAS,eAAe,EAA2D,CAC/E,OAAOT,EAAa,OAAO,QAAQ,GAASY,EAAkBF,EAAM,KAAK,CAAC,CAAC,IAAI,GAASV,EAAa,MAAME,EAAM,KAAMQ,EAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,CACxJ,CAEA,SAAS,QAAQ,EAAiD,CAC9D,OAAOR,IAAU,IACrB"}
|
|
1
|
+
{"version":3,"file":"FoldedEventSources.js","names":["foldedEventsByPass","index","declarations","slice","event","declared","published","projection","target","folded","block","allEvents","owner","spec","eventDeclarations"],"sources":["../../../../../../Compiler/Parsing/FoldedEventSources.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 { EventSyntax } from '../Syntax/Declarations';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ProjectionBlockSyntax, ProjectionSyntax } from '../Syntax/Projections';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\ntype FoldedEvents = ReadonlyMap<SliceSyntax, ReadonlyMap<EventSyntax, readonly EventSyntax[]>>;\n\n// An outbound event projection publishes the facts it folds, so those facts' event-source types are the event's.\n// Indexed once per validation pass (one RefusalDeclarations), per declaring slice, rather than resolved again for every lookup.\nconst foldedEventsByPass = new WeakMap<RefusalDeclarations, FoldedEvents>();\n\nexport function foldedSources(declarations: RefusalDeclarations, slice: SliceSyntax, event: EventSyntax): readonly EventSyntax[] {\n let index = foldedEventsByPass.get(declarations);\n if (index === undefined) {\n index = foldedEvents(declarations);\n foldedEventsByPass.set(declarations, index);\n }\n return index.get(slice)?.get(event) ?? [];\n}\n\nfunction foldedEvents(declarations: RefusalDeclarations): FoldedEvents {\n let declared: readonly EventSyntax[] | undefined;\n const allEvents = () => declared ??= declaredEvents(declarations);\n return new Map<SliceSyntax, ReadonlyMap<EventSyntax, readonly EventSyntax[]>>(declarations.slices.map(({ slice }) => [slice, publishedEvents(slice, declarations, allEvents)]));\n}\n\nfunction publishedEvents(slice: SliceSyntax, declarations: RefusalDeclarations, allEvents: () => readonly EventSyntax[]): ReadonlyMap<EventSyntax, readonly EventSyntax[]> {\n const published = new Map<EventSyntax, EventSyntax[]>();\n for (const projection of slice.projections) {\n const target = publishedEvent(projection, slice, declarations);\n if (target === null) continue;\n const folded = published.get(target) ?? [];\n published.set(target, folded);\n for (const block of projection.blocks) folded.push(...blockEvents(block, slice, declarations, allEvents));\n }\n return published;\n}\n\nfunction publishedEvent(projection: ProjectionSyntax, slice: SliceSyntax, declarations: RefusalDeclarations): EventSyntax | null {\n if (projection.readModel === null || declarations.resolve(projection.readModel, slice, owner => owner.readModels) !== null) return null;\n return declarations.event(projection.readModel, slice);\n}\n\nfunction blockEvents(block: ProjectionBlockSyntax, slice: SliceSyntax, declarations: RefusalDeclarations, allEvents: () => readonly EventSyntax[]): readonly EventSyntax[] {\n if (block.kind === 'FromSyntax') return block.events.map(spec => declarations.event(spec.event, slice)).filter(isEvent);\n return block.kind === 'EverySyntax' || block.kind === 'AllSyntax' ? allEvents() : [];\n}\n\nfunction declaredEvents(declarations: RefusalDeclarations): readonly EventSyntax[] {\n return declarations.slices.flatMap(owner => eventDeclarations(owner.slice).map(event => declarations.event(event.name, owner.slice))).filter(isEvent);\n}\n\nfunction isEvent(event: EventSyntax | null): event is EventSyntax {\n return event !== null;\n}\n"],"mappings":"A,wHAaA,MAAMA,kBAAqB,IAAI,QAE/B,SAAgB,cAAc,EAAmC,EAAoB,EAA4C,CAC7H,IAAIC,EAAQD,EAAmB,IAAIE,CAAY,EAK/C,OAJID,IAAU,IAAA,KACV,EAAQ,aAAaC,CAAY,EACjCF,EAAmB,IAAIE,EAAcD,CAAK,GAEvCA,EAAM,IAAIE,CAAK,CAAC,EAAE,IAAIC,CAAK,GAAK,CAAC,CAC5C,CAEA,SAAS,aAAa,E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"}
|
|
@@ -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{isFile as t,parseCode as n,parseFile as r}from"./ImplementationParser.js";import{locationOf as i}from"./SourceLine.js";function parseGenerationBody(a,o,s){let c=!1,l;for(;(l=a.peekChild(o.indent))!==void 0;){a.reader.takeSignificant();let o=t(l),u=l.content.startsWith("```");if(s.strategy!==`rule`||!o&&!u){a.error(e.UnknownRuleImplementationDirective,`Generation rule bodies accept only one 'file <path>' or tagged inline fence.`,i(l)),a.skipBlock(l.indent);continue}c&&a.error(e.ConflictingImplementationSources,`A generation rule has exactly one file or inline payload.`,i(l));let d=o?r(a,l):null,f=u?n(a,l):null;c||(s={...s,file:d,code:f}),c=!0;let p=o?a.peekChild(l.indent):void 0;p!==void 0&&(a.error(e.UnknownRuleImplementationDirective,`A generation file directive cannot have children.`,i(p)),a.skipBlock(l.indent))}return s}export{parseGenerationBody};
|
|
2
2
|
//# sourceMappingURL=GenerationBodyParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerationBodyParser.js","names":["hasBody","child","context","line","file","isFile","fence","generation","DiagnosticCodes","locationOf","parsedFile","parseFile","parsedCode","parseCode","nested"],"sources":["../../../../../../Compiler/Parsing/GenerationBodyParser.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 { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { isFile, parseCode, parseFile } from './ImplementationParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport function parseGenerationBody(context: ParserContext, line: SourceLine, generation: GenerationSyntax): GenerationSyntax {\n let hasBody = false;\n let child: SourceLine | undefined;\n while ((child = context.peekChild(line.indent)) !== undefined) {\n context.reader.takeSignificant();\n const file = isFile(child);\n const fence = child.content.startsWith('```');\n if (generation.strategy !== 'rule' || (!file && !fence)) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, \"Generation rule bodies accept only one 'file <path>' or tagged inline fence.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n if (hasBody) context.error(DiagnosticCodes.ConflictingImplementationSources, 'A generation rule has exactly one file or inline payload.', locationOf(child));\n const parsedFile = file ? parseFile(context, child) : null;\n const parsedCode = fence ? parseCode(context, child) : null;\n if (!hasBody) generation = { ...generation, file: parsedFile, code: parsedCode };\n hasBody = true;\n const nested = file ? context.peekChild(child.indent) : undefined;\n if (nested !== undefined) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, 'A generation file directive cannot have children.', locationOf(nested));\n context.skipBlock(child.indent);\n }\n }\n return generation;\n}\n"],"mappings":"uPASA,SAAgB,oBAAoB,EAAwB,EAAkB,EAAgD,CAC1H,IAAIA,EAAU,GACVC,EACJ,MAAQ,EAAQC,EAAQ,UAAUC,EAAK,MAAM,KAAO,IAAA,IAAW,CAC3DD,EAAQ,OAAO,gBAAgB,EAC/B,IAAME,EAAOC,EAAOJ,CAAK,EACnBK,EAAQL,EAAM,QAAQ,WAAW,KAAK,EAC5C,GAAIM,EAAW,WAAa,QAAW,CAACH,GAAQ,CAACE,EAAQ,CACrDJ,EAAQ,MAAMM,EAAgB,mCAAoC,+EAAgFC,EAAWR,CAAK,CAAC,EACnKC,EAAQ,UAAUD,EAAM,MAAM,EAC9B,QACJ,CACID,GAASE,EAAQ,MAAMM,EAAgB,iCAAkC,4DAA6DC,EAAWR,CAAK,CAAC,EAC3J,IAAMS,EAAaN,EAAOO,EAAUT,EAASD,CAAK,EAAI,KAChDW,EAAaN,EAAQO,EAAUX,EAASD,CAAK,EAAI,KAClDD,IAAS,EAAa,CAAE,GAAGO,EAAY,KAAMG,EAAY,KAAME,CAAW,GAC/E,EAAU,GACV,IAAME,EAASV,EAAOF,EAAQ,UAAUD,EAAM,MAAM,EAAI,IAAA,GACpDa,IAAW,IAAA,KACXZ,EAAQ,MAAMM,EAAgB,mCAAoC,oDAAqDC,EAAWK,CAAM,CAAC,EACzIZ,EAAQ,UAAUD,EAAM,MAAM,EAEtC,CACA,OAAOM,CACX"}
|
|
1
|
+
{"version":3,"file":"GenerationBodyParser.js","names":["hasBody","child","context","line","file","isFile","fence","generation","DiagnosticCodes","locationOf","parsedFile","parseFile","parsedCode","parseCode","nested"],"sources":["../../../../../../Compiler/Parsing/GenerationBodyParser.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 { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { isFile, parseCode, parseFile } from './ImplementationParser';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport function parseGenerationBody(context: ParserContext, line: SourceLine, generation: GenerationSyntax): GenerationSyntax {\n let hasBody = false;\n let child: SourceLine | undefined;\n while ((child = context.peekChild(line.indent)) !== undefined) {\n context.reader.takeSignificant();\n const file = isFile(child);\n const fence = child.content.startsWith('```');\n if (generation.strategy !== 'rule' || (!file && !fence)) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, \"Generation rule bodies accept only one 'file <path>' or tagged inline fence.\", locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n if (hasBody) context.error(DiagnosticCodes.ConflictingImplementationSources, 'A generation rule has exactly one file or inline payload.', locationOf(child));\n const parsedFile = file ? parseFile(context, child) : null;\n const parsedCode = fence ? parseCode(context, child) : null;\n if (!hasBody) generation = { ...generation, file: parsedFile, code: parsedCode };\n hasBody = true;\n const nested = file ? context.peekChild(child.indent) : undefined;\n if (nested !== undefined) {\n context.error(DiagnosticCodes.UnknownRuleImplementationDirective, 'A generation file directive cannot have children.', locationOf(nested));\n context.skipBlock(child.indent);\n }\n }\n return generation;\n}\n"],"mappings":"A,uPASA,SAAgB,oBAAoB,EAAwB,EAAkB,EAAgD,CAC1H,IAAIA,EAAU,GACVC,EACJ,MAAQ,EAAQC,EAAQ,UAAUC,EAAK,MAAM,KAAO,IAAA,IAAW,CAC3DD,EAAQ,OAAO,gBAAgB,EAC/B,IAAME,EAAOC,EAAOJ,CAAK,EACnBK,EAAQL,EAAM,QAAQ,WAAW,KAAK,EAC5C,GAAIM,EAAW,WAAa,QAAW,CAACH,GAAQ,CAACE,EAAQ,CACrDJ,EAAQ,MAAMM,EAAgB,mCAAoC,+EAAgFC,EAAWR,CAAK,CAAC,EACnKC,EAAQ,UAAUD,EAAM,MAAM,EAC9B,QACJ,CACID,GAASE,EAAQ,MAAMM,EAAgB,iCAAkC,4DAA6DC,EAAWR,CAAK,CAAC,EAC3J,IAAMS,EAAaN,EAAOO,EAAUT,EAASD,CAAK,EAAI,KAChDW,EAAaN,EAAQO,EAAUX,EAASD,CAAK,EAAI,KAClDD,IAAS,EAAa,CAAE,GAAGO,EAAY,KAAMG,EAAY,KAAME,CAAW,GAC/E,EAAU,GACV,IAAME,EAASV,EAAOF,EAAQ,UAAUD,EAAM,MAAM,EAAI,IAAA,GACpDa,IAAW,IAAA,KACXZ,EAAQ,MAAMM,EAAgB,mCAAoC,oDAAqDC,EAAWK,CAAM,CAAC,EACzIZ,EAAQ,UAAUD,EAAM,MAAM,EAEtC,CACA,OAAOM,CACX,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import"../Generation/index.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{InvalidGenerationPattern as r}from"../Generation/InvalidGenerationPattern.js";import{parseGenerationPattern as i}from"../Generation/GenerationPattern.js";import{parseGenerationBody as a}from"./GenerationBodyParser.js";import{locationOf as o}from"./SourceLine.js";const s=RegExp(`"${t}"|\\S+`,`g`),c=/^([a-z]([a-z_]{0,61}[a-z])?)?$(?![\s\S])/,printable=e=>[...e].every(e=>e>=` `&&e<=`~`),literal=e=>e!==void 0&&e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?n(e.slice(1,-1)):void 0,integer=e=>e!==void 0&&/^-?[0-9]+$(?![\s\S])/.test(e)&&Number(e)>=-2147483648&&Number(e)<=2147483647?Number(e):void 0;function parseGeneration(t,n,l){let u=[...n.content.matchAll(s)].map(e=>e[0]).slice(1),error=(e,r)=>t.error(e,r,o(n));if(u.length===0)return error(e.InvalidGenerationArgument,`Expected 'generate <strategy> [modifiers]'.`),null;let d=u[0];if(![`uuid`,`uuidv7`,`ulid`,`typeid`,`nanoid`,`bytes`,`pattern`,`random`,`rule`,`sequence`].includes(d))return error(e.UnknownGenerationStrategy,`Unknown generation strategy '${d}'.`),null;let f={kind:`GenerationSyntax`,strategy:d,location:o(n)},p=1,m=!0;switch(d){case`typeid`:case`pattern`:{let e=literal(u[p++]);m=e!==void 0,f=d===`typeid`?{...f,prefix:e}:{...f,pattern:e};break}case`nanoid`:{let e=integer(u[p]);e!==void 0&&(f={...f,size:e},p++);break}case`bytes`:{let e=integer(u[p++]),t=u[p++];m=e!==void 0&&[`base64url`,`hex`,`base32`].includes(t),f={...f,count:e,encoding:t};break}case`random`:{let e=u[p++],t=e?.match(/^(-?(?:0|[1-9][0-9]*))\.\.(-?(?:0|[1-9][0-9]*))$(?![\s\S])/);m=t!=null&&BigInt(t[1])>=-9223372036854775808n&&BigInt(t[2])<=9223372036854775807n&&BigInt(t[1])<=BigInt(t[2]),f={...f,range:e};break}case`rule`:{let e=u[p++];m=e!==void 0&&/^[A-Za-z_][A-Za-z0-9_]*$(?![\s\S])/.test(e),f={...f,rule:e};break}}if(!m)return error(e.InvalidGenerationArgument,`Missing or invalid argument for generation strategy '${d}'.`),f;let h=/* @__PURE__ */ new Set;for(;p<u.length;){let t=u[p++],n=u[p++];if(h.has(t)&&error(e.DuplicateGenerationModifier,`Generation modifier '${t}' is repeated.`),h.add(t),!allows(d,l,f.encoding,t)){error(e.InvalidGenerationModifier,`Generation modifier '${t}' is not allowed for '${d}' on '${l}'.`);continue}let r=literal(n);if(t===`prefix`||t===`alphabet`?r===void 0:t===`case`?![`lower`,`upper`].includes(n):![`luhn`,`mod11`,`mod97`].includes(n))error(e.InvalidGenerationArgument,`Missing or invalid value for generation modifier '${t}'.`);else switch(t){case`prefix`:f={...f,prefix:r};break;case`alphabet`:f={...f,alphabet:r};break;case`case`:f={...f,case:n};break;default:f={...f,checksum:n}}}if(d===`pattern`&&f.pattern!==void 0&&f.pattern!==null)try{i(f.pattern,f.checksum)}catch(t){if(!(t instanceof r))throw t;error(t.message.includes(`expanded length`)?e.GenerationSizeOutsideRange:e.InvalidGenerationArgument,t.message)}return d===`sequence`||(l===`Uuid`?[`uuid`,`uuidv7`].includes(d):l===`String`?d!==`random`:l===`Int`&&d===`random`)||error(e.InvalidGenerationPrimitive,`Generation strategy '${d}' is not allowed on '${l}'.`),f.prefix!==void 0&&f.prefix!==null&&(d===`typeid`?c.test(f.prefix)||error(e.InvalidTypeIdPrefix,`TypeID prefix must be empty or 1..63 lowercase letters and underscores, starting and ending with a letter.`):(f.prefix.length>32||!printable(f.prefix))&&error(e.InvalidGenerationPrefix,`Generation prefix must contain at most 32 printable ASCII characters.`)),f.alphabet!==void 0&&f.alphabet!==null&&(f.alphabet.length<2||f.alphabet.length>256||!printable(f.alphabet)||new Set(f.alphabet).size!==f.alphabet.length)&&error(e.InvalidGenerationAlphabet,`NanoID alphabet must contain 2..256 distinct printable ASCII characters.`),(f.size!==void 0&&f.size!==null&&(f.size<1||f.size>256)||f.count!==void 0&&f.count!==null&&(f.count<1||f.count>512))&&error(e.GenerationSizeOutsideRange,`NanoID size must be 1..256 and bytes count must be 1..512.`),a(t,n,f)}function allows(e,t,n,r){switch(r){case`prefix`:return t===`String`&&[`uuid`,`uuidv7`,`ulid`,`nanoid`,`bytes`].includes(e);case`alphabet`:return e===`nanoid`;case`case`:return e===`ulid`||t===`String`&&[`uuid`,`uuidv7`].includes(e)||e===`bytes`&&[`hex`,`base32`].includes(n??``);case`checksum`:return e===`pattern`;default:return!1}}export{parseGeneration};
|
|
2
2
|
//# sourceMappingURL=GenerationParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerationParser.js","names":["tokenPattern","stringBodyPattern","typeIdPrefix","value","character","unescapeString","tokens","line","match","context","code","message","locationOf","DiagnosticCodes","strategy","result","index","valid","text","size","count","encoding","range","rule","seen","modifier","primitive","parseGenerationPattern","failure","InvalidGenerationPattern","parseGenerationBody"],"sources":["../../../../../../Compiler/Parsing/GenerationParser.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 { ChecksumAlgorithm, InvalidGenerationPattern, parseGenerationPattern } from '../Generation';\nimport { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { ParserContext } from './ParserContext';\nimport { parseGenerationBody } from './GenerationBodyParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst tokenPattern = new RegExp(`\"${stringBodyPattern}\"|\\\\S+`, 'g');\nconst typeIdPrefix = /^([a-z]([a-z_]{0,61}[a-z])?)?$(?![\\s\\S])/;\nconst printable = (value: string): boolean => [...value].every(character => character >= ' ' && character <= '~');\nconst literal = (value: string | undefined): string | undefined => value !== undefined && value.length >= 2 && value.startsWith('\"') && value.endsWith('\"') ? unescapeString(value.slice(1, -1)) : undefined;\nconst integer = (value: string | undefined): number | undefined => value !== undefined && /^-?[0-9]+$(?![\\s\\S])/.test(value) && Number(value) >= -2147483648 && Number(value) <= 2147483647 ? Number(value) : undefined;\n\nexport function parseGeneration(context: ParserContext, line: SourceLine, primitive: string): GenerationSyntax | null {\n const tokens = [...line.content.matchAll(tokenPattern)].map(match => match[0]).slice(1);\n const error = (code: string, message: string): void => context.error(code, message, locationOf(line));\n if (tokens.length === 0) {\n error(DiagnosticCodes.InvalidGenerationArgument, \"Expected 'generate <strategy> [modifiers]'.\");\n return null;\n }\n const strategy = tokens[0];\n if (!['uuid', 'uuidv7', 'ulid', 'typeid', 'nanoid', 'bytes', 'pattern', 'random', 'rule', 'sequence'].includes(strategy)) {\n error(DiagnosticCodes.UnknownGenerationStrategy, `Unknown generation strategy '${strategy}'.`);\n return null;\n }\n let result: GenerationSyntax = { kind: 'GenerationSyntax', strategy, location: locationOf(line) };\n let index = 1;\n let valid = true;\n switch (strategy) {\n case 'typeid':\n case 'pattern': {\n const text = literal(tokens[index++]);\n valid = text !== undefined;\n result = strategy === 'typeid' ? { ...result, prefix: text } : { ...result, pattern: text };\n break;\n }\n case 'nanoid': {\n const size = integer(tokens[index]);\n if (size !== undefined) { result = { ...result, size }; index++; }\n break;\n }\n case 'bytes': {\n const count = integer(tokens[index++]);\n const encoding = tokens[index++];\n valid = count !== undefined && ['base64url', 'hex', 'base32'].includes(encoding);\n result = { ...result, count, encoding };\n break;\n }\n case 'random': {\n const range = tokens[index++];\n const match = range?.match(/^(-?(?:0|[1-9][0-9]*))\\.\\.(-?(?:0|[1-9][0-9]*))$(?![\\s\\S])/);\n valid = match !== null && match !== undefined && BigInt(match[1]) >= -9223372036854775808n && BigInt(match[2]) <= 9223372036854775807n && BigInt(match[1]) <= BigInt(match[2]);\n result = { ...result, range };\n break;\n }\n case 'rule': {\n const rule = tokens[index++];\n valid = rule !== undefined && /^[A-Za-z_][A-Za-z0-9_]*$(?![\\s\\S])/.test(rule);\n result = { ...result, rule };\n break;\n }\n }\n if (!valid) {\n error(DiagnosticCodes.InvalidGenerationArgument, `Missing or invalid argument for generation strategy '${strategy}'.`);\n return result;\n }\n const seen = new Set<string>();\n while (index < tokens.length) {\n const modifier = tokens[index++];\n const value = tokens[index++];\n if (seen.has(modifier)) error(DiagnosticCodes.DuplicateGenerationModifier, `Generation modifier '${modifier}' is repeated.`);\n seen.add(modifier);\n if (!allows(strategy, primitive, result.encoding, modifier)) {\n error(DiagnosticCodes.InvalidGenerationModifier, `Generation modifier '${modifier}' is not allowed for '${strategy}' on '${primitive}'.`);\n continue;\n }\n const text = literal(value);\n if (modifier === 'prefix' || modifier === 'alphabet' ? text === undefined : modifier === 'case' ? !['lower', 'upper'].includes(value) : !['luhn', 'mod11', 'mod97'].includes(value)) {\n error(DiagnosticCodes.InvalidGenerationArgument, `Missing or invalid value for generation modifier '${modifier}'.`);\n continue;\n }\n switch (modifier) {\n case 'prefix': result = { ...result, prefix: text }; break;\n case 'alphabet': result = { ...result, alphabet: text }; break;\n case 'case': result = { ...result, case: value }; break;\n default: result = { ...result, checksum: value };\n }\n }\n if (strategy === 'pattern' && result.pattern !== undefined && result.pattern !== null) {\n try { parseGenerationPattern(result.pattern, result.checksum as ChecksumAlgorithm | undefined); }\n catch (failure) {\n if (!(failure instanceof InvalidGenerationPattern)) throw failure;\n error(failure.message.includes('expanded length') ? DiagnosticCodes.GenerationSizeOutsideRange : DiagnosticCodes.InvalidGenerationArgument, failure.message);\n }\n }\n const allowed = strategy === 'sequence' || (primitive === 'Uuid' ? ['uuid', 'uuidv7'].includes(strategy) : primitive === 'String' ? strategy !== 'random' : primitive === 'Int' && strategy === 'random');\n if (!allowed) error(DiagnosticCodes.InvalidGenerationPrimitive, `Generation strategy '${strategy}' is not allowed on '${primitive}'.`);\n if (result.prefix !== undefined && result.prefix !== null) {\n if (strategy === 'typeid') {\n if (!typeIdPrefix.test(result.prefix)) error(DiagnosticCodes.InvalidTypeIdPrefix, 'TypeID prefix must be empty or 1..63 lowercase letters and underscores, starting and ending with a letter.');\n } else if (result.prefix.length > 32 || !printable(result.prefix)) error(DiagnosticCodes.InvalidGenerationPrefix, 'Generation prefix must contain at most 32 printable ASCII characters.');\n }\n if (result.alphabet !== undefined && result.alphabet !== null && (result.alphabet.length < 2 || result.alphabet.length > 256 || !printable(result.alphabet) || new Set(result.alphabet).size !== result.alphabet.length)) {\n error(DiagnosticCodes.InvalidGenerationAlphabet, 'NanoID alphabet must contain 2..256 distinct printable ASCII characters.');\n }\n if ((result.size !== undefined && result.size !== null && (result.size < 1 || result.size > 256)) || (result.count !== undefined && result.count !== null && (result.count < 1 || result.count > 512))) {\n error(DiagnosticCodes.GenerationSizeOutsideRange, 'NanoID size must be 1..256 and bytes count must be 1..512.');\n }\n return parseGenerationBody(context, line, result);\n}\n\nfunction allows(strategy: string, primitive: string, encoding: string | null | undefined, modifier: string): boolean {\n switch (modifier) {\n case 'prefix': return primitive === 'String' && ['uuid', 'uuidv7', 'ulid', 'nanoid', 'bytes'].includes(strategy);\n case 'alphabet': return strategy === 'nanoid';\n case 'case': return strategy === 'ulid' || (primitive === 'String' && ['uuid', 'uuidv7'].includes(strategy)) || (strategy === 'bytes' && ['hex', 'base32'].includes(encoding ?? ''));\n case 'checksum': return strategy === 'pattern';\n default: return false;\n }\n}\n"],"mappings":"ufAWA,MAAMA,EAAmB,OAAO,IAAIC,EAAkB,QAAS,GAAG,EAC5DC,EAAe,2CACf,UAAa,GAA2B,CAAC,GAAGC,CAAK,CAAC,CAAC,MAAM,GAAaC,GAAa,KAAOA,GAAa,GAAG,EAC1G,QAAW,GAAkDD,IAAU,IAAA,IAAaA,EAAM,QAAU,GAAKA,EAAM,WAAW,GAAG,GAAKA,EAAM,SAAS,GAAG,EAAIE,EAAeF,EAAM,MAAM,EAAG,EAAE,CAAC,EAAI,IAAA,GAC7L,QAAW,GAAkDA,IAAU,IAAA,IAAa,uBAAuB,KAAKA,CAAK,GAAK,OAAOA,CAAK,GAAK,aAAe,OAA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AAO,KAAO,MAAUA,EAAO,QAAU,IAAA,IAAaA,EAAO,QAAU,OAASA,EAAO,MAAQ,GAAKA,EAAO,MAAQ,OAC7L,MAAMF,EAAgB,2BAA4B,4DAA4D,EAE3GiB,EAAoBrB,EAASF,EAAMQ,CAAM,CACpD,CAEA,SAAS,OAAO,EAAkB,EAAmB,EAAqC,EAA2B,CACjH,OAAQU,EAAR,CACI,IAAK,SAAU,OAAOC,IAAc,UAAY,CAAC,OAAQ,SAAU,OAAQ,SAAU,OAAO,CAAC,CAAC,SAASZ,CAAQ,EAC/G,IAAK,WAAY,OAAOA,IAAa,SACrC,IAAK,OAAQ,OAAOA,IAAa,QAAWY,IAAc,UAAY,CAAC,OAAQ,QAAQ,CAAC,CAAC,SAASZ,CAAQ,GAAOA,IAAa,SAAW,CAAC,MAAO,QAAQ,CAAC,CAAC,SAASO,GAAY,EAAE,EAClL,IAAK,WAAY,OAAOP,IAAa,UACrC,QAAS,MAAO,EACpB,CACJ"}
|
|
1
|
+
{"version":3,"file":"GenerationParser.js","names":["tokenPattern","stringBodyPattern","typeIdPrefix","value","character","unescapeString","tokens","line","match","context","code","message","locationOf","DiagnosticCodes","strategy","result","index","valid","text","size","count","encoding","range","rule","seen","modifier","primitive","parseGenerationPattern","failure","InvalidGenerationPattern","parseGenerationBody"],"sources":["../../../../../../Compiler/Parsing/GenerationParser.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 { ChecksumAlgorithm, InvalidGenerationPattern, parseGenerationPattern } from '../Generation';\nimport { GenerationSyntax } from '../Syntax/GenerationSyntax';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { ParserContext } from './ParserContext';\nimport { parseGenerationBody } from './GenerationBodyParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst tokenPattern = new RegExp(`\"${stringBodyPattern}\"|\\\\S+`, 'g');\nconst typeIdPrefix = /^([a-z]([a-z_]{0,61}[a-z])?)?$(?![\\s\\S])/;\nconst printable = (value: string): boolean => [...value].every(character => character >= ' ' && character <= '~');\nconst literal = (value: string | undefined): string | undefined => value !== undefined && value.length >= 2 && value.startsWith('\"') && value.endsWith('\"') ? unescapeString(value.slice(1, -1)) : undefined;\nconst integer = (value: string | undefined): number | undefined => value !== undefined && /^-?[0-9]+$(?![\\s\\S])/.test(value) && Number(value) >= -2147483648 && Number(value) <= 2147483647 ? Number(value) : undefined;\n\nexport function parseGeneration(context: ParserContext, line: SourceLine, primitive: string): GenerationSyntax | null {\n const tokens = [...line.content.matchAll(tokenPattern)].map(match => match[0]).slice(1);\n const error = (code: string, message: string): void => context.error(code, message, locationOf(line));\n if (tokens.length === 0) {\n error(DiagnosticCodes.InvalidGenerationArgument, \"Expected 'generate <strategy> [modifiers]'.\");\n return null;\n }\n const strategy = tokens[0];\n if (!['uuid', 'uuidv7', 'ulid', 'typeid', 'nanoid', 'bytes', 'pattern', 'random', 'rule', 'sequence'].includes(strategy)) {\n error(DiagnosticCodes.UnknownGenerationStrategy, `Unknown generation strategy '${strategy}'.`);\n return null;\n }\n let result: GenerationSyntax = { kind: 'GenerationSyntax', strategy, location: locationOf(line) };\n let index = 1;\n let valid = true;\n switch (strategy) {\n case 'typeid':\n case 'pattern': {\n const text = literal(tokens[index++]);\n valid = text !== undefined;\n result = strategy === 'typeid' ? { ...result, prefix: text } : { ...result, pattern: text };\n break;\n }\n case 'nanoid': {\n const size = integer(tokens[index]);\n if (size !== undefined) { result = { ...result, size }; index++; }\n break;\n }\n case 'bytes': {\n const count = integer(tokens[index++]);\n const encoding = tokens[index++];\n valid = count !== undefined && ['base64url', 'hex', 'base32'].includes(encoding);\n result = { ...result, count, encoding };\n break;\n }\n case 'random': {\n const range = tokens[index++];\n const match = range?.match(/^(-?(?:0|[1-9][0-9]*))\\.\\.(-?(?:0|[1-9][0-9]*))$(?![\\s\\S])/);\n valid = match !== null && match !== undefined && BigInt(match[1]) >= -9223372036854775808n && BigInt(match[2]) <= 9223372036854775807n && BigInt(match[1]) <= BigInt(match[2]);\n result = { ...result, range };\n break;\n }\n case 'rule': {\n const rule = tokens[index++];\n valid = rule !== undefined && /^[A-Za-z_][A-Za-z0-9_]*$(?![\\s\\S])/.test(rule);\n result = { ...result, rule };\n break;\n }\n }\n if (!valid) {\n error(DiagnosticCodes.InvalidGenerationArgument, `Missing or invalid argument for generation strategy '${strategy}'.`);\n return result;\n }\n const seen = new Set<string>();\n while (index < tokens.length) {\n const modifier = tokens[index++];\n const value = tokens[index++];\n if (seen.has(modifier)) error(DiagnosticCodes.DuplicateGenerationModifier, `Generation modifier '${modifier}' is repeated.`);\n seen.add(modifier);\n if (!allows(strategy, primitive, result.encoding, modifier)) {\n error(DiagnosticCodes.InvalidGenerationModifier, `Generation modifier '${modifier}' is not allowed for '${strategy}' on '${primitive}'.`);\n continue;\n }\n const text = literal(value);\n if (modifier === 'prefix' || modifier === 'alphabet' ? text === undefined : modifier === 'case' ? !['lower', 'upper'].includes(value) : !['luhn', 'mod11', 'mod97'].includes(value)) {\n error(DiagnosticCodes.InvalidGenerationArgument, `Missing or invalid value for generation modifier '${modifier}'.`);\n continue;\n }\n switch (modifier) {\n case 'prefix': result = { ...result, prefix: text }; break;\n case 'alphabet': result = { ...result, alphabet: text }; break;\n case 'case': result = { ...result, case: value }; break;\n default: result = { ...result, checksum: value };\n }\n }\n if (strategy === 'pattern' && result.pattern !== undefined && result.pattern !== null) {\n try { parseGenerationPattern(result.pattern, result.checksum as ChecksumAlgorithm | undefined); }\n catch (failure) {\n if (!(failure instanceof InvalidGenerationPattern)) throw failure;\n error(failure.message.includes('expanded length') ? DiagnosticCodes.GenerationSizeOutsideRange : DiagnosticCodes.InvalidGenerationArgument, failure.message);\n }\n }\n const allowed = strategy === 'sequence' || (primitive === 'Uuid' ? ['uuid', 'uuidv7'].includes(strategy) : primitive === 'String' ? strategy !== 'random' : primitive === 'Int' && strategy === 'random');\n if (!allowed) error(DiagnosticCodes.InvalidGenerationPrimitive, `Generation strategy '${strategy}' is not allowed on '${primitive}'.`);\n if (result.prefix !== undefined && result.prefix !== null) {\n if (strategy === 'typeid') {\n if (!typeIdPrefix.test(result.prefix)) error(DiagnosticCodes.InvalidTypeIdPrefix, 'TypeID prefix must be empty or 1..63 lowercase letters and underscores, starting and ending with a letter.');\n } else if (result.prefix.length > 32 || !printable(result.prefix)) error(DiagnosticCodes.InvalidGenerationPrefix, 'Generation prefix must contain at most 32 printable ASCII characters.');\n }\n if (result.alphabet !== undefined && result.alphabet !== null && (result.alphabet.length < 2 || result.alphabet.length > 256 || !printable(result.alphabet) || new Set(result.alphabet).size !== result.alphabet.length)) {\n error(DiagnosticCodes.InvalidGenerationAlphabet, 'NanoID alphabet must contain 2..256 distinct printable ASCII characters.');\n }\n if ((result.size !== undefined && result.size !== null && (result.size < 1 || result.size > 256)) || (result.count !== undefined && result.count !== null && (result.count < 1 || result.count > 512))) {\n error(DiagnosticCodes.GenerationSizeOutsideRange, 'NanoID size must be 1..256 and bytes count must be 1..512.');\n }\n return parseGenerationBody(context, line, result);\n}\n\nfunction allows(strategy: string, primitive: string, encoding: string | null | undefined, modifier: string): boolean {\n switch (modifier) {\n case 'prefix': return primitive === 'String' && ['uuid', 'uuidv7', 'ulid', 'nanoid', 'bytes'].includes(strategy);\n case 'alphabet': return strategy === 'nanoid';\n case 'case': return strategy === 'ulid' || (primitive === 'String' && ['uuid', 'uuidv7'].includes(strategy)) || (strategy === 'bytes' && ['hex', 'base32'].includes(encoding ?? ''));\n case 'checksum': return strategy === 'pattern';\n default: return false;\n }\n}\n"],"mappings":"A,ufAWA,MAAMA,EAAmB,OAAO,IAAIC,EAAkB,QAAS,GAAG,EAC5DC,EAAe,2CACf,UAAa,GAA2B,CAAC,GAAGC,CAAK,CAAC,CAAC,MAAM,GAAaC,GAAa,KAAOA,GAAa,GAAG,EAC1G,QAAW,GAAkDD,IAAU,IAAA,IAAaA,E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S,OAAS,KAAO,CAAC,UAAUA,EAAO,QAAQ,GAAK,IAAI,IAAIA,EAAO,QAAQ,CAAC,CAAC,OAASA,EAAO,SAAS,SAC7M,MAAMF,EAAgB,0BAA2B,0EAA0E,GAE1HE,EAAO,OAAS,IAAA,IAAaA,EAAO,OAAS,OAASA,EAAO,KAAO,GAAKA,EAAO,KAAO,MAAUA,EAAO,QAAU,IAAA,IAAaA,EAAO,QAAU,OAASA,EAAO,MAAQ,GAAKA,EAAO,MAAQ,OAC7L,MAAMF,EAAgB,2BAA4B,4DAA4D,EAE3GiB,EAAoBrB,EAASF,EAAMQ,CAAM,CACpD,CAEA,SAAS,OAAO,EAAkB,EAAmB,EAAqC,EAA2B,CACjH,OAAQU,EAAR,CACI,IAAK,SAAU,OAAOC,IAAc,UAAY,CAAC,OAAQ,SAAU,OAAQ,SAAU,OAAO,CAAC,CAAC,SAASZ,CAAQ,EAC/G,IAAK,WAAY,OAAOA,IAAa,SACrC,IAAK,OAAQ,OAAOA,IAAa,QAAWY,IAAc,UAAY,CAAC,OAAQ,QAAQ,CAAC,CAAC,SAASZ,CAAQ,GAAOA,IAAa,SAAW,CAAC,MAAO,QAAQ,CAAC,CAAC,SAASO,GAAY,EAAE,EAClL,IAAK,WAAY,OAAOP,IAAa,UACrC,QAAS,MAAO,EACpB,CACJ,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardedActionInputs.js","names":["primitives","declarations","name","slice","candidate","command","commandName","argument","arguments_","inputs","property","context","DiagnosticCodes","subjectProperty","properties","path","segments","index","segment","matches","allowTerminalCollection","location","type","concept","composite","condition"],"sources":["../../../../../../Compiler/Parsing/GuardedActionInputs.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 { ComparisonConditionSyntax, ConditionSyntax } from '../Syntax/Conditions';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { InteractionArgumentSyntax } from '../Syntax/Screens';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\nconst primitives = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime']);\n\nexport function viewProperties(name: string, slice: SliceSyntax | undefined, declarations: RefusalDeclarations): readonly PropertySyntax[] | null {\n return declarations.resolve(name, slice, candidate => candidate.readModels)?.node.properties ?? null;\n}\n\nexport function validateArguments(commandName: string, arguments_: readonly InteractionArgumentSyntax[], properties: readonly PropertySyntax[] | null, slice: SliceSyntax | undefined, declarations: RefusalDeclarations, context: ParserContext): void {\n const command = declarations.resolve(commandName, slice, candidate => candidate.commands)?.node;\n for (const argument of arguments_) {\n const inputs = command?.properties.filter(property => property.name === argument.name);\n if (inputs?.length === 0) context.warning(DiagnosticCodes.UnknownActionArgumentProperty, `Command '${commandName}' has no argument property '${argument.name}'`, argument.location);\n const subjectProperty = validateItemPath(argument.binding, argument.location, properties, slice, declarations, context, true);\n if (inputs?.length === 1 && subjectProperty !== null && inputs[0].type.isCollection !== subjectProperty.type.isCollection) {\n context.warning(DiagnosticCodes.UnknownActionArgumentProperty, `Command argument '${commandName}.${argument.name}' and subject field '${argument.binding}' must have matching collection cardinality`, argument.location);\n }\n }\n}\n\nexport function validateItemPath(path: string, location: SourceLocation, properties: readonly PropertySyntax[] | null, slice: SliceSyntax | undefined, declarations: RefusalDeclarations, context: ParserContext, allowTerminalCollection = false): PropertySyntax | null {\n if (!path.startsWith('item.') || properties === null) return null;\n const segments = path.substring('item.'.length).split('.');\n for (const [index, segment] of segments.entries()) {\n const matches: readonly PropertySyntax[] = properties.filter(property => property.name === segment);\n if (matches.length === 0 || (matches.length === 1 && matches[0].type.isCollection && (!allowTerminalCollection || index < segments.length - 1))) {\n context.warning(DiagnosticCodes.UnknownActionSubjectField, `Unknown or collection-valued subject field '${path}' - guarded actions require an item field path`, location);\n return null;\n }\n if (matches.length !== 1) return null;\n if (index === segments.length - 1) return matches[0];\n const type = matches[0].type;\n properties = declarations.types.get(type.name)?.properties ?? viewProperties(type.name, slice, declarations);\n if (properties === null) {\n if (primitives.has(type.name) || declarations.application.concepts.some(concept => concept.name === type.name) && !declarations.application.types.some(composite => composite.name === type.name)) {\n context.warning(DiagnosticCodes.UnknownActionSubjectField, `Subject field '${path}' continues past scalar '${segment}'`, location);\n }\n return null;\n }\n }\n return null;\n}\n\nexport function comparisons(condition: ConditionSyntax): readonly ComparisonConditionSyntax[] {\n return condition.kind === 'ComparisonConditionSyntax' ? [condition] : [...comparisons(condition.left), ...comparisons(condition.right)];\n}\n"],"mappings":"yHAYA,MAAMA,kBAAa,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,CAAC,EAE3F,SAAgB,eAAe,EAAc,EAAgC,EAAqE,CAC9I,OAAOC,EAAa,QAAQC,EAAMC,EAAO,GAAaC,EAAU,UAAU,CAAC,EAAE,KAAK,YAAc,IACpG,CAEA,SAAgB,kBAAkB,EAAqB,EAAkD,EAA8C,EAAgC,EAAmC,EAA8B,CACpP,IAAMC,EAAUJ,EAAa,QAAQK,EAAaH,EAAO,GAAaC,EAAU,QAAQ,CAAC,EAAE,KAC3F,IAAK,IAAMG,KAAYC,EAAY,CAC/B,IAAMC,EAASJ,GAAS,WAAW,OAAO,GAAYK,EAAS,OAASH,EAAS,IAAI,EACjFE,GAAQ,SAAW,GAAGE,EAAQ,QAAQC,EAAgB,8BAA+B,YAAYN,EAAY,8BAA8BC,EAAS,KAAK,GAAIA,EAAS,QAAQ,EAClL,IAAMM,EAAkB,iBAAiBN,EAAS,QAASA,EAAS,SAAUO,EAAYX,EAAOF,EAAcU,EAAS,EAAI,EACxHF,GAAQ,SAAW,GAAKI,IAAoB,MAAQJ,EAAO,EAAE,CAAC,KAAK,eAAiBI,EAAgB,KAAK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I,EAAU,OAAS,4BAA8B,CAACA,CAAS,EAAI,CAAC,GAAG,YAAYA,EAAU,IAAI,EAAG,GAAG,YAAYA,EAAU,KAAK,CAAC,CAC1I"}
|
|
1
|
+
{"version":3,"file":"GuardedActionInputs.js","names":["primitives","declarations","name","slice","candidate","command","commandName","argument","arguments_","inputs","property","context","DiagnosticCodes","subjectProperty","properties","path","segments","index","segment","matches","allowTerminalCollection","location","type","concept","composite","condition"],"sources":["../../../../../../Compiler/Parsing/GuardedActionInputs.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 { ComparisonConditionSyntax, ConditionSyntax } from '../Syntax/Conditions';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { InteractionArgumentSyntax } from '../Syntax/Screens';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\nconst primitives = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime']);\n\nexport function viewProperties(name: string, slice: SliceSyntax | undefined, declarations: RefusalDeclarations): readonly PropertySyntax[] | null {\n return declarations.resolve(name, slice, candidate => candidate.readModels)?.node.properties ?? null;\n}\n\nexport function validateArguments(commandName: string, arguments_: readonly InteractionArgumentSyntax[], properties: readonly PropertySyntax[] | null, slice: SliceSyntax | undefined, declarations: RefusalDeclarations, context: ParserContext): void {\n const command = declarations.resolve(commandName, slice, candidate => candidate.commands)?.node;\n for (const argument of arguments_) {\n const inputs = command?.properties.filter(property => property.name === argument.name);\n if (inputs?.length === 0) context.warning(DiagnosticCodes.UnknownActionArgumentProperty, `Command '${commandName}' has no argument property '${argument.name}'`, argument.location);\n const subjectProperty = validateItemPath(argument.binding, argument.location, properties, slice, declarations, context, true);\n if (inputs?.length === 1 && subjectProperty !== null && inputs[0].type.isCollection !== subjectProperty.type.isCollection) {\n context.warning(DiagnosticCodes.UnknownActionArgumentProperty, `Command argument '${commandName}.${argument.name}' and subject field '${argument.binding}' must have matching collection cardinality`, argument.location);\n }\n }\n}\n\nexport function validateItemPath(path: string, location: SourceLocation, properties: readonly PropertySyntax[] | null, slice: SliceSyntax | undefined, declarations: RefusalDeclarations, context: ParserContext, allowTerminalCollection = false): PropertySyntax | null {\n if (!path.startsWith('item.') || properties === null) return null;\n const segments = path.substring('item.'.length).split('.');\n for (const [index, segment] of segments.entries()) {\n const matches: readonly PropertySyntax[] = properties.filter(property => property.name === segment);\n if (matches.length === 0 || (matches.length === 1 && matches[0].type.isCollection && (!allowTerminalCollection || index < segments.length - 1))) {\n context.warning(DiagnosticCodes.UnknownActionSubjectField, `Unknown or collection-valued subject field '${path}' - guarded actions require an item field path`, location);\n return null;\n }\n if (matches.length !== 1) return null;\n if (index === segments.length - 1) return matches[0];\n const type = matches[0].type;\n properties = declarations.types.get(type.name)?.properties ?? viewProperties(type.name, slice, declarations);\n if (properties === null) {\n if (primitives.has(type.name) || declarations.application.concepts.some(concept => concept.name === type.name) && !declarations.application.types.some(composite => composite.name === type.name)) {\n context.warning(DiagnosticCodes.UnknownActionSubjectField, `Subject field '${path}' continues past scalar '${segment}'`, location);\n }\n return null;\n }\n }\n return null;\n}\n\nexport function comparisons(condition: ConditionSyntax): readonly ComparisonConditionSyntax[] {\n return condition.kind === 'ComparisonConditionSyntax' ? [condition] : [...comparisons(condition.left), ...comparisons(condition.right)];\n}\n"],"mappings":"A,yHAYA,MAAMA,kBAAa,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,UAAU,CAAC,EAE3F,SAAgB,eAAe,EAAc,EAAgC,EAAqE,CAC9I,OAAOC,EAAa,QAAQC,EAAMC,EAAO,GAAaC,EAAU,UAAU,CAAC,EAAE,KAAK,YAAc,IACpG,CAEA,SAAgB,kBAAkB,EAAqB,EAAkD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S,EAAG,OAAOG,EAAQ,GAClD,IAAMG,EAAOH,EAAQ,EAAE,CAAC,KAExB,GADA,EAAalB,EAAa,MAAM,IAAIqB,EAAK,IAAI,CAAC,EAAE,YAAc,eAAeA,EAAK,KAAMnB,EAAOF,CAAY,EACvGa,IAAe,KAIf,OAHId,EAAW,IAAIsB,EAAK,IAAI,GAAKrB,EAAa,YAAY,SAAS,KAAK,GAAWsB,EAAQ,OAASD,EAAK,IAAI,GAAK,CAACrB,EAAa,YAAY,MAAM,KAAK,GAAauB,EAAU,OAASF,EAAK,IAAI,IAC5LX,EAAQ,QAAQC,EAAgB,0BAA2B,kBAAkBG,EAAK,2BAA2BG,EAAQ,GAAIG,CAAQ,EAE9H,IAEf,CACA,OAAO,IACX,CAEA,SAAgB,YAAY,EAAkE,CAC1F,OAAOI,EAAU,OAAS,4BAA8B,CAACA,CAAS,EAAI,CAAC,GAAG,YAAYA,EAAU,IAAI,EAAG,GAAG,YAAYA,EAAU,KAAK,CAAC,CAC1I,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,pattern as n}from"../Text/patterns.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,pattern as n}from"../Text/patterns.js";import{parseCondition as r}from"./ConditionParser.js";import{firstWord as i}from"./LineText.js";import{locationOf as a}from"./SourceLine.js";const o=n(`^when${t}+([^\\n]+)${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),s=n(`^otherwise${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),c=n(`^with${t}+([A-Za-z_]\\w*)${t}+from${t}+([^\\n]+)$`),l=n(`^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$`),u=RegExp(`^${t}+|${t}+$`,`gu`);function parseGuardedAction(t,n,c,l){let u=[],d=null,f=null,p=!1;for(let c=t.peekChild(n.indent);c!==void 0;c=t.peekChild(n.indent)){t.reader.takeSignificant();let n=o.exec(c.content),m=s.exec(c.content);if(n!==null){p&&t.error(e.MisplacedActionOtherwise,`A 'when' alternative must precede 'otherwise'`,a(c));let i=r(t,n[1],a(c),!0),o=parseArguments(t,c);i!==null&&(validateCondition(t,i),u.push({kind:`ScreenActionAlternativeSyntax`,condition:i,command:n[2],arguments:o,location:a(c)}))}else if(c.content===`otherwise hidden`||m!==null){if(p&&t.error(e.MisplacedActionOtherwise,`A guarded action permits only one 'otherwise'`,a(c)),p=!0,m!==null)d={kind:`ScreenActionOtherwiseSyntax`,outcome:`Execute`,command:m[1],arguments:parseArguments(t,c),location:a(c)};else{d={kind:`ScreenActionOtherwiseSyntax`,outcome:`Hidden`,command:null,arguments:[],location:a(c)};for(let n=t.peekChild(c.indent);n!==void 0;n=t.peekChild(c.indent))t.reader.takeSignificant(),t.error(e.InvalidActionAlternative,`'otherwise hidden' cannot declare command arguments`,a(n)),t.skipBlock(n.indent)}}else if(i(c.content)===`navigate`)f!==null&&t.error(e.InvalidActionAlternative,`A guarded action permits only one 'navigate to'`,a(c)),f=l(t,c.content,c)??null;else{let n=i(c.content)===`label`;t.error(n?e.UnknownActionDirective:e.InvalidActionAlternative,n?`A guarded action's header already supplies its label`:`Unexpected '${c.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,a(c)),t.skipBlock(c.indent)}}return u.length===0&&t.error(e.GuardedActionWithoutAlternatives,`A guarded action must declare at least one 'when' alternative`,a(n)),{kind:`ScreenGuardedActionSyntax`,label:c,alternatives:u,otherwise:d,navigate:f,location:a(n)}}function parseArguments(t,n){let r=[];for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent)){t.reader.takeSignificant();let n=c.exec(i.content);n===null?(t.error(e.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,a(i)),t.skipBlock(i.indent)):r.push({kind:`InteractionArgumentSyntax`,name:n[1],binding:n[2].replace(u,``),location:a(i)})}return r}function validateCondition(t,n){if(n.kind===`LogicalConditionSyntax`){validateCondition(t,n.left),validateCondition(t,n.right);return}let r=n.right.kind===`LiteralExpressionSyntax`?n.right.value:void 0,i=l.test(n.left)&&n.right.kind===`LiteralExpressionSyntax`;[`GreaterThan`,`GreaterThanOrEqual`,`LessThan`,`LessThanOrEqual`].includes(n.operator)?i&&=typeof r==`number`||typeof r==`object`&&!!r:[`Contains`,`StartsWith`].includes(n.operator)&&(i&&=typeof r==`string`),i||t.error(e.UnsupportedActionConditionOperand,`Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string`,n.location)}export{parseGuardedAction,validateCondition};
|
|
2
2
|
//# sourceMappingURL=GuardedActionParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardedActionParser.js","names":["alternative","pattern","dotNetWhitespace","otherwise","argument","itemPath","bindingWhitespace","alternatives","fallback","navigate","sawOtherwise","child","context","line","match","fallbackMatch","DiagnosticCodes","locationOf","condition","parseCondition","args","nested","firstWord","parseNavigate","isLabel","value","supported"],"sources":["../../../../../../Compiler/Parsing/GuardedActionParser.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 { ConditionSyntax } from '../Syntax/Conditions';\nimport { InteractionArgumentSyntax, ScreenActionAlternativeSyntax, ScreenActionOtherwiseSyntax, ScreenGuardedActionSyntax, ScreenNavigateSyntax } from '../Syntax/Screens';\nimport { dotNetWhitespace, pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// .NET '.' stops only at LF; U+2028/U+2029 stay inside a CR/LF-delimited source line.\nconst alternative = pattern(`^when${dotNetWhitespace}+([^\\\\n]+)${dotNetWhitespace}+execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst otherwise = pattern(`^otherwise${dotNetWhitespace}+execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst argument = pattern(`^with${dotNetWhitespace}+([A-Za-z_]\\\\w*)${dotNetWhitespace}+from${dotNetWhitespace}+([^\\\\n]+)$`);\nconst itemPath = pattern('^item\\\\.[A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*$');\nconst bindingWhitespace = new RegExp(`^${dotNetWhitespace}+|${dotNetWhitespace}+$`, 'gu');\n\ntype ParseNavigate = (context: ParserContext, text: string, line: SourceLine) => ScreenNavigateSyntax | undefined;\n\nexport function parseGuardedAction(context: ParserContext, line: SourceLine, label: string, parseNavigate: ParseNavigate): ScreenGuardedActionSyntax {\n const alternatives: ScreenActionAlternativeSyntax[] = [];\n let fallback: ScreenActionOtherwiseSyntax | null = null;\n let navigate: ScreenNavigateSyntax | null = null;\n let sawOtherwise = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const match = alternative.exec(child.content);\n const fallbackMatch = otherwise.exec(child.content);\n if (match !== null) {\n if (sawOtherwise) context.error(DiagnosticCodes.MisplacedActionOtherwise, \"A 'when' alternative must precede 'otherwise'\", locationOf(child));\n const condition = parseCondition(context, match[1], locationOf(child), true);\n const args = parseArguments(context, child);\n if (condition !== null) {\n validateCondition(context, condition);\n alternatives.push({ kind: 'ScreenActionAlternativeSyntax', condition, command: match[2], arguments: args, location: locationOf(child) });\n }\n } else if (child.content === 'otherwise hidden' || fallbackMatch !== null) {\n if (sawOtherwise) context.error(DiagnosticCodes.MisplacedActionOtherwise, \"A guarded action permits only one 'otherwise'\", locationOf(child));\n sawOtherwise = true;\n if (fallbackMatch !== null) {\n fallback = { kind: 'ScreenActionOtherwiseSyntax', outcome: 'Execute', command: fallbackMatch[1], arguments: parseArguments(context, child), location: locationOf(child) };\n } else {\n fallback = { kind: 'ScreenActionOtherwiseSyntax', outcome: 'Hidden', command: null, arguments: [], location: locationOf(child) };\n for (let nested = context.peekChild(child.indent); nested !== undefined; nested = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n context.error(DiagnosticCodes.InvalidActionAlternative, \"'otherwise hidden' cannot declare command arguments\", locationOf(nested));\n context.skipBlock(nested.indent);\n }\n }\n } else if (firstWord(child.content) === 'navigate') {\n if (navigate !== null) context.error(DiagnosticCodes.InvalidActionAlternative, \"A guarded action permits only one 'navigate to'\", locationOf(child));\n navigate = parseNavigate(context, child.content, child) ?? null;\n } else {\n const isLabel = firstWord(child.content) === 'label';\n context.error(isLabel ? DiagnosticCodes.UnknownActionDirective : DiagnosticCodes.InvalidActionAlternative, isLabel\n ? \"A guarded action's header already supplies its label\"\n : `Unexpected '${child.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (alternatives.length === 0) context.error(DiagnosticCodes.GuardedActionWithoutAlternatives, \"A guarded action must declare at least one 'when' alternative\", locationOf(line));\n return { kind: 'ScreenGuardedActionSyntax', label, alternatives, otherwise: fallback, navigate, location: locationOf(line) };\n}\n\nfunction parseArguments(context: ParserContext, line: SourceLine): InteractionArgumentSyntax[] {\n const args: InteractionArgumentSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const match = argument.exec(child.content);\n if (match !== null) args.push({ kind: 'InteractionArgumentSyntax', name: match[1], binding: match[2].replace(bindingWhitespace, ''), location: locationOf(child) });\n else {\n context.error(DiagnosticCodes.InvalidInteractionArgument, `Invalid argument '${child.content}' - expected 'with <name> from <binding>'`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return args;\n}\n\nexport function validateCondition(context: ParserContext, condition: ConditionSyntax): void {\n if (condition.kind === 'LogicalConditionSyntax') {\n validateCondition(context, condition.left);\n validateCondition(context, condition.right);\n return;\n }\n const value = condition.right.kind === 'LiteralExpressionSyntax' ? condition.right.value : undefined;\n let supported = itemPath.test(condition.left) && condition.right.kind === 'LiteralExpressionSyntax';\n if (['GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual'].includes(condition.operator)) {\n supported &&= typeof value === 'number' || (typeof value === 'object' && value !== null);\n } else if (['Contains', 'StartsWith'].includes(condition.operator)) supported &&= typeof value === 'string';\n if (!supported) context.error(DiagnosticCodes.UnsupportedActionConditionOperand, \"Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string\", condition.location);\n}\n"],"mappings":"0UAaA,MAAMA,EAAcC,EAAQ,QAAQC,EAAiB,YAAYA,EAAiB,UAAUA,EAAiB,8BAA8B,EACrIC,EAAYF,EAAQ,aAAaC,EAAiB,UAAUA,EAAiB,8BAA8B,EAC3GE,EAAWH,EAAQ,QAAQC,EAAiB,kBAAkBA,EAAiB,OAAOA,EAAiB,YAAY,EACnHG,EAAWJ,EAAQ,6CAA6C,EAChEK,EAAwB,OAAO,IAAIJ,EAAiB,IAAIA,EAAiB,IAAK,IAAI,EAIxF,SAAgB,mBAAmB,EAAwB,EAAkB,EAAe,EAAyD,CACjJ,IAAMK,EAAgD,CAAC,EACnDC,EAA+C,KAC/CC,EAAwC,KACxCC,EAAe,GACnB,IAAK,IAAIC,EAAQC,EAAQ,UAAUC,EAAK,MAAM,EAAGF,IAAU,IAAA,GAAW,EAAQC,EAAQ,UAAUC,EAAK,MAAM,EAAG,CAC1GD,EAAQ,OAAO,gBAAgB,EAC/B,IAAME,EAAQd,EAAY,KAAKW,EAAM,OAAO,EACtCI,EAAgBZ,EAAU,KAAKQ,EAAM,OAAO,EAClD,GAAIG,IAAU,KAAM,CACZJ,GAAcE,EAAQ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OAAOO,GAAU,UAAa,OAAOA,GAAU,YAAYA,EAClE,CAAC,WAAY,YAAY,CAAC,CAAC,SAASP,EAAU,QAAQ,IAAG,IAAc,OAAOO,GAAU,UAC9FC,GAAWd,EAAQ,MAAMI,EAAgB,kCAAmC,kIAAmIE,EAAU,QAAQ,CAC1O"}
|
|
1
|
+
{"version":3,"file":"GuardedActionParser.js","names":["alternative","pattern","dotNetWhitespace","otherwise","argument","itemPath","bindingWhitespace","alternatives","fallback","navigate","sawOtherwise","child","context","line","match","fallbackMatch","DiagnosticCodes","locationOf","condition","parseCondition","args","nested","firstWord","parseNavigate","isLabel","value","supported"],"sources":["../../../../../../Compiler/Parsing/GuardedActionParser.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 { ConditionSyntax } from '../Syntax/Conditions';\nimport { InteractionArgumentSyntax, ScreenActionAlternativeSyntax, ScreenActionOtherwiseSyntax, ScreenGuardedActionSyntax, ScreenNavigateSyntax } from '../Syntax/Screens';\nimport { dotNetWhitespace, pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// .NET '.' stops only at LF; U+2028/U+2029 stay inside a CR/LF-delimited source line.\nconst alternative = pattern(`^when${dotNetWhitespace}+([^\\\\n]+)${dotNetWhitespace}+execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst otherwise = pattern(`^otherwise${dotNetWhitespace}+execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst argument = pattern(`^with${dotNetWhitespace}+([A-Za-z_]\\\\w*)${dotNetWhitespace}+from${dotNetWhitespace}+([^\\\\n]+)$`);\nconst itemPath = pattern('^item\\\\.[A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*$');\nconst bindingWhitespace = new RegExp(`^${dotNetWhitespace}+|${dotNetWhitespace}+$`, 'gu');\n\ntype ParseNavigate = (context: ParserContext, text: string, line: SourceLine) => ScreenNavigateSyntax | undefined;\n\nexport function parseGuardedAction(context: ParserContext, line: SourceLine, label: string, parseNavigate: ParseNavigate): ScreenGuardedActionSyntax {\n const alternatives: ScreenActionAlternativeSyntax[] = [];\n let fallback: ScreenActionOtherwiseSyntax | null = null;\n let navigate: ScreenNavigateSyntax | null = null;\n let sawOtherwise = false;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const match = alternative.exec(child.content);\n const fallbackMatch = otherwise.exec(child.content);\n if (match !== null) {\n if (sawOtherwise) context.error(DiagnosticCodes.MisplacedActionOtherwise, \"A 'when' alternative must precede 'otherwise'\", locationOf(child));\n const condition = parseCondition(context, match[1], locationOf(child), true);\n const args = parseArguments(context, child);\n if (condition !== null) {\n validateCondition(context, condition);\n alternatives.push({ kind: 'ScreenActionAlternativeSyntax', condition, command: match[2], arguments: args, location: locationOf(child) });\n }\n } else if (child.content === 'otherwise hidden' || fallbackMatch !== null) {\n if (sawOtherwise) context.error(DiagnosticCodes.MisplacedActionOtherwise, \"A guarded action permits only one 'otherwise'\", locationOf(child));\n sawOtherwise = true;\n if (fallbackMatch !== null) {\n fallback = { kind: 'ScreenActionOtherwiseSyntax', outcome: 'Execute', command: fallbackMatch[1], arguments: parseArguments(context, child), location: locationOf(child) };\n } else {\n fallback = { kind: 'ScreenActionOtherwiseSyntax', outcome: 'Hidden', command: null, arguments: [], location: locationOf(child) };\n for (let nested = context.peekChild(child.indent); nested !== undefined; nested = context.peekChild(child.indent)) {\n context.reader.takeSignificant();\n context.error(DiagnosticCodes.InvalidActionAlternative, \"'otherwise hidden' cannot declare command arguments\", locationOf(nested));\n context.skipBlock(nested.indent);\n }\n }\n } else if (firstWord(child.content) === 'navigate') {\n if (navigate !== null) context.error(DiagnosticCodes.InvalidActionAlternative, \"A guarded action permits only one 'navigate to'\", locationOf(child));\n navigate = parseNavigate(context, child.content, child) ?? null;\n } else {\n const isLabel = firstWord(child.content) === 'label';\n context.error(isLabel ? DiagnosticCodes.UnknownActionDirective : DiagnosticCodes.InvalidActionAlternative, isLabel\n ? \"A guarded action's header already supplies its label\"\n : `Unexpected '${child.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n if (alternatives.length === 0) context.error(DiagnosticCodes.GuardedActionWithoutAlternatives, \"A guarded action must declare at least one 'when' alternative\", locationOf(line));\n return { kind: 'ScreenGuardedActionSyntax', label, alternatives, otherwise: fallback, navigate, location: locationOf(line) };\n}\n\nfunction parseArguments(context: ParserContext, line: SourceLine): InteractionArgumentSyntax[] {\n const args: InteractionArgumentSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const match = argument.exec(child.content);\n if (match !== null) args.push({ kind: 'InteractionArgumentSyntax', name: match[1], binding: match[2].replace(bindingWhitespace, ''), location: locationOf(child) });\n else {\n context.error(DiagnosticCodes.InvalidInteractionArgument, `Invalid argument '${child.content}' - expected 'with <name> from <binding>'`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return args;\n}\n\nexport function validateCondition(context: ParserContext, condition: ConditionSyntax): void {\n if (condition.kind === 'LogicalConditionSyntax') {\n validateCondition(context, condition.left);\n validateCondition(context, condition.right);\n return;\n }\n const value = condition.right.kind === 'LiteralExpressionSyntax' ? condition.right.value : undefined;\n let supported = itemPath.test(condition.left) && condition.right.kind === 'LiteralExpressionSyntax';\n if (['GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual'].includes(condition.operator)) {\n supported &&= typeof value === 'number' || (typeof value === 'object' && value !== null);\n } else if (['Contains', 'StartsWith'].includes(condition.operator)) supported &&= typeof value === 'string';\n if (!supported) context.error(DiagnosticCodes.UnsupportedActionConditionOperand, \"Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string\", condition.location);\n}\n"],"mappings":"A,0UAaA,MAAMA,EAAcC,EAAQ,QAAQC,EAAiB,YAAYA,EAAiB,UAAUA,EAAiB,8BAA8B,EACrIC,EAAYF,EAAQ,aAAaC,EAAiB,UAAUA,EAAiB,8BAA8B,EAC3GE,EAAWH,EAAQ,QAAQC,EAAiB,kBAAkBA,EAAiB,OAAOA,EAAiB,YAAY,EACnHG,EAAWJ,EAAQ,6CAA6C,EAChEK,EAAwB,OAAO,IAAIJ,EAAiB,IAAIA,EAAiB,IAAK,IAAI,EAIxF,SAAgB,mBAAmB,EAAwB,EAAkB,EAAe,EAAyD,CACjJ,IAAMK,EAAgD,CAAC,EACnDC,EAA+C,KAC/CC,EAAwC,KACxCC,EAAe,GACnB,IAAK,IAAIC,EAAQC,EAAQ,UAAUC,EAAK,MAAM,EAAGF,IAAU,IAAA,GAAW,EAAQC,EAAQ,UAAUC,EAAK,MAAM,EAAG,CAC1GD,EAAQ,OAAO,gBAAgB,EAC/B,IAAME,EAAQd,EAAY,KAAKW,EAAM,OAAO,EACtCI,EAAgBZ,EAAU,KAAKQ,EAAM,OAAO,EAClD,GAAIG,IAAU,KAAM,CACZJ,GAAcE,EAAQ,MAAMI,EAAgB,yBAA0B,gDAAiDC,EAAWN,CAAK,CAAC,EAC5I,IAAMO,EAAYC,EAAeP,EAASE,EAAM,GAAIG,EAAWN,CAAK,EAAG,EAAI,EACrES,EAAO,eAAeR,EAASD,CAAK,EACtCO,IAAc,OACd,kBAAkBN,EAASM,CAAS,EACpCX,EAAa,KAAK,CAAE,KAAM,gCAAiC,YAAW,QAASO,EAAM,GAAI,UAAWM,EAAM,SAAUH,EAAWN,CAAK,CAAE,CAAC,EAE/I,MAAO,GAAIA,EAAM,UAAY,oBAAsBI,IAAkB,KAAM,CAGvE,GAFIL,GAAcE,E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AAQ,UAAUC,EAAK,MAAM,EAAGF,IAAU,IAAA,GAAW,EAAQC,EAAQ,UAAUC,EAAK,MAAM,EAAG,CAC1GD,EAAQ,OAAO,gBAAgB,EAC/B,IAAME,EAAQV,EAAS,KAAKO,EAAM,OAAO,EACrCG,IAAU,MAEVF,EAAQ,MAAMI,EAAgB,2BAA4B,qBAAqBL,EAAM,QAAQ,2CAA4CM,EAAWN,CAAK,CAAC,EAC1JC,EAAQ,UAAUD,EAAM,MAAM,GAHdS,EAAK,KAAK,CAAE,KAAM,4BAA6B,KAAMN,EAAM,GAAI,QAASA,EAAM,EAAE,CAAC,QAAQR,EAAmB,EAAE,EAAG,SAAUW,EAAWN,CAAK,CAAE,CAAC,CAKtK,CACA,OAAOS,CACX,CAEA,SAAgB,kBAAkB,EAAwB,EAAkC,CACxF,GAAIF,EAAU,OAAS,yBAA0B,CAC7C,kBAAkBN,EAASM,EAAU,IAAI,EACzC,kBAAkBN,EAASM,EAAU,KAAK,EAC1C,MACJ,CACA,IAAMO,EAAQP,EAAU,MAAM,OAAS,0BAA4BA,EAAU,MAAM,MAAQ,IAAA,GACvFQ,EAAYrB,EAAS,KAAKa,EAAU,IAAI,GAAKA,EAAU,MAAM,OAAS,0BACtE,CAAC,cAAe,qBAAsB,WAAY,iBAAiB,CAAC,CAAC,SAASA,EAAU,QAAQ,EAChG,IAAc,OAAOO,GAAU,UAAa,OAAOA,GAAU,YAAYA,EAClE,CAAC,WAAY,YAAY,CAAC,CAAC,SAASP,EAAU,QAAQ,IAAG,IAAc,OAAOO,GAAU,UAC9FC,GAAWd,EAAQ,MAAMI,EAAgB,kCAAmC,kIAAmIE,EAAU,QAAQ,CAC1O,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardedActionShadowing.js","names":["action","alternative","context","earlier","alternatives","terms","previous","term","comparison","DiagnosticCodes","condition","value","left","right","first","second"],"sources":["../../../../../../Compiler/Parsing/GuardedActionShadowing.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ConditionSyntax } from '../Syntax/Conditions';\nimport { ScreenGuardedActionSyntax } from '../Syntax/Screens';\nimport { ParserContext } from './ParserContext';\n\nconst maximumDisjuncts = 64;\n\nexport interface ShadowingAlternative {\n readonly condition: ConditionSyntax;\n readonly location: SourceLocation;\n readonly message: string;\n}\n\nexport function validateGuardedActionShadowing(action: ScreenGuardedActionSyntax, context: ParserContext): void {\n validateAlternativeShadowing(action.alternatives.map(alternative => ({ ...alternative, message: `Alternative executing '${alternative.command}' is shadowed by earlier alternatives in this action` })), context);\n}\n\n// Proves shadowing by comparison-set inclusion, bounding each DNF expansion to 64 disjuncts.\nexport function validateAlternativeShadowing(alternatives: readonly ShadowingAlternative[], context: ParserContext): void {\n const earlier: ReadonlySet<string>[] = [];\n for (const alternative of alternatives) {\n const terms = normalize(alternative.condition);\n if (terms === null) continue;\n if (terms.length > 0 && terms.every(term => earlier.some(previous => [...previous].every(comparison => term.has(comparison))))) {\n context.warning(DiagnosticCodes.UnreachableActionAlternative, alternative.message, alternative.location);\n }\n earlier.push(...terms);\n }\n}\n\nfunction normalize(condition: ConditionSyntax): ReadonlySet<string>[] | null {\n if (condition.kind === 'ComparisonConditionSyntax') {\n if (condition.right.kind !== 'LiteralExpressionSyntax') return null;\n const value = condition.right.value;\n // Preserve literal type as well as value (null, text, Boolean, Double or exact Decimal).\n const comparison = JSON.stringify([condition.left, condition.operator, typeof value, value !== null && typeof value === 'object' ? value.value : typeof value === 'number' ? String(value) : value]);\n return [new Set([comparison])];\n }\n const left = normalize(condition.left);\n const right = normalize(condition.right);\n if (left === null || right === null) return null;\n if (condition.operator === 'Or') return left.length + right.length > maximumDisjuncts ? null : [...left, ...right];\n if (left.length * right.length > maximumDisjuncts) return null;\n return left.flatMap(first => right.map(second => new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GAASC,EAAM,IAAI,mBAAU,IAAI,IAAI,CAAC,GAAGC,EAAO,GAAGC,CAAM,CAAC,CAAC,CAAC,CACpF"}
|
|
1
|
+
{"version":3,"file":"GuardedActionShadowing.js","names":["action","alternative","context","earlier","alternatives","terms","previous","term","comparison","DiagnosticCodes","condition","value","left","right","first","second"],"sources":["../../../../../../Compiler/Parsing/GuardedActionShadowing.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ConditionSyntax } from '../Syntax/Conditions';\nimport { ScreenGuardedActionSyntax } from '../Syntax/Screens';\nimport { ParserContext } from './ParserContext';\n\nconst maximumDisjuncts = 64;\n\nexport interface ShadowingAlternative {\n readonly condition: ConditionSyntax;\n readonly location: SourceLocation;\n readonly message: string;\n}\n\nexport function validateGuardedActionShadowing(action: ScreenGuardedActionSyntax, context: ParserContext): void {\n validateAlternativeShadowing(action.alternatives.map(alternative => ({ ...alternative, message: `Alternative executing '${alternative.command}' is shadowed by earlier alternatives in this action` })), context);\n}\n\n// Proves shadowing by comparison-set inclusion, bounding each DNF expansion to 64 disjuncts.\nexport function validateAlternativeShadowing(alternatives: readonly ShadowingAlternative[], context: ParserContext): void {\n const earlier: ReadonlySet<string>[] = [];\n for (const alternative of alternatives) {\n const terms = normalize(alternative.condition);\n if (terms === null) continue;\n if (terms.length > 0 && terms.every(term => earlier.some(previous => [...previous].every(comparison => term.has(comparison))))) {\n context.warning(DiagnosticCodes.UnreachableActionAlternative, alternative.message, alternative.location);\n }\n earlier.push(...terms);\n }\n}\n\nfunction normalize(condition: ConditionSyntax): ReadonlySet<string>[] | null {\n if (condition.kind === 'ComparisonConditionSyntax') {\n if (condition.right.kind !== 'LiteralExpressionSyntax') return null;\n const value = condition.right.value;\n // Preserve literal type as well as value (null, text, Boolean, Double or exact Decimal).\n const comparison = JSON.stringify([condition.left, condition.operator, typeof value, value !== null && typeof value === 'object' ? value.value : typeof value === 'number' ? String(value) : value]);\n return [new Set([comparison])];\n }\n const left = normalize(condition.left);\n const right = normalize(condition.right);\n if (left === null || right === null) return null;\n if (condition.operator === 'Or') return left.length + right.length > maximumDisjuncts ? null : [...left, ...right];\n if (left.length * right.length > maximumDisjuncts) return null;\n return left.flatMap(first => right.map(second => new Set([...first, ...second])));\n}\n"],"mappings":"A,yHAiBA,SAAgB,+BAA+B,EAAmC,EAA8B,CAC5G,6BAA6BA,EAAO,aAAa,IAAI,IAAgB,CAAE,GAAGC,EAAa,QAAS,0BAA0BA,EAAY,QAAQ,qDAAsD,EAAE,EAAGC,CAAO,CACpN,CAGA,SAAgB,6BAA6B,EAA+C,EAA8B,CACtH,IAAMC,EAAiC,CAAC,EACxC,IAAK,IAAMF,KAAeG,EAAc,CACpC,IAAMC,EAAQ,UAAUJ,EAAY,SAAS,EACzCI,IAAU,OACVA,EAAM,OAAS,GAAKA,EAAM,MAAM,GAAQF,EAAQ,KAAK,GAAY,CAAC,GAAGG,CAAQ,CAAC,CAAC,MAAM,GAAcC,EAAK,IAAIC,CAAU,CAAC,CAAC,CAAC,GACzHN,EAAQ,QAAQO,EAAgB,6BAA8BR,EAAY,QAASA,EAAY,QAAQ,EAE3GE,EAAQ,KAAK,GAAGE,CAAK,EACzB,CACJ,CAEA,SAAS,UAAU,EAA0D,CACzE,GAAIK,EAAU,OAAS,4BAA6B,CAChD,GAAIA,EAAU,MAAM,OAAS,0BAA2B,OAAO,KAC/D,IAAMC,EAAQD,EAAU,MAAM,MAExBF,EAAa,KAAK,UAAU,CAACE,EAAU,KAAMA,EAAU,SAAU,OAAOC,EAAyB,OAAOA,GAAU,UAAnCA,EAA8CA,EAAM,MAAQ,OAAOA,GAAU,SAAW,OAAOA,CAAK,EAAIA,CAAK,CAAC,EACnM,MAAO,iBAAC,IAAI,IAAI,CAACH,CAAU,CAAC,CAAC,CACjC,CACA,IAAMI,EAAO,UAAUF,EAAU,IAAI,EAC/BG,EAAQ,UAAUH,EAAU,KAAK,EAIvC,OAHIE,IAAS,MAAQC,IAAU,KAAa,KACxCH,EAAU,WAAa,KAAaE,EAAK,OAASC,EAAM,OAAS,GAAmB,KAAO,CAAC,GAAGD,EAAM,GAAGC,CAAK,EAC7GD,EAAK,OAASC,EAAM,OAAS,GAAyB,KACnDD,EAAK,QAAQ,GAASC,EAAM,IAAI,mBAAU,IAAI,IAAI,CAAC,GAAGC,EAAO,GAAGC,CAAM,CAAC,CAAC,CAAC,CACpF,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{resolveActionSubjects as e}from"../ScreenActionSubjects.js";import{comparisons as t,validateArguments as n,validateItemPath as r,viewProperties as i}from"./GuardedActionInputs.js";import{validateGuardedActionShadowing as a}from"./GuardedActionShadowing.js";import{GuardedInteractions as o}from"./GuardedInteractions.js";import{RefusalDeclarations as s}from"./RefusalDeclarations.js";function validateGuardedActions(t,n){for(let r of e(t).diagnostics)n[r.severity](r.code,r.message,r.location,r.arguments);let r=new s(t),i=new o(r,n);i.structural(t);for(let{slice:e}of r.slices)for(let t of e.screens)validateContainer(t.directives,[],e,r,n,i)}function tableSubjects(e,t,n,r){let a=t.filter(t=>t.type.name===e.target);if(a.length>0||t.length!==1)return a;let o=t[0],s=i(o.type.name,n,r)?.filter(t=>t.name===e.target&&t.type.isCollection);return s?.length===1?[{...o,type:s[0].type,by:null,location:e.location}]:[]}function validateContainer(e,t,r,a,o,s){let c=e.filter(e=>e.kind===`ScreenDataSyntax`),l=c.length===0?t:c;for(let t of e)switch(t.kind){case`ScreenGuardedActionSyntax`:validateAction(t,l,r,a,o);break;case`ScreenActionSyntax`:n(t.command,t.inputs??[],l.length===1?i(l[0].type.name,r,a):null,r,a,o);break;case`ScreenBehaviorSyntax`:s.at(t.location,l,r);break;case`ScreenUsesBehaviorSyntax`:s.useAt(t.location,l,r);break;case`ScreenTableSyntax`:s.at(t.location,tableSubjects(t,l,r,a),r,!0);break;case`ScreenComponentSyntax`:s.at(t.location,l,r,!0);for(let e of t.outlets)validateContainer(e.directives,l,r,a,o,s);break;case`ScreenSectionSyntax`:validateContainer(t.directives,l,r,a,o,s);break;case`ScreenTemplateReferenceSyntax`:for(let e of t.slots)validateContainer(e.directives,l,r,a,o,s)}}function validateAction(e,o,s,c,l){let u=o.length===1?i(o[0].type.name,s,c):null;for(let i of e.alternatives){for(let e of t(i.condition))r(e.left,e.location,u,s,c,l);n(i.command,i.arguments,u,s,c,l)}e.otherwise?.command!=null&&n(e.otherwise.command,e.otherwise.arguments,u,s,c,l),a(e,l)}export{validateGuardedActions};
|
|
2
2
|
//# sourceMappingURL=GuardedActionValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardedActionValidator.js","names":["diagnostic","resolveActionSubjects","application","context","declarations","RefusalDeclarations","interactions","GuardedInteractions","screen","slice","direct","subjects","subject","table","source","fields","viewProperties","property","local","directives","directive","inherited","validateArguments","outlet","slot","properties","alternative","action","comparison","comparisons","validateItemPath","validateGuardedActionShadowing"],"sources":["../../../../../../Compiler/Parsing/GuardedActionValidator.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 { resolveActionSubjects } from '../ScreenActionSubjects';\nimport { ScreenDataSyntax, ScreenDirectiveSyntax, ScreenGuardedActionSyntax, ScreenTableSyntax } from '../Syntax/Screens';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { comparisons, validateArguments, validateItemPath, viewProperties } from './GuardedActionInputs';\nimport { validateGuardedActionShadowing } from './GuardedActionShadowing';\nimport { GuardedInteractions } from './GuardedInteractions';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\n// Resolves known subject and input shapes without guessing imported or ambiguous declarations.\nexport function validateGuardedActions(application: ApplicationSyntax, context: ParserContext): void {\n for (const diagnostic of resolveActionSubjects(application).diagnostics) context[diagnostic.severity](diagnostic.code, diagnostic.message, diagnostic.location, diagnostic.arguments);\n const declarations = new RefusalDeclarations(application);\n const interactions = new GuardedInteractions(declarations, context);\n interactions.structural(application);\n for (const { slice } of declarations.slices) {\n for (const screen of slice.screens) validateContainer(screen.directives, [], slice, declarations, context, interactions);\n }\n}\n\nfunction tableSubjects(table: ScreenTableSyntax, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations): readonly ScreenDataSyntax[] {\n const direct = subjects.filter(subject => subject.type.name === table.target);\n if (direct.length > 0 || subjects.length !== 1) return direct;\n const source = subjects[0];\n const fields = viewProperties(source.type.name, slice, declarations)?.filter(property => property.name === table.target && property.type.isCollection);\n return fields?.length === 1 ? [{ ...source, type: fields[0].type, by: null, location: table.location }] : [];\n}\n\nfunction validateContainer(directives: readonly ScreenDirectiveSyntax[], inherited: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations, context: ParserContext, interactions: GuardedInteractions): void {\n const local = directives.filter(directive => directive.kind === 'ScreenDataSyntax');\n const subjects = local.length === 0 ? inherited : local;\n for (const directive of directives) {\n switch (directive.kind) {\n case 'ScreenGuardedActionSyntax':\n validateAction(directive, subjects, slice, declarations, context);\n break;\n case 'ScreenActionSyntax':\n validateArguments(directive.command, directive.inputs ?? [], subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, declarations) : null, slice, declarations, context);\n break;\n case 'ScreenBehaviorSyntax':\n interactions.at(directive.location, subjects, slice);\n break;\n case 'ScreenUsesBehaviorSyntax':\n interactions.useAt(directive.location, subjects, slice);\n break;\n case 'ScreenTableSyntax':\n interactions.at(directive.location, tableSubjects(directive, subjects, slice, declarations), slice, true);\n break;\n case 'ScreenComponentSyntax':\n interactions.at(directive.location, subjects, slice, true);\n for (const outlet of directive.outlets) validateContainer(outlet.directives, subjects, slice, declarations, context, interactions);\n break;\n case 'ScreenSectionSyntax':\n validateContainer(directive.directives, subjects, slice, declarations, context, interactions);\n break;\n case 'ScreenTemplateReferenceSyntax':\n for (const slot of directive.slots) validateContainer(slot.directives, subjects, slice, declarations, context, interactions);\n break;\n }\n }\n}\n\nfunction validateAction(action: ScreenGuardedActionSyntax, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations, context: ParserContext): void {\n const properties = subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, declarations) : null;\n for (const alternative of action.alternatives) {\n for (const comparison of comparisons(alternative.condition)) validateItemPath(comparison.left, comparison.location, properties, slice, declarations, context);\n validateArguments(alternative.command, alternative.arguments, properties, slice, declarations, context);\n }\n if (action.otherwise?.command != null) validateArguments(action.otherwise.command, action.otherwise.arguments, properties, slice, declarations, context);\n validateGuardedActionShadowing(action, context);\n}\n"],"mappings":"2bAaA,SAAgB,uBAAuB,EAAgC,EAA8B,CACjG,IAAK,IAAMA,KAAcC,EAAsBC,CAAW,CAAC,CAAC,YAAaC,EAAQH,EAAW,SAAS,CAACA,EAAW,KAAMA,EAAW,QAASA,EAAW,SAAUA,EAAW,SAAS,EACpL,IAAMI,EAAe,IAAIC,EAAoBH,CAAW,EAClDI,EAAe,IAAIC,EAAoBH,EAAcD,CAAO,EAClEG,EAAa,WAAWJ,CAAW,EACnC,IAAK,GAAM,CAAE,WAAWE,EAAa,OACjC,IAAK,IAAMI,KAAUC,EAAM,QAAS,kBAAkBD,EAAO,WAAY,CAAC,EAAGC,EAAOL,EAAcD,EAASG,CAAY,CAE/H,CAEA,SAAS,cAAc,EAA0B,EAAuC,EAAoB,EAAgE,CACxK,IAAMI,EAASC,EAAS,OAAO,GAAWC,EAAQ,KAAK,OAASC,EAAM,MAAM,EAC5E,GAAIH,EAAO,OAAS,GAAKC,EAAS,SAAW,EAAG,OAAOD,EACvD,IAAMI,EAASH,EAAS,GAClBI,EAASC,EAAeF,EAAO,KAAK,K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kBAAkBI,EAAK,WAAYb,EAAUF,EAAOL,EAAcD,EAASG,CAAY,CAEnI,CAER,CAEA,SAAS,eAAe,EAAmC,EAAuC,EAAoB,EAAmC,EAA8B,CACnL,IAAMmB,EAAad,EAAS,SAAW,EAAIK,EAAeL,EAAS,EAAE,CAAC,KAAK,KAAMF,EAAOL,CAAY,EAAI,KACxG,IAAK,IAAMsB,KAAeC,EAAO,aAAc,CAC3C,IAAK,IAAMC,KAAcC,EAAYH,EAAY,SAAS,EAAGI,EAAiBF,EAAW,KAAMA,EAAW,SAAUH,EAAYhB,EAAOL,EAAcD,CAAO,EAC5JmB,EAAkBI,EAAY,QAASA,EAAY,UAAWD,EAAYhB,EAAOL,EAAcD,CAAO,CAC1G,CACIwB,EAAO,WAAW,SAAW,MAAML,EAAkBK,EAAO,UAAU,QAASA,EAAO,UAAU,UAAWF,EAAYhB,EAAOL,EAAcD,CAAO,EACvJ4B,EAA+BJ,EAAQxB,CAAO,CAClD"}
|
|
1
|
+
{"version":3,"file":"GuardedActionValidator.js","names":["diagnostic","resolveActionSubjects","application","context","declarations","RefusalDeclarations","interactions","GuardedInteractions","screen","slice","direct","subjects","subject","table","source","fields","viewProperties","property","local","directives","directive","inherited","validateArguments","outlet","slot","properties","alternative","action","comparison","comparisons","validateItemPath","validateGuardedActionShadowing"],"sources":["../../../../../../Compiler/Parsing/GuardedActionValidator.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 { resolveActionSubjects } from '../ScreenActionSubjects';\nimport { ScreenDataSyntax, ScreenDirectiveSyntax, ScreenGuardedActionSyntax, ScreenTableSyntax } from '../Syntax/Screens';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { comparisons, validateArguments, validateItemPath, viewProperties } from './GuardedActionInputs';\nimport { validateGuardedActionShadowing } from './GuardedActionShadowing';\nimport { GuardedInteractions } from './GuardedInteractions';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\n// Resolves known subject and input shapes without guessing imported or ambiguous declarations.\nexport function validateGuardedActions(application: ApplicationSyntax, context: ParserContext): void {\n for (const diagnostic of resolveActionSubjects(application).diagnostics) context[diagnostic.severity](diagnostic.code, diagnostic.message, diagnostic.location, diagnostic.arguments);\n const declarations = new RefusalDeclarations(application);\n const interactions = new GuardedInteractions(declarations, context);\n interactions.structural(application);\n for (const { slice } of declarations.slices) {\n for (const screen of slice.screens) validateContainer(screen.directives, [], slice, declarations, context, interactions);\n }\n}\n\nfunction tableSubjects(table: ScreenTableSyntax, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations): readonly ScreenDataSyntax[] {\n const direct = subjects.filter(subject => subject.type.name === table.target);\n if (direct.length > 0 || subjects.length !== 1) return direct;\n const source = subjects[0];\n const fields = viewProperties(source.type.name, slice, declarations)?.filter(property => property.name === table.target && property.type.isCollection);\n return fields?.length === 1 ? [{ ...source, type: fields[0].type, by: null, location: table.location }] : [];\n}\n\nfunction validateContainer(directives: readonly ScreenDirectiveSyntax[], inherited: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations, context: ParserContext, interactions: GuardedInteractions): void {\n const local = directives.filter(directive => directive.kind === 'ScreenDataSyntax');\n const subjects = local.length === 0 ? inherited : local;\n for (const directive of directives) {\n switch (directive.kind) {\n case 'ScreenGuardedActionSyntax':\n validateAction(directive, subjects, slice, declarations, context);\n break;\n case 'ScreenActionSyntax':\n validateArguments(directive.command, directive.inputs ?? [], subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, declarations) : null, slice, declarations, context);\n break;\n case 'ScreenBehaviorSyntax':\n interactions.at(directive.location, subjects, slice);\n break;\n case 'ScreenUsesBehaviorSyntax':\n interactions.useAt(directive.location, subjects, slice);\n break;\n case 'ScreenTableSyntax':\n interactions.at(directive.location, tableSubjects(directive, subjects, slice, declarations), slice, true);\n break;\n case 'ScreenComponentSyntax':\n interactions.at(directive.location, subjects, slice, true);\n for (const outlet of directive.outlets) validateContainer(outlet.directives, subjects, slice, declarations, context, interactions);\n break;\n case 'ScreenSectionSyntax':\n validateContainer(directive.directives, subjects, slice, declarations, context, interactions);\n break;\n case 'ScreenTemplateReferenceSyntax':\n for (const slot of directive.slots) validateContainer(slot.directives, subjects, slice, declarations, context, interactions);\n break;\n }\n }\n}\n\nfunction validateAction(action: ScreenGuardedActionSyntax, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations, context: ParserContext): void {\n const properties = subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, declarations) : null;\n for (const alternative of action.alternatives) {\n for (const comparison of comparisons(alternative.condition)) validateItemPath(comparison.left, comparison.location, properties, slice, declarations, context);\n validateArguments(alternative.command, alternative.arguments, properties, slice, declarations, context);\n }\n if (action.otherwise?.command != null) validateArguments(action.otherwise.command, action.otherwise.arguments, properties, slice, declarations, context);\n validateGuardedActionShadowing(action, context);\n}\n"],"mappings":"A,2bAaA,SAAgB,uBAAuB,EAAgC,EAA8B,CACjG,IAAK,IAAMA,KAAcC,EAAsBC,CAAW,CAAC,CAAC,YAAaC,EAAQH,EAAW,SAAS,CAACA,EAAW,KAAMA,EAAW,QAASA,EAAW,SAAUA,EAAW,SAAS,EACpL,IAAMI,EAAe,IAAIC,EAAoBH,CAAW,EAClDI,EAAe,IAAIC,EAAoBH,EAAcD,CAAO,EAClEG,EAAa,WAAWJ,CAAW,EACnC,IAAK,GAAM,CAAE,WAAWE,EAAa,OACjC,IAAK,IAAMI,KAAUC,EAAM,QAAS,kBAAkBD,EAAO,WAAY,CAAC,EAAGC,EAAOL,EAAcD,EAASG,CAAY,CAE/H,CAEA,SAAS,cAAc,EAA0B,EAAuC,EAAoB,EAAgE,CACxK,IAAMI,EAASC,EAAS,OAAO,GAAWC,EAAQ,KAAK,OAASC,EAAM,MAAM,EAC5E,GAAIH,EAAO,OAAS,GAAKC,EAAS,SAAW,EAAG,OAAOD,EAC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5F,MACJ,IAAK,gCACD,IAAK,IAAMkB,KAAQJ,EAAU,MAAO,kBAAkBI,EAAK,WAAYb,EAAUF,EAAOL,EAAcD,EAASG,CAAY,CAEnI,CAER,CAEA,SAAS,eAAe,EAAmC,EAAuC,EAAoB,EAAmC,EAA8B,CACnL,IAAMmB,EAAad,EAAS,SAAW,EAAIK,EAAeL,EAAS,EAAE,CAAC,KAAK,KAAMF,EAAOL,CAAY,EAAI,KACxG,IAAK,IAAMsB,KAAeC,EAAO,aAAc,CAC3C,IAAK,IAAMC,KAAcC,EAAYH,EAAY,SAAS,EAAGI,EAAiBF,EAAW,KAAMA,EAAW,SAAUH,EAAYhB,EAAOL,EAAcD,CAAO,EAC5JmB,EAAkBI,EAAY,QAASA,EAAY,UAAWD,EAAYhB,EAAOL,EAAcD,CAAO,CAC1G,CACIwB,EAAO,WAAW,SAAW,MAAML,EAAkBK,EAAO,UAAU,QAASA,EAAO,UAAU,UAAWF,EAAYhB,EAAOL,EAAcD,CAAO,EACvJ4B,EAA+BJ,EAAQxB,CAAO,CAClD,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{comparisons as t,validateArguments as n,validateItemPath as r,viewProperties as i}from"./GuardedActionInputs.js";import{validateAlternativeShadowing as a}from"./GuardedActionShadowing.js";import{effectiveStructuralInteractions as o,sameInteractionLocation as s}from"./StructuralInteractionSites.js";import{ParserContext as c}from"./ParserContext.js";var GuardedInteractions=class{declarations;context;constructor(e,t){this.declarations=e,this.context=t}structural(e){for(let t of o(e))`behavior`in t?this.validateUse(t,[],void 0):t.ancestors.some(e=>e.keyword===`behavior`)?a(t.alternatives,this.context):this.validate(t,[],void 0,this.context)}at(e,t,n,r=!1){for(let i of this.context.guardedInteractions){let a=r?i.ancestors.at(-1)?.location:i.location;a!==void 0&&s(a,e)&&this.validate(i,t,n,this.context)}if(r)for(let r of this.context.interactionUses){let i=r.ancestors.at(-1)?.location;i!==void 0&&s(i,e)&&this.validateUse(r,t,n)}}useAt(e,t,n){for(let r of this.context.interactionUses.filter(t=>s(t.location,e)))this.validateUse(r,t,n)}validateUse(e,t,n){let r=this.context.interactionBehaviors.filter(t=>t.name===e.behavior);if(r.length!==1)return;let i=new c(this.context.reader);for(let a of this.context.guardedInteractions)a.ancestors.some(e=>e.keyword===`behavior`&&s(e.location,r[0].location))&&this.validate(a,t,n,i,e.location);for(let e of i.diagnostics)this.context.diagnostics.some(t=>t.code===e.code&&t.message===e.message&&t.severity===e.severity&&s(t.location,e.location))||this.context.warning(e.code,e.message,e.location,e.arguments)}validate(o,s,c,l,u){let d=s.length===1?i(s[0].type.name,c,this.declarations)??this.declarations.types.get(s[0].type.name)?.properties??null:null;s.length!==1&&l.warning(e.UnresolvedActionSubject,`A guarded interaction requires exactly one nearest 'data' subject; component context and selection do not supply 'item'`,u??o.location);for(let e of o.alternatives){for(let n of t(e.condition))r(n.left,n.location,d,c,this.declarations,l);for(let t of e.executions)n(t.command,t.arguments,d,c,this.declarations,l)}for(let e of o.otherwise)n(e.command,e.arguments,d,c,this.declarations,l);u===void 0&&a(o.alternatives,l)}};export{GuardedInteractions};
|
|
2
2
|
//# sourceMappingURL=GuardedInteractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardedInteractions.js","names":["declarations","context","site","effectiveStructuralInteractions","application","ancestor","validateAlternativeShadowing","binding","attachment","container","sameInteractionLocation","location","subjects","slice","uses","matches","behavior","ParserContext","diagnostic","existing","properties","viewProperties","DiagnosticCodes","alternative","comparison","comparisons","validateItemPath","execution","validateArguments"],"sources":["../../../../../../Compiler/Parsing/GuardedInteractions.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 { ScreenDataSyntax } from '../Syntax/Screens';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { comparisons, validateArguments, validateItemPath, viewProperties } from './GuardedActionInputs';\nimport { validateAlternativeShadowing } from './GuardedActionShadowing';\nimport { GuardedInteractionBinding } from './InteractionAlternatives';\nimport { effectiveStructuralInteractions, sameInteractionLocation } from './StructuralInteractionSites';\nimport { InteractionUse } from './InteractionUse';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\n// Subject-dependent interaction checks share the guarded screen-action path and input validators.\nexport class GuardedInteractions {\n constructor(private readonly declarations: RefusalDeclarations, private readonly context: ParserContext) {}\n\n structural(application: ApplicationSyntax): void {\n for (const site of effectiveStructuralInteractions(application)) {\n if ('behavior' in site) this.validateUse(site, [], undefined);\n else if (site.ancestors.some(ancestor => ancestor.keyword === 'behavior')) validateAlternativeShadowing(site.alternatives, this.context);\n else this.validate(site, [], undefined, this.context);\n }\n }\n\n at(location: SourceLocation, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, container = false): void {\n for (const binding of this.context.guardedInteractions) {\n const attachment = container ? binding.ancestors.at(-1)?.location : binding.location;\n if (attachment !== undefined && sameInteractionLocation(attachment, location)) this.validate(binding, subjects, slice, this.context);\n }\n if (container) {\n for (const uses of this.context.interactionUses) {\n const attachment = uses.ancestors.at(-1)?.location;\n if (attachment !== undefined && sameInteractionLocation(attachment, location)) this.validateUse(uses, subjects, slice);\n }\n }\n }\n\n useAt(location: SourceLocation, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax): void {\n for (const uses of this.context.interactionUses.filter(uses => sameInteractionLocation(uses.location, location))) this.validateUse(uses, subjects, slice);\n }\n\n private validateUse(uses: InteractionUse, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax | undefined): void {\n const matches = this.context.interactionBehaviors.filter(behavior => behavior.name === uses.behavior);\n if (matches.length !== 1) return;\n const site = new ParserContext(this.context.reader);\n for (const binding of this.context.guardedInteractions) {\n if (binding.ancestors.some(ancestor => ancestor.keyword === 'behavior' && sameInteractionLocation(ancestor.location, matches[0].location))) {\n this.validate(binding, subjects, slice, site, uses.location);\n }\n }\n for (const diagnostic of site.diagnostics) {\n if (!this.context.diagnostics.some(existing => existing.code === diagnostic.code && existing.message === diagnostic.message && existing.severity === diagnostic.severity && sameInteractionLocation(existing.location, diagnostic.location))) {\n this.context.warning(diagnostic.code, diagnostic.message, diagnostic.location, diagnostic.arguments);\n }\n }\n }\n\n private validate(binding: GuardedInteractionBinding, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax | undefined, context: ParserContext, attachment?: SourceLocation): void {\n const properties = subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, this.declarations) ?? this.declarations.types.get(subjects[0].type.name)?.properties ?? null : null;\n if (subjects.length !== 1) {\n context.warning(DiagnosticCodes.UnresolvedActionSubject, \"A guarded interaction requires exactly one nearest 'data' subject; component context and selection do not supply 'item'\", attachment ?? binding.location);\n }\n for (const alternative of binding.alternatives) {\n for (const comparison of comparisons(alternative.condition)) validateItemPath(comparison.left, comparison.location, properties, slice, this.declarations, context);\n for (const execution of alternative.executions) validateArguments(execution.command, execution.arguments, properties, slice, this.declarations, context);\n }\n for (const execution of binding.otherwise) validateArguments(execution.command, execution.arguments, properties, slice, this.declarations, context);\n if (attachment === undefined) validateAlternativeShadowing(binding.alternatives, context);\n }\n}\n"],"mappings":"8dAgBA,IAAa,oBAAb,KAAiC,CACA,aAAoD,QAAjF,YAAY,EAAoD,EAAyC,CAA5E,KAAA,aAAAA,EAAoD,KAAA,QAAAC,CAAyB,CAE1G,WAAW,EAAsC,CAC7C,IAAK,IAAMC,KAAQC,EAAgCC,CAAW,EACtD,aAAcF,EAAM,KAAK,YAAYA,EAAM,CAAC,EAAG,IAAA,EAAS,EACnDA,EAAK,UAAU,K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,IAAMI,KAAchB,EAAK,YACrB,KAAK,QAAQ,YAAY,KAAK,GAAYiB,EAAS,OAASD,EAAW,MAAQC,EAAS,UAAYD,EAAW,SAAWC,EAAS,WAAaD,EAAW,UAAYR,EAAwBS,EAAS,SAAUD,EAAW,QAAQ,CAAC,GACvO,KAAK,QAAQ,QAAQA,EAAW,KAAMA,EAAW,QAASA,EAAW,SAAUA,EAAW,SAAS,CAG/G,CAEA,SAAiB,EAAoC,EAAuC,EAAgC,EAAwB,EAAmC,CACnL,IAAME,EAAaR,EAAS,SAAW,EAAIS,EAAeT,EAAS,EAAE,CAAC,KAAK,KAAMC,EAAO,KAAK,YAAY,GAAK,KAAK,aAAa,MAAM,IAAID,EAAS,EAAE,CAAC,KAAK,IAAI,CAAC,EAAE,YAAc,KAAO,KACnLA,EAAS,SAAW,GACpBX,EAAQ,QAAQqB,EAAgB,wBAAyB,0HAA2Hd,GAAcD,EAAQ,QAAQ,EAEtN,IAAK,IAAMgB,KAAehB,EAAQ,aAAc,CAC5C,IAAK,IAAMiB,KAAcC,EAAYF,EAAY,SAAS,EAAGG,EAAiBF,EAAW,KAAMA,EAAW,SAAUJ,EAAYP,EAAO,KAAK,aAAcZ,CAAO,EACjK,IAAK,IAAM0B,KAAaJ,EAAY,WAAYK,EAAkBD,EAAU,QAASA,EAAU,UAAWP,EAAYP,EAAO,KAAK,aAAcZ,CAAO,CAC3J,CACA,IAAK,IAAM0B,KAAapB,EAAQ,UAAWqB,EAAkBD,EAAU,QAASA,EAAU,UAAWP,EAAYP,EAAO,KAAK,aAAcZ,CAAO,EAC9IO,IAAe,IAAA,IAAWF,EAA6BC,EAAQ,aAAcN,CAAO,CAC5F,CACJ"}
|
|
1
|
+
{"version":3,"file":"GuardedInteractions.js","names":["declarations","context","site","effectiveStructuralInteractions","application","ancestor","validateAlternativeShadowing","binding","attachment","container","sameInteractionLocation","location","subjects","slice","uses","matches","behavior","ParserContext","diagnostic","existing","properties","viewProperties","DiagnosticCodes","alternative","comparison","comparisons","validateItemPath","execution","validateArguments"],"sources":["../../../../../../Compiler/Parsing/GuardedInteractions.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 { ScreenDataSyntax } from '../Syntax/Screens';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { comparisons, validateArguments, validateItemPath, viewProperties } from './GuardedActionInputs';\nimport { validateAlternativeShadowing } from './GuardedActionShadowing';\nimport { GuardedInteractionBinding } from './InteractionAlternatives';\nimport { effectiveStructuralInteractions, sameInteractionLocation } from './StructuralInteractionSites';\nimport { InteractionUse } from './InteractionUse';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\n// Subject-dependent interaction checks share the guarded screen-action path and input validators.\nexport class GuardedInteractions {\n constructor(private readonly declarations: RefusalDeclarations, private readonly context: ParserContext) {}\n\n structural(application: ApplicationSyntax): void {\n for (const site of effectiveStructuralInteractions(application)) {\n if ('behavior' in site) this.validateUse(site, [], undefined);\n else if (site.ancestors.some(ancestor => ancestor.keyword === 'behavior')) validateAlternativeShadowing(site.alternatives, this.context);\n else this.validate(site, [], undefined, this.context);\n }\n }\n\n at(location: SourceLocation, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, container = false): void {\n for (const binding of this.context.guardedInteractions) {\n const attachment = container ? binding.ancestors.at(-1)?.location : binding.location;\n if (attachment !== undefined && sameInteractionLocation(attachment, location)) this.validate(binding, subjects, slice, this.context);\n }\n if (container) {\n for (const uses of this.context.interactionUses) {\n const attachment = uses.ancestors.at(-1)?.location;\n if (attachment !== undefined && sameInteractionLocation(attachment, location)) this.validateUse(uses, subjects, slice);\n }\n }\n }\n\n useAt(location: SourceLocation, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax): void {\n for (const uses of this.context.interactionUses.filter(uses => sameInteractionLocation(uses.location, location))) this.validateUse(uses, subjects, slice);\n }\n\n private validateUse(uses: InteractionUse, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax | undefined): void {\n const matches = this.context.interactionBehaviors.filter(behavior => behavior.name === uses.behavior);\n if (matches.length !== 1) return;\n const site = new ParserContext(this.context.reader);\n for (const binding of this.context.guardedInteractions) {\n if (binding.ancestors.some(ancestor => ancestor.keyword === 'behavior' && sameInteractionLocation(ancestor.location, matches[0].location))) {\n this.validate(binding, subjects, slice, site, uses.location);\n }\n }\n for (const diagnostic of site.diagnostics) {\n if (!this.context.diagnostics.some(existing => existing.code === diagnostic.code && existing.message === diagnostic.message && existing.severity === diagnostic.severity && sameInteractionLocation(existing.location, diagnostic.location))) {\n this.context.warning(diagnostic.code, diagnostic.message, diagnostic.location, diagnostic.arguments);\n }\n }\n }\n\n private validate(binding: GuardedInteractionBinding, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax | undefined, context: ParserContext, attachment?: SourceLocation): void {\n const properties = subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, this.declarations) ?? this.declarations.types.get(subjects[0].type.name)?.properties ?? null : null;\n if (subjects.length !== 1) {\n context.warning(DiagnosticCodes.UnresolvedActionSubject, \"A guarded interaction requires exactly one nearest 'data' subject; component context and selection do not supply 'item'\", attachment ?? binding.location);\n }\n for (const alternative of binding.alternatives) {\n for (const comparison of comparisons(alternative.condition)) validateItemPath(comparison.left, comparison.location, properties, slice, this.declarations, context);\n for (const execution of alternative.executions) validateArguments(execution.command, execution.arguments, properties, slice, this.declarations, context);\n }\n for (const execution of binding.otherwise) validateArguments(execution.command, execution.arguments, properties, slice, this.declarations, context);\n if (attachment === undefined) validateAlternativeShadowing(binding.alternatives, context);\n }\n}\n"],"mappings":"A,8dAgBA,IAAa,oBAAb,KAAiC,CACA,aAAoD,QAAjF,YAAY,EAAoD,EAAyC,CAA5E,KAAA,aAAAA,EAAoD,KAAA,QAAAC,CAAyB,CAE1G,WAA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tual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{AuthoringProductionResolver as t}from"../Syntax/AuthoringProductionResolver.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{dependencySourcesOf as r}from"../Syntax/DependencySources.js";import{uniqueByName as i}from"./ResponseValidator.js";function validateIdentifierCompliance(a,o){let s=new Set(a.concepts.filter(e=>e.attributes.some(e=>e.name===`pii`)).map(e=>e.name)),c=new Set(a.concepts.filter(e=>e.attributes.some(e=>e.name===`sensitive`)).map(e=>e.name)),l=i(a.types),u=new t(a),d=new Set(a.imports.map(e=>e.qualifiedName.split(`.`).at(-1))),f=/* @__PURE__ */ new Map;for(let e of a.declaredTriggers??[]){let t=f.get(e.name)??[];t.push(e.data),f.set(e.name,t)}let validate=(t,n,r=`an event source identifier`)=>{if(s.has(t.name)||c.has(t.name)){let i=s.has(t.name)?`pii`:`secret`;o.error(e.PiiNotSupportedOnIdentifier,`Concept '${t.name}' is ${i} and cannot be ${r} - use a surrogate Uuid identifier and keep the ${i} value as a property`,n)}},property=(e,t)=>{let[n,...r]=t.split(`.`),i=e.filter(e=>e.name===n);if(i.length!==1)return null;let a=i[0];return r.length===0?a:property(l.get(a.type.name)?.properties??[],r.join(`.`))};for(let e of a.eventSources??[]){e.identifier!=null&&validate(e.identifier,e.identifier.location);for(let t of e.streams){t.streamId!==null&&validate(t.streamId,t.streamId.location,`a stream id`);for(let e of t.streamIdParts)validate(e.type,e.type.location,`a stream id part '${e.name}'`)}}let p=new n(a);for(let{slice:e}of u.slices){for(let t of e.commands){for(let e of t.properties.filter(e=>e.isIdentifier))validate(e.type,e.location);for(let e of[...t.stream?[t.stream]:[],...t.streamCandidates??[],...t.produces.flatMap(e=>e.stream==null?[]:[e.stream])].filter(e=>e.propertyCandidate===null)){let n=p.resolve(e.eventSource,e.stream),r=n.kind===`unique`?n.streams[0]:void 0,i=[...e.streamId===null?[]:[{mapping:e.streamId,target:r?.streamId}],...e.streamIdParts.map(e=>({mapping:e,target:r?.streamIdParts.find(t=>t.name===e.property)?.type}))];for(let{mapping:e,target:n}of i){if(e.source.kind!==`PathExpressionSyntax`)continue;let r=property(t.properties,e.source.path);r!==null&&(r.type.name!==n?.name||!s.has(r.type.name)&&!c.has(r.type.name))&&validate(r.type,e.source.location,`a stream id route mapping`)}}for(let n of t.produces.filter(t=>u.isEventProduction(t,e))){if(n.for?.kind!==`PathExpressionSyntax`)continue;let e=property(t.properties,n.for.path);e!==null&&!e.isIdentifier&&validate(e.type,n.for.location)}}for(let t of e.reactions.flatMap(e=>e.triggers)){if(t.source.kind!==`NamedTriggerSourceSyntax`)continue;let n=u.resolve(t.source.name,e).declaration?.node,i=(r(t).data??[]).flatMap(e=>e.type===null?[]:[{kind:`PropertySyntax`,name:e.name,type:e.type,isIdentifier:!1,location:e.location}]),a=[n?.kind===`EventSyntax`?n.properties:[],i];n?.kind!==`EventSyntax`&&!d.has(t.source.name)&&a.push(...f.get(t.source.name)??[]);for(let n of t.produces.filter(t=>u.isEventProduction(t,e))){if(n.for?.kind!==`PathExpressionSyntax`)continue;let e=n.for.path,t=a.map(t=>property(t,e)).find(e=>e!==null&&(s.has(e.type.name)||c.has(e.type.name)));t!=null&&validate(t.type,n.for.location)}}}}export{validateIdentifierCompliance};
|
|
2
2
|
//# sourceMappingURL=IdentifierComplianceValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifierComplianceValidator.js","names":["personal","application","concept","attribute","sensitive","types","uniqueByName","resolver","AuthoringProductionResolver","imports","imported","declaredTriggers","declared","shapes","type","context","DiagnosticCodes","position","location","name","rest","path","matches","properties","entry","value","source","stream","part","catalog","EventSourceCatalog","command","slice","route","produced","resolution","mappings","mapping","target","production","trigger","reaction","event","clauseData","dependencySourcesOf","datum"],"sources":["../../../../../../Compiler/Parsing/IdentifierComplianceValidator.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 { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { dependencySourcesOf } from '../Syntax/DependencySources';\nimport { ParserContext } from './ParserContext';\nimport { uniqueByName } from './ResponseValidator';\n\nexport function validateIdentifierCompliance(application: ApplicationSyntax, context: ParserContext): void {\n const personal = new Set(application.concepts.filter(concept => concept.attributes.some(attribute => attribute.name === 'pii')).map(concept => concept.name));\n const sensitive = new Set(application.concepts.filter(concept => concept.attributes.some(attribute => attribute.name === 'sensitive')).map(concept => concept.name));\n const types = uniqueByName(application.types);\n const resolver = new AuthoringProductionResolver(application);\n const imports = new Set(application.imports.map(imported => imported.qualifiedName.split('.').at(-1)!));\n const declaredTriggers = new Map<string, (readonly PropertySyntax[])[]>();\n for (const declared of application.declaredTriggers ?? []) {\n const shapes = declaredTriggers.get(declared.name) ?? [];\n shapes.push(declared.data);\n declaredTriggers.set(declared.name, shapes);\n }\n const validate = (type: TypeRefSyntax, location: SourceLocation, position = 'an event source identifier'): void => {\n if (personal.has(type.name) || sensitive.has(type.name)) {\n const attribute = personal.has(type.name) ? 'pii' : 'secret';\n context.error(DiagnosticCodes.PiiNotSupportedOnIdentifier, `Concept '${type.name}' is ${attribute} and cannot be ${position} - use a surrogate Uuid identifier and keep the ${attribute} value as a property`, location);\n }\n };\n const property = (properties: readonly PropertySyntax[], path: string): PropertySyntax | null => {\n const [name, ...rest] = path.split('.');\n const matches = properties.filter(entry => entry.name === name);\n if (matches.length !== 1) return null;\n const value = matches[0];\n if (rest.length === 0) return value;\n return property(types.get(value.type.name)?.properties ?? [], rest.join('.'));\n };\n for (const source of application.eventSources ?? []) {\n if (source.identifier != null) validate(source.identifier, source.identifier.location);\n for (const stream of source.streams) {\n if (stream.streamId !== null) validate(stream.streamId, stream.streamId.location, 'a stream id');\n for (const part of stream.streamIdParts) validate(part.type, part.type.location, `a stream id part '${part.name}'`);\n }\n }\n const catalog = new EventSourceCatalog(application);\n for (const { slice } of resolver.slices) {\n for (const command of slice.commands) {\n for (const entry of command.properties.filter(entry => entry.isIdentifier)) validate(entry.type, entry.location);\n for (const route of [...(command.stream ? [command.stream] : []), ...command.streamCandidates ?? [], ...command.produces.flatMap(produced => produced.stream == null ? [] : [produced.stream])].filter(route => route.propertyCandidate === null)) {\n const resolution = catalog.resolve(route.eventSource, route.stream);\n const stream = resolution.kind === EventSourceResolutionKind.Unique ? resolution.streams[0] : undefined;\n const mappings = [\n ...(route.streamId === null ? [] : [{ mapping: route.streamId, target: stream?.streamId }]),\n ...route.streamIdParts.map(mapping => ({ mapping, target: stream?.streamIdParts.find(part => part.name === mapping.property)?.type })),\n ];\n for (const { mapping, target } of mappings) {\n if (mapping.source.kind !== 'PathExpressionSyntax') continue;\n const entry = property(command.properties, mapping.source.path);\n if (entry === null) continue;\n // The same protected concept has already been reported at its resolved declaration.\n if (entry.type.name === target?.name && (personal.has(entry.type.name) || sensitive.has(entry.type.name))) continue;\n validate(entry.type, mapping.source.location, 'a stream id route mapping');\n }\n }\n for (const production of command.produces.filter(production => resolver.isEventProduction(production, slice))) {\n if (production.for?.kind !== 'PathExpressionSyntax') continue;\n const entry = property(command.properties, production.for.path);\n if (entry !== null && !entry.isIdentifier) validate(entry.type, production.for.location);\n }\n }\n for (const trigger of slice.reactions.flatMap(reaction => reaction.triggers)) {\n if (trigger.source.kind !== 'NamedTriggerSourceSyntax') continue;\n const resolution = resolver.resolve(trigger.source.name, slice);\n const event = resolution.declaration?.node;\n const clauseData = (dependencySourcesOf(trigger).data ?? []).flatMap<PropertySyntax>(datum => datum.type === null ? [] : [{ kind: 'PropertySyntax', name: datum.name, type: datum.type, isIdentifier: false, location: datum.location }]);\n const shapes = [event?.kind === 'EventSyntax' ? event.properties : [], clauseData];\n if (event?.kind !== 'EventSyntax' && !imports.has(trigger.source.name)) {\n shapes.push(...declaredTriggers.get(trigger.source.name) ?? []);\n }\n for (const production of trigger.produces.filter(production => resolver.isEventProduction(production, slice))) {\n if (production.for?.kind !== 'PathExpressionSyntax') continue;\n // Check clause-local types alongside the occurrence selected by event-first reaction resolution.\n const path = production.for.path;\n const entry = shapes.map(properties => property(properties, path)).find(entry => entry !== null && (personal.has(entry.type.name) || sensitive.has(entry.type.name)));\n if (entry != null) validate(entry.type, production.for.location);\n }\n }\n }\n}\n"],"mappings":"gZAcA,SAAgB,6BAA6B,EAAgC,EAA8B,CACvG,IAAMA,EAAW,IAAI,IAAIC,EAAY,SAAS,OAAO,GAAWC,EAAQ,WAAW,KAAK,GAAaC,EAAU,OAAS,KAAK,CAAC,CAAC,CAAC,IAAI,GAAWD,EAAQ,IAAI,CAAC,EACtJE,EAAY,IAAI,IAAIH,EAAY,SAAS,OAAO,GAAWC,EAAQ,WAAW,KAAK,GAAaC,EAAU,OAAS,WAAW,CAAC,CAAC,CAAC,IAAI,GAAWD,EAAQ,IAAI,CAAC,EAC7JG,EAAQC,EAAaL,EAAY,KAAK,EACtCM,EAAW,IAAIC,EAA4BP,CAAW,EACtDQ,EAAU,IAAI,IAAIR,EAAY,QAAQ,IAAI,GAAYS,EAAS,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAC,EAChGC,kBAAmB,IAAI,IAC7B,IAAK,IAAMC,KAAYX,EAAY,kBAAoB,CAAC,EAAG,CACvD,IAAMY,EAASF,EAAiB,IAAIC,EAAS,IAAI,GAAK,CAAC,EACvDC,EAAO,KAA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IAAU,MAAQ,CAACA,EAAM,cAAc,SAASA,EAAM,KAAMe,EAAW,IAAI,QAAQ,CAC3F,CACJ,CACA,IAAK,IAAMC,KAAWR,EAAM,UAAU,QAAQ,GAAYS,EAAS,QAAQ,EAAG,CAC1E,GAAID,EAAQ,OAAO,OAAS,2BAA4B,SAExD,IAAME,EADanC,EAAS,QAAQiC,EAAQ,OAAO,KAAMR,CAClC,CAAC,CAAC,aAAa,KAChCW,GAAcC,EAAoBJ,CAAO,CAAC,CAAC,MAAQ,CAAC,EAAA,CAAG,QAAwB,GAASK,EAAM,OAAS,KAAO,CAAC,EAAI,CAAC,CAAE,KAAM,iBAAkB,KAAMA,EAAM,KAAM,KAAMA,EAAM,KAAM,aAAc,GAAO,SAAUA,EAAM,QAAS,CAAC,CAAC,EAClOhC,EAAS,CAAC6B,GAAO,OAAS,cAAgBA,EAAM,WAAa,CAAC,EAAGC,CAAU,EAC7ED,GAAO,OAAS,eAAiB,CAACjC,EAAQ,IAAI+B,EAAQ,OAAO,IAAI,GACjE3B,EAAO,KAAK,GAAGF,EAAiB,IAAI6B,EAAQ,OAAO,IAAI,GAAK,CAAC,CAAC,EAElE,IAAK,IAAMD,KAAcC,EAAQ,SAAS,OAAO,GAAcjC,EAAS,kBAAkBgC,EAAYP,CAAK,CAAC,EAAG,CAC3G,GAAIO,EAAW,KAAK,OAAS,uBAAwB,SAErD,IAAMlB,EAAOkB,EAAW,IAAI,KACtBf,EAAQX,EAAO,IAAI,GAAc,SAASU,EAAYF,CAAI,CAAC,CAAC,CAAC,KAAK,GAASG,IAAU,OAASxB,EAAS,IAAIwB,EAAM,KAAK,IAAI,GAAKpB,EAAU,IAAIoB,EAAM,KAAK,IAAI,EAAE,EAChKA,GAAS,MAAM,SAASA,EAAM,KAAMe,EAAW,IAAI,QAAQ,CACnE,CACJ,CACJ,CACJ"}
|
|
1
|
+
{"version":3,"file":"IdentifierComplianceValidator.js","names":["personal","application","concept","attribute","sensitive","types","uniqueByName","resolver","AuthoringProductionResolver","imports","imported","declaredTriggers","declared","shapes","type","context","DiagnosticCodes","position","location","name","rest","path","matches","properties","entry","value","source","stream","part","catalog","EventSourceCatalog","command","slice","route","produced","resolution","mappings","mapping","target","production","trigger","reaction","event","clauseData","dependencySourcesOf","datum"],"sources":["../../../../../../Compiler/Parsing/IdentifierComplianceValidator.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 { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { PropertySyntax, TypeRefSyntax } from '../Syntax/Declarations';\nimport { EventSourceCatalog } from '../Syntax/EventSourceCatalog';\nimport { EventSourceResolutionKind } from '../Syntax/EventSources';\nimport { ApplicationSyntax } from '../Syntax/Structure';\nimport { dependencySourcesOf } from '../Syntax/DependencySources';\nimport { ParserContext } from './ParserContext';\nimport { uniqueByName } from './ResponseValidator';\n\nexport function validateIdentifierCompliance(application: ApplicationSyntax, context: ParserContext): void {\n const personal = new Set(application.concepts.filter(concept => concept.attributes.some(attribute => attribute.name === 'pii')).map(concept => concept.name));\n const sensitive = new Set(application.concepts.filter(concept => concept.attributes.some(attribute => attribute.name === 'sensitive')).map(concept => concept.name));\n const types = uniqueByName(application.types);\n const resolver = new AuthoringProductionResolver(application);\n const imports = new Set(application.imports.map(imported => imported.qualifiedName.split('.').at(-1)!));\n const declaredTriggers = new Map<string, (readonly PropertySyntax[])[]>();\n for (const declared of application.declaredTriggers ?? []) {\n const shapes = declaredTriggers.get(declared.name) ?? [];\n shapes.push(declared.data);\n declaredTriggers.set(declared.name, shapes);\n }\n const validate = (type: TypeRefSyntax, location: SourceLocation, position = 'an event source identifier'): void => {\n if (personal.has(type.name) || sensitive.has(type.name)) {\n const attribute = personal.has(type.name) ? 'pii' : 'secret';\n context.error(DiagnosticCodes.PiiNotSupportedOnIdentifier, `Concept '${type.name}' is ${attribute} and cannot be ${position} - use a surrogate Uuid identifier and keep the ${attribute} value as a property`, location);\n }\n };\n const property = (properties: readonly PropertySyntax[], path: string): PropertySyntax | null => {\n const [name, ...rest] = path.split('.');\n const matches = properties.filter(entry => entry.name === name);\n if (matches.length !== 1) return null;\n const value = matches[0];\n if (rest.length === 0) return value;\n return property(types.get(value.type.name)?.properties ?? [], rest.join('.'));\n };\n for (const source of application.eventSources ?? []) {\n if (source.identifier != null) validate(source.identifier, source.identifier.location);\n for (const stream of source.streams) {\n if (stream.streamId !== null) validate(stream.streamId, stream.streamId.location, 'a stream id');\n for (const part of stream.streamIdParts) validate(part.type, part.type.location, `a stream id part '${part.name}'`);\n }\n }\n const catalog = new EventSourceCatalog(application);\n for (const { slice } of resolver.slices) {\n for (const command of slice.commands) {\n for (const entry of command.properties.filter(entry => entry.isIdentifier)) validate(entry.type, entry.location);\n for (const route of [...(command.stream ? [command.stream] : []), ...command.streamCandidates ?? [], ...command.produces.flatMap(produced => produced.stream == null ? [] : [produced.stream])].filter(route => route.propertyCandidate === null)) {\n const resolution = catalog.resolve(route.eventSource, route.stream);\n const stream = resolution.kind === EventSourceResolutionKind.Unique ? resolution.streams[0] : undefined;\n const mappings = [\n ...(route.streamId === null ? [] : [{ mapping: route.streamId, target: stream?.streamId }]),\n ...route.streamIdParts.map(mapping => ({ mapping, target: stream?.streamIdParts.find(part => part.name === mapping.property)?.type })),\n ];\n for (const { mapping, target } of mappings) {\n if (mapping.source.kind !== 'PathExpressionSyntax') continue;\n const entry = property(command.properties, mapping.source.path);\n if (entry === null) continue;\n // The same protected concept has already been reported at its resolved declaration.\n if (entry.type.name === target?.name && (personal.has(entry.type.name) || sensitive.has(entry.type.name))) continue;\n validate(entry.type, mapping.source.location, 'a stream id route mapping');\n }\n }\n for (const production of command.produces.filter(production => resolver.isEventProduction(production, slice))) {\n if (production.for?.kind !== 'PathExpressionSyntax') continue;\n const entry = property(command.properties, production.for.path);\n if (entry !== null && !entry.isIdentifier) validate(entry.type, production.for.location);\n }\n }\n for (const trigger of slice.reactions.flatMap(reaction => reaction.triggers)) {\n if (trigger.source.kind !== 'NamedTriggerSourceSyntax') continue;\n const resolution = resolver.resolve(trigger.source.name, slice);\n const event = resolution.declaration?.node;\n const clauseData = (dependencySourcesOf(trigger).data ?? []).flatMap<PropertySyntax>(datum => datum.type === null ? [] : [{ kind: 'PropertySyntax', name: datum.name, type: datum.type, isIdentifier: false, location: datum.location }]);\n const shapes = [event?.kind === 'EventSyntax' ? event.properties : [], clauseData];\n if (event?.kind !== 'EventSyntax' && !imports.has(trigger.source.name)) {\n shapes.push(...declaredTriggers.get(trigger.source.name) ?? []);\n }\n for (const production of trigger.produces.filter(production => resolver.isEventProduction(production, slice))) {\n if (production.for?.kind !== 'PathExpressionSyntax') continue;\n // Check clause-local types alongside the occurrence selected by event-first reaction resolution.\n const path = production.for.path;\n const entry = shapes.map(properties => property(properties, path)).find(entry => entry !== null && (personal.has(entry.type.name) || sensitive.has(entry.type.name)));\n if (entry != null) validate(entry.type, production.for.location);\n }\n }\n }\n}\n"],"mappings":"A,gZAcA,SAAgB,6BAA6B,EAAgC,EAA8B,CACvG,IAAMA,EAAW,IAAI,IAAIC,EAAY,SAAS,OAAO,GAAWC,EAAQ,WAAW,KAAK,GAAaC,EAAU,OAAS,KAAK,CAAC,CAAC,CAAC,IAAI,GAAWD,EAAQ,IAAI,CAAC,EACtJE,EAAY,IAAI,IAAIH,EAAY,SAAS,OAAO,GAAWC,EAAQ,WAAW,KAAK,GAAaC,EAAU,OAAS,WAAW,CAAC,CAAC,CAAC,IAAI,GAAWD,EAAQ,IAAI,CAAC,EAC7JG,EAAQC,EAAaL,EAAY,KAAK,EACtCM,EAAW,IAAIC,EAA4BP,CAAW,EACtDQ,EAAU,IAAI,IAAIR,EAAY,QAAQ,IAAI,GAAYS,EAAS,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAC,EAChGC,kBAAmB,I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e,EAAW,IAAI,QAAQ,CACnE,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{pattern as t}from"../Text/patterns.js";import{stringBodyPattern as n,unescapeString as r}from"../Text/StringLiteral.js";import{parseDescription as i}from"./DescriptionParser.js";import{parseMappingSource as a}from"./ExpressionParser.js";import{isCode as o,isFile as s,parseCode as c,parseFile as l}from"./ImplementationParser.js";import{firstWord as u,unescapeIdentifier as d}from"./LineText.js";import{parseTypeRef as f,reportLegacyOptionalSuffix as p}from"./PropertyLineParser.js";import{locationOf as m}from"./SourceLine.js";const h=t(`^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$`),g=t(`^claim\\s+"(${n})"$`),_=t(`^query\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(?:\\s+by\\s+(.+))?$`);function parseIdentity(t,n,r){if(n.content!==`identity`)return t.error(e.InvalidIdentityDeclaration,`Invalid identity declaration '${n.content}' - expected 'identity'`,m(n)),t.skipBlock(n.indent),r;if(r!==null)return t.error(e.DuplicateIdentity,`The document already declares an identity block - a document can have at most one`,m(n)),t.skipBlock(n.indent),r;let a=[],o=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){if(t.reader.takeSignificant(),u(r.content)===`description`){o=i(t,r,o,`Identity`);continue}let n=h.exec(r.content);if(n===null){t.error(e.InvalidIdentityDetail,`Invalid identity detail '${r.content}' - expected '<name> <Type> [from claim "<name>" | from query <Query> by <expression>]'`,m(r)),t.skipBlock(r.indent);continue}let s=f(n[2],{...m(r),column:r.indent+1+r.content.indexOf(n[2],n[1].length)});p(t,s,r);let c=n[3]===void 0?parseEscape(t,r):parseSource(t,r,n[3]);c!==null&&a.push({kind:`IdentityDetailSyntax`,name:d(n[1]),type:s,source:c,location:m(r)}),rejectBody(t,r,n[3]===void 0?e.InvalidIdentityDetail:e.IdentitySourceWithBody)}return{kind:`IdentitySyntax`,details:a,description:o,location:m(n)}}function parseSource(t,n,i){let o=g.exec(i);if(o!==null)return{kind:`ClaimIdentitySourceSyntax`,claim:r(o[1]),location:m(n)};let s=_.exec(i);if(s!==null)return s[2]===void 0?(t.error(e.IdentityQueryWithoutKey,`An identity query source requires 'by <expression>'`,m(n)),null):{kind:`QueryIdentitySourceSyntax`,query:s[1],by:a(s[2],m(n),t),location:m(n)};let c=u(i);return t.error(c===`claim`||c===`query`?e.InvalidIdentityDetail:e.UnknownIdentitySource,`Invalid identity source '${i}' - expected 'claim "<name>"' or 'query <Query> by <expression>'`,m(n)),null}function parseEscape(t,n){let r=t.peekChild(n.indent);if(r===void 0)return t.error(e.IdentityDetailWithoutSource,`An identity detail requires a claim, query, inline code block or file source`,m(n)),null;if(t.reader.takeSignificant(),s(r)){let n=l(t,r);return rejectBody(t,r,e.InvalidIdentityDetail),{kind:`FileIdentitySourceSyntax`,file:n,location:m(r)}}if(o(t,r)){let e=c(t,r);return e===null?null:{kind:`CodeIdentitySourceSyntax`,code:e,location:m(r)}}return t.error(e.InvalidIdentityDetail,`Unexpected '${r.content}' under an identity detail - expected a file reference or inline code block`,m(r)),t.skipBlock(r.indent),null}function rejectBody(e,t,n){for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),e.error(n,`Unexpected '${r.content}' under an identity source - refresh and caching are the runtime's business; a detail has exactly one source`,m(r)),e.skipBlock(r.indent)}export{parseIdentity};
|
|
2
2
|
//# sourceMappingURL=IdentityParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityParser.js","names":["detailPattern","pattern","claimPattern","stringBodyPattern","queryPattern","header","context","DiagnosticCodes","locationOf","existing","details","description","line","firstWord","parseDescription","match","type","parseTypeRef","reportLegacyOptionalSuffix","source","unescapeIdentifier","claim","text","unescapeString","query","parseMappingSource","kind","body","detail","isFile","file","parseFile","isCode","code","parseCode","child","parent"],"sources":["../../../../../../Compiler/Parsing/IdentityParser.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 { IdentitySyntax } from '../Syntax/IdentitySyntax';\nimport { IdentityDetailSyntax } from '../Syntax/IdentityDetailSyntax';\nimport { IdentitySourceSyntax } from '../Syntax/IdentitySourceSyntax';\nimport { pattern } from '../Text/patterns';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { isCode, isFile, parseCode, parseFile } from './ImplementationParser';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseTypeRef, reportLegacyOptionalSuffix } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst detailPattern = pattern('^(@?[a-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)(?:\\\\s+from\\\\s+(.+))?$');\nconst claimPattern = pattern(`^claim\\\\s+\"(${stringBodyPattern})\"$`);\nconst queryPattern = pattern('^query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)(?:\\\\s+by\\\\s+(.+))?$');\n\nexport function parseIdentity(context: ParserContext, header: SourceLine, existing: IdentitySyntax | null): IdentitySyntax | null {\n if (header.content !== 'identity') {\n context.error(DiagnosticCodes.InvalidIdentityDeclaration, `Invalid identity declaration '${header.content}' - expected 'identity'`, locationOf(header));\n context.skipBlock(header.indent);\n return existing;\n }\n if (existing !== null) {\n context.error(DiagnosticCodes.DuplicateIdentity, 'The document already declares an identity block - a document can have at most one', locationOf(header));\n context.skipBlock(header.indent);\n return existing;\n }\n const details: IdentityDetailSyntax[] = [];\n let description: string | null = null;\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (firstWord(line.content) === 'description') {\n description = parseDescription(context, line, description, 'Identity');\n continue;\n }\n const match = detailPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidIdentityDetail, `Invalid identity detail '${line.content}' - expected '<name> <Type> [from claim \"<name>\" | from query <Query> by <expression>]'`, locationOf(line));\n context.skipBlock(line.indent);\n continue;\n }\n const type = parseTypeRef(match[2], { ...locationOf(line), column: line.indent + 1 + line.content.indexOf(match[2], match[1].length) });\n reportLegacyOptionalSuffix(context, type, line);\n const source = match[3] !== undefined ? parseSource(context, line, match[3]) : parseEscape(context, line);\n if (source !== null) details.push({ kind: 'IdentityDetailSyntax', name: unescapeIdentifier(match[1]), type, source, location: locationOf(line) });\n rejectBody(context, line, match[3] !== undefined ? DiagnosticCodes.IdentitySourceWithBody : DiagnosticCodes.InvalidIdentityDetail);\n }\n return { kind: 'IdentitySyntax', details, description, location: locationOf(header) };\n}\n\nfunction parseSource(context: ParserContext, line: SourceLine, text: string): IdentitySourceSyntax | null {\n const claim = claimPattern.exec(text);\n if (claim !== null) return { kind: 'ClaimIdentitySourceSyntax', claim: unescapeString(claim[1]), location: locationOf(line) };\n const query = queryPattern.exec(text);\n if (query !== null) {\n if (query[2] === undefined) {\n context.error(DiagnosticCodes.IdentityQueryWithoutKey, \"An identity query source requires 'by <expression>'\", locationOf(line));\n return null;\n }\n return { kind: 'QueryIdentitySourceSyntax', query: query[1], by: parseMappingSource(query[2], locationOf(line), context), location: locationOf(line) };\n }\n const kind = firstWord(text);\n context.error(kind === 'claim' || kind === 'query' ? DiagnosticCodes.InvalidIdentityDetail : DiagnosticCodes.UnknownIdentitySource,\n `Invalid identity source '${text}' - expected 'claim \"<name>\"' or 'query <Query> by <expression>'`, locationOf(line));\n return null;\n}\n\nfunction parseEscape(context: ParserContext, detail: SourceLine): IdentitySourceSyntax | null {\n const body = context.peekChild(detail.indent);\n if (body === undefined) {\n context.error(DiagnosticCodes.IdentityDetailWithoutSource, 'An identity detail requires a claim, query, inline code block or file source', locationOf(detail));\n return null;\n }\n context.reader.takeSignificant();\n if (isFile(body)) {\n const file = parseFile(context, body);\n rejectBody(context, body, DiagnosticCodes.InvalidIdentityDetail);\n return { kind: 'FileIdentitySourceSyntax', file, location: locationOf(body) };\n }\n if (isCode(context, body)) {\n const code = parseCode(context, body);\n return code === null ? null : { kind: 'CodeIdentitySourceSyntax', code, location: locationOf(body) };\n }\n context.error(DiagnosticCodes.InvalidIdentityDetail, `Unexpected '${body.content}' under an identity detail - expected a file reference or inline code block`, locationOf(body));\n context.skipBlock(body.indent);\n return null;\n}\n\nfunction rejectBody(context: ParserContext, parent: SourceLine, code: string): void {\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n context.error(code, `Unexpected '${child.content}' under an identity source - refresh and caching are the runtime's business; a detail has exactly one source`, locationOf(child));\n context.skipBlock(child.indent);\n }\n}\n"],"mappings":"gpBAiBA,MAAMA,EAAgBC,EAAQ,oFAAoF,EAC5GC,EAAeD,EAAQ,eAAeE,EAAkB,IAAI,EAC5DC,EAAeH,EAAQ,oEAAoE,EAEjG,SAAgB,cAAc,EAAwB,EAAoB,EAAwD,CAC9H,GAAII,EAAO,UAAY,WAGnB,OAFAC,EAAQ,MAAMC,EAAgB,2BAA4B,iCAAiCF,EAAO,QAAQ,yBAA0BG,EAAWH,CAAM,CAAC,EACtJC,EAAQ,UAAUD,EAAO,MAAM,EACxBI,EAEX,GAAIA,IAAa,KAGb,OAFAH,EAAQ,MAAMC,EAAgB,kBAAmB,oFAAqFC,EAAWH,CAAM,CAAC,EACxJC,EAAQ,UAAUD,EAAO,MAAM,EACxBI,EAEX,IAAMC,EAAkC,C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AUqB,EAAK,MAAM,EACtB,IACX,CAEA,SAAS,WAAW,EAAwB,EAAoB,EAAoB,CAChF,IAAK,IAAIQ,EAAQ7B,EAAQ,UAAU8B,EAAO,MAAM,EAAGD,IAAU,IAAA,GAAW,EAAQ7B,EAAQ,UAAU8B,EAAO,MAAM,EAC3G9B,EAAQ,OAAO,gBAAgB,EAC/BA,EAAQ,MAAM2B,EAAM,eAAeE,EAAM,QAAQ,8GAA+G3B,EAAW2B,CAAK,CAAC,EACjL7B,EAAQ,UAAU6B,EAAM,MAAM,CAEtC"}
|
|
1
|
+
{"version":3,"file":"IdentityParser.js","names":["detailPattern","pattern","claimPattern","stringBodyPattern","queryPattern","header","context","DiagnosticCodes","locationOf","existing","details","description","line","firstWord","parseDescription","match","type","parseTypeRef","reportLegacyOptionalSuffix","source","unescapeIdentifier","claim","text","unescapeString","query","parseMappingSource","kind","body","detail","isFile","file","parseFile","isCode","code","parseCode","child","parent"],"sources":["../../../../../../Compiler/Parsing/IdentityParser.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 { IdentitySyntax } from '../Syntax/IdentitySyntax';\nimport { IdentityDetailSyntax } from '../Syntax/IdentityDetailSyntax';\nimport { IdentitySourceSyntax } from '../Syntax/IdentitySourceSyntax';\nimport { pattern } from '../Text/patterns';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { parseDescription } from './DescriptionParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { isCode, isFile, parseCode, parseFile } from './ImplementationParser';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parseTypeRef, reportLegacyOptionalSuffix } from './PropertyLineParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst detailPattern = pattern('^(@?[a-z_]\\\\w*)\\\\s+([\\\\w.]+(?:\\\\[\\\\])?(?:\\\\?|\\\\s+optional)?)(?:\\\\s+from\\\\s+(.+))?$');\nconst claimPattern = pattern(`^claim\\\\s+\"(${stringBodyPattern})\"$`);\nconst queryPattern = pattern('^query\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)(?:\\\\s+by\\\\s+(.+))?$');\n\nexport function parseIdentity(context: ParserContext, header: SourceLine, existing: IdentitySyntax | null): IdentitySyntax | null {\n if (header.content !== 'identity') {\n context.error(DiagnosticCodes.InvalidIdentityDeclaration, `Invalid identity declaration '${header.content}' - expected 'identity'`, locationOf(header));\n context.skipBlock(header.indent);\n return existing;\n }\n if (existing !== null) {\n context.error(DiagnosticCodes.DuplicateIdentity, 'The document already declares an identity block - a document can have at most one', locationOf(header));\n context.skipBlock(header.indent);\n return existing;\n }\n const details: IdentityDetailSyntax[] = [];\n let description: string | null = null;\n for (let line = context.peekChild(header.indent); line !== undefined; line = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n if (firstWord(line.content) === 'description') {\n description = parseDescription(context, line, description, 'Identity');\n continue;\n }\n const match = detailPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidIdentityDetail, `Invalid identity detail '${line.content}' - expected '<name> <Type> [from claim \"<name>\" | from query <Query> by <expression>]'`, locationOf(line));\n context.skipBlock(line.indent);\n continue;\n }\n const type = parseTypeRef(match[2], { ...locationOf(line), column: line.indent + 1 + line.content.indexOf(match[2], match[1].length) });\n reportLegacyOptionalSuffix(context, type, line);\n const source = match[3] !== undefined ? parseSource(context, line, match[3]) : parseEscape(context, line);\n if (source !== null) details.push({ kind: 'IdentityDetailSyntax', name: unescapeIdentifier(match[1]), type, source, location: locationOf(line) });\n rejectBody(context, line, match[3] !== undefined ? DiagnosticCodes.IdentitySourceWithBody : DiagnosticCodes.InvalidIdentityDetail);\n }\n return { kind: 'IdentitySyntax', details, description, location: locationOf(header) };\n}\n\nfunction parseSource(context: ParserContext, line: SourceLine, text: string): IdentitySourceSyntax | null {\n const claim = claimPattern.exec(text);\n if (claim !== null) return { kind: 'ClaimIdentitySourceSyntax', claim: unescapeString(claim[1]), location: locationOf(line) };\n const query = queryPattern.exec(text);\n if (query !== null) {\n if (query[2] === undefined) {\n context.error(DiagnosticCodes.IdentityQueryWithoutKey, \"An identity query source requires 'by <expression>'\", locationOf(line));\n return null;\n }\n return { kind: 'QueryIdentitySourceSyntax', query: query[1], by: parseMappingSource(query[2], locationOf(line), context), location: locationOf(line) };\n }\n const kind = firstWord(text);\n context.error(kind === 'claim' || kind === 'query' ? DiagnosticCodes.InvalidIdentityDetail : DiagnosticCodes.UnknownIdentitySource,\n `Invalid identity source '${text}' - expected 'claim \"<name>\"' or 'query <Query> by <expression>'`, locationOf(line));\n return null;\n}\n\nfunction parseEscape(context: ParserContext, detail: SourceLine): IdentitySourceSyntax | null {\n const body = context.peekChild(detail.indent);\n if (body === undefined) {\n context.error(DiagnosticCodes.IdentityDetailWithoutSource, 'An identity detail requires a claim, query, inline code block or file source', locationOf(detail));\n return null;\n }\n context.reader.takeSignificant();\n if (isFile(body)) {\n const file = parseFile(context, body);\n rejectBody(context, body, DiagnosticCodes.InvalidIdentityDetail);\n return { kind: 'FileIdentitySourceSyntax', file, location: locationOf(body) };\n }\n if (isCode(context, body)) {\n const code = parseCode(context, body);\n return code === null ? null : { kind: 'CodeIdentitySourceSyntax', code, location: locationOf(body) };\n }\n context.error(DiagnosticCodes.InvalidIdentityDetail, `Unexpected '${body.content}' under an identity detail - expected a file reference or inline code block`, locationOf(body));\n context.skipBlock(body.indent);\n return null;\n}\n\nfunction rejectBody(context: ParserContext, parent: SourceLine, code: string): void {\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n context.error(code, `Unexpected '${child.content}' under an identity source - refresh and caching are the runtime's business; a detail has exactly one source`, locationOf(child));\n context.skipBlock(child.indent);\n }\n}\n"],"mappings":"A,gpBAiBA,MAAMA,EAAgBC,EAAQ,oFAAoF,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