@topgunbuild/core 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1236 -913
- package/dist/index.d.ts +1236 -913
- package/dist/index.js +1232 -616
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1212 -616
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -30,11 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
AuthFailMessageSchema: () => AuthFailMessageSchema,
|
|
33
34
|
AuthMessageSchema: () => AuthMessageSchema,
|
|
34
35
|
BM25Scorer: () => BM25Scorer,
|
|
35
36
|
BatchMessageSchema: () => BatchMessageSchema,
|
|
36
37
|
BuiltInProcessors: () => BuiltInProcessors,
|
|
37
38
|
BuiltInResolvers: () => BuiltInResolvers,
|
|
39
|
+
CRDTDebugger: () => CRDTDebugger,
|
|
38
40
|
ClientOpMessageSchema: () => ClientOpMessageSchema,
|
|
39
41
|
ClientOpSchema: () => ClientOpSchema,
|
|
40
42
|
ClusterSearchReqMessageSchema: () => ClusterSearchReqMessageSchema,
|
|
@@ -91,8 +93,12 @@ __export(index_exports, {
|
|
|
91
93
|
FallbackIndex: () => FallbackIndex,
|
|
92
94
|
FilteringResultSet: () => FilteringResultSet,
|
|
93
95
|
FullTextIndex: () => FullTextIndex,
|
|
96
|
+
GcPruneMessageSchema: () => GcPruneMessageSchema,
|
|
97
|
+
GcPrunePayloadSchema: () => GcPrunePayloadSchema,
|
|
94
98
|
HLC: () => HLC,
|
|
95
99
|
HashIndex: () => HashIndex,
|
|
100
|
+
HybridQueryDeltaPayloadSchema: () => HybridQueryDeltaPayloadSchema,
|
|
101
|
+
HybridQueryRespPayloadSchema: () => HybridQueryRespPayloadSchema,
|
|
96
102
|
IndexRegistry: () => IndexRegistry,
|
|
97
103
|
IndexedLWWMap: () => IndexedLWWMap,
|
|
98
104
|
IndexedORMap: () => IndexedORMap,
|
|
@@ -112,7 +118,9 @@ __export(index_exports, {
|
|
|
112
118
|
ListResolversRequestSchema: () => ListResolversRequestSchema,
|
|
113
119
|
ListResolversResponseSchema: () => ListResolversResponseSchema,
|
|
114
120
|
LiveQueryManager: () => LiveQueryManager,
|
|
121
|
+
LockGrantedPayloadSchema: () => LockGrantedPayloadSchema,
|
|
115
122
|
LockReleaseSchema: () => LockReleaseSchema,
|
|
123
|
+
LockReleasedPayloadSchema: () => LockReleasedPayloadSchema,
|
|
116
124
|
LockRequestSchema: () => LockRequestSchema,
|
|
117
125
|
LowercaseFilter: () => LowercaseFilter,
|
|
118
126
|
MaxLengthFilter: () => MaxLengthFilter,
|
|
@@ -156,12 +164,15 @@ __export(index_exports, {
|
|
|
156
164
|
QuerySchema: () => QuerySchema,
|
|
157
165
|
QuerySubMessageSchema: () => QuerySubMessageSchema,
|
|
158
166
|
QueryUnsubMessageSchema: () => QueryUnsubMessageSchema,
|
|
167
|
+
QueryUpdateMessageSchema: () => QueryUpdateMessageSchema,
|
|
168
|
+
QueryUpdatePayloadSchema: () => QueryUpdatePayloadSchema,
|
|
159
169
|
RESOLVER_FORBIDDEN_PATTERNS: () => RESOLVER_FORBIDDEN_PATTERNS,
|
|
160
170
|
ReciprocalRankFusion: () => ReciprocalRankFusion,
|
|
161
171
|
RegisterResolverRequestSchema: () => RegisterResolverRequestSchema,
|
|
162
172
|
RegisterResolverResponseSchema: () => RegisterResolverResponseSchema,
|
|
163
173
|
Ringbuffer: () => Ringbuffer,
|
|
164
174
|
SearchCursor: () => SearchCursor,
|
|
175
|
+
SearchDebugger: () => SearchDebugger,
|
|
165
176
|
SearchMessageSchema: () => SearchMessageSchema,
|
|
166
177
|
SearchOptionsSchema: () => SearchOptionsSchema,
|
|
167
178
|
SearchPayloadSchema: () => SearchPayloadSchema,
|
|
@@ -174,6 +185,9 @@ __export(index_exports, {
|
|
|
174
185
|
SearchUpdateMessageSchema: () => SearchUpdateMessageSchema,
|
|
175
186
|
SearchUpdatePayloadSchema: () => SearchUpdatePayloadSchema,
|
|
176
187
|
SearchUpdateTypeSchema: () => SearchUpdateTypeSchema,
|
|
188
|
+
ServerBatchEventMessageSchema: () => ServerBatchEventMessageSchema,
|
|
189
|
+
ServerEventMessageSchema: () => ServerEventMessageSchema,
|
|
190
|
+
ServerEventPayloadSchema: () => ServerEventPayloadSchema,
|
|
177
191
|
SetResultSet: () => SetResultSet,
|
|
178
192
|
SimpleAttribute: () => SimpleAttribute,
|
|
179
193
|
SortedMap: () => SortedMap,
|
|
@@ -182,6 +196,7 @@ __export(index_exports, {
|
|
|
182
196
|
StandingQueryRegistry: () => StandingQueryRegistry,
|
|
183
197
|
StopWordFilter: () => StopWordFilter,
|
|
184
198
|
SyncInitMessageSchema: () => SyncInitMessageSchema,
|
|
199
|
+
SyncResetRequiredPayloadSchema: () => SyncResetRequiredPayloadSchema,
|
|
185
200
|
SyncRespBucketsMessageSchema: () => SyncRespBucketsMessageSchema,
|
|
186
201
|
SyncRespLeafMessageSchema: () => SyncRespLeafMessageSchema,
|
|
187
202
|
SyncRespRootMessageSchema: () => SyncRespRootMessageSchema,
|
|
@@ -213,7 +228,9 @@ __export(index_exports, {
|
|
|
213
228
|
disableNativeHash: () => disableNativeHash,
|
|
214
229
|
encodeBase64Url: () => encodeBase64Url,
|
|
215
230
|
evaluatePredicate: () => evaluatePredicate,
|
|
231
|
+
getCRDTDebugger: () => getCRDTDebugger,
|
|
216
232
|
getHighestWriteConcernLevel: () => getHighestWriteConcernLevel,
|
|
233
|
+
getSearchDebugger: () => getSearchDebugger,
|
|
217
234
|
hashORMapEntry: () => hashORMapEntry,
|
|
218
235
|
hashORMapRecord: () => hashORMapRecord,
|
|
219
236
|
hashObject: () => hashObject,
|
|
@@ -222,9 +239,12 @@ __export(index_exports, {
|
|
|
222
239
|
isSimpleQuery: () => isSimpleQuery,
|
|
223
240
|
isUsingNativeHash: () => isUsingNativeHash,
|
|
224
241
|
isWriteConcernAchieved: () => isWriteConcernAchieved,
|
|
242
|
+
logger: () => logger,
|
|
225
243
|
multiAttribute: () => multiAttribute,
|
|
226
244
|
porterStem: () => porterStem,
|
|
245
|
+
resetCRDTDebugger: () => resetCRDTDebugger,
|
|
227
246
|
resetNativeHash: () => resetNativeHash,
|
|
247
|
+
resetSearchDebugger: () => resetSearchDebugger,
|
|
228
248
|
serialize: () => serialize,
|
|
229
249
|
simpleAttribute: () => simpleAttribute,
|
|
230
250
|
timestampToString: () => timestampToString,
|
|
@@ -233,16 +253,34 @@ __export(index_exports, {
|
|
|
233
253
|
});
|
|
234
254
|
module.exports = __toCommonJS(index_exports);
|
|
235
255
|
|
|
256
|
+
// src/utils/logger.ts
|
|
257
|
+
var import_pino = __toESM(require("pino"));
|
|
258
|
+
var logLevel = typeof process !== "undefined" && process.env && process.env.LOG_LEVEL || "info";
|
|
259
|
+
var logger = (0, import_pino.default)({
|
|
260
|
+
level: logLevel,
|
|
261
|
+
browser: {
|
|
262
|
+
asObject: true
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
236
266
|
// src/HLC.ts
|
|
237
|
-
var
|
|
238
|
-
constructor(nodeId) {
|
|
267
|
+
var HLC = class {
|
|
268
|
+
constructor(nodeId, options = {}) {
|
|
239
269
|
this.nodeId = nodeId;
|
|
270
|
+
this.strictMode = options.strictMode ?? false;
|
|
271
|
+
this.maxDriftMs = options.maxDriftMs ?? 6e4;
|
|
240
272
|
this.lastMillis = 0;
|
|
241
273
|
this.lastCounter = 0;
|
|
242
274
|
}
|
|
243
275
|
get getNodeId() {
|
|
244
276
|
return this.nodeId;
|
|
245
277
|
}
|
|
278
|
+
get getStrictMode() {
|
|
279
|
+
return this.strictMode;
|
|
280
|
+
}
|
|
281
|
+
get getMaxDriftMs() {
|
|
282
|
+
return this.maxDriftMs;
|
|
283
|
+
}
|
|
246
284
|
/**
|
|
247
285
|
* Generates a new unique timestamp for a local event.
|
|
248
286
|
* Ensures monotonicity: always greater than any previously generated or received timestamp.
|
|
@@ -267,8 +305,18 @@ var _HLC = class _HLC {
|
|
|
267
305
|
*/
|
|
268
306
|
update(remote) {
|
|
269
307
|
const systemTime = Date.now();
|
|
270
|
-
|
|
271
|
-
|
|
308
|
+
const drift = remote.millis - systemTime;
|
|
309
|
+
if (drift > this.maxDriftMs) {
|
|
310
|
+
if (this.strictMode) {
|
|
311
|
+
throw new Error(`Clock drift detected: Remote time ${remote.millis} is ${drift}ms ahead of local ${systemTime} (threshold: ${this.maxDriftMs}ms)`);
|
|
312
|
+
} else {
|
|
313
|
+
logger.warn({
|
|
314
|
+
drift,
|
|
315
|
+
remoteMillis: remote.millis,
|
|
316
|
+
localMillis: systemTime,
|
|
317
|
+
maxDriftMs: this.maxDriftMs
|
|
318
|
+
}, "Clock drift detected");
|
|
319
|
+
}
|
|
272
320
|
}
|
|
273
321
|
const maxMillis = Math.max(this.lastMillis, systemTime, remote.millis);
|
|
274
322
|
if (maxMillis === this.lastMillis && maxMillis === remote.millis) {
|
|
@@ -317,9 +365,6 @@ var _HLC = class _HLC {
|
|
|
317
365
|
};
|
|
318
366
|
}
|
|
319
367
|
};
|
|
320
|
-
// Max allowable drift in milliseconds (1 minute)
|
|
321
|
-
_HLC.MAX_DRIFT = 6e4;
|
|
322
|
-
var HLC = _HLC;
|
|
323
368
|
|
|
324
369
|
// src/utils/hash.ts
|
|
325
370
|
var nativeHash = null;
|
|
@@ -1508,7 +1553,7 @@ var EventJournalImpl = class {
|
|
|
1508
1553
|
try {
|
|
1509
1554
|
listener(event);
|
|
1510
1555
|
} catch (e) {
|
|
1511
|
-
|
|
1556
|
+
logger.error({ err: e, context: "listener" }, "EventJournal listener error");
|
|
1512
1557
|
}
|
|
1513
1558
|
}
|
|
1514
1559
|
return event;
|
|
@@ -1554,7 +1599,7 @@ var EventJournalImpl = class {
|
|
|
1554
1599
|
try {
|
|
1555
1600
|
listener(event);
|
|
1556
1601
|
} catch (e) {
|
|
1557
|
-
|
|
1602
|
+
logger.error({ err: e, context: "replay" }, "EventJournal replay error");
|
|
1558
1603
|
}
|
|
1559
1604
|
}
|
|
1560
1605
|
}
|
|
@@ -2213,7 +2258,7 @@ var Predicates = class {
|
|
|
2213
2258
|
static containsAny(attribute, values) {
|
|
2214
2259
|
return { op: "containsAny", attribute, value: values };
|
|
2215
2260
|
}
|
|
2216
|
-
// ============== Full-Text Search Predicates
|
|
2261
|
+
// ============== Full-Text Search Predicates ==============
|
|
2217
2262
|
/**
|
|
2218
2263
|
* Create a 'match' predicate for full-text search.
|
|
2219
2264
|
* Uses BM25 scoring to find relevant documents.
|
|
@@ -2357,7 +2402,7 @@ function evaluatePredicate(predicate, data) {
|
|
|
2357
2402
|
}
|
|
2358
2403
|
}
|
|
2359
2404
|
|
|
2360
|
-
// src/schemas.ts
|
|
2405
|
+
// src/schemas/base-schemas.ts
|
|
2361
2406
|
var import_zod3 = require("zod");
|
|
2362
2407
|
var WriteConcernSchema = import_zod3.z.enum([
|
|
2363
2408
|
"FIRE_AND_FORGET",
|
|
@@ -2407,35 +2452,16 @@ var QuerySchema = import_zod3.z.object({
|
|
|
2407
2452
|
sort: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.enum(["asc", "desc"])).optional(),
|
|
2408
2453
|
limit: import_zod3.z.number().optional(),
|
|
2409
2454
|
cursor: import_zod3.z.string().optional()
|
|
2410
|
-
//
|
|
2411
|
-
});
|
|
2412
|
-
var CursorStatusSchema = import_zod3.z.enum(["valid", "expired", "invalid", "none"]);
|
|
2413
|
-
var QueryRespPayloadSchema = import_zod3.z.object({
|
|
2414
|
-
queryId: import_zod3.z.string(),
|
|
2415
|
-
results: import_zod3.z.array(import_zod3.z.object({
|
|
2416
|
-
key: import_zod3.z.string(),
|
|
2417
|
-
value: import_zod3.z.unknown()
|
|
2418
|
-
})),
|
|
2419
|
-
nextCursor: import_zod3.z.string().optional(),
|
|
2420
|
-
hasMore: import_zod3.z.boolean().optional(),
|
|
2421
|
-
/** Debug info: status of input cursor processing */
|
|
2422
|
-
cursorStatus: CursorStatusSchema.optional()
|
|
2423
|
-
});
|
|
2424
|
-
var QueryRespMessageSchema = import_zod3.z.object({
|
|
2425
|
-
type: import_zod3.z.literal("QUERY_RESP"),
|
|
2426
|
-
payload: QueryRespPayloadSchema
|
|
2455
|
+
// Replaces offset for pagination
|
|
2427
2456
|
});
|
|
2428
2457
|
var ClientOpSchema = import_zod3.z.object({
|
|
2429
2458
|
id: import_zod3.z.string().optional(),
|
|
2430
2459
|
mapName: import_zod3.z.string(),
|
|
2431
2460
|
key: import_zod3.z.string(),
|
|
2432
|
-
// Permissive opType to match ServerCoordinator behavior logic
|
|
2433
|
-
// It can be 'REMOVE', 'OR_ADD', 'OR_REMOVE' or undefined/other (implies PUT/LWW)
|
|
2434
2461
|
opType: import_zod3.z.string().optional(),
|
|
2435
2462
|
record: LWWRecordSchema.nullable().optional(),
|
|
2436
2463
|
orRecord: ORMapRecordSchema.nullable().optional(),
|
|
2437
2464
|
orTag: import_zod3.z.string().nullable().optional(),
|
|
2438
|
-
// Write Concern fields (Phase 5.01)
|
|
2439
2465
|
writeConcern: WriteConcernSchema.optional(),
|
|
2440
2466
|
timeout: import_zod3.z.number().optional()
|
|
2441
2467
|
});
|
|
@@ -2443,548 +2469,674 @@ var AuthMessageSchema = import_zod3.z.object({
|
|
|
2443
2469
|
type: import_zod3.z.literal("AUTH"),
|
|
2444
2470
|
token: import_zod3.z.string()
|
|
2445
2471
|
});
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
query: QuerySchema
|
|
2452
|
-
})
|
|
2453
|
-
});
|
|
2454
|
-
var QueryUnsubMessageSchema = import_zod3.z.object({
|
|
2455
|
-
type: import_zod3.z.literal("QUERY_UNSUB"),
|
|
2456
|
-
payload: import_zod3.z.object({
|
|
2457
|
-
queryId: import_zod3.z.string()
|
|
2458
|
-
})
|
|
2459
|
-
});
|
|
2460
|
-
var ClientOpMessageSchema = import_zod3.z.object({
|
|
2461
|
-
type: import_zod3.z.literal("CLIENT_OP"),
|
|
2472
|
+
|
|
2473
|
+
// src/schemas/sync-schemas.ts
|
|
2474
|
+
var import_zod4 = require("zod");
|
|
2475
|
+
var ClientOpMessageSchema = import_zod4.z.object({
|
|
2476
|
+
type: import_zod4.z.literal("CLIENT_OP"),
|
|
2462
2477
|
payload: ClientOpSchema
|
|
2463
2478
|
});
|
|
2464
|
-
var OpBatchMessageSchema =
|
|
2465
|
-
type:
|
|
2466
|
-
payload:
|
|
2467
|
-
ops:
|
|
2468
|
-
// Batch-level Write Concern (can be overridden per-op)
|
|
2479
|
+
var OpBatchMessageSchema = import_zod4.z.object({
|
|
2480
|
+
type: import_zod4.z.literal("OP_BATCH"),
|
|
2481
|
+
payload: import_zod4.z.object({
|
|
2482
|
+
ops: import_zod4.z.array(ClientOpSchema),
|
|
2469
2483
|
writeConcern: WriteConcernSchema.optional(),
|
|
2470
|
-
timeout:
|
|
2484
|
+
timeout: import_zod4.z.number().optional()
|
|
2471
2485
|
})
|
|
2472
2486
|
});
|
|
2473
|
-
var SyncInitMessageSchema =
|
|
2474
|
-
type:
|
|
2475
|
-
mapName:
|
|
2476
|
-
lastSyncTimestamp:
|
|
2487
|
+
var SyncInitMessageSchema = import_zod4.z.object({
|
|
2488
|
+
type: import_zod4.z.literal("SYNC_INIT"),
|
|
2489
|
+
mapName: import_zod4.z.string(),
|
|
2490
|
+
lastSyncTimestamp: import_zod4.z.number().optional()
|
|
2477
2491
|
});
|
|
2478
|
-
var SyncRespRootMessageSchema =
|
|
2479
|
-
type:
|
|
2480
|
-
payload:
|
|
2481
|
-
mapName:
|
|
2482
|
-
rootHash:
|
|
2492
|
+
var SyncRespRootMessageSchema = import_zod4.z.object({
|
|
2493
|
+
type: import_zod4.z.literal("SYNC_RESP_ROOT"),
|
|
2494
|
+
payload: import_zod4.z.object({
|
|
2495
|
+
mapName: import_zod4.z.string(),
|
|
2496
|
+
rootHash: import_zod4.z.number(),
|
|
2483
2497
|
timestamp: TimestampSchema
|
|
2484
2498
|
})
|
|
2485
2499
|
});
|
|
2486
|
-
var SyncRespBucketsMessageSchema =
|
|
2487
|
-
type:
|
|
2488
|
-
payload:
|
|
2489
|
-
mapName:
|
|
2490
|
-
path:
|
|
2491
|
-
buckets:
|
|
2500
|
+
var SyncRespBucketsMessageSchema = import_zod4.z.object({
|
|
2501
|
+
type: import_zod4.z.literal("SYNC_RESP_BUCKETS"),
|
|
2502
|
+
payload: import_zod4.z.object({
|
|
2503
|
+
mapName: import_zod4.z.string(),
|
|
2504
|
+
path: import_zod4.z.string(),
|
|
2505
|
+
buckets: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number())
|
|
2492
2506
|
})
|
|
2493
2507
|
});
|
|
2494
|
-
var SyncRespLeafMessageSchema =
|
|
2495
|
-
type:
|
|
2496
|
-
payload:
|
|
2497
|
-
mapName:
|
|
2498
|
-
path:
|
|
2499
|
-
records:
|
|
2500
|
-
key:
|
|
2508
|
+
var SyncRespLeafMessageSchema = import_zod4.z.object({
|
|
2509
|
+
type: import_zod4.z.literal("SYNC_RESP_LEAF"),
|
|
2510
|
+
payload: import_zod4.z.object({
|
|
2511
|
+
mapName: import_zod4.z.string(),
|
|
2512
|
+
path: import_zod4.z.string(),
|
|
2513
|
+
records: import_zod4.z.array(import_zod4.z.object({
|
|
2514
|
+
key: import_zod4.z.string(),
|
|
2501
2515
|
record: LWWRecordSchema
|
|
2502
2516
|
}))
|
|
2503
2517
|
})
|
|
2504
2518
|
});
|
|
2505
|
-
var MerkleReqBucketMessageSchema =
|
|
2506
|
-
type:
|
|
2507
|
-
payload:
|
|
2508
|
-
mapName:
|
|
2509
|
-
path:
|
|
2519
|
+
var MerkleReqBucketMessageSchema = import_zod4.z.object({
|
|
2520
|
+
type: import_zod4.z.literal("MERKLE_REQ_BUCKET"),
|
|
2521
|
+
payload: import_zod4.z.object({
|
|
2522
|
+
mapName: import_zod4.z.string(),
|
|
2523
|
+
path: import_zod4.z.string()
|
|
2510
2524
|
})
|
|
2511
2525
|
});
|
|
2512
|
-
var
|
|
2513
|
-
type:
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
})
|
|
2526
|
+
var ORMapSyncInitSchema = import_zod4.z.object({
|
|
2527
|
+
type: import_zod4.z.literal("ORMAP_SYNC_INIT"),
|
|
2528
|
+
mapName: import_zod4.z.string(),
|
|
2529
|
+
rootHash: import_zod4.z.number(),
|
|
2530
|
+
bucketHashes: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number()),
|
|
2531
|
+
lastSyncTimestamp: import_zod4.z.number().optional()
|
|
2519
2532
|
});
|
|
2520
|
-
var
|
|
2521
|
-
type:
|
|
2522
|
-
payload:
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2533
|
+
var ORMapSyncRespRootSchema = import_zod4.z.object({
|
|
2534
|
+
type: import_zod4.z.literal("ORMAP_SYNC_RESP_ROOT"),
|
|
2535
|
+
payload: import_zod4.z.object({
|
|
2536
|
+
mapName: import_zod4.z.string(),
|
|
2537
|
+
rootHash: import_zod4.z.number(),
|
|
2538
|
+
timestamp: TimestampSchema
|
|
2526
2539
|
})
|
|
2527
2540
|
});
|
|
2528
|
-
var
|
|
2529
|
-
type:
|
|
2530
|
-
payload:
|
|
2531
|
-
|
|
2541
|
+
var ORMapSyncRespBucketsSchema = import_zod4.z.object({
|
|
2542
|
+
type: import_zod4.z.literal("ORMAP_SYNC_RESP_BUCKETS"),
|
|
2543
|
+
payload: import_zod4.z.object({
|
|
2544
|
+
mapName: import_zod4.z.string(),
|
|
2545
|
+
path: import_zod4.z.string(),
|
|
2546
|
+
buckets: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number())
|
|
2532
2547
|
})
|
|
2533
2548
|
});
|
|
2534
|
-
var
|
|
2535
|
-
type:
|
|
2536
|
-
payload:
|
|
2537
|
-
|
|
2549
|
+
var ORMapMerkleReqBucketSchema = import_zod4.z.object({
|
|
2550
|
+
type: import_zod4.z.literal("ORMAP_MERKLE_REQ_BUCKET"),
|
|
2551
|
+
payload: import_zod4.z.object({
|
|
2552
|
+
mapName: import_zod4.z.string(),
|
|
2553
|
+
path: import_zod4.z.string()
|
|
2538
2554
|
})
|
|
2539
2555
|
});
|
|
2540
|
-
var
|
|
2541
|
-
type:
|
|
2542
|
-
payload:
|
|
2543
|
-
|
|
2544
|
-
|
|
2556
|
+
var ORMapSyncRespLeafSchema = import_zod4.z.object({
|
|
2557
|
+
type: import_zod4.z.literal("ORMAP_SYNC_RESP_LEAF"),
|
|
2558
|
+
payload: import_zod4.z.object({
|
|
2559
|
+
mapName: import_zod4.z.string(),
|
|
2560
|
+
path: import_zod4.z.string(),
|
|
2561
|
+
entries: import_zod4.z.array(import_zod4.z.object({
|
|
2562
|
+
key: import_zod4.z.string(),
|
|
2563
|
+
records: import_zod4.z.array(ORMapRecordSchema),
|
|
2564
|
+
tombstones: import_zod4.z.array(import_zod4.z.string())
|
|
2565
|
+
}))
|
|
2545
2566
|
})
|
|
2546
2567
|
});
|
|
2547
|
-
var
|
|
2548
|
-
type:
|
|
2549
|
-
payload:
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
publisherId: import_zod3.z.string().optional(),
|
|
2553
|
-
timestamp: import_zod3.z.number()
|
|
2568
|
+
var ORMapDiffRequestSchema = import_zod4.z.object({
|
|
2569
|
+
type: import_zod4.z.literal("ORMAP_DIFF_REQUEST"),
|
|
2570
|
+
payload: import_zod4.z.object({
|
|
2571
|
+
mapName: import_zod4.z.string(),
|
|
2572
|
+
keys: import_zod4.z.array(import_zod4.z.string())
|
|
2554
2573
|
})
|
|
2555
2574
|
});
|
|
2556
|
-
var
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
name: import_zod3.z.string()
|
|
2575
|
+
var ORMapDiffResponseSchema = import_zod4.z.object({
|
|
2576
|
+
type: import_zod4.z.literal("ORMAP_DIFF_RESPONSE"),
|
|
2577
|
+
payload: import_zod4.z.object({
|
|
2578
|
+
mapName: import_zod4.z.string(),
|
|
2579
|
+
entries: import_zod4.z.array(import_zod4.z.object({
|
|
2580
|
+
key: import_zod4.z.string(),
|
|
2581
|
+
records: import_zod4.z.array(ORMapRecordSchema),
|
|
2582
|
+
tombstones: import_zod4.z.array(import_zod4.z.string())
|
|
2583
|
+
}))
|
|
2566
2584
|
})
|
|
2567
2585
|
});
|
|
2568
|
-
var
|
|
2569
|
-
type:
|
|
2570
|
-
payload:
|
|
2571
|
-
|
|
2572
|
-
|
|
2586
|
+
var ORMapPushDiffSchema = import_zod4.z.object({
|
|
2587
|
+
type: import_zod4.z.literal("ORMAP_PUSH_DIFF"),
|
|
2588
|
+
payload: import_zod4.z.object({
|
|
2589
|
+
mapName: import_zod4.z.string(),
|
|
2590
|
+
entries: import_zod4.z.array(import_zod4.z.object({
|
|
2591
|
+
key: import_zod4.z.string(),
|
|
2592
|
+
records: import_zod4.z.array(ORMapRecordSchema),
|
|
2593
|
+
tombstones: import_zod4.z.array(import_zod4.z.string())
|
|
2594
|
+
}))
|
|
2573
2595
|
})
|
|
2574
2596
|
});
|
|
2575
|
-
var
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2597
|
+
var OpResultSchema = import_zod4.z.object({
|
|
2598
|
+
opId: import_zod4.z.string(),
|
|
2599
|
+
success: import_zod4.z.boolean(),
|
|
2600
|
+
achievedLevel: WriteConcernSchema,
|
|
2601
|
+
error: import_zod4.z.string().optional()
|
|
2602
|
+
});
|
|
2603
|
+
var OpAckMessageSchema = import_zod4.z.object({
|
|
2604
|
+
type: import_zod4.z.literal("OP_ACK"),
|
|
2605
|
+
payload: import_zod4.z.object({
|
|
2606
|
+
lastId: import_zod4.z.string(),
|
|
2607
|
+
achievedLevel: WriteConcernSchema.optional(),
|
|
2608
|
+
results: import_zod4.z.array(OpResultSchema).optional()
|
|
2580
2609
|
})
|
|
2581
2610
|
});
|
|
2582
|
-
var
|
|
2583
|
-
type:
|
|
2584
|
-
payload:
|
|
2585
|
-
|
|
2586
|
-
|
|
2611
|
+
var OpRejectedMessageSchema = import_zod4.z.object({
|
|
2612
|
+
type: import_zod4.z.literal("OP_REJECTED"),
|
|
2613
|
+
payload: import_zod4.z.object({
|
|
2614
|
+
opId: import_zod4.z.string(),
|
|
2615
|
+
reason: import_zod4.z.string(),
|
|
2616
|
+
code: import_zod4.z.number().optional()
|
|
2587
2617
|
})
|
|
2588
2618
|
});
|
|
2589
|
-
var
|
|
2590
|
-
type:
|
|
2591
|
-
|
|
2592
|
-
|
|
2619
|
+
var BatchMessageSchema = import_zod4.z.object({
|
|
2620
|
+
type: import_zod4.z.literal("BATCH"),
|
|
2621
|
+
count: import_zod4.z.number(),
|
|
2622
|
+
data: import_zod4.z.instanceof(Uint8Array)
|
|
2593
2623
|
});
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2624
|
+
|
|
2625
|
+
// src/schemas/query-schemas.ts
|
|
2626
|
+
var import_zod5 = require("zod");
|
|
2627
|
+
var QuerySubMessageSchema = import_zod5.z.object({
|
|
2628
|
+
type: import_zod5.z.literal("QUERY_SUB"),
|
|
2629
|
+
payload: import_zod5.z.object({
|
|
2630
|
+
queryId: import_zod5.z.string(),
|
|
2631
|
+
mapName: import_zod5.z.string(),
|
|
2632
|
+
query: QuerySchema
|
|
2633
|
+
})
|
|
2600
2634
|
});
|
|
2601
|
-
var
|
|
2602
|
-
type:
|
|
2603
|
-
|
|
2604
|
-
|
|
2635
|
+
var QueryUnsubMessageSchema = import_zod5.z.object({
|
|
2636
|
+
type: import_zod5.z.literal("QUERY_UNSUB"),
|
|
2637
|
+
payload: import_zod5.z.object({
|
|
2638
|
+
queryId: import_zod5.z.string()
|
|
2639
|
+
})
|
|
2605
2640
|
});
|
|
2606
|
-
var
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2641
|
+
var CursorStatusSchema = import_zod5.z.enum(["valid", "expired", "invalid", "none"]);
|
|
2642
|
+
var QueryRespPayloadSchema = import_zod5.z.object({
|
|
2643
|
+
queryId: import_zod5.z.string(),
|
|
2644
|
+
results: import_zod5.z.array(import_zod5.z.object({
|
|
2645
|
+
key: import_zod5.z.string(),
|
|
2646
|
+
value: import_zod5.z.unknown()
|
|
2647
|
+
})),
|
|
2648
|
+
nextCursor: import_zod5.z.string().optional(),
|
|
2649
|
+
hasMore: import_zod5.z.boolean().optional(),
|
|
2650
|
+
cursorStatus: CursorStatusSchema.optional()
|
|
2613
2651
|
});
|
|
2614
|
-
var
|
|
2615
|
-
type:
|
|
2616
|
-
payload:
|
|
2617
|
-
mapName: import_zod3.z.string(),
|
|
2618
|
-
rootHash: import_zod3.z.number(),
|
|
2619
|
-
timestamp: TimestampSchema
|
|
2620
|
-
})
|
|
2652
|
+
var QueryRespMessageSchema = import_zod5.z.object({
|
|
2653
|
+
type: import_zod5.z.literal("QUERY_RESP"),
|
|
2654
|
+
payload: QueryRespPayloadSchema
|
|
2621
2655
|
});
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2656
|
+
|
|
2657
|
+
// src/schemas/search-schemas.ts
|
|
2658
|
+
var import_zod6 = require("zod");
|
|
2659
|
+
var SearchOptionsSchema = import_zod6.z.object({
|
|
2660
|
+
limit: import_zod6.z.number().optional(),
|
|
2661
|
+
minScore: import_zod6.z.number().optional(),
|
|
2662
|
+
boost: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.number()).optional()
|
|
2629
2663
|
});
|
|
2630
|
-
var
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
})
|
|
2664
|
+
var SearchPayloadSchema = import_zod6.z.object({
|
|
2665
|
+
requestId: import_zod6.z.string(),
|
|
2666
|
+
mapName: import_zod6.z.string(),
|
|
2667
|
+
query: import_zod6.z.string(),
|
|
2668
|
+
options: SearchOptionsSchema.optional()
|
|
2636
2669
|
});
|
|
2637
|
-
var
|
|
2638
|
-
type:
|
|
2639
|
-
payload:
|
|
2640
|
-
mapName: import_zod3.z.string(),
|
|
2641
|
-
path: import_zod3.z.string(),
|
|
2642
|
-
entries: import_zod3.z.array(import_zod3.z.object({
|
|
2643
|
-
key: import_zod3.z.string(),
|
|
2644
|
-
records: import_zod3.z.array(ORMapRecordSchema),
|
|
2645
|
-
tombstones: import_zod3.z.array(import_zod3.z.string())
|
|
2646
|
-
// Tombstone tags for this key's records
|
|
2647
|
-
}))
|
|
2648
|
-
})
|
|
2670
|
+
var SearchMessageSchema = import_zod6.z.object({
|
|
2671
|
+
type: import_zod6.z.literal("SEARCH"),
|
|
2672
|
+
payload: SearchPayloadSchema
|
|
2649
2673
|
});
|
|
2650
|
-
var
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2674
|
+
var SearchRespPayloadSchema = import_zod6.z.object({
|
|
2675
|
+
requestId: import_zod6.z.string(),
|
|
2676
|
+
results: import_zod6.z.array(import_zod6.z.object({
|
|
2677
|
+
key: import_zod6.z.string(),
|
|
2678
|
+
value: import_zod6.z.unknown(),
|
|
2679
|
+
score: import_zod6.z.number(),
|
|
2680
|
+
matchedTerms: import_zod6.z.array(import_zod6.z.string())
|
|
2681
|
+
})),
|
|
2682
|
+
totalCount: import_zod6.z.number(),
|
|
2683
|
+
error: import_zod6.z.string().optional()
|
|
2656
2684
|
});
|
|
2657
|
-
var
|
|
2658
|
-
type:
|
|
2659
|
-
payload:
|
|
2660
|
-
mapName: import_zod3.z.string(),
|
|
2661
|
-
entries: import_zod3.z.array(import_zod3.z.object({
|
|
2662
|
-
key: import_zod3.z.string(),
|
|
2663
|
-
records: import_zod3.z.array(ORMapRecordSchema),
|
|
2664
|
-
tombstones: import_zod3.z.array(import_zod3.z.string())
|
|
2665
|
-
}))
|
|
2666
|
-
})
|
|
2685
|
+
var SearchRespMessageSchema = import_zod6.z.object({
|
|
2686
|
+
type: import_zod6.z.literal("SEARCH_RESP"),
|
|
2687
|
+
payload: SearchRespPayloadSchema
|
|
2667
2688
|
});
|
|
2668
|
-
var
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
records: import_zod3.z.array(ORMapRecordSchema),
|
|
2675
|
-
tombstones: import_zod3.z.array(import_zod3.z.string())
|
|
2676
|
-
}))
|
|
2677
|
-
})
|
|
2689
|
+
var SearchUpdateTypeSchema = import_zod6.z.enum(["ENTER", "UPDATE", "LEAVE"]);
|
|
2690
|
+
var SearchSubPayloadSchema = import_zod6.z.object({
|
|
2691
|
+
subscriptionId: import_zod6.z.string(),
|
|
2692
|
+
mapName: import_zod6.z.string(),
|
|
2693
|
+
query: import_zod6.z.string(),
|
|
2694
|
+
options: SearchOptionsSchema.optional()
|
|
2678
2695
|
});
|
|
2679
|
-
var
|
|
2680
|
-
type:
|
|
2681
|
-
payload:
|
|
2682
|
-
currentVersion: import_zod3.z.number().optional()
|
|
2683
|
-
}).optional()
|
|
2696
|
+
var SearchSubMessageSchema = import_zod6.z.object({
|
|
2697
|
+
type: import_zod6.z.literal("SEARCH_SUB"),
|
|
2698
|
+
payload: SearchSubPayloadSchema
|
|
2684
2699
|
});
|
|
2685
|
-
var
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2700
|
+
var SearchUpdatePayloadSchema = import_zod6.z.object({
|
|
2701
|
+
subscriptionId: import_zod6.z.string(),
|
|
2702
|
+
key: import_zod6.z.string(),
|
|
2703
|
+
value: import_zod6.z.unknown(),
|
|
2704
|
+
score: import_zod6.z.number(),
|
|
2705
|
+
matchedTerms: import_zod6.z.array(import_zod6.z.string()),
|
|
2706
|
+
type: SearchUpdateTypeSchema
|
|
2689
2707
|
});
|
|
2690
|
-
var
|
|
2691
|
-
type:
|
|
2692
|
-
|
|
2693
|
-
mapName: import_zod3.z.string(),
|
|
2694
|
-
key: import_zod3.z.string(),
|
|
2695
|
-
processor: EntryProcessorSchema
|
|
2708
|
+
var SearchUpdateMessageSchema = import_zod6.z.object({
|
|
2709
|
+
type: import_zod6.z.literal("SEARCH_UPDATE"),
|
|
2710
|
+
payload: SearchUpdatePayloadSchema
|
|
2696
2711
|
});
|
|
2697
|
-
var
|
|
2698
|
-
|
|
2699
|
-
requestId: import_zod3.z.string(),
|
|
2700
|
-
mapName: import_zod3.z.string(),
|
|
2701
|
-
keys: import_zod3.z.array(import_zod3.z.string()),
|
|
2702
|
-
processor: EntryProcessorSchema
|
|
2712
|
+
var SearchUnsubPayloadSchema = import_zod6.z.object({
|
|
2713
|
+
subscriptionId: import_zod6.z.string()
|
|
2703
2714
|
});
|
|
2704
|
-
var
|
|
2705
|
-
type:
|
|
2706
|
-
|
|
2707
|
-
success: import_zod3.z.boolean(),
|
|
2708
|
-
result: import_zod3.z.unknown().optional(),
|
|
2709
|
-
newValue: import_zod3.z.unknown().optional(),
|
|
2710
|
-
error: import_zod3.z.string().optional()
|
|
2715
|
+
var SearchUnsubMessageSchema = import_zod6.z.object({
|
|
2716
|
+
type: import_zod6.z.literal("SEARCH_UNSUB"),
|
|
2717
|
+
payload: SearchUnsubPayloadSchema
|
|
2711
2718
|
});
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2719
|
+
|
|
2720
|
+
// src/schemas/cluster-schemas.ts
|
|
2721
|
+
var import_zod7 = require("zod");
|
|
2722
|
+
var PartitionMapRequestSchema = import_zod7.z.object({
|
|
2723
|
+
type: import_zod7.z.literal("PARTITION_MAP_REQUEST"),
|
|
2724
|
+
payload: import_zod7.z.object({
|
|
2725
|
+
currentVersion: import_zod7.z.number().optional()
|
|
2726
|
+
}).optional()
|
|
2717
2727
|
});
|
|
2718
|
-
var
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2728
|
+
var ClusterSubRegisterPayloadSchema = import_zod7.z.object({
|
|
2729
|
+
subscriptionId: import_zod7.z.string(),
|
|
2730
|
+
coordinatorNodeId: import_zod7.z.string(),
|
|
2731
|
+
mapName: import_zod7.z.string(),
|
|
2732
|
+
type: import_zod7.z.enum(["SEARCH", "QUERY"]),
|
|
2733
|
+
searchQuery: import_zod7.z.string().optional(),
|
|
2734
|
+
searchOptions: import_zod7.z.object({
|
|
2735
|
+
limit: import_zod7.z.number().int().positive().optional(),
|
|
2736
|
+
minScore: import_zod7.z.number().optional(),
|
|
2737
|
+
boost: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.number()).optional()
|
|
2738
|
+
}).optional(),
|
|
2739
|
+
queryPredicate: import_zod7.z.any().optional(),
|
|
2740
|
+
querySort: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.enum(["asc", "desc"])).optional()
|
|
2722
2741
|
});
|
|
2723
|
-
var
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
// bigint as string
|
|
2727
|
-
type: JournalEventTypeSchema,
|
|
2728
|
-
mapName: import_zod3.z.string(),
|
|
2729
|
-
key: import_zod3.z.string(),
|
|
2730
|
-
value: import_zod3.z.unknown().optional(),
|
|
2731
|
-
previousValue: import_zod3.z.unknown().optional(),
|
|
2732
|
-
timestamp: TimestampSchema,
|
|
2733
|
-
nodeId: import_zod3.z.string(),
|
|
2734
|
-
metadata: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional()
|
|
2742
|
+
var ClusterSubRegisterMessageSchema = import_zod7.z.object({
|
|
2743
|
+
type: import_zod7.z.literal("CLUSTER_SUB_REGISTER"),
|
|
2744
|
+
payload: ClusterSubRegisterPayloadSchema
|
|
2735
2745
|
});
|
|
2736
|
-
var
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2746
|
+
var ClusterSubAckPayloadSchema = import_zod7.z.object({
|
|
2747
|
+
subscriptionId: import_zod7.z.string(),
|
|
2748
|
+
nodeId: import_zod7.z.string(),
|
|
2749
|
+
success: import_zod7.z.boolean(),
|
|
2750
|
+
error: import_zod7.z.string().optional(),
|
|
2751
|
+
initialResults: import_zod7.z.array(import_zod7.z.object({
|
|
2752
|
+
key: import_zod7.z.string(),
|
|
2753
|
+
value: import_zod7.z.unknown(),
|
|
2754
|
+
score: import_zod7.z.number().optional(),
|
|
2755
|
+
matchedTerms: import_zod7.z.array(import_zod7.z.string()).optional()
|
|
2756
|
+
})).optional(),
|
|
2757
|
+
totalHits: import_zod7.z.number().int().nonnegative().optional()
|
|
2743
2758
|
});
|
|
2744
|
-
var
|
|
2745
|
-
type:
|
|
2746
|
-
|
|
2759
|
+
var ClusterSubAckMessageSchema = import_zod7.z.object({
|
|
2760
|
+
type: import_zod7.z.literal("CLUSTER_SUB_ACK"),
|
|
2761
|
+
payload: ClusterSubAckPayloadSchema
|
|
2747
2762
|
});
|
|
2748
|
-
var
|
|
2749
|
-
|
|
2750
|
-
|
|
2763
|
+
var ClusterSubUpdatePayloadSchema = import_zod7.z.object({
|
|
2764
|
+
subscriptionId: import_zod7.z.string(),
|
|
2765
|
+
sourceNodeId: import_zod7.z.string(),
|
|
2766
|
+
key: import_zod7.z.string(),
|
|
2767
|
+
value: import_zod7.z.unknown(),
|
|
2768
|
+
score: import_zod7.z.number().optional(),
|
|
2769
|
+
matchedTerms: import_zod7.z.array(import_zod7.z.string()).optional(),
|
|
2770
|
+
changeType: import_zod7.z.enum(["ENTER", "UPDATE", "LEAVE"]),
|
|
2771
|
+
timestamp: import_zod7.z.number()
|
|
2751
2772
|
});
|
|
2752
|
-
var
|
|
2753
|
-
type:
|
|
2754
|
-
|
|
2755
|
-
fromSequence: import_zod3.z.string(),
|
|
2756
|
-
limit: import_zod3.z.number().optional(),
|
|
2757
|
-
mapName: import_zod3.z.string().optional()
|
|
2773
|
+
var ClusterSubUpdateMessageSchema = import_zod7.z.object({
|
|
2774
|
+
type: import_zod7.z.literal("CLUSTER_SUB_UPDATE"),
|
|
2775
|
+
payload: ClusterSubUpdatePayloadSchema
|
|
2758
2776
|
});
|
|
2759
|
-
var
|
|
2760
|
-
|
|
2761
|
-
requestId: import_zod3.z.string(),
|
|
2762
|
-
events: import_zod3.z.array(JournalEventDataSchema),
|
|
2763
|
-
hasMore: import_zod3.z.boolean()
|
|
2777
|
+
var ClusterSubUnregisterPayloadSchema = import_zod7.z.object({
|
|
2778
|
+
subscriptionId: import_zod7.z.string()
|
|
2764
2779
|
});
|
|
2765
|
-
var
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
boost: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.number()).optional()
|
|
2780
|
+
var ClusterSubUnregisterMessageSchema = import_zod7.z.object({
|
|
2781
|
+
type: import_zod7.z.literal("CLUSTER_SUB_UNREGISTER"),
|
|
2782
|
+
payload: ClusterSubUnregisterPayloadSchema
|
|
2769
2783
|
});
|
|
2770
|
-
var
|
|
2771
|
-
requestId:
|
|
2772
|
-
mapName:
|
|
2773
|
-
query:
|
|
2774
|
-
options:
|
|
2784
|
+
var ClusterSearchReqPayloadSchema = import_zod7.z.object({
|
|
2785
|
+
requestId: import_zod7.z.string(),
|
|
2786
|
+
mapName: import_zod7.z.string(),
|
|
2787
|
+
query: import_zod7.z.string(),
|
|
2788
|
+
options: import_zod7.z.object({
|
|
2789
|
+
limit: import_zod7.z.number().int().positive().max(1e3),
|
|
2790
|
+
minScore: import_zod7.z.number().optional(),
|
|
2791
|
+
boost: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.number()).optional(),
|
|
2792
|
+
includeMatchedTerms: import_zod7.z.boolean().optional(),
|
|
2793
|
+
afterScore: import_zod7.z.number().optional(),
|
|
2794
|
+
afterKey: import_zod7.z.string().optional()
|
|
2795
|
+
}),
|
|
2796
|
+
timeoutMs: import_zod7.z.number().int().positive().optional()
|
|
2775
2797
|
});
|
|
2776
|
-
var
|
|
2777
|
-
type:
|
|
2778
|
-
payload:
|
|
2798
|
+
var ClusterSearchReqMessageSchema = import_zod7.z.object({
|
|
2799
|
+
type: import_zod7.z.literal("CLUSTER_SEARCH_REQ"),
|
|
2800
|
+
payload: ClusterSearchReqPayloadSchema
|
|
2779
2801
|
});
|
|
2780
|
-
var
|
|
2781
|
-
requestId:
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2802
|
+
var ClusterSearchRespPayloadSchema = import_zod7.z.object({
|
|
2803
|
+
requestId: import_zod7.z.string(),
|
|
2804
|
+
nodeId: import_zod7.z.string(),
|
|
2805
|
+
results: import_zod7.z.array(import_zod7.z.object({
|
|
2806
|
+
key: import_zod7.z.string(),
|
|
2807
|
+
value: import_zod7.z.unknown(),
|
|
2808
|
+
score: import_zod7.z.number(),
|
|
2809
|
+
matchedTerms: import_zod7.z.array(import_zod7.z.string()).optional()
|
|
2787
2810
|
})),
|
|
2788
|
-
|
|
2789
|
-
|
|
2811
|
+
totalHits: import_zod7.z.number().int().nonnegative(),
|
|
2812
|
+
executionTimeMs: import_zod7.z.number().nonnegative(),
|
|
2813
|
+
error: import_zod7.z.string().optional()
|
|
2790
2814
|
});
|
|
2791
|
-
var
|
|
2792
|
-
type:
|
|
2793
|
-
payload:
|
|
2815
|
+
var ClusterSearchRespMessageSchema = import_zod7.z.object({
|
|
2816
|
+
type: import_zod7.z.literal("CLUSTER_SEARCH_RESP"),
|
|
2817
|
+
payload: ClusterSearchRespPayloadSchema
|
|
2794
2818
|
});
|
|
2795
|
-
var
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
query: import_zod3.z.string(),
|
|
2819
|
+
var ClusterSearchSubscribePayloadSchema = import_zod7.z.object({
|
|
2820
|
+
subscriptionId: import_zod7.z.string(),
|
|
2821
|
+
mapName: import_zod7.z.string(),
|
|
2822
|
+
query: import_zod7.z.string(),
|
|
2800
2823
|
options: SearchOptionsSchema.optional()
|
|
2801
2824
|
});
|
|
2802
|
-
var
|
|
2803
|
-
type:
|
|
2804
|
-
payload:
|
|
2825
|
+
var ClusterSearchSubscribeMessageSchema = import_zod7.z.object({
|
|
2826
|
+
type: import_zod7.z.literal("CLUSTER_SEARCH_SUBSCRIBE"),
|
|
2827
|
+
payload: ClusterSearchSubscribePayloadSchema
|
|
2805
2828
|
});
|
|
2806
|
-
var
|
|
2807
|
-
subscriptionId:
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2829
|
+
var ClusterSearchUnsubscribePayloadSchema = import_zod7.z.object({
|
|
2830
|
+
subscriptionId: import_zod7.z.string()
|
|
2831
|
+
});
|
|
2832
|
+
var ClusterSearchUnsubscribeMessageSchema = import_zod7.z.object({
|
|
2833
|
+
type: import_zod7.z.literal("CLUSTER_SEARCH_UNSUBSCRIBE"),
|
|
2834
|
+
payload: ClusterSearchUnsubscribePayloadSchema
|
|
2835
|
+
});
|
|
2836
|
+
var ClusterSearchUpdatePayloadSchema = import_zod7.z.object({
|
|
2837
|
+
subscriptionId: import_zod7.z.string(),
|
|
2838
|
+
nodeId: import_zod7.z.string(),
|
|
2839
|
+
key: import_zod7.z.string(),
|
|
2840
|
+
value: import_zod7.z.unknown(),
|
|
2841
|
+
score: import_zod7.z.number(),
|
|
2842
|
+
matchedTerms: import_zod7.z.array(import_zod7.z.string()).optional(),
|
|
2812
2843
|
type: SearchUpdateTypeSchema
|
|
2813
2844
|
});
|
|
2814
|
-
var
|
|
2815
|
-
type:
|
|
2816
|
-
payload:
|
|
2845
|
+
var ClusterSearchUpdateMessageSchema = import_zod7.z.object({
|
|
2846
|
+
type: import_zod7.z.literal("CLUSTER_SEARCH_UPDATE"),
|
|
2847
|
+
payload: ClusterSearchUpdatePayloadSchema
|
|
2848
|
+
});
|
|
2849
|
+
|
|
2850
|
+
// src/schemas/messaging-schemas.ts
|
|
2851
|
+
var import_zod8 = require("zod");
|
|
2852
|
+
var TopicSubSchema = import_zod8.z.object({
|
|
2853
|
+
type: import_zod8.z.literal("TOPIC_SUB"),
|
|
2854
|
+
payload: import_zod8.z.object({ topic: import_zod8.z.string() })
|
|
2817
2855
|
});
|
|
2818
|
-
var
|
|
2819
|
-
|
|
2856
|
+
var TopicUnsubSchema = import_zod8.z.object({
|
|
2857
|
+
type: import_zod8.z.literal("TOPIC_UNSUB"),
|
|
2858
|
+
payload: import_zod8.z.object({ topic: import_zod8.z.string() })
|
|
2820
2859
|
});
|
|
2821
|
-
var
|
|
2822
|
-
type:
|
|
2823
|
-
payload:
|
|
2860
|
+
var TopicPubSchema = import_zod8.z.object({
|
|
2861
|
+
type: import_zod8.z.literal("TOPIC_PUB"),
|
|
2862
|
+
payload: import_zod8.z.object({
|
|
2863
|
+
topic: import_zod8.z.string(),
|
|
2864
|
+
data: import_zod8.z.any()
|
|
2865
|
+
})
|
|
2824
2866
|
});
|
|
2825
|
-
var
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2867
|
+
var TopicMessageEventSchema = import_zod8.z.object({
|
|
2868
|
+
type: import_zod8.z.literal("TOPIC_MESSAGE"),
|
|
2869
|
+
payload: import_zod8.z.object({
|
|
2870
|
+
topic: import_zod8.z.string(),
|
|
2871
|
+
data: import_zod8.z.any(),
|
|
2872
|
+
publisherId: import_zod8.z.string().optional(),
|
|
2873
|
+
timestamp: import_zod8.z.number()
|
|
2874
|
+
})
|
|
2830
2875
|
});
|
|
2831
|
-
var
|
|
2832
|
-
type:
|
|
2833
|
-
|
|
2834
|
-
|
|
2876
|
+
var LockRequestSchema = import_zod8.z.object({
|
|
2877
|
+
type: import_zod8.z.literal("LOCK_REQUEST"),
|
|
2878
|
+
payload: import_zod8.z.object({
|
|
2879
|
+
requestId: import_zod8.z.string(),
|
|
2880
|
+
name: import_zod8.z.string(),
|
|
2881
|
+
ttl: import_zod8.z.number().optional()
|
|
2882
|
+
})
|
|
2883
|
+
});
|
|
2884
|
+
var LockReleaseSchema = import_zod8.z.object({
|
|
2885
|
+
type: import_zod8.z.literal("LOCK_RELEASE"),
|
|
2886
|
+
payload: import_zod8.z.object({
|
|
2887
|
+
requestId: import_zod8.z.string().optional(),
|
|
2888
|
+
name: import_zod8.z.string(),
|
|
2889
|
+
fencingToken: import_zod8.z.number()
|
|
2890
|
+
})
|
|
2891
|
+
});
|
|
2892
|
+
var PNCounterStateObjectSchema = import_zod8.z.object({
|
|
2893
|
+
p: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.number()),
|
|
2894
|
+
n: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.number())
|
|
2895
|
+
});
|
|
2896
|
+
var CounterRequestSchema = import_zod8.z.object({
|
|
2897
|
+
type: import_zod8.z.literal("COUNTER_REQUEST"),
|
|
2898
|
+
payload: import_zod8.z.object({ name: import_zod8.z.string() })
|
|
2899
|
+
});
|
|
2900
|
+
var CounterSyncSchema = import_zod8.z.object({
|
|
2901
|
+
type: import_zod8.z.literal("COUNTER_SYNC"),
|
|
2902
|
+
payload: import_zod8.z.object({
|
|
2903
|
+
name: import_zod8.z.string(),
|
|
2904
|
+
state: PNCounterStateObjectSchema
|
|
2905
|
+
})
|
|
2906
|
+
});
|
|
2907
|
+
var CounterResponseSchema = import_zod8.z.object({
|
|
2908
|
+
type: import_zod8.z.literal("COUNTER_RESPONSE"),
|
|
2909
|
+
payload: import_zod8.z.object({
|
|
2910
|
+
name: import_zod8.z.string(),
|
|
2911
|
+
state: PNCounterStateObjectSchema
|
|
2912
|
+
})
|
|
2913
|
+
});
|
|
2914
|
+
var CounterUpdateSchema = import_zod8.z.object({
|
|
2915
|
+
type: import_zod8.z.literal("COUNTER_UPDATE"),
|
|
2916
|
+
payload: import_zod8.z.object({
|
|
2917
|
+
name: import_zod8.z.string(),
|
|
2918
|
+
state: PNCounterStateObjectSchema
|
|
2919
|
+
})
|
|
2920
|
+
});
|
|
2921
|
+
var PingMessageSchema = import_zod8.z.object({
|
|
2922
|
+
type: import_zod8.z.literal("PING"),
|
|
2923
|
+
timestamp: import_zod8.z.number()
|
|
2924
|
+
});
|
|
2925
|
+
var PongMessageSchema = import_zod8.z.object({
|
|
2926
|
+
type: import_zod8.z.literal("PONG"),
|
|
2927
|
+
timestamp: import_zod8.z.number(),
|
|
2928
|
+
serverTime: import_zod8.z.number()
|
|
2929
|
+
});
|
|
2930
|
+
var EntryProcessorSchema = import_zod8.z.object({
|
|
2931
|
+
name: import_zod8.z.string().min(1).max(100),
|
|
2932
|
+
code: import_zod8.z.string().min(1).max(1e4),
|
|
2933
|
+
args: import_zod8.z.unknown().optional()
|
|
2934
|
+
});
|
|
2935
|
+
var EntryProcessRequestSchema = import_zod8.z.object({
|
|
2936
|
+
type: import_zod8.z.literal("ENTRY_PROCESS"),
|
|
2937
|
+
requestId: import_zod8.z.string(),
|
|
2938
|
+
mapName: import_zod8.z.string(),
|
|
2939
|
+
key: import_zod8.z.string(),
|
|
2940
|
+
processor: EntryProcessorSchema
|
|
2941
|
+
});
|
|
2942
|
+
var EntryProcessBatchRequestSchema = import_zod8.z.object({
|
|
2943
|
+
type: import_zod8.z.literal("ENTRY_PROCESS_BATCH"),
|
|
2944
|
+
requestId: import_zod8.z.string(),
|
|
2945
|
+
mapName: import_zod8.z.string(),
|
|
2946
|
+
keys: import_zod8.z.array(import_zod8.z.string()),
|
|
2947
|
+
processor: EntryProcessorSchema
|
|
2948
|
+
});
|
|
2949
|
+
var EntryProcessResponseSchema = import_zod8.z.object({
|
|
2950
|
+
type: import_zod8.z.literal("ENTRY_PROCESS_RESPONSE"),
|
|
2951
|
+
requestId: import_zod8.z.string(),
|
|
2952
|
+
success: import_zod8.z.boolean(),
|
|
2953
|
+
result: import_zod8.z.unknown().optional(),
|
|
2954
|
+
newValue: import_zod8.z.unknown().optional(),
|
|
2955
|
+
error: import_zod8.z.string().optional()
|
|
2956
|
+
});
|
|
2957
|
+
var EntryProcessKeyResultSchema = import_zod8.z.object({
|
|
2958
|
+
success: import_zod8.z.boolean(),
|
|
2959
|
+
result: import_zod8.z.unknown().optional(),
|
|
2960
|
+
newValue: import_zod8.z.unknown().optional(),
|
|
2961
|
+
error: import_zod8.z.string().optional()
|
|
2962
|
+
});
|
|
2963
|
+
var EntryProcessBatchResponseSchema = import_zod8.z.object({
|
|
2964
|
+
type: import_zod8.z.literal("ENTRY_PROCESS_BATCH_RESPONSE"),
|
|
2965
|
+
requestId: import_zod8.z.string(),
|
|
2966
|
+
results: import_zod8.z.record(import_zod8.z.string(), EntryProcessKeyResultSchema)
|
|
2967
|
+
});
|
|
2968
|
+
var JournalEventTypeSchema = import_zod8.z.enum(["PUT", "UPDATE", "DELETE"]);
|
|
2969
|
+
var JournalEventDataSchema = import_zod8.z.object({
|
|
2970
|
+
sequence: import_zod8.z.string(),
|
|
2971
|
+
type: JournalEventTypeSchema,
|
|
2972
|
+
mapName: import_zod8.z.string(),
|
|
2973
|
+
key: import_zod8.z.string(),
|
|
2974
|
+
value: import_zod8.z.unknown().optional(),
|
|
2975
|
+
previousValue: import_zod8.z.unknown().optional(),
|
|
2976
|
+
timestamp: TimestampSchema,
|
|
2977
|
+
nodeId: import_zod8.z.string(),
|
|
2978
|
+
metadata: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.unknown()).optional()
|
|
2979
|
+
});
|
|
2980
|
+
var JournalSubscribeRequestSchema = import_zod8.z.object({
|
|
2981
|
+
type: import_zod8.z.literal("JOURNAL_SUBSCRIBE"),
|
|
2982
|
+
requestId: import_zod8.z.string(),
|
|
2983
|
+
fromSequence: import_zod8.z.string().optional(),
|
|
2984
|
+
mapName: import_zod8.z.string().optional(),
|
|
2985
|
+
types: import_zod8.z.array(JournalEventTypeSchema).optional()
|
|
2986
|
+
});
|
|
2987
|
+
var JournalUnsubscribeRequestSchema = import_zod8.z.object({
|
|
2988
|
+
type: import_zod8.z.literal("JOURNAL_UNSUBSCRIBE"),
|
|
2989
|
+
subscriptionId: import_zod8.z.string()
|
|
2990
|
+
});
|
|
2991
|
+
var JournalEventMessageSchema = import_zod8.z.object({
|
|
2992
|
+
type: import_zod8.z.literal("JOURNAL_EVENT"),
|
|
2993
|
+
event: JournalEventDataSchema
|
|
2994
|
+
});
|
|
2995
|
+
var JournalReadRequestSchema = import_zod8.z.object({
|
|
2996
|
+
type: import_zod8.z.literal("JOURNAL_READ"),
|
|
2997
|
+
requestId: import_zod8.z.string(),
|
|
2998
|
+
fromSequence: import_zod8.z.string(),
|
|
2999
|
+
limit: import_zod8.z.number().optional(),
|
|
3000
|
+
mapName: import_zod8.z.string().optional()
|
|
3001
|
+
});
|
|
3002
|
+
var JournalReadResponseSchema = import_zod8.z.object({
|
|
3003
|
+
type: import_zod8.z.literal("JOURNAL_READ_RESPONSE"),
|
|
3004
|
+
requestId: import_zod8.z.string(),
|
|
3005
|
+
events: import_zod8.z.array(JournalEventDataSchema),
|
|
3006
|
+
hasMore: import_zod8.z.boolean()
|
|
3007
|
+
});
|
|
3008
|
+
var ConflictResolverSchema = import_zod8.z.object({
|
|
3009
|
+
name: import_zod8.z.string().min(1).max(100),
|
|
3010
|
+
code: import_zod8.z.string().max(5e4),
|
|
3011
|
+
priority: import_zod8.z.number().int().min(0).max(100).optional(),
|
|
3012
|
+
keyPattern: import_zod8.z.string().optional()
|
|
3013
|
+
});
|
|
3014
|
+
var RegisterResolverRequestSchema = import_zod8.z.object({
|
|
3015
|
+
type: import_zod8.z.literal("REGISTER_RESOLVER"),
|
|
3016
|
+
requestId: import_zod8.z.string(),
|
|
3017
|
+
mapName: import_zod8.z.string(),
|
|
2835
3018
|
resolver: ConflictResolverSchema
|
|
2836
3019
|
});
|
|
2837
|
-
var RegisterResolverResponseSchema =
|
|
2838
|
-
type:
|
|
2839
|
-
requestId:
|
|
2840
|
-
success:
|
|
2841
|
-
error:
|
|
3020
|
+
var RegisterResolverResponseSchema = import_zod8.z.object({
|
|
3021
|
+
type: import_zod8.z.literal("REGISTER_RESOLVER_RESPONSE"),
|
|
3022
|
+
requestId: import_zod8.z.string(),
|
|
3023
|
+
success: import_zod8.z.boolean(),
|
|
3024
|
+
error: import_zod8.z.string().optional()
|
|
2842
3025
|
});
|
|
2843
|
-
var UnregisterResolverRequestSchema =
|
|
2844
|
-
type:
|
|
2845
|
-
requestId:
|
|
2846
|
-
mapName:
|
|
2847
|
-
resolverName:
|
|
3026
|
+
var UnregisterResolverRequestSchema = import_zod8.z.object({
|
|
3027
|
+
type: import_zod8.z.literal("UNREGISTER_RESOLVER"),
|
|
3028
|
+
requestId: import_zod8.z.string(),
|
|
3029
|
+
mapName: import_zod8.z.string(),
|
|
3030
|
+
resolverName: import_zod8.z.string()
|
|
2848
3031
|
});
|
|
2849
|
-
var UnregisterResolverResponseSchema =
|
|
2850
|
-
type:
|
|
2851
|
-
requestId:
|
|
2852
|
-
success:
|
|
2853
|
-
error:
|
|
3032
|
+
var UnregisterResolverResponseSchema = import_zod8.z.object({
|
|
3033
|
+
type: import_zod8.z.literal("UNREGISTER_RESOLVER_RESPONSE"),
|
|
3034
|
+
requestId: import_zod8.z.string(),
|
|
3035
|
+
success: import_zod8.z.boolean(),
|
|
3036
|
+
error: import_zod8.z.string().optional()
|
|
2854
3037
|
});
|
|
2855
|
-
var MergeRejectedMessageSchema =
|
|
2856
|
-
type:
|
|
2857
|
-
mapName:
|
|
2858
|
-
key:
|
|
2859
|
-
attemptedValue:
|
|
2860
|
-
reason:
|
|
3038
|
+
var MergeRejectedMessageSchema = import_zod8.z.object({
|
|
3039
|
+
type: import_zod8.z.literal("MERGE_REJECTED"),
|
|
3040
|
+
mapName: import_zod8.z.string(),
|
|
3041
|
+
key: import_zod8.z.string(),
|
|
3042
|
+
attemptedValue: import_zod8.z.unknown(),
|
|
3043
|
+
reason: import_zod8.z.string(),
|
|
2861
3044
|
timestamp: TimestampSchema
|
|
2862
3045
|
});
|
|
2863
|
-
var ListResolversRequestSchema =
|
|
2864
|
-
type:
|
|
2865
|
-
requestId:
|
|
2866
|
-
mapName:
|
|
3046
|
+
var ListResolversRequestSchema = import_zod8.z.object({
|
|
3047
|
+
type: import_zod8.z.literal("LIST_RESOLVERS"),
|
|
3048
|
+
requestId: import_zod8.z.string(),
|
|
3049
|
+
mapName: import_zod8.z.string().optional()
|
|
2867
3050
|
});
|
|
2868
|
-
var ListResolversResponseSchema =
|
|
2869
|
-
type:
|
|
2870
|
-
requestId:
|
|
2871
|
-
resolvers:
|
|
2872
|
-
mapName:
|
|
2873
|
-
name:
|
|
2874
|
-
priority:
|
|
2875
|
-
keyPattern:
|
|
3051
|
+
var ListResolversResponseSchema = import_zod8.z.object({
|
|
3052
|
+
type: import_zod8.z.literal("LIST_RESOLVERS_RESPONSE"),
|
|
3053
|
+
requestId: import_zod8.z.string(),
|
|
3054
|
+
resolvers: import_zod8.z.array(import_zod8.z.object({
|
|
3055
|
+
mapName: import_zod8.z.string(),
|
|
3056
|
+
name: import_zod8.z.string(),
|
|
3057
|
+
priority: import_zod8.z.number().optional(),
|
|
3058
|
+
keyPattern: import_zod8.z.string().optional()
|
|
2876
3059
|
}))
|
|
2877
3060
|
});
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
3061
|
+
|
|
3062
|
+
// src/schemas/client-message-schemas.ts
|
|
3063
|
+
var import_zod9 = require("zod");
|
|
3064
|
+
var ServerEventPayloadSchema = import_zod9.z.object({
|
|
3065
|
+
mapName: import_zod9.z.string(),
|
|
3066
|
+
eventType: import_zod9.z.enum(["PUT", "REMOVE", "OR_ADD", "OR_REMOVE"]),
|
|
3067
|
+
key: import_zod9.z.string(),
|
|
3068
|
+
record: LWWRecordSchema.optional(),
|
|
3069
|
+
orRecord: ORMapRecordSchema.optional(),
|
|
3070
|
+
orTag: import_zod9.z.string().optional()
|
|
2883
3071
|
});
|
|
2884
|
-
var
|
|
2885
|
-
type:
|
|
2886
|
-
payload:
|
|
2887
|
-
/** ID of the last operation in the batch (for backwards compatibility) */
|
|
2888
|
-
lastId: import_zod3.z.string(),
|
|
2889
|
-
/** Write Concern level achieved (for simple ACKs) */
|
|
2890
|
-
achievedLevel: WriteConcernSchema.optional(),
|
|
2891
|
-
/** Per-operation results (for batch operations with mixed Write Concern) */
|
|
2892
|
-
results: import_zod3.z.array(OpResultSchema).optional()
|
|
2893
|
-
})
|
|
3072
|
+
var ServerEventMessageSchema = import_zod9.z.object({
|
|
3073
|
+
type: import_zod9.z.literal("SERVER_EVENT"),
|
|
3074
|
+
payload: ServerEventPayloadSchema
|
|
2894
3075
|
});
|
|
2895
|
-
var
|
|
2896
|
-
type:
|
|
2897
|
-
payload:
|
|
2898
|
-
|
|
2899
|
-
opId: import_zod3.z.string(),
|
|
2900
|
-
/** Reason for rejection */
|
|
2901
|
-
reason: import_zod3.z.string(),
|
|
2902
|
-
/** Error code */
|
|
2903
|
-
code: import_zod3.z.number().optional()
|
|
3076
|
+
var ServerBatchEventMessageSchema = import_zod9.z.object({
|
|
3077
|
+
type: import_zod9.z.literal("SERVER_BATCH_EVENT"),
|
|
3078
|
+
payload: import_zod9.z.object({
|
|
3079
|
+
events: import_zod9.z.array(ServerEventPayloadSchema)
|
|
2904
3080
|
})
|
|
2905
3081
|
});
|
|
2906
|
-
var
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
/** Map name to subscribe to */
|
|
2912
|
-
mapName: import_zod3.z.string(),
|
|
2913
|
-
/** Subscription type */
|
|
2914
|
-
type: import_zod3.z.enum(["SEARCH", "QUERY"]),
|
|
2915
|
-
// For FTS subscriptions
|
|
2916
|
-
/** Search query string (for SEARCH type) */
|
|
2917
|
-
searchQuery: import_zod3.z.string().optional(),
|
|
2918
|
-
/** Search options (for SEARCH type) */
|
|
2919
|
-
searchOptions: import_zod3.z.object({
|
|
2920
|
-
limit: import_zod3.z.number().int().positive().optional(),
|
|
2921
|
-
minScore: import_zod3.z.number().optional(),
|
|
2922
|
-
boost: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.number()).optional()
|
|
2923
|
-
}).optional(),
|
|
2924
|
-
// For Query subscriptions
|
|
2925
|
-
/** Query predicate (for QUERY type) */
|
|
2926
|
-
queryPredicate: import_zod3.z.any().optional(),
|
|
2927
|
-
/** Query sort order (for QUERY type) */
|
|
2928
|
-
querySort: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.enum(["asc", "desc"])).optional()
|
|
3082
|
+
var QueryUpdatePayloadSchema = import_zod9.z.object({
|
|
3083
|
+
queryId: import_zod9.z.string(),
|
|
3084
|
+
key: import_zod9.z.string(),
|
|
3085
|
+
value: import_zod9.z.unknown(),
|
|
3086
|
+
type: import_zod9.z.enum(["ENTER", "UPDATE", "REMOVE"])
|
|
2929
3087
|
});
|
|
2930
|
-
var
|
|
2931
|
-
type:
|
|
2932
|
-
payload:
|
|
3088
|
+
var QueryUpdateMessageSchema = import_zod9.z.object({
|
|
3089
|
+
type: import_zod9.z.literal("QUERY_UPDATE"),
|
|
3090
|
+
payload: QueryUpdatePayloadSchema
|
|
2933
3091
|
});
|
|
2934
|
-
var
|
|
2935
|
-
|
|
2936
|
-
subscriptionId: import_zod3.z.string(),
|
|
2937
|
-
/** Node that registered this subscription */
|
|
2938
|
-
nodeId: import_zod3.z.string(),
|
|
2939
|
-
/** Registration success status */
|
|
2940
|
-
success: import_zod3.z.boolean(),
|
|
2941
|
-
/** Error message if failed */
|
|
2942
|
-
error: import_zod3.z.string().optional(),
|
|
2943
|
-
/** Initial results from this node */
|
|
2944
|
-
initialResults: import_zod3.z.array(import_zod3.z.object({
|
|
2945
|
-
key: import_zod3.z.string(),
|
|
2946
|
-
value: import_zod3.z.unknown(),
|
|
2947
|
-
score: import_zod3.z.number().optional(),
|
|
2948
|
-
matchedTerms: import_zod3.z.array(import_zod3.z.string()).optional()
|
|
2949
|
-
})).optional(),
|
|
2950
|
-
/** Total matching documents on this node */
|
|
2951
|
-
totalHits: import_zod3.z.number().int().nonnegative().optional()
|
|
3092
|
+
var GcPrunePayloadSchema = import_zod9.z.object({
|
|
3093
|
+
olderThan: TimestampSchema
|
|
2952
3094
|
});
|
|
2953
|
-
var
|
|
2954
|
-
type:
|
|
2955
|
-
payload:
|
|
3095
|
+
var GcPruneMessageSchema = import_zod9.z.object({
|
|
3096
|
+
type: import_zod9.z.literal("GC_PRUNE"),
|
|
3097
|
+
payload: GcPrunePayloadSchema
|
|
2956
3098
|
});
|
|
2957
|
-
var
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
sourceNodeId: import_zod3.z.string(),
|
|
2962
|
-
/** Document key */
|
|
2963
|
-
key: import_zod3.z.string(),
|
|
2964
|
-
/** Document value (null for LEAVE) */
|
|
2965
|
-
value: import_zod3.z.unknown(),
|
|
2966
|
-
/** Search score (for SEARCH type) */
|
|
2967
|
-
score: import_zod3.z.number().optional(),
|
|
2968
|
-
/** Matched terms (for SEARCH type) */
|
|
2969
|
-
matchedTerms: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
2970
|
-
/** Change type: ENTER (new match), UPDATE (still matches), LEAVE (no longer matches) */
|
|
2971
|
-
changeType: import_zod3.z.enum(["ENTER", "UPDATE", "LEAVE"]),
|
|
2972
|
-
/** Timestamp for ordering */
|
|
2973
|
-
timestamp: import_zod3.z.number()
|
|
3099
|
+
var AuthFailMessageSchema = import_zod9.z.object({
|
|
3100
|
+
type: import_zod9.z.literal("AUTH_FAIL"),
|
|
3101
|
+
error: import_zod9.z.string().optional(),
|
|
3102
|
+
code: import_zod9.z.number().optional()
|
|
2974
3103
|
});
|
|
2975
|
-
var
|
|
2976
|
-
|
|
2977
|
-
|
|
3104
|
+
var HybridQueryRespPayloadSchema = import_zod9.z.object({
|
|
3105
|
+
subscriptionId: import_zod9.z.string(),
|
|
3106
|
+
results: import_zod9.z.array(import_zod9.z.object({
|
|
3107
|
+
key: import_zod9.z.string(),
|
|
3108
|
+
value: import_zod9.z.unknown(),
|
|
3109
|
+
score: import_zod9.z.number(),
|
|
3110
|
+
matchedTerms: import_zod9.z.array(import_zod9.z.string())
|
|
3111
|
+
})),
|
|
3112
|
+
nextCursor: import_zod9.z.string().optional(),
|
|
3113
|
+
hasMore: import_zod9.z.boolean().optional(),
|
|
3114
|
+
cursorStatus: CursorStatusSchema.optional()
|
|
2978
3115
|
});
|
|
2979
|
-
var
|
|
2980
|
-
|
|
2981
|
-
|
|
3116
|
+
var HybridQueryDeltaPayloadSchema = import_zod9.z.object({
|
|
3117
|
+
subscriptionId: import_zod9.z.string(),
|
|
3118
|
+
key: import_zod9.z.string(),
|
|
3119
|
+
value: import_zod9.z.unknown().nullable(),
|
|
3120
|
+
score: import_zod9.z.number().optional(),
|
|
3121
|
+
matchedTerms: import_zod9.z.array(import_zod9.z.string()).optional(),
|
|
3122
|
+
type: import_zod9.z.enum(["ENTER", "UPDATE", "LEAVE"])
|
|
2982
3123
|
});
|
|
2983
|
-
var
|
|
2984
|
-
|
|
2985
|
-
|
|
3124
|
+
var LockGrantedPayloadSchema = import_zod9.z.object({
|
|
3125
|
+
requestId: import_zod9.z.string(),
|
|
3126
|
+
fencingToken: import_zod9.z.number()
|
|
3127
|
+
});
|
|
3128
|
+
var LockReleasedPayloadSchema = import_zod9.z.object({
|
|
3129
|
+
requestId: import_zod9.z.string(),
|
|
3130
|
+
success: import_zod9.z.boolean()
|
|
3131
|
+
});
|
|
3132
|
+
var SyncResetRequiredPayloadSchema = import_zod9.z.object({
|
|
3133
|
+
mapName: import_zod9.z.string(),
|
|
3134
|
+
reason: import_zod9.z.string()
|
|
2986
3135
|
});
|
|
2987
|
-
|
|
3136
|
+
|
|
3137
|
+
// src/schemas/index.ts
|
|
3138
|
+
var import_zod10 = require("zod");
|
|
3139
|
+
var MessageSchema = import_zod10.z.discriminatedUnion("type", [
|
|
2988
3140
|
AuthMessageSchema,
|
|
2989
3141
|
QuerySubMessageSchema,
|
|
2990
3142
|
QueryUnsubMessageSchema,
|
|
@@ -3002,7 +3154,6 @@ var MessageSchema = import_zod3.z.discriminatedUnion("type", [
|
|
|
3002
3154
|
TopicPubSchema,
|
|
3003
3155
|
PingMessageSchema,
|
|
3004
3156
|
PongMessageSchema,
|
|
3005
|
-
// ORMap Sync Messages
|
|
3006
3157
|
ORMapSyncInitSchema,
|
|
3007
3158
|
ORMapSyncRespRootSchema,
|
|
3008
3159
|
ORMapSyncRespBucketsSchema,
|
|
@@ -3011,23 +3162,18 @@ var MessageSchema = import_zod3.z.discriminatedUnion("type", [
|
|
|
3011
3162
|
ORMapDiffRequestSchema,
|
|
3012
3163
|
ORMapDiffResponseSchema,
|
|
3013
3164
|
ORMapPushDiffSchema,
|
|
3014
|
-
// Phase 4: Partition Map
|
|
3015
3165
|
PartitionMapRequestSchema,
|
|
3016
|
-
// Phase 5.2: PN Counter
|
|
3017
3166
|
CounterRequestSchema,
|
|
3018
3167
|
CounterSyncSchema,
|
|
3019
|
-
// Phase 5.03: Entry Processor
|
|
3020
3168
|
EntryProcessRequestSchema,
|
|
3021
3169
|
EntryProcessBatchRequestSchema,
|
|
3022
3170
|
EntryProcessResponseSchema,
|
|
3023
3171
|
EntryProcessBatchResponseSchema,
|
|
3024
|
-
// Phase 5.04: Event Journal
|
|
3025
3172
|
JournalSubscribeRequestSchema,
|
|
3026
3173
|
JournalUnsubscribeRequestSchema,
|
|
3027
3174
|
JournalEventMessageSchema,
|
|
3028
3175
|
JournalReadRequestSchema,
|
|
3029
3176
|
JournalReadResponseSchema,
|
|
3030
|
-
// Phase 5.05: Conflict Resolver
|
|
3031
3177
|
RegisterResolverRequestSchema,
|
|
3032
3178
|
RegisterResolverResponseSchema,
|
|
3033
3179
|
UnregisterResolverRequestSchema,
|
|
@@ -3035,101 +3181,16 @@ var MessageSchema = import_zod3.z.discriminatedUnion("type", [
|
|
|
3035
3181
|
MergeRejectedMessageSchema,
|
|
3036
3182
|
ListResolversRequestSchema,
|
|
3037
3183
|
ListResolversResponseSchema,
|
|
3038
|
-
// Phase 11.1: Full-Text Search
|
|
3039
3184
|
SearchMessageSchema,
|
|
3040
3185
|
SearchRespMessageSchema,
|
|
3041
|
-
// Phase 11.1b: Live Search Subscriptions
|
|
3042
3186
|
SearchSubMessageSchema,
|
|
3043
3187
|
SearchUpdateMessageSchema,
|
|
3044
3188
|
SearchUnsubMessageSchema,
|
|
3045
|
-
// Phase 14.2: Distributed Live Subscriptions (cluster-internal)
|
|
3046
3189
|
ClusterSubRegisterMessageSchema,
|
|
3047
3190
|
ClusterSubAckMessageSchema,
|
|
3048
3191
|
ClusterSubUpdateMessageSchema,
|
|
3049
3192
|
ClusterSubUnregisterMessageSchema
|
|
3050
3193
|
]);
|
|
3051
|
-
var ClusterSearchReqPayloadSchema = import_zod3.z.object({
|
|
3052
|
-
/** Unique request ID for correlation */
|
|
3053
|
-
requestId: import_zod3.z.string(),
|
|
3054
|
-
/** Map name to search */
|
|
3055
|
-
mapName: import_zod3.z.string(),
|
|
3056
|
-
/** Search query text */
|
|
3057
|
-
query: import_zod3.z.string(),
|
|
3058
|
-
/** Search options */
|
|
3059
|
-
options: import_zod3.z.object({
|
|
3060
|
-
/** Maximum results per node (for Top-K) */
|
|
3061
|
-
limit: import_zod3.z.number().int().positive().max(1e3),
|
|
3062
|
-
/** Minimum score threshold */
|
|
3063
|
-
minScore: import_zod3.z.number().optional(),
|
|
3064
|
-
/** Fields to boost */
|
|
3065
|
-
boost: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.number()).optional(),
|
|
3066
|
-
/** Include matched terms in response */
|
|
3067
|
-
includeMatchedTerms: import_zod3.z.boolean().optional(),
|
|
3068
|
-
/** For cursor-based pagination: return results after this score */
|
|
3069
|
-
afterScore: import_zod3.z.number().optional(),
|
|
3070
|
-
/** For cursor-based pagination: return results after this key (tie-breaking) */
|
|
3071
|
-
afterKey: import_zod3.z.string().optional()
|
|
3072
|
-
}),
|
|
3073
|
-
/** Timeout in milliseconds */
|
|
3074
|
-
timeoutMs: import_zod3.z.number().int().positive().optional()
|
|
3075
|
-
});
|
|
3076
|
-
var ClusterSearchReqMessageSchema = import_zod3.z.object({
|
|
3077
|
-
type: import_zod3.z.literal("CLUSTER_SEARCH_REQ"),
|
|
3078
|
-
payload: ClusterSearchReqPayloadSchema
|
|
3079
|
-
});
|
|
3080
|
-
var ClusterSearchRespPayloadSchema = import_zod3.z.object({
|
|
3081
|
-
/** Correlates to requestId */
|
|
3082
|
-
requestId: import_zod3.z.string(),
|
|
3083
|
-
/** Node that produced these results */
|
|
3084
|
-
nodeId: import_zod3.z.string(),
|
|
3085
|
-
/** Search results with scores */
|
|
3086
|
-
results: import_zod3.z.array(import_zod3.z.object({
|
|
3087
|
-
key: import_zod3.z.string(),
|
|
3088
|
-
value: import_zod3.z.unknown(),
|
|
3089
|
-
score: import_zod3.z.number(),
|
|
3090
|
-
matchedTerms: import_zod3.z.array(import_zod3.z.string()).optional()
|
|
3091
|
-
})),
|
|
3092
|
-
/** Total matching documents on this node (for pagination) */
|
|
3093
|
-
totalHits: import_zod3.z.number().int().nonnegative(),
|
|
3094
|
-
/** Execution time on this node in ms (for monitoring) */
|
|
3095
|
-
executionTimeMs: import_zod3.z.number().nonnegative(),
|
|
3096
|
-
/** Error if search failed on this node */
|
|
3097
|
-
error: import_zod3.z.string().optional()
|
|
3098
|
-
});
|
|
3099
|
-
var ClusterSearchRespMessageSchema = import_zod3.z.object({
|
|
3100
|
-
type: import_zod3.z.literal("CLUSTER_SEARCH_RESP"),
|
|
3101
|
-
payload: ClusterSearchRespPayloadSchema
|
|
3102
|
-
});
|
|
3103
|
-
var ClusterSearchSubscribePayloadSchema = import_zod3.z.object({
|
|
3104
|
-
subscriptionId: import_zod3.z.string(),
|
|
3105
|
-
mapName: import_zod3.z.string(),
|
|
3106
|
-
query: import_zod3.z.string(),
|
|
3107
|
-
options: SearchOptionsSchema.optional()
|
|
3108
|
-
});
|
|
3109
|
-
var ClusterSearchSubscribeMessageSchema = import_zod3.z.object({
|
|
3110
|
-
type: import_zod3.z.literal("CLUSTER_SEARCH_SUBSCRIBE"),
|
|
3111
|
-
payload: ClusterSearchSubscribePayloadSchema
|
|
3112
|
-
});
|
|
3113
|
-
var ClusterSearchUnsubscribePayloadSchema = import_zod3.z.object({
|
|
3114
|
-
subscriptionId: import_zod3.z.string()
|
|
3115
|
-
});
|
|
3116
|
-
var ClusterSearchUnsubscribeMessageSchema = import_zod3.z.object({
|
|
3117
|
-
type: import_zod3.z.literal("CLUSTER_SEARCH_UNSUBSCRIBE"),
|
|
3118
|
-
payload: ClusterSearchUnsubscribePayloadSchema
|
|
3119
|
-
});
|
|
3120
|
-
var ClusterSearchUpdatePayloadSchema = import_zod3.z.object({
|
|
3121
|
-
subscriptionId: import_zod3.z.string(),
|
|
3122
|
-
nodeId: import_zod3.z.string(),
|
|
3123
|
-
key: import_zod3.z.string(),
|
|
3124
|
-
value: import_zod3.z.unknown(),
|
|
3125
|
-
score: import_zod3.z.number(),
|
|
3126
|
-
matchedTerms: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
3127
|
-
type: SearchUpdateTypeSchema
|
|
3128
|
-
});
|
|
3129
|
-
var ClusterSearchUpdateMessageSchema = import_zod3.z.object({
|
|
3130
|
-
type: import_zod3.z.literal("CLUSTER_SEARCH_UPDATE"),
|
|
3131
|
-
payload: ClusterSearchUpdatePayloadSchema
|
|
3132
|
-
});
|
|
3133
3194
|
|
|
3134
3195
|
// src/types/WriteConcern.ts
|
|
3135
3196
|
var WriteConcern = /* @__PURE__ */ ((WriteConcern2) => {
|
|
@@ -6054,7 +6115,7 @@ var IndexRegistry = class {
|
|
|
6054
6115
|
constructor() {
|
|
6055
6116
|
/** Indexes grouped by attribute name */
|
|
6056
6117
|
this.attributeIndexes = /* @__PURE__ */ new Map();
|
|
6057
|
-
/** Compound indexes
|
|
6118
|
+
/** Compound indexes - keyed by sorted attribute names */
|
|
6058
6119
|
this.compoundIndexes = /* @__PURE__ */ new Map();
|
|
6059
6120
|
/** Fallback index for full scan (optional) */
|
|
6060
6121
|
this.fallbackIndex = null;
|
|
@@ -6081,7 +6142,7 @@ var IndexRegistry = class {
|
|
|
6081
6142
|
}
|
|
6082
6143
|
}
|
|
6083
6144
|
/**
|
|
6084
|
-
* Register a compound index
|
|
6145
|
+
* Register a compound index.
|
|
6085
6146
|
*
|
|
6086
6147
|
* @param index - Compound index to register
|
|
6087
6148
|
*/
|
|
@@ -6115,7 +6176,7 @@ var IndexRegistry = class {
|
|
|
6115
6176
|
return true;
|
|
6116
6177
|
}
|
|
6117
6178
|
/**
|
|
6118
|
-
* Remove a compound index
|
|
6179
|
+
* Remove a compound index.
|
|
6119
6180
|
*
|
|
6120
6181
|
* @param index - Compound index to remove
|
|
6121
6182
|
* @returns true if index was found and removed
|
|
@@ -6195,10 +6256,10 @@ var IndexRegistry = class {
|
|
|
6195
6256
|
return indexes.filter((index) => index.supportsQuery(queryType)).sort((a, b) => a.getRetrievalCost() - b.getRetrievalCost());
|
|
6196
6257
|
}
|
|
6197
6258
|
// ========================================
|
|
6198
|
-
//
|
|
6259
|
+
// Compound Index Methods
|
|
6199
6260
|
// ========================================
|
|
6200
6261
|
/**
|
|
6201
|
-
* Find a compound index that covers the given attribute names
|
|
6262
|
+
* Find a compound index that covers the given attribute names.
|
|
6202
6263
|
* The compound index must cover ALL the attributes (exact match or superset).
|
|
6203
6264
|
*
|
|
6204
6265
|
* @param attributeNames - Array of attribute names to search for
|
|
@@ -6216,7 +6277,7 @@ var IndexRegistry = class {
|
|
|
6216
6277
|
return null;
|
|
6217
6278
|
}
|
|
6218
6279
|
/**
|
|
6219
|
-
* Check if a compound index exists for the given attributes
|
|
6280
|
+
* Check if a compound index exists for the given attributes.
|
|
6220
6281
|
*
|
|
6221
6282
|
* @param attributeNames - Array of attribute names
|
|
6222
6283
|
* @returns true if a compound index exists
|
|
@@ -6225,7 +6286,7 @@ var IndexRegistry = class {
|
|
|
6225
6286
|
return this.findCompoundIndex(attributeNames) !== null;
|
|
6226
6287
|
}
|
|
6227
6288
|
/**
|
|
6228
|
-
* Get all compound indexes
|
|
6289
|
+
* Get all compound indexes.
|
|
6229
6290
|
*
|
|
6230
6291
|
* @returns Array of all compound indexes
|
|
6231
6292
|
*/
|
|
@@ -6363,22 +6424,15 @@ var QueryOptimizer = class {
|
|
|
6363
6424
|
/**
|
|
6364
6425
|
* Create a QueryOptimizer.
|
|
6365
6426
|
*
|
|
6366
|
-
* @param
|
|
6367
|
-
* @param standingQueryRegistry - Optional StandingQueryRegistry (deprecated, use options)
|
|
6427
|
+
* @param options - QueryOptimizer options
|
|
6368
6428
|
*/
|
|
6369
|
-
constructor(
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
this.fullTextIndexes = indexRegistryOrOptions.fullTextIndexes ?? /* @__PURE__ */ new Map();
|
|
6374
|
-
} else {
|
|
6375
|
-
this.indexRegistry = indexRegistryOrOptions;
|
|
6376
|
-
this.standingQueryRegistry = standingQueryRegistry;
|
|
6377
|
-
this.fullTextIndexes = /* @__PURE__ */ new Map();
|
|
6378
|
-
}
|
|
6429
|
+
constructor(options) {
|
|
6430
|
+
this.indexRegistry = options.indexRegistry;
|
|
6431
|
+
this.standingQueryRegistry = options.standingQueryRegistry;
|
|
6432
|
+
this.fullTextIndexes = options.fullTextIndexes ?? /* @__PURE__ */ new Map();
|
|
6379
6433
|
}
|
|
6380
6434
|
/**
|
|
6381
|
-
* Register a full-text index for a field
|
|
6435
|
+
* Register a full-text index for a field.
|
|
6382
6436
|
*
|
|
6383
6437
|
* @param field - Field name
|
|
6384
6438
|
* @param index - FullTextIndex instance
|
|
@@ -6387,7 +6441,7 @@ var QueryOptimizer = class {
|
|
|
6387
6441
|
this.fullTextIndexes.set(field, index);
|
|
6388
6442
|
}
|
|
6389
6443
|
/**
|
|
6390
|
-
* Unregister a full-text index
|
|
6444
|
+
* Unregister a full-text index.
|
|
6391
6445
|
*
|
|
6392
6446
|
* @param field - Field name
|
|
6393
6447
|
*/
|
|
@@ -6395,7 +6449,7 @@ var QueryOptimizer = class {
|
|
|
6395
6449
|
this.fullTextIndexes.delete(field);
|
|
6396
6450
|
}
|
|
6397
6451
|
/**
|
|
6398
|
-
* Get registered full-text index for a field
|
|
6452
|
+
* Get registered full-text index for a field.
|
|
6399
6453
|
*
|
|
6400
6454
|
* @param field - Field name
|
|
6401
6455
|
* @returns FullTextIndex or undefined
|
|
@@ -6404,7 +6458,7 @@ var QueryOptimizer = class {
|
|
|
6404
6458
|
return this.fullTextIndexes.get(field);
|
|
6405
6459
|
}
|
|
6406
6460
|
/**
|
|
6407
|
-
* Check if a full-text index exists for a field
|
|
6461
|
+
* Check if a full-text index exists for a field.
|
|
6408
6462
|
*
|
|
6409
6463
|
* @param field - Field name
|
|
6410
6464
|
* @returns True if FTS index exists
|
|
@@ -6477,7 +6531,7 @@ var QueryOptimizer = class {
|
|
|
6477
6531
|
sort: sortField && sortDirection ? { field: sortField, direction: sortDirection } : void 0,
|
|
6478
6532
|
limit: options.limit,
|
|
6479
6533
|
cursor: options.cursor
|
|
6480
|
-
//
|
|
6534
|
+
// replaces offset
|
|
6481
6535
|
};
|
|
6482
6536
|
}
|
|
6483
6537
|
/**
|
|
@@ -6495,7 +6549,7 @@ var QueryOptimizer = class {
|
|
|
6495
6549
|
}
|
|
6496
6550
|
}
|
|
6497
6551
|
/**
|
|
6498
|
-
* Optimize a full-text search query
|
|
6552
|
+
* Optimize a full-text search query.
|
|
6499
6553
|
*/
|
|
6500
6554
|
optimizeFTS(query) {
|
|
6501
6555
|
const field = query.attribute;
|
|
@@ -6505,7 +6559,7 @@ var QueryOptimizer = class {
|
|
|
6505
6559
|
return this.buildFTSScanStep(query);
|
|
6506
6560
|
}
|
|
6507
6561
|
/**
|
|
6508
|
-
* Build an FTS scan step from a query node
|
|
6562
|
+
* Build an FTS scan step from a query node.
|
|
6509
6563
|
*/
|
|
6510
6564
|
buildFTSScanStep(query) {
|
|
6511
6565
|
const field = query.attribute;
|
|
@@ -6545,7 +6599,7 @@ var QueryOptimizer = class {
|
|
|
6545
6599
|
}
|
|
6546
6600
|
}
|
|
6547
6601
|
/**
|
|
6548
|
-
* Estimate cost of FTS query based on index size
|
|
6602
|
+
* Estimate cost of FTS query based on index size.
|
|
6549
6603
|
*/
|
|
6550
6604
|
estimateFTSCost(field) {
|
|
6551
6605
|
const index = this.fullTextIndexes.get(field);
|
|
@@ -6556,7 +6610,7 @@ var QueryOptimizer = class {
|
|
|
6556
6610
|
return 50 + Math.log2(docCount + 1) * 10;
|
|
6557
6611
|
}
|
|
6558
6612
|
/**
|
|
6559
|
-
* Classify predicates by type for hybrid query planning
|
|
6613
|
+
* Classify predicates by type for hybrid query planning.
|
|
6560
6614
|
*
|
|
6561
6615
|
* @param predicates - Array of predicates to classify
|
|
6562
6616
|
* @returns Classified predicates
|
|
@@ -6597,7 +6651,7 @@ var QueryOptimizer = class {
|
|
|
6597
6651
|
return result;
|
|
6598
6652
|
}
|
|
6599
6653
|
/**
|
|
6600
|
-
* Determine fusion strategy based on step types
|
|
6654
|
+
* Determine fusion strategy based on step types.
|
|
6601
6655
|
*
|
|
6602
6656
|
* Strategy selection:
|
|
6603
6657
|
* - All binary (exact/range with no scores) → 'intersection'
|
|
@@ -6619,7 +6673,7 @@ var QueryOptimizer = class {
|
|
|
6619
6673
|
}
|
|
6620
6674
|
}
|
|
6621
6675
|
/**
|
|
6622
|
-
* Check if a plan step returns scored results
|
|
6676
|
+
* Check if a plan step returns scored results.
|
|
6623
6677
|
*/
|
|
6624
6678
|
stepReturnsScored(step) {
|
|
6625
6679
|
switch (step.type) {
|
|
@@ -6663,7 +6717,7 @@ var QueryOptimizer = class {
|
|
|
6663
6717
|
* Strategy: Find child with lowest cost, use as base, filter with rest.
|
|
6664
6718
|
*
|
|
6665
6719
|
* CQEngine "smallest first" strategy:
|
|
6666
|
-
* 1. Check for CompoundIndex covering all eq children
|
|
6720
|
+
* 1. Check for CompoundIndex covering all eq children
|
|
6667
6721
|
* 2. Sort children by merge cost
|
|
6668
6722
|
* 3. Use intersection if multiple indexes available
|
|
6669
6723
|
* 4. Apply remaining predicates as filters
|
|
@@ -6704,7 +6758,7 @@ var QueryOptimizer = class {
|
|
|
6704
6758
|
return { type: "intersection", steps: indexedSteps };
|
|
6705
6759
|
}
|
|
6706
6760
|
/**
|
|
6707
|
-
* Try to use a CompoundIndex for an AND query
|
|
6761
|
+
* Try to use a CompoundIndex for an AND query.
|
|
6708
6762
|
*
|
|
6709
6763
|
* Returns a compound index scan step if:
|
|
6710
6764
|
* 1. All children are simple 'eq' queries
|
|
@@ -6886,7 +6940,7 @@ var QueryOptimizer = class {
|
|
|
6886
6940
|
return this.estimateCost(step.source) + 10;
|
|
6887
6941
|
case "not":
|
|
6888
6942
|
return this.estimateCost(step.source) + 100;
|
|
6889
|
-
//
|
|
6943
|
+
// FTS step types
|
|
6890
6944
|
case "fts-scan":
|
|
6891
6945
|
return step.estimatedCost;
|
|
6892
6946
|
case "fusion":
|
|
@@ -6918,7 +6972,7 @@ var QueryOptimizer = class {
|
|
|
6918
6972
|
return this.usesIndexes(step.source);
|
|
6919
6973
|
case "not":
|
|
6920
6974
|
return this.usesIndexes(step.source);
|
|
6921
|
-
//
|
|
6975
|
+
// FTS step types
|
|
6922
6976
|
case "fts-scan":
|
|
6923
6977
|
return true;
|
|
6924
6978
|
// FTS uses FullTextIndex
|
|
@@ -7175,7 +7229,7 @@ var LiveQueryManager = class {
|
|
|
7175
7229
|
results: initialResults
|
|
7176
7230
|
});
|
|
7177
7231
|
} catch (error) {
|
|
7178
|
-
|
|
7232
|
+
logger.error({ err: error, query, context: "initial_callback" }, "LiveQueryManager initial callback error");
|
|
7179
7233
|
}
|
|
7180
7234
|
return () => {
|
|
7181
7235
|
callbacks?.delete(callback);
|
|
@@ -7274,7 +7328,7 @@ var LiveQueryManager = class {
|
|
|
7274
7328
|
newResultCount: index.getResultCount()
|
|
7275
7329
|
});
|
|
7276
7330
|
} catch (error) {
|
|
7277
|
-
|
|
7331
|
+
logger.error({ err: error, operation, context: "delta_callback" }, "LiveQueryManager callback error");
|
|
7278
7332
|
}
|
|
7279
7333
|
}
|
|
7280
7334
|
}
|
|
@@ -7409,7 +7463,7 @@ var QueryPatternTracker = class {
|
|
|
7409
7463
|
}
|
|
7410
7464
|
}
|
|
7411
7465
|
/**
|
|
7412
|
-
* Record a compound (AND) query execution for pattern tracking
|
|
7466
|
+
* Record a compound (AND) query execution for pattern tracking.
|
|
7413
7467
|
*
|
|
7414
7468
|
* @param attributes - Array of attribute names being queried together
|
|
7415
7469
|
* @param executionTime - Query execution time in milliseconds
|
|
@@ -7449,7 +7503,7 @@ var QueryPatternTracker = class {
|
|
|
7449
7503
|
}
|
|
7450
7504
|
}
|
|
7451
7505
|
/**
|
|
7452
|
-
* Get all compound query statistics
|
|
7506
|
+
* Get all compound query statistics.
|
|
7453
7507
|
*
|
|
7454
7508
|
* @returns Array of compound query statistics, sorted by query count descending
|
|
7455
7509
|
*/
|
|
@@ -7639,7 +7693,7 @@ var QueryPatternTracker = class {
|
|
|
7639
7693
|
}
|
|
7640
7694
|
}
|
|
7641
7695
|
/**
|
|
7642
|
-
* Evict the oldest compound query entry
|
|
7696
|
+
* Evict the oldest compound query entry.
|
|
7643
7697
|
*/
|
|
7644
7698
|
evictOldestCompound() {
|
|
7645
7699
|
let oldestKey = null;
|
|
@@ -7655,7 +7709,7 @@ var QueryPatternTracker = class {
|
|
|
7655
7709
|
}
|
|
7656
7710
|
}
|
|
7657
7711
|
/**
|
|
7658
|
-
* Prune stale compound statistics
|
|
7712
|
+
* Prune stale compound statistics.
|
|
7659
7713
|
*/
|
|
7660
7714
|
pruneStaleCompound() {
|
|
7661
7715
|
const cutoff = Date.now() - this.statsTtl;
|
|
@@ -7904,7 +7958,7 @@ var IndexAdvisor = class {
|
|
|
7904
7958
|
return reason;
|
|
7905
7959
|
}
|
|
7906
7960
|
// ========================================
|
|
7907
|
-
//
|
|
7961
|
+
// Compound Index Suggestions
|
|
7908
7962
|
// ========================================
|
|
7909
7963
|
/**
|
|
7910
7964
|
* Get compound index suggestions based on AND query patterns.
|
|
@@ -8225,7 +8279,7 @@ var AutoIndexManager = class {
|
|
|
8225
8279
|
this.tracker.updateIndexStatus(attributeName, true);
|
|
8226
8280
|
this.config.onIndexCreated(attributeName, indexType);
|
|
8227
8281
|
} catch (error) {
|
|
8228
|
-
|
|
8282
|
+
logger.error({ err: error, attributeName, indexType, context: "index_creation" }, `AutoIndexManager: Failed to create ${indexType} index on '${attributeName}'`);
|
|
8229
8283
|
}
|
|
8230
8284
|
}
|
|
8231
8285
|
};
|
|
@@ -9023,7 +9077,7 @@ var IndexedLWWMap = class extends LWWMap {
|
|
|
9023
9077
|
* Execute a query using indexes.
|
|
9024
9078
|
* Returns lazy ResultSet of matching keys.
|
|
9025
9079
|
*
|
|
9026
|
-
* Also tracks query patterns for adaptive indexing
|
|
9080
|
+
* Also tracks query patterns for adaptive indexing.
|
|
9027
9081
|
*
|
|
9028
9082
|
* @param query - Query to execute
|
|
9029
9083
|
* @returns ResultSet of matching keys
|
|
@@ -9392,7 +9446,7 @@ var IndexedLWWMap = class extends LWWMap {
|
|
|
9392
9446
|
explainQuery(query) {
|
|
9393
9447
|
return this.queryOptimizer.optimize(query);
|
|
9394
9448
|
}
|
|
9395
|
-
// ==================== Adaptive Indexing
|
|
9449
|
+
// ==================== Adaptive Indexing ====================
|
|
9396
9450
|
/**
|
|
9397
9451
|
* Register an attribute for auto-indexing.
|
|
9398
9452
|
* Required before auto-index can create indexes on this attribute.
|
|
@@ -9474,7 +9528,7 @@ var IndexedLWWMap = class extends LWWMap {
|
|
|
9474
9528
|
isAutoIndexingEnabled() {
|
|
9475
9529
|
return this.autoIndexManager !== null;
|
|
9476
9530
|
}
|
|
9477
|
-
// ==================== Lazy Indexing
|
|
9531
|
+
// ==================== Lazy Indexing ====================
|
|
9478
9532
|
/**
|
|
9479
9533
|
* Check if lazy index building is enabled.
|
|
9480
9534
|
*/
|
|
@@ -10679,7 +10733,7 @@ var FullTextIndex = class {
|
|
|
10679
10733
|
var IndexedORMap = class extends ORMap {
|
|
10680
10734
|
constructor(hlc, options = {}) {
|
|
10681
10735
|
super(hlc);
|
|
10682
|
-
// Full-Text Search
|
|
10736
|
+
// Full-Text Search
|
|
10683
10737
|
this.fullTextIndex = null;
|
|
10684
10738
|
this.options = options;
|
|
10685
10739
|
this.indexRegistry = new IndexRegistry();
|
|
@@ -10761,7 +10815,7 @@ var IndexedORMap = class extends ORMap {
|
|
|
10761
10815
|
this.indexRegistry.addIndex(index);
|
|
10762
10816
|
this.buildIndexFromExisting(index);
|
|
10763
10817
|
}
|
|
10764
|
-
// ==================== Full-Text Search
|
|
10818
|
+
// ==================== Full-Text Search ====================
|
|
10765
10819
|
/**
|
|
10766
10820
|
* Enable BM25-based full-text search on specified fields.
|
|
10767
10821
|
* This creates a FullTextIndex for relevance-ranked search.
|
|
@@ -10904,7 +10958,7 @@ var IndexedORMap = class extends ORMap {
|
|
|
10904
10958
|
* Execute a query across all records.
|
|
10905
10959
|
* Returns array of matching results with key, tag, and value.
|
|
10906
10960
|
*
|
|
10907
|
-
* Also tracks query patterns for adaptive indexing
|
|
10961
|
+
* Also tracks query patterns for adaptive indexing.
|
|
10908
10962
|
*
|
|
10909
10963
|
* @param query - Query to execute
|
|
10910
10964
|
* @returns Array of query results
|
|
@@ -11270,7 +11324,7 @@ var IndexedORMap = class extends ORMap {
|
|
|
11270
11324
|
explainQuery(query) {
|
|
11271
11325
|
return this.queryOptimizer.optimize(query);
|
|
11272
11326
|
}
|
|
11273
|
-
// ==================== Adaptive Indexing
|
|
11327
|
+
// ==================== Adaptive Indexing ====================
|
|
11274
11328
|
/**
|
|
11275
11329
|
* Register an attribute for auto-indexing.
|
|
11276
11330
|
* Required before auto-index can create indexes on this attribute.
|
|
@@ -11603,13 +11657,557 @@ var SearchCursor = class {
|
|
|
11603
11657
|
};
|
|
11604
11658
|
}
|
|
11605
11659
|
};
|
|
11660
|
+
|
|
11661
|
+
// src/debug/CRDTDebugger.ts
|
|
11662
|
+
var CRDTDebugger = class {
|
|
11663
|
+
constructor(options = {}) {
|
|
11664
|
+
this.snapshots = [];
|
|
11665
|
+
this.conflicts = [];
|
|
11666
|
+
this.idCounter = 0;
|
|
11667
|
+
this.maxSnapshots = options.maxSnapshots || 1e4;
|
|
11668
|
+
this.enabled = options.enabled ?? process.env.TOPGUN_DEBUG === "true";
|
|
11669
|
+
}
|
|
11670
|
+
// ============================================================================
|
|
11671
|
+
// Recording Control
|
|
11672
|
+
// ============================================================================
|
|
11673
|
+
isEnabled() {
|
|
11674
|
+
return this.enabled;
|
|
11675
|
+
}
|
|
11676
|
+
enable() {
|
|
11677
|
+
this.enabled = true;
|
|
11678
|
+
}
|
|
11679
|
+
disable() {
|
|
11680
|
+
this.enabled = false;
|
|
11681
|
+
}
|
|
11682
|
+
// ============================================================================
|
|
11683
|
+
// Operation Recording
|
|
11684
|
+
// ============================================================================
|
|
11685
|
+
recordOperation(snapshot) {
|
|
11686
|
+
if (!this.enabled) return;
|
|
11687
|
+
this.snapshots.push({
|
|
11688
|
+
...snapshot,
|
|
11689
|
+
id: `op-${++this.idCounter}`
|
|
11690
|
+
});
|
|
11691
|
+
if (this.snapshots.length > this.maxSnapshots) {
|
|
11692
|
+
this.snapshots = this.snapshots.slice(-this.maxSnapshots);
|
|
11693
|
+
}
|
|
11694
|
+
}
|
|
11695
|
+
recordSet(mapId, key, value, timestamp, nodeId, oldValue, merkleRoot) {
|
|
11696
|
+
this.recordOperation({
|
|
11697
|
+
timestamp,
|
|
11698
|
+
operation: "set",
|
|
11699
|
+
mapId,
|
|
11700
|
+
key,
|
|
11701
|
+
value,
|
|
11702
|
+
oldValue,
|
|
11703
|
+
nodeId,
|
|
11704
|
+
merkleRoot
|
|
11705
|
+
});
|
|
11706
|
+
}
|
|
11707
|
+
recordDelete(mapId, key, timestamp, nodeId, oldValue, merkleRoot) {
|
|
11708
|
+
this.recordOperation({
|
|
11709
|
+
timestamp,
|
|
11710
|
+
operation: "delete",
|
|
11711
|
+
mapId,
|
|
11712
|
+
key,
|
|
11713
|
+
oldValue,
|
|
11714
|
+
nodeId,
|
|
11715
|
+
merkleRoot
|
|
11716
|
+
});
|
|
11717
|
+
}
|
|
11718
|
+
recordMerge(mapId, key, value, timestamp, nodeId, wasUpdated, oldValue, merkleRoot) {
|
|
11719
|
+
this.recordOperation({
|
|
11720
|
+
timestamp,
|
|
11721
|
+
operation: "merge",
|
|
11722
|
+
mapId,
|
|
11723
|
+
key,
|
|
11724
|
+
value,
|
|
11725
|
+
oldValue,
|
|
11726
|
+
nodeId,
|
|
11727
|
+
merkleRoot,
|
|
11728
|
+
metadata: { wasUpdated }
|
|
11729
|
+
});
|
|
11730
|
+
}
|
|
11731
|
+
recordConflict(conflict) {
|
|
11732
|
+
if (!this.enabled) return;
|
|
11733
|
+
this.conflicts.push(conflict);
|
|
11734
|
+
}
|
|
11735
|
+
// ============================================================================
|
|
11736
|
+
// Querying
|
|
11737
|
+
// ============================================================================
|
|
11738
|
+
getOperations(options = {}) {
|
|
11739
|
+
let results = this.snapshots;
|
|
11740
|
+
if (options.mapId) {
|
|
11741
|
+
results = results.filter((s) => s.mapId === options.mapId);
|
|
11742
|
+
}
|
|
11743
|
+
if (options.nodeId) {
|
|
11744
|
+
results = results.filter((s) => s.nodeId === options.nodeId);
|
|
11745
|
+
}
|
|
11746
|
+
if (options.operation) {
|
|
11747
|
+
results = results.filter((s) => s.operation === options.operation);
|
|
11748
|
+
}
|
|
11749
|
+
if (options.since) {
|
|
11750
|
+
results = results.filter(
|
|
11751
|
+
(s) => this.compareTimestamp(s.timestamp, options.since) >= 0
|
|
11752
|
+
);
|
|
11753
|
+
}
|
|
11754
|
+
if (options.until) {
|
|
11755
|
+
results = results.filter(
|
|
11756
|
+
(s) => this.compareTimestamp(s.timestamp, options.until) <= 0
|
|
11757
|
+
);
|
|
11758
|
+
}
|
|
11759
|
+
if (options.limit) {
|
|
11760
|
+
results = results.slice(-options.limit);
|
|
11761
|
+
}
|
|
11762
|
+
return results;
|
|
11763
|
+
}
|
|
11764
|
+
getConflicts(mapId) {
|
|
11765
|
+
if (mapId) {
|
|
11766
|
+
return this.conflicts.filter((c) => c.mapId === mapId);
|
|
11767
|
+
}
|
|
11768
|
+
return this.conflicts;
|
|
11769
|
+
}
|
|
11770
|
+
getLastOperation() {
|
|
11771
|
+
return this.snapshots[this.snapshots.length - 1];
|
|
11772
|
+
}
|
|
11773
|
+
getOperationsForKey(mapId, key) {
|
|
11774
|
+
return this.snapshots.filter((s) => s.mapId === mapId && s.key === key);
|
|
11775
|
+
}
|
|
11776
|
+
// ============================================================================
|
|
11777
|
+
// Statistics
|
|
11778
|
+
// ============================================================================
|
|
11779
|
+
getStatistics(mapId) {
|
|
11780
|
+
const ops = mapId ? this.snapshots.filter((s) => s.mapId === mapId) : this.snapshots;
|
|
11781
|
+
const operationsByType = {};
|
|
11782
|
+
const operationsByNode = {};
|
|
11783
|
+
const uniqueKeys = /* @__PURE__ */ new Set();
|
|
11784
|
+
for (const op of ops) {
|
|
11785
|
+
operationsByType[op.operation] = (operationsByType[op.operation] || 0) + 1;
|
|
11786
|
+
operationsByNode[op.nodeId] = (operationsByNode[op.nodeId] || 0) + 1;
|
|
11787
|
+
if (op.key) uniqueKeys.add(op.key);
|
|
11788
|
+
}
|
|
11789
|
+
const timeRange = {
|
|
11790
|
+
start: ops.length > 0 ? ops[0].timestamp : null,
|
|
11791
|
+
end: ops.length > 0 ? ops[ops.length - 1].timestamp : null
|
|
11792
|
+
};
|
|
11793
|
+
let avgOpsPerSecond = 0;
|
|
11794
|
+
if (timeRange.start && timeRange.end) {
|
|
11795
|
+
const durationMs = timeRange.end.millis - timeRange.start.millis;
|
|
11796
|
+
if (durationMs > 0) {
|
|
11797
|
+
avgOpsPerSecond = ops.length / durationMs * 1e3;
|
|
11798
|
+
}
|
|
11799
|
+
}
|
|
11800
|
+
return {
|
|
11801
|
+
totalOperations: ops.length,
|
|
11802
|
+
operationsByType,
|
|
11803
|
+
operationsByNode,
|
|
11804
|
+
conflictsResolved: this.conflicts.length,
|
|
11805
|
+
timeRange,
|
|
11806
|
+
uniqueKeys: uniqueKeys.size,
|
|
11807
|
+
averageOpsPerSecond: avgOpsPerSecond
|
|
11808
|
+
};
|
|
11809
|
+
}
|
|
11810
|
+
// ============================================================================
|
|
11811
|
+
// Replay
|
|
11812
|
+
// ============================================================================
|
|
11813
|
+
/**
|
|
11814
|
+
* Replays operations up to the target timestamp and returns the map state.
|
|
11815
|
+
*/
|
|
11816
|
+
replayUntil(targetTimestamp, mapId, hlc) {
|
|
11817
|
+
const map = new LWWMap(hlc || new HLC("replay-node"));
|
|
11818
|
+
const ops = this.getOperations({ mapId, until: targetTimestamp });
|
|
11819
|
+
for (const op of ops) {
|
|
11820
|
+
if (op.operation === "set" && op.key !== void 0) {
|
|
11821
|
+
const record = {
|
|
11822
|
+
value: op.value,
|
|
11823
|
+
timestamp: op.timestamp
|
|
11824
|
+
};
|
|
11825
|
+
map.merge(op.key, record);
|
|
11826
|
+
} else if (op.operation === "delete" && op.key !== void 0) {
|
|
11827
|
+
const record = {
|
|
11828
|
+
value: null,
|
|
11829
|
+
timestamp: op.timestamp
|
|
11830
|
+
};
|
|
11831
|
+
map.merge(op.key, record);
|
|
11832
|
+
} else if (op.operation === "merge" && op.key !== void 0) {
|
|
11833
|
+
const record = {
|
|
11834
|
+
value: op.value,
|
|
11835
|
+
timestamp: op.timestamp
|
|
11836
|
+
};
|
|
11837
|
+
map.merge(op.key, record);
|
|
11838
|
+
}
|
|
11839
|
+
}
|
|
11840
|
+
return map;
|
|
11841
|
+
}
|
|
11842
|
+
/**
|
|
11843
|
+
* Creates a timeline of operations grouped by time intervals.
|
|
11844
|
+
*/
|
|
11845
|
+
getTimeline(intervalMs = 1e3, mapId) {
|
|
11846
|
+
const ops = mapId ? this.snapshots.filter((s) => s.mapId === mapId) : this.snapshots;
|
|
11847
|
+
if (ops.length === 0) return [];
|
|
11848
|
+
const timeline = [];
|
|
11849
|
+
let currentBucket = [];
|
|
11850
|
+
let bucketStart = Math.floor(ops[0].timestamp.millis / intervalMs) * intervalMs;
|
|
11851
|
+
for (const op of ops) {
|
|
11852
|
+
const opBucket = Math.floor(op.timestamp.millis / intervalMs) * intervalMs;
|
|
11853
|
+
if (opBucket !== bucketStart) {
|
|
11854
|
+
if (currentBucket.length > 0) {
|
|
11855
|
+
timeline.push({ timestamp: bucketStart, operations: currentBucket });
|
|
11856
|
+
}
|
|
11857
|
+
currentBucket = [];
|
|
11858
|
+
bucketStart = opBucket;
|
|
11859
|
+
}
|
|
11860
|
+
currentBucket.push(op);
|
|
11861
|
+
}
|
|
11862
|
+
if (currentBucket.length > 0) {
|
|
11863
|
+
timeline.push({ timestamp: bucketStart, operations: currentBucket });
|
|
11864
|
+
}
|
|
11865
|
+
return timeline;
|
|
11866
|
+
}
|
|
11867
|
+
// ============================================================================
|
|
11868
|
+
// Export / Import
|
|
11869
|
+
// ============================================================================
|
|
11870
|
+
exportHistory(format = "json") {
|
|
11871
|
+
switch (format) {
|
|
11872
|
+
case "csv":
|
|
11873
|
+
return this.toCSV();
|
|
11874
|
+
case "ndjson":
|
|
11875
|
+
return this.snapshots.map((s) => JSON.stringify(s)).join("\n");
|
|
11876
|
+
default:
|
|
11877
|
+
return JSON.stringify(
|
|
11878
|
+
{
|
|
11879
|
+
version: "1.0",
|
|
11880
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11881
|
+
statistics: this.getStatistics(),
|
|
11882
|
+
operations: this.snapshots,
|
|
11883
|
+
conflicts: this.conflicts
|
|
11884
|
+
},
|
|
11885
|
+
null,
|
|
11886
|
+
2
|
|
11887
|
+
);
|
|
11888
|
+
}
|
|
11889
|
+
}
|
|
11890
|
+
toCSV() {
|
|
11891
|
+
const header = "id,timestamp_millis,timestamp_counter,operation,map_id,key,node_id,merkle_root\n";
|
|
11892
|
+
const rows = this.snapshots.map(
|
|
11893
|
+
(s) => `${s.id},${s.timestamp.millis},${s.timestamp.counter},${s.operation},${s.mapId},${s.key || ""},${s.nodeId},${s.merkleRoot || ""}`
|
|
11894
|
+
).join("\n");
|
|
11895
|
+
return header + rows;
|
|
11896
|
+
}
|
|
11897
|
+
importHistory(json) {
|
|
11898
|
+
const data = JSON.parse(json);
|
|
11899
|
+
if (data.version === "1.0") {
|
|
11900
|
+
this.snapshots = data.operations || [];
|
|
11901
|
+
this.conflicts = data.conflicts || [];
|
|
11902
|
+
const maxId = this.snapshots.reduce((max, s) => {
|
|
11903
|
+
const num = parseInt(s.id.replace("op-", ""), 10);
|
|
11904
|
+
return isNaN(num) ? max : Math.max(max, num);
|
|
11905
|
+
}, 0);
|
|
11906
|
+
this.idCounter = maxId;
|
|
11907
|
+
} else {
|
|
11908
|
+
throw new Error(
|
|
11909
|
+
'Unsupported history format. Expected v1.0 format with { version: "1.0", operations: [...], conflicts: [...] }. Legacy array format is no longer supported.'
|
|
11910
|
+
);
|
|
11911
|
+
}
|
|
11912
|
+
}
|
|
11913
|
+
// ============================================================================
|
|
11914
|
+
// Diff
|
|
11915
|
+
// ============================================================================
|
|
11916
|
+
/**
|
|
11917
|
+
* Compares two points in time and returns the differences.
|
|
11918
|
+
*/
|
|
11919
|
+
diff(fromTimestamp, toTimestamp, mapId) {
|
|
11920
|
+
const fromOps = this.getOperations({ mapId, until: fromTimestamp });
|
|
11921
|
+
const toOps = this.getOperations({ mapId, until: toTimestamp });
|
|
11922
|
+
const fromState = /* @__PURE__ */ new Map();
|
|
11923
|
+
const toState = /* @__PURE__ */ new Map();
|
|
11924
|
+
for (const op of fromOps) {
|
|
11925
|
+
if (op.key) {
|
|
11926
|
+
fromState.set(`${op.mapId}:${op.key}`, op);
|
|
11927
|
+
}
|
|
11928
|
+
}
|
|
11929
|
+
for (const op of toOps) {
|
|
11930
|
+
if (op.key) {
|
|
11931
|
+
toState.set(`${op.mapId}:${op.key}`, op);
|
|
11932
|
+
}
|
|
11933
|
+
}
|
|
11934
|
+
const added = [];
|
|
11935
|
+
const modified = [];
|
|
11936
|
+
const deleted = [];
|
|
11937
|
+
for (const [key, toOp] of toState) {
|
|
11938
|
+
const fromOp = fromState.get(key);
|
|
11939
|
+
if (!fromOp) {
|
|
11940
|
+
if (toOp.operation !== "delete") {
|
|
11941
|
+
added.push(toOp);
|
|
11942
|
+
}
|
|
11943
|
+
} else if (toOp.operation === "delete" && fromOp.operation !== "delete") {
|
|
11944
|
+
deleted.push(toOp);
|
|
11945
|
+
} else if (toOp.operation !== "delete" && JSON.stringify(toOp.value) !== JSON.stringify(fromOp.value)) {
|
|
11946
|
+
modified.push(toOp);
|
|
11947
|
+
}
|
|
11948
|
+
}
|
|
11949
|
+
return { added, modified, deleted };
|
|
11950
|
+
}
|
|
11951
|
+
// ============================================================================
|
|
11952
|
+
// Utilities
|
|
11953
|
+
// ============================================================================
|
|
11954
|
+
clear() {
|
|
11955
|
+
this.snapshots = [];
|
|
11956
|
+
this.conflicts = [];
|
|
11957
|
+
this.idCounter = 0;
|
|
11958
|
+
}
|
|
11959
|
+
compareTimestamp(a, b) {
|
|
11960
|
+
if (a.millis !== b.millis) return a.millis - b.millis;
|
|
11961
|
+
if (a.counter !== b.counter) return a.counter - b.counter;
|
|
11962
|
+
return a.nodeId.localeCompare(b.nodeId);
|
|
11963
|
+
}
|
|
11964
|
+
};
|
|
11965
|
+
var globalDebugger = null;
|
|
11966
|
+
function getCRDTDebugger() {
|
|
11967
|
+
if (!globalDebugger) {
|
|
11968
|
+
globalDebugger = new CRDTDebugger();
|
|
11969
|
+
}
|
|
11970
|
+
return globalDebugger;
|
|
11971
|
+
}
|
|
11972
|
+
function resetCRDTDebugger() {
|
|
11973
|
+
globalDebugger = null;
|
|
11974
|
+
}
|
|
11975
|
+
|
|
11976
|
+
// src/debug/SearchDebugger.ts
|
|
11977
|
+
var SearchDebugger = class {
|
|
11978
|
+
constructor(options = {}) {
|
|
11979
|
+
this.lastQuery = null;
|
|
11980
|
+
this.history = [];
|
|
11981
|
+
this.enabled = options.enabled ?? process.env.TOPGUN_DEBUG === "true";
|
|
11982
|
+
this.maxHistory = options.maxHistory || 100;
|
|
11983
|
+
}
|
|
11984
|
+
// ============================================================================
|
|
11985
|
+
// Control
|
|
11986
|
+
// ============================================================================
|
|
11987
|
+
isEnabled() {
|
|
11988
|
+
return this.enabled;
|
|
11989
|
+
}
|
|
11990
|
+
enable() {
|
|
11991
|
+
this.enabled = true;
|
|
11992
|
+
}
|
|
11993
|
+
disable() {
|
|
11994
|
+
this.enabled = false;
|
|
11995
|
+
}
|
|
11996
|
+
// ============================================================================
|
|
11997
|
+
// Recording
|
|
11998
|
+
// ============================================================================
|
|
11999
|
+
recordSearch(debugInfo) {
|
|
12000
|
+
if (!this.enabled) return;
|
|
12001
|
+
this.lastQuery = debugInfo;
|
|
12002
|
+
this.history.push(debugInfo);
|
|
12003
|
+
if (this.history.length > this.maxHistory) {
|
|
12004
|
+
this.history = this.history.slice(-this.maxHistory);
|
|
12005
|
+
}
|
|
12006
|
+
}
|
|
12007
|
+
// ============================================================================
|
|
12008
|
+
// Querying
|
|
12009
|
+
// ============================================================================
|
|
12010
|
+
getLastQuery() {
|
|
12011
|
+
return this.lastQuery;
|
|
12012
|
+
}
|
|
12013
|
+
getHistory() {
|
|
12014
|
+
return this.history;
|
|
12015
|
+
}
|
|
12016
|
+
getHistoryByMap(mapId) {
|
|
12017
|
+
return this.history.filter((q) => q.mapId === mapId);
|
|
12018
|
+
}
|
|
12019
|
+
explainResult(docId) {
|
|
12020
|
+
return this.lastQuery?.results.find((r) => r.docId === docId);
|
|
12021
|
+
}
|
|
12022
|
+
// ============================================================================
|
|
12023
|
+
// Formatting
|
|
12024
|
+
// ============================================================================
|
|
12025
|
+
formatExplanation(docId) {
|
|
12026
|
+
const result = this.explainResult(docId);
|
|
12027
|
+
if (!result) return "No debug info available for this document.";
|
|
12028
|
+
const lines = [];
|
|
12029
|
+
lines.push(`Score Breakdown for ${docId}`);
|
|
12030
|
+
lines.push(`Final Score: ${result.finalScore.toFixed(4)}`);
|
|
12031
|
+
lines.push("");
|
|
12032
|
+
if (result.scoreBreakdown.bm25) {
|
|
12033
|
+
const bm25 = result.scoreBreakdown.bm25;
|
|
12034
|
+
lines.push("BM25 Full-Text Search:");
|
|
12035
|
+
lines.push(` Score: ${bm25.score.toFixed(4)}`);
|
|
12036
|
+
lines.push(
|
|
12037
|
+
` Document length: ${bm25.docLength} (avg: ${bm25.avgDocLength.toFixed(1)})`
|
|
12038
|
+
);
|
|
12039
|
+
lines.push(` Parameters: k1=${bm25.k1}, b=${bm25.b}`);
|
|
12040
|
+
lines.push(" Term contributions:");
|
|
12041
|
+
for (const term of bm25.matchedTerms) {
|
|
12042
|
+
const tf = bm25.tf[term] || 0;
|
|
12043
|
+
const idf = bm25.idf[term] || 0;
|
|
12044
|
+
const contribution = tf * idf;
|
|
12045
|
+
lines.push(
|
|
12046
|
+
` "${term}": TF=${tf.toFixed(3)}, IDF=${idf.toFixed(3)}, contribution=${contribution.toFixed(4)}`
|
|
12047
|
+
);
|
|
12048
|
+
}
|
|
12049
|
+
lines.push("");
|
|
12050
|
+
}
|
|
12051
|
+
if (result.scoreBreakdown.exact) {
|
|
12052
|
+
const exact = result.scoreBreakdown.exact;
|
|
12053
|
+
lines.push("Exact Match:");
|
|
12054
|
+
lines.push(` Score: ${exact.score.toFixed(4)}`);
|
|
12055
|
+
lines.push(` Matched fields: ${exact.matchedFields.join(", ")}`);
|
|
12056
|
+
lines.push(` Boost applied: ${exact.boostApplied}x`);
|
|
12057
|
+
lines.push("");
|
|
12058
|
+
}
|
|
12059
|
+
if (result.scoreBreakdown.rrf) {
|
|
12060
|
+
const rrf = result.scoreBreakdown.rrf;
|
|
12061
|
+
lines.push("Reciprocal Rank Fusion (RRF):");
|
|
12062
|
+
lines.push(` Final rank: ${rrf.rank}`);
|
|
12063
|
+
lines.push(` RRF score: ${rrf.score.toFixed(4)}`);
|
|
12064
|
+
lines.push(` k parameter: ${rrf.k}`);
|
|
12065
|
+
lines.push(" Contributing ranks:");
|
|
12066
|
+
for (const contrib of rrf.contributingRanks) {
|
|
12067
|
+
lines.push(` ${contrib.source}: rank ${contrib.rank}`);
|
|
12068
|
+
}
|
|
12069
|
+
lines.push("");
|
|
12070
|
+
}
|
|
12071
|
+
if (result.scoreBreakdown.vector) {
|
|
12072
|
+
const vector = result.scoreBreakdown.vector;
|
|
12073
|
+
lines.push("Vector Similarity:");
|
|
12074
|
+
lines.push(` Score: ${vector.score.toFixed(4)}`);
|
|
12075
|
+
lines.push(` Distance: ${vector.distance.toFixed(4)}`);
|
|
12076
|
+
lines.push(` Metric: ${vector.similarity}`);
|
|
12077
|
+
lines.push("");
|
|
12078
|
+
}
|
|
12079
|
+
return lines.join("\n");
|
|
12080
|
+
}
|
|
12081
|
+
formatQuerySummary() {
|
|
12082
|
+
if (!this.lastQuery) return "No query recorded.";
|
|
12083
|
+
const q = this.lastQuery;
|
|
12084
|
+
const lines = [];
|
|
12085
|
+
lines.push(`Query: "${q.query}"`);
|
|
12086
|
+
lines.push(`Tokens: ${q.queryTokens.join(", ")}`);
|
|
12087
|
+
lines.push(`Type: ${q.searchType}`);
|
|
12088
|
+
lines.push(`Results: ${q.matchingDocuments} of ${q.totalDocuments} documents`);
|
|
12089
|
+
lines.push("");
|
|
12090
|
+
lines.push("Timing:");
|
|
12091
|
+
lines.push(` Tokenization: ${q.timing.tokenization.toFixed(2)}ms`);
|
|
12092
|
+
lines.push(` Index lookup: ${q.timing.indexLookup.toFixed(2)}ms`);
|
|
12093
|
+
lines.push(` Scoring: ${q.timing.scoring.toFixed(2)}ms`);
|
|
12094
|
+
lines.push(` Ranking: ${q.timing.ranking.toFixed(2)}ms`);
|
|
12095
|
+
if (q.timing.fusion !== void 0) {
|
|
12096
|
+
lines.push(` Fusion: ${q.timing.fusion.toFixed(2)}ms`);
|
|
12097
|
+
}
|
|
12098
|
+
lines.push(` Total: ${q.timing.total.toFixed(2)}ms`);
|
|
12099
|
+
lines.push("");
|
|
12100
|
+
lines.push("Index stats:");
|
|
12101
|
+
lines.push(` Type: ${q.indexStats.indexType}`);
|
|
12102
|
+
lines.push(` Size: ${q.indexStats.indexSize} entries`);
|
|
12103
|
+
lines.push(` Terms searched: ${q.indexStats.termsSearched}`);
|
|
12104
|
+
return lines.join("\n");
|
|
12105
|
+
}
|
|
12106
|
+
formatAllResults() {
|
|
12107
|
+
if (!this.lastQuery) return "No query recorded.";
|
|
12108
|
+
const lines = [];
|
|
12109
|
+
lines.push(this.formatQuerySummary());
|
|
12110
|
+
lines.push("");
|
|
12111
|
+
lines.push("Results:");
|
|
12112
|
+
lines.push("");
|
|
12113
|
+
for (let i = 0; i < this.lastQuery.results.length; i++) {
|
|
12114
|
+
const result = this.lastQuery.results[i];
|
|
12115
|
+
lines.push(`${i + 1}. ${result.docId}`);
|
|
12116
|
+
lines.push(` Final score: ${result.finalScore.toFixed(4)}`);
|
|
12117
|
+
if (result.scoreBreakdown.bm25) {
|
|
12118
|
+
const bm25 = result.scoreBreakdown.bm25;
|
|
12119
|
+
lines.push(` BM25: ${bm25.score.toFixed(4)}`);
|
|
12120
|
+
const topTerms = bm25.matchedTerms.slice(0, 3);
|
|
12121
|
+
for (const term of topTerms) {
|
|
12122
|
+
lines.push(
|
|
12123
|
+
` - "${term}": TF=${bm25.tf[term]?.toFixed(3)}, IDF=${bm25.idf[term]?.toFixed(3)}`
|
|
12124
|
+
);
|
|
12125
|
+
}
|
|
12126
|
+
}
|
|
12127
|
+
if (result.scoreBreakdown.exact) {
|
|
12128
|
+
lines.push(
|
|
12129
|
+
` Exact: ${result.scoreBreakdown.exact.score.toFixed(4)} (${result.scoreBreakdown.exact.matchedFields.join(", ")})`
|
|
12130
|
+
);
|
|
12131
|
+
}
|
|
12132
|
+
if (result.scoreBreakdown.rrf) {
|
|
12133
|
+
lines.push(` RRF rank: ${result.scoreBreakdown.rrf.rank}`);
|
|
12134
|
+
}
|
|
12135
|
+
lines.push("");
|
|
12136
|
+
}
|
|
12137
|
+
return lines.join("\n");
|
|
12138
|
+
}
|
|
12139
|
+
// ============================================================================
|
|
12140
|
+
// Export
|
|
12141
|
+
// ============================================================================
|
|
12142
|
+
exportDebugInfo() {
|
|
12143
|
+
return JSON.stringify(this.lastQuery, null, 2);
|
|
12144
|
+
}
|
|
12145
|
+
exportHistory() {
|
|
12146
|
+
return JSON.stringify(
|
|
12147
|
+
{
|
|
12148
|
+
version: "1.0",
|
|
12149
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12150
|
+
queryCount: this.history.length,
|
|
12151
|
+
queries: this.history
|
|
12152
|
+
},
|
|
12153
|
+
null,
|
|
12154
|
+
2
|
|
12155
|
+
);
|
|
12156
|
+
}
|
|
12157
|
+
// ============================================================================
|
|
12158
|
+
// Analysis
|
|
12159
|
+
// ============================================================================
|
|
12160
|
+
getSearchStats() {
|
|
12161
|
+
if (this.history.length === 0) {
|
|
12162
|
+
return {
|
|
12163
|
+
totalQueries: 0,
|
|
12164
|
+
averageResultCount: 0,
|
|
12165
|
+
averageLatencyMs: 0,
|
|
12166
|
+
queryTypeBreakdown: {}
|
|
12167
|
+
};
|
|
12168
|
+
}
|
|
12169
|
+
const queryTypeBreakdown = {};
|
|
12170
|
+
let totalResults = 0;
|
|
12171
|
+
let totalLatency = 0;
|
|
12172
|
+
for (const q of this.history) {
|
|
12173
|
+
queryTypeBreakdown[q.searchType] = (queryTypeBreakdown[q.searchType] || 0) + 1;
|
|
12174
|
+
totalResults += q.matchingDocuments;
|
|
12175
|
+
totalLatency += q.timing.total;
|
|
12176
|
+
}
|
|
12177
|
+
return {
|
|
12178
|
+
totalQueries: this.history.length,
|
|
12179
|
+
averageResultCount: totalResults / this.history.length,
|
|
12180
|
+
averageLatencyMs: totalLatency / this.history.length,
|
|
12181
|
+
queryTypeBreakdown
|
|
12182
|
+
};
|
|
12183
|
+
}
|
|
12184
|
+
// ============================================================================
|
|
12185
|
+
// Utilities
|
|
12186
|
+
// ============================================================================
|
|
12187
|
+
clear() {
|
|
12188
|
+
this.lastQuery = null;
|
|
12189
|
+
this.history = [];
|
|
12190
|
+
}
|
|
12191
|
+
};
|
|
12192
|
+
var globalSearchDebugger = null;
|
|
12193
|
+
function getSearchDebugger() {
|
|
12194
|
+
if (!globalSearchDebugger) {
|
|
12195
|
+
globalSearchDebugger = new SearchDebugger();
|
|
12196
|
+
}
|
|
12197
|
+
return globalSearchDebugger;
|
|
12198
|
+
}
|
|
12199
|
+
function resetSearchDebugger() {
|
|
12200
|
+
globalSearchDebugger = null;
|
|
12201
|
+
}
|
|
11606
12202
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11607
12203
|
0 && (module.exports = {
|
|
12204
|
+
AuthFailMessageSchema,
|
|
11608
12205
|
AuthMessageSchema,
|
|
11609
12206
|
BM25Scorer,
|
|
11610
12207
|
BatchMessageSchema,
|
|
11611
12208
|
BuiltInProcessors,
|
|
11612
12209
|
BuiltInResolvers,
|
|
12210
|
+
CRDTDebugger,
|
|
11613
12211
|
ClientOpMessageSchema,
|
|
11614
12212
|
ClientOpSchema,
|
|
11615
12213
|
ClusterSearchReqMessageSchema,
|
|
@@ -11666,8 +12264,12 @@ var SearchCursor = class {
|
|
|
11666
12264
|
FallbackIndex,
|
|
11667
12265
|
FilteringResultSet,
|
|
11668
12266
|
FullTextIndex,
|
|
12267
|
+
GcPruneMessageSchema,
|
|
12268
|
+
GcPrunePayloadSchema,
|
|
11669
12269
|
HLC,
|
|
11670
12270
|
HashIndex,
|
|
12271
|
+
HybridQueryDeltaPayloadSchema,
|
|
12272
|
+
HybridQueryRespPayloadSchema,
|
|
11671
12273
|
IndexRegistry,
|
|
11672
12274
|
IndexedLWWMap,
|
|
11673
12275
|
IndexedORMap,
|
|
@@ -11687,7 +12289,9 @@ var SearchCursor = class {
|
|
|
11687
12289
|
ListResolversRequestSchema,
|
|
11688
12290
|
ListResolversResponseSchema,
|
|
11689
12291
|
LiveQueryManager,
|
|
12292
|
+
LockGrantedPayloadSchema,
|
|
11690
12293
|
LockReleaseSchema,
|
|
12294
|
+
LockReleasedPayloadSchema,
|
|
11691
12295
|
LockRequestSchema,
|
|
11692
12296
|
LowercaseFilter,
|
|
11693
12297
|
MaxLengthFilter,
|
|
@@ -11731,12 +12335,15 @@ var SearchCursor = class {
|
|
|
11731
12335
|
QuerySchema,
|
|
11732
12336
|
QuerySubMessageSchema,
|
|
11733
12337
|
QueryUnsubMessageSchema,
|
|
12338
|
+
QueryUpdateMessageSchema,
|
|
12339
|
+
QueryUpdatePayloadSchema,
|
|
11734
12340
|
RESOLVER_FORBIDDEN_PATTERNS,
|
|
11735
12341
|
ReciprocalRankFusion,
|
|
11736
12342
|
RegisterResolverRequestSchema,
|
|
11737
12343
|
RegisterResolverResponseSchema,
|
|
11738
12344
|
Ringbuffer,
|
|
11739
12345
|
SearchCursor,
|
|
12346
|
+
SearchDebugger,
|
|
11740
12347
|
SearchMessageSchema,
|
|
11741
12348
|
SearchOptionsSchema,
|
|
11742
12349
|
SearchPayloadSchema,
|
|
@@ -11749,6 +12356,9 @@ var SearchCursor = class {
|
|
|
11749
12356
|
SearchUpdateMessageSchema,
|
|
11750
12357
|
SearchUpdatePayloadSchema,
|
|
11751
12358
|
SearchUpdateTypeSchema,
|
|
12359
|
+
ServerBatchEventMessageSchema,
|
|
12360
|
+
ServerEventMessageSchema,
|
|
12361
|
+
ServerEventPayloadSchema,
|
|
11752
12362
|
SetResultSet,
|
|
11753
12363
|
SimpleAttribute,
|
|
11754
12364
|
SortedMap,
|
|
@@ -11757,6 +12367,7 @@ var SearchCursor = class {
|
|
|
11757
12367
|
StandingQueryRegistry,
|
|
11758
12368
|
StopWordFilter,
|
|
11759
12369
|
SyncInitMessageSchema,
|
|
12370
|
+
SyncResetRequiredPayloadSchema,
|
|
11760
12371
|
SyncRespBucketsMessageSchema,
|
|
11761
12372
|
SyncRespLeafMessageSchema,
|
|
11762
12373
|
SyncRespRootMessageSchema,
|
|
@@ -11788,7 +12399,9 @@ var SearchCursor = class {
|
|
|
11788
12399
|
disableNativeHash,
|
|
11789
12400
|
encodeBase64Url,
|
|
11790
12401
|
evaluatePredicate,
|
|
12402
|
+
getCRDTDebugger,
|
|
11791
12403
|
getHighestWriteConcernLevel,
|
|
12404
|
+
getSearchDebugger,
|
|
11792
12405
|
hashORMapEntry,
|
|
11793
12406
|
hashORMapRecord,
|
|
11794
12407
|
hashObject,
|
|
@@ -11797,9 +12410,12 @@ var SearchCursor = class {
|
|
|
11797
12410
|
isSimpleQuery,
|
|
11798
12411
|
isUsingNativeHash,
|
|
11799
12412
|
isWriteConcernAchieved,
|
|
12413
|
+
logger,
|
|
11800
12414
|
multiAttribute,
|
|
11801
12415
|
porterStem,
|
|
12416
|
+
resetCRDTDebugger,
|
|
11802
12417
|
resetNativeHash,
|
|
12418
|
+
resetSearchDebugger,
|
|
11803
12419
|
serialize,
|
|
11804
12420
|
simpleAttribute,
|
|
11805
12421
|
timestampToString,
|