@event-driven-io/emmett 0.43.0-beta.2 → 0.43.0-beta.20

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/dist/index.d.ts CHANGED
@@ -1,67 +1,100 @@
1
- import { a as EmmettError, C as ConcurrencyError, e as ErrorConstructor } from './index-Amos00J7.js';
2
- export { l as ConcurrencyInMemoryDatabaseError, i as EmmettCliCommand, d as EmmettCliPlugin, g as EmmettCliPluginRegistration, c as EmmettPlugin, f as EmmettPluginConfig, h as EmmettPluginRegistration, b as EmmettPluginType, E as EmmettPluginsConfig, I as IllegalStateError, N as NotFoundError, V as ValidationError, k as isErrorConstructor, j as isPluginConfig } from './index-Amos00J7.js';
3
- import retry from 'async-retry';
1
+ import { _ as isPluginConfig, a as IllegalStateError, c as isErrorConstructor, d as EmmettCliPlugin, f as EmmettCliPluginRegistration, g as EmmettPluginType, h as EmmettPluginRegistration, i as ErrorConstructor, l as EmmettPluginsConfig, m as EmmettPluginConfig, n as ConcurrencyInMemoryDatabaseError, o as NotFoundError, p as EmmettPlugin, r as EmmettError, s as ValidationError, t as ConcurrencyError, u as EmmettCliCommand } from "./index-B6YAVHH1.js";
2
+ import retry from "async-retry";
3
+ import { AttributeTarget, Meter, ObservabilityConfig, ObservabilityScope, SpanContext, TracePropagation, Tracer } from "@event-driven-io/almanac";
4
+ export * from "@event-driven-io/almanac";
4
5
 
6
+ //#region src/typing/deepReadonly.d.ts
5
7
  type Primitive = undefined | null | boolean | string | number | bigint | symbol | Function;
6
8
  type ImmutableTypes = Date | RegExp;
7
9
  type DeepReadonly<T> = T extends Primitive | ImmutableTypes ? T : T extends Array<infer U> ? ReadonlyArray<DeepReadonly<U>> : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer M> ? ReadonlySet<DeepReadonly<M>> : T extends Promise<infer U> ? Promise<DeepReadonly<U>> : T extends object ? DeepReadonlyObject<T> : Readonly<T>;
8
- type DeepReadonlyObject<T> = {
9
- readonly [P in keyof T]: DeepReadonly<T[P]>;
10
- };
10
+ type DeepReadonlyObject<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> };
11
11
  type Mutable<T> = T extends Primitive ? T : T extends ReadonlyArray<infer U> ? MutableArray<U> : T extends ReadonlyMap<infer K, infer V> ? MutableMap<K, V> : T extends ReadonlySet<infer M> ? MutableSet<M> : T extends Function ? T : T extends object ? MutableObject<T> : unknown;
12
12
  type MutableArray<T> = Array<Mutable<T>>;
13
13
  type MutableMap<K, V> = Map<Mutable<K>, Mutable<V>>;
14
14
  type MutableSet<T> = Set<Mutable<T>>;
15
- type MutableObject<T> = {
16
- -readonly [P in keyof T]: Mutable<T[P]>;
17
- };
18
-
15
+ type MutableObject<T> = { -readonly [P in keyof T]: Mutable<T[P]> };
16
+ //#endregion
17
+ //#region src/typing/command.d.ts
19
18
  type Command<CommandType extends string = string, CommandData extends DefaultRecord = DefaultRecord, CommandMetaData extends DefaultRecord | undefined = undefined> = Readonly<CommandMetaData extends undefined ? {
20
- type: CommandType;
21
- data: Readonly<CommandData>;
22
- metadata?: DefaultCommandMetadata | undefined;
19
+ type: CommandType;
20
+ data: Readonly<CommandData>;
21
+ metadata?: DefaultCommandMetadata | undefined;
23
22
  } : {
24
- type: CommandType;
25
- data: CommandData;
26
- metadata: CommandMetaData;
23
+ type: CommandType;
24
+ data: CommandData;
25
+ metadata: CommandMetaData;
27
26
  }> & {
28
- readonly kind?: 'Command';
27
+ readonly kind?: 'Command';
29
28
  };
30
29
  type AnyCommand = Command<any, any, any>;
31
30
  type CommandTypeOf<T extends Command> = T['type'];
32
31
  type CommandDataOf<T extends Command> = T['data'];
33
32
  type CommandMetaDataOf<T extends Command> = T extends {
34
- metadata: infer M;
33
+ metadata: infer M;
35
34
  } ? M : undefined;
36
35
  type CreateCommandType<CommandType extends string, CommandData extends DefaultRecord, CommandMetaData extends DefaultRecord | undefined = undefined> = Readonly<CommandMetaData extends undefined ? {
37
- type: CommandType;
38
- data: CommandData;
39
- metadata?: DefaultCommandMetadata | undefined;
36
+ type: CommandType;
37
+ data: CommandData;
38
+ metadata?: DefaultCommandMetadata | undefined;
40
39
  } : {
41
- type: CommandType;
42
- data: CommandData;
43
- metadata: CommandMetaData;
40
+ type: CommandType;
41
+ data: CommandData;
42
+ metadata: CommandMetaData;
44
43
  }> & {
45
- readonly kind?: 'Command';
44
+ readonly kind?: 'Command';
46
45
  };
47
46
  declare const command: <CommandType extends Command<string, any, any>>(...args: CommandMetaDataOf<CommandType> extends undefined ? [type: CommandTypeOf<CommandType>, data: CommandDataOf<CommandType>, metadata?: DefaultCommandMetadata | undefined] : [type: CommandTypeOf<CommandType>, data: CommandDataOf<CommandType>, metadata: CommandMetaDataOf<CommandType>]) => CommandType;
48
47
  type DefaultCommandMetadata = {
49
- now: Date;
48
+ now: Date;
50
49
  };
51
-
50
+ //#endregion
51
+ //#region src/processors/checkpoints.d.ts
52
+ type ProcessorCheckpoint = Brand<string, 'ProcessorCheckpoint'>;
53
+ declare const ProcessorCheckpoint: (checkpoint: string) => ProcessorCheckpoint;
54
+ declare const bigIntProcessorCheckpoint: (value: bigint) => ProcessorCheckpoint;
55
+ declare const parseBigIntProcessorCheckpoint: (value: ProcessorCheckpoint) => bigint;
56
+ type GetCheckpoint<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata> = (message: RecordedMessage<MessageType, MessageMetadataType>) => ProcessorCheckpoint | null;
57
+ declare const getCheckpoint: <MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata>(message: RecordedMessage<MessageType, MessageMetadataType>) => ProcessorCheckpoint | null;
58
+ type Checkpointer<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord = DefaultRecord> = {
59
+ read: ReadProcessorCheckpoint<HandlerContext>;
60
+ store: StoreProcessorCheckpoint<MessageType, MessageMetadataType, HandlerContext>;
61
+ };
62
+ type ReadProcessorCheckpoint<HandlerContext extends DefaultRecord = DefaultRecord> = (options: {
63
+ processorId: string;
64
+ partition?: string;
65
+ }, context: HandlerContext) => Promise<ReadProcessorCheckpointResult>;
66
+ type StoreProcessorCheckpoint<MessageType extends Message = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord | undefined = undefined> = (options: {
67
+ message: RecordedMessage<MessageType, MessageMetadataType>;
68
+ processorId: string;
69
+ version: number | undefined;
70
+ lastCheckpoint: ProcessorCheckpoint | null;
71
+ partition?: string;
72
+ }, context: HandlerContext) => Promise<StoreProcessorCheckpointResult>;
73
+ type StoreProcessorCheckpointResult = {
74
+ success: true;
75
+ newCheckpoint: ProcessorCheckpoint | null;
76
+ } | {
77
+ success: false;
78
+ reason: 'IGNORED' | 'MISMATCH' | 'CURRENT_AHEAD';
79
+ };
80
+ type ReadProcessorCheckpointResult = {
81
+ lastCheckpoint: ProcessorCheckpoint | null;
82
+ };
83
+ //#endregion
84
+ //#region src/database/types.d.ts
52
85
  /** TypeScript Omit (Exclude to be specific) does not work for objects with an "any" indexed type, and breaks discriminated unions @public */
53
86
  declare type EnhancedOmit<TRecordOrUnion, KeyUnion> = string extends keyof TRecordOrUnion ? TRecordOrUnion : TRecordOrUnion extends any ? Pick<TRecordOrUnion, Exclude<keyof TRecordOrUnion, KeyUnion>> : never;
54
87
  declare type WithId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
55
- _id: string;
88
+ _id: string;
56
89
  };
57
90
  type WithoutId<T> = Omit<T, '_id'>;
58
91
  declare type WithVersion<TSchema> = EnhancedOmit<TSchema, '_version'> & {
59
- _version: bigint;
92
+ _version: bigint;
60
93
  };
61
94
  type WithoutVersion<T> = Omit<T, '_version'>;
62
95
  type WithIdAndVersion<TSchema> = EnhancedOmit<TSchema, '_version' | '_id'> & {
63
- _id: string;
64
- _version: bigint;
96
+ _id: string;
97
+ _version: bigint;
65
98
  };
66
99
  type Document = Record<string, unknown>;
67
100
  type DocumentHandler<T extends Document> = (document: T | null) => T | null;
@@ -69,330 +102,601 @@ type ExpectedDocumentVersionGeneral = 'DOCUMENT_EXISTS' | 'DOCUMENT_DOES_NOT_EXI
69
102
  type ExpectedDocumentVersion = bigint | ExpectedDocumentVersionGeneral;
70
103
  type ExpectedDocumentVersionValue = bigint;
71
104
  type DatabaseHandleOptions = {
72
- expectedVersion?: ExpectedDocumentVersion;
105
+ expectedVersion?: ExpectedDocumentVersion;
73
106
  };
74
107
  type OperationResult = {
75
- acknowledged: boolean;
76
- successful: boolean;
77
- assertSuccessful: (errorMessage?: string) => void;
108
+ acknowledged: boolean;
109
+ successful: boolean;
110
+ assertSuccessful: (errorMessage?: string) => void;
78
111
  };
79
112
  interface InsertOneResult extends OperationResult {
80
- insertedId: string | null;
81
- nextExpectedVersion: bigint;
113
+ insertedId: string | null;
114
+ nextExpectedVersion: bigint;
82
115
  }
83
116
  interface InsertManyResult extends OperationResult {
84
- insertedIds: string[];
85
- insertedCount: number;
117
+ insertedIds: string[];
118
+ insertedCount: number;
86
119
  }
87
120
  interface UpdateResult extends OperationResult {
88
- matchedCount: number;
89
- modifiedCount: number;
90
- nextExpectedVersion: bigint;
121
+ matchedCount: number;
122
+ modifiedCount: number;
123
+ nextExpectedVersion: bigint;
91
124
  }
92
125
  interface UpdateManyResult extends OperationResult {
93
- matchedCount: number;
94
- modifiedCount: number;
126
+ matchedCount: number;
127
+ modifiedCount: number;
95
128
  }
96
129
  interface DeleteResult extends OperationResult {
97
- matchedCount: number;
98
- deletedCount: number;
130
+ matchedCount: number;
131
+ deletedCount: number;
99
132
  }
100
133
  interface DeleteManyResult extends OperationResult {
101
- deletedCount: number;
134
+ deletedCount: number;
102
135
  }
103
136
  type DatabaseHandleResult<T> = (InsertOneResult & {
104
- document: WithIdAndVersion<T>;
137
+ document: WithIdAndVersion<T>;
105
138
  }) | (UpdateResult & {
106
- document: WithIdAndVersion<T>;
139
+ document: WithIdAndVersion<T>;
107
140
  }) | (DeleteResult & {
108
- document: null;
141
+ document: null;
109
142
  }) | (OperationResult & {
110
- document: null;
143
+ document: null;
111
144
  });
112
145
  type DatabaseHandleOptionErrors = {
113
- throwOnOperationFailures?: boolean;
146
+ throwOnOperationFailures?: boolean;
114
147
  } | undefined;
115
148
  declare type OptionalId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
116
- _id?: string;
149
+ _id?: string;
117
150
  };
118
151
  declare type OptionalVersion<TSchema> = EnhancedOmit<TSchema, '_version'> & {
119
- _version?: bigint;
152
+ _version?: bigint;
120
153
  };
121
154
  declare type OptionalUnlessRequiredId<TSchema> = TSchema extends {
122
- _id: string;
155
+ _id: string;
123
156
  } ? TSchema : OptionalId<TSchema>;
124
157
  declare type OptionalUnlessRequiredVersion<TSchema> = TSchema extends {
125
- _version: bigint;
158
+ _version: bigint;
126
159
  } ? TSchema : OptionalVersion<TSchema>;
127
160
  declare type OptionalUnlessRequiredIdAndVersion<TSchema> = OptionalUnlessRequiredId<TSchema> & OptionalUnlessRequiredVersion<TSchema>;
128
161
  type InsertOneOptions = {
129
- expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK'>;
162
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK'>;
130
163
  };
131
164
  type InsertManyOptions = {
132
- expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK'>;
165
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK'>;
133
166
  };
134
167
  type UpdateOneOptions = {
135
- expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
168
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
136
169
  };
137
170
  type UpdateManyOptions = {
138
- expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_EXISTS' | 'NO_CONCURRENCY_CHECK'>;
171
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_EXISTS' | 'NO_CONCURRENCY_CHECK'>;
139
172
  };
140
173
  type ReplaceOneOptions = {
141
- expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
174
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
142
175
  };
143
176
  type DeleteOneOptions = {
144
- expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
177
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
145
178
  };
146
179
  type DeleteManyOptions = {
147
- expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_EXISTS' | 'NO_CONCURRENCY_CHECK'>;
180
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_EXISTS' | 'NO_CONCURRENCY_CHECK'>;
148
181
  };
149
182
  type FullId<Collection extends string, Id extends string> = `${Collection}-${Id}`;
150
-
183
+ //#endregion
184
+ //#region src/database/inMemoryDatabase.d.ts
151
185
  interface InMemoryDocumentsCollection<T extends Document> {
152
- handle: (id: string, handle: DocumentHandler<T>, options?: DatabaseHandleOptions) => Promise<DatabaseHandleResult<T>>;
153
- findOne: (predicate?: Predicate<T>) => Promise<T | null>;
154
- find: (predicate?: Predicate<T>) => Promise<T[]>;
155
- insertOne: (document: OptionalUnlessRequiredIdAndVersion<T>) => Promise<InsertOneResult>;
156
- deleteOne: (predicate?: Predicate<T>) => Promise<DeleteResult>;
157
- replaceOne: (predicate: Predicate<T>, document: WithoutId<T>, options?: ReplaceOneOptions) => Promise<UpdateResult>;
186
+ handle: (id: string, handle: DocumentHandler<T>, options?: DatabaseHandleOptions) => Promise<DatabaseHandleResult<T>>;
187
+ findOne: (predicate?: Predicate<T>) => Promise<T | null>;
188
+ find: (predicate?: Predicate<T>) => Promise<T[]>;
189
+ insertOne: (document: OptionalUnlessRequiredIdAndVersion<T>) => Promise<InsertOneResult>;
190
+ deleteOne: (predicate?: Predicate<T>) => Promise<DeleteResult>;
191
+ replaceOne: (predicate: Predicate<T>, document: WithoutId<T>, options?: ReplaceOneOptions) => Promise<UpdateResult>;
158
192
  }
159
193
  interface InMemoryDatabase {
160
- collection: <T extends Document>(name: string) => InMemoryDocumentsCollection<T>;
194
+ collection: <T extends Document>(name: string) => InMemoryDocumentsCollection<T>;
161
195
  }
162
196
  type Predicate<T> = (item: T) => boolean;
163
197
  declare const getInMemoryDatabase: () => InMemoryDatabase;
