import type { Store } from '../core/index.js'; import type { WorkOSWebhookEndpoint, WorkOSEvent } from './entities.js'; import type { WorkOSEventName } from './constants.js'; export interface EventPayload { event: WorkOSEventName | string; data: Record; /** The organization the event occurred within, for payloads whose `data.organization_id` does not say. */ organization_id?: string | null; environment_id?: string; /** Spec `context` envelope, delivered alongside `data` to webhook endpoints. */ context?: Record; } export interface WebhookRetryConfig { maxRetries: number; initialDelayMs: number; maxDelayMs: number; backoffMultiplier: number; } export interface EventBusOptions { retryConfig?: WebhookRetryConfig; debugMode?: boolean; } export declare class EventBus { private store; private endpointsByEvent; private catchAllEndpoints; private deadLetterQueue; private retryConfig; private debugMode; constructor(store: Store, options?: EventBusOptions); /** Rebuild the event-type index. Auto-called via collection hooks; call manually only in tests. */ rebuildIndex(): void; emit(payload: EventPayload): void; private deliver; private sleep; /** Get the dead letter queue for inspection/testing */ getDeadLetterQueue(): Array<{ endpoint: WorkOSWebhookEndpoint; event: WorkOSEvent; error: Error; }>; /** Clear the dead letter queue */ clearDeadLetterQueue(): void; /** Retry all webhooks in the dead letter queue */ retryDeadLetterQueue(): Promise<{ success: number; failed: number; }>; }