@cratis/chronicle 6.59.0 → 6.61.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/ChronicleClient.ts +1 -1
- package/ChronicleOptions.ts +11 -0
- package/EventStore.ts +9 -1
- package/IEventStore.ts +7 -0
- package/README.md +1 -1
- package/artifacts/DefaultClientArtifactsProvider.ts +13 -1
- package/artifacts/IClientArtifactsProvider.ts +6 -0
- package/dist/ChronicleClient.js +1 -1
- package/dist/ChronicleClient.js.map +1 -1
- package/dist/ChronicleOptions.d.ts +7 -0
- package/dist/ChronicleOptions.d.ts.map +1 -1
- package/dist/ChronicleOptions.js +8 -0
- package/dist/ChronicleOptions.js.map +1 -1
- package/dist/EventStore.d.ts +3 -1
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +7 -1
- package/dist/EventStore.js.map +1 -1
- package/dist/IEventStore.d.ts +6 -0
- package/dist/IEventStore.d.ts.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts +4 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.js +11 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -1
- package/dist/artifacts/IClientArtifactsProvider.d.ts +4 -0
- package/dist/artifacts/IClientArtifactsProvider.d.ts.map +1 -1
- package/dist/projections/ChildrenOrderingNotSupportedByContracts.d.ts +15 -0
- package/dist/projections/ChildrenOrderingNotSupportedByContracts.d.ts.map +1 -0
- package/dist/projections/ChildrenOrderingNotSupportedByContracts.js +22 -0
- package/dist/projections/ChildrenOrderingNotSupportedByContracts.js.map +1 -0
- package/dist/projections/InvalidCausedByProperty.d.ts +10 -0
- package/dist/projections/InvalidCausedByProperty.d.ts.map +1 -0
- package/dist/projections/InvalidCausedByProperty.js +16 -0
- package/dist/projections/InvalidCausedByProperty.js.map +1 -0
- package/dist/projections/Projections.d.ts.map +1 -1
- package/dist/projections/Projections.js +7 -30
- package/dist/projections/Projections.js.map +1 -1
- package/dist/projections/causedBy.d.ts +15 -0
- package/dist/projections/causedBy.d.ts.map +1 -0
- package/dist/projections/causedBy.js +24 -0
- package/dist/projections/causedBy.js.map +1 -0
- package/dist/projections/childrenOrdering.d.ts +38 -0
- package/dist/projections/childrenOrdering.d.ts.map +1 -0
- package/dist/projections/childrenOrdering.js +37 -0
- package/dist/projections/childrenOrdering.js.map +1 -0
- package/dist/projections/childrenOrderingSupport.d.ts +14 -0
- package/dist/projections/childrenOrderingSupport.d.ts.map +1 -0
- package/dist/projections/childrenOrderingSupport.js +37 -0
- package/dist/projections/childrenOrderingSupport.js.map +1 -0
- package/dist/projections/declarative/AllSetBuilder.d.ts +3 -0
- package/dist/projections/declarative/AllSetBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/AllSetBuilder.js +6 -0
- package/dist/projections/declarative/AllSetBuilder.js.map +1 -1
- package/dist/projections/declarative/ChildrenBuilder.d.ts +9 -0
- package/dist/projections/declarative/ChildrenBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/ChildrenBuilder.js +29 -1
- package/dist/projections/declarative/ChildrenBuilder.js.map +1 -1
- package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.d.ts +6 -0
- package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.d.ts.map +1 -0
- package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.js +11 -0
- package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.js.map +1 -0
- package/dist/projections/declarative/DictionaryKey.d.ts +48 -0
- package/dist/projections/declarative/DictionaryKey.d.ts.map +1 -0
- package/dist/projections/declarative/DictionaryKey.js +82 -0
- package/dist/projections/declarative/DictionaryKey.js.map +1 -0
- package/dist/projections/declarative/FromAllBuilder.d.ts +2 -0
- package/dist/projections/declarative/FromAllBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/FromAllBuilder.js +5 -0
- package/dist/projections/declarative/FromAllBuilder.js.map +1 -1
- package/dist/projections/declarative/FromBuilder.d.ts +18 -6
- package/dist/projections/declarative/FromBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/FromBuilder.js +34 -31
- package/dist/projections/declarative/FromBuilder.js.map +1 -1
- package/dist/projections/declarative/FromEveryBuilder.d.ts +2 -0
- package/dist/projections/declarative/FromEveryBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/FromEveryBuilder.js +7 -0
- package/dist/projections/declarative/FromEveryBuilder.js.map +1 -1
- package/dist/projections/declarative/IAllSetBuilder.d.ts +7 -0
- package/dist/projections/declarative/IAllSetBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/IChildrenBuilder.d.ts +19 -0
- package/dist/projections/declarative/IChildrenBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/IFromAllBuilder.d.ts +6 -0
- package/dist/projections/declarative/IFromAllBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/IFromEveryBuilder.d.ts +6 -0
- package/dist/projections/declarative/IFromEveryBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/IReadModelPropertiesBuilder.d.ts +37 -6
- package/dist/projections/declarative/IReadModelPropertiesBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/ISetBuilder.d.ts +7 -0
- package/dist/projections/declarative/ISetBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/InvalidDictionaryKey.d.ts +10 -0
- package/dist/projections/declarative/InvalidDictionaryKey.d.ts.map +1 -0
- package/dist/projections/declarative/InvalidDictionaryKey.js +16 -0
- package/dist/projections/declarative/InvalidDictionaryKey.js.map +1 -0
- package/dist/projections/declarative/JoinBuilder.d.ts +18 -6
- package/dist/projections/declarative/JoinBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/JoinBuilder.js +34 -31
- package/dist/projections/declarative/JoinBuilder.js.map +1 -1
- package/dist/projections/declarative/ProjectionBuilderCore.d.ts +2 -0
- package/dist/projections/declarative/ProjectionBuilderCore.d.ts.map +1 -1
- package/dist/projections/declarative/ProjectionBuilderCore.js.map +1 -1
- package/dist/projections/declarative/SetBuilder.d.ts +3 -0
- package/dist/projections/declarative/SetBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/SetBuilder.js +6 -0
- package/dist/projections/declarative/SetBuilder.js.map +1 -1
- package/dist/projections/declarative/index.d.ts +4 -0
- package/dist/projections/declarative/index.d.ts.map +1 -1
- package/dist/projections/declarative/index.js +3 -0
- package/dist/projections/declarative/index.js.map +1 -1
- package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts +29 -0
- package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts.map +1 -0
- package/dist/projections/for_Graphs/given/a_discovered_graph.js +19 -0
- package/dist/projections/for_Graphs/given/a_discovered_graph.js.map +1 -0
- package/dist/projections/for_Graphs/given/a_fake_connection.d.ts +24 -0
- package/dist/projections/for_Graphs/given/a_fake_connection.d.ts.map +1 -0
- package/dist/projections/for_Graphs/given/a_fake_connection.js +17 -0
- package/dist/projections/for_Graphs/given/a_fake_connection.js.map +1 -0
- package/dist/projections/for_Graphs/given/organization.d.ts +43 -0
- package/dist/projections/for_Graphs/given/organization.d.ts.map +1 -0
- package/dist/projections/for_Graphs/given/organization.js +84 -0
- package/dist/projections/for_Graphs/given/organization.js.map +1 -0
- package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.d.ts +11 -0
- package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.d.ts.map +1 -0
- package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.js +16 -0
- package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.js.map +1 -0
- package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.d.ts +11 -0
- package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.d.ts.map +1 -0
- package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.js +16 -0
- package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.js.map +1 -0
- package/dist/projections/graphs/GraphDeclaredMoreThanOnce.d.ts +11 -0
- package/dist/projections/graphs/GraphDeclaredMoreThanOnce.d.ts.map +1 -0
- package/dist/projections/graphs/GraphDeclaredMoreThanOnce.js +16 -0
- package/dist/projections/graphs/GraphDeclaredMoreThanOnce.js.map +1 -0
- package/dist/projections/graphs/GraphDefinitionBuilder.d.ts +24 -0
- package/dist/projections/graphs/GraphDefinitionBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphDefinitionBuilder.js +148 -0
- package/dist/projections/graphs/GraphDefinitionBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphEdgeBuilder.d.ts +41 -0
- package/dist/projections/graphs/GraphEdgeBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphEdgeBuilder.js +94 -0
- package/dist/projections/graphs/GraphEdgeBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphEdgeFromBuilder.d.ts +25 -0
- package/dist/projections/graphs/GraphEdgeFromBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphEdgeFromBuilder.js +37 -0
- package/dist/projections/graphs/GraphEdgeFromBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphEdgeFromModel.d.ts +16 -0
- package/dist/projections/graphs/GraphEdgeFromModel.d.ts.map +1 -0
- package/dist/projections/graphs/GraphEdgeFromModel.js +4 -0
- package/dist/projections/graphs/GraphEdgeFromModel.js.map +1 -0
- package/dist/projections/graphs/GraphEdgeModel.d.ts +24 -0
- package/dist/projections/graphs/GraphEdgeModel.d.ts.map +1 -0
- package/dist/projections/graphs/GraphEdgeModel.js +4 -0
- package/dist/projections/graphs/GraphEdgeModel.js.map +1 -0
- package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.d.ts +21 -0
- package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.js +31 -0
- package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphEdgeRemovedWithModel.d.ts +14 -0
- package/dist/projections/graphs/GraphEdgeRemovedWithModel.d.ts.map +1 -0
- package/dist/projections/graphs/GraphEdgeRemovedWithModel.js +4 -0
- package/dist/projections/graphs/GraphEdgeRemovedWithModel.js.map +1 -0
- package/dist/projections/graphs/GraphElementCannotBeReadModel.d.ts +11 -0
- package/dist/projections/graphs/GraphElementCannotBeReadModel.d.ts.map +1 -0
- package/dist/projections/graphs/GraphElementCannotBeReadModel.js +16 -0
- package/dist/projections/graphs/GraphElementCannotBeReadModel.js.map +1 -0
- package/dist/projections/graphs/GraphHasDuplicateElement.d.ts +13 -0
- package/dist/projections/graphs/GraphHasDuplicateElement.d.ts.map +1 -0
- package/dist/projections/graphs/GraphHasDuplicateElement.js +18 -0
- package/dist/projections/graphs/GraphHasDuplicateElement.js.map +1 -0
- package/dist/projections/graphs/GraphKeyPropertyNotFound.d.ts +12 -0
- package/dist/projections/graphs/GraphKeyPropertyNotFound.d.ts.map +1 -0
- package/dist/projections/graphs/GraphKeyPropertyNotFound.js +17 -0
- package/dist/projections/graphs/GraphKeyPropertyNotFound.js.map +1 -0
- package/dist/projections/graphs/GraphMappingBuilder.d.ts +32 -0
- package/dist/projections/graphs/GraphMappingBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphMappingBuilder.js +48 -0
- package/dist/projections/graphs/GraphMappingBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphMemberMappings.d.ts +9 -0
- package/dist/projections/graphs/GraphMemberMappings.d.ts.map +1 -0
- package/dist/projections/graphs/GraphMemberMappings.js +59 -0
- package/dist/projections/graphs/GraphMemberMappings.js.map +1 -0
- package/dist/projections/graphs/GraphModel.d.ts +15 -0
- package/dist/projections/graphs/GraphModel.d.ts.map +1 -0
- package/dist/projections/graphs/GraphModel.js +4 -0
- package/dist/projections/graphs/GraphModel.js.map +1 -0
- package/dist/projections/graphs/GraphNameRequired.d.ts +11 -0
- package/dist/projections/graphs/GraphNameRequired.d.ts.map +1 -0
- package/dist/projections/graphs/GraphNameRequired.js +16 -0
- package/dist/projections/graphs/GraphNameRequired.js.map +1 -0
- package/dist/projections/graphs/GraphNodeBuilder.d.ts +34 -0
- package/dist/projections/graphs/GraphNodeBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphNodeBuilder.js +66 -0
- package/dist/projections/graphs/GraphNodeBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphNodeFromBuilder.d.ts +21 -0
- package/dist/projections/graphs/GraphNodeFromBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphNodeFromBuilder.js +30 -0
- package/dist/projections/graphs/GraphNodeFromBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphNodeFromModel.d.ts +14 -0
- package/dist/projections/graphs/GraphNodeFromModel.d.ts.map +1 -0
- package/dist/projections/graphs/GraphNodeFromModel.js +4 -0
- package/dist/projections/graphs/GraphNodeFromModel.js.map +1 -0
- package/dist/projections/graphs/GraphNodeModel.d.ts +18 -0
- package/dist/projections/graphs/GraphNodeModel.d.ts.map +1 -0
- package/dist/projections/graphs/GraphNodeModel.js +4 -0
- package/dist/projections/graphs/GraphNodeModel.js.map +1 -0
- package/dist/projections/graphs/GraphNodeRemovedWithBuilder.d.ts +17 -0
- package/dist/projections/graphs/GraphNodeRemovedWithBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphNodeRemovedWithBuilder.js +24 -0
- package/dist/projections/graphs/GraphNodeRemovedWithBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphNodeRemovedWithModel.d.ts +12 -0
- package/dist/projections/graphs/GraphNodeRemovedWithModel.d.ts.map +1 -0
- package/dist/projections/graphs/GraphNodeRemovedWithModel.js +4 -0
- package/dist/projections/graphs/GraphNodeRemovedWithModel.js.map +1 -0
- package/dist/projections/graphs/GraphProjectionBuilder.d.ts +25 -0
- package/dist/projections/graphs/GraphProjectionBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/GraphProjectionBuilder.js +36 -0
- package/dist/projections/graphs/GraphProjectionBuilder.js.map +1 -0
- package/dist/projections/graphs/GraphRegistration.d.ts +14 -0
- package/dist/projections/graphs/GraphRegistration.d.ts.map +1 -0
- package/dist/projections/graphs/GraphRegistration.js +4 -0
- package/dist/projections/graphs/GraphRegistration.js.map +1 -0
- package/dist/projections/graphs/GraphSchemaWriter.d.ts +28 -0
- package/dist/projections/graphs/GraphSchemaWriter.d.ts.map +1 -0
- package/dist/projections/graphs/GraphSchemaWriter.js +76 -0
- package/dist/projections/graphs/GraphSchemaWriter.js.map +1 -0
- package/dist/projections/graphs/Graphs.d.ts +39 -0
- package/dist/projections/graphs/Graphs.d.ts.map +1 -0
- package/dist/projections/graphs/Graphs.js +144 -0
- package/dist/projections/graphs/Graphs.js.map +1 -0
- package/dist/projections/graphs/IGraphEdgeBuilder.d.ts +37 -0
- package/dist/projections/graphs/IGraphEdgeBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphEdgeBuilder.js +4 -0
- package/dist/projections/graphs/IGraphEdgeBuilder.js.map +1 -0
- package/dist/projections/graphs/IGraphEdgeFromBuilder.d.ts +29 -0
- package/dist/projections/graphs/IGraphEdgeFromBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphEdgeFromBuilder.js +4 -0
- package/dist/projections/graphs/IGraphEdgeFromBuilder.js.map +1 -0
- package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.d.ts +27 -0
- package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.js +4 -0
- package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.js.map +1 -0
- package/dist/projections/graphs/IGraphMappingBuilder.d.ts +49 -0
- package/dist/projections/graphs/IGraphMappingBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphMappingBuilder.js +4 -0
- package/dist/projections/graphs/IGraphMappingBuilder.js.map +1 -0
- package/dist/projections/graphs/IGraphNodeBuilder.d.ts +32 -0
- package/dist/projections/graphs/IGraphNodeBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphNodeBuilder.js +4 -0
- package/dist/projections/graphs/IGraphNodeBuilder.js.map +1 -0
- package/dist/projections/graphs/IGraphNodeFromBuilder.d.ts +21 -0
- package/dist/projections/graphs/IGraphNodeFromBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphNodeFromBuilder.js +4 -0
- package/dist/projections/graphs/IGraphNodeFromBuilder.js.map +1 -0
- package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.d.ts +19 -0
- package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.js +4 -0
- package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.js.map +1 -0
- package/dist/projections/graphs/IGraphProjection.d.ts +13 -0
- package/dist/projections/graphs/IGraphProjection.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphProjection.js +4 -0
- package/dist/projections/graphs/IGraphProjection.js.map +1 -0
- package/dist/projections/graphs/IGraphProjectionBuilder.d.ts +26 -0
- package/dist/projections/graphs/IGraphProjectionBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphProjectionBuilder.js +4 -0
- package/dist/projections/graphs/IGraphProjectionBuilder.js.map +1 -0
- package/dist/projections/graphs/IGraphs.d.ts +27 -0
- package/dist/projections/graphs/IGraphs.d.ts.map +1 -0
- package/dist/projections/graphs/IGraphs.js +4 -0
- package/dist/projections/graphs/IGraphs.js.map +1 -0
- package/dist/projections/graphs/ModelBoundGraphReader.d.ts +30 -0
- package/dist/projections/graphs/ModelBoundGraphReader.d.ts.map +1 -0
- package/dist/projections/graphs/ModelBoundGraphReader.js +112 -0
- package/dist/projections/graphs/ModelBoundGraphReader.js.map +1 -0
- package/dist/projections/graphs/NestedObjectInGraph.d.ts +12 -0
- package/dist/projections/graphs/NestedObjectInGraph.d.ts.map +1 -0
- package/dist/projections/graphs/NestedObjectInGraph.js +17 -0
- package/dist/projections/graphs/NestedObjectInGraph.js.map +1 -0
- package/dist/projections/graphs/NodeMustHaveExactlyOneKey.d.ts +12 -0
- package/dist/projections/graphs/NodeMustHaveExactlyOneKey.d.ts.map +1 -0
- package/dist/projections/graphs/NodeMustHaveExactlyOneKey.js +17 -0
- package/dist/projections/graphs/NodeMustHaveExactlyOneKey.js.map +1 -0
- package/dist/projections/graphs/SetOnceNotSupportedInGraph.d.ts +13 -0
- package/dist/projections/graphs/SetOnceNotSupportedInGraph.d.ts.map +1 -0
- package/dist/projections/graphs/SetOnceNotSupportedInGraph.js +18 -0
- package/dist/projections/graphs/SetOnceNotSupportedInGraph.js.map +1 -0
- package/dist/projections/graphs/UnknownGraphEventProperty.d.ts +13 -0
- package/dist/projections/graphs/UnknownGraphEventProperty.d.ts.map +1 -0
- package/dist/projections/graphs/UnknownGraphEventProperty.js +18 -0
- package/dist/projections/graphs/UnknownGraphEventProperty.js.map +1 -0
- package/dist/projections/graphs/UnknownGraphNode.d.ts +12 -0
- package/dist/projections/graphs/UnknownGraphNode.d.ts.map +1 -0
- package/dist/projections/graphs/UnknownGraphNode.js +17 -0
- package/dist/projections/graphs/UnknownGraphNode.js.map +1 -0
- package/dist/projections/graphs/edge.d.ts +23 -0
- package/dist/projections/graphs/edge.d.ts.map +1 -0
- package/dist/projections/graphs/edge.js +29 -0
- package/dist/projections/graphs/edge.js.map +1 -0
- package/dist/projections/graphs/edgeFrom.d.ts +31 -0
- package/dist/projections/graphs/edgeFrom.d.ts.map +1 -0
- package/dist/projections/graphs/edgeFrom.js +26 -0
- package/dist/projections/graphs/edgeFrom.js.map +1 -0
- package/dist/projections/graphs/edgeRemovedWith.d.ts +22 -0
- package/dist/projections/graphs/edgeRemovedWith.d.ts.map +1 -0
- package/dist/projections/graphs/edgeRemovedWith.js +25 -0
- package/dist/projections/graphs/edgeRemovedWith.js.map +1 -0
- package/dist/projections/graphs/edgeSource.d.ts +22 -0
- package/dist/projections/graphs/edgeSource.d.ts.map +1 -0
- package/dist/projections/graphs/edgeSource.js +30 -0
- package/dist/projections/graphs/edgeSource.js.map +1 -0
- package/dist/projections/graphs/edgeTarget.d.ts +22 -0
- package/dist/projections/graphs/edgeTarget.d.ts.map +1 -0
- package/dist/projections/graphs/edgeTarget.js +30 -0
- package/dist/projections/graphs/edgeTarget.js.map +1 -0
- package/dist/projections/graphs/graph.d.ts +16 -0
- package/dist/projections/graphs/graph.d.ts.map +1 -0
- package/dist/projections/graphs/graph.js +24 -0
- package/dist/projections/graphs/graph.js.map +1 -0
- package/dist/projections/graphs/graphKey.d.ts +16 -0
- package/dist/projections/graphs/graphKey.d.ts.map +1 -0
- package/dist/projections/graphs/graphKey.js +28 -0
- package/dist/projections/graphs/graphKey.js.map +1 -0
- package/dist/projections/graphs/graphProjection.d.ts +21 -0
- package/dist/projections/graphs/graphProjection.d.ts.map +1 -0
- package/dist/projections/graphs/graphProjection.js +28 -0
- package/dist/projections/graphs/graphProjection.js.map +1 -0
- package/dist/projections/graphs/index.d.ts +49 -0
- package/dist/projections/graphs/index.d.ts.map +1 -0
- package/dist/projections/graphs/index.js +28 -0
- package/dist/projections/graphs/index.js.map +1 -0
- package/dist/projections/graphs/isGraphElement.d.ts +7 -0
- package/dist/projections/graphs/isGraphElement.d.ts.map +1 -0
- package/dist/projections/graphs/isGraphElement.js +13 -0
- package/dist/projections/graphs/isGraphElement.js.map +1 -0
- package/dist/projections/graphs/node.d.ts +22 -0
- package/dist/projections/graphs/node.d.ts.map +1 -0
- package/dist/projections/graphs/node.js +29 -0
- package/dist/projections/graphs/node.js.map +1 -0
- package/dist/projections/graphs/nodeFrom.d.ts +31 -0
- package/dist/projections/graphs/nodeFrom.d.ts.map +1 -0
- package/dist/projections/graphs/nodeFrom.js +26 -0
- package/dist/projections/graphs/nodeFrom.js.map +1 -0
- package/dist/projections/graphs/nodeRemovedWith.d.ts +28 -0
- package/dist/projections/graphs/nodeRemovedWith.d.ts.map +1 -0
- package/dist/projections/graphs/nodeRemovedWith.js +25 -0
- package/dist/projections/graphs/nodeRemovedWith.js.map +1 -0
- package/dist/projections/graphs/propertyPathOf.d.ts +8 -0
- package/dist/projections/graphs/propertyPathOf.d.ts.map +1 -0
- package/dist/projections/graphs/propertyPathOf.js +14 -0
- package/dist/projections/graphs/propertyPathOf.js.map +1 -0
- package/dist/projections/index.d.ts +6 -0
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/index.js +4 -0
- package/dist/projections/index.js.map +1 -1
- package/dist/projections/modelBound/ConflictingChildrenOrdering.d.ts +10 -0
- package/dist/projections/modelBound/ConflictingChildrenOrdering.d.ts.map +1 -0
- package/dist/projections/modelBound/ConflictingChildrenOrdering.js +16 -0
- package/dist/projections/modelBound/ConflictingChildrenOrdering.js.map +1 -0
- package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts +2 -0
- package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts.map +1 -1
- package/dist/projections/modelBound/childrenAndNestedBuilder.js +9 -5
- package/dist/projections/modelBound/childrenAndNestedBuilder.js.map +1 -1
- package/dist/projections/modelBound/childrenFrom.d.ts +39 -1
- package/dist/projections/modelBound/childrenFrom.d.ts.map +1 -1
- package/dist/projections/modelBound/childrenFrom.js +30 -1
- package/dist/projections/modelBound/childrenFrom.js.map +1 -1
- package/dist/projections/modelBound/index.d.ts +3 -2
- package/dist/projections/modelBound/index.d.ts.map +1 -1
- package/dist/projections/modelBound/index.js +1 -0
- package/dist/projections/modelBound/index.js.map +1 -1
- package/dist/projections/modelBound/setFrom.d.ts +26 -0
- package/dist/projections/modelBound/setFrom.d.ts.map +1 -1
- package/dist/projections/modelBound/setFrom.js +15 -8
- package/dist/projections/modelBound/setFrom.js.map +1 -1
- package/dist/projections/modelBound/setFromContext.d.ts +23 -1
- package/dist/projections/modelBound/setFromContext.d.ts.map +1 -1
- package/dist/projections/modelBound/setFromContext.js +20 -2
- package/dist/projections/modelBound/setFromContext.js.map +1 -1
- package/dist/projections/propertyExpressions.d.ts +9 -0
- package/dist/projections/propertyExpressions.d.ts.map +1 -0
- package/dist/projections/propertyExpressions.js +13 -0
- package/dist/projections/propertyExpressions.js.map +1 -0
- package/dist/projections/registerProjectionWithRetry.d.ts +15 -0
- package/dist/projections/registerProjectionWithRetry.d.ts.map +1 -0
- package/dist/projections/registerProjectionWithRetry.js +44 -0
- package/dist/projections/registerProjectionWithRetry.js.map +1 -0
- package/dist/readModels/rootReadModelTypes.d.ts.map +1 -1
- package/dist/readModels/rootReadModelTypes.js +3 -1
- package/dist/readModels/rootReadModelTypes.js.map +1 -1
- package/dist/reducers/Reducers.d.ts.map +1 -1
- package/dist/reducers/Reducers.js +2 -1
- package/dist/reducers/Reducers.js.map +1 -1
- package/dist/sinks/WellKnownSinks.d.ts +4 -0
- package/dist/sinks/WellKnownSinks.d.ts.map +1 -1
- package/dist/sinks/WellKnownSinks.js +5 -1
- package/dist/sinks/WellKnownSinks.js.map +1 -1
- package/dist/testing/projections/ProjectionCapabilities.d.ts.map +1 -1
- package/dist/testing/projections/ProjectionCapabilities.js +2 -0
- package/dist/testing/projections/ProjectionCapabilities.js.map +1 -1
- package/dist/testing/projections/ProjectionChildrenCapabilities.d.ts.map +1 -1
- package/dist/testing/projections/ProjectionChildrenCapabilities.js +2 -0
- package/dist/testing/projections/ProjectionChildrenCapabilities.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/DecoratorType.d.ts +5 -1
- package/dist/types/DecoratorType.d.ts.map +1 -1
- package/dist/types/DecoratorType.js +4 -0
- package/dist/types/DecoratorType.js.map +1 -1
- package/for_ChronicleOptions/when_configuring_the_graph_sink/with_graph_sink_type.spec.ts +22 -0
- package/package.json +3 -3
- package/projections/ChildrenOrderingNotSupportedByContracts.ts +18 -0
- package/projections/InvalidCausedByProperty.ts +14 -0
- package/projections/Projections.ts +8 -29
- package/projections/causedBy.ts +30 -0
- package/projections/childrenOrdering.ts +53 -0
- package/projections/childrenOrderingSupport.ts +40 -0
- package/projections/declarative/AllSetBuilder.ts +7 -0
- package/projections/declarative/ChildrenBuilder.ts +34 -1
- package/projections/declarative/ChildrenOrderingAlreadyDefined.ts +11 -0
- package/projections/declarative/DictionaryKey.ts +88 -0
- package/projections/declarative/FromAllBuilder.ts +10 -0
- package/projections/declarative/FromBuilder.ts +42 -32
- package/projections/declarative/FromEveryBuilder.ts +12 -0
- package/projections/declarative/IAllSetBuilder.ts +8 -0
- package/projections/declarative/IChildrenBuilder.ts +22 -0
- package/projections/declarative/IFromAllBuilder.ts +7 -0
- package/projections/declarative/IFromEveryBuilder.ts +7 -0
- package/projections/declarative/IReadModelPropertiesBuilder.ts +39 -6
- package/projections/declarative/ISetBuilder.ts +8 -0
- package/projections/declarative/InvalidDictionaryKey.ts +14 -0
- package/projections/declarative/JoinBuilder.ts +41 -32
- package/projections/declarative/ProjectionBuilderCore.ts +2 -0
- package/projections/declarative/SetBuilder.ts +7 -0
- package/projections/declarative/for_ChildrenBuilder/when_ordering_children.spec.ts +52 -0
- package/projections/declarative/for_FromAllBuilder/when_setting_once.spec.ts +29 -0
- package/projections/declarative/for_FromBuilder/when_setting_once.spec.ts +39 -0
- package/projections/declarative/for_FromBuilder/when_targeting_dictionary_entries.spec.ts +99 -0
- package/projections/declarative/for_JoinBuilder/when_setting_once_and_targeting_dictionary_entries.spec.ts +36 -0
- package/projections/declarative/for_SetBuilder/when_setting_to_the_causing_identity.spec.ts +37 -0
- package/projections/declarative/index.ts +4 -0
- package/projections/for_Graphs/given/a_discovered_graph.ts +21 -0
- package/projections/for_Graphs/given/a_fake_connection.ts +19 -0
- package/projections/for_Graphs/given/organization.ts +96 -0
- package/projections/for_Graphs/when_building_a_fluent_graph.spec.ts +112 -0
- package/projections/for_Graphs/when_building_a_model_bound_graph.spec.ts +92 -0
- package/projections/for_Graphs/when_declaring_an_edge_with_an_identity.spec.ts +137 -0
- package/projections/for_Graphs/when_declaring_an_invalid_graph.spec.ts +227 -0
- package/projections/for_Graphs/when_declaring_with_standard_decorators.standard.spec.ts +92 -0
- package/projections/for_Graphs/when_discovering_graph_elements.spec.ts +32 -0
- package/projections/for_Graphs/when_mapping_properties.spec.ts +159 -0
- package/projections/for_Graphs/when_registering_graphs.spec.ts +56 -0
- package/projections/for_Projections/when_registering_ordered_children.spec.ts +66 -0
- package/projections/for_childrenOrderingSupport/when_detecting_support_in_the_pinned_contracts.spec.ts +22 -0
- package/projections/for_childrenOrderingSupport/when_ensuring_children_ordering_is_supported.spec.ts +35 -0
- package/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.ts +16 -0
- package/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.ts +16 -0
- package/projections/graphs/GraphDeclaredMoreThanOnce.ts +16 -0
- package/projections/graphs/GraphDefinitionBuilder.ts +169 -0
- package/projections/graphs/GraphEdgeBuilder.ts +107 -0
- package/projections/graphs/GraphEdgeFromBuilder.ts +47 -0
- package/projections/graphs/GraphEdgeFromModel.ts +22 -0
- package/projections/graphs/GraphEdgeModel.ts +34 -0
- package/projections/graphs/GraphEdgeRemovedWithBuilder.ts +39 -0
- package/projections/graphs/GraphEdgeRemovedWithModel.ts +19 -0
- package/projections/graphs/GraphElementCannotBeReadModel.ts +16 -0
- package/projections/graphs/GraphHasDuplicateElement.ts +18 -0
- package/projections/graphs/GraphKeyPropertyNotFound.ts +17 -0
- package/projections/graphs/GraphMappingBuilder.ts +65 -0
- package/projections/graphs/GraphMemberMappings.ts +60 -0
- package/projections/graphs/GraphModel.ts +20 -0
- package/projections/graphs/GraphNameRequired.ts +16 -0
- package/projections/graphs/GraphNodeBuilder.ts +76 -0
- package/projections/graphs/GraphNodeFromBuilder.ts +38 -0
- package/projections/graphs/GraphNodeFromModel.ts +19 -0
- package/projections/graphs/GraphNodeModel.ts +25 -0
- package/projections/graphs/GraphNodeRemovedWithBuilder.ts +30 -0
- package/projections/graphs/GraphNodeRemovedWithModel.ts +16 -0
- package/projections/graphs/GraphProjectionBuilder.ts +52 -0
- package/projections/graphs/GraphRegistration.ts +19 -0
- package/projections/graphs/GraphSchemaWriter.ts +80 -0
- package/projections/graphs/Graphs.ts +165 -0
- package/projections/graphs/IGraphEdgeBuilder.ts +43 -0
- package/projections/graphs/IGraphEdgeFromBuilder.ts +34 -0
- package/projections/graphs/IGraphEdgeRemovedWithBuilder.ts +32 -0
- package/projections/graphs/IGraphMappingBuilder.ts +57 -0
- package/projections/graphs/IGraphNodeBuilder.ts +37 -0
- package/projections/graphs/IGraphNodeFromBuilder.ts +25 -0
- package/projections/graphs/IGraphNodeRemovedWithBuilder.ts +23 -0
- package/projections/graphs/IGraphProjection.ts +16 -0
- package/projections/graphs/IGraphProjectionBuilder.ts +34 -0
- package/projections/graphs/IGraphs.ts +33 -0
- package/projections/graphs/ModelBoundGraphReader.ts +119 -0
- package/projections/graphs/NestedObjectInGraph.ts +17 -0
- package/projections/graphs/NodeMustHaveExactlyOneKey.ts +17 -0
- package/projections/graphs/SetOnceNotSupportedInGraph.ts +18 -0
- package/projections/graphs/UnknownGraphEventProperty.ts +18 -0
- package/projections/graphs/UnknownGraphNode.ts +17 -0
- package/projections/graphs/edge.ts +40 -0
- package/projections/graphs/edgeFrom.ts +48 -0
- package/projections/graphs/edgeRemovedWith.ts +36 -0
- package/projections/graphs/edgeSource.ts +39 -0
- package/projections/graphs/edgeTarget.ts +39 -0
- package/projections/graphs/graph.ts +28 -0
- package/projections/graphs/graphKey.ts +31 -0
- package/projections/graphs/graphProjection.ts +39 -0
- package/projections/graphs/index.ts +51 -0
- package/projections/graphs/isGraphElement.ts +14 -0
- package/projections/graphs/node.ts +40 -0
- package/projections/graphs/nodeFrom.ts +48 -0
- package/projections/graphs/nodeRemovedWith.ts +44 -0
- package/projections/graphs/propertyPathOf.ts +15 -0
- package/projections/index.ts +6 -0
- package/projections/modelBound/ConflictingChildrenOrdering.ts +14 -0
- package/projections/modelBound/childrenAndNestedBuilder.ts +11 -5
- package/projections/modelBound/childrenFrom.ts +62 -2
- package/projections/modelBound/for_childrenFrom/when_ordering_children.spec.ts +91 -0
- package/projections/modelBound/for_setFrom/when_setting_once.spec.ts +52 -0
- package/projections/modelBound/index.ts +3 -2
- package/projections/modelBound/setFrom.ts +37 -2
- package/projections/modelBound/setFromContext.ts +38 -3
- package/projections/propertyExpressions.ts +14 -0
- package/projections/registerProjectionWithRetry.ts +53 -0
- package/readModels/rootReadModelTypes.ts +3 -1
- package/reducers/Reducers.ts +2 -1
- package/sinks/WellKnownSinks.ts +7 -1
- package/testing/projections/ProjectionCapabilities.ts +1 -0
- package/testing/projections/ProjectionChildrenCapabilities.ts +1 -0
- package/testing/projections/for_ProjectionCapabilities/when_rejecting_set_once_dictionary_entries_and_ordered_children.spec.ts +52 -0
- package/types/DecoratorType.ts +7 -1
|
@@ -0,0 +1,107 @@
|
|
|
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 { Constructor, PropertyAccessor } from '@cratis/fundamentals';
|
|
5
|
+
import { TypeIntrospector } from '../../types/index.js';
|
|
6
|
+
import { EdgeCanHaveOnlyOneIdentifyingKey } from './EdgeCanHaveOnlyOneIdentifyingKey.js';
|
|
7
|
+
import { EdgeMustHaveOneSourceAndOneTarget } from './EdgeMustHaveOneSourceAndOneTarget.js';
|
|
8
|
+
import { getEdgeMetadata } from './edge.js';
|
|
9
|
+
import { getEdgeSourceMetadata } from './edgeSource.js';
|
|
10
|
+
import { getEdgeTargetMetadata } from './edgeTarget.js';
|
|
11
|
+
import { GraphEdgeFromBuilder } from './GraphEdgeFromBuilder.js';
|
|
12
|
+
import type { GraphEdgeFromModel } from './GraphEdgeFromModel.js';
|
|
13
|
+
import type { GraphEdgeModel } from './GraphEdgeModel.js';
|
|
14
|
+
import { GraphEdgeRemovedWithBuilder } from './GraphEdgeRemovedWithBuilder.js';
|
|
15
|
+
import type { GraphEdgeRemovedWithModel } from './GraphEdgeRemovedWithModel.js';
|
|
16
|
+
import { isGraphKey } from './graphKey.js';
|
|
17
|
+
import type { IGraphEdgeBuilder } from './IGraphEdgeBuilder.js';
|
|
18
|
+
import type { IGraphEdgeFromBuilder } from './IGraphEdgeFromBuilder.js';
|
|
19
|
+
import type { IGraphEdgeRemovedWithBuilder } from './IGraphEdgeRemovedWithBuilder.js';
|
|
20
|
+
import { propertyPathOf } from './propertyPathOf.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Implements {@link IGraphEdgeBuilder}.
|
|
24
|
+
* @template TEdge - The type of edge.
|
|
25
|
+
*/
|
|
26
|
+
export class GraphEdgeBuilder<TEdge> implements IGraphEdgeBuilder<TEdge> {
|
|
27
|
+
private readonly _from: GraphEdgeFromModel[] = [];
|
|
28
|
+
private readonly _removedWith: GraphEdgeRemovedWithModel[] = [];
|
|
29
|
+
private _type?: string;
|
|
30
|
+
private _identifyingProperty?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new {@link GraphEdgeBuilder}.
|
|
34
|
+
* @param _edge - The type of the edge.
|
|
35
|
+
* @param _source - The type of the node the edge starts at.
|
|
36
|
+
* @param _target - The type of the node the edge ends at.
|
|
37
|
+
*/
|
|
38
|
+
constructor(
|
|
39
|
+
private readonly _edge: Constructor<TEdge>,
|
|
40
|
+
private readonly _source: Function,
|
|
41
|
+
private readonly _target: Function
|
|
42
|
+
) {}
|
|
43
|
+
|
|
44
|
+
/** @inheritdoc */
|
|
45
|
+
named(type: string): IGraphEdgeBuilder<TEdge> {
|
|
46
|
+
this._type = type;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @inheritdoc */
|
|
51
|
+
identifiedBy(identityAccessor: PropertyAccessor<TEdge>): IGraphEdgeBuilder<TEdge> {
|
|
52
|
+
this._identifyingProperty = propertyPathOf(identityAccessor);
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** @inheritdoc */
|
|
57
|
+
from<TEvent>(eventType: Constructor<TEvent>, configure: (builder: IGraphEdgeFromBuilder<TEdge, TEvent>) => void): IGraphEdgeBuilder<TEdge> {
|
|
58
|
+
const builder = new GraphEdgeFromBuilder<TEdge, TEvent>();
|
|
59
|
+
configure(builder);
|
|
60
|
+
this._from.push({
|
|
61
|
+
eventType,
|
|
62
|
+
sourceKey: builder.sourceKey,
|
|
63
|
+
targetKey: builder.targetKey,
|
|
64
|
+
identity: builder.identity,
|
|
65
|
+
properties: builder.properties
|
|
66
|
+
});
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** @inheritdoc */
|
|
71
|
+
removedWith<TEvent>(eventType: Constructor<TEvent>, configure: (builder: IGraphEdgeRemovedWithBuilder<TEvent>) => void): IGraphEdgeBuilder<TEdge> {
|
|
72
|
+
const builder = new GraphEdgeRemovedWithBuilder<TEvent>();
|
|
73
|
+
configure(builder);
|
|
74
|
+
this._removedWith.push({ eventType, sourceKey: builder.sourceKey, targetKey: builder.targetKey, identity: builder.identity });
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Builds the {@link GraphEdgeModel}.
|
|
80
|
+
* @returns The model.
|
|
81
|
+
* @throws {EdgeMustHaveOneSourceAndOneTarget} When the end nodes are not types.
|
|
82
|
+
* @throws {EdgeCanHaveOnlyOneIdentifyingKey} When the type has more than one member with the graphKey decorator.
|
|
83
|
+
*/
|
|
84
|
+
build(): GraphEdgeModel {
|
|
85
|
+
if (typeof this._source !== 'function' || typeof this._target !== 'function') {
|
|
86
|
+
throw new EdgeMustHaveOneSourceAndOneTarget(this._edge);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const members = TypeIntrospector.getTrackedProperties(this._edge);
|
|
90
|
+
const keys = members.filter(member => isGraphKey(this._edge.prototype, member));
|
|
91
|
+
if (keys.length > 1) throw new EdgeCanHaveOnlyOneIdentifyingKey(this._edge);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
type: this._edge,
|
|
95
|
+
edgeType: this._type ?? getEdgeMetadata(this._edge)?.type ?? this._edge.name,
|
|
96
|
+
sourceNode: this._source,
|
|
97
|
+
targetNode: this._target,
|
|
98
|
+
identifyingProperty: this._identifyingProperty ?? keys[0],
|
|
99
|
+
// The members that hold the keys of the end nodes are not properties of the edge.
|
|
100
|
+
excludedProperties: members.filter(member =>
|
|
101
|
+
getEdgeSourceMetadata(this._edge.prototype, member) !== undefined ||
|
|
102
|
+
getEdgeTargetMetadata(this._edge.prototype, member) !== undefined),
|
|
103
|
+
from: this._from,
|
|
104
|
+
removedWith: this._removedWith
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { PropertyAccessor } from '@cratis/fundamentals';
|
|
5
|
+
import { GraphMappingBuilder } from './GraphMappingBuilder.js';
|
|
6
|
+
import type { IGraphEdgeFromBuilder } from './IGraphEdgeFromBuilder.js';
|
|
7
|
+
import { propertyPathOf } from './propertyPathOf.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Implements {@link IGraphEdgeFromBuilder}.
|
|
11
|
+
* @template TEdge - The type of edge.
|
|
12
|
+
* @template TEvent - The type of event.
|
|
13
|
+
*/
|
|
14
|
+
export class GraphEdgeFromBuilder<TEdge, TEvent> extends GraphMappingBuilder<TEdge, TEvent, IGraphEdgeFromBuilder<TEdge, TEvent>>
|
|
15
|
+
implements IGraphEdgeFromBuilder<TEdge, TEvent> {
|
|
16
|
+
/** The expression for the key of the source node, or undefined for the event source id. */
|
|
17
|
+
sourceKey?: string;
|
|
18
|
+
|
|
19
|
+
/** The expression for the key of the target node, or undefined for the event source id. */
|
|
20
|
+
targetKey?: string;
|
|
21
|
+
|
|
22
|
+
/** The expression for the identity of the edge. */
|
|
23
|
+
identity?: string;
|
|
24
|
+
|
|
25
|
+
/** @inheritdoc */
|
|
26
|
+
protected get self(): IGraphEdgeFromBuilder<TEdge, TEvent> {
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** @inheritdoc */
|
|
31
|
+
usingSourceKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent> {
|
|
32
|
+
this.sourceKey = propertyPathOf(keyAccessor);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** @inheritdoc */
|
|
37
|
+
usingTargetKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent> {
|
|
38
|
+
this.targetKey = propertyPathOf(keyAccessor);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @inheritdoc */
|
|
43
|
+
usingIdentity(identityAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent> {
|
|
44
|
+
this.identity = propertyPathOf(identityAccessor);
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Represents how an event creates or updates an edge.
|
|
6
|
+
*/
|
|
7
|
+
export interface GraphEdgeFromModel {
|
|
8
|
+
/** The event type. */
|
|
9
|
+
readonly eventType: Function;
|
|
10
|
+
|
|
11
|
+
/** The expression for the key of the source node, or undefined for the event source id. */
|
|
12
|
+
readonly sourceKey?: string;
|
|
13
|
+
|
|
14
|
+
/** The expression for the key of the target node, or undefined for the event source id. */
|
|
15
|
+
readonly targetKey?: string;
|
|
16
|
+
|
|
17
|
+
/** The expression for the identity of the edge, for an edge type with an identifying property. */
|
|
18
|
+
readonly identity?: string;
|
|
19
|
+
|
|
20
|
+
/** The property mapping expressions by edge property name. */
|
|
21
|
+
readonly properties: Readonly<Record<string, string>>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { GraphEdgeFromModel } from './GraphEdgeFromModel.js';
|
|
5
|
+
import type { GraphEdgeRemovedWithModel } from './GraphEdgeRemovedWithModel.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents an edge type with what it is projected from.
|
|
9
|
+
*/
|
|
10
|
+
export interface GraphEdgeModel {
|
|
11
|
+
/** The type of the edge. */
|
|
12
|
+
readonly type: Function;
|
|
13
|
+
|
|
14
|
+
/** The edge type name, for example MEMBER_OF. */
|
|
15
|
+
readonly edgeType: string;
|
|
16
|
+
|
|
17
|
+
/** The type of the node the edge starts at. */
|
|
18
|
+
readonly sourceNode: Function;
|
|
19
|
+
|
|
20
|
+
/** The type of the node the edge ends at. */
|
|
21
|
+
readonly targetNode: Function;
|
|
22
|
+
|
|
23
|
+
/** The name of the identifying property, if any. */
|
|
24
|
+
readonly identifyingProperty?: string;
|
|
25
|
+
|
|
26
|
+
/** The names of the members that are not properties of the edge: the ones holding the keys of the end nodes. */
|
|
27
|
+
readonly excludedProperties: readonly string[];
|
|
28
|
+
|
|
29
|
+
/** The mappings that create or update edges. */
|
|
30
|
+
readonly from: readonly GraphEdgeFromModel[];
|
|
31
|
+
|
|
32
|
+
/** The mappings that delete edges. */
|
|
33
|
+
readonly removedWith: readonly GraphEdgeRemovedWithModel[];
|
|
34
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { PropertyAccessor } from '@cratis/fundamentals';
|
|
5
|
+
import type { IGraphEdgeRemovedWithBuilder } from './IGraphEdgeRemovedWithBuilder.js';
|
|
6
|
+
import { propertyPathOf } from './propertyPathOf.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Implements {@link IGraphEdgeRemovedWithBuilder}.
|
|
10
|
+
* @template TEvent - The type of event.
|
|
11
|
+
*/
|
|
12
|
+
export class GraphEdgeRemovedWithBuilder<TEvent> implements IGraphEdgeRemovedWithBuilder<TEvent> {
|
|
13
|
+
/** The expression for the key of the source node, or undefined for the event source id. */
|
|
14
|
+
sourceKey?: string;
|
|
15
|
+
|
|
16
|
+
/** The expression for the key of the target node, or undefined for the event source id. */
|
|
17
|
+
targetKey?: string;
|
|
18
|
+
|
|
19
|
+
/** The expression for the identity of the edge. */
|
|
20
|
+
identity?: string;
|
|
21
|
+
|
|
22
|
+
/** @inheritdoc */
|
|
23
|
+
usingSourceKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent> {
|
|
24
|
+
this.sourceKey = propertyPathOf(keyAccessor);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @inheritdoc */
|
|
29
|
+
usingTargetKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent> {
|
|
30
|
+
this.targetKey = propertyPathOf(keyAccessor);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @inheritdoc */
|
|
35
|
+
usingIdentity(identityAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent> {
|
|
36
|
+
this.identity = propertyPathOf(identityAccessor);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Represents how an event deletes an edge.
|
|
6
|
+
*/
|
|
7
|
+
export interface GraphEdgeRemovedWithModel {
|
|
8
|
+
/** The event type. */
|
|
9
|
+
readonly eventType: Function;
|
|
10
|
+
|
|
11
|
+
/** The expression for the key of the source node, or undefined for the event source id. */
|
|
12
|
+
readonly sourceKey?: string;
|
|
13
|
+
|
|
14
|
+
/** The expression for the key of the target node, or undefined for the event source id. */
|
|
15
|
+
readonly targetKey?: string;
|
|
16
|
+
|
|
17
|
+
/** The expression for the identity of the edge, for an edge type with an identifying property. */
|
|
18
|
+
readonly identity?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Error thrown when a node or an edge is also declared as a read model with the fromEvent decorator.
|
|
6
|
+
*/
|
|
7
|
+
export class GraphElementCannotBeReadModel extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new {@link GraphElementCannotBeReadModel}.
|
|
10
|
+
* @param type - The type.
|
|
11
|
+
*/
|
|
12
|
+
constructor(type: Function) {
|
|
13
|
+
super(`The type '${type.name}' is a node or an edge in a graph and cannot also be a read model.`);
|
|
14
|
+
this.name = 'GraphElementCannotBeReadModel';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Error thrown when a graph has two nodes with the same label or two edges of the same type.
|
|
6
|
+
*/
|
|
7
|
+
export class GraphHasDuplicateElement extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new {@link GraphHasDuplicateElement}.
|
|
10
|
+
* @param graph - The name of the graph.
|
|
11
|
+
* @param kind - Either node or edge.
|
|
12
|
+
* @param name - The label or type.
|
|
13
|
+
*/
|
|
14
|
+
constructor(graph: string, kind: string, name: string) {
|
|
15
|
+
super(`The graph '${graph}' declares the ${kind} '${name}' more than once.`);
|
|
16
|
+
this.name = 'GraphHasDuplicateElement';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Error thrown when the key of a node or the identity of an edge is not a property of its type.
|
|
6
|
+
*/
|
|
7
|
+
export class GraphKeyPropertyNotFound extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new {@link GraphKeyPropertyNotFound}.
|
|
10
|
+
* @param type - The node or edge type.
|
|
11
|
+
* @param property - The name of the key property.
|
|
12
|
+
*/
|
|
13
|
+
constructor(type: Function, property: string) {
|
|
14
|
+
super(`The key '${property}' of '${type.name}' is not a property of the type. Declare it with an initializer or with the field decorator so its type can be resolved.`);
|
|
15
|
+
this.name = 'GraphKeyPropertyNotFound';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 { PropertyAccessor } from '@cratis/fundamentals';
|
|
5
|
+
import { AddBuilder } from '../declarative/AddBuilder.js';
|
|
6
|
+
import type { IAddBuilder } from '../declarative/IAddBuilder.js';
|
|
7
|
+
import type { ISetBuilder } from '../declarative/ISetBuilder.js';
|
|
8
|
+
import type { ISubtractBuilder } from '../declarative/ISubtractBuilder.js';
|
|
9
|
+
import { SetBuilder } from '../declarative/SetBuilder.js';
|
|
10
|
+
import { SubtractBuilder } from '../declarative/SubtractBuilder.js';
|
|
11
|
+
import type { IGraphMappingBuilder } from './IGraphMappingBuilder.js';
|
|
12
|
+
import { propertyPathOf } from './propertyPathOf.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Implements the property mappings shared by nodes and edges, recording them as expressions by property name.
|
|
16
|
+
* @template TElement - The type of the node or edge.
|
|
17
|
+
* @template TEvent - The type of event.
|
|
18
|
+
* @template TSelf - The type of the builder, for continuation.
|
|
19
|
+
*/
|
|
20
|
+
export abstract class GraphMappingBuilder<TElement, TEvent, TSelf> implements IGraphMappingBuilder<TElement, TEvent, TSelf> {
|
|
21
|
+
/** The property mapping expressions by property name. */
|
|
22
|
+
readonly properties: Record<string, string> = {};
|
|
23
|
+
|
|
24
|
+
/** Gets the builder to return for continuation. */
|
|
25
|
+
protected abstract get self(): TSelf;
|
|
26
|
+
|
|
27
|
+
/** @inheritdoc */
|
|
28
|
+
set(propertyAccessor: PropertyAccessor<TElement>): ISetBuilder<TEvent, TSelf> {
|
|
29
|
+
return new SetBuilder<TEvent, TSelf>(propertyPathOf(propertyAccessor), this.record, this.self);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** @inheritdoc */
|
|
33
|
+
add(propertyAccessor: PropertyAccessor<TElement>): IAddBuilder<TEvent, TSelf> {
|
|
34
|
+
return new AddBuilder<TEvent, TSelf>(propertyPathOf(propertyAccessor), this.record, this.self);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @inheritdoc */
|
|
38
|
+
subtract(propertyAccessor: PropertyAccessor<TElement>): ISubtractBuilder<TEvent, TSelf> {
|
|
39
|
+
return new SubtractBuilder<TEvent, TSelf>(propertyPathOf(propertyAccessor), this.record, this.self);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @inheritdoc */
|
|
43
|
+
increment(propertyAccessor: PropertyAccessor<TElement>): TSelf {
|
|
44
|
+
return this.constant(propertyAccessor, '$increment');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** @inheritdoc */
|
|
48
|
+
decrement(propertyAccessor: PropertyAccessor<TElement>): TSelf {
|
|
49
|
+
return this.constant(propertyAccessor, '$decrement');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** @inheritdoc */
|
|
53
|
+
count(propertyAccessor: PropertyAccessor<TElement>): TSelf {
|
|
54
|
+
return this.constant(propertyAccessor, '$count');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private readonly record = (property: string, expression: string): void => {
|
|
58
|
+
this.properties[property] = expression;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
private constant(propertyAccessor: PropertyAccessor<TElement>, expression: string): TSelf {
|
|
62
|
+
this.record(propertyPathOf(propertyAccessor), expression);
|
|
63
|
+
return this.self;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 { constantValueExpression } from '../constantValueExpression.js';
|
|
5
|
+
import { getAddFromMetadata } from '../modelBound/addFrom.js';
|
|
6
|
+
import { getCountMetadata } from '../modelBound/count.js';
|
|
7
|
+
import { getDecrementMetadata } from '../modelBound/decrement.js';
|
|
8
|
+
import { getIncrementMetadata } from '../modelBound/increment.js';
|
|
9
|
+
import { getSetFromMetadata, setFromExpression } from '../modelBound/setFrom.js';
|
|
10
|
+
import { getSetFromContextMetadata, setFromContextExpression } from '../modelBound/setFromContext.js';
|
|
11
|
+
import { getSetValueMetadata } from '../modelBound/setValue.js';
|
|
12
|
+
import { getSubtractFromMetadata } from '../modelBound/subtractFrom.js';
|
|
13
|
+
import { SetOnceNotSupportedInGraph } from './SetOnceNotSupportedInGraph.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Reads the property mappings the model-bound decorators on the members of a node or an edge declare per event type.
|
|
17
|
+
* @param prototype - The class prototype of the node or edge.
|
|
18
|
+
* @param properties - The names of the members to read.
|
|
19
|
+
* @returns For each event type, the property name to expression.
|
|
20
|
+
* @throws {SetOnceNotSupportedInGraph} When a member is mapped with setOnce - graph projections cannot honor it.
|
|
21
|
+
*/
|
|
22
|
+
export function readGraphMemberMappings(prototype: object, properties: Iterable<string>): Map<Function, Record<string, string>> {
|
|
23
|
+
const result = new Map<Function, Record<string, string>>();
|
|
24
|
+
const record = (eventType: Function, property: string, expression: string) => {
|
|
25
|
+
const mappings = result.get(eventType) ?? {};
|
|
26
|
+
mappings[property] = expression;
|
|
27
|
+
result.set(eventType, mappings);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
for (const property of properties) {
|
|
31
|
+
for (const mapping of getSetFromMetadata(prototype, property)) {
|
|
32
|
+
if (mapping.setOnce === true) throw new SetOnceNotSupportedInGraph(prototype.constructor, property);
|
|
33
|
+
record(mapping.eventType, property, setFromExpression(mapping, property));
|
|
34
|
+
}
|
|
35
|
+
for (const mapping of getSetFromContextMetadata(prototype, property)) {
|
|
36
|
+
if (mapping.setOnce === true) throw new SetOnceNotSupportedInGraph(prototype.constructor, property);
|
|
37
|
+
record(mapping.eventType, property, setFromContextExpression(mapping, property));
|
|
38
|
+
}
|
|
39
|
+
for (const mapping of getSetValueMetadata(prototype, property)) {
|
|
40
|
+
record(mapping.eventType, property, constantValueExpression(mapping.value));
|
|
41
|
+
}
|
|
42
|
+
for (const mapping of getAddFromMetadata(prototype, property)) {
|
|
43
|
+
record(mapping.eventType, property, `$add(${mapping.eventPropertyName ?? property})`);
|
|
44
|
+
}
|
|
45
|
+
for (const mapping of getSubtractFromMetadata(prototype, property)) {
|
|
46
|
+
record(mapping.eventType, property, `$subtract(${mapping.eventPropertyName ?? property})`);
|
|
47
|
+
}
|
|
48
|
+
for (const mapping of getIncrementMetadata(prototype, property)) {
|
|
49
|
+
record(mapping.eventType, property, '$increment');
|
|
50
|
+
}
|
|
51
|
+
for (const mapping of getDecrementMetadata(prototype, property)) {
|
|
52
|
+
record(mapping.eventType, property, '$decrement');
|
|
53
|
+
}
|
|
54
|
+
for (const mapping of getCountMetadata(prototype, property)) {
|
|
55
|
+
record(mapping.eventType, property, '$count');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { GraphEdgeModel } from './GraphEdgeModel.js';
|
|
5
|
+
import type { GraphNodeModel } from './GraphNodeModel.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a graph as declared by the decorators or by the fluent builder, before it is turned into the
|
|
9
|
+
* definitions that are registered. Both forms produce this model, which is what makes them produce identical definitions.
|
|
10
|
+
*/
|
|
11
|
+
export interface GraphModel {
|
|
12
|
+
/** The name of the graph. */
|
|
13
|
+
readonly name: string;
|
|
14
|
+
|
|
15
|
+
/** The nodes. */
|
|
16
|
+
readonly nodes: readonly GraphNodeModel[];
|
|
17
|
+
|
|
18
|
+
/** The edges. */
|
|
19
|
+
readonly edges: readonly GraphEdgeModel[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Error thrown when a model-bound node or edge does not say which graph it belongs to.
|
|
6
|
+
*/
|
|
7
|
+
export class GraphNameRequired extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new {@link GraphNameRequired}.
|
|
10
|
+
* @param type - The node or edge type.
|
|
11
|
+
*/
|
|
12
|
+
constructor(type: Function) {
|
|
13
|
+
super(`The type '${type.name}' is a node or an edge but does not name its graph. Put the graph decorator on it, for example @graph('Organization').`);
|
|
14
|
+
this.name = 'GraphNameRequired';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 { Constructor, PropertyAccessor } from '@cratis/fundamentals';
|
|
5
|
+
import { TypeIntrospector } from '../../types/index.js';
|
|
6
|
+
import { getNodeMetadata } from './node.js';
|
|
7
|
+
import { GraphNodeFromBuilder } from './GraphNodeFromBuilder.js';
|
|
8
|
+
import { GraphNodeRemovedWithBuilder } from './GraphNodeRemovedWithBuilder.js';
|
|
9
|
+
import type { GraphNodeFromModel } from './GraphNodeFromModel.js';
|
|
10
|
+
import type { GraphNodeModel } from './GraphNodeModel.js';
|
|
11
|
+
import type { GraphNodeRemovedWithModel } from './GraphNodeRemovedWithModel.js';
|
|
12
|
+
import { isGraphKey } from './graphKey.js';
|
|
13
|
+
import type { IGraphNodeBuilder } from './IGraphNodeBuilder.js';
|
|
14
|
+
import type { IGraphNodeFromBuilder } from './IGraphNodeFromBuilder.js';
|
|
15
|
+
import type { IGraphNodeRemovedWithBuilder } from './IGraphNodeRemovedWithBuilder.js';
|
|
16
|
+
import { NodeMustHaveExactlyOneKey } from './NodeMustHaveExactlyOneKey.js';
|
|
17
|
+
import { propertyPathOf } from './propertyPathOf.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Implements {@link IGraphNodeBuilder}.
|
|
21
|
+
* @template TNode - The type of node.
|
|
22
|
+
*/
|
|
23
|
+
export class GraphNodeBuilder<TNode> implements IGraphNodeBuilder<TNode> {
|
|
24
|
+
private readonly _from: GraphNodeFromModel[] = [];
|
|
25
|
+
private readonly _removedWith: GraphNodeRemovedWithModel[] = [];
|
|
26
|
+
private _keyProperty?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new {@link GraphNodeBuilder}.
|
|
30
|
+
* @param _type - The type of the node.
|
|
31
|
+
*/
|
|
32
|
+
constructor(private readonly _type: Constructor<TNode>) {}
|
|
33
|
+
|
|
34
|
+
/** @inheritdoc */
|
|
35
|
+
identifiedBy(keyAccessor: PropertyAccessor<TNode>): IGraphNodeBuilder<TNode> {
|
|
36
|
+
this._keyProperty = propertyPathOf(keyAccessor);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @inheritdoc */
|
|
41
|
+
from<TEvent>(eventType: Constructor<TEvent>, configure?: (builder: IGraphNodeFromBuilder<TNode, TEvent>) => void): IGraphNodeBuilder<TNode> {
|
|
42
|
+
const builder = new GraphNodeFromBuilder<TNode, TEvent>();
|
|
43
|
+
configure?.(builder);
|
|
44
|
+
this._from.push({ eventType, key: builder.key, properties: builder.properties, updateOnly: builder.updateOnly });
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @inheritdoc */
|
|
49
|
+
removedWith<TEvent>(eventType: Constructor<TEvent>, configure?: (builder: IGraphNodeRemovedWithBuilder<TEvent>) => void): IGraphNodeBuilder<TNode> {
|
|
50
|
+
const builder = new GraphNodeRemovedWithBuilder<TEvent>();
|
|
51
|
+
configure?.(builder);
|
|
52
|
+
this._removedWith.push({ eventType, key: builder.key, detach: builder.detachEdges });
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Builds the {@link GraphNodeModel}.
|
|
58
|
+
* @returns The model.
|
|
59
|
+
* @throws {NodeMustHaveExactlyOneKey} When no key is declared and the type does not have exactly one member with the graphKey decorator.
|
|
60
|
+
*/
|
|
61
|
+
build(): GraphNodeModel {
|
|
62
|
+
return {
|
|
63
|
+
type: this._type,
|
|
64
|
+
label: getNodeMetadata(this._type)?.label ?? this._type.name,
|
|
65
|
+
keyProperty: this._keyProperty ?? GraphNodeBuilder.keyOf(this._type),
|
|
66
|
+
from: this._from,
|
|
67
|
+
removedWith: this._removedWith
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private static keyOf(type: Function): string {
|
|
72
|
+
const keys = TypeIntrospector.getTrackedProperties(type).filter(member => isGraphKey(type.prototype, member));
|
|
73
|
+
if (keys.length !== 1) throw new NodeMustHaveExactlyOneKey(type, keys.length);
|
|
74
|
+
return keys[0];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { PropertyAccessor } from '@cratis/fundamentals';
|
|
5
|
+
import { GraphMappingBuilder } from './GraphMappingBuilder.js';
|
|
6
|
+
import type { IGraphNodeFromBuilder } from './IGraphNodeFromBuilder.js';
|
|
7
|
+
import { propertyPathOf } from './propertyPathOf.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Implements {@link IGraphNodeFromBuilder}.
|
|
11
|
+
* @template TNode - The type of node.
|
|
12
|
+
* @template TEvent - The type of event.
|
|
13
|
+
*/
|
|
14
|
+
export class GraphNodeFromBuilder<TNode, TEvent> extends GraphMappingBuilder<TNode, TEvent, IGraphNodeFromBuilder<TNode, TEvent>>
|
|
15
|
+
implements IGraphNodeFromBuilder<TNode, TEvent> {
|
|
16
|
+
/** The expression for the key of the node, or undefined for the event source id. */
|
|
17
|
+
key?: string;
|
|
18
|
+
|
|
19
|
+
/** Whether the event only changes a node that already exists. */
|
|
20
|
+
updateOnly = false;
|
|
21
|
+
|
|
22
|
+
/** @inheritdoc */
|
|
23
|
+
protected get self(): IGraphNodeFromBuilder<TNode, TEvent> {
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @inheritdoc */
|
|
28
|
+
usingKey(keyAccessor: PropertyAccessor<TEvent>): IGraphNodeFromBuilder<TNode, TEvent> {
|
|
29
|
+
this.key = propertyPathOf(keyAccessor);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @inheritdoc */
|
|
34
|
+
onlyWhenExisting(): IGraphNodeFromBuilder<TNode, TEvent> {
|
|
35
|
+
this.updateOnly = true;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Represents how an event creates or updates a node.
|
|
6
|
+
*/
|
|
7
|
+
export interface GraphNodeFromModel {
|
|
8
|
+
/** The event type. */
|
|
9
|
+
readonly eventType: Function;
|
|
10
|
+
|
|
11
|
+
/** The expression for the key of the node, or undefined for the event source id. */
|
|
12
|
+
readonly key?: string;
|
|
13
|
+
|
|
14
|
+
/** The property mapping expressions by node property name. */
|
|
15
|
+
readonly properties: Readonly<Record<string, string>>;
|
|
16
|
+
|
|
17
|
+
/** Whether the event only changes a node that already exists. */
|
|
18
|
+
readonly updateOnly: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { GraphNodeFromModel } from './GraphNodeFromModel.js';
|
|
5
|
+
import type { GraphNodeRemovedWithModel } from './GraphNodeRemovedWithModel.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a node type with what it is projected from.
|
|
9
|
+
*/
|
|
10
|
+
export interface GraphNodeModel {
|
|
11
|
+
/** The type of the node. */
|
|
12
|
+
readonly type: Function;
|
|
13
|
+
|
|
14
|
+
/** The node label. */
|
|
15
|
+
readonly label: string;
|
|
16
|
+
|
|
17
|
+
/** The name of the key property. */
|
|
18
|
+
readonly keyProperty: string;
|
|
19
|
+
|
|
20
|
+
/** The mappings that create or update nodes. */
|
|
21
|
+
readonly from: readonly GraphNodeFromModel[];
|
|
22
|
+
|
|
23
|
+
/** The mappings that delete nodes. */
|
|
24
|
+
readonly removedWith: readonly GraphNodeRemovedWithModel[];
|
|
25
|
+
}
|