/** * WebSocket Subscription Module * * This module provides real-time data subscriptions using WebSocket v2 protocol * with multiplexed connections (one connection per client, multiple subscriptions). * * The external API remains unchanged - just use subscribe(path, options) as before. */ import { SubscriptionOptions } from '../types'; /** * Subscribe to real-time updates for a path. * * @param path - The path to subscribe to (e.g., 'users/123' or 'posts') * @param subscriptionOptions - Options including onData and onError callbacks * @returns A function to unsubscribe * * @example * ```typescript * const unsubscribe = await subscribe('users/123', { * onData: (data) => console.log('User updated:', data), * onError: (error) => console.error('Subscription error:', error), * }); * * // Later, to unsubscribe: * await unsubscribe(); * ``` */ export declare function subscribe(path: string, subscriptionOptions: SubscriptionOptions | ((data: any) => void)): Promise<() => Promise>; /** * Close all active subscriptions. * Call this when cleaning up (e.g., on logout or component unmount). */ export declare function closeAllSubscriptions(): Promise; /** * Clear the subscription cache. * * @param path - Optional path to clear. If not provided, clears all cached data. */ export declare function clearCache(path?: string): void; /** * Get cached data for a path without making a network request. * * @param path - The path to get cached data for * @param prompt - Optional prompt that was used for the subscription * @returns The cached data, or null if not cached or expired */ export declare function getCachedData(path: string, prompt?: string): any | null; /** * Reconnect all WebSocket connections with fresh authentication. * Call this when the user's auth state changes (login/logout). * * This will: * 1. Close existing connections * 2. Re-establish with new auth token * 3. Re-subscribe to all active paths * * Existing subscriptions will receive new initial data after reconnection. */ export declare function reconnectWithNewAuth(): Promise;