@topgunbuild/client 0.8.1 → 0.10.0

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/LICENSE ADDED
@@ -0,0 +1,97 @@
1
+ Business Source License 1.1
2
+
3
+ Parameters
4
+
5
+ Licensor: TopGun Contributors
6
+ Licensed Work: TopGun
7
+ The Licensed Work is (c) 2024 TopGun Contributors.
8
+ Additional Use Grant: You may make production use of the Licensed Work,
9
+ provided Your use does not include offering the
10
+ Licensed Work to third parties as a commercial
11
+ managed database service, database-as-a-service,
12
+ or similar hosted database offering that competes
13
+ with TopGun products or services.
14
+
15
+ For purposes of this license:
16
+ - "Managed database service" means a service that
17
+ allows third parties to create, manage, or operate
18
+ databases using TopGun as the underlying technology.
19
+ - Internal use within your organization is permitted.
20
+ - Using TopGun as part of your application's backend
21
+ (not exposed as a database service) is permitted.
22
+ - Consulting and professional services around TopGun
23
+ are permitted.
24
+
25
+ Change Date: Four years from the date of each version release
26
+ Change License: Apache License, Version 2.0
27
+
28
+ For information about alternative licensing arrangements for the Licensed Work,
29
+ please contact the Licensor.
30
+
31
+ Notice
32
+
33
+ Business Source License 1.1
34
+
35
+ Terms
36
+
37
+ The Licensor hereby grants you the right to copy, modify, create derivative
38
+ works, redistribute, and make non-production use of the Licensed Work. The
39
+ Licensor may make an Additional Use Grant, above, permitting limited production use.
40
+
41
+ Effective on the Change Date, or the fourth anniversary of the first publicly
42
+ available distribution of a specific version of the Licensed Work under this
43
+ License, whichever comes first, the Licensor hereby grants you rights under
44
+ the terms of the Change License, and the rights granted in the paragraph
45
+ above terminate.
46
+
47
+ If your use of the Licensed Work does not comply with the requirements
48
+ currently in effect as described in this License, you must purchase a
49
+ commercial license from the Licensor, its affiliated entities, or authorized
50
+ resellers, or you must refrain from using the Licensed Work.
51
+
52
+ All copies of the original and modified Licensed Work, and derivative works
53
+ of the Licensed Work, are subject to this License. This License applies
54
+ separately for each version of the Licensed Work and the Change Date may vary
55
+ for each version of the Licensed Work released by Licensor.
56
+
57
+ You must conspicuously display this License on each original or modified copy
58
+ of the Licensed Work. If you receive the Licensed Work in original or
59
+ modified form from a third party, the terms and conditions set forth in this
60
+ License apply to your use of that work.
61
+
62
+ Any use of the Licensed Work in violation of this License will automatically
63
+ terminate your rights under this License for the current and all other
64
+ versions of the Licensed Work.
65
+
66
+ This License does not grant you any right in any trademark or logo of
67
+ Licensor or its affiliates (provided that you may use a trademark or logo of
68
+ Licensor as expressly required by this License).
69
+
70
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
71
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
72
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
73
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
74
+ TITLE.
75
+
76
+ MariaDB hereby grants you permission to use this License's text to license
77
+ your works, and to refer to it using the trademark "Business Source License",
78
+ as long as you comply with the Covenants of Licensor below.
79
+
80
+ Covenants of Licensor
81
+
82
+ In consideration of the right to use this License's text and the "Business
83
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
84
+ other recipients of the licensed work to be provided by Licensor:
85
+
86
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
87
+ or a license that is compatible with GPL Version 2.0 or a later version,
88
+ where "compatible" means that software provided under the Change License can
89
+ be included in a program with software provided under GPL Version 2.0 or a
90
+ later version. Licensor may specify additional Change Licenses without
91
+ limitation.
92
+
93
+ 2. To either: (a) specify an Additional Use Grant (above) that does not impose
94
+ any additional restriction on the right granted in this License, as the
95
+ Additional Use Grant; or (b) insert the text "None" to specify a Change Date.
96
+
97
+ 3. Not to modify this License in any other way.
package/dist/index.d.mts CHANGED
@@ -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 (Phase 14.1: replaces offset) */
103
+ cursor?: string;
104
+ }
105
+ /** Cursor status for debugging (Phase 14.1) */
106
+ type CursorStatus = 'valid' | 'expired' | 'invalid' | 'none';
107
+ /** Pagination info from server (Phase 14.1) */
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;
@@ -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
  /**
@@ -213,8 +247,8 @@ interface HybridQueryFilter {
213
247
  sort?: Record<string, 'asc' | 'desc'>;
214
248
  /** Maximum results */
