@cratis/chronicle 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChronicleClient.ts +453 -0
- package/ChronicleOptions.ts +104 -0
- package/EventSequences/AppendError.ts +10 -0
- package/EventSequences/AppendOptions.ts +15 -0
- package/EventSequences/AppendResult.ts +23 -0
- package/EventSequences/ConstraintViolation.ts +16 -0
- package/EventSequences/EventLog.ts +21 -0
- package/EventSequences/EventSequence.ts +372 -0
- package/EventSequences/EventSequenceId.ts +17 -0
- package/EventSequences/EventSequenceNumber.ts +38 -0
- package/EventSequences/IEventLog.ts +10 -0
- package/EventSequences/IEventSequence.ts +47 -0
- package/EventSequences/index.ts +13 -0
- package/EventStore.ts +132 -0
- package/EventStoreName.ts +14 -0
- package/EventStoreNamespaceName.ts +17 -0
- package/Events/AppendedEvent.ts +19 -0
- package/Events/CausationEntry.ts +13 -0
- package/Events/Constraints/ConstraintBuilder.ts +86 -0
- package/Events/Constraints/ConstraintId.ts +14 -0
- package/Events/Constraints/Constraints.ts +117 -0
- package/Events/Constraints/IConstraint.ts +18 -0
- package/Events/Constraints/IConstraintBuilder.ts +44 -0
- package/Events/Constraints/IConstraints.ts +28 -0
- package/Events/Constraints/IUniqueConstraintBuilder.ts +52 -0
- package/Events/Constraints/UniqueConstraintBuilder.ts +97 -0
- package/Events/Constraints/constraint.ts +56 -0
- package/Events/Constraints/index.ts +15 -0
- package/Events/EventContext.ts +28 -0
- package/Events/EventType.ts +41 -0
- package/Events/EventTypeGeneration.ts +20 -0
- package/Events/EventTypeId.ts +19 -0
- package/Events/EventTypes.ts +95 -0
- package/Events/IEventTypes.ts +39 -0
- package/Events/eventTypeDecorator.ts +147 -0
- package/Events/index.ts +14 -0
- package/IChronicleClient.ts +39 -0
- package/IEventStore.ts +56 -0
- package/Metrics.ts +109 -0
- package/Observation/ObserverId.ts +14 -0
- package/Observation/ObserverRunningState.ts +34 -0
- package/Observation/index.ts +5 -0
- package/Projections/IProjections.ts +19 -0
- package/Projections/ProjectionId.ts +14 -0
- package/Projections/Projections.ts +463 -0
- package/Projections/declarative/AllSetBuilder.ts +39 -0
- package/Projections/declarative/FromBuilder.ts +144 -0
- package/Projections/declarative/FromEveryBuilder.ts +46 -0
- package/Projections/declarative/IAddBuilder.ts +18 -0
- package/Projections/declarative/IAddChildBuilder.ts +25 -0
- package/Projections/declarative/IAllSetBuilder.ts +31 -0
- package/Projections/declarative/IChildrenBuilder.ts +31 -0
- package/Projections/declarative/ICompositeKeyBuilder.ts +22 -0
- package/Projections/declarative/IFromBuilder.ts +12 -0
- package/Projections/declarative/IFromEveryBuilder.ts +24 -0
- package/Projections/declarative/IJoinBuilder.ts +20 -0
- package/Projections/declarative/INestedBuilder.ts +19 -0
- package/Projections/declarative/IProjectionBuilder.ts +98 -0
- package/Projections/declarative/IProjectionBuilderFor.ts +38 -0
- package/Projections/declarative/IProjectionFor.ts +18 -0
- package/Projections/declarative/IReadModelPropertiesBuilder.ts +132 -0
- package/Projections/declarative/IRemovedWithBuilder.ts +25 -0
- package/Projections/declarative/IRemovedWithJoinBuilder.ts +25 -0
- package/Projections/declarative/ISetBuilder.ts +38 -0
- package/Projections/declarative/ISubtractBuilder.ts +18 -0
- package/Projections/declarative/JoinBuilder.ts +148 -0
- package/Projections/declarative/ProjectionBuilderFor.ts +277 -0
- package/Projections/declarative/RemovedWithBuilder.ts +40 -0
- package/Projections/declarative/RemovedWithJoinBuilder.ts +43 -0
- package/Projections/declarative/SetBuilder.ts +46 -0
- package/Projections/declarative/index.ts +26 -0
- package/Projections/declarative/projection.ts +59 -0
- package/Projections/index.ts +8 -0
- package/Projections/modelBound/FromEventMetadata.ts +10 -0
- package/Projections/modelBound/FromEventOptions.ts +12 -0
- package/Projections/modelBound/addFrom.ts +41 -0
- package/Projections/modelBound/childrenFrom.ts +52 -0
- package/Projections/modelBound/clearWith.ts +54 -0
- package/Projections/modelBound/count.ts +41 -0
- package/Projections/modelBound/decrement.ts +41 -0
- package/Projections/modelBound/fromEvent.ts +40 -0
- package/Projections/modelBound/fromEvery.ts +39 -0
- package/Projections/modelBound/increment.ts +41 -0
- package/Projections/modelBound/index.ts +38 -0
- package/Projections/modelBound/join.ts +44 -0
- package/Projections/modelBound/modelBound.ts +59 -0
- package/Projections/modelBound/nested.ts +29 -0
- package/Projections/modelBound/notRewindable.ts +24 -0
- package/Projections/modelBound/removedWith.ts +60 -0
- package/Projections/modelBound/removedWithJoin.ts +55 -0
- package/Projections/modelBound/setFrom.ts +41 -0
- package/Projections/modelBound/setFromContext.ts +41 -0
- package/Projections/modelBound/setValue.ts +41 -0
- package/Projections/modelBound/subtractFrom.ts +41 -0
- package/README.md +69 -0
- package/Reactors/IReactors.ts +19 -0
- package/Reactors/ReactorId.ts +14 -0
- package/Reactors/Reactors.ts +320 -0
- package/Reactors/index.ts +8 -0
- package/Reactors/reactor.ts +75 -0
- package/ReadModels/ReadModelId.ts +14 -0
- package/ReadModels/index.ts +6 -0
- package/ReadModels/readModel.ts +89 -0
- package/Reducers/IReducers.ts +19 -0
- package/Reducers/ReducerId.ts +14 -0
- package/Reducers/Reducers.ts +322 -0
- package/Reducers/index.ts +8 -0
- package/Reducers/reducer.ts +87 -0
- package/Schemas/JsonSchema.ts +18 -0
- package/Schemas/JsonSchemaGenerator.ts +107 -0
- package/Schemas/index.ts +6 -0
- package/Schemas/jsonSchemaProperty.ts +24 -0
- package/Tracing.ts +21 -0
- package/artifacts/DefaultClientArtifactsProvider.ts +56 -0
- package/artifacts/IClientArtifactsProvider.ts +30 -0
- package/artifacts/index.ts +5 -0
- package/connection/ChronicleConnection.ts +226 -0
- package/connection/ChronicleConnectionString.ts +4 -0
- package/connection/ChronicleServices.ts +4 -0
- package/connection/ConnectionLifecycle.ts +77 -0
- package/connection/DateTimeOffset.ts +4 -0
- package/connection/Guid.ts +4 -0
- package/connection/TokenProvider.ts +13 -0
- package/connection/index.ts +9 -0
- package/dist/ChronicleClient.d.ts +55 -0
- package/dist/ChronicleClient.d.ts.map +1 -0
- package/dist/ChronicleClient.js +396 -0
- package/dist/ChronicleClient.js.map +1 -0
- package/dist/ChronicleOptions.d.ts +54 -0
- package/dist/ChronicleOptions.d.ts.map +1 -0
- package/dist/ChronicleOptions.js +75 -0
- package/dist/ChronicleOptions.js.map +1 -0
- package/dist/EventSequences/AppendError.d.ts +8 -0
- package/dist/EventSequences/AppendError.d.ts.map +1 -0
- package/dist/EventSequences/AppendError.js +4 -0
- package/dist/EventSequences/AppendError.js.map +1 -0
- package/dist/EventSequences/AppendOptions.d.ts +11 -0
- package/dist/EventSequences/AppendOptions.d.ts.map +1 -0
- package/dist/EventSequences/AppendOptions.js +4 -0
- package/dist/EventSequences/AppendOptions.js.map +1 -0
- package/dist/EventSequences/AppendResult.d.ts +17 -0
- package/dist/EventSequences/AppendResult.d.ts.map +1 -0
- package/dist/EventSequences/AppendResult.js +4 -0
- package/dist/EventSequences/AppendResult.js.map +1 -0
- package/dist/EventSequences/ConstraintViolation.d.ts +12 -0
- package/dist/EventSequences/ConstraintViolation.d.ts.map +1 -0
- package/dist/EventSequences/ConstraintViolation.js +4 -0
- package/dist/EventSequences/ConstraintViolation.js.map +1 -0
- package/dist/EventSequences/EventLog.d.ts +11 -0
- package/dist/EventSequences/EventLog.d.ts.map +1 -0
- package/dist/EventSequences/EventLog.js +14 -0
- package/dist/EventSequences/EventLog.js.map +1 -0
- package/dist/EventSequences/EventSequence.d.ts +27 -0
- package/dist/EventSequences/EventSequence.d.ts.map +1 -0
- package/dist/EventSequences/EventSequence.js +337 -0
- package/dist/EventSequences/EventSequence.js.map +1 -0
- package/dist/EventSequences/EventSequenceId.d.ts +12 -0
- package/dist/EventSequences/EventSequenceId.d.ts.map +1 -0
- package/dist/EventSequences/EventSequenceId.js +18 -0
- package/dist/EventSequences/EventSequenceId.js.map +1 -0
- package/dist/EventSequences/EventSequenceNumber.d.ts +26 -0
- package/dist/EventSequences/EventSequenceNumber.d.ts.map +1 -0
- package/dist/EventSequences/EventSequenceNumber.js +36 -0
- package/dist/EventSequences/EventSequenceNumber.js.map +1 -0
- package/dist/EventSequences/IEventLog.d.ts +8 -0
- package/dist/EventSequences/IEventLog.d.ts.map +1 -0
- package/dist/EventSequences/IEventLog.js +4 -0
- package/dist/EventSequences/IEventLog.js.map +1 -0
- package/dist/EventSequences/IEventSequence.d.ts +40 -0
- package/dist/EventSequences/IEventSequence.d.ts.map +1 -0
- package/dist/EventSequences/IEventSequence.js +4 -0
- package/dist/EventSequences/IEventSequence.js.map +1 -0
- package/dist/EventSequences/index.d.ts +11 -0
- package/dist/EventSequences/index.d.ts.map +1 -0
- package/dist/EventSequences/index.js +7 -0
- package/dist/EventSequences/index.js.map +1 -0
- package/dist/EventStore.d.ts +42 -0
- package/dist/EventStore.d.ts.map +1 -0
- package/dist/EventStore.js +111 -0
- package/dist/EventStore.js.map +1 -0
- package/dist/EventStoreName.d.ts +10 -0
- package/dist/EventStoreName.d.ts.map +1 -0
- package/dist/EventStoreName.js +16 -0
- package/dist/EventStoreName.js.map +1 -0
- package/dist/EventStoreNamespaceName.d.ts +12 -0
- package/dist/EventStoreNamespaceName.d.ts.map +1 -0
- package/dist/EventStoreNamespaceName.js +18 -0
- package/dist/EventStoreNamespaceName.js.map +1 -0
- package/dist/Events/AppendedEvent.d.ts +14 -0
- package/dist/Events/AppendedEvent.d.ts.map +1 -0
- package/dist/Events/AppendedEvent.js +4 -0
- package/dist/Events/AppendedEvent.js.map +1 -0
- package/dist/Events/CausationEntry.d.ts +10 -0
- package/dist/Events/CausationEntry.d.ts.map +1 -0
- package/dist/Events/CausationEntry.js +4 -0
- package/dist/Events/CausationEntry.js.map +1 -0
- package/dist/Events/Constraints/ConstraintBuilder.d.ts +42 -0
- package/dist/Events/Constraints/ConstraintBuilder.d.ts.map +1 -0
- package/dist/Events/Constraints/ConstraintBuilder.js +55 -0
- package/dist/Events/Constraints/ConstraintBuilder.js.map +1 -0
- package/dist/Events/Constraints/ConstraintId.d.ts +10 -0
- package/dist/Events/Constraints/ConstraintId.d.ts.map +1 -0
- package/dist/Events/Constraints/ConstraintId.js +16 -0
- package/dist/Events/Constraints/ConstraintId.js.map +1 -0
- package/dist/Events/Constraints/Constraints.d.ts +27 -0
- package/dist/Events/Constraints/Constraints.d.ts.map +1 -0
- package/dist/Events/Constraints/Constraints.js +104 -0
- package/dist/Events/Constraints/Constraints.js.map +1 -0
- package/dist/Events/Constraints/IConstraint.d.ts +15 -0
- package/dist/Events/Constraints/IConstraint.d.ts.map +1 -0
- package/dist/Events/Constraints/IConstraint.js +4 -0
- package/dist/Events/Constraints/IConstraint.js.map +1 -0
- package/dist/Events/Constraints/IConstraintBuilder.d.ts +37 -0
- package/dist/Events/Constraints/IConstraintBuilder.d.ts.map +1 -0
- package/dist/Events/Constraints/IConstraintBuilder.js +4 -0
- package/dist/Events/Constraints/IConstraintBuilder.js.map +1 -0
- package/dist/Events/Constraints/IConstraints.d.ts +23 -0
- package/dist/Events/Constraints/IConstraints.d.ts.map +1 -0
- package/dist/Events/Constraints/IConstraints.js +4 -0
- package/dist/Events/Constraints/IConstraints.js.map +1 -0
- package/dist/Events/Constraints/IUniqueConstraintBuilder.d.ts +44 -0
- package/dist/Events/Constraints/IUniqueConstraintBuilder.d.ts.map +1 -0
- package/dist/Events/Constraints/IUniqueConstraintBuilder.js +4 -0
- package/dist/Events/Constraints/IUniqueConstraintBuilder.js.map +1 -0
- package/dist/Events/Constraints/UniqueConstraintBuilder.d.ts +42 -0
- package/dist/Events/Constraints/UniqueConstraintBuilder.d.ts.map +1 -0
- package/dist/Events/Constraints/UniqueConstraintBuilder.js +72 -0
- package/dist/Events/Constraints/UniqueConstraintBuilder.js.map +1 -0
- package/dist/Events/Constraints/constraint.d.ts +29 -0
- package/dist/Events/Constraints/constraint.d.ts.map +1 -0
- package/dist/Events/Constraints/constraint.js +39 -0
- package/dist/Events/Constraints/constraint.js.map +1 -0
- package/dist/Events/Constraints/index.d.ts +13 -0
- package/dist/Events/Constraints/index.d.ts.map +1 -0
- package/dist/Events/Constraints/index.js +8 -0
- package/dist/Events/Constraints/index.js.map +1 -0
- package/dist/Events/EventContext.d.ts +20 -0
- package/dist/Events/EventContext.d.ts.map +1 -0
- package/dist/Events/EventContext.js +4 -0
- package/dist/Events/EventContext.js.map +1 -0
- package/dist/Events/EventType.d.ts +23 -0
- package/dist/Events/EventType.d.ts.map +1 -0
- package/dist/Events/EventType.js +40 -0
- package/dist/Events/EventType.js.map +1 -0
- package/dist/Events/EventTypeGeneration.d.ts +14 -0
- package/dist/Events/EventTypeGeneration.d.ts.map +1 -0
- package/dist/Events/EventTypeGeneration.js +20 -0
- package/dist/Events/EventTypeGeneration.js.map +1 -0
- package/dist/Events/EventTypeId.d.ts +14 -0
- package/dist/Events/EventTypeId.d.ts.map +1 -0
- package/dist/Events/EventTypeId.js +20 -0
- package/dist/Events/EventTypeId.js.map +1 -0
- package/dist/Events/EventTypes.d.ts +33 -0
- package/dist/Events/EventTypes.d.ts.map +1 -0
- package/dist/Events/EventTypes.js +83 -0
- package/dist/Events/EventTypes.js.map +1 -0
- package/dist/Events/IEventTypes.d.ts +32 -0
- package/dist/Events/IEventTypes.d.ts.map +1 -0
- package/dist/Events/IEventTypes.js +4 -0
- package/dist/Events/IEventTypes.js.map +1 -0
- package/dist/Events/eventTypeDecorator.d.ts +71 -0
- package/dist/Events/eventTypeDecorator.d.ts.map +1 -0
- package/dist/Events/eventTypeDecorator.js +86 -0
- package/dist/Events/eventTypeDecorator.js.map +1 -0
- package/dist/Events/index.d.ts +12 -0
- package/dist/Events/index.d.ts.map +1 -0
- package/dist/Events/index.js +9 -0
- package/dist/Events/index.js.map +1 -0
- package/dist/Grpc.d.ts +19 -0
- package/dist/Grpc.d.ts.map +1 -0
- package/dist/Grpc.js +33 -0
- package/dist/Grpc.js.map +1 -0
- package/dist/IChronicleClient.d.ts +33 -0
- package/dist/IChronicleClient.d.ts.map +1 -0
- package/dist/IChronicleClient.js +4 -0
- package/dist/IChronicleClient.js.map +1 -0
- package/dist/IEventStore.d.ts +44 -0
- package/dist/IEventStore.d.ts.map +1 -0
- package/dist/IEventStore.js +4 -0
- package/dist/IEventStore.js.map +1 -0
- package/dist/Metrics.d.ts +70 -0
- package/dist/Metrics.d.ts.map +1 -0
- package/dist/Metrics.js +100 -0
- package/dist/Metrics.js.map +1 -0
- package/dist/Observation/ObserverId.d.ts +10 -0
- package/dist/Observation/ObserverId.d.ts.map +1 -0
- package/dist/Observation/ObserverId.js +16 -0
- package/dist/Observation/ObserverId.js.map +1 -0
- package/dist/Observation/ObserverRunningState.d.ts +24 -0
- package/dist/Observation/ObserverRunningState.d.ts.map +1 -0
- package/dist/Observation/ObserverRunningState.js +27 -0
- package/dist/Observation/ObserverRunningState.js.map +1 -0
- package/dist/Observation/index.d.ts +3 -0
- package/dist/Observation/index.d.ts.map +1 -0
- package/dist/Observation/index.js +5 -0
- package/dist/Observation/index.js.map +1 -0
- package/dist/Projections/IProjections.d.ts +16 -0
- package/dist/Projections/IProjections.d.ts.map +1 -0
- package/dist/Projections/IProjections.js +4 -0
- package/dist/Projections/IProjections.js.map +1 -0
- package/dist/Projections/ProjectionId.d.ts +10 -0
- package/dist/Projections/ProjectionId.d.ts.map +1 -0
- package/dist/Projections/ProjectionId.js +16 -0
- package/dist/Projections/ProjectionId.js.map +1 -0
- package/dist/Projections/Projections.d.ts +36 -0
- package/dist/Projections/Projections.d.ts.map +1 -0
- package/dist/Projections/Projections.js +390 -0
- package/dist/Projections/Projections.js.map +1 -0
- package/dist/Projections/declarative/AllSetBuilder.d.ts +20 -0
- package/dist/Projections/declarative/AllSetBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/AllSetBuilder.js +37 -0
- package/dist/Projections/declarative/AllSetBuilder.js.map +1 -0
- package/dist/Projections/declarative/FromBuilder.d.ts +56 -0
- package/dist/Projections/declarative/FromBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/FromBuilder.js +105 -0
- package/dist/Projections/declarative/FromBuilder.js.map +1 -0
- package/dist/Projections/declarative/FromEveryBuilder.d.ts +22 -0
- package/dist/Projections/declarative/FromEveryBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/FromEveryBuilder.js +28 -0
- package/dist/Projections/declarative/FromEveryBuilder.js.map +1 -0
- package/dist/Projections/declarative/IAddBuilder.d.ts +15 -0
- package/dist/Projections/declarative/IAddBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IAddBuilder.js +4 -0
- package/dist/Projections/declarative/IAddBuilder.js.map +1 -0
- package/dist/Projections/declarative/IAddChildBuilder.d.ts +21 -0
- package/dist/Projections/declarative/IAddChildBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IAddChildBuilder.js +4 -0
- package/dist/Projections/declarative/IAddChildBuilder.js.map +1 -0
- package/dist/Projections/declarative/IAllSetBuilder.d.ts +26 -0
- package/dist/Projections/declarative/IAllSetBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IAllSetBuilder.js +4 -0
- package/dist/Projections/declarative/IAllSetBuilder.js.map +1 -0
- package/dist/Projections/declarative/IChildrenBuilder.d.ts +22 -0
- package/dist/Projections/declarative/IChildrenBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IChildrenBuilder.js +4 -0
- package/dist/Projections/declarative/IChildrenBuilder.js.map +1 -0
- package/dist/Projections/declarative/ICompositeKeyBuilder.d.ts +16 -0
- package/dist/Projections/declarative/ICompositeKeyBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/ICompositeKeyBuilder.js +4 -0
- package/dist/Projections/declarative/ICompositeKeyBuilder.js.map +1 -0
- package/dist/Projections/declarative/IFromBuilder.d.ts +9 -0
- package/dist/Projections/declarative/IFromBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IFromBuilder.js +4 -0
- package/dist/Projections/declarative/IFromBuilder.js.map +1 -0
- package/dist/Projections/declarative/IFromEveryBuilder.d.ts +20 -0
- package/dist/Projections/declarative/IFromEveryBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IFromEveryBuilder.js +4 -0
- package/dist/Projections/declarative/IFromEveryBuilder.js.map +1 -0
- package/dist/Projections/declarative/IJoinBuilder.d.ts +16 -0
- package/dist/Projections/declarative/IJoinBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IJoinBuilder.js +4 -0
- package/dist/Projections/declarative/IJoinBuilder.js.map +1 -0
- package/dist/Projections/declarative/INestedBuilder.d.ts +15 -0
- package/dist/Projections/declarative/INestedBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/INestedBuilder.js +4 -0
- package/dist/Projections/declarative/INestedBuilder.js.map +1 -0
- package/dist/Projections/declarative/IProjectionBuilder.d.ts +80 -0
- package/dist/Projections/declarative/IProjectionBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IProjectionBuilder.js +4 -0
- package/dist/Projections/declarative/IProjectionBuilder.js.map +1 -0
- package/dist/Projections/declarative/IProjectionBuilderFor.d.ts +31 -0
- package/dist/Projections/declarative/IProjectionBuilderFor.d.ts.map +1 -0
- package/dist/Projections/declarative/IProjectionBuilderFor.js +4 -0
- package/dist/Projections/declarative/IProjectionBuilderFor.js.map +1 -0
- package/dist/Projections/declarative/IProjectionFor.d.ts +15 -0
- package/dist/Projections/declarative/IProjectionFor.d.ts.map +1 -0
- package/dist/Projections/declarative/IProjectionFor.js +4 -0
- package/dist/Projections/declarative/IProjectionFor.js.map +1 -0
- package/dist/Projections/declarative/IReadModelPropertiesBuilder.d.ts +111 -0
- package/dist/Projections/declarative/IReadModelPropertiesBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IReadModelPropertiesBuilder.js +4 -0
- package/dist/Projections/declarative/IReadModelPropertiesBuilder.js.map +1 -0
- package/dist/Projections/declarative/IRemovedWithBuilder.d.ts +21 -0
- package/dist/Projections/declarative/IRemovedWithBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IRemovedWithBuilder.js +4 -0
- package/dist/Projections/declarative/IRemovedWithBuilder.js.map +1 -0
- package/dist/Projections/declarative/IRemovedWithJoinBuilder.d.ts +21 -0
- package/dist/Projections/declarative/IRemovedWithJoinBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/IRemovedWithJoinBuilder.js +4 -0
- package/dist/Projections/declarative/IRemovedWithJoinBuilder.js.map +1 -0
- package/dist/Projections/declarative/ISetBuilder.d.ts +32 -0
- package/dist/Projections/declarative/ISetBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/ISetBuilder.js +4 -0
- package/dist/Projections/declarative/ISetBuilder.js.map +1 -0
- package/dist/Projections/declarative/ISubtractBuilder.d.ts +15 -0
- package/dist/Projections/declarative/ISubtractBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/ISubtractBuilder.js +4 -0
- package/dist/Projections/declarative/ISubtractBuilder.js.map +1 -0
- package/dist/Projections/declarative/JoinBuilder.d.ts +58 -0
- package/dist/Projections/declarative/JoinBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/JoinBuilder.js +107 -0
- package/dist/Projections/declarative/JoinBuilder.js.map +1 -0
- package/dist/Projections/declarative/ProjectionBuilderFor.d.ts +68 -0
- package/dist/Projections/declarative/ProjectionBuilderFor.d.ts.map +1 -0
- package/dist/Projections/declarative/ProjectionBuilderFor.js +207 -0
- package/dist/Projections/declarative/ProjectionBuilderFor.js.map +1 -0
- package/dist/Projections/declarative/RemovedWithBuilder.d.ts +22 -0
- package/dist/Projections/declarative/RemovedWithBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/RemovedWithBuilder.js +28 -0
- package/dist/Projections/declarative/RemovedWithBuilder.js.map +1 -0
- package/dist/Projections/declarative/RemovedWithJoinBuilder.d.ts +22 -0
- package/dist/Projections/declarative/RemovedWithJoinBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/RemovedWithJoinBuilder.js +31 -0
- package/dist/Projections/declarative/RemovedWithJoinBuilder.js.map +1 -0
- package/dist/Projections/declarative/SetBuilder.d.ts +23 -0
- package/dist/Projections/declarative/SetBuilder.d.ts.map +1 -0
- package/dist/Projections/declarative/SetBuilder.js +43 -0
- package/dist/Projections/declarative/SetBuilder.js.map +1 -0
- package/dist/Projections/declarative/index.d.ts +24 -0
- package/dist/Projections/declarative/index.d.ts.map +1 -0
- package/dist/Projections/declarative/index.js +8 -0
- package/dist/Projections/declarative/index.js.map +1 -0
- package/dist/Projections/declarative/projection.d.ts +31 -0
- package/dist/Projections/declarative/projection.d.ts.map +1 -0
- package/dist/Projections/declarative/projection.js +39 -0
- package/dist/Projections/declarative/projection.js.map +1 -0
- package/dist/Projections/index.d.ts +6 -0
- package/dist/Projections/index.d.ts.map +1 -0
- package/dist/Projections/index.js +7 -0
- package/dist/Projections/index.js.map +1 -0
- package/dist/Projections/modelBound/FromEventMetadata.d.ts +7 -0
- package/dist/Projections/modelBound/FromEventMetadata.d.ts.map +1 -0
- package/dist/Projections/modelBound/FromEventMetadata.js +4 -0
- package/dist/Projections/modelBound/FromEventMetadata.js.map +1 -0
- package/dist/Projections/modelBound/FromEventOptions.d.ts +10 -0
- package/dist/Projections/modelBound/FromEventOptions.d.ts.map +1 -0
- package/dist/Projections/modelBound/FromEventOptions.js +4 -0
- package/dist/Projections/modelBound/FromEventOptions.js.map +1 -0
- package/dist/Projections/modelBound/addFrom.d.ts +23 -0
- package/dist/Projections/modelBound/addFrom.d.ts.map +1 -0
- package/dist/Projections/modelBound/addFrom.js +30 -0
- package/dist/Projections/modelBound/addFrom.js.map +1 -0
- package/dist/Projections/modelBound/childrenFrom.d.ts +29 -0
- package/dist/Projections/modelBound/childrenFrom.d.ts.map +1 -0
- package/dist/Projections/modelBound/childrenFrom.js +32 -0
- package/dist/Projections/modelBound/childrenFrom.js.map +1 -0
- package/dist/Projections/modelBound/clearWith.d.ts +28 -0
- package/dist/Projections/modelBound/clearWith.d.ts.map +1 -0
- package/dist/Projections/modelBound/clearWith.js +45 -0
- package/dist/Projections/modelBound/clearWith.js.map +1 -0
- package/dist/Projections/modelBound/count.d.ts +23 -0
- package/dist/Projections/modelBound/count.d.ts.map +1 -0
- package/dist/Projections/modelBound/count.js +30 -0
- package/dist/Projections/modelBound/count.js.map +1 -0
- package/dist/Projections/modelBound/decrement.d.ts +23 -0
- package/dist/Projections/modelBound/decrement.d.ts.map +1 -0
- package/dist/Projections/modelBound/decrement.js +30 -0
- package/dist/Projections/modelBound/decrement.js.map +1 -0
- package/dist/Projections/modelBound/fromEvent.d.ts +23 -0
- package/dist/Projections/modelBound/fromEvent.d.ts.map +1 -0
- package/dist/Projections/modelBound/fromEvent.js +34 -0
- package/dist/Projections/modelBound/fromEvent.js.map +1 -0
- package/dist/Projections/modelBound/fromEvery.d.ts +23 -0
- package/dist/Projections/modelBound/fromEvery.d.ts.map +1 -0
- package/dist/Projections/modelBound/fromEvery.js +28 -0
- package/dist/Projections/modelBound/fromEvery.js.map +1 -0
- package/dist/Projections/modelBound/increment.d.ts +23 -0
- package/dist/Projections/modelBound/increment.d.ts.map +1 -0
- package/dist/Projections/modelBound/increment.js +30 -0
- package/dist/Projections/modelBound/increment.js.map +1 -0
- package/dist/Projections/modelBound/index.d.ts +36 -0
- package/dist/Projections/modelBound/index.d.ts.map +1 -0
- package/dist/Projections/modelBound/index.js +21 -0
- package/dist/Projections/modelBound/index.js.map +1 -0
- package/dist/Projections/modelBound/join.d.ts +26 -0
- package/dist/Projections/modelBound/join.d.ts.map +1 -0
- package/dist/Projections/modelBound/join.js +31 -0
- package/dist/Projections/modelBound/join.js.map +1 -0
- package/dist/Projections/modelBound/modelBound.d.ts +31 -0
- package/dist/Projections/modelBound/modelBound.d.ts.map +1 -0
- package/dist/Projections/modelBound/modelBound.js +39 -0
- package/dist/Projections/modelBound/modelBound.js.map +1 -0
- package/dist/Projections/modelBound/nested.d.ts +16 -0
- package/dist/Projections/modelBound/nested.d.ts.map +1 -0
- package/dist/Projections/modelBound/nested.js +26 -0
- package/dist/Projections/modelBound/nested.js.map +1 -0
- package/dist/Projections/modelBound/notRewindable.d.ts +14 -0
- package/dist/Projections/modelBound/notRewindable.d.ts.map +1 -0
- package/dist/Projections/modelBound/notRewindable.js +21 -0
- package/dist/Projections/modelBound/notRewindable.js.map +1 -0
- package/dist/Projections/modelBound/removedWith.d.ts +34 -0
- package/dist/Projections/modelBound/removedWith.d.ts.map +1 -0
- package/dist/Projections/modelBound/removedWith.js +47 -0
- package/dist/Projections/modelBound/removedWith.js.map +1 -0
- package/dist/Projections/modelBound/removedWithJoin.d.ts +29 -0
- package/dist/Projections/modelBound/removedWithJoin.d.ts.map +1 -0
- package/dist/Projections/modelBound/removedWithJoin.js +44 -0
- package/dist/Projections/modelBound/removedWithJoin.js.map +1 -0
- package/dist/Projections/modelBound/setFrom.d.ts +23 -0
- package/dist/Projections/modelBound/setFrom.d.ts.map +1 -0
- package/dist/Projections/modelBound/setFrom.js +30 -0
- package/dist/Projections/modelBound/setFrom.js.map +1 -0
- package/dist/Projections/modelBound/setFromContext.d.ts +23 -0
- package/dist/Projections/modelBound/setFromContext.d.ts.map +1 -0
- package/dist/Projections/modelBound/setFromContext.js +30 -0
- package/dist/Projections/modelBound/setFromContext.js.map +1 -0
- package/dist/Projections/modelBound/setValue.d.ts +23 -0
- package/dist/Projections/modelBound/setValue.d.ts.map +1 -0
- package/dist/Projections/modelBound/setValue.js +30 -0
- package/dist/Projections/modelBound/setValue.js.map +1 -0
- package/dist/Projections/modelBound/subtractFrom.d.ts +23 -0
- package/dist/Projections/modelBound/subtractFrom.d.ts.map +1 -0
- package/dist/Projections/modelBound/subtractFrom.js +30 -0
- package/dist/Projections/modelBound/subtractFrom.js.map +1 -0
- package/dist/Reactors/IReactors.d.ts +16 -0
- package/dist/Reactors/IReactors.d.ts.map +1 -0
- package/dist/Reactors/IReactors.js +4 -0
- package/dist/Reactors/IReactors.js.map +1 -0
- package/dist/Reactors/ReactorId.d.ts +10 -0
- package/dist/Reactors/ReactorId.d.ts.map +1 -0
- package/dist/Reactors/ReactorId.js +16 -0
- package/dist/Reactors/ReactorId.js.map +1 -0
- package/dist/Reactors/Reactors.d.ts +38 -0
- package/dist/Reactors/Reactors.d.ts.map +1 -0
- package/dist/Reactors/Reactors.js +279 -0
- package/dist/Reactors/Reactors.js.map +1 -0
- package/dist/Reactors/index.d.ts +6 -0
- package/dist/Reactors/index.d.ts.map +1 -0
- package/dist/Reactors/index.js +6 -0
- package/dist/Reactors/index.js.map +1 -0
- package/dist/Reactors/reactor.d.ts +47 -0
- package/dist/Reactors/reactor.d.ts.map +1 -0
- package/dist/Reactors/reactor.js +55 -0
- package/dist/Reactors/reactor.js.map +1 -0
- package/dist/ReadModels/ReadModelId.d.ts +10 -0
- package/dist/ReadModels/ReadModelId.d.ts.map +1 -0
- package/dist/ReadModels/ReadModelId.js +16 -0
- package/dist/ReadModels/ReadModelId.js.map +1 -0
- package/dist/ReadModels/index.d.ts +4 -0
- package/dist/ReadModels/index.d.ts.map +1 -0
- package/dist/ReadModels/index.js +5 -0
- package/dist/ReadModels/index.js.map +1 -0
- package/dist/ReadModels/readModel.d.ts +33 -0
- package/dist/ReadModels/readModel.d.ts.map +1 -0
- package/dist/ReadModels/readModel.js +64 -0
- package/dist/ReadModels/readModel.js.map +1 -0
- package/dist/Reducers/IReducers.d.ts +16 -0
- package/dist/Reducers/IReducers.d.ts.map +1 -0
- package/dist/Reducers/IReducers.js +4 -0
- package/dist/Reducers/IReducers.js.map +1 -0
- package/dist/Reducers/ReducerId.d.ts +10 -0
- package/dist/Reducers/ReducerId.d.ts.map +1 -0
- package/dist/Reducers/ReducerId.js +16 -0
- package/dist/Reducers/ReducerId.js.map +1 -0
- package/dist/Reducers/Reducers.d.ts +38 -0
- package/dist/Reducers/Reducers.d.ts.map +1 -0
- package/dist/Reducers/Reducers.js +279 -0
- package/dist/Reducers/Reducers.js.map +1 -0
- package/dist/Reducers/index.d.ts +6 -0
- package/dist/Reducers/index.d.ts.map +1 -0
- package/dist/Reducers/index.js +6 -0
- package/dist/Reducers/index.js.map +1 -0
- package/dist/Reducers/reducer.d.ts +51 -0
- package/dist/Reducers/reducer.d.ts.map +1 -0
- package/dist/Reducers/reducer.js +59 -0
- package/dist/Reducers/reducer.js.map +1 -0
- package/dist/Schemas/JsonSchema.d.ts +16 -0
- package/dist/Schemas/JsonSchema.d.ts.map +1 -0
- package/dist/Schemas/JsonSchema.js +4 -0
- package/dist/Schemas/JsonSchema.js.map +1 -0
- package/dist/Schemas/JsonSchemaGenerator.d.ts +26 -0
- package/dist/Schemas/JsonSchemaGenerator.d.ts.map +1 -0
- package/dist/Schemas/JsonSchemaGenerator.js +90 -0
- package/dist/Schemas/JsonSchemaGenerator.js.map +1 -0
- package/dist/Schemas/index.d.ts +4 -0
- package/dist/Schemas/index.d.ts.map +1 -0
- package/dist/Schemas/index.js +5 -0
- package/dist/Schemas/index.js.map +1 -0
- package/dist/Schemas/jsonSchemaProperty.d.ts +13 -0
- package/dist/Schemas/jsonSchemaProperty.d.ts.map +1 -0
- package/dist/Schemas/jsonSchemaProperty.js +22 -0
- package/dist/Schemas/jsonSchemaProperty.js.map +1 -0
- package/dist/Tracing.d.ts +16 -0
- package/dist/Tracing.d.ts.map +1 -0
- package/dist/Tracing.js +19 -0
- package/dist/Tracing.js.map +1 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts +31 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.js +48 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -0
- package/dist/artifacts/IClientArtifactsProvider.d.ts +21 -0
- package/dist/artifacts/IClientArtifactsProvider.d.ts.map +1 -0
- package/dist/artifacts/IClientArtifactsProvider.js +4 -0
- package/dist/artifacts/IClientArtifactsProvider.js.map +1 -0
- package/dist/artifacts/index.d.ts +3 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +4 -0
- package/dist/artifacts/index.js.map +1 -0
- package/dist/connection/ChronicleConnection.d.ts +117 -0
- package/dist/connection/ChronicleConnection.d.ts.map +1 -0
- package/dist/connection/ChronicleConnection.js +194 -0
- package/dist/connection/ChronicleConnection.js.map +1 -0
- package/dist/connection/ChronicleConnectionString.d.ts +2 -0
- package/dist/connection/ChronicleConnectionString.d.ts.map +1 -0
- package/dist/connection/ChronicleConnectionString.js +4 -0
- package/dist/connection/ChronicleConnectionString.js.map +1 -0
- package/dist/connection/ChronicleServices.d.ts +2 -0
- package/dist/connection/ChronicleServices.d.ts.map +1 -0
- package/dist/connection/ChronicleServices.js +4 -0
- package/dist/connection/ChronicleServices.js.map +1 -0
- package/dist/connection/ConnectionLifecycle.d.ts +41 -0
- package/dist/connection/ConnectionLifecycle.d.ts.map +1 -0
- package/dist/connection/ConnectionLifecycle.js +66 -0
- package/dist/connection/ConnectionLifecycle.js.map +1 -0
- package/dist/connection/DateTimeOffset.d.ts +2 -0
- package/dist/connection/DateTimeOffset.d.ts.map +1 -0
- package/dist/connection/DateTimeOffset.js +4 -0
- package/dist/connection/DateTimeOffset.js.map +1 -0
- package/dist/connection/Guid.d.ts +2 -0
- package/dist/connection/Guid.d.ts.map +1 -0
- package/dist/connection/Guid.js +4 -0
- package/dist/connection/Guid.js.map +1 -0
- package/dist/connection/TokenProvider.d.ts +5 -0
- package/dist/connection/TokenProvider.d.ts.map +1 -0
- package/dist/connection/TokenProvider.js +4 -0
- package/dist/connection/TokenProvider.js.map +1 -0
- package/dist/connection/index.d.ts +7 -0
- package/dist/connection/index.d.ts.map +1 -0
- package/dist/connection/index.js +7 -0
- package/dist/connection/index.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/DecoratorType.d.ts +20 -0
- package/dist/types/DecoratorType.d.ts.map +1 -0
- package/dist/types/DecoratorType.js +23 -0
- package/dist/types/DecoratorType.js.map +1 -0
- package/dist/types/TypeDiscoverer.d.ts +54 -0
- package/dist/types/TypeDiscoverer.d.ts.map +1 -0
- package/dist/types/TypeDiscoverer.js +91 -0
- package/dist/types/TypeDiscoverer.js.map +1 -0
- package/dist/types/TypeIntrospector.d.ts +30 -0
- package/dist/types/TypeIntrospector.d.ts.map +1 -0
- package/dist/types/TypeIntrospector.js +154 -0
- package/dist/types/TypeIntrospector.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/index.ts +24 -0
- package/package.json +38 -0
- package/types/DecoratorType.ts +28 -0
- package/types/TypeDiscoverer.ts +109 -0
- package/types/TypeIntrospector.ts +176 -0
- package/types/index.ts +6 -0
|
@@ -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
|
+
import { EventContext } from './EventContext';
|
|
5
|
+
import { EventType } from './EventType';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents an event that has been appended to an event sequence.
|
|
9
|
+
*/
|
|
10
|
+
export interface AppendedEvent<TContent = Record<string, unknown>> {
|
|
11
|
+
/** The context of the event. */
|
|
12
|
+
readonly context: EventContext;
|
|
13
|
+
|
|
14
|
+
/** The type of the event. */
|
|
15
|
+
readonly eventType: EventType;
|
|
16
|
+
|
|
17
|
+
/** The deserialized content of the event. */
|
|
18
|
+
readonly content: TContent;
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 a single entry in the causation chain of an event.
|
|
6
|
+
*/
|
|
7
|
+
export interface CausationEntry {
|
|
8
|
+
/** The type identifier of the causing operation. */
|
|
9
|
+
readonly type: string;
|
|
10
|
+
|
|
11
|
+
/** The properties associated with the causation entry. */
|
|
12
|
+
readonly properties: Readonly<Record<string, string>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { getEventTypeFor } from '../eventTypeDecorator';
|
|
5
|
+
import { IConstraintBuilder } from './IConstraintBuilder';
|
|
6
|
+
import { IUniqueConstraintBuilder } from './IUniqueConstraintBuilder';
|
|
7
|
+
import { UniqueConstraintBuilder, UniqueConstraintCapture } from './UniqueConstraintBuilder';
|
|
8
|
+
|
|
9
|
+
/** Represents the captured scope for a constraint. */
|
|
10
|
+
export interface ConstraintScopeCapture {
|
|
11
|
+
perEventSourceType: boolean;
|
|
12
|
+
perEventStreamType: boolean;
|
|
13
|
+
perEventStreamId: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Represents the captured definition of a unique event type constraint. */
|
|
17
|
+
export interface UniqueEventTypeCapture {
|
|
18
|
+
eventTypeId: string;
|
|
19
|
+
message?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Represents the full captured definition of a constraint. */
|
|
24
|
+
export interface ConstraintCapture {
|
|
25
|
+
name: string;
|
|
26
|
+
scope: ConstraintScopeCapture;
|
|
27
|
+
uniqueConstraint?: UniqueConstraintCapture;
|
|
28
|
+
uniqueEventType?: UniqueEventTypeCapture;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Implements {@link IConstraintBuilder}, capturing the constraint definition
|
|
33
|
+
* for later serialization and registration with the Kernel.
|
|
34
|
+
*/
|
|
35
|
+
export class ConstraintBuilder implements IConstraintBuilder {
|
|
36
|
+
readonly capture: ConstraintCapture;
|
|
37
|
+
private _uniqueBuilder?: UniqueConstraintBuilder;
|
|
38
|
+
|
|
39
|
+
constructor(name: string) {
|
|
40
|
+
this.capture = {
|
|
41
|
+
name,
|
|
42
|
+
scope: { perEventSourceType: false, perEventStreamType: false, perEventStreamId: false }
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @inheritdoc */
|
|
47
|
+
perEventSourceType(): IConstraintBuilder {
|
|
48
|
+
this.capture.scope.perEventSourceType = true;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** @inheritdoc */
|
|
53
|
+
perEventStreamType(): IConstraintBuilder {
|
|
54
|
+
this.capture.scope.perEventStreamType = true;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** @inheritdoc */
|
|
59
|
+
perEventStreamId(): IConstraintBuilder {
|
|
60
|
+
this.capture.scope.perEventStreamId = true;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @inheritdoc */
|
|
65
|
+
unique(callback: (builder: IUniqueConstraintBuilder) => void): IConstraintBuilder {
|
|
66
|
+
const uniqueCapture: UniqueConstraintCapture = {
|
|
67
|
+
eventDefinitions: [],
|
|
68
|
+
ignoreCasing: false
|
|
69
|
+
};
|
|
70
|
+
this.capture.uniqueConstraint = uniqueCapture;
|
|
71
|
+
this._uniqueBuilder = new UniqueConstraintBuilder(uniqueCapture);
|
|
72
|
+
callback(this._uniqueBuilder);
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** @inheritdoc */
|
|
77
|
+
uniqueFor(eventType: Function, message?: string, name?: string): IConstraintBuilder {
|
|
78
|
+
const et = getEventTypeFor(eventType);
|
|
79
|
+
this.capture.uniqueEventType = {
|
|
80
|
+
eventTypeId: et.id.value,
|
|
81
|
+
message,
|
|
82
|
+
name
|
|
83
|
+
};
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -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
|
+
/**
|
|
5
|
+
* Unique identifier for a constraint.
|
|
6
|
+
*/
|
|
7
|
+
export class ConstraintId {
|
|
8
|
+
constructor(readonly value: string) {}
|
|
9
|
+
|
|
10
|
+
/** @inheritdoc */
|
|
11
|
+
toString(): string {
|
|
12
|
+
return this.value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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 { ConstraintType } from '@cratis/chronicle.contracts';
|
|
5
|
+
import { IClientArtifactsProvider } from '../../artifacts';
|
|
6
|
+
import { ChronicleConnection } from '../../connection';
|
|
7
|
+
import { ConstraintId } from './ConstraintId';
|
|
8
|
+
import { IConstraint } from './IConstraint';
|
|
9
|
+
import { IConstraints } from './IConstraints';
|
|
10
|
+
import { ConstraintBuilder, ConstraintCapture } from './ConstraintBuilder';
|
|
11
|
+
import { getConstraintMetadata } from './constraint';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Manages discovery and registration of constraints with the Chronicle Kernel.
|
|
15
|
+
*/
|
|
16
|
+
export class Constraints implements IConstraints {
|
|
17
|
+
private readonly _captures = new Map<string, ConstraintCapture>();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new {@link Constraints} instance.
|
|
21
|
+
* @param _eventStore - The name of the event store these constraints belong to.
|
|
22
|
+
* @param _connection - The connection used to communicate with the Kernel.
|
|
23
|
+
* @param _clientArtifacts - Provider for discovered client artifact types.
|
|
24
|
+
*/
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly _eventStore: string,
|
|
27
|
+
private readonly _connection: ChronicleConnection,
|
|
28
|
+
private readonly _clientArtifacts: IClientArtifactsProvider
|
|
29
|
+
) {}
|
|
30
|
+
|
|
31
|
+
/** @inheritdoc */
|
|
32
|
+
async discover(): Promise<void> {
|
|
33
|
+
this._captures.clear();
|
|
34
|
+
for (const type of this._clientArtifacts.constraints) {
|
|
35
|
+
const metadata = getConstraintMetadata(type);
|
|
36
|
+
if (!metadata) continue;
|
|
37
|
+
|
|
38
|
+
const builder = new ConstraintBuilder(metadata.id.value);
|
|
39
|
+
const instance = new (type as new () => IConstraint)();
|
|
40
|
+
instance.define(builder);
|
|
41
|
+
this._captures.set(metadata.id.value, builder.capture);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @inheritdoc */
|
|
46
|
+
async register(): Promise<void> {
|
|
47
|
+
if (this._captures.size === 0) {
|
|
48
|
+
await this.discover();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const constraints = [...this._captures.values()].map(capture => {
|
|
52
|
+
const scope = {
|
|
53
|
+
EventSourceType: capture.scope.perEventSourceType ? '*' : '',
|
|
54
|
+
EventStreamType: capture.scope.perEventStreamType ? '*' : '',
|
|
55
|
+
EventStreamId: capture.scope.perEventStreamId ? '*' : ''
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
if (capture.uniqueConstraint) {
|
|
59
|
+
const uc = capture.uniqueConstraint;
|
|
60
|
+
return {
|
|
61
|
+
Name: capture.name,
|
|
62
|
+
Type: ConstraintType.Unique,
|
|
63
|
+
RemovedWith: uc.removedWithEventTypeId ?? '',
|
|
64
|
+
Definition: {
|
|
65
|
+
Value0: {
|
|
66
|
+
EventDefinitions: uc.eventDefinitions.map(ed => ({
|
|
67
|
+
EventTypeId: ed.eventTypeId,
|
|
68
|
+
Properties: ed.properties
|
|
69
|
+
})),
|
|
70
|
+
IgnoreCasing: uc.ignoreCasing
|
|
71
|
+
},
|
|
72
|
+
Value1: undefined
|
|
73
|
+
},
|
|
74
|
+
Scope: scope
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (capture.uniqueEventType) {
|
|
79
|
+
const uet = capture.uniqueEventType;
|
|
80
|
+
return {
|
|
81
|
+
Name: uet.name ?? capture.name,
|
|
82
|
+
Type: ConstraintType.UniqueEventType,
|
|
83
|
+
RemovedWith: '',
|
|
84
|
+
Definition: {
|
|
85
|
+
Value0: undefined,
|
|
86
|
+
Value1: {
|
|
87
|
+
EventTypeId: uet.eventTypeId
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
Scope: scope
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
Name: capture.name,
|
|
96
|
+
Type: ConstraintType.Unknown,
|
|
97
|
+
RemovedWith: '',
|
|
98
|
+
Definition: undefined,
|
|
99
|
+
Scope: scope
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (constraints.length === 0) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
await this._connection.constraints.register({
|
|
108
|
+
EventStore: this._eventStore,
|
|
109
|
+
Constraints: constraints
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** @inheritdoc */
|
|
114
|
+
hasFor(id: ConstraintId): boolean {
|
|
115
|
+
return this._captures.has(id.value);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -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
|
+
import { IConstraintBuilder } from './IConstraintBuilder';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Defines a constraint for events.
|
|
8
|
+
* Implement this interface on any class decorated with {@link constraint} to describe
|
|
9
|
+
* the constraint rules that the Chronicle server should enforce.
|
|
10
|
+
* Matches the C# IConstraint contract.
|
|
11
|
+
*/
|
|
12
|
+
export interface IConstraint {
|
|
13
|
+
/**
|
|
14
|
+
* Defines the constraint rules.
|
|
15
|
+
* @param builder - The {@link IConstraintBuilder} used to configure constraint rules.
|
|
16
|
+
*/
|
|
17
|
+
define(builder: IConstraintBuilder): void;
|
|
18
|
+
}
|
|
@@ -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 { IUniqueConstraintBuilder } from './IUniqueConstraintBuilder';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Defines the builder for building constraints.
|
|
8
|
+
* Matches the C# IConstraintBuilder contract.
|
|
9
|
+
*/
|
|
10
|
+
export interface IConstraintBuilder {
|
|
11
|
+
/**
|
|
12
|
+
* Scopes the constraint per event source type.
|
|
13
|
+
* @returns This builder for fluent chaining.
|
|
14
|
+
*/
|
|
15
|
+
perEventSourceType(): IConstraintBuilder;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Scopes the constraint per event stream type.
|
|
19
|
+
* @returns This builder for fluent chaining.
|
|
20
|
+
*/
|
|
21
|
+
perEventStreamType(): IConstraintBuilder;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Scopes the constraint per event stream identifier.
|
|
25
|
+
* @returns This builder for fluent chaining.
|
|
26
|
+
*/
|
|
27
|
+
perEventStreamId(): IConstraintBuilder;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Starts building a unique constraint using a fluent builder callback.
|
|
31
|
+
* @param callback - Callback that configures the unique constraint via {@link IUniqueConstraintBuilder}.
|
|
32
|
+
* @returns This builder for fluent chaining.
|
|
33
|
+
*/
|
|
34
|
+
unique(callback: (builder: IUniqueConstraintBuilder) => void): IConstraintBuilder;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Adds a unique constraint for a specific event type.
|
|
38
|
+
* This means there can only be one instance of this event type per event source identifier.
|
|
39
|
+
* @param message - Optional violation message.
|
|
40
|
+
* @param name - Optional constraint name.
|
|
41
|
+
* @returns This builder for fluent chaining.
|
|
42
|
+
*/
|
|
43
|
+
uniqueFor(eventType: Function, message?: string, name?: string): IConstraintBuilder;
|
|
44
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { ConstraintId } from './ConstraintId';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Defines a system to work with constraints, including discovery and registration with the Kernel.
|
|
8
|
+
*/
|
|
9
|
+
export interface IConstraints {
|
|
10
|
+
/**
|
|
11
|
+
* Discovers all constraints from the registered client artifacts.
|
|
12
|
+
* @returns A promise that resolves when discovery is complete.
|
|
13
|
+
*/
|
|
14
|
+
discover(): Promise<void>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Registers all discovered constraints with the Chronicle Kernel.
|
|
18
|
+
* @returns A promise that resolves when registration is complete.
|
|
19
|
+
*/
|
|
20
|
+
register(): Promise<void>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether a constraint exists for the given identifier.
|
|
24
|
+
* @param id - The constraint identifier to look up.
|
|
25
|
+
* @returns True if a matching constraint exists; otherwise false.
|
|
26
|
+
*/
|
|
27
|
+
hasFor(id: ConstraintId): boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 } from '@cratis/fundamentals';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Defines the builder for building unique constraints.
|
|
8
|
+
* Matches the C# IUniqueConstraintBuilder contract.
|
|
9
|
+
*/
|
|
10
|
+
export interface IUniqueConstraintBuilder {
|
|
11
|
+
/**
|
|
12
|
+
* Defines the name of the unique constraint.
|
|
13
|
+
* The name is optional and if not provided, it will use the type name the constraint belongs to.
|
|
14
|
+
* @param name - Name to use.
|
|
15
|
+
* @returns This builder for fluent chaining.
|
|
16
|
+
*/
|
|
17
|
+
withName(name: string): IUniqueConstraintBuilder;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Constrains on specific properties of an event type.
|
|
21
|
+
* @param properties - Property accessor expressions for specifying the properties on the event.
|
|
22
|
+
* @returns This builder for fluent chaining.
|
|
23
|
+
*/
|
|
24
|
+
on<TEvent>(...properties: PropertyAccessor<TEvent>[]): IUniqueConstraintBuilder;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Ignores casing when comparing property values during constraint evaluation.
|
|
28
|
+
* @returns This builder for fluent chaining.
|
|
29
|
+
*/
|
|
30
|
+
ignoreCasing(): IUniqueConstraintBuilder;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Specifies the event type that removes this unique constraint (e.g. a deletion event).
|
|
34
|
+
* @param eventType - The event constructor that removes the constraint.
|
|
35
|
+
* @returns This builder for fluent chaining.
|
|
36
|
+
*/
|
|
37
|
+
removedWith(eventType: Function): IUniqueConstraintBuilder;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Specifies a static message to use when the unique constraint is violated.
|
|
41
|
+
* @param message - The violation message.
|
|
42
|
+
* @returns This builder for fluent chaining.
|
|
43
|
+
*/
|
|
44
|
+
withMessage(message: string): IUniqueConstraintBuilder;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Specifies a provider function that produces the violation message dynamically.
|
|
48
|
+
* @param messageProvider - Callback that returns the violation message.
|
|
49
|
+
* @returns This builder for fluent chaining.
|
|
50
|
+
*/
|
|
51
|
+
withMessageFrom(messageProvider: () => string): IUniqueConstraintBuilder;
|
|
52
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
import { getEventTypeFor } from '../eventTypeDecorator';
|
|
6
|
+
import { IUniqueConstraintBuilder } from './IUniqueConstraintBuilder';
|
|
7
|
+
|
|
8
|
+
/** Resolves a property path string from a {@link PropertyAccessor}. */
|
|
9
|
+
function resolvePropertyPath<T>(accessor: PropertyAccessor<T>): string {
|
|
10
|
+
const handler = new PropertyPathResolverProxyHandler();
|
|
11
|
+
const proxy = new Proxy({}, handler);
|
|
12
|
+
accessor(proxy as T);
|
|
13
|
+
return handler.path;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Captured definition of a unique constraint event entry. */
|
|
17
|
+
export interface UniqueConstraintEventEntry {
|
|
18
|
+
eventTypeId: string;
|
|
19
|
+
properties: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Captured definition of a unique constraint. */
|
|
23
|
+
export interface UniqueConstraintCapture {
|
|
24
|
+
name?: string;
|
|
25
|
+
eventDefinitions: UniqueConstraintEventEntry[];
|
|
26
|
+
ignoreCasing: boolean;
|
|
27
|
+
removedWithEventTypeId?: string;
|
|
28
|
+
message?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Implements {@link IUniqueConstraintBuilder}, capturing the unique constraint definition
|
|
33
|
+
* for later serialization and registration with the Kernel.
|
|
34
|
+
*/
|
|
35
|
+
export class UniqueConstraintBuilder implements IUniqueConstraintBuilder {
|
|
36
|
+
private readonly _capture: UniqueConstraintCapture;
|
|
37
|
+
private _currentEventTypeId?: string;
|
|
38
|
+
|
|
39
|
+
constructor(capture: UniqueConstraintCapture) {
|
|
40
|
+
this._capture = capture;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @inheritdoc */
|
|
44
|
+
withName(name: string): IUniqueConstraintBuilder {
|
|
45
|
+
this._capture.name = name;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @inheritdoc */
|
|
50
|
+
on<TEvent>(...properties: PropertyAccessor<TEvent>[]): IUniqueConstraintBuilder {
|
|
51
|
+
if (!this._currentEventTypeId) {
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
const paths = properties.map(p => resolvePropertyPath(p));
|
|
55
|
+
const existing = this._capture.eventDefinitions.find(d => d.eventTypeId === this._currentEventTypeId);
|
|
56
|
+
if (existing) {
|
|
57
|
+
existing.properties.push(...paths);
|
|
58
|
+
} else {
|
|
59
|
+
this._capture.eventDefinitions.push({ eventTypeId: this._currentEventTypeId, properties: paths });
|
|
60
|
+
}
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @inheritdoc */
|
|
65
|
+
ignoreCasing(): IUniqueConstraintBuilder {
|
|
66
|
+
this._capture.ignoreCasing = true;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** @inheritdoc */
|
|
71
|
+
removedWith(eventType: Function): IUniqueConstraintBuilder {
|
|
72
|
+
const et = getEventTypeFor(eventType);
|
|
73
|
+
this._capture.removedWithEventTypeId = et.id.value;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** @inheritdoc */
|
|
78
|
+
withMessage(message: string): IUniqueConstraintBuilder {
|
|
79
|
+
this._capture.message = message;
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** @inheritdoc */
|
|
84
|
+
withMessageFrom(messageProvider: () => string): IUniqueConstraintBuilder {
|
|
85
|
+
this._capture.message = messageProvider();
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Sets the current event type context for subsequent {@link on} calls.
|
|
91
|
+
* @param eventTypeId - The event type identifier string.
|
|
92
|
+
*/
|
|
93
|
+
withEventType(eventTypeId: string): UniqueConstraintBuilder {
|
|
94
|
+
this._currentEventTypeId = eventTypeId;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { Constructor } from '@cratis/fundamentals';
|
|
6
|
+
import { ConstraintId } from './ConstraintId';
|
|
7
|
+
import { DecoratorType, TypeDiscoverer } from '../../types';
|
|
8
|
+
|
|
9
|
+
/** Metadata key used to store constraint information on a class. */
|
|
10
|
+
const CONSTRAINT_METADATA_KEY = 'chronicle:constraint';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Metadata stored on a constraint class.
|
|
14
|
+
*/
|
|
15
|
+
export interface ConstraintMetadata {
|
|
16
|
+
/** The unique identifier for the constraint. */
|
|
17
|
+
readonly id: ConstraintId;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* TypeScript decorator that marks a class as an event constraint.
|
|
22
|
+
* The decorated class may implement {@link IConstraint} to define the constraint rules.
|
|
23
|
+
* @param id - The unique identifier for the constraint. Defaults to the class name if omitted.
|
|
24
|
+
* @returns A class decorator.
|
|
25
|
+
*/
|
|
26
|
+
export function constraint(id: string = ''): ClassDecorator {
|
|
27
|
+
return (target: object) => {
|
|
28
|
+
const constructor = target as Function;
|
|
29
|
+
const constraintId = new ConstraintId(id || constructor.name);
|
|
30
|
+
const metadata: ConstraintMetadata = { id: constraintId };
|
|
31
|
+
Reflect.defineMetadata(CONSTRAINT_METADATA_KEY, metadata, target);
|
|
32
|
+
TypeDiscoverer.default.register(
|
|
33
|
+
DecoratorType.Constraint,
|
|
34
|
+
constructor as Constructor,
|
|
35
|
+
constraintId.value
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Gets the {@link ConstraintMetadata} associated with a class decorated with {@link constraint}.
|
|
42
|
+
* @param target - The class constructor to retrieve metadata for.
|
|
43
|
+
* @returns The associated metadata, or undefined if not decorated.
|
|
44
|
+
*/
|
|
45
|
+
export function getConstraintMetadata(target: Function): ConstraintMetadata | undefined {
|
|
46
|
+
return Reflect.getMetadata(CONSTRAINT_METADATA_KEY, target);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Checks whether a class has been decorated with {@link constraint}.
|
|
51
|
+
* @param target - The class constructor to check.
|
|
52
|
+
* @returns True if the class has a constraint decorator; false otherwise.
|
|
53
|
+
*/
|
|
54
|
+
export function isConstraint(target: Function): boolean {
|
|
55
|
+
return Reflect.hasMetadata(CONSTRAINT_METADATA_KEY, target);
|
|
56
|
+
}
|
|
@@ -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
|
+
export { ConstraintId } from './ConstraintId';
|
|
5
|
+
export type { IConstraint } from './IConstraint';
|
|
6
|
+
export type { IConstraintBuilder } from './IConstraintBuilder';
|
|
7
|
+
export type { IUniqueConstraintBuilder } from './IUniqueConstraintBuilder';
|
|
8
|
+
export { constraint, getConstraintMetadata, isConstraint } from './constraint';
|
|
9
|
+
export type { ConstraintMetadata } from './constraint';
|
|
10
|
+
export type { IConstraints } from './IConstraints';
|
|
11
|
+
export { Constraints } from './Constraints';
|
|
12
|
+
export { ConstraintBuilder } from './ConstraintBuilder';
|
|
13
|
+
export type { ConstraintCapture, ConstraintScopeCapture, UniqueEventTypeCapture } from './ConstraintBuilder';
|
|
14
|
+
export { UniqueConstraintBuilder } from './UniqueConstraintBuilder';
|
|
15
|
+
export type { UniqueConstraintCapture, UniqueConstraintEventEntry } from './UniqueConstraintBuilder';
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { EventType } from './EventType';
|
|
5
|
+
import { CausationEntry } from './CausationEntry';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents contextual information about an appended event.
|
|
9
|
+
*/
|
|
10
|
+
export interface EventContext {
|
|
11
|
+
/** The sequence number of the event in the event sequence. */
|
|
12
|
+
readonly sequenceNumber: number;
|
|
13
|
+
|
|
14
|
+
/** The unique identifier of the event source. */
|
|
15
|
+
readonly eventSourceId: string;
|
|
16
|
+
|
|
17
|
+
/** The type of the event. */
|
|
18
|
+
readonly eventType: EventType;
|
|
19
|
+
|
|
20
|
+
/** The timestamp when the event occurred. */
|
|
21
|
+
readonly occurred: Date;
|
|
22
|
+
|
|
23
|
+
/** The correlation identifier for the event. */
|
|
24
|
+
readonly correlationId: string;
|
|
25
|
+
|
|
26
|
+
/** The causation chain for the event. */
|
|
27
|
+
readonly causation: ReadonlyArray<CausationEntry>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { EventTypeId } from './EventTypeId';
|
|
5
|
+
import { EventTypeGeneration } from './EventTypeGeneration';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents the type of an event.
|
|
9
|
+
*/
|
|
10
|
+
export class EventType {
|
|
11
|
+
/** Represents an unknown event type. */
|
|
12
|
+
static readonly unknown = new EventType(EventTypeId.unknown, EventTypeGeneration.first, false);
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
readonly id: EventTypeId,
|
|
16
|
+
readonly generation: EventTypeGeneration,
|
|
17
|
+
readonly tombstone: boolean = false
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
/** @inheritdoc */
|
|
21
|
+
toString(): string {
|
|
22
|
+
return `${this.id.value}+${this.generation.value}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Parse from a string representation of event type to actual type.
|
|
27
|
+
* The expected format is id+generation. Ex: EmployeeHired+1.
|
|
28
|
+
* @param input - The string representation to parse.
|
|
29
|
+
* @returns The parsed EventType.
|
|
30
|
+
*/
|
|
31
|
+
static parse(input: string): EventType {
|
|
32
|
+
const segments = input.split('+');
|
|
33
|
+
if (segments.length === 1) {
|
|
34
|
+
return new EventType(new EventTypeId(segments[0]), EventTypeGeneration.first, false);
|
|
35
|
+
}
|
|
36
|
+
if (segments.length === 2) {
|
|
37
|
+
return new EventType(new EventTypeId(segments[0]), new EventTypeGeneration(parseInt(segments[1], 10)), false);
|
|
38
|
+
}
|
|
39
|
+
return new EventType(new EventTypeId(segments[0]), new EventTypeGeneration(parseInt(segments[1], 10)), segments[2] === 'true');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -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
|
+
/**
|
|
5
|
+
* Represents the generation of an event type.
|
|
6
|
+
*/
|
|
7
|
+
export class EventTypeGeneration {
|
|
8
|
+
/** The first generation value. */
|
|
9
|
+
static readonly firstValue = 1;
|
|
10
|
+
|
|
11
|
+
/** The first generation of any event type. */
|
|
12
|
+
static readonly first = new EventTypeGeneration(EventTypeGeneration.firstValue);
|
|
13
|
+
|
|
14
|
+
constructor(readonly value: number) {}
|
|
15
|
+
|
|
16
|
+
/** @inheritdoc */
|
|
17
|
+
toString(): string {
|
|
18
|
+
return this.value.toString();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -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 the unique identifier for an event type.
|
|
6
|
+
*/
|
|
7
|
+
export class EventTypeId {
|
|
8
|
+
/**
|
|
9
|
+
* Represents an unknown event type identifier.
|
|
10
|
+
*/
|
|
11
|
+
static readonly unknown = new EventTypeId('00000000-0000-0000-0000-000000000000');
|
|
12
|
+
|
|
13
|
+
constructor(readonly value: string) {}
|
|
14
|
+
|
|
15
|
+
/** @inheritdoc */
|
|
16
|
+
toString(): string {
|
|
17
|
+
return this.value;
|
|
18
|
+
}
|
|
19
|
+
}
|