@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
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { h as BackupChainBase, i as BackupChainChange, g as BackupChain, k as BackupChainRecord, B as BackupDestination, I as SQLiteConnection, P as DriverCapabilities, Q as BackupEngine, p as BackupFileReport, y as BackupToDestinationOptions, f as BackupRunReport, O as BackupScheduleOptions, n as BackupCycleOptions, o as BackupCycleStatus, z as BackupVerifyResult } from './types-Dc8oWlxj.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The backup operations that one runtime supports, so that a caller can check
|
|
5
|
+
* them before it starts a backup. A runtime whose driver lacks a stepped copy
|
|
6
|
+
* reports `fullCopy` as false, along with every operation that depends on it.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
interface BackupCapabilities {
|
|
11
|
+
/** Whether this runtime can copy an open database while writes continue. */
|
|
12
|
+
fullCopy: boolean;
|
|
13
|
+
/** Whether this runtime can send a full copy to the destination without writing a local file. */
|
|
14
|
+
streamedCopy: boolean;
|
|
15
|
+
/** Whether this runtime can write a full copy to a local file and then send that file to the destination. */
|
|
16
|
+
stagedCopy: boolean;
|
|
17
|
+
/** The local disk space that a full copy needs, which is `'equal-to-backup'` when only the staged route is available. */
|
|
18
|
+
localDiskRequired: 'none' | 'equal-to-backup';
|
|
19
|
+
/** Whether this runtime can repeat a full copy on a schedule. */
|
|
20
|
+
schedule: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The records that one restore reads, and the moment that the restored database reflects.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
interface BackupRestorePlan {
|
|
27
|
+
/** The chain that the restore reads from. */
|
|
28
|
+
chainId: string;
|
|
29
|
+
/** The full copy to start from. */
|
|
30
|
+
base: BackupChainBase;
|
|
31
|
+
/** The change pieces to apply on top of it, oldest first. */
|
|
32
|
+
changes: BackupChainChange[];
|
|
33
|
+
/**
|
|
34
|
+
* The moment, in epoch milliseconds, that the restored database reflects.
|
|
35
|
+
* It is the capture time of the last change piece in the plan, or the finish
|
|
36
|
+
* time of the full copy where the plan holds no change piece, so it falls at
|
|
37
|
+
* or before the moment that you ask for.
|
|
38
|
+
*/
|
|
39
|
+
restoresTo: number;
|
|
40
|
+
}
|
|
41
|
+
/** The earliest moment that a restore must still reach.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
interface BackupSafeToDeleteOptions {
|
|
45
|
+
/**
|
|
46
|
+
* The earliest moment, in epoch milliseconds, that a restore must still
|
|
47
|
+
* reach. When you leave it out, the answer lists only the records that no
|
|
48
|
+
* restore can use.
|
|
49
|
+
*/
|
|
50
|
+
restorableFrom?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns what a restore to a given moment reads: the newest full copy that
|
|
54
|
+
* finished at or before that moment, and every change piece of its chain that
|
|
55
|
+
* Sirannon captured up to it.
|
|
56
|
+
*
|
|
57
|
+
* The plan also states the moment that the restored database reflects, which
|
|
58
|
+
* is the capture time of its last piece. Each change piece holds every write
|
|
59
|
+
* from one capture interval, so a restore stops at a piece boundary, which can
|
|
60
|
+
* fall before the exact millisecond that you name.
|
|
61
|
+
*
|
|
62
|
+
* This throws `BACKUP_CHAIN_BROKEN` where no full copy finished at or before
|
|
63
|
+
* the moment. It throws the same code, naming the missing piece, where the
|
|
64
|
+
* chain has a gap before that moment, since a restore that stopped at the gap
|
|
65
|
+
* would lose every write after it.
|
|
66
|
+
*
|
|
67
|
+
* @param chains - The chains at a destination, as {@link readBackupChains} returns them.
|
|
68
|
+
* @param moment - The moment to restore to, in epoch milliseconds.
|
|
69
|
+
* @returns The full copy, the change pieces to apply, and the moment that the restored database reflects.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
declare function planBackupRestore(chains: readonly BackupChain[], moment: number): BackupRestorePlan;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the backup records that no restore needs any longer, so that you can
|
|
76
|
+
* delete them from the destination yourself.
|
|
77
|
+
*
|
|
78
|
+
* The list always includes the change pieces of a chain whose full copy is
|
|
79
|
+
* gone, and every change piece after a gap in a chain, since a restore can
|
|
80
|
+
* replay nothing past the gap. When you pass `restorableFrom`, the list also
|
|
81
|
+
* includes every chain whose full copy finished before the full copy that a
|
|
82
|
+
* restore to that moment would start from.
|
|
83
|
+
*
|
|
84
|
+
* @param chains - The chains at a destination, as {@link readBackupChains} returns them.
|
|
85
|
+
* @param options - The earliest moment that a restore must still reach.
|
|
86
|
+
* @returns The records that you can delete, oldest chain first.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
declare function backupPiecesSafeToDelete(chains: readonly BackupChain[], options?: BackupSafeToDeleteOptions): BackupChainRecord[];
|
|
91
|
+
|
|
92
|
+
type RunExclusive = (op: () => Promise<void>) => Promise<void>;
|
|
93
|
+
/** The destination and chain name under which Sirannon stores one database's backups, with the directory where it stages each capture.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
interface BackupChainLocation {
|
|
97
|
+
/** The destination that Sirannon sends the backup pieces and chain records to. */
|
|
98
|
+
destination: BackupDestination;
|
|
99
|
+
/** The name that Sirannon lists this database's chains under at the destination. */
|
|
100
|
+
chainName: string;
|
|
101
|
+
/** The directory where the backup cycle writes each capture before it sends that capture to the destination. */
|
|
102
|
+
stagingDir: string;
|
|
103
|
+
/** The deadline, in milliseconds, that the operator set on each call to the destination, when the operator set one. */
|
|
104
|
+
destinationTimeoutMs?: number;
|
|
105
|
+
}
|
|
106
|
+
declare class DatabaseBackupController {
|
|
107
|
+
private readonly runExclusive;
|
|
108
|
+
private readonly acquireWriter;
|
|
109
|
+
private readonly driverCapabilities;
|
|
110
|
+
private readonly databaseId;
|
|
111
|
+
private readonly sourcePath;
|
|
112
|
+
private readonly engine?;
|
|
113
|
+
private readonly cancellers;
|
|
114
|
+
private cycle;
|
|
115
|
+
private cycleOptions;
|
|
116
|
+
private cycleStarted;
|
|
117
|
+
constructor(runExclusive: RunExclusive, acquireWriter: () => SQLiteConnection, driverCapabilities: DriverCapabilities, databaseId: string, sourcePath: string, engine?: BackupEngine | undefined);
|
|
118
|
+
private require;
|
|
119
|
+
private requireCycle;
|
|
120
|
+
capabilities(): BackupCapabilities;
|
|
121
|
+
backup(destPath: string): Promise<BackupFileReport>;
|
|
122
|
+
backupTo(options: BackupToDestinationOptions): Promise<BackupRunReport>;
|
|
123
|
+
schedule(options: BackupScheduleOptions): void;
|
|
124
|
+
/**
|
|
125
|
+
* Builds the backup cycle and starts it without awaiting the first turn, which
|
|
126
|
+
* copies the whole database, so that the open can return first. When the start
|
|
127
|
+
* fails, this method passes the error to the `onError` callback in the cycle
|
|
128
|
+
* options.
|
|
129
|
+
*/
|
|
130
|
+
startCycle(options: BackupCycleOptions): void;
|
|
131
|
+
captureChanges(): Promise<BackupRunReport | undefined>;
|
|
132
|
+
chains(): Promise<BackupChain[]>;
|
|
133
|
+
status(): BackupCycleStatus;
|
|
134
|
+
location(): BackupChainLocation;
|
|
135
|
+
verify(name: string): Promise<BackupVerifyResult>;
|
|
136
|
+
restorePlan(moment: number): Promise<BackupRestorePlan>;
|
|
137
|
+
piecesSafeToDelete(options?: BackupSafeToDeleteOptions): Promise<BackupChainRecord[]>;
|
|
138
|
+
/** Stops the backup cycle after one last capture, which sends the writes made since the previous turn to the destination. */
|
|
139
|
+
stopCycle(): Promise<void>;
|
|
140
|
+
cancelAll(): void;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { type BackupCapabilities as B, DatabaseBackupController as D, type BackupChainLocation as a, type BackupRestorePlan as b, type BackupSafeToDeleteOptions as c, backupPiecesSafeToDelete as d, planBackupRestore as p };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SQLiteDriver } from '../types-
|
|
2
|
-
import '../query-types-
|
|
1
|
+
import { S as SQLiteDriver } from '../types-Dc8oWlxj.js';
|
|
2
|
+
import '../query-types-5B02ixH0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Settings for the better-sqlite3 driver.
|
|
@@ -8,22 +8,23 @@ import '../query-types-p1liOP-b.js';
|
|
|
8
8
|
*/
|
|
9
9
|
interface BetterSqlite3Options {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* The number of milliseconds that SQLite waits for the database lock before it returns a busy error, which defaults to 5000.
|
|
12
12
|
*/
|
|
13
13
|
busyTimeout?: number;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* destination. It defaults to the
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* The path to the compiled extension that Sirannon uses to stream a backup
|
|
16
|
+
* to a destination that the caller supplies. It defaults to the library in
|
|
17
|
+
* the `@delali/sirannon-vfs-*` package for this platform, when that package
|
|
18
|
+
* is installed. Set it on a platform without a published binary, so that
|
|
19
|
+
* Sirannon streams backups through an extension that you build yourself.
|
|
19
20
|
*/
|
|
20
21
|
vfsExtensionPath?: string;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
+
* Returns a driver that opens SQLite databases on Node through the `better-sqlite3` native module.
|
|
24
25
|
*
|
|
25
|
-
* @param driverOptions -
|
|
26
|
-
* @returns The driver,
|
|
26
|
+
* @param driverOptions - The busy timeout and the path to the backup streaming extension.
|
|
27
|
+
* @returns The driver, which you can pass to a `Sirannon` registry.
|
|
27
28
|
*
|
|
28
29
|
* @public
|
|
29
30
|
*/
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { nodeResolveExtensionPath, nodeWriterContext, nodeBackupEngine, nodeStreamingSupport, WriterWorker, createStatementCache, loadThroughRuntime, narrowSafeBigInt, narrowRowIntegers, narrowRowsIntegers } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import { defineDriver } from '../chunk-
|
|
1
|
+
import { nodeResolveExtensionPath, nodeWriterContext, nodeBackupEngine, nodeStreamingSupport, WriterWorker, createStatementCache, loadThroughRuntime, narrowSafeBigInt, narrowRowIntegers, narrowRowsIntegers } from '../chunk-NZGSDALX.mjs';
|
|
2
|
+
import '../chunk-DX4WGJL7.mjs';
|
|
3
|
+
import '../chunk-NVSQ2T5Q.mjs';
|
|
4
|
+
import { defineDriver } from '../chunk-IEKIYO4V.mjs';
|
|
5
5
|
import '../chunk-W67A4H2E.mjs';
|
|
6
6
|
import '../chunk-MVSES6MS.mjs';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-
|
|
10
|
-
import '../chunk-
|
|
11
|
-
import { synchronousPragmaValue } from '../chunk-
|
|
12
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-6AOJCNRU.mjs';
|
|
8
|
+
import '../chunk-QGVRRKB2.mjs';
|
|
9
|
+
import '../chunk-KJLNYOOL.mjs';
|
|
10
|
+
import '../chunk-R7GBXNTO.mjs';
|
|
11
|
+
import { synchronousPragmaValue } from '../chunk-YCMB6GR4.mjs';
|
|
12
|
+
import '../chunk-CZL4D3BM.mjs';
|
|
13
13
|
import '../chunk-QBBLSQHQ.mjs';
|
|
14
|
-
import { BackupError } from '../chunk-
|
|
14
|
+
import { BackupError } from '../chunk-KINDFBQP.mjs';
|
|
15
15
|
|
|
16
16
|
// src/drivers/better-sqlite3/copy.ts
|
|
17
17
|
var OPEN_TRANSACTION_MESSAGE = "A stepped copy cannot start while a transaction is open on the same connection, because SQLite copies no pages and reports success";
|
package/dist/driver/bun.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SQLiteDriver } from '../types-
|
|
2
|
-
import '../query-types-
|
|
1
|
+
import { S as SQLiteDriver } from '../types-Dc8oWlxj.js';
|
|
2
|
+
import '../query-types-5B02ixH0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Settings for the driver built on Bun's built-in SQLite.
|
|
@@ -8,18 +8,19 @@ import '../query-types-p1liOP-b.js';
|
|
|
8
8
|
*/
|
|
9
9
|
interface BunSqliteOptions {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* The number of milliseconds that SQLite waits for the database lock before it returns a busy error, which defaults to 5000.
|
|
12
12
|
*/
|
|
13
13
|
busyTimeout?: number;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Returns a driver that opens SQLite databases through `bun:sqlite`, which is built into the Bun runtime.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* The driver opens each connection with `safeIntegers`, so SQLite returns every
|
|
19
|
+
* integer as a `bigint`, and the driver converts each one within the safe range
|
|
20
|
+
* back to a `number`. A value beyond `Number.MAX_SAFE_INTEGER` therefore stays exact.
|
|
20
21
|
*
|
|
21
|
-
* @param driverOptions -
|
|
22
|
-
* @returns The driver,
|
|
22
|
+
* @param driverOptions - The busy timeout for each connection.
|
|
23
|
+
* @returns The driver, which you can pass to a `Sirannon` registry under Bun.
|
|
23
24
|
*
|
|
24
25
|
* @public
|
|
25
26
|
*/
|
package/dist/driver/expo.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { S as SQLiteDriver } from '../types-
|
|
2
|
-
import '../query-types-
|
|
1
|
+
import { S as SQLiteDriver } from '../types-Dc8oWlxj.js';
|
|
2
|
+
import '../query-types-5B02ixH0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Returns a driver that opens SQLite databases on a device through `expo-sqlite`.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* single connection.
|
|
7
|
+
* The driver sets `multipleConnections` to `false`, so Sirannon opens no reader
|
|
8
|
+
* pool and sends every read and write for a database through one connection.
|
|
10
9
|
*
|
|
11
|
-
* @returns The driver,
|
|
10
|
+
* @returns The driver, which you can pass to a `Sirannon` registry in a React Native app.
|
|
12
11
|
*
|
|
13
12
|
* @public
|
|
14
13
|
*/
|
package/dist/driver/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SQLiteDriver } from '../types-
|
|
2
|
-
import '../query-types-
|
|
1
|
+
import { S as SQLiteDriver } from '../types-Dc8oWlxj.js';
|
|
2
|
+
import '../query-types-5B02ixH0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Settings for the driver built on Node's own SQLite module.
|
|
@@ -8,22 +8,23 @@ import '../query-types-p1liOP-b.js';
|
|
|
8
8
|
*/
|
|
9
9
|
interface NodeSqliteOptions {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* The number of milliseconds that SQLite waits for the database lock before it returns a busy error, which defaults to 5000.
|
|
12
12
|
*/
|
|
13
13
|
busyTimeout?: number;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* destination. It defaults to the
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* The path to the compiled extension that Sirannon uses to stream a backup
|
|
16
|
+
* to a destination that the caller supplies. It defaults to the library in
|
|
17
|
+
* the `@delali/sirannon-vfs-*` package for this platform, when that package
|
|
18
|
+
* is installed. Set it on a platform without a published binary, so that
|
|
19
|
+
* Sirannon streams backups through an extension that you build yourself.
|
|
19
20
|
*/
|
|
20
21
|
vfsExtensionPath?: string;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
+
* Returns a driver that opens SQLite databases through Node's built-in `node:sqlite` module, so your project installs no native dependency.
|
|
24
25
|
*
|
|
25
|
-
* @param driverOptions -
|
|
26
|
-
* @returns The driver,
|
|
26
|
+
* @param driverOptions - The busy timeout and the path to the backup streaming extension.
|
|
27
|
+
* @returns The driver, which you can pass to a `Sirannon` registry.
|
|
27
28
|
*
|
|
28
29
|
* @public
|
|
29
30
|
*/
|
package/dist/driver/node.mjs
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { nodeResolveExtensionPath, nodeWriterContext, createStatementCache, nodeBackupEngine, nodeStreamingSupport, WriterWorker, loadThroughRuntime, narrowSafeBigInt, narrowRowIntegers, narrowRowsIntegers } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import { defineDriver } from '../chunk-
|
|
1
|
+
import { nodeResolveExtensionPath, nodeWriterContext, createStatementCache, nodeBackupEngine, nodeStreamingSupport, WriterWorker, loadThroughRuntime, narrowSafeBigInt, narrowRowIntegers, narrowRowsIntegers } from '../chunk-NZGSDALX.mjs';
|
|
2
|
+
import '../chunk-DX4WGJL7.mjs';
|
|
3
|
+
import '../chunk-NVSQ2T5Q.mjs';
|
|
4
|
+
import { defineDriver } from '../chunk-IEKIYO4V.mjs';
|
|
5
5
|
import '../chunk-W67A4H2E.mjs';
|
|
6
6
|
import '../chunk-MVSES6MS.mjs';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-
|
|
10
|
-
import '../chunk-
|
|
11
|
-
import { synchronousPragmaValue } from '../chunk-
|
|
12
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-6AOJCNRU.mjs';
|
|
8
|
+
import '../chunk-QGVRRKB2.mjs';
|
|
9
|
+
import '../chunk-KJLNYOOL.mjs';
|
|
10
|
+
import '../chunk-R7GBXNTO.mjs';
|
|
11
|
+
import { synchronousPragmaValue } from '../chunk-YCMB6GR4.mjs';
|
|
12
|
+
import '../chunk-CZL4D3BM.mjs';
|
|
13
13
|
import '../chunk-QBBLSQHQ.mjs';
|
|
14
|
-
import { ExtensionError, BackupError } from '../chunk-
|
|
14
|
+
import { ExtensionError, BackupError, SirannonError } from '../chunk-KINDFBQP.mjs';
|
|
15
15
|
import { createRequire } from 'module';
|
|
16
16
|
|
|
17
17
|
// src/drivers/node/copy.ts
|
|
18
18
|
var OPEN_TRANSACTION_MESSAGE = "A stepped copy cannot start while a transaction is open on the same connection, because SQLite copies no pages and reports success";
|
|
19
|
+
var NO_NODE_SQLITE_BACKUP_MESSAGE = "This Node.js build provides no backup function in node:sqlite, so the Node driver cannot copy a database. Upgrade Node.js to a release whose node:sqlite exports backup.";
|
|
19
20
|
async function copyDatabaseWithNodeSqlite(db, request) {
|
|
20
21
|
if (db.isTransaction) throw new BackupError(OPEN_TRANSACTION_MESSAGE);
|
|
21
22
|
const { backup } = await import('node:sqlite');
|
|
23
|
+
if (typeof backup !== "function") throw new SirannonError(NO_NODE_SQLITE_BACKUP_MESSAGE, "BACKUP_UNSUPPORTED");
|
|
22
24
|
let totalPages = 0;
|
|
23
25
|
const pageCount = await backup(db, request.destPath, {
|
|
24
26
|
rate: request.pagesPerStep,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SQLiteDriver } from '../types-
|
|
2
|
-
import '../query-types-
|
|
1
|
+
import { S as SQLiteDriver } from '../types-Dc8oWlxj.js';
|
|
2
|
+
import '../query-types-5B02ixH0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Settings for the browser driver built on wa-sqlite.
|
|
@@ -8,15 +8,15 @@ import '../query-types-p1liOP-b.js';
|
|
|
8
8
|
*/
|
|
9
9
|
interface WaSqliteOptions {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* The virtual file system that stores the database in the browser, which defaults to `IDBBatchAtomicVFS`.
|
|
12
12
|
*/
|
|
13
13
|
vfs?: 'IDBBatchAtomicVFS' | 'AccessHandlePoolVFS';
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Returns a driver that opens SQLite databases in the browser through the wa-sqlite WebAssembly build.
|
|
17
17
|
*
|
|
18
|
-
* @param driverOptions -
|
|
19
|
-
* @returns The driver,
|
|
18
|
+
* @param driverOptions - The virtual file system that stores the database.
|
|
19
|
+
* @returns The driver, which you can pass to a `Sirannon` registry.
|
|
20
20
|
*
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base class for every sirannon-db error, which has a machine-readable
|
|
3
|
+
* {@link SirannonError.code}. Extend it to define an error of your own.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
declare class SirannonError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* The machine-readable code that the server maps to an HTTP status.
|
|
10
|
+
*/
|
|
11
|
+
readonly code: string;
|
|
12
|
+
constructor(message: string,
|
|
13
|
+
/**
|
|
14
|
+
* The machine-readable code that the server maps to an HTTP status.
|
|
15
|
+
*/
|
|
16
|
+
code: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thrown when the registry has no open database under an identifier, because
|
|
20
|
+
* the database was never opened or is already closed.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
declare class DatabaseNotFoundError extends SirannonError {
|
|
25
|
+
constructor(id: string);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Thrown when a caller opens a database under an identifier that the registry
|
|
29
|
+
* already uses, since each identifier names one database.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
declare class DatabaseAlreadyExistsError extends SirannonError {
|
|
34
|
+
constructor(id: string);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when a caller writes to a database that is open in read-only mode.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
declare class ReadOnlyError extends SirannonError {
|
|
42
|
+
constructor(id: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Thrown when SQLite fails to execute a statement, with that statement in
|
|
46
|
+
* {@link QueryError.sql} for your logs.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
declare class QueryError extends SirannonError {
|
|
51
|
+
/**
|
|
52
|
+
* The statement that failed.
|
|
53
|
+
*/
|
|
54
|
+
readonly sql: string;
|
|
55
|
+
constructor(message: string,
|
|
56
|
+
/**
|
|
57
|
+
* The statement that failed.
|
|
58
|
+
*/
|
|
59
|
+
sql: string);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Sirannon raises this error when SQLite refuses to commit a transaction whose
|
|
63
|
+
* statements all succeeded, such as on a deferred foreign key; `cause` holds
|
|
64
|
+
* SQLite's own error. The server responds to its `TRANSACTION_ERROR` code with status 400.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
declare class TransactionError extends SirannonError {
|
|
69
|
+
constructor(message: string, cause?: unknown);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Thrown when a migration fails, with the version of that migration in
|
|
73
|
+
* {@link MigrationError.version}.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
declare class MigrationError extends SirannonError {
|
|
78
|
+
/**
|
|
79
|
+
* The version of the migration that failed.
|
|
80
|
+
*/
|
|
81
|
+
readonly version: number;
|
|
82
|
+
constructor(message: string,
|
|
83
|
+
/**
|
|
84
|
+
* The version of the migration that failed.
|
|
85
|
+
*/
|
|
86
|
+
version: number, code?: string);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* An error that a before-hook can throw to reject an operation, which the
|
|
90
|
+
* server responds to with status 403. The message includes the optional
|
|
91
|
+
* `reason`, so that a caller can tell one hook policy from another.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
declare class HookDeniedError extends SirannonError {
|
|
96
|
+
constructor(hookName: string, reason?: string);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Rejects one request with a status of your own; throw it from an authenticate hook or a registered operation.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
declare class RequestDeniedError extends SirannonError {
|
|
104
|
+
/**
|
|
105
|
+
* The HTTP status that the server responds to the rejected request with.
|
|
106
|
+
*/
|
|
107
|
+
readonly status: number;
|
|
108
|
+
constructor(status: number, code: string, message: string);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Thrown when change capture cannot proceed, for example when a caller watches
|
|
112
|
+
* a table that does not exist, when Sirannon cannot read the change-log epoch
|
|
113
|
+
* or the node identity, or when a live query uses a statement that Sirannon
|
|
114
|
+
* cannot keep current.
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
declare class CDCError extends SirannonError {
|
|
119
|
+
constructor(message: string);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Thrown when a statement through the query API names a `_sirannon` table,
|
|
123
|
+
* modifies a `sqlite_` table, contains ATTACH or DETACH, or sets
|
|
124
|
+
* `PRAGMA writable_schema`. Sirannon rejects these statements to keep its
|
|
125
|
+
* change log, its replication ledger, and SQLite's schema catalogue out of the
|
|
126
|
+
* caller's reach.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
declare class ForbiddenSqlError extends SirannonError {
|
|
131
|
+
constructor(message: string);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Thrown when a copy to a file or a scheduled backup fails, or when its path,
|
|
135
|
+
* cron expression, or time zone is invalid.
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
declare class BackupError extends SirannonError {
|
|
140
|
+
constructor(message: string);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Thrown when a caller asks a closed or empty connection pool for a connection, asks a
|
|
144
|
+
* read-only pool for the writer, or closes a pool and one of its connections
|
|
145
|
+
* fails to close.
|
|
146
|
+
*
|
|
147
|
+
* @public
|
|
148
|
+
*/
|
|
149
|
+
declare class ConnectionPoolError extends SirannonError {
|
|
150
|
+
constructor(message: string);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Thrown when the lifecycle resolver would open a database past `maxOpen`, and
|
|
154
|
+
* evicting the least recently used database frees no slot. Close a database
|
|
155
|
+
* before you open another one.
|
|
156
|
+
*
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
declare class MaxDatabasesError extends SirannonError {
|
|
160
|
+
constructor(max: number);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Thrown when more writes are pending than the writer-worker limit allows, so
|
|
164
|
+
* that the database sheds load. The server responds to it with status 503 and
|
|
165
|
+
* a `Retry-After` header.
|
|
166
|
+
*
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
declare class WriteOverloadError extends SirannonError {
|
|
170
|
+
/**
|
|
171
|
+
* The number of pending writes that the database accepts before it rejects more.
|
|
172
|
+
*/
|
|
173
|
+
readonly limit: number;
|
|
174
|
+
/**
|
|
175
|
+
* The number of milliseconds that the caller should wait before it retries.
|
|
176
|
+
*/
|
|
177
|
+
readonly retryAfterMs: number;
|
|
178
|
+
constructor(
|
|
179
|
+
/**
|
|
180
|
+
* The number of pending writes that the database accepts before it rejects more.
|
|
181
|
+
*/
|
|
182
|
+
limit: number,
|
|
183
|
+
/**
|
|
184
|
+
* The number of milliseconds that the caller should wait before it retries.
|
|
185
|
+
*/
|
|
186
|
+
retryAfterMs: number);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Thrown when Sirannon cannot load a compiled SQLite extension. The message
|
|
190
|
+
* names the extension path, and the optional `cause` gives the reason that
|
|
191
|
+
* SQLite or Sirannon reported.
|
|
192
|
+
*
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
declare class ExtensionError extends SirannonError {
|
|
196
|
+
constructor(path: string, cause?: string);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export { BackupError as B, CDCError as C, DatabaseAlreadyExistsError as D, ExtensionError as E, ForbiddenSqlError as F, HookDeniedError as H, MaxDatabasesError as M, QueryError as Q, ReadOnlyError as R, SirannonError as S, TransactionError as T, WriteOverloadError as W, ConnectionPoolError as a, DatabaseNotFoundError as b, MigrationError as c, RequestDeniedError as d };
|