export type StorageTier = 'durable' | 'checkpointed' | 'ephemeral'; export type SubscriptionStatus = 'idle' | 'cached' | 'loading' | 'live' | 'error' | 'reconnecting'; export type DeltaChange = 'added' | 'modified' | 'removed'; export interface SubscriptionState { data: T[]; status: SubscriptionStatus; isStale: boolean; error: Error | null; } export interface SubscribeOptions { tier?: StorageTier; /** * Opt into IndexedDB-backed stale snapshot delivery for this legacy store * subscription. Anonymous/no-auth subscriptions never use persisted snapshots. */ cache?: boolean; filter?: Record; prompt?: string; includeSubPaths?: boolean; limit?: number; onData?: (data: any) => void; onState?: (state: SubscriptionState) => void; onError?: (error: Error) => void; mode?: 'callback' | 'ref'; } export declare class RealtimeStore { private ws; private wsUrl; private appId; private subscriptions; private pendingRequests; private connectPromise; private reconnectTimer; private reconnectDelay; private maxReconnectDelay; private idbFlushTimer; private idbDirtyKeys; private closed; private authToken; private authPrincipalKey; private authenticating; private suppressNextReconnect; init(): Promise; private isServer; private tokenRefreshTimer; private refreshToken; private startTokenRefresh; private ensureInitialized; private ensureCurrentAuth; private rekeySubscriptionsForPrincipal; private applyAuthPrincipalChange; private initPromise; private ensureConnected; private connect; private scheduleReconnect; private resubscribeAll; private handleMessage; private handleSnapshot; private handleDelta; private handleLegacyData; private handleResult; private handleError; subscribe(path: string, opts?: SubscribeOptions): Promise<() => Promise>; getRef(path: string, opts?: SubscribeOptions): { current: Map; }; set(path: string, doc: any): Promise; get(path: string): Promise; getMany(paths: string[]): Promise>; delete(path: string): Promise; query(path: string, opts?: { filter?: any; sort?: any; limit?: number; includeSubPaths?: boolean; }): Promise; count(path: string): Promise; aggregate(path: string, operation: string, opts?: { field?: string; }): Promise; private sendSubscribe; private sendRequest; private notifySubscription; private notifyState; private getState; private docsToArray; private findSubscriptionById; private findSubscriptionByPath; private getCollectionPath; private getSubKey; private idbKey; private shouldUseIdb; private markIdbDirty; private flushIdb; private createUnsubscribe; private resolveOperations; private rejectAllPending; private setAllSubscriptionStatus; close(): void; reconnectWithNewAuth(): Promise; } export declare function getRealtimeStore(): RealtimeStore; export declare function resetRealtimeStore(): void; export declare function reconnectRealtimeStoreWithNewAuth(): Promise;