@cratis/chronicle 6.65.0 → 6.67.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.
Files changed (137) hide show
  1. package/ArtifactRegistrationResult.ts +31 -0
  2. package/ChronicleClient.ts +4 -3
  3. package/ChronicleOptions.ts +76 -24
  4. package/EventStore.ts +31 -6
  5. package/IEventStore.ts +7 -0
  6. package/artifacts/ArtifactRegistrationAttempt.ts +50 -0
  7. package/connection/ChronicleConnection.auth.spec.ts +3 -3
  8. package/connection/ChronicleConnection.ts +7 -0
  9. package/connection/CompatibilityPreflight.ts +22 -4
  10. package/connection/for_ChronicleConnection/when_checking_compatibility/before_append.spec.ts +12 -1
  11. package/connection/for_ChronicleConnection/when_creating_clients/with_correlated_multi_host_callers.spec.ts +1 -1
  12. package/connection/for_ChronicleConnection/when_deferring_client_creation/and_connecting.spec.ts +1 -1
  13. package/connection/for_CompatibilityPreflight/when_verifying/with_concurrent_calls.spec.ts +2 -2
  14. package/connection/for_CompatibilityPreflight/when_verifying/with_kernel_versions.spec.ts +38 -0
  15. package/connection/for_TraceContextMiddleware/when_calling/with_active_context.spec.ts +1 -1
  16. package/connection/for_TraceContextMiddleware/when_calling/with_grpc_instrumentation.spec.ts +1 -1
  17. package/dist/ArtifactRegistrationResult.d.ts +35 -0
  18. package/dist/ArtifactRegistrationResult.d.ts.map +1 -0
  19. package/dist/ArtifactRegistrationResult.js +4 -0
  20. package/dist/ArtifactRegistrationResult.js.map +1 -0
  21. package/dist/ChronicleClient.d.ts.map +1 -1
  22. package/dist/ChronicleClient.js +4 -3
  23. package/dist/ChronicleClient.js.map +1 -1
  24. package/dist/ChronicleOptions.d.ts +22 -0
  25. package/dist/ChronicleOptions.d.ts.map +1 -1
  26. package/dist/ChronicleOptions.js +62 -24
  27. package/dist/ChronicleOptions.js.map +1 -1
  28. package/dist/EventStore.d.ts +11 -2
  29. package/dist/EventStore.d.ts.map +1 -1
  30. package/dist/EventStore.js +29 -6
  31. package/dist/EventStore.js.map +1 -1
  32. package/dist/IEventStore.d.ts +6 -0
  33. package/dist/IEventStore.d.ts.map +1 -1
  34. package/dist/artifacts/ArtifactRegistrationAttempt.d.ts +20 -0
  35. package/dist/artifacts/ArtifactRegistrationAttempt.d.ts.map +1 -0
  36. package/dist/artifacts/ArtifactRegistrationAttempt.js +47 -0
  37. package/dist/artifacts/ArtifactRegistrationAttempt.js.map +1 -0
  38. package/dist/connection/ChronicleConnection.d.ts +2 -0
  39. package/dist/connection/ChronicleConnection.d.ts.map +1 -1
  40. package/dist/connection/ChronicleConnection.js +6 -0
  41. package/dist/connection/ChronicleConnection.js.map +1 -1
  42. package/dist/connection/CompatibilityPreflight.d.ts +5 -0
  43. package/dist/connection/CompatibilityPreflight.d.ts.map +1 -1
  44. package/dist/connection/CompatibilityPreflight.js +18 -3
  45. package/dist/connection/CompatibilityPreflight.js.map +1 -1
  46. package/dist/eventSequences/EventEnrichmentContext.d.ts +15 -0
  47. package/dist/eventSequences/EventEnrichmentContext.d.ts.map +1 -0
  48. package/dist/eventSequences/EventEnrichmentContext.js +4 -0
  49. package/dist/eventSequences/EventEnrichmentContext.js.map +1 -0
  50. package/dist/eventSequences/EventEnrichmentProvider.d.ts +10 -0
  51. package/dist/eventSequences/EventEnrichmentProvider.d.ts.map +1 -0
  52. package/dist/eventSequences/EventEnrichmentProvider.js +4 -0
  53. package/dist/eventSequences/EventEnrichmentProvider.js.map +1 -0
  54. package/dist/eventSequences/EventLog.d.ts +2 -1
  55. package/dist/eventSequences/EventLog.d.ts.map +1 -1
  56. package/dist/eventSequences/EventLog.js +2 -2
  57. package/dist/eventSequences/EventLog.js.map +1 -1
  58. package/dist/eventSequences/EventSequence.d.ts +7 -1
  59. package/dist/eventSequences/EventSequence.d.ts.map +1 -1
  60. package/dist/eventSequences/EventSequence.js +40 -11
  61. package/dist/eventSequences/EventSequence.js.map +1 -1
  62. package/dist/eventSequences/IEventSequence.d.ts +2 -0
  63. package/dist/eventSequences/IEventSequence.d.ts.map +1 -1
  64. package/dist/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.d.ts +1 -1
  65. package/dist/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.d.ts.map +1 -1
  66. package/dist/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.js +3 -3
  67. package/dist/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.js.map +1 -1
  68. package/dist/eventSequences/enrichEventContent.d.ts +5 -0
  69. package/dist/eventSequences/enrichEventContent.d.ts.map +1 -0
  70. package/dist/eventSequences/enrichEventContent.js +16 -0
  71. package/dist/eventSequences/enrichEventContent.js.map +1 -0
  72. package/dist/eventSequences/ensureNamedTagBatchIsSupported.d.ts +2 -2
  73. package/dist/eventSequences/ensureNamedTagBatchIsSupported.d.ts.map +1 -1
  74. package/dist/eventSequences/ensureNamedTagBatchIsSupported.js +10 -3
  75. package/dist/eventSequences/ensureNamedTagBatchIsSupported.js.map +1 -1
  76. package/dist/eventSequences/index.d.ts +2 -0
  77. package/dist/eventSequences/index.d.ts.map +1 -1
  78. package/dist/eventSequences/index.js.map +1 -1
  79. package/dist/for_EventStore/when_inspecting_registration/given/an_event_store.d.ts +13 -0
  80. package/dist/for_EventStore/when_inspecting_registration/given/an_event_store.d.ts.map +1 -0
  81. package/dist/for_EventStore/when_inspecting_registration/given/an_event_store.js +79 -0
  82. package/dist/for_EventStore/when_inspecting_registration/given/an_event_store.js.map +1 -0
  83. package/dist/index.d.ts +2 -0
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +1 -0
  86. package/dist/index.js.map +1 -1
  87. package/dist/projections/Projections.d.ts +2 -1
  88. package/dist/projections/Projections.d.ts.map +1 -1
  89. package/dist/projections/Projections.js +7 -4
  90. package/dist/projections/Projections.js.map +1 -1
  91. package/dist/projections/registerProjectionWithRetry.d.ts +4 -2
  92. package/dist/projections/registerProjectionWithRetry.d.ts.map +1 -1
  93. package/dist/projections/registerProjectionWithRetry.js +8 -4
  94. package/dist/projections/registerProjectionWithRetry.js.map +1 -1
  95. package/dist/testing/ReactorScenario.d.ts.map +1 -1
  96. package/dist/testing/ReactorScenario.js +0 -2
  97. package/dist/testing/ReactorScenario.js.map +1 -1
  98. package/dist/transactions/UnitOfWork.d.ts +1 -0
  99. package/dist/transactions/UnitOfWork.d.ts.map +1 -1
  100. package/dist/transactions/UnitOfWork.js +17 -11
  101. package/dist/transactions/UnitOfWork.js.map +1 -1
  102. package/dist/tsconfig.tsbuildinfo +1 -1
  103. package/eventSequences/EventEnrichmentContext.ts +18 -0
  104. package/eventSequences/EventEnrichmentProvider.ts +16 -0
  105. package/eventSequences/EventLog.ts +4 -2
  106. package/eventSequences/EventSequence.ts +47 -13
  107. package/eventSequences/IEventSequence.ts +3 -0
  108. package/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.ts +3 -3
  109. package/eventSequences/enrichEventContent.ts +22 -0
  110. package/eventSequences/ensureNamedTagBatchIsSupported.ts +11 -3
  111. package/eventSequences/for_EventSequence/when_appending_named_tags/given.fixture.ts +3 -2
  112. package/eventSequences/for_EventSequence/when_appending_named_tags/with_kernel_versions.spec.ts +92 -0
  113. package/eventSequences/for_EventSequence/when_appending_named_tags/with_registered_sources.spec.ts +28 -22
  114. package/eventSequences/for_EventSequence/when_enriching_appends/from_client_options.spec.ts +64 -0
  115. package/eventSequences/for_EventSequence/when_enriching_appends/given.fixture.ts +53 -0
  116. package/eventSequences/for_EventSequence/when_enriching_appends/with_a_failing_provider.spec.ts +57 -0
  117. package/eventSequences/for_EventSequence/when_enriching_appends/with_a_pending_provider.spec.ts +58 -0
  118. package/eventSequences/for_EventSequence/when_enriching_appends/with_providers.spec.ts +66 -0
  119. package/eventSequences/for_EventSequence/when_enriching_appends/without_providers.spec.ts +25 -0
  120. package/eventSequences/index.ts +2 -0
  121. package/for_ChronicleClient/connectTimeout.spec.ts +29 -0
  122. package/for_ChronicleClient/when_starting_background_work/with_a_correlated_caller.spec.ts +1 -1
  123. package/for_ChronicleOptions/when_configuring_the_connect_timeout/with_connect_timeout.spec.ts +23 -0
  124. package/for_EventStore/when_inspecting_registration/given/an_event_store.ts +59 -0
  125. package/for_EventStore/when_inspecting_registration/with_new_attempts.spec.ts +104 -0
  126. package/for_EventStore/when_inspecting_registration/with_projection_outcomes.spec.ts +80 -0
  127. package/for_index/when_importing_connection_helpers.spec.ts +13 -0
  128. package/index.ts +2 -0
  129. package/package.json +1 -1
  130. package/patterns/for_Patterns/when_querying_through_the_connection/after_resetting_the_channel.spec.ts +1 -1
  131. package/projections/Projections.ts +10 -4
  132. package/projections/for_registerProjectionWithRetry/when_reporting_outcomes.spec.ts +71 -0
  133. package/projections/registerProjectionWithRetry.ts +11 -5
  134. package/testing/ReactorScenario.ts +0 -3
  135. package/testing/for_ReactorScenario/when_recording_side_effects/with_named_tags.spec.ts +11 -13
  136. package/transactions/UnitOfWork.ts +18 -14
  137. package/transactions/for_UnitOfWork/when_committing_events_with_named_tags.spec.ts +87 -29
