@topgunbuild/client 0.9.0 → 0.10.1

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.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { LWWRecord, ORMapRecord, PredicateNode, ConflictResolverDef, MergeRejection, Timestamp, LWWMap, ORMap, HLC, EntryProcessorDef, EntryProcessorResult, SearchOptions, PNCounter, PNCounterState, JournalEvent, JournalEventType, NodeHealth, ConnectionPoolConfig, PartitionRouterConfig, PartitionMap, ClusterClientConfig } from '@topgunbuild/core';
1
+ import { LWWRecord, ORMapRecord, PredicateNode, ConflictResolverDef, MergeRejection, Timestamp, LWWMap, ORMap, HLC, EntryProcessorDef, EntryProcessorResult, SearchOptions, HybridQueryRespPayload, HybridQueryDeltaPayload, PNCounter, PNCounterState, JournalEvent, JournalEventType, NodeHealth, ConnectionPoolConfig, PartitionRouterConfig, PartitionMap, ClusterClientConfig } from '@topgunbuild/core';
2
2
  export { LWWMap, LWWRecord, PredicateNode, Predicates } from '@topgunbuild/core';
3
3
  import pino from 'pino';
4
4
 
@@ -99,7 +99,19 @@ interface QueryFilter {
99
99
  predicate?: PredicateNode;
100
100
  sort?: Record<string, 'asc' | 'desc'>;
101
101
  limit?: number;
102
- offset?: number;
102
+ /** Cursor for pagination */
103
+ cursor?: string;
104
+ }
105
+ /** Cursor status for debugging */
106
+ type CursorStatus = 'valid' | 'expired' | 'invalid' | 'none';
107
+ /** Pagination info from server */
108
+ interface PaginationInfo {
109
+ /** Cursor for fetching next page */
110
+ nextCursor?: string;
111
+ /** Whether more results are available */
112
+ hasMore: boolean;
113
+ /** Debug info: status of input cursor processing */
114
+ cursorStatus: CursorStatus;
103
115
  }
104
116
  /** Source of query results for proper handling of race conditions */
105
117
  type QueryResultSource = 'local' | 'server';