215
249
  limit?: number;
216
- /** Skip N results */
217
- offset?: number;
250
+ /** Cursor for pagination (Phase 14.1: replaces offset) */
251
+ cursor?: string;
218
252
  }
219
253
  /**
220
254
  * Result item with score for hybrid queries.
@@ -265,6 +299,8 @@ declare class HybridQueryHandle<T> {
265
299
  private pendingChanges;
266
300
  private changeListeners;
267
301
  private hasReceivedServerData;
302
+ private _paginationInfo;
303
+ private paginationListeners;
268
304
  constructor(syncEngine: SyncEngine, mapName: string, filter?: HybridQueryFilter);
269
305
  /**
270
306
  * Subscribe to query results.
@@ -328,6 +364,26 @@ declare class HybridQueryHandle<T> {
328
364
  */
329
365
  hasFTSPredicate(): boolean;
330
366
  private containsFTS;
367
+ /**
368
+ * Get current pagination info.
369
+ * Returns nextCursor, hasMore, and cursorStatus.
370
+ */
371
+ getPaginationInfo(): PaginationInfo;
372
+ /**
373
+ * Subscribe to pagination info changes.
374
+ * Called when server sends HYBRID_QUERY_RESP with new cursor info.
375
+ *
376
+ * @returns Unsubscribe function
377
+ */
378
+ onPaginationChange(listener: (info: PaginationInfo) => void): () => void;
379
+ /**
380
+ * Update pagination info from server response.
381
+ * Called by SyncEngine when processing HYBRID_QUERY_RESP.
382
+ *
383
+ * @internal
384
+ */
385
+ updatePaginationInfo(info: Partial<PaginationInfo>): void;
386
+ private notifyPaginationListeners;
331
387
  }
332
388
 
333
389
  type TopicCallback = (data: any, context: {
@@ -1235,6 +1291,9 @@ declare class SyncEngine {
1235
1291
  score: number;
1236
1292
  matchedTerms: string[];
1237
1293
  }>;
1294
+ nextCursor?: string;
1295
+ hasMore?: boolean;
1296
+ cursorStatus?: 'valid' | 'expired' | 'invalid' | 'none';
1238
1297
  }): void;
1239
1298
  /**
1240
1299
  * Handle hybrid query delta update from server.
@@ -1845,7 +1904,7 @@ declare class TopGunClient {
1845
1904
  * Results include relevance scores for FTS ranking.
1846
1905
  *
1847
1906
  * @param mapName Name of the map to query
1848
- * @param filter Hybrid query filter with predicate, where, sort, limit, offset
1907
+ * @param filter Hybrid query filter with predicate, where, sort, limit, cursor
1849
1908
  * @returns HybridQueryHandle for managing the subscription
1850
1909
  *
1851
1910
  * @example
@@ -2705,4 +2764,4 @@ declare class SingleServerProvider implements IConnectionProvider {
2705
2764
 
2706
2765
  declare const logger: pino.Logger<never, boolean>;
2707
2766
 
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 };
2767
+ 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 };
package/dist/index.d.ts CHANGED
@@ -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 (Phase 14.1: replaces offset) */
103
+ cursor?: string;
104
+ }
105
+ /** Cursor status for debugging (Phase 14.1) */
106
+ type CursorStatus = 'valid' | 'expired' | 'invalid' | 'none';
107
+ /** Pagination info from server (Phase 14.1) */
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;
@@ -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
  /**
@@ -213,8 +247,8 @@ interface HybridQueryFilter {
213
247
  sort?: Record<string, 'asc' | 'desc'>;
214
248
  /** Maximum results */
