import type { Kysely } from 'kysely'; import type { EventListener } from './types.js'; /** * Simple pub/sub event bus that supports two dispatch modes: * - sync: invoke listeners directly in sequence * - async (default): enqueue the event as a background job via the database */ export declare class EventBus { private readonly listeners; private db; /** Provide the database connection used for async event dispatch. */ setDb(db: Kysely): void; /** Register a listener for a specific event. */ on(event: string, handler: (payload: unknown) => Promise, source?: string): void; /** * Emit an event. By default, the event is enqueued as a background job. * Pass { sync: true } to invoke listeners immediately in sequence. */ emit(event: string, payload: unknown, options?: { sync?: boolean; }): Promise; /** * Emit an event within an existing database transaction. * Sync mode invokes listeners directly; async mode enqueues via the transaction. */ emitWithTrx(event: string, payload: unknown, trx: Kysely, options?: { sync?: boolean; }): Promise; /** Return all listeners registered for a given event. */ getListeners(event: string): EventListener[]; /** Return the names of all events that have at least one listener. */ getAllEvents(): string[]; /** Check whether any listeners are registered for a given event. */ hasListeners(event: string): boolean; /** Invoke all listeners for an event synchronously, one after another. */ private dispatchSync; /** Enqueue the event as a background job via the database. */ private dispatchAsync; } //# sourceMappingURL=bus.d.ts.map