@topgunbuild/client 0.8.0 → 0.8.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 +223 -1
- package/dist/index.d.ts +223 -1
- package/dist/index.js +419 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +418 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -188,6 +188,148 @@ declare class QueryHandle<T> {
|
|
|
188
188
|
getMapName(): string;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* HybridQueryHandle - Query handle for hybrid FTS + filter queries
|
|
193
|
+
*
|
|
194
|
+
* Extends QueryHandle functionality to support:
|
|
195
|
+
* - FTS predicates (match, matchPhrase, matchPrefix)
|
|
196
|
+
* - Score-based sorting (_score field)
|
|
197
|
+
* - Hybrid queries combining FTS with traditional filters
|
|
198
|
+
*
|
|
199
|
+
* Part of Phase 12: Unified Search
|
|
200
|
+
*
|
|
201
|
+
* @module HybridQueryHandle
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Filter options for hybrid queries.
|
|
206
|
+
*/
|
|
207
|
+
interface HybridQueryFilter {
|
|
208
|
+
/** Traditional where clause filters */
|
|
209
|
+
where?: Record<string, any>;
|
|
210
|
+
/** Predicate tree (can include FTS predicates) */
|
|
211
|
+
predicate?: PredicateNode;
|
|
212
|
+
/** Sort configuration - use '_score' for FTS relevance sorting */
|
|
213
|
+
sort?: Record<string, 'asc' | 'desc'>;
|
|
214
|
+
/** Maximum results */
|
|
215
|
+
limit?: number;
|
|
216
|
+
/** Skip N results */
|
|
217
|
+
offset?: number;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Result item with score for hybrid queries.
|
|
221
|
+
*/
|
|
222
|
+
interface HybridResultItem<T> {
|
|
223
|
+
/** The document */
|
|
224
|
+
value: T;
|
|
225
|
+
/** Unique key */
|
|
226
|
+
_key: string;
|
|
227
|
+
/** Relevance score (only for FTS queries) */
|
|
228
|
+
_score?: number;
|
|
229
|
+
/** Matched terms (only for FTS queries) */
|
|
230
|
+
_matchedTerms?: string[];
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Source of query results.
|
|
234
|
+
*/
|
|
235
|
+
type HybridResultSource = 'local' | 'server';
|
|
236
|
+
/**
|
|
237
|
+
* HybridQueryHandle manages hybrid queries that combine FTS with filters.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* // Create hybrid query: FTS + filter
|
|
242
|
+
* const handle = new HybridQueryHandle(syncEngine, 'articles', {
|
|
243
|
+
* predicate: Predicates.and(
|
|
244
|
+
* Predicates.match('body', 'machine learning'),
|
|
245
|
+
* Predicates.equal('category', 'tech')
|
|
246
|
+
* ),
|
|
247
|
+
* sort: { _score: 'desc' },
|
|
248
|
+
* limit: 20
|
|
249
|
+
* });
|
|
250
|
+
*
|
|
251
|
+
* // Subscribe to results
|
|
252
|
+
* handle.subscribe((results) => {
|
|
253
|
+
* results.forEach(r => console.log(`${r._key}: ${r._score}`));
|
|
254
|
+
* });
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
declare class HybridQueryHandle<T> {
|
|
258
|
+
readonly id: string;
|
|
259
|
+
private syncEngine;
|
|
260
|
+
private mapName;
|
|
261
|
+
private filter;
|
|
262
|
+
private listeners;
|
|
263
|
+
private currentResults;
|
|
264
|
+
private changeTracker;
|
|
265
|
+
private pendingChanges;
|
|
266
|
+
private changeListeners;
|
|
267
|
+
private hasReceivedServerData;
|
|
268
|
+
constructor(syncEngine: SyncEngine, mapName: string, filter?: HybridQueryFilter);
|
|
269
|
+
/**
|
|
270
|
+
* Subscribe to query results.
|
|
271
|
+
*/
|
|
272
|
+
subscribe(callback: (results: HybridResultItem<T>[]) => void): () => void;
|
|
273
|
+
private loadInitialLocalData;
|
|
274
|
+
/**
|
|
275
|
+
* Called by SyncEngine with query results.
|
|
276
|
+
*/
|
|
277
|
+
onResult(items: Array<{
|
|
278
|
+
key: string;
|
|
279
|
+
value: T;
|
|
280
|
+
score?: number;
|
|
281
|
+
matchedTerms?: string[];
|
|
282
|
+
}>, source?: HybridResultSource): void;
|
|
283
|
+
/**
|
|
284
|
+
* Called by SyncEngine on live update.
|
|
285
|
+
*/
|
|
286
|
+
onUpdate(key: string, value: T | null, score?: number, matchedTerms?: string[]): void;
|
|
287
|
+
/**
|
|
288
|
+
* Subscribe to change events.
|
|
289
|
+
*/
|
|
290
|
+
onChanges(listener: (changes: ChangeEvent<T>[]) => void): () => void;
|
|
291
|
+
/**
|
|
292
|
+
* Get and clear pending changes.
|
|
293
|
+
*/
|
|
294
|
+
consumeChanges(): ChangeEvent<T>[];
|
|
295
|
+
/**
|
|
296
|
+
* Get last change without consuming.
|
|
297
|
+
*/
|
|
298
|
+
getLastChange(): ChangeEvent<T> | null;
|
|
299
|
+
/**
|
|
300
|
+
* Get all pending changes without consuming.
|
|
301
|
+
*/
|
|
302
|
+
getPendingChanges(): ChangeEvent<T>[];
|
|
303
|
+
/**
|
|
304
|
+
* Clear all pending changes.
|
|
305
|
+
*/
|
|
306
|
+
clearChanges(): void;
|
|
307
|
+
/**
|
|
308
|
+
* Reset change tracker.
|
|
309
|
+
*/
|
|
310
|
+
resetChangeTracker(): void;
|
|
311
|
+
private computeAndNotifyChanges;
|
|
312
|
+
private notifyChangeListeners;
|
|
313
|
+
private notify;
|
|
314
|
+
/**
|
|
315
|
+
* Get sorted results with _key and _score.
|
|
316
|
+
*/
|
|
317
|
+
private getSortedResults;
|
|
318
|
+
/**
|
|
319
|
+
* Get the filter configuration.
|
|
320
|
+
*/
|
|
321
|
+
getFilter(): HybridQueryFilter;
|
|
322
|
+
/**
|
|
323
|
+
* Get the map name.
|
|
324
|
+
*/
|
|
325
|
+
getMapName(): string;
|
|
326
|
+
/**
|
|
327
|
+
* Check if this query contains FTS predicates.
|
|
328
|
+
*/
|
|
329
|
+
hasFTSPredicate(): boolean;
|
|
330
|
+
private containsFTS;
|
|
331
|
+
}
|
|
332
|
+
|
|
191
333
|
type TopicCallback = (data: any, context: {
|
|
192
334
|
timestamp: number;
|
|
193
335
|
publisherId?: string;
|
|
@@ -1057,6 +1199,54 @@ declare class SyncEngine {
|
|
|
1057
1199
|
* and subscribing to merge rejection events.
|
|
1058
1200
|
*/
|
|
1059
1201
|
getConflictResolverClient(): ConflictResolverClient;
|
|
1202
|
+
/** Active hybrid query subscriptions */
|
|
1203
|
+
private hybridQueries;
|
|
1204
|
+
/**
|
|
1205
|
+
* Subscribe to a hybrid query (FTS + filter combination).
|
|
1206
|
+
*/
|
|
1207
|
+
subscribeToHybridQuery<T>(query: HybridQueryHandle<T>): void;
|
|
1208
|
+
/**
|
|
1209
|
+
* Unsubscribe from a hybrid query.
|
|
1210
|
+
*/
|
|
1211
|
+
unsubscribeFromHybridQuery(queryId: string): void;
|
|
1212
|
+
/**
|
|
1213
|
+
* Send hybrid query subscription to server.
|
|
1214
|
+
*/
|
|
1215
|
+
private sendHybridQuerySubscription;
|
|
1216
|
+
/**
|
|
1217
|
+
* 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.
|
|
1220
|
+
*/
|
|
1221
|
+
runLocalHybridQuery<T>(mapName: string, filter: HybridQueryFilter): Promise<Array<{
|
|
1222
|
+
key: string;
|
|
1223
|
+
value: T;
|
|
1224
|
+
score?: number;
|
|
1225
|
+
matchedTerms?: string[];
|
|
1226
|
+
}>>;
|
|
1227
|
+
/**
|
|
1228
|
+
* Handle hybrid query response from server.
|
|
1229
|
+
*/
|
|
1230
|
+
handleHybridQueryResponse(payload: {
|
|
1231
|
+
subscriptionId: string;
|
|
1232
|
+
results: Array<{
|
|
1233
|
+
key: string;
|
|
1234
|
+
value: unknown;
|
|
1235
|
+
score: number;
|
|
1236
|
+
matchedTerms: string[];
|
|
1237
|
+
}>;
|
|
1238
|
+
}): void;
|
|
1239
|
+
/**
|
|
1240
|
+
* Handle hybrid query delta update from server.
|
|
1241
|
+
*/
|
|
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;
|
|
1060
1250
|
}
|
|
1061
1251
|
|
|
1062
1252
|
interface ILock {
|
|
@@ -1647,6 +1837,38 @@ declare class TopGunClient {
|
|
|
1647
1837
|
* ```
|
|
1648
1838
|
*/
|
|
1649
1839
|
searchSubscribe<T>(mapName: string, query: string, options?: SearchOptions): SearchHandle<T>;
|
|
1840
|
+
/**
|
|
1841
|
+
* Create a hybrid query combining FTS with traditional filters.
|
|
1842
|
+
*
|
|
1843
|
+
* Hybrid queries allow combining full-text search predicates (match, matchPhrase, matchPrefix)
|
|
1844
|
+
* with traditional filter predicates (eq, gt, lt, contains, etc.) in a single query.
|
|
1845
|
+
* Results include relevance scores for FTS ranking.
|
|
1846
|
+
*
|
|
1847
|
+
* @param mapName Name of the map to query
|
|
1848
|
+
* @param filter Hybrid query filter with predicate, where, sort, limit, offset
|
|
1849
|
+
* @returns HybridQueryHandle for managing the subscription
|
|
1850
|
+
*
|
|
1851
|
+
* @example
|
|
1852
|
+
* ```typescript
|
|
1853
|
+
* import { Predicates } from '@topgunbuild/core';
|
|
1854
|
+
*
|
|
1855
|
+
* // Hybrid query: FTS + filter
|
|
1856
|
+
* const handle = client.hybridQuery<Article>('articles', {
|
|
1857
|
+
* predicate: Predicates.and(
|
|
1858
|
+
* Predicates.match('body', 'machine learning'),
|
|
1859
|
+
* Predicates.equal('category', 'tech')
|
|
1860
|
+
* ),
|
|
1861
|
+
* sort: { _score: 'desc' },
|
|
1862
|
+
* limit: 20
|
|
1863
|
+
* });
|
|
1864
|
+
*
|
|
1865
|
+
* // Subscribe to results
|
|
1866
|
+
* handle.subscribe((results) => {
|
|
1867
|
+
* results.forEach(r => console.log(`${r._key}: score=${r._score}`));
|
|
1868
|
+
* });
|
|
1869
|
+
* ```
|
|
1870
|
+
*/
|
|
1871
|
+
hybridQuery<T>(mapName: string, filter?: HybridQueryFilter): HybridQueryHandle<T>;
|
|
1650
1872
|
/**
|
|
1651
1873
|
* Execute an entry processor on a single key atomically.
|
|
1652
1874
|
*
|
|
@@ -2483,4 +2705,4 @@ declare class SingleServerProvider implements IConnectionProvider {
|
|
|
2483
2705
|
|
|
2484
2706
|
declare const logger: pino.Logger<never, boolean>;
|
|
2485
2707
|
|
|
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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -188,6 +188,148 @@ declare class QueryHandle<T> {
|
|
|
188
188
|
getMapName(): string;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* HybridQueryHandle - Query handle for hybrid FTS + filter queries
|
|
193
|
+
*
|
|
194
|
+
* Extends QueryHandle functionality to support:
|
|
195
|
+
* - FTS predicates (match, matchPhrase, matchPrefix)
|
|
196
|
+
* - Score-based sorting (_score field)
|
|
197
|
+
* - Hybrid queries combining FTS with traditional filters
|
|
198
|
+
*
|
|
199
|
+
* Part of Phase 12: Unified Search
|
|
200
|
+
*
|
|
201
|
+
* @module HybridQueryHandle
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Filter options for hybrid queries.
|
|
206
|
+
*/
|
|
207
|
+
interface HybridQueryFilter {
|
|
208
|
+
/** Traditional where clause filters */
|
|
209
|
+
where?: Record<string, any>;
|
|
210
|
+
/** Predicate tree (can include FTS predicates) */
|
|
211
|
+
predicate?: PredicateNode;
|
|
212
|
+
/** Sort configuration - use '_score' for FTS relevance sorting */
|
|
213
|
+
sort?: Record<string, 'asc' | 'desc'>;
|
|
214
|
+
/** Maximum results */
|
|
215
|
+
limit?: number;
|
|
216
|
+
/** Skip N results */
|
|
217
|
+
offset?: number;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Result item with score for hybrid queries.
|
|
221
|
+
*/
|
|
222
|
+
interface HybridResultItem<T> {
|
|
223
|
+
/** The document */
|
|
224
|
+
value: T;
|
|
225
|
+
/** Unique key */
|
|
226
|
+
_key: string;
|
|
227
|
+
/** Relevance score (only for FTS queries) */
|
|
228
|
+
_score?: number;
|
|
229
|
+
/** Matched terms (only for FTS queries) */
|
|
230
|
+
_matchedTerms?: string[];
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Source of query results.
|
|
234
|
+
*/
|
|
235
|
+
type HybridResultSource = 'local' | 'server';
|
|
236
|
+
/**
|
|
237
|
+
* HybridQueryHandle manages hybrid queries that combine FTS with filters.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* // Create hybrid query: FTS + filter
|
|
242
|
+
* const handle = new HybridQueryHandle(syncEngine, 'articles', {
|
|
243
|
+
* predicate: Predicates.and(
|
|
244
|
+
* Predicates.match('body', 'machine learning'),
|
|
245
|
+
* Predicates.equal('category', 'tech')
|
|
246
|
+
* ),
|
|
247
|
+
* sort: { _score: 'desc' },
|
|
248
|
+
* limit: 20
|
|
249
|
+
* });
|
|
250
|
+
*
|
|
251
|
+
* // Subscribe to results
|
|
252
|
+
* handle.subscribe((results) => {
|
|
253
|
+
* results.forEach(r => console.log(`${r._key}: ${r._score}`));
|
|
254
|
+
* });
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
declare class HybridQueryHandle<T> {
|
|
258
|
+
readonly id: string;
|
|
259
|
+
private syncEngine;
|
|
260
|
+
private mapName;
|
|
261
|
+
private filter;
|
|
262
|
+
private listeners;
|
|
263
|
+
private currentResults;
|
|
264
|
+
private changeTracker;
|
|
265
|
+
private pendingChanges;
|
|
266
|
+
private changeListeners;
|
|
267
|
+
private hasReceivedServerData;
|
|
268
|
+
constructor(syncEngine: SyncEngine, mapName: string, filter?: HybridQueryFilter);
|
|
269
|
+
/**
|
|
270
|
+
* Subscribe to query results.
|
|
271
|
+
*/
|
|
272
|
+
subscribe(callback: (results: HybridResultItem<T>[]) => void): () => void;
|
|
273
|
+
private loadInitialLocalData;
|
|
274
|
+
/**
|
|
275
|
+
* Called by SyncEngine with query results.
|
|
276
|
+
*/
|
|
277
|
+
onResult(items: Array<{
|
|
278
|
+
key: string;
|
|
279
|
+
value: T;
|
|
280
|
+
score?: number;
|
|
281
|
+
matchedTerms?: string[];
|
|
282
|
+
}>, source?: HybridResultSource): void;
|
|
283
|
+
/**
|
|
284
|
+
* Called by SyncEngine on live update.
|
|
285
|
+
*/
|
|
286
|
+
onUpdate(key: string, value: T | null, score?: number, matchedTerms?: string[]): void;
|
|
287
|
+
/**
|
|
288
|
+
* Subscribe to change events.
|
|
289
|
+
*/
|
|
290
|
+
onChanges(listener: (changes: ChangeEvent<T>[]) => void): () => void;
|
|
291
|
+
/**
|
|
292
|
+
* Get and clear pending changes.
|
|
293
|
+
*/
|
|
294
|
+
consumeChanges(): ChangeEvent<T>[];
|
|
295
|
+
/**
|
|
296
|
+
* Get last change without consuming.
|
|
297
|
+
*/
|
|
298
|
+
getLastChange(): ChangeEvent<T> | null;
|
|
299
|
+
/**
|
|
300
|
+
* Get all pending changes without consuming.
|
|
301
|
+
*/
|
|
302
|
+
getPendingChanges(): ChangeEvent<T>[];
|
|
303
|
+
/**
|
|
304
|
+
* Clear all pending changes.
|
|
305
|
+
*/
|
|
306
|
+
clearChanges(): void;
|
|
307
|
+
/**
|
|
308
|
+
* Reset change tracker.
|
|
309
|
+
*/
|
|
310
|
+
resetChangeTracker(): void;
|
|
311
|
+
private computeAndNotifyChanges;
|
|
312
|
+
private notifyChangeListeners;
|
|
313
|
+
private notify;
|
|
314
|
+
/**
|
|
315
|
+
* Get sorted results with _key and _score.
|
|
316
|
+
*/
|
|
317
|
+
private getSortedResults;
|
|
318
|
+
/**
|
|
319
|
+
* Get the filter configuration.
|
|
320
|
+
*/
|
|
321
|
+
getFilter(): HybridQueryFilter;
|
|
322
|
+
/**
|
|
323
|
+
* Get the map name.
|
|
324
|
+
*/
|
|
325
|
+
getMapName(): string;
|
|
326
|
+
/**
|
|
327
|
+
* Check if this query contains FTS predicates.
|
|
328
|
+
*/
|
|
329
|
+
hasFTSPredicate(): boolean;
|
|
330
|
+
private containsFTS;
|
|
331
|
+
}
|
|
332
|
+
|
|
191
333
|
type TopicCallback = (data: any, context: {
|
|
192
334
|
timestamp: number;
|
|
193
335
|
publisherId?: string;
|
|
@@ -1057,6 +1199,54 @@ declare class SyncEngine {
|
|
|
1057
1199
|
* and subscribing to merge rejection events.
|
|
1058
1200
|
*/
|
|
1059
1201
|
getConflictResolverClient(): ConflictResolverClient;
|
|
1202
|
+
/** Active hybrid query subscriptions */
|
|
1203
|
+
private hybridQueries;
|
|
1204
|
+
/**
|
|
1205
|
+
* Subscribe to a hybrid query (FTS + filter combination).
|
|
1206
|
+
*/
|
|
1207
|
+
subscribeToHybridQuery<T>(query: HybridQueryHandle<T>): void;
|
|
1208
|
+
/**
|
|
1209
|
+
* Unsubscribe from a hybrid query.
|
|
1210
|
+
*/
|
|
1211
|
+
unsubscribeFromHybridQuery(queryId: string): void;
|
|
1212
|
+
/**
|
|
1213
|
+
* Send hybrid query subscription to server.
|
|
1214
|
+
*/
|
|
1215
|
+
private sendHybridQuerySubscription;
|
|
1216
|
+
/**
|
|
1217
|
+
* 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.
|
|
1220
|
+
*/
|
|
1221
|
+
runLocalHybridQuery<T>(mapName: string, filter: HybridQueryFilter): Promise<Array<{
|
|
1222
|
+
key: string;
|
|
1223
|
+
value: T;
|
|
1224
|
+
score?: number;
|
|
1225
|
+
matchedTerms?: string[];
|
|
1226
|
+
}>>;
|
|
1227
|
+
/**
|
|
1228
|
+
* Handle hybrid query response from server.
|
|
1229
|
+
*/
|
|
1230
|
+
handleHybridQueryResponse(payload: {
|
|
1231
|
+
subscriptionId: string;
|
|
1232
|
+
results: Array<{
|
|
1233
|
+
key: string;
|
|
1234
|
+
value: unknown;
|
|
1235
|
+
score: number;
|
|
1236
|
+
matchedTerms: string[];
|
|
1237
|
+
}>;
|
|
1238
|
+
}): void;
|
|
1239
|
+
/**
|
|
1240
|
+
* Handle hybrid query delta update from server.
|
|
1241
|
+
*/
|
|
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;
|
|
1060
1250
|
}
|
|
1061
1251
|
|
|
1062
1252
|
interface ILock {
|
|
@@ -1647,6 +1837,38 @@ declare class TopGunClient {
|
|
|
1647
1837
|
* ```
|
|
1648
1838
|
*/
|
|
1649
1839
|
searchSubscribe<T>(mapName: string, query: string, options?: SearchOptions): SearchHandle<T>;
|
|
1840
|
+
/**
|
|
1841
|
+
* Create a hybrid query combining FTS with traditional filters.
|
|
1842
|
+
*
|
|
1843
|
+
* Hybrid queries allow combining full-text search predicates (match, matchPhrase, matchPrefix)
|
|
1844
|
+
* with traditional filter predicates (eq, gt, lt, contains, etc.) in a single query.
|
|
1845
|
+
* Results include relevance scores for FTS ranking.
|
|
1846
|
+
*
|
|
1847
|
+
* @param mapName Name of the map to query
|
|
1848
|
+
* @param filter Hybrid query filter with predicate, where, sort, limit, offset
|
|
1849
|
+
* @returns HybridQueryHandle for managing the subscription
|
|
1850
|
+
*
|
|
1851
|
+
* @example
|
|
1852
|
+
* ```typescript
|
|
1853
|
+
* import { Predicates } from '@topgunbuild/core';
|
|
1854
|
+
*
|
|
1855
|
+
* // Hybrid query: FTS + filter
|
|
1856
|
+
* const handle = client.hybridQuery<Article>('articles', {
|
|
1857
|
+
* predicate: Predicates.and(
|
|
1858
|
+
* Predicates.match('body', 'machine learning'),
|
|
1859
|
+
* Predicates.equal('category', 'tech')
|
|
1860
|
+
* ),
|
|
1861
|
+
* sort: { _score: 'desc' },
|
|
1862
|
+
* limit: 20
|
|
1863
|
+
* });
|
|
1864
|
+
*
|
|
1865
|
+
* // Subscribe to results
|
|
1866
|
+
* handle.subscribe((results) => {
|
|
1867
|
+
* results.forEach(r => console.log(`${r._key}: score=${r._score}`));
|
|
1868
|
+
* });
|
|
1869
|
+
* ```
|
|
1870
|
+
*/
|
|
1871
|
+
hybridQuery<T>(mapName: string, filter?: HybridQueryFilter): HybridQueryHandle<T>;
|
|
1650
1872
|
/**
|
|
1651
1873
|
* Execute an entry processor on a single key atomically.
|
|
1652
1874
|
*
|
|
@@ -2483,4 +2705,4 @@ declare class SingleServerProvider implements IConnectionProvider {
|
|
|
2483
2705
|
|
|
2484
2706
|
declare const logger: pino.Logger<never, boolean>;
|
|
2485
2707
|
|
|
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 };
|
|
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 };
|