215
249
  limit?: number;
216
- /** Skip N results */
217
- offset?: number;
250
+ /** Cursor for pagination (Phase 14.1: replaces offset) */
251
+ cursor?: string;
218
252
  }
219
253
  /**
220
254
  * Result item with score for hybrid queries.
@@ -265,6 +299,8 @@ declare class HybridQueryHandle<T> {
265
299
  private pendingChanges;
266
300
  private changeListeners;
267
301
  private hasReceivedServerData;
302
+ private _paginationInfo;
303
+ private paginationListeners;
268
304
  constructor(syncEngine: SyncEngine, mapName: string, filter?: HybridQueryFilter);
269
305
  /**
270
306
  * Subscribe to query results.
@@ -328,6 +364,26 @@ declare class HybridQueryHandle<T> {
328
364
  */
329
365
  hasFTSPredicate(): boolean;
330
366
  private containsFTS;
367
+ /**
368
+ * Get current pagination info.
369
+ * Returns nextCursor, hasMore, and cursorStatus.
370
+ */
371
+ getPaginationInfo(): PaginationInfo;
372
+ /**
373
+ * Subscribe to pagination info changes.
374
+ * Called when server sends HYBRID_QUERY_RESP with new cursor info.
375
+ *
376
+ * @returns Unsubscribe function
377
+ */
378
+ onPaginationChange(listener: (info: PaginationInfo) => void): () => void;
379
+ /**
380
+ * Update pagination info from server response.
381
+ * Called by SyncEngine when processing HYBRID_QUERY_RESP.
382
+ *
383
+ * @internal
384
+ */
385
+ updatePaginationInfo(info: Partial<PaginationInfo>): void;
386
+ private notifyPaginationListeners;
331
387
  }
332
388
 
333
389
  type TopicCallback = (data: any, context: {
@@ -1235,6 +1291,9 @@ declare class SyncEngine {
1235
1291
  score: number;
1236
1292
  matchedTerms: string[];
1237
1293
  }>;
1294
+ nextCursor?: string;
1295
+ hasMore?: boolean;
1296
+ cursorStatus?: 'valid' | 'expired' | 'invalid' | 'none';
1238
1297
  }): void;