@@ -0,0 +1,31 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import type { ProjectionsClient } from '@cratis/chronicle.contracts';
5
+
6
+ /** The aggregate outcome of an artifact registration attempt. */
7
+ export type ArtifactRegistrationState = 'not-run' | 'in-progress' | 'successful' | 'partially-failed' | 'failed';
8
+
9
+ /** The kernel's actual projection registration response (currently an empty acknowledgment). */
10
+ export type ProjectionRegistrationResponse = Awaited<ReturnType<ProjectionsClient['register']>>;
11
+
12
+ /** The outcome of registering one declared projection. Unattempted projections remain not-run. */
13
+ export type ProjectionRegistrationOutcome =
14
+ | { readonly identifier: string; readonly state: 'not-run' }
15
+ | { readonly identifier: string; readonly state: 'successful'; readonly response: ProjectionRegistrationResponse }
16
+ | { readonly identifier: string; readonly state: 'failed'; readonly error: unknown };
17
+
18
+ /** An inspectable snapshot of an event store's most recent artifact registration attempt. */
19
+ export interface ArtifactRegistrationResult {
20
+ /** Monotonically increasing within this event store; zero means registration has not run. */
21
+ readonly attemptId: number;
22
+ /** Why the client registered again, for example new-store or a reconnect reason. */
23
+ readonly reason: string;
24
+ readonly state: ArtifactRegistrationState;
25
+ readonly projections: readonly ProjectionRegistrationOutcome[];
26
+ readonly failures: readonly Extract<ProjectionRegistrationOutcome, { state: 'failed' }>[];
27
+ /** The error thrown by orchestration, if any. Inspect it explicitly; it is not sanitized for logging. */
28
+ readonly error?: unknown;
29
+ /** Declaration registration never proves that a client-hosted observer is live. */
30
+ readonly observerLiveness: 'unknown';
31
+ }
@@ -122,7 +122,8 @@ export class ChronicleClient implements IChronicleClient {
122
122
  deferClientCreation: options.skipKeepAlive,
123
123
  logger: options.logger,
124
124
  maxReceiveMessageSize: options.maxReceiveMessageSize ?? undefined,
125
- maxSendMessageSize: options.maxSendMessageSize ?? undefined
125
+ maxSendMessageSize: options.maxSendMessageSize ?? undefined,
126
+ connectTimeout: options.connectTimeout
126
127
  });
