@topgunbuild/client 0.6.0 → 0.8.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/dist/index.d.mts +231 -2
- package/dist/index.d.ts +231 -2
- package/dist/index.js +363 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +362 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LWWRecord, ORMapRecord, PredicateNode, ConflictResolverDef, MergeRejection, Timestamp, LWWMap, ORMap, HLC, EntryProcessorDef, EntryProcessorResult, 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, 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
|
|
|
@@ -639,6 +639,15 @@ declare class ConflictResolverClient {
|
|
|
639
639
|
get rejectionListenerCount(): number;
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
+
/**
|
|
643
|
+
* Search result item from server.
|
|
644
|
+
*/
|
|
645
|
+
interface SearchResult<T> {
|
|
646
|
+
key: string;
|
|
647
|
+
value: T;
|
|
648
|
+
score: number;
|
|
649
|
+
matchedTerms: string[];
|
|
650
|
+
}
|
|
642
651
|
interface HeartbeatConfig {
|
|
643
652
|
intervalMs: number;
|
|
644
653
|
timeoutMs: number;
|
|
@@ -1026,6 +1035,23 @@ declare class SyncEngine {
|
|
|
1026
1035
|
* Called internally when a message is received.
|
|
1027
1036
|
*/
|
|
1028
1037
|
private emitMessage;
|
|
1038
|
+
/** Pending search requests by requestId */
|
|
1039
|
+
private pendingSearchRequests;
|
|
1040
|
+
/** Default timeout for search requests (ms) */
|
|
1041
|
+
private static readonly SEARCH_TIMEOUT;
|
|
1042
|
+
/**
|
|
1043
|
+
* Perform a one-shot BM25 search on the server.
|
|
1044
|
+
*
|
|
1045
|
+
* @param mapName Name of the map to search
|
|
1046
|
+
* @param query Search query text
|
|
1047
|
+
* @param options Search options (limit, minScore, boost)
|
|
1048
|
+
* @returns Promise resolving to search results
|
|
1049
|
+
*/
|
|
1050
|
+
search<T>(mapName: string, query: string, options?: SearchOptions): Promise<SearchResult<T>[]>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Handle search response from server.
|
|
1053
|
+
*/
|
|
1054
|
+
private handleSearchResponse;
|
|
1029
1055
|
/**
|
|
1030
1056
|
* Get the conflict resolver client for registering custom resolvers
|
|
1031
1057
|
* and subscribing to merge rejection events.
|
|
@@ -1209,6 +1235,140 @@ declare class EventJournalReader {
|
|
|
1209
1235
|
private generateRequestId;
|
|
1210
1236
|
}
|
|
1211
1237
|
|
|
1238
|
+
/**
|
|
1239
|
+
* SearchHandle - Client-side Live Search Subscription Handle
|
|
1240
|
+
*
|
|
1241
|
+
* Manages a live search subscription with delta updates.
|
|
1242
|
+
* Part of Phase 11.1b: Live Search Subscriptions.
|
|
1243
|
+
*
|
|
1244
|
+
* @module SearchHandle
|
|
1245
|
+
*/
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* Callback type for result change notifications.
|
|
1249
|
+
*/
|
|
1250
|
+
type SearchResultsCallback<T> = (results: SearchResult<T>[]) => void;
|
|
1251
|
+
/**
|
|
1252
|
+
* SearchHandle manages a live search subscription.
|
|
1253
|
+
*
|
|
1254
|
+
* Provides:
|
|
1255
|
+
* - Initial results on subscription
|
|
1256
|
+
* - Real-time delta updates (ENTER/UPDATE/LEAVE)
|
|
1257
|
+
* - Sorted results by relevance score
|
|
1258
|
+
* - Query update without re-subscribing
|
|
1259
|
+
*
|
|
1260
|
+
* @example
|
|
1261
|
+
* ```typescript
|
|
1262
|
+
* const handle = client.searchSubscribe<Article>('articles', 'machine learning', {
|
|
1263
|
+
* limit: 20,
|
|
1264
|
+
* minScore: 0.5
|
|
1265
|
+
* });
|
|
1266
|
+
*
|
|
1267
|
+
* // Subscribe to results
|
|
1268
|
+
* const unsubscribe = handle.subscribe((results) => {
|
|
1269
|
+
* console.log('Results updated:', results.length);
|
|
1270
|
+
* });
|
|
1271
|
+
*
|
|
1272
|
+
* // Get current snapshot
|
|
1273
|
+
* const snapshot = handle.getResults();
|
|
1274
|
+
*
|
|
1275
|
+
* // Update query
|
|
1276
|
+
* handle.setQuery('deep learning');
|
|
1277
|
+
*
|
|
1278
|
+
* // Cleanup
|
|
1279
|
+
* handle.dispose();
|
|
1280
|
+
* ```
|
|
1281
|
+
*/
|
|
1282
|
+
declare class SearchHandle<T = unknown> {
|
|
1283
|
+
/** Map name being searched */
|
|
1284
|
+
readonly mapName: string;
|
|
1285
|
+
/** Current search query */
|
|
1286
|
+
private _query;
|
|
1287
|
+
/** Search options */
|
|
1288
|
+
private _options?;
|
|
1289
|
+
/** Unique subscription ID */
|
|
1290
|
+
private subscriptionId;
|
|
1291
|
+
/** Current results map (key → result) */
|
|
1292
|
+
private results;
|
|
1293
|
+
/** Result change listeners */
|
|
1294
|
+
private listeners;
|
|
1295
|
+
/** Whether the handle has been disposed */
|
|
1296
|
+
private disposed;
|
|
1297
|
+
/** Reference to SyncEngine */
|
|
1298
|
+
private syncEngine;
|
|
1299
|
+
/** Handler for all messages (SEARCH_RESP and SEARCH_UPDATE) */
|
|
1300
|
+
private messageHandler;
|
|
1301
|
+
constructor(syncEngine: SyncEngine, mapName: string, query: string, options?: SearchOptions);
|
|
1302
|
+
/**
|
|
1303
|
+
* Handle incoming messages (both SEARCH_RESP and SEARCH_UPDATE).
|
|
1304
|
+
*/
|
|
1305
|
+
private handleMessage;
|
|
1306
|
+
/**
|
|
1307
|
+
* Get the current query string.
|
|
1308
|
+
*/
|
|
1309
|
+
get query(): string;
|
|
1310
|
+
/**
|
|
1311
|
+
* Subscribe to result changes.
|
|
1312
|
+
* Callback is immediately called with current results.
|
|
1313
|
+
*
|
|
1314
|
+
* @param callback - Function called with updated results
|
|
1315
|
+
* @returns Unsubscribe function
|
|
1316
|
+
*/
|
|
1317
|
+
subscribe(callback: SearchResultsCallback<T>): () => void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Get current results snapshot sorted by score (highest first).
|
|
1320
|
+
*
|
|
1321
|
+
* @returns Array of search results
|
|
1322
|
+
*/
|
|
1323
|
+
getResults(): SearchResult<T>[];
|
|
1324
|
+
/**
|
|
1325
|
+
* Get result count.
|
|
1326
|
+
*/
|
|
1327
|
+
get size(): number;
|
|
1328
|
+
/**
|
|
1329
|
+
* Update the search query.
|
|
1330
|
+
* Triggers a new subscription with the updated query.
|
|
1331
|
+
*
|
|
1332
|
+
* @param query - New query string
|
|
1333
|
+
*/
|
|
1334
|
+
setQuery(query: string): void;
|
|
1335
|
+
/**
|
|
1336
|
+
* Update search options.
|
|
1337
|
+
*
|
|
1338
|
+
* @param options - New search options
|
|
1339
|
+
*/
|
|
1340
|
+
setOptions(options: SearchOptions): void;
|
|
1341
|
+
/**
|
|
1342
|
+
* Dispose of the handle and cleanup resources.
|
|
1343
|
+
* After disposal, the handle cannot be used.
|
|
1344
|
+
*/
|
|
1345
|
+
dispose(): void;
|
|
1346
|
+
/**
|
|
1347
|
+
* Check if handle is disposed.
|
|
1348
|
+
*/
|
|
1349
|
+
isDisposed(): boolean;
|
|
1350
|
+
/**
|
|
1351
|
+
* Send SEARCH_SUB message to server.
|
|
1352
|
+
*/
|
|
1353
|
+
private sendSubscribe;
|
|
1354
|
+
/**
|
|
1355
|
+
* Send SEARCH_UNSUB message to server.
|
|
1356
|
+
*/
|
|
1357
|
+
private sendUnsubscribe;
|
|
1358
|
+
/**
|
|
1359
|
+
* Handle SEARCH_RESP message (initial results).
|
|
1360
|
+
*/
|
|
1361
|
+
private handleSearchResponse;
|
|
1362
|
+
/**
|
|
1363
|
+
* Handle SEARCH_UPDATE message (delta updates).
|
|
1364
|
+
*/
|
|
1365
|
+
private handleSearchUpdate;
|
|
1366
|
+
/**
|
|
1367
|
+
* Notify all listeners of result changes.
|
|
1368
|
+
*/
|
|
1369
|
+
private notifyListeners;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1212
1372
|
/**
|
|
1213
1373
|
* Cluster mode configuration for TopGunClient.
|
|
1214
1374
|
* When provided, the client connects to multiple nodes with partition-aware routing.
|
|
@@ -1418,6 +1578,75 @@ declare class TopGunClient {
|
|
|
1418
1578
|
* ```
|
|
1419
1579
|
*/
|
|
1420
1580
|
onBackpressure(event: 'backpressure:high' | 'backpressure:low' | 'backpressure:paused' | 'backpressure:resumed' | 'operation:dropped', listener: (data?: BackpressureThresholdEvent | OperationDroppedEvent) => void): () => void;
|
|
1581
|
+
/**
|
|
1582
|
+
* Perform a one-shot BM25 search on the server.
|
|
1583
|
+
*
|
|
1584
|
+
* Searches the specified map using BM25 ranking algorithm.
|
|
1585
|
+
* Requires FTS to be enabled for the map on the server.
|
|
1586
|
+
*
|
|
1587
|
+
* @param mapName Name of the map to search
|
|
1588
|
+
* @param query Search query text
|
|
1589
|
+
* @param options Search options
|
|
1590
|
+
* @returns Promise resolving to search results sorted by relevance
|
|
1591
|
+
*
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```typescript
|
|
1594
|
+
* const results = await client.search<Article>('articles', 'machine learning', {
|
|
1595
|
+
* limit: 20,
|
|
1596
|
+
* minScore: 0.5,
|
|
1597
|
+
* boost: { title: 2.0, body: 1.0 }
|
|
1598
|
+
* });
|
|
1599
|
+
*
|
|
1600
|
+
* for (const result of results) {
|
|
1601
|
+
* console.log(`${result.key}: ${result.value.title} (score: ${result.score})`);
|
|
1602
|
+
* }
|
|
1603
|
+
* ```
|
|
1604
|
+
*/
|
|
1605
|
+
search<T>(mapName: string, query: string, options?: {
|
|
1606
|
+
limit?: number;
|
|
1607
|
+
minScore?: number;
|
|
1608
|
+
boost?: Record<string, number>;
|
|
1609
|
+
}): Promise<Array<{
|
|
1610
|
+
key: string;
|
|
1611
|
+
value: T;
|
|
1612
|
+
score: number;
|
|
1613
|
+
matchedTerms: string[];
|
|
1614
|
+
}>>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Subscribe to live search results with real-time updates.
|
|
1617
|
+
*
|
|
1618
|
+
* Unlike the one-shot `search()` method, `searchSubscribe()` returns a handle
|
|
1619
|
+
* that receives delta updates (ENTER/UPDATE/LEAVE) when documents change.
|
|
1620
|
+
* This is ideal for live search UIs that need to reflect data changes.
|
|
1621
|
+
*
|
|
1622
|
+
* @param mapName Name of the map to search
|
|
1623
|
+
* @param query Search query text
|
|
1624
|
+
* @param options Search options (limit, minScore, boost)
|
|
1625
|
+
* @returns SearchHandle for managing the subscription
|
|
1626
|
+
*
|
|
1627
|
+
* @example
|
|
1628
|
+
* ```typescript
|
|
1629
|
+
* const handle = client.searchSubscribe<Article>('articles', 'machine learning', {
|
|
1630
|
+
* limit: 20,
|
|
1631
|
+
* minScore: 0.5
|
|
1632
|
+
* });
|
|
1633
|
+
*
|
|
1634
|
+
* // Subscribe to result changes
|
|
1635
|
+
* const unsubscribe = handle.subscribe((results) => {
|
|
1636
|
+
* setSearchResults(results);
|
|
1637
|
+
* });
|
|
1638
|
+
*
|
|
1639
|
+
* // Update query dynamically
|
|
1640
|
+
* handle.setQuery('deep learning');
|
|
1641
|
+
*
|
|
1642
|
+
* // Get current snapshot
|
|
1643
|
+
* const snapshot = handle.getResults();
|
|
1644
|
+
*
|
|
1645
|
+
* // Cleanup when done
|
|
1646
|
+
* handle.dispose();
|
|
1647
|
+
* ```
|
|
1648
|
+
*/
|
|
1649
|
+
searchSubscribe<T>(mapName: string, query: string, options?: SearchOptions): SearchHandle<T>;
|
|
1421
1650
|
/**
|
|
1422
1651
|
* Execute an entry processor on a single key atomically.
|
|
1423
1652
|
*
|
|
@@ -2254,4 +2483,4 @@ declare class SingleServerProvider implements IConnectionProvider {
|
|
|
2254
2483
|
|
|
2255
2484
|
declare const logger: pino.Logger<never, boolean>;
|
|
2256
2485
|
|
|
2257
|
-
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 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, 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 };
|
|
2486
|
+
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 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LWWRecord, ORMapRecord, PredicateNode, ConflictResolverDef, MergeRejection, Timestamp, LWWMap, ORMap, HLC, EntryProcessorDef, EntryProcessorResult, 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, 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
|
|
|
@@ -639,6 +639,15 @@ declare class ConflictResolverClient {
|
|
|
639
639
|
get rejectionListenerCount(): number;
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
+
/**
|
|
643
|
+
* Search result item from server.
|
|
644
|
+
*/
|
|
645
|
+
interface SearchResult<T> {
|
|
646
|
+
key: string;
|
|
647
|
+
value: T;
|
|
648
|
+
score: number;
|
|
649
|
+
matchedTerms: string[];
|
|
650
|
+
}
|
|
642
651
|
interface HeartbeatConfig {
|
|
643
652
|
intervalMs: number;
|
|
644
653
|
timeoutMs: number;
|
|
@@ -1026,6 +1035,23 @@ declare class SyncEngine {
|
|
|
1026
1035
|
* Called internally when a message is received.
|
|
1027
1036
|
*/
|
|
1028
1037
|
private emitMessage;
|
|
1038
|
+
/** Pending search requests by requestId */
|
|
1039
|
+
private pendingSearchRequests;
|
|
1040
|
+
/** Default timeout for search requests (ms) */
|
|
1041
|
+
private static readonly SEARCH_TIMEOUT;
|
|
1042
|
+
/**
|
|
1043
|
+
* Perform a one-shot BM25 search on the server.
|
|
1044
|
+
*
|
|
1045
|
+
* @param mapName Name of the map to search
|
|
1046
|
+
* @param query Search query text
|
|
1047
|
+
* @param options Search options (limit, minScore, boost)
|
|
1048
|
+
* @returns Promise resolving to search results
|
|
1049
|
+
*/
|
|
1050
|
+
search<T>(mapName: string, query: string, options?: SearchOptions): Promise<SearchResult<T>[]>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Handle search response from server.
|
|
1053
|
+
*/
|
|
1054
|
+
private handleSearchResponse;
|
|
1029
1055
|
/**
|
|
1030
1056
|
* Get the conflict resolver client for registering custom resolvers
|
|
1031
1057
|
* and subscribing to merge rejection events.
|
|
@@ -1209,6 +1235,140 @@ declare class EventJournalReader {
|
|
|
1209
1235
|
private generateRequestId;
|
|
1210
1236
|
}
|
|
1211
1237
|
|
|
1238
|
+
/**
|
|
1239
|
+
* SearchHandle - Client-side Live Search Subscription Handle
|
|
1240
|
+
*
|
|
1241
|
+
* Manages a live search subscription with delta updates.
|
|
1242
|
+
* Part of Phase 11.1b: Live Search Subscriptions.
|
|
1243
|
+
*
|
|
1244
|
+
* @module SearchHandle
|
|
1245
|
+
*/
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* Callback type for result change notifications.
|
|
1249
|
+
*/
|
|
1250
|
+
type SearchResultsCallback<T> = (results: SearchResult<T>[]) => void;
|
|
1251
|
+
/**
|
|
1252
|
+
* SearchHandle manages a live search subscription.
|
|
1253
|
+
*
|
|
1254
|
+
* Provides:
|
|
1255
|
+
* - Initial results on subscription
|
|
1256
|
+
* - Real-time delta updates (ENTER/UPDATE/LEAVE)
|
|
1257
|
+
* - Sorted results by relevance score
|
|
1258
|
+
* - Query update without re-subscribing
|
|
1259
|
+
*
|
|
1260
|
+
* @example
|
|
1261
|
+
* ```typescript
|
|
1262
|
+
* const handle = client.searchSubscribe<Article>('articles', 'machine learning', {
|
|
1263
|
+
* limit: 20,
|
|
1264
|
+
* minScore: 0.5
|
|
1265
|
+
* });
|
|
1266
|
+
*
|
|
1267
|
+
* // Subscribe to results
|
|
1268
|
+
* const unsubscribe = handle.subscribe((results) => {
|
|
1269
|
+
* console.log('Results updated:', results.length);
|
|
1270
|
+
* });
|
|
1271
|
+
*
|
|
1272
|
+
* // Get current snapshot
|
|
1273
|
+
* const snapshot = handle.getResults();
|
|
1274
|
+
*
|
|
1275
|
+
* // Update query
|
|
1276
|
+
* handle.setQuery('deep learning');
|
|
1277
|
+
*
|
|
1278
|
+
* // Cleanup
|
|
1279
|
+
* handle.dispose();
|
|
1280
|
+
* ```
|
|
1281
|
+
*/
|
|
1282
|
+
declare class SearchHandle<T = unknown> {
|
|
1283
|
+
/** Map name being searched */
|
|
1284
|
+
readonly mapName: string;
|
|
1285
|
+
/** Current search query */
|
|
1286
|
+
private _query;
|
|
1287
|
+
/** Search options */
|
|
1288
|
+
private _options?;
|
|
1289
|
+
/** Unique subscription ID */
|
|
1290
|
+
private subscriptionId;
|
|
1291
|
+
/** Current results map (key → result) */
|
|
1292
|
+
private results;
|
|
1293
|
+
/** Result change listeners */
|
|
1294
|
+
private listeners;
|
|
1295
|
+
/** Whether the handle has been disposed */
|
|
1296
|
+
private disposed;
|
|
1297
|
+
/** Reference to SyncEngine */
|
|
1298
|
+
private syncEngine;
|
|
1299
|
+
/** Handler for all messages (SEARCH_RESP and SEARCH_UPDATE) */
|
|
1300
|
+
private messageHandler;
|
|
1301
|
+
constructor(syncEngine: SyncEngine, mapName: string, query: string, options?: SearchOptions);
|
|
1302
|
+
/**
|
|
1303
|
+
* Handle incoming messages (both SEARCH_RESP and SEARCH_UPDATE).
|
|
1304
|
+
*/
|
|
1305
|
+
private handleMessage;
|
|
1306
|
+
/**
|
|
1307
|
+
* Get the current query string.
|
|
1308
|
+
*/
|
|
1309
|
+
get query(): string;
|
|
1310
|
+
/**
|
|
1311
|
+
* Subscribe to result changes.
|
|
1312
|
+
* Callback is immediately called with current results.
|
|
1313
|
+
*
|
|
1314
|
+
* @param callback - Function called with updated results
|
|
1315
|
+
* @returns Unsubscribe function
|
|
1316
|
+
*/
|
|
1317
|
+
subscribe(callback: SearchResultsCallback<T>): () => void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Get current results snapshot sorted by score (highest first).
|
|
1320
|
+
*
|
|
1321
|
+
* @returns Array of search results
|
|
1322
|
+
*/
|
|
1323
|
+
getResults(): SearchResult<T>[];
|
|
1324
|
+
/**
|
|
1325
|
+
* Get result count.
|
|
1326
|
+
*/
|
|
1327
|
+
get size(): number;
|
|
1328
|
+
/**
|
|
1329
|
+
* Update the search query.
|
|
1330
|
+
* Triggers a new subscription with the updated query.
|
|
1331
|
+
*
|
|
1332
|
+
* @param query - New query string
|
|
1333
|
+
*/
|
|
1334
|
+
setQuery(query: string): void;
|
|
1335
|
+
/**
|
|
1336
|
+
* Update search options.
|
|
1337
|
+
*
|
|
1338
|
+
* @param options - New search options
|
|
1339
|
+
*/
|
|
1340
|
+
setOptions(options: SearchOptions): void;
|
|
1341
|
+
/**
|
|
1342
|
+
* Dispose of the handle and cleanup resources.
|
|
1343
|
+
* After disposal, the handle cannot be used.
|
|
1344
|
+
*/
|
|
1345
|
+
dispose(): void;
|
|
1346
|
+
/**
|
|
1347
|
+
* Check if handle is disposed.
|
|
1348
|
+
*/
|
|
1349
|
+
isDisposed(): boolean;
|
|
1350
|
+
/**
|
|
1351
|
+
* Send SEARCH_SUB message to server.
|
|
1352
|
+
*/
|
|
1353
|
+
private sendSubscribe;
|
|
1354
|
+
/**
|
|
1355
|
+
* Send SEARCH_UNSUB message to server.
|
|
1356
|
+
*/
|
|
1357
|
+
private sendUnsubscribe;
|
|
1358
|
+
/**
|
|
1359
|
+
* Handle SEARCH_RESP message (initial results).
|
|
1360
|
+
*/
|
|
1361
|
+
private handleSearchResponse;
|
|
1362
|
+
/**
|
|
1363
|
+
* Handle SEARCH_UPDATE message (delta updates).
|
|
1364
|
+
*/
|
|
1365
|
+
private handleSearchUpdate;
|
|
1366
|
+
/**
|
|
1367
|
+
* Notify all listeners of result changes.
|
|
1368
|
+
*/
|
|
1369
|
+
private notifyListeners;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1212
1372
|
/**
|
|
1213
1373
|
* Cluster mode configuration for TopGunClient.
|
|
1214
1374
|
* When provided, the client connects to multiple nodes with partition-aware routing.
|
|
@@ -1418,6 +1578,75 @@ declare class TopGunClient {
|
|
|
1418
1578
|
* ```
|
|
1419
1579
|
*/
|
|
1420
1580
|
onBackpressure(event: 'backpressure:high' | 'backpressure:low' | 'backpressure:paused' | 'backpressure:resumed' | 'operation:dropped', listener: (data?: BackpressureThresholdEvent | OperationDroppedEvent) => void): () => void;
|
|
1581
|
+
/**
|
|
1582
|
+
* Perform a one-shot BM25 search on the server.
|
|
1583
|
+
*
|
|
1584
|
+
* Searches the specified map using BM25 ranking algorithm.
|
|
1585
|
+
* Requires FTS to be enabled for the map on the server.
|
|
1586
|
+
*
|
|
1587
|
+
* @param mapName Name of the map to search
|
|
1588
|
+
* @param query Search query text
|
|
1589
|
+
* @param options Search options
|
|
1590
|
+
* @returns Promise resolving to search results sorted by relevance
|
|
1591
|
+
*
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```typescript
|
|
1594
|
+
* const results = await client.search<Article>('articles', 'machine learning', {
|
|
1595
|
+
* limit: 20,
|
|
1596
|
+
* minScore: 0.5,
|
|
1597
|
+
* boost: { title: 2.0, body: 1.0 }
|
|
1598
|
+
* });
|
|
1599
|
+
*
|
|
1600
|
+
* for (const result of results) {
|
|
1601
|
+
* console.log(`${result.key}: ${result.value.title} (score: ${result.score})`);
|
|
1602
|
+
* }
|
|
1603
|
+
* ```
|
|
1604
|
+
*/
|
|
1605
|
+
search<T>(mapName: string, query: string, options?: {
|
|
1606
|
+
limit?: number;
|
|
1607
|
+
minScore?: number;
|
|
1608
|
+
boost?: Record<string, number>;
|
|
1609
|
+
}): Promise<Array<{
|
|
1610
|
+
key: string;
|
|
1611
|
+
value: T;
|
|
1612
|
+
score: number;
|
|
1613
|
+
matchedTerms: string[];
|
|
1614
|
+
}>>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Subscribe to live search results with real-time updates.
|
|
1617
|
+
*
|
|
1618
|
+
* Unlike the one-shot `search()` method, `searchSubscribe()` returns a handle
|
|
1619
|
+
* that receives delta updates (ENTER/UPDATE/LEAVE) when documents change.
|
|
1620
|
+
* This is ideal for live search UIs that need to reflect data changes.
|
|
1621
|
+
*
|
|
1622
|
+
* @param mapName Name of the map to search
|
|
1623
|
+
* @param query Search query text
|
|
1624
|
+
* @param options Search options (limit, minScore, boost)
|
|
1625
|
+
* @returns SearchHandle for managing the subscription
|
|
1626
|
+
*
|
|
1627
|
+
* @example
|
|
1628
|
+
* ```typescript
|
|
1629
|
+
* const handle = client.searchSubscribe<Article>('articles', 'machine learning', {
|
|
1630
|
+
* limit: 20,
|
|
1631
|
+
* minScore: 0.5
|
|
1632
|
+
* });
|
|
1633
|
+
*
|
|
1634
|
+
* // Subscribe to result changes
|
|
1635
|
+
* const unsubscribe = handle.subscribe((results) => {
|
|
1636
|
+
* setSearchResults(results);
|
|
1637
|
+
* });
|
|
1638
|
+
*
|
|
1639
|
+
* // Update query dynamically
|
|
1640
|
+
* handle.setQuery('deep learning');
|
|
1641
|
+
*
|
|
1642
|
+
* // Get current snapshot
|
|
1643
|
+
* const snapshot = handle.getResults();
|
|
1644
|
+
*
|
|
1645
|
+
* // Cleanup when done
|
|
1646
|
+
* handle.dispose();
|
|
1647
|
+
* ```
|
|
1648
|
+
*/
|
|
1649
|
+
searchSubscribe<T>(mapName: string, query: string, options?: SearchOptions): SearchHandle<T>;
|
|
1421
1650
|
/**
|
|
1422
1651
|
* Execute an entry processor on a single key atomically.
|
|
1423
1652
|
*
|
|
@@ -2254,4 +2483,4 @@ declare class SingleServerProvider implements IConnectionProvider {
|
|
|
2254
2483
|
|
|
2255
2484
|
declare const logger: pino.Logger<never, boolean>;
|
|
2256
2485
|
|
|
2257
|
-
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 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, 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 };
|
|
2486
|
+
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 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 };
|