1239
1298
  /**
1240
1299
  * Handle hybrid query delta update from server.
@@ -1845,7 +1904,7 @@ declare class TopGunClient {
1845
1904
  * Results include relevance scores for FTS ranking.
1846
1905
  *
1847
1906
  * @param mapName Name of the map to query
1848
- * @param filter Hybrid query filter with predicate, where, sort, limit, offset
1907
+ * @param filter Hybrid query filter with predicate, where, sort, limit, cursor
1849
1908
  * @returns HybridQueryHandle for managing the subscription
1850
1909
  *
1851
1910
  * @example
@@ -2705,4 +2764,4 @@ declare class SingleServerProvider implements IConnectionProvider {
2705
2764
 
2706
2765
  declare const logger: pino.Logger<never, boolean>;
2707
2766
 
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 };
2767
+ 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 };
package/dist/index.js CHANGED
@@ -1398,10 +1398,11 @@ var _SyncEngine = class _SyncEngine {
1398
1398
  break;
1399
1399
  }
1400
1400
  case "QUERY_RESP": {
1401
- const { queryId, results } = message.payload;
1401
+ const { queryId, results, nextCursor, hasMore, cursorStatus } = message.payload;
1402
1402
  const query = this.queries.get(queryId);
1403
1403
  if (query) {
1404
1404
  query.onResult(results, "server");
1405
+ query.updatePaginationInfo({ nextCursor, hasMore, cursorStatus });
1405
1406
  }
1406
1407
  break;
1407
1408
  }
@@ -2555,7 +2556,8 @@ var _SyncEngine = class _SyncEngine {
2555
2556
  where: filter.where,
2556
2557
  sort: filter.sort,
2557
2558
  limit: filter.limit,
2558
- offset: filter.offset
2559
+ cursor: filter.cursor
2560
+ // Phase 14.1: replaces offset
2559
2561
  }
2560
2562
  });
2561
2563
  }
@@ -2628,9 +2630,6 @@ var _SyncEngine = class _SyncEngine {
2628
2630
  });
2629
2631
  }
2630
2632
  let sliced = results;
2631
- if (filter.offset) {
2632
- sliced = sliced.slice(filter.offset);
2633
- }
2634
2633
  if (filter.limit) {
2635
2634
  sliced = sliced.slice(0, filter.limit);
2636
2635
  }
@@ -2643,6 +2642,11 @@ var _SyncEngine = class _SyncEngine {
2643
2642
  const query = this.hybridQueries.get(payload.subscriptionId);
2644
2643
  if (query) {
2645
2644
  query.onResult(payload.results, "server");
2645
+ query.updatePaginationInfo({
2646
+ nextCursor: payload.nextCursor,
2647
+ hasMore: payload.hasMore,
2648
+ cursorStatus: payload.cursorStatus
2649
+ });
2646
2650
  }
2647
2651
  }
2648
2652
  /**
@@ -2765,6 +2769,9 @@ var QueryHandle = class {
2765
2769
  this.changeTracker = new ChangeTracker();
2766
2770
  this.pendingChanges = [];
2767
2771
  this.changeListeners = /* @__PURE__ */ new Set();
2772
+ // Pagination info (Phase 14.1)
2773
+ this._paginationInfo = { hasMore: false, cursorStatus: "none" };
2774
+ this.paginationListeners = /* @__PURE__ */ new Set();
2768
2775
  // Track if we've received authoritative server response
2769
2776
  this.hasReceivedServerData = false;
2770
2777
  this.id = crypto.randomUUID();
@@ -2958,6 +2965,49 @@ var QueryHandle = class {
2958
2965
  getMapName() {
2959
2966
  return this.mapName;
2960
2967
  }
2968
+ // ============== Pagination Methods (Phase 14.1) ==============
2969
+ /**
2970
+ * Get current pagination info.
2971
+ * Returns nextCursor, hasMore, and cursorStatus.
2972
+ */
2973
+ getPaginationInfo() {
2974
+ return { ...this._paginationInfo };
2975
+ }
2976
+ /**
2977
+ * Subscribe to pagination info changes.
2978
+ * Called when server sends QUERY_RESP with new cursor info.
2979
+ *
2980
+ * @returns Unsubscribe function
2981
+ */
2982
+ onPaginationChange(listener) {
2983
+ this.paginationListeners.add(listener);
2984
+ listener(this.getPaginationInfo());
2985
+ return () => this.paginationListeners.delete(listener);
2986
+ }
2987
+ /**
2988
+ * Update pagination info from server response.
2989
+ * Called by SyncEngine when processing QUERY_RESP.
2990
+ *
2991
+ * @internal
2992
+ */
2993
+ updatePaginationInfo(info) {
2994
+ this._paginationInfo = {
2995
+ nextCursor: info.nextCursor,
2996
+ hasMore: info.hasMore ?? false,
2997
+ cursorStatus: info.cursorStatus ?? "none"
2998
+ };
2999
+ this.notifyPaginationListeners();
3000
+ }
3001
+ notifyPaginationListeners() {
3002
+ const info = this.getPaginationInfo();
3003
+ for (const listener of this.paginationListeners) {
3004
+ try {
3005
+ listener(info);
3006
+ } catch (e) {
3007
+ logger.error({ err: e }, "QueryHandle pagination listener error");
3008
+ }
3009
+ }
3010
+ }
2961
3011
  };
