import type { Logger } from '@kubun/logger'; import { type UnsubscribeFunction } from '@sozai/event'; /** * Map of event names to their data types. * Uses `Record` so any namespaced string key is valid. */ type EventMap = Record; /** * Transaction-aware event bus built on top of `@sozai/event`. * * Events emitted outside a transaction fire immediately. * Events emitted inside a transaction are buffered until commit, * and discarded on rollback. */ export declare class EngineEventBus { #private; constructor(options?: { logger?: Logger; }); /** * Subscribe to a namespaced event. * Returns an unsubscribe function. */ on(name: TName, listener: (data: TEvents[TName]) => void | Promise): UnsubscribeFunction; /** * Emit an event immediately (not inside any transaction). */ emit(name: TName, data: TEvents[TName]): Promise; /** * Begin a new transaction context for event buffering. * Events emitted via `emitBuffered` with this transaction ID * will be held until `commit` or `rollback` is called. */ beginTransaction(transactionID: string): void; /** * Emit an event inside a transaction. The event is buffered * and will only be delivered to listeners upon commit. */ emitBuffered(transactionID: string, name: TName, data: TEvents[TName]): void; /** * Commit a transaction: release all buffered events to listeners * in the order they were emitted. * * Listener errors do not prevent remaining buffered events from firing. * Since `@sozai/event` uses `Promise.allSettled` internally, all listeners * for a given event run even if some throw. Errors from individual event * emissions are caught so the full buffer is always drained. */ commit(transactionID: string): Promise; /** * Rollback a transaction: discard all buffered events. */ rollback(transactionID: string): void; } export {};