@topgunbuild/core 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -30,8 +30,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AuthAckMessageSchema: () => AuthAckMessageSchema,
33
34
  AuthFailMessageSchema: () => AuthFailMessageSchema,
34
35
  AuthMessageSchema: () => AuthMessageSchema,
36
+ AuthRequiredMessageSchema: () => AuthRequiredMessageSchema,
35
37
  BM25Scorer: () => BM25Scorer,
36
38
  BatchMessageSchema: () => BatchMessageSchema,
37
39
  BuiltInProcessors: () => BuiltInProcessors,
@@ -39,6 +41,7 @@ __export(index_exports, {
39
41
  COST_WEIGHTS: () => COST_WEIGHTS,
40
42
  CRDTDebugger: () => CRDTDebugger,
41
43
  CRDTInvariants: () => CRDTInvariants,
44
+ ChangeEventTypeSchema: () => ChangeEventTypeSchema,
42
45
  ClientOpMessageSchema: () => ClientOpMessageSchema,
43
46
  ClientOpSchema: () => ClientOpSchema,
44
47
  ClusterSearchReqMessageSchema: () => ClusterSearchReqMessageSchema,
@@ -89,6 +92,7 @@ __export(index_exports, {
89
92
  EntryProcessResponseSchema: () => EntryProcessResponseSchema,
90
93
  EntryProcessorDefSchema: () => EntryProcessorDefSchema,
91
94
  EntryProcessorSchema: () => EntryProcessorSchema,
95
+ ErrorMessageSchema: () => ErrorMessageSchema,
92
96
  EventJournalImpl: () => EventJournalImpl,
93
97
  FORBIDDEN_PATTERNS: () => FORBIDDEN_PATTERNS,
94
98
  FTSInvertedIndex: () => BM25InvertedIndex,
@@ -107,8 +111,6 @@ __export(index_exports, {
107
111
  HttpSyncErrorSchema: () => HttpSyncErrorSchema,
108
112
  HttpSyncRequestSchema: () => HttpSyncRequestSchema,
109
113
  HttpSyncResponseSchema: () => HttpSyncResponseSchema,
110
- HybridQueryDeltaPayloadSchema: () => HybridQueryDeltaPayloadSchema,
111
- HybridQueryRespPayloadSchema: () => HybridQueryRespPayloadSchema,
112
114
  IndexRegistry: () => IndexRegistry,
113
115
  IndexedLWWMap: () => IndexedLWWMap,
114
116
  IndexedORMap: () => IndexedORMap,
@@ -129,8 +131,10 @@ __export(index_exports, {
129
131
  ListResolversRequestSchema: () => ListResolversRequestSchema,
130
132
  ListResolversResponseSchema: () => ListResolversResponseSchema,
131
133
  LiveQueryManager: () => LiveQueryManager,
134
+ LockGrantedMessageSchema: () => LockGrantedMessageSchema,
132
135
  LockGrantedPayloadSchema: () => LockGrantedPayloadSchema,
133
136
  LockReleaseSchema: () => LockReleaseSchema,
137
+ LockReleasedMessageSchema: () => LockReleasedMessageSchema,
134
138
  LockReleasedPayloadSchema: () => LockReleasedPayloadSchema,
135
139
  LockRequestSchema: () => LockRequestSchema,
136
140
  LowercaseFilter: () => LowercaseFilter,
@@ -144,9 +148,11 @@ __export(index_exports, {
144
148
  MultiValueAttribute: () => MultiValueAttribute,
145
149
  NGramTokenizer: () => NGramTokenizer,
146
150
  NavigableIndex: () => NavigableIndex,
151
+ NodeInfoSchema: () => NodeInfoSchema,
147
152
  ORMap: () => ORMap,
148
153
  ORMapDiffRequestSchema: () => ORMapDiffRequestSchema,
149
154
  ORMapDiffResponseSchema: () => ORMapDiffResponseSchema,
155
+ ORMapEntrySchema: () => ORMapEntrySchema,
150
156
  ORMapMerkleReqBucketSchema: () => ORMapMerkleReqBucketSchema,
151
157
  ORMapMerkleTree: () => ORMapMerkleTree,
152
158
  ORMapPushDiffSchema: () => ORMapPushDiffSchema,
@@ -162,6 +168,9 @@ __export(index_exports, {
162
168
  PARTITION_COUNT: () => PARTITION_COUNT,
163
169
  PNCounterImpl: () => PNCounterImpl,
164
170
  PNCounterStateObjectSchema: () => PNCounterStateObjectSchema,
171
+ PartitionInfoSchema: () => PartitionInfoSchema,
172
+ PartitionMapMessageSchema: () => PartitionMapMessageSchema,
173
+ PartitionMapPayloadSchema: () => PartitionMapPayloadSchema,
165
174
  PartitionMapRequestSchema: () => PartitionMapRequestSchema,
166
175
  PartitionState: () => PartitionState,
167
176
  PingMessageSchema: () => PingMessageSchema,
@@ -175,6 +184,8 @@ __export(index_exports, {
175
184
  QueryRespPayloadSchema: () => QueryRespPayloadSchema,
176
185
  QuerySchema: () => QuerySchema,
177
186
  QuerySubMessageSchema: () => QuerySubMessageSchema,
187
+ QuerySyncInitMessageSchema: () => QuerySyncInitMessageSchema,
188
+ QuerySyncInitPayloadSchema: () => QuerySyncInitPayloadSchema,
178
189
  QueryUnsubMessageSchema: () => QueryUnsubMessageSchema,
179
190
  QueryUpdateMessageSchema: () => QueryUpdateMessageSchema,
180
191
  QueryUpdatePayloadSchema: () => QueryUpdatePayloadSchema,
@@ -212,6 +223,7 @@ __export(index_exports, {
212
223
  StopWordFilter: () => StopWordFilter,
213
224
  SyncInitMessageSchema: () => SyncInitMessageSchema,
214
225
  SyncMapEntrySchema: () => SyncMapEntrySchema,
226
+ SyncResetRequiredMessageSchema: () => SyncResetRequiredMessageSchema,
215
227
  SyncResetRequiredPayloadSchema: () => SyncResetRequiredPayloadSchema,
216
228
  SyncRespBucketsMessageSchema: () => SyncRespBucketsMessageSchema,
217
229
  SyncRespLeafMessageSchema: () => SyncRespLeafMessageSchema,
@@ -244,7 +256,6 @@ __export(index_exports, {
244
256
  decodeBase64Url: () => decodeBase64Url,
245
257
  deepMerge: () => deepMerge,
246
258
  deserialize: () => deserialize,
247
- disableNativeHash: () => disableNativeHash,
248
259
  encodeBase64Url: () => encodeBase64Url,
249
260
  evaluatePredicate: () => evaluatePredicate,
250
261
  getCRDTDebugger: () => getCRDTDebugger,
@@ -256,13 +267,11 @@ __export(index_exports, {
256
267
  hashString: () => hashString,
257
268
  isLogicalQuery: () => isLogicalQuery,
258
269
  isSimpleQuery: () => isSimpleQuery,
259
- isUsingNativeHash: () => isUsingNativeHash,
260
270
  isWriteConcernAchieved: () => isWriteConcernAchieved,
261
271
  logger: () => logger,
262
272
  multiAttribute: () => multiAttribute,
263
273
  porterStem: () => porterStem,
264
274
  resetCRDTDebugger: () => resetCRDTDebugger,
265
- resetNativeHash: () => resetNativeHash,
266
275
  resetSearchDebugger: () => resetSearchDebugger,
267
276
  serialize: () => serialize,
268
277
  simpleAttribute: () => simpleAttribute,
@@ -285,6 +294,9 @@ var logger = (0, import_pino.default)({
285
294
  // src/HLC.ts
286
295
  var HLC = class {
287
296
  constructor(nodeId, options = {}) {
297
+ if (nodeId.includes(":")) {
298
+ throw new Error('Node ID must not contain ":" (used as delimiter in timestamp format)');
299
+ }
288
300
  this.nodeId = nodeId;
289
301
  this.strictMode = options.strictMode ?? false;
290
302
  this.maxDriftMs = options.maxDriftMs ?? 6e4;
@@ -331,27 +343,33 @@ var HLC = class {
331
343
  * Must be called whenever a message/event is received from another node.
332
344
  */
333
345
  update(remote) {
346
+ const remoteMillis = Number(remote.millis);
347
+ const remoteCounter = Number(remote.counter);
348
+ if (!Number.isFinite(remoteMillis) || !Number.isFinite(remoteCounter)) {
349
+ logger.warn({ remoteMillis, remoteCounter, remote }, "HLC.update() received invalid timestamp, ignoring");
350
+ return;
351
+ }
334
352
  const systemTime = this.clockSource.now();
335
- const drift = remote.millis - systemTime;
353
+ const drift = remoteMillis - systemTime;
336
354
  if (drift > this.maxDriftMs) {
337
355
  if (this.strictMode) {
338
- throw new Error(`Clock drift detected: Remote time ${remote.millis} is ${drift}ms ahead of local ${systemTime} (threshold: ${this.maxDriftMs}ms)`);
356
+ throw new Error(`Clock drift detected: Remote time ${remoteMillis} is ${drift}ms ahead of local ${systemTime} (threshold: ${this.maxDriftMs}ms)`);
339
357
  } else {
340
358
  logger.warn({
341
359
  drift,
342
- remoteMillis: remote.millis,
360
+ remoteMillis,
343
361
  localMillis: systemTime,
344
362
  maxDriftMs: this.maxDriftMs
345
363
  }, "Clock drift detected");
346
364
  }
347
365
  }
348
- const maxMillis = Math.max(this.lastMillis, systemTime, remote.millis);
349
- if (maxMillis === this.lastMillis && maxMillis === remote.millis) {
350
- this.lastCounter = Math.max(this.lastCounter, remote.counter) + 1;
366
+ const maxMillis = Math.max(this.lastMillis, systemTime, remoteMillis);
367
+ if (maxMillis === this.lastMillis && maxMillis === remoteMillis) {
368
+ this.lastCounter = Math.max(this.lastCounter, remoteCounter) + 1;
351
369
  } else if (maxMillis === this.lastMillis) {
352
370
  this.lastCounter++;
353
- } else if (maxMillis === remote.millis) {
354
- this.lastCounter = remote.counter + 1;
371
+ } else if (maxMillis === remoteMillis) {
372
+ this.lastCounter = remoteCounter + 1;
355
373
  } else {
356
374
  this.lastCounter = 0;
357
375
  }
@@ -394,17 +412,7 @@ var HLC = class {
394
412
  };
395
413
 
396
414
  // src/utils/hash.ts
397
- var nativeHash = null;
398
- var nativeLoadAttempted = false;
399
- function tryLoadNative() {
400
- if (nativeLoadAttempted) return;
401
- nativeLoadAttempted = true;
402
- try {
403
- nativeHash = require("@topgunbuild/native");
404
- } catch {
405
- }
406
- }
407
- function fnv1aHash(str) {
415
+ function hashString(str) {
408
416
  let hash = 2166136261;
409
417
  for (let i = 0; i < str.length; i++) {
410
418
  hash ^= str.charCodeAt(i);
@@ -412,13 +420,6 @@ function fnv1aHash(str) {
412
420
  }
413
421
  return hash >>> 0;
414
422
  }
415
- function hashString(str) {
416
- tryLoadNative();
417
- if (nativeHash && nativeHash.isNativeHashAvailable()) {
418
- return nativeHash.hashString(str);
419
- }
420
- return fnv1aHash(str);
421
- }
422
423
  function combineHashes(hashes) {
423
424
  let result = 0;
424
425
  for (const h of hashes) {
@@ -426,18 +427,6 @@ function combineHashes(hashes) {
426
427
  }
427
428
  return result >>> 0;
428
429
  }
429
- function isUsingNativeHash() {
430
- tryLoadNative();
431
- return nativeHash?.isNativeHashAvailable() === true;
432
- }
433
- function disableNativeHash() {
434
- nativeHash = null;
435
- nativeLoadAttempted = true;
436
- }
437
- function resetNativeHash() {
438
- nativeHash = null;
439
- nativeLoadAttempted = false;
440
- }
441
430
  function hashObject(obj) {
442
431
  const json = JSON.stringify(obj, (_, value) => {
443
432
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -1275,11 +1264,49 @@ var ORMap = class {
1275
1264
  // src/serializer.ts
1276
1265
  var import_msgpackr = require("msgpackr");
1277
1266
  function serialize(data) {
1278
- return (0, import_msgpackr.pack)(data);
1267
+ return (0, import_msgpackr.pack)(stripUndefined(data));
1279
1268
  }
1280
1269
  function deserialize(data) {
1281
1270
  const buffer = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
1282
- return (0, import_msgpackr.unpack)(buffer);
1271
+ const result = (0, import_msgpackr.unpack)(buffer);
1272
+ return coerceBigInts(result);
1273
+ }
1274
+ function stripUndefined(value) {
1275
+ if (value === void 0) {
1276
+ return null;
1277
+ }
1278
+ if (Array.isArray(value)) {
1279
+ return value.map(stripUndefined);
1280
+ }
1281
+ if (value !== null && typeof value === "object") {
1282
+ const result = {};
1283
+ for (const [k, v] of Object.entries(value)) {
1284
+ if (v !== void 0) {
1285
+ result[k] = stripUndefined(v);
1286
+ }
1287
+ }
1288
+ return result;
1289
+ }
1290
+ return value;
1291
+ }
1292
+ function coerceBigInts(value) {
1293
+ if (typeof value === "bigint") {
1294
+ return Number(value);
1295
+ }
1296
+ if (Array.isArray(value)) {
1297
+ for (let i = 0; i < value.length; i++) {
1298
+ value[i] = coerceBigInts(value[i]);
1299
+ }
1300
+ return value;
1301
+ }
1302
+ if (value !== null && typeof value === "object") {
1303
+ const obj = value;
1304
+ for (const key of Object.keys(obj)) {
1305
+ obj[key] = coerceBigInts(obj[key]);
1306
+ }
1307
+ return obj;
1308
+ }
1309
+ return value;
1283
1310
  }
1284
1311
 
1285
1312
  // src/PNCounter.ts
@@ -2454,6 +2481,7 @@ var ORMapRecordSchema = import_zod3.z.object({
2454
2481
  tag: import_zod3.z.string(),
2455
2482
  ttlMs: import_zod3.z.number().optional()
2456
2483
  });
2484
+ var ChangeEventTypeSchema = import_zod3.z.enum(["ENTER", "UPDATE", "LEAVE"]);
2457
2485
  var PredicateOpSchema = import_zod3.z.enum([
2458
2486
  "eq",
2459
2487
  "neq",
@@ -2494,7 +2522,11 @@ var ClientOpSchema = import_zod3.z.object({
2494
2522
  });
2495
2523
  var AuthMessageSchema = import_zod3.z.object({
2496
2524
  type: import_zod3.z.literal("AUTH"),
2497
- token: import_zod3.z.string()
2525
+ token: import_zod3.z.string(),
2526
+ protocolVersion: import_zod3.z.number().optional()
2527
+ });
2528
+ var AuthRequiredMessageSchema = import_zod3.z.object({
2529
+ type: import_zod3.z.literal("AUTH_REQUIRED")
2498
2530
  });
2499
2531
 
2500
2532
  // src/schemas/sync-schemas.ts
@@ -2550,6 +2582,11 @@ var MerkleReqBucketMessageSchema = import_zod4.z.object({
2550
2582
  path: import_zod4.z.string()
2551
2583
  })
2552
2584
  });
2585
+ var ORMapEntrySchema = import_zod4.z.object({
2586
+ key: import_zod4.z.string(),
2587
+ records: import_zod4.z.array(ORMapRecordSchema),
2588
+ tombstones: import_zod4.z.array(import_zod4.z.string())
2589
+ });
2553
2590
  var ORMapSyncInitSchema = import_zod4.z.object({
2554
2591
  type: import_zod4.z.literal("ORMAP_SYNC_INIT"),
2555
2592
  mapName: import_zod4.z.string(),
@@ -2585,11 +2622,7 @@ var ORMapSyncRespLeafSchema = import_zod4.z.object({
2585
2622
  payload: import_zod4.z.object({
2586
2623
  mapName: import_zod4.z.string(),
2587
2624
  path: import_zod4.z.string(),
2588
- entries: import_zod4.z.array(import_zod4.z.object({
2589
- key: import_zod4.z.string(),
2590
- records: import_zod4.z.array(ORMapRecordSchema),
2591
- tombstones: import_zod4.z.array(import_zod4.z.string())
2592
- }))
2625
+ entries: import_zod4.z.array(ORMapEntrySchema)
2593
2626
  })
2594
2627
  });
2595
2628
  var ORMapDiffRequestSchema = import_zod4.z.object({
@@ -2603,22 +2636,14 @@ var ORMapDiffResponseSchema = import_zod4.z.object({
2603
2636
  type: import_zod4.z.literal("ORMAP_DIFF_RESPONSE"),
2604
2637
  payload: import_zod4.z.object({
2605
2638
  mapName: import_zod4.z.string(),
2606
- entries: import_zod4.z.array(import_zod4.z.object({
2607
- key: import_zod4.z.string(),
2608
- records: import_zod4.z.array(ORMapRecordSchema),
2609
- tombstones: import_zod4.z.array(import_zod4.z.string())
2610
- }))
2639
+ entries: import_zod4.z.array(ORMapEntrySchema)
2611
2640
  })
2612
2641
  });
2613
2642
  var ORMapPushDiffSchema = import_zod4.z.object({
2614
2643
  type: import_zod4.z.literal("ORMAP_PUSH_DIFF"),
2615
2644
  payload: import_zod4.z.object({
2616
2645
  mapName: import_zod4.z.string(),
2617
- entries: import_zod4.z.array(import_zod4.z.object({
2618
- key: import_zod4.z.string(),
2619
- records: import_zod4.z.array(ORMapRecordSchema),
2620
- tombstones: import_zod4.z.array(import_zod4.z.string())
2621
- }))
2646
+ entries: import_zod4.z.array(ORMapEntrySchema)
2622
2647
  })
2623
2648
  });
2624
2649
  var OpResultSchema = import_zod4.z.object({
@@ -2656,7 +2681,8 @@ var QuerySubMessageSchema = import_zod5.z.object({
2656
2681
  payload: import_zod5.z.object({
2657
2682
  queryId: import_zod5.z.string(),
2658
2683
  mapName: import_zod5.z.string(),
2659
- query: QuerySchema
2684
+ query: QuerySchema,
2685
+ fields: import_zod5.z.array(import_zod5.z.string()).optional()
2660
2686
  })
2661
2687
  });
2662
2688
  var QueryUnsubMessageSchema = import_zod5.z.object({
@@ -2674,12 +2700,21 @@ var QueryRespPayloadSchema = import_zod5.z.object({
2674
2700
  })),
2675
2701
  nextCursor: import_zod5.z.string().optional(),
2676
2702
  hasMore: import_zod5.z.boolean().optional(),
2677
- cursorStatus: CursorStatusSchema.optional()
2703
+ cursorStatus: CursorStatusSchema.optional(),
2704
+ merkleRootHash: import_zod5.z.number().int().optional()
2678
2705
  });
2679
2706
  var QueryRespMessageSchema = import_zod5.z.object({
2680
2707
  type: import_zod5.z.literal("QUERY_RESP"),
2681
2708
  payload: QueryRespPayloadSchema
2682
2709
  });
2710
+ var QuerySyncInitPayloadSchema = import_zod5.z.object({
2711
+ queryId: import_zod5.z.string(),
2712
+ rootHash: import_zod5.z.number().int()
2713
+ });
2714
+ var QuerySyncInitMessageSchema = import_zod5.z.object({
2715
+ type: import_zod5.z.literal("QUERY_SYNC_INIT"),
2716
+ payload: QuerySyncInitPayloadSchema
2717
+ });
2683
2718
 
2684
2719
  // src/schemas/search-schemas.ts
2685
2720
  var import_zod6 = require("zod");
@@ -2713,7 +2748,7 @@ var SearchRespMessageSchema = import_zod6.z.object({
2713
2748
  type: import_zod6.z.literal("SEARCH_RESP"),
2714
2749
  payload: SearchRespPayloadSchema
2715
2750
  });
2716
- var SearchUpdateTypeSchema = import_zod6.z.enum(["ENTER", "UPDATE", "LEAVE"]);
2751
+ var SearchUpdateTypeSchema = ChangeEventTypeSchema;
2717
2752
  var SearchSubPayloadSchema = import_zod6.z.object({
2718
2753
  subscriptionId: import_zod6.z.string(),
2719
2754
  mapName: import_zod6.z.string(),
@@ -2730,7 +2765,7 @@ var SearchUpdatePayloadSchema = import_zod6.z.object({
2730
2765
  value: import_zod6.z.unknown(),
2731
2766
  score: import_zod6.z.number(),
2732
2767
  matchedTerms: import_zod6.z.array(import_zod6.z.string()),
2733
- type: SearchUpdateTypeSchema
2768
+ changeType: SearchUpdateTypeSchema
2734
2769
  });
2735
2770
  var SearchUpdateMessageSchema = import_zod6.z.object({
2736
2771
  type: import_zod6.z.literal("SEARCH_UPDATE"),
@@ -2752,17 +2787,37 @@ var PartitionMapRequestSchema = import_zod7.z.object({
2752
2787
  currentVersion: import_zod7.z.number().optional()
2753
2788
  }).optional()
2754
2789
  });
2790
+ var NodeInfoSchema = import_zod7.z.object({
2791
+ nodeId: import_zod7.z.string(),
2792
+ endpoints: import_zod7.z.object({
2793
+ websocket: import_zod7.z.string(),
2794
+ http: import_zod7.z.string().optional()
2795
+ }),
2796
+ status: import_zod7.z.enum(["ACTIVE", "JOINING", "LEAVING", "SUSPECTED", "FAILED"])
2797
+ });
2798
+ var PartitionInfoSchema = import_zod7.z.object({
2799
+ partitionId: import_zod7.z.number(),
2800
+ ownerNodeId: import_zod7.z.string(),
2801
+ backupNodeIds: import_zod7.z.array(import_zod7.z.string())
2802
+ });
2803
+ var PartitionMapPayloadSchema = import_zod7.z.object({
2804
+ version: import_zod7.z.number(),
2805
+ partitionCount: import_zod7.z.number(),
2806
+ nodes: import_zod7.z.array(NodeInfoSchema),
2807
+ partitions: import_zod7.z.array(PartitionInfoSchema),
2808
+ generatedAt: import_zod7.z.number()
2809
+ });
2810
+ var PartitionMapMessageSchema = import_zod7.z.object({
2811
+ type: import_zod7.z.literal("PARTITION_MAP"),
2812
+ payload: PartitionMapPayloadSchema
2813
+ });
2755
2814
  var ClusterSubRegisterPayloadSchema = import_zod7.z.object({
2756
2815
  subscriptionId: import_zod7.z.string(),
2757
2816
  coordinatorNodeId: import_zod7.z.string(),
2758
2817
  mapName: import_zod7.z.string(),
2759
2818
  type: import_zod7.z.enum(["SEARCH", "QUERY"]),
2760
2819
  searchQuery: import_zod7.z.string().optional(),
2761
- searchOptions: import_zod7.z.object({
2762
- limit: import_zod7.z.number().int().positive().optional(),
2763
- minScore: import_zod7.z.number().optional(),
2764
- boost: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.number()).optional()
2765
- }).optional(),
2820
+ searchOptions: SearchOptionsSchema.optional(),
2766
2821
  queryPredicate: import_zod7.z.any().optional(),
2767
2822
  querySort: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.enum(["asc", "desc"])).optional()
2768
2823
  });
@@ -2794,7 +2849,7 @@ var ClusterSubUpdatePayloadSchema = import_zod7.z.object({
2794
2849
  value: import_zod7.z.unknown(),
2795
2850
  score: import_zod7.z.number().optional(),
2796
2851
  matchedTerms: import_zod7.z.array(import_zod7.z.string()).optional(),
2797
- changeType: import_zod7.z.enum(["ENTER", "UPDATE", "LEAVE"]),
2852
+ changeType: ChangeEventTypeSchema,
2798
2853
  timestamp: import_zod7.z.number()
2799
2854
  });
2800
2855
  var ClusterSubUpdateMessageSchema = import_zod7.z.object({
@@ -2812,10 +2867,8 @@ var ClusterSearchReqPayloadSchema = import_zod7.z.object({
2812
2867
  requestId: import_zod7.z.string(),
2813
2868
  mapName: import_zod7.z.string(),
2814
2869
  query: import_zod7.z.string(),
2815
- options: import_zod7.z.object({
2870
+ options: SearchOptionsSchema.extend({
2816
2871
  limit: import_zod7.z.number().int().positive().max(1e3),
2817
- minScore: import_zod7.z.number().optional(),
2818
- boost: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.number()).optional(),
2819
2872
  includeMatchedTerms: import_zod7.z.boolean().optional(),
2820
2873
  afterScore: import_zod7.z.number().optional(),
2821
2874
  afterKey: import_zod7.z.string().optional()
@@ -2867,7 +2920,7 @@ var ClusterSearchUpdatePayloadSchema = import_zod7.z.object({
2867
2920
  value: import_zod7.z.unknown(),
2868
2921
  score: import_zod7.z.number(),
2869
2922
  matchedTerms: import_zod7.z.array(import_zod7.z.string()).optional(),
2870
- type: SearchUpdateTypeSchema
2923
+ changeType: ChangeEventTypeSchema
2871
2924
  });
2872
2925
  var ClusterSearchUpdateMessageSchema = import_zod7.z.object({
2873
2926
  type: import_zod7.z.literal("CLUSTER_SEARCH_UPDATE"),
@@ -3110,7 +3163,7 @@ var QueryUpdatePayloadSchema = import_zod9.z.object({
3110
3163
  queryId: import_zod9.z.string(),
3111
3164
  key: import_zod9.z.string(),
3112
3165
  value: import_zod9.z.unknown(),
3113
- type: import_zod9.z.enum(["ENTER", "UPDATE", "REMOVE"])
3166
+ changeType: ChangeEventTypeSchema
3114
3167
  });
3115
3168
  var QueryUpdateMessageSchema = import_zod9.z.object({
3116
3169
  type: import_zod9.z.literal("QUERY_UPDATE"),
@@ -3123,43 +3176,50 @@ var GcPruneMessageSchema = import_zod9.z.object({
3123
3176
  type: import_zod9.z.literal("GC_PRUNE"),
3124
3177
  payload: GcPrunePayloadSchema
3125
3178
  });
3179
+ var AuthAckMessageSchema = import_zod9.z.object({
3180
+ type: import_zod9.z.literal("AUTH_ACK"),
3181
+ protocolVersion: import_zod9.z.number().optional(),
3182
+ userId: import_zod9.z.string().optional()
3183
+ });
3126
3184
  var AuthFailMessageSchema = import_zod9.z.object({
3127
3185
  type: import_zod9.z.literal("AUTH_FAIL"),
3128
3186
  error: import_zod9.z.string().optional(),
3129
3187
  code: import_zod9.z.number().optional()
3130
3188
  });
3131
- var HybridQueryRespPayloadSchema = import_zod9.z.object({
3132
- subscriptionId: import_zod9.z.string(),
3133
- results: import_zod9.z.array(import_zod9.z.object({
3134
- key: import_zod9.z.string(),
3135
- value: import_zod9.z.unknown(),
3136
- score: import_zod9.z.number(),
3137
- matchedTerms: import_zod9.z.array(import_zod9.z.string())
3138
- })),
3139
- nextCursor: import_zod9.z.string().optional(),
3140
- hasMore: import_zod9.z.boolean().optional(),
3141
- cursorStatus: CursorStatusSchema.optional()
3142
- });
3143
- var HybridQueryDeltaPayloadSchema = import_zod9.z.object({
3144
- subscriptionId: import_zod9.z.string(),
3145
- key: import_zod9.z.string(),
3146
- value: import_zod9.z.unknown().nullable(),
3147
- score: import_zod9.z.number().optional(),
3148
- matchedTerms: import_zod9.z.array(import_zod9.z.string()).optional(),
3149
- type: import_zod9.z.enum(["ENTER", "UPDATE", "LEAVE"])
3189
+ var ErrorMessageSchema = import_zod9.z.object({
3190
+ type: import_zod9.z.literal("ERROR"),
3191
+ payload: import_zod9.z.object({
3192
+ code: import_zod9.z.number(),
3193
+ message: import_zod9.z.string(),
3194
+ details: import_zod9.z.unknown().optional()
3195
+ })
3150
3196
  });
3151
3197
  var LockGrantedPayloadSchema = import_zod9.z.object({
3152
3198
  requestId: import_zod9.z.string(),
3199
+ name: import_zod9.z.string(),
3153
3200
  fencingToken: import_zod9.z.number()
3154
3201
  });
3155
3202
  var LockReleasedPayloadSchema = import_zod9.z.object({
3156
3203
  requestId: import_zod9.z.string(),
3204
+ name: import_zod9.z.string(),
3157
3205
  success: import_zod9.z.boolean()
3158
3206
  });
3207
+ var LockGrantedMessageSchema = import_zod9.z.object({
3208
+ type: import_zod9.z.literal("LOCK_GRANTED"),
3209
+ payload: LockGrantedPayloadSchema
3210
+ });
3211
+ var LockReleasedMessageSchema = import_zod9.z.object({
3212
+ type: import_zod9.z.literal("LOCK_RELEASED"),
3213
+ payload: LockReleasedPayloadSchema
3214
+ });
3159
3215
  var SyncResetRequiredPayloadSchema = import_zod9.z.object({
3160
3216
  mapName: import_zod9.z.string(),
3161
3217
  reason: import_zod9.z.string()
3162
3218
  });
3219
+ var SyncResetRequiredMessageSchema = import_zod9.z.object({
3220
+ type: import_zod9.z.literal("SYNC_RESET_REQUIRED"),
3221
+ payload: SyncResetRequiredPayloadSchema
3222
+ });
3163
3223
 
3164
3224
  // src/schemas/http-sync-schemas.ts
3165
3225
  var import_zod10 = require("zod");
@@ -3241,9 +3301,10 @@ var HttpSyncResponseSchema = import_zod10.z.object({
3241
3301
  // src/schemas/index.ts
3242
3302
  var import_zod11 = require("zod");
3243
3303
  var MessageSchema = import_zod11.z.discriminatedUnion("type", [
3304
+ // --- Base ---
3244
3305
  AuthMessageSchema,
3245
- QuerySubMessageSchema,
3246
- QueryUnsubMessageSchema,
3306
+ AuthRequiredMessageSchema,
3307
+ // --- Sync ---
3247
3308
  ClientOpMessageSchema,
3248
3309
  OpBatchMessageSchema,
3249
3310
  SyncInitMessageSchema,
@@ -3251,13 +3312,10 @@ var MessageSchema = import_zod11.z.discriminatedUnion("type", [
3251
3312
  SyncRespBucketsMessageSchema,
3252
3313
  SyncRespLeafMessageSchema,
3253
3314
  MerkleReqBucketMessageSchema,
3254
- LockRequestSchema,
3255
- LockReleaseSchema,
3256
- TopicSubSchema,
3257
- TopicUnsubSchema,
3258
- TopicPubSchema,
3259
- PingMessageSchema,
3260
- PongMessageSchema,
3315
+ OpAckMessageSchema,
3316
+ OpRejectedMessageSchema,
3317
+ BatchMessageSchema,
3318
+ // --- ORMap Sync ---
3261
3319
  ORMapSyncInitSchema,
3262
3320
  ORMapSyncRespRootSchema,
3263
3321
  ORMapSyncRespBucketsSchema,
@@ -3266,18 +3324,55 @@ var MessageSchema = import_zod11.z.discriminatedUnion("type", [
3266
3324
  ORMapDiffRequestSchema,
3267
3325
  ORMapDiffResponseSchema,
3268
3326
  ORMapPushDiffSchema,
3327
+ // --- Query ---
3328
+ QuerySubMessageSchema,
3329
+ QueryUnsubMessageSchema,
3330
+ QueryRespMessageSchema,
3331
+ QuerySyncInitMessageSchema,
3332
+ QueryUpdateMessageSchema,
3333
+ // --- Search ---
3334
+ SearchMessageSchema,
3335
+ SearchRespMessageSchema,
3336
+ SearchSubMessageSchema,
3337
+ SearchUpdateMessageSchema,
3338
+ SearchUnsubMessageSchema,
3339
+ // --- Cluster ---
3269
3340
  PartitionMapRequestSchema,
3341
+ PartitionMapMessageSchema,
3342
+ ClusterSubRegisterMessageSchema,
3343
+ ClusterSubAckMessageSchema,
3344
+ ClusterSubUpdateMessageSchema,
3345
+ ClusterSubUnregisterMessageSchema,
3346
+ ClusterSearchReqMessageSchema,
3347
+ ClusterSearchRespMessageSchema,
3348
+ ClusterSearchSubscribeMessageSchema,
3349
+ ClusterSearchUnsubscribeMessageSchema,
3350
+ ClusterSearchUpdateMessageSchema,
3351
+ // --- Messaging ---
3352
+ TopicSubSchema,
3353
+ TopicUnsubSchema,
3354
+ TopicPubSchema,
3355
+ TopicMessageEventSchema,
3356
+ LockRequestSchema,
3357
+ LockReleaseSchema,
3270
3358
  CounterRequestSchema,
3271
3359
  CounterSyncSchema,
3360
+ CounterResponseSchema,
3361
+ CounterUpdateSchema,
3362
+ PingMessageSchema,
3363
+ PongMessageSchema,
3364
+ // --- Entry Processor ---
3272
3365
  EntryProcessRequestSchema,
3273
3366
  EntryProcessBatchRequestSchema,
3274
3367
  EntryProcessResponseSchema,
3275
3368
  EntryProcessBatchResponseSchema,
3369
+ // --- Journal ---
3276
3370
  JournalSubscribeRequestSchema,
3277
3371
  JournalUnsubscribeRequestSchema,
3278
3372
  JournalEventMessageSchema,
3279
3373
  JournalReadRequestSchema,
3280
3374
  JournalReadResponseSchema,
3375
+ // --- Conflict Resolver ---
3281
3376
  RegisterResolverRequestSchema,
3282
3377
  RegisterResolverResponseSchema,
3283
3378
  UnregisterResolverRequestSchema,
@@ -3285,15 +3380,16 @@ var MessageSchema = import_zod11.z.discriminatedUnion("type", [
3285
3380
  MergeRejectedMessageSchema,
3286
3381
  ListResolversRequestSchema,
3287
3382
  ListResolversResponseSchema,
3288
- SearchMessageSchema,
3289
- SearchRespMessageSchema,
3290
- SearchSubMessageSchema,
3291
- SearchUpdateMessageSchema,
3292
- SearchUnsubMessageSchema,
3293
- ClusterSubRegisterMessageSchema,
3294
- ClusterSubAckMessageSchema,
3295
- ClusterSubUpdateMessageSchema,
3296
- ClusterSubUnregisterMessageSchema
3383
+ // --- Server-to-Client ---
3384
+ ServerEventMessageSchema,
3385
+ ServerBatchEventMessageSchema,
3386
+ GcPruneMessageSchema,
3387
+ AuthAckMessageSchema,
3388
+ AuthFailMessageSchema,
3389
+ ErrorMessageSchema,
3390
+ LockGrantedMessageSchema,
3391
+ LockReleasedMessageSchema,
3392
+ SyncResetRequiredMessageSchema
3297
3393
  ]);
3298
3394
 
3299
3395
  // src/types/WriteConcern.ts
@@ -13034,8 +13130,10 @@ var ScenarioRunner = class {
13034
13130
  };
13035
13131
  // Annotate the CommonJS export names for ESM import in node:
13036
13132
  0 && (module.exports = {
13133
+ AuthAckMessageSchema,
13037
13134
  AuthFailMessageSchema,
13038
13135
  AuthMessageSchema,
13136
+ AuthRequiredMessageSchema,
13039
13137
  BM25Scorer,
13040
13138
  BatchMessageSchema,
13041
13139
  BuiltInProcessors,
@@ -13043,6 +13141,7 @@ var ScenarioRunner = class {
13043
13141
  COST_WEIGHTS,
13044
13142
  CRDTDebugger,
13045
13143
  CRDTInvariants,
13144
+ ChangeEventTypeSchema,
13046
13145
  ClientOpMessageSchema,
13047
13146
  ClientOpSchema,
13048
13147
  ClusterSearchReqMessageSchema,
@@ -13093,6 +13192,7 @@ var ScenarioRunner = class {
13093
13192
  EntryProcessResponseSchema,
13094
13193
  EntryProcessorDefSchema,
13095
13194
  EntryProcessorSchema,
13195
+ ErrorMessageSchema,
13096
13196
  EventJournalImpl,
13097
13197
  FORBIDDEN_PATTERNS,
13098
13198
  FTSInvertedIndex,
@@ -13111,8 +13211,6 @@ var ScenarioRunner = class {
13111
13211
  HttpSyncErrorSchema,
13112
13212
  HttpSyncRequestSchema,
13113
13213
  HttpSyncResponseSchema,
13114
- HybridQueryDeltaPayloadSchema,
13115
- HybridQueryRespPayloadSchema,
13116
13214
  IndexRegistry,
13117
13215
  IndexedLWWMap,
13118
13216
  IndexedORMap,
@@ -13133,8 +13231,10 @@ var ScenarioRunner = class {
13133
13231
  ListResolversRequestSchema,
13134
13232
  ListResolversResponseSchema,
13135
13233
  LiveQueryManager,
13234
+ LockGrantedMessageSchema,
13136
13235
  LockGrantedPayloadSchema,
13137
13236
  LockReleaseSchema,
13237
+ LockReleasedMessageSchema,
13138
13238
  LockReleasedPayloadSchema,
13139
13239
  LockRequestSchema,
13140
13240
  LowercaseFilter,
@@ -13148,9 +13248,11 @@ var ScenarioRunner = class {
13148
13248
  MultiValueAttribute,
13149
13249
  NGramTokenizer,
13150
13250
  NavigableIndex,
13251
+ NodeInfoSchema,
13151
13252
  ORMap,
13152
13253
  ORMapDiffRequestSchema,
13153
13254
  ORMapDiffResponseSchema,
13255
+ ORMapEntrySchema,
13154
13256
  ORMapMerkleReqBucketSchema,
13155
13257
  ORMapMerkleTree,
13156
13258
  ORMapPushDiffSchema,
@@ -13166,6 +13268,9 @@ var ScenarioRunner = class {
13166
13268
  PARTITION_COUNT,
13167
13269
  PNCounterImpl,
13168
13270
  PNCounterStateObjectSchema,
13271
+ PartitionInfoSchema,
13272
+ PartitionMapMessageSchema,
13273
+ PartitionMapPayloadSchema,
13169
13274
  PartitionMapRequestSchema,
13170
13275
  PartitionState,
13171
13276
  PingMessageSchema,
@@ -13179,6 +13284,8 @@ var ScenarioRunner = class {
13179
13284
  QueryRespPayloadSchema,
13180
13285
  QuerySchema,
13181
13286
  QuerySubMessageSchema,
13287
+ QuerySyncInitMessageSchema,
13288
+ QuerySyncInitPayloadSchema,
13182
13289
  QueryUnsubMessageSchema,
13183
13290
  QueryUpdateMessageSchema,
13184
13291
  QueryUpdatePayloadSchema,
@@ -13216,6 +13323,7 @@ var ScenarioRunner = class {
13216
13323
  StopWordFilter,
13217
13324
  SyncInitMessageSchema,
13218
13325
  SyncMapEntrySchema,
13326
+ SyncResetRequiredMessageSchema,
13219
13327
  SyncResetRequiredPayloadSchema,
13220
13328
  SyncRespBucketsMessageSchema,
13221
13329
  SyncRespLeafMessageSchema,
@@ -13248,7 +13356,6 @@ var ScenarioRunner = class {
13248
13356
  decodeBase64Url,
13249
13357
  deepMerge,
13250
13358
  deserialize,
13251
- disableNativeHash,
13252
13359
  encodeBase64Url,
13253
13360
  evaluatePredicate,
13254
13361
  getCRDTDebugger,
@@ -13260,13 +13367,11 @@ var ScenarioRunner = class {
13260
13367
  hashString,
13261
13368
  isLogicalQuery,
13262
13369
  isSimpleQuery,
13263
- isUsingNativeHash,
13264
13370
  isWriteConcernAchieved,
13265
13371
  logger,
13266
13372
  multiAttribute,
13267
13373
  porterStem,
13268
13374
  resetCRDTDebugger,
13269
- resetNativeHash,
13270
13375
  resetSearchDebugger,
13271
13376
  serialize,
13272
13377
  simpleAttribute,