@@ -117,6 +129,8 @@ declare class QueryHandle<T> {
117
129
  private changeTracker;
118
130
  private pendingChanges;
119
131
  private changeListeners;
132
+ private _paginationInfo;
133
+ private paginationListeners;
120
134
  constructor(syncEngine: SyncEngine, mapName: string, filter?: QueryFilter);
121
135
  subscribe(callback: (results: QueryResultItem<T>[]) => void): () => void;
122
136
  private loadInitialLocalData;
@@ -142,7 +156,7 @@ declare class QueryHandle<T> {
142
156
  */
143
157
  onUpdate(key: string, value: T | null): void;
144
158
  /**
145
- * Subscribe to change events (Phase 5.1).
159
+ * Subscribe to change events.
146
160
  * Returns an unsubscribe function.
147
161
  *
148
162
  * @example
@@ -158,25 +172,25 @@ declare class QueryHandle<T> {
158
172
  */
159
173
  onChanges(listener: (changes: ChangeEvent<T>[]) => void): () => void;
160
174
  /**
161
- * Get and clear pending changes (Phase 5.1).
175
+ * Get and clear pending changes.
162
176
  * Call this to retrieve all changes since the last consume.
163
177
  */
164
178
  consumeChanges(): ChangeEvent<T>[];
165
179
  /**
166
- * Get last change without consuming (Phase 5.1).
180
+ * Get last change without consuming.
167
181
  * Returns null if no pending changes.
168
182
  */
169
183
  getLastChange(): ChangeEvent<T> | null;
170
184
  /**
171
- * Get all pending changes without consuming (Phase 5.1).
185
+ * Get all pending changes without consuming.
172
186
  */
173
187
  getPendingChanges(): ChangeEvent<T>[];
174
188
  /**
175
- * Clear all pending changes (Phase 5.1).
189
+ * Clear all pending changes.
176
190
  */
177
191
  clearChanges(): void;
178
192
  /**
179
- * Reset change tracker (Phase 5.1).
193
+ * Reset change tracker.
180
194
  * Use when query filter changes or on reconnect.
181
195
  */
182
196
  resetChangeTracker(): void;
@@ -186,6 +200,26 @@ declare class QueryHandle<T> {
186
200
  private getSortedResults;
187
201
  getFilter(): QueryFilter;
188
202
  getMapName(): string;
203
+ /**
204
+ * Get current pagination info.
205
+ * Returns nextCursor, hasMore, and cursorStatus.
206
+ */
207
+ getPaginationInfo(): PaginationInfo;
208
+ /**
209
+ * Subscribe to pagination info changes.
210
+ * Called when server sends QUERY_RESP with new cursor info.
211
+ *
212
+ * @returns Unsubscribe function
213
+ */
214
+ onPaginationChange(listener: (info: PaginationInfo) => void): () => void;
215
+ /**
216
+ * Update pagination info from server response.
217
+ * Called by SyncEngine when processing QUERY_RESP.
218
+ *
219
+ * @internal
220
+ */
221
+ updatePaginationInfo(info: Partial<PaginationInfo>): void;
222
+ private notifyPaginationListeners;
189
223
  }
190
224
 
191
225
  /**
@@ -196,8 +230,6 @@ declare class QueryHandle<T> {
196
230
  * - Score-based sorting (_score field)
197
231
  * - Hybrid queries combining FTS with traditional filters
198
232
  *
199
- * Part of Phase 12: Unified Search
200
- *
201
233
  * @module HybridQueryHandle
202
234
  */
203
235
 
@@ -213,8 +245,8 @@ interface HybridQueryFilter {
213
245
  sort?: Record<string, 'asc' | 'desc'>;
214
246
  /** Maximum results */
215
247
  limit?: number;
216
- /** Skip N results */
217
- offset?: number;
248
+ /** Cursor for pagination */
249
+ cursor?: string;
218
250
  }
219
251
  /**
220
252
  * Result item with score for hybrid queries.
@@ -265,6 +297,8 @@ declare class HybridQueryHandle<T> {
265
297
  private pendingChanges;
266
298
  private changeListeners;
267
299
  private hasReceivedServerData;
300
+ private _paginationInfo;
301
+ private paginationListeners;
268
302
  constructor(syncEngine: SyncEngine, mapName: string, filter?: HybridQueryFilter);
269
303
  /**
270
304
  * Subscribe to query results.
@@ -328,9 +362,29 @@ declare class HybridQueryHandle<T> {
328
362
  */
329
363
  hasFTSPredicate(): boolean;
330
364
  private containsFTS;
365
+ /**
366
+ * Get current pagination info.
367
+ * Returns nextCursor, hasMore, and cursorStatus.
368
+ */
369
+ getPaginationInfo(): PaginationInfo;
370
+ /**
371
+ * Subscribe to pagination info changes.
372
+ * Called when server sends HYBRID_QUERY_RESP with new cursor info.
373
+ *
374
+ * @returns Unsubscribe function
375
+ */
376
+ onPaginationChange(listener: (info: PaginationInfo) => void): () => void;
377
+ /**
378
+ * Update pagination info from server response.
379
+ * Called by SyncEngine when processing HYBRID_QUERY_RESP.
380
+ *
381
+ * @internal
382
+ */
383
+ updatePaginationInfo(info: Partial<PaginationInfo>): void;
384
+ private notifyPaginationListeners;
331
385
  }
332
386
 
333
- type TopicCallback = (data: any, context: {
387
+ type TopicCallback<T = unknown> = (data: T, context: {
334
388
  timestamp: number;
335
389
  publisherId?: string;
336
390
  }) => void;
@@ -343,7 +397,7 @@ declare class TopicHandle {
343
397
  /**
344
398
  * Publish a message to the topic
345
399
  */
346
- publish(data: any): void;
400
+ publish(data: unknown): void;
347
401
  /**
348
402
  * Subscribe to the topic
349
403
  */
@@ -352,7 +406,7 @@ declare class TopicHandle {
352
406
  /**
353
407
  * Called by SyncEngine when a message is received
354
408
  */
355
- onMessage(data: any, context: {
409
+ onMessage(data: unknown, context: {
356
410
  timestamp: number;
357
411
  publisherId?: string;
358
412
  }): void;
@@ -781,6 +835,13 @@ declare class ConflictResolverClient {
781
835
  get rejectionListenerCount(): number;
782
836
  }
783
837
 
838
+ /**
839
+ * Sync Module Types
840
+ *
841
+ * Types and interfaces for the sync module that handles
842
+ * WebSocket/connection operations and query management for SyncEngine.
843
+ */
844
+
784
845
  /**
785
846
  * Search result item from server.
786
847
  */
@@ -790,6 +851,7 @@ interface SearchResult<T> {
790
851
  score: number;
791
852
  matchedTerms: string[];
792
853
  }
854
+
793
855
  interface HeartbeatConfig {
794
856
  intervalMs: number;
795
857
  timeoutMs: number;
@@ -807,50 +869,63 @@ interface BackoffConfig {
807
869
  /** Maximum number of retry attempts before entering ERROR state (default: 10) */
808
870
  maxRetries: number;
809
871
  }
872
+ interface TopicQueueConfig {
873
+ /** Maximum queued topic messages when offline (default: 100) */
874
+ maxSize: number;
875
+ /** Strategy when queue is full: 'drop-oldest' | 'drop-newest' (default: 'drop-oldest') */
876
+ strategy: 'drop-oldest' | 'drop-newest';
877
+ }
810
878
  interface SyncEngineConfig {
811
879
  nodeId: string;
812
- /** @deprecated Use connectionProvider instead */
813
- serverUrl?: string;
814
- /** Connection provider (preferred over serverUrl) */
815
- connectionProvider?: IConnectionProvider;
880
+ /** Connection provider for WebSocket connections */
881
+ connectionProvider: IConnectionProvider;
816
882
  storageAdapter: IStorageAdapter;
817
883
  reconnectInterval?: number;
818
884
  heartbeat?: Partial<HeartbeatConfig>;
819
885
  backoff?: Partial<BackoffConfig>;
820
886
  backpressure?: Partial<BackpressureConfig>;
887
+ /** Configuration for offline topic message queue */
888
+ topicQueue?: Partial<TopicQueueConfig>;
821
889
  }
822
890
  declare class SyncEngine {
823
891
  private readonly nodeId;
824
- private readonly serverUrl;
825
892
  private readonly storageAdapter;
826
893
  private readonly hlc;
827
894
  private readonly stateMachine;
895
+ private readonly heartbeatConfig;
828
896
  private readonly backoffConfig;
829
- private readonly connectionProvider;
830
- private readonly useConnectionProvider;
831
- private websocket;
897
+ private readonly webSocketManager;
898
+ private readonly queryManager;
899
+ private readonly topicManager;
900
+ private readonly lockManager;
901
+ private readonly writeConcernManager;
902
+ private readonly counterManager;
903
+ private readonly entryProcessorClient;
904
+ private readonly searchClient;
905
+ private readonly merkleSyncHandler;
906
+ private readonly orMapSyncHandler;
907
+ private readonly messageRouter;
832
908
  private opLog;
833
909
  private maps;
834
- private queries;
835
- private topics;
836
- private pendingLockRequests;
837
910
  private lastSyncTimestamp;
838
- private reconnectTimer;
839
911
  private authToken;
840
912
  private tokenProvider;
841
- private backoffAttempt;
842
- private readonly heartbeatConfig;
843
- private heartbeatInterval;
844
- private lastPongReceived;
845
- private lastRoundTripTime;
846
913
  private readonly backpressureConfig;
847
- private backpressurePaused;
848
- private waitingForCapacity;
849
- private highWaterMarkEmitted;
850
- private backpressureListeners;
851
- private pendingWriteConcernPromises;
914
+ private readonly backpressureController;
852
915
  private readonly conflictResolverClient;
853
916
  constructor(config: SyncEngineConfig);
917
+ /**
918
+ * Called when connection is established (initial or reconnect).
919
+ */
920
+ private handleConnectionEstablished;
921
+ /**
922
+ * Called when connection is lost.
923
+ */
924
+ private handleConnectionLost;
925
+ /**
926
+ * Called when reconnection succeeds.
927
+ */
928
+ private handleReconnection;
854
929
  /**
855
930
  * Get the current connection state
856
931
  */
@@ -876,33 +951,11 @@ declare class SyncEngine {
876
951
  * Check if fully connected and synced
877
952
  */
878
953
  private isConnected;
879
- /**
880
- * Initialize connection using IConnectionProvider (Phase 4.5 cluster mode).
881
- * Sets up event handlers for the connection provider.
882
- */
883
- private initConnectionProvider;
884
- /**
885
- * Initialize connection using direct WebSocket (legacy single-server mode).
886
- */
887
- private initConnection;
888
- private scheduleReconnect;
889
- private calculateBackoffDelay;
890
- /**
891
- * Reset backoff counter (called on successful connection)
892
- */
893
- private resetBackoff;
894
954
  /**
895
955
  * Send a message through the current connection.
896
- * Uses connectionProvider if in cluster mode, otherwise uses direct websocket.
897
- * @param message Message object to serialize and send
898
- * @param key Optional key for routing (cluster mode only)
899
- * @returns true if message was sent, false otherwise
956
+ * Delegates to WebSocketManager.
900
957
  */
901
958
  private sendMessage;
902
- /**
903
- * Check if we can send messages (connection is ready).
904
- */
905
- private canSend;
906
959
  private loadOpLog;
907
960
  private saveOpLog;
908
961
  registerMap(mapName: string, map: LWWMap<any, any> | ORMap<any, any>): void;
@@ -917,25 +970,69 @@ declare class SyncEngine {
917
970
  setAuthToken(token: string): void;
918
971
  setTokenProvider(provider: () => Promise<string | null>): void;
919
972
  private sendAuth;
973
+ /**
974
+ * Subscribe to a standard query.
975
+ * Delegates to QueryManager.
976
+ */
920
977
  subscribeToQuery(query: QueryHandle<any>): void;
978
+ /**
979
+ * Subscribe to a topic.
980
+ * Delegates to TopicManager.
981
+ */
921
982
  subscribeToTopic(topic: string, handle: TopicHandle): void;
983
+ /**
984
+ * Unsubscribe from a topic.
985
+ * Delegates to TopicManager.
986
+ */
922
987
  unsubscribeFromTopic(topic: string): void;
923
- publishTopic(topic: string, data: any): void;
924
- private sendTopicSubscription;
925
988
  /**
926
- * Executes a query against local storage immediately
989
+ * Publish a message to a topic.
990
+ * Delegates to TopicManager.
991
+ */
992
+ publishTopic(topic: string, data: unknown): void;
993
+ /**
994
+ * Get topic queue status.
995
+ * Delegates to TopicManager.
996
+ */
997
+ getTopicQueueStatus(): {
998
+ size: number;
999
+ maxSize: number;
1000
+ };
1001
+ /**
1002
+ * Executes a query against local storage immediately.
1003
+ * Delegates to QueryManager.
927
1004
  */
928
1005
  runLocalQuery(mapName: string, filter: QueryFilter): Promise<{
929
1006
  key: string;
930
1007
  value: any;
931
1008
  }[]>;
1009
+ /**
1010
+ * Unsubscribe from a query.
1011
+ * Delegates to QueryManager.
1012
+ */
932
1013
  unsubscribeFromQuery(queryId: string): void;
933
- private sendQuerySubscription;
1014
+ /**
1015
+ * Request a distributed lock.
1016
+ * Delegates to LockManager.
1017
+ */
934
1018
  requestLock(name: string, requestId: string, ttl: number): Promise<{
935
1019
  fencingToken: number;
936
1020
  }>;
1021
+ /**
1022
+ * Release a distributed lock.
1023
+ * Delegates to LockManager.
1024
+ */
937
1025
  releaseLock(name: string, requestId: string, fencingToken: number): Promise<boolean>;
938
1026
  private handleServerMessage;
1027
+ private handleBatch;
1028
+ private handleAuthAck;
1029
+ private handleAuthFail;
1030
+ private handleOpAck;
1031
+ private handleQueryResp;
1032
+ private handleQueryUpdate;
1033
+ private handleServerEvent;
1034
+ private handleServerBatchEvent;
1035
+ private handleGcPrune;
939
1036
  getHLC(): HLC;
940
1037
  /**
941
1038
  * Helper method to apply a single server event to the local map.
@@ -989,26 +1086,6 @@ declare class SyncEngine {
989
1086
  */
990
1087
  getConnectionProvider(): IConnectionProvider;
991
1088
  private resetMap;
992
- /**
993
- * Starts the heartbeat mechanism after successful connection.
994
- */
995
- private startHeartbeat;
996
- /**
997
- * Stops the heartbeat mechanism.
998
- */
999
- private stopHeartbeat;
1000
- /**
1001
- * Sends a PING message to the server.
1002
- */
1003
- private sendPing;
1004
- /**
1005
- * Handles incoming PONG message from server.
1006
- */
1007
- private handlePong;
1008
- /**
1009
- * Checks if heartbeat has timed out and triggers reconnection if needed.
1010
- */
1011
- private checkHeartbeatTimeout;
1012
1089
  /**
1013
1090
  * Returns the last measured round-trip time in milliseconds.
1014
1091
  * Returns null if no PONG has been received yet.
@@ -1020,108 +1097,68 @@ declare class SyncEngine {
1020
1097
  * a PONG within the timeout window.
1021
1098
  */
1022
1099
  isConnectionHealthy(): boolean;
1023
- /**
1024
- * Push local ORMap diff to server for the given keys.
1025
- * Sends local records and tombstones that the server might not have.
1026
- */
1027
- private pushORMapDiff;
1028
1100
  /**
1029
1101
  * Get the current number of pending (unsynced) operations.
1102
+ * Delegates to BackpressureController.
1030
1103
  */
1031
1104
  getPendingOpsCount(): number;
1032
1105
  /**
1033
1106
  * Get the current backpressure status.
1107
+ * Delegates to BackpressureController.
1034
1108
  */
1035
1109
  getBackpressureStatus(): BackpressureStatus;
1036
1110
  /**
1037
1111
  * Returns true if writes are currently paused due to backpressure.
1112
+ * Delegates to BackpressureController.
1038
1113
  */
1039
1114
  isBackpressurePaused(): boolean;
1040
1115
  /**
1041
1116
  * Subscribe to backpressure events.
1117
+ * Delegates to BackpressureController.
1042
1118
  * @param event Event name: 'backpressure:high', 'backpressure:low', 'backpressure:paused', 'backpressure:resumed', 'operation:dropped'
1043
1119
  * @param listener Callback function
1044
1120
  * @returns Unsubscribe function
1045
1121
  */
1046
1122
  onBackpressure(event: 'backpressure:high' | 'backpressure:low' | 'backpressure:paused' | 'backpressure:resumed' | 'operation:dropped', listener: (data?: BackpressureThresholdEvent | OperationDroppedEvent) => void): () => void;
1047
- /**
1048
- * Emit a backpressure event to all listeners.
1049
- */
1050
- private emitBackpressureEvent;
1051
- /**
1052
- * Check backpressure before adding a new operation.
1053
- * May pause, throw, or drop depending on strategy.
1054
- */
1055
- private checkBackpressure;
1056
- /**
1057
- * Check high water mark and emit event if threshold reached.
1058
- */
1059
- private checkHighWaterMark;
1060
- /**
1061
- * Check low water mark and resume paused writes if threshold reached.
1062
- */
1063
- private checkLowWaterMark;
1064
- /**
1065
- * Wait for capacity to become available (used by 'pause' strategy).
1066
- */
1067
- private waitForCapacity;
1068
- /**
1069
- * Drop the oldest pending operation (used by 'drop-oldest' strategy).
1070
- */
1071
- private dropOldestOp;
1072
1123
  /**
1073
1124
  * Register a pending Write Concern promise for an operation.
1074
- * The promise will be resolved when the server sends an ACK with the operation result.
1125
+ * Delegates to WriteConcernManager.
1075
1126
  *
1076
1127
  * @param opId - Operation ID
1077
1128
  * @param timeout - Timeout in ms (default: 5000)
1078
1129
  * @returns Promise that resolves with the Write Concern result
1079
1130
  */
1080
1131
  registerWriteConcernPromise(opId: string, timeout?: number): Promise<any>;
1081
- /**
1082
- * Resolve a pending Write Concern promise with the server result.
1083
- *
1084
- * @param opId - Operation ID
1085
- * @param result - Result from server ACK
1086
- */
1087
- private resolveWriteConcernPromise;
1088
- /**
1089
- * Cancel all pending Write Concern promises (e.g., on disconnect).
1090
- */
1091
- private cancelAllWriteConcernPromises;
1092
- /** Counter update listeners by name */
1093
- private counterUpdateListeners;
1094
1132
  /**
1095
1133
  * Subscribe to counter updates from server.
1134
+ * Delegates to CounterManager.
1096
1135
  * @param name Counter name
1097
1136
  * @param listener Callback when counter state is updated
1098
1137
  * @returns Unsubscribe function
1099
1138
  */
1100
- onCounterUpdate(name: string, listener: (state: any) => void): () => void;
1139
+ onCounterUpdate(name: string, listener: (state: {
1140
+ positive: Map<string, number>;
1141
+ negative: Map<string, number>;
1142
+ }) => void): () => void;
1101
1143
  /**
1102
1144
  * Request initial counter state from server.
1145
+ * Delegates to CounterManager.
1103
1146
  * @param name Counter name
1104
1147
  */
1105
1148
  requestCounter(name: string): void;
1106
1149
  /**
1107
1150
  * Sync local counter state to server.
1151
+ * Delegates to CounterManager.
1108
1152
  * @param name Counter name
1109
1153
  * @param state Counter state to sync
1110
1154
  */
1111
- syncCounter(name: string, state: any): void;
1112
- /**
1113
- * Handle incoming counter update from server.
1114
- * Called by handleServerMessage for COUNTER_UPDATE messages.
1115
- */
1116
- private handleCounterUpdate;
1117
- /** Pending entry processor requests by requestId */
1118
- private pendingProcessorRequests;
1119
- /** Pending batch entry processor requests by requestId */
1120
- private pendingBatchProcessorRequests;
1121
- /** Default timeout for entry processor requests (ms) */
1122
- private static readonly PROCESSOR_TIMEOUT;
1155
+ syncCounter(name: string, state: {
1156
+ positive: Map<string, number>;
1157
+ negative: Map<string, number>;
1158
+ }): void;
1123
1159
  /**
1124
1160
  * Execute an entry processor on a single key atomically.
1161
+ * Delegates to EntryProcessorClient.
1125
1162
  *
1126
1163
  * @param mapName Name of the map
1127
1164
  * @param key Key to process
@@ -1131,6 +1168,7 @@ declare class SyncEngine {
1131
1168
  executeOnKey<V, R = V>(mapName: string, key: string, processor: EntryProcessorDef<V, R>): Promise<EntryProcessorResult<R>>;
1132
1169
  /**
1133
1170
  * Execute an entry processor on multiple keys.
1171
+ * Delegates to EntryProcessorClient.
1134
1172
  *
1135
1173
  * @param mapName Name of the map
1136
1174
  * @param keys Keys to process
@@ -1138,16 +1176,6 @@ declare class SyncEngine {
1138
1176
  * @returns Promise resolving to a map of key -> result
1139
1177
  */
1140
1178
  executeOnKeys<V, R = V>(mapName: string, keys: string[], processor: EntryProcessorDef<V, R>): Promise<Map<string, EntryProcessorResult<R>>>;
1141
- /**
1142
- * Handle entry processor response from server.
1143
- * Called by handleServerMessage for ENTRY_PROCESS_RESPONSE messages.
1144
- */
1145
- private handleEntryProcessResponse;
1146
- /**
1147
- * Handle entry processor batch response from server.
1148
- * Called by handleServerMessage for ENTRY_PROCESS_BATCH_RESPONSE messages.
1149
- */
1150
- private handleEntryProcessBatchResponse;
1151
1179
  /** Message listeners for journal and other generic messages */
1152
1180
  private messageListeners;
1153
1181
  /**
@@ -1157,32 +1185,29 @@ declare class SyncEngine {
1157
1185
  * @param event Event type (currently only 'message')
1158
1186
  * @param handler Message handler
1159
1187
  */
1160
- on(event: 'message', handler: (message: any) => void): void;
1188
+ on(event: 'message', handler: (message: unknown) => void): void;
1161
1189
  /**
1162
1190
  * Unsubscribe from incoming messages.
1163
1191
  *
1164
1192
  * @param event Event type (currently only 'message')
1165
1193
  * @param handler Message handler to remove
1166
1194
  */
1167
- off(event: 'message', handler: (message: any) => void): void;
1195
+ off(event: 'message', handler: (message: unknown) => void): void;
1168
1196
  /**
1169
1197
  * Send a message to the server.
1170
1198
  * Public method for EventJournalReader and other components.
1171
1199
  *
1172
1200
  * @param message Message object to send
1173
1201
  */
1174
- send(message: any): void;
1202
+ send(message: unknown): void;
1175
1203
  /**
1176
1204
  * Emit message to all listeners.
1177
1205
  * Called internally when a message is received.
1178
1206
  */
1179
1207
  private emitMessage;
1180
- /** Pending search requests by requestId */
1181
- private pendingSearchRequests;
1182
- /** Default timeout for search requests (ms) */
1183
- private static readonly SEARCH_TIMEOUT;
1184
1208
  /**
1185
1209
  * Perform a one-shot BM25 search on the server.
1210
+ * Delegates to SearchClient.
1186
1211
  *
1187
1212
  * @param mapName Name of the map to search
1188
1213
  * @param query Search query text
@@ -1190,33 +1215,24 @@ declare class SyncEngine {
1190
1215
  * @returns Promise resolving to search results
1191
1216
  */
1192
1217
  search<T>(mapName: string, query: string, options?: SearchOptions): Promise<SearchResult<T>[]>;
1193
- /**
1194
- * Handle search response from server.
1195
- */
1196
- private handleSearchResponse;
1197
1218
  /**
1198
1219
  * Get the conflict resolver client for registering custom resolvers
1199
1220
  * and subscribing to merge rejection events.
1200
1221
  */
1201
1222
  getConflictResolverClient(): ConflictResolverClient;
1202
- /** Active hybrid query subscriptions */
1203
- private hybridQueries;
1204
1223
  /**
1205
1224
  * Subscribe to a hybrid query (FTS + filter combination).
1225
+ * Delegates to QueryManager.
1206
1226
  */
1207
1227
  subscribeToHybridQuery<T>(query: HybridQueryHandle<T>): void;
1208
1228
  /**
1209
1229
  * Unsubscribe from a hybrid query.
1230
+ * Delegates to QueryManager.
1210
1231
  */
1211
1232
  unsubscribeFromHybridQuery(queryId: string): void;
1212
- /**
1213
- * Send hybrid query subscription to server.
1214
- */
1215
- private sendHybridQuerySubscription;
1216
1233
  /**
1217
1234
  * Run a local hybrid query (FTS + filter combination).
1218
- * For FTS predicates, returns results with score = 0 (local-only mode).
1219
- * Server provides actual FTS scoring.
1235
+ * Delegates to QueryManager.
1220
1236
  */
1221
1237
  runLocalHybridQuery<T>(mapName: string, filter: HybridQueryFilter): Promise<Array<{
1222
1238
  key: string;
@@ -1227,26 +1243,11 @@ declare class SyncEngine {
1227
1243
  /**
1228
1244
  * Handle hybrid query response from server.
1229
1245
  */
1230
- handleHybridQueryResponse(payload: {
1231
- subscriptionId: string;
1232
- results: Array<{
1233
- key: string;
1234
- value: unknown;
1235
- score: number;
1236
- matchedTerms: string[];
1237
- }>;
1238
- }): void;
1246
+ handleHybridQueryResponse(payload: HybridQueryRespPayload): void;
1239
1247
  /**
1240
1248
  * Handle hybrid query delta update from server.
1241
1249
  */
1242
- handleHybridQueryDelta(payload: {
1243
- subscriptionId: string;
1244
- key: string;
1245
- value: unknown | null;
1246
- score?: number;
1247
- matchedTerms?: string[];
1248
- type: 'ENTER' | 'UPDATE' | 'LEAVE';
1249
- }): void;
1250
+ handleHybridQueryDelta(payload: HybridQueryDeltaPayload): void;
1250
1251
  }
1251
1252
 
1252
1253
  interface ILock {
@@ -1429,7 +1430,6 @@ declare class EventJournalReader {
1429
1430
  * SearchHandle - Client-side Live Search Subscription Handle
1430
1431
  *
1431
1432
  * Manages a live search subscription with delta updates.
1432
- * Part of Phase 11.1b: Live Search Subscriptions.
1433
1433
  *
1434
1434
  * @module SearchHandle
1435
1435
  */
@@ -1845,7 +1845,7 @@ declare class TopGunClient {
1845
1845
  * Results include relevance scores for FTS ranking.
1846
1846
  *
1847
1847
  * @param mapName Name of the map to query
1848
- * @param filter Hybrid query filter with predicate, where, sort, limit, offset
1848
+ * @param filter Hybrid query filter with predicate, where, sort, limit, cursor
1849
1849
  * @returns HybridQueryHandle for managing the subscription
1850
1850
  *
1851
1851
  * @example
@@ -2138,8 +2138,6 @@ declare class BackpressureError extends Error {
2138
2138
  /**
2139
2139
  * ConnectionPool - Manages WebSocket connections to multiple cluster nodes
2140
2140
  *
2141
- * Phase 4: Partition-Aware Client Routing
2142
- *
2143
2141
  * Features:
2144
2142
  * - Maintains connections to all known cluster nodes
2145
2143
  * - Automatic reconnection with exponential backoff
@@ -2246,8 +2244,6 @@ declare class ConnectionPool {
2246
2244
  /**
2247
2245
  * PartitionRouter - Routes operations to the correct cluster node
2248
2246
  *
2249
- * Phase 4: Partition-Aware Client Routing
2250
- *
2251
2247
  * Features:
2252
2248
  * - Maintains local copy of partition map
2253
2249
  * - Routes keys to owner nodes using consistent hashing
@@ -2380,9 +2376,7 @@ declare class PartitionRouter {
2380
2376
  /**
2381
2377
  * ClusterClient - Cluster-aware client wrapper
2382
2378
  *
2383
- * Phase 4: Partition-Aware Client Routing
2384
- * Phase 4.5: Implements IConnectionProvider for SyncEngine abstraction
2385
- *
2379
+ * Implements IConnectionProvider for SyncEngine abstraction.
2386
2380
  * Wraps the standard TopGunClient with cluster-aware routing capabilities.
2387
2381
  * Coordinates between ConnectionPool and PartitionRouter for optimal
2388
2382
  * request routing in a clustered environment.
@@ -2513,11 +2507,6 @@ declare class ClusterClient implements IConnectionProvider {
2513
2507
  * Set authentication token
2514
2508
  */
2515
2509
  setAuthToken(token: string): void;
2516
- /**
2517
- * Send operation with automatic routing (legacy API for cluster operations).
2518
- * @deprecated Use send(data, key) for IConnectionProvider interface
2519
- */
2520
- sendMessage(key: string, message: any): boolean;
2521
2510
  /**
2522
2511
  * Send directly to partition owner
2523
2512
  */
@@ -2705,4 +2694,4 @@ declare class SingleServerProvider implements IConnectionProvider {
2705
2694
 
2706
2695
  declare const logger: pino.Logger<never, boolean>;
2707
2696
 
2708
- export { type BackoffConfig, type BackpressureConfig, BackpressureError, type BackpressureStatus, type BackpressureStrategy, type BackpressureThresholdEvent, type ChangeEvent, ChangeTracker, type CircuitState, ClusterClient, type ClusterClientEvents, type ClusterRoutingMode, ConflictResolverClient, type ConnectionEventHandler, ConnectionPool, type ConnectionPoolEvents, type ConnectionProviderEvent, DEFAULT_BACKPRESSURE_CONFIG, DEFAULT_CLUSTER_CONFIG, EncryptedStorageAdapter, EventJournalReader, type HeartbeatConfig, type HybridQueryFilter, HybridQueryHandle, type HybridResultItem, type HybridResultSource, type IConnectionProvider, IDBAdapter, type IStorageAdapter, type JournalEventData, type JournalSubscribeOptions, type OpLogEntry, type OperationDroppedEvent, PNCounterHandle, PartitionRouter, type PartitionRouterEvents, type QueryFilter, QueryHandle, type QueryResultItem, type QueryResultSource, type RegisterResult, type ResolverInfo, type RoutingMetrics, type RoutingResult, SearchHandle, type SearchResult, type SearchResultsCallback, SingleServerProvider, type SingleServerProviderConfig, type StateChangeEvent, type StateChangeListener, SyncEngine, type SyncEngineConfig, SyncState, SyncStateMachine, type SyncStateMachineConfig, TopGun, TopGunClient, type TopGunClientConfig, type TopGunClusterConfig, type TopicCallback, TopicHandle, VALID_TRANSITIONS, isValidTransition, logger };
2697
+ export { type BackoffConfig, type BackpressureConfig, BackpressureError, type BackpressureStatus, type BackpressureStrategy, type BackpressureThresholdEvent, type ChangeEvent, ChangeTracker, type CircuitState, ClusterClient, type ClusterClientEvents, type ClusterRoutingMode, ConflictResolverClient, type ConnectionEventHandler, ConnectionPool, type ConnectionPoolEvents, type ConnectionProviderEvent, type CursorStatus, DEFAULT_BACKPRESSURE_CONFIG, DEFAULT_CLUSTER_CONFIG, EncryptedStorageAdapter, EventJournalReader, type HeartbeatConfig, type HybridQueryFilter, HybridQueryHandle, type HybridResultItem, type HybridResultSource, type IConnectionProvider, IDBAdapter, type IStorageAdapter, type JournalEventData, type JournalSubscribeOptions, type OpLogEntry, type OperationDroppedEvent, PNCounterHandle, type PaginationInfo, PartitionRouter, type PartitionRouterEvents, type QueryFilter, QueryHandle, type QueryResultItem, type QueryResultSource, type RegisterResult, type ResolverInfo, type RoutingMetrics, type RoutingResult, SearchHandle, type SearchResult, type SearchResultsCallback, SingleServerProvider, type SingleServerProviderConfig, type StateChangeEvent, type StateChangeListener, SyncEngine, type SyncEngineConfig, SyncState, SyncStateMachine, type SyncStateMachineConfig, TopGun, TopGunClient, type TopGunClientConfig, type TopGunClusterConfig, type TopicCallback, TopicHandle, VALID_TRANSITIONS, isValidTransition, logger };