datahike 0.8.1877 → 0.8.1879

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.
Files changed (147) hide show
  1. package/boring.core.js +2 -2
  2. package/boring.data.js +7 -7
  3. package/boring.options.js +16 -16
  4. package/boring.reader.js +4 -4
  5. package/boring.writer.js +2 -2
  6. package/browser/datahike.js +3757 -3750
  7. package/cljs.cache.js +10 -10
  8. package/cljs.cache.wrapped.js +7 -7
  9. package/cljs.core.async.impl.channels.js +8 -8
  10. package/cljs.core.async.impl.dispatch.js +3 -3
  11. package/cljs.core.async.impl.ioc_helpers.js +2 -2
  12. package/cljs.core.async.impl.timers.js +5 -5
  13. package/cljs.core.async.js +16 -16
  14. package/cljs.core.js +473 -474
  15. package/cljs.nodejs.js +1 -1
  16. package/cljs.reader.js +11 -11
  17. package/cljs.spec.alpha.js +74 -74
  18. package/cljs.tools.reader.edn.js +26 -26
  19. package/cljs.tools.reader.impl.commons.js +7 -7
  20. package/cljs.tools.reader.impl.errors.js +10 -10
  21. package/cljs.tools.reader.impl.inspect.js +4 -4
  22. package/cljs.tools.reader.impl.utils.js +3 -3
  23. package/cljs.tools.reader.js +2 -2
  24. package/cljs.tools.reader.reader_types.js +1 -1
  25. package/cljs_env.js +17 -17
  26. package/cljs_node_io.core.js +11 -11
  27. package/cljs_node_io.file.js +26 -26
  28. package/cljs_node_io.fs.js +1 -1
  29. package/clojure.data.js +14 -14
  30. package/clojure.set.js +2 -2
  31. package/clojure.string.js +13 -13
  32. package/clojure.walk.js +3 -3
  33. package/datahike.api.impl.js +34 -34
  34. package/datahike.api.js +5 -5
  35. package/datahike.array.js +8 -8
  36. package/datahike.attr_preds.js +1 -1
  37. package/datahike.bitemporal.predicate.js +1 -1
  38. package/datahike.config.js +49 -49
  39. package/datahike.connections.js +4 -4
  40. package/datahike.connector.js +77 -77
  41. package/datahike.constants.js +21 -20
  42. package/datahike.core.js +1 -1
  43. package/datahike.datom.js +17 -17
  44. package/datahike.db.interface.js +11 -11
  45. package/datahike.db.js +93 -93
  46. package/datahike.db.search.js +49 -49
  47. package/datahike.db.transaction.js +11 -11
  48. package/datahike.db.utils.js +48 -48
  49. package/datahike.env.js +4 -4
  50. package/datahike.gc.js +12 -12
  51. package/datahike.gc_roots.js +2 -2
  52. package/datahike.impl.entity.js +16 -16
  53. package/datahike.index.interface.js +12 -12
  54. package/datahike.index.js +1 -1
  55. package/datahike.index.persistent_set.js +170 -170
  56. package/datahike.index.persistent_set.warm.js +1 -1
  57. package/datahike.index.secondary.js +5 -5
  58. package/datahike.js.api.js +258 -258
  59. package/datahike.js.convert.js +1 -1
  60. package/datahike.lru.js +7 -7
  61. package/datahike.metrics.js +10 -10
  62. package/datahike.migrate.ids.js +1 -1
  63. package/datahike.online_gc.js +2 -2
  64. package/datahike.optimistic.js +12 -12
  65. package/datahike.pull_api.js +7 -7
  66. package/datahike.query.analyze.js +4 -4
  67. package/datahike.query.estimate.js +2 -2
  68. package/datahike.query.execute.js +7 -7
  69. package/datahike.query.ir.js +6 -6
  70. package/datahike.query.js +1319 -1309
  71. package/datahike.query.logical.js +2 -2
  72. package/datahike.query.lower.js +2 -2
  73. package/datahike.query.plan.js +12 -12
  74. package/datahike.query.relation.js +1 -1
  75. package/datahike.query.resolve.js +1 -1
  76. package/datahike.query_stats.js +1 -1
  77. package/datahike.readers.js +10 -10
  78. package/datahike.remote.js +1 -1
  79. package/datahike.schema.js +48 -48
  80. package/datahike.schema_cache.js +3 -3
  81. package/datahike.store.js +62 -62
  82. package/datahike.tools.js +5 -5
  83. package/datahike.tx_preds.js +1 -1
  84. package/datahike.versioning.js +4 -4
  85. package/datahike.writer.js +805 -804
  86. package/datahike.writing.js +52 -52
  87. package/datalog.parser.impl.js +4 -4
  88. package/datalog.parser.impl.proto.js +1 -1
  89. package/datalog.parser.impl.util.js +1 -1
  90. package/datalog.parser.js +1 -1
  91. package/datalog.parser.pull.js +3 -3
  92. package/datalog.parser.type.js +28 -28
  93. package/fress.api.js +1 -1
  94. package/fress.impl.adler32.js +4 -4
  95. package/fress.impl.bigdec.js +2 -2
  96. package/fress.impl.buffer.js +4 -4
  97. package/fress.impl.raw_input.js +1 -1
  98. package/fress.impl.raw_output.js +4 -4
  99. package/fress.impl.table.js +1 -1
  100. package/fress.reader.js +15 -15
  101. package/fress.util.js +11 -11
  102. package/fress.writer.js +24 -24
  103. package/geheimnis.aes.js +1 -1
  104. package/hasch.benc.js +3 -3
  105. package/hasch.core.js +11 -11
  106. package/hasch.platform.js +16 -16
  107. package/is.simm.partial_cps.sequence.js +5 -5
  108. package/kabel/datahike.js +5114 -5108
  109. package/konserve.compressor.js +16 -16
  110. package/konserve.core.js +52 -52
  111. package/konserve.encryptor.js +11 -11
  112. package/konserve.gc.js +1 -1
  113. package/konserve.gc_guard.js +1 -1
  114. package/konserve.impl.defaults.js +14 -14
  115. package/konserve.impl.storage_layout.js +3 -3
  116. package/konserve.memory.js +1 -1
  117. package/konserve.metrics.js +6 -6
  118. package/konserve.node_filestore.js +603 -603
  119. package/konserve.protocols.js +7 -7
  120. package/konserve.serializers.js +16 -16
  121. package/konserve.store.js +95 -95
  122. package/konserve.tiered.js +10 -10
  123. package/konserve.utils.js +6 -6
  124. package/org.replikativ.persistent_sorted_set.branch.js +3 -3
  125. package/org.replikativ.persistent_sorted_set.btset.js +366 -366
  126. package/org.replikativ.persistent_sorted_set.fressian.js +5 -5
  127. package/org.replikativ.persistent_sorted_set.impl.boundary.js +1 -1
  128. package/org.replikativ.persistent_sorted_set.impl.nodes.js +2 -2
  129. package/org.replikativ.persistent_sorted_set.js +1 -1
  130. package/org.replikativ.persistent_sorted_set.leaf.js +1 -1
  131. package/org.replikativ.persistent_sorted_set.util.js +1 -1
  132. package/org.replikativ.persistent_sorted_set.warm.js +1 -1
  133. package/package.json +4 -5
  134. package/remote/api.generated.d.ts +178 -0
  135. package/remote/core.d.ts +133 -0
  136. package/remote/index.d.ts +66 -0
  137. package/remote/index.js +523 -3
  138. package/remote/index.mjs +478 -48
  139. package/replikativ.logging.js +1 -1
  140. package/replikativ.metrics.js +1 -1
  141. package/s3/datahike.js +4506 -4499
  142. package/superv.async.js +26 -26
  143. package/tailrecursion.priority_map.js +16 -16
  144. package/taoensso.trove.console.js +4 -4
  145. package/taoensso.trove.js +1 -1
  146. package/remote/datahike.js +0 -679
  147. package/remote.d.ts +0 -709
