import { RealtimeProvider } from "@rebasepro/types"; /** * A realtime client message as forwarded by the WebSocket server. */ interface ClientMessage { type: string; payload?: Record; subscriptionId?: string; } /** * The concrete realtime service surface the WebSocket server drives — the * typed {@link RealtimeProvider} plus the client-connection methods that * every engine's realtime service implements. */ export interface WsRealtimeService extends RealtimeProvider { addClient(clientId: string, ws: unknown): void; handleClientMessage(clientId: string, message: ClientMessage, authContext?: unknown): Promise | void; } export interface RoutedRealtimeOptions { /** Per-engine realtime providers, keyed by data-source key. */ providers: Record; /** Key of the default provider (handles channels/presence/broadcast). */ defaultKey: string; /** Resolve a collection path to its data-source key. */ resolveKey: (collectionPath: string) => string; } /** * Compose multiple per-engine {@link RealtimeProvider}s into one that routes * each subscription to the provider owning the subscribed collection — the * realtime counterpart of `buildRoutedRebaseData`. * * The WebSocket server stays single and engine-agnostic; this composite is * passed in its place. Routing rules: * - `subscribe_collection` / `subscribe_entity` → the provider for the * collection's data source (by `payload.path`). * - `unsubscribe` → forwarded to all providers (a no-op on non-owners). * - channel / presence / broadcast → the default provider (these are global * pub/sub, not bound to an engine). * - `addClient` and lifecycle (`onServerReady`/`destroy`/`stopListening`) → * all providers (each registers its own ws close handler for cleanup). */ export declare function createRoutedRealtimeService(opts: RoutedRealtimeOptions): WsRealtimeService; export {};