@cratis/chronicle 6.58.0 → 6.60.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 +2 -2
- package/artifacts/DefaultClientArtifactsProvider.ts +13 -1
- package/artifacts/IClientArtifactsProvider.ts +6 -0
- package/connection/ChronicleConnection.ts +2 -2
- package/connection/ChronicleConnectionString.spec.ts +21 -0
- package/connection/ChronicleConnectionString.ts +16 -6
- package/connection/LeastConnectionsLoadBalancerStrategy.ts +1 -1
- package/connection/LoadBalancerStrategyFactory.ts +2 -2
- package/connection/TokenProvider.ts +2 -1
- package/connection/fetchOAuthAccessToken.ts +3 -3
- package/connection/for_ChronicleConnection/when_warning_about_tls_validation/tls_validation_warning.spec.ts +6 -1
- 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/connection/ChronicleConnection.js +2 -2
- package/dist/connection/ChronicleConnection.js.map +1 -1
- package/dist/connection/ChronicleConnectionString.d.ts +7 -2
- package/dist/connection/ChronicleConnectionString.d.ts.map +1 -1
- package/dist/connection/ChronicleConnectionString.js +14 -6
- package/dist/connection/ChronicleConnectionString.js.map +1 -1
- package/dist/connection/LeastConnectionsLoadBalancerStrategy.d.ts +1 -1
- package/dist/connection/LeastConnectionsLoadBalancerStrategy.js +1 -1
- package/dist/connection/LoadBalancerStrategyFactory.d.ts +2 -2
- package/dist/connection/LoadBalancerStrategyFactory.js +2 -2
- package/dist/connection/TokenProvider.d.ts +2 -1
- package/dist/connection/TokenProvider.d.ts.map +1 -1
- package/dist/connection/TokenProvider.js +2 -1
- package/dist/connection/TokenProvider.js.map +1 -1
- package/dist/connection/fetchOAuthAccessToken.d.ts +1 -1
- package/dist/connection/fetchOAuthAccessToken.js +3 -3
- package/dist/connection/fetchOAuthAccessToken.js.map +1 -1
- package/dist/projections/Projections.d.ts.map +1 -1
- package/dist/projections/Projections.js +3 -30
- package/dist/projections/Projections.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 +145 -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 +8 -0
- package/dist/projections/graphs/GraphMemberMappings.d.ts.map +1 -0
- package/dist/projections/graphs/GraphMemberMappings.js +54 -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/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 +48 -0
- package/dist/projections/graphs/index.d.ts.map +1 -0
- package/dist/projections/graphs/index.js +27 -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 +1 -0
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/index.js +1 -0
- package/dist/projections/index.js.map +1 -1
- 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/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/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/Projections.ts +4 -29
- 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 +91 -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 +199 -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/graphs/EdgeCanHaveOnlyOneIdentifyingKey.ts +16 -0
- package/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.ts +16 -0
- package/projections/graphs/GraphDeclaredMoreThanOnce.ts +16 -0
- package/projections/graphs/GraphDefinitionBuilder.ts +166 -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 +57 -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/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 +50 -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 +1 -0
- package/projections/registerProjectionWithRetry.ts +53 -0
- package/readModels/rootReadModelTypes.ts +3 -1
- package/sinks/WellKnownSinks.ts +7 -1
- package/types/DecoratorType.ts +7 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import 'reflect-metadata';
|
|
5
|
+
import { TypeIntrospector } from '../../types/index.js';
|
|
6
|
+
import { ChroniclePropertyDecorator, decorateProperty, getPropertyMetadata } from '../../types/propertyDecoratorMetadata.js';
|
|
7
|
+
|
|
8
|
+
const METADATA_KEY = 'chronicle:graph:key';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Property decorator that marks the unique key of a node, or the property that identifies an edge among edges of the
|
|
12
|
+
* same type between the same two nodes.
|
|
13
|
+
* @returns A property decorator.
|
|
14
|
+
*/
|
|
15
|
+
export function graphKey(): ChroniclePropertyDecorator {
|
|
16
|
+
return decorateProperty((target: object, propertyKey: string | symbol) => {
|
|
17
|
+
const key = propertyKey.toString();
|
|
18
|
+
TypeIntrospector.trackProperty((target as { constructor: Function }).constructor, key);
|
|
19
|
+
Reflect.defineMetadata(METADATA_KEY, true, target, key);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Gets whether a property is marked with the graphKey decorator.
|
|
25
|
+
* @param target - The class prototype.
|
|
26
|
+
* @param propertyKey - The property name.
|
|
27
|
+
* @returns True if it is marked, false if not.
|
|
28
|
+
*/
|
|
29
|
+
export function isGraphKey(target: object, propertyKey: string): boolean {
|
|
30
|
+
return getPropertyMetadata<boolean>(METADATA_KEY, target, propertyKey) === true;
|
|
31
|
+
}
|
|
@@ -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 'reflect-metadata';
|
|
5
|
+
import type { Constructor } from '@cratis/fundamentals';
|
|
6
|
+
import { DecoratorType, TypeDiscoverer } from '../../types/index.js';
|
|
7
|
+
import type { ChronicleClassDecorator } from '../../types/standardDecoratorMetadata.js';
|
|
8
|
+
|
|
9
|
+
/** Metadata stored by the graphProjection class decorator. */
|
|
10
|
+
export interface GraphProjectionMetadata {
|
|
11
|
+
/** The name of the graph. */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const METADATA_KEY = 'chronicle:graph:projection';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Class decorator that marks a class implementing IGraphProjection as a graph projection, declared with a fluent builder.
|
|
19
|
+
* @param name - The name of the graph, which is also the name of the read model the graph is registered as.
|
|
20
|
+
* Defaults to the name of the class.
|
|
21
|
+
* @returns A class decorator.
|
|
22
|
+
*/
|
|
23
|
+
export function graphProjection(name?: string): ChronicleClassDecorator {
|
|
24
|
+
return (target: object) => {
|
|
25
|
+
const type = target as Function;
|
|
26
|
+
const metadata: GraphProjectionMetadata = { name: name ?? type.name };
|
|
27
|
+
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
28
|
+
TypeDiscoverer.default.register(DecoratorType.GraphProjection, type as Constructor);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the metadata stored by the graphProjection decorator.
|
|
34
|
+
* @param target - The class constructor.
|
|
35
|
+
* @returns The metadata, or undefined when the class is not a graph projection.
|
|
36
|
+
*/
|
|
37
|
+
export function getGraphProjectionMetadata(target: Function): GraphProjectionMetadata | undefined {
|
|
38
|
+
return Reflect.getMetadata(METADATA_KEY, target) as GraphProjectionMetadata | undefined;
|
|
39
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
export { graph, getGraphName } from './graph.js';
|
|
5
|
+
export { node, getNodeMetadata } from './node.js';
|
|
6
|
+
export type { NodeMetadata } from './node.js';
|
|
7
|
+
export { edge, getEdgeMetadata } from './edge.js';
|
|
8
|
+
export type { EdgeMetadata } from './edge.js';
|
|
9
|
+
export { graphProjection, getGraphProjectionMetadata } from './graphProjection.js';
|
|
10
|
+
export type { GraphProjectionMetadata } from './graphProjection.js';
|
|
11
|
+
export { graphKey, isGraphKey } from './graphKey.js';
|
|
12
|
+
export { edgeSource, getEdgeSourceMetadata } from './edgeSource.js';
|
|
13
|
+
export type { EdgeSourceMetadata } from './edgeSource.js';
|
|
14
|
+
export { edgeTarget, getEdgeTargetMetadata } from './edgeTarget.js';
|
|
15
|
+
export type { EdgeTargetMetadata } from './edgeTarget.js';
|
|
16
|
+
export { nodeFrom, getNodeFromMetadata } from './nodeFrom.js';
|
|
17
|
+
export type { NodeFromOptions, NodeFromMetadata } from './nodeFrom.js';
|
|
18
|
+
export { nodeRemovedWith, getNodeRemovedWithMetadata } from './nodeRemovedWith.js';
|
|
19
|
+
export type { NodeRemovedWithOptions, NodeRemovedWithMetadata } from './nodeRemovedWith.js';
|
|
20
|
+
export { edgeFrom, getEdgeFromMetadata } from './edgeFrom.js';
|
|
21
|
+
export type { EdgeFromOptions, EdgeFromMetadata } from './edgeFrom.js';
|
|
22
|
+
export { edgeRemovedWith, getEdgeRemovedWithMetadata } from './edgeRemovedWith.js';
|
|
23
|
+
export type { EdgeRemovedWithMetadata } from './edgeRemovedWith.js';
|
|
24
|
+
export { isGraphElement } from './isGraphElement.js';
|
|
25
|
+
export type { IGraphProjection } from './IGraphProjection.js';
|
|
26
|
+
export type { IGraphProjectionBuilder } from './IGraphProjectionBuilder.js';
|
|
27
|
+
export type { IGraphNodeBuilder } from './IGraphNodeBuilder.js';
|
|
28
|
+
export type { IGraphNodeFromBuilder } from './IGraphNodeFromBuilder.js';
|
|
29
|
+
export type { IGraphNodeRemovedWithBuilder } from './IGraphNodeRemovedWithBuilder.js';
|
|
30
|
+
export type { IGraphEdgeBuilder } from './IGraphEdgeBuilder.js';
|
|
31
|
+
export type { IGraphEdgeFromBuilder } from './IGraphEdgeFromBuilder.js';
|
|
32
|
+
export type { IGraphEdgeRemovedWithBuilder } from './IGraphEdgeRemovedWithBuilder.js';
|
|
33
|
+
export type { IGraphMappingBuilder } from './IGraphMappingBuilder.js';
|
|
34
|
+
export type { IGraphs } from './IGraphs.js';
|
|
35
|
+
export { Graphs } from './Graphs.js';
|
|
36
|
+
export type { GraphRegistration } from './GraphRegistration.js';
|
|
37
|
+
export type { GraphModel } from './GraphModel.js';
|
|
38
|
+
export type { GraphNodeModel } from './GraphNodeModel.js';
|
|
39
|
+
export type { GraphEdgeModel } from './GraphEdgeModel.js';
|
|
40
|
+
export { NodeMustHaveExactlyOneKey } from './NodeMustHaveExactlyOneKey.js';
|
|
41
|
+
export { EdgeMustHaveOneSourceAndOneTarget } from './EdgeMustHaveOneSourceAndOneTarget.js';
|
|
42
|
+
export { EdgeCanHaveOnlyOneIdentifyingKey } from './EdgeCanHaveOnlyOneIdentifyingKey.js';
|
|
43
|
+
export { NestedObjectInGraph } from './NestedObjectInGraph.js';
|
|
44
|
+
export { UnknownGraphEventProperty } from './UnknownGraphEventProperty.js';
|
|
45
|
+
export { UnknownGraphNode } from './UnknownGraphNode.js';
|
|
46
|
+
export { GraphNameRequired } from './GraphNameRequired.js';
|
|
47
|
+
export { GraphKeyPropertyNotFound } from './GraphKeyPropertyNotFound.js';
|
|
48
|
+
export { GraphElementCannotBeReadModel } from './GraphElementCannotBeReadModel.js';
|
|
49
|
+
export { GraphHasDuplicateElement } from './GraphHasDuplicateElement.js';
|
|
50
|
+
export { GraphDeclaredMoreThanOnce } from './GraphDeclaredMoreThanOnce.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { getEdgeMetadata } from './edge.js';
|
|
5
|
+
import { getNodeMetadata } from './node.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets whether a type is a node or an edge of a property graph.
|
|
9
|
+
* @param type - The type to check.
|
|
10
|
+
* @returns True if it is a node or an edge, false if not.
|
|
11
|
+
*/
|
|
12
|
+
export function isGraphElement(type: Function): boolean {
|
|
13
|
+
return getNodeMetadata(type) !== undefined || getEdgeMetadata(type) !== undefined;
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 type { Constructor } from '@cratis/fundamentals';
|
|
6
|
+
import { DecoratorType, TypeDiscoverer } from '../../types/index.js';
|
|
7
|
+
import type { ChronicleClassDecorator } from '../../types/standardDecoratorMetadata.js';
|
|
8
|
+
|
|
9
|
+
/** Metadata stored by the node class decorator. */
|
|
10
|
+
export interface NodeMetadata {
|
|
11
|
+
/** The node label. */
|
|
12
|
+
readonly label: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const METADATA_KEY = 'chronicle:graph:node';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Class decorator that marks a class as a node in a property graph. The properties of the class are the
|
|
19
|
+
* properties of the node, and the member with the graphKey decorator holds its unique key. Which events create,
|
|
20
|
+
* update and remove nodes is declared with nodeFrom, nodeRemovedWith and the property mapping decorators.
|
|
21
|
+
* @param label - The node label. Defaults to the name of the class.
|
|
22
|
+
* @returns A class decorator.
|
|
23
|
+
*/
|
|
24
|
+
export function node(label?: string): ChronicleClassDecorator {
|
|
25
|
+
return (target: object) => {
|
|
26
|
+
const type = target as Function;
|
|
27
|
+
const metadata: NodeMetadata = { label: label ?? type.name };
|
|
28
|
+
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
29
|
+
TypeDiscoverer.default.register(DecoratorType.GraphElement, type as Constructor);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves the metadata stored by the node decorator.
|
|
35
|
+
* @param target - The class constructor.
|
|
36
|
+
* @returns The metadata, or undefined when the class is not a node.
|
|
37
|
+
*/
|
|
38
|
+
export function getNodeMetadata(target: Function): NodeMetadata | undefined {
|
|
39
|
+
return Reflect.getMetadata(METADATA_KEY, target) as NodeMetadata | undefined;
|
|
40
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 type { ChronicleClassDecorator } from '../../types/standardDecoratorMetadata.js';
|
|
6
|
+
|
|
7
|
+
/** Options for the nodeFrom class decorator. */
|
|
8
|
+
export interface NodeFromOptions {
|
|
9
|
+
/** The name of the event property that holds the key of the node. Defaults to the event source id. */
|
|
10
|
+
readonly key?: string;
|
|
11
|
+
|
|
12
|
+
/** A constant key. Every event then updates the same node. */
|
|
13
|
+
readonly constantKey?: string;
|
|
14
|
+
|
|
15
|
+
/** Only set properties on a node that already exists, instead of creating it. */
|
|
16
|
+
readonly updateOnly?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Metadata stored by the nodeFrom class decorator. */
|
|
20
|
+
export interface NodeFromMetadata extends NodeFromOptions {
|
|
21
|
+
/** The event constructor. */
|
|
22
|
+
readonly eventType: Function;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const METADATA_KEY = 'chronicle:graph:nodeFrom';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Class decorator that creates or updates a node when an event is observed. Properties of the node are mapped by
|
|
29
|
+
* name from an event property of the same name, or explicitly with the property mapping decorators.
|
|
30
|
+
* @param eventType - The event constructor.
|
|
31
|
+
* @param options - Optional key and update-only configuration.
|
|
32
|
+
* @returns A class decorator.
|
|
33
|
+
*/
|
|
34
|
+
export function nodeFrom(eventType: Function, options?: NodeFromOptions): ChronicleClassDecorator {
|
|
35
|
+
return (target: object) => {
|
|
36
|
+
const existing: NodeFromMetadata[] = Reflect.getMetadata(METADATA_KEY, target) ?? [];
|
|
37
|
+
Reflect.defineMetadata(METADATA_KEY, [...existing, { eventType, ...options }], target);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves all nodeFrom metadata stored on the given class constructor.
|
|
43
|
+
* @param target - The class constructor.
|
|
44
|
+
* @returns An array of nodeFrom metadata entries.
|
|
45
|
+
*/
|
|
46
|
+
export function getNodeFromMetadata(target: Function): NodeFromMetadata[] {
|
|
47
|
+
return Reflect.getMetadata(METADATA_KEY, target) ?? [];
|
|
48
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 type { ChronicleClassDecorator } from '../../types/standardDecoratorMetadata.js';
|
|
6
|
+
|
|
7
|
+
/** Options for the nodeRemovedWith class decorator. */
|
|
8
|
+
export interface NodeRemovedWithOptions {
|
|
9
|
+
/** The name of the event property that holds the key of the node. Defaults to the event source id. */
|
|
10
|
+
readonly key?: string;
|
|
11
|
+
|
|
12
|
+
/** Delete the edges attached to the node with it. Without it a node that still has edges cannot be deleted. */
|
|
13
|
+
readonly detach?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Metadata stored by the nodeRemovedWith class decorator. */
|
|
17
|
+
export interface NodeRemovedWithMetadata extends NodeRemovedWithOptions {
|
|
18
|
+
/** The event constructor. */
|
|
19
|
+
readonly eventType: Function;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const METADATA_KEY = 'chronicle:graph:nodeRemovedWith';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Class decorator that deletes a node when an event is observed.
|
|
26
|
+
* @param eventType - The event constructor.
|
|
27
|
+
* @param options - Optional key and detach configuration.
|
|
28
|
+
* @returns A class decorator.
|
|
29
|
+
*/
|
|
30
|
+
export function nodeRemovedWith(eventType: Function, options?: NodeRemovedWithOptions): ChronicleClassDecorator {
|
|
31
|
+
return (target: object) => {
|
|
32
|
+
const existing: NodeRemovedWithMetadata[] = Reflect.getMetadata(METADATA_KEY, target) ?? [];
|
|
33
|
+
Reflect.defineMetadata(METADATA_KEY, [...existing, { eventType, ...options }], target);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves all nodeRemovedWith metadata stored on the given class constructor.
|
|
39
|
+
* @param target - The class constructor.
|
|
40
|
+
* @returns An array of nodeRemovedWith metadata entries.
|
|
41
|
+
*/
|
|
42
|
+
export function getNodeRemovedWithMetadata(target: Function): NodeRemovedWithMetadata[] {
|
|
43
|
+
return Reflect.getMetadata(METADATA_KEY, target) ?? [];
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 { PropertyAccessor, PropertyPathResolverProxyHandler } from '@cratis/fundamentals';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the path of the property an accessor selects.
|
|
8
|
+
* @param accessor - The property accessor, for example `event => event.personId`.
|
|
9
|
+
* @returns The property path.
|
|
10
|
+
*/
|
|
11
|
+
export function propertyPathOf<T>(accessor: PropertyAccessor<T>): string {
|
|
12
|
+
const handler = new PropertyPathResolverProxyHandler();
|
|
13
|
+
accessor(new Proxy({}, handler) as T);
|
|
14
|
+
return handler.property;
|
|
15
|
+
}
|
package/projections/index.ts
CHANGED
|
@@ -12,3 +12,4 @@ export { VariantMustDeclareEntersOnEvent } from './VariantMustDeclareEntersOnEve
|
|
|
12
12
|
export { GlobalHandlerPropertyNotOnVariant } from './GlobalHandlerPropertyNotOnVariant.js';
|
|
13
13
|
export * from './declarative/index.js';
|
|
14
14
|
export * from './modelBound/index.js';
|
|
15
|
+
export * from './graphs/index.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { ProjectionOwner, type ProjectionDefinition } from '@cratis/chronicle.contracts';
|
|
5
|
+
import type { ChronicleConnection } from '../connection/index.js';
|
|
6
|
+
import type { createLogger } from '../logging/createLogger.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Registers a projection with the kernel, retrying with a growing delay while the kernel reports a transient failure.
|
|
10
|
+
* @param connection - The Chronicle connection.
|
|
11
|
+
* @param eventStore - The event store name.
|
|
12
|
+
* @param logger - The logger to report with.
|
|
13
|
+
* @param projection - The projection definition to register.
|
|
14
|
+
* @param identifier - The identifier of the projection, for reporting.
|
|
15
|
+
* @param maxAttempts - The number of attempts before giving up.
|
|
16
|
+
* @returns A promise that resolves when the projection is registered.
|
|
17
|
+
*/
|
|
18
|
+
export async function registerProjectionWithRetry(
|
|
19
|
+
connection: ChronicleConnection,
|
|
20
|
+
eventStore: string,
|
|
21
|
+
logger: ReturnType<typeof createLogger>,
|
|
22
|
+
projection: ProjectionDefinition,
|
|
23
|
+
identifier: string,
|
|
24
|
+
maxAttempts = 5
|
|
25
|
+
): Promise<void> {
|
|
26
|
+
let delay = 2000;
|
|
27
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
28
|
+
try {
|
|
29
|
+
logger.info('Registering projection', { identifier, readModel: projection.ReadModel, attempt });
|
|
30
|
+
await connection.projections.register({
|
|
31
|
+
EventStore: eventStore,
|
|
32
|
+
Owner: ProjectionOwner.PROJECTION_OWNER_Client,
|
|
33
|
+
Projections: [projection]
|
|
34
|
+
});
|
|
35
|
+
logger.info('Projection registered successfully', { identifier });
|
|
36
|
+
return;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const msg = String(error);
|
|
39
|
+
const isTransient = msg.includes('UNKNOWN') || msg.includes('UNAVAILABLE') || msg.includes('INTERNAL');
|
|
40
|
+
if (!isTransient || attempt === maxAttempts) {
|
|
41
|
+
throw new Error(`Failed to register projection '${identifier}' after ${attempt} attempt(s): ${msg}`);
|
|
42
|
+
}
|
|
43
|
+
logger.warn('Projection registration failed with transient error, retrying', {
|
|
44
|
+
identifier,
|
|
45
|
+
attempt,
|
|
46
|
+
nextAttemptInMs: delay,
|
|
47
|
+
error
|
|
48
|
+
});
|
|
49
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
50
|
+
delay = Math.min(delay * 2, 15000);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -13,11 +13,13 @@ import type { IProjectionFor } from '../projections/declarative/IProjectionFor.j
|
|
|
13
13
|
import { getChildrenFromMetadata } from '../projections/modelBound/childrenFrom.js';
|
|
14
14
|
import { resolveChildElementType, resolveNestedType } from '../projections/modelBound/childrenAndNestedBuilder.js';
|
|
15
15
|
import { isNested } from '../projections/modelBound/nested.js';
|
|
16
|
+
import { isGraphElement } from '../projections/graphs/isGraphElement.js';
|
|
16
17
|
import { getReducerMetadata } from '../reducers/reducer.js';
|
|
17
18
|
import { TypeIntrospector } from '../types/TypeIntrospector.js';
|
|
18
19
|
|
|
19
20
|
function inspectReadModelTypes(artifacts: IClientArtifactsProvider): { models: Constructor[]; usedAsChildren: Set<Function>; visited: Set<Function> } {
|
|
20
|
-
|
|
21
|
+
// Nodes and edges map properties like a read model does but are projected into a graph, never into a read model.
|
|
22
|
+
const models = artifacts.readModels.filter(type => !isGraphElement(type));
|
|
21
23
|
const usedAsChildren = new Set<Function>();
|
|
22
24
|
const visited = new Set<Function>();
|
|
23
25
|
const inspect = (type: Function): void => {
|
package/sinks/WellKnownSinks.ts
CHANGED
|
@@ -15,5 +15,11 @@ export const WellKnownSinks = {
|
|
|
15
15
|
MongoDB: 'MongoDB',
|
|
16
16
|
|
|
17
17
|
/** SQL sink. */
|
|
18
|
-
SQL: 'SQL'
|
|
18
|
+
SQL: 'SQL',
|
|
19
|
+
|
|
20
|
+
/** Neo4j graph sink, the default sink of property graphs. */
|
|
21
|
+
Neo4j: 'Neo4j',
|
|
22
|
+
|
|
23
|
+
/** In-memory graph sink, which keeps a property graph in the kernel's memory. */
|
|
24
|
+
InMemoryGraph: 'InMemoryGraph'
|
|
19
25
|
} as const;
|
package/types/DecoratorType.ts
CHANGED
|
@@ -36,5 +36,11 @@ export enum DecoratorType {
|
|
|
36
36
|
GlobalForHandler = 'globalForHandler',
|
|
37
37
|
|
|
38
38
|
/** Event source definition artifacts discovered through the eventSource decorator. */
|
|
39
|
-
EventSource = 'eventSource'
|
|
39
|
+
EventSource = 'eventSource',
|
|
40
|
+
|
|
41
|
+
/** Node and edge artifacts of a property graph discovered through the node and edge decorators. */
|
|
42
|
+
GraphElement = 'graphElement',
|
|
43
|
+
|
|
44
|
+
/** Fluent graph projection artifacts discovered through the graphProjection decorator. */
|
|
45
|
+
GraphProjection = 'graphProjection'
|
|
40
46
|
}
|