164
-
165
- type ProjectionHandlingType = 'inline' | 'async';
166
- type ProjectionHandler<EventType extends Event = AnyEvent, EventMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = BatchRecordedMessageHandlerWithContext<EventType, EventMetaDataType, ProjectionHandlerContext>;
167
- type TruncateProjection<ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = (context: ProjectionHandlerContext) => Promise<void>;
168
- type ProjectionInitOptions<ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = {
169
- version: number;
170
- status?: 'active' | 'inactive';
171
- registrationType: ProjectionHandlingType;
172
- context: ProjectionHandlerContext;
173
- };
174
- interface ProjectionDefinition<EventType extends Event = AnyEvent, EventMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, EventPayloadType extends Event = EventType> {
175
- name?: string;
176
- version?: number;
177
- kind?: string;
178
- canHandle: CanHandle<EventType>;
179
- handle: ProjectionHandler<EventType, EventMetaDataType, ProjectionHandlerContext>;
180
- truncate?: TruncateProjection<ProjectionHandlerContext>;
181
- init?: (options: ProjectionInitOptions<ProjectionHandlerContext>) => void | Promise<void>;
182
- eventsOptions?: {
183
- schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
198
+ //#endregion
199
+ //#region src/observability/attributes.d.ts
200
+ declare const EmmettAttributes: {
201
+ readonly scope: {
202
+ readonly type: "emmett.scope.type";
203
+ };
204
+ readonly command: {
205
+ readonly type: "emmett.command.type";
206
+ readonly status: "emmett.command.status";
207
+ readonly eventCount: "emmett.command.event_count";
208
+ readonly eventTypes: "emmett.command.event_types";
209
+ };
210
+ readonly stream: {
211
+ readonly name: "emmett.stream.name";
212
+ readonly versionBefore: "emmett.stream.version.before";
213
+ readonly versionAfter: "emmett.stream.version.after";
214
+ };
215
+ readonly eventStore: {
216
+ readonly operation: "emmett.eventstore.operation";
217
+ readonly read: {
218
+ readonly eventCount: "emmett.eventstore.read.event_count";
219
+ readonly eventTypes: "emmett.eventstore.read.event_types";
220
+ readonly status: "emmett.eventstore.read.status";
221
+ };
222
+ readonly append: {
223
+ readonly batchSize: "emmett.eventstore.append.batch_size";
224
+ readonly status: "emmett.eventstore.append.status";
184
225
  };
226
+ };
227
+ readonly event: {
228
+ readonly type: "emmett.event.type";
229
+ };
230
+ readonly processor: {
231
+ readonly id: "emmett.processor.id";
232
+ readonly type: "emmett.processor.type";
233
+ readonly status: "emmett.processor.status";
234
+ readonly batchSize: "emmett.processor.batch_size";
235
+ readonly eventTypes: "emmett.processor.event_types";
236
+ readonly checkpointBefore: "emmett.processor.checkpoint.before";
237
+ readonly checkpointAfter: "emmett.processor.checkpoint.after";
238
+ readonly lagEvents: "emmett.processor.lag_events";
239
+ };
240
+ readonly workflow: {
241
+ readonly id: "emmett.workflow.id";
242
+ readonly type: "emmett.workflow.type";
243
+ readonly inputType: "emmett.workflow.input.type";
244
+ readonly outputs: "emmett.workflow.outputs";
245
+ readonly outputsCount: "emmett.workflow.outputs.count";
246
+ readonly streamPosition: "emmett.workflow.stream_position";
247
+ readonly stateRebuildEventCount: "emmett.workflow.state_rebuild.event_count";
248
+ };
249
+ readonly consumer: {
250
+ readonly batchSize: "emmett.consumer.batch_size";
251
+ readonly processorCount: "emmett.consumer.processor_count";
252
+ readonly delivery: {
253
+ readonly processorId: "emmett.consumer.delivery.processor_id";
254
+ };
255
+ };
256
+ };
257
+ declare const EmmettMetrics: {
258
+ readonly command: {
259
+ readonly handlingDuration: "emmett.command.handling.duration";
260
+ };
261
+ readonly event: {
262
+ readonly appendingCount: "emmett.event.appending.count";
263
+ readonly readingCount: "emmett.event.reading.count";
264
+ };
265
+ readonly stream: {
266
+ readonly readingDuration: "emmett.stream.reading.duration";
267
+ readonly readingSize: "emmett.stream.reading.size";
268
+ readonly appendingDuration: "emmett.stream.appending.duration";
269
+ readonly appendingSize: "emmett.stream.appending.size";
270
+ };
271
+ readonly processor: {
272
+ readonly processingDuration: "emmett.processor.processing.duration";
273
+ readonly lagEvents: "emmett.processor.lag_events";
274
+ };
275
+ readonly workflow: {
276
+ readonly processingDuration: "emmett.workflow.processing.duration";
277
+ };
278
+ readonly consumer: {
279
+ readonly pollDuration: "emmett.consumer.poll.duration";
280
+ readonly deliveryDuration: "emmett.consumer.delivery.duration";
281
+ };
282
+ };
283
+ declare const ScopeTypes: {
284
+ readonly command: "command";
285
+ readonly processor: "processor";
286
+ readonly reactor: "reactor";
287
+ readonly projector: "projector";
288
+ readonly workflow: "workflow";
289
+ readonly consumer: "consumer";
290
+ };
291
+ declare const MessagingSystemName: "emmett";
292
+ //#endregion
293
+ //#region src/observability/options.d.ts
294
+ type WithObservabilityScope<Context> = Context & {
295
+ observabilityScope: ObservabilityScope;
296
+ };
297
+ type PollTracing = 'off' | 'active' | 'verbose';
298
+ type EmmettObservabilityConfig = ObservabilityConfig<'emmett'> & {
299
+ pollTracing?: PollTracing;
300
+ includeMessagePayloads?: boolean;
301
+ };
302
+ type EmmettObservabilityOptions = {
303
+ observability?: EmmettObservabilityConfig;
304
+ };
305
+ type ConsumerObservabilityConfig = Pick<EmmettObservabilityConfig, 'tracer' | 'meter' | 'pollTracing' | 'attributeTarget'>;
306
+ type WorkflowObservabilityConfig = Pick<EmmettObservabilityConfig, 'tracer' | 'meter' | 'propagation' | 'attributeTarget' | 'includeMessagePayloads'>;
307
+ type ResolvedConsumerObservability = {
308
+ tracer: Tracer;
309
+ meter: Meter;
310
+ pollTracing: PollTracing;
311
+ attributeTarget: AttributeTarget;
312
+ };
313
+ type ResolvedWorkflowObservability = {
314
+ tracer: Tracer;
315
+ meter: Meter;
316
+ propagation: TracePropagation;
317
+ attributeTarget: AttributeTarget;
318
+ includeMessagePayloads: boolean;
319
+ };
320
+ declare const resolveConsumerObservability: (options: {
321
+ observability?: ConsumerObservabilityConfig;
322
+ } | undefined, parent?: EmmettObservabilityOptions) => ResolvedConsumerObservability;
323
+ declare const resolveWorkflowObservability: (options: {
324
+ observability?: WorkflowObservabilityConfig;
325
+ } | undefined, parent?: EmmettObservabilityOptions) => ResolvedWorkflowObservability;
326
+ //#endregion
327
+ //#region src/observability/tracer.d.ts
328
+ declare const tracer: {
329
+ (): void;
330
+ info(eventName: string, attributes?: Record<string, any>): void;
331
+ warn(eventName: string, attributes?: Record<string, any>): void;
332
+ log(eventName: string, attributes?: Record<string, any>): void;
333
+ error(eventName: string, attributes?: Record<string, any>): void;
334
+ };
335
+ type LogLevel = 'DISABLED' | 'INFO' | 'LOG' | 'WARN' | 'ERROR';
336
+ declare const LogLevel: {
337
+ DISABLED: LogLevel;
338
+ INFO: LogLevel;
339
+ LOG: LogLevel;
340
+ WARN: LogLevel;
341
+ ERROR: LogLevel;
342
+ };
343
+ type LogType = 'CONSOLE';
344
+ type LogStyle = 'RAW' | 'PRETTY';
345
+ declare const LogStyle: {
346
+ RAW: LogStyle;
347
+ PRETTY: LogStyle;
348
+ };
349
+ //#endregion
350
+ //#region src/eventStore/observability/eventStoreCollector.d.ts
351
+ type EventStoreObservabilityConfig = Pick<EmmettObservabilityConfig, 'tracer' | 'meter' | 'attributeTarget'>;
352
+ type ResolvedEventStoreObservability = {
353
+ tracer: Tracer;
354
+ meter: Meter;
355
+ attributeTarget: AttributeTarget;
356
+ };
357
+ declare const resolveEventStoreObservability: (options: {
358
+ observability?: EventStoreObservabilityConfig;
359
+ } | undefined, parent?: EmmettObservabilityOptions) => ResolvedEventStoreObservability;
360
+ declare const eventStoreCollector: (observability: ResolvedEventStoreObservability) => {
361
+ instrumentRead: <EventType extends Event, ReadEventMetadataType extends AnyReadEventMetadata = AnyRecordedMessageMetadata>(streamName: string, fn: () => Promise<ReadStreamResult<EventType, ReadEventMetadataType>>) => Promise<ReadStreamResult<EventType, ReadEventMetadataType>>;
362
+ instrumentAppend: <Result extends AppendToStreamResult, EventType extends Event = Event>(streamName: string, events: EventType[], fn: () => Promise<Result>) => Promise<Result>;
363
+ };
364
+ //#endregion
365
+ //#region src/observability/collectors/consumerCollector.d.ts
366
+ declare const consumerCollector: (observability: ResolvedConsumerObservability) => {
367
+ tracePoll: <T>(context: {
368
+ processorCount: number;
369
+ batchSize: number;
370
+ empty: boolean;
371
+ waitMs?: number;
372
+ }, fn: (scope: ObservabilityScope) => Promise<T>) => Promise<T>;
373
+ recordPollMetrics: (durationMs: number, attrs?: Record<string, unknown>) => void;
374
+ traceDelivery: <T>(scope: ObservabilityScope, processorId: string, fn: () => Promise<T>) => Promise<T>;
375
+ };
376
+ //#endregion
377
+ //#region src/observability/collectors/workflowCollector.d.ts
378
+ type WorkflowCollectorContext = {
379
+ workflowId: string;
380
+ workflowType: string;
381
+ inputType: string;
382
+ };
383
+ declare const workflowCollector: (observability: ResolvedWorkflowObservability) => {
384
+ startScope: <T>(context: WorkflowCollectorContext, fn: (scope: ObservabilityScope) => Promise<T>) => Promise<T>;
385
+ recordOutputs: (scope: ObservabilityScope, outputs: {
386
+ type: string;
387
+ }[]) => void;
388
+ recordStateRebuild: (scope: ObservabilityScope, eventCount: number) => void;
389
+ };
390
+ //#endregion
391
+ //#region src/serialization/json/serializer.d.ts
392
+ interface Serializer<Payload, SerializeOptions extends Record<string, unknown> = Record<string, unknown>, DeserializeOptions extends Record<string, unknown> = SerializeOptions> {
393
+ serialize<T>(object: T, options?: SerializeOptions): Payload;
394
+ deserialize<T>(payload: Payload, options?: DeserializeOptions): T;
395
+ }
396
+ interface SerializationCodec<T, Payload, SerializeOptions extends Record<string, unknown> = Record<string, unknown>, DeserializeOptions extends Record<string, unknown> = SerializeOptions> {
397
+ encode(object: T, options?: SerializeOptions): Payload;
398
+ decode(payload: Payload, options?: DeserializeOptions): T;
185
399
  }
186
- type ProjectionRegistration<HandlingType extends ProjectionHandlingType, ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = {
187
- type: HandlingType;
188
- projection: ProjectionDefinition<AnyEvent, ReadEventMetadataType, ProjectionHandlerContext, AnyEvent>;
189
- };
190
- declare const filterProjections: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord>(type: ProjectionHandlingType, projections: ProjectionRegistration<ProjectionHandlingType, ReadEventMetadataType, ProjectionHandlerContext>[]) => ProjectionDefinition<AnyEvent, ReadEventMetadataType, ProjectionHandlerContext, AnyEvent>[];
191
- declare const projection: <EventType extends Event = Event, EventMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, EventPayloadType extends Event = EventType>(definition: ProjectionDefinition<EventType, EventMetaDataType, ProjectionHandlerContext, EventPayloadType>) => ProjectionDefinition<EventType, EventMetaDataType, ProjectionHandlerContext, EventPayloadType>;
192
- declare const inlineProjections: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord>(definitions: ProjectionDefinition<any, ReadEventMetadataType, ProjectionHandlerContext>[]) => ProjectionRegistration<"inline", ReadEventMetadataType, ProjectionHandlerContext>[];
193
- declare const asyncProjections: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord>(definitions: ProjectionDefinition<AnyEvent, ReadEventMetadataType, ProjectionHandlerContext>[]) => ProjectionRegistration<"inline", ReadEventMetadataType, ProjectionHandlerContext>[];
400
+ //#endregion
401
+ //#region src/serialization/json/jsonSerializer.d.ts
402
+ interface JSONSerializer<SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> extends Serializer<string, SerializeOptions, DeserializeOptions> {
403
+ serialize<T>(object: T, options?: SerializeOptions): string;
404
+ deserialize<T>(payload: string, options?: DeserializeOptions): T;
405
+ }
406
+ type JSONSerializerOptions = {
407
+ parseDates?: boolean;
408
+ parseBigInts?: boolean;
409
+ failOnBigIntSerialization?: boolean;
410
+ useDefaultDateSerialization?: boolean;
411
+ };
412
+ type JSONSerializeOptions = {
413
+ replacer?: JSONReplacer;
414
+ } & JSONSerializerOptions;
415
+ type JSONDeserializeOptions = {
416
+ reviver?: JSONReviver;
417
+ } & JSONSerializerOptions;
418
+ interface JSONCodec<T, SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> extends SerializationCodec<T, string, SerializeOptions, DeserializeOptions> {
419
+ encode(object: T, options?: SerializeOptions): string;
420
+ decode(payload: string, options?: DeserializeOptions): T;
421
+ }
422
+ type JSONCodecSerializationOptions<SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> = {
423
+ serializer?: JSONSerializer<SerializeOptions, DeserializeOptions>;
424
+ serializerOptions?: never;
425
+ } | {
426
+ serializer?: never;
427
+ serializerOptions?: JSONSerializerOptions;
428
+ };
429
+ type JSONSerializationOptions<SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> = {
430
+ serialization?: {
431
+ serializer?: JSONSerializer<SerializeOptions, DeserializeOptions>;
432
+ options?: JSONSerializeOptions | JSONDeserializeOptions;
433
+ } | undefined;
434
+ };
435
+ type JSONCodecOptions<T, Payload = T, SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> = JSONCodecSerializationOptions<SerializeOptions, DeserializeOptions> & {
436
+ upcast?: (document: Payload) => T;
437
+ downcast?: (document: T) => Payload;
438
+ };
439
+ type JSONReplacer = (this: any, key: string, value: any) => any;
440
+ type JSONReviver = (this: any, key: string, value: any, context: JSONReviverContext) => any;
441
+ type JSONReviverContext = {
442
+ source: string;
443
+ };
444
+ declare const composeJSONReplacers: (...replacers: (JSONReplacer | undefined)[]) => JSONReplacer | undefined;
445
+ declare const composeJSONRevivers: (...revivers: (JSONReviver | undefined)[]) => JSONReviver | undefined;
446
+ declare const JSONReplacer: (opts?: JSONSerializeOptions) => JSONReplacer | undefined;
447
+ declare const JSONReviver: (opts?: JSONDeserializeOptions) => JSONReviver | undefined;
448
+ declare const JSONReplacers: {
449
+ bigInt: JSONReplacer;
450
+ date: JSONReplacer;
451
+ };
452
+ declare const JSONRevivers: {
453
+ bigInt: JSONReviver;
454
+ date: JSONReviver;
455
+ };
456
+ declare const jsonSerializer: (options?: JSONSerializerOptions & JSONDeserializeOptions & JSONSerializeOptions) => JSONSerializer;
457
+ declare const JSONSerializer: JSONSerializer & {
458
+ from: <SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions>(options?: JSONSerializationOptions<SerializeOptions, DeserializeOptions>) => JSONSerializer<SerializeOptions, DeserializeOptions>;
459
+ };
460
+ declare const JSONCodec: <T, Payload = T, SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions>(options: JSONCodecOptions<T, Payload, SerializeOptions, DeserializeOptions>) => JSONCodec<T, SerializeOptions, DeserializeOptions>;
461
+ //#endregion
462
+ //#region src/projections/index.d.ts
463
+ type ProjectionHandlingType = 'inline' | 'async';
464
+ type ProjectionHandlerContext<HandlerContext extends DefaultRecord = DefaultRecord> = MessageHandlerContext<HandlerContext>;
465
+ type ProjectionHandler<EventType extends Event = AnyEvent, EventMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext> = BatchRecordedMessageHandlerWithContext<EventType, EventMetaDataType, HandlerContext>;
466
+ type TruncateProjection<HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext> = (context: HandlerContext) => Promise<void>;
467
+ type ProjectionInitOptions<HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext> = {
468
+ version: number;
469
+ status?: 'active' | 'inactive';
470
+ registrationType: ProjectionHandlingType;
471
+ context: HandlerContext;
472
+ };
473
+ type ProjectionDefinition<EventType extends Event = AnyEvent, EventMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext, EventPayloadType extends Event = EventType> = {
474
+ name?: string;
475
+ version?: number;
476
+ kind?: string;
477
+ canHandle: CanHandle<EventType>;
478
+ handle: ProjectionHandler<EventType, EventMetaDataType, HandlerContext>;
479
+ truncate?: TruncateProjection<HandlerContext>;
480
+ init?: (options: ProjectionInitOptions<HandlerContext>) => void | Promise<void>;
481
+ eventsOptions?: {
482
+ schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
483
+ };
484
+ } & JSONSerializationOptions;
485
+ type ProjectionRegistration<HandlingType extends ProjectionHandlingType, ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext> = {
486
+ type: HandlingType;
487
+ projection: ProjectionDefinition<AnyEvent, ReadEventMetadataType, HandlerContext, AnyEvent>;
488
+ };
489
+ declare const filterProjections: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext>(type: ProjectionHandlingType, projections: ProjectionRegistration<ProjectionHandlingType, ReadEventMetadataType, HandlerContext>[]) => ProjectionDefinition<AnyEvent, ReadEventMetadataType, HandlerContext, AnyEvent>[];
490
+ declare const projection: <EventType extends Event = Event, EventMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext, EventPayloadType extends Event = EventType>(definition: ProjectionDefinition<EventType, EventMetaDataType, HandlerContext, EventPayloadType>) => ProjectionDefinition<EventType, EventMetaDataType, HandlerContext, EventPayloadType>;
491
+ declare const inlineProjections: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext>(definitions: ProjectionDefinition<any, ReadEventMetadataType, HandlerContext>[]) => ProjectionRegistration<"inline", ReadEventMetadataType, HandlerContext>[];
492
+ declare const asyncProjections: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext>(definitions: ProjectionDefinition<AnyEvent, ReadEventMetadataType, HandlerContext>[]) => ProjectionRegistration<"inline", ReadEventMetadataType, HandlerContext>[];
194
493
  declare const projections: {
195
- inline: <ReadEventMetadataType extends AnyReadEventMetadata = AnyRecordedMessageMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord>(definitions: ProjectionDefinition<any, ReadEventMetadataType, ProjectionHandlerContext>[]) => ProjectionRegistration<"inline", ReadEventMetadataType, ProjectionHandlerContext>[];
196
- async: <ReadEventMetadataType extends AnyReadEventMetadata = AnyRecordedMessageMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord>(definitions: ProjectionDefinition<AnyEvent, ReadEventMetadataType, ProjectionHandlerContext>[]) => ProjectionRegistration<"inline", ReadEventMetadataType, ProjectionHandlerContext>[];
197
- };
198
-
494
+ inline: <ReadEventMetadataType extends AnyReadEventMetadata = AnyRecordedMessageMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext<DefaultRecord>>(definitions: ProjectionDefinition<any, ReadEventMetadataType, HandlerContext>[]) => ProjectionRegistration<"inline", ReadEventMetadataType, HandlerContext>[];
495
+ async: <ReadEventMetadataType extends AnyReadEventMetadata = AnyRecordedMessageMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext<DefaultRecord>>(definitions: ProjectionDefinition<AnyEvent, ReadEventMetadataType, HandlerContext>[]) => ProjectionRegistration<"inline", ReadEventMetadataType, HandlerContext>[];
496
+ };
497
+ //#endregion
498
+ //#region src/processors/observability/processorCollector.d.ts
499
+ type ProcessorObservabilityConfig = Pick<EmmettObservabilityConfig, 'tracer' | 'meter' | 'propagation' | 'attributeTarget' | 'includeMessagePayloads'>;
500
+ type ResolvedProcessorObservability = {
501
+ tracer: Tracer;
502
+ meter: Meter;
503
+ propagation: TracePropagation;
504
+ attributeTarget: AttributeTarget;
505
+ includeMessagePayloads: boolean;
506
+ };
507
+ declare const resolveProcessorObservability: (options: {
508
+ observability?: ProcessorObservabilityConfig;
509
+ } | undefined, parent?: EmmettObservabilityOptions) => ResolvedProcessorObservability;
510
+ type ProcessorCollectorContext = {
511
+ processorId: string;
512
+ type: string;
513
+ checkpoint: ProcessorCheckpoint | null;
514
+ };
515
+ declare const processorCollector: (observability: ResolvedProcessorObservability) => {
516
+ startScope: <MessageType extends Message = Message, MessageMetadataType extends AnyReadEventMetadata = AnyRecordedMessageMetadata, T = void>(context: ProcessorCollectorContext, messages: RecordedMessage<MessageType, MessageMetadataType>[], fn: (scope: ObservabilityScope) => Promise<T>) => Promise<T>;
517
+ startMessageScope: <MessageType extends Message = Message, MessageMetadataType extends AnyReadEventMetadata = AnyRecordedMessageMetadata, T = void>(context: ProcessorCollectorContext & {
518
+ archetypeType: string;
519
+ }, message: RecordedMessage<MessageType, MessageMetadataType>, batchCtx: SpanContext, fn: (scope: ObservabilityScope) => Promise<T>) => Promise<T>;
520
+ recordLag: (processorId: string, lag: number) => void;
521
+ };
522
+ //#endregion
523
+ //#region src/processors/processors.d.ts
199
524
  type CurrentMessageProcessorPosition = {
200
- lastCheckpoint: ProcessorCheckpoint;
525
+ lastCheckpoint: ProcessorCheckpoint;
201
526
  } | 'BEGINNING' | 'END';
202
- type GetCheckpoint<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata> = (message: RecordedMessage<MessageType, MessageMetadataType>) => ProcessorCheckpoint | null;
203
- declare const getCheckpoint: <MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata>(message: RecordedMessage<MessageType, MessageMetadataType>) => ProcessorCheckpoint | null;
204
527
  declare const wasMessageHandled: <MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata>(message: RecordedMessage<MessageType, MessageMetadataType>, checkpoint: ProcessorCheckpoint | null) => boolean;
205
528
  type MessageProcessorStartFrom = CurrentMessageProcessorPosition | 'CURRENT';
206
529
  type MessageProcessorType = 'projector' | 'reactor';
207
530
  declare const MessageProcessorType: {
208
- PROJECTOR: MessageProcessorType;
209
- REACTOR: MessageProcessorType;
210
- };
211
- type MessageProcessor<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord | undefined = undefined> = {
212
- id: string;
213
- instanceId: string;
214
- type: string;
215
- canHandle?: string[];
216
- init: (options: Partial<HandlerContext>) => Promise<void>;
217
- start: (options: Partial<HandlerContext>) => Promise<CurrentMessageProcessorPosition | undefined>;
218
- close: (closeOptions: Partial<HandlerContext>) => Promise<void>;
219
- isActive: boolean;
220
- handle: BatchRecordedMessageHandlerWithContext<MessageType, MessageMetadataType, Partial<HandlerContext>>;
531
+ PROJECTOR: MessageProcessorType;
532
+ REACTOR: MessageProcessorType;
533
+ };
534
+ type MessageProcessor<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends MessageHandlerContext | undefined = undefined> = {
535
+ id: string;
536
+ instanceId: string;
537
+ type: string;
538
+ canHandle?: string[];
539
+ init: (options?: Partial<HandlerContext>) => Promise<void>;
540
+ start: (options?: Partial<HandlerContext>) => Promise<CurrentMessageProcessorPosition | undefined>;
541
+ close: (closeOptions?: Partial<HandlerContext>) => Promise<void>;
542
+ isActive: boolean;
543
+ handle: BatchRecordedMessageHandlerWithContext<MessageType, MessageMetadataType, Partial<HandlerContext>>;
221
544
  };
222
545
  declare const MessageProcessor: {
223
- result: {
224
- skip: (options?: {
225
- reason?: string;
226
- }) => MessageHandlerResult;
227
- stop: (options?: {
228
- reason?: string;
229
- error?: EmmettError;
230
- }) => MessageHandlerResult;
231
- };
232
- };
233
- type MessageProcessingScope<HandlerContext extends DefaultRecord | undefined = undefined> = <Result = MessageHandlerResult>(handler: (context: HandlerContext) => Result | Promise<Result>, partialContext: Partial<HandlerContext>) => Result | Promise<Result>;
234
- type Checkpointer<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord = DefaultRecord> = {
235
- read: ReadProcessorCheckpoint<HandlerContext>;
236
- store: StoreProcessorCheckpoint<MessageType, MessageMetadataType, HandlerContext>;
237
- };
238
- type ProcessorHooks<HandlerContext extends DefaultRecord = DefaultRecord> = {
239
- onInit?: OnReactorInitHook<HandlerContext>;
240
- onStart?: OnReactorStartHook<HandlerContext>;
241
- onClose?: OnReactorCloseHook<HandlerContext>;
242
- };
243
- type BaseMessageProcessorOptions<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord = DefaultRecord> = {
244
- type?: string;
245
- processorId: string;
246
- processorInstanceId?: string;
247
- version?: number;
248
- partition?: string;
249
- startFrom?: MessageProcessorStartFrom;
250
- stopAfter?: (message: RecordedMessage<MessageType, MessageMetadataType>) => boolean;
251
- processingScope?: MessageProcessingScope<HandlerContext>;
252
- checkpoints?: Checkpointer<MessageType, MessageMetadataType, HandlerContext>;
253
- canHandle?: CanHandle<MessageType>;
254
- hooks?: ProcessorHooks<HandlerContext>;
255
- };
256
- type HandlerOptions<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord = DefaultRecord> = {
257
- eachMessage: SingleRecordedMessageHandlerWithContext<MessageType, MessageMetadataType, HandlerContext>;
258
- eachBatch?: never;
546
+ result: {
547
+ skip: (options?: {
548
+ reason?: string;
549
+ }) => SingleMessageHandlerResult;
550
+ stop: (options?: {
551
+ reason?: string;
552
+ error?: EmmettError;
553
+ }) => SingleMessageHandlerResult;
554
+ };
555
+ };
556
+ type MessageProcessingScope<HandlerContext extends MessageHandlerContext | undefined = undefined> = <Result = SingleMessageHandlerResult>(handler: (context: HandlerContext) => Result | Promise<Result>, partialContext: WithObservabilityScope<Partial<HandlerContext>>) => Result | Promise<Result>;
557
+ type ProcessorHooks<HandlerContext extends MessageHandlerContext = MessageHandlerContext> = {
558
+ onInit?: OnReactorInitHook<HandlerContext>;
559
+ onStart?: OnReactorStartHook<HandlerContext>;
560
+ onClose?: OnReactorCloseHook<HandlerContext>;
561
+ };
562
+ type BaseMessageProcessorOptions<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends MessageHandlerContext = MessageHandlerContext> = {
563
+ type?: string;
564
+ processorId: string;
565
+ processorInstanceId?: string;
566
+ version?: number;
567
+ partition?: string;
568
+ startFrom?: MessageProcessorStartFrom;
569
+ stopAfter?: (message: RecordedMessage<MessageType, MessageMetadataType>) => boolean;
570
+ processingScope?: MessageProcessingScope<HandlerContext>;
571
+ checkpoints?: Checkpointer<MessageType, MessageMetadataType, HandlerContext>;
572
+ canHandle?: CanHandle<MessageType>;
573
+ hooks?: ProcessorHooks<HandlerContext>;
574
+ } & JSONSerializationOptions & {
575
+ observability?: ProcessorObservabilityConfig;
576
+ };
577
+ type HandlerOptions<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends MessageHandlerContext = MessageHandlerContext> = {
578
+ eachMessage: SingleRecordedMessageHandlerWithContext<MessageType, MessageMetadataType, HandlerContext>;
579
+ eachBatch?: never;
259
580
  } | {
260
- eachMessage?: never;
261
- eachBatch: BatchRecordedMessageHandlerWithContext<MessageType, MessageMetadataType, HandlerContext>;
262
- };
263
- type OnReactorInitHook<HandlerContext extends DefaultRecord = DefaultRecord> = (context: HandlerContext) => Promise<void>;
264
- type OnReactorStartHook<HandlerContext extends DefaultRecord = DefaultRecord> = (context: HandlerContext) => Promise<void>;
265
- type OnReactorCloseHook<HandlerContext extends DefaultRecord = DefaultRecord> = (context: HandlerContext) => Promise<void>;
266
- type ReactorOptions<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord = DefaultRecord, MessagePayloadType extends AnyMessage = MessageType> = BaseMessageProcessorOptions<MessageType, MessageMetadataType, HandlerContext> & HandlerOptions<MessageType, MessageMetadataType, HandlerContext> & {
267
- messageOptions?: {
268
- schema?: {
269
- versioning?: {
270
- upcast?: (event: MessagePayloadType) => MessageType;
271
- };
272
- };
581
+ eachMessage?: never;
582
+ eachBatch: BatchRecordedMessageHandlerWithContext<MessageType, MessageMetadataType, HandlerContext>;
583
+ };
584
+ type OnReactorInitHook<HandlerContext extends MessageHandlerContext = MessageHandlerContext> = (context: HandlerContext) => Promise<void>;
585
+ type OnReactorStartHook<HandlerContext extends MessageHandlerContext = MessageHandlerContext> = (context: HandlerContext) => Promise<void>;
586
+ type OnReactorCloseHook<HandlerContext extends MessageHandlerContext = MessageHandlerContext> = (context: HandlerContext) => Promise<void>;
587
+ type ReactorOptions<MessageType extends AnyMessage = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends MessageHandlerContext = MessageHandlerContext, MessagePayloadType extends AnyMessage = MessageType> = BaseMessageProcessorOptions<MessageType, MessageMetadataType, HandlerContext> & HandlerOptions<MessageType, MessageMetadataType, HandlerContext> & {
588
+ messageOptions?: {
589
+ schema?: {
590
+ versioning?: {
591
+ upcast?: (event: MessagePayloadType) => MessageType;
592
+ };
273
593
  };
594
+ };
274
595
  };
275
- type ProjectorOptions<EventType extends AnyEvent = AnyEvent, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord = DefaultRecord, EventPayloadType extends Event = EventType> = Omit<BaseMessageProcessorOptions<EventType, MessageMetadataType, HandlerContext>, 'type' | 'processorId'> & {
276
- processorId?: string;
596
+ type ProjectorOptions<EventType extends AnyEvent = AnyEvent, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends MessageHandlerContext = MessageHandlerContext, EventPayloadType extends Event = EventType> = Omit<BaseMessageProcessorOptions<EventType, MessageMetadataType, HandlerContext>, 'type' | 'processorId'> & {
597
+ processorId?: string;
277
598
  } & {
278
- truncateOnStart?: boolean;
279
- projection: ProjectionDefinition<EventType, MessageMetadataType, HandlerContext, EventPayloadType>;
599
+ truncateOnStart?: boolean;
600
+ projection: ProjectionDefinition<EventType, MessageMetadataType, HandlerContext, EventPayloadType>;
280
601
  };
281
- declare const defaultProcessingMessageProcessingScope: <HandlerContext = never, Result = MessageHandlerResult>(handler: (context: HandlerContext) => Result | Promise<Result>, partialContext: Partial<HandlerContext>) => Result | Promise<Result>;
282
- type ProcessorCheckpoint = Brand<string, 'ProcessorCheckpoint'>;
283
- declare const bigIntProcessorCheckpoint: (value: bigint) => ProcessorCheckpoint;
284
- declare const parseBigIntProcessorCheckpoint: (value: ProcessorCheckpoint) => bigint;
285
- type ReadProcessorCheckpointResult = {
286
- lastCheckpoint: ProcessorCheckpoint | null;
287
- };
288
- type ReadProcessorCheckpoint<HandlerContext extends DefaultRecord = DefaultRecord> = (options: {
289
- processorId: string;
290
- partition?: string;
291
- }, context: HandlerContext) => Promise<ReadProcessorCheckpointResult>;
292
- type StoreProcessorCheckpointResult = {
293
- success: true;
294
- newCheckpoint: ProcessorCheckpoint | null;
295
- } | {
296
- success: false;
297
- reason: 'IGNORED' | 'MISMATCH' | 'CURRENT_AHEAD';
298
- };
299
- type StoreProcessorCheckpoint<MessageType extends Message = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord | undefined = undefined> = (options: {
300
- message: RecordedMessage<MessageType, MessageMetadataType>;
301
- processorId: string;
302
- version: number | undefined;
303
- lastCheckpoint: ProcessorCheckpoint | null;
304
- partition?: string;
305
- }, context: HandlerContext) => Promise<StoreProcessorCheckpointResult>;
602
+ declare const defaultProcessingMessageProcessingScope: <HandlerContext = never, Result = SingleMessageHandlerResult>(handler: (context: WithObservabilityScope<HandlerContext>) => Result | Promise<Result>, partialContext: WithObservabilityScope<Partial<HandlerContext>>) => Result | Promise<Result>;
306
603
  declare const defaultProcessorVersion = 1;
307
604
  declare const defaultProcessorPartition = "emt:default";
308
605
  declare const getProcessorInstanceId: (processorId: string) => string;
309
606
  declare const getProjectorId: (options: {
310
- projectionName: string;
607
+ projectionName: string;
311
608
  }) => string;
312
- declare const reactor: <MessageType extends Message = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends DefaultRecord = DefaultRecord, MessagePayloadType extends Message = MessageType>(options: ReactorOptions<MessageType, MessageMetadataType, HandlerContext, MessagePayloadType>) => MessageProcessor<MessageType, MessageMetadataType, HandlerContext>;
313
- declare const projector: <EventType extends Event = Event, EventMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord = DefaultRecord, EventPayloadType extends Event = EventType>(options: ProjectorOptions<EventType, EventMetaDataType, HandlerContext, EventPayloadType>) => MessageProcessor<EventType, EventMetaDataType, HandlerContext>;
314
-
315
- type InMemoryProcessorHandlerContext = {
316
- database: InMemoryDatabase;
317
- };
609
+ declare const reactor: <MessageType extends Message = AnyMessage, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends MessageHandlerContext = MessageHandlerContext, MessagePayloadType extends Message = MessageType>(options: ReactorOptions<MessageType, MessageMetadataType, HandlerContext, MessagePayloadType>) => MessageProcessor<MessageType, MessageMetadataType, HandlerContext>;
610
+ declare const projector: <EventType extends Event = Event, EventMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends MessageHandlerContext = MessageHandlerContext, EventPayloadType extends Event = EventType>(options: ProjectorOptions<EventType, EventMetaDataType, HandlerContext, EventPayloadType>) => MessageProcessor<EventType, EventMetaDataType, HandlerContext>;
611
+ //#endregion
612
+ //#region src/processors/inMemoryProcessors.d.ts
613
+ type InMemoryProcessorHandlerContext = MessageHandlerContext<{
614
+ database: InMemoryDatabase;
615
+ }>;
318
616
  type InMemoryProcessor<MessageType extends AnyMessage = AnyMessage> = MessageProcessor<MessageType, ReadEventMetadataWithGlobalPosition, InMemoryProcessorHandlerContext> & {
319
- database: InMemoryDatabase;
617
+ database: InMemoryDatabase;
320
618
  };
321
619
  type InMemoryProcessorEachMessageHandler<MessageType extends AnyMessage = AnyMessage> = SingleRecordedMessageHandlerWithContext<MessageType, ReadEventMetadataWithGlobalPosition, InMemoryProcessorHandlerContext>;
322
620
  type InMemoryProcessorEachBatchHandler<MessageType extends AnyMessage = AnyMessage> = BatchRecordedMessageHandlerWithContext<MessageType, ReadEventMetadataWithGlobalPosition, InMemoryProcessorHandlerContext>;
323
621
  type InMemoryProcessorConnectionOptions = {
324
- database?: InMemoryDatabase;
622
+ database?: InMemoryDatabase;
325
623
  };
326
624
  type InMemoryCheckpointer<MessageType extends AnyMessage = AnyMessage> = Checkpointer<MessageType, ReadEventMetadataWithGlobalPosition, InMemoryProcessorHandlerContext>;
327
625
  declare const inMemoryCheckpointer: <MessageType extends AnyMessage = AnyMessage>() => InMemoryCheckpointer<MessageType>;
328
626
  type InMemoryConnectionOptions = {
329
- connectionOptions?: InMemoryProcessorConnectionOptions;
627
+ connectionOptions?: InMemoryProcessorConnectionOptions;
330
628
  };
331
629
  type InMemoryReactorOptions<MessageType extends AnyMessage = AnyMessage> = ReactorOptions<MessageType, ReadEventMetadataWithGlobalPosition, InMemoryProcessorHandlerContext> & InMemoryConnectionOptions;
332
630
  type InMemoryProjectorOptions<EventType extends AnyEvent = AnyEvent> = ProjectorOptions<EventType, ReadEventMetadataWithGlobalPosition, InMemoryProcessorHandlerContext> & InMemoryConnectionOptions;
333
631
  type InMemoryProcessorOptions<MessageType extends AnyMessage = AnyMessage> = InMemoryReactorOptions<MessageType> | InMemoryProjectorOptions<MessageType & AnyEvent>;
334
632
  declare const inMemoryProjector: <EventType extends AnyEvent = AnyEvent>(options: InMemoryProjectorOptions<EventType>) => InMemoryProcessor<EventType>;
335
633
  declare const inMemoryReactor: <MessageType extends AnyMessage = AnyMessage>(options: InMemoryReactorOptions<MessageType>) => InMemoryProcessor<MessageType>;
336
-
634
+ //#endregion
635
+ //#region src/typing/message.d.ts
337
636
  type Message<Type extends string = string, Data extends DefaultRecord = DefaultRecord, MetaData extends DefaultRecord | undefined = undefined> = Command<Type, Data, MetaData> | Event<Type, Data, MetaData>;
338
637
  type AnyMessage = AnyEvent | AnyCommand;
339
638
  type MessageKindOf<T extends Message> = T['kind'];
340
639
  type MessageTypeOf<T extends Message> = T['type'];
341
640
  type MessageDataOf<T extends Message> = T['data'];
342
641
  type MessageMetaDataOf<T extends Message> = T extends {
343
- metadata: infer M;
642
+ metadata: infer M;
344
643
  } ? M : undefined;
345
644
  type CanHandle<T extends Message> = MessageTypeOf<T>[];
346
645
  declare const message: <MessageType extends Message<string, any, any>>(...args: MessageMetaDataOf<MessageType> extends undefined ? [kind: MessageKindOf<MessageType>, type: MessageTypeOf<MessageType>, data: MessageDataOf<MessageType>] : [kind: MessageKindOf<MessageType>, type: MessageTypeOf<MessageType>, data: MessageDataOf<MessageType>, metadata: MessageMetaDataOf<MessageType>]) => MessageType;
347
646
  type CombinedMessageMetadata<MessageType extends Message = Message, MessageMetaDataType extends DefaultRecord = DefaultRecord> = MessageMetaDataOf<MessageType> extends undefined ? MessageMetaDataType : MessageMetaDataOf<MessageType> & MessageMetaDataType;
348
647
  type CombineMetadata<MessageType extends Message = Message, MessageMetaDataType extends DefaultRecord = DefaultRecord> = MessageType & {
349
- metadata: CombinedMessageMetadata<MessageType, MessageMetaDataType>;
648
+ metadata: CombinedMessageMetadata<MessageType, MessageMetaDataType>;
350
649
  };
351
650
  type RecordedMessage<MessageType extends Message = Message, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = CombineMetadata<MessageType, MessageMetaDataType> & {
352
- kind: NonNullable<MessageKindOf<Message>>;
651
+ kind: NonNullable<MessageKindOf<Message>>;
353
652
  };
354
653
  type CommonRecordedMessageMetadata = Readonly<{
355
- messageId: string;
356
- streamPosition: StreamPosition;
357
- streamName: string;
358
- checkpoint?: ProcessorCheckpoint | null;
654
+ messageId: string;
655
+ streamPosition: StreamPosition;
656
+ streamName: string;
657
+ checkpoint?: ProcessorCheckpoint | null;
658
+ correlationId?: string;
659
+ causationId?: string;
660
+ traceId?: string;
661
+ spanId?: string;
359
662
  }>;
360
663
  type WithGlobalPosition = Readonly<{
361
- globalPosition: GlobalPosition;
664
+ globalPosition: GlobalPosition;
362
665
  }>;
363
666
  type RecordedMessageMetadata<HasGlobalPosition = undefined> = CommonRecordedMessageMetadata & (HasGlobalPosition extends undefined ? {} : WithGlobalPosition);
364
667
  type AnyRecordedMessage = Message<any, any, any>;
365
668
  type AnyRecordedMessageMetadata = RecordedMessageMetadata<any>;
366
669
  type RecordedMessageMetadataWithGlobalPosition = RecordedMessageMetadata<true>;
367
670
  type RecordedMessageMetadataWithoutGlobalPosition = RecordedMessageMetadata<undefined>;
368
-
671
+ //#endregion
672
+ //#region src/typing/event.d.ts
369
673
  type StreamPosition = bigint;
370
- type GlobalPosition = bigint;
674
+ type GlobalPosition = string;
371
675
  type Event<EventType extends string = string, EventData extends DefaultRecord = DefaultRecord, EventMetaData extends DefaultRecord | undefined = undefined> = Readonly<EventMetaData extends undefined ? {
372
- type: EventType;
373
- data: EventData;
676
+ type: EventType;
677
+ data: EventData;
374
678
  } : {
375
- type: EventType;
376
- data: EventData;
377
- metadata: EventMetaData;
679
+ type: EventType;
680
+ data: EventData;
681
+ metadata: EventMetaData;
378
682
  }> & {
379
- readonly kind?: 'Event';
683
+ readonly kind?: 'Event';
380
684
  };
381
685
  type AnyEvent = Event<any, any, any>;
382
686
  type EventTypeOf<T extends Event> = T['type'];
383
687
  type EventDataOf<T extends Event> = T['data'];
384
688
  type EventMetaDataOf<T extends Event> = T extends {
385
- metadata: infer M;
689
+ metadata: infer M;
386
690
  } ? M : undefined;
387
691
  type CreateEventType<EventType extends string, EventData extends DefaultRecord, EventMetaData extends DefaultRecord | undefined = undefined> = Readonly<EventMetaData extends undefined ? {
388
- type: EventType;
389
- data: EventData;
692
+ type: EventType;
693
+ data: EventData;
390
694
  } : {
391
- type: EventType;
392
- data: EventData;
393
- metadata: EventMetaData;
695
+ type: EventType;
696
+ data: EventData;
697
+ metadata: EventMetaData;
394
698
  }> & {
395
- readonly kind?: 'Event';
699
+ readonly kind?: 'Event';
396
700
  };
397
701
  declare const event: <EventType extends Event<string, any, any>>(...args: EventMetaDataOf<EventType> extends undefined ? [type: EventTypeOf<EventType>, data: EventDataOf<EventType>] : [type: EventTypeOf<EventType>, data: EventDataOf<EventType>, metadata: EventMetaDataOf<EventType>]) => EventType;
398
702
  type CombinedReadEventMetadata<EventType extends Event = Event, EventMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = CombinedMessageMetadata<EventType, EventMetaDataType>;
@@ -403,42 +707,60 @@ type ReadEventMetadata<HasGlobalPosition = undefined> = RecordedMessageMetadata<
403
707
  type AnyReadEventMetadata = AnyRecordedMessageMetadata;
404
708
  type ReadEventMetadataWithGlobalPosition = RecordedMessageMetadataWithGlobalPosition;
405
709
  type ReadEventMetadataWithoutGlobalPosition = RecordedMessageMetadataWithoutGlobalPosition;
406
-
407
- type SingleRawMessageHandlerWithoutContext<MessageType extends Message = AnyMessage> = (message: MessageType) => Promise<MessageHandlerResult> | MessageHandlerResult;
408
- type SingleRecordedMessageHandlerWithoutContext<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = (message: RecordedMessage<MessageType, MessageMetaDataType>) => Promise<MessageHandlerResult> | MessageHandlerResult;
710
+ //#endregion
711
+ //#region src/typing/messageHandling.d.ts
712
+ type MessageHandlerContext<HandlerContext extends DefaultRecord = DefaultRecord> = WithObservabilityScope<HandlerContext>;
713
+ type SingleRawMessageHandlerWithoutContext<MessageType extends Message = AnyMessage> = (message: MessageType) => Promise<SingleMessageHandlerResult> | SingleMessageHandlerResult;
714
+ type SingleRecordedMessageHandlerWithoutContext<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = (message: RecordedMessage<MessageType, MessageMetaDataType>) => Promise<SingleMessageHandlerResult> | SingleMessageHandlerResult;
409
715
  type SingleMessageHandlerWithoutContext<MessageType extends AnyMessage = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = never> = SingleRawMessageHandlerWithoutContext<MessageType> | SingleRecordedMessageHandlerWithoutContext<MessageType, MessageMetaDataType>;
410
- type SingleRawMessageHandlerWithContext<MessageType extends Message = AnyMessage, HandlerContext extends DefaultRecord | undefined = undefined> = (message: MessageType, context: HandlerContext) => Promise<MessageHandlerResult> | MessageHandlerResult;
411
- type SingleRecordedMessageHandlerWithContext<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord | undefined = undefined> = (message: RecordedMessage<MessageType, MessageMetaDataType>, context: HandlerContext) => Promise<MessageHandlerResult> | MessageHandlerResult;
716
+ type SingleRawMessageHandlerWithContext<MessageType extends Message = AnyMessage, HandlerContext extends DefaultRecord | undefined = undefined> = (message: MessageType, context: HandlerContext) => Promise<SingleMessageHandlerResult> | SingleMessageHandlerResult;
717
+ type SingleRecordedMessageHandlerWithContext<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord | undefined = undefined> = (message: RecordedMessage<MessageType, MessageMetaDataType>, context: HandlerContext) => Promise<SingleMessageHandlerResult> | SingleMessageHandlerResult;
412
718
  type SingleMessageHandlerWithContext<MessageType extends AnyMessage = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = never, HandlerContext extends DefaultRecord = DefaultRecord> = SingleRawMessageHandlerWithContext<MessageType, HandlerContext> | SingleRecordedMessageHandlerWithContext<MessageType, MessageMetaDataType, HandlerContext>;
413
719
  type SingleMessageHandler<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord | undefined = undefined> = HandlerContext extends DefaultRecord ? SingleMessageHandlerWithContext<MessageType, MessageMetaDataType, HandlerContext> : SingleMessageHandlerWithoutContext<MessageType, MessageMetaDataType>;
414
- type BatchRawMessageHandlerWithoutContext<MessageType extends Message = AnyMessage> = (messages: MessageType[]) => Promise<MessageHandlerResult> | MessageHandlerResult;
415
- type BatchRecordedMessageHandlerWithoutContext<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = (messages: RecordedMessage<MessageType, MessageMetaDataType>[]) => Promise<MessageHandlerResult> | MessageHandlerResult;
720
+ type BatchRawMessageHandlerWithoutContext<MessageType extends Message = AnyMessage> = (messages: MessageType[]) => Promise<BatchMessageHandlerResult> | BatchMessageHandlerResult;
721
+ type BatchRecordedMessageHandlerWithoutContext<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = (messages: RecordedMessage<MessageType, MessageMetaDataType>[]) => Promise<BatchMessageHandlerResult> | BatchMessageHandlerResult;
416
722
  type BatchMessageHandlerWithoutContext<MessageType extends AnyMessage = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = BatchRawMessageHandlerWithoutContext<MessageType> | BatchRecordedMessageHandlerWithoutContext<MessageType, MessageMetaDataType>;
417
- type BatchRawMessageHandlerWithContext<MessageType extends Message = AnyMessage, HandlerContext extends DefaultRecord | undefined = undefined> = (messages: MessageType[], context: HandlerContext) => Promise<MessageHandlerResult> | MessageHandlerResult;
418
- type BatchRecordedMessageHandlerWithContext<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord = DefaultRecord> = (messages: RecordedMessage<MessageType, MessageMetaDataType>[], context: HandlerContext) => Promise<MessageHandlerResult> | MessageHandlerResult;
723
+ type BatchRawMessageHandlerWithContext<MessageType extends Message = AnyMessage, HandlerContext extends DefaultRecord | undefined = undefined> = (messages: MessageType[], context: HandlerContext) => Promise<BatchMessageHandlerResult> | BatchMessageHandlerResult;
724
+ type BatchRecordedMessageHandlerWithContext<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord = DefaultRecord> = (messages: RecordedMessage<MessageType, MessageMetaDataType>[], context: HandlerContext) => Promise<BatchMessageHandlerResult> | BatchMessageHandlerResult;
419
725
  type BatchMessageHandlerWithContext<MessageType extends AnyMessage = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord = DefaultRecord> = BatchRawMessageHandlerWithContext<MessageType, HandlerContext> | BatchRecordedMessageHandlerWithContext<MessageType, MessageMetaDataType, HandlerContext>;
420
726
  type BatchMessageHandler<MessageType extends Message = AnyMessage, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord | undefined = undefined> = HandlerContext extends DefaultRecord ? BatchMessageHandlerWithContext<MessageType, MessageMetaDataType, HandlerContext> : BatchMessageHandlerWithoutContext<MessageType, MessageMetaDataType>;
421
727
  type MessageHandler<MessageType extends Message = Message, MessageMetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends DefaultRecord | undefined = undefined> = (HandlerContext extends DefaultRecord ? SingleMessageHandler<MessageType, MessageMetaDataType, HandlerContext> : SingleMessageHandler<MessageType, MessageMetaDataType>) | (HandlerContext extends DefaultRecord ? BatchMessageHandler<MessageType, MessageMetaDataType, HandlerContext> : BatchMessageHandler<MessageType, MessageMetaDataType>);
422
- type MessageHandlerResult = void | {
423
- type: 'SKIP';
424
- reason?: string;
728
+ type SingleMessageHandlerResult = void | {
729
+ type: 'ACK';
730
+ } | {
731
+ type: 'SKIP';
732
+ reason?: string;
425
733
  } | {
426
- type: 'STOP';
427
- reason?: string;
428
- error?: EmmettError;
734
+ type: 'STOP';
735
+ reason?: string;
736
+ error?: EmmettError;
429
737
  };
430
-
738
+ type BatchMessageHandlerResult = void | {
739
+ type: 'ACK';
740
+ } | {
741
+ type: 'SKIP';
742
+ reason?: string;
743
+ lastSuccessfulMessage: AnyRecordedMessage;
744
+ } | {
745
+ type: 'STOP';
746
+ reason?: string;
747
+ error?: EmmettError;
748
+ lastSuccessfulMessage?: AnyRecordedMessage;
749
+ };
750
+ //#endregion
751
+ //#region src/typing/decider.d.ts
431
752
  type Decider<State, CommandType extends Command, StreamEvent extends Event> = {
432
- decide: (command: CommandType, state: State) => StreamEvent | StreamEvent[];
433
- evolve: (currentState: State, event: StreamEvent) => State;
434
- initialState: () => State;
753
+ decide: (command: CommandType, state: State) => StreamEvent | StreamEvent[];
754
+ evolve: (currentState: State, event: StreamEvent) => State;
755
+ initialState: () => State;
435
756
  };
436
-
757
+ //#endregion
758
+ //#region src/typing/index.d.ts
437
759
  type Brand<K, T> = K & {
438
- readonly __brand: T;
760
+ readonly __brand: T;
439
761
  };
440
762
  type Flavour<K, T> = K & {
441
- readonly __brand?: T;
763
+ readonly __brand?: T;
442
764
  };
443
765
  type DefaultRecord = Record<string, unknown>;
444
766
  type AnyRecord = Record<string, any>;
@@ -447,7 +769,8 @@ declare const emmettPrefix = "emt";
447
769
  declare const globalTag = "global";
448
770
  declare const defaultTag = "emt:default";
449
771
  declare const unknownTag = "emt:unknown";
450
-
772
+ //#endregion
773
+ //#region src/eventStore/expectedVersion.d.ts
451
774
  type ExpectedStreamVersion = ExpectedStreamVersionWithValue | ExpectedStreamVersionGeneral;
452
775
  type ExpectedStreamVersionWithValue = Flavour<StreamPosition, 'StreamVersion'>;
453
776
  type ExpectedStreamVersionGeneral = Flavour<'STREAM_EXISTS' | 'STREAM_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK', 'StreamVersion'>;
@@ -457,187 +780,198 @@ declare const NO_CONCURRENCY_CHECK: ExpectedStreamVersionGeneral;
457
780
  declare const matchesExpectedVersion: (current: StreamPosition | undefined, expected: ExpectedStreamVersion, defaultVersion: StreamPosition) => boolean;
458
781
  declare const assertExpectedVersionMatchesCurrent: (current: StreamPosition, expected: ExpectedStreamVersion | undefined, defaultVersion: StreamPosition) => void;
459
782
  declare class ExpectedVersionConflictError extends ConcurrencyError {
460
- constructor(current: StreamPosition, expected: ExpectedStreamVersion);
783
+ constructor(current: StreamPosition, expected: ExpectedStreamVersion);
461
784
  }
462
785
  declare const isExpectedVersionConflictError: (error: unknown) => error is ExpectedVersionConflictError;
463
-
786
+ //#endregion
787
+ //#region src/eventStore/eventStore.d.ts
464
788
  interface EventStore<ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata> {
465
- aggregateStream<State, EventType extends Event, EventPayloadType extends Event = EventType>(streamName: string, options: AggregateStreamOptions<State, EventType, ReadEventMetadataType, EventPayloadType>): Promise<AggregateStreamResult<State>>;
466
- readStream<EventType extends Event, EventPayloadType extends Event = EventType>(streamName: string, options?: ReadStreamOptions<EventType, EventPayloadType>): Promise<ReadStreamResult<EventType, ReadEventMetadataType>>;
467
- appendToStream<EventType extends Event, EventPayloadType extends Event = EventType>(streamName: string, events: EventType[], options?: AppendToStreamOptions<EventType, EventPayloadType>): Promise<AppendToStreamResult>;
468
- streamExists(streamName: string): Promise<StreamExistsResult>;
789
+ aggregateStream<State, EventType extends Event, EventPayloadType extends Event = EventType>(streamName: string, options: AggregateStreamOptions<State, EventType, ReadEventMetadataType, EventPayloadType>): Promise<AggregateStreamResult<State>>;
790
+ readStream<EventType extends Event, EventPayloadType extends Event = EventType>(streamName: string, options?: ReadStreamOptions<EventType, EventPayloadType>): Promise<ReadStreamResult<EventType, ReadEventMetadataType>>;
791
+ appendToStream<EventType extends Event, EventPayloadType extends Event = EventType>(streamName: string, events: EventType[], options?: AppendToStreamOptions<EventType, EventPayloadType>): Promise<AppendToStreamResult>;
792
+ streamExists(streamName: string): Promise<StreamExistsResult>;
469
793
  }
470
794
  type EventStoreReadEventMetadata<Store extends EventStore> = Store extends EventStore<infer T> ? T extends CommonReadEventMetadata ? T extends WithGlobalPosition ? ReadEventMetadata<true> & T : ReadEventMetadata<undefined> & T : never : never;
471
795
  type EventStoreSession<EventStoreType extends EventStore> = {
472
- eventStore: EventStoreType;
473
- close: () => Promise<void>;
796
+ eventStore: EventStoreType;
797
+ close: () => Promise<void>;
474
798
  };
475
799
  interface EventStoreSessionFactory<EventStoreType extends EventStore> {
476
- withSession<T = unknown>(callback: (session: EventStoreSession<EventStoreType>) => Promise<T>): Promise<T>;
800
+ withSession<T = unknown>(callback: (session: EventStoreSession<EventStoreType>) => Promise<T>): Promise<T>;
477
801
  }
478
802
  declare const canCreateEventStoreSession: <Store extends EventStore>(eventStore: Store | EventStoreSessionFactory<Store>) => eventStore is EventStoreSessionFactory<Store>;
479
803
  declare const nulloSessionFactory: <EventStoreType extends EventStore>(eventStore: EventStoreType) => EventStoreSessionFactory<EventStoreType>;
480
804
  type EventStoreReadSchemaOptions<StreamEvent extends Event = Event, StoredEvent extends Event = StreamEvent> = {
481
- versioning?: {
482
- upcast?: (event: StoredEvent) => StreamEvent;
483
- };
805
+ versioning?: {
806
+ upcast?: (event: StoredEvent) => StreamEvent;
807
+ };
484
808
  };
485
809
  type EventStoreAppendSchemaOptions<StreamEvent extends Event = Event, StoredEvent extends Event = StreamEvent> = {
486
- versioning?: {
487
- downcast?: (event: StreamEvent) => StoredEvent;
488
- };
810
+ versioning?: {
811
+ downcast?: (event: StreamEvent) => StoredEvent;
812
+ };
489
813
  };
490
814
  type EventStoreSchemaOptions<StreamEvent extends Event = Event, StoredEvent extends Event = StreamEvent> = EventStoreReadSchemaOptions<StreamEvent, StoredEvent> & EventStoreAppendSchemaOptions<StreamEvent, StoredEvent>;
491
815
  type ReadStreamOptions<EventType extends Event = Event, EventPayloadType extends Event = EventType> = {
492
- from?: StreamPosition;
493
- to?: StreamPosition;
494
- maxCount?: bigint;
495
- expectedStreamVersion?: ExpectedStreamVersion;
496
- schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
497
- };
816
+ from?: StreamPosition;
817
+ to?: StreamPosition;
818
+ maxCount?: bigint;
819
+ expectedStreamVersion?: ExpectedStreamVersion;
820
+ schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
821
+ } & JSONSerializationOptions;
498
822
  type ReadStreamResult<EventType extends Event, ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata> = {
499
- currentStreamVersion: StreamPosition;
500
- events: ReadEvent<EventType, ReadEventMetadataType>[];
501
- streamExists: boolean;
823
+ currentStreamVersion: StreamPosition;
824
+ events: ReadEvent<EventType, ReadEventMetadataType>[];
825
+ streamExists: boolean;
502
826
  };
503
827
  type Evolve<State, EventType extends Event, ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata> = ((currentState: State, event: EventType) => State) | ((currentState: State, event: ReadEvent<EventType, ReadEventMetadataType>) => State) | ((currentState: State, event: ReadEvent<EventType>) => State);
504
828
  type AggregateStreamOptions<State, EventType extends Event, ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, EventPayloadType extends Event = EventType> = {
505
- evolve: Evolve<State, EventType, ReadEventMetadataType>;
506
- initialState: () => State;
507
- read?: ReadStreamOptions<EventType, EventPayloadType>;
829
+ evolve: Evolve<State, EventType, ReadEventMetadataType>;
830
+ initialState: () => State;
831
+ read?: ReadStreamOptions<EventType, EventPayloadType>;
508
832
  };
509
833
  type AggregateStreamResult<State> = {
510
- currentStreamVersion: StreamPosition;
511
- state: State;
512
- streamExists: boolean;
834
+ currentStreamVersion: StreamPosition;
835
+ state: State;
836
+ streamExists: boolean;
513
837
  };
514
838
  type AggregateStreamResultWithGlobalPosition<State> = (AggregateStreamResult<State> & {
515
- streamExists: true;
516
- lastEventGlobalPosition: GlobalPosition;
839
+ streamExists: true;
840
+ lastEventGlobalPosition: ProcessorCheckpoint;
517
841
  }) | (AggregateStreamResult<State> & {
518
- streamExists: false;
842
+ streamExists: false;
519
843
  });
520
- type AggregateStreamResultOfEventStore<Store extends EventStore> = Store['aggregateStream'] extends (...args: any[]) => Promise<infer R> ? R : never;
844
+ type AggregateStreamResultOfEventStore<Store extends EventStore> = Store['aggregateStream'] extends ((...args: any[]) => Promise<infer R>) ? R : never;
521
845
  type AppendToStreamOptions<EventType extends Event = Event, EventPayloadType extends Event = EventType> = {
522
- expectedStreamVersion?: ExpectedStreamVersion;
523
- schema?: EventStoreAppendSchemaOptions<EventType, EventPayloadType>;
846
+ expectedStreamVersion?: ExpectedStreamVersion;
847
+ schema?: EventStoreAppendSchemaOptions<EventType, EventPayloadType> & JSONSerializationOptions;
848
+ correlationId?: string;
849
+ causationId?: string;
850
+ traceId?: string;
851
+ spanId?: string;
524
852
  };
525
853
  type AppendToStreamResult = {
526
- nextExpectedStreamVersion: StreamPosition;
527
- createdNewStream: boolean;
854
+ nextExpectedStreamVersion: StreamPosition;
855
+ createdNewStream: boolean;
528
856
  };
529
857
  type AppendToStreamResultWithGlobalPosition = AppendToStreamResult & {
530
- lastEventGlobalPosition: GlobalPosition;
858
+ lastEventGlobalPosition: ProcessorCheckpoint;
531
859
  };
532
- type AppendStreamResultOfEventStore<Store extends EventStore> = Store['appendToStream'] extends (...args: any[]) => Promise<infer R> ? R : never;
860
+ type AppendStreamResultOfEventStore<Store extends EventStore> = Store['appendToStream'] extends ((...args: any[]) => Promise<infer R>) ? R : never;
533
861
  type StreamExistsResult = boolean;
534
862
  type DefaultEventStoreOptions<Store extends EventStore, HandlerContext extends DefaultRecord | undefined = undefined> = {
863
+ /**
864
+ * Pluggable set of hooks informing about the event store internal behaviour.
865
+ */
866
+ hooks?: {
535
867
  /**
536
- * Pluggable set of hooks informing about the event store internal behaviour.
868
+ * This hook will be called **AFTER** events were stored in the event store.
869
+ * It's designed to handle scenarios where delivery and ordering guarantees do not matter much.
870
+ *
871
+ * **WARNINGS:**
872
+ *
873
+ * 1. It will be called **EXACTLY ONCE** if append succeded.
874
+ * 2. If the hook fails, its append **will still silently succeed**, and no error will be thrown.
875
+ * 3. Wen process crashes after events were committed, but before the hook was called, delivery won't be retried.
876
+ * That can lead to state inconsistencies.
877
+ * 4. In the case of high concurrent traffic, **race conditions may cause ordering issues**.
878
+ * For instance, where the second hook takes longer to process than the first one, ordering won't be guaranteed.
879
+ *
880
+ * @type {AfterEventStoreCommitHandler<Store, HandlerContext>}
537
881
  */
538
- hooks?: {
539
- /**
540
- * This hook will be called **AFTER** events were stored in the event store.
541
- * It's designed to handle scenarios where delivery and ordering guarantees do not matter much.
542
- *
543
- * **WARNINGS:**
544
- *
545
- * 1. It will be called **EXACTLY ONCE** if append succeded.
546
- * 2. If the hook fails, its append **will still silently succeed**, and no error will be thrown.
547
- * 3. Wen process crashes after events were committed, but before the hook was called, delivery won't be retried.
548
- * That can lead to state inconsistencies.
549
- * 4. In the case of high concurrent traffic, **race conditions may cause ordering issues**.
550
- * For instance, where the second hook takes longer to process than the first one, ordering won't be guaranteed.
551
- *
552
- * @type {AfterEventStoreCommitHandler<Store, HandlerContext>}
553
- */
554
- onAfterCommit?: AfterEventStoreCommitHandler<Store, HandlerContext>;
555
- };
882
+ onAfterCommit?: AfterEventStoreCommitHandler<Store, HandlerContext>;
883
+ };
556
884
  };
557
-
885
+ //#endregion
886
+ //#region src/eventStore/afterCommit/afterEventStoreCommitHandler.d.ts
558
887
  type AfterEventStoreCommitHandler<Store extends EventStore, HandlerContext extends DefaultRecord | undefined = undefined> = HandlerContext extends undefined ? BatchRecordedMessageHandlerWithoutContext<Event, EventStoreReadEventMetadata<Store>> : BatchRecordedMessageHandlerWithContext<Event, EventStoreReadEventMetadata<Store>, NonNullable<HandlerContext>>;
559
888
  type BeforeEventStoreCommitHandler<Store extends EventStore, HandlerContext extends DefaultRecord | undefined = undefined> = HandlerContext extends undefined ? BatchRecordedMessageHandlerWithoutContext<Event, EventStoreReadEventMetadata<Store>> : BatchRecordedMessageHandlerWithContext<Event, EventStoreReadEventMetadata<Store>, NonNullable<HandlerContext>>;
560
889
  type TryPublishMessagesAfterCommitOptions<Store extends EventStore, HandlerContext extends DefaultRecord | undefined = undefined> = {
561
- onAfterCommit?: AfterEventStoreCommitHandler<Store, HandlerContext>;
890
+ onAfterCommit?: AfterEventStoreCommitHandler<Store, HandlerContext>;
562
891
  };
563
892
  declare function tryPublishMessagesAfterCommit<Store extends EventStore>(messages: ReadEvent<Event, EventStoreReadEventMetadata<Store>>[], options: TryPublishMessagesAfterCommitOptions<Store, undefined> | undefined): Promise<boolean>;
564
893
  declare function tryPublishMessagesAfterCommit<Store extends EventStore, HandlerContext extends DefaultRecord | undefined = undefined>(messages: ReadEvent<Event, EventStoreReadEventMetadata<Store>>[], options: TryPublishMessagesAfterCommitOptions<Store, HandlerContext> | undefined, context: HandlerContext): Promise<boolean>;
565
-
894
+ //#endregion
895
+ //#region src/messageBus/index.d.ts
566
896
  interface CommandSender {
567
- send<CommandType extends Command = Command>(command: CommandType): Promise<void>;
897
+ send<CommandType extends Command = Command>(command: CommandType): Promise<void>;
568
898
  }
569
899
  interface EventsPublisher {
570
- publish<EventType extends Event = Event>(event: EventType): Promise<void>;
900
+ publish<EventType extends Event = Event>(event: EventType): Promise<void>;
571
901
  }
572
902
  type ScheduleOptions = {
573
- afterInMs: number;
903
+ afterInMs: number;
574
904
  } | {
575
- at: Date;
905
+ at: Date;
576
906
  };
577
907
  interface MessageScheduler<CommandOrEvent extends Command | Event> {
578
- schedule<MessageType extends CommandOrEvent>(message: MessageType, when?: ScheduleOptions): void;
579
- }
580
- interface CommandBus extends CommandSender, MessageScheduler<Command> {
581
- }
582
- interface EventBus extends EventsPublisher, MessageScheduler<Event> {
908
+ schedule<MessageType extends CommandOrEvent>(message: MessageType, when?: ScheduleOptions): void;
583
909
  }
910
+ interface CommandBus extends CommandSender, MessageScheduler<Command> {}
911
+ interface EventBus extends EventsPublisher, MessageScheduler<Event> {}
584
912
  interface MessageBus extends CommandBus, EventBus {
585
- schedule<MessageType extends Command | Event>(message: MessageType, when?: ScheduleOptions): void;
913
+ schedule<MessageType extends Command | Event>(message: MessageType, when?: ScheduleOptions): void;
586
914
  }
587
915
  interface CommandProcessor {
588
- handle<CommandType extends Command>(commandHandler: SingleMessageHandler<CommandType>, ...commandTypes: CommandTypeOf<CommandType>[]): void;
916
+ handle<CommandType extends Command>(commandHandler: SingleMessageHandler<CommandType>, ...commandTypes: CommandTypeOf<CommandType>[]): void;
589
917
  }
590
918
  interface EventSubscription {
591
- subscribe<EventType extends Event>(eventHandler: SingleMessageHandler<EventType>, ...eventTypes: EventTypeOf<EventType>[]): void;
919
+ subscribe<EventType extends Event>(eventHandler: SingleMessageHandler<EventType>, ...eventTypes: EventTypeOf<EventType>[]): void;
592
920
  }
593
921
  type ScheduledMessage = {
594
- message: Message;
595
- options?: ScheduleOptions;
922
+ message: Message;
923
+ options?: ScheduleOptions;
596
924
  };
597
925
  interface ScheduledMessageProcessor {
598
- dequeue(): ScheduledMessage[];
926
+ dequeue(): ScheduledMessage[];
599
927
  }
600
928
  type MessageSubscription = EventSubscription | CommandProcessor;
601
929
  declare const getInMemoryMessageBus: () => MessageBus & EventSubscription & CommandProcessor & ScheduledMessageProcessor;
602
-
930
+ //#endregion
931
+ //#region src/eventStore/afterCommit/forwardToMessageBus.d.ts
603
932
  declare const forwardToMessageBus: <Store extends EventStore, HandlerContext extends DefaultRecord | undefined = undefined>(eventPublisher: EventsPublisher) => AfterEventStoreCommitHandler<Store, HandlerContext>;
604
-
933
+ //#endregion
934
+ //#region src/eventStore/events/index.d.ts
605
935
  declare const GlobalStreamCaughtUpType = "__emt:GlobalStreamCaughtUp";
606
936
  type GlobalStreamCaughtUp = Event<'__emt:GlobalStreamCaughtUp', {
607
- globalPosition: bigint;
937
+ globalPosition: GlobalPosition;
608
938
  }, {
609
- globalPosition: bigint;
939
+ globalPosition: GlobalPosition;
610
940
  }>;
611
941
  declare const isGlobalStreamCaughtUp: (event: Event) => event is GlobalStreamCaughtUp;
612
- declare const caughtUpEventFrom: (position: bigint) => (event: ReadEvent<Event, ReadEventMetadataWithGlobalPosition>) => event is ReadEvent<GlobalStreamCaughtUp, ReadEventMetadataWithGlobalPosition>;
942
+ declare const caughtUpEventFrom: (position: string) => (event: ReadEvent<Event, ReadEventMetadataWithGlobalPosition>) => event is ReadEvent<GlobalStreamCaughtUp, ReadEventMetadataWithGlobalPosition>;
613
943
  declare const globalStreamCaughtUp: (data: EventDataOf<GlobalStreamCaughtUp>) => GlobalStreamCaughtUp;
614
944
  declare const isSubscriptionEvent: (event: Event) => event is GlobalSubscriptionEvent;
615
945
  declare const isNotInternalEvent: (event: Event) => boolean;
616
946
  type GlobalSubscriptionEvent = GlobalStreamCaughtUp;
617
-
947
+ //#endregion
948
+ //#region src/eventStore/inMemoryEventStore.d.ts
618
949
  declare const InMemoryEventStoreDefaultStreamVersion = 0n;
619
950
  type InMemoryEventStore = EventStore<ReadEventMetadataWithGlobalPosition> & {
620
- database: InMemoryDatabase;
951
+ database: InMemoryDatabase;
621
952
  };
622
953
  type InMemoryReadEventMetadata = ReadEventMetadataWithGlobalPosition;
623
- type InMemoryProjectionHandlerContext = {
624
- eventStore?: InMemoryEventStore;
625
- database?: InMemoryDatabase;
626
- };
954
+ type InMemoryProjectionHandlerContext = MessageHandlerContext<{
955
+ eventStore?: InMemoryEventStore;
956
+ database?: InMemoryDatabase;
957
+ }>;
627
958
  type InMemoryEventStoreOptions = DefaultEventStoreOptions<InMemoryEventStore> & {
628
- projections?: ProjectionRegistration<'inline', InMemoryReadEventMetadata, InMemoryProjectionHandlerContext>[];
629
- database?: InMemoryDatabase;
959
+ projections?: ProjectionRegistration<'inline', InMemoryReadEventMetadata, InMemoryProjectionHandlerContext>[];
960
+ database?: InMemoryDatabase;
961
+ observability?: EventStoreObservabilityConfig;
630
962
  };
631
963
  type InMemoryReadEvent<EventType extends Event = Event> = ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>;
632
964
  declare const getInMemoryEventStore: (eventStoreOptions?: InMemoryEventStoreOptions) => InMemoryEventStore;
633
-
965
+ //#endregion
966
+ //#region src/eventStore/projections/inMemory/inMemoryProjection.d.ts
634
967
  declare const DATABASE_REQUIRED_ERROR_MESSAGE = "Database is required in context for InMemory projections";
635
968
  type InMemoryProjectionDefinition<EventType extends Event> = ProjectionDefinition<EventType, InMemoryReadEventMetadata, InMemoryProjectionHandlerContext>;
636
969
  type InMemoryProjectionHandlerOptions<EventType extends Event = Event> = {
637
- projections: InMemoryProjectionDefinition<EventType>[];
638
- events: ReadEvent<EventType, InMemoryReadEventMetadata>[];
639
- database: InMemoryDatabase;
640
- eventStore?: InMemoryProjectionHandlerContext['eventStore'];
970
+ projections: InMemoryProjectionDefinition<EventType>[];
971
+ events: ReadEvent<EventType, InMemoryReadEventMetadata>[];
972
+ database: InMemoryDatabase;
973
+ eventStore?: InMemoryProjectionHandlerContext['eventStore'];
974
+ observability: ResolvedEventStoreObservability;
641
975
  };
642
976
  /**
643
977
  * Handles projections for the InMemoryEventStore
@@ -648,30 +982,34 @@ type InMemoryWithNotNullDocumentEvolve<DocumentType extends Record<string, unkno
648
982
  type InMemoryWithNullableDocumentEvolve<DocumentType extends Record<string, unknown>, EventType extends Event> = (document: DocumentType | null, event: ReadEvent<EventType, InMemoryReadEventMetadata>) => DocumentType | null;
649
983
  type InMemoryDocumentEvolve<DocumentType extends Record<string, unknown>, EventType extends Event> = InMemoryWithNotNullDocumentEvolve<DocumentType, EventType> | InMemoryWithNullableDocumentEvolve<DocumentType, EventType>;
650
984
  type InMemoryProjectionOptions<EventType extends Event> = {
651
- handle: (events: ReadEvent<EventType, InMemoryReadEventMetadata>[], context: InMemoryProjectionHandlerContext & {
652
- database: InMemoryDatabase;
653
- }) => Promise<void>;
654
- canHandle: CanHandle<EventType>;
655
- truncate?: TruncateProjection<InMemoryProjectionHandlerContext & {
656
- database: InMemoryDatabase;
657
- }>;
985
+ handle: (events: ReadEvent<EventType, InMemoryReadEventMetadata>[], context: InMemoryProjectionHandlerContext & {
986
+ database: InMemoryDatabase;
987
+ }) => Promise<void>;
988
+ canHandle: CanHandle<EventType>;
989
+ truncate?: TruncateProjection<InMemoryProjectionHandlerContext & {
990
+ database: InMemoryDatabase;
991
+ }>;
658
992
  };
659
993
  /**
660
994
  * Creates an InMemory projection
661
995
  */
662
- declare const inMemoryProjection: <EventType extends Event>({ truncate, handle, canHandle, }: InMemoryProjectionOptions<EventType>) => InMemoryProjectionDefinition<EventType>;
996
+ declare const inMemoryProjection: <EventType extends Event>({
997
+ truncate,
998
+ handle,
999
+ canHandle
1000
+ }: InMemoryProjectionOptions<EventType>) => InMemoryProjectionDefinition<EventType>;
663
1001
  /**
664
1002
  * Creates a multi-stream projection for InMemoryDatabase
665
1003
  */
666
1004
  type InMemoryMultiStreamProjectionOptions<DocumentType extends Record<string, unknown>, EventType extends Event> = {
667
- canHandle: CanHandle<EventType>;
668
- collectionName: string;
669
- getDocumentId: (event: ReadEvent<EventType>) => string;
1005
+ canHandle: CanHandle<EventType>;
1006
+ collectionName: string;
1007
+ getDocumentId: (event: ReadEvent<EventType>) => string;
670
1008
  } & ({
671
- evolve: InMemoryWithNullableDocumentEvolve<DocumentType, EventType>;
1009
+ evolve: InMemoryWithNullableDocumentEvolve<DocumentType, EventType>;
672
1010
  } | {
673
- evolve: InMemoryWithNotNullDocumentEvolve<DocumentType, EventType>;
674
- initialState: () => DocumentType;
1011
+ evolve: InMemoryWithNotNullDocumentEvolve<DocumentType, EventType>;
1012
+ initialState: () => DocumentType;
675
1013
  });
676
1014
  /**
677
1015
  * Creates a projection that handles events across multiple streams
@@ -681,279 +1019,298 @@ declare const inMemoryMultiStreamProjection: <DocumentType extends Record<string
681
1019
  * Creates a single-stream projection for InMemoryDatabase
682
1020
  */
683
1021
  type InMemorySingleStreamProjectionOptions<DocumentType extends Record<string, unknown>, EventType extends Event> = {
684
- canHandle: CanHandle<EventType>;
685
- getDocumentId?: (event: ReadEvent<EventType>) => string;
686
- collectionName: string;
1022
+ canHandle: CanHandle<EventType>;
1023
+ getDocumentId?: (event: ReadEvent<EventType>) => string;
1024
+ collectionName: string;
687
1025
  } & ({
688
- evolve: InMemoryWithNullableDocumentEvolve<DocumentType, EventType>;
1026
+ evolve: InMemoryWithNullableDocumentEvolve<DocumentType, EventType>;
689
1027
  } | {
690
- evolve: InMemoryWithNotNullDocumentEvolve<DocumentType, EventType>;
691
- initialState: () => DocumentType;
1028
+ evolve: InMemoryWithNotNullDocumentEvolve<DocumentType, EventType>;
1029
+ initialState: () => DocumentType;
692
1030
  });
693
1031
  /**
694
1032
  * Creates a projection that handles events from a single stream
695
1033
  */
696
1034
  declare const inMemorySingleStreamProjection: <DocumentType extends Record<string, unknown>, EventType extends Event>(options: InMemorySingleStreamProjectionOptions<DocumentType, EventType>) => InMemoryProjectionDefinition<EventType>;
697
-
1035
+ //#endregion
1036
+ //#region src/testing/assertions.d.ts
698
1037
  declare class AssertionError extends Error {
699
- constructor(message: string);
1038
+ constructor(message: string);
700
1039
  }
701
1040
  declare const isSubset: (superObj: unknown, subObj: unknown) => boolean;
702
1041
  declare const assertFails: (message?: string) => never;
703
- declare const assertThrowsAsync: <TError extends Error>(fun: () => Promise<void>, errorCheck?: (error: Error) => boolean) => Promise<TError>;
704
- declare const assertThrows: <TError extends Error>(fun: () => void, errorCheck?: (error: Error) => boolean) => TError;
1042
+ declare const assertThrowsAsync: <TError extends Error>(fun: () => Promise<unknown>, errorCheck?: (error: TError) => boolean) => Promise<TError>;
1043
+ declare const assertThrows: <TError extends Error>(fun: () => void, errorCheck?: (error: TError) => boolean) => TError;
705
1044
  declare const assertDoesNotThrow: <TError extends Error>(fun: () => void, errorCheck?: (error: Error) => boolean) => TError | null;
706
1045
  declare const assertRejects: <T, TError extends Error = Error>(promise: Promise<T>, errorCheck?: ((error: TError) => boolean) | TError) => Promise<void>;
707
1046
  declare const assertMatches: (actual: unknown, expected: unknown, message?: string) => void;
708
1047
  declare const assertDeepEqual: <T = unknown>(actual: T, expected: T, message?: string) => void;
709
1048
  declare const assertNotDeepEqual: <T = unknown>(actual: T, expected: T, message?: string) => void;
710
1049
  declare const assertThat: <T>(item: T) => {
711
- isEqualTo: (other: T) => void;
1050
+ isEqualTo: (other: T) => void;
712
1051
  };
713
- declare const assertDefined: (value: unknown, message?: string | Error) => asserts value;
1052
+ declare function assertDefined<T>(value: T, message?: string | Error): asserts value is NonNullable<T>;
1053
+ declare function assertUndefined<T>(value: T | undefined, message?: string | Error): asserts value is undefined;
714
1054
  declare function assertFalse(condition: boolean, message?: string): asserts condition is false;
715
1055
  declare function assertTrue(condition: boolean, message?: string): asserts condition is true;
716
1056
  declare function assertOk<T>(obj: T | null | undefined, message?: string): asserts obj is T;
717
1057
  declare function assertEqual<T>(expected: T | null | undefined, actual: T | null | undefined, message?: string): void;
718
1058
  declare function assertNotEqual<T>(obj: T | null | undefined, other: T | null | undefined, message?: string): void;
719
- declare function assertIsNotNull<T extends object | bigint>(result: T | null): asserts result is T;
720
- declare function assertIsNull<T extends object>(result: T | null): asserts result is null;
1059
+ declare function assertIsNotNull<T extends object | string | bigint | boolean | number>(result: T | null): asserts result is T;
1060
+ declare function assertIsNull<T extends object | string | bigint | boolean | number>(result: T | null): asserts result is null;
721
1061
  type Call = {
722
- arguments: unknown[];
723
- result: unknown;
724
- target: unknown;
725
- this: unknown;
1062
+ arguments: unknown[];
1063
+ result: unknown;
1064
+ target: unknown;
1065
+ this: unknown;
726
1066
  };
727
1067
  type ArgumentMatcher = (arg: unknown) => boolean;
728
1068
  declare const argValue: <T>(value: T) => ArgumentMatcher;
729
1069
  declare const argMatches: <T>(matches: (arg: T) => boolean) => ArgumentMatcher;
730
1070
  type MockedFunction = Function & {
731
- mock?: {
732
- calls: Call[];
733
- };
1071
+ mock?: {
1072
+ calls: Call[];
1073
+ };
734
1074
  };
735
1075
  declare function verifyThat(fn: MockedFunction): {
736
- calledTimes: (times: number) => void;
737
- notCalled: () => void;
738
- called: () => void;
739
- calledWith: (...args: unknown[]) => void;
740
- calledOnceWith: (...args: unknown[]) => void;
741
- calledWithArgumentMatching: (...matches: ArgumentMatcher[]) => void;
742
- notCalledWithArgumentMatching: (...matches: ArgumentMatcher[]) => void;
1076
+ calledTimes: (times: number) => void;
1077
+ notCalled: () => void;
1078
+ called: () => void;
1079
+ calledWith: (...args: unknown[]) => void;
1080
+ calledOnceWith: (...args: unknown[]) => void;
1081
+ calledWithArgumentMatching: (...matches: ArgumentMatcher[]) => void;
1082
+ notCalledWithArgumentMatching: (...matches: ArgumentMatcher[]) => void;
743
1083
  };
744
1084
  declare const assertThatArray: <T>(array: T[]) => {
745
- isEmpty: () => void;
746
- isNotEmpty: () => void;
747
- hasSize: (length: number) => void;
748
- containsElements: (other: T[]) => void;
749
- containsElementsMatching: (other: T[]) => void;
750
- containsOnlyElementsMatching: (other: T[]) => void;
751
- containsExactlyInAnyOrder: (other: T[]) => void;
752
- containsExactlyInAnyOrderElementsOf: (other: T[]) => void;
753
- containsExactlyElementsOf: (other: T[]) => void;
754
- containsExactly: (elem: T) => void;
755
- contains: (elem: T) => void;
756
- containsOnlyOnceElementsOf: (other: T[]) => void;
757
- containsAnyOf: (other: T[]) => void;
758
- allMatch: (matches: (item: T) => boolean) => void;
759
- anyMatches: (matches: (item: T) => boolean) => void;
760
- allMatchAsync: (matches: (item: T) => Promise<boolean>) => Promise<void>;
761
- };
762
-
1085
+ isEmpty: () => void;
1086
+ isNotEmpty: () => void;
1087
+ hasSize: (length: number) => void;
1088
+ containsElements: (other: T[]) => void;
1089
+ containsElementsMatching: (other: T[]) => void;
1090
+ containsOnlyElementsMatching: (other: T[]) => void;
1091
+ containsExactlyInAnyOrder: (other: T[]) => void;
1092
+ containsExactlyInAnyOrderElementsOf: (other: T[]) => void;
1093
+ containsExactlyElementsOf: (other: T[]) => void;
1094
+ containsExactly: (elem: T) => void;
1095
+ contains: (elem: T) => void;
1096
+ containsOnlyOnceElementsOf: (other: T[]) => void;
1097
+ containsAnyOf: (other: T[]) => void;
1098
+ allMatch: (matches: (item: T) => boolean) => void;
1099
+ anyMatches: (matches: (item: T) => boolean) => void;
1100
+ allMatchAsync: (matches: (item: T) => Promise<boolean>) => Promise<void>;
1101
+ };
1102
+ //#endregion
1103
+ //#region src/testing/deciderSpecification.d.ts
763
1104
  type ErrorCheck<ErrorType> = (error: ErrorType) => boolean;
764
1105
  type ThenThrows<ErrorType extends Error> = (() => void) | ((errorConstructor: ErrorConstructor<ErrorType>) => void) | ((errorCheck: ErrorCheck<ErrorType>) => void) | ((errorConstructor: ErrorConstructor<ErrorType>, errorCheck?: ErrorCheck<ErrorType>) => void);
765
- type AsyncDeciderSpecification<Command, Event> = (givenEvents: Event | Event[]) => {
766
- when: (command: Command) => {
767
- then: (expectedEvents: Event | Event[]) => Promise<void>;
768
- thenNothingHappened: () => Promise<void>;
769
- thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
770
- };
771
- };
772
1106
  type DeciderSpecification<Command, Event> = (givenEvents: Event | Event[]) => {
773
- when: (command: Command) => {
774
- then: (expectedEvents: Event | Event[]) => void;
775
- thenNothingHappened: () => void;
776
- thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => void;
777
- };
1107
+ when: (command: Command) => {
1108
+ then: (expectedEvents: Event | Event[]) => void;
1109
+ thenNothingHappened: () => void;
1110
+ thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => void;
1111
+ };
1112
+ };
1113
+ type AsyncDeciderSpecification<Command, Event> = (givenEvents: Event | Event[]) => {
1114
+ when: (command: Command) => {
1115
+ then: (expectedEvents: Event | Event[]) => Promise<void>;
1116
+ thenNothingHappened: () => Promise<void>;
1117
+ thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
1118
+ };
778
1119
  };
779
1120
  declare const DeciderSpecification: {
780
- for: typeof deciderSpecificationFor;
1121
+ for: typeof deciderSpecificationFor;
781
1122
  };
782
1123
  declare function deciderSpecificationFor<Command, Event, State>(decider: {
783
- decide: (command: Command, state: State) => Event | Event[];
784
- evolve: (state: State, event: Event) => State;
785
- initialState: () => State;
1124
+ decide: (command: Command, state: State) => Event | Event[];
1125
+ evolve: (state: State, event: Event) => State;
1126
+ initialState: () => State;
786
1127
  }): DeciderSpecification<Command, Event>;
787
1128
  declare function deciderSpecificationFor<Command, Event, State>(decider: {
788
- decide: (command: Command, state: State) => Promise<Event | Event[]>;
789
- evolve: (state: State, event: Event) => State;
790
- initialState: () => State;
1129
+ decide: (command: Command, state: State) => Promise<Event | Event[]>;
1130
+ evolve: (state: State, event: Event) => State;
1131
+ initialState: () => State;
791
1132
  }): AsyncDeciderSpecification<Command, Event>;
792
-
1133
+ //#endregion
1134
+ //#region src/workflows/workflow.d.ts
1135
+ type Workflow<Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, Name extends string = string> = {
1136
+ name: Name;
1137
+ decide: (command: Input, state: State) => WorkflowOutput<Output>;
1138
+ evolve: (currentState: State, event: WorkflowEvent<Input | Output>) => State;
1139
+ initialState: () => State;
1140
+ };
793
1141
  type WorkflowEvent<Output extends AnyEvent | AnyCommand> = Extract<Output, {
794
- kind?: 'Event';
1142
+ kind?: 'Event';
795
1143
  }>;
796
1144
  type WorkflowCommand<Output extends AnyEvent | AnyCommand> = Extract<Output, {
797
- kind?: 'Command';
1145
+ kind?: 'Command';
798
1146
  }>;
799
1147
  type WorkflowMessageAction = 'InitiatedBy' | 'Received' | 'Sent' | 'Published' | 'Scheduled';
800
1148
  type WorkflowInputMessageMetadata = Readonly<{
801
- originalMessageId: string | undefined;
802
- input: true;
803
- action?: Extract<WorkflowMessageAction, 'InitiatedBy' | 'Received'>;
1149
+ originalMessageId: string | undefined;
1150
+ input: true;
1151
+ action?: Extract<WorkflowMessageAction, 'InitiatedBy' | 'Received'>;
804
1152
  }>;
805
1153
  type WorkflowOutputMessageMetadata = Readonly<{
806
- action?: Extract<WorkflowMessageAction, 'Sent' | 'Published' | 'Scheduled'>;
1154
+ action?: Extract<WorkflowMessageAction, 'Sent' | 'Published' | 'Scheduled'>;
807
1155
  }>;
808
1156
  type WorkflowOutput<Output extends AnyEvent | AnyCommand | EmmettError> = Output | Output[];
809
- type Workflow<Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, Name extends string = string> = {
810
- name: Name;
811
- decide: (command: Input, state: State) => WorkflowOutput<Output>;
812
- evolve: (currentState: State, event: WorkflowEvent<Input | Output>) => State;
813
- initialState: () => State;
814
- };
815
1157
  declare const Workflow: <Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand>(workflow: Workflow<Input, State, Output>) => Workflow<Input, State, Output>;
816
-
1158
+ //#endregion
1159
+ //#region src/testing/workflowSpecification.d.ts
817
1160
  type WorkflowSpecification<Input extends AnyEvent | AnyCommand, Output extends AnyEvent | AnyCommand> = (givenEvents: WorkflowEvent<Input | Output> | WorkflowEvent<Input | Output>[]) => {
818
- when: (input: Input) => {
819
- then: (expectedOutput: Output | Output[]) => void;
820
- thenNothingHappened: () => void;
821
- thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => void;
822
- };
1161
+ when: (input: Input) => {
1162
+ then: (expectedOutput: Output | Output[]) => void;
1163
+ thenNothingHappened: () => void;
1164
+ thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => void;
1165
+ };
823
1166
  };
824
1167
  declare const WorkflowSpecification: {
825
- for: typeof workflowSpecificationFor;
1168
+ for: typeof workflowSpecificationFor;
826
1169
  };
827
1170
  declare function workflowSpecificationFor<Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand>(workflow: Workflow<Input, State, Output>): WorkflowSpecification<Input, Output>;
828
-
829
- type TestEventStream<EventType extends Event = Event> = [
830
- string,
831
- EventType[]
832
- ];
1171
+ //#endregion
1172
+ //#region src/testing/wrapEventStore.d.ts
1173
+ type TestEventStream<EventType extends Event = Event> = [string, EventType[]];
833
1174
  type EventStoreWrapper<Store extends EventStore> = Store & {
834
- appendedEvents: Map<string, TestEventStream>;
835
- setup<EventType extends Event>(streamName: string, events: EventType[]): Promise<AppendToStreamResult>;
1175
+ appendedEvents: Map<string, TestEventStream>;
1176
+ setup<EventType extends Event>(streamName: string, events: EventType[]): Promise<AppendToStreamResult>;
836
1177
  };
837
1178
  declare const WrapEventStore: <Store extends EventStore>(eventStore: Store) => EventStoreWrapper<Store>;
838
-
1179
+ //#endregion
1180
+ //#region src/eventStore/projections/inMemory/inMemoryProjectionSpec.d.ts
839
1181
  type DocumentWithId = Document & {
840
- _id?: string | number;
1182
+ _id?: string | number;
841
1183
  };
842
1184
  type InMemoryProjectionSpecEvent<EventType extends Event, EventMetaDataType extends InMemoryReadEventMetadata = InMemoryReadEventMetadata> = EventType & {
843
- metadata?: Partial<EventMetaDataType>;
1185
+ metadata?: Partial<EventMetaDataType>;
844
1186
  };
845
1187
  type InMemoryProjectionSpecWhenOptions = {
846
- numberOfTimes: number;
1188
+ numberOfTimes: number;
1189
+ };
1190
+ type InMemoryProjectionSpec<EventType extends Event> = (givenEvents: InMemoryProjectionSpecEvent<EventType>[]) => {
1191
+ when: (events: InMemoryProjectionSpecEvent<EventType>[], options?: InMemoryProjectionSpecWhenOptions) => {
1192
+ then: (assert: InMemoryProjectionAssert, message?: string) => Promise<void>;
1193
+ thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
1194
+ };
847
1195
  };
848
1196
  type InMemoryProjectionAssert = (options: {
849
- database: InMemoryDatabase;
1197
+ database: InMemoryDatabase;
850
1198
  }) => Promise<void | boolean>;
851
1199
  type InMemoryProjectionSpecOptions<EventType extends Event> = {
852
- projection: InMemoryProjectionDefinition<EventType>;
853
- };
854
- type InMemoryProjectionSpec<EventType extends Event> = (givenEvents: InMemoryProjectionSpecEvent<EventType>[]) => {
855
- when: (events: InMemoryProjectionSpecEvent<EventType>[], options?: InMemoryProjectionSpecWhenOptions) => {
856
- then: (assert: InMemoryProjectionAssert, message?: string) => Promise<void>;
857
- thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
858
- };
1200
+ projection: InMemoryProjectionDefinition<EventType>;
859
1201
  };
860
1202
  declare const InMemoryProjectionSpec: {
861
- for: <EventType extends Event>(options: InMemoryProjectionSpecOptions<EventType>) => InMemoryProjectionSpec<EventType>;
1203
+ for: <EventType extends Event>(options: InMemoryProjectionSpecOptions<EventType>) => InMemoryProjectionSpec<EventType>;
862
1204
  };
863
1205
  declare const eventInStream: <EventType extends Event = Event, EventMetaDataType extends InMemoryReadEventMetadata = InMemoryReadEventMetadata>(streamName: string, event: InMemoryProjectionSpecEvent<EventType, EventMetaDataType>) => InMemoryProjectionSpecEvent<EventType, EventMetaDataType>;
864
1206
  declare const eventsInStream: <EventType extends Event = Event, EventMetaDataType extends InMemoryReadEventMetadata = InMemoryReadEventMetadata>(streamName: string, events: InMemoryProjectionSpecEvent<EventType, EventMetaDataType>[]) => InMemoryProjectionSpecEvent<EventType, EventMetaDataType>[];
865
1207
  declare const newEventsInStream: <EventType extends Event = Event, EventMetaDataType extends InMemoryReadEventMetadata = RecordedMessageMetadataWithGlobalPosition>(streamName: string, events: InMemoryProjectionSpecEvent<EventType, EventMetaDataType>[]) => InMemoryProjectionSpecEvent<EventType, EventMetaDataType>[];
866
1208
  declare function documentExists<T extends DocumentWithId>(expected: Partial<T>, options: {
867
- inCollection: string;
868
- withId: string | number;
1209
+ inCollection: string;
1210
+ withId: string | number;
869
1211
  }): InMemoryProjectionAssert;
870
1212
  declare const expectInMemoryDocuments: {
871
- fromCollection: <T extends DocumentWithId>(collectionName: string) => {
872
- withId: (id: string | number) => {
873
- toBeEqual: (expected: Partial<T>) => InMemoryProjectionAssert;
874
- };
1213
+ fromCollection: <T extends DocumentWithId>(collectionName: string) => {
1214
+ withId: (id: string | number) => {
1215
+ toBeEqual: (expected: Partial<T>) => InMemoryProjectionAssert;
875
1216
  };
1217
+ };
876
1218
  };
877
-
1219
+ //#endregion
1220
+ //#region src/eventStore/versioning/downcasting.d.ts
878
1221
  type MessageDowncast<MessageType extends AnyMessage, MessagePayloadType extends AnyMessage = MessageType, RecordedMessageMetadataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = ((message: RecordedMessage<MessageType, RecordedMessageMetadataType>) => RecordedMessage<MessagePayloadType, RecordedMessageMetadataType>) | ((message: MessageType) => MessagePayloadType);
879
1222
  declare const downcastRecordedMessage: <MessageType extends AnyMessage, MessagePayloadType extends AnyMessage = MessageType, RecordedMessageMetadataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata>(recordedMessage: RecordedMessage<MessageType, RecordedMessageMetadataType> | MessageType, options?: {
880
- downcast?: MessageDowncast<MessageType, MessagePayloadType, RecordedMessageMetadataType>;
1223
+ downcast?: MessageDowncast<MessageType, MessagePayloadType, RecordedMessageMetadataType>;
881
1224
  }) => RecordedMessage<MessagePayloadType, RecordedMessageMetadataType>;
882
1225
  declare const downcastRecordedMessages: <MessageType extends AnyMessage, MessagePayloadType extends AnyMessage = MessageType, RecordedMessageMetadataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata>(recordedMessages: RecordedMessage<MessageType, RecordedMessageMetadataType>[] | MessageType[], options?: {
883
- downcast?: MessageDowncast<MessageType, MessagePayloadType, RecordedMessageMetadataType>;
1226
+ downcast?: MessageDowncast<MessageType, MessagePayloadType, RecordedMessageMetadataType>;
884
1227
  }) => RecordedMessage<MessagePayloadType, RecordedMessageMetadataType>[];
885
-
1228
+ //#endregion
1229
+ //#region src/eventStore/versioning/upcasting.d.ts
886
1230
  type MessageUpcast<MessageType extends AnyMessage, MessagePayloadType extends AnyMessage = MessageType, RecordedMessageMetadataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata> = ((message: MessagePayloadType) => MessageType) | ((message: RecordedMessage<MessagePayloadType, RecordedMessageMetadataType>) => RecordedMessage<MessageType, RecordedMessageMetadataType>);
887
1231
  declare const upcastRecordedMessage: <MessageType extends AnyMessage, MessagePayloadType extends AnyMessage = MessageType, RecordedMessageMetadataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata>(recordedMessage: RecordedMessage<MessagePayloadType, RecordedMessageMetadataType> | MessagePayloadType, options?: {
888
- upcast?: MessageUpcast<MessageType, MessagePayloadType, RecordedMessageMetadataType>;
1232
+ upcast?: MessageUpcast<MessageType, MessagePayloadType, RecordedMessageMetadataType>;
889
1233
  }) => RecordedMessage<MessageType, RecordedMessageMetadataType>;
890
1234
  declare const upcastRecordedMessages: <MessageType extends AnyMessage, MessagePayloadType extends AnyMessage = MessageType, RecordedMessageMetadataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata>(recordedMessages: RecordedMessage<MessagePayloadType, RecordedMessageMetadataType>[] | MessagePayloadType[], options?: {
891
- upcast?: MessageUpcast<MessageType, MessagePayloadType, RecordedMessageMetadataType>;
1235
+ upcast?: MessageUpcast<MessageType, MessagePayloadType, RecordedMessageMetadataType>;
892
1236
  }) => RecordedMessage<MessageType, RecordedMessageMetadataType>[];
893
-
1237
+ //#endregion
1238
+ //#region src/utils/async/mapAsync.d.ts
1239
+ declare function reduceAsync<T, R>(items: T[], fn: (accumulator: R, item: T, index: number) => Promise<R>, initial: R): Promise<R>;
1240
+ //#endregion
1241
+ //#region src/utils/closeable.d.ts
894
1242
  type Closeable = {
895
- /**
896
- * Gracefully cleans up managed resources
897
- *
898
- * @memberof Closeable
899
- */
900
- close: () => Promise<void>;
901
- };
902
-
1243
+ /**
1244
+ * Gracefully cleans up managed resources
1245
+ *
1246
+ * @memberof Closeable
1247
+ */
1248
+ close: () => Promise<void>;
1249
+ };
1250
+ //#endregion
1251
+ //#region src/utils/collections/merge.d.ts
903
1252
  declare const merge: <T>(array: T[], item: T, where: (current: T) => boolean, onExisting: (current: T) => T, onNotFound?: () => T | undefined) => T[];
904
-
1253
+ //#endregion
1254
+ //#region src/utils/collections/index.d.ts
905
1255
  declare const arrayUtils: {
906
- merge: <T>(array: T[], item: T, where: (current: T) => boolean, onExisting: (current: T) => T, onNotFound?: () => T | undefined) => T[];
907
- hasDuplicates: <ArrayItem, Mapped>(array: ArrayItem[], predicate: (value: ArrayItem, index: number, array: ArrayItem[]) => Mapped) => boolean;
908
- getDuplicates: <ArrayItem, Mapped>(array: ArrayItem[], predicate: (value: ArrayItem, index: number, array: ArrayItem[]) => Mapped) => ArrayItem[];
1256
+ merge: <T>(array: T[], item: T, where: (current: T) => boolean, onExisting: (current: T) => T, onNotFound?: () => T | undefined) => T[];
1257
+ hasDuplicates: <ArrayItem, Mapped>(array: ArrayItem[], predicate: (value: ArrayItem, index: number, array: ArrayItem[]) => Mapped) => boolean;
1258
+ getDuplicates: <ArrayItem, Mapped>(array: ArrayItem[], predicate: (value: ArrayItem, index: number, array: ArrayItem[]) => Mapped) => ArrayItem[];
909
1259
  };
910
-
1260
+ //#endregion
1261
+ //#region src/utils/deepEquals.d.ts
911
1262
  declare const deepEquals: <T>(left: T, right: T) => boolean;
912
1263
  type Equatable<T> = {
913
- equals: (right: T) => boolean;
1264
+ equals: (right: T) => boolean;
914
1265
  } & T;
915
1266
  declare const isEquatable: <T>(left: T) => left is Equatable<T>;
916
-
1267
+ //#endregion
1268
+ //#region src/utils/iterators.d.ts
917
1269
  declare const sum: (iterator: Iterator<number, number, number> | Iterator<number>) => number;
918
-
1270
+ //#endregion
1271
+ //#region src/utils/locking/index.d.ts
919
1272
  type LockOptions = {
920
- lockId: number;
1273
+ lockId: number;
921
1274
  };
922
1275
  type AcquireLockOptions = {
923
- lockId: string;
1276
+ lockId: string;
924
1277
  };
925
1278
  type ReleaseLockOptions = {
926
- lockId: string;
1279
+ lockId: string;
927
1280
  };
928
1281
  type Lock = {
929
- acquire(options: AcquireLockOptions): Promise<void>;
930
- tryAcquire(options: AcquireLockOptions): Promise<boolean>;
931
- release(options: ReleaseLockOptions): Promise<boolean>;
932
- withAcquire: <Result = unknown>(handle: () => Promise<Result>, options: AcquireLockOptions) => Promise<Result>;
1282
+ acquire(options: AcquireLockOptions): Promise<void>;
1283
+ tryAcquire(options: AcquireLockOptions): Promise<boolean>;
1284
+ release(options: ReleaseLockOptions): Promise<boolean>;
1285
+ withAcquire: <Result = unknown>(handle: () => Promise<Result>, options: AcquireLockOptions) => Promise<Result>;
933
1286
  };
934
1287
  declare const InProcessLock: () => Lock;
935
-
1288
+ //#endregion
1289
+ //#region src/utils/numbers/bigint.d.ts
936
1290
  declare const toNormalizedString: (value: bigint) => string;
937
1291
  declare const bigInt: {
938
- toNormalizedString: (value: bigint) => string;
1292
+ toNormalizedString: (value: bigint) => string;
939
1293
  };
940
-
1294
+ //#endregion
1295
+ //#region src/utils/promises.d.ts
941
1296
  declare const delay: (ms: number) => Promise<void>;
942
1297
  type AsyncAwaiter<T = void> = {
943
- wait: Promise<T>;
944
- resolve: (value: T | PromiseLike<T>) => void;
945
- reject: (reason?: any) => void;
946
- reset: () => void;
1298
+ wait: Promise<T>;
1299
+ resolve: (value: T | PromiseLike<T>) => void;
1300
+ reject: (reason?: any) => void;
1301
+ reset: () => void;
947
1302
  };
948
1303
  declare const asyncAwaiter: <T = void>() => AsyncAwaiter<T>;
949
-
1304
+ //#endregion
1305
+ //#region src/utils/retry.d.ts
950
1306
  type AsyncRetryOptions<T = unknown> = retry.Options & {
951
- shouldRetryResult?: (result: T) => boolean;
952
- shouldRetryError?: (error?: unknown) => boolean;
1307
+ shouldRetryResult?: (result: T) => boolean;
1308
+ shouldRetryError?: (error?: unknown) => boolean;
953
1309
  };
954
1310
  declare const NoRetries: AsyncRetryOptions;
955
1311
  declare const asyncRetry: <T>(fn: () => Promise<T>, opts?: AsyncRetryOptions<T>) => Promise<T>;
956
-
1312
+ //#endregion
1313
+ //#region src/utils/shutdown/gracefulShutdown.d.ts
957
1314
  type ShutdownHandler = () => void | Promise<void>;
958
1315
  /**
959
1316
  * Registers handlers for OS signals to enable graceful shutdown.
@@ -964,113 +1321,160 @@ type ShutdownHandler = () => void | Promise<void>;
964
1321
  * @returns Cleanup function to unregister the handlers
965
1322
  */
966
1323
  declare const onShutdown: (handler: ShutdownHandler) => (() => void);
967
-
1324
+ //#endregion
1325
+ //#region src/utils/strings/hashText.d.ts
968
1326
  declare const hashText: (text: string) => Promise<bigint>;
969
-
1327
+ //#endregion
1328
+ //#region src/commandHandling/observability/commandHandlerCollector.d.ts
1329
+ type CommandObservabilityConfig = Pick<EmmettObservabilityConfig, 'tracer' | 'meter' | 'attributeTarget' | 'includeMessagePayloads'>;
1330
+ //#endregion
1331
+ //#region src/commandHandling/handleCommand.d.ts
970
1332
  declare const CommandHandlerStreamVersionConflictRetryOptions: AsyncRetryOptions;
971
1333
  type CommandHandlerRetryOptions = AsyncRetryOptions | {
972
- onVersionConflict: true | number | AsyncRetryOptions;
1334
+ onVersionConflict: true | number | AsyncRetryOptions;
973
1335
  };
974
1336
  type CommandHandlerResult<State, StreamEvent extends Event, Store extends EventStore> = AppendStreamResultOfEventStore<Store> & {
975
- newState: State;
976
- newEvents: StreamEvent[];
1337
+ newState: State;
1338
+ newEvents: StreamEvent[];
977
1339
  };
978
1340
  type CommandHandlerOptions<State, StreamEvent extends Event, StoredEvent extends Event = StreamEvent> = {
979
- evolve: (state: State, event: StreamEvent) => State;
980
- initialState: () => State;
981
- mapToStreamId?: (id: string) => string;
982
- retry?: CommandHandlerRetryOptions;
983
- schema?: {
984
- versioning?: {
985
- upcast?: (event: StoredEvent) => StreamEvent;
986
- downcast?: (event: StreamEvent) => StoredEvent;
987
- };
1341
+ evolve: (state: State, event: StreamEvent) => State;
1342
+ initialState: () => State;
1343
+ mapToStreamId?: (id: string) => string;
1344
+ retry?: CommandHandlerRetryOptions;
1345
+ schema?: {
1346
+ versioning?: {
1347
+ upcast?: (event: StoredEvent) => StreamEvent;
1348
+ downcast?: (event: StreamEvent) => StoredEvent;
988
1349
  };
1350
+ };
1351
+ name?: string;
1352
+ commandType?: string | string[];
1353
+ } & JSONSerializationOptions & {
1354
+ observability?: CommandObservabilityConfig;
989
1355
  };
990
1356
  type HandleOptions<Store extends EventStore> = Parameters<Store['appendToStream']>[2] & ({
991
- expectedStreamVersion?: ExpectedStreamVersion;
1357
+ expectedStreamVersion?: ExpectedStreamVersion;
992
1358
  } | {
993
- retry?: CommandHandlerRetryOptions;
994
- });
1359
+ retry?: CommandHandlerRetryOptions;
1360
+ }) & {
1361
+ commandType?: string | string[];
1362
+ observability?: {
1363
+ traceId?: string;
1364
+ spanId?: string;
1365
+ correlationId?: string;
1366
+ causationId?: string;
1367
+ };
1368
+ };
995
1369
  type CommandHandlerFunction<State, StreamEvent extends Event> = (state: State) => StreamEvent | StreamEvent[] | Promise<StreamEvent | StreamEvent[]>;
996
1370
  declare const CommandHandler: <State, StreamEvent extends Event, EventPayloadType extends Event = StreamEvent>(options: CommandHandlerOptions<State, StreamEvent, EventPayloadType>) => <Store extends EventStore>(store: Store, id: string, handle: CommandHandlerFunction<State, StreamEvent> | CommandHandlerFunction<State, StreamEvent>[], handleOptions?: HandleOptions<Store>) => Promise<CommandHandlerResult<State, StreamEvent, Store>>;
997
-
1371
+ //#endregion
1372
+ //#region src/commandHandling/handleCommandWithDecider.d.ts
998
1373
  type DeciderCommandHandlerOptions<State, CommandType extends Command, StreamEvent extends Event> = CommandHandlerOptions<State, StreamEvent> & Decider<State, CommandType, StreamEvent>;
999
1374
  declare const DeciderCommandHandler: <State, CommandType extends Command, StreamEvent extends Event>(options: DeciderCommandHandlerOptions<State, CommandType, StreamEvent>) => <Store extends EventStore>(eventStore: Store, id: string, commands: CommandType | CommandType[], handleOptions?: HandleOptions<Store>) => Promise<CommandHandlerResult<State, StreamEvent, Store>>;
1000
-
1375
+ //#endregion
1376
+ //#region src/consumers/consumers.d.ts
1001
1377
  type MessageConsumerOptions<ConsumerMessageType extends Message = any> = {
1002
- consumerId?: string;
1003
- processors?: Array<MessageProcessor<ConsumerMessageType, any, any>>;
1378
+ consumerId?: string;
1379
+ processors?: Array<MessageProcessor<ConsumerMessageType, any, any>>;
1004
1380
  };
1005
1381
  type MessageConsumer<ConsumerMessageType extends Message = any> = Readonly<{
1006
- consumerId: string;
1007
- isRunning: boolean;
1008
- processors: ReadonlyArray<MessageProcessor<ConsumerMessageType, any, any>>;
1009
- start: () => Promise<void>;
1010
- stop: () => Promise<void>;
1011
- close: () => Promise<void>;
1382
+ consumerId: string;
1383
+ isRunning: boolean;
1384
+ whenStarted: () => Promise<void>;
1385
+ processors: ReadonlyArray<MessageProcessor<ConsumerMessageType, any, any>>;
1386
+ start: () => Promise<void>;
1387
+ stop: () => Promise<void>;
1388
+ close: () => Promise<void>;
1012
1389
  }>;
1013
-
1014
- declare class ParseError extends Error {
1015
- constructor(text: string);
1016
- }
1017
- type Mapper<From, To = From> = ((value: unknown) => To) | ((value: Partial<From>) => To) | ((value: From) => To) | ((value: Partial<To>) => To) | ((value: To) => To) | ((value: Partial<To | From>) => To) | ((value: To | From) => To);
1018
- type MapperArgs<From, To = From> = Partial<From> & From & Partial<To> & To;
1019
- type ParseOptions<From, To = From> = {
1020
- reviver?: (key: string, value: unknown) => unknown;
1021
- map?: Mapper<From, To>;
1022
- typeCheck?: <To>(value: unknown) => value is To;
1023
- };
1024
- type StringifyOptions<From, To = From> = {
1025
- map?: Mapper<From, To>;
1026
- };
1027
- declare const JSONParser: {
1028
- stringify: <From, To = From>(value: From, options?: StringifyOptions<From, To>) => string;
1029
- parse: <From, To = From>(text: string, options?: ParseOptions<From, To>) => To | undefined;
1030
- };
1031
-
1390
+ //#endregion
1391
+ //#region src/taskProcessing/executionGuards.d.ts
1392
+ type ExclusiveAccessGuard = {
1393
+ execute: <Result>(operation: () => Promise<Result>) => Promise<Result>;
1394
+ waitForIdle: () => Promise<void>;
1395
+ stop: (options?: {
1396
+ force?: boolean;
1397
+ }) => Promise<void>;
1398
+ };
1399
+ declare const guardExclusiveAccess: (options?: {
1400
+ maxQueueSize?: number;
1401
+ }) => ExclusiveAccessGuard;
1402
+ type BoundedAccessGuard<Resource> = {
1403
+ acquire: () => Promise<Resource>;
1404
+ release: (resource: Resource) => void;
1405
+ execute: <Result>(operation: (resource: Resource) => Promise<Result>) => Promise<Result>;
1406
+ waitForIdle: () => Promise<void>;
1407
+ stop: (options?: {
1408
+ force?: boolean;
1409
+ }) => Promise<void>;
1410
+ };
1411
+ declare const guardBoundedAccess: <Resource>(getResource: () => Resource | Promise<Resource>, options: {
1412
+ maxResources: number;
1413
+ maxQueueSize?: number;
1414
+ reuseResources?: boolean;
1415
+ closeResource?: (resource: Resource) => void | Promise<void>;
1416
+ }) => BoundedAccessGuard<Resource>;
1417
+ type InitializedOnceGuard<T> = {
1418
+ ensureInitialized: () => Promise<T>;
1419
+ reset: () => void;
1420
+ stop: (options?: {
1421
+ force?: boolean;
1422
+ }) => Promise<void>;
1423
+ };
1424
+ declare const guardInitializedOnce: <T>(initialize: () => Promise<T>, options?: {
1425
+ maxQueueSize?: number;
1426
+ maxRetries?: number;
1427
+ }) => InitializedOnceGuard<T>;
1428
+ //#endregion
1429
+ //#region src/taskProcessing/taskProcessor.d.ts
1032
1430
  type TaskQueue = TaskQueueItem[];
1033
1431
  type TaskQueueItem = {
1034
- task: () => Promise<void>;
1035
- options?: EnqueueTaskOptions;
1432
+ task: () => Promise<void>;
1433
+ options?: EnqueueTaskOptions | undefined;
1036
1434
  };
1037
1435
  type TaskProcessorOptions = {
1038
- maxActiveTasks: number;
1039
- maxQueueSize: number;
1040
- maxTaskIdleTime?: number;
1436
+ maxActiveTasks: number;
1437
+ maxQueueSize: number;
1438
+ maxTaskIdleTime?: number;
1041
1439
  };
1042
1440
  type Task<T> = (context: TaskContext) => Promise<T>;
1043
1441
  type TaskContext = {
1044
- ack: () => void;
1442
+ ack: () => void;
1045
1443
  };
1046
1444
  type EnqueueTaskOptions = {
1047
- taskGroupId?: string;
1445
+ taskGroupId?: string;
1048
1446
  };
1049
1447
  declare class TaskProcessor {
1050
- private options;
1051
- private queue;
1052
- private isProcessing;
1053
- private activeTasks;
1054
- private activeGroups;
1055
- constructor(options: TaskProcessorOptions);
1056
- enqueue<T>(task: Task<T>, options?: EnqueueTaskOptions): Promise<T>;
1057
- waitForEndOfProcessing(): Promise<void>;
1058
- private schedule;
1059
- private ensureProcessing;
1060
- private processQueue;
1061
- private executeItem;
1062
- private takeFirstAvailableItem;
1063
- private hasItemsToProcess;
1448
+ private queue;
1449
+ private isProcessing;
1450
+ private activeTasks;
1451
+ private activeGroups;
1452
+ private options;
1453
+ private stopped;
1454
+ constructor(options: TaskProcessorOptions);
1455
+ enqueue<T>(task: Task<T>, options?: EnqueueTaskOptions): Promise<T>;
1456
+ waitForEndOfProcessing(): Promise<void>;
1457
+ stop(options?: {
1458
+ force?: boolean;
1459
+ }): Promise<void>;
1460
+ private schedule;
1461
+ private ensureProcessing;
1462
+ private processQueue;
1463
+ private executeItem;
1464
+ private takeFirstAvailableItem;
1465
+ private hasItemsToProcess;
1064
1466
  }
1065
-
1467
+ //#endregion
1468
+ //#region src/validation/dates.d.ts
1066
1469
  declare const formatDateToUtcYYYYMMDD: (date: Date) => string;
1067
1470
  declare const isValidYYYYMMDD: (dateString: string) => boolean;
1068
1471
  declare const parseDateFromUtcYYYYMMDD: (dateString: string) => Date;
1069
-
1472
+ //#endregion
1473
+ //#region src/validation/index.d.ts
1070
1474
  declare const enum ValidationErrors {
1071
- NOT_A_NONEMPTY_STRING = "NOT_A_NONEMPTY_STRING",
1072
- NOT_A_POSITIVE_NUMBER = "NOT_A_POSITIVE_NUMBER",
1073
- NOT_AN_UNSIGNED_BIGINT = "NOT_AN_UNSIGNED_BIGINT"
1475
+ NOT_A_NONEMPTY_STRING = "NOT_A_NONEMPTY_STRING",
1476
+ NOT_A_POSITIVE_NUMBER = "NOT_A_POSITIVE_NUMBER",
1477
+ NOT_AN_UNSIGNED_BIGINT = "NOT_AN_UNSIGNED_BIGINT"
1074
1478
  }
1075
1479
  declare const isNumber: (val: unknown) => val is number;
1076
1480
  declare const isBigint: (val: any) => val is bigint;
@@ -1078,59 +1482,85 @@ declare const isString: (val: unknown) => val is string;
1078
1482
  declare const assertNotEmptyString: (value: unknown) => string;
1079
1483
  declare const assertPositiveNumber: (value: unknown) => number;
1080
1484
  declare const assertUnsignedBigInt: (value: string) => bigint;
1081
-
1485
+ //#endregion
1486
+ //#region src/workflows/workflowProcessor.d.ts
1082
1487
  type WorkflowOptions<Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, StoredMessage extends AnyEvent | AnyCommand = Output> = {
1083
- workflow: Workflow<Input, State, Output>;
1084
- getWorkflowId: (input: Input | RecordedMessage<Input, MessageMetadataType>) => string | null;
1085
- mapWorkflowId?: (workflowId: string) => string;
1086
- separateInputInboxFromProcessing?: boolean;
1087
- inputs: {
1088
- commands: CanHandle<WorkflowCommand<Input>>;
1089
- events: CanHandle<WorkflowEvent<Input>>;
1090
- };
1091
- outputs: {
1092
- commands: MessageTypeOf<WorkflowCommand<Output>>[];
1093
- events: MessageTypeOf<WorkflowEvent<Output>>[];
1094
- };
1095
- schema?: {
1096
- versioning?: {
1097
- upcast?: (event: StoredMessage) => Input;
1098
- downcast?: (event: Output) => StoredMessage;
1099
- };
1100
- };
1101
- };
1102
- type WorkflowProcessorContext = {
1103
- connection: {
1104
- messageStore: EventStore;
1488
+ workflow: Workflow<Input, State, Output>;
1489
+ getWorkflowId: (input: Input | RecordedMessage<Input, MessageMetadataType>) => string | null;
1490
+ mapWorkflowId?: (workflowId: string) => string;
1491
+ separateInputInboxFromProcessing?: boolean;
1492
+ inputs: {
1493
+ commands: CanHandle<WorkflowCommand<Input>>;
1494
+ events: CanHandle<WorkflowEvent<Input>>;
1495
+ };
1496
+ outputs: {
1497
+ commands: MessageTypeOf<WorkflowCommand<Output>>[];
1498
+ events: MessageTypeOf<WorkflowEvent<Output>>[];
1499
+ };
1500
+ schema?: {
1501
+ versioning?: {
1502
+ upcast?: (event: StoredMessage) => Input;
1503
+ downcast?: (event: Output) => StoredMessage;
1105
1504
  };
1505
+ };
1106
1506
  };
1107
- type WorkflowProcessorOptions<Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext, StoredMessage extends AnyEvent | AnyCommand = Output> = Omit<BaseMessageProcessorOptions<Input | Output, MessageMetadataType, HandlerContext>, 'type' | 'canHandle' | 'processorId'> & {
1108
- processorId?: string;
1507
+ type WorkflowProcessorContext = MessageHandlerContext<{
1508
+ connection: {
1509
+ messageStore: EventStore;
1510
+ };
1511
+ }>;
1512
+ type WorkflowOutputHandlerResult<Input extends AnyEvent | AnyCommand> = Promise<Input | Input[] | EmmettError | [] | void> | Input | Input[] | EmmettError | [] | void;
1513
+ type SingleWorkflowOutputHandler<Input extends AnyEvent | AnyCommand, Output extends AnyEvent | AnyCommand, MessageMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext> = (message: Output | RecordedMessage<Output, MessageMetaDataType>, context: HandlerContext) => WorkflowOutputHandlerResult<Input>;
1514
+ type BatchWorkflowOutputHandler<Input extends AnyEvent | AnyCommand, Output extends AnyEvent | AnyCommand, MessageMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext> = (messages: RecordedMessage<Output, MessageMetaDataType>[], context: HandlerContext) => WorkflowOutputHandlerResult<Input>;
1515
+ type WorkflowOutputHandlerOptions<Input extends AnyEvent | AnyCommand, Output extends AnyEvent | AnyCommand, MessageMetaDataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext> = {
1516
+ eachMessage: SingleWorkflowOutputHandler<Input, Output, MessageMetaDataType, HandlerContext>;
1517
+ eachBatch?: never;
1518
+ } | {
1519
+ eachMessage?: never;
1520
+ eachBatch: BatchWorkflowOutputHandler<Input, Output, MessageMetaDataType, HandlerContext>;
1521
+ };
1522
+ type WorkflowOutputHandlerDefinition<Input extends AnyEvent | AnyCommand, Output extends AnyEvent | AnyCommand, HandledOutput extends Output = Output, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext> = {
1523
+ canHandle: CanHandle<HandledOutput>;
1524
+ } & WorkflowOutputHandlerOptions<Input, HandledOutput, MessageMetadataType, HandlerContext>;
1525
+ declare const workflowOutputHandler: <Input extends AnyEvent | AnyCommand, Output extends AnyEvent | AnyCommand, HandledOutput extends Output = Output, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext>(handler: WorkflowOutputHandlerDefinition<Input, Output, HandledOutput, MessageMetadataType, HandlerContext>) => WorkflowOutputHandlerDefinition<Input, Output, HandledOutput, MessageMetadataType, HandlerContext>;
1526
+ type WorkflowProcessorOptions<Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext, StoredMessage extends AnyEvent | AnyCommand = Output, HandledOutput extends Output = Output> = Omit<BaseMessageProcessorOptions<Input | Output, MessageMetadataType, HandlerContext>, 'type' | 'canHandle' | 'processorId'> & {
1527
+ processorId?: string;
1109
1528
  } & WorkflowOptions<Input, State, Output, MessageMetadataType, StoredMessage> & {
1110
- retry?: WorkflowHandlerRetryOptions;
1529
+ retry?: WorkflowHandlerRetryOptions;
1530
+ outputHandler?: WorkflowOutputHandlerDefinition<Input, Output, HandledOutput, MessageMetadataType, HandlerContext>;
1111
1531
  };
1112
1532
  declare const getWorkflowId: (options: {
1113
- workflowName: string;
1533
+ workflowName: string;
1114
1534
  }) => string;
1115
- declare const workflowProcessor: <Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext, StoredMessage extends AnyEvent | AnyCommand = Output>(options: WorkflowProcessorOptions<Input, State, Output, MetaDataType, HandlerContext, StoredMessage>) => MessageProcessor<Input, MetaDataType, HandlerContext>;
1116
-
1535
+ declare const workflowProcessor: <Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext, StoredMessage extends AnyEvent | AnyCommand = Output, HandledOutput extends Output = Output>(options: WorkflowProcessorOptions<Input, State, Output, MetaDataType, HandlerContext, StoredMessage, HandledOutput>) => MessageProcessor<Input, MetaDataType, HandlerContext>;
1536
+ //#endregion
1537
+ //#region src/workflows/handleWorkflow.d.ts
1117
1538
  declare const WorkflowHandlerStreamVersionConflictRetryOptions: AsyncRetryOptions;
1118
1539
  type WorkflowHandlerRetryOptions = AsyncRetryOptions | {
1119
- onVersionConflict: true | number | AsyncRetryOptions;
1540
+ onVersionConflict: true | number | AsyncRetryOptions;
1120
1541
  };
1121
1542
  type WorkflowHandlerResult<Output extends AnyEvent | AnyCommand, Store extends EventStore> = AppendStreamResultOfEventStore<Store> & {
1122
- newMessages: Output[];
1543
+ newMessages: Output[];
1123
1544
  };
1124
1545
  type WorkflowHandleOptions<Store extends EventStore> = Parameters<Store['appendToStream']>[2] & {
1125
- expectedStreamVersion?: ExpectedStreamVersion;
1126
- retry?: WorkflowHandlerRetryOptions;
1127
- };
1128
- declare const workflowStreamName: ({ workflowName, workflowId, }: {
1129
- workflowName: string;
1130
- workflowId: string;
1546
+ expectedStreamVersion?: ExpectedStreamVersion;
1547
+ retry?: WorkflowHandlerRetryOptions;
1548
+ };
1549
+ declare const workflowStreamName: ({
1550
+ workflowName,
1551
+ workflowId
1552
+ }: {
1553
+ workflowName: string;
1554
+ workflowId: string;
1131
1555
  }) => string;
1132
- declare const WorkflowHandler: <Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, StoredMessage extends AnyEvent | AnyCommand = Output>(options: WorkflowOptions<Input, State, Output, MessageMetadataType, StoredMessage> & {
1133
- retry?: WorkflowHandlerRetryOptions;
1134
- }) => <Store extends EventStore>(store: Store, message: Input | RecordedMessage<Input, MessageMetadataType>, handleOptions?: WorkflowHandleOptions<Store>) => Promise<WorkflowHandlerResult<Output, Store>>;
1135
-
1136
- export { type AcquireLockOptions, type AfterEventStoreCommitHandler, type AggregateStreamOptions, type AggregateStreamResult, type AggregateStreamResultOfEventStore, type AggregateStreamResultWithGlobalPosition, type AnyCommand, type AnyEvent, type AnyMessage, type AnyReadEvent, type AnyReadEventMetadata, type AnyRecord, type AnyRecordedMessage, type AnyRecordedMessageMetadata, type AppendStreamResultOfEventStore, type AppendToStreamOptions, type AppendToStreamResult, type AppendToStreamResultWithGlobalPosition, type ArgumentMatcher, AssertionError, type AsyncAwaiter, type AsyncDeciderSpecification, type AsyncRetryOptions, type BaseMessageProcessorOptions, type BatchMessageHandler, type BatchMessageHandlerWithContext, type BatchMessageHandlerWithoutContext, type BatchRawMessageHandlerWithContext, type BatchRawMessageHandlerWithoutContext, type BatchRecordedMessageHandlerWithContext, type BatchRecordedMessageHandlerWithoutContext, type BeforeEventStoreCommitHandler, type Brand, type CanHandle, type Checkpointer, type Closeable, type CombineMetadata, type CombinedMessageMetadata, type CombinedReadEventMetadata, type Command, type CommandBus, type CommandDataOf, CommandHandler, type CommandHandlerOptions, type CommandHandlerResult, type CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, type CommandMetaDataOf, type CommandProcessor, type CommandSender, type CommandTypeOf, type CommonReadEventMetadata, type CommonRecordedMessageMetadata, ConcurrencyError, type CreateCommandType, type CreateEventType, type CurrentMessageProcessorPosition, DATABASE_REQUIRED_ERROR_MESSAGE, type DatabaseHandleOptionErrors, type DatabaseHandleOptions, type DatabaseHandleResult, type Decider, DeciderCommandHandler, type DeciderCommandHandlerOptions, DeciderSpecification, type DeepReadonly, type DefaultCommandMetadata, type DefaultEventStoreOptions, type DefaultRecord, type DeleteManyOptions, type DeleteManyResult, type DeleteOneOptions, type DeleteResult, type Document, type DocumentHandler, EmmettError, type EnhancedOmit, type EnqueueTaskOptions, type Equatable, ErrorConstructor, type Event, type EventBus, type EventDataOf, type EventMetaDataOf, type EventStore, type EventStoreAppendSchemaOptions, type EventStoreReadEventMetadata, type EventStoreReadSchemaOptions, type EventStoreSchemaOptions, type EventStoreSession, type EventStoreSessionFactory, type EventStoreWrapper, type EventSubscription, type EventTypeOf, type EventsPublisher, type ExpectedDocumentVersion, type ExpectedDocumentVersionGeneral, type ExpectedDocumentVersionValue, type ExpectedStreamVersion, type ExpectedStreamVersionGeneral, type ExpectedStreamVersionWithValue, ExpectedVersionConflictError, type Flavour, type FullId, type GetCheckpoint, type GlobalPosition, type GlobalStreamCaughtUp, GlobalStreamCaughtUpType, type GlobalSubscriptionEvent, type HandleOptions, type HandlerOptions, type InMemoryCheckpointer, type InMemoryDatabase, type InMemoryDocumentEvolve, type InMemoryDocumentsCollection, type InMemoryEventStore, InMemoryEventStoreDefaultStreamVersion, type InMemoryEventStoreOptions, type InMemoryMultiStreamProjectionOptions, type InMemoryProcessor, type InMemoryProcessorConnectionOptions, type InMemoryProcessorEachBatchHandler, type InMemoryProcessorEachMessageHandler, type InMemoryProcessorHandlerContext, type InMemoryProcessorOptions, type InMemoryProjectionAssert, type InMemoryProjectionDefinition, type InMemoryProjectionHandlerContext, type InMemoryProjectionHandlerOptions, type InMemoryProjectionOptions, InMemoryProjectionSpec, type InMemoryProjectionSpecEvent, type InMemoryProjectionSpecOptions, type InMemoryProjectionSpecWhenOptions, type InMemoryProjectorOptions, type InMemoryReactorOptions, type InMemoryReadEvent, type InMemoryReadEventMetadata, type InMemorySingleStreamProjectionOptions, type InMemoryWithNotNullDocumentEvolve, type InMemoryWithNullableDocumentEvolve, InProcessLock, type InsertManyOptions, type InsertManyResult, type InsertOneOptions, type InsertOneResult, JSONParser, type Lock, type LockOptions, type Mapper, type MapperArgs, type Message, type MessageBus, type MessageConsumer, type MessageConsumerOptions, type MessageDataOf, type MessageDowncast, type MessageHandler, type MessageHandlerResult, type MessageKindOf, type MessageMetaDataOf, type MessageProcessingScope, MessageProcessor, type MessageProcessorStartFrom, MessageProcessorType, type MessageScheduler, type MessageSubscription, type MessageTypeOf, type MessageUpcast, type MockedFunction, type Mutable, NO_CONCURRENCY_CHECK, NoRetries, type NonNullable$1 as NonNullable, type OnReactorCloseHook, type OnReactorInitHook, type OnReactorStartHook, type OperationResult, type OptionalId, type OptionalUnlessRequiredId, type OptionalUnlessRequiredIdAndVersion, type OptionalUnlessRequiredVersion, type OptionalVersion, ParseError, type ParseOptions, type ProcessorCheckpoint, type ProcessorHooks, type ProjectionDefinition, type ProjectionHandler, type ProjectionHandlingType, type ProjectionInitOptions, type ProjectionRegistration, type ProjectorOptions, type ReactorOptions, type ReadEvent, type ReadEventMetadata, type ReadEventMetadataWithGlobalPosition, type ReadEventMetadataWithoutGlobalPosition, type ReadProcessorCheckpoint, type ReadProcessorCheckpointResult, type ReadStreamOptions, type ReadStreamResult, type RecordedMessage, type RecordedMessageMetadata, type RecordedMessageMetadataWithGlobalPosition, type RecordedMessageMetadataWithoutGlobalPosition, type ReleaseLockOptions, type ReplaceOneOptions, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, type ScheduleOptions, type ScheduledMessage, type ScheduledMessageProcessor, type ShutdownHandler, type SingleMessageHandler, type SingleMessageHandlerWithContext, type SingleMessageHandlerWithoutContext, type SingleRawMessageHandlerWithContext, type SingleRawMessageHandlerWithoutContext, type SingleRecordedMessageHandlerWithContext, type SingleRecordedMessageHandlerWithoutContext, type StoreProcessorCheckpoint, type StoreProcessorCheckpointResult, type StreamExistsResult, type StreamPosition, type StringifyOptions, type Task, type TaskContext, TaskProcessor, type TaskProcessorOptions, type TaskQueue, type TaskQueueItem, type TestEventStream, type ThenThrows, type TruncateProjection, type UpdateManyOptions, type UpdateManyResult, type UpdateOneOptions, type UpdateResult, ValidationErrors, type WithGlobalPosition, type WithId, type WithIdAndVersion, type WithVersion, type WithoutId, type WithoutVersion, Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowHandleOptions, WorkflowHandler, type WorkflowHandlerResult, type WorkflowHandlerRetryOptions, WorkflowHandlerStreamVersionConflictRetryOptions, type WorkflowInputMessageMetadata, type WorkflowMessageAction, type WorkflowOptions, type WorkflowOutput, type WorkflowOutputMessageMetadata, type WorkflowProcessorContext, type WorkflowProcessorOptions, WorkflowSpecification, WrapEventStore, argMatches, argValue, arrayUtils, assertDeepEqual, assertDefined, assertDoesNotThrow, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUnsignedBigInt, asyncAwaiter, asyncProjections, asyncRetry, bigInt, bigIntProcessorCheckpoint, canCreateEventStoreSession, caughtUpEventFrom, command, deepEquals, defaultProcessingMessageProcessingScope, defaultProcessorPartition, defaultProcessorVersion, defaultTag, delay, documentExists, downcastRecordedMessage, downcastRecordedMessages, emmettPrefix, event, eventInStream, eventsInStream, expectInMemoryDocuments, filterProjections, formatDateToUtcYYYYMMDD, forwardToMessageBus, getCheckpoint, getInMemoryDatabase, getInMemoryEventStore, getInMemoryMessageBus, getProcessorInstanceId, getProjectorId, getWorkflowId, globalStreamCaughtUp, globalTag, handleInMemoryProjections, hashText, inMemoryCheckpointer, inMemoryMultiStreamProjection, inMemoryProjection, inMemoryProjector, inMemoryReactor, inMemorySingleStreamProjection, inlineProjections, isBigint, isEquatable, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, matchesExpectedVersion, merge, message, newEventsInStream, nulloSessionFactory, onShutdown, parseBigIntProcessorCheckpoint, parseDateFromUtcYYYYMMDD, projection, projections, projector, reactor, sum, toNormalizedString, tryPublishMessagesAfterCommit, unknownTag, upcastRecordedMessage, upcastRecordedMessages, verifyThat, wasMessageHandled, workflowProcessor, workflowStreamName };
1556
+ type WorkflowHandlerOptions<Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, StoredMessage extends AnyEvent | AnyCommand = Output> = WorkflowOptions<Input, State, Output, MessageMetadataType, StoredMessage> & {
1557
+ retry?: WorkflowHandlerRetryOptions;
1558
+ observability?: WorkflowObservabilityConfig;
1559
+ };
1560
+ declare const WorkflowHandler: <Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MessageMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, StoredMessage extends AnyEvent | AnyCommand = Output>(options: WorkflowHandlerOptions<Input, State, Output, MessageMetadataType, StoredMessage>) => <Store extends EventStore>(store: Store, message: Input | RecordedMessage<Input, MessageMetadataType>, handleOptions?: WorkflowHandleOptions<Store>) => Promise<WorkflowHandlerResult<Output, Store>>;
1561
+ declare namespace index_d_exports {
1562
+ export { AcquireLockOptions, AfterEventStoreCommitHandler, AggregateStreamOptions, AggregateStreamResult, AggregateStreamResultOfEventStore, AggregateStreamResultWithGlobalPosition, AnyCommand, AnyEvent, AnyMessage, AnyReadEvent, AnyReadEventMetadata, AnyRecord, AnyRecordedMessage, AnyRecordedMessageMetadata, AppendStreamResultOfEventStore, AppendToStreamOptions, AppendToStreamResult, AppendToStreamResultWithGlobalPosition, ArgumentMatcher, AssertionError, AsyncAwaiter, AsyncDeciderSpecification, AsyncRetryOptions, BaseMessageProcessorOptions, BatchMessageHandler, BatchMessageHandlerResult, BatchMessageHandlerWithContext, BatchMessageHandlerWithoutContext, BatchRawMessageHandlerWithContext, BatchRawMessageHandlerWithoutContext, BatchRecordedMessageHandlerWithContext, BatchRecordedMessageHandlerWithoutContext, BatchWorkflowOutputHandler, BeforeEventStoreCommitHandler, BoundedAccessGuard, Brand, CanHandle, Checkpointer, Closeable, CombineMetadata, CombinedMessageMetadata, CombinedReadEventMetadata, Command, CommandBus, CommandDataOf, CommandHandler, CommandHandlerOptions, CommandHandlerResult, CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, CommandMetaDataOf, CommandProcessor, CommandSender, CommandTypeOf, CommonReadEventMetadata, CommonRecordedMessageMetadata, ConcurrencyError, ConcurrencyInMemoryDatabaseError, ConsumerObservabilityConfig, CreateCommandType, CreateEventType, CurrentMessageProcessorPosition, DATABASE_REQUIRED_ERROR_MESSAGE, DatabaseHandleOptionErrors, DatabaseHandleOptions, DatabaseHandleResult, Decider, DeciderCommandHandler, DeciderCommandHandlerOptions, DeciderSpecification, DeepReadonly, DefaultCommandMetadata, DefaultEventStoreOptions, DefaultRecord, DeleteManyOptions, DeleteManyResult, DeleteOneOptions, DeleteResult, Document, DocumentHandler, EmmettAttributes, EmmettCliCommand, EmmettCliPlugin, EmmettCliPluginRegistration, EmmettError, EmmettMetrics, EmmettObservabilityConfig, EmmettObservabilityOptions, EmmettPlugin, EmmettPluginConfig, EmmettPluginRegistration, EmmettPluginType, EmmettPluginsConfig, EnhancedOmit, EnqueueTaskOptions, Equatable, ErrorConstructor, Event, EventBus, EventDataOf, EventMetaDataOf, EventStore, EventStoreAppendSchemaOptions, EventStoreObservabilityConfig, EventStoreReadEventMetadata, EventStoreReadSchemaOptions, EventStoreSchemaOptions, EventStoreSession, EventStoreSessionFactory, EventStoreWrapper, EventSubscription, EventTypeOf, EventsPublisher, ExclusiveAccessGuard, ExpectedDocumentVersion, ExpectedDocumentVersionGeneral, ExpectedDocumentVersionValue, ExpectedStreamVersion, ExpectedStreamVersionGeneral, ExpectedStreamVersionWithValue, ExpectedVersionConflictError, Flavour, FullId, GetCheckpoint, GlobalPosition, GlobalStreamCaughtUp, GlobalStreamCaughtUpType, GlobalSubscriptionEvent, HandleOptions, HandlerOptions, IllegalStateError, InMemoryCheckpointer, InMemoryDatabase, InMemoryDocumentEvolve, InMemoryDocumentsCollection, InMemoryEventStore, InMemoryEventStoreDefaultStreamVersion, InMemoryEventStoreOptions, InMemoryMultiStreamProjectionOptions, InMemoryProcessor, InMemoryProcessorConnectionOptions, InMemoryProcessorEachBatchHandler, InMemoryProcessorEachMessageHandler, InMemoryProcessorHandlerContext, InMemoryProcessorOptions, InMemoryProjectionAssert, InMemoryProjectionDefinition, InMemoryProjectionHandlerContext, InMemoryProjectionHandlerOptions, InMemoryProjectionOptions, InMemoryProjectionSpec, InMemoryProjectionSpecEvent, InMemoryProjectionSpecOptions, InMemoryProjectionSpecWhenOptions, InMemoryProjectorOptions, InMemoryReactorOptions, InMemoryReadEvent, InMemoryReadEventMetadata, InMemorySingleStreamProjectionOptions, InMemoryWithNotNullDocumentEvolve, InMemoryWithNullableDocumentEvolve, InProcessLock, InitializedOnceGuard, InsertManyOptions, InsertManyResult, InsertOneOptions, InsertOneResult, JSONCodec, JSONCodecOptions, JSONDeserializeOptions, JSONReplacer, JSONReplacers, JSONReviver, JSONReviverContext, JSONRevivers, JSONSerializationOptions, JSONSerializeOptions, JSONSerializer, JSONSerializerOptions, Lock, LockOptions, LogLevel, LogStyle, LogType, Message, MessageBus, MessageConsumer, MessageConsumerOptions, MessageDataOf, MessageDowncast, MessageHandler, MessageHandlerContext, MessageKindOf, MessageMetaDataOf, MessageProcessingScope, MessageProcessor, MessageProcessorStartFrom, MessageProcessorType, MessageScheduler, MessageSubscription, MessageTypeOf, MessageUpcast, MessagingSystemName, MockedFunction, Mutable, NO_CONCURRENCY_CHECK, NoRetries, NonNullable$1 as NonNullable, NotFoundError, OnReactorCloseHook, OnReactorInitHook, OnReactorStartHook, OperationResult, OptionalId, OptionalUnlessRequiredId, OptionalUnlessRequiredIdAndVersion, OptionalUnlessRequiredVersion, OptionalVersion, PollTracing, ProcessorCheckpoint, ProcessorCollectorContext, ProcessorHooks, ProcessorObservabilityConfig, ProjectionDefinition, ProjectionHandler, ProjectionHandlerContext, ProjectionHandlingType, ProjectionInitOptions, ProjectionRegistration, ProjectorOptions, ReactorOptions, ReadEvent, ReadEventMetadata, ReadEventMetadataWithGlobalPosition, ReadEventMetadataWithoutGlobalPosition, ReadProcessorCheckpoint, ReadProcessorCheckpointResult, ReadStreamOptions, ReadStreamResult, RecordedMessage, RecordedMessageMetadata, RecordedMessageMetadataWithGlobalPosition, RecordedMessageMetadataWithoutGlobalPosition, ReleaseLockOptions, ReplaceOneOptions, ResolvedConsumerObservability, ResolvedEventStoreObservability, ResolvedProcessorObservability, ResolvedWorkflowObservability, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, ScheduleOptions, ScheduledMessage, ScheduledMessageProcessor, ScopeTypes, SerializationCodec, Serializer, ShutdownHandler, SingleMessageHandler, SingleMessageHandlerResult, SingleMessageHandlerWithContext, SingleMessageHandlerWithoutContext, SingleRawMessageHandlerWithContext, SingleRawMessageHandlerWithoutContext, SingleRecordedMessageHandlerWithContext, SingleRecordedMessageHandlerWithoutContext, SingleWorkflowOutputHandler, StoreProcessorCheckpoint, StoreProcessorCheckpointResult, StreamExistsResult, StreamPosition, Task, TaskContext, TaskProcessor, TaskProcessorOptions, TaskQueue, TaskQueueItem, TestEventStream, ThenThrows, TruncateProjection, UpdateManyOptions, UpdateManyResult, UpdateOneOptions, UpdateResult, ValidationError, ValidationErrors, WithGlobalPosition, WithId, WithIdAndVersion, WithObservabilityScope, WithVersion, WithoutId, WithoutVersion, Workflow, WorkflowCollectorContext, WorkflowCommand, WorkflowEvent, WorkflowHandleOptions, WorkflowHandler, WorkflowHandlerOptions, WorkflowHandlerResult, WorkflowHandlerRetryOptions, WorkflowHandlerStreamVersionConflictRetryOptions, WorkflowInputMessageMetadata, WorkflowMessageAction, WorkflowObservabilityConfig, WorkflowOptions, WorkflowOutput, WorkflowOutputHandlerDefinition, WorkflowOutputHandlerOptions, WorkflowOutputHandlerResult, WorkflowOutputMessageMetadata, WorkflowProcessorContext, WorkflowProcessorOptions, WorkflowSpecification, WrapEventStore, argMatches, argValue, arrayUtils, assertDeepEqual, assertDefined, assertDoesNotThrow, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUndefined, assertUnsignedBigInt, asyncAwaiter, asyncProjections, asyncRetry, bigInt, bigIntProcessorCheckpoint, canCreateEventStoreSession, caughtUpEventFrom, command, composeJSONReplacers, composeJSONRevivers, consumerCollector, deepEquals, defaultProcessingMessageProcessingScope, defaultProcessorPartition, defaultProcessorVersion, defaultTag, delay, documentExists, downcastRecordedMessage, downcastRecordedMessages, emmettPrefix, event, eventInStream, eventStoreCollector, eventsInStream, expectInMemoryDocuments, filterProjections, formatDateToUtcYYYYMMDD, forwardToMessageBus, getCheckpoint, getInMemoryDatabase, getInMemoryEventStore, getInMemoryMessageBus, getProcessorInstanceId, getProjectorId, getWorkflowId, globalStreamCaughtUp, globalTag, guardBoundedAccess, guardExclusiveAccess, guardInitializedOnce, handleInMemoryProjections, hashText, inMemoryCheckpointer, inMemoryMultiStreamProjection, inMemoryProjection, inMemoryProjector, inMemoryReactor, inMemorySingleStreamProjection, inlineProjections, isBigint, isEquatable, isErrorConstructor, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isPluginConfig, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, jsonSerializer, matchesExpectedVersion, merge, message, newEventsInStream, nulloSessionFactory, onShutdown, parseBigIntProcessorCheckpoint, parseDateFromUtcYYYYMMDD, processorCollector, projection, projections, projector, reactor, reduceAsync, resolveConsumerObservability, resolveEventStoreObservability, resolveProcessorObservability, resolveWorkflowObservability, sum, toNormalizedString, tracer, tryPublishMessagesAfterCommit, unknownTag, upcastRecordedMessage, upcastRecordedMessages, verifyThat, wasMessageHandled, workflowCollector, workflowOutputHandler, workflowProcessor, workflowStreamName };
1563
+ }
1564
+ //#endregion
1565
+ export { AcquireLockOptions, AfterEventStoreCommitHandler, AggregateStreamOptions, AggregateStreamResult, AggregateStreamResultOfEventStore, AggregateStreamResultWithGlobalPosition, AnyCommand, AnyEvent, AnyMessage, AnyReadEvent, AnyReadEventMetadata, AnyRecord, AnyRecordedMessage, AnyRecordedMessageMetadata, AppendStreamResultOfEventStore, AppendToStreamOptions, AppendToStreamResult, AppendToStreamResultWithGlobalPosition, ArgumentMatcher, AssertionError, AsyncAwaiter, AsyncDeciderSpecification, AsyncRetryOptions, BaseMessageProcessorOptions, BatchMessageHandler, BatchMessageHandlerResult, BatchMessageHandlerWithContext, BatchMessageHandlerWithoutContext, BatchRawMessageHandlerWithContext, BatchRawMessageHandlerWithoutContext, BatchRecordedMessageHandlerWithContext, BatchRecordedMessageHandlerWithoutContext, BatchWorkflowOutputHandler, BeforeEventStoreCommitHandler, BoundedAccessGuard, Brand, CanHandle, Checkpointer, Closeable, CombineMetadata, CombinedMessageMetadata, CombinedReadEventMetadata, Command, CommandBus, CommandDataOf, CommandHandler, CommandHandlerOptions, CommandHandlerResult, CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, CommandMetaDataOf, CommandProcessor, CommandSender, CommandTypeOf, CommonReadEventMetadata, CommonRecordedMessageMetadata, ConcurrencyError, ConcurrencyInMemoryDatabaseError, ConsumerObservabilityConfig, CreateCommandType, CreateEventType, CurrentMessageProcessorPosition, DATABASE_REQUIRED_ERROR_MESSAGE, DatabaseHandleOptionErrors, DatabaseHandleOptions, DatabaseHandleResult, Decider, DeciderCommandHandler, DeciderCommandHandlerOptions, DeciderSpecification, DeepReadonly, DefaultCommandMetadata, DefaultEventStoreOptions, DefaultRecord, DeleteManyOptions, DeleteManyResult, DeleteOneOptions, DeleteResult, Document, DocumentHandler, EmmettAttributes, EmmettCliCommand, EmmettCliPlugin, EmmettCliPluginRegistration, EmmettError, EmmettMetrics, EmmettObservabilityConfig, EmmettObservabilityOptions, EmmettPlugin, EmmettPluginConfig, EmmettPluginRegistration, EmmettPluginType, EmmettPluginsConfig, EnhancedOmit, EnqueueTaskOptions, Equatable, ErrorConstructor, Event, EventBus, EventDataOf, EventMetaDataOf, EventStore, EventStoreAppendSchemaOptions, EventStoreObservabilityConfig, EventStoreReadEventMetadata, EventStoreReadSchemaOptions, EventStoreSchemaOptions, EventStoreSession, EventStoreSessionFactory, EventStoreWrapper, EventSubscription, EventTypeOf, EventsPublisher, ExclusiveAccessGuard, ExpectedDocumentVersion, ExpectedDocumentVersionGeneral, ExpectedDocumentVersionValue, ExpectedStreamVersion, ExpectedStreamVersionGeneral, ExpectedStreamVersionWithValue, ExpectedVersionConflictError, Flavour, FullId, GetCheckpoint, GlobalPosition, GlobalStreamCaughtUp, GlobalStreamCaughtUpType, GlobalSubscriptionEvent, HandleOptions, HandlerOptions, IllegalStateError, InMemoryCheckpointer, InMemoryDatabase, InMemoryDocumentEvolve, InMemoryDocumentsCollection, InMemoryEventStore, InMemoryEventStoreDefaultStreamVersion, InMemoryEventStoreOptions, InMemoryMultiStreamProjectionOptions, InMemoryProcessor, InMemoryProcessorConnectionOptions, InMemoryProcessorEachBatchHandler, InMemoryProcessorEachMessageHandler, InMemoryProcessorHandlerContext, InMemoryProcessorOptions, InMemoryProjectionAssert, InMemoryProjectionDefinition, InMemoryProjectionHandlerContext, InMemoryProjectionHandlerOptions, InMemoryProjectionOptions, InMemoryProjectionSpec, InMemoryProjectionSpecEvent, InMemoryProjectionSpecOptions, InMemoryProjectionSpecWhenOptions, InMemoryProjectorOptions, InMemoryReactorOptions, InMemoryReadEvent, InMemoryReadEventMetadata, InMemorySingleStreamProjectionOptions, InMemoryWithNotNullDocumentEvolve, InMemoryWithNullableDocumentEvolve, InProcessLock, InitializedOnceGuard, InsertManyOptions, InsertManyResult, InsertOneOptions, InsertOneResult, JSONCodec, type JSONCodecOptions, type JSONDeserializeOptions, JSONReplacer, JSONReplacers, JSONReviver, JSONReviverContext, JSONRevivers, type JSONSerializationOptions, type JSONSerializeOptions, JSONSerializer, type JSONSerializerOptions, Lock, LockOptions, LogLevel, LogStyle, LogType, Message, MessageBus, MessageConsumer, MessageConsumerOptions, MessageDataOf, MessageDowncast, MessageHandler, MessageHandlerContext, MessageKindOf, MessageMetaDataOf, MessageProcessingScope, MessageProcessor, MessageProcessorStartFrom, MessageProcessorType, MessageScheduler, MessageSubscription, MessageTypeOf, MessageUpcast, MessagingSystemName, MockedFunction, Mutable, NO_CONCURRENCY_CHECK, NoRetries, NonNullable$1 as NonNullable, NotFoundError, OnReactorCloseHook, OnReactorInitHook, OnReactorStartHook, OperationResult, OptionalId, OptionalUnlessRequiredId, OptionalUnlessRequiredIdAndVersion, OptionalUnlessRequiredVersion, OptionalVersion, PollTracing, ProcessorCheckpoint, ProcessorCollectorContext, ProcessorHooks, ProcessorObservabilityConfig, ProjectionDefinition, ProjectionHandler, ProjectionHandlerContext, ProjectionHandlingType, ProjectionInitOptions, ProjectionRegistration, ProjectorOptions, ReactorOptions, ReadEvent, ReadEventMetadata, ReadEventMetadataWithGlobalPosition, ReadEventMetadataWithoutGlobalPosition, ReadProcessorCheckpoint, ReadProcessorCheckpointResult, ReadStreamOptions, ReadStreamResult, RecordedMessage, RecordedMessageMetadata, RecordedMessageMetadataWithGlobalPosition, RecordedMessageMetadataWithoutGlobalPosition, ReleaseLockOptions, ReplaceOneOptions, ResolvedConsumerObservability, ResolvedEventStoreObservability, ResolvedProcessorObservability, ResolvedWorkflowObservability, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, ScheduleOptions, ScheduledMessage, ScheduledMessageProcessor, ScopeTypes, SerializationCodec, Serializer, ShutdownHandler, SingleMessageHandler, SingleMessageHandlerResult, SingleMessageHandlerWithContext, SingleMessageHandlerWithoutContext, SingleRawMessageHandlerWithContext, SingleRawMessageHandlerWithoutContext, SingleRecordedMessageHandlerWithContext, SingleRecordedMessageHandlerWithoutContext, SingleWorkflowOutputHandler, StoreProcessorCheckpoint, StoreProcessorCheckpointResult, StreamExistsResult, StreamPosition, Task, TaskContext, TaskProcessor, TaskProcessorOptions, TaskQueue, TaskQueueItem, TestEventStream, ThenThrows, TruncateProjection, UpdateManyOptions, UpdateManyResult, UpdateOneOptions, UpdateResult, ValidationError, ValidationErrors, WithGlobalPosition, WithId, WithIdAndVersion, WithObservabilityScope, WithVersion, WithoutId, WithoutVersion, Workflow, WorkflowCollectorContext, WorkflowCommand, WorkflowEvent, WorkflowHandleOptions, WorkflowHandler, WorkflowHandlerOptions, WorkflowHandlerResult, WorkflowHandlerRetryOptions, WorkflowHandlerStreamVersionConflictRetryOptions, WorkflowInputMessageMetadata, WorkflowMessageAction, WorkflowObservabilityConfig, WorkflowOptions, WorkflowOutput, WorkflowOutputHandlerDefinition, WorkflowOutputHandlerOptions, WorkflowOutputHandlerResult, WorkflowOutputMessageMetadata, WorkflowProcessorContext, WorkflowProcessorOptions, WorkflowSpecification, WrapEventStore, argMatches, argValue, arrayUtils, assertDeepEqual, assertDefined, assertDoesNotThrow, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUndefined, assertUnsignedBigInt, asyncAwaiter, asyncProjections, asyncRetry, bigInt, bigIntProcessorCheckpoint, canCreateEventStoreSession, caughtUpEventFrom, command, composeJSONReplacers, composeJSONRevivers, consumerCollector, deepEquals, defaultProcessingMessageProcessingScope, defaultProcessorPartition, defaultProcessorVersion, defaultTag, delay, documentExists, downcastRecordedMessage, downcastRecordedMessages, emmettPrefix, event, eventInStream, eventStoreCollector, eventsInStream, expectInMemoryDocuments, filterProjections, formatDateToUtcYYYYMMDD, forwardToMessageBus, getCheckpoint, getInMemoryDatabase, getInMemoryEventStore, getInMemoryMessageBus, getProcessorInstanceId, getProjectorId, getWorkflowId, globalStreamCaughtUp, globalTag, guardBoundedAccess, guardExclusiveAccess, guardInitializedOnce, handleInMemoryProjections, hashText, inMemoryCheckpointer, inMemoryMultiStreamProjection, inMemoryProjection, inMemoryProjector, inMemoryReactor, inMemorySingleStreamProjection, inlineProjections, isBigint, isEquatable, isErrorConstructor, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isPluginConfig, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, jsonSerializer, matchesExpectedVersion, merge, message, newEventsInStream, nulloSessionFactory, onShutdown, parseBigIntProcessorCheckpoint, parseDateFromUtcYYYYMMDD, processorCollector, projection, projections, projector, reactor, reduceAsync, resolveConsumerObservability, resolveEventStoreObservability, resolveProcessorObservability, resolveWorkflowObservability, sum, toNormalizedString, tracer, tryPublishMessagesAfterCommit, unknownTag, upcastRecordedMessage, upcastRecordedMessages, verifyThat, wasMessageHandled, workflowCollector, workflowOutputHandler, workflowProcessor, workflowStreamName };
1566
+ //# sourceMappingURL=index.d.ts.map