@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
|
@@ -0,0 +1,218 @@
|
|
|
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 { chai, describe, it } from 'vitest';
|
|
6
|
+
import { graph } from '../graphs/graph.js';
|
|
7
|
+
import { GraphNameRequired } from '../graphs/GraphNameRequired.js';
|
|
8
|
+
import { follows } from '../graphs/views/follows.js';
|
|
9
|
+
import { fromEdge } from '../graphs/views/fromEdge.js';
|
|
10
|
+
import { GraphEdgeDirection } from '../graphs/views/GraphEdgeDirection.js';
|
|
11
|
+
import { GraphViewCardinality } from '../graphs/views/GraphViewCardinality.js';
|
|
12
|
+
import { GraphViewDefinitionSerializer } from '../graphs/views/GraphViewDefinitionSerializer.js';
|
|
13
|
+
import { GraphViewMemberKind } from '../graphs/views/GraphViewMemberKind.js';
|
|
14
|
+
import type { GraphViewRelationMember } from '../graphs/views/GraphViewRelationMember.js';
|
|
15
|
+
import { GraphViewReason } from '../graphs/views/GraphViewReason.js';
|
|
16
|
+
import { viewKey } from '../graphs/views/viewKey.js';
|
|
17
|
+
import { viewOf } from '../graphs/views/viewOf.js';
|
|
18
|
+
import { viewProperty } from '../graphs/views/viewProperty.js';
|
|
19
|
+
import { ViewRootNotANode } from '../graphs/views/ViewRootNotANode.js';
|
|
20
|
+
import { discoverGraphs } from './given/a_discovered_graph.js';
|
|
21
|
+
import { aView, anOrganization, discoverViews } from './given/a_graph_with_views.js';
|
|
22
|
+
import { Group, MemberOf, Person } from './given/organization.js';
|
|
23
|
+
|
|
24
|
+
chai.should();
|
|
25
|
+
|
|
26
|
+
describe('when a view reads properties of its root node', () => {
|
|
27
|
+
it('should read the key from the key of the node and the others by name without regard to case', async () => {
|
|
28
|
+
const organization = anOrganization('Properties');
|
|
29
|
+
const view = aView(organization.graphName, 'Person', () => organization.Person,
|
|
30
|
+
['id', viewKey()], ['Name', viewProperty()], ['fullName', viewProperty('NAME')]);
|
|
31
|
+
const graphs = await discoverViews(organization, view);
|
|
32
|
+
graphs.failures.size.should.equal(0);
|
|
33
|
+
graphs.viewDefinitions[0].views[0].members.should.deep.equal([
|
|
34
|
+
{ name: 'id', kind: GraphViewMemberKind.Property, source: 'personId' },
|
|
35
|
+
{ name: 'Name', kind: GraphViewMemberKind.Property, source: 'name' },
|
|
36
|
+
{ name: 'fullName', kind: GraphViewMemberKind.Property, source: 'name' }
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should keep the members in the order they are declared', async () => {
|
|
41
|
+
const organization = anOrganization('Order');
|
|
42
|
+
const view = aView(organization.graphName, 'Person', () => organization.Person,
|
|
43
|
+
['name', viewProperty()], ['id', viewKey()]);
|
|
44
|
+
const graphs = await discoverViews(organization, view);
|
|
45
|
+
graphs.viewDefinitions[0].views[0].members.map(member => member.name).should.deep.equal(['name', 'id']);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('when a relation follows an edge', () => {
|
|
50
|
+
it('should derive the outgoing direction and a many cardinality when the root is the source of the edge', async () => {
|
|
51
|
+
const organization = anOrganization('Outgoing');
|
|
52
|
+
const group = aView(organization.graphName, 'GroupSummary', () => organization.Group, ['id', viewKey()]);
|
|
53
|
+
const view = aView(organization.graphName, 'PersonWithGroups', () => organization.Person, ['groups', follows(() => organization.MemberOf, () => group)]);
|
|
54
|
+
const graphs = await discoverViews(organization, group, view);
|
|
55
|
+
graphs.failures.size.should.equal(0);
|
|
56
|
+
const relation = graphs.viewDefinitions[0].views.find(candidate => candidate.name === 'PersonWithGroups')!.members[0] as GraphViewRelationMember;
|
|
57
|
+
relation.should.deep.equal({
|
|
58
|
+
name: 'groups', kind: GraphViewMemberKind.Relation, edge: 'MEMBER_OF',
|
|
59
|
+
direction: GraphEdgeDirection.Outgoing, cardinality: GraphViewCardinality.Many, view: 'GroupSummary'
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should derive the incoming direction when the root is the target of the edge', async () => {
|
|
64
|
+
const organization = anOrganization('Incoming');
|
|
65
|
+
const person = aView(organization.graphName, 'PersonSummary', () => organization.Person, ['id', viewKey()]);
|
|
66
|
+
const view = aView(organization.graphName, 'GroupWithMembers', () => organization.Group, ['members', follows('MEMBER_OF', () => person)]);
|
|
67
|
+
const graphs = await discoverViews(organization, person, view);
|
|
68
|
+
graphs.failures.size.should.equal(0);
|
|
69
|
+
const relation = graphs.viewDefinitions[0].views.find(candidate => candidate.name === 'GroupWithMembers')!.members[0] as GraphViewRelationMember;
|
|
70
|
+
relation.direction.should.equal(GraphEdgeDirection.Incoming);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should take the explicit direction of a self edge and the declared single cardinality', async () => {
|
|
74
|
+
const organization = anOrganization('SelfEdge');
|
|
75
|
+
const person = aView(organization.graphName, 'PersonSummary', () => organization.Person, ['id', viewKey()]);
|
|
76
|
+
const view = aView(organization.graphName, 'PersonWithKnownBy', () => organization.Person,
|
|
77
|
+
['knownBy', follows(() => organization.Knows, () => person, { direction: GraphEdgeDirection.Incoming, cardinality: GraphViewCardinality.One })]);
|
|
78
|
+
const graphs = await discoverViews(organization, person, view);
|
|
79
|
+
graphs.failures.size.should.equal(0);
|
|
80
|
+
const relation = graphs.viewDefinitions[0].views.find(candidate => candidate.name === 'PersonWithKnownBy')!.members[0] as GraphViewRelationMember;
|
|
81
|
+
relation.direction.should.equal(GraphEdgeDirection.Incoming);
|
|
82
|
+
relation.cardinality.should.equal(GraphViewCardinality.One);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should name the view of the relation by its view name, which may differ from its class name', async () => {
|
|
86
|
+
const organization = anOrganization('NamedTarget');
|
|
87
|
+
class Summary { id = ''; }
|
|
88
|
+
viewOf(() => organization.Group, { name: 'GroupCard' })(Summary);
|
|
89
|
+
viewKey()(Summary.prototype, 'id');
|
|
90
|
+
const view = aView(organization.graphName, 'PersonWithGroups', () => organization.Person, ['groups', follows(() => organization.MemberOf, () => Summary)]);
|
|
91
|
+
graph(organization.graphName)(Summary);
|
|
92
|
+
const graphs = await discoverViews(organization, Summary, view);
|
|
93
|
+
graphs.failures.size.should.equal(0);
|
|
94
|
+
(graphs.viewDefinitions[0].views.find(candidate => candidate.name === 'PersonWithGroups')!.members[0] as GraphViewRelationMember).view.should.equal('GroupCard');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should read the property of the edge it follows into the view', async () => {
|
|
98
|
+
const organization = anOrganization('EdgeProperties');
|
|
99
|
+
const membership = aView(organization.graphName, 'Membership', () => organization.Group, ['id', viewKey()], ['joined', fromEdge('SINCE')]);
|
|
100
|
+
const view = aView(organization.graphName, 'PersonWithGroups', () => organization.Person, ['groups', follows(() => organization.MemberOf, () => membership)]);
|
|
101
|
+
const graphs = await discoverViews(organization, membership, view);
|
|
102
|
+
graphs.failures.size.should.equal(0);
|
|
103
|
+
graphs.viewDefinitions[0].views.find(candidate => candidate.name === 'Membership')!.members[1].should.deep.equal(
|
|
104
|
+
{ name: 'joined', kind: GraphViewMemberKind.EdgeProperty, source: 'since' });
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('when members are declared more than once', () => {
|
|
109
|
+
it('should refuse to declare one member as two kinds', () => {
|
|
110
|
+
class Confused { id = ''; }
|
|
111
|
+
(() => {
|
|
112
|
+
viewKey()(Confused.prototype, 'id');
|
|
113
|
+
viewProperty()(Confused.prototype, 'id');
|
|
114
|
+
}).should.throw(TypeError, /one kind of member/);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('when a graph has an invalid view', () => {
|
|
119
|
+
it('should withhold the definition of that graph only and register every graph', async () => {
|
|
120
|
+
const good = anOrganization('Good');
|
|
121
|
+
const goodView = aView(good.graphName, 'Person', () => good.Person, ['id', viewKey()]);
|
|
122
|
+
const bad = anOrganization('Bad');
|
|
123
|
+
const badView = aView(bad.graphName, 'Broken', () => bad.Person, ['nickname', viewProperty()]);
|
|
124
|
+
const siblingOfBad = aView(bad.graphName, 'Fine', () => bad.Person, ['id', viewKey()]);
|
|
125
|
+
const result = await discoverGraphs([...good.elements, ...bad.elements], [], 'Neo4j', [goodView, badView, siblingOfBad]);
|
|
126
|
+
result.graphs.registrations.map(_ => _.graphName).should.have.members(['Good', 'Bad']);
|
|
127
|
+
result.graphs.viewDefinitions.map(_ => _.graph).should.deep.equal(['Good']);
|
|
128
|
+
result.graphs.failures.has(badView).should.be.true;
|
|
129
|
+
result.graphs.failures.has(siblingOfBad).should.be.false;
|
|
130
|
+
result.graphs.failures.has(goodView).should.be.false;
|
|
131
|
+
result.readModelRequests.length.should.equal(0);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('should register the graphs when they are registered', async () => {
|
|
135
|
+
const bad = anOrganization('BadRegistered');
|
|
136
|
+
const badView = aView(bad.graphName, 'Broken', () => bad.Person, ['nickname', viewProperty()]);
|
|
137
|
+
const result = await discoverGraphs(bad.elements, [], 'Neo4j', [badView]);
|
|
138
|
+
await result.graphs.register();
|
|
139
|
+
result.readModelRequests[0].ReadModels.map(readModel => readModel.Type.Identifier).should.deep.equal(['BadRegistered']);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('when a view names a graph that is not registered', () => {
|
|
144
|
+
it('should fail with ViewRootNotANode', async () => {
|
|
145
|
+
const organization = anOrganization('Registered');
|
|
146
|
+
const stray = anOrganization('Unregistered');
|
|
147
|
+
const view = aView(stray.graphName, 'Person', () => stray.Person, ['id', viewKey()]);
|
|
148
|
+
const graphs = await discoverViews(organization, view);
|
|
149
|
+
graphs.failures.get(view)!.should.be.instanceOf(ViewRootNotANode).and.have.property('reason', GraphViewReason.ViewRootNotANode);
|
|
150
|
+
graphs.viewDefinitions.should.have.lengthOf(0);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('when a view does not say which graph it belongs to', () => {
|
|
155
|
+
it('should fail with GraphNameRequired', async () => {
|
|
156
|
+
const organization = anOrganization('Homeless');
|
|
157
|
+
class Homeless { id = ''; }
|
|
158
|
+
viewOf(() => organization.Person)(Homeless);
|
|
159
|
+
viewKey()(Homeless.prototype, 'id');
|
|
160
|
+
const graphs = await discoverViews(organization, Homeless);
|
|
161
|
+
graphs.failures.get(Homeless)!.should.be.instanceOf(GraphNameRequired);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('when discovering a graph that has no views', () => {
|
|
166
|
+
it('should register exactly what it registered without views, and emit no view definition', async () => {
|
|
167
|
+
const alone = await discoverGraphs([Person, Group, MemberOf]);
|
|
168
|
+
const organization = anOrganization('Elsewhere');
|
|
169
|
+
const view = aView(organization.graphName, 'Person', () => organization.Person, ['id', viewKey()]);
|
|
170
|
+
const beside = await discoverGraphs([Person, Group, MemberOf, ...organization.elements], [], 'Neo4j', [view]);
|
|
171
|
+
|
|
172
|
+
alone.graphs.viewDefinitions.should.have.lengthOf(0);
|
|
173
|
+
alone.graphs.failures.size.should.equal(0);
|
|
174
|
+
const registrationOf = (graphs: typeof alone.graphs) => graphs.registrations.find(_ => _.graphName === 'Organization');
|
|
175
|
+
registrationOf(beside.graphs)!.should.deep.equal(registrationOf(alone.graphs));
|
|
176
|
+
beside.graphs.viewDefinitions.map(_ => _.graph).should.deep.equal(['Elsewhere']);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
describe('when serializing a definition', () => {
|
|
181
|
+
const serializer = new GraphViewDefinitionSerializer();
|
|
182
|
+
|
|
183
|
+
it('should sort the views by name in ordinal order and keep the members in declaration order', () => {
|
|
184
|
+
const member = (name: string) => ({ name, kind: GraphViewMemberKind.Property as const, source: name });
|
|
185
|
+
const text = serializer.serialize({
|
|
186
|
+
graph: 'G',
|
|
187
|
+
views: [
|
|
188
|
+
{ name: 'alpha', root: 'N', members: [member('b'), member('a')] },
|
|
189
|
+
{ name: 'Zulu', root: 'N', members: [] }
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
text.should.equal([
|
|
193
|
+
'{',
|
|
194
|
+
' "graph": "G",',
|
|
195
|
+
' "views": [',
|
|
196
|
+
' {',
|
|
197
|
+
' "name": "Zulu",',
|
|
198
|
+
' "root": "N",',
|
|
199
|
+
' "members": []',
|
|
200
|
+
' },',
|
|
201
|
+
' {',
|
|
202
|
+
' "name": "alpha",',
|
|
203
|
+
' "root": "N",',
|
|
204
|
+
' "members": [',
|
|
205
|
+
' { "name": "b", "kind": "property", "source": "b" },',
|
|
206
|
+
' { "name": "a", "kind": "property", "source": "a" }',
|
|
207
|
+
' ]',
|
|
208
|
+
' }',
|
|
209
|
+
' ]',
|
|
210
|
+
'}',
|
|
211
|
+
''
|
|
212
|
+
].join('\n'));
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should write a definition without views', () => {
|
|
216
|
+
serializer.serialize({ graph: 'G', views: [] }).should.equal('{\n "graph": "G",\n "views": []\n}\n');
|
|
217
|
+
});
|
|
218
|
+
});
|
|
@@ -0,0 +1,229 @@
|
|
|
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 { chai, describe, it } from 'vitest';
|
|
6
|
+
import { graph } from '../graphs/graph.js';
|
|
7
|
+
import { graphKey } from '../graphs/graphKey.js';
|
|
8
|
+
import { node } from '../graphs/node.js';
|
|
9
|
+
import { AmbiguousDirection } from '../graphs/views/AmbiguousDirection.js';
|
|
10
|
+
import { DuplicateViewName } from '../graphs/views/DuplicateViewName.js';
|
|
11
|
+
import { EdgeNotIncidentOnRoot } from '../graphs/views/EdgeNotIncidentOnRoot.js';
|
|
12
|
+
import { EdgePropertyViewNotUsedAsTarget } from '../graphs/views/EdgePropertyViewNotUsedAsTarget.js';
|
|
13
|
+
import { EdgePropertyViewSharedAcrossEdges } from '../graphs/views/EdgePropertyViewSharedAcrossEdges.js';
|
|
14
|
+
import { follows } from '../graphs/views/follows.js';
|
|
15
|
+
import { fromEdge } from '../graphs/views/fromEdge.js';
|
|
16
|
+
import { GraphEdgeDirection } from '../graphs/views/GraphEdgeDirection.js';
|
|
17
|
+
import { GraphViewReason } from '../graphs/views/GraphViewReason.js';
|
|
18
|
+
import { RecursiveView } from '../graphs/views/RecursiveView.js';
|
|
19
|
+
import { RelationTargetNotAView } from '../graphs/views/RelationTargetNotAView.js';
|
|
20
|
+
import { TargetLabelMismatch } from '../graphs/views/TargetLabelMismatch.js';
|
|
21
|
+
import { UnknownEdge } from '../graphs/views/UnknownEdge.js';
|
|
22
|
+
import { UnknownEdgeProperty } from '../graphs/views/UnknownEdgeProperty.js';
|
|
23
|
+
import { UnknownNodeProperty } from '../graphs/views/UnknownNodeProperty.js';
|
|
24
|
+
import { viewKey } from '../graphs/views/viewKey.js';
|
|
25
|
+
import { viewOf } from '../graphs/views/viewOf.js';
|
|
26
|
+
import { ViewIsAlsoSchema } from '../graphs/views/ViewIsAlsoSchema.js';
|
|
27
|
+
import { viewProperty } from '../graphs/views/viewProperty.js';
|
|
28
|
+
import { ViewRootNotANode } from '../graphs/views/ViewRootNotANode.js';
|
|
29
|
+
import { aView, anOrganization, discoverViews } from './given/a_graph_with_views.js';
|
|
30
|
+
|
|
31
|
+
chai.should();
|
|
32
|
+
|
|
33
|
+
describe('when a view is anchored at a type that is not a node of the graph', () => {
|
|
34
|
+
it('should fail with ViewRootNotANode', async () => {
|
|
35
|
+
const organization = anOrganization('RootNotANode');
|
|
36
|
+
class Stranger { strangerId = ''; }
|
|
37
|
+
const view = aView(organization.graphName, 'Stranger', () => Stranger, ['id', viewKey()]);
|
|
38
|
+
const graphs = await discoverViews(organization, view);
|
|
39
|
+
graphs.failures.get(view)!.should.be.instanceOf(ViewRootNotANode).and.have.property('reason', GraphViewReason.ViewRootNotANode);
|
|
40
|
+
graphs.viewDefinitions.should.have.lengthOf(0);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('when a view is also a node', () => {
|
|
45
|
+
it('should fail with ViewIsAlsoSchema and still register the graph', async () => {
|
|
46
|
+
const organization = anOrganization('AlsoSchema');
|
|
47
|
+
class Both { bothId = ''; }
|
|
48
|
+
graph(organization.graphName)(Both);
|
|
49
|
+
node()(Both);
|
|
50
|
+
graphKey()(Both.prototype, 'bothId');
|
|
51
|
+
viewOf(() => Both)(Both);
|
|
52
|
+
viewKey()(Both.prototype, 'bothId');
|
|
53
|
+
const graphs = await discoverViews({ ...organization, elements: [...organization.elements, Both] }, Both);
|
|
54
|
+
graphs.failures.get(Both)!.should.be.instanceOf(ViewIsAlsoSchema).and.have.property('reason', GraphViewReason.ViewIsAlsoSchema);
|
|
55
|
+
graphs.registrations.map(_ => _.graphName).should.deep.equal([organization.graphName]);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('when two views of a graph have the same name', () => {
|
|
60
|
+
it('should fail the second with DuplicateViewName', async () => {
|
|
61
|
+
const organization = anOrganization('Duplicates');
|
|
62
|
+
const first = aView(organization.graphName, 'Summary', () => organization.Person, ['id', viewKey()]);
|
|
63
|
+
const second = aView(organization.graphName, 'Summary', () => organization.Group, ['id', viewKey()]);
|
|
64
|
+
const graphs = await discoverViews(organization, first, second);
|
|
65
|
+
graphs.failures.has(first).should.be.false;
|
|
66
|
+
graphs.failures.get(second)!.should.be.instanceOf(DuplicateViewName).and.have.property('reason', GraphViewReason.DuplicateViewName);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should accept the same class name once a view is given another name', async () => {
|
|
70
|
+
const organization = anOrganization('Renamed');
|
|
71
|
+
class Summary { id = ''; }
|
|
72
|
+
graph(organization.graphName)(Summary);
|
|
73
|
+
viewOf(() => organization.Person, { name: 'PersonSummary' })(Summary);
|
|
74
|
+
viewKey()(Summary.prototype, 'id');
|
|
75
|
+
const other = aView(organization.graphName, 'Summary', () => organization.Group, ['id', viewKey()]);
|
|
76
|
+
const graphs = await discoverViews(organization, Summary, other);
|
|
77
|
+
graphs.failures.size.should.equal(0);
|
|
78
|
+
graphs.viewDefinitions[0].views.map(view => view.name).should.deep.equal(['PersonSummary', 'Summary']);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('when a view reads a property the node does not declare', () => {
|
|
83
|
+
it('should fail with UnknownNodeProperty', async () => {
|
|
84
|
+
const organization = anOrganization('UnknownNodeProperty');
|
|
85
|
+
const view = aView(organization.graphName, 'Nicknamed', () => organization.Person, ['nickname', viewProperty()]);
|
|
86
|
+
const graphs = await discoverViews(organization, view);
|
|
87
|
+
graphs.failures.get(view)!.should.be.instanceOf(UnknownNodeProperty).and.have.property('reason', GraphViewReason.UnknownNodeProperty);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should fail when the explicit source is not a property of the node', async () => {
|
|
91
|
+
const organization = anOrganization('UnknownSource');
|
|
92
|
+
const view = aView(organization.graphName, 'Titled', () => organization.Person, ['title', viewProperty('fullName')]);
|
|
93
|
+
const graphs = await discoverViews(organization, view);
|
|
94
|
+
graphs.failures.get(view)!.should.be.instanceOf(UnknownNodeProperty).and.have.property('message').that.includes("'fullName'");
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('when a relation follows an edge the graph does not declare', () => {
|
|
99
|
+
it('should fail with UnknownEdge for an edge type string', async () => {
|
|
100
|
+
const organization = anOrganization('UnknownEdgeString');
|
|
101
|
+
const target = aView(organization.graphName, 'GroupSummary', () => organization.Group, ['id', viewKey()]);
|
|
102
|
+
const view = aView(organization.graphName, 'Lonely', () => organization.Person, ['groups', follows('LIKES', () => target)]);
|
|
103
|
+
const graphs = await discoverViews(organization, target, view);
|
|
104
|
+
graphs.failures.get(view)!.should.be.instanceOf(UnknownEdge).and.have.property('reason', GraphViewReason.UnknownEdge);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should fail with UnknownEdge for a class that is not an edge of the graph', async () => {
|
|
108
|
+
const organization = anOrganization('UnknownEdgeClass');
|
|
109
|
+
class Elsewhere { fromId = ''; toId = ''; }
|
|
110
|
+
const target = aView(organization.graphName, 'GroupSummary', () => organization.Group, ['id', viewKey()]);
|
|
111
|
+
const view = aView(organization.graphName, 'Lonely', () => organization.Person, ['groups', follows(() => Elsewhere, () => target)]);
|
|
112
|
+
const graphs = await discoverViews(organization, target, view);
|
|
113
|
+
graphs.failures.get(view)!.should.be.instanceOf(UnknownEdge);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('when a view reads a property the edge does not declare', () => {
|
|
118
|
+
it('should fail with UnknownEdgeProperty', async () => {
|
|
119
|
+
const organization = anOrganization('UnknownEdgeProperty');
|
|
120
|
+
const target = aView(organization.graphName, 'Membership', () => organization.Group, ['id', viewKey()], ['weight', fromEdge()]);
|
|
121
|
+
const view = aView(organization.graphName, 'PersonWithGroups', () => organization.Person, ['groups', follows(() => organization.MemberOf, () => target)]);
|
|
122
|
+
const graphs = await discoverViews(organization, target, view);
|
|
123
|
+
graphs.failures.get(target)!.should.be.instanceOf(UnknownEdgeProperty).and.have.property('reason', GraphViewReason.UnknownEdgeProperty);
|
|
124
|
+
graphs.failures.has(view).should.be.false;
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('when a relation follows an edge that does not start or end at the root of the view', () => {
|
|
129
|
+
it('should fail with EdgeNotIncidentOnRoot', async () => {
|
|
130
|
+
const organization = anOrganization('NotIncident');
|
|
131
|
+
const target = aView(organization.graphName, 'PersonSummary', () => organization.Person, ['id', viewKey()]);
|
|
132
|
+
const view = aView(organization.graphName, 'GroupWithFriends', () => organization.Group, ['friends', follows(() => organization.Knows, () => target)]);
|
|
133
|
+
const graphs = await discoverViews(organization, target, view);
|
|
134
|
+
graphs.failures.get(view)!.should.be.instanceOf(EdgeNotIncidentOnRoot).and.have.property('reason', GraphViewReason.EdgeNotIncidentOnRoot);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should fail when the explicit direction is one the edge cannot be followed in from the root', async () => {
|
|
138
|
+
const organization = anOrganization('WrongDirection');
|
|
139
|
+
const target = aView(organization.graphName, 'GroupSummary', () => organization.Group, ['id', viewKey()]);
|
|
140
|
+
const view = aView(organization.graphName, 'PersonWithGroups', () => organization.Person,
|
|
141
|
+
['groups', follows(() => organization.MemberOf, () => target, { direction: GraphEdgeDirection.Incoming })]);
|
|
142
|
+
const graphs = await discoverViews(organization, target, view);
|
|
143
|
+
graphs.failures.get(view)!.should.be.instanceOf(EdgeNotIncidentOnRoot);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('when a relation follows a self edge without a direction', () => {
|
|
148
|
+
it('should fail with AmbiguousDirection', async () => {
|
|
149
|
+
const organization = anOrganization('Ambiguous');
|
|
150
|
+
const target = aView(organization.graphName, 'Friend', () => organization.Person, ['id', viewKey()]);
|
|
151
|
+
const view = aView(organization.graphName, 'PersonWithFriends', () => organization.Person, ['friends', follows(() => organization.Knows, () => target)]);
|
|
152
|
+
const graphs = await discoverViews(organization, target, view);
|
|
153
|
+
graphs.failures.get(view)!.should.be.instanceOf(AmbiguousDirection).and.have.property('reason', GraphViewReason.AmbiguousDirection);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('when the target view is anchored at a label that is not at the far end of the edge', () => {
|
|
158
|
+
it('should fail with TargetLabelMismatch', async () => {
|
|
159
|
+
const organization = anOrganization('Mismatch');
|
|
160
|
+
const target = aView(organization.graphName, 'PersonSummary', () => organization.Person, ['id', viewKey()]);
|
|
161
|
+
const view = aView(organization.graphName, 'PersonWithGroups', () => organization.Person, ['groups', follows(() => organization.MemberOf, () => target)]);
|
|
162
|
+
const graphs = await discoverViews(organization, target, view);
|
|
163
|
+
graphs.failures.get(view)!.should.be.instanceOf(TargetLabelMismatch).and.have.property('reason', GraphViewReason.TargetLabelMismatch);
|
|
164
|
+
graphs.failures.has(target).should.be.false;
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe('when a relation yields a type that is not a view', () => {
|
|
169
|
+
it('should fail with RelationTargetNotAView', async () => {
|
|
170
|
+
const organization = anOrganization('NotAView');
|
|
171
|
+
class Plain { id = ''; }
|
|
172
|
+
const view = aView(organization.graphName, 'PersonWithGroups', () => organization.Person, ['groups', follows(() => organization.MemberOf, () => Plain)]);
|
|
173
|
+
const graphs = await discoverViews(organization, view);
|
|
174
|
+
graphs.failures.get(view)!.should.be.instanceOf(RelationTargetNotAView).and.have.property('reason', GraphViewReason.RelationTargetNotAView);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should fail when the view belongs to another graph', async () => {
|
|
178
|
+
const organization = anOrganization('Here');
|
|
179
|
+
const elsewhere = anOrganization('There');
|
|
180
|
+
const foreign = aView(elsewhere.graphName, 'GroupSummary', () => elsewhere.Group, ['id', viewKey()]);
|
|
181
|
+
const view = aView(organization.graphName, 'PersonWithGroups', () => organization.Person, ['groups', follows(() => organization.MemberOf, () => foreign)]);
|
|
182
|
+
const graphs = await discoverViews(organization, view);
|
|
183
|
+
graphs.failures.get(view)!.should.be.instanceOf(RelationTargetNotAView);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('when a view contains itself', () => {
|
|
188
|
+
it('should fail directly with RecursiveView', async () => {
|
|
189
|
+
const organization = anOrganization('DirectRecursion');
|
|
190
|
+
const view = aView(organization.graphName, 'Friends', () => organization.Person,
|
|
191
|
+
['friends', follows(() => organization.Knows, () => view, { direction: GraphEdgeDirection.Outgoing })]);
|
|
192
|
+
const graphs = await discoverViews(organization, view);
|
|
193
|
+
graphs.failures.get(view)!.should.be.instanceOf(RecursiveView).and.have.property('reason', GraphViewReason.RecursiveView);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('should fail transitively with RecursiveView, naming the cycle', async () => {
|
|
197
|
+
const organization = anOrganization('TransitiveRecursion');
|
|
198
|
+
const person = aView(organization.graphName, 'PersonWithGroups', () => organization.Person,
|
|
199
|
+
['groups', follows(() => organization.MemberOf, () => group)]);
|
|
200
|
+
const group = aView(organization.graphName, 'GroupWithMembers', () => organization.Group,
|
|
201
|
+
['members', follows(() => organization.MemberOf, () => person)]);
|
|
202
|
+
const graphs = await discoverViews(organization, person, group);
|
|
203
|
+
graphs.failures.get(person)!.should.be.instanceOf(RecursiveView).and.have.property('message').that.includes('PersonWithGroups -> GroupWithMembers -> PersonWithGroups');
|
|
204
|
+
graphs.failures.get(group)!.should.be.instanceOf(RecursiveView);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe('when a view reads edge properties but no relation yields it', () => {
|
|
209
|
+
it('should fail with EdgePropertyViewNotUsedAsTarget', async () => {
|
|
210
|
+
const organization = anOrganization('NotUsed');
|
|
211
|
+
const view = aView(organization.graphName, 'Membership', () => organization.Group, ['id', viewKey()], ['since', fromEdge()]);
|
|
212
|
+
const graphs = await discoverViews(organization, view);
|
|
213
|
+
graphs.failures.get(view)!.should.be.instanceOf(EdgePropertyViewNotUsedAsTarget).and.have.property('reason', GraphViewReason.EdgePropertyViewNotUsedAsTarget);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe('when a view reads edge properties and relations of more than one edge type yield it', () => {
|
|
218
|
+
it('should fail with EdgePropertyViewSharedAcrossEdges', async () => {
|
|
219
|
+
const organization = anOrganization('Shared');
|
|
220
|
+
const friend = aView(organization.graphName, 'Friend', () => organization.Person, ['id', viewKey()], ['since', fromEdge()]);
|
|
221
|
+
const group = aView(organization.graphName, 'GroupWithMembers', () => organization.Group, ['members', follows(() => organization.MemberOf, () => friend)]);
|
|
222
|
+
const person = aView(organization.graphName, 'PersonWithFriends', () => organization.Person,
|
|
223
|
+
['friends', follows(() => organization.Knows, () => friend, { direction: GraphEdgeDirection.Outgoing })]);
|
|
224
|
+
const graphs = await discoverViews(organization, friend, group, person);
|
|
225
|
+
graphs.failures.get(friend)!.should.be.instanceOf(EdgePropertyViewSharedAcrossEdges).and.have.property('reason', GraphViewReason.EdgePropertyViewSharedAcrossEdges);
|
|
226
|
+
graphs.failures.has(group).should.be.false;
|
|
227
|
+
graphs.failures.has(person).should.be.false;
|
|
228
|
+
});
|
|
229
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
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 { readFileSync } from 'node:fs';
|
|
5
|
+
import { chai, describe, it, type Assertion } from 'vitest';
|
|
6
|
+
import { GraphViewDefinitionSerializer } from '../graphs/views/GraphViewDefinitionSerializer.js';
|
|
7
|
+
import { GraphViewMemberKind } from '../graphs/views/GraphViewMemberKind.js';
|
|
8
|
+
import { discoverGraphs } from './given/a_discovered_graph.js';
|
|
9
|
+
import { organizationElements, organizationViews } from './given/organization_with_views.fixture.js';
|
|
10
|
+
|
|
11
|
+
chai.should();
|
|
12
|
+
function should(value: unknown): Assertion { return (value as { should: Assertion }).should; }
|
|
13
|
+
|
|
14
|
+
const fixtureText = readFileSync(new URL('./given/graph-views-organization.json', import.meta.url), 'utf8');
|
|
15
|
+
const fixture = JSON.parse(fixtureText) as { graph: string; schema: unknown; views: unknown };
|
|
16
|
+
|
|
17
|
+
// The fixture carries the graph the views are declared over beside the definition. The definition is the graph name
|
|
18
|
+
// and the views, so what is compared byte for byte is the fixture without its schema section.
|
|
19
|
+
function withoutSchema(text: string): string {
|
|
20
|
+
const lines = text.split('\n');
|
|
21
|
+
const start = lines.indexOf(' "schema": {');
|
|
22
|
+
const end = lines.indexOf(' },', start);
|
|
23
|
+
lines.splice(start, end - start + 1);
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('when declaring the organization graph and its views with decorators', () => {
|
|
28
|
+
it('should emit the schema-included form of the fixture, byte for byte', async () => {
|
|
29
|
+
const result = await discoverGraphs(organizationElements, [], 'Neo4j', organizationViews);
|
|
30
|
+
should(result.graphs.failures.size).equal(0);
|
|
31
|
+
should(new GraphViewDefinitionSerializer().serialize(result.graphs.viewDefinitions[0], { includeSchema: true })).equal(fixtureText);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should emit the default form as the fixture without its schema section, byte for byte', async () => {
|
|
35
|
+
const result = await discoverGraphs(organizationElements, [], 'Neo4j', organizationViews);
|
|
36
|
+
should(result.graphs.failures.size).equal(0);
|
|
37
|
+
should(result.graphs.viewDefinitions).have.lengthOf(1);
|
|
38
|
+
should(new GraphViewDefinitionSerializer().serialize(result.graphs.viewDefinitions[0])).equal(withoutSchema(fixtureText));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should emit views and members the way the fixture says', async () => {
|
|
42
|
+
const result = await discoverGraphs(organizationElements, [], 'Neo4j', organizationViews);
|
|
43
|
+
const definition = result.graphs.viewDefinitions[0];
|
|
44
|
+
should(definition.graph).equal(fixture.graph);
|
|
45
|
+
should(definition.views.map(view => view.name)).deep.equal((fixture.views as Array<{ name: string }>).map(view => view.name));
|
|
46
|
+
should(JSON.parse(new GraphViewDefinitionSerializer().serialize(definition)).views).deep.equal(fixture.views);
|
|
47
|
+
should(definition.views.flatMap(view => view.members).some(member => member.kind === GraphViewMemberKind.Relation)).be.true;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
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 { chai, describe, it } from 'vitest';
|
|
6
|
+
import { DefaultClientArtifactsProvider } from '../../artifacts/DefaultClientArtifactsProvider.js';
|
|
7
|
+
import { rootReadModelTypes } from '../../readModels/rootReadModelTypes.js';
|
|
8
|
+
import { TypeDiscoverer } from '../../types/index.js';
|
|
9
|
+
import { graph } from '../graphs/graph.js';
|
|
10
|
+
import { viewKey } from '../graphs/views/viewKey.js';
|
|
11
|
+
import { viewOf } from '../graphs/views/viewOf.js';
|
|
12
|
+
import { discoverGraphs } from './given/a_discovered_graph.js';
|
|
13
|
+
import { aView, anOrganization } from './given/a_graph_with_views.js';
|
|
14
|
+
import { GroupSummary, MemberSummary, organizationViews, Person } from './given/organization_with_views.fixture.js';
|
|
15
|
+
|
|
16
|
+
chai.should();
|
|
17
|
+
|
|
18
|
+
describe('when discovering the artifacts of an application with graph views', () => {
|
|
19
|
+
const provider = new DefaultClientArtifactsProvider(TypeDiscoverer.default);
|
|
20
|
+
|
|
21
|
+
it('should find the views', () => {
|
|
22
|
+
provider.graphViews.should.include.members(organizationViews);
|
|
23
|
+
});
|
|
24
|
+
it('should not find a view among the nodes and edges', () => {
|
|
25
|
+
provider.graphElements.should.not.include.members(organizationViews);
|
|
26
|
+
});
|
|
27
|
+
it('should not treat a view as a read model', () => {
|
|
28
|
+
provider.readModels.should.not.include.members(organizationViews);
|
|
29
|
+
rootReadModelTypes(provider).should.not.include.members(organizationViews);
|
|
30
|
+
provider.graphElements.should.include.members([Person]);
|
|
31
|
+
});
|
|
32
|
+
it('should build the definition from what it finds', async () => {
|
|
33
|
+
const result = await discoverGraphs(provider.graphElements, [], 'Neo4j', provider.graphViews);
|
|
34
|
+
result.graphs.failures.size.should.equal(0);
|
|
35
|
+
result.graphs.viewDefinitions.map(_ => _.graph).should.deep.equal(['Organization']);
|
|
36
|
+
result.graphs.viewDefinitions[0].views.map(view => view.name).should.include.members([GroupSummary.name, MemberSummary.name]);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('when views of different graphs have the same class name', () => {
|
|
41
|
+
it('should discover both', () => {
|
|
42
|
+
const first = anOrganization('FirstGraph');
|
|
43
|
+
const second = anOrganization('SecondGraph');
|
|
44
|
+
const one = aView(first.graphName, 'SharedName', () => first.Person, ['id', viewKey()]);
|
|
45
|
+
const other = aView(second.graphName, 'SharedName', () => second.Person, ['id', viewKey()]);
|
|
46
|
+
const found = new DefaultClientArtifactsProvider(TypeDiscoverer.default).graphViews;
|
|
47
|
+
found.should.include.members([one, other]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should discover a class once however often it is decorated', () => {
|
|
51
|
+
const organization = anOrganization('Redecorated');
|
|
52
|
+
class Once { id = ''; }
|
|
53
|
+
graph(organization.graphName)(Once);
|
|
54
|
+
viewOf(() => organization.Person)(Once);
|
|
55
|
+
viewOf(() => organization.Person)(Once);
|
|
56
|
+
new DefaultClientArtifactsProvider(TypeDiscoverer.default).graphViews.filter(type => type === Once).should.have.lengthOf(1);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -22,6 +22,10 @@ import { getEdgeMetadata } from './edge.js';
|
|
|
22
22
|
import { getGraphProjectionMetadata } from './graphProjection.js';
|
|
23
23
|
import { getNodeMetadata } from './node.js';
|
|
24
24
|
import { ModelBoundGraphReader } from './ModelBoundGraphReader.js';
|
|
25
|
+
import type { GraphViewDefinition } from './views/GraphViewDefinition.js';
|
|
26
|
+
import { GraphViewDefinitionBuilder } from './views/GraphViewDefinitionBuilder.js';
|
|
27
|
+
import { getViewOfMetadata } from './views/viewOf.js';
|
|
28
|
+
import { ViewRootNotANode } from './views/ViewRootNotANode.js';
|
|
25
29
|
|
|
26
30
|
interface DeclaredGraph {
|
|
27
31
|
readonly source: Constructor;
|
|
@@ -37,6 +41,7 @@ export class Graphs implements IGraphs {
|
|
|
37
41
|
private readonly _failures = new Map<Constructor, Error>();
|
|
38
42
|
private readonly _logger: ReturnType<typeof createLogger>;
|
|
39
43
|
private _registrations: readonly GraphRegistration[] = [];
|
|
44
|
+
private _viewDefinitions: readonly GraphViewDefinition[] = [];
|
|
40
45
|
|
|
41
46
|
/**
|
|
42
47
|
* Creates a new {@link Graphs} instance.
|
|
@@ -59,6 +64,11 @@ export class Graphs implements IGraphs {
|
|
|
59
64
|
return this._registrations;
|
|
60
65
|
}
|
|
61
66
|
|
|
67
|
+
/** @inheritdoc */
|
|
68
|
+
get viewDefinitions(): readonly GraphViewDefinition[] {
|
|
69
|
+
return this._viewDefinitions;
|
|
70
|
+
}
|
|
71
|
+
|
|
62
72
|
/** @inheritdoc */
|
|
63
73
|
get failures(): ReadonlyMap<Constructor, Error> {
|
|
64
74
|
return this._failures;
|
|
@@ -70,17 +80,20 @@ export class Graphs implements IGraphs {
|
|
|
70
80
|
const builder = new GraphDefinitionBuilder();
|
|
71
81
|
const registrations: GraphRegistration[] = [];
|
|
72
82
|
const names = new Set<string>();
|
|
83
|
+
const models = new Map<string, GraphModel>();
|
|
73
84
|
for (const declared of [...this.modelBoundGraphs(), ...this.fluentGraphs()]) {
|
|
74
85
|
try {
|
|
75
86
|
if (names.has(declared.model.name)) throw new GraphDeclaredMoreThanOnce(declared.model.name);
|
|
76
87
|
registrations.push(builder.build(declared.model, declared.projectionId, this._graphSinkTypeId));
|
|
77
88
|
names.add(declared.model.name);
|
|
89
|
+
models.set(declared.model.name, declared.model);
|
|
78
90
|
} catch (error) {
|
|
79
91
|
this.fail(declared.source, error);
|
|
80
92
|
}
|
|
81
93
|
}
|
|
82
94
|
|
|
83
95
|
this._registrations = registrations;
|
|
96
|
+
this._viewDefinitions = this.discoverViews(models);
|
|
84
97
|
this._logger.debug('Graph discovery complete', { graphCount: registrations.length, failureCount: this._failures.size });
|
|
85
98
|
}
|
|
86
99
|
|
|
@@ -149,6 +162,37 @@ export class Graphs implements IGraphs {
|
|
|
149
162
|
return result;
|
|
150
163
|
}
|
|
151
164
|
|
|
165
|
+
private discoverViews(models: ReadonlyMap<string, GraphModel>): GraphViewDefinition[] {
|
|
166
|
+
const byGraph = new Map<string, Constructor[]>();
|
|
167
|
+
for (const type of this._clientArtifacts.graphViews ?? []) {
|
|
168
|
+
this.tryRead(type, () => {
|
|
169
|
+
const graph = ModelBoundGraphReader.graphNameOf(type);
|
|
170
|
+
byGraph.set(graph, [...(byGraph.get(graph) ?? []), type]);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const builder = new GraphViewDefinitionBuilder();
|
|
175
|
+
const definitions: GraphViewDefinition[] = [];
|
|
176
|
+
for (const [graph, views] of byGraph) {
|
|
177
|
+
const model = models.get(graph);
|
|
178
|
+
if (model === undefined) {
|
|
179
|
+
// The graph is not registered, so a view has nothing to read. Why is reported for the graph itself.
|
|
180
|
+
for (const view of views) this.tryRead(view, () => { throw new ViewRootNotANode(view, graph, getViewOfMetadata(view)!.root()); });
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
const result = builder.build(model, views);
|
|
186
|
+
for (const [view, failure] of result.failures) this.fail(view, failure);
|
|
187
|
+
if (result.definition !== undefined) definitions.push(result.definition);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
for (const view of views) this.fail(view, error);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return definitions;
|
|
194
|
+
}
|
|
195
|
+
|
|
152
196
|
private tryRead(type: Constructor, read: () => void): void {
|
|
153
197
|
try {
|
|
154
198
|
read();
|