2962
3012
 
2963
3013
  // src/DistributedLock.ts
@@ -3549,6 +3599,9 @@ var HybridQueryHandle = class {
3549
3599
  this.changeListeners = /* @__PURE__ */ new Set();
3550
3600
  // Track server data reception
3551
3601
  this.hasReceivedServerData = false;
3602
+ // Pagination info (Phase 14.1)
3603
+ this._paginationInfo = { hasMore: false, cursorStatus: "none" };
3604
+ this.paginationListeners = /* @__PURE__ */ new Set();
3552
3605
  this.id = crypto.randomUUID();
3553
3606
  this.syncEngine = syncEngine;
3554
3607
  this.mapName = mapName;
@@ -3731,9 +3784,6 @@ var HybridQueryHandle = class {
3731
3784
  });
3732
3785
  }
3733
3786
  let sliced = results;
3734
- if (this.filter.offset) {
3735
- sliced = sliced.slice(this.filter.offset);
3736
- }
3737
3787
  if (this.filter.limit) {
3738
3788
  sliced = sliced.slice(0, this.filter.limit);
3739
3789
  }
@@ -3766,6 +3816,49 @@ var HybridQueryHandle = class {
3766
3816
  }
3767
3817
  return false;
3768
3818
  }
3819
+ // ============== Pagination Methods (Phase 14.1) ==============
3820
+ /**
3821
+ * Get current pagination info.
3822
+ * Returns nextCursor, hasMore, and cursorStatus.
3823
+ */
3824
+ getPaginationInfo() {
3825
+ return { ...this._paginationInfo };
3826
+ }
3827
+ /**
3828
+ * Subscribe to pagination info changes.
3829
+ * Called when server sends HYBRID_QUERY_RESP with new cursor info.
3830
+ *
3831
+ * @returns Unsubscribe function
3832
+ */
3833
+ onPaginationChange(listener) {
3834
+ this.paginationListeners.add(listener);
3835
+ listener(this.getPaginationInfo());
3836
+ return () => this.paginationListeners.delete(listener);
3837
+ }
3838
+ /**
3839
+ * Update pagination info from server response.
3840
+ * Called by SyncEngine when processing HYBRID_QUERY_RESP.
3841
+ *
3842
+ * @internal
3843
+ */
3844
+ updatePaginationInfo(info) {
3845
+ this._paginationInfo = {
3846
+ nextCursor: info.nextCursor,
3847
+ hasMore: info.hasMore ?? false,
3848
+ cursorStatus: info.cursorStatus ?? "none"
3849
+ };
3850
+ this.notifyPaginationListeners();
3851
+ }
3852
+ notifyPaginationListeners() {
3853
+ const info = this.getPaginationInfo();
3854
+ for (const listener of this.paginationListeners) {
3855
+ try {
3856
+ listener(info);
3857
+ } catch (e) {
3858
+ logger.error({ err: e }, "HybridQueryHandle pagination listener error");
3859
+ }
3860
+ }
3861
+ }
3769
3862
  };
3770
3863
 
3771
3864
  // src/cluster/ClusterClient.ts
@@ -5661,7 +5754,7 @@ var TopGunClient = class {
5661
5754
  * Results include relevance scores for FTS ranking.
5662
5755
  *
5663
5756
  * @param mapName Name of the map to query
5664
- * @param filter Hybrid query filter with predicate, where, sort, limit, offset
5757
+ * @param filter Hybrid query filter with predicate, where, sort, limit, cursor
5665
5758
  * @returns HybridQueryHandle for managing the subscription
5666
5759
  *
5667
5760
  * @example