@pooflabs/core 0.0.48 → 0.0.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ export type StorageTier = 'durable' | 'checkpointed' | 'ephemeral';
2
+ export type SubscriptionStatus = 'idle' | 'cached' | 'loading' | 'live' | 'error' | 'reconnecting';
3
+ export type DeltaChange = 'added' | 'modified' | 'removed';
4
+ export interface SubscriptionState<T = any> {
5
+ data: T[];
6
+ status: SubscriptionStatus;
7
+ isStale: boolean;
8
+ error: Error | null;
9
+ }
10
+ export interface SubscribeOptions {
11
+ tier?: StorageTier;
12
+ filter?: Record<string, any>;
13
+ prompt?: string;
14
+ includeSubPaths?: boolean;
15
+ limit?: number;
16
+ onData?: (data: any) => void;
17
+ onState?: (state: SubscriptionState) => void;
18
+ onError?: (error: Error) => void;
19
+ mode?: 'callback' | 'ref';
20
+ }
21
+ export declare class RealtimeStore {
22
+ private ws;
23
+ private wsUrl;
24
+ private appId;
25
+ private subscriptions;
26
+ private pendingRequests;
27
+ private connectPromise;
28
+ private reconnectTimer;
29
+ private reconnectDelay;
30
+ private maxReconnectDelay;
31
+ private idbFlushTimer;
32
+ private idbDirtyKeys;
33
+ private closed;
34
+ private authToken;
35
+ init(): Promise<void>;
36
+ private ensureConnected;
37
+ private connect;
38
+ private scheduleReconnect;
39
+ private resubscribeAll;
40
+ private handleMessage;
41
+ private handleSnapshot;
42
+ private handleDelta;
43
+ private handleLegacyData;
44
+ private handleResult;
45
+ private handleError;
46
+ subscribe(path: string, opts?: SubscribeOptions): Promise<() => Promise<void>>;
47
+ getRef(path: string, opts?: SubscribeOptions): {
48
+ current: Map<string, any>;
49
+ };
50
+ set(path: string, doc: any): Promise<any>;
51
+ get(path: string): Promise<any>;
52
+ getMany(paths: string[]): Promise<Record<string, any>>;
53
+ delete(path: string): Promise<void>;
54
+ query(path: string, opts?: {
55
+ filter?: any;
56
+ sort?: any;
57
+ limit?: number;
58
+ includeSubPaths?: boolean;
59
+ }): Promise<any[]>;
60
+ count(path: string): Promise<number>;
61
+ aggregate(path: string, operation: string, opts?: {
62
+ field?: string;
63
+ }): Promise<any>;
64
+ private sendSubscribe;
65
+ private sendRequest;
66
+ private notifySubscription;
67
+ private notifyState;
68
+ private getState;
69
+ private docsToArray;
70
+ private findSubscriptionById;
71
+ private findSubscriptionByPath;
72
+ private getCollectionPath;
73
+ private getSubKey;
74
+ private idbKey;
75
+ private markIdbDirty;
76
+ private flushIdb;
77
+ private createUnsubscribe;
78
+ private resolveOperations;
79
+ private rejectAllPending;
80
+ private setAllSubscriptionStatus;
81
+ close(): void;
82
+ }
83
+ export declare function getRealtimeStore(): RealtimeStore;
84
+ export declare function resetRealtimeStore(): void;
@@ -40,6 +40,23 @@ export declare function reconnectWithNewAuthV2(): Promise<void>;
40
40
  * a complete teardown and rebuild of connections.
41
41
  */
42
42
  export declare function forceReconnectV2(): Promise<void>;
43
+ /**
44
+ * Returns true if there is an active v2 WebSocket connection open.
45
+ */
46
+ export declare function hasActiveConnection(): boolean;
47
+ export declare function wsGet(path: string): Promise<any>;
48
+ export declare function wsSet(documents: Array<{
49
+ destinationPath: string;
50
+ document: any;
51
+ }>): Promise<any>;
52
+ export declare function wsQuery(path: string, opts?: {
53
+ filter?: any;
54
+ sort?: any;
55
+ limit?: number;
56
+ includeSubPaths?: boolean;
57
+ }): Promise<any>;
58
+ export declare function wsDelete(path: string): Promise<any>;
59
+ export declare function wsGetMany(paths: string[]): Promise<any>;
43
60
  declare global {
44
61
  interface Window {
45
62
  CUSTOM_TAROBASE_APP_ID_HEADER?: string;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { init } from './client/config';
2
2
  export { getConfig, ClientConfig } from './client/config';
3
3
  export { get, getMany, set, setMany, setFile, getFiles, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, count, aggregate, RequestOverrides, SetOptions, GetOptions, RunQueryOptions, CountOptions, AggregateOptions, AggregateOperation, AggregateResult, RunExpressionOptions, RunExpressionResult, InsufficientBalanceError, GetManyResult } from './client/operations';
4
4
  export { subscribe, closeAllSubscriptions, clearCache, getCachedData, reconnectWithNewAuth } from './client/subscription';
5
+ export { hasActiveConnection, wsGet, wsSet, wsQuery, wsDelete, wsGetMany } from './client/subscription-v2';
5
6
  export * from './types';
6
7
  export { getIdToken } from './utils/utils';
7
8
  export { WebSessionManager } from './utils/web-session-manager';
@@ -12,3 +13,5 @@ export { createSessionWithPrivy, createSessionWithSignature, refreshSession, sig
12
13
  export { Tarobase as Tarobase6 } from './utils/sol/taro6CvKqwrYrDc16ufYgzQ2NZcyyVKStffbtudrhRuDevnet-program';
13
14
  export { Tarobase as TarobasePoof } from './utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpMainnet-program';
14
15
  export { buildSetDocumentsTransaction, convertRemainingAccounts, RemainingAccount, genSolanaMessage } from './utils/sol/sol-utils';
16
+ export { RealtimeStore, getRealtimeStore, resetRealtimeStore } from './client/realtime-store';
17
+ export type { StorageTier, SubscriptionStatus, SubscriptionState, SubscribeOptions, DeltaChange } from './client/realtime-store';