package/remote/index.js CHANGED
@@ -1,3 +1,523 @@
1
- require('./datahike.js');
2
- var root = (typeof self !== 'undefined' ? self : global);
3
- module.exports = root['datahike']['js']['remote'];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asOf = asOf;
4
+ exports.branch = branch;
5
+ exports.branchAsDb = branchAsDb;
6
+ exports.branches = branches;
7
+ exports.commitAsDb = commitAsDb;
8
+ exports.commitId = commitId;
9
+ exports.connect = connect;
10
+ exports.createDatabase = createDatabase;
11
+ exports.databaseExists = databaseExists;
12
+ exports.datoms = datoms;
13
+ exports.db = db;
14
+ exports.deleteBranch = deleteBranch;
15
+ exports.deleteDatabase = deleteDatabase;
16
+ exports.entity = entity;
17
+ exports.entityDb = entityDb;
18
+ exports.gcStorage = gcStorage;
19
+ exports.history = history;
20
+ exports.indexRange = indexRange;
21
+ exports.loadEntities = loadEntities;
22
+ exports.mergeDb = mergeDb;
23
+ exports.metrics = metrics;
24
+ exports.parentCommitIds = parentCommitIds;
25
+ exports.pull = pull;
26
+ exports.pullMany = pullMany;
27
+ exports.q = q;
28
+ exports.queryStats = queryStats;
29
+ exports.release = release;
30
+ exports.reverseSchema = reverseSchema;
31
+ exports.rseekDatoms = rseekDatoms;
32
+ exports.schema = schema;
33
+ exports.seekDatoms = seekDatoms;
34
+ exports.since = since;
35
+ exports.transact = transact;
36
+ exports.validAll = validAll;
37
+ exports.validAt = validAt;
38
+ exports.validBetween = validBetween;
39
+ exports.validDuring = validDuring;
40
+ exports.isPromise = isPromise;
41
+ exports.listen = listen;
42
+ exports.randomUuid = randomUuid;
43
+ exports.unlisten = unlisten;
44
+ exports.uuid = uuid;
45
+ const tagSymbol = Symbol("datahike.tag");
46
+ const rawSymbol = Symbol("datahike.raw");
47
+ const peerSymbol = Symbol("datahike.peer");
48
+ const uuidSymbol = Symbol("datahike.uuid");
49
+ const handleTags = new Set([
50
+ "!datahike/Connection",
51
+ "!datahike/DB",
52
+ "!datahike/HistoricalDB",
53
+ "!datahike/SinceDB",
54
+ "!datahike/AsOfDB",
55
+ "!datahike/Entity",
56
+ "!datahike/TxReport",
57
+ ]);
58
+ function taggedObject(tag, raw, peer) {
59
+ const decoded = decodeValue(raw, peer);
60
+ const value = decoded !== null && typeof decoded === "object" && !Array.isArray(decoded)
61
+ ? { ...decoded }
62
+ : { value: decoded };
63
+ Object.defineProperties(value, {
64
+ [tagSymbol]: { value: tag },
65
+ [rawSymbol]: { value: raw },
66
+ [peerSymbol]: { value: peer },
67
+ });
68
+ return value;
69
+ }
70
+ function isTaggedObject(value) {
71
+ return value !== null && typeof value === "object" && tagSymbol in value;
72
+ }
73
+ function isUuid(value) {
74
+ return value !== null && typeof value === "object" && uuidSymbol in value;
75
+ }
76
+ function decodeValue(value, peer) {
77
+ if (Array.isArray(value)) {
78
+ if (value.length === 2 && typeof value[0] === "string") {
79
+ const tag = value[0];
80
+ const payload = value[1];
81
+ if (handleTags.has(tag))
82
+ return taggedObject(tag, payload, peer);
83
+ switch (tag) {
84
+ case "!kw":
85
+ return `:${String(payload)}`;
86
+ case "!sym":
87
+ return String(payload);
88
+ case "!set":
89
+ return Array.isArray(payload) ? payload.map((item) => decodeValue(item, peer)) : [];
90
+ case "!uuid":
91
+ return String(payload);
92
+ case "!date":
93
+ return new Date(Number(payload));
94
+ case "!datahike/Datom": {
95
+ const [e, a, v, tx, added] = payload.map((item) => decodeValue(item, peer));
96
+ return { e, a, v, tx, added };
97
+ }
98
+ }
99
+ }
100
+ return value.map((item) => decodeValue(item, peer));
101
+ }
102
+ if (value !== null && typeof value === "object") {
103
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, decodeValue(item, peer)]));
104
+ }
105
+ return value;
106
+ }
107
+ function encodeValue(value) {
108
+ if (isTaggedObject(value))
109
+ return [value[tagSymbol], value[rawSymbol]];
110
+ if (isUuid(value))
111
+ return ["!uuid", value.value];
112
+ if (value instanceof Date)
113
+ return ["!date", String(value.getTime())];
114
+ if (typeof value === "string") {
115
+ if (value.startsWith("\\:"))
116
+ return value.slice(1);
117
+ if (value.startsWith(":"))
118
+ return ["!kw", value.slice(1)];
119
+ return value;
120
+ }
121
+ if (Array.isArray(value))
122
+ return value.map(encodeValue);
123
+ if (value instanceof Set)
124
+ return ["!set", Array.from(value, encodeValue)];
125
+ if (value !== null && typeof value === "object") {
126
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
127
+ key.startsWith(":") ? key.slice(1) : key,
128
+ encodeValue(item),
129
+ ]));
130
+ }
131
+ return value;
132
+ }
133
+ function peerFromArgs(args) {
134
+ const peers = new Set();
135
+ const first = args[0];
136
+ if (first !== null && typeof first === "object") {
137
+ const peer = first["remote-peer"] ??
138
+ first[":remote-peer"] ??
139
+ first[peerSymbol];
140
+ if (peer)
141
+ peers.add(peer);
142
+ }
143
+ for (const arg of args.slice(1)) {
144
+ if (isTaggedObject(arg) && arg[peerSymbol])
145
+ peers.add(arg[peerSymbol]);
146
+ }
147
+ if (peers.size !== 1) {
148
+ throw new Error(peers.size === 0
149
+ ? "No remote-peer found in arguments."
150
+ : "Arguments refer to more than one remote-peer.");
151
+ }
152
+ return peers.values().next().value;
153
+ }
154
+ function withoutCredentials(args) {
155
+ return args.map((arg) => {
156
+ if (arg === null || typeof arg !== "object" || Array.isArray(arg) || isTaggedObject(arg))
157
+ return arg;
158
+ const copy = { ...arg };
159
+ for (const key of ["remote-peer", ":remote-peer", "writer", ":writer"]) {
160
+ const value = copy[key];
161
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
162
+ const nested = { ...value };
163
+ delete nested.token;
164
+ delete nested[":token"];
165
+ copy[key] = nested;
166
+ }
167
+ }
168
+ return copy;
169
+ });
170
+ }
171
+ function normalizeSetArguments(route, args) {
172
+ const copy = [...args];
173
+ if ((route === "force-branch" && Array.isArray(copy[2])) ||
174
+ (route === "merge-db" && Array.isArray(copy[1]))) {
175
+ const index = route === "force-branch" ? 2 : 1;
176
+ copy[index] = new Set(copy[index]);
177
+ }
178
+ return copy;
179
+ }
180
+ function base64url(bytes) {
181
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
182
+ let encoded = "";
183
+ for (let index = 0; index < bytes.length; index += 3) {
184
+ const value = (bytes[index] << 16) |
185
+ ((bytes[index + 1] ?? 0) << 8) |
186
+ (bytes[index + 2] ?? 0);
187
+ encoded += alphabet[(value >>> 18) & 63] + alphabet[(value >>> 12) & 63];
188
+ if (index + 1 < bytes.length)
189
+ encoded += alphabet[(value >>> 6) & 63];
190
+ if (index + 2 < bytes.length)
191
+ encoded += alphabet[value & 63];
192
+ }
193
+ return encoded;
194
+ }
195
+ async function responseValue(response, target, peer) {
196
+ const text = await response.text();
197
+ let decoded = null;
198
+ if (text) {
199
+ try {
200
+ decoded = decodeValue(JSON.parse(text), peer);
201
+ }
202
+ catch (cause) {
203
+ throw new Error(`Undecodable response from ${target}`, { cause });
204
+ }
205
+ }
206
+ if (!response.ok) {
207
+ const error = new Error(decoded?.msg ?? `HTTP ${response.status} from ${target}`);
208
+ Object.assign(error, decoded?.["ex-data"] ?? {}, { status: response.status, url: target });
209
+ throw error;
210
+ }
211
+ return decoded;
212
+ }
213
+ async function request(route, readable, args, create = false) {
214
+ const peer = peerFromArgs(args);
215
+ const encoded = new TextEncoder().encode(JSON.stringify(encodeValue(normalizeSetArguments(route, withoutCredentials(args)))));
216
+ const asGet = readable && encoded.byteLength <= 2048;
217
+ const base = `${peer.url}/${route}`;
218
+ const target = asGet ? `${base}?args=${base64url(encoded)}&f=json` : base;
219
+ const headers = { Accept: "application/json" };
220
+ if (!asGet)
221
+ headers["Content-Type"] = "application/json";
222
+ if (peer.token)
223
+ headers.Authorization = `token ${peer.token}`;
224
+ const response = await fetch(target, {
225
+ method: asGet ? "GET" : "POST",
226
+ headers,
227
+ ...(asGet ? {} : { body: encoded }),
228
+ });
229
+ const result = await responseValue(response, target, peer);
230
+ if (create && result !== null && typeof result === "object")
231
+ result["remote-peer"] = peer;
232
+ return result;
233
+ }
234
+ function uuid(value) {
235
+ const out = { value };
236
+ Object.defineProperty(out, uuidSymbol, { value: true });
237
+ return out;
238
+ }
239
+ function randomUuid() {
240
+ const bytes = new Uint8Array(16);
241
+ if (globalThis.crypto?.getRandomValues)
242
+ globalThis.crypto.getRandomValues(bytes);
243
+ else
244
+ for (let index = 0; index < bytes.length; index++)
245
+ bytes[index] = Math.floor(Math.random() * 256);
246
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
247
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
248
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
249
+ return uuid(`${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`);
250
+ }
251
+ function isPromise(value) {
252
+ return value instanceof Promise;
253
+ }
254
+ const listeners = new Map();
255
+ function connectionParts(conn) {
256
+ if (!isTaggedObject(conn) || conn[tagSymbol] !== "!datahike/Connection" || !conn[peerSymbol]) {
257
+ throw new Error("listen requires a remote connection handle.");
258
+ }
259
+ const storeId = decodeValue(conn[rawSymbol], conn[peerSymbol]);
260
+ const [store, branch = ":db"] = Array.isArray(storeId) ? storeId : [storeId, ":db"];
261
+ return { peer: conn[peerSymbol], store: String(store), branch: String(branch).replace(/^:/, "") };
262
+ }
263
+ function listenerId(conn, key) {
264
+ const { peer, store } = connectionParts(conn);
265
+ return `${peer.url}\0${store}\0${key}`;
266
+ }
267
+ function stopListener(id, listener) {
268
+ listener.stopped = true;
269
+ if (listener.timer !== undefined)
270
+ clearTimeout(listener.timer);
271
+ listener.controller?.abort();
272
+ if (listeners.get(id) === listener)
273
+ listeners.delete(id);
274
+ }
275
+ function remoteDbFromHead(conn, rawData) {
276
+ const { peer } = connectionParts(conn);
277
+ const raw = {
278
+ "store-id": [rawData["store-id"], rawData.branch],
279
+ "commit-id": rawData["commit-id"],
280
+ "max-eid": rawData["max-eid"],
281
+ "max-tx": rawData["max-tx"],
282
+ };
283
+ return taggedObject("!datahike/DB", raw, peer);
284
+ }
285
+ function deliverEvent(id, listener, event, raw) {
286
+ if (listener.stopped || listeners.get(id) !== listener)
287
+ return;
288
+ const { peer } = connectionParts(listener.conn);
289
+ const data = decodeValue(raw, peer);
290
+ const rawData = raw;
291
+ if (event === "report") {
292
+ listener.lastCommit = data["commit-id"];
293
+ listener.callback({
294
+ "db-after": remoteDbFromHead(listener.conn, rawData),
295
+ "db-before": null,
296
+ tempids: data.tempids,
297
+ "commit-id": data["commit-id"],
298
+ ...(Object.hasOwn(data, "tx-data") ? { "tx-data": data["tx-data"] } : {}),
299
+ ...(data.truncated ? { truncated: true } : {}),
300
+ });
301
+ }
302
+ else if (event === "resync" || event === "coalesced") {
303
+ listener.lastCommit = data["commit-id"];
304
+ listener.callback({ resync: true, "db-after": remoteDbFromHead(listener.conn, rawData) });
305
+ }
306
+ else if (event === "deleted") {
307
+ listener.callback({ deleted: true });
308
+ stopListener(id, listener);
309
+ }
310
+ }
311
+ function parseFrame(id, listener, frame) {
312
+ let event;
313
+ const data = [];
314
+ for (const line of frame.split("\n")) {
315
+ if (!line || line.startsWith(":"))
316
+ continue;
317
+ if (line.startsWith("event:"))
318
+ event = line.slice(6).trim();
319
+ else if (line.startsWith("data:"))
320
+ data.push(line.slice(5).trimStart());
321
+ }
322
+ if (event && data.length)
323
+ deliverEvent(id, listener, event, JSON.parse(data.join("\n")));
324
+ }
325
+ async function readStream(id, listener, body) {
326
+ const reader = body.getReader();
327
+ const decoder = new TextDecoder();
328
+ let pending = "";
329
+ while (!listener.stopped) {
330
+ const result = await reader.read();
331
+ if (result.done)
332
+ break;
333
+ const raw = pending + decoder.decode(result.value, { stream: true });
334
+ const trailingCr = raw.endsWith("\r");
335
+ const complete = trailingCr ? raw.slice(0, -1) : raw;
336
+ const frames = complete.replace(/\r\n?/g, "\n").split("\n\n");
337
+ pending = frames.pop() + (trailingCr ? "\r" : "");
338
+ for (const frame of frames)
339
+ if (frame)
340
+ parseFrame(id, listener, frame);
341
+ }
342
+ if (listener.stopped)
343
+ await reader.cancel();
344
+ }
345
+ function reconnect(id, listener) {
346
+ if (listener.stopped || listeners.get(id) !== listener)
347
+ return;
348
+ const delay = listener.backoff;
349
+ listener.backoff = Math.min(30_000, delay * 2);
350
+ listener.timer = setTimeout(() => {
351
+ listener.timer = undefined;
352
+ void connectListener(id, listener);
353
+ }, delay);
354
+ }
355
+ async function connectListener(id, listener) {
356
+ if (listener.stopped || listeners.get(id) !== listener)
357
+ return;
358
+ const { peer, store, branch } = connectionParts(listener.conn);
359
+ const query = new URLSearchParams({ store, branch });
360
+ if (listener.lastCommit)
361
+ query.set("since", listener.lastCommit);
362
+ const target = `${peer.url}/listen?${query}`;
363
+ const controller = new AbortController();
364
+ listener.controller = controller;
365
+ try {
366
+ const response = await fetch(target, {
367
+ method: "GET",
368
+ headers: {
369
+ Accept: "text/event-stream",
370
+ ...(peer.token ? { Authorization: `token ${peer.token}` } : {}),
371
+ },
372
+ signal: controller.signal,
373
+ });
374
+ if (!response.ok) {
375
+ if ([401, 403, 404].includes(response.status)) {
376
+ const error = new Error(`HTTP ${response.status} from ${target}`);
377
+ Object.assign(error, { status: response.status, url: target });
378
+ listener.callback({ error, status: response.status });
379
+ stopListener(id, listener);
380
+ return;
381
+ }
382
+ throw new Error(`HTTP ${response.status} from ${target}`);
383
+ }
384
+ listener.backoff = 500;
385
+ if (!response.body)
386
+ throw new Error(`No response body from ${target}`);
387
+ await readStream(id, listener, response.body);
388
+ reconnect(id, listener);
389
+ }
390
+ catch (error) {
391
+ if (!listener.stopped)
392
+ reconnect(id, listener);
393
+ }
394
+ }
395
+ function listen(conn, callback) {
396
+ const key = randomUuid().value;
397
+ const id = listenerId(conn, key);
398
+ const listener = { conn, callback, backoff: 500, stopped: false };
399
+ listeners.set(id, listener);
400
+ void connectListener(id, listener);
401
+ return key;
402
+ }
403
+ function unlisten(conn, key) {
404
+ const id = listenerId(conn, key);
405
+ const listener = listeners.get(id);
406
+ if (listener)
407
+ stopListener(id, listener);
408
+ }
409
+ // Generated from datahike.api.specification. DO NOT EDIT.
410
+ function asOf(...args) {
411
+ return request("as-of", true, args, false);
412
+ }
413
+ function branch(...args) {
414
+ return request("branch", false, args, false);
415
+ }
416
+ function branchAsDb(...args) {
417
+ return request("branch-as-db", false, args, false);
418
+ }
419
+ function branches(...args) {
420
+ return request("branches", false, args, false);
421
+ }
422
+ function commitAsDb(...args) {
423
+ return request("commit-as-db", false, args, false);
424
+ }
425
+ function commitId(...args) {
426
+ return request("commit-id", true, args, false);
427
+ }
428
+ function connect(...args) {
429
+ return request("connect", false, args, false);
430
+ }
431
+ function createDatabase(...args) {
432
+ return request("create-database", false, args, true);
433
+ }
434
+ function databaseExists(...args) {
435
+ return request("database-exists", false, args, false);
436
+ }
437
+ function datoms(...args) {
438
+ return request("datoms", true, args, false);
439
+ }
440
+ function db(...args) {
441
+ return request("db", false, args, false);
442
+ }
443
+ function deleteBranch(...args) {
444
+ return request("delete-branch", false, args, false);
445
+ }
446
+ function deleteDatabase(...args) {
447
+ return request("delete-database", false, args, false);
448
+ }
449
+ function entity(...args) {
450
+ return request("entity", true, args, false);
451
+ }
452
+ function entityDb(...args) {
453
+ return request("entity-db", true, args, false);
454
+ }
455
+ function gcStorage(...args) {
456
+ return request("gc-storage", false, args, false);
457
+ }
458
+ function history(...args) {
459
+ return request("history", true, args, false);
460
+ }
461
+ function indexRange(...args) {
462
+ return request("index-range", true, args, false);
463
+ }
464
+ function loadEntities(...args) {
465
+ return request("load-entities", false, args, false);
466
+ }
467
+ function mergeDb(...args) {
468
+ return request("merge-db", false, args, false);
469
+ }
470
+ function metrics(...args) {
471
+ return request("metrics", true, args, false);
472
+ }
473
+ function parentCommitIds(...args) {
474
+ return request("parent-commit-ids", true, args, false);
475
+ }
476
+ function pull(...args) {
477
+ return request("pull", true, args, false);
478
+ }
479
+ function pullMany(...args) {
480
+ return request("pull-many", true, args, false);
481
+ }
482
+ function q(...args) {
483
+ return request("q", true, args, false);
484
+ }
485
+ function queryStats(...args) {
486
+ return request("query-stats", true, args, false);
487
+ }
488
+ function release(...args) {
489
+ return request("release", false, args, false);
490
+ }
491
+ function reverseSchema(...args) {
492
+ return request("reverse-schema", true, args, false);
493
+ }
494
+ function rseekDatoms(...args) {
495
+ return request("rseek-datoms", true, args, false);
496
+ }
497
+ function schema(...args) {
498
+ return request("schema", true, args, false);
499
+ }
500
+ function seekDatoms(...args) {
501
+ return request("seek-datoms", true, args, false);
502
+ }
503
+ function since(...args) {
504
+ return request("since", true, args, false);
505
+ }
506
+ function transact(...args) {
507
+ return request("transact", false, args, false);
508
+ }
509
+ function validAll(...args) {
510
+ return request("valid-all", true, args, false);
511
+ }
512
+ function validAt(...args) {
513
+ return request("valid-at", true, args, false);
514
+ }
515
+ function validBetween(...args) {
516
+ return request("valid-between", true, args, false);
517
+ }
518
+ function validDuring(...args) {
519
+ return request("valid-during", true, args, false);
520
+ }
521
+ exports.default = { asOf, branch, branchAsDb, branches, commitAsDb, commitId, connect, createDatabase, databaseExists, datoms, db, deleteBranch, deleteDatabase, entity, entityDb, gcStorage, history, indexRange, loadEntities, mergeDb, metrics, parentCommitIds, pull, pullMany, q, queryStats, release, reverseSchema, rseekDatoms, schema, seekDatoms, since, transact, validAll, validAt, validBetween, validDuring, isPromise, listen, randomUuid, unlisten, uuid };
522
+
523
+ module.exports = exports.default;