import type { ICommand, ICommandBus, Identifier, IEvent, IEventStore, IMutableState, ISaga, ISagaConstructor, ISagaConstructorParams } from './interfaces/index.ts'; import { SagaEventHandler } from './SagaEventHandler.ts'; /** * Base class for Saga definition */ export declare abstract class AbstractSaga implements ISaga { #private; /** * Optional list of events that start new saga. * * When not defined, saga start is inferred by the absence of `message.sagaOrigins[sagaDescriptor]`. */ static get startsWith(): string[] | undefined; /** List of event types being handled by Saga, can be overridden in Saga implementation */ static get handles(): string[]; /** * Convenience helper to create a `SagaEventHandler` for this saga type and subscribe it to * the provided `eventStore`. */ static register(this: ISagaConstructor & (new (options: ISagaConstructorParams) => T), eventStore: IEventStore, commandBus: ICommandBus): SagaEventHandler; /** Saga ID */ get id(): Identifier; /** Saga version */ get version(): number; protected state?: IMutableState | object; /** * Creates an instance of AbstractSaga */ constructor(options: ISagaConstructorParams); /** Modify saga state by applying an event */ mutate(event: IEvent): void; /** Process saga event and return produced commands */ handle(event: IEvent): Promise>; /** Format a command and put it to the execution queue */ protected enqueue(commandType: string): void; protected enqueue(commandType: string, aggregateId: Identifier): void; protected enqueue(commandType: string, aggregateId: Identifier | undefined, payload: T): void; /** Put a command to the execution queue */ protected enqueueRaw(command: ICommand): void; /** Get human-readable Saga name */ toString(): string; }