@cratis/chronicle 6.56.0 → 6.58.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/EventStore.ts +2 -2
- package/WellKnownTelemetryNames.ts +2 -0
- package/auditing/CausationType.ts +5 -0
- package/dist/EventStore.js +2 -2
- package/dist/EventStore.js.map +1 -1
- package/dist/WellKnownTelemetryNames.d.ts +2 -0
- package/dist/WellKnownTelemetryNames.d.ts.map +1 -1
- package/dist/WellKnownTelemetryNames.js +2 -0
- package/dist/WellKnownTelemetryNames.js.map +1 -1
- package/dist/auditing/CausationType.d.ts +4 -0
- package/dist/auditing/CausationType.d.ts.map +1 -1
- package/dist/auditing/CausationType.js +4 -0
- package/dist/auditing/CausationType.js.map +1 -1
- package/dist/eventSequences/CompensateOptions.d.ts +7 -0
- package/dist/eventSequences/CompensateOptions.d.ts.map +1 -0
- package/dist/eventSequences/CompensateOptions.js +4 -0
- package/dist/eventSequences/CompensateOptions.js.map +1 -0
- package/dist/eventSequences/EventSequence.d.ts +3 -0
- package/dist/eventSequences/EventSequence.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +45 -0
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/eventSequences/IEventSequence.d.ts +13 -0
- package/dist/eventSequences/IEventSequence.d.ts.map +1 -1
- package/dist/eventSequences/index.d.ts +1 -0
- package/dist/eventSequences/index.d.ts.map +1 -1
- package/dist/eventSequences/index.js.map +1 -1
- package/dist/events/EventContext.d.ts +5 -0
- package/dist/events/EventContext.d.ts.map +1 -1
- package/dist/events/compensationForDecorator.d.ts +32 -0
- package/dist/events/compensationForDecorator.d.ts.map +1 -0
- package/dist/events/compensationForDecorator.js +44 -0
- package/dist/events/compensationForDecorator.js.map +1 -0
- package/dist/events/eventTypeDecorator.d.ts +7 -0
- package/dist/events/eventTypeDecorator.d.ts.map +1 -1
- package/dist/events/eventTypeDecorator.js +13 -4
- package/dist/events/eventTypeDecorator.js.map +1 -1
- package/dist/events/index.d.ts +2 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -1
- package/dist/events/index.js.map +1 -1
- package/dist/events/toClientEventContext.d.ts.map +1 -1
- package/dist/events/toClientEventContext.js +20 -0
- package/dist/events/toClientEventContext.js.map +1 -1
- package/dist/observation/batches/BatchContext.d.ts +43 -0
- package/dist/observation/batches/BatchContext.d.ts.map +1 -0
- package/dist/observation/batches/BatchContext.js +60 -0
- package/dist/observation/batches/BatchContext.js.map +1 -0
- package/dist/observation/batches/BatchContextObserver.d.ts +14 -0
- package/dist/observation/batches/BatchContextObserver.d.ts.map +1 -0
- package/dist/observation/batches/BatchContextObserver.js +4 -0
- package/dist/observation/batches/BatchContextObserver.js.map +1 -0
- package/dist/observation/batches/BatchContextValues.d.ts +13 -0
- package/dist/observation/batches/BatchContextValues.d.ts.map +1 -0
- package/dist/observation/batches/BatchContextValues.js +4 -0
- package/dist/observation/batches/BatchContextValues.js.map +1 -0
- package/dist/observation/batches/BatchMethod.d.ts +9 -0
- package/dist/observation/batches/BatchMethod.d.ts.map +1 -0
- package/dist/observation/batches/BatchMethod.js +4 -0
- package/dist/observation/batches/BatchMethod.js.map +1 -0
- package/dist/observation/batches/BatchMethodReturnedAValue.d.ts +12 -0
- package/dist/observation/batches/BatchMethodReturnedAValue.d.ts.map +1 -0
- package/dist/observation/batches/BatchMethodReturnedAValue.js +20 -0
- package/dist/observation/batches/BatchMethodReturnedAValue.js.map +1 -0
- package/dist/observation/batches/BatchMethods.d.ts +31 -0
- package/dist/observation/batches/BatchMethods.d.ts.map +1 -0
- package/dist/observation/batches/BatchMethods.js +81 -0
- package/dist/observation/batches/BatchMethods.js.map +1 -0
- package/dist/observation/batches/BatchOutcome.d.ts +15 -0
- package/dist/observation/batches/BatchOutcome.d.ts.map +1 -0
- package/dist/observation/batches/BatchOutcome.js +4 -0
- package/dist/observation/batches/BatchOutcome.js.map +1 -0
- package/dist/observation/batches/BatchOutcomeKind.d.ts +8 -0
- package/dist/observation/batches/BatchOutcomeKind.d.ts.map +1 -0
- package/dist/observation/batches/BatchOutcomeKind.js +11 -0
- package/dist/observation/batches/BatchOutcomeKind.js.map +1 -0
- package/dist/observation/batches/DeferralNotSupportedByKernel.d.ts +13 -0
- package/dist/observation/batches/DeferralNotSupportedByKernel.d.ts.map +1 -0
- package/dist/observation/batches/DeferralNotSupportedByKernel.js +19 -0
- package/dist/observation/batches/DeferralNotSupportedByKernel.js.map +1 -0
- package/dist/observation/batches/DeliveredPartition.d.ts +11 -0
- package/dist/observation/batches/DeliveredPartition.d.ts.map +1 -0
- package/dist/observation/batches/DeliveredPartition.js +4 -0
- package/dist/observation/batches/DeliveredPartition.js.map +1 -0
- package/dist/observation/batches/EventAndContext.d.ts +28 -0
- package/dist/observation/batches/EventAndContext.d.ts.map +1 -0
- package/dist/observation/batches/EventAndContext.js +35 -0
- package/dist/observation/batches/EventAndContext.js.map +1 -0
- package/dist/observation/batches/EventBatch.d.ts +52 -0
- package/dist/observation/batches/EventBatch.d.ts.map +1 -0
- package/dist/observation/batches/EventBatch.js +92 -0
- package/dist/observation/batches/EventBatch.js.map +1 -0
- package/dist/observation/batches/EventTypeObservedByMoreThanOneMethod.d.ts +14 -0
- package/dist/observation/batches/EventTypeObservedByMoreThanOneMethod.d.ts.map +1 -0
- package/dist/observation/batches/EventTypeObservedByMoreThanOneMethod.js +23 -0
- package/dist/observation/batches/EventTypeObservedByMoreThanOneMethod.js.map +1 -0
- package/dist/observation/batches/InvalidBatchMethod.d.ts +13 -0
- package/dist/observation/batches/InvalidBatchMethod.d.ts.map +1 -0
- package/dist/observation/batches/InvalidBatchMethod.js +20 -0
- package/dist/observation/batches/InvalidBatchMethod.js.map +1 -0
- package/dist/observation/batches/ObservationOrigin.d.ts +21 -0
- package/dist/observation/batches/ObservationOrigin.d.ts.map +1 -0
- package/dist/observation/batches/ObservationOrigin.js +32 -0
- package/dist/observation/batches/ObservationOrigin.js.map +1 -0
- package/dist/observation/batches/ObservedEventType.d.ts +11 -0
- package/dist/observation/batches/ObservedEventType.d.ts.map +1 -0
- package/dist/observation/batches/ObservedEventType.js +4 -0
- package/dist/observation/batches/ObservedEventType.js.map +1 -0
- package/dist/observation/batches/PageMessages.d.ts +22 -0
- package/dist/observation/batches/PageMessages.d.ts.map +1 -0
- package/dist/observation/batches/PageMessages.js +32 -0
- package/dist/observation/batches/PageMessages.js.map +1 -0
- package/dist/observation/batches/PartitionFailedInBatch.d.ts +10 -0
- package/dist/observation/batches/PartitionFailedInBatch.d.ts.map +1 -0
- package/dist/observation/batches/PartitionFailedInBatch.js +16 -0
- package/dist/observation/batches/PartitionFailedInBatch.js.map +1 -0
- package/dist/observation/batches/PartitionNotInBatch.d.ts +10 -0
- package/dist/observation/batches/PartitionNotInBatch.d.ts.map +1 -0
- package/dist/observation/batches/PartitionNotInBatch.js +16 -0
- package/dist/observation/batches/PartitionNotInBatch.js.map +1 -0
- package/dist/observation/batches/PartitionOutcome.d.ts +19 -0
- package/dist/observation/batches/PartitionOutcome.d.ts.map +1 -0
- package/dist/observation/batches/PartitionOutcome.js +4 -0
- package/dist/observation/batches/PartitionOutcome.js.map +1 -0
- package/dist/observation/batches/PartitionProblem.d.ts +17 -0
- package/dist/observation/batches/PartitionProblem.d.ts.map +1 -0
- package/dist/observation/batches/PartitionProblem.js +4 -0
- package/dist/observation/batches/PartitionProblem.js.map +1 -0
- package/dist/observation/batches/PartitionSettlement.d.ts +29 -0
- package/dist/observation/batches/PartitionSettlement.d.ts.map +1 -0
- package/dist/observation/batches/PartitionSettlement.js +64 -0
- package/dist/observation/batches/PartitionSettlement.js.map +1 -0
- package/dist/observation/batches/ReducerMixesBatchAndPerEventMethods.d.ts +12 -0
- package/dist/observation/batches/ReducerMixesBatchAndPerEventMethods.d.ts.map +1 -0
- package/dist/observation/batches/ReducerMixesBatchAndPerEventMethods.js +20 -0
- package/dist/observation/batches/ReducerMixesBatchAndPerEventMethods.js.map +1 -0
- package/dist/observation/batches/batchSize.d.ts +42 -0
- package/dist/observation/batches/batchSize.d.ts.map +1 -0
- package/dist/observation/batches/batchSize.js +55 -0
- package/dist/observation/batches/batchSize.js.map +1 -0
- package/dist/observation/batches/createBatchContext.d.ts +13 -0
- package/dist/observation/batches/createBatchContext.d.ts.map +1 -0
- package/dist/observation/batches/createBatchContext.js +27 -0
- package/dist/observation/batches/createBatchContext.js.map +1 -0
- package/dist/observation/batches/observes.d.ts +39 -0
- package/dist/observation/batches/observes.d.ts.map +1 -0
- package/dist/observation/batches/observes.js +63 -0
- package/dist/observation/batches/observes.js.map +1 -0
- package/dist/observation/batches/runConcurrently.d.ts +9 -0
- package/dist/observation/batches/runConcurrently.d.ts.map +1 -0
- package/dist/observation/batches/runConcurrently.js +22 -0
- package/dist/observation/batches/runConcurrently.js.map +1 -0
- package/dist/observation/createHandlerInstanceValidator.d.ts +1 -1
- package/dist/observation/createHandlerInstanceValidator.d.ts.map +1 -1
- package/dist/observation/createHandlerInstanceValidator.js +5 -7
- package/dist/observation/createHandlerInstanceValidator.js.map +1 -1
- package/dist/observation/getInstanceMethods.d.ts +3 -1
- package/dist/observation/getInstanceMethods.d.ts.map +1 -1
- package/dist/observation/getInstanceMethods.js +13 -4
- package/dist/observation/getInstanceMethods.js.map +1 -1
- package/dist/observation/index.d.ts +14 -0
- package/dist/observation/index.d.ts.map +1 -1
- package/dist/observation/index.js +13 -0
- package/dist/observation/index.js.map +1 -1
- package/dist/projections/eventContextPropertyExpression.js +1 -1
- package/dist/projections/eventContextPropertyExpression.js.map +1 -1
- package/dist/reactors/ReactorDispatcher.d.ts +15 -0
- package/dist/reactors/ReactorDispatcher.d.ts.map +1 -1
- package/dist/reactors/ReactorDispatcher.js +25 -2
- package/dist/reactors/ReactorDispatcher.js.map +1 -1
- package/dist/reactors/ReactorObservationTarget.d.ts +45 -0
- package/dist/reactors/ReactorObservationTarget.d.ts.map +1 -0
- package/dist/reactors/ReactorObservationTarget.js +4 -0
- package/dist/reactors/ReactorObservationTarget.js.map +1 -0
- package/dist/reactors/ReactorPageDispatcher.d.ts +33 -0
- package/dist/reactors/ReactorPageDispatcher.d.ts.map +1 -0
- package/dist/reactors/ReactorPageDispatcher.js +293 -0
- package/dist/reactors/ReactorPageDispatcher.js.map +1 -0
- package/dist/reactors/Reactors.d.ts.map +1 -1
- package/dist/reactors/Reactors.js +21 -149
- package/dist/reactors/Reactors.js.map +1 -1
- package/dist/reactors/for_Reactors/given/observe_reactor_messages.d.ts +14 -0
- package/dist/reactors/for_Reactors/given/observe_reactor_messages.d.ts.map +1 -0
- package/dist/reactors/for_Reactors/given/observe_reactor_messages.js +61 -0
- package/dist/reactors/for_Reactors/given/observe_reactor_messages.js.map +1 -0
- package/dist/reactors/index.d.ts +2 -0
- package/dist/reactors/index.d.ts.map +1 -1
- package/dist/reactors/index.js +1 -0
- package/dist/reactors/index.js.map +1 -1
- package/dist/reducers/ReducerEventDispatcher.d.ts +26 -1
- package/dist/reducers/ReducerEventDispatcher.d.ts.map +1 -1
- package/dist/reducers/ReducerEventDispatcher.js +35 -3
- package/dist/reducers/ReducerEventDispatcher.js.map +1 -1
- package/dist/reducers/Reducers.d.ts +2 -0
- package/dist/reducers/Reducers.d.ts.map +1 -1
- package/dist/reducers/Reducers.js +94 -22
- package/dist/reducers/Reducers.js.map +1 -1
- package/dist/reducers/ReductionOutcome.d.ts +27 -3
- package/dist/reducers/ReductionOutcome.d.ts.map +1 -1
- package/dist/reducers/ReductionOutcome.js +51 -7
- package/dist/reducers/ReductionOutcome.js.map +1 -1
- package/dist/reducers/for_Reducers/given/observe_reducer_messages.d.ts +19 -0
- package/dist/reducers/for_Reducers/given/observe_reducer_messages.d.ts.map +1 -0
- package/dist/reducers/for_Reducers/given/observe_reducer_messages.js +61 -0
- package/dist/reducers/for_Reducers/given/observe_reducer_messages.js.map +1 -0
- package/dist/reducers/index.d.ts +2 -0
- package/dist/reducers/index.d.ts.map +1 -1
- package/dist/reducers/index.js +1 -0
- package/dist/reducers/index.js.map +1 -1
- package/dist/schemas/JsonSchema.d.ts +2 -0
- package/dist/schemas/JsonSchema.d.ts.map +1 -1
- package/dist/testing/InProcessEventSequence.d.ts +1 -0
- package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
- package/dist/testing/InProcessEventSequence.js +1 -0
- package/dist/testing/InProcessEventSequence.js.map +1 -1
- package/dist/testing/ReactorScenario.d.ts.map +1 -1
- package/dist/testing/ReactorScenario.js +4 -1
- package/dist/testing/ReactorScenario.js.map +1 -1
- package/dist/testing/ReducerReadModelProcessor.d.ts +1 -0
- package/dist/testing/ReducerReadModelProcessor.d.ts.map +1 -1
- package/dist/testing/ReducerReadModelProcessor.js +45 -0
- package/dist/testing/ReducerReadModelProcessor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eventSequences/CompensateOptions.ts +10 -0
- package/eventSequences/EventSequence.compensate.spec.ts +72 -0
- package/eventSequences/EventSequence.ts +51 -0
- package/eventSequences/IEventSequence.ts +14 -0
- package/eventSequences/index.ts +1 -0
- package/events/EventContext.ts +6 -0
- package/events/compensationFor.spec.ts +73 -0
- package/events/compensationForDecorator.ts +48 -0
- package/events/eventTypeDecorator.ts +13 -4
- package/events/index.ts +2 -1
- package/events/toClientEventContext.ts +21 -0
- package/observation/batches/BatchContext.ts +75 -0
- package/observation/batches/BatchContextObserver.ts +16 -0
- package/observation/batches/BatchContextValues.ts +16 -0
- package/observation/batches/BatchMethod.ts +13 -0
- package/observation/batches/BatchMethodReturnedAValue.ts +16 -0
- package/observation/batches/BatchMethods.ts +90 -0
- package/observation/batches/BatchOutcome.ts +22 -0
- package/observation/batches/BatchOutcomeKind.ts +11 -0
- package/observation/batches/DeferralNotSupportedByKernel.ts +17 -0
- package/observation/batches/DeliveredPartition.ts +16 -0
- package/observation/batches/EventAndContext.ts +37 -0
- package/observation/batches/EventBatch.ts +105 -0
- package/observation/batches/EventTypeObservedByMoreThanOneMethod.ts +17 -0
- package/observation/batches/InvalidBatchMethod.ts +16 -0
- package/observation/batches/ObservationOrigin.ts +37 -0
- package/observation/batches/ObservedEventType.ts +16 -0
- package/observation/batches/PageMessages.ts +37 -0
- package/observation/batches/PartitionFailedInBatch.ts +14 -0
- package/observation/batches/PartitionNotInBatch.ts +14 -0
- package/observation/batches/PartitionOutcome.ts +22 -0
- package/observation/batches/PartitionProblem.ts +25 -0
- package/observation/batches/PartitionSettlement.ts +70 -0
- package/observation/batches/ReducerMixesBatchAndPerEventMethods.ts +16 -0
- package/observation/batches/batchSize.ts +79 -0
- package/observation/batches/createBatchContext.ts +32 -0
- package/observation/batches/for_BatchMethods/when_discovering_batch_methods.spec.ts +155 -0
- package/observation/batches/for_EventBatch/when_reporting_outcomes.spec.ts +66 -0
- package/observation/batches/for_PartitionSettlement/when_settling_a_partition.spec.ts +31 -0
- package/observation/batches/for_batchSize/when_declaring_bounds.spec.ts +23 -0
- package/observation/batches/for_observes/when_decorating_methods.legacy.spec.ts +28 -0
- package/observation/batches/for_observes/when_decorating_methods.spec.ts +33 -0
- package/observation/batches/for_runConcurrently/when_running_items.spec.ts +22 -0
- package/observation/batches/observes.ts +68 -0
- package/observation/batches/runConcurrently.ts +23 -0
- package/observation/createHandlerInstanceValidator.ts +5 -7
- package/observation/getInstanceMethods.ts +13 -4
- package/observation/index.ts +14 -0
- package/package.json +2 -2
- package/projections/eventContextPropertyExpression.ts +2 -2
- package/reactors/ReactorDispatcher.ts +27 -2
- package/reactors/ReactorObservationTarget.ts +48 -0
- package/reactors/ReactorPageDispatcher.ts +321 -0
- package/reactors/Reactors.ts +22 -164
- package/reactors/for_Reactors/given/observe_reactor_messages.ts +72 -0
- package/reactors/for_Reactors/when_delivering_pages/as_a_legacy_single_partition.spec.ts +51 -0
- package/reactors/for_Reactors/when_delivering_pages/returning_a_value_from_a_batch_method.spec.ts +34 -0
- package/reactors/for_Reactors/when_delivering_pages/with_batch_and_per_event_methods.spec.ts +81 -0
- package/reactors/for_Reactors/when_delivering_pages/with_batch_outcomes.spec.ts +86 -0
- package/reactors/for_Reactors/when_delivering_pages/with_per_event_handlers.spec.ts +52 -0
- package/reactors/index.ts +2 -0
- package/reducers/ReducerEventDispatcher.ts +44 -3
- package/reducers/Reducers.ts +109 -25
- package/reducers/ReductionOutcome.ts +55 -8
- package/reducers/for_Reducers/given/observe_reducer_messages.ts +77 -0
- package/reducers/for_Reducers/when_delivering_pages/to_a_batch_reducer.spec.ts +111 -0
- package/reducers/for_Reducers/when_delivering_pages/to_a_per_event_reducer.spec.ts +53 -0
- package/reducers/index.ts +2 -0
- package/schemas/JsonSchema.ts +2 -0
- package/telemetry/for_ChronicleTelemetry/given/a_client.fixture.ts +1 -0
- package/telemetry/for_ChronicleTelemetry/given/a_span_name_registry.fixture.ts +2 -0
- package/telemetry/for_ChronicleTelemetry/when_naming_spans/with_convention_names.spec.ts +2 -1
- package/testing/InProcessEventSequence.ts +1 -0
- package/testing/ReactorScenario.ts +5 -1
- package/testing/ReducerReadModelProcessor.ts +44 -0
- package/testing/for_ReactorScenario/when_the_reactor_has_a_batch_method.spec.ts +26 -0
- package/testing/for_ReadModelScenario/when_reducing_with_a_batch_method/with_events_for_two_event_sources.spec.ts +43 -0
|
@@ -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
|
+
import 'reflect-metadata';
|
|
4
|
+
/** Metadata key used to store the compensated event type on a class. */
|
|
5
|
+
const COMPENSATION_FOR_METADATA_KEY = 'chronicle:compensationFor';
|
|
6
|
+
/**
|
|
7
|
+
* TypeScript decorator that declares an event type as a compensation for another event type.
|
|
8
|
+
* This is the TypeScript equivalent of the C# `[CompensationFor<TEventType>]` attribute.
|
|
9
|
+
*
|
|
10
|
+
* Chronicle registers the link with the event type's schema. A compensation event type can compensate
|
|
11
|
+
* for one event type, and is appended with `IEventSequence.compensate()`.
|
|
12
|
+
*
|
|
13
|
+
* Apply it together with {@link eventType}; the order of the decorators does not matter.
|
|
14
|
+
*
|
|
15
|
+
* @param compensated - The class of the event type being compensated for.
|
|
16
|
+
* @returns A class decorator.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* @eventType()
|
|
21
|
+
* class EntryPosted { constructor(readonly amount: number) {} }
|
|
22
|
+
*
|
|
23
|
+
* @eventType()
|
|
24
|
+
* @compensationFor(EntryPosted)
|
|
25
|
+
* class EntryReversed { constructor(readonly reason: string) {} }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function compensationFor(compensated) {
|
|
29
|
+
return (target, context) => {
|
|
30
|
+
Reflect.defineMetadata(COMPENSATION_FOR_METADATA_KEY, compensated, target);
|
|
31
|
+
context?.addInitializer(function () {
|
|
32
|
+
Reflect.defineMetadata(COMPENSATION_FOR_METADATA_KEY, compensated, this);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets the class of the event type that a class declared as a compensation with {@link compensationFor} compensates for.
|
|
38
|
+
* @param target - The class constructor to inspect.
|
|
39
|
+
* @returns The compensated event class, or undefined when the class is not a compensation.
|
|
40
|
+
*/
|
|
41
|
+
export function getCompensatedTypeFor(target) {
|
|
42
|
+
return Reflect.getMetadata(COMPENSATION_FOR_METADATA_KEY, target);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=compensationForDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compensationForDecorator.js","sourceRoot":"","sources":["../../events/compensationForDecorator.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAG1B,wEAAwE;AACxE,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,eAAe,CAAC,WAAwB;IACpD,OAAO,CAAC,MAAc,EAAE,OAA+B,EAAE,EAAE;QACvD,OAAO,CAAC,cAAc,CAAC,6BAA6B,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC3E,OAAO,EAAE,cAAc,CAAC;YACpB,OAAO,CAAC,cAAc,CAAC,6BAA6B,EAAE,WAAW,EAAE,IAAc,CAAC,CAAC;QACvF,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAgB;IAClD,OAAO,OAAO,CAAC,WAAW,CAAC,6BAA6B,EAAE,MAAM,CAA4B,CAAC;AACjG,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { EventType } from './EventType.js';
|
|
3
|
+
import { EventTypeId } from './EventTypeId.js';
|
|
3
4
|
import { JsonSchema } from '../schemas/index.js';
|
|
4
5
|
import { ChronicleClassDecorator } from '../types/standardDecoratorMetadata.js';
|
|
5
6
|
/**
|
|
@@ -74,4 +75,10 @@ export declare function getEventTypeMetadata(target: Function): EventTypeMetadat
|
|
|
74
75
|
* @returns The generated JSON schema.
|
|
75
76
|
*/
|
|
76
77
|
export declare function getEventTypeJsonSchemaFor(target: Function): JsonSchema;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the identifier of the event type that a class declared with `@compensationFor` compensates for.
|
|
80
|
+
* @param target - The class constructor to inspect.
|
|
81
|
+
* @returns The compensated event type identifier, or undefined when the class is not a compensation.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getCompensatedEventTypeIdFor(target: Function): EventTypeId | undefined;
|
|
77
84
|
//# sourceMappingURL=eventTypeDecorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventTypeDecorator.d.ts","sourceRoot":"","sources":["../../events/eventTypeDecorator.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"eventTypeDec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;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,QAAQ,GAAG,iBAAiB,GAAG,SAAS,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,QAAQ,GAAG,UAAU,CAKtE;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS,CAGtF"}
|
|
@@ -4,6 +4,7 @@ import 'reflect-metadata';
|
|
|
4
4
|
import { EventType } from './EventType.js';
|
|
5
5
|
import { EventTypeId } from './EventTypeId.js';
|
|
6
6
|
import { EventTypeGeneration } from './EventTypeGeneration.js';
|
|
7
|
+
import { getCompensatedTypeFor } from './compensationForDecorator.js';
|
|
7
8
|
import { DecoratorType, TypeDiscoverer, TypeIntrospector } from '../types/index.js';
|
|
8
9
|
import { JsonSchemaGenerator } from '../schemas/index.js';
|
|
9
10
|
import { createDeferredSchema } from '../schemas/createDeferredSchema.js';
|
|
@@ -95,9 +96,17 @@ export function getEventTypeMetadata(target) {
|
|
|
95
96
|
*/
|
|
96
97
|
export function getEventTypeJsonSchemaFor(target) {
|
|
97
98
|
const metadata = getEventTypeMetadata(target);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
99
|
+
const schema = metadata ? metadata.schema : JsonSchemaGenerator.createEmptySchema(target.name);
|
|
100
|
+
const compensated = getCompensatedEventTypeIdFor(target);
|
|
101
|
+
return compensated ? { ...schema, compensationFor: compensated.value } : schema;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gets the identifier of the event type that a class declared with `@compensationFor` compensates for.
|
|
105
|
+
* @param target - The class constructor to inspect.
|
|
106
|
+
* @returns The compensated event type identifier, or undefined when the class is not a compensation.
|
|
107
|
+
*/
|
|
108
|
+
export function getCompensatedEventTypeIdFor(target) {
|
|
109
|
+
const compensated = getCompensatedTypeFor(target);
|
|
110
|
+
return compensated ? getEventTypeFor(compensated).id : undefined;
|
|
102
111
|
}
|
|
103
112
|
//# sourceMappingURL=eventTypeDecorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventTypeDecorator.js","sourceRoot":"","sources":["../../events/eventTypeDecorator.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAc,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,oEAAoE;AACpE,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAqDtD,MAAM,UAAU,SAAS,CACrB,yBAAqD,EACrD,qBAAwC,EACxC,SAAS,GAAY,KAAK;IAE1B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,IAAI,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC;IAChD,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,IAAI,OAAO,yBAAyB,KAAK,QAAQ,EAAE,CAAC;QAChD,EAAE,GAAG,yBAAyB,CAAC;QAC/B,IAAI,OAAO,qBAAqB,KAAK,QAAQ,EAAE,CAAC;YAC5C,UAAU,GAAG,qBAAqB,CAAC;QACvC,CAAC;QACD,IAAI,OAAO,qBAAqB,KAAK,SAAS,EAAE,CAAC;YAC7C,WAAW,GAAG,qBAAqB,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,WAAW,GAAG,SAAS,CAAC;QAC5B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C,WAAkC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5F,CAAC"}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export { handles } from './handles.js';
|
|
|
3
3
|
export { EventType } from './EventType.js';
|
|
4
4
|
export { EventTypeId } from './EventTypeId.js';
|
|
5
5
|
export { EventTypeGeneration } from './EventTypeGeneration.js';
|
|
6
|
-
export { eventType, getEventTypeFor, hasEventType, getEventTypeMetadata, getEventTypeJsonSchemaFor } from './eventTypeDecorator.js';
|
|
6
|
+
export { eventType, getEventTypeFor, hasEventType, getEventTypeMetadata, getEventTypeJsonSchemaFor, getCompensatedEventTypeIdFor } from './eventTypeDecorator.js';
|
|
7
|
+
export { compensationFor, getCompensatedTypeFor } from './compensationForDecorator.js';
|
|
7
8
|
export type { EventTypeMetadata } from './eventTypeDecorator.js';
|
|
8
9
|
export type { EventContext } from './EventContext.js';
|
|
9
10
|
export type { CausationEntry } from './CausationEntry.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAGA,OAAO,uCAAuC,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAGA,OAAO,uCAAuC,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MA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,uBAAuB,CAAC"}
|
package/dist/events/index.js
CHANGED
|
@@ -5,7 +5,8 @@ export { handles } from './handles.js';
|
|
|
5
5
|
export { EventType } from './EventType.js';
|
|
6
6
|
export { EventTypeId } from './EventTypeId.js';
|
|
7
7
|
export { EventTypeGeneration } from './EventTypeGeneration.js';
|
|
8
|
-
export { eventType, getEventTypeFor, hasEventType, getEventTypeMetadata, getEventTypeJsonSchemaFor } from './eventTypeDecorator.js';
|
|
8
|
+
export { eventType, getEventTypeFor, hasEventType, getEventTypeMetadata, getEventTypeJsonSchemaFor, getCompensatedEventTypeIdFor } from './eventTypeDecorator.js';
|
|
9
|
+
export { compensationFor, getCompensatedTypeFor } from './compensationForDecorator.js';
|
|
9
10
|
export { EventTypes } from './EventTypes.js';
|
|
10
11
|
export { isRegisteredEvent } from './isRegisteredEvent.js';
|
|
11
12
|
export { Tag } from './Tag.js';
|
package/dist/events/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,uCAAuC,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,uCAAuC,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,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
|
1
|
+
{"version":3,"file":"toClientEventContext.d.ts","sourceRoot":"","sources":["../../events/toClientEventContext.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAK9D,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,YAAY,CA8B5E"}
|
|
@@ -7,6 +7,9 @@ import { EventTypeGeneration } from './EventTypeGeneration.js';
|
|
|
7
7
|
import { EventTypeId } from './EventTypeId.js';
|
|
8
8
|
import { Tag } from './Tag.js';
|
|
9
9
|
import { NamedTag } from './NamedTag.js';
|
|
10
|
+
import { DecoratorType } from '../types/DecoratorType.js';
|
|
11
|
+
import { TypeDiscoverer } from '../types/TypeDiscoverer.js';
|
|
12
|
+
import { getCompensatedTypeFor } from './compensationForDecorator.js';
|
|
10
13
|
/** Converts kernel metadata identically for reads, reactors, and reducers. */
|
|
11
14
|
export function toClientEventContext(context) {
|
|
12
15
|
return {
|
|
@@ -30,6 +33,7 @@ export function toClientEventContext(context) {
|
|
|
30
33
|
occurred: causation.Occurred ? new Date(causation.Occurred.Value) : undefined,
|
|
31
34
|
properties: { ...causation.Properties }
|
|
32
35
|
})),
|
|
36
|
+
compensationFor: toClientCompensationFor(context),
|
|
33
37
|
tags: (context.Tags ?? []).map(value => new Tag(value)),
|
|
34
38
|
namedTags: (context.NamedTags ?? []).map(tag => new NamedTag(tag.Name, tag.Value))
|
|
35
39
|
};
|
|
@@ -37,4 +41,20 @@ export function toClientEventContext(context) {
|
|
|
37
41
|
function toClientIdentity(identity) {
|
|
38
42
|
return identity ? new Identity(identity.Subject, identity.Name, identity.UserName, toClientIdentity(identity.OnBehalfOf)) : undefined;
|
|
39
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* The wire format carries an unset compensation as zero, which is also a valid sequence number. Zero is therefore
|
|
46
|
+
* only a compensation when the event type is a registered compensation event type.
|
|
47
|
+
*/
|
|
48
|
+
function toClientCompensationFor(context) {
|
|
49
|
+
const compensationFor = context.CompensationFor;
|
|
50
|
+
if (compensationFor === undefined) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (compensationFor !== 0n) {
|
|
54
|
+
return compensationFor;
|
|
55
|
+
}
|
|
56
|
+
const eventTypeId = context.EventType?.Id;
|
|
57
|
+
const type = eventTypeId ? TypeDiscoverer.default.getTypeByDecoratorTypeAndName(DecoratorType.EventType, eventTypeId) : undefined;
|
|
58
|
+
return type && getCompensatedTypeFor(type) ? 0n : undefined;
|
|
59
|
+
}
|
|
40
60
|
//# sourceMappingURL=toClientEventContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toClientEventContext.js","sourceRoot":"","sources":["../../events/toClientEventContext.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"toClientEventContext.js","sourceRoot":"","sources":["../../events/toClientEventContext.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,O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K,SAAS,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,IAAI,eAAe,KAAK,EAAE,EAAE,CAAC;QACzB,OAAO,eAAe,CAAC;IAC3B,CAAC;IACD,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,6BAA6B,CAAC,aAAa,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAClI,OAAO,IAAI,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ObservationOrigin } from './ObservationOrigin.js';
|
|
2
|
+
import type { BatchContextValues } from './BatchContextValues.js';
|
|
3
|
+
/**
|
|
4
|
+
* Describes the page of events a batch method is called for. It is read-only, and only batch methods receive it:
|
|
5
|
+
* per-event methods never get a {@link BatchContext}.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BatchContext {
|
|
8
|
+
/** The identifier of the observer (reactor or reducer). */
|
|
9
|
+
readonly observerId: string;
|
|
10
|
+
/** The event store the events come from. */
|
|
11
|
+
readonly eventStore: string;
|
|
12
|
+
/** The namespace the events come from. */
|
|
13
|
+
readonly namespace: string;
|
|
14
|
+
/** The event sequence the events come from. */
|
|
15
|
+
readonly eventSequenceId: string;
|
|
16
|
+
/** The path the page came from: live, catch-up, replay or retry. */
|
|
17
|
+
readonly origin: ObservationOrigin;
|
|
18
|
+
/** The partitions (event source identifiers) in the page, in the order the kernel delivered them. */
|
|
19
|
+
readonly partitions: readonly string[];
|
|
20
|
+
/** The number of events in the page. */
|
|
21
|
+
readonly eventCount: number;
|
|
22
|
+
/** The sequence number of the first event in the page, or undefined when the page is empty. */
|
|
23
|
+
readonly firstSequenceNumber: bigint | undefined;
|
|
24
|
+
/** The sequence number of the last event in the page, or undefined when the page is empty. */
|
|
25
|
+
readonly lastSequenceNumber: bigint | undefined;
|
|
26
|
+
/** When the kernel stops waiting for the result, or undefined when it waits without a deadline. */
|
|
27
|
+
readonly deadline: Date | undefined;
|
|
28
|
+
/** Aborted when the observation disconnects or the client is disposed. */
|
|
29
|
+
readonly signal: AbortSignal;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the kernel accepts deferred partitions for this page. A kernel that delivers single partitions
|
|
32
|
+
* instead of pages cannot defer; a deferral is then reported as a failure.
|
|
33
|
+
*/
|
|
34
|
+
readonly canDefer: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new {@link BatchContext}.
|
|
37
|
+
* @param values - The values describing the page.
|
|
38
|
+
*/
|
|
39
|
+
constructor(values: BatchContextValues);
|
|
40
|
+
/** Whether the page is part of a replay. */
|
|
41
|
+
get isReplay(): boolean;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=BatchContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchContext.d.ts","sourceRoot":"","sources":["../../../observation/batches/BatchContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE;;;GAGG;AACH,qBAAa,YAAY;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,+CAA+C;IAC/C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAEnC,qGAAqG;IACrG,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAEvC,wCAAwC;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,+FAA+F;IAC/F,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjD,8FAA8F;IAC9F,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IAEhD,mGAAmG;IACnG,QAAQ,CAAC,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IAEpC,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,YAAY,MAAM,EAAE,kBAAkB,EAcrC;IAED,4CAA4C;IAC5C,IAAI,QAAQ,IAAI,OAAO,CAEtB;CACJ"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
import { ObservationOrigin } from './ObservationOrigin.js';
|
|
4
|
+
/**
|
|
5
|
+
* Describes the page of events a batch method is called for. It is read-only, and only batch methods receive it:
|
|
6
|
+
* per-event methods never get a {@link BatchContext}.
|
|
7
|
+
*/
|
|
8
|
+
export class BatchContext {
|
|
9
|
+
/** The identifier of the observer (reactor or reducer). */
|
|
10
|
+
observerId;
|
|
11
|
+
/** The event store the events come from. */
|
|
12
|
+
eventStore;
|
|
13
|
+
/** The namespace the events come from. */
|
|
14
|
+
namespace;
|
|
15
|
+
/** The event sequence the events come from. */
|
|
16
|
+
eventSequenceId;
|
|
17
|
+
/** The path the page came from: live, catch-up, replay or retry. */
|
|
18
|
+
origin;
|
|
19
|
+
/** The partitions (event source identifiers) in the page, in the order the kernel delivered them. */
|
|
20
|
+
partitions;
|
|
21
|
+
/** The number of events in the page. */
|
|
22
|
+
eventCount;
|
|
23
|
+
/** The sequence number of the first event in the page, or undefined when the page is empty. */
|
|
24
|
+
firstSequenceNumber;
|
|
25
|
+
/** The sequence number of the last event in the page, or undefined when the page is empty. */
|
|
26
|
+
lastSequenceNumber;
|
|
27
|
+
/** When the kernel stops waiting for the result, or undefined when it waits without a deadline. */
|
|
28
|
+
deadline;
|
|
29
|
+
/** Aborted when the observation disconnects or the client is disposed. */
|
|
30
|
+
signal;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the kernel accepts deferred partitions for this page. A kernel that delivers single partitions
|
|
33
|
+
* instead of pages cannot defer; a deferral is then reported as a failure.
|
|
34
|
+
*/
|
|
35
|
+
canDefer;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new {@link BatchContext}.
|
|
38
|
+
* @param values - The values describing the page.
|
|
39
|
+
*/
|
|
40
|
+
constructor(values) {
|
|
41
|
+
this.observerId = values.observerId;
|
|
42
|
+
this.eventStore = values.eventStore;
|
|
43
|
+
this.namespace = values.namespace;
|
|
44
|
+
this.eventSequenceId = values.eventSequenceId;
|
|
45
|
+
this.origin = values.origin;
|
|
46
|
+
this.partitions = Object.freeze([...values.partitions]);
|
|
47
|
+
this.eventCount = values.eventCount;
|
|
48
|
+
this.firstSequenceNumber = values.firstSequenceNumber;
|
|
49
|
+
this.lastSequenceNumber = values.lastSequenceNumber;
|
|
50
|
+
this.deadline = values.deadline;
|
|
51
|
+
this.signal = values.signal;
|
|
52
|
+
this.canDefer = values.canDefer;
|
|
53
|
+
Object.freeze(this);
|
|
54
|
+
}
|
|
55
|
+
/** Whether the page is part of a replay. */
|
|
56
|
+
get isReplay() {
|
|
57
|
+
return this.origin === ObservationOrigin.Replay;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=BatchContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchContext.js","sourceRoot":"","sources":["../../../observation/batches/BatchContext.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE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AAQ,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,4CAA4C;IAC5C,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,MAAM,KAAK,iBAAiB,CAAC,MAAM,CAAC;IACpD,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The observer a {@link BatchContext} is created for. */
|
|
2
|
+
export type BatchContextObserver = {
|
|
3
|
+
/** The identifier of the observer. */
|
|
4
|
+
readonly observerId: string;
|
|
5
|
+
/** The event store the observer is registered with. */
|
|
6
|
+
readonly eventStore: string;
|
|
7
|
+
/** The namespace the observer is registered in. */
|
|
8
|
+
readonly namespace: string;
|
|
9
|
+
/** The event sequence the observer observes. */
|
|
10
|
+
readonly eventSequenceId: string;
|
|
11
|
+
/** Aborted when the observation stops. */
|
|
12
|
+
readonly signal: AbortSignal;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=BatchContextObserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchContextObserver.d.ts","sourceRoot":"","sources":["../../../observation/batches/BatchContextObserver.ts"],"names":[],"mappings":"AAGA,0DAA0D;AAC1D,MAAM,MAAM,oBAAoB,GAAG;IAC/B,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gDAAgD;IAChD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchContextObserver.js","sourceRoot":"","sources":["../../../observation/batches/BatchContextObserver.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BatchContextObserver } from './BatchContextObserver.js';
|
|
2
|
+
import type { ObservationOrigin } from './ObservationOrigin.js';
|
|
3
|
+
/** The values a {@link BatchContext} is created from. See {@link BatchContext} for what each value means. */
|
|
4
|
+
export type BatchContextValues = BatchContextObserver & {
|
|
5
|
+
readonly origin: ObservationOrigin;
|
|
6
|
+
readonly partitions: readonly string[];
|
|
7
|
+
readonly eventCount: number;
|
|
8
|
+
readonly firstSequenceNumber: bigint | undefined;
|
|
9
|
+
readonly lastSequenceNumber: bigint | undefined;
|
|
10
|
+
readonly deadline: Date | undefined;
|
|
11
|
+
readonly canDefer: boolean;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=BatchContextValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchContextValues.d.ts","sourceRoot":"","sources":["../../../observation/batches/BatchContextValues.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,6GAA6G;AAC7G,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG;IACpD,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchContextValues.js","sourceRoot":"","sources":["../../../observation/batches/BatchContextValues.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ObservedEventType } from './ObservedEventType.js';
|
|
2
|
+
/** A method of an observer that takes an {@link EventBatch}. */
|
|
3
|
+
export interface BatchMethod {
|
|
4
|
+
/** The name of the method. */
|
|
5
|
+
readonly methodName: string;
|
|
6
|
+
/** The event types the method observes, by event type identifier. */
|
|
7
|
+
readonly eventTypes: ReadonlyMap<string, ObservedEventType>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=BatchMethod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchMethod.d.ts","sourceRoot":"","sources":["../../../observation/batches/BatchMethod.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,gEAAgE;AAChE,MAAM,WAAW,WAAW;IACxB,8BAA8B;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchMethod.js","sourceRoot":"","sources":["../../../observation/batches/BatchMethod.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Reported when a reactor batch method returns a value. Batch reactor methods do not return events or other side effects. */
|
|
2
|
+
export declare class BatchMethodReturnedAValue extends Error {
|
|
3
|
+
readonly observerType: string;
|
|
4
|
+
readonly method: string;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new {@link BatchMethodReturnedAValue}.
|
|
7
|
+
* @param observerType - The name of the reactor class.
|
|
8
|
+
* @param method - The name of the batch method.
|
|
9
|
+
*/
|
|
10
|
+
constructor(observerType: string, method: string);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=BatchMethodReturnedAValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchMethodReturnedAValue.d.ts","sourceRoot":"","sources":["../../../observation/batches/BatchMethodReturnedAValue.ts"],"names":[],"mappings":"AAGA,8HAA8H;AAC9H,qBAAa,yBAA0B,SAAQ,KAAK;IAMpC,QAAQ,CAAC,YAAY,EAAE,MAAM;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM;IALlE;;;;OAIG;IACH,YAAqB,YAAY,EAAE,MAAM,EAAW,MAAM,EAAE,MAAM,EAIjE;CACJ"}
|
|
@@ -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
|
+
/** Reported when a reactor batch method returns a value. Batch reactor methods do not return events or other side effects. */
|
|
4
|
+
export class BatchMethodReturnedAValue extends Error {
|
|
5
|
+
observerType;
|
|
6
|
+
method;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new {@link BatchMethodReturnedAValue}.
|
|
9
|
+
* @param observerType - The name of the reactor class.
|
|
10
|
+
* @param method - The name of the batch method.
|
|
11
|
+
*/
|
|
12
|
+
constructor(observerType, method) {
|
|
13
|
+
super(`Batch method '${method}' on reactor '${observerType}' returned a value. Batch reactor methods return nothing; ` +
|
|
14
|
+
'append through an event log instead of returning events.');
|
|
15
|
+
this.observerType = observerType;
|
|
16
|
+
this.method = method;
|
|
17
|
+
this.name = 'BatchMethodReturnedAValue';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=BatchMethodReturnedAValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchMethodReturnedAValue.js","sourceRoot":"","sources":["../../../observation/batches/BatchMethodReturnedAValue.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,8HAA8H;AAC9H,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAM3B,YAAY;IAAmB,MAAM;IAL1D;;;;OAIG;IACH,YAAqB,YAAoB,EAAW,MAAc;QAC9D,KAAK,CAAC,iBAAiB,MAAM,iBAAiB,YAAY,4DAA4D;YAClH,0DAA0D,CAAC,CAAC;4BAF/C,YAAY;sBAAmB,MAAM;QAGtD,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC5C,CAAC;CACJ"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Constructor } from '@cratis/fundamentals';
|
|
2
|
+
import type { BatchMethod } from './BatchMethod.js';
|
|
3
|
+
/**
|
|
4
|
+
* Discovers the batch methods of an observer: the methods decorated with `@observes`.
|
|
5
|
+
* @param observerType - The observer class.
|
|
6
|
+
* @param registeredTypes - The event types registered with the event store.
|
|
7
|
+
* @param methods - The instance methods of the observer.
|
|
8
|
+
* @returns The {@link BatchMethod} instances.
|
|
9
|
+
* @throws {@link InvalidBatchMethod} when a batch method also declares a per-event decorator or observes an unregistered type.
|
|
10
|
+
* @throws {@link EventTypeObservedByMoreThanOneMethod} when two batch methods observe the same event type.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getBatchMethods(observerType: Constructor, registeredTypes: readonly Constructor[], methods?: ReadonlyMap<string, Function>): BatchMethod[];
|
|
13
|
+
/**
|
|
14
|
+
* Gets the instance methods of an observer that are not batch methods, for per-event discovery.
|
|
15
|
+
* @param methods - The instance methods.
|
|
16
|
+
* @param batchMethods - The batch methods.
|
|
17
|
+
* @returns The methods without the batch methods.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withoutBatchMethods(methods: ReadonlyMap<string, Function>, batchMethods: readonly BatchMethod[]): Map<string, Function>;
|
|
20
|
+
/**
|
|
21
|
+
* Throws when an event type observed by a batch method is also handled by a per-event method.
|
|
22
|
+
* @param observerType - The observer class.
|
|
23
|
+
* @param batchMethods - The batch methods.
|
|
24
|
+
* @param handlers - The per-event handlers, each with the event type identifier and the methods it reaches.
|
|
25
|
+
* @throws {@link EventTypeObservedByMoreThanOneMethod} when an event type reaches both.
|
|
26
|
+
*/
|
|
27
|
+
export declare function assertEachEventTypeReachesOneMethod(observerType: Constructor, batchMethods: readonly BatchMethod[], handlers: readonly {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly methodNames: readonly string[];
|
|
30
|
+
}[]): void;
|
|
31
|
+
//# sourceMappingURL=BatchMethods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchMethods.d.ts","sourceRoot":"","sources":["../../../observation/batches/BatchMethods.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,WAAW,EAAE,EAC9F,OAAO,GAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAoC,GAAG,WAAW,EAAE,CAkC5F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,SAAS,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAGvI;AAED;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,WAAW,EAAE,EAC/G,QAAQ,EAAE,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,GAAG,IAAI,CAS/F"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
import { getEventTypeMetadata } from '../../events/eventTypeDecorator.js';
|
|
4
|
+
import { getHandledEventType } from '../../events/handles.js';
|
|
5
|
+
import { isOnceOnly } from '../../reactors/onceOnly.js';
|
|
6
|
+
import { getReplayEventType } from '../../reactors/replay.js';
|
|
7
|
+
import { getInstanceMethods } from '../getInstanceMethods.js';
|
|
8
|
+
import { EventTypeObservedByMoreThanOneMethod } from './EventTypeObservedByMoreThanOneMethod.js';
|
|
9
|
+
import { InvalidBatchMethod } from './InvalidBatchMethod.js';
|
|
10
|
+
import { getObservedEventTypes } from './observes.js';
|
|
11
|
+
/**
|
|
12
|
+
* Discovers the batch methods of an observer: the methods decorated with `@observes`.
|
|
13
|
+
* @param observerType - The observer class.
|
|
14
|
+
* @param registeredTypes - The event types registered with the event store.
|
|
15
|
+
* @param methods - The instance methods of the observer.
|
|
16
|
+
* @returns The {@link BatchMethod} instances.
|
|
17
|
+
* @throws {@link InvalidBatchMethod} when a batch method also declares a per-event decorator or observes an unregistered type.
|
|
18
|
+
* @throws {@link EventTypeObservedByMoreThanOneMethod} when two batch methods observe the same event type.
|
|
19
|
+
*/
|
|
20
|
+
export function getBatchMethods(observerType, registeredTypes, methods = getInstanceMethods(observerType)) {
|
|
21
|
+
const typeName = observerType.name;
|
|
22
|
+
const observedBy = new Map();
|
|
23
|
+
const batchMethods = [];
|
|
24
|
+
for (const [name, method] of methods) {
|
|
25
|
+
const observed = getObservedEventTypes(method);
|
|
26
|
+
if (observed.length === 0)
|
|
27
|
+
continue;
|
|
28
|
+
if (getHandledEventType(method) !== undefined) {
|
|
29
|
+
throw new InvalidBatchMethod(typeName, name, 'it cannot also declare @handles. A batch method declares its event types with @observes only.');
|
|
30
|
+
}
|
|
31
|
+
if (getReplayEventType(method) !== undefined) {
|
|
32
|
+
throw new InvalidBatchMethod(typeName, name, 'it cannot also declare @replay. Batch methods receive replayed pages; check BatchContext.isReplay.');
|
|
33
|
+
}
|
|
34
|
+
if (isOnceOnly(method)) {
|
|
35
|
+
throw new InvalidBatchMethod(typeName, name, 'it cannot be @onceOnly. Mark the whole reactor @onceOnly, or check BatchContext.isReplay.');
|
|
36
|
+
}
|
|
37
|
+
const eventTypes = new Map();
|
|
38
|
+
for (const eventType of observed) {
|
|
39
|
+
const metadata = registeredTypes.includes(eventType) ? getEventTypeMetadata(eventType) : undefined;
|
|
40
|
+
if (!metadata) {
|
|
41
|
+
throw new InvalidBatchMethod(typeName, name, `it observes '${eventType.name}', which has no registered event type. Register that event constructor with the event store.`);
|
|
42
|
+
}
|
|
43
|
+
const id = metadata.eventType.id.value;
|
|
44
|
+
const previous = observedBy.get(id);
|
|
45
|
+
if (previous !== undefined) {
|
|
46
|
+
throw new EventTypeObservedByMoreThanOneMethod(typeName, eventType.name, [previous, name]);
|
|
47
|
+
}
|
|
48
|
+
observedBy.set(id, name);
|
|
49
|
+
eventTypes.set(id, { type: eventType, id, generation: metadata.eventType.generation.value });
|
|
50
|
+
}
|
|
51
|
+
batchMethods.push({ methodName: name, eventTypes });
|
|
52
|
+
}
|
|
53
|
+
return batchMethods;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the instance methods of an observer that are not batch methods, for per-event discovery.
|
|
57
|
+
* @param methods - The instance methods.
|
|
58
|
+
* @param batchMethods - The batch methods.
|
|
59
|
+
* @returns The methods without the batch methods.
|
|
60
|
+
*/
|
|
61
|
+
export function withoutBatchMethods(methods, batchMethods) {
|
|
62
|
+
const names = new Set(batchMethods.map(method => method.methodName));
|
|
63
|
+
return new Map([...methods].filter(([name]) => !names.has(name)));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Throws when an event type observed by a batch method is also handled by a per-event method.
|
|
67
|
+
* @param observerType - The observer class.
|
|
68
|
+
* @param batchMethods - The batch methods.
|
|
69
|
+
* @param handlers - The per-event handlers, each with the event type identifier and the methods it reaches.
|
|
70
|
+
* @throws {@link EventTypeObservedByMoreThanOneMethod} when an event type reaches both.
|
|
71
|
+
*/
|
|
72
|
+
export function assertEachEventTypeReachesOneMethod(observerType, batchMethods, handlers) {
|
|
73
|
+
for (const handler of handlers) {
|
|
74
|
+
const batchMethod = batchMethods.find(method => method.eventTypes.has(handler.id));
|
|
75
|
+
if (batchMethod) {
|
|
76
|
+
const observed = batchMethod.eventTypes.get(handler.id);
|
|
77
|
+
throw new EventTypeObservedByMoreThanOneMethod(observerType.name, observed.type.name, [batchMethod.methodName, ...handler.methodNames]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=BatchMethods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchMethods.js","sourceRoot":"","sources":["../../../observation/batches/BatchMethods.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAGrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAItD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,YAAyB,EAAE,eAAuC,EAC9F,OAAO,GAAkC,kBAAkB,CAAC,YAAY,CAAC;IACzE,MAAM,QAAQ,GAAI,YAAyB,CAAC,IAAI,CAAC;IACjD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,MAAM,YAAY,GAAkB,EAA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AC,EAAE,CAAE,CAAC;YACzD,MAAM,IAAI,oCAAoC,CAAE,YAAyB,CAAC,IAAI,EAAG,QAAQ,CAAC,IAAiB,CAAC,IAAI,EAC5G,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QAC1D,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BatchOutcomeKind } from './BatchOutcomeKind.js';
|
|
2
|
+
/** A partition a batch method reported it could not handle. */
|
|
3
|
+
export interface BatchOutcome {
|
|
4
|
+
/** The partition. */
|
|
5
|
+
readonly partition: string;
|
|
6
|
+
/** The sequence number of the first event not handled. */
|
|
7
|
+
readonly at: bigint;
|
|
8
|
+
/** Whether the partition failed or was deferred. */
|
|
9
|
+
readonly kind: BatchOutcomeKind;
|
|
10
|
+
/** The error describing a failure. */
|
|
11
|
+
readonly error?: unknown;
|
|
12
|
+
/** How long to wait before delivering the partition again, for a deferral. */
|
|
13
|
+
readonly retryAfterMilliseconds: number;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=BatchOutcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchOutcome.d.ts","sourceRoot":"","sources":["../../../observation/batches/BatchOutcome.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IACzB,qBAAqB;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC,sCAAsC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEzB,8EAA8E;IAC9E,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CAC3C"}
|