@delali/sirannon-db 0.3.4-next.62 → 0.3.4
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/README.md +79 -56
- package/dist/backup/index.d.ts +44 -45
- package/dist/backup/index.mjs +7 -7
- package/dist/backup-scheduler/index.d.ts +42 -41
- package/dist/backup-scheduler/index.mjs +4 -4
- package/dist/baseline-Co3iIsN_.d.ts +19 -0
- package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
- package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
- package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
- package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
- package/dist/chunk-4KASJKKK.mjs +2501 -0
- package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
- package/dist/chunk-55YRLSM2.mjs +57 -0
- package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
- package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
- package/dist/chunk-ADNWEHGZ.mjs +299 -0
- package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
- package/dist/chunk-BVMZJOVM.mjs +5 -0
- package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
- package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
- package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
- package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
- package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
- package/dist/chunk-HR7K3GZW.mjs +36 -0
- package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
- package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
- package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
- package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
- package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
- package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
- package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
- package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
- package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
- package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
- package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
- package/dist/chunk-WOMADPM4.mjs +12 -0
- package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
- package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
- package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
- package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
- package/dist/client/index.d.ts +135 -137
- package/dist/client/index.mjs +177 -82
- package/dist/client/topology.d.ts +31 -31
- package/dist/client/topology.mjs +42 -23
- package/dist/client-base-BxTocU1x.d.ts +398 -0
- package/dist/client-streams-YKANXMWO.mjs +112 -0
- package/dist/codegen/cli.mjs +4 -4
- package/dist/codegen/index.d.ts +36 -29
- package/dist/codegen/index.mjs +4 -4
- package/dist/core/index.d.ts +130 -115
- package/dist/core/index.mjs +387 -297
- package/dist/core/writer-worker.mjs +3 -3
- package/dist/database-CGDsXW1K.d.ts +959 -0
- package/dist/database-backup-DcLhxoa1.d.ts +143 -0
- package/dist/driver/better-sqlite3.d.ts +11 -10
- package/dist/driver/better-sqlite3.mjs +11 -11
- package/dist/driver/bun.d.ts +9 -8
- package/dist/driver/expo.d.ts +6 -7
- package/dist/driver/node.d.ts +11 -10
- package/dist/driver/node.mjs +13 -11
- package/dist/driver/wa-sqlite.d.ts +6 -6
- package/dist/errors-CJUkQ-KL.d.ts +199 -0
- package/dist/file-migrations/index.d.ts +20 -18
- package/dist/file-migrations/index.mjs +3 -3
- package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
- package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
- package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
- package/dist/protocol-DFpNNsIT.d.ts +153 -0
- package/dist/query-types-5B02ixH0.d.ts +129 -0
- package/dist/react/index.d.ts +22 -22
- package/dist/replication/coordinator/etcd.d.ts +37 -31
- package/dist/replication/coordinator/etcd.mjs +296 -131
- package/dist/replication/index.d.ts +201 -161
- package/dist/replication/index.mjs +630 -529
- package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
- package/dist/server/index.d.ts +201 -191
- package/dist/server/index.mjs +736 -619
- package/dist/server-options-aYtCkefX.d.ts +317 -0
- package/dist/server-streams-24XL4T43.mjs +254 -0
- package/dist/sirannon-J3EgPVD7.d.ts +179 -0
- package/dist/transport/grpc.d.ts +37 -24
- package/dist/transport/grpc.mjs +83 -3199
- package/dist/transport/memory.d.ts +25 -26
- package/dist/transport/memory.mjs +18 -9
- package/dist/types-BrAiDGOb.d.ts +505 -0
- package/dist/types-CEJG0eFS.d.ts +88 -0
- package/dist/types-Dc8oWlxj.d.ts +1580 -0
- package/dist/types-DqODKeOq.d.ts +123 -0
- package/dist/types-guEKSzMr.d.ts +367 -0
- package/package.json +7 -7
- package/dist/baseline-D93hcIEE.d.ts +0 -17
- package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
- package/dist/client-base-Cmd9EVme.d.ts +0 -397
- package/dist/database-BLQvqjsw.d.ts +0 -917
- package/dist/database-backup-B7oszQ2n.d.ts +0 -141
- package/dist/errors-Dei4GdBb.d.ts +0 -196
- package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
- package/dist/primary-wins-B0np8JS3.d.ts +0 -85
- package/dist/protocol-HI-nY8DD.d.ts +0 -152
- package/dist/query-types-p1liOP-b.d.ts +0 -127
- package/dist/restore-options-CksYsH1l.d.ts +0 -83
- package/dist/server-options-Bj5iJnjx.d.ts +0 -292
- package/dist/sirannon-BPxC5tC2.d.ts +0 -178
- package/dist/types-B0EhgDbr.d.ts +0 -340
- package/dist/types-CbjfRwrK.d.ts +0 -499
- package/dist/types-CjhxcjhA.d.ts +0 -123
- package/dist/types-DPSmjU54.d.ts +0 -1518
- package/dist/types-DTO4CYhW.d.ts +0 -88
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { R as ReplicationAck, F as ForwardedTransaction, a as ForwardedTransactionResult, S as SyncRequest, b as SyncBatch, c as SyncComplete, d as SyncAck, N as NodeInfo, e as ReplicationTransport, T as TransportConfig } from '../types-
|
|
2
|
-
import { R as ReplicationBatch } from '../types-
|
|
3
|
-
import '../change-tracker-
|
|
4
|
-
import '../types-
|
|
5
|
-
import '../query-types-
|
|
6
|
-
import '../types-
|
|
1
|
+
import { R as ReplicationAck, F as ForwardedTransaction, a as ForwardedTransactionResult, S as SyncRequest, b as SyncBatch, c as SyncComplete, d as SyncAck, N as NodeInfo, e as ReplicationTransport, T as TransportConfig } from '../types-BrAiDGOb.js';
|
|
2
|
+
import { R as ReplicationBatch } from '../types-DqODKeOq.js';
|
|
3
|
+
import '../change-tracker-DqCdeEyx.js';
|
|
4
|
+
import '../types-Dc8oWlxj.js';
|
|
5
|
+
import '../query-types-5B02ixH0.js';
|
|
6
|
+
import '../types-guEKSzMr.js';
|
|
7
7
|
|
|
8
8
|
type BatchHandler = (batch: ReplicationBatch, fromPeerId: string) => Promise<void>;
|
|
9
9
|
type AckHandler = (ack: ReplicationAck, fromPeerId: string) => void;
|
|
@@ -16,15 +16,15 @@ type SyncCompleteHandler = (complete: SyncComplete, fromPeerId: string) => Promi
|
|
|
16
16
|
type SyncAckHandler = (ack: SyncAck, fromPeerId: string) => void;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Sends replication messages between nodes that share one process, for tests
|
|
20
|
+
* and for single-process setups with several nodes.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
* microtask
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* The transport delivers each message through a shared {@link MemoryBus} in a
|
|
23
|
+
* later microtask (`queueMicrotask`), so that delivery stays asynchronous, as
|
|
24
|
+
* it is over a network, with no I/O. For a forwarded write, the transport
|
|
25
|
+
* calls the primary's handler directly and returns its result. Every send
|
|
26
|
+
* method validates its message first and throws a `TransportError` for a
|
|
27
|
+
* malformed one.
|
|
28
28
|
*
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
@@ -48,9 +48,9 @@ declare class InMemoryTransport implements ReplicationTransport {
|
|
|
48
48
|
private syncAckHandler;
|
|
49
49
|
constructor(bus: MemoryBus);
|
|
50
50
|
private get role();
|
|
51
|
-
/**
|
|
51
|
+
/** Joins the bus and connects this node to every other connected transport on the bus. */
|
|
52
52
|
connect(localNodeId: string, config: TransportConfig): Promise<void>;
|
|
53
|
-
/**
|
|
53
|
+
/** Leaves the bus and disconnects this node from every peer. */
|
|
54
54
|
disconnect(): Promise<void>;
|
|
55
55
|
/** Sends one batch of changes to one peer. */
|
|
56
56
|
send(peerId: string, batch: ReplicationBatch): Promise<void>;
|
|
@@ -64,15 +64,15 @@ declare class InMemoryTransport implements ReplicationTransport {
|
|
|
64
64
|
requestSync(peerId: string, request: SyncRequest): Promise<void>;
|
|
65
65
|
/** Sends one page of first-sync table data. */
|
|
66
66
|
sendSyncBatch(peerId: string, batch: SyncBatch): Promise<void>;
|
|
67
|
-
/** Tells a joining node that first sync
|
|
67
|
+
/** Tells a joining node that first sync is complete, and sends the manifests that the node checks its copy against. */
|
|
68
68
|
sendSyncComplete(peerId: string, complete: SyncComplete): Promise<void>;
|
|
69
|
-
/**
|
|
69
|
+
/** Tells the source whether this joining node stored one first-sync page. */
|
|
70
70
|
sendSyncAck(peerId: string, ack: SyncAck): Promise<void>;
|
|
71
71
|
/** Registers the handler that applies incoming change batches. */
|
|
72
72
|
onBatchReceived(handler: BatchHandler): void;
|
|
73
73
|
/** Registers the handler that records incoming acknowledgements. */
|
|
74
74
|
onAckReceived(handler: AckHandler): void;
|
|
75
|
-
/** Registers the handler that
|
|
75
|
+
/** Registers the handler that executes a write that a replica forwards. */
|
|
76
76
|
onForwardReceived(handler: ForwardHandler): void;
|
|
77
77
|
/** Registers the handler that serves a first-sync request. */
|
|
78
78
|
onSyncRequested(handler: SyncRequestHandler): void;
|
|
@@ -82,11 +82,11 @@ declare class InMemoryTransport implements ReplicationTransport {
|
|
|
82
82
|
onSyncCompleteReceived(handler: SyncCompleteHandler): void;
|
|
83
83
|
/** Registers the handler that records first-sync page acknowledgements. */
|
|
84
84
|
onSyncAckReceived(handler: SyncAckHandler): void;
|
|
85
|
-
/** Registers the handler that
|
|
85
|
+
/** Registers the handler that the transport calls when a peer connects. */
|
|
86
86
|
onPeerConnected(handler: PeerConnectedHandler): void;
|
|
87
|
-
/** Registers the handler that
|
|
87
|
+
/** Registers the handler that the transport calls when a peer disconnects. */
|
|
88
88
|
onPeerDisconnected(handler: PeerDisconnectedHandler): void;
|
|
89
|
-
/** Returns every connected peer, keyed by
|
|
89
|
+
/** Returns every connected peer, keyed by node ID. */
|
|
90
90
|
peers(): ReadonlyMap<string, NodeInfo>;
|
|
91
91
|
private _receiveBatch;
|
|
92
92
|
private _receiveAck;
|
|
@@ -99,10 +99,9 @@ declare class InMemoryTransport implements ReplicationTransport {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* microtask scheduling, simulating async network delivery with no I/O.
|
|
102
|
+
* Connects {@link InMemoryTransport} instances inside one process. Each
|
|
103
|
+
* transport joins the bus in `connect()`. A sending transport looks up its
|
|
104
|
+
* target on the bus and calls the target's receive method, with no network I/O.
|
|
106
105
|
*
|
|
107
106
|
* @public
|
|
108
107
|
*/
|
|
@@ -63,7 +63,7 @@ function isValidAck(ack) {
|
|
|
63
63
|
function isValidForwardedTransaction(req) {
|
|
64
64
|
if (typeof req !== "object" || req === null) return false;
|
|
65
65
|
const r = req;
|
|
66
|
-
return typeof r.requestId === "string" && Array.isArray(r.statements) && optionalString(r.groupId) && optionalBigint(r.primaryTerm);
|
|
66
|
+
return typeof r.requestId === "string" && Array.isArray(r.statements) && optionalString(r.groupId) && optionalBigint(r.primaryTerm) && optionalWriteConcern(r.writeConcern);
|
|
67
67
|
}
|
|
68
68
|
function isValidSyncRequest(req) {
|
|
69
69
|
if (typeof req !== "object" || req === null) return false;
|
|
@@ -91,6 +91,15 @@ function optionalString(value) {
|
|
|
91
91
|
function optionalBigint(value) {
|
|
92
92
|
return value === void 0 || typeof value === "bigint";
|
|
93
93
|
}
|
|
94
|
+
function optionalWriteConcern(value) {
|
|
95
|
+
if (value === void 0) return true;
|
|
96
|
+
if (typeof value !== "object" || value === null) return false;
|
|
97
|
+
const concern = value;
|
|
98
|
+
const knownLevel = concern.level === "local" || concern.level === "majority" || concern.level === "all";
|
|
99
|
+
const timeoutMs = concern.timeoutMs;
|
|
100
|
+
const validTimeout = timeoutMs === void 0 || typeof timeoutMs === "number" && Number.isSafeInteger(timeoutMs) && timeoutMs > 0;
|
|
101
|
+
return knownLevel && validTimeout;
|
|
102
|
+
}
|
|
94
103
|
function optionalNonNegativeInteger(value) {
|
|
95
104
|
return value === void 0 || typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
96
105
|
}
|
|
@@ -120,7 +129,7 @@ var InMemoryTransport = class {
|
|
|
120
129
|
get role() {
|
|
121
130
|
return this.localRole;
|
|
122
131
|
}
|
|
123
|
-
/**
|
|
132
|
+
/** Joins the bus and connects this node to every other connected transport on the bus. */
|
|
124
133
|
async connect(localNodeId, config) {
|
|
125
134
|
if (this.connected) {
|
|
126
135
|
throw new TransportError("Transport is already connected");
|
|
@@ -166,7 +175,7 @@ var InMemoryTransport = class {
|
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
}
|
|
169
|
-
/**
|
|
178
|
+
/** Leaves the bus and disconnects this node from every peer. */
|
|
170
179
|
async disconnect() {
|
|
171
180
|
if (!this.connected) return;
|
|
172
181
|
this.connected = false;
|
|
@@ -266,7 +275,7 @@ var InMemoryTransport = class {
|
|
|
266
275
|
});
|
|
267
276
|
});
|
|
268
277
|
}
|
|
269
|
-
/** Tells a joining node that first sync
|
|
278
|
+
/** Tells a joining node that first sync is complete, and sends the manifests that the node checks its copy against. */
|
|
270
279
|
async sendSyncComplete(peerId, complete) {
|
|
271
280
|
this.ensureConnected();
|
|
272
281
|
if (!isValidSyncComplete(complete)) throw new TransportError("Invalid sync complete structure");
|
|
@@ -278,7 +287,7 @@ var InMemoryTransport = class {
|
|
|
278
287
|
});
|
|
279
288
|
});
|
|
280
289
|
}
|
|
281
|
-
/**
|
|
290
|
+
/** Tells the source whether this joining node stored one first-sync page. */
|
|
282
291
|
async sendSyncAck(peerId, ack) {
|
|
283
292
|
this.ensureConnected();
|
|
284
293
|
if (!isValidSyncAck(ack)) throw new TransportError("Invalid sync ack structure");
|
|
@@ -297,7 +306,7 @@ var InMemoryTransport = class {
|
|
|
297
306
|
onAckReceived(handler) {
|
|
298
307
|
this.ackHandler = handler;
|
|
299
308
|
}
|
|
300
|
-
/** Registers the handler that
|
|
309
|
+
/** Registers the handler that executes a write that a replica forwards. */
|
|
301
310
|
onForwardReceived(handler) {
|
|
302
311
|
this.forwardHandler = handler;
|
|
303
312
|
}
|
|
@@ -317,15 +326,15 @@ var InMemoryTransport = class {
|
|
|
317
326
|
onSyncAckReceived(handler) {
|
|
318
327
|
this.syncAckHandler = handler;
|
|
319
328
|
}
|
|
320
|
-
/** Registers the handler that
|
|
329
|
+
/** Registers the handler that the transport calls when a peer connects. */
|
|
321
330
|
onPeerConnected(handler) {
|
|
322
331
|
this.peerConnectedHandler = handler;
|
|
323
332
|
}
|
|
324
|
-
/** Registers the handler that
|
|
333
|
+
/** Registers the handler that the transport calls when a peer disconnects. */
|
|
325
334
|
onPeerDisconnected(handler) {
|
|
326
335
|
this.peerDisconnectedHandler = handler;
|
|
327
336
|
}
|
|
328
|
-
/** Returns every connected peer, keyed by
|
|
337
|
+
/** Returns every connected peer, keyed by node ID. */
|
|
329
338
|
peers() {
|
|
330
339
|
return this.connectedPeers;
|
|
331
340
|
}
|