127
128
 
128
129
  this._logger.info('Created Chronicle client', {
@@ -231,7 +232,7 @@ export class ChronicleClient implements IChronicleClient {
231
232
  });
232
233
  ensureCommandSuccess('ensure event store', await this._connection.eventStores.ensureEventStore({ Name: storeName.value }));
233
234
 
234
- const created = new EventStore(storeName, namespaceName, this._connection, this._lifecycle, this.options.defaultSinkTypeId, this.options.clientArtifactsProvider, this.options.reactorResultHandler, this.options.artifactActivator, this.options.readModelNamingPolicy, this.options.telemetry, this.options.skipKeepAlive, this.options.defaultGraphSinkTypeId);
235
+ const created = new EventStore(storeName, namespaceName, this._connection, this._lifecycle, this.options.defaultSinkTypeId, this.options.clientArtifactsProvider, this.options.reactorResultHandler, this.options.artifactActivator, this.options.readModelNamingPolicy, this.options.telemetry, this.options.skipKeepAlive, this.options.defaultGraphSinkTypeId, this.options.eventEnrichmentProviders);
235
236
  this._stores.set(key, created);
236
237
 
237
238
  try {
@@ -670,7 +671,7 @@ export class ChronicleClient implements IChronicleClient {
670
671
  );
671
672
  }
672
673
 
673
- await store.registerArtifacts();
674
+ await store.registerArtifacts(reason);
674
675
 
675
676
  this._logger.info('Registered artifacts for event store', {
676
677
  eventStore: store.name.value,
@@ -6,12 +6,14 @@ import { DefaultClientArtifactsProvider, IClientArtifactsProvider } from './arti
6
6
  import { ChronicleConnectionString } from './connection/index.js';
7
7
  import { WellKnownSinks } from './sinks/index.js';
8
8
  import type { ReactorResultHandler } from './reactors/ReactorResultHandler.js';
9
+ import type { EventEnrichmentProvider } from './eventSequences/EventEnrichmentProvider.js';
9
10
  import type { ClientArtifactsActivator } from './artifacts/ClientArtifactsActivator.js';
10
11
  import type { ReadModelNamingPolicy } from './readModels/ReadModelNamingPolicy.js';
11
12
  import type { ChronicleTelemetryOptions } from './telemetry/ChronicleTelemetryOptions.js';
12
13
  import type { IChronicleLogger } from './logging/IChronicleLogger.js';
13
14
 
14
15
  type ChronicleOptionsConstructorParams = {
16
+ eventEnrichmentProviders?: readonly EventEnrichmentProvider[];
15
17
  telemetry?: ChronicleTelemetryOptions;
16
18
  logger?: IChronicleLogger;
17
19
  connectionString: ChronicleConnectionString;
@@ -28,9 +30,11 @@ type ChronicleOptionsConstructorParams = {
28
30
  readModelNamingPolicy?: ReadModelNamingPolicy;
29
31
  maxReceiveMessageSize?: number | null;
30
32
  maxSendMessageSize?: number | null;
33
+ connectTimeout?: number;
31
34
  };
32
35
 
33
36
  type ChronicleOptionsFactoryParams = {
37
+ eventEnrichmentProviders?: readonly EventEnrichmentProvider[];
34
38
  skipKeepAlive?: boolean;
35
39
  telemetry?: ChronicleTelemetryOptions;
36
40
  logger?: IChronicleLogger;
@@ -43,6 +47,7 @@ type ChronicleOptionsFactoryParams = {
43
47
  readModelNamingPolicy?: ReadModelNamingPolicy;
44
48
  maxReceiveMessageSize?: number | null;
45
49
  maxSendMessageSize?: number | null;
50
+ connectTimeout?: number;
46
51
  };
47
52
 
48
53
  /**
@@ -110,6 +115,9 @@ export class ChronicleOptions {
110
115
  /** Optional handler for application-owned reactor returns, installed before observations begin. */
111
116
  readonly reactorResultHandler?: ReactorResultHandler;
112
117
 
118
+ /** Ordered post-serialization providers for single and batch appends on every event store and sequence. */
119
+ readonly eventEnrichmentProviders: readonly EventEnrichmentProvider[];
120
+
113
121
  /** Optional per-delivery reactor/reducer activator; absent means one instance per observation stream. */
114
122
  readonly artifactActivator?: ClientArtifactsActivator;
115
123
 
@@ -133,6 +141,13 @@ export class ChronicleOptions {
133
141
  */
134
142
  readonly maxSendMessageSize: number | null;
135
143
 
144
+ /**
145
+ * How long, in milliseconds, the client waits for the kernel to answer the compatibility check on each new
146
+ * connection. Defaults to 10 seconds. A kernel that does not answer in time fails the connection attempt,
147
+ * which is retried; the check itself is never skipped by a timeout.
148
+ */
149
+ readonly connectTimeout: number;
150
+
136
151
  private constructor(options: ChronicleOptionsConstructorParams) {
137
152
  this.connectionString = options.connectionString;
138
153
  this.skipKeepAlive = options.skipKeepAlive === true;
@@ -144,36 +159,70 @@ export class ChronicleOptions {
144
159
  this.defaultSinkTypeId = options.defaultSinkTypeId ?? WellKnownSinks.MongoDB;
145
160
  this.defaultGraphSinkTypeId = options.defaultGraphSinkTypeId ?? WellKnownSinks.Neo4j;
146
161
  this.reactorResultHandler = options.reactorResultHandler;
162
+ this.eventEnrichmentProviders = [...(options.eventEnrichmentProviders ?? [])];
147
163
  this.artifactActivator = options.artifactActivator;
148
164
  this.readModelNamingPolicy = options.readModelNamingPolicy;
149
165
  this.maxReceiveMessageSize = options.maxReceiveMessageSize === undefined ? ChronicleOptions.defaultMaxMessageSize : options.maxReceiveMessageSize;
150
166
  this.maxSendMessageSize = options.maxSendMessageSize === undefined ? ChronicleOptions.defaultMaxMessageSize : options.maxSendMessageSize;
151
- const spanNames = options.telemetry?.spanNames;
152
- if (spanNames !== undefined && spanNames !== 'legacy' && spanNames !== 'convention') {
167
+ this.connectTimeout = ChronicleOptions.validConnectTimeout(options.connectTimeout ?? ChronicleOptions.defaultConnectTimeout);
168
+ ChronicleOptions.validateTelemetry(options.telemetry);
169
+ this.telemetry = options.telemetry;
170
+ this.logger = options.logger;
171
+ }
172
+
173
+ private static validConnectTimeout(connectTimeout: number): number {
174
+ // AbortSignal.timeout accepts only whole milliseconds that fit an unsigned 32-bit integer.
175
+ const isSupportedTimeout = Number.isInteger(connectTimeout) && connectTimeout > 0 && connectTimeout <= ChronicleOptions.maxConnectTimeout;
176
+ if (!isSupportedTimeout) {
177
+ throw new TypeError(`connectTimeout must be a whole number of milliseconds between 1 and ${ChronicleOptions.maxConnectTimeout}.`);
178
+ }
179
+ return connectTimeout;
180
+ }
181
+
182
+ private static validateTelemetry(telemetry?: ChronicleTelemetryOptions): void {
183
+ ChronicleOptions.validateSpanNames(telemetry?.spanNames);
184
+ ChronicleOptions.validateEventSourceIdPolicy(telemetry?.eventSourceId);
185
+ }
186
+
187
+ private static validateSpanNames(spanNames?: string): void {
188
+ if (spanNames !== undefined && !ChronicleOptions._spanNames.has(spanNames)) {
153
189
  throw new TypeError('telemetry.spanNames must be legacy or convention.');
154
190
  }
155
- const policy = options.telemetry?.eventSourceId;
156
- if (policy !== undefined) {
157
- if (policy?.mode !== 'raw' && policy?.mode !== 'hmac') {
158
- throw new TypeError('telemetry.eventSourceId.mode must be raw or hmac.');
159
- }
160
- if (policy.mode === 'hmac' && (!types.isUint8Array(policy.key) || policy.key.byteLength === 0)) {
161
- throw new TypeError('telemetry.eventSourceId.key must be a non-empty Uint8Array for hmac mode.');
162
- }
191
+ }
192
+
193
+ private static validateEventSourceIdPolicy(policy: ChronicleTelemetryOptions['eventSourceId']): void {
194
+ if (policy === undefined) return;
195
+ if (!ChronicleOptions._eventSourceIdModes.has(policy?.mode)) {
196
+ throw new TypeError('telemetry.eventSourceId.mode must be raw or hmac.');
197
+ }
198
+ if (policy.mode === 'hmac' && !ChronicleOptions.isNonEmptyKey(policy.key)) {
199
+ throw new TypeError('telemetry.eventSourceId.key must be a non-empty Uint8Array for hmac mode.');
163
200
  }
164
- this.telemetry = options.telemetry;
165
- this.logger = options.logger;
201
+ }
202
+
203
+ private static readonly _spanNames: ReadonlySet<unknown> = new Set(['legacy', 'convention']);
204
+ private static readonly _eventSourceIdModes: ReadonlySet<unknown> = new Set(['raw', 'hmac']);
205
+
206
+ private static isNonEmptyKey(key: unknown): boolean {
207
+ return types.isUint8Array(key) && key.byteLength > 0;
166
208
  }
167
209
 
168
210
  /** The default maximum gRPC message size in bytes: 100 MB. */
169
211
  static readonly defaultMaxMessageSize = 100 * 1024 * 1024;
170
212
 
213
+ /** The default time, in milliseconds, the client waits for the kernel's compatibility check: 10 seconds. */
214
+ static readonly defaultConnectTimeout = 10_000;
215
+
216
+ /** The longest connect timeout, in milliseconds, the client accepts: the largest unsigned 32-bit integer. */
217
+ static readonly maxConnectTimeout = 4_294_967_295;
218
+
171
219
  private static defaultDiscoveryPatterns(): string[] {
172
220
  const typescriptEntry = /\.(?:ts|tsx|mts|cts)$/i.test(process.argv[1] ?? '');
173
221
  const typescriptLoader = process.execArgv.some(arg => /(?:tsx|ts-node|--experimental-strip-types|--experimental-transform-types)/i.test(arg));
174
222
  // process.features.typescript is set on every Node.js 24+ process (type stripping), so it
175
223
  // does not mean the program was started from TypeScript; it is deliberately not consulted.
176
- if (!typescriptEntry && !process.env.VITEST && !typescriptLoader) return [];
224
+ const discoversTypeScript = typescriptEntry || !!process.env.VITEST || typescriptLoader;
225
+ if (!discoversTypeScript) return [];
177
226
  return [
178
227
  '**/*.ts',
179
228
  '**/*.tsx',
@@ -206,20 +255,23 @@ export class ChronicleOptions {
206
255
  const parsed = typeof connectionString === 'string'
207
256
  ? new ChronicleConnectionString(connectionString)
208
257
  : connectionString;
258
+ const factoryOptions: ChronicleOptionsFactoryParams = options ?? {};
209
259
  return new ChronicleOptions({
210
260
  connectionString: parsed,
211
261
  skipKeepAlive: ChronicleOptions.shouldSkipKeepAlive(parsed, options),
212
- clientArtifactsProvider: options?.clientArtifactsProvider,
213
- discoveryPatterns: options?.discoveryPatterns,
214
- defaultSinkTypeId: options?.defaultSinkTypeId,
215
- defaultGraphSinkTypeId: options?.defaultGraphSinkTypeId,
216
- reactorResultHandler: options?.reactorResultHandler,
217
- artifactActivator: options?.artifactActivator,
218
- readModelNamingPolicy: options?.readModelNamingPolicy,
219
- maxReceiveMessageSize: options?.maxReceiveMessageSize,
220
- maxSendMessageSize: options?.maxSendMessageSize,
221
- telemetry: options?.telemetry,
222
- logger: options?.logger
262
+ clientArtifactsProvider: factoryOptions.clientArtifactsProvider,
263
+ discoveryPatterns: factoryOptions.discoveryPatterns,
264
+ defaultSinkTypeId: factoryOptions.defaultSinkTypeId,
265
+ defaultGraphSinkTypeId: factoryOptions.defaultGraphSinkTypeId,
266
+ reactorResultHandler: factoryOptions.reactorResultHandler,
267
+ eventEnrichmentProviders: factoryOptions.eventEnrichmentProviders,
268
+ artifactActivator: factoryOptions.artifactActivator,
269
+ readModelNamingPolicy: factoryOptions.readModelNamingPolicy,
270
+ maxReceiveMessageSize: factoryOptions.maxReceiveMessageSize,
271
+ maxSendMessageSize: factoryOptions.maxSendMessageSize,
272
+ connectTimeout: factoryOptions.connectTimeout,
273
+ telemetry: factoryOptions.telemetry,
274
+ logger: factoryOptions.logger
223
275
  });
224
276
  }
225
277
 
package/EventStore.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
4
  import { createLogger } from './logging/createLogger.js';
5
+ import type { ArtifactRegistrationResult } from './ArtifactRegistrationResult.js';
6
+ import { ArtifactRegistrationAttempt } from './artifacts/ArtifactRegistrationAttempt.js';
5
7
  import type { ChronicleTelemetryOptions } from './telemetry/ChronicleTelemetryOptions.js';
6
8
  import { setTelemetryAttribute, recordSafeException } from './telemetry/spanAttributes.js';
7
9
  import { SpanStatusCode } from '@opentelemetry/api';
@@ -13,6 +15,7 @@ import { ensureQuerySuccess } from './connection/callResults.js';
13
15
  import { EventLog } from './eventSequences/EventLog.js';
14
16
  import { EventSequence } from './eventSequences/EventSequence.js';
15
17
  import { EventSequenceId } from './eventSequences/EventSequenceId.js';
18
+ import type { EventEnrichmentProvider } from './eventSequences/EventEnrichmentProvider.js';
16
19
  import { IEventLog } from './eventSequences/IEventLog.js';
17
20
  import { IEventSequence } from './eventSequences/IEventSequence.js';
18
21
  import { EventStoreName } from './EventStoreName.js';
@@ -95,6 +98,13 @@ export class EventStore implements IEventStore {
95
98
 
96
99
  private readonly _sequences: Map<string, IEventSequence> = new Map();
97
100
  private readonly _constraints: Constraints;
101
+ private readonly _projections: Projections;
102
+ private _registrationAttempt = new ArtifactRegistrationAttempt();
103
+
104
+ /** Gets a snapshot of the latest registration attempt, not observer readiness. */
105
+ get registrationResult(): ArtifactRegistrationResult {
106
+ return this._registrationAttempt.result;
107
+ }
98
108
 
99
109
  constructor(
100
110
  readonly name: EventStoreName,
@@ -108,7 +118,8 @@ export class EventStore implements IEventStore {
108
118
  readModelNamingPolicy?: ReadModelNamingPolicy,
109
119
  private readonly _telemetry?: ChronicleTelemetryOptions,
110
120
  private readonly _skipKeepAlive: boolean = false,
111
- defaultGraphSinkTypeId: string = WellKnownSinks.Neo4j
121
+ defaultGraphSinkTypeId: string = WellKnownSinks.Neo4j,
122
+ private readonly _eventEnrichmentProviders: readonly EventEnrichmentProvider[] = []
112
123
  ) {
113
124
  this._logger = createLogger('@cratis/chronicle/EventStore', _connection.logger);
114
125
  this.unitOfWorkManager = new UnitOfWorkManager(this);
@@ -118,11 +129,12 @@ export class EventStore implements IEventStore {
118
129
  this.constraints = this._constraints;
119
130
  this.eventSources = new EventSources(name.value, _connection, artifacts);
120
131
  const resolveConstraintMessage = this._constraints.resolveMessageFor.bind(this._constraints);
121
- this.eventLog = new EventLog(name.value, namespace.value, _connection, this.unitOfWorkManager, resolveConstraintMessage, _telemetry, this.eventSources);
132
+ this.eventLog = new EventLog(name.value, namespace.value, _connection, this.unitOfWorkManager, resolveConstraintMessage, _telemetry, this.eventSources, _eventEnrichmentProviders);
122
133
  this._sequences.set(EventSequenceId.eventLog.value, this.eventLog);
123
134
 
124
135
  this.eventTypes = new EventTypes(name.value, _connection, artifacts);
125
- this.projections = new Projections(name.value, namespace.value, _connection, artifacts, defaultSinkTypeId, readModelNamingPolicy);
136
+ this._projections = new Projections(name.value, namespace.value, _connection, artifacts, defaultSinkTypeId, readModelNamingPolicy);
137
+ this.projections = this._projections;
126
138
  this.graphs = new Graphs(name.value, _connection, artifacts, defaultGraphSinkTypeId);
127
139
  this.reactors = new Reactors(artifacts, _connection, name.value, namespace.value, lifecycle, this.eventLog, reactorResultHandler, this, artifactActivator, _skipKeepAlive);
128
140
  this.reducers = new Reducers(artifacts, _connection, name.value, namespace.value, lifecycle, defaultSinkTypeId, this, artifactActivator, readModelNamingPolicy, _skipKeepAlive);
@@ -142,9 +154,22 @@ export class EventStore implements IEventStore {
142
154
  /**
143
155
  * Registers all discovered artifacts with the Chronicle Kernel.
144
156
  * Called on initial connect and on reconnect.
157
+ * @param reason - Why this registration attempt started.
145
158
  * @returns A promise that resolves when all registrations are complete.
146
159
  */
147
- async registerArtifacts(): Promise<void> {
160
+ async registerArtifacts(reason = 'explicit'): Promise<void> {
161
+ const attempt = new ArtifactRegistrationAttempt(this._registrationAttempt.attemptId + 1, reason);
162
+ this._registrationAttempt = attempt;
163
+ try {
164
+ await this.performRegistration(attempt);
165
+ attempt.complete();
166
+ } catch (error) {
167
+ attempt.fail(error);
168
+ throw error;
169
+ }
170
+ }
171
+
172
+ private async performRegistration(attempt: ArtifactRegistrationAttempt): Promise<void> {
148
173
  if (this._skipKeepAlive) refuseClientHostedObservers(this._artifacts);
149
174
 
150
175
  this._logger.debug('Discovering artifacts for registration', {
@@ -182,7 +207,7 @@ export class EventStore implements IEventStore {
182
207
  await this.eventSources.register();
183
208
  await Promise.all([
184
209
  this.constraints.register(),
185
- this.projections.register(),
210
+ this._projections.register(outcome => attempt.record(outcome)),
186
211
  this.graphs.register(),
187
212
  this.reactors.register(),
188
213
  this.reducers.register(),
@@ -213,7 +238,7 @@ export class EventStore implements IEventStore {
213
238
 
214
239
  const sequence = new EventSequence(
215
240
  id, this.name.value, this.namespace.value, this._connection, this.unitOfWorkManager,
216
- this._constraints.resolveMessageFor.bind(this._constraints), this._telemetry, this.eventSources
241
+ this._constraints.resolveMessageFor.bind(this._constraints), this._telemetry, this.eventSources, this._eventEnrichmentProviders
217
242
  );
218
243
  this._sequences.set(id.value, sequence);
219
244
  return sequence;
package/IEventStore.ts CHANGED
@@ -5,6 +5,7 @@ import { IEventLog } from './eventSequences/IEventLog.js';
5
5
  import { IEventSequence } from './eventSequences/IEventSequence.js';
6
6
  import { EventSequenceId } from './eventSequences/EventSequenceId.js';
7
7
  import { EventStoreName } from './EventStoreName.js';
8
+ import type { ArtifactRegistrationResult } from './ArtifactRegistrationResult.js';
8
9
  import { EventStoreNamespaceName } from './EventStoreNamespaceName.js';
9
10
  import type { IEventSources } from './eventSources/IEventSources.js';
10
11
  import { IEventTypes } from './events/IEventTypes.js';
@@ -31,6 +32,12 @@ import { IObservers } from './observation/IObservers.js';
31
32
  * An event store is a logical grouping of event sequences within a namespace.
32
33
  */
33
34
  export interface IEventStore {
35
+ /**
36
+ * Snapshot of the most recent artifact registration attempt, not observer readiness.
37
+ * Optional for compatibility with event stores that do not perform kernel registration.
38
+ */
39
+ readonly registrationResult?: ArtifactRegistrationResult;
40
+
34
41
  /** The name of the event store. */
35
42
  readonly name: EventStoreName;
36
43
 
@@ -0,0 +1,50 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import type { ArtifactRegistrationResult, ArtifactRegistrationState, ProjectionRegistrationOutcome } from '../ArtifactRegistrationResult.js';
5
+
6
+ /** Keeps updates isolated to their own registration attempt, including work completing after a rejection. */
7
+ export class ArtifactRegistrationAttempt {
8
+ private readonly _projections = new Map<string, ProjectionRegistrationOutcome>();
9
+ private _state: ArtifactRegistrationState;
10
+ private _error?: unknown;
11
+
12
+ constructor(readonly attemptId: number = 0, readonly reason: string = 'not-run') {
13
+ this._state = attemptId === 0 ? 'not-run' : 'in-progress';
14
+ }
15
+
16
+ /** Gets a snapshot; reading a later attempt never changes a previously retained snapshot. */
17
+ get result(): ArtifactRegistrationResult {
18
+ return Object.freeze({
19
+ attemptId: this.attemptId,
20
+ reason: this.reason,
21
+ state: this._state,
22
+ projections: Object.freeze([...this._projections.values()]),
23
+ failures: Object.freeze([...this._projections.values()].filter(outcome => outcome.state === 'failed')),
24
+ error: this._error,
25
+ observerLiveness: 'unknown'
26
+ });
27
+ }
28
+
29
+ /** Records a projection response or failure without changing the registration control flow. */
30
+ record(outcome: ProjectionRegistrationOutcome): void {
31
+ this._projections.set(outcome.identifier, Object.freeze(outcome));
32
+ if (this._state === 'failed' || this._state === 'partially-failed') this.updateFailureState();
33
+ }
34
+
35
+ /** Marks the orchestration complete. */
36
+ complete(): void {
37
+ this._state = 'successful';
38
+ }
39
+
40
+ /** Retains the same error the caller receives. */
41
+ fail(error: unknown): void {
42
+ this._error = error;
43
+ this.updateFailureState();
44
+ }
45
+
46
+ private updateFailureState(): void {
47
+ this._state = [...this._projections.values()].some(outcome => outcome.state === 'successful')
48
+ ? 'partially-failed' : 'failed';
49
+ }
50
+ }
@@ -27,7 +27,7 @@ async function listen(rejectAnonymous = false): Promise<number> {
27
27
  server.add(ConnectionServiceDefinition, {
28
28
  ...methods, checkCompatibility: async () => {
29
29
  if (rejectAnonymous) throw new ServerError(status.UNAUTHENTICATED, 'Unauthenticated');
30
- return { IsCompatible: true, Incompatibilities: [], ServerVersion: 'test' };
30
+ return { IsCompatible: true, Incompatibilities: [], ServerVersion: '19.37.4' };
31
31
  }
32
32
  } as ServiceImplementation<typeof ConnectionServiceDefinition>);
33
33
  servers.push(server);
@@ -46,7 +46,7 @@ async function listenAuthenticated(onCheck?: () => void): Promise<number> {
46
46
  checkCompatibility: async (request, context) => {
47
47
  onCheck?.();
48
48
  await authenticate(request, context);
49
- return { IsCompatible: true, Incompatibilities: [], ServerVersion: 'test' };
49
+ return { IsCompatible: true, Incompatibilities: [], ServerVersion: '19.37.4' };
50
50
  }
51
51
  } as ServiceImplementation<typeof ConnectionServiceDefinition>);
52
52
  server.add(ServerDefinition, {
@@ -195,7 +195,7 @@ describe('ChronicleConnection authentication', () => {
195
195
  const unsupported = async () => { throw new Error('Unexpected RPC'); };
196
196
  server.add(ConnectionServiceDefinition, {
197
197
  ...Object.fromEntries(Object.keys(ConnectionServiceDefinition.methods).map(name => [name, unsupported])),
198
- checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: 'test' }),
198
+ checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: '19.37.4' }),
199
199
  observeConnectedClients: async function* () {
200
200
  attempts();
201
201
  throw new ServerError(status.UNAUTHENTICATED, 'Token expired');
@@ -268,6 +268,13 @@ export class ChronicleConnection implements ChronicleServices {
268
268
  return this._connections;
269
269
  }
270
270
 
271
+ /** Gets the server version after verifying this channel's contract, or undefined when skipped. */
272
+ async getKernelVersion(): Promise<string | undefined> {
273
+ await (this._clientsReady ??= this.startClientCreation());
274
+ await this._compatibility.verify();
275
+ return this._compatibility.kernelVersion;
276
+ }
277
+
271
278
  private startClientCreation(): Promise<void> {
272
279
  return runInBackgroundContext(() => this.createClients());
273
280
  }
@@ -2,7 +2,7 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
4
  import { createRequire } from 'node:module';
5
- import { chronicleDescriptorSet, type ConnectionServiceClient } from '@cratis/chronicle.contracts';
5
+ import { chronicleDescriptorSet, type CompatibilityResponse, type ConnectionServiceClient } from '@cratis/chronicle.contracts';
6
6
  import { ClientError, Status, type ClientMiddleware } from 'nice-grpc-common';
7
7
  import { IncompatibleChronicleServer } from './IncompatibleChronicleServer.js';
8
8
  import { clientVersion } from './clientVersion.js';
@@ -14,6 +14,12 @@ const protocolVersion = (require('@cratis/chronicle.contracts/package.json') as
14
14
  /** Verifies the installed wire contract before a channel can perform event-sequence operations. */
15
15
  export class CompatibilityPreflight {
16
16
  private _verification?: Promise<void>;
17
+ private _kernelVersion?: string;
18
+
19
+ /** The server version reported by a successful contract check, or undefined when skipped. */
20
+ get kernelVersion(): string | undefined {
21
+ return this._kernelVersion;
22
+ }
17
23
 
18
24
  constructor(
19
25
  private readonly _connections: ConnectionServiceClient,
@@ -63,9 +69,21 @@ export class CompatibilityPreflight {
63
69
  }
64
70
  throw error;
65
71
  });
66
- if (response?.IsCompatible !== true || !Array.isArray(response.Incompatibilities) || response.Incompatibilities.length !== 0) {
67
- const reasons = response?.Incompatibilities?.join('; ') || 'missing, negative, or inconsistent compatibility verdict';
68
- throw new IncompatibleChronicleServer(`Chronicle server ${response?.ServerVersion ?? 'unknown'} is incompatible with contracts ${protocolVersion}: ${reasons}`);
72
+ this.verifyContract(response);
73
+ this._kernelVersion = response.ServerVersion;
74
+ }
75
+
76
+ private verifyContract(response: CompatibilityResponse): void {
77
+ const compatible = response?.IsCompatible === true;
78
+ const noIncompatibilities = Array.isArray(response?.Incompatibilities) && response.Incompatibilities.length === 0;
79
+ if (compatible && noIncompatibilities) {
80
+ return;
69
81
  }
82
+ throw this.incompatibleContract(response);
83
+ }
84
+
85
+ private incompatibleContract(response: CompatibilityResponse): IncompatibleChronicleServer {
86
+ const reasons = response?.Incompatibilities?.join('; ') || 'missing, negative, or inconsistent compatibility verdict';
87
+ return new IncompatibleChronicleServer(`Chronicle server ${response?.ServerVersion ?? 'unknown'} is incompatible with contracts ${protocolVersion}: ${reasons}`);
70
88
  }
71
89
  }
@@ -17,15 +17,17 @@ describe('when checking server compatibility before append', () => {
17
17
  let server: ReturnType<typeof createServer>;
18
18
  let connection: ChronicleConnection;
19
19
  let compatible: boolean;
20
+ let serverVersion: string;
20
21
  let address: string;
21
22
  let check: ReturnType<typeof vi.fn>;
22
23
  let append: ReturnType<typeof vi.fn>;
23
24
  let appendMany: ReturnType<typeof vi.fn>;
24
25
  beforeEach(async () => {
25
26
  compatible = true;
27
+ serverVersion = '19.37.4';
26
28
  server = createServer();
27
29
  check = vi.fn(async (_request: CompatibilityRequest, _context: CallContext) => ({
28
- IsCompatible: compatible, Incompatibilities: compatible ? [] : ['missing field'], ServerVersion: 'server'
30
+ IsCompatible: compatible, Incompatibilities: compatible ? [] : ['missing field'], ServerVersion: serverVersion
29
31
  }));
30
32
  append = vi.fn(async () => ({ Response: { SequenceNumber: 0n } }));
31
33
  appendMany = vi.fn(async () => ({ Response: { SequenceNumbers: [0n] } }));
@@ -61,6 +63,15 @@ describe('when checking server compatibility before append', () => {
61
63
  appendMany.mock.calls.should.have.lengthOf(0);
62
64
  connection.isConnected.should.equal(false);
63
65
  });
66
+ it('should connect to an older compatible kernel and send a plain batch', async () => {
67
+ serverVersion = '19.37.3';
68
+ await connection.resetChannel();
69
+ await connection.connect();
70
+ await connection.eventSequences.appendManyForEventSources({});
71
+ (await connection.getKernelVersion())!.should.equal('19.37.3');
72
+ appendMany.mock.calls.should.have.lengthOf(1);
73
+ connection.isConnected.should.equal(true);
74
+ });
64
75
  it('should reject an unavailable compatibility endpoint without trying the append', async () => {
65
76
  check.mockRejectedValue(new ServerError(Status.UNAVAILABLE, 'compatibility endpoint unavailable'));
66
77
  await connection.resetChannel();
@@ -21,7 +21,7 @@ beforeEach(async () => {
21
21
  const unused = async () => { throw new Error('Unexpected RPC'); };
22
22
  server.add(ConnectionServiceDefinition, {
23
23
  ...Object.fromEntries(Object.keys(ConnectionServiceDefinition.methods).map(name => [name, unused])),
24
- checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: 'test' })
24
+ checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: '19.37.4' })
25
25
  } as ServiceImplementation<typeof ConnectionServiceDefinition>);
26
26
  const port = await server.listen('127.0.0.1:0');
27
27
  vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, options) => {
@@ -27,7 +27,7 @@ beforeEach(async () => {
27
27
  const unused = async () => { throw new Error('Unexpected RPC'); };
28
28
  server.add(ConnectionServiceDefinition, {
29
29
  ...Object.fromEntries(Object.keys(ConnectionServiceDefinition.methods).map(name => [name, unused])),
30
- checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: 'test' })
30
+ checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: '19.37.4' })
31
31
  } as ServiceImplementation<typeof ConnectionServiceDefinition>);
32
32
  const port = await server.listen('127.0.0.1:0');
33
33
  address = `chronicle://127.0.0.1:${port},127.0.0.1:1?disableTls=true`;
@@ -25,12 +25,12 @@ describe('when verifying with concurrent calls', () => {
25
25
  it('should share the same flight and issue exactly one RPC', async () => {
26
26
  first.should.equal(second);
27
27
  check.mock.calls.should.have.lengthOf(1);
28
- complete(CompatibilityResponse.create({ IsCompatible: true }));
28
+ complete(CompatibilityResponse.create({ IsCompatible: true, ServerVersion: '19.37.4' }));
29
29
  await Promise.all([first, second]);
30
30
  });
31
31
 
32
32
  it('should retain the successful verdict for later calls', async () => {
33
- complete(CompatibilityResponse.create({ IsCompatible: true }));
33
+ complete(CompatibilityResponse.create({ IsCompatible: true, ServerVersion: '19.37.4' }));
34
34
  await Promise.all([first, second]);
35
35
  await preflight.verify();
36
36
  check.mock.calls.should.have.lengthOf(1);
@@ -0,0 +1,38 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { describe, it, beforeEach, vi } from 'vitest';
5
+ import { should } from 'chai';
6
+ import { CompatibilityPreflight } from '../../CompatibilityPreflight.js';
7
+
8
+ should();
9
+
10
+ for (const version of ['19.37.4', '19.37.4-development', '19.38.0', '20.0.0', '19.37.3', '19.36.99', '1.0.0', 'unknown', '']) {
11
+ describe(`when verifying a compatible contract on kernel ${version || 'without a version'}`, () => {
12
+ let check: ReturnType<typeof vi.fn>;
13
+ let preflight: CompatibilityPreflight;
14
+
15
+ beforeEach(async () => {
16
+ check = vi.fn().mockResolvedValue({ IsCompatible: true, Incompatibilities: [], ServerVersion: version });
17
+ preflight = new CompatibilityPreflight({ checkCompatibility: check } as never, 1000, false);
18
+ await preflight.verify();
19
+ });
20
+
21
+ it('should check compatibility once', () => check.mock.calls.should.have.lengthOf(1));
22
+ it('should retain the reported version without refusing the connection', () => preflight.kernelVersion!.should.equal(version));
23
+ });
24
+ }
25
+
26
+ describe('when skipping the contract check', () => {
27
+ let check: ReturnType<typeof vi.fn>;
28
+ let preflight: CompatibilityPreflight;
29
+
30
+ beforeEach(async () => {
31
+ check = vi.fn();
32
+ preflight = new CompatibilityPreflight({ checkCompatibility: check } as never, 1000, true);
33
+ await preflight.verify();
34
+ });
35
+
36
+ it('should not request a server version', () => check.mock.calls.should.have.lengthOf(0));
37
+ it('should leave the kernel version unknown', () => (preflight.kernelVersion === undefined).should.equal(true));
38
+ });
@@ -32,7 +32,7 @@ beforeEach(async () => {
32
32
  const unused = async () => { throw new Error('Unexpected RPC'); };
33
33
  server.add(ConnectionServiceDefinition, {
34
34
  ...Object.fromEntries(Object.keys(ConnectionServiceDefinition.methods).map(name => [name, unused])),
35
- checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: 'test' }),
35
+ checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: '19.37.4' }),
36
36
  connectionKeepAlive: async () => ({})
37
37
  } as ServiceImplementation<typeof ConnectionServiceDefinition>);
38
38
  server.add(EventStoresDefinition, {
@@ -32,7 +32,7 @@ beforeAll(async () => {
32
32
  const unused = async () => { throw new Error('Unexpected RPC'); };
33
33
  server.add(ConnectionServiceDefinition, {
34
34
  ...Object.fromEntries(Object.keys(ConnectionServiceDefinition.methods).map(name => [name, unused])),
35
- checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: 'test' })
35
+ checkCompatibility: async () => ({ IsCompatible: true, Incompatibilities: [], ServerVersion: '19.37.4' })
36
36
  } as ServiceImplementation<typeof ConnectionServiceDefinition>);
37
37
  server.add(EventStoresDefinition, {
38
38
  ...Object.fromEntries(Object.keys(EventStoresDefinition.methods).map(name => [name, unused])),