@topgunbuild/core 0.1.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/LICENSE +97 -0
- package/dist/index.d.mts +725 -0
- package/dist/index.d.ts +725 -0
- package/dist/index.js +966 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +906 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface Timestamp {
|
|
4
|
+
millis: number;
|
|
5
|
+
counter: number;
|
|
6
|
+
nodeId: string;
|
|
7
|
+
}
|
|
8
|
+
declare class HLC {
|
|
9
|
+
private lastMillis;
|
|
10
|
+
private lastCounter;
|
|
11
|
+
private readonly nodeId;
|
|
12
|
+
private static readonly MAX_DRIFT;
|
|
13
|
+
constructor(nodeId: string);
|
|
14
|
+
get getNodeId(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a new unique timestamp for a local event.
|
|
17
|
+
* Ensures monotonicity: always greater than any previously generated or received timestamp.
|
|
18
|
+
*/
|
|
19
|
+
now(): Timestamp;
|
|
20
|
+
/**
|
|
21
|
+
* Updates the local clock based on a received remote timestamp.
|
|
22
|
+
* Must be called whenever a message/event is received from another node.
|
|
23
|
+
*/
|
|
24
|
+
update(remote: Timestamp): void;
|
|
25
|
+
/**
|
|
26
|
+
* Compares two timestamps.
|
|
27
|
+
* Returns -1 if a < b, 1 if a > b, 0 if equal.
|
|
28
|
+
*/
|
|
29
|
+
static compare(a: Timestamp, b: Timestamp): number;
|
|
30
|
+
/**
|
|
31
|
+
* Serializes timestamp to a string representation (e.g., for storage/network).
|
|
32
|
+
* Format: "<millis>:<counter>:<nodeId>"
|
|
33
|
+
*/
|
|
34
|
+
static toString(ts: Timestamp): string;
|
|
35
|
+
/**
|
|
36
|
+
* Parses a string representation back to a Timestamp object.
|
|
37
|
+
*/
|
|
38
|
+
static parse(str: string): Timestamp;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface MerkleNode {
|
|
42
|
+
hash: number;
|
|
43
|
+
children?: {
|
|
44
|
+
[key: string]: MerkleNode;
|
|
45
|
+
};
|
|
46
|
+
entries?: Map<string, number>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A specific implementation of Merkle Tree for syncing LWW-Maps.
|
|
50
|
+
* It uses a Prefix Trie structure based on the hash of the Record Key.
|
|
51
|
+
*
|
|
52
|
+
* Structure:
|
|
53
|
+
* - Level 0: Root
|
|
54
|
+
* - Level 1..N: Buckets based on hex digits of Key Hash.
|
|
55
|
+
*
|
|
56
|
+
* This allows us to quickly identify which "bucket" of keys is out of sync.
|
|
57
|
+
*/
|
|
58
|
+
declare class MerkleTree {
|
|
59
|
+
private root;
|
|
60
|
+
private readonly depth;
|
|
61
|
+
constructor(records?: Map<string, LWWRecord<any>>, depth?: number);
|
|
62
|
+
/**
|
|
63
|
+
* Incrementally updates the Merkle Tree with a single record.
|
|
64
|
+
* @param key The key of the record
|
|
65
|
+
* @param record The record (value + timestamp)
|
|
66
|
+
*/
|
|
67
|
+
update(key: string, record: LWWRecord<any>): void;
|
|
68
|
+
/**
|
|
69
|
+
* Removes a key from the Merkle Tree.
|
|
70
|
+
* Necessary for Garbage Collection of tombstones.
|
|
71
|
+
*/
|
|
72
|
+
remove(key: string): void;
|
|
73
|
+
private removeNode;
|
|
74
|
+
private updateNode;
|
|
75
|
+
getRootHash(): number;
|
|
76
|
+
getNode(path: string): MerkleNode | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the hashes of the children at the given path.
|
|
79
|
+
* Used by the client/server to compare buckets.
|
|
80
|
+
*/
|
|
81
|
+
getBuckets(path: string): Record<string, number>;
|
|
82
|
+
/**
|
|
83
|
+
* For a leaf node (bucket), returns the actual keys it contains.
|
|
84
|
+
* Used to request specific keys when a bucket differs.
|
|
85
|
+
*/
|
|
86
|
+
getKeysInBucket(path: string): string[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A record in the LWW-Map.
|
|
91
|
+
* Can represent a value or a deletion (tombstone).
|
|
92
|
+
*/
|
|
93
|
+
interface LWWRecord<V> {
|
|
94
|
+
value: V | null;
|
|
95
|
+
timestamp: Timestamp;
|
|
96
|
+
ttlMs?: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Last-Write-Wins Map Implementation.
|
|
100
|
+
* This structure guarantees convergence by always keeping the entry with the highest timestamp.
|
|
101
|
+
*/
|
|
102
|
+
declare class LWWMap<K, V> {
|
|
103
|
+
private data;
|
|
104
|
+
private readonly hlc;
|
|
105
|
+
private listeners;
|
|
106
|
+
private merkleTree;
|
|
107
|
+
constructor(hlc: HLC);
|
|
108
|
+
onChange(callback: () => void): () => void;
|
|
109
|
+
private notify;
|
|
110
|
+
getMerkleTree(): MerkleTree;
|
|
111
|
+
get size(): number;
|
|
112
|
+
/**
|
|
113
|
+
* Sets a value for a key.
|
|
114
|
+
* Generates a new timestamp using the local HLC.
|
|
115
|
+
*/
|
|
116
|
+
set(key: K, value: V, ttlMs?: number): LWWRecord<V>;
|
|
117
|
+
/**
|
|
118
|
+
* Retrieves the value for a key.
|
|
119
|
+
* Returns undefined if key doesn't exist, is a tombstone, or is expired.
|
|
120
|
+
*/
|
|
121
|
+
get(key: K): V | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Returns the full record (including timestamp).
|
|
124
|
+
* Useful for synchronization.
|
|
125
|
+
*/
|
|
126
|
+
getRecord(key: K): LWWRecord<V> | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Removes a key (creates a tombstone).
|
|
129
|
+
*/
|
|
130
|
+
remove(key: K): LWWRecord<V>;
|
|
131
|
+
/**
|
|
132
|
+
* Merges a record from a remote source.
|
|
133
|
+
* Returns true if the local state was updated.
|
|
134
|
+
*/
|
|
135
|
+
merge(key: K, remoteRecord: LWWRecord<V>): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Garbage Collection: Prunes tombstones older than the specified timestamp.
|
|
138
|
+
* Only removes records that are tombstones (deleted) AND older than the threshold.
|
|
139
|
+
*
|
|
140
|
+
* @param olderThan The timestamp threshold. Tombstones older than this will be removed.
|
|
141
|
+
* @returns The number of tombstones removed.
|
|
142
|
+
*/
|
|
143
|
+
prune(olderThan: Timestamp): K[];
|
|
144
|
+
/**
|
|
145
|
+
* Clears all data and tombstones.
|
|
146
|
+
* Resets the MerkleTree.
|
|
147
|
+
*/
|
|
148
|
+
clear(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Returns an iterator over all non-deleted entries.
|
|
151
|
+
*/
|
|
152
|
+
entries(): IterableIterator<[K, V]>;
|
|
153
|
+
/**
|
|
154
|
+
* Returns all keys (including tombstones).
|
|
155
|
+
*/
|
|
156
|
+
allKeys(): IterableIterator<K>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A record in the OR-Map (Observed-Remove Map).
|
|
161
|
+
* Represents a single value instance with a unique tag.
|
|
162
|
+
*/
|
|
163
|
+
interface ORMapRecord<V> {
|
|
164
|
+
value: V;
|
|
165
|
+
timestamp: Timestamp;
|
|
166
|
+
tag: string;
|
|
167
|
+
ttlMs?: number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* OR-Map (Observed-Remove Map) Implementation.
|
|
171
|
+
*
|
|
172
|
+
* Acts as a Multimap where each Key holds a Set of Values.
|
|
173
|
+
* Supports concurrent additions to the same key without data loss.
|
|
174
|
+
*
|
|
175
|
+
* Logic:
|
|
176
|
+
* - Add(K, V): Generates a unique tag. Stores (V, tag) under K.
|
|
177
|
+
* - Remove(K, V): Finds all *currently observed* tags for V under K, and moves them to a Remove Set (Tombstones).
|
|
178
|
+
* - Merge: Union of items minus Union of tombstones.
|
|
179
|
+
*/
|
|
180
|
+
declare class ORMap<K, V> {
|
|
181
|
+
private items;
|
|
182
|
+
private tombstones;
|
|
183
|
+
private readonly hlc;
|
|
184
|
+
constructor(hlc: HLC);
|
|
185
|
+
private listeners;
|
|
186
|
+
onChange(callback: () => void): () => void;
|
|
187
|
+
private notify;
|
|
188
|
+
get size(): number;
|
|
189
|
+
get totalRecords(): number;
|
|
190
|
+
/**
|
|
191
|
+
* Adds a value to the set associated with the key.
|
|
192
|
+
* Generates a unique tag for this specific addition.
|
|
193
|
+
*/
|
|
194
|
+
add(key: K, value: V, ttlMs?: number): ORMapRecord<V>;
|
|
195
|
+
/**
|
|
196
|
+
* Removes a specific value from the set associated with the key.
|
|
197
|
+
* Marks all *currently observed* instances of this value as removed (tombstones).
|
|
198
|
+
* Returns the list of tags that were removed (useful for sync).
|
|
199
|
+
*/
|
|
200
|
+
remove(key: K, value: V): string[];
|
|
201
|
+
/**
|
|
202
|
+
* Clears all data and tombstones.
|
|
203
|
+
*/
|
|
204
|
+
clear(): void;
|
|
205
|
+
/**
|
|
206
|
+
* Returns all active values for a key.
|
|
207
|
+
* Filters out expired records.
|
|
208
|
+
*/
|
|
209
|
+
get(key: K): V[];
|
|
210
|
+
/**
|
|
211
|
+
* Returns all active records for a key.
|
|
212
|
+
* Useful for persistence and sync.
|
|
213
|
+
* Filters out expired records.
|
|
214
|
+
*/
|
|
215
|
+
getRecords(key: K): ORMapRecord<V>[];
|
|
216
|
+
/**
|
|
217
|
+
* Returns all tombstone tags.
|
|
218
|
+
*/
|
|
219
|
+
getTombstones(): string[];
|
|
220
|
+
/**
|
|
221
|
+
* Applies a record from a remote source (Sync).
|
|
222
|
+
*/
|
|
223
|
+
apply(key: K, record: ORMapRecord<V>): void;
|
|
224
|
+
/**
|
|
225
|
+
* Applies a tombstone (deletion) from a remote source.
|
|
226
|
+
*/
|
|
227
|
+
applyTombstone(tag: string): void;
|
|
228
|
+
/**
|
|
229
|
+
* Merges state from another ORMap.
|
|
230
|
+
* - Adds all new tombstones from 'other'.
|
|
231
|
+
* - Adds all new items from 'other' that are not in tombstones.
|
|
232
|
+
* - Updates HLC with observed timestamps.
|
|
233
|
+
*/
|
|
234
|
+
merge(other: ORMap<K, V>): void;
|
|
235
|
+
/**
|
|
236
|
+
* Garbage Collection: Prunes tombstones older than the specified timestamp.
|
|
237
|
+
*/
|
|
238
|
+
prune(olderThan: Timestamp): string[];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* FNV-1a Hash implementation for strings.
|
|
243
|
+
* Fast, non-cryptographic, synchronous.
|
|
244
|
+
* Good enough for data synchronization checks.
|
|
245
|
+
*/
|
|
246
|
+
declare function hashString(str: string): number;
|
|
247
|
+
/**
|
|
248
|
+
* Combines multiple hash numbers into one order-independent hash.
|
|
249
|
+
* Used for combining bucket hashes.
|
|
250
|
+
* XOR is simple and effective for order-independent combination,
|
|
251
|
+
* but for Merkle trees we usually want position dependence if it's a Trie,
|
|
252
|
+
* or order-independence if it's a Set.
|
|
253
|
+
* Here we simply sum or XOR.
|
|
254
|
+
*/
|
|
255
|
+
declare function combineHashes(hashes: number[]): number;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Serializes a JavaScript object to MessagePack binary format.
|
|
259
|
+
* @param data The data to serialize.
|
|
260
|
+
* @returns A Uint8Array containing the serialized data.
|
|
261
|
+
*/
|
|
262
|
+
declare function serialize(data: unknown): Uint8Array;
|
|
263
|
+
/**
|
|
264
|
+
* Deserializes MessagePack binary data to a JavaScript object.
|
|
265
|
+
* @param data The binary data to deserialize (Uint8Array or ArrayBuffer).
|
|
266
|
+
* @returns The deserialized object.
|
|
267
|
+
*/
|
|
268
|
+
declare function deserialize<T = unknown>(data: Uint8Array | ArrayBuffer): T;
|
|
269
|
+
|
|
270
|
+
type PredicateOp = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'regex' | 'and' | 'or' | 'not';
|
|
271
|
+
interface PredicateNode {
|
|
272
|
+
op: PredicateOp;
|
|
273
|
+
attribute?: string;
|
|
274
|
+
value?: any;
|
|
275
|
+
children?: PredicateNode[];
|
|
276
|
+
}
|
|
277
|
+
declare class Predicates {
|
|
278
|
+
static equal(attribute: string, value: any): PredicateNode;
|
|
279
|
+
static notEqual(attribute: string, value: any): PredicateNode;
|
|
280
|
+
static greaterThan(attribute: string, value: any): PredicateNode;
|
|
281
|
+
static greaterThanOrEqual(attribute: string, value: any): PredicateNode;
|
|
282
|
+
static lessThan(attribute: string, value: any): PredicateNode;
|
|
283
|
+
static lessThanOrEqual(attribute: string, value: any): PredicateNode;
|
|
284
|
+
static like(attribute: string, pattern: string): PredicateNode;
|
|
285
|
+
static regex(attribute: string, pattern: string): PredicateNode;
|
|
286
|
+
static between(attribute: string, from: any, to: any): PredicateNode;
|
|
287
|
+
static and(...predicates: PredicateNode[]): PredicateNode;
|
|
288
|
+
static or(...predicates: PredicateNode[]): PredicateNode;
|
|
289
|
+
static not(predicate: PredicateNode): PredicateNode;
|
|
290
|
+
}
|
|
291
|
+
declare function evaluatePredicate(predicate: PredicateNode, data: any): boolean;
|
|
292
|
+
|
|
293
|
+
type PermissionType = 'READ' | 'PUT' | 'REMOVE' | 'ALL';
|
|
294
|
+
interface PermissionPolicy {
|
|
295
|
+
role: string;
|
|
296
|
+
mapNamePattern: string;
|
|
297
|
+
actions: PermissionType[];
|
|
298
|
+
allowedFields?: string[];
|
|
299
|
+
}
|
|
300
|
+
interface Principal {
|
|
301
|
+
userId: string;
|
|
302
|
+
roles: string[];
|
|
303
|
+
[key: string]: any;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
declare const TimestampSchema: z.ZodObject<{
|
|
307
|
+
millis: z.ZodNumber;
|
|
308
|
+
counter: z.ZodNumber;
|
|
309
|
+
nodeId: z.ZodString;
|
|
310
|
+
}, z.core.$strip>;
|
|
311
|
+
declare const LWWRecordSchema: z.ZodObject<{
|
|
312
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
313
|
+
timestamp: z.ZodObject<{
|
|
314
|
+
millis: z.ZodNumber;
|
|
315
|
+
counter: z.ZodNumber;
|
|
316
|
+
nodeId: z.ZodString;
|
|
317
|
+
}, z.core.$strip>;
|
|
318
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
319
|
+
}, z.core.$strip>;
|
|
320
|
+
declare const ORMapRecordSchema: z.ZodObject<{
|
|
321
|
+
value: z.ZodAny;
|
|
322
|
+
timestamp: z.ZodObject<{
|
|
323
|
+
millis: z.ZodNumber;
|
|
324
|
+
counter: z.ZodNumber;
|
|
325
|
+
nodeId: z.ZodString;
|
|
326
|
+
}, z.core.$strip>;
|
|
327
|
+
tag: z.ZodString;
|
|
328
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
329
|
+
}, z.core.$strip>;
|
|
330
|
+
declare const PredicateOpSchema: z.ZodEnum<{
|
|
331
|
+
eq: "eq";
|
|
332
|
+
neq: "neq";
|
|
333
|
+
gt: "gt";
|
|
334
|
+
gte: "gte";
|
|
335
|
+
lt: "lt";
|
|
336
|
+
lte: "lte";
|
|
337
|
+
like: "like";
|
|
338
|
+
regex: "regex";
|
|
339
|
+
and: "and";
|
|
340
|
+
or: "or";
|
|
341
|
+
not: "not";
|
|
342
|
+
}>;
|
|
343
|
+
declare const PredicateNodeSchema: z.ZodType<any>;
|
|
344
|
+
declare const QuerySchema: z.ZodObject<{
|
|
345
|
+
where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
346
|
+
predicate: z.ZodOptional<z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>>;
|
|
347
|
+
sort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
348
|
+
asc: "asc";
|
|
349
|
+
desc: "desc";
|
|
350
|
+
}>>>;
|
|
351
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
352
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
353
|
+
}, z.core.$strip>;
|
|
354
|
+
declare const ClientOpSchema: z.ZodObject<{
|
|
355
|
+
id: z.ZodOptional<z.ZodString>;
|
|
356
|
+
mapName: z.ZodString;
|
|
357
|
+
key: z.ZodString;
|
|
358
|
+
opType: z.ZodOptional<z.ZodString>;
|
|
359
|
+
record: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
360
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
361
|
+
timestamp: z.ZodObject<{
|
|
362
|
+
millis: z.ZodNumber;
|
|
363
|
+
counter: z.ZodNumber;
|
|
364
|
+
nodeId: z.ZodString;
|
|
365
|
+
}, z.core.$strip>;
|
|
366
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
367
|
+
}, z.core.$strip>>>;
|
|
368
|
+
orRecord: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
369
|
+
value: z.ZodAny;
|
|
370
|
+
timestamp: z.ZodObject<{
|
|
371
|
+
millis: z.ZodNumber;
|
|
372
|
+
counter: z.ZodNumber;
|
|
373
|
+
nodeId: z.ZodString;
|
|
374
|
+
}, z.core.$strip>;
|
|
375
|
+
tag: z.ZodString;
|
|
376
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
377
|
+
}, z.core.$strip>>>;
|
|
378
|
+
orTag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
379
|
+
}, z.core.$strip>;
|
|
380
|
+
declare const AuthMessageSchema: z.ZodObject<{
|
|
381
|
+
type: z.ZodLiteral<"AUTH">;
|
|
382
|
+
token: z.ZodString;
|
|
383
|
+
}, z.core.$strip>;
|
|
384
|
+
declare const QuerySubMessageSchema: z.ZodObject<{
|
|
385
|
+
type: z.ZodLiteral<"QUERY_SUB">;
|
|
386
|
+
payload: z.ZodObject<{
|
|
387
|
+
queryId: z.ZodString;
|
|
388
|
+
mapName: z.ZodString;
|
|
389
|
+
query: z.ZodObject<{
|
|
390
|
+
where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
391
|
+
predicate: z.ZodOptional<z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>>;
|
|
392
|
+
sort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
393
|
+
asc: "asc";
|
|
394
|
+
desc: "desc";
|
|
395
|
+
}>>>;
|
|
396
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
397
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
398
|
+
}, z.core.$strip>;
|
|
399
|
+
}, z.core.$strip>;
|
|
400
|
+
}, z.core.$strip>;
|
|
401
|
+
declare const QueryUnsubMessageSchema: z.ZodObject<{
|
|
402
|
+
type: z.ZodLiteral<"QUERY_UNSUB">;
|
|
403
|
+
payload: z.ZodObject<{
|
|
404
|
+
queryId: z.ZodString;
|
|
405
|
+
}, z.core.$strip>;
|
|
406
|
+
}, z.core.$strip>;
|
|
407
|
+
declare const ClientOpMessageSchema: z.ZodObject<{
|
|
408
|
+
type: z.ZodLiteral<"CLIENT_OP">;
|
|
409
|
+
payload: z.ZodObject<{
|
|
410
|
+
id: z.ZodOptional<z.ZodString>;
|
|
411
|
+
mapName: z.ZodString;
|
|
412
|
+
key: z.ZodString;
|
|
413
|
+
opType: z.ZodOptional<z.ZodString>;
|
|
414
|
+
record: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
415
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
416
|
+
timestamp: z.ZodObject<{
|
|
417
|
+
millis: z.ZodNumber;
|
|
418
|
+
counter: z.ZodNumber;
|
|
419
|
+
nodeId: z.ZodString;
|
|
420
|
+
}, z.core.$strip>;
|
|
421
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
422
|
+
}, z.core.$strip>>>;
|
|
423
|
+
orRecord: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
424
|
+
value: z.ZodAny;
|
|
425
|
+
timestamp: z.ZodObject<{
|
|
426
|
+
millis: z.ZodNumber;
|
|
427
|
+
counter: z.ZodNumber;
|
|
428
|
+
nodeId: z.ZodString;
|
|
429
|
+
}, z.core.$strip>;
|
|
430
|
+
tag: z.ZodString;
|
|
431
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
432
|
+
}, z.core.$strip>>>;
|
|
433
|
+
orTag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
434
|
+
}, z.core.$strip>;
|
|
435
|
+
}, z.core.$strip>;
|
|
436
|
+
declare const OpBatchMessageSchema: z.ZodObject<{
|
|
437
|
+
type: z.ZodLiteral<"OP_BATCH">;
|
|
438
|
+
payload: z.ZodObject<{
|
|
439
|
+
ops: z.ZodArray<z.ZodObject<{
|
|
440
|
+
id: z.ZodOptional<z.ZodString>;
|
|
441
|
+
mapName: z.ZodString;
|
|
442
|
+
key: z.ZodString;
|
|
443
|
+
opType: z.ZodOptional<z.ZodString>;
|
|
444
|
+
record: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
445
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
446
|
+
timestamp: z.ZodObject<{
|
|
447
|
+
millis: z.ZodNumber;
|
|
448
|
+
counter: z.ZodNumber;
|
|
449
|
+
nodeId: z.ZodString;
|
|
450
|
+
}, z.core.$strip>;
|
|
451
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
452
|
+
}, z.core.$strip>>>;
|
|
453
|
+
orRecord: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
454
|
+
value: z.ZodAny;
|
|
455
|
+
timestamp: z.ZodObject<{
|
|
456
|
+
millis: z.ZodNumber;
|
|
457
|
+
counter: z.ZodNumber;
|
|
458
|
+
nodeId: z.ZodString;
|
|
459
|
+
}, z.core.$strip>;
|
|
460
|
+
tag: z.ZodString;
|
|
461
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
462
|
+
}, z.core.$strip>>>;
|
|
463
|
+
orTag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
464
|
+
}, z.core.$strip>>;
|
|
465
|
+
}, z.core.$strip>;
|
|
466
|
+
}, z.core.$strip>;
|
|
467
|
+
declare const SyncInitMessageSchema: z.ZodObject<{
|
|
468
|
+
type: z.ZodLiteral<"SYNC_INIT">;
|
|
469
|
+
mapName: z.ZodString;
|
|
470
|
+
lastSyncTimestamp: z.ZodOptional<z.ZodNumber>;
|
|
471
|
+
}, z.core.$strip>;
|
|
472
|
+
declare const SyncRespRootMessageSchema: z.ZodObject<{
|
|
473
|
+
type: z.ZodLiteral<"SYNC_RESP_ROOT">;
|
|
474
|
+
payload: z.ZodObject<{
|
|
475
|
+
mapName: z.ZodString;
|
|
476
|
+
rootHash: z.ZodNumber;
|
|
477
|
+
timestamp: z.ZodObject<{
|
|
478
|
+
millis: z.ZodNumber;
|
|
479
|
+
counter: z.ZodNumber;
|
|
480
|
+
nodeId: z.ZodString;
|
|
481
|
+
}, z.core.$strip>;
|
|
482
|
+
}, z.core.$strip>;
|
|
483
|
+
}, z.core.$strip>;
|
|
484
|
+
declare const SyncRespBucketsMessageSchema: z.ZodObject<{
|
|
485
|
+
type: z.ZodLiteral<"SYNC_RESP_BUCKETS">;
|
|
486
|
+
payload: z.ZodObject<{
|
|
487
|
+
mapName: z.ZodString;
|
|
488
|
+
path: z.ZodString;
|
|
489
|
+
buckets: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
490
|
+
}, z.core.$strip>;
|
|
491
|
+
}, z.core.$strip>;
|
|
492
|
+
declare const SyncRespLeafMessageSchema: z.ZodObject<{
|
|
493
|
+
type: z.ZodLiteral<"SYNC_RESP_LEAF">;
|
|
494
|
+
payload: z.ZodObject<{
|
|
495
|
+
mapName: z.ZodString;
|
|
496
|
+
path: z.ZodString;
|
|
497
|
+
records: z.ZodArray<z.ZodObject<{
|
|
498
|
+
key: z.ZodString;
|
|
499
|
+
record: z.ZodObject<{
|
|
500
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
501
|
+
timestamp: z.ZodObject<{
|
|
502
|
+
millis: z.ZodNumber;
|
|
503
|
+
counter: z.ZodNumber;
|
|
504
|
+
nodeId: z.ZodString;
|
|
505
|
+
}, z.core.$strip>;
|
|
506
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
507
|
+
}, z.core.$strip>;
|
|
508
|
+
}, z.core.$strip>>;
|
|
509
|
+
}, z.core.$strip>;
|
|
510
|
+
}, z.core.$strip>;
|
|
511
|
+
declare const MerkleReqBucketMessageSchema: z.ZodObject<{
|
|
512
|
+
type: z.ZodLiteral<"MERKLE_REQ_BUCKET">;
|
|
513
|
+
payload: z.ZodObject<{
|
|
514
|
+
mapName: z.ZodString;
|
|
515
|
+
path: z.ZodString;
|
|
516
|
+
}, z.core.$strip>;
|
|
517
|
+
}, z.core.$strip>;
|
|
518
|
+
declare const LockRequestSchema: z.ZodObject<{
|
|
519
|
+
type: z.ZodLiteral<"LOCK_REQUEST">;
|
|
520
|
+
payload: z.ZodObject<{
|
|
521
|
+
requestId: z.ZodString;
|
|
522
|
+
name: z.ZodString;
|
|
523
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
524
|
+
}, z.core.$strip>;
|
|
525
|
+
}, z.core.$strip>;
|
|
526
|
+
declare const LockReleaseSchema: z.ZodObject<{
|
|
527
|
+
type: z.ZodLiteral<"LOCK_RELEASE">;
|
|
528
|
+
payload: z.ZodObject<{
|
|
529
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
530
|
+
name: z.ZodString;
|
|
531
|
+
fencingToken: z.ZodNumber;
|
|
532
|
+
}, z.core.$strip>;
|
|
533
|
+
}, z.core.$strip>;
|
|
534
|
+
declare const TopicSubSchema: z.ZodObject<{
|
|
535
|
+
type: z.ZodLiteral<"TOPIC_SUB">;
|
|
536
|
+
payload: z.ZodObject<{
|
|
537
|
+
topic: z.ZodString;
|
|
538
|
+
}, z.core.$strip>;
|
|
539
|
+
}, z.core.$strip>;
|
|
540
|
+
declare const TopicUnsubSchema: z.ZodObject<{
|
|
541
|
+
type: z.ZodLiteral<"TOPIC_UNSUB">;
|
|
542
|
+
payload: z.ZodObject<{
|
|
543
|
+
topic: z.ZodString;
|
|
544
|
+
}, z.core.$strip>;
|
|
545
|
+
}, z.core.$strip>;
|
|
546
|
+
declare const TopicPubSchema: z.ZodObject<{
|
|
547
|
+
type: z.ZodLiteral<"TOPIC_PUB">;
|
|
548
|
+
payload: z.ZodObject<{
|
|
549
|
+
topic: z.ZodString;
|
|
550
|
+
data: z.ZodAny;
|
|
551
|
+
}, z.core.$strip>;
|
|
552
|
+
}, z.core.$strip>;
|
|
553
|
+
declare const TopicMessageEventSchema: z.ZodObject<{
|
|
554
|
+
type: z.ZodLiteral<"TOPIC_MESSAGE">;
|
|
555
|
+
payload: z.ZodObject<{
|
|
556
|
+
topic: z.ZodString;
|
|
557
|
+
data: z.ZodAny;
|
|
558
|
+
publisherId: z.ZodOptional<z.ZodString>;
|
|
559
|
+
timestamp: z.ZodNumber;
|
|
560
|
+
}, z.core.$strip>;
|
|
561
|
+
}, z.core.$strip>;
|
|
562
|
+
declare const MessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
563
|
+
type: z.ZodLiteral<"AUTH">;
|
|
564
|
+
token: z.ZodString;
|
|
565
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
566
|
+
type: z.ZodLiteral<"QUERY_SUB">;
|
|
567
|
+
payload: z.ZodObject<{
|
|
568
|
+
queryId: z.ZodString;
|
|
569
|
+
mapName: z.ZodString;
|
|
570
|
+
query: z.ZodObject<{
|
|
571
|
+
where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
572
|
+
predicate: z.ZodOptional<z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>>;
|
|
573
|
+
sort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
574
|
+
asc: "asc";
|
|
575
|
+
desc: "desc";
|
|
576
|
+
}>>>;
|
|
577
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
578
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
579
|
+
}, z.core.$strip>;
|
|
580
|
+
}, z.core.$strip>;
|
|
581
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
582
|
+
type: z.ZodLiteral<"QUERY_UNSUB">;
|
|
583
|
+
payload: z.ZodObject<{
|
|
584
|
+
queryId: z.ZodString;
|
|
585
|
+
}, z.core.$strip>;
|
|
586
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
587
|
+
type: z.ZodLiteral<"CLIENT_OP">;
|
|
588
|
+
payload: z.ZodObject<{
|
|
589
|
+
id: z.ZodOptional<z.ZodString>;
|
|
590
|
+
mapName: z.ZodString;
|
|
591
|
+
key: z.ZodString;
|
|
592
|
+
opType: z.ZodOptional<z.ZodString>;
|
|
593
|
+
record: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
594
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
595
|
+
timestamp: z.ZodObject<{
|
|
596
|
+
millis: z.ZodNumber;
|
|
597
|
+
counter: z.ZodNumber;
|
|
598
|
+
nodeId: z.ZodString;
|
|
599
|
+
}, z.core.$strip>;
|
|
600
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
601
|
+
}, z.core.$strip>>>;
|
|
602
|
+
orRecord: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
603
|
+
value: z.ZodAny;
|
|
604
|
+
timestamp: z.ZodObject<{
|
|
605
|
+
millis: z.ZodNumber;
|
|
606
|
+
counter: z.ZodNumber;
|
|
607
|
+
nodeId: z.ZodString;
|
|
608
|
+
}, z.core.$strip>;
|
|
609
|
+
tag: z.ZodString;
|
|
610
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
611
|
+
}, z.core.$strip>>>;
|
|
612
|
+
orTag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
613
|
+
}, z.core.$strip>;
|
|
614
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
615
|
+
type: z.ZodLiteral<"OP_BATCH">;
|
|
616
|
+
payload: z.ZodObject<{
|
|
617
|
+
ops: z.ZodArray<z.ZodObject<{
|
|
618
|
+
id: z.ZodOptional<z.ZodString>;
|
|
619
|
+
mapName: z.ZodString;
|
|
620
|
+
key: z.ZodString;
|
|
621
|
+
opType: z.ZodOptional<z.ZodString>;
|
|
622
|
+
record: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
623
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
624
|
+
timestamp: z.ZodObject<{
|
|
625
|
+
millis: z.ZodNumber;
|
|
626
|
+
counter: z.ZodNumber;
|
|
627
|
+
nodeId: z.ZodString;
|
|
628
|
+
}, z.core.$strip>;
|
|
629
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
630
|
+
}, z.core.$strip>>>;
|
|
631
|
+
orRecord: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
632
|
+
value: z.ZodAny;
|
|
633
|
+
timestamp: z.ZodObject<{
|
|
634
|
+
millis: z.ZodNumber;
|
|
635
|
+
counter: z.ZodNumber;
|
|
636
|
+
nodeId: z.ZodString;
|
|
637
|
+
}, z.core.$strip>;
|
|
638
|
+
tag: z.ZodString;
|
|
639
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
640
|
+
}, z.core.$strip>>>;
|
|
641
|
+
orTag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
642
|
+
}, z.core.$strip>>;
|
|
643
|
+
}, z.core.$strip>;
|
|
644
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
645
|
+
type: z.ZodLiteral<"SYNC_INIT">;
|
|
646
|
+
mapName: z.ZodString;
|
|
647
|
+
lastSyncTimestamp: z.ZodOptional<z.ZodNumber>;
|
|
648
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
649
|
+
type: z.ZodLiteral<"SYNC_RESP_ROOT">;
|
|
650
|
+
payload: z.ZodObject<{
|
|
651
|
+
mapName: z.ZodString;
|
|
652
|
+
rootHash: z.ZodNumber;
|
|
653
|
+
timestamp: z.ZodObject<{
|
|
654
|
+
millis: z.ZodNumber;
|
|
655
|
+
counter: z.ZodNumber;
|
|
656
|
+
nodeId: z.ZodString;
|
|
657
|
+
}, z.core.$strip>;
|
|
658
|
+
}, z.core.$strip>;
|
|
659
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
660
|
+
type: z.ZodLiteral<"SYNC_RESP_BUCKETS">;
|
|
661
|
+
payload: z.ZodObject<{
|
|
662
|
+
mapName: z.ZodString;
|
|
663
|
+
path: z.ZodString;
|
|
664
|
+
buckets: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
665
|
+
}, z.core.$strip>;
|
|
666
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
667
|
+
type: z.ZodLiteral<"SYNC_RESP_LEAF">;
|
|
668
|
+
payload: z.ZodObject<{
|
|
669
|
+
mapName: z.ZodString;
|
|
670
|
+
path: z.ZodString;
|
|
671
|
+
records: z.ZodArray<z.ZodObject<{
|
|
672
|
+
key: z.ZodString;
|
|
673
|
+
record: z.ZodObject<{
|
|
674
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
675
|
+
timestamp: z.ZodObject<{
|
|
676
|
+
millis: z.ZodNumber;
|
|
677
|
+
counter: z.ZodNumber;
|
|
678
|
+
nodeId: z.ZodString;
|
|
679
|
+
}, z.core.$strip>;
|
|
680
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
681
|
+
}, z.core.$strip>;
|
|
682
|
+
}, z.core.$strip>>;
|
|
683
|
+
}, z.core.$strip>;
|
|
684
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
685
|
+
type: z.ZodLiteral<"MERKLE_REQ_BUCKET">;
|
|
686
|
+
payload: z.ZodObject<{
|
|
687
|
+
mapName: z.ZodString;
|
|
688
|
+
path: z.ZodString;
|
|
689
|
+
}, z.core.$strip>;
|
|
690
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
691
|
+
type: z.ZodLiteral<"LOCK_REQUEST">;
|
|
692
|
+
payload: z.ZodObject<{
|
|
693
|
+
requestId: z.ZodString;
|
|
694
|
+
name: z.ZodString;
|
|
695
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
696
|
+
}, z.core.$strip>;
|
|
697
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
698
|
+
type: z.ZodLiteral<"LOCK_RELEASE">;
|
|
699
|
+
payload: z.ZodObject<{
|
|
700
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
701
|
+
name: z.ZodString;
|
|
702
|
+
fencingToken: z.ZodNumber;
|
|
703
|
+
}, z.core.$strip>;
|
|
704
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
705
|
+
type: z.ZodLiteral<"TOPIC_SUB">;
|
|
706
|
+
payload: z.ZodObject<{
|
|
707
|
+
topic: z.ZodString;
|
|
708
|
+
}, z.core.$strip>;
|
|
709
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
710
|
+
type: z.ZodLiteral<"TOPIC_UNSUB">;
|
|
711
|
+
payload: z.ZodObject<{
|
|
712
|
+
topic: z.ZodString;
|
|
713
|
+
}, z.core.$strip>;
|
|
714
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
715
|
+
type: z.ZodLiteral<"TOPIC_PUB">;
|
|
716
|
+
payload: z.ZodObject<{
|
|
717
|
+
topic: z.ZodString;
|
|
718
|
+
data: z.ZodAny;
|
|
719
|
+
}, z.core.$strip>;
|
|
720
|
+
}, z.core.$strip>], "type">;
|
|
721
|
+
type Query = z.infer<typeof QuerySchema>;
|
|
722
|
+
type ClientOp = z.infer<typeof ClientOpSchema>;
|
|
723
|
+
type Message = z.infer<typeof MessageSchema>;
|
|
724
|
+
|
|
725
|
+
export { AuthMessageSchema, type ClientOp, ClientOpMessageSchema, ClientOpSchema, HLC, LWWMap, type LWWRecord, LWWRecordSchema, LockReleaseSchema, LockRequestSchema, MerkleReqBucketMessageSchema, MerkleTree, type Message, MessageSchema, ORMap, type ORMapRecord, ORMapRecordSchema, OpBatchMessageSchema, type PermissionPolicy, type PermissionType, type PredicateNode, PredicateNodeSchema, type PredicateOp, PredicateOpSchema, Predicates, type Principal, type Query, QuerySchema, QuerySubMessageSchema, QueryUnsubMessageSchema, SyncInitMessageSchema, SyncRespBucketsMessageSchema, SyncRespLeafMessageSchema, SyncRespRootMessageSchema, type Timestamp, TimestampSchema, TopicMessageEventSchema, TopicPubSchema, TopicSubSchema, TopicUnsubSchema, combineHashes, deserialize, evaluatePredicate, hashString, serialize };
|