@topgunbuild/core 0.9.0 → 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/dist/index.d.mts +873 -9
- package/dist/index.d.ts +873 -9
- package/dist/index.js +691 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +662 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1145,6 +1145,14 @@ declare function disableNativeHash(): void;
|
|
|
1145
1145
|
* Resets the load state so native module can be loaded again.
|
|
1146
1146
|
*/
|
|
1147
1147
|
declare function resetNativeHash(): void;
|
|
1148
|
+
/**
|
|
1149
|
+
* Hash an object to a 32-bit unsigned integer.
|
|
1150
|
+
* Uses deterministic JSON serialization + hashString.
|
|
1151
|
+
*
|
|
1152
|
+
* @param obj - Object to hash (must be JSON-serializable)
|
|
1153
|
+
* @returns 32-bit unsigned integer hash
|
|
1154
|
+
*/
|
|
1155
|
+
declare function hashObject(obj: unknown): number;
|
|
1148
1156
|
|
|
1149
1157
|
/**
|
|
1150
1158
|
* Serializes a JavaScript object to MessagePack binary format.
|
|
@@ -1377,7 +1385,53 @@ declare const QuerySchema: z.ZodObject<{
|
|
|
1377
1385
|
desc: "desc";
|
|
1378
1386
|
}>>>;
|
|
1379
1387
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
1380
|
-
|
|
1388
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
1389
|
+
}, z.core.$strip>;
|
|
1390
|
+
/**
|
|
1391
|
+
* Cursor status for debugging.
|
|
1392
|
+
* - valid: Cursor was valid and applied
|
|
1393
|
+
* - expired: Cursor was expired (fell back to first page)
|
|
1394
|
+
* - invalid: Cursor was malformed or hash mismatch (fell back to first page)
|
|
1395
|
+
* - none: No cursor was provided
|
|
1396
|
+
*/
|
|
1397
|
+
declare const CursorStatusSchema: z.ZodEnum<{
|
|
1398
|
+
valid: "valid";
|
|
1399
|
+
expired: "expired";
|
|
1400
|
+
invalid: "invalid";
|
|
1401
|
+
none: "none";
|
|
1402
|
+
}>;
|
|
1403
|
+
declare const QueryRespPayloadSchema: z.ZodObject<{
|
|
1404
|
+
queryId: z.ZodString;
|
|
1405
|
+
results: z.ZodArray<z.ZodObject<{
|
|
1406
|
+
key: z.ZodString;
|
|
1407
|
+
value: z.ZodUnknown;
|
|
1408
|
+
}, z.core.$strip>>;
|
|
1409
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
1410
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
1411
|
+
cursorStatus: z.ZodOptional<z.ZodEnum<{
|
|
1412
|
+
valid: "valid";
|
|
1413
|
+
expired: "expired";
|
|
1414
|
+
invalid: "invalid";
|
|
1415
|
+
none: "none";
|
|
1416
|
+
}>>;
|
|
1417
|
+
}, z.core.$strip>;
|
|
1418
|
+
declare const QueryRespMessageSchema: z.ZodObject<{
|
|
1419
|
+
type: z.ZodLiteral<"QUERY_RESP">;
|
|
1420
|
+
payload: z.ZodObject<{
|
|
1421
|
+
queryId: z.ZodString;
|
|
1422
|
+
results: z.ZodArray<z.ZodObject<{
|
|
1423
|
+
key: z.ZodString;
|
|
1424
|
+
value: z.ZodUnknown;
|
|
1425
|
+
}, z.core.$strip>>;
|
|
1426
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
1427
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
1428
|
+
cursorStatus: z.ZodOptional<z.ZodEnum<{
|
|
1429
|
+
valid: "valid";
|
|
1430
|
+
expired: "expired";
|
|
1431
|
+
invalid: "invalid";
|
|
1432
|
+
none: "none";
|
|
1433
|
+
}>>;
|
|
1434
|
+
}, z.core.$strip>;
|
|
1381
1435
|
}, z.core.$strip>;
|
|
1382
1436
|
declare const ClientOpSchema: z.ZodObject<{
|
|
1383
1437
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -1430,7 +1484,7 @@ declare const QuerySubMessageSchema: z.ZodObject<{
|
|
|
1430
1484
|
desc: "desc";
|
|
1431
1485
|
}>>>;
|
|
1432
1486
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
1433
|
-
|
|
1487
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
1434
1488
|
}, z.core.$strip>;
|
|
1435
1489
|
}, z.core.$strip>;
|
|
1436
1490
|
}, z.core.$strip>;
|
|
@@ -2278,6 +2332,134 @@ declare const OpRejectedMessageSchema: z.ZodObject<{
|
|
|
2278
2332
|
code: z.ZodOptional<z.ZodNumber>;
|
|
2279
2333
|
}, z.core.$strip>;
|
|
2280
2334
|
}, z.core.$strip>;
|
|
2335
|
+
/**
|
|
2336
|
+
* CLUSTER_SUB_REGISTER - Register a distributed subscription on a node.
|
|
2337
|
+
* Sent from coordinator to data-owning nodes for both FTS and Query subscriptions.
|
|
2338
|
+
*/
|
|
2339
|
+
declare const ClusterSubRegisterPayloadSchema: z.ZodObject<{
|
|
2340
|
+
subscriptionId: z.ZodString;
|
|
2341
|
+
coordinatorNodeId: z.ZodString;
|
|
2342
|
+
mapName: z.ZodString;
|
|
2343
|
+
type: z.ZodEnum<{
|
|
2344
|
+
SEARCH: "SEARCH";
|
|
2345
|
+
QUERY: "QUERY";
|
|
2346
|
+
}>;
|
|
2347
|
+
searchQuery: z.ZodOptional<z.ZodString>;
|
|
2348
|
+
searchOptions: z.ZodOptional<z.ZodObject<{
|
|
2349
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
2350
|
+
minScore: z.ZodOptional<z.ZodNumber>;
|
|
2351
|
+
boost: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
2352
|
+
}, z.core.$strip>>;
|
|
2353
|
+
queryPredicate: z.ZodOptional<z.ZodAny>;
|
|
2354
|
+
querySort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
2355
|
+
asc: "asc";
|
|
2356
|
+
desc: "desc";
|
|
2357
|
+
}>>>;
|
|
2358
|
+
}, z.core.$strip>;
|
|
2359
|
+
declare const ClusterSubRegisterMessageSchema: z.ZodObject<{
|
|
2360
|
+
type: z.ZodLiteral<"CLUSTER_SUB_REGISTER">;
|
|
2361
|
+
payload: z.ZodObject<{
|
|
2362
|
+
subscriptionId: z.ZodString;
|
|
2363
|
+
coordinatorNodeId: z.ZodString;
|
|
2364
|
+
mapName: z.ZodString;
|
|
2365
|
+
type: z.ZodEnum<{
|
|
2366
|
+
SEARCH: "SEARCH";
|
|
2367
|
+
QUERY: "QUERY";
|
|
2368
|
+
}>;
|
|
2369
|
+
searchQuery: z.ZodOptional<z.ZodString>;
|
|
2370
|
+
searchOptions: z.ZodOptional<z.ZodObject<{
|
|
2371
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
2372
|
+
minScore: z.ZodOptional<z.ZodNumber>;
|
|
2373
|
+
boost: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
2374
|
+
}, z.core.$strip>>;
|
|
2375
|
+
queryPredicate: z.ZodOptional<z.ZodAny>;
|
|
2376
|
+
querySort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
2377
|
+
asc: "asc";
|
|
2378
|
+
desc: "desc";
|
|
2379
|
+
}>>>;
|
|
2380
|
+
}, z.core.$strip>;
|
|
2381
|
+
}, z.core.$strip>;
|
|
2382
|
+
/**
|
|
2383
|
+
* CLUSTER_SUB_ACK - Acknowledgment of subscription registration with initial results.
|
|
2384
|
+
* Sent from data node back to coordinator.
|
|
2385
|
+
*/
|
|
2386
|
+
declare const ClusterSubAckPayloadSchema: z.ZodObject<{
|
|
2387
|
+
subscriptionId: z.ZodString;
|
|
2388
|
+
nodeId: z.ZodString;
|
|
2389
|
+
success: z.ZodBoolean;
|
|
2390
|
+
error: z.ZodOptional<z.ZodString>;
|
|
2391
|
+
initialResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2392
|
+
key: z.ZodString;
|
|
2393
|
+
value: z.ZodUnknown;
|
|
2394
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
2395
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2396
|
+
}, z.core.$strip>>>;
|
|
2397
|
+
totalHits: z.ZodOptional<z.ZodNumber>;
|
|
2398
|
+
}, z.core.$strip>;
|
|
2399
|
+
declare const ClusterSubAckMessageSchema: z.ZodObject<{
|
|
2400
|
+
type: z.ZodLiteral<"CLUSTER_SUB_ACK">;
|
|
2401
|
+
payload: z.ZodObject<{
|
|
2402
|
+
subscriptionId: z.ZodString;
|
|
2403
|
+
nodeId: z.ZodString;
|
|
2404
|
+
success: z.ZodBoolean;
|
|
2405
|
+
error: z.ZodOptional<z.ZodString>;
|
|
2406
|
+
initialResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2407
|
+
key: z.ZodString;
|
|
2408
|
+
value: z.ZodUnknown;
|
|
2409
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
2410
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2411
|
+
}, z.core.$strip>>>;
|
|
2412
|
+
totalHits: z.ZodOptional<z.ZodNumber>;
|
|
2413
|
+
}, z.core.$strip>;
|
|
2414
|
+
}, z.core.$strip>;
|
|
2415
|
+
/**
|
|
2416
|
+
* CLUSTER_SUB_UPDATE - Delta update from a data node to coordinator.
|
|
2417
|
+
* Sent when a document enters/updates/leaves the subscription result set.
|
|
2418
|
+
*/
|
|
2419
|
+
declare const ClusterSubUpdatePayloadSchema: z.ZodObject<{
|
|
2420
|
+
subscriptionId: z.ZodString;
|
|
2421
|
+
sourceNodeId: z.ZodString;
|
|
2422
|
+
key: z.ZodString;
|
|
2423
|
+
value: z.ZodUnknown;
|
|
2424
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
2425
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2426
|
+
changeType: z.ZodEnum<{
|
|
2427
|
+
UPDATE: "UPDATE";
|
|
2428
|
+
ENTER: "ENTER";
|
|
2429
|
+
LEAVE: "LEAVE";
|
|
2430
|
+
}>;
|
|
2431
|
+
timestamp: z.ZodNumber;
|
|
2432
|
+
}, z.core.$strip>;
|
|
2433
|
+
declare const ClusterSubUpdateMessageSchema: z.ZodObject<{
|
|
2434
|
+
type: z.ZodLiteral<"CLUSTER_SUB_UPDATE">;
|
|
2435
|
+
payload: z.ZodObject<{
|
|
2436
|
+
subscriptionId: z.ZodString;
|
|
2437
|
+
sourceNodeId: z.ZodString;
|
|
2438
|
+
key: z.ZodString;
|
|
2439
|
+
value: z.ZodUnknown;
|
|
2440
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
2441
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2442
|
+
changeType: z.ZodEnum<{
|
|
2443
|
+
UPDATE: "UPDATE";
|
|
2444
|
+
ENTER: "ENTER";
|
|
2445
|
+
LEAVE: "LEAVE";
|
|
2446
|
+
}>;
|
|
2447
|
+
timestamp: z.ZodNumber;
|
|
2448
|
+
}, z.core.$strip>;
|
|
2449
|
+
}, z.core.$strip>;
|
|
2450
|
+
/**
|
|
2451
|
+
* CLUSTER_SUB_UNREGISTER - Remove a subscription from a node.
|
|
2452
|
+
* Sent from coordinator to data-owning nodes when client unsubscribes.
|
|
2453
|
+
*/
|
|
2454
|
+
declare const ClusterSubUnregisterPayloadSchema: z.ZodObject<{
|
|
2455
|
+
subscriptionId: z.ZodString;
|
|
2456
|
+
}, z.core.$strip>;
|
|
2457
|
+
declare const ClusterSubUnregisterMessageSchema: z.ZodObject<{
|
|
2458
|
+
type: z.ZodLiteral<"CLUSTER_SUB_UNREGISTER">;
|
|
2459
|
+
payload: z.ZodObject<{
|
|
2460
|
+
subscriptionId: z.ZodString;
|
|
2461
|
+
}, z.core.$strip>;
|
|
2462
|
+
}, z.core.$strip>;
|
|
2281
2463
|
declare const MessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2282
2464
|
type: z.ZodLiteral<"AUTH">;
|
|
2283
2465
|
token: z.ZodString;
|
|
@@ -2294,7 +2476,7 @@ declare const MessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2294
2476
|
desc: "desc";
|
|
2295
2477
|
}>>>;
|
|
2296
2478
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
2297
|
-
|
|
2479
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
2298
2480
|
}, z.core.$strip>;
|
|
2299
2481
|
}, z.core.$strip>;
|
|
2300
2482
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -2784,6 +2966,64 @@ declare const MessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2784
2966
|
payload: z.ZodObject<{
|
|
2785
2967
|
subscriptionId: z.ZodString;
|
|
2786
2968
|
}, z.core.$strip>;
|
|
2969
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
2970
|
+
type: z.ZodLiteral<"CLUSTER_SUB_REGISTER">;
|
|
2971
|
+
payload: z.ZodObject<{
|
|
2972
|
+
subscriptionId: z.ZodString;
|
|
2973
|
+
coordinatorNodeId: z.ZodString;
|
|
2974
|
+
mapName: z.ZodString;
|
|
2975
|
+
type: z.ZodEnum<{
|
|
2976
|
+
SEARCH: "SEARCH";
|
|
2977
|
+
QUERY: "QUERY";
|
|
2978
|
+
}>;
|
|
2979
|
+
searchQuery: z.ZodOptional<z.ZodString>;
|
|
2980
|
+
searchOptions: z.ZodOptional<z.ZodObject<{
|
|
2981
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
2982
|
+
minScore: z.ZodOptional<z.ZodNumber>;
|
|
2983
|
+
boost: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
2984
|
+
}, z.core.$strip>>;
|
|
2985
|
+
queryPredicate: z.ZodOptional<z.ZodAny>;
|
|
2986
|
+
querySort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
2987
|
+
asc: "asc";
|
|
2988
|
+
desc: "desc";
|
|
2989
|
+
}>>>;
|
|
2990
|
+
}, z.core.$strip>;
|
|
2991
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
2992
|
+
type: z.ZodLiteral<"CLUSTER_SUB_ACK">;
|
|
2993
|
+
payload: z.ZodObject<{
|
|
2994
|
+
subscriptionId: z.ZodString;
|
|
2995
|
+
nodeId: z.ZodString;
|
|
2996
|
+
success: z.ZodBoolean;
|
|
2997
|
+
error: z.ZodOptional<z.ZodString>;
|
|
2998
|
+
initialResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2999
|
+
key: z.ZodString;
|
|
3000
|
+
value: z.ZodUnknown;
|
|
3001
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
3002
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3003
|
+
}, z.core.$strip>>>;
|
|
3004
|
+
totalHits: z.ZodOptional<z.ZodNumber>;
|
|
3005
|
+
}, z.core.$strip>;
|
|
3006
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
3007
|
+
type: z.ZodLiteral<"CLUSTER_SUB_UPDATE">;
|
|
3008
|
+
payload: z.ZodObject<{
|
|
3009
|
+
subscriptionId: z.ZodString;
|
|
3010
|
+
sourceNodeId: z.ZodString;
|
|
3011
|
+
key: z.ZodString;
|
|
3012
|
+
value: z.ZodUnknown;
|
|
3013
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
3014
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3015
|
+
changeType: z.ZodEnum<{
|
|
3016
|
+
UPDATE: "UPDATE";
|
|
3017
|
+
ENTER: "ENTER";
|
|
3018
|
+
LEAVE: "LEAVE";
|
|
3019
|
+
}>;
|
|
3020
|
+
timestamp: z.ZodNumber;
|
|
3021
|
+
}, z.core.$strip>;
|
|
3022
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
3023
|
+
type: z.ZodLiteral<"CLUSTER_SUB_UNREGISTER">;
|
|
3024
|
+
payload: z.ZodObject<{
|
|
3025
|
+
subscriptionId: z.ZodString;
|
|
3026
|
+
}, z.core.$strip>;
|
|
2787
3027
|
}, z.core.$strip>], "type">;
|
|
2788
3028
|
type Query$1 = z.infer<typeof QuerySchema>;
|
|
2789
3029
|
type ClientOp = z.infer<typeof ClientOpSchema>;
|
|
@@ -2825,6 +3065,164 @@ type SearchUpdatePayload = z.infer<typeof SearchUpdatePayloadSchema>;
|
|
|
2825
3065
|
type SearchUpdateMessage = z.infer<typeof SearchUpdateMessageSchema>;
|
|
2826
3066
|
type SearchUnsubPayload = z.infer<typeof SearchUnsubPayloadSchema>;
|
|
2827
3067
|
type SearchUnsubMessage = z.infer<typeof SearchUnsubMessageSchema>;
|
|
3068
|
+
/**
|
|
3069
|
+
* CLUSTER_SEARCH_REQ: Broadcast search request to cluster nodes.
|
|
3070
|
+
* Sent from coordinator to data-owning nodes.
|
|
3071
|
+
*/
|
|
3072
|
+
declare const ClusterSearchReqPayloadSchema: z.ZodObject<{
|
|
3073
|
+
requestId: z.ZodString;
|
|
3074
|
+
mapName: z.ZodString;
|
|
3075
|
+
query: z.ZodString;
|
|
3076
|
+
options: z.ZodObject<{
|
|
3077
|
+
limit: z.ZodNumber;
|
|
3078
|
+
minScore: z.ZodOptional<z.ZodNumber>;
|
|
3079
|
+
boost: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
3080
|
+
includeMatchedTerms: z.ZodOptional<z.ZodBoolean>;
|
|
3081
|
+
afterScore: z.ZodOptional<z.ZodNumber>;
|
|
3082
|
+
afterKey: z.ZodOptional<z.ZodString>;
|
|
3083
|
+
}, z.core.$strip>;
|
|
3084
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
3085
|
+
}, z.core.$strip>;
|
|
3086
|
+
declare const ClusterSearchReqMessageSchema: z.ZodObject<{
|
|
3087
|
+
type: z.ZodLiteral<"CLUSTER_SEARCH_REQ">;
|
|
3088
|
+
payload: z.ZodObject<{
|
|
3089
|
+
requestId: z.ZodString;
|
|
3090
|
+
mapName: z.ZodString;
|
|
3091
|
+
query: z.ZodString;
|
|
3092
|
+
options: z.ZodObject<{
|
|
3093
|
+
limit: z.ZodNumber;
|
|
3094
|
+
minScore: z.ZodOptional<z.ZodNumber>;
|
|
3095
|
+
boost: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
3096
|
+
includeMatchedTerms: z.ZodOptional<z.ZodBoolean>;
|
|
3097
|
+
afterScore: z.ZodOptional<z.ZodNumber>;
|
|
3098
|
+
afterKey: z.ZodOptional<z.ZodString>;
|
|
3099
|
+
}, z.core.$strip>;
|
|
3100
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
3101
|
+
}, z.core.$strip>;
|
|
3102
|
+
}, z.core.$strip>;
|
|
3103
|
+
/**
|
|
3104
|
+
* CLUSTER_SEARCH_RESP: Response from a node with local search results.
|
|
3105
|
+
*/
|
|
3106
|
+
declare const ClusterSearchRespPayloadSchema: z.ZodObject<{
|
|
3107
|
+
requestId: z.ZodString;
|
|
3108
|
+
nodeId: z.ZodString;
|
|
3109
|
+
results: z.ZodArray<z.ZodObject<{
|
|
3110
|
+
key: z.ZodString;
|
|
3111
|
+
value: z.ZodUnknown;
|
|
3112
|
+
score: z.ZodNumber;
|
|
3113
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3114
|
+
}, z.core.$strip>>;
|
|
3115
|
+
totalHits: z.ZodNumber;
|
|
3116
|
+
executionTimeMs: z.ZodNumber;
|
|
3117
|
+
error: z.ZodOptional<z.ZodString>;
|
|
3118
|
+
}, z.core.$strip>;
|
|
3119
|
+
declare const ClusterSearchRespMessageSchema: z.ZodObject<{
|
|
3120
|
+
type: z.ZodLiteral<"CLUSTER_SEARCH_RESP">;
|
|
3121
|
+
payload: z.ZodObject<{
|
|
3122
|
+
requestId: z.ZodString;
|
|
3123
|
+
nodeId: z.ZodString;
|
|
3124
|
+
results: z.ZodArray<z.ZodObject<{
|
|
3125
|
+
key: z.ZodString;
|
|
3126
|
+
value: z.ZodUnknown;
|
|
3127
|
+
score: z.ZodNumber;
|
|
3128
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3129
|
+
}, z.core.$strip>>;
|
|
3130
|
+
totalHits: z.ZodNumber;
|
|
3131
|
+
executionTimeMs: z.ZodNumber;
|
|
3132
|
+
error: z.ZodOptional<z.ZodString>;
|
|
3133
|
+
}, z.core.$strip>;
|
|
3134
|
+
}, z.core.$strip>;
|
|
3135
|
+
/**
|
|
3136
|
+
* CLUSTER_SEARCH_SUBSCRIBE: Live distributed search subscription.
|
|
3137
|
+
*/
|
|
3138
|
+
declare const ClusterSearchSubscribePayloadSchema: z.ZodObject<{
|
|
3139
|
+
subscriptionId: z.ZodString;
|
|
3140
|
+
mapName: z.ZodString;
|
|
3141
|
+
query: z.ZodString;
|
|
3142
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
3143
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
3144
|
+
minScore: z.ZodOptional<z.ZodNumber>;
|
|
3145
|
+
boost: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
3146
|
+
}, z.core.$strip>>;
|
|
3147
|
+
}, z.core.$strip>;
|
|
3148
|
+
declare const ClusterSearchSubscribeMessageSchema: z.ZodObject<{
|
|
3149
|
+
type: z.ZodLiteral<"CLUSTER_SEARCH_SUBSCRIBE">;
|
|
3150
|
+
payload: z.ZodObject<{
|
|
3151
|
+
subscriptionId: z.ZodString;
|
|
3152
|
+
mapName: z.ZodString;
|
|
3153
|
+
query: z.ZodString;
|
|
3154
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
3155
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
3156
|
+
minScore: z.ZodOptional<z.ZodNumber>;
|
|
3157
|
+
boost: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
3158
|
+
}, z.core.$strip>>;
|
|
3159
|
+
}, z.core.$strip>;
|
|
3160
|
+
}, z.core.$strip>;
|
|
3161
|
+
/**
|
|
3162
|
+
* CLUSTER_SEARCH_UNSUBSCRIBE: Unsubscribe from distributed search.
|
|
3163
|
+
*/
|
|
3164
|
+
declare const ClusterSearchUnsubscribePayloadSchema: z.ZodObject<{
|
|
3165
|
+
subscriptionId: z.ZodString;
|
|
3166
|
+
}, z.core.$strip>;
|
|
3167
|
+
declare const ClusterSearchUnsubscribeMessageSchema: z.ZodObject<{
|
|
3168
|
+
type: z.ZodLiteral<"CLUSTER_SEARCH_UNSUBSCRIBE">;
|
|
3169
|
+
payload: z.ZodObject<{
|
|
3170
|
+
subscriptionId: z.ZodString;
|
|
3171
|
+
}, z.core.$strip>;
|
|
3172
|
+
}, z.core.$strip>;
|
|
3173
|
+
/**
|
|
3174
|
+
* CLUSTER_SEARCH_UPDATE: Delta update for live distributed search.
|
|
3175
|
+
*/
|
|
3176
|
+
declare const ClusterSearchUpdatePayloadSchema: z.ZodObject<{
|
|
3177
|
+
subscriptionId: z.ZodString;
|
|
3178
|
+
nodeId: z.ZodString;
|
|
3179
|
+
key: z.ZodString;
|
|
3180
|
+
value: z.ZodUnknown;
|
|
3181
|
+
score: z.ZodNumber;
|
|
3182
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3183
|
+
type: z.ZodEnum<{
|
|
3184
|
+
UPDATE: "UPDATE";
|
|
3185
|
+
ENTER: "ENTER";
|
|
3186
|
+
LEAVE: "LEAVE";
|
|
3187
|
+
}>;
|
|
3188
|
+
}, z.core.$strip>;
|
|
3189
|
+
declare const ClusterSearchUpdateMessageSchema: z.ZodObject<{
|
|
3190
|
+
type: z.ZodLiteral<"CLUSTER_SEARCH_UPDATE">;
|
|
3191
|
+
payload: z.ZodObject<{
|
|
3192
|
+
subscriptionId: z.ZodString;
|
|
3193
|
+
nodeId: z.ZodString;
|
|
3194
|
+
key: z.ZodString;
|
|
3195
|
+
value: z.ZodUnknown;
|
|
3196
|
+
score: z.ZodNumber;
|
|
3197
|
+
matchedTerms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3198
|
+
type: z.ZodEnum<{
|
|
3199
|
+
UPDATE: "UPDATE";
|
|
3200
|
+
ENTER: "ENTER";
|
|
3201
|
+
LEAVE: "LEAVE";
|
|
3202
|
+
}>;
|
|
3203
|
+
}, z.core.$strip>;
|
|
3204
|
+
}, z.core.$strip>;
|
|
3205
|
+
type ClusterSearchReqPayload = z.infer<typeof ClusterSearchReqPayloadSchema>;
|
|
3206
|
+
type ClusterSearchReqMessage = z.infer<typeof ClusterSearchReqMessageSchema>;
|
|
3207
|
+
type ClusterSearchRespPayload = z.infer<typeof ClusterSearchRespPayloadSchema>;
|
|
3208
|
+
type ClusterSearchRespMessage = z.infer<typeof ClusterSearchRespMessageSchema>;
|
|
3209
|
+
type ClusterSearchSubscribePayload = z.infer<typeof ClusterSearchSubscribePayloadSchema>;
|
|
3210
|
+
type ClusterSearchSubscribeMessage = z.infer<typeof ClusterSearchSubscribeMessageSchema>;
|
|
3211
|
+
type ClusterSearchUnsubscribePayload = z.infer<typeof ClusterSearchUnsubscribePayloadSchema>;
|
|
3212
|
+
type ClusterSearchUnsubscribeMessage = z.infer<typeof ClusterSearchUnsubscribeMessageSchema>;
|
|
3213
|
+
type ClusterSearchUpdatePayload = z.infer<typeof ClusterSearchUpdatePayloadSchema>;
|
|
3214
|
+
type ClusterSearchUpdateMessage = z.infer<typeof ClusterSearchUpdateMessageSchema>;
|
|
3215
|
+
type ClusterSubRegisterPayload = z.infer<typeof ClusterSubRegisterPayloadSchema>;
|
|
3216
|
+
type ClusterSubRegisterMessage = z.infer<typeof ClusterSubRegisterMessageSchema>;
|
|
3217
|
+
type ClusterSubAckPayload = z.infer<typeof ClusterSubAckPayloadSchema>;
|
|
3218
|
+
type ClusterSubAckMessage = z.infer<typeof ClusterSubAckMessageSchema>;
|
|
3219
|
+
type ClusterSubUpdatePayload = z.infer<typeof ClusterSubUpdatePayloadSchema>;
|
|
3220
|
+
type ClusterSubUpdateMessage = z.infer<typeof ClusterSubUpdateMessageSchema>;
|
|
3221
|
+
type ClusterSubUnregisterPayload = z.infer<typeof ClusterSubUnregisterPayloadSchema>;
|
|
3222
|
+
type ClusterSubUnregisterMessage = z.infer<typeof ClusterSubUnregisterMessageSchema>;
|
|
3223
|
+
type CursorStatus$1 = z.infer<typeof CursorStatusSchema>;
|
|
3224
|
+
type QueryRespPayload = z.infer<typeof QueryRespPayloadSchema>;
|
|
3225
|
+
type QueryRespMessage = z.infer<typeof QueryRespMessageSchema>;
|
|
2828
3226
|
|
|
2829
3227
|
/**
|
|
2830
3228
|
* Write Concern - Configurable Acknowledgment Levels
|
|
@@ -3925,15 +4323,15 @@ interface LogicalQueryNode {
|
|
|
3925
4323
|
*/
|
|
3926
4324
|
type Query = SimpleQueryNode | LogicalQueryNode | FTSQueryNode;
|
|
3927
4325
|
/**
|
|
3928
|
-
* Query execution options for sort/limit/
|
|
4326
|
+
* Query execution options for sort/limit/cursor.
|
|
3929
4327
|
*/
|
|
3930
4328
|
interface QueryOptions {
|
|
3931
4329
|
/** Sort by field(s): field name -> direction */
|
|
3932
4330
|
sort?: Record<string, 'asc' | 'desc'>;
|
|
3933
4331
|
/** Maximum number of results to return */
|
|
3934
4332
|
limit?: number;
|
|
3935
|
-
/**
|
|
3936
|
-
|
|
4333
|
+
/** Cursor for pagination (Phase 14.1: replaces offset) */
|
|
4334
|
+
cursor?: string;
|
|
3937
4335
|
}
|
|
3938
4336
|
/**
|
|
3939
4337
|
* Execution plan step.
|
|
@@ -4039,8 +4437,8 @@ interface QueryPlan {
|
|
|
4039
4437
|
};
|
|
4040
4438
|
/** Limit configuration */
|
|
4041
4439
|
limit?: number;
|
|
4042
|
-
/**
|
|
4043
|
-
|
|
4440
|
+
/** Cursor for pagination (Phase 14.1: replaces offset) */
|
|
4441
|
+
cursor?: string;
|
|
4044
4442
|
}
|
|
4045
4443
|
/**
|
|
4046
4444
|
* Check if a query is a simple query node.
|
|
@@ -6088,6 +6486,15 @@ declare function createFieldComparator<V>(field: string, direction: 'asc' | 'des
|
|
|
6088
6486
|
* Applies offset/limit to source ResultSet.
|
|
6089
6487
|
* Implements early termination for efficiency.
|
|
6090
6488
|
*
|
|
6489
|
+
* NOTE: The offset parameter is intentionally retained in this internal component
|
|
6490
|
+
* even though Phase 14.1 replaced offset with cursor-based pagination in the query API.
|
|
6491
|
+
* This class is used internally by:
|
|
6492
|
+
* - EventJournalService (SQL queries require numeric offset)
|
|
6493
|
+
* - Index result set operations where offset is computed internally
|
|
6494
|
+
* - Unit tests for result set behavior
|
|
6495
|
+
*
|
|
6496
|
+
* The query API (QueryOptions, QueryHandle) uses cursor-based pagination via QueryCursor.
|
|
6497
|
+
*
|
|
6091
6498
|
* @module query/resultset/LimitResultSet
|
|
6092
6499
|
*/
|
|
6093
6500
|
|
|
@@ -7370,6 +7777,310 @@ declare class AutoIndexManager<K, V> {
|
|
|
7370
7777
|
private createIndex;
|
|
7371
7778
|
}
|
|
7372
7779
|
|
|
7780
|
+
/**
|
|
7781
|
+
* QueryExecutor Implementation (Phase 12)
|
|
7782
|
+
*
|
|
7783
|
+
* Executes query plans produced by QueryOptimizer.
|
|
7784
|
+
* Supports hybrid queries with FTS and traditional predicates,
|
|
7785
|
+
* using Reciprocal Rank Fusion (RRF) for result merging.
|
|
7786
|
+
*
|
|
7787
|
+
* @module query/QueryExecutor
|
|
7788
|
+
*/
|
|
7789
|
+
|
|
7790
|
+
/**
|
|
7791
|
+
* Query result with optional score and matched terms.
|
|
7792
|
+
*/
|
|
7793
|
+
interface QueryResult<K, V> {
|
|
7794
|
+
/** Record key */
|
|
7795
|
+
key: K;
|
|
7796
|
+
/** Record value */
|
|
7797
|
+
value: V;
|
|
7798
|
+
/** BM25 or RRF score (for ranked results) */
|
|
7799
|
+
score?: number;
|
|
7800
|
+
/** Matched search terms (for FTS results) */
|
|
7801
|
+
matchedTerms?: string[];
|
|
7802
|
+
}
|
|
7803
|
+
/**
|
|
7804
|
+
* Cursor status for debugging.
|
|
7805
|
+
*/
|
|
7806
|
+
type CursorStatus = 'valid' | 'expired' | 'invalid' | 'none';
|
|
7807
|
+
/**
|
|
7808
|
+
* Extended query result with cursor info (Phase 14.1).
|
|
7809
|
+
*/
|
|
7810
|
+
interface QueryResultWithCursor<K, V> {
|
|
7811
|
+
/** Query results */
|
|
7812
|
+
results: QueryResult<K, V>[];
|
|
7813
|
+
/** Cursor for next page (undefined if no more results) */
|
|
7814
|
+
nextCursor?: string;
|
|
7815
|
+
/** Whether more results are available */
|
|
7816
|
+
hasMore: boolean;
|
|
7817
|
+
/** Debug info: status of input cursor processing */
|
|
7818
|
+
cursorStatus: CursorStatus;
|
|
7819
|
+
}
|
|
7820
|
+
|
|
7821
|
+
/**
|
|
7822
|
+
* QueryCursor - Cursor-based pagination for distributed queries (Phase 14.1)
|
|
7823
|
+
*
|
|
7824
|
+
* Implements opaque cursor encoding for efficient deep pagination in distributed
|
|
7825
|
+
* predicate-based queries. Cursors encode the last seen position per node, enabling
|
|
7826
|
+
* each node to resume from where it left off.
|
|
7827
|
+
*
|
|
7828
|
+
* Problem solved: With offset-based pagination in a distributed system, each node
|
|
7829
|
+
* must return offset+limit results, causing O(N*offset) network overhead.
|
|
7830
|
+
* Cursor-based pagination reduces this to O(N*limit).
|
|
7831
|
+
*
|
|
7832
|
+
* Related: SearchCursor (search/SearchCursor.ts) provides similar functionality for
|
|
7833
|
+
* FTS queries using BM25 scores. Both use shared base64url encoding utilities.
|
|
7834
|
+
*
|
|
7835
|
+
* Future consideration: A shared base class could extract common encode/decode
|
|
7836
|
+
* and timestamp validation logic, but the semantic differences (sortValue vs score,
|
|
7837
|
+
* configurable direction vs fixed DESC) make this a low-priority refactor.
|
|
7838
|
+
*
|
|
7839
|
+
* @module query/QueryCursor
|
|
7840
|
+
*/
|
|
7841
|
+
/**
|
|
7842
|
+
* Internal cursor data structure for query pagination.
|
|
7843
|
+
* Encoded as base64url for wire transfer.
|
|
7844
|
+
*/
|
|
7845
|
+
interface QueryCursorData {
|
|
7846
|
+
/**
|
|
7847
|
+
* Last seen sort values per node.
|
|
7848
|
+
* For single-field sort only (multi-field sort is out of scope for v1).
|
|
7849
|
+
*/
|
|
7850
|
+
nodeValues: Record<string, unknown>;
|
|
7851
|
+
/**
|
|
7852
|
+
* Last seen keys per node (for tie-breaking).
|
|
7853
|
+
*/
|
|
7854
|
+
nodeKeys: Record<string, string>;
|
|
7855
|
+
/**
|
|
7856
|
+
* Sort field name (must match query sort).
|
|
7857
|
+
*/
|
|
7858
|
+
sortField: string;
|
|
7859
|
+
/**
|
|
7860
|
+
* Sort direction.
|
|
7861
|
+
*/
|
|
7862
|
+
sortDirection: 'asc' | 'desc';
|
|
7863
|
+
/**
|
|
7864
|
+
* Hash of query predicate (for validation).
|
|
7865
|
+
*/
|
|
7866
|
+
predicateHash: number;
|
|
7867
|
+
/**
|
|
7868
|
+
* Hash of sort configuration (for validation).
|
|
7869
|
+
*/
|
|
7870
|
+
sortHash: number;
|
|
7871
|
+
/**
|
|
7872
|
+
* Timestamp when cursor was created (for expiration).
|
|
7873
|
+
*/
|
|
7874
|
+
timestamp: number;
|
|
7875
|
+
}
|
|
7876
|
+
/**
|
|
7877
|
+
* Result item with node tracking for cursor generation.
|
|
7878
|
+
*/
|
|
7879
|
+
interface CursorableQueryResult {
|
|
7880
|
+
key: string;
|
|
7881
|
+
sortValue: unknown;
|
|
7882
|
+
nodeId?: string;
|
|
7883
|
+
}
|
|
7884
|
+
/**
|
|
7885
|
+
* Options for cursor validation.
|
|
7886
|
+
*/
|
|
7887
|
+
interface QueryCursorOptions {
|
|
7888
|
+
/**
|
|
7889
|
+
* Maximum cursor age in milliseconds.
|
|
7890
|
+
* Default: 10 minutes (600,000 ms)
|
|
7891
|
+
*/
|
|
7892
|
+
maxAgeMs?: number;
|
|
7893
|
+
}
|
|
7894
|
+
/**
|
|
7895
|
+
* Default cursor expiration time (10 minutes).
|
|
7896
|
+
*/
|
|
7897
|
+
declare const DEFAULT_QUERY_CURSOR_MAX_AGE_MS: number;
|
|
7898
|
+
/**
|
|
7899
|
+
* QueryCursor provides cursor-based pagination for distributed queries.
|
|
7900
|
+
*
|
|
7901
|
+
* @example
|
|
7902
|
+
* ```typescript
|
|
7903
|
+
* // Create cursor from query results
|
|
7904
|
+
* const cursor = QueryCursor.fromResults(
|
|
7905
|
+
* results,
|
|
7906
|
+
* { createdAt: 'desc' },
|
|
7907
|
+
* predicate
|
|
7908
|
+
* );
|
|
7909
|
+
*
|
|
7910
|
+
* // Use cursor in next query request
|
|
7911
|
+
* const cursorData = QueryCursor.decode(cursor);
|
|
7912
|
+
* if (cursorData && QueryCursor.isValid(cursorData, predicate, sort)) {
|
|
7913
|
+
* // Filter results using cursor position
|
|
7914
|
+
* const filtered = results.filter(r =>
|
|
7915
|
+
* QueryCursor.isAfterCursor(r, cursorData)
|
|
7916
|
+
* );
|
|
7917
|
+
* }
|
|
7918
|
+
* ```
|
|
7919
|
+
*/
|
|
7920
|
+
declare class QueryCursor {
|
|
7921
|
+
/**
|
|
7922
|
+
* Encode cursor data to an opaque base64url string.
|
|
7923
|
+
*
|
|
7924
|
+
* @param data - Cursor data to encode
|
|
7925
|
+
* @returns Opaque cursor string
|
|
7926
|
+
*/
|
|
7927
|
+
static encode(data: QueryCursorData): string;
|
|
7928
|
+
/**
|
|
7929
|
+
* Decode cursor string back to data.
|
|
7930
|
+
*
|
|
7931
|
+
* @param cursor - Opaque cursor string
|
|
7932
|
+
* @returns Decoded cursor data, or null if invalid
|
|
7933
|
+
*/
|
|
7934
|
+
static decode(cursor: string): QueryCursorData | null;
|
|
7935
|
+
/**
|
|
7936
|
+
* Create a cursor from query results.
|
|
7937
|
+
*
|
|
7938
|
+
* The cursor captures the last seen position for each node that contributed
|
|
7939
|
+
* results, enabling efficient resumption in the next page request.
|
|
7940
|
+
*
|
|
7941
|
+
* @param results - Array of results with sort values and optional node tracking
|
|
7942
|
+
* @param sort - Sort configuration (single field only for v1)
|
|
7943
|
+
* @param predicate - Query predicate (for validation)
|
|
7944
|
+
* @returns Encoded cursor string
|
|
7945
|
+
*/
|
|
7946
|
+
static fromResults(results: CursorableQueryResult[], sort: Record<string, 'asc' | 'desc'>, predicate?: unknown): string;
|
|
7947
|
+
/**
|
|
7948
|
+
* Create a cursor from the last result only.
|
|
7949
|
+
* Useful for local-only queries.
|
|
7950
|
+
*
|
|
7951
|
+
* @param lastResult - The last result in the current page
|
|
7952
|
+
* @param sort - Sort configuration
|
|
7953
|
+
* @param predicate - Query predicate
|
|
7954
|
+
* @returns Encoded cursor string
|
|
7955
|
+
*/
|
|
7956
|
+
static fromLastResult(lastResult: CursorableQueryResult, sort: Record<string, 'asc' | 'desc'>, predicate?: unknown): string;
|
|
7957
|
+
/**
|
|
7958
|
+
* Validate that a cursor is valid for the given query.
|
|
7959
|
+
*
|
|
7960
|
+
* Checks:
|
|
7961
|
+
* 1. Predicate hash matches (cursor was created for this query)
|
|
7962
|
+
* 2. Sort hash matches (sort configuration unchanged)
|
|
7963
|
+
* 3. Cursor is not expired
|
|
7964
|
+
*
|
|
7965
|
+
* @param cursor - Decoded cursor data
|
|
7966
|
+
* @param predicate - Query predicate to validate against
|
|
7967
|
+
* @param sort - Sort configuration to validate against
|
|
7968
|
+
* @param options - Validation options
|
|
7969
|
+
* @returns true if cursor is valid
|
|
7970
|
+
*/
|
|
7971
|
+
static isValid(cursor: QueryCursorData, predicate: unknown, sort: Record<string, 'asc' | 'desc'>, options?: QueryCursorOptions): boolean;
|
|
7972
|
+
/**
|
|
7973
|
+
* Get the cursor position for a specific node.
|
|
7974
|
+
*
|
|
7975
|
+
* @param cursor - Decoded cursor data
|
|
7976
|
+
* @param nodeId - Node ID to get position for (defaults to 'local')
|
|
7977
|
+
* @returns Position info or null if node not in cursor
|
|
7978
|
+
*/
|
|
7979
|
+
static getNodePosition(cursor: QueryCursorData, nodeId?: string): {
|
|
7980
|
+
afterValue: unknown;
|
|
7981
|
+
afterKey: string;
|
|
7982
|
+
} | null;
|
|
7983
|
+
/**
|
|
7984
|
+
* Check if a result should be included based on cursor position.
|
|
7985
|
+
*
|
|
7986
|
+
* For ASC sort: value > cursorValue OR (value === cursorValue AND key > cursorKey)
|
|
7987
|
+
* For DESC sort: value < cursorValue OR (value === cursorValue AND key > cursorKey)
|
|
7988
|
+
*
|
|
7989
|
+
* @param result - Result to check
|
|
7990
|
+
* @param cursor - Decoded cursor data
|
|
7991
|
+
* @returns true if result should be included (is after cursor)
|
|
7992
|
+
*/
|
|
7993
|
+
static isAfterCursor(result: CursorableQueryResult, cursor: QueryCursorData): boolean;
|
|
7994
|
+
/**
|
|
7995
|
+
* Compare two values with type-aware comparison.
|
|
7996
|
+
* Delegates to shared compareValues utility.
|
|
7997
|
+
*
|
|
7998
|
+
* @param a - First value
|
|
7999
|
+
* @param b - Second value
|
|
8000
|
+
* @returns Negative if a < b, 0 if equal, positive if a > b
|
|
8001
|
+
*/
|
|
8002
|
+
static compareValues(a: unknown, b: unknown): number;
|
|
8003
|
+
/**
|
|
8004
|
+
* Merge multiple cursors into one.
|
|
8005
|
+
* Useful when combining results from multiple sub-queries or nodes.
|
|
8006
|
+
*
|
|
8007
|
+
* Keeps the furthest position for each node.
|
|
8008
|
+
*
|
|
8009
|
+
* @param cursors - Array of decoded cursor data
|
|
8010
|
+
* @param sort - Sort configuration
|
|
8011
|
+
* @param predicate - Query predicate
|
|
8012
|
+
* @returns New merged cursor
|
|
8013
|
+
*/
|
|
8014
|
+
static merge(cursors: QueryCursorData[], sort: Record<string, 'asc' | 'desc'>, predicate?: unknown): QueryCursorData;
|
|
8015
|
+
/**
|
|
8016
|
+
* Extract sort value from a record for cursor generation.
|
|
8017
|
+
*
|
|
8018
|
+
* @param record - Record to extract sort value from
|
|
8019
|
+
* @param sortField - Field to extract
|
|
8020
|
+
* @returns Sort value
|
|
8021
|
+
*/
|
|
8022
|
+
static extractSortValue(record: Record<string, unknown>, sortField: string): unknown;
|
|
8023
|
+
}
|
|
8024
|
+
|
|
8025
|
+
/**
|
|
8026
|
+
* Universal Base64URL encoding/decoding utilities.
|
|
8027
|
+
*
|
|
8028
|
+
* Works in both Node.js and browser environments.
|
|
8029
|
+
* Used by QueryCursor and SearchCursor for opaque cursor encoding.
|
|
8030
|
+
*
|
|
8031
|
+
* @module utils/base64url
|
|
8032
|
+
*/
|
|
8033
|
+
/**
|
|
8034
|
+
* Encode a string to base64url format.
|
|
8035
|
+
* URL-safe, no padding characters.
|
|
8036
|
+
*
|
|
8037
|
+
* @param str - UTF-8 string to encode
|
|
8038
|
+
* @returns Base64url encoded string
|
|
8039
|
+
*/
|
|
8040
|
+
declare function encodeBase64Url(str: string): string;
|
|
8041
|
+
/**
|
|
8042
|
+
* Decode a base64url string back to UTF-8.
|
|
8043
|
+
*
|
|
8044
|
+
* @param encoded - Base64url encoded string
|
|
8045
|
+
* @returns Decoded UTF-8 string
|
|
8046
|
+
* @throws Error if decoding fails
|
|
8047
|
+
*/
|
|
8048
|
+
declare function decodeBase64Url(encoded: string): string;
|
|
8049
|
+
|
|
8050
|
+
/**
|
|
8051
|
+
* Universal value comparison utilities.
|
|
8052
|
+
*
|
|
8053
|
+
* Provides type-aware comparison for sorting and cursor-based pagination.
|
|
8054
|
+
* Used by QueryCursor, QueryExecutor, and other components that need
|
|
8055
|
+
* consistent value ordering.
|
|
8056
|
+
*
|
|
8057
|
+
* @module utils/compare
|
|
8058
|
+
*/
|
|
8059
|
+
/**
|
|
8060
|
+
* Compare two values with type-aware comparison.
|
|
8061
|
+
*
|
|
8062
|
+
* Comparison order:
|
|
8063
|
+
* 1. null/undefined (always less than defined values)
|
|
8064
|
+
* 2. Numbers (numeric comparison)
|
|
8065
|
+
* 3. Date objects (by timestamp)
|
|
8066
|
+
* 4. Strings (ISO date parsing attempted, then localeCompare)
|
|
8067
|
+
* 5. Booleans (false < true)
|
|
8068
|
+
* 6. Fallback: string conversion and localeCompare
|
|
8069
|
+
*
|
|
8070
|
+
* @param a - First value
|
|
8071
|
+
* @param b - Second value
|
|
8072
|
+
* @returns Negative if a < b, 0 if equal, positive if a > b
|
|
8073
|
+
*
|
|
8074
|
+
* @example
|
|
8075
|
+
* ```typescript
|
|
8076
|
+
* compareValues(1, 2); // -1
|
|
8077
|
+
* compareValues('b', 'a'); // 1
|
|
8078
|
+
* compareValues(null, 1); // -1
|
|
8079
|
+
* compareValues(new Date('2024-01-01'), new Date('2024-01-02')); // -86400000
|
|
8080
|
+
* ```
|
|
8081
|
+
*/
|
|
8082
|
+
declare function compareValues(a: unknown, b: unknown): number;
|
|
8083
|
+
|
|
7373
8084
|
/**
|
|
7374
8085
|
* IndexedLWWMap Implementation
|
|
7375
8086
|
*
|
|
@@ -8125,4 +8836,157 @@ declare class ReciprocalRankFusion {
|
|
|
8125
8836
|
getK(): number;
|
|
8126
8837
|
}
|
|
8127
8838
|
|
|
8128
|
-
|
|
8839
|
+
/**
|
|
8840
|
+
* SearchCursor - Cursor-based pagination for distributed search
|
|
8841
|
+
*
|
|
8842
|
+
* Implements opaque cursor encoding for efficient deep pagination in distributed
|
|
8843
|
+
* search queries. Cursors encode the last seen position per node, enabling
|
|
8844
|
+
* each node to resume from where it left off.
|
|
8845
|
+
*
|
|
8846
|
+
* Problem solved: With offset-based pagination in a distributed system, each node
|
|
8847
|
+
* must return offset+limit results, causing O(N*offset) network overhead.
|
|
8848
|
+
* Cursor-based pagination reduces this to O(N*limit).
|
|
8849
|
+
*
|
|
8850
|
+
* Related: QueryCursor (query/QueryCursor.ts) provides similar functionality for
|
|
8851
|
+
* predicate-based queries. Both use shared base64url encoding utilities.
|
|
8852
|
+
*
|
|
8853
|
+
* Future consideration: A shared base class could extract common encode/decode
|
|
8854
|
+
* and timestamp validation logic, but the semantic differences (score vs sortValue,
|
|
8855
|
+
* fixed DESC vs configurable direction) make this a low-priority refactor.
|
|
8856
|
+
*
|
|
8857
|
+
* @module search/SearchCursor
|
|
8858
|
+
*/
|
|
8859
|
+
/**
|
|
8860
|
+
* Internal cursor data structure.
|
|
8861
|
+
* Encoded as base64url for wire transfer.
|
|
8862
|
+
*/
|
|
8863
|
+
interface SearchCursorData {
|
|
8864
|
+
/** Last seen scores per node */
|
|
8865
|
+
nodeScores: Record<string, number>;
|
|
8866
|
+
/** Last seen keys per node (for tie-breaking when scores are equal) */
|
|
8867
|
+
nodeKeys: Record<string, string>;
|
|
8868
|
+
/** Hash of original query (for validation) */
|
|
8869
|
+
queryHash: number;
|
|
8870
|
+
/** Timestamp when cursor was created (for expiration) */
|
|
8871
|
+
timestamp: number;
|
|
8872
|
+
}
|
|
8873
|
+
/**
|
|
8874
|
+
* Result item with node tracking for cursor generation.
|
|
8875
|
+
*/
|
|
8876
|
+
interface CursorableResult {
|
|
8877
|
+
key: string;
|
|
8878
|
+
score: number;
|
|
8879
|
+
nodeId: string;
|
|
8880
|
+
}
|
|
8881
|
+
/**
|
|
8882
|
+
* Default cursor expiration time (5 minutes).
|
|
8883
|
+
*/
|
|
8884
|
+
declare const DEFAULT_CURSOR_MAX_AGE_MS: number;
|
|
8885
|
+
/**
|
|
8886
|
+
* SearchCursor provides cursor-based pagination for distributed search.
|
|
8887
|
+
*
|
|
8888
|
+
* @example
|
|
8889
|
+
* ```typescript
|
|
8890
|
+
* // Create cursor from search results
|
|
8891
|
+
* const cursor = SearchCursor.fromResults(results, 'machine learning');
|
|
8892
|
+
*
|
|
8893
|
+
* // Use cursor in next search request
|
|
8894
|
+
* const cursorData = SearchCursor.decode(cursor);
|
|
8895
|
+
* if (cursorData && SearchCursor.isValid(cursorData, 'machine learning')) {
|
|
8896
|
+
* // Each node filters: score < cursorData.nodeScores[nodeId]
|
|
8897
|
+
* // OR (score === nodeScores[nodeId] && key > nodeKeys[nodeId])
|
|
8898
|
+
* }
|
|
8899
|
+
* ```
|
|
8900
|
+
*/
|
|
8901
|
+
declare class SearchCursor {
|
|
8902
|
+
/**
|
|
8903
|
+
* Encode cursor data to an opaque base64url string.
|
|
8904
|
+
*
|
|
8905
|
+
* @param data - Cursor data to encode
|
|
8906
|
+
* @returns Opaque cursor string
|
|
8907
|
+
*/
|
|
8908
|
+
static encode(data: SearchCursorData): string;
|
|
8909
|
+
/**
|
|
8910
|
+
* Decode cursor string back to data.
|
|
8911
|
+
*
|
|
8912
|
+
* @param cursor - Opaque cursor string
|
|
8913
|
+
* @returns Decoded cursor data, or null if invalid
|
|
8914
|
+
*/
|
|
8915
|
+
static decode(cursor: string): SearchCursorData | null;
|
|
8916
|
+
/**
|
|
8917
|
+
* Create a cursor from the last results of a search.
|
|
8918
|
+
*
|
|
8919
|
+
* The cursor captures the last seen position for each node that contributed
|
|
8920
|
+
* results, enabling efficient resumption in the next page request.
|
|
8921
|
+
*
|
|
8922
|
+
* @param results - Array of results with node tracking
|
|
8923
|
+
* @param query - Original query string (for validation)
|
|
8924
|
+
* @returns Encoded cursor string
|
|
8925
|
+
*/
|
|
8926
|
+
static fromResults(results: CursorableResult[], query: string): string;
|
|
8927
|
+
/**
|
|
8928
|
+
* Create a cursor from the last result only.
|
|
8929
|
+
* Useful when you only have the final merged result.
|
|
8930
|
+
*
|
|
8931
|
+
* @param lastResult - The last result in the current page
|
|
8932
|
+
* @param query - Original query string
|
|
8933
|
+
* @returns Encoded cursor string
|
|
8934
|
+
*/
|
|
8935
|
+
static fromLastResult(lastResult: CursorableResult, query: string): string;
|
|
8936
|
+
/**
|
|
8937
|
+
* Generate a hash for a query string.
|
|
8938
|
+
* Used to validate that cursor matches the current query.
|
|
8939
|
+
*
|
|
8940
|
+
* @param query - Query string to hash
|
|
8941
|
+
* @returns Numeric hash
|
|
8942
|
+
*/
|
|
8943
|
+
static hashQuery(query: string): number;
|
|
8944
|
+
/**
|
|
8945
|
+
* Validate that a cursor is valid for the given query.
|
|
8946
|
+
*
|
|
8947
|
+
* Checks:
|
|
8948
|
+
* 1. Query hash matches (cursor was created for this query)
|
|
8949
|
+
* 2. Cursor is not expired
|
|
8950
|
+
*
|
|
8951
|
+
* @param cursor - Decoded cursor data
|
|
8952
|
+
* @param query - Query string to validate against
|
|
8953
|
+
* @param maxAgeMs - Maximum cursor age in milliseconds (default: 5 minutes)
|
|
8954
|
+
* @returns true if cursor is valid
|
|
8955
|
+
*/
|
|
8956
|
+
static isValid(cursor: SearchCursorData, query: string, maxAgeMs?: number): boolean;
|
|
8957
|
+
/**
|
|
8958
|
+
* Get the cursor position for a specific node.
|
|
8959
|
+
*
|
|
8960
|
+
* @param cursor - Decoded cursor data
|
|
8961
|
+
* @param nodeId - Node ID to get position for
|
|
8962
|
+
* @returns Position info or null if node not in cursor
|
|
8963
|
+
*/
|
|
8964
|
+
static getNodePosition(cursor: SearchCursorData, nodeId: string): {
|
|
8965
|
+
afterScore: number;
|
|
8966
|
+
afterKey: string;
|
|
8967
|
+
} | null;
|
|
8968
|
+
/**
|
|
8969
|
+
* Check if a result should be included based on cursor position.
|
|
8970
|
+
*
|
|
8971
|
+
* Results are ordered by score descending, then key ascending for tie-breaking.
|
|
8972
|
+
* A result should be included if it comes AFTER the cursor position:
|
|
8973
|
+
* - score < cursorScore, OR
|
|
8974
|
+
* - score === cursorScore AND key > cursorKey
|
|
8975
|
+
*
|
|
8976
|
+
* @param result - Result to check
|
|
8977
|
+
* @param cursor - Decoded cursor data
|
|
8978
|
+
* @returns true if result should be included (is after cursor)
|
|
8979
|
+
*/
|
|
8980
|
+
static isAfterCursor(result: CursorableResult, cursor: SearchCursorData): boolean;
|
|
8981
|
+
/**
|
|
8982
|
+
* Merge multiple cursors into one.
|
|
8983
|
+
* Useful when combining results from multiple sub-queries.
|
|
8984
|
+
*
|
|
8985
|
+
* @param cursors - Array of decoded cursor data
|
|
8986
|
+
* @param query - Original query string
|
|
8987
|
+
* @returns New merged cursor
|
|
8988
|
+
*/
|
|
8989
|
+
static merge(cursors: SearchCursorData[], query: string): SearchCursorData;
|
|
8990
|
+
}
|
|
8991
|
+
|
|
8992
|
+
export { type Attribute, AuthMessageSchema, type BM25Options, BM25Scorer, type BatchMessage, BatchMessageSchema, BuiltInProcessors, BuiltInResolvers, type CircuitBreakerConfig, type ClientOp, ClientOpMessageSchema, ClientOpSchema, type ClusterClientConfig, type ClusterEvents, type ReadOptions as ClusterReadOptions, type ClusterSearchReqMessage, ClusterSearchReqMessageSchema, type ClusterSearchReqPayload, ClusterSearchReqPayloadSchema, type ClusterSearchRespMessage, ClusterSearchRespMessageSchema, type ClusterSearchRespPayload, ClusterSearchRespPayloadSchema, type ClusterSearchSubscribeMessage, ClusterSearchSubscribeMessageSchema, type ClusterSearchSubscribePayload, ClusterSearchSubscribePayloadSchema, type ClusterSearchUnsubscribeMessage, ClusterSearchUnsubscribeMessageSchema, type ClusterSearchUnsubscribePayload, ClusterSearchUnsubscribePayloadSchema, type ClusterSearchUpdateMessage, ClusterSearchUpdateMessageSchema, type ClusterSearchUpdatePayload, ClusterSearchUpdatePayloadSchema, type ClusterSubAckMessage, ClusterSubAckMessageSchema, type ClusterSubAckPayload, ClusterSubAckPayloadSchema, type ClusterSubRegisterMessage, ClusterSubRegisterMessageSchema, type ClusterSubRegisterPayload, ClusterSubRegisterPayloadSchema, type ClusterSubUnregisterMessage, ClusterSubUnregisterMessageSchema, type ClusterSubUnregisterPayload, ClusterSubUnregisterPayloadSchema, type ClusterSubUpdateMessage, ClusterSubUpdateMessageSchema, type ClusterSubUpdatePayload, ClusterSubUpdatePayloadSchema, type WriteOptions as ClusterWriteOptions, type CompareFn, type ConflictResolver, type ConflictResolverDef, ConflictResolverDefSchema, type ConflictResolverFn, ConflictResolverSchema, type ConnectionPoolConfig, type ConnectionState, ConsistencyLevel, CounterRequestSchema, CounterResponseSchema, CounterSyncSchema, CounterUpdateSchema, type CursorStatus$1 as CursorStatus, CursorStatusSchema, type CursorableQueryResult, type CursorableResult, DEFAULT_BACKUP_COUNT, DEFAULT_CIRCUIT_BREAKER_CONFIG, DEFAULT_CONNECTION_POOL_CONFIG, DEFAULT_CURSOR_MAX_AGE_MS, DEFAULT_EVENT_JOURNAL_CONFIG, DEFAULT_MIGRATION_CONFIG, DEFAULT_PARTITION_ROUTER_CONFIG, DEFAULT_PROCESSOR_RATE_LIMITS, DEFAULT_QUERY_CURSOR_MAX_AGE_MS, DEFAULT_REPLICATION_CONFIG, DEFAULT_RESOLVER_RATE_LIMITS, DEFAULT_STOP_WORDS, DEFAULT_WRITE_CONCERN_TIMEOUT, ENGLISH_STOPWORDS, type EntryProcessBatchRequest, EntryProcessBatchRequestSchema, type EntryProcessBatchResponse, EntryProcessBatchResponseSchema, type EntryProcessKeyResult, EntryProcessKeyResultSchema, type EntryProcessRequest, EntryProcessRequestSchema, type EntryProcessResponse, EntryProcessResponseSchema, type EntryProcessorDef, EntryProcessorDefSchema, type EntryProcessorFn, type EntryProcessorResult, EntryProcessorSchema, type EventJournal, type EventJournalConfig, EventJournalImpl, FORBIDDEN_PATTERNS, BM25InvertedIndex as FTSInvertedIndex, type SearchOptions as FTSSearchOptions, type SearchResult as FTSSearchResult, BM25Tokenizer as FTSTokenizer, type TokenizerOptions as FTSTokenizerOptions, FallbackIndex, type FilterStep, FilteringResultSet, type FullScanStep, FullTextIndex, type FullTextIndexConfig, HLC, HashIndex, type Index, type IndexQuery, IndexRegistry, type IndexRegistryStats, type IndexScanStep, type IndexStats, IndexedLWWMap, IndexedORMap, IntersectionResultSet, type IntersectionStep, InvertedIndex, type InvertedIndexStats, type IteratorFactory, type JournalEvent, type JournalEventData, JournalEventDataSchema, type JournalEventInput, type JournalEventListener, type JournalEventMessage, JournalEventMessageSchema, type JournalEventType, JournalEventTypeSchema, type JournalReadRequest, JournalReadRequestSchema, type JournalReadResponse, JournalReadResponseSchema, type JournalSubscribeRequest, JournalSubscribeRequestSchema, type JournalUnsubscribeRequest, JournalUnsubscribeRequestSchema, LWWMap, type LWWRecord, LWWRecordSchema, LazyResultSet, LimitResultSet, type ListResolversRequest, ListResolversRequestSchema, type ListResolversResponse, ListResolversResponseSchema, type LiveQueryCallback, type LiveQueryDeltaEvent, type LiveQueryEvent, type LiveQueryInitialEvent, LiveQueryManager, type LiveQueryManagerOptions, type LiveQueryManagerStats, LockReleaseSchema, LockRequestSchema, type LogicalQueryNode, LowercaseFilter, type MatchOptions, MaxLengthFilter, type MergeContext, type MergeKeyResult, type MergeRejectedMessage, MergeRejectedMessageSchema, type MergeRejection, type MergeResult, type MergedResult, MerkleReqBucketMessageSchema, MerkleTree, type Message, MessageSchema, type MigrationChunkAckMessage, type MigrationChunkMessage, type MigrationCompleteMessage, type MigrationConfig, type MigrationMessage, type MigrationMetrics, type MigrationStartMessage, type MigrationStatus, type MigrationVerifyMessage, MinLengthFilter, MultiValueAttribute, NGramTokenizer, NavigableIndex, type NodeHealth, type NodeInfo, type NodeStatus, type NotOwnerError, type NotStep, ORMap, ORMapDiffRequestSchema, ORMapDiffResponseSchema, type ORMapMerkleNode, ORMapMerkleReqBucketSchema, ORMapMerkleTree, ORMapPushDiffSchema, type ORMapQueryResult, type ORMapRecord, ORMapRecordSchema, type ORMapSearchResult, type ORMapSnapshot, ORMapSyncInitSchema, ORMapSyncRespBucketsSchema, ORMapSyncRespLeafSchema, ORMapSyncRespRootSchema, type OpAckMessage, OpAckMessageSchema, OpBatchMessageSchema, type OpRejectedMessage, OpRejectedMessageSchema, type OpResult, OpResultSchema, PARTITION_COUNT, type PNCounter, type PNCounterConfig, PNCounterImpl, type PNCounterState, type PNCounterStateObject, PNCounterStateObjectSchema, type PartitionChange, type PartitionInfo, type PartitionMap, type PartitionMapDeltaMessage, type PartitionMapMessage, type PartitionMapRequestMessage, PartitionMapRequestSchema, type PartitionMigration, type PartitionRouterConfig, PartitionState, type PendingWrite, type PermissionPolicy, type PermissionType, type PingMessage, PingMessageSchema, type PlanStep, type PongMessage, PongMessageSchema, type Posting, type PredicateFn, type PredicateNode, PredicateNodeSchema, type PredicateOp, PredicateOpSchema, Predicates, type Principal, type ProcessorRateLimitConfig, type Query$1 as Query, QueryCursor, type QueryCursorData, type QueryCursorOptions, type Query as QueryExpression, type QueryNode, QueryOptimizer, type QueryOptimizerOptions, type QueryOptions, type QueryPlan, type QueryRespMessage, QueryRespMessageSchema, type QueryRespPayload, QueryRespPayloadSchema, type QueryResultWithCursor, QuerySchema, QuerySubMessageSchema, QueryUnsubMessageSchema, RESOLVER_FORBIDDEN_PATTERNS, type RRFConfig, type RankedResult, ReciprocalRankFusion, type RegisterResolverRequest, RegisterResolverRequestSchema, type RegisterResolverResponse, RegisterResolverResponseSchema, type ReplicationAckMessage, type ReplicationBatchAckMessage, type ReplicationBatchMessage, type ReplicationConfig, type ReplicationHealth, type ReplicationLag, type ReplicationMessage, type ReplicationProtocolMessage, type ReplicationResult, type ReplicationTask, type ResolverRateLimitConfig, type ResultSet, Ringbuffer, type RoutingError, type ScoredDocument, SearchCursor, type SearchCursorData, type SearchMessage, SearchMessageSchema, type SearchOptions$1 as SearchOptions, SearchOptionsSchema, type SearchPayload, SearchPayloadSchema, type SearchRespMessage, SearchRespMessageSchema, type SearchRespPayload, SearchRespPayloadSchema, type SearchSubMessage, SearchSubMessageSchema, type SearchSubPayload, SearchSubPayloadSchema, type SearchUnsubMessage, SearchUnsubMessageSchema, type SearchUnsubPayload, SearchUnsubPayloadSchema, type SearchUpdateMessage, SearchUpdateMessageSchema, type SearchUpdatePayload, SearchUpdatePayloadSchema, type SearchUpdateType, SearchUpdateTypeSchema, type SerializedIndex, SetResultSet, SimpleAttribute, type SimpleQueryNode, SortedMap, SortedResultSet, type StaleMapError, type StandingQueryChange, StandingQueryIndex, type StandingQueryIndexOptions, StandingQueryRegistry, type StandingQueryRegistryOptions, type StandingQueryRegistryStats, StopWordFilter, SyncInitMessageSchema, SyncRespBucketsMessageSchema, SyncRespLeafMessageSchema, SyncRespRootMessageSchema, type TermInfo, type Timestamp, TimestampSchema, type TokenFilter, TokenizationPipeline, type TokenizationPipelineOptions, type Tokenizer, TopicMessageEventSchema, TopicPubSchema, TopicSubSchema, TopicUnsubSchema, TrimFilter, UnionResultSet, type UnionStep, UniqueFilter, type UnregisterResolverRequest, UnregisterResolverRequestSchema, type UnregisterResolverResponse, UnregisterResolverResponseSchema, WRITE_CONCERN_ORDER, WhitespaceTokenizer, WordBoundaryTokenizer, WriteConcern, WriteConcernSchema, type WriteConcernValue, type WriteOptions$1 as WriteOptions, type WriteResult, combineHashes, compareHLCTimestamps, compareTimestamps, compareValues, createFieldComparator, createPredicateMatcher, decodeBase64Url, deepMerge, deserialize, disableNativeHash, encodeBase64Url, evaluatePredicate, getHighestWriteConcernLevel, hashORMapEntry, hashORMapRecord, hashObject, hashString, isLogicalQuery, isSimpleQuery, isUsingNativeHash, isWriteConcernAchieved, multiAttribute, porterStem, resetNativeHash, serialize, simpleAttribute, timestampToString, validateProcessorCode, validateResolverCode };
|