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