@cratis/chronicle 6.63.0 → 6.64.0
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/artifacts/DefaultClientArtifactsProvider.ts +5 -0
- package/artifacts/IClientArtifactsProvider.ts +3 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts +2 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.js +4 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -1
- package/dist/artifacts/IClientArtifactsProvider.d.ts +2 -0
- package/dist/artifacts/IClientArtifactsProvider.d.ts.map +1 -1
- package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts +2 -1
- package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts.map +1 -1
- package/dist/projections/for_Graphs/given/a_discovered_graph.js +3 -2
- package/dist/projections/for_Graphs/given/a_discovered_graph.js.map +1 -1
- package/dist/projections/for_Graphs/given/a_graph_with_views.d.ts +40 -0
- package/dist/projections/for_Graphs/given/a_graph_with_views.d.ts.map +1 -0
- package/dist/projections/for_Graphs/given/a_graph_with_views.js +80 -0
- package/dist/projections/for_Graphs/given/a_graph_with_views.js.map +1 -0
- package/dist/projections/for_Graphs/given/organization.d.ts +2 -1
- package/dist/projections/for_Graphs/given/organization.d.ts.map +1 -1
- package/dist/projections/for_Graphs/given/organization.js +3 -2
- package/dist/projections/for_Graphs/given/organization.js.map +1 -1
- package/dist/projections/graphs/Graphs.d.ts +5 -0
- package/dist/projections/graphs/Graphs.d.ts.map +1 -1
- package/dist/projections/graphs/Graphs.js +43 -0
- package/dist/projections/graphs/Graphs.js.map +1 -1
- package/dist/projections/graphs/IGraphs.d.ts +9 -2
- package/dist/projections/graphs/IGraphs.d.ts.map +1 -1
- package/dist/projections/graphs/index.d.ts +1 -0
- package/dist/projections/graphs/index.d.ts.map +1 -1
- package/dist/projections/graphs/index.js +1 -0
- package/dist/projections/graphs/index.js.map +1 -1
- package/dist/projections/graphs/views/AmbiguousDirection.d.ts +16 -0
- package/dist/projections/graphs/views/AmbiguousDirection.d.ts.map +1 -0
- package/dist/projections/graphs/views/AmbiguousDirection.js +21 -0
- package/dist/projections/graphs/views/AmbiguousDirection.js.map +1 -0
- package/dist/projections/graphs/views/DuplicateViewName.d.ts +16 -0
- package/dist/projections/graphs/views/DuplicateViewName.d.ts.map +1 -0
- package/dist/projections/graphs/views/DuplicateViewName.js +21 -0
- package/dist/projections/graphs/views/DuplicateViewName.js.map +1 -0
- package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.d.ts +17 -0
- package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.d.ts.map +1 -0
- package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.js +22 -0
- package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.js.map +1 -0
- package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.d.ts +14 -0
- package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.d.ts.map +1 -0
- package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.js +19 -0
- package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.js.map +1 -0
- package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.d.ts +15 -0
- package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.d.ts.map +1 -0
- package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.js +20 -0
- package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.js.map +1 -0
- package/dist/projections/graphs/views/FollowsOptions.d.ts +16 -0
- package/dist/projections/graphs/views/FollowsOptions.d.ts.map +1 -0
- package/dist/projections/graphs/views/FollowsOptions.js +4 -0
- package/dist/projections/graphs/views/FollowsOptions.js.map +1 -0
- package/dist/projections/graphs/views/GraphEdgeDirection.d.ts +10 -0
- package/dist/projections/graphs/views/GraphEdgeDirection.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphEdgeDirection.js +13 -0
- package/dist/projections/graphs/views/GraphEdgeDirection.js.map +1 -0
- package/dist/projections/graphs/views/GraphView.d.ts +13 -0
- package/dist/projections/graphs/views/GraphView.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphView.js +4 -0
- package/dist/projections/graphs/views/GraphView.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewBuildResult.d.ts +15 -0
- package/dist/projections/graphs/views/GraphViewBuildResult.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewBuildResult.js +4 -0
- package/dist/projections/graphs/views/GraphViewBuildResult.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewCardinality.d.ts +10 -0
- package/dist/projections/graphs/views/GraphViewCardinality.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewCardinality.js +13 -0
- package/dist/projections/graphs/views/GraphViewCardinality.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinition.d.ts +15 -0
- package/dist/projections/graphs/views/GraphViewDefinition.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinition.js +4 -0
- package/dist/projections/graphs/views/GraphViewDefinition.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinitionBuilder.d.ts +30 -0
- package/dist/projections/graphs/views/GraphViewDefinitionBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinitionBuilder.js +259 -0
- package/dist/projections/graphs/views/GraphViewDefinitionBuilder.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinitionSerializer.d.ts +21 -0
- package/dist/projections/graphs/views/GraphViewDefinitionSerializer.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinitionSerializer.js +77 -0
- package/dist/projections/graphs/views/GraphViewDefinitionSerializer.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewEdgeReference.d.ts +6 -0
- package/dist/projections/graphs/views/GraphViewEdgeReference.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewEdgeReference.js +4 -0
- package/dist/projections/graphs/views/GraphViewEdgeReference.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewMember.d.ts +8 -0
- package/dist/projections/graphs/views/GraphViewMember.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewMember.js +4 -0
- package/dist/projections/graphs/views/GraphViewMember.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewMemberKind.d.ts +12 -0
- package/dist/projections/graphs/views/GraphViewMemberKind.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewMemberKind.js +15 -0
- package/dist/projections/graphs/views/GraphViewMemberKind.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewMemberMetadata.d.ts +22 -0
- package/dist/projections/graphs/views/GraphViewMemberMetadata.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewMemberMetadata.js +4 -0
- package/dist/projections/graphs/views/GraphViewMemberMetadata.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewPropertyMember.d.ts +13 -0
- package/dist/projections/graphs/views/GraphViewPropertyMember.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewPropertyMember.js +4 -0
- package/dist/projections/graphs/views/GraphViewPropertyMember.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewReason.d.ts +33 -0
- package/dist/projections/graphs/views/GraphViewReason.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewReason.js +36 -0
- package/dist/projections/graphs/views/GraphViewReason.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewRelationMember.d.ts +21 -0
- package/dist/projections/graphs/views/GraphViewRelationMember.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewRelationMember.js +4 -0
- package/dist/projections/graphs/views/GraphViewRelationMember.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchema.d.ts +10 -0
- package/dist/projections/graphs/views/GraphViewSchema.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchema.js +4 -0
- package/dist/projections/graphs/views/GraphViewSchema.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchemaEdge.d.ts +14 -0
- package/dist/projections/graphs/views/GraphViewSchemaEdge.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchemaEdge.js +4 -0
- package/dist/projections/graphs/views/GraphViewSchemaEdge.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchemaNode.d.ts +10 -0
- package/dist/projections/graphs/views/GraphViewSchemaNode.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchemaNode.js +4 -0
- package/dist/projections/graphs/views/GraphViewSchemaNode.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewSerializerOptions.d.ts +9 -0
- package/dist/projections/graphs/views/GraphViewSerializerOptions.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewSerializerOptions.js +4 -0
- package/dist/projections/graphs/views/GraphViewSerializerOptions.js.map +1 -0
- package/dist/projections/graphs/views/RecursiveView.d.ts +15 -0
- package/dist/projections/graphs/views/RecursiveView.d.ts.map +1 -0
- package/dist/projections/graphs/views/RecursiveView.js +20 -0
- package/dist/projections/graphs/views/RecursiveView.js.map +1 -0
- package/dist/projections/graphs/views/RelationTargetNotAView.d.ts +16 -0
- package/dist/projections/graphs/views/RelationTargetNotAView.d.ts.map +1 -0
- package/dist/projections/graphs/views/RelationTargetNotAView.js +21 -0
- package/dist/projections/graphs/views/RelationTargetNotAView.js.map +1 -0
- package/dist/projections/graphs/views/TargetLabelMismatch.d.ts +18 -0
- package/dist/projections/graphs/views/TargetLabelMismatch.d.ts.map +1 -0
- package/dist/projections/graphs/views/TargetLabelMismatch.js +23 -0
- package/dist/projections/graphs/views/TargetLabelMismatch.js.map +1 -0
- package/dist/projections/graphs/views/UnknownEdge.d.ts +16 -0
- package/dist/projections/graphs/views/UnknownEdge.d.ts.map +1 -0
- package/dist/projections/graphs/views/UnknownEdge.js +21 -0
- package/dist/projections/graphs/views/UnknownEdge.js.map +1 -0
- package/dist/projections/graphs/views/UnknownEdgeProperty.d.ts +17 -0
- package/dist/projections/graphs/views/UnknownEdgeProperty.d.ts.map +1 -0
- package/dist/projections/graphs/views/UnknownEdgeProperty.js +22 -0
- package/dist/projections/graphs/views/UnknownEdgeProperty.js.map +1 -0
- package/dist/projections/graphs/views/UnknownNodeProperty.d.ts +17 -0
- package/dist/projections/graphs/views/UnknownNodeProperty.d.ts.map +1 -0
- package/dist/projections/graphs/views/UnknownNodeProperty.js +22 -0
- package/dist/projections/graphs/views/UnknownNodeProperty.js.map +1 -0
- package/dist/projections/graphs/views/ViewIsAlsoSchema.d.ts +14 -0
- package/dist/projections/graphs/views/ViewIsAlsoSchema.d.ts.map +1 -0
- package/dist/projections/graphs/views/ViewIsAlsoSchema.js +19 -0
- package/dist/projections/graphs/views/ViewIsAlsoSchema.js.map +1 -0
- package/dist/projections/graphs/views/ViewOfMetadata.d.ts +8 -0
- package/dist/projections/graphs/views/ViewOfMetadata.d.ts.map +1 -0
- package/dist/projections/graphs/views/ViewOfMetadata.js +4 -0
- package/dist/projections/graphs/views/ViewOfMetadata.js.map +1 -0
- package/dist/projections/graphs/views/ViewOfOptions.d.ts +6 -0
- package/dist/projections/graphs/views/ViewOfOptions.d.ts.map +1 -0
- package/dist/projections/graphs/views/ViewOfOptions.js +4 -0
- package/dist/projections/graphs/views/ViewOfOptions.js.map +1 -0
- package/dist/projections/graphs/views/ViewRootNotANode.d.ts +16 -0
- package/dist/projections/graphs/views/ViewRootNotANode.d.ts.map +1 -0
- package/dist/projections/graphs/views/ViewRootNotANode.js +21 -0
- package/dist/projections/graphs/views/ViewRootNotANode.js.map +1 -0
- package/dist/projections/graphs/views/declareGraphViewMember.d.ts +17 -0
- package/dist/projections/graphs/views/declareGraphViewMember.d.ts.map +1 -0
- package/dist/projections/graphs/views/declareGraphViewMember.js +31 -0
- package/dist/projections/graphs/views/declareGraphViewMember.js.map +1 -0
- package/dist/projections/graphs/views/follows.d.ts +13 -0
- package/dist/projections/graphs/views/follows.d.ts.map +1 -0
- package/dist/projections/graphs/views/follows.js +24 -0
- package/dist/projections/graphs/views/follows.js.map +1 -0
- package/dist/projections/graphs/views/fromEdge.d.ts +10 -0
- package/dist/projections/graphs/views/fromEdge.d.ts.map +1 -0
- package/dist/projections/graphs/views/fromEdge.js +15 -0
- package/dist/projections/graphs/views/fromEdge.js.map +1 -0
- package/dist/projections/graphs/views/index.d.ts +41 -0
- package/dist/projections/graphs/views/index.d.ts.map +1 -0
- package/dist/projections/graphs/views/index.js +28 -0
- package/dist/projections/graphs/views/index.js.map +1 -0
- package/dist/projections/graphs/views/viewKey.d.ts +8 -0
- package/dist/projections/graphs/views/viewKey.d.ts.map +1 -0
- package/dist/projections/graphs/views/viewKey.js +13 -0
- package/dist/projections/graphs/views/viewKey.js.map +1 -0
- package/dist/projections/graphs/views/viewOf.d.ts +22 -0
- package/dist/projections/graphs/views/viewOf.d.ts.map +1 -0
- package/dist/projections/graphs/views/viewOf.js +41 -0
- package/dist/projections/graphs/views/viewOf.js.map +1 -0
- package/dist/projections/graphs/views/viewProperty.d.ts +9 -0
- package/dist/projections/graphs/views/viewProperty.d.ts.map +1 -0
- package/dist/projections/graphs/views/viewProperty.js +14 -0
- package/dist/projections/graphs/views/viewProperty.js.map +1 -0
- package/dist/testing/InProcessAppendMetadata.d.ts +30 -0
- package/dist/testing/InProcessAppendMetadata.d.ts.map +1 -0
- package/dist/testing/InProcessAppendMetadata.js +107 -0
- package/dist/testing/InProcessAppendMetadata.js.map +1 -0
- package/dist/testing/InProcessBatchAppend.d.ts +62 -0
- package/dist/testing/InProcessBatchAppend.d.ts.map +1 -0
- package/dist/testing/InProcessBatchAppend.js +131 -0
- package/dist/testing/InProcessBatchAppend.js.map +1 -0
- package/dist/testing/InProcessEventPayload.d.ts +23 -0
- package/dist/testing/InProcessEventPayload.d.ts.map +1 -0
- package/dist/testing/InProcessEventPayload.js +94 -0
- package/dist/testing/InProcessEventPayload.js.map +1 -0
- package/dist/testing/InProcessEventReadCriteria.d.ts +9 -0
- package/dist/testing/InProcessEventReadCriteria.d.ts.map +1 -0
- package/dist/testing/InProcessEventReadCriteria.js +4 -0
- package/dist/testing/InProcessEventReadCriteria.js.map +1 -0
- package/dist/testing/InProcessEventReadFilter.d.ts +14 -0
- package/dist/testing/InProcessEventReadFilter.d.ts.map +1 -0
- package/dist/testing/InProcessEventReadFilter.js +31 -0
- package/dist/testing/InProcessEventReadFilter.js.map +1 -0
- package/dist/testing/InProcessEventSequence.d.ts +8 -5
- package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
- package/dist/testing/InProcessEventSequence.js +59 -275
- package/dist/testing/InProcessEventSequence.js.map +1 -1
- package/dist/testing/InProcessEventSequenceEnvironment.d.ts +13 -0
- package/dist/testing/InProcessEventSequenceEnvironment.d.ts.map +1 -0
- package/dist/testing/InProcessEventSequenceEnvironment.js +4 -0
- package/dist/testing/InProcessEventSequenceEnvironment.js.map +1 -0
- package/dist/testing/InProcessSingleAppend.d.ts +34 -0
- package/dist/testing/InProcessSingleAppend.d.ts.map +1 -0
- package/dist/testing/InProcessSingleAppend.js +95 -0
- package/dist/testing/InProcessSingleAppend.js.map +1 -0
- package/dist/testing/projections/ProjectionCapabilities.d.ts +0 -8
- package/dist/testing/projections/ProjectionCapabilities.d.ts.map +1 -1
- package/dist/testing/projections/ProjectionCapabilities.js +21 -312
- package/dist/testing/projections/ProjectionCapabilities.js.map +1 -1
- package/dist/testing/projections/ProjectionCapabilityReject.d.ts +3 -0
- package/dist/testing/projections/ProjectionCapabilityReject.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionCapabilityReject.js +4 -0
- package/dist/testing/projections/ProjectionCapabilityReject.js.map +1 -0
- package/dist/testing/projections/ProjectionCapabilityReporter.d.ts +12 -0
- package/dist/testing/projections/ProjectionCapabilityReporter.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionCapabilityReporter.js +33 -0
- package/dist/testing/projections/ProjectionCapabilityReporter.js.map +1 -0
- package/dist/testing/projections/ProjectionDefinitionCapabilities.d.ts +11 -0
- package/dist/testing/projections/ProjectionDefinitionCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionDefinitionCapabilities.js +45 -0
- package/dist/testing/projections/ProjectionDefinitionCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionEventSchemaResolver.d.ts +13 -0
- package/dist/testing/projections/ProjectionEventSchemaResolver.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionEventSchemaResolver.js +22 -0
- package/dist/testing/projections/ProjectionEventSchemaResolver.js.map +1 -0
- package/dist/testing/projections/ProjectionExpressionCapabilities.d.ts +19 -0
- package/dist/testing/projections/ProjectionExpressionCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionExpressionCapabilities.js +103 -0
- package/dist/testing/projections/ProjectionExpressionCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionInitialValueCapabilities.d.ts +16 -0
- package/dist/testing/projections/ProjectionInitialValueCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionInitialValueCapabilities.js +72 -0
- package/dist/testing/projections/ProjectionInitialValueCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionMappingCapabilities.d.ts +21 -0
- package/dist/testing/projections/ProjectionMappingCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionMappingCapabilities.js +86 -0
- package/dist/testing/projections/ProjectionMappingCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionMappingValidation.d.ts +9 -0
- package/dist/testing/projections/ProjectionMappingValidation.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionMappingValidation.js +4 -0
- package/dist/testing/projections/ProjectionMappingValidation.js.map +1 -0
- package/dist/testing/projections/ProjectionReadModelCapabilities.d.ts +11 -0
- package/dist/testing/projections/ProjectionReadModelCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionReadModelCapabilities.js +40 -0
- package/dist/testing/projections/ProjectionReadModelCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionRootCapabilities.d.ts +20 -0
- package/dist/testing/projections/ProjectionRootCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionRootCapabilities.js +73 -0
- package/dist/testing/projections/ProjectionRootCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionScalarConverter.d.ts +21 -0
- package/dist/testing/projections/ProjectionScalarConverter.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionScalarConverter.js +105 -0
- package/dist/testing/projections/ProjectionScalarConverter.js.map +1 -0
- package/dist/testing/projections/ProjectionSchemaCapabilities.d.ts +26 -0
- package/dist/testing/projections/ProjectionSchemaCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionSchemaCapabilities.js +109 -0
- package/dist/testing/projections/ProjectionSchemaCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionValueConverter.d.ts +5 -0
- package/dist/testing/projections/ProjectionValueConverter.d.ts.map +1 -1
- package/dist/testing/projections/ProjectionValueConverter.js +36 -84
- package/dist/testing/projections/ProjectionValueConverter.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/DecoratorType.d.ts +3 -1
- package/dist/types/DecoratorType.d.ts.map +1 -1
- package/dist/types/DecoratorType.js +2 -0
- package/dist/types/DecoratorType.js.map +1 -1
- package/package.json +2 -2
- package/projections/for_Graphs/given/a_discovered_graph.ts +3 -2
- package/projections/for_Graphs/given/a_graph_with_views.ts +91 -0
- package/projections/for_Graphs/given/organization.ts +3 -2
- package/projections/for_Graphs/given/organization_with_views.fixture.ts +129 -0
- package/projections/for_Graphs/when_building_graph_views.spec.ts +218 -0
- package/projections/for_Graphs/when_declaring_an_invalid_graph_view.spec.ts +229 -0
- package/projections/for_Graphs/when_declaring_graph_views.standard.spec.ts +49 -0
- package/projections/for_Graphs/when_discovering_graph_views.spec.ts +58 -0
- package/projections/graphs/Graphs.ts +44 -0
- package/projections/graphs/IGraphs.ts +10 -2
- package/projections/graphs/index.ts +1 -0
- package/projections/graphs/views/AmbiguousDirection.ts +23 -0
- package/projections/graphs/views/DuplicateViewName.ts +23 -0
- package/projections/graphs/views/EdgeNotIncidentOnRoot.ts +24 -0
- package/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.ts +21 -0
- package/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.ts +22 -0
- package/projections/graphs/views/FollowsOptions.ts +20 -0
- package/projections/graphs/views/GraphEdgeDirection.ts +13 -0
- package/projections/graphs/views/GraphView.ts +18 -0
- package/projections/graphs/views/GraphViewBuildResult.ts +19 -0
- package/projections/graphs/views/GraphViewCardinality.ts +13 -0
- package/projections/graphs/views/GraphViewDefinition.ts +20 -0
- package/projections/graphs/views/GraphViewDefinitionBuilder.ts +322 -0
- package/projections/graphs/views/GraphViewDefinitionSerializer.ts +90 -0
- package/projections/graphs/views/GraphViewEdgeReference.ts +8 -0
- package/projections/graphs/views/GraphViewMember.ts +11 -0
- package/projections/graphs/views/GraphViewMemberKind.ts +16 -0
- package/projections/graphs/views/GraphViewMemberMetadata.ts +31 -0
- package/projections/graphs/views/GraphViewPropertyMember.ts +18 -0
- package/projections/graphs/views/GraphViewReason.ts +47 -0
- package/projections/graphs/views/GraphViewRelationMember.ts +29 -0
- package/projections/graphs/views/GraphViewSchema.ts +14 -0
- package/projections/graphs/views/GraphViewSchemaEdge.ts +20 -0
- package/projections/graphs/views/GraphViewSchemaNode.ts +14 -0
- package/projections/graphs/views/GraphViewSerializerOptions.ts +11 -0
- package/projections/graphs/views/RecursiveView.ts +22 -0
- package/projections/graphs/views/RelationTargetNotAView.ts +23 -0
- package/projections/graphs/views/TargetLabelMismatch.ts +25 -0
- package/projections/graphs/views/UnknownEdge.ts +23 -0
- package/projections/graphs/views/UnknownEdgeProperty.ts +24 -0
- package/projections/graphs/views/UnknownNodeProperty.ts +24 -0
- package/projections/graphs/views/ViewIsAlsoSchema.ts +21 -0
- package/projections/graphs/views/ViewOfMetadata.ts +11 -0
- package/projections/graphs/views/ViewOfOptions.ts +8 -0
- package/projections/graphs/views/ViewRootNotANode.ts +23 -0
- package/projections/graphs/views/declareGraphViewMember.ts +36 -0
- package/projections/graphs/views/follows.ts +28 -0
- package/projections/graphs/views/fromEdge.ts +17 -0
- package/projections/graphs/views/index.ts +43 -0
- package/projections/graphs/views/viewKey.ts +15 -0
- package/projections/graphs/views/viewOf.ts +50 -0
- package/projections/graphs/views/viewProperty.ts +16 -0
- package/testing/InProcessAppendMetadata.ts +119 -0
- package/testing/InProcessBatchAppend.ts +142 -0
- package/testing/InProcessEventPayload.ts +100 -0
- package/testing/InProcessEventReadCriteria.ts +11 -0
- package/testing/InProcessEventReadFilter.ts +37 -0
- package/testing/InProcessEventSequence.ts +63 -257
- package/testing/InProcessEventSequenceEnvironment.ts +16 -0
- package/testing/InProcessSingleAppend.ts +99 -0
- package/testing/for_InProcessEventSequence/when_preserving_validation_and_commit_order.spec.ts +95 -0
- package/testing/projections/ProjectionCapabilities.ts +23 -279
- package/testing/projections/ProjectionCapabilityReject.ts +5 -0
- package/testing/projections/ProjectionCapabilityReporter.ts +31 -0
- package/testing/projections/ProjectionDefinitionCapabilities.ts +45 -0
- package/testing/projections/ProjectionEventSchemaResolver.ts +23 -0
- package/testing/projections/ProjectionExpressionCapabilities.ts +101 -0
- package/testing/projections/ProjectionInitialValueCapabilities.ts +73 -0
- package/testing/projections/ProjectionMappingCapabilities.ts +85 -0
- package/testing/projections/ProjectionMappingValidation.ts +12 -0
- package/testing/projections/ProjectionReadModelCapabilities.ts +42 -0
- package/testing/projections/ProjectionRootCapabilities.ts +75 -0
- package/testing/projections/ProjectionScalarConverter.ts +106 -0
- package/testing/projections/ProjectionSchemaCapabilities.ts +112 -0
- package/testing/projections/ProjectionValueConverter.ts +37 -76
- package/testing/projections/for_ProjectionCapabilities/when_reporting_the_first_unsupported_operation.spec.ts +74 -0
- package/testing/projections/for_ProjectionValueConverter/when_converting_structured_and_scalar_values.spec.ts +64 -0
- package/types/DecoratorType.ts +4 -1
package/testing/for_InProcessEventSequence/when_preserving_validation_and_commit_order.spec.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import 'reflect-metadata';
|
|
5
|
+
import { field } from '@cratis/fundamentals';
|
|
6
|
+
import { chai, describe, it } from 'vitest';
|
|
7
|
+
import { eventType } from '../../events/eventTypeDecorator.js';
|
|
8
|
+
import type { AppendOptions } from '../../eventSequences/AppendOptions.js';
|
|
9
|
+
import { EventSequenceNumber } from '../../eventSequences/EventSequenceNumber.js';
|
|
10
|
+
import { InProcessEventSequence, observeUnsupportedOperations } from '../InProcessEventSequence.js';
|
|
11
|
+
import { UnsupportedEventSequenceOperation } from '../UnsupportedEventSequenceOperation.js';
|
|
12
|
+
|
|
13
|
+
chai.should();
|
|
14
|
+
|
|
15
|
+
@eventType('ValidationOrderRecorded')
|
|
16
|
+
class Recorded {
|
|
17
|
+
@field(String) name = 'recorded';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const create = () => new InProcessEventSequence({ constraints: 'disabled' }, [Recorded]);
|
|
21
|
+
|
|
22
|
+
async function rejects(pending: Promise<unknown>, operation: string): Promise<void> {
|
|
23
|
+
await pending.then(() => { throw new Error('Expected rejection'); }, error => {
|
|
24
|
+
(error instanceof UnsupportedEventSequenceOperation).should.equal(true);
|
|
25
|
+
(error as Error).message.should.include(operation);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('when preserving validation and commit order', () => {
|
|
30
|
+
it('should report an invalid event before an invalid source', async () => {
|
|
31
|
+
const sequence = create();
|
|
32
|
+
await rejects(sequence.append('invalid source', null as unknown as object), 'append.event');
|
|
33
|
+
sequence.results.length.should.equal(0);
|
|
34
|
+
sequence.appendedEvents.length.should.equal(0);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should latch failures immediately and retain the async append guard until settlement', async () => {
|
|
38
|
+
const sequence = create();
|
|
39
|
+
const observed: UnsupportedEventSequenceOperation[] = [];
|
|
40
|
+
observeUnsupportedOperations(sequence, error => observed.push(error));
|
|
41
|
+
const first = sequence.append('invalid source', new Recorded());
|
|
42
|
+
observed.length.should.equal(1);
|
|
43
|
+
const overlapping = sequence.append('A', new Recorded());
|
|
44
|
+
observed.length.should.equal(2);
|
|
45
|
+
await rejects(first, 'append.source');
|
|
46
|
+
await rejects(overlapping, 'Overlapping calls do not have proven ordering.');
|
|
47
|
+
(await sequence.append('A', new Recorded())).sequenceNumber.value.should.equal(0n);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should reject shared batch options before inspecting entries', async () => {
|
|
51
|
+
const sequence = create();
|
|
52
|
+
await rejects(sequence.appendMany([null as never], { subject: 42 } as unknown as AppendOptions), 'appendMany.subject');
|
|
53
|
+
sequence.results.length.should.equal(0);
|
|
54
|
+
(await sequence.getNextSequenceNumber()).value.should.equal(0n);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should reject malformed entry metadata before invoking the correlation hook', async () => {
|
|
58
|
+
let calls = 0;
|
|
59
|
+
const sequence = new InProcessEventSequence({ constraints: 'disabled', correlationId: () => { calls++; throw new Error('hook'); } }, [Recorded]);
|
|
60
|
+
await rejects(sequence.appendMany([{ eventSourceId: 'A', event: new Recorded(), unexpected: true } as never]), 'appendMany.entry');
|
|
61
|
+
calls.should.equal(0);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should release a failed batch guard and leave its sequence numbers unallocated', async () => {
|
|
65
|
+
const sequence = create();
|
|
66
|
+
await rejects(sequence.appendMany('A', [new Recorded(), Object.assign(new Recorded(), { name: null })]), 'appendMany.content');
|
|
67
|
+
sequence.results.length.should.equal(0);
|
|
68
|
+
sequence.appendedEvents.length.should.equal(0);
|
|
69
|
+
(await sequence.appendMany('B', [new Recorded()]))[0].sequenceNumber.value.should.equal(0n);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should discard staged seeds and release setup ownership after a later invalid event', async () => {
|
|
73
|
+
const sequence = create();
|
|
74
|
+
await rejects(sequence.seed('A', [new Recorded(), Object.assign(new Recorded(), { name: null })]), 'append.content');
|
|
75
|
+
sequence.results.length.should.equal(0);
|
|
76
|
+
sequence.appendedEvents.length.should.equal(0);
|
|
77
|
+
await sequence.seed('B', [new Recorded()]);
|
|
78
|
+
(await sequence.append('C', new Recorded())).sequenceNumber.value.should.equal(1n);
|
|
79
|
+
sequence.results.length.should.equal(1);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should preserve the kernel whitespace distinction in stored subjects', async () => {
|
|
83
|
+
const sequence = create();
|
|
84
|
+
await sequence.append('A', new Recorded(), { subject: '\u0085' });
|
|
85
|
+
await sequence.appendMany('B', [new Recorded()], { subject: '\ufeff' });
|
|
86
|
+
sequence.appendedEvents.map(event => event.context.subject).should.deep.equal(['A', '\ufeff']);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should validate read arguments before route and catalog filters', async () => {
|
|
90
|
+
const sequence = create();
|
|
91
|
+
await rejects(sequence.getTailSequenceNumber(' A ', 'bad route', undefined, undefined, [class Missing {}]), 'getTailSequenceNumber.source');
|
|
92
|
+
await rejects(sequence.getForEventSourceIdAndEventTypes(' A ', [], 'bad route'), 'getForEventSourceIdAndEventTypes.filters');
|
|
93
|
+
await rejects(sequence.getFromSequenceNumber(new EventSequenceNumber(-1n), ' A '), 'getFromSequenceNumber.sequenceNumber');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
|
-
import { AutoMap, type ProjectionDefinition } from '@cratis/chronicle.contracts';
|
|
5
|
-
import { EventSequenceId } from '../../eventSequences/EventSequenceId.js';
|
|
4
|
+
import { type AutoMap, type ProjectionDefinition } from '@cratis/chronicle.contracts';
|
|
6
5
|
import type { CompiledProjectionDefinitions } from '../../projections/CompiledProjectionDefinitions.js';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import { getEventTypeMapKey, type ChildrenDefinitionLike } from '../../projections/modelBound/childrenAndNestedBuilder.js';
|
|
10
|
-
import type { JsonSchema } from '../../schemas/JsonSchema.js';
|
|
11
|
-
import { ProjectionArithmetic } from './ProjectionArithmetic.js';
|
|
6
|
+
import type { ChildrenDefinitionLike } from '../../projections/modelBound/childrenAndNestedBuilder.js';
|
|
7
|
+
import { ProjectionCapabilityReporter } from './ProjectionCapabilityReporter.js';
|
|
12
8
|
import { ProjectionChildrenCapabilities } from './ProjectionChildrenCapabilities.js';
|
|
9
|
+
import { ProjectionDefinitionCapabilities } from './ProjectionDefinitionCapabilities.js';
|
|
10
|
+
import { ProjectionEventSchemaResolver } from './ProjectionEventSchemaResolver.js';
|
|
11
|
+
import { ProjectionInitialValueCapabilities } from './ProjectionInitialValueCapabilities.js';
|
|
13
12
|
import { ProjectionJoinsCapabilities } from './ProjectionJoinsCapabilities.js';
|
|
14
|
-
import {
|
|
13
|
+
import { ProjectionMappingCapabilities } from './ProjectionMappingCapabilities.js';
|
|
14
|
+
import { ProjectionReadModelCapabilities } from './ProjectionReadModelCapabilities.js';
|
|
15
|
+
import { ProjectionRootCapabilities } from './ProjectionRootCapabilities.js';
|
|
16
|
+
import { ProjectionSchemaCapabilities } from './ProjectionSchemaCapabilities.js';
|
|
15
17
|
|
|
16
18
|
/** Validates *all* subscribed operations against the bounded scenario subset, before replay. */
|
|
17
19
|
export class ProjectionCapabilities {
|
|
@@ -23,286 +25,28 @@ export class ProjectionCapabilities {
|
|
|
23
25
|
static validate(compiled: CompiledProjectionDefinitions, definition: ProjectionDefinition): void {
|
|
24
26
|
const model = String(definition.ReadModel ?? definition.Identifier ?? '<unknown>');
|
|
25
27
|
const wire = definition as unknown as Record<string, unknown>;
|
|
26
|
-
const reject = (
|
|
27
|
-
const source = compiled.provenance.get(definition)?.find(entry => entry.contractPath.startsWith('From['))?.declaration ?? '.from';
|
|
28
|
-
const declaration = compiled.provenance.get(definition)?.find(entry => entry.contractPath === path)?.declaration
|
|
29
|
-
?? compiled.provenance.get(definition)?.find(entry => entry.contractPath.startsWith('Join[') && path.startsWith(`${entry.contractPath}.`))?.declaration
|
|
30
|
-
?? fallback ?? (path.includes('.AutoMap.') ? `${source} (AutoMap)`
|
|
31
|
-
: path.startsWith('InitialModelState') ? '.withInitialValues'
|
|
32
|
-
: path.startsWith('ReadModel') ? source : 'contract');
|
|
33
|
-
throw new UnsupportedProjectionOperation(model, path, declaration, reason);
|
|
34
|
-
};
|
|
28
|
+
const reject = new ProjectionCapabilityReporter(compiled, definition).reject;
|
|
35
29
|
if (!compiled.definitions.includes(definition)) reject('Definition', 'definition is not part of this compile');
|
|
36
30
|
const provenance = compiled.provenance.get(definition) ?? reject('Definition', 'capability provenance is unavailable');
|
|
37
31
|
const catalog = compiled.eventSchemas.get(definition) ?? reject('Definition', 'event-schema catalog is unavailable');
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (wire.EventSequenceId !== EventSequenceId.eventLog.value) reject('EventSequenceId', 'non-default event sequences require a kernel-backed test');
|
|
43
|
-
for (const section of ['Nested', 'RemovedWithJoin'] as const) {
|
|
44
|
-
const value = wire[section];
|
|
45
|
-
const paths = Array.isArray(value) ? value.map((entry: { Key: ContractEventType }) => eventContractPath(section, entry.Key))
|
|
46
|
-
: Object.keys(value as Record<string, unknown> ?? {}).map(property => `${section}.${property}`);
|
|
47
|
-
if (paths.length) reject(paths[0], `${section === 'Nested' ? 'nested projections' : 'removedWithJoin'} require a kernel-backed test`);
|
|
48
|
-
}
|
|
49
|
-
if ((wire.FromEvery as unknown[] | undefined)?.length) reject('FromEvery', 'derivative projections require a kernel-backed test');
|
|
50
|
-
if (wire.FromEventProperty) reject('FromEventProperty', 'event-property subscriptions require a kernel-backed test');
|
|
51
|
-
const all = wire.All as { Properties?: Record<string, string>; IncludeChildren?: boolean; AutoMap?: AutoMap } | undefined;
|
|
52
|
-
if (provenance.some(entry => entry.contractPath === 'All') || all?.IncludeChildren ||
|
|
53
|
-
Object.keys(all?.Properties ?? {}).length || all?.AutoMap === AutoMap.Enabled) {
|
|
54
|
-
reject('All', 'fromEvery/all subscriptions require a kernel-backed test');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const readModel = compiled.readModels.find(candidate => candidate.Type.Identifier === model)
|
|
58
|
-
?? reject('ReadModel', 'a single registered read-model schema is required');
|
|
59
|
-
let schema: JsonSchema;
|
|
60
|
-
try {
|
|
61
|
-
schema = JSON.parse(readModel.Schema) as JsonSchema;
|
|
62
|
-
} catch {
|
|
63
|
-
reject('ReadModel.Schema', 'read-model schema is not valid JSON');
|
|
64
|
-
}
|
|
65
|
-
this.checkProtection(schema!, 'ReadModel.Schema', reject);
|
|
66
|
-
const identifier = schema!.properties?.id;
|
|
67
|
-
if (!identifier || !((identifier.type === 'string' && (!identifier.format || identifier.format === 'guid')) ||
|
|
68
|
-
(identifier.type === 'number' && identifier.format === 'double'))) {
|
|
69
|
-
reject('ReadModel.Schema.id', 'only a lowercase id with a fixture-backed string, GUID, or number/double schema is supported; other identifiers require a kernel-backed test (ChronicleKernelScenario / live kernel)');
|
|
70
|
-
}
|
|
71
|
-
const names = Object.keys(schema!.properties ?? {});
|
|
72
|
-
for (const [index, name] of names.entries()) {
|
|
73
|
-
if (names.slice(index + 1).some(other => other.toLowerCase() === name.toLowerCase())) {
|
|
74
|
-
reject(`ReadModel.Schema.${name}`, 'case-insensitively colliding read-model properties require a kernel-backed test (ChronicleKernelScenario / live kernel)');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
let initial: unknown;
|
|
78
|
-
try { initial = JSON.parse(String(wire.InitialModelState ?? '{}')); } catch { reject('InitialModelState', 'initial values must be a JSON object'); }
|
|
79
|
-
if (initial === null || typeof initial !== 'object' || Array.isArray(initial)) reject('InitialModelState', 'initial values must be a JSON object');
|
|
80
|
-
for (const [property, value] of Object.entries(initial as Record<string, unknown>)) {
|
|
81
|
-
const target = schema!.properties?.[property]
|
|
82
|
-
?? reject(`InitialModelState.${property}`, 'initial value has no read-model schema');
|
|
83
|
-
this.checkSchema(target, `InitialModelState.${property}`, reject);
|
|
84
|
-
this.checkInitialValue(value, target, `InitialModelState.${property}`, reject);
|
|
85
|
-
}
|
|
86
|
-
const generations = new Map<string, number>();
|
|
87
|
-
const requireEventSchema = (eventType: ContractEventType, path: string): JsonSchema => {
|
|
88
|
-
const previous = generations.get(eventType.Id);
|
|
89
|
-
if (previous !== undefined && previous !== eventType.Generation) reject(path, 'multiple generations of the same event-type id require a kernel-backed test');
|
|
90
|
-
generations.set(eventType.Id, eventType.Generation);
|
|
91
|
-
const event = catalog.get(getEventTypeMapKey(eventType)) ?? reject(path, 'participating event schema is unavailable');
|
|
92
|
-
return event.schema;
|
|
93
|
-
};
|
|
32
|
+
ProjectionDefinitionCapabilities.validate(wire, provenance, reject);
|
|
33
|
+
const schema = ProjectionReadModelCapabilities.schema(compiled, model, reject);
|
|
34
|
+
const initial = ProjectionInitialValueCapabilities.validate(String(wire.InitialModelState ?? '{}'), schema, reject);
|
|
35
|
+
const resolver = new ProjectionEventSchemaResolver(catalog, reject);
|
|
94
36
|
ProjectionJoinsCapabilities.validate(definition, {
|
|
95
|
-
schema:
|
|
96
|
-
checkProtection: (eventSchema, path) =>
|
|
37
|
+
schema, requireEventSchema: resolver.require, reject,
|
|
38
|
+
checkProtection: (eventSchema, path) => ProjectionSchemaCapabilities.checkProtection(eventSchema, path, reject),
|
|
97
39
|
checkMapping: (modelSchema, eventSchema, destination, expression, path) =>
|
|
98
|
-
|
|
40
|
+
new ProjectionMappingCapabilities(modelSchema, reject).check({ eventSchema, destination, expression, path })
|
|
99
41
|
});
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
for (const entry of from) {
|
|
103
|
-
if (removedWith.some(removal => removal.Key.Id === entry.Key.Id)) {
|
|
104
|
-
reject(eventContractPath('From', entry.Key), 'events subscribed through both From and RemovedWith require a kernel-backed test (ChronicleKernelScenario / live kernel)');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const accumulators = new Set(from.flatMap(entry => Object.entries(entry.Value.Properties ?? {})
|
|
108
|
-
.filter(([, expression]) => ProjectionArithmetic.isArithmetic(expression)).map(([property]) => property)));
|
|
109
|
-
if (accumulators.size && Object.keys(wire.Children as object ?? {}).length) {
|
|
110
|
-
reject('Children', 'root arithmetic combined with children requires a kernel-backed test');
|
|
111
|
-
}
|
|
112
|
-
for (const entry of from) {
|
|
113
|
-
for (const [property, expression] of Object.entries(entry.Value.Properties ?? {})) {
|
|
114
|
-
if (expression === '$null' && accumulators.has(property)) {
|
|
115
|
-
reject(`${eventContractPath('From', entry.Key)}.Properties.${property}`,
|
|
116
|
-
'clearing an arithmetic accumulator requires a kernel-backed test; the kernel rejects arithmetic on a present null');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
for (const entry of [...from, ...removedWith]) {
|
|
121
|
-
const section = from.includes(entry as FromRecord) ? 'From' : 'RemovedWith';
|
|
122
|
-
const path = eventContractPath(section, entry.Key);
|
|
123
|
-
const eventSchema = requireEventSchema(entry.Key, path);
|
|
124
|
-
if (entry.Value.Key !== '$eventSourceId') reject(`${path}.Key`, 'only $eventSourceId keys are supported');
|
|
125
|
-
if (entry.Value.ParentKey) reject(`${path}.ParentKey`, 'parent keys require a kernel-backed test');
|
|
126
|
-
if (section === 'RemovedWith') continue;
|
|
127
|
-
const properties = (entry as FromRecord).Value.Properties ?? {};
|
|
128
|
-
for (const [property, expression] of Object.entries(properties)) {
|
|
129
|
-
const mappingPath = `${path}.Properties.${property}`;
|
|
130
|
-
this.checkMapping(schema!, eventSchema, property, expression, mappingPath, reject, accumulators);
|
|
131
|
-
}
|
|
132
|
-
if (wire.AutoMap !== AutoMap.Disabled && !ProjectionArithmetic.suppressesAutoMap(properties)) {
|
|
133
|
-
this.checkAutoMap(schema!, eventSchema, properties, wire.NoAutoMapProperties as string[] ?? [], path, reject, accumulators);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
42
|
+
const roots = new ProjectionRootCapabilities(schema, wire, reject);
|
|
43
|
+
roots.validate(resolver);
|
|
136
44
|
ProjectionChildrenCapabilities.validate(wire.Children as Record<string, ChildrenDefinitionLike> ?? {}, {
|
|
137
|
-
schema
|
|
45
|
+
schema, rootAutoMap: wire.AutoMap as AutoMap, hasInitialModelState: Object.keys(initial).length > 0,
|
|
46
|
+
from: roots.from, removedWith: roots.removedWith, requireEventSchema: resolver.require, reject,
|
|
138
47
|
declarationFor: path => provenance.find(entry => entry.contractPath === path)?.declaration,
|
|
139
48
|
checkMapping: (modelSchema, eventSchema, destination, expression, path) =>
|
|
140
|
-
|
|
49
|
+
new ProjectionMappingCapabilities(modelSchema, reject).check({ eventSchema, destination, expression, path })
|
|
141
50
|
});
|
|
142
51
|
}
|
|
143
|
-
|
|
144
|
-
private static checkAutoMap(
|
|
145
|
-
modelSchema: JsonSchema, eventSchema: JsonSchema, explicit: Record<string, string>, exclusions: string[],
|
|
146
|
-
path: string, reject: (path: string, reason: string) => never, accumulators: ReadonlySet<string>
|
|
147
|
-
): void {
|
|
148
|
-
for (const [destination] of Object.entries(modelSchema.properties ?? {})) {
|
|
149
|
-
if (Object.keys(explicit).some(name => name.toLowerCase() === destination.toLowerCase()) ||
|
|
150
|
-
exclusions.some(name => name.toLowerCase() === destination.toLowerCase())) continue;
|
|
151
|
-
const candidates = Object.keys(eventSchema.properties ?? {}).filter(source => source.toLowerCase() === destination.toLowerCase());
|
|
152
|
-
if (candidates.length > 1) reject(`${path}.AutoMap.${destination}`, `inferred AutoMap source is ambiguous: ${candidates.join(', ')}`);
|
|
153
|
-
if (candidates.length) this.checkMapping(modelSchema, eventSchema, destination, candidates[0], `${path}.AutoMap.${destination}`, reject, accumulators);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
private static checkMapping(
|
|
158
|
-
modelSchema: JsonSchema, eventSchema: JsonSchema, destination: string, expression: string,
|
|
159
|
-
path: string, reject: (path: string, reason: string) => never, accumulators?: ReadonlySet<string>
|
|
160
|
-
): void {
|
|
161
|
-
const fail = (reason: string): never => reject(path, `expression '${expression}': ${reason}`);
|
|
162
|
-
const target = modelSchema.properties?.[destination]
|
|
163
|
-
?? fail('dynamic or unknown destination paths require a kernel-backed test');
|
|
164
|
-
if (destination.includes('.') || destination.includes('$')) fail('dynamic or unknown destination paths require a kernel-backed test');
|
|
165
|
-
if (destination.toLowerCase() === 'id' || Object.keys(modelSchema.properties ?? {}).some(name =>
|
|
166
|
-
name !== destination && name.toLowerCase() === destination.toLowerCase())) {
|
|
167
|
-
fail('identifier or case-insensitively colliding target mappings require a kernel-backed test (ChronicleKernelScenario / live kernel)');
|
|
168
|
-
}
|
|
169
|
-
if (target.type === 'object' || target.type === 'array') fail('object/array target mappings require a kernel-backed test (ChronicleKernelScenario / live kernel)');
|
|
170
|
-
this.checkSchema(target, path, (_path, reason) => fail(reason));
|
|
171
|
-
if (expression === '$eventSourceId') {
|
|
172
|
-
if (target.type !== 'string' || (target.format && target.format !== 'guid')) {
|
|
173
|
-
fail('$eventSourceId requires a string or GUID target; other targets require a kernel-backed test (ChronicleKernelScenario / live kernel)');
|
|
174
|
-
}
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (expression === '$null') return;
|
|
178
|
-
if (expression.startsWith('$setOnce(')) fail('set once requires a kernel-backed test');
|
|
179
|
-
if (expression.startsWith('$eventContext(')) {
|
|
180
|
-
if (expression === '$eventContext(Occurred)') fail('raw Occurred is converted inconsistently by the kernel; only its Year, Month and Day paths are supported');
|
|
181
|
-
if (/^\$eventContext\(.+\(\)\)$/.test(expression)) fail('derived event-context functions require a kernel-backed test');
|
|
182
|
-
const path = /^\$eventContext\(([^()]*)\)$/.exec(expression)?.[1];
|
|
183
|
-
const strings = ['EventSourceId', 'EventStore', 'Namespace', 'EventSourceType', 'EventStreamType',
|
|
184
|
-
'EventStreamId', 'Subject', 'Subject.Value', 'Hash', 'CorrelationId', 'CorrelationId.Value',
|
|
185
|
-
'CausedBy.Subject', 'CausedBy.Name', 'CausedBy.UserName', 'EventType.Id.Value', 'SequenceNumber', 'SequenceNumber.Value'];
|
|
186
|
-
const integers = ['Occurred.Year', 'Occurred.Month', 'Occurred.Day', 'EventType.Generation.Value'];
|
|
187
|
-
if (path && ((strings.includes(path) && target.type === 'string' && !target.format) ||
|
|
188
|
-
(integers.includes(path) && target.type === 'integer' && target.format === 'int32'))) return;
|
|
189
|
-
fail('event-context path and target schema require a kernel-backed test');
|
|
190
|
-
}
|
|
191
|
-
if (/^\$value\([\p{L}\p{Mn}\p{Nd}\p{Pc} ._/:*+-]*\)$/u.test(expression)) {
|
|
192
|
-
const text = expression.slice(7, -1);
|
|
193
|
-
if (target.format === 'date-time') fail('$value date-time literals require a kernel-backed test');
|
|
194
|
-
if (this.numeric(target)) {
|
|
195
|
-
if (!(target.type === 'integer' ? /^[+-]?\d+$/.test(text) : /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(text)) || !Number.isFinite(Number(text)) ||
|
|
196
|
-
(target.type === 'integer' && (!Number.isSafeInteger(Number(text)) ||
|
|
197
|
-
(target.format === 'int32' && (Number(text) < -2147483648 || Number(text) > 2147483647)) ||
|
|
198
|
-
(target.format === 'uint32' && (Number(text) < 0 || Number(text) > 4294967295))))) {
|
|
199
|
-
fail('$value numeric literal is outside the supported finite/integer range');
|
|
200
|
-
}
|
|
201
|
-
} else if (target.type === 'boolean' && !/^(?:true|false)$/i.test(text)) {
|
|
202
|
-
fail('$value boolean literal must be true or false');
|
|
203
|
-
} else if (target.format === 'guid' && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(text)) {
|
|
204
|
-
fail('$value GUID literal is not canonical');
|
|
205
|
-
} else if (target.type === 'object' || target.type === 'array') {
|
|
206
|
-
fail('$value object/array literals require a kernel-backed test');
|
|
207
|
-
}
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (ProjectionArithmetic.isArithmetic(expression)) {
|
|
211
|
-
ProjectionArithmetic.validate(expression, target, eventSchema, fail);
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
if (/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*$/.test(expression)) {
|
|
215
|
-
if (['true', 'True', 'false', 'False'].includes(expression)) {
|
|
216
|
-
fail('kernel resolves this expression as a boolean literal before event content');
|
|
217
|
-
}
|
|
218
|
-
if (expression.includes('.')) fail('nested event property paths require a kernel-backed test');
|
|
219
|
-
const source = this.propertyAt(eventSchema, expression);
|
|
220
|
-
if (!source) return fail(`event property '${expression}' is absent from the participating event schema`);
|
|
221
|
-
this.checkSchema(source, path, (_path, reason) => fail(reason));
|
|
222
|
-
if (accumulators?.has(destination) && !this.numeric(source)) {
|
|
223
|
-
fail('assigning non-numeric event properties to an arithmetic accumulator requires a kernel-backed test; missing values can clear it');
|
|
224
|
-
}
|
|
225
|
-
if (!this.compatible(source, target)) {
|
|
226
|
-
fail(`source '${expression}' (${source.type}${source.format ? `/${source.format}` : ''}) to target '${destination}' (${target.type}${target.format ? `/${target.format}` : ''}) requires a kernel-backed test`);
|
|
227
|
-
}
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
if (expression.startsWith('$context.')) {
|
|
231
|
-
return fail('is a legacy expression the kernel does not resolve; event-context mappings use $eventContext(...)');
|
|
232
|
-
}
|
|
233
|
-
fail('requires a kernel-backed test');
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
private static compatible(source: JsonSchema, target: JsonSchema): boolean {
|
|
237
|
-
if (JSON.stringify(source.type) === JSON.stringify(target.type) && source.format === target.format) {
|
|
238
|
-
return source.type !== 'object' && source.type !== 'array';
|
|
239
|
-
}
|
|
240
|
-
if (source.type === 'string' && !source.format && Array.isArray(target.type) &&
|
|
241
|
-
target.type[0] === 'string' && target.type[1] === 'null') return true;
|
|
242
|
-
if (source.type === 'string' && !source.format &&
|
|
243
|
-
((target.type === 'number' && (!target.format || target.format === 'double')) ||
|
|
244
|
-
(target.type === 'integer' && ['int32', 'uint32'].includes(target.format ?? '')))) return true;
|
|
245
|
-
if (source.type === 'string' && source.format === 'guid' && target.type === 'string' && !target.format) return true;
|
|
246
|
-
return source.type === 'integer' && ['int32', 'uint32'].includes(source.format ?? '') &&
|
|
247
|
-
target.type === 'number' && (!target.format || target.format === 'double');
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
private static checkInitialValue(value: unknown, target: JsonSchema, path: string, reject: (path: string, reason: string) => never): void {
|
|
251
|
-
if (value === null && Array.isArray(target.type) && target.type.includes('null')) return;
|
|
252
|
-
if (target.type === 'object' || target.type === 'array' || target.format === 'date-time') {
|
|
253
|
-
reject(path, 'initial object, array, or date-time values require a kernel-backed test');
|
|
254
|
-
}
|
|
255
|
-
if (target.type === 'integer' || target.type === 'number') {
|
|
256
|
-
if (typeof value !== 'number') reject(path, 'initial numeric value must be a JSON number');
|
|
257
|
-
const outsideIntegerRange = !Number.isSafeInteger(value) ||
|
|
258
|
-
(target.format === 'int32' && (value < -2147483648 || value > 2147483647)) ||
|
|
259
|
-
(target.format === 'uint32' && (value < 0 || value > 4294967295));
|
|
260
|
-
if (!Number.isFinite(value) || (target.type === 'integer' && outsideIntegerRange)) {
|
|
261
|
-
reject(path, 'initial numeric value is outside the supported finite/integer range');
|
|
262
|
-
}
|
|
263
|
-
} else if (target.type === 'boolean') {
|
|
264
|
-
if (typeof value !== 'boolean') reject(path, 'initial boolean value must be a JSON boolean');
|
|
265
|
-
} else if (target.type === 'string' || Array.isArray(target.type)) {
|
|
266
|
-
if (typeof value !== 'string') reject(path, 'initial string value must be a JSON string');
|
|
267
|
-
if (target.format === 'guid' && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(value)) {
|
|
268
|
-
reject(path, 'initial GUID value must be canonical lowercase text');
|
|
269
|
-
}
|
|
270
|
-
} else reject(path, 'initial value requires a kernel-backed test');
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
private static propertyAt(schema: JsonSchema, path: string): JsonSchema | undefined {
|
|
274
|
-
return path.split('.').reduce<JsonSchema | undefined>((current, segment) => current?.properties?.[segment], schema);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
private static numeric(schema: JsonSchema): boolean {
|
|
278
|
-
return (schema.type === 'number' && (!schema.format || schema.format === 'double')) ||
|
|
279
|
-
(schema.type === 'integer' && ['int32', 'uint32'].includes(schema.format ?? ''));
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
private static checkProtection(schema: JsonSchema, path: string, reject: (path: string, reason: string) => never): void {
|
|
283
|
-
if (schema.compliance?.length || schema.security?.length) reject(path, 'protected fields require a kernel-backed test');
|
|
284
|
-
for (const [name, property] of Object.entries(schema.properties ?? {})) this.checkProtection(property, `${path}.${name}`, reject);
|
|
285
|
-
if (schema.items) this.checkProtection(schema.items, `${path}.items`, reject);
|
|
286
|
-
if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
|
|
287
|
-
this.checkProtection(schema.additionalProperties, `${path}.additionalProperties`, reject);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
private static checkSchema(schema: JsonSchema, path: string, reject: (path: string, reason: string) => never): void {
|
|
292
|
-
if (schema.compliance?.length || schema.security?.length) reject(path, 'protected fields require a kernel-backed test');
|
|
293
|
-
if (!schema.type || schema.type === 'null' || (Array.isArray(schema.type) &&
|
|
294
|
-
(schema.type.length !== 2 || schema.type[0] !== 'string' || schema.type[1] !== 'null')) ||
|
|
295
|
-
(schema.format && !['guid', 'date-time', 'double', 'int32', 'uint32'].includes(schema.format)) ||
|
|
296
|
-
(schema.format === 'date-time' && schema.type !== 'string') ||
|
|
297
|
-
(schema.format === 'guid' && schema.type !== 'string') ||
|
|
298
|
-
(schema.format === 'double' && schema.type !== 'number') ||
|
|
299
|
-
(['int32', 'uint32'].includes(schema.format ?? '') && schema.type !== 'integer')) {
|
|
300
|
-
reject(path, `schema type/format '${schema.type ?? 'unknown'}${schema.format ? `/${schema.format}` : ''}' requires a kernel-backed test`);
|
|
301
|
-
}
|
|
302
|
-
if (schema.type === 'integer' && !this.numeric(schema)) reject(path, 'integer width requires a kernel-backed test');
|
|
303
|
-
if (schema.type === 'array' && schema.items) this.checkSchema(schema.items, path, reject);
|
|
304
|
-
if (schema.type === 'object') {
|
|
305
|
-
for (const property of Object.values(schema.properties ?? {})) this.checkSchema(property, path, reject);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
52
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
/** Reports the first unsupported operation at its original contract path. */
|
|
5
|
+
export type ProjectionCapabilityReject = (path: string, reason: string, fallback?: string) => never;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import type { ProjectionDefinition } from '@cratis/chronicle.contracts';
|
|
5
|
+
import type { CompiledProjectionDefinitions } from '../../projections/CompiledProjectionDefinitions.js';
|
|
6
|
+
import { UnsupportedProjectionOperation } from './UnsupportedProjectionOperation.js';
|
|
7
|
+
|
|
8
|
+
/** Resolves diagnostics back to their original declaration, including inferred AutoMap. */
|
|
9
|
+
export class ProjectionCapabilityReporter {
|
|
10
|
+
constructor(private readonly compiled: CompiledProjectionDefinitions, private readonly definition: ProjectionDefinition) {}
|
|
11
|
+
|
|
12
|
+
readonly reject = (path: string, reason: string, fallback?: string): never => {
|
|
13
|
+
const model = String(this.definition.ReadModel ?? this.definition.Identifier ?? '<unknown>');
|
|
14
|
+
throw new UnsupportedProjectionOperation(model, path, this.declaration(path, fallback), reason);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
private declaration(path: string, fallback?: string): string {
|
|
18
|
+
const provenance = this.compiled.provenance.get(this.definition);
|
|
19
|
+
const exact = provenance?.find(entry => entry.contractPath === path)?.declaration;
|
|
20
|
+
const join = provenance?.find(entry => entry.contractPath.startsWith('Join[') && path.startsWith(`${entry.contractPath}.`))?.declaration;
|
|
21
|
+
return exact ?? join ?? fallback ?? this.inferred(path);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private inferred(path: string): string {
|
|
25
|
+
const source = this.compiled.provenance.get(this.definition)?.find(entry => entry.contractPath.startsWith('From['))?.declaration ?? '.from';
|
|
26
|
+
if (path.includes('.AutoMap.')) return `${source} (AutoMap)`;
|
|
27
|
+
if (path.startsWith('InitialModelState')) return '.withInitialValues';
|
|
28
|
+
if (path.startsWith('ReadModel')) return source;
|
|
29
|
+
return 'contract';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { AutoMap } from '@cratis/chronicle.contracts';
|
|
5
|
+
import { EventSequenceId } from '../../eventSequences/EventSequenceId.js';
|
|
6
|
+
import type { ContractEventType } from '../../projections/declarative/ProjectionBuilderCore.js';
|
|
7
|
+
import { eventContractPath } from '../../projections/eventContractPath.js';
|
|
8
|
+
import type { ProjectionCapabilityProvenance } from '../../projections/ProjectionCapabilityProvenance.js';
|
|
9
|
+
import type { ProjectionCapabilityReject } from './ProjectionCapabilityReject.js';
|
|
10
|
+
|
|
11
|
+
/** Subscription shapes that must be rejected before inspecting any model schema. */
|
|
12
|
+
export class ProjectionDefinitionCapabilities {
|
|
13
|
+
static validate(wire: Record<string, unknown>, provenance: readonly ProjectionCapabilityProvenance[], reject: ProjectionCapabilityReject): void {
|
|
14
|
+
if (provenance.find(entry => entry.contractPath === 'Variant')) reject('Variant', 'variants require a kernel-backed test');
|
|
15
|
+
this.subscription(wire, reject);
|
|
16
|
+
for (const section of ['Nested', 'RemovedWithJoin']) this.unsupportedSection(wire, section, reject);
|
|
17
|
+
if ((wire.FromEvery as unknown[] | undefined)?.length) reject('FromEvery', 'derivative projections require a kernel-backed test');
|
|
18
|
+
if (wire.FromEventProperty) reject('FromEventProperty', 'event-property subscriptions require a kernel-backed test');
|
|
19
|
+
this.all(wire, provenance, reject);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private static subscription(wire: Record<string, unknown>, reject: ProjectionCapabilityReject): void {
|
|
23
|
+
if (wire.IsActive === false) reject('IsActive', 'passive projections require a kernel-backed test');
|
|
24
|
+
if (wire.SubscribesToAllEvents === true) reject('SubscribesToAllEvents', 'subscribe-to-all projections require a kernel-backed test');
|
|
25
|
+
if (wire.EventSequenceId !== EventSequenceId.eventLog.value) reject('EventSequenceId', 'non-default event sequences require a kernel-backed test');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private static unsupportedSection(wire: Record<string, unknown>, section: string, reject: ProjectionCapabilityReject): void {
|
|
29
|
+
const value = wire[section];
|
|
30
|
+
const paths = Array.isArray(value) ? value.map((entry: { Key: ContractEventType }) => eventContractPath(section, entry.Key))
|
|
31
|
+
: Object.keys(value as Record<string, unknown> ?? {}).map(property => `${section}.${property}`);
|
|
32
|
+
if (paths.length) reject(paths[0], `${section === 'Nested' ? 'nested projections' : 'removedWithJoin'} require a kernel-backed test`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private static all(wire: Record<string, unknown>, provenance: readonly ProjectionCapabilityProvenance[], reject: ProjectionCapabilityReject): void {
|
|
36
|
+
const all = wire.All as { Properties?: Record<string, string>; IncludeChildren?: boolean; AutoMap?: AutoMap } | undefined;
|
|
37
|
+
if (provenance.some(entry => entry.contractPath === 'All') || this.hasAllMappings(all)) {
|
|
38
|
+
reject('All', 'fromEvery/all subscriptions require a kernel-backed test');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private static hasAllMappings(all: { Properties?: Record<string, string>; IncludeChildren?: boolean; AutoMap?: AutoMap } | undefined): boolean {
|
|
43
|
+
return !!(all?.IncludeChildren || Object.keys(all?.Properties ?? {}).length || all?.AutoMap === AutoMap.Enabled);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import type { ContractEventType } from '../../projections/declarative/ProjectionBuilderCore.js';
|
|
5
|
+
import { getEventTypeMapKey } from '../../projections/modelBound/childrenAndNestedBuilder.js';
|
|
6
|
+
import type { ProjectionEventSchema } from '../../projections/ProjectionEventSchema.js';
|
|
7
|
+
import type { JsonSchema } from '../../schemas/JsonSchema.js';
|
|
8
|
+
import type { ProjectionCapabilityReject } from './ProjectionCapabilityReject.js';
|
|
9
|
+
|
|
10
|
+
/** Tracks generations across joins, roots, removals, and children in validation order. */
|
|
11
|
+
export class ProjectionEventSchemaResolver {
|
|
12
|
+
private readonly generations = new Map<string, number>();
|
|
13
|
+
|
|
14
|
+
constructor(private readonly catalog: ReadonlyMap<string, ProjectionEventSchema>, private readonly reject: ProjectionCapabilityReject) {}
|
|
15
|
+
|
|
16
|
+
readonly require = (eventType: ContractEventType, path: string): JsonSchema => {
|
|
17
|
+
const previous = this.generations.get(eventType.Id);
|
|
18
|
+
if (previous !== undefined && previous !== eventType.Generation) this.reject(path, 'multiple generations of the same event-type id require a kernel-backed test');
|
|
19
|
+
this.generations.set(eventType.Id, eventType.Generation);
|
|
20
|
+
const event = this.catalog.get(getEventTypeMapKey(eventType)) ?? this.reject(path, 'participating event schema is unavailable');
|
|
21
|
+
return event.schema;
|
|
22
|
+
};
|
|
23
|
+
}
|