@event-driven-io/emmett 0.21.1-alpha.1 → 0.22.0-alpha.2

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
@@ -36,6 +36,8 @@ type DefaultCommandMetadata = {
36
36
  now: Date;
37
37
  };
38
38
 
39
+ type BigIntStreamPosition = bigint;
40
+ type BigIntGlobalPosition = bigint;
39
41
  type Event<EventType extends string = string, EventData extends DefaultRecord = DefaultRecord, EventMetaData extends DefaultRecord = DefaultRecord> = Flavour<Readonly<{
40
42
  type: EventType;
41
43
  data: EventData;
@@ -51,17 +53,20 @@ type CreateEventType<EventType extends string, EventData extends DefaultRecord,
51
53
  metadata?: EventMetaData;
52
54
  }>;
53
55
  declare const event: <EventType extends Event>(type: EventTypeOf<EventType>, data: EventDataOf<EventType>, metadata?: EventMetaDataOf<EventType>) => CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataOf<EventType>>;
54
- type ReadEvent<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataType> & EventType & {
56
+ type ReadEvent<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, any>> = CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataType> & EventType & {
55
57
  metadata: EventMetaDataType;
56
58
  };
57
- type ReadEventMetadata = Readonly<{
59
+ type ReadEventMetadata<GlobalPosition = undefined, StreamPosition = BigIntStreamPosition> = Readonly<{
58
60
  eventId: string;
59
- streamPosition: bigint;
61
+ streamPosition: StreamPosition;
60
62
  streamName: string;
61
- }>;
62
- type ReadEventMetadataWithGlobalPosition = ReadEventMetadata & {
63
- globalPosition: bigint;
64
- };
63
+ }> & (GlobalPosition extends undefined ? object : {
64
+ globalPosition: GlobalPosition;
65
+ });
66
+ type ReadEventMetadataWithGlobalPosition<GlobalPosition = BigIntGlobalPosition> = ReadEventMetadata<GlobalPosition>;
67
+ type ReadEventMetadataWithoutGlobalPosition<StreamPosition = BigIntStreamPosition> = ReadEventMetadata<undefined, StreamPosition>;
68
+ type GlobalPositionTypeOfReadEventMetadata<ReadEventMetadataType> = ReadEventMetadataType extends ReadEventMetadata<infer GP, any> ? GP : never;
69
+ type StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType> = ReadEventMetadataType extends ReadEventMetadata<any, infer SV> ? SV : never;
65
70
 
66
71
  type Decider<State, CommandType extends Command, StreamEvent extends Event> = {
67
72
  decide: (command: CommandType, state: State) => StreamEvent | StreamEvent[];
@@ -130,35 +135,37 @@ type Flavour<K, T> = K & {
130
135
  type DefaultRecord = Record<string, unknown>;
131
136
  type NonNullable<T> = T extends null | undefined ? never : T;
132
137
 
133
- type ExpectedStreamVersion<VersionType = DefaultStreamVersionType> = ExpectedStreamVersionWithValue<VersionType> | ExpectedStreamVersionGeneral;
134
- type ExpectedStreamVersionWithValue<VersionType = DefaultStreamVersionType> = Flavour<VersionType, 'StreamVersion'>;
138
+ type ExpectedStreamVersion<VersionType = BigIntStreamPosition> = ExpectedStreamVersionWithValue<VersionType> | ExpectedStreamVersionGeneral;
139
+ type ExpectedStreamVersionWithValue<VersionType = BigIntStreamPosition> = Flavour<VersionType, 'StreamVersion'>;
135
140
  type ExpectedStreamVersionGeneral = Flavour<'STREAM_EXISTS' | 'STREAM_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK', 'StreamVersion'>;
136
141
  declare const STREAM_EXISTS: ExpectedStreamVersionGeneral;
137
142
  declare const STREAM_DOES_NOT_EXIST: ExpectedStreamVersionGeneral;
138
143
  declare const NO_CONCURRENCY_CHECK: ExpectedStreamVersionGeneral;
139
144
  declare const matchesExpectedVersion: <StreamVersion = bigint>(current: StreamVersion | undefined, expected: ExpectedStreamVersion<StreamVersion>, defaultVersion: StreamVersion) => boolean;
140
145
  declare const assertExpectedVersionMatchesCurrent: <StreamVersion = bigint>(current: StreamVersion, expected: ExpectedStreamVersion<StreamVersion> | undefined, defaultVersion: StreamVersion) => void;
141
- declare class ExpectedVersionConflictError<VersionType = DefaultStreamVersionType> extends ConcurrencyError {
146
+ declare class ExpectedVersionConflictError<VersionType = BigIntStreamPosition> extends ConcurrencyError {
142
147
  constructor(current: VersionType, expected: ExpectedStreamVersion<VersionType>);
143
148
  }
144
149
  declare const isExpectedVersionConflictError: (error: unknown) => error is ExpectedVersionConflictError;
145
150
 
146
- interface EventStore<StreamVersion = DefaultStreamVersionType, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> {
147
- aggregateStream<State, EventType extends Event>(streamName: string, options: AggregateStreamOptions<State, EventType, StreamVersion, ReadEventMetadataType>): Promise<AggregateStreamResult<State, StreamVersion>>;
148
- readStream<EventType extends Event>(streamName: string, options?: ReadStreamOptions<StreamVersion>): Promise<ReadStreamResult<EventType, StreamVersion, ReadEventMetadataType>>;
149
- appendToStream<EventType extends Event>(streamName: string, events: EventType[], options?: AppendToStreamOptions<StreamVersion>): Promise<AppendToStreamResult<StreamVersion>>;
151
+ interface EventStore<ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>> {
152
+ aggregateStream<State, EventType extends Event>(streamName: string, options: AggregateStreamOptions<State, EventType, ReadEventMetadataType & EventMetaDataOf<EventType>>): Promise<AggregateStreamResult<State, StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>>;
153
+ readStream<EventType extends Event>(streamName: string, options?: ReadStreamOptions<StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>): Promise<ReadStreamResult<EventType, ReadEventMetadataType & EventMetaDataOf<EventType>>>;
154
+ appendToStream<EventType extends Event>(streamName: string, events: EventType[], options?: AppendToStreamOptions<StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>): Promise<AppendToStreamResult<StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>>;
150
155
  }
151
- type EventStoreSession<EventStoreType extends EventStore<StreamVersion>, StreamVersion = DefaultStreamVersionType> = {
156
+ type EventStoreReadEventMetadata<Store extends EventStore> = Store extends EventStore<infer ReadEventMetadataType> ? ReadEventMetadataType extends ReadEventMetadata<infer GV, infer SV> ? ReadEventMetadata<GV, SV> & ReadEventMetadataType : never : never;
157
+ type GlobalPositionTypeOfEventStore<Store extends EventStore> = GlobalPositionTypeOfReadEventMetadata<EventStoreReadEventMetadata<Store>>;
158
+ type StreamPositionTypeOfEventStore<Store extends EventStore> = StreamPositionTypeOfReadEventMetadata<EventStoreReadEventMetadata<Store>>;
159
+ type EventStoreSession<EventStoreType extends EventStore> = {
152
160
  eventStore: EventStoreType;
153
161
  close: () => Promise<void>;
154
162
  };
155
- interface EventStoreSessionFactory<EventStoreType extends EventStore<StreamVersion>, StreamVersion = DefaultStreamVersionType> {
156
- withSession<T = unknown>(callback: (session: EventStoreSession<EventStoreType, StreamVersion>) => Promise<T>): Promise<T>;
163
+ interface EventStoreSessionFactory<EventStoreType extends EventStore> {
164
+ withSession<T = unknown>(callback: (session: EventStoreSession<EventStoreType>) => Promise<T>): Promise<T>;
157
165
  }
158
- type DefaultStreamVersionType = bigint;
159
- declare const canCreateEventStoreSession: <Store extends EventStore<StreamVersion>, StreamVersion = bigint>(eventStore: Store | EventStoreSessionFactory<Store, StreamVersion>) => eventStore is EventStoreSessionFactory<Store, StreamVersion>;
160
- declare const nulloSessionFactory: <EventStoreType extends EventStore<StreamVersion>, StreamVersion = bigint>(eventStore: EventStoreType) => EventStoreSessionFactory<EventStoreType, StreamVersion>;
161
- type ReadStreamOptions<StreamVersion = DefaultStreamVersionType> = ({
166
+ declare const canCreateEventStoreSession: <Store extends EventStore>(eventStore: Store | EventStoreSessionFactory<Store>) => eventStore is EventStoreSessionFactory<Store>;
167
+ declare const nulloSessionFactory: <EventStoreType extends EventStore>(eventStore: EventStoreType) => EventStoreSessionFactory<EventStoreType>;
168
+ type ReadStreamOptions<StreamVersion = BigIntStreamPosition> = ({
162
169
  from: StreamVersion;
163
170
  } | {
164
171
  to: StreamVersion;
@@ -170,29 +177,40 @@ type ReadStreamOptions<StreamVersion = DefaultStreamVersionType> = ({
170
177
  }) & {
171
178
  expectedStreamVersion?: ExpectedStreamVersion<StreamVersion>;
172
179
  };
173
- type ReadStreamResult<EventType extends Event, StreamVersion = DefaultStreamVersionType, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> = {
174
- currentStreamVersion: StreamVersion;
175
- events: ReadEvent<EventType, ReadEventMetadataType>[];
180
+ type ReadStreamResult<EventType extends Event, ReadEventMetadataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, bigint>> = {
181
+ currentStreamVersion: StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>;
182
+ events: ReadEvent<EventType, ReadEventMetadataType & EventMetaDataOf<EventType>>[];
176
183
  streamExists: boolean;
177
184
  };
178
- type Evolve<State, EventType extends Event, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> = ((currentState: State, event: EventType) => State) | ((currentState: State, event: ReadEvent<EventType, ReadEventMetadataType>) => State) | ((currentState: State, event: ReadEvent<EventType>) => State);
179
- type AggregateStreamOptions<State, EventType extends Event, StreamVersion = DefaultStreamVersionType, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> = {
185
+ type Evolve<State, EventType extends Event, ReadEventMetadataType extends ReadEventMetadata<any, any> & EventMetaDataOf<EventType> = ReadEventMetadata<any, any> & EventMetaDataOf<EventType>> = ((currentState: State, event: EventType) => State) | ((currentState: State, event: ReadEvent<EventType, ReadEventMetadataType>) => State) | ((currentState: State, event: ReadEvent<EventType>) => State);
186
+ type AggregateStreamOptions<State, EventType extends Event, ReadEventMetadataType extends ReadEventMetadata<any, any> & EventMetaDataOf<EventType> = ReadEventMetadata<any, any> & EventMetaDataOf<EventType>> = {
180
187
  evolve: Evolve<State, EventType, ReadEventMetadataType>;
181
188
  initialState: () => State;
182
- read?: ReadStreamOptions<StreamVersion>;
189
+ read?: ReadStreamOptions<StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>;
183
190
  };
184
- type AggregateStreamResult<State, StreamVersion = DefaultStreamVersionType> = {
185
- currentStreamVersion: StreamVersion;
191
+ type AggregateStreamResult<State, StreamPosition = BigIntStreamPosition> = {
192
+ currentStreamVersion: StreamPosition;
186
193
  state: State;
187
194
  streamExists: boolean;
188
195
  };
189
- type AppendToStreamOptions<StreamVersion = DefaultStreamVersionType> = {
196
+ type AggregateStreamResultWithGlobalPosition<State, StreamPosition = BigIntStreamPosition, GlobalPosition = BigIntGlobalPosition> = (AggregateStreamResult<State, StreamPosition> & {
197
+ streamExists: true;
198
+ lastEventGlobalPosition: GlobalPosition;
199
+ }) | (AggregateStreamResult<State, StreamPosition> & {
200
+ streamExists: false;
201
+ });
202
+ type AggregateStreamResultOfEventStore<Store extends EventStore> = Store['aggregateStream'] extends (...args: any[]) => Promise<infer R> ? R : never;
203
+ type AppendToStreamOptions<StreamVersion = BigIntStreamPosition> = {
190
204
  expectedStreamVersion?: ExpectedStreamVersion<StreamVersion>;
191
205
  };
192
- type AppendToStreamResult<StreamVersion = DefaultStreamVersionType> = {
206
+ type AppendToStreamResult<StreamVersion = BigIntStreamPosition> = {
193
207
  nextExpectedStreamVersion: StreamVersion;
194
208
  createdNewStream: boolean;
195
209
  };
210
+ type AppendToStreamResultWithGlobalPosition<StreamVersion = BigIntStreamPosition, GlobalPosition = BigIntGlobalPosition> = AppendToStreamResult<StreamVersion> & {
211
+ lastEventGlobalPosition: GlobalPosition;
212
+ };
213
+ type AppendStreamResultOfEventStore<Store extends EventStore> = Store['appendToStream'] extends (...args: any[]) => Promise<infer R> ? R : never;
196
214
 
197
215
  declare const GlobalStreamCaughtUpType = "__emt:GlobalStreamCaughtUp";
198
216
  type GlobalStreamCaughtUp = Event<'__emt:GlobalStreamCaughtUp', {
@@ -209,7 +227,8 @@ type GlobalSubscriptionEvent = GlobalStreamCaughtUp;
209
227
 
210
228
  type EventHandler$1<E extends Event = Event> = (eventEnvelope: ReadEvent<E>) => void;
211
229
  declare const InMemoryEventStoreDefaultStreamVersion = 0n;
212
- declare const getInMemoryEventStore: () => EventStore<DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition>;
230
+ type InMemoryEventStore = EventStore<ReadEventMetadataWithGlobalPosition>;
231
+ declare const getInMemoryEventStore: () => InMemoryEventStore;
213
232
 
214
233
  declare const streamTrackingGlobalPosition: (currentEvents: ReadEvent<Event, ReadEventMetadataWithGlobalPosition>[]) => CaughtUpTransformStream;
215
234
  declare class CaughtUpTransformStream extends TransformStream<ReadEvent<Event, ReadEventMetadataWithGlobalPosition>, ReadEvent<Event, ReadEventMetadataWithGlobalPosition> | GlobalSubscriptionEvent> {
@@ -244,7 +263,7 @@ declare const CommandHandlerStreamVersionConflictRetryOptions: AsyncRetryOptions
244
263
  type CommandHandlerRetryOptions = AsyncRetryOptions | {
245
264
  onVersionConflict: true | number | AsyncRetryOptions;
246
265
  };
247
- type CommandHandlerResult<State, StreamEvent extends Event, StreamVersion = DefaultStreamVersionType> = AppendToStreamResult<StreamVersion> & {
266
+ type CommandHandlerResult<State, StreamEvent extends Event, Store extends EventStore> = AppendStreamResultOfEventStore<Store> & {
248
267
  newState: State;
249
268
  newEvents: StreamEvent[];
250
269
  };
@@ -254,15 +273,15 @@ type CommandHandlerOptions<State, StreamEvent extends Event> = {
254
273
  mapToStreamId?: (id: string) => string;
255
274
  retry?: CommandHandlerRetryOptions;
256
275
  };
257
- type HandleOptions<StreamVersion, Store extends EventStore<StreamVersion>> = Parameters<Store['appendToStream']>[2] & ({
258
- expectedStreamVersion?: ExpectedStreamVersion<StreamVersion>;
276
+ type HandleOptions<Store extends EventStore> = Parameters<Store['appendToStream']>[2] & ({
277
+ expectedStreamVersion?: ExpectedStreamVersion<StreamPositionTypeOfEventStore<Store>>;
259
278
  } | {
260
279
  retry?: CommandHandlerRetryOptions;
261
280
  });
262
- declare const CommandHandler$1: <State, StreamEvent extends Event, StreamVersion = bigint>(options: CommandHandlerOptions<State, StreamEvent>) => <Store extends EventStore<StreamVersion>>(store: Store, id: string, handle: (state: State) => StreamEvent | StreamEvent[] | Promise<StreamEvent> | Promise<StreamEvent[]>, handleOptions?: HandleOptions<StreamVersion, Store>) => Promise<CommandHandlerResult<State, StreamEvent, StreamVersion>>;
281
+ declare const CommandHandler$1: <State, StreamEvent extends Event>(options: CommandHandlerOptions<State, StreamEvent>) => <Store extends EventStore>(store: Store, id: string, handle: (state: State) => StreamEvent | StreamEvent[] | Promise<StreamEvent> | Promise<StreamEvent[]>, handleOptions?: HandleOptions<Store>) => Promise<CommandHandlerResult<State, StreamEvent, Store>>;
263
282
 
264
283
  type DeciderCommandHandlerOptions<State, CommandType extends Command, StreamEvent extends Event> = CommandHandlerOptions<State, StreamEvent> & Decider<State, CommandType, StreamEvent>;
265
- declare const DeciderCommandHandler: <State, CommandType extends Command, StreamEvent extends Event, StreamVersion = bigint>(options: DeciderCommandHandlerOptions<State, CommandType, StreamEvent>) => (eventStore: EventStore<StreamVersion>, id: string, command: CommandType, handleOptions?: HandleOptions<StreamVersion, EventStore<StreamVersion>>) => Promise<CommandHandlerResult<State, StreamEvent, StreamVersion>>;
284
+ declare const DeciderCommandHandler: <State, CommandType extends Command, StreamEvent extends Event>(options: DeciderCommandHandlerOptions<State, CommandType, StreamEvent>) => <Store extends EventStore>(eventStore: Store, id: string, command: CommandType, handleOptions?: HandleOptions<Store>) => Promise<CommandHandlerResult<State, StreamEvent, Store>>;
266
285
 
267
286
  interface CommandSender {
268
287
  send<CommandType extends Command = Command>(command: CommandType): Promise<void>;
@@ -305,31 +324,27 @@ type MessageProcessor = EventProcessor | CommandProcessor;
305
324
  declare const getInMemoryMessageBus: () => MessageBus & EventProcessor & CommandProcessor & ScheduledMessageProcessor;
306
325
 
307
326
  type ProjectionHandlingType = 'inline' | 'async';
308
- type ProjectionHandler<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = (events: ReadEvent<EventType, EventMetaDataType>[], context: ProjectionHandlerContext) => Promise<void> | void;
309
- interface ProjectionDefinition<ProjectionHandlerContext extends DefaultRecord = DefaultRecord> {
327
+ type ProjectionHandler<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = (events: ReadEvent<EventType, EventMetaDataType>[], context: ProjectionHandlerContext) => Promise<void> | void;
328
+ interface ProjectionDefinition<ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> {
310
329
  name?: string;
311
330
  canHandle: CanHandle<Event>;
312
- handle: ProjectionHandler<Event, ReadEventMetadata, ProjectionHandlerContext>;
331
+ handle: ProjectionHandler<Event, ReadEventMetadataType, ProjectionHandlerContext>;
313
332
  }
314
- interface TypedProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> {
333
+ interface TypedProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> {
315
334
  name?: string;
316
335
  canHandle: CanHandle<EventType>;
317
336
  handle: ProjectionHandler<EventType, EventMetaDataType, ProjectionHandlerContext>;
318
337
  }
319
- type ProjectionRegistration<HandlingType extends ProjectionHandlingType, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = {
338
+ type ProjectionRegistration<HandlingType extends ProjectionHandlingType, ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = {
320
339
  type: HandlingType;
321
- projection: ProjectionDefinition<ProjectionHandlerContext>;
340
+ projection: ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>;
322
341
  };
323
- declare const projection: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & Readonly<{
324
- eventId: string;
325
- streamPosition: bigint;
326
- streamName: string;
327
- }>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends TypedProjectionDefinition<EventType, EventMetaDataType, ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definition: ProjectionDefintionType) => ProjectionDefintionType;
328
- declare const inlineProjections: <ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"inline", ProjectionHandlerContext>[];
329
- declare const asyncProjections: <ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"async", ProjectionHandlerContext>[];
342
+ declare const projection: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends TypedProjectionDefinition<EventType, EventMetaDataType, ProjectionHandlerContext> = TypedProjectionDefinition<EventType, EventMetaDataType, ProjectionHandlerContext>>(definition: ProjectionDefintionType) => ProjectionDefintionType;
343
+ declare const inlineProjections: <ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext> = ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"inline", ReadEventMetadataType, ProjectionHandlerContext>[];
344
+ declare const asyncProjections: <ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext> = ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"async", ReadEventMetadataType, ProjectionHandlerContext>[];
330
345
  declare const projections: {
331
- inline: <ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"inline", ProjectionHandlerContext>[];
332
- async: <ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"async", ProjectionHandlerContext>[];
346
+ inline: <ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext> = ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"inline", ReadEventMetadataType, ProjectionHandlerContext>[];
347
+ async: <ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext> = ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"async", ReadEventMetadataType, ProjectionHandlerContext>[];
333
348
  };
334
349
 
335
350
  declare class ParseError extends Error {
@@ -511,14 +526,16 @@ declare const assertThatArray: <T>(array: T[]) => {
511
526
  isEmpty: () => void;
512
527
  isNotEmpty: () => void;
513
528
  hasSize: (length: number) => void;
514
- containsElements: (...other: T[]) => void;
515
- containsExactlyInAnyOrder: (...other: T[]) => void;
529
+ containsElements: (other: T[]) => void;
530
+ containsElementsMatching: (other: T[]) => void;
531
+ containsOnlyElementsMatching: (other: T[]) => void;
532
+ containsExactlyInAnyOrder: (other: T[]) => void;
516
533
  containsExactlyInAnyOrderElementsOf: (other: T[]) => void;
517
534
  containsExactlyElementsOf: (other: T[]) => void;
518
535
  containsExactly: (elem: T) => void;
519
536
  contains: (elem: T) => void;
520
537
  containsOnlyOnceElementsOf: (other: T[]) => void;
521
- containsAnyOf: (...other: T[]) => void;
538
+ containsAnyOf: (other: T[]) => void;
522
539
  allMatch: (matches: (item: T) => boolean) => void;
523
540
  anyMatches: (matches: (item: T) => boolean) => void;
524
541
  allMatchAsync: (matches: (item: T) => Promise<boolean>) => Promise<void>;
@@ -544,14 +561,11 @@ type TestEventStream<EventType extends Event = Event> = [
544
561
  string,
545
562
  EventType[]
546
563
  ];
547
- declare const WrapEventStore: <StreamVersion = bigint, ReadEventMetadataType extends ReadEventMetadata = Readonly<{
548
- eventId: string;
549
- streamPosition: bigint;
550
- streamName: string;
551
- }>>(eventStore: EventStore<StreamVersion, ReadEventMetadataType>) => EventStore<StreamVersion, ReadEventMetadataType> & {
564
+ type EventStoreWrapper<Store extends EventStore> = Store & {
552
565
  appendedEvents: Map<string, TestEventStream>;
553
- setup<EventType extends Event>(streamName: string, events: EventType[]): Promise<AppendToStreamResult<StreamVersion>>;
566
+ setup<EventType extends Event>(streamName: string, events: EventType[]): Promise<AppendToStreamResult<StreamPositionTypeOfEventStore<Store>>>;
554
567
  };
568
+ declare const WrapEventStore: <Store extends EventStore>(eventStore: Store) => EventStoreWrapper<Store>;
555
569
 
556
570
  declare const formatDateToUtcYYYYMMDD: (date: Date) => string;
557
571
  declare const isValidYYYYMMDD: (dateString: string) => boolean;
@@ -568,4 +582,4 @@ declare const assertNotEmptyString: (value: unknown) => string;
568
582
  declare const assertPositiveNumber: (value: unknown) => number;
569
583
  declare const assertUnsignedBigInt: (value: string) => bigint;
570
584
 
571
- export { type AggregateStreamOptions, type AggregateStreamResult, type AppendToStreamOptions, type AppendToStreamResult, type ArgumentMatcher, AssertionError, type AsyncRetryOptions, BinaryJsonDecoder, type Brand, type CanHandle, CaughtUpTransformStream, type Command, type CommandBus, type CommandDataOf, CommandHandler$1 as CommandHandler, type CommandHandlerOptions, type CommandHandlerResult, type CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, type CommandMetaDataOf, type CommandProcessor, type CommandSender, type CommandTypeOf, CompositeDecoder, ConcurrencyError, type CreateCommandType, type CreateEventType, type Decider, DeciderCommandHandler, type DeciderCommandHandlerOptions, type DeciderSpecfication, DeciderSpecification, type Decoder, type DeepReadonly, type DefaultCommandMetadata, DefaultDecoder, type DefaultRecord, type DefaultStreamVersionType, type Equatable, ErrorConstructor, type Event, type EventBus, type EventDataOf, type EventHandler$1 as EventHandler, type EventMetaDataOf, type EventProcessor, type EventStore, type EventStoreSession, type EventStoreSessionFactory, type EventTypeOf, type EventsPublisher, type ExpectedStreamVersion, type ExpectedStreamVersionGeneral, type ExpectedStreamVersionWithValue, ExpectedVersionConflictError, type Flavour, type GlobalStreamCaughtUp, GlobalStreamCaughtUpType, type GlobalSubscriptionEvent, type HandleOptions, InMemoryEventStoreDefaultStreamVersion, JSONParser, JsonDecoder, type Mapper, type MapperArgs, type MessageBus, type MessageHandler, type MessageProcessor, type MessageScheduler, type MockedFunction, type Mutable, NO_CONCURRENCY_CHECK, NoRetries, type NonNullable, ObjectDecoder, ParseError, type ParseOptions, type ProjectionDefinition, type ProjectionHandler, type ProjectionHandlingType, type ProjectionRegistration, type ReadEvent, type ReadEventMetadata, type ReadEventMetadataWithGlobalPosition, type ReadStreamOptions, type ReadStreamResult, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, type ScheduleOptions, type ScheduledMessage, type ScheduledMessageProcessor, StreamingCoordinator, StringDecoder, type StringifyOptions, type TestEventStream, type ThenThrows, type TypedProjectionDefinition, ValidationErrors, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, WrapEventStore, accept, argMatches, argValue, assertDeepEqual, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUnsignedBigInt, asyncProjections, asyncRetry, canCreateEventStoreSession, caughtUpEventFrom, collect, command, complete, concatUint8Arrays, deepEquals, error, event, formatDateToUtcYYYYMMDD, getInMemoryEventStore, getInMemoryMessageBus, globalStreamCaughtUp, ignore, inlineProjections, isEquatable, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, matchesExpectedVersion, merge, nulloSessionFactory, parseDateFromUtcYYYYMMDD, projection, projections, publish, reply, restream, schedule, send, streamGenerators, streamTrackingGlobalPosition, streamTransformations, sum, verifyThat };
585
+ export { type AggregateStreamOptions, type AggregateStreamResult, type AggregateStreamResultOfEventStore, type AggregateStreamResultWithGlobalPosition, type AppendStreamResultOfEventStore, type AppendToStreamOptions, type AppendToStreamResult, type AppendToStreamResultWithGlobalPosition, type ArgumentMatcher, AssertionError, type AsyncRetryOptions, type BigIntGlobalPosition, type BigIntStreamPosition, BinaryJsonDecoder, type Brand, type CanHandle, CaughtUpTransformStream, type Command, type CommandBus, type CommandDataOf, CommandHandler$1 as CommandHandler, type CommandHandlerOptions, type CommandHandlerResult, type CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, type CommandMetaDataOf, type CommandProcessor, type CommandSender, type CommandTypeOf, CompositeDecoder, ConcurrencyError, type CreateCommandType, type CreateEventType, type Decider, DeciderCommandHandler, type DeciderCommandHandlerOptions, type DeciderSpecfication, DeciderSpecification, type Decoder, type DeepReadonly, type DefaultCommandMetadata, DefaultDecoder, type DefaultRecord, type Equatable, ErrorConstructor, type Event, type EventBus, type EventDataOf, type EventHandler$1 as EventHandler, type EventMetaDataOf, type EventProcessor, type EventStore, type EventStoreReadEventMetadata, type EventStoreSession, type EventStoreSessionFactory, type EventStoreWrapper, type EventTypeOf, type EventsPublisher, type ExpectedStreamVersion, type ExpectedStreamVersionGeneral, type ExpectedStreamVersionWithValue, ExpectedVersionConflictError, type Flavour, type GlobalPositionTypeOfEventStore, type GlobalPositionTypeOfReadEventMetadata, type GlobalStreamCaughtUp, GlobalStreamCaughtUpType, type GlobalSubscriptionEvent, type HandleOptions, type InMemoryEventStore, InMemoryEventStoreDefaultStreamVersion, JSONParser, JsonDecoder, type Mapper, type MapperArgs, type MessageBus, type MessageHandler, type MessageProcessor, type MessageScheduler, type MockedFunction, type Mutable, NO_CONCURRENCY_CHECK, NoRetries, type NonNullable, ObjectDecoder, ParseError, type ParseOptions, type ProjectionDefinition, type ProjectionHandler, type ProjectionHandlingType, type ProjectionRegistration, type ReadEvent, type ReadEventMetadata, type ReadEventMetadataWithGlobalPosition, type ReadEventMetadataWithoutGlobalPosition, type ReadStreamOptions, type ReadStreamResult, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, type ScheduleOptions, type ScheduledMessage, type ScheduledMessageProcessor, type StreamPositionTypeOfEventStore, type StreamPositionTypeOfReadEventMetadata, StreamingCoordinator, StringDecoder, type StringifyOptions, type TestEventStream, type ThenThrows, type TypedProjectionDefinition, ValidationErrors, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, WrapEventStore, accept, argMatches, argValue, assertDeepEqual, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUnsignedBigInt, asyncProjections, asyncRetry, canCreateEventStoreSession, caughtUpEventFrom, collect, command, complete, concatUint8Arrays, deepEquals, error, event, formatDateToUtcYYYYMMDD, getInMemoryEventStore, getInMemoryMessageBus, globalStreamCaughtUp, ignore, inlineProjections, isEquatable, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, matchesExpectedVersion, merge, nulloSessionFactory, parseDateFromUtcYYYYMMDD, projection, projections, publish, reply, restream, schedule, send, streamGenerators, streamTrackingGlobalPosition, streamTransformations, sum, verifyThat };
package/dist/index.d.ts CHANGED
@@ -36,6 +36,8 @@ type DefaultCommandMetadata = {
36
36
  now: Date;
37
37
  };
38
38
 
39
+ type BigIntStreamPosition = bigint;
40
+ type BigIntGlobalPosition = bigint;
39
41
  type Event<EventType extends string = string, EventData extends DefaultRecord = DefaultRecord, EventMetaData extends DefaultRecord = DefaultRecord> = Flavour<Readonly<{
40
42
  type: EventType;
41
43
  data: EventData;
@@ -51,17 +53,20 @@ type CreateEventType<EventType extends string, EventData extends DefaultRecord,
51
53
  metadata?: EventMetaData;
52
54
  }>;
53
55
  declare const event: <EventType extends Event>(type: EventTypeOf<EventType>, data: EventDataOf<EventType>, metadata?: EventMetaDataOf<EventType>) => CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataOf<EventType>>;
54
- type ReadEvent<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataType> & EventType & {
56
+ type ReadEvent<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, any>> = CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataType> & EventType & {
55
57
  metadata: EventMetaDataType;
56
58
  };
57
- type ReadEventMetadata = Readonly<{
59
+ type ReadEventMetadata<GlobalPosition = undefined, StreamPosition = BigIntStreamPosition> = Readonly<{
58
60
  eventId: string;
59
- streamPosition: bigint;
61
+ streamPosition: StreamPosition;
60
62
  streamName: string;
61
- }>;
62
- type ReadEventMetadataWithGlobalPosition = ReadEventMetadata & {
63
- globalPosition: bigint;
64
- };
63
+ }> & (GlobalPosition extends undefined ? object : {
64
+ globalPosition: GlobalPosition;
65
+ });
66
+ type ReadEventMetadataWithGlobalPosition<GlobalPosition = BigIntGlobalPosition> = ReadEventMetadata<GlobalPosition>;
67
+ type ReadEventMetadataWithoutGlobalPosition<StreamPosition = BigIntStreamPosition> = ReadEventMetadata<undefined, StreamPosition>;
68
+ type GlobalPositionTypeOfReadEventMetadata<ReadEventMetadataType> = ReadEventMetadataType extends ReadEventMetadata<infer GP, any> ? GP : never;
69
+ type StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType> = ReadEventMetadataType extends ReadEventMetadata<any, infer SV> ? SV : never;
65
70
 
66
71
  type Decider<State, CommandType extends Command, StreamEvent extends Event> = {
67
72
  decide: (command: CommandType, state: State) => StreamEvent | StreamEvent[];
@@ -130,35 +135,37 @@ type Flavour<K, T> = K & {
130
135
  type DefaultRecord = Record<string, unknown>;
131
136
  type NonNullable<T> = T extends null | undefined ? never : T;
132
137
 
133
- type ExpectedStreamVersion<VersionType = DefaultStreamVersionType> = ExpectedStreamVersionWithValue<VersionType> | ExpectedStreamVersionGeneral;
134
- type ExpectedStreamVersionWithValue<VersionType = DefaultStreamVersionType> = Flavour<VersionType, 'StreamVersion'>;
138
+ type ExpectedStreamVersion<VersionType = BigIntStreamPosition> = ExpectedStreamVersionWithValue<VersionType> | ExpectedStreamVersionGeneral;
139
+ type ExpectedStreamVersionWithValue<VersionType = BigIntStreamPosition> = Flavour<VersionType, 'StreamVersion'>;
135
140
  type ExpectedStreamVersionGeneral = Flavour<'STREAM_EXISTS' | 'STREAM_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK', 'StreamVersion'>;
136
141
  declare const STREAM_EXISTS: ExpectedStreamVersionGeneral;
137
142
  declare const STREAM_DOES_NOT_EXIST: ExpectedStreamVersionGeneral;
138
143
  declare const NO_CONCURRENCY_CHECK: ExpectedStreamVersionGeneral;
139
144
  declare const matchesExpectedVersion: <StreamVersion = bigint>(current: StreamVersion | undefined, expected: ExpectedStreamVersion<StreamVersion>, defaultVersion: StreamVersion) => boolean;
140
145
  declare const assertExpectedVersionMatchesCurrent: <StreamVersion = bigint>(current: StreamVersion, expected: ExpectedStreamVersion<StreamVersion> | undefined, defaultVersion: StreamVersion) => void;
141
- declare class ExpectedVersionConflictError<VersionType = DefaultStreamVersionType> extends ConcurrencyError {
146
+ declare class ExpectedVersionConflictError<VersionType = BigIntStreamPosition> extends ConcurrencyError {
142
147
  constructor(current: VersionType, expected: ExpectedStreamVersion<VersionType>);
143
148
  }
144
149
  declare const isExpectedVersionConflictError: (error: unknown) => error is ExpectedVersionConflictError;
145
150
 
146
- interface EventStore<StreamVersion = DefaultStreamVersionType, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> {
147
- aggregateStream<State, EventType extends Event>(streamName: string, options: AggregateStreamOptions<State, EventType, StreamVersion, ReadEventMetadataType>): Promise<AggregateStreamResult<State, StreamVersion>>;
148
- readStream<EventType extends Event>(streamName: string, options?: ReadStreamOptions<StreamVersion>): Promise<ReadStreamResult<EventType, StreamVersion, ReadEventMetadataType>>;
149
- appendToStream<EventType extends Event>(streamName: string, events: EventType[], options?: AppendToStreamOptions<StreamVersion>): Promise<AppendToStreamResult<StreamVersion>>;
151
+ interface EventStore<ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>> {
152
+ aggregateStream<State, EventType extends Event>(streamName: string, options: AggregateStreamOptions<State, EventType, ReadEventMetadataType & EventMetaDataOf<EventType>>): Promise<AggregateStreamResult<State, StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>>;
153
+ readStream<EventType extends Event>(streamName: string, options?: ReadStreamOptions<StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>): Promise<ReadStreamResult<EventType, ReadEventMetadataType & EventMetaDataOf<EventType>>>;
154
+ appendToStream<EventType extends Event>(streamName: string, events: EventType[], options?: AppendToStreamOptions<StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>): Promise<AppendToStreamResult<StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>>;
150
155
  }
151
- type EventStoreSession<EventStoreType extends EventStore<StreamVersion>, StreamVersion = DefaultStreamVersionType> = {
156
+ type EventStoreReadEventMetadata<Store extends EventStore> = Store extends EventStore<infer ReadEventMetadataType> ? ReadEventMetadataType extends ReadEventMetadata<infer GV, infer SV> ? ReadEventMetadata<GV, SV> & ReadEventMetadataType : never : never;
157
+ type GlobalPositionTypeOfEventStore<Store extends EventStore> = GlobalPositionTypeOfReadEventMetadata<EventStoreReadEventMetadata<Store>>;
158
+ type StreamPositionTypeOfEventStore<Store extends EventStore> = StreamPositionTypeOfReadEventMetadata<EventStoreReadEventMetadata<Store>>;
159
+ type EventStoreSession<EventStoreType extends EventStore> = {
152
160
  eventStore: EventStoreType;
153
161
  close: () => Promise<void>;
154
162
  };
155
- interface EventStoreSessionFactory<EventStoreType extends EventStore<StreamVersion>, StreamVersion = DefaultStreamVersionType> {
156
- withSession<T = unknown>(callback: (session: EventStoreSession<EventStoreType, StreamVersion>) => Promise<T>): Promise<T>;
163
+ interface EventStoreSessionFactory<EventStoreType extends EventStore> {
164
+ withSession<T = unknown>(callback: (session: EventStoreSession<EventStoreType>) => Promise<T>): Promise<T>;
157
165
  }
158
- type DefaultStreamVersionType = bigint;
159
- declare const canCreateEventStoreSession: <Store extends EventStore<StreamVersion>, StreamVersion = bigint>(eventStore: Store | EventStoreSessionFactory<Store, StreamVersion>) => eventStore is EventStoreSessionFactory<Store, StreamVersion>;
160
- declare const nulloSessionFactory: <EventStoreType extends EventStore<StreamVersion>, StreamVersion = bigint>(eventStore: EventStoreType) => EventStoreSessionFactory<EventStoreType, StreamVersion>;
161
- type ReadStreamOptions<StreamVersion = DefaultStreamVersionType> = ({
166
+ declare const canCreateEventStoreSession: <Store extends EventStore>(eventStore: Store | EventStoreSessionFactory<Store>) => eventStore is EventStoreSessionFactory<Store>;
167
+ declare const nulloSessionFactory: <EventStoreType extends EventStore>(eventStore: EventStoreType) => EventStoreSessionFactory<EventStoreType>;
168
+ type ReadStreamOptions<StreamVersion = BigIntStreamPosition> = ({
162
169
  from: StreamVersion;
163
170
  } | {
164
171
  to: StreamVersion;
@@ -170,29 +177,40 @@ type ReadStreamOptions<StreamVersion = DefaultStreamVersionType> = ({
170
177
  }) & {
171
178
  expectedStreamVersion?: ExpectedStreamVersion<StreamVersion>;
172
179
  };
173
- type ReadStreamResult<EventType extends Event, StreamVersion = DefaultStreamVersionType, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> = {
174
- currentStreamVersion: StreamVersion;
175
- events: ReadEvent<EventType, ReadEventMetadataType>[];
180
+ type ReadStreamResult<EventType extends Event, ReadEventMetadataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, bigint>> = {
181
+ currentStreamVersion: StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>;
182
+ events: ReadEvent<EventType, ReadEventMetadataType & EventMetaDataOf<EventType>>[];
176
183
  streamExists: boolean;
177
184
  };
178
- type Evolve<State, EventType extends Event, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> = ((currentState: State, event: EventType) => State) | ((currentState: State, event: ReadEvent<EventType, ReadEventMetadataType>) => State) | ((currentState: State, event: ReadEvent<EventType>) => State);
179
- type AggregateStreamOptions<State, EventType extends Event, StreamVersion = DefaultStreamVersionType, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> = {
185
+ type Evolve<State, EventType extends Event, ReadEventMetadataType extends ReadEventMetadata<any, any> & EventMetaDataOf<EventType> = ReadEventMetadata<any, any> & EventMetaDataOf<EventType>> = ((currentState: State, event: EventType) => State) | ((currentState: State, event: ReadEvent<EventType, ReadEventMetadataType>) => State) | ((currentState: State, event: ReadEvent<EventType>) => State);
186
+ type AggregateStreamOptions<State, EventType extends Event, ReadEventMetadataType extends ReadEventMetadata<any, any> & EventMetaDataOf<EventType> = ReadEventMetadata<any, any> & EventMetaDataOf<EventType>> = {
180
187
  evolve: Evolve<State, EventType, ReadEventMetadataType>;
181
188
  initialState: () => State;
182
- read?: ReadStreamOptions<StreamVersion>;
189
+ read?: ReadStreamOptions<StreamPositionTypeOfReadEventMetadata<ReadEventMetadataType>>;
183
190
  };
184
- type AggregateStreamResult<State, StreamVersion = DefaultStreamVersionType> = {
185
- currentStreamVersion: StreamVersion;
191
+ type AggregateStreamResult<State, StreamPosition = BigIntStreamPosition> = {
192
+ currentStreamVersion: StreamPosition;
186
193
  state: State;
187
194
  streamExists: boolean;
188
195
  };
189
- type AppendToStreamOptions<StreamVersion = DefaultStreamVersionType> = {
196
+ type AggregateStreamResultWithGlobalPosition<State, StreamPosition = BigIntStreamPosition, GlobalPosition = BigIntGlobalPosition> = (AggregateStreamResult<State, StreamPosition> & {
197
+ streamExists: true;
198
+ lastEventGlobalPosition: GlobalPosition;
199
+ }) | (AggregateStreamResult<State, StreamPosition> & {
200
+ streamExists: false;
201
+ });
202
+ type AggregateStreamResultOfEventStore<Store extends EventStore> = Store['aggregateStream'] extends (...args: any[]) => Promise<infer R> ? R : never;
203
+ type AppendToStreamOptions<StreamVersion = BigIntStreamPosition> = {
190
204
  expectedStreamVersion?: ExpectedStreamVersion<StreamVersion>;
191
205
  };
192
- type AppendToStreamResult<StreamVersion = DefaultStreamVersionType> = {
206
+ type AppendToStreamResult<StreamVersion = BigIntStreamPosition> = {
193
207
  nextExpectedStreamVersion: StreamVersion;
194
208
  createdNewStream: boolean;
195
209
  };
210
+ type AppendToStreamResultWithGlobalPosition<StreamVersion = BigIntStreamPosition, GlobalPosition = BigIntGlobalPosition> = AppendToStreamResult<StreamVersion> & {
211
+ lastEventGlobalPosition: GlobalPosition;
212
+ };
213
+ type AppendStreamResultOfEventStore<Store extends EventStore> = Store['appendToStream'] extends (...args: any[]) => Promise<infer R> ? R : never;
196
214
 
197
215
  declare const GlobalStreamCaughtUpType = "__emt:GlobalStreamCaughtUp";
198
216
  type GlobalStreamCaughtUp = Event<'__emt:GlobalStreamCaughtUp', {
@@ -209,7 +227,8 @@ type GlobalSubscriptionEvent = GlobalStreamCaughtUp;
209
227
 
210
228
  type EventHandler$1<E extends Event = Event> = (eventEnvelope: ReadEvent<E>) => void;
211
229
  declare const InMemoryEventStoreDefaultStreamVersion = 0n;
212
- declare const getInMemoryEventStore: () => EventStore<DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition>;
230
+ type InMemoryEventStore = EventStore<ReadEventMetadataWithGlobalPosition>;
231
+ declare const getInMemoryEventStore: () => InMemoryEventStore;
213
232
 
214
233
  declare const streamTrackingGlobalPosition: (currentEvents: ReadEvent<Event, ReadEventMetadataWithGlobalPosition>[]) => CaughtUpTransformStream;
215
234
  declare class CaughtUpTransformStream extends TransformStream<ReadEvent<Event, ReadEventMetadataWithGlobalPosition>, ReadEvent<Event, ReadEventMetadataWithGlobalPosition> | GlobalSubscriptionEvent> {
@@ -244,7 +263,7 @@ declare const CommandHandlerStreamVersionConflictRetryOptions: AsyncRetryOptions
244
263
  type CommandHandlerRetryOptions = AsyncRetryOptions | {
245
264
  onVersionConflict: true | number | AsyncRetryOptions;
246
265
  };
247
- type CommandHandlerResult<State, StreamEvent extends Event, StreamVersion = DefaultStreamVersionType> = AppendToStreamResult<StreamVersion> & {
266
+ type CommandHandlerResult<State, StreamEvent extends Event, Store extends EventStore> = AppendStreamResultOfEventStore<Store> & {
248
267
  newState: State;
249
268
  newEvents: StreamEvent[];
250
269
  };
@@ -254,15 +273,15 @@ type CommandHandlerOptions<State, StreamEvent extends Event> = {
254
273
  mapToStreamId?: (id: string) => string;
255
274
  retry?: CommandHandlerRetryOptions;
256
275
  };
257
- type HandleOptions<StreamVersion, Store extends EventStore<StreamVersion>> = Parameters<Store['appendToStream']>[2] & ({
258
- expectedStreamVersion?: ExpectedStreamVersion<StreamVersion>;
276
+ type HandleOptions<Store extends EventStore> = Parameters<Store['appendToStream']>[2] & ({
277
+ expectedStreamVersion?: ExpectedStreamVersion<StreamPositionTypeOfEventStore<Store>>;
259
278
  } | {
260
279
  retry?: CommandHandlerRetryOptions;
261
280
  });
262
- declare const CommandHandler$1: <State, StreamEvent extends Event, StreamVersion = bigint>(options: CommandHandlerOptions<State, StreamEvent>) => <Store extends EventStore<StreamVersion>>(store: Store, id: string, handle: (state: State) => StreamEvent | StreamEvent[] | Promise<StreamEvent> | Promise<StreamEvent[]>, handleOptions?: HandleOptions<StreamVersion, Store>) => Promise<CommandHandlerResult<State, StreamEvent, StreamVersion>>;
281
+ declare const CommandHandler$1: <State, StreamEvent extends Event>(options: CommandHandlerOptions<State, StreamEvent>) => <Store extends EventStore>(store: Store, id: string, handle: (state: State) => StreamEvent | StreamEvent[] | Promise<StreamEvent> | Promise<StreamEvent[]>, handleOptions?: HandleOptions<Store>) => Promise<CommandHandlerResult<State, StreamEvent, Store>>;
263
282
 
264
283
  type DeciderCommandHandlerOptions<State, CommandType extends Command, StreamEvent extends Event> = CommandHandlerOptions<State, StreamEvent> & Decider<State, CommandType, StreamEvent>;
265
- declare const DeciderCommandHandler: <State, CommandType extends Command, StreamEvent extends Event, StreamVersion = bigint>(options: DeciderCommandHandlerOptions<State, CommandType, StreamEvent>) => (eventStore: EventStore<StreamVersion>, id: string, command: CommandType, handleOptions?: HandleOptions<StreamVersion, EventStore<StreamVersion>>) => Promise<CommandHandlerResult<State, StreamEvent, StreamVersion>>;
284
+ declare const DeciderCommandHandler: <State, CommandType extends Command, StreamEvent extends Event>(options: DeciderCommandHandlerOptions<State, CommandType, StreamEvent>) => <Store extends EventStore>(eventStore: Store, id: string, command: CommandType, handleOptions?: HandleOptions<Store>) => Promise<CommandHandlerResult<State, StreamEvent, Store>>;
266
285
 
267
286
  interface CommandSender {
268
287
  send<CommandType extends Command = Command>(command: CommandType): Promise<void>;
@@ -305,31 +324,27 @@ type MessageProcessor = EventProcessor | CommandProcessor;
305
324
  declare const getInMemoryMessageBus: () => MessageBus & EventProcessor & CommandProcessor & ScheduledMessageProcessor;
306
325
 
307
326
  type ProjectionHandlingType = 'inline' | 'async';
308
- type ProjectionHandler<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = (events: ReadEvent<EventType, EventMetaDataType>[], context: ProjectionHandlerContext) => Promise<void> | void;
309
- interface ProjectionDefinition<ProjectionHandlerContext extends DefaultRecord = DefaultRecord> {
327
+ type ProjectionHandler<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = (events: ReadEvent<EventType, EventMetaDataType>[], context: ProjectionHandlerContext) => Promise<void> | void;
328
+ interface ProjectionDefinition<ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> {
310
329
  name?: string;
311
330
  canHandle: CanHandle<Event>;
312
- handle: ProjectionHandler<Event, ReadEventMetadata, ProjectionHandlerContext>;
331
+ handle: ProjectionHandler<Event, ReadEventMetadataType, ProjectionHandlerContext>;
313
332
  }
314
- interface TypedProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> {
333
+ interface TypedProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> {
315
334
  name?: string;
316
335
  canHandle: CanHandle<EventType>;
317
336
  handle: ProjectionHandler<EventType, EventMetaDataType, ProjectionHandlerContext>;
318
337
  }
319
- type ProjectionRegistration<HandlingType extends ProjectionHandlingType, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = {
338
+ type ProjectionRegistration<HandlingType extends ProjectionHandlingType, ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord> = {
320
339
  type: HandlingType;
321
- projection: ProjectionDefinition<ProjectionHandlerContext>;
340
+ projection: ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>;
322
341
  };
323
- declare const projection: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & Readonly<{
324
- eventId: string;
325
- streamPosition: bigint;
326
- streamName: string;
327
- }>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends TypedProjectionDefinition<EventType, EventMetaDataType, ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definition: ProjectionDefintionType) => ProjectionDefintionType;
328
- declare const inlineProjections: <ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"inline", ProjectionHandlerContext>[];
329
- declare const asyncProjections: <ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"async", ProjectionHandlerContext>[];
342
+ declare const projection: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata<any, any> = EventMetaDataOf<EventType> & ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends TypedProjectionDefinition<EventType, EventMetaDataType, ProjectionHandlerContext> = TypedProjectionDefinition<EventType, EventMetaDataType, ProjectionHandlerContext>>(definition: ProjectionDefintionType) => ProjectionDefintionType;
343
+ declare const inlineProjections: <ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext> = ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"inline", ReadEventMetadataType, ProjectionHandlerContext>[];
344
+ declare const asyncProjections: <ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext> = ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"async", ReadEventMetadataType, ProjectionHandlerContext>[];
330
345
  declare const projections: {
331
- inline: <ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"inline", ProjectionHandlerContext>[];
332
- async: <ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ProjectionHandlerContext> = ProjectionDefinition<ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"async", ProjectionHandlerContext>[];
346
+ inline: <ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext> = ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"inline", ReadEventMetadataType, ProjectionHandlerContext>[];
347
+ async: <ReadEventMetadataType extends ReadEventMetadata<any, any> = ReadEventMetadata<any, any>, ProjectionHandlerContext extends DefaultRecord = DefaultRecord, ProjectionDefintionType extends ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext> = ProjectionDefinition<ReadEventMetadataType, ProjectionHandlerContext>>(definitions: ProjectionDefintionType[]) => ProjectionRegistration<"async", ReadEventMetadataType, ProjectionHandlerContext>[];
333
348
  };
334
349
 
335
350
  declare class ParseError extends Error {
@@ -511,14 +526,16 @@ declare const assertThatArray: <T>(array: T[]) => {
511
526
  isEmpty: () => void;
512
527
  isNotEmpty: () => void;
513
528
  hasSize: (length: number) => void;
514
- containsElements: (...other: T[]) => void;
515
- containsExactlyInAnyOrder: (...other: T[]) => void;
529
+ containsElements: (other: T[]) => void;
530
+ containsElementsMatching: (other: T[]) => void;
531
+ containsOnlyElementsMatching: (other: T[]) => void;
532
+ containsExactlyInAnyOrder: (other: T[]) => void;
516
533
  containsExactlyInAnyOrderElementsOf: (other: T[]) => void;
517
534
  containsExactlyElementsOf: (other: T[]) => void;
518
535
  containsExactly: (elem: T) => void;
519
536
  contains: (elem: T) => void;
520
537
  containsOnlyOnceElementsOf: (other: T[]) => void;
521
- containsAnyOf: (...other: T[]) => void;
538
+ containsAnyOf: (other: T[]) => void;
522
539
  allMatch: (matches: (item: T) => boolean) => void;
523
540
  anyMatches: (matches: (item: T) => boolean) => void;
524
541
  allMatchAsync: (matches: (item: T) => Promise<boolean>) => Promise<void>;
@@ -544,14 +561,11 @@ type TestEventStream<EventType extends Event = Event> = [
544
561
  string,
545
562
  EventType[]
546
563
  ];
547
- declare const WrapEventStore: <StreamVersion = bigint, ReadEventMetadataType extends ReadEventMetadata = Readonly<{
548
- eventId: string;
549
- streamPosition: bigint;
550
- streamName: string;
551
- }>>(eventStore: EventStore<StreamVersion, ReadEventMetadataType>) => EventStore<StreamVersion, ReadEventMetadataType> & {
564
+ type EventStoreWrapper<Store extends EventStore> = Store & {
552
565
  appendedEvents: Map<string, TestEventStream>;
553
- setup<EventType extends Event>(streamName: string, events: EventType[]): Promise<AppendToStreamResult<StreamVersion>>;
566
+ setup<EventType extends Event>(streamName: string, events: EventType[]): Promise<AppendToStreamResult<StreamPositionTypeOfEventStore<Store>>>;
554
567
  };
568
+ declare const WrapEventStore: <Store extends EventStore>(eventStore: Store) => EventStoreWrapper<Store>;
555
569
 
556
570
  declare const formatDateToUtcYYYYMMDD: (date: Date) => string;
557
571
  declare const isValidYYYYMMDD: (dateString: string) => boolean;
@@ -568,4 +582,4 @@ declare const assertNotEmptyString: (value: unknown) => string;
568
582
  declare const assertPositiveNumber: (value: unknown) => number;
569
583
  declare const assertUnsignedBigInt: (value: string) => bigint;
570
584
 
571
- export { type AggregateStreamOptions, type AggregateStreamResult, type AppendToStreamOptions, type AppendToStreamResult, type ArgumentMatcher, AssertionError, type AsyncRetryOptions, BinaryJsonDecoder, type Brand, type CanHandle, CaughtUpTransformStream, type Command, type CommandBus, type CommandDataOf, CommandHandler$1 as CommandHandler, type CommandHandlerOptions, type CommandHandlerResult, type CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, type CommandMetaDataOf, type CommandProcessor, type CommandSender, type CommandTypeOf, CompositeDecoder, ConcurrencyError, type CreateCommandType, type CreateEventType, type Decider, DeciderCommandHandler, type DeciderCommandHandlerOptions, type DeciderSpecfication, DeciderSpecification, type Decoder, type DeepReadonly, type DefaultCommandMetadata, DefaultDecoder, type DefaultRecord, type DefaultStreamVersionType, type Equatable, ErrorConstructor, type Event, type EventBus, type EventDataOf, type EventHandler$1 as EventHandler, type EventMetaDataOf, type EventProcessor, type EventStore, type EventStoreSession, type EventStoreSessionFactory, type EventTypeOf, type EventsPublisher, type ExpectedStreamVersion, type ExpectedStreamVersionGeneral, type ExpectedStreamVersionWithValue, ExpectedVersionConflictError, type Flavour, type GlobalStreamCaughtUp, GlobalStreamCaughtUpType, type GlobalSubscriptionEvent, type HandleOptions, InMemoryEventStoreDefaultStreamVersion, JSONParser, JsonDecoder, type Mapper, type MapperArgs, type MessageBus, type MessageHandler, type MessageProcessor, type MessageScheduler, type MockedFunction, type Mutable, NO_CONCURRENCY_CHECK, NoRetries, type NonNullable, ObjectDecoder, ParseError, type ParseOptions, type ProjectionDefinition, type ProjectionHandler, type ProjectionHandlingType, type ProjectionRegistration, type ReadEvent, type ReadEventMetadata, type ReadEventMetadataWithGlobalPosition, type ReadStreamOptions, type ReadStreamResult, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, type ScheduleOptions, type ScheduledMessage, type ScheduledMessageProcessor, StreamingCoordinator, StringDecoder, type StringifyOptions, type TestEventStream, type ThenThrows, type TypedProjectionDefinition, ValidationErrors, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, WrapEventStore, accept, argMatches, argValue, assertDeepEqual, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUnsignedBigInt, asyncProjections, asyncRetry, canCreateEventStoreSession, caughtUpEventFrom, collect, command, complete, concatUint8Arrays, deepEquals, error, event, formatDateToUtcYYYYMMDD, getInMemoryEventStore, getInMemoryMessageBus, globalStreamCaughtUp, ignore, inlineProjections, isEquatable, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, matchesExpectedVersion, merge, nulloSessionFactory, parseDateFromUtcYYYYMMDD, projection, projections, publish, reply, restream, schedule, send, streamGenerators, streamTrackingGlobalPosition, streamTransformations, sum, verifyThat };
585
+ export { type AggregateStreamOptions, type AggregateStreamResult, type AggregateStreamResultOfEventStore, type AggregateStreamResultWithGlobalPosition, type AppendStreamResultOfEventStore, type AppendToStreamOptions, type AppendToStreamResult, type AppendToStreamResultWithGlobalPosition, type ArgumentMatcher, AssertionError, type AsyncRetryOptions, type BigIntGlobalPosition, type BigIntStreamPosition, BinaryJsonDecoder, type Brand, type CanHandle, CaughtUpTransformStream, type Command, type CommandBus, type CommandDataOf, CommandHandler$1 as CommandHandler, type CommandHandlerOptions, type CommandHandlerResult, type CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, type CommandMetaDataOf, type CommandProcessor, type CommandSender, type CommandTypeOf, CompositeDecoder, ConcurrencyError, type CreateCommandType, type CreateEventType, type Decider, DeciderCommandHandler, type DeciderCommandHandlerOptions, type DeciderSpecfication, DeciderSpecification, type Decoder, type DeepReadonly, type DefaultCommandMetadata, DefaultDecoder, type DefaultRecord, type Equatable, ErrorConstructor, type Event, type EventBus, type EventDataOf, type EventHandler$1 as EventHandler, type EventMetaDataOf, type EventProcessor, type EventStore, type EventStoreReadEventMetadata, type EventStoreSession, type EventStoreSessionFactory, type EventStoreWrapper, type EventTypeOf, type EventsPublisher, type ExpectedStreamVersion, type ExpectedStreamVersionGeneral, type ExpectedStreamVersionWithValue, ExpectedVersionConflictError, type Flavour, type GlobalPositionTypeOfEventStore, type GlobalPositionTypeOfReadEventMetadata, type GlobalStreamCaughtUp, GlobalStreamCaughtUpType, type GlobalSubscriptionEvent, type HandleOptions, type InMemoryEventStore, InMemoryEventStoreDefaultStreamVersion, JSONParser, JsonDecoder, type Mapper, type MapperArgs, type MessageBus, type MessageHandler, type MessageProcessor, type MessageScheduler, type MockedFunction, type Mutable, NO_CONCURRENCY_CHECK, NoRetries, type NonNullable, ObjectDecoder, ParseError, type ParseOptions, type ProjectionDefinition, type ProjectionHandler, type ProjectionHandlingType, type ProjectionRegistration, type ReadEvent, type ReadEventMetadata, type ReadEventMetadataWithGlobalPosition, type ReadEventMetadataWithoutGlobalPosition, type ReadStreamOptions, type ReadStreamResult, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, type ScheduleOptions, type ScheduledMessage, type ScheduledMessageProcessor, type StreamPositionTypeOfEventStore, type StreamPositionTypeOfReadEventMetadata, StreamingCoordinator, StringDecoder, type StringifyOptions, type TestEventStream, type ThenThrows, type TypedProjectionDefinition, ValidationErrors, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, WrapEventStore, accept, argMatches, argValue, assertDeepEqual, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUnsignedBigInt, asyncProjections, asyncRetry, canCreateEventStoreSession, caughtUpEventFrom, collect, command, complete, concatUint8Arrays, deepEquals, error, event, formatDateToUtcYYYYMMDD, getInMemoryEventStore, getInMemoryMessageBus, globalStreamCaughtUp, ignore, inlineProjections, isEquatable, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, matchesExpectedVersion, merge, nulloSessionFactory, parseDateFromUtcYYYYMMDD, projection, projections, publish, reply, restream, schedule, send, streamGenerators, streamTrackingGlobalPosition, streamTransformations, sum, verifyThat };