@cratis/chronicle 6.66.0 → 6.67.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/ArtifactRegistrationResult.ts +31 -0
- package/ChronicleClient.ts +2 -2
- package/ChronicleOptions.ts +12 -2
- package/EventStore.ts +31 -6
- package/IEventStore.ts +7 -0
- package/artifacts/ArtifactRegistrationAttempt.ts +50 -0
- package/dist/ArtifactRegistrationResult.d.ts +35 -0
- package/dist/ArtifactRegistrationResult.d.ts.map +1 -0
- package/dist/ArtifactRegistrationResult.js +4 -0
- package/dist/ArtifactRegistrationResult.js.map +1 -0
- package/dist/ChronicleClient.js +2 -2
- package/dist/ChronicleClient.js.map +1 -1
- package/dist/ChronicleOptions.d.ts +4 -0
- package/dist/ChronicleOptions.d.ts.map +1 -1
- package/dist/ChronicleOptions.js +8 -2
- package/dist/ChronicleOptions.js.map +1 -1
- package/dist/EventStore.d.ts +11 -2
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +29 -6
- package/dist/EventStore.js.map +1 -1
- package/dist/IEventStore.d.ts +6 -0
- package/dist/IEventStore.d.ts.map +1 -1
- package/dist/artifacts/ArtifactRegistrationAttempt.d.ts +20 -0
- package/dist/artifacts/ArtifactRegistrationAttempt.d.ts.map +1 -0
- package/dist/artifacts/ArtifactRegistrationAttempt.js +47 -0
- package/dist/artifacts/ArtifactRegistrationAttempt.js.map +1 -0
- package/dist/eventSequences/EventEnrichmentContext.d.ts +15 -0
- package/dist/eventSequences/EventEnrichmentContext.d.ts.map +1 -0
- package/dist/eventSequences/EventEnrichmentContext.js +4 -0
- package/dist/eventSequences/EventEnrichmentContext.js.map +1 -0
- package/dist/eventSequences/EventEnrichmentProvider.d.ts +10 -0
- package/dist/eventSequences/EventEnrichmentProvider.d.ts.map +1 -0
- package/dist/eventSequences/EventEnrichmentProvider.js +4 -0
- package/dist/eventSequences/EventEnrichmentProvider.js.map +1 -0
- package/dist/eventSequences/EventLog.d.ts +2 -1
- package/dist/eventSequences/EventLog.d.ts.map +1 -1
- package/dist/eventSequences/EventLog.js +2 -2
- package/dist/eventSequences/EventLog.js.map +1 -1
- package/dist/eventSequences/EventSequence.d.ts +4 -1
- package/dist/eventSequences/EventSequence.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +28 -8
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/eventSequences/enrichEventContent.d.ts +5 -0
- package/dist/eventSequences/enrichEventContent.d.ts.map +1 -0
- package/dist/eventSequences/enrichEventContent.js +16 -0
- package/dist/eventSequences/enrichEventContent.js.map +1 -0
- package/dist/eventSequences/index.d.ts +2 -0
- package/dist/eventSequences/index.d.ts.map +1 -1
- package/dist/eventSequences/index.js.map +1 -1
- package/dist/for_EventStore/when_inspecting_registration/given/an_event_store.d.ts +13 -0
- package/dist/for_EventStore/when_inspecting_registration/given/an_event_store.d.ts.map +1 -0
- package/dist/for_EventStore/when_inspecting_registration/given/an_event_store.js +79 -0
- package/dist/for_EventStore/when_inspecting_registration/given/an_event_store.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/projections/Projections.d.ts +2 -1
- package/dist/projections/Projections.d.ts.map +1 -1
- package/dist/projections/Projections.js +7 -4
- package/dist/projections/Projections.js.map +1 -1
- package/dist/projections/registerProjectionWithRetry.d.ts +4 -2
- package/dist/projections/registerProjectionWithRetry.d.ts.map +1 -1
- package/dist/projections/registerProjectionWithRetry.js +8 -4
- package/dist/projections/registerProjectionWithRetry.js.map +1 -1
- package/dist/testing/InProcessConstraints.d.ts.map +1 -1
- package/dist/testing/InProcessConstraints.js +0 -3
- package/dist/testing/InProcessConstraints.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eventSequences/EventEnrichmentContext.ts +18 -0
- package/eventSequences/EventEnrichmentProvider.ts +16 -0
- package/eventSequences/EventLog.ts +4 -2
- package/eventSequences/EventSequence.ts +33 -10
- package/eventSequences/enrichEventContent.ts +22 -0
- package/eventSequences/for_EventSequence/when_enriching_appends/from_client_options.spec.ts +64 -0
- package/eventSequences/for_EventSequence/when_enriching_appends/given.fixture.ts +53 -0
- package/eventSequences/for_EventSequence/when_enriching_appends/with_a_failing_provider.spec.ts +57 -0
- package/eventSequences/for_EventSequence/when_enriching_appends/with_a_pending_provider.spec.ts +58 -0
- package/eventSequences/for_EventSequence/when_enriching_appends/with_providers.spec.ts +66 -0
- package/eventSequences/for_EventSequence/when_enriching_appends/without_providers.spec.ts +25 -0
- package/eventSequences/index.ts +2 -0
- package/for_EventStore/when_inspecting_registration/given/an_event_store.ts +59 -0
- package/for_EventStore/when_inspecting_registration/with_new_attempts.spec.ts +104 -0
- package/for_EventStore/when_inspecting_registration/with_projection_outcomes.spec.ts +80 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/projections/Projections.ts +10 -4
- package/projections/for_registerProjectionWithRetry/when_reporting_outcomes.spec.ts +71 -0
- package/projections/registerProjectionWithRetry.ts +11 -5
- package/testing/InProcessConstraints.ts +0 -3
- package/testing/for_EventScenario/when_appending_scoped_constraints/scope_scenario_behaviors.fixture.ts +32 -22
- package/testing/for_EventScenario/when_appending_scoped_constraints/with_legacy_decorators.legacy.spec.ts +27 -1
- package/testing/for_EventScenario/when_appending_scoped_constraints/with_standard_decorators.standard.spec.ts +27 -1
- package/testing/for_EventScenario/when_appending_scoped_constraints/with_unproven_operations.spec.ts +32 -2
package/dist/EventStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventStore.d.ts","sourceRoot":"","sources":["../EventStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAG1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,m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BAAoB,CAAqC;IAEjE,kFAAkF;IAClF,IAAI,kBAAkB,IAAI,0BAA0B,CAEnD;IAED,YACa,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,uBAAuB,EAC1B,WAAW,EAAE,mBAAmB,EACjD,SAAS,EAAE,mBAAmB,EAC9B,iBAAiB,EAAE,MAAM,EACR,UAAU,GAAE,wBAAiE,EAC9F,oBAAoB,CAAC,EAAE,oBAAoB,EAC3C,iBAAiB,CAAC,EAAE,wBAAwB,EAC5C,qBAAqB,CAAC,EAAE,qBAAqB,EAC5B,UAAU,CAAC,EAAE,yBAAyB,YAAA,EACtC,cAAc,GAAE,OAAe,EAChD,sBAAsB,GAAE,MAA6B,EACpC,yBAAyB,GAAE,SAAS,uBAAuB,EAAO,EA8BtF;IAED;;;;;OAKG;IACG,iBAAiB,CAAC,MAAM,SAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAU1D;YAEa,mBAAmB;IAqDjC,6EAA6E;IAC7E,mBAAmB,IAAI,IAAI,CAI1B;IAED,kBAAkB;IAClB,gBAAgB,CAAC,EAAE,EAAE,eAAe,GAAG,cAAc,CAYpD;IAED,kBAAkB;IACZ,aAAa,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAexD;CACJ"}
|
package/dist/EventStore.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
import { createLogger } from './logging/createLogger.js';
|
|
4
|
+
import { ArtifactRegistrationAttempt } from './artifacts/ArtifactRegistrationAttempt.js';
|
|
4
5
|
import { setTelemetryAttribute, recordSafeException } from './telemetry/spanAttributes.js';
|
|
5
6
|
import { SpanStatusCode } from '@opentelemetry/api';
|
|
6
7
|
import { EventSources } from './eventSources/EventSources.js';
|
|
@@ -45,6 +46,7 @@ export class EventStore {
|
|
|
45
46
|
_artifacts;
|
|
46
47
|
_telemetry;
|
|
47
48
|
_skipKeepAlive;
|
|
49
|
+
_eventEnrichmentProviders;
|
|
48
50
|
_logger;
|
|
49
51
|
eventLog;
|
|
50
52
|
eventTypes;
|
|
@@ -68,13 +70,20 @@ export class EventStore {
|
|
|
68
70
|
observers;
|
|
69
71
|
_sequences = new Map();
|
|
70
72
|
_constraints;
|
|
71
|
-
|
|
73
|
+
_projections;
|
|
74
|
+
_registrationAttempt = new ArtifactRegistrationAttempt();
|
|
75
|
+
/** Gets a snapshot of the latest registration attempt, not observer readiness. */
|
|
76
|
+
get registrationResult() {
|
|
77
|
+
return this._registrationAttempt.result;
|
|
78
|
+
}
|
|
79
|
+
constructor(name, namespace, _connection, lifecycle, defaultSinkTypeId, _artifacts = DefaultClientArtifactsProvider.default, reactorResultHandler, artifactActivator, readModelNamingPolicy, _telemetry, _skipKeepAlive = false, defaultGraphSinkTypeId = WellKnownSinks.Neo4j, _eventEnrichmentProviders = []) {
|
|
72
80
|
this.name = name;
|
|
73
81
|
this.namespace = namespace;
|
|
74
82
|
this._connection = _connection;
|
|
75
83
|
this._artifacts = _artifacts;
|
|
76
84
|
this._telemetry = _telemetry;
|
|
77
85
|
this._skipKeepAlive = _skipKeepAlive;
|
|
86
|
+
this._eventEnrichmentProviders = _eventEnrichmentProviders;
|
|
78
87
|
this._logger = createLogger('@cratis/chronicle/EventStore', _connection.logger);
|
|
79
88
|
this.unitOfWorkManager = new UnitOfWorkManager(this);
|
|
80
89
|
const artifacts = this._artifacts;
|
|
@@ -82,10 +91,11 @@ export class EventStore {
|
|
|
82
91
|
this.constraints = this._constraints;
|
|
83
92
|
this.eventSources = new EventSources(name.value, _connection, artifacts);
|
|
84
93
|
const resolveConstraintMessage = this._constraints.resolveMessageFor.bind(this._constraints);
|
|
85
|
-
this.eventLog = new EventLog(name.value, namespace.value, _connection, this.unitOfWorkManager, resolveConstraintMessage, _telemetry, this.eventSources);
|
|
94
|
+
this.eventLog = new EventLog(name.value, namespace.value, _connection, this.unitOfWorkManager, resolveConstraintMessage, _telemetry, this.eventSources, _eventEnrichmentProviders);
|
|
86
95
|
this._sequences.set(EventSequenceId.eventLog.value, this.eventLog);
|
|
87
96
|
this.eventTypes = new EventTypes(name.value, _connection, artifacts);
|
|
88
|
-
this.
|
|
97
|
+
this._projections = new Projections(name.value, namespace.value, _connection, artifacts, defaultSinkTypeId, readModelNamingPolicy);
|
|
98
|
+
this.projections = this._projections;
|
|
89
99
|
this.graphs = new Graphs(name.value, _connection, artifacts, defaultGraphSinkTypeId);
|
|
90
100
|
this.reactors = new Reactors(artifacts, _connection, name.value, namespace.value, lifecycle, this.eventLog, reactorResultHandler, this, artifactActivator, _skipKeepAlive);
|
|
91
101
|
this.reducers = new Reducers(artifacts, _connection, name.value, namespace.value, lifecycle, defaultSinkTypeId, this, artifactActivator, readModelNamingPolicy, _skipKeepAlive);
|
|
@@ -104,9 +114,22 @@ export class EventStore {
|
|
|
104
114
|
/**
|
|
105
115
|
* Registers all discovered artifacts with the Chronicle Kernel.
|
|
106
116
|
* Called on initial connect and on reconnect.
|
|
117
|
+
* @param reason - Why this registration attempt started.
|
|
107
118
|
* @returns A promise that resolves when all registrations are complete.
|
|
108
119
|
*/
|
|
109
|
-
async registerArtifacts() {
|
|
120
|
+
async registerArtifacts(reason = 'explicit') {
|
|
121
|
+
const attempt = new ArtifactRegistrationAttempt(this._registrationAttempt.attemptId + 1, reason);
|
|
122
|
+
this._registrationAttempt = attempt;
|
|
123
|
+
try {
|
|
124
|
+
await this.performRegistration(attempt);
|
|
125
|
+
attempt.complete();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
attempt.fail(error);
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async performRegistration(attempt) {
|
|
110
133
|
if (this._skipKeepAlive)
|
|
111
134
|
refuseClientHostedObservers(this._artifacts);
|
|
112
135
|
this._logger.debug('Discovering artifacts for registration', {
|
|
@@ -141,7 +164,7 @@ export class EventStore {
|
|
|
141
164
|
await this.eventSources.register();
|
|
142
165
|
await Promise.all([
|
|
143
166
|
this.constraints.register(),
|
|
144
|
-
this.
|
|
167
|
+
this._projections.register(outcome => attempt.record(outcome)),
|
|
145
168
|
this.graphs.register(),
|
|
146
169
|
this.reactors.register(),
|
|
147
170
|
this.reducers.register(),
|
|
@@ -165,7 +188,7 @@ export class EventStore {
|
|
|
165
188
|
if (existing) {
|
|
166
189
|
return existing;
|
|
167
190
|
}
|
|
168
|
-
const sequence = new EventSequence(id, this.name.value, this.namespace.value, this._connection, this.unitOfWorkManager, this._constraints.resolveMessageFor.bind(this._constraints), this._telemetry, this.eventSources);
|
|
191
|
+
const sequence = new EventSequence(id, this.name.value, this.namespace.value, this._connection, this.unitOfWorkManager, this._constraints.resolveMessageFor.bind(this._constraints), this._telemetry, this.eventSources, this._eventEnrichmentProviders);
|
|
169
192
|
this._sequences.set(id.value, sequence);
|
|
170
193
|
return sequence;
|
|
171
194
|
}
|
package/dist/EventStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventStore.js","sourceRoot":"","sources":["../EventStore.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"EventStore.js","sourceRoot":"","sources":["../EventStore.ts"],"names":[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AAC,WAAW,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;gBAClG,MAAM,MAAM,GAAG,kBAAkB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,uBAAuB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC5H,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC5C,OAAO,MAAM,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBACjC,MAAM,KAAK,CAAC;YAChB,CAAC;oBAAS,CAAC;gBACP,IAAI,CAAC,GAAG,EAAE,CAAC;YACf,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
package/dist/IEventStore.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { IEventLog } from './eventSequences/IEventLog.js';
|
|
|
2
2
|
import { IEventSequence } from './eventSequences/IEventSequence.js';
|
|
3
3
|
import { EventSequenceId } from './eventSequences/EventSequenceId.js';
|
|
4
4
|
import { EventStoreName } from './EventStoreName.js';
|
|
5
|
+
import type { ArtifactRegistrationResult } from './ArtifactRegistrationResult.js';
|
|
5
6
|
import { EventStoreNamespaceName } from './EventStoreNamespaceName.js';
|
|
6
7
|
import type { IEventSources } from './eventSources/IEventSources.js';
|
|
7
8
|
import { IEventTypes } from './events/IEventTypes.js';
|
|
@@ -27,6 +28,11 @@ import { IObservers } from './observation/IObservers.js';
|
|
|
27
28
|
* An event store is a logical grouping of event sequences within a namespace.
|
|
28
29
|
*/
|
|
29
30
|
export interface IEventStore {
|
|
31
|
+
/**
|
|
32
|
+
* Snapshot of the most recent artifact registration attempt, not observer readiness.
|
|
33
|
+
* Optional for compatibility with event stores that do not perform kernel registration.
|
|
34
|
+
*/
|
|
35
|
+
readonly registrationResult?: ArtifactRegistrationResult;
|
|
30
36
|
/** The name of the event store. */
|
|
31
37
|
readonly name: EventStoreName;
|
|
32
38
|
/** The namespace of the event store. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IEventStore.d.ts","sourceRoot":"","sources":["../IEventStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,6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empt, including work completing after a rejection. */
|
|
3
|
+
export declare class ArtifactRegistrationAttempt {
|
|
4
|
+
readonly attemptId: number;
|
|
5
|
+
readonly reason: string;
|
|
6
|
+
private readonly _projections;
|
|
7
|
+
private _state;
|
|
8
|
+
private _error?;
|
|
9
|
+
constructor(attemptId?: number, reason?: string);
|
|
10
|
+
/** Gets a snapshot; reading a later attempt never changes a previously retained snapshot. */
|
|
11
|
+
get result(): ArtifactRegistrationResult;
|
|
12
|
+
/** Records a projection response or failure without changing the registration control flow. */
|
|
13
|
+
record(outcome: ProjectionRegistrationOutcome): void;
|
|
14
|
+
/** Marks the orchestration complete. */
|
|
15
|
+
complete(): void;
|
|
16
|
+
/** Retains the same error the caller receives. */
|
|
17
|
+
fail(error: unknown): void;
|
|
18
|
+
private updateFailureState;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ArtifactRegistrationAttempt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArtifactRegistrationAttempt.d.ts","sourceRoot":"","sources":["../../artifacts/ArtifactRegistrationAttempt.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAA6B,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAE7I,6GAA6G;AAC7G,qBAAa,2BAA2B;IAKxB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAAM,QAAQ,CAAC,MAAM,EAAE,MAAM;IAJnE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoD;IACjF,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAAC,CAAU;IAEzB,YAAqB,SAAS,GAAE,MAAU,EAAW,MAAM,GAAE,MAAkB,EAE9E;IAED,6FAA6F;IAC7F,IAAI,MAAM,IAAI,0BAA0B,CAUvC;IAED,+FAA+F;IAC/F,MAAM,CAAC,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAGnD;IAED,wCAAwC;IACxC,QAAQ,IAAI,IAAI,CAEf;IAED,kDAAkD;IAClD,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAGzB;IAED,OAAO,CAAC,kBAAkB;CAI7B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** Keeps updates isolated to their own registration attempt, including work completing after a rejection. */
|
|
4
|
+
export class ArtifactRegistrationAttempt {
|
|
5
|
+
attemptId;
|
|
6
|
+
reason;
|
|
7
|
+
_projections = new Map();
|
|
8
|
+
_state;
|
|
9
|
+
_error;
|
|
10
|
+
constructor(attemptId = 0, reason = 'not-run') {
|
|
11
|
+
this.attemptId = attemptId;
|
|
12
|
+
this.reason = reason;
|
|
13
|
+
this._state = attemptId === 0 ? 'not-run' : 'in-progress';
|
|
14
|
+
}
|
|
15
|
+
/** Gets a snapshot; reading a later attempt never changes a previously retained snapshot. */
|
|
16
|
+
get result() {
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
attemptId: this.attemptId,
|
|
19
|
+
reason: this.reason,
|
|
20
|
+
state: this._state,
|
|
21
|
+
projections: Object.freeze([...this._projections.values()]),
|
|
22
|
+
failures: Object.freeze([...this._projections.values()].filter(outcome => outcome.state === 'failed')),
|
|
23
|
+
error: this._error,
|
|
24
|
+
observerLiveness: 'unknown'
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Records a projection response or failure without changing the registration control flow. */
|
|
28
|
+
record(outcome) {
|
|
29
|
+
this._projections.set(outcome.identifier, Object.freeze(outcome));
|
|
30
|
+
if (this._state === 'failed' || this._state === 'partially-failed')
|
|
31
|
+
this.updateFailureState();
|
|
32
|
+
}
|
|
33
|
+
/** Marks the orchestration complete. */
|
|
34
|
+
complete() {
|
|
35
|
+
this._state = 'successful';
|
|
36
|
+
}
|
|
37
|
+
/** Retains the same error the caller receives. */
|
|
38
|
+
fail(error) {
|
|
39
|
+
this._error = error;
|
|
40
|
+
this.updateFailureState();
|
|
41
|
+
}
|
|
42
|
+
updateFailureState() {
|
|
43
|
+
this._state = [...this._projections.values()].some(outcome => outcome.state === 'successful')
|
|
44
|
+
? 'partially-failed' : 'failed';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=ArtifactRegistrationAttempt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArtifactRegistrationAttempt.js","sourceRoot":"","sources":["../../artifacts/ArtifactRegistrationAttempt.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAIrG,6GAA6G;AAC7G,MAAM,OAAO,2BAA2B;IAKf,SAAS;IAAuB,MAAM;IAJ1C,YAAY,GAAG,IAAI,GAAG,EAAyC,CAAC;IACzE,MAAM,CAA4B;IAClC,MAAM,CAAW;IAEzB,YAAqB,SAAS,GAAW,CAAC,EAAW,MAAM,GAAW,SAAS;yBAA1D,SAAS;sBAAuB,MAAM;QACvD,IAAI,CAAC,MAAM,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC;IAC9D,CAAC;IAED,6FAA6F;IAC7F,IAAI,MAAM;QACN,OAAO,MAAM,CAAC,MAAM,CAAC;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3D,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;YACtG,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,gBAAgB,EAAE,SAAS;SAC9B,CAAC,CAAC;IACP,CAAC;IAED,+FAA+F;IAC/F,MAAM,CAAC,OAAsC;QACzC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAClE,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,kBAAkB;YAAE,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAClG,CAAC;IAED,wCAAwC;IACxC,QAAQ;QACJ,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC/B,CAAC;IAED,kDAAkD;IAClD,IAAI,CAAC,KAAc;QACf,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC9B,CAAC;IAEO,kBAAkB;QACtB,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,YAAY,CAAC;YACzF,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxC,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Guid } from '@cratis/fundamentals';
|
|
2
|
+
import type { EventType } from '../events/EventType.js';
|
|
3
|
+
import type { EventSequenceId } from './EventSequenceId.js';
|
|
4
|
+
/** Read-only event and append information available to an enrichment provider. */
|
|
5
|
+
export interface EventEnrichmentContext {
|
|
6
|
+
/** The original event. Providers must mutate the serialized content, not this instance. */
|
|
7
|
+
readonly event: Readonly<object>;
|
|
8
|
+
readonly eventType: Readonly<EventType>;
|
|
9
|
+
readonly eventStore: string;
|
|
10
|
+
readonly namespace: string;
|
|
11
|
+
readonly eventSequenceId: EventSequenceId;
|
|
12
|
+
readonly eventSourceId: string;
|
|
13
|
+
readonly correlationId: Guid;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=EventEnrichmentContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEnrichmentContext.d.ts","sourceRoot":"","sources":["../../eventSequences/EventEnrichmentContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,kFAAkF;AAClF,MAAM,WAAW,sBAAsB;IACnC,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEnrichmentContext.js","sourceRoot":"","sources":["../../eventSequences/EventEnrichmentContext.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EventEnrichmentContext } from './EventEnrichmentContext.js';
|
|
2
|
+
/**
|
|
3
|
+
* Enriches an event's serialized JSON object before append transmission.
|
|
4
|
+
* Providers may add, replace, or remove content properties, including nested values,
|
|
5
|
+
* but must leave JSON-serializable content compatible with the registered event schema.
|
|
6
|
+
* Routing, event type, tags, and other append metadata are not content and cannot be changed here.
|
|
7
|
+
* Providers run and are awaited in registration order; throwing or rejecting prevents transmission.
|
|
8
|
+
*/
|
|
9
|
+
export type EventEnrichmentProvider = (content: Record<string, unknown>, context: EventEnrichmentContext) => void | Promise<void>;
|
|
10
|
+
//# sourceMappingURL=EventEnrichmentProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEnrichmentProvider.d.ts","sourceRoot":"","sources":["../../eventSequences/EventEnrichmentProvider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,sBAAsB,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEnrichmentProvider.js","sourceRoot":"","sources":["../../eventSequences/EventEnrichmentProvider.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
|
|
@@ -4,12 +4,13 @@ import { IEventLog } from './IEventLog.js';
|
|
|
4
4
|
import { IUnitOfWorkManager } from '../transactions/IUnitOfWorkManager.js';
|
|
5
5
|
import type { ConstraintViolation } from './ConstraintViolation.js';
|
|
6
6
|
import type { IEventSources } from '../eventSources/IEventSources.js';
|
|
7
|
+
import type { EventEnrichmentProvider } from './EventEnrichmentProvider.js';
|
|
7
8
|
import type { ChronicleTelemetryOptions } from '../telemetry/ChronicleTelemetryOptions.js';
|
|
8
9
|
/**
|
|
9
10
|
* Implements {@link IEventLog} by extending the base {@link EventSequence}.
|
|
10
11
|
* The event log is the default event sequence used for all domain events.
|
|
11
12
|
*/
|
|
12
13
|
export declare class EventLog extends EventSequence implements IEventLog {
|
|
13
|
-
constructor(eventStoreName: string, namespace: string, connection: ChronicleConnection, unitOfWorkManager: IUnitOfWorkManager, resolveConstraintMessage?: (violation: ConstraintViolation) => ConstraintViolation, telemetry?: ChronicleTelemetryOptions, eventSources?: IEventSources);
|
|
14
|
+
constructor(eventStoreName: string, namespace: string, connection: ChronicleConnection, unitOfWorkManager: IUnitOfWorkManager, resolveConstraintMessage?: (violation: ConstraintViolation) => ConstraintViolation, telemetry?: ChronicleTelemetryOptions, eventSources?: IEventSources, eventEnrichmentProviders?: readonly EventEnrichmentProvider[]);
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=EventLog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventLog.d.ts","sourceRoot":"","sources":["../../eventSequences/EventLog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAE3F;;;GAGG;AACH,qBAAa,QAAS,SAAQ,aAAc,YAAW,SAAS;IAC5D,YACI,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,mBAAmB,EAC/B,iBAAiB,EAAE,kBAAkB,EACrC,wBAAwB,CAAC,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,mBAAmB,EAClF,SAAS,CAAC,EAAE,yBAAyB,EACrC,YAAY,CAAC,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"EventLog.d.ts","sourceRoot":"","sources":["../../eventSequences/EventLog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAE3F;;;GAGG;AACH,qBAAa,QAAS,SAAQ,aAAc,YAAW,SAAS;IAC5D,YACI,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,mBAAmB,EAC/B,iBAAiB,EAAE,kBAAkB,EACrC,wBAAwB,CAAC,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,mBAAmB,EAClF,SAAS,CAAC,EAAE,yBAAyB,EACrC,YAAY,CAAC,EAAE,aAAa,EAC5B,wBAAwB,GAAE,SAAS,uBAAuB,EAAO,EAGpE;CACJ"}
|
|
@@ -7,8 +7,8 @@ import { EventSequenceId } from './EventSequenceId.js';
|
|
|
7
7
|
* The event log is the default event sequence used for all domain events.
|
|
8
8
|
*/
|
|
9
9
|
export class EventLog extends EventSequence {
|
|
10
|
-
constructor(eventStoreName, namespace, connection, unitOfWorkManager, resolveConstraintMessage, telemetry, eventSources) {
|
|
11
|
-
super(EventSequenceId.eventLog, eventStoreName, namespace, connection, unitOfWorkManager, resolveConstraintMessage, telemetry, eventSources);
|
|
10
|
+
constructor(eventStoreName, namespace, connection, unitOfWorkManager, resolveConstraintMessage, telemetry, eventSources, eventEnrichmentProviders = []) {
|
|
11
|
+
super(EventSequenceId.eventLog, eventStoreName, namespace, connection, unitOfWorkManager, resolveConstraintMessage, telemetry, eventSources, eventEnrichmentProviders);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=EventLog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventLog.js","sourceRoot":"","sources":["../../eventSequences/EventLog.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAGrG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"EventLog.js","sourceRoot":"","sources":["../../eventSequences/EventLog.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAGrG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAQvD;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,aAAa;IACvC,YACI,cAAsB,EACtB,SAAiB,EACjB,UAA+B,EAC/B,iBAAqC,EACrC,wBAAkF,EAClF,SAAqC,EACrC,YAA4B,EAC5B,wBAAwB,GAAuC,EAAE;QAEjE,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,SAAS,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAC;IAC3K,CAAC;CACJ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChronicleConnection } from '../connection/index.js';
|
|
2
2
|
import { Constructor } from '@cratis/fundamentals';
|
|
3
|
+
import type { EventEnrichmentProvider } from './EventEnrichmentProvider.js';
|
|
3
4
|
import type { AppendedEvent } from '../events/AppendedEvent.js';
|
|
4
5
|
import { AppendedEventWithResult } from './AppendedEventWithResult.js';
|
|
5
6
|
import { AppendOperationsBroadcaster } from './AppendOperationsBroadcaster.js';
|
|
@@ -33,9 +34,10 @@ export declare class EventSequence implements IEventSequence {
|
|
|
33
34
|
private readonly _resolveConstraintMessage?;
|
|
34
35
|
private readonly _telemetry?;
|
|
35
36
|
private readonly _eventSources?;
|
|
37
|
+
private readonly _eventEnrichmentProviders;
|
|
36
38
|
readonly transactional: ITransactionalEventSequence;
|
|
37
39
|
readonly appendOperations: AppendOperationsBroadcaster<AppendedEventWithResult[]>;
|
|
38
|
-
constructor(id: EventSequenceId, _eventStoreName: string, _namespace: string, _connection: ChronicleConnection, _unitOfWorkManager: IUnitOfWorkManager, _resolveConstraintMessage?: ((violation: ConstraintViolation) => ConstraintViolation) | undefined, _telemetry?: ChronicleTelemetryOptions | undefined, _eventSources?: IEventSources | undefined);
|
|
40
|
+
constructor(id: EventSequenceId, _eventStoreName: string, _namespace: string, _connection: ChronicleConnection, _unitOfWorkManager: IUnitOfWorkManager, _resolveConstraintMessage?: ((violation: ConstraintViolation) => ConstraintViolation) | undefined, _telemetry?: ChronicleTelemetryOptions | undefined, _eventSources?: IEventSources | undefined, _eventEnrichmentProviders?: readonly EventEnrichmentProvider[]);
|
|
39
41
|
/** @inheritdoc */
|
|
40
42
|
append(eventSourceId: string, event: object, options?: AppendOptions): Promise<AppendResult>;
|
|
41
43
|
private get sequenceMetricAttributes();
|
|
@@ -50,6 +52,7 @@ export declare class EventSequence implements IEventSequence {
|
|
|
50
52
|
appendMany(events: EventForEventSourceId[], options?: AppendOptions): Promise<AppendResult[]>;
|
|
51
53
|
private verifyNamedTagBatch;
|
|
52
54
|
private applyBatchRouting;
|
|
55
|
+
private enrichContent;
|
|
53
56
|
private sendAppendMany;
|
|
54
57
|
private toAppendManyResults;
|
|
55
58
|
private recordAppendManyMetrics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventSequence.d.ts","sourceRoot":"","sources":["../../eventSequences/EventSequence.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAO7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,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AM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4BlG;IAED,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,2BAA2B;IAMnC,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,iBAAiB;IAUzB;;;OAGG;YACW,yBAAyB;IAoCvC,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAC8C;IAEzE,OAAO,CAAC,0BAA0B;CAcrC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { SpanStatusCode } from '@opentelemetry/api';
|
|
4
4
|
import { prepareSingleAppend } from './prepareSingleAppend.js';
|
|
5
5
|
import { prepareBatchAppend } from './prepareBatchAppend.js';
|
|
6
|
+
import { enrichEventContent } from './enrichEventContent.js';
|
|
6
7
|
import { ensureNamedTagBatchIsSupported } from './ensureNamedTagBatchIsSupported.js';
|
|
7
8
|
import { toContractsCausation } from './toContractsCausation.js';
|
|
8
9
|
import { createAppendNotification, mapAppendNotificationCausation } from './createAppendNotification.js';
|
|
@@ -42,9 +43,10 @@ export class EventSequence {
|
|
|
42
43
|
_resolveConstraintMessage;
|
|
43
44
|
_telemetry;
|
|
44
45
|
_eventSources;
|
|
46
|
+
_eventEnrichmentProviders;
|
|
45
47
|
transactional;
|
|
46
48
|
appendOperations = new AppendOperationsBroadcaster();
|
|
47
|
-
constructor(id, _eventStoreName, _namespace, _connection, _unitOfWorkManager, _resolveConstraintMessage, _telemetry, _eventSources) {
|
|
49
|
+
constructor(id, _eventStoreName, _namespace, _connection, _unitOfWorkManager, _resolveConstraintMessage, _telemetry, _eventSources, _eventEnrichmentProviders = []) {
|
|
48
50
|
this.id = id;
|
|
49
51
|
this._eventStoreName = _eventStoreName;
|
|
50
52
|
this._namespace = _namespace;
|
|
@@ -53,12 +55,16 @@ export class EventSequence {
|
|
|
53
55
|
this._resolveConstraintMessage = _resolveConstraintMessage;
|
|
54
56
|
this._telemetry = _telemetry;
|
|
55
57
|
this._eventSources = _eventSources;
|
|
58
|
+
this._eventEnrichmentProviders = _eventEnrichmentProviders;
|
|
56
59
|
this.transactional = new TransactionalEventSequence(this, this._unitOfWorkManager);
|
|
57
60
|
}
|
|
58
61
|
/** @inheritdoc */
|
|
59
62
|
async append(eventSourceId, event, options) {
|
|
60
63
|
const routing = resolveSingleRouting(this._eventSources, options);
|
|
61
|
-
const prepared = prepareSingleAppend(event, options);
|
|
64
|
+
const prepared = { ...prepareSingleAppend(event, options), eventSourceId, event };
|
|
65
|
+
if (this._eventEnrichmentProviders.length > 0) {
|
|
66
|
+
prepared.content = await this.enrichContent(prepared);
|
|
67
|
+
}
|
|
62
68
|
const { eventType, correlationId, tags, namedTags, causationChain } = prepared;
|
|
63
69
|
const sequenceMetricAttributes = this.sequenceMetricAttributes;
|
|
64
70
|
const metricAttributes = { ...sequenceMetricAttributes, [names.attributes.eventTypeId]: eventType.id.value };
|
|
@@ -71,7 +77,7 @@ export class EventSequence {
|
|
|
71
77
|
span.setAttribute(names.attributes.eventSourceType, options.sourceType);
|
|
72
78
|
const startTime = performance.now();
|
|
73
79
|
try {
|
|
74
|
-
const response = await this.sendAppend(
|
|
80
|
+
const response = await this.sendAppend(prepared, routing, options);
|
|
75
81
|
const appendResponse = ensureCommandResponse('append event', response);
|
|
76
82
|
const durationInSeconds = (performance.now() - startTime) / 1000;
|
|
77
83
|
const result = this.mapAppendResponse(appendResponse.SequenceNumber, appendResponse.ConstraintViolations ?? [], appendResponse.Errors ?? [], appendResponse.ConcurrencyViolation);
|
|
@@ -100,11 +106,12 @@ export class EventSequence {
|
|
|
100
106
|
[names.attributes.eventSequenceId]: this.id.value
|
|
101
107
|
};
|
|
102
108
|
}
|
|
103
|
-
async sendAppend(
|
|
109
|
+
async sendAppend(prepared, routing, options) {
|
|
110
|
+
const { eventSourceId } = prepared;
|
|
104
111
|
const concurrencyScope = options?.concurrencyScope ?? (routing
|
|
105
112
|
? await deriveConcurrencyScope(routing, eventSourceId, options?.streamId, this.tailReader)
|
|
106
113
|
: undefined);
|
|
107
|
-
const request = this.createAppendRequest(
|
|
114
|
+
const request = this.createAppendRequest(prepared, concurrencyScope, this.toAppendRouteFields(routing, options));
|
|
108
115
|
// Named tags travel on the dedicated call so a kernel without support rejects them instead of dropping them.
|
|
109
116
|
return prepared.namedTags.length === 0
|
|
110
117
|
? await this._connection.eventSequences.append(request)
|
|
@@ -119,7 +126,7 @@ export class EventSequence {
|
|
|
119
126
|
Occurred: toContractsOccurred(options?.occurred)
|
|
120
127
|
};
|
|
121
128
|
}
|
|
122
|
-
createAppendRequest(eventSourceId,
|
|
129
|
+
createAppendRequest({ eventSourceId, eventType, correlationId, content, tags, causationChain, identity, subject }, concurrencyScope, routeFields) {
|
|
123
130
|
return {
|
|
124
131
|
EventStore: this._eventStoreName,
|
|
125
132
|
Namespace: this._namespace,
|
|
@@ -159,6 +166,11 @@ export class EventSequence {
|
|
|
159
166
|
const { eventsForEventSourceIds, appendOptions, correlationId, concurrencyScopes, eventsToAppend } = prepared;
|
|
160
167
|
const wireEvents = eventsToAppend;
|
|
161
168
|
const routings = eventsForEventSourceIds.map(event => resolveBatchRouting(this._eventSources, event, appendOptions));
|
|
169
|
+
if (this._eventEnrichmentProviders.length > 0) {
|
|
170
|
+
for (const [index, { eventSourceId, event }] of eventsForEventSourceIds.entries()) {
|
|
171
|
+
wireEvents[index].Content = await this.enrichContent({ eventSourceId, event, content: wireEvents[index].Content, correlationId });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
162
174
|
await this.verifyNamedTagBatch(prepared, routings);
|
|
163
175
|
const explicitIds = new Set([...concurrencyScopes].filter(([, scope]) => scope !== undefined).map(([id]) => id));
|
|
164
176
|
const derivedGuards = planDerivedGuards(routings, eventsForEventSourceIds, appendOptions?.streamId, explicitIds);
|
|
@@ -179,7 +191,7 @@ export class EventSequence {
|
|
|
179
191
|
const response = await this.sendAppendMany(prepared, wireEvents);
|
|
180
192
|
const appendManyResponse = ensureCommandResponse('append many events', response);
|
|
181
193
|
const durationInSeconds = (performance.now() - startTime) / 1000;
|
|
182
|
-
const result = this.toAppendManyResults(appendManyResponse,
|
|
194
|
+
const result = this.toAppendManyResults(appendManyResponse, prepared);
|
|
183
195
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
184
196
|
this.recordAppendManyMetrics(result, eventsForEventSourceIds.length, durationInSeconds, batchMetricAttributes);
|
|
185
197
|
this.publishAppendMany(prepared, result);
|
|
@@ -212,6 +224,13 @@ export class EventSequence {
|
|
|
212
224
|
};
|
|
213
225
|
});
|
|
214
226
|
}
|
|
227
|
+
enrichContent({ eventSourceId, event, content, correlationId }) {
|
|
228
|
+
return enrichEventContent(content, {
|
|
229
|
+
event, eventType: getEventTypeFor(event.constructor),
|
|
230
|
+
eventStore: this._eventStoreName, namespace: this._namespace,
|
|
231
|
+
eventSequenceId: this.id, eventSourceId, correlationId
|
|
232
|
+
}, this._eventEnrichmentProviders);
|
|
233
|
+
}
|
|
215
234
|
async sendAppendMany({ correlationId, batchCausationChain, identity, concurrencyScopes, namedTags }, wireEvents) {
|
|
216
235
|
const request = {
|
|
217
236
|
EventStore: this._eventStoreName,
|
|
@@ -233,7 +252,8 @@ export class EventSequence {
|
|
|
233
252
|
Events: wireEvents.map((wireEvent, index) => ({ ...wireEvent, NamedTags: toContractsNamedTags(namedTags[index]) }))
|
|
234
253
|
});
|
|
235
254
|
}
|
|
236
|
-
toAppendManyResults(appendManyResponse,
|
|
255
|
+
toAppendManyResults(appendManyResponse, { eventsForEventSourceIds }) {
|
|
256
|
+
const eventCount = eventsForEventSourceIds.length;
|
|
237
257
|
// Mirrors the C# client: every per-event AppendResult in a batch carries all
|
|
238
258
|
// constraint violations and the first concurrency violation of the whole batch —
|
|
239
259
|
// the wire response doesn't correlate either back to a specific event index.
|