@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
package/dist/codegen/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { runCodegen } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { runCodegen } from '../chunk-2ES3DT4A.mjs';
|
|
2
|
+
import '../chunk-ZYWI45EN.mjs';
|
|
3
|
+
import '../chunk-KB4OLJAD.mjs';
|
|
4
4
|
import '../chunk-GVCNMPOS.mjs';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-KINDFBQP.mjs';
|
|
6
6
|
|
|
7
7
|
// src/codegen/cli.ts
|
|
8
8
|
runCodegen(process.argv.slice(2)).catch((err) => {
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -1,100 +1,105 @@
|
|
|
1
|
-
import { a as OperationRegistry } from '../operation-registry-
|
|
2
|
-
import '../query-types-
|
|
1
|
+
import { a as OperationRegistry, D as DatabaseOperations } from '../operation-registry-CGhNT-Sn.js';
|
|
2
|
+
import '../query-types-5B02ixH0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* The version of the manifest format that the generator writes.
|
|
6
6
|
*
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
declare const OPERATION_MANIFEST_VERSION = 1;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Describes the arguments and result columns of one registered operation for code generation.
|
|
12
12
|
*
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
15
|
interface OperationShape {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* The names of the arguments that the caller supplies.
|
|
18
18
|
*/
|
|
19
19
|
args: string[];
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* The names of the arguments that the server sets from the authenticated identity.
|
|
22
22
|
*/
|
|
23
23
|
identityArgs: string[];
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* The column names in every row of a read, or `null` for a write and for a read whose columns the generator cannot derive.
|
|
26
26
|
*/
|
|
27
27
|
columns: string[] | null;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Describes the named reads and writes that the registry holds for one database.
|
|
31
31
|
*
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
34
|
interface DatabaseManifest {
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* The registered reads, keyed by operation name.
|
|
37
37
|
*/
|
|
38
38
|
reads: Record<string, OperationShape>;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* The registered writes, keyed by operation name.
|
|
41
41
|
*/
|
|
42
42
|
writes: Record<string, OperationShape>;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Describes every database's registered operations for code generation.
|
|
46
46
|
*
|
|
47
47
|
* @public
|
|
48
48
|
*/
|
|
49
49
|
interface OperationManifest {
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* The version of the manifest format.
|
|
52
52
|
*/
|
|
53
53
|
version: number;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* The registry digest, which a client can compare with the digest that the server announces.
|
|
56
56
|
*/
|
|
57
57
|
digest: string | undefined;
|
|
58
58
|
/**
|
|
59
|
-
* One manifest
|
|
59
|
+
* One manifest for each database, keyed by database ID.
|
|
60
60
|
*/
|
|
61
61
|
databases: Record<string, DatabaseManifest>;
|
|
62
|
+
/**
|
|
63
|
+
* The operations that callers may invoke on every database, present when {@link buildOperationManifest} receives a shared set.
|
|
64
|
+
*/
|
|
65
|
+
shared?: DatabaseManifest;
|
|
62
66
|
}
|
|
63
67
|
/**
|
|
64
|
-
*
|
|
68
|
+
* Returns a manifest that describes the arguments and result columns of every operation in a registry.
|
|
65
69
|
*
|
|
66
|
-
* @param registry - The registered operations to describe.
|
|
67
|
-
* @
|
|
70
|
+
* @param registry - The registered operations to describe, keyed by database identifier.
|
|
71
|
+
* @param shared - The operations that callers may invoke on every database, which you pass to the server as `sharedOperations`.
|
|
72
|
+
* @returns The manifest from which code generation renders types.
|
|
68
73
|
*
|
|
69
74
|
* @public
|
|
70
75
|
*/
|
|
71
|
-
declare function buildOperationManifest<I>(registry: OperationRegistry<I>): OperationManifest;
|
|
76
|
+
declare function buildOperationManifest<I>(registry: OperationRegistry<I>, shared?: DatabaseOperations<I>): OperationManifest;
|
|
72
77
|
/**
|
|
73
|
-
*
|
|
78
|
+
* Returns the column names that a `SELECT` statement produces.
|
|
74
79
|
*
|
|
75
80
|
* @param sql - The statement to inspect.
|
|
76
|
-
* @returns The column names, or null when the
|
|
81
|
+
* @returns The column names, or `null` when the parser cannot derive every column name from the statement's text.
|
|
77
82
|
*
|
|
78
83
|
* @public
|
|
79
84
|
*/
|
|
80
85
|
declare function selectColumns(sql: string): string[] | null;
|
|
81
86
|
|
|
82
87
|
/**
|
|
83
|
-
*
|
|
88
|
+
* Settings for the TypeScript source that {@link renderOperationTypes} returns.
|
|
84
89
|
*
|
|
85
90
|
* @public
|
|
86
91
|
*/
|
|
87
92
|
interface RenderOptions {
|
|
88
93
|
/**
|
|
89
|
-
*
|
|
94
|
+
* The package that the generated file imports its types from, which defaults to `@delali/sirannon-db`.
|
|
90
95
|
*/
|
|
91
96
|
packageName?: string;
|
|
92
97
|
}
|
|
93
98
|
/**
|
|
94
|
-
*
|
|
99
|
+
* Returns TypeScript source that declares a typed reference for every operation in a manifest.
|
|
95
100
|
*
|
|
96
101
|
* @param manifest - The operations to render.
|
|
97
|
-
* @param options - The package the generated file imports from.
|
|
102
|
+
* @param options - The package that the generated file imports its types from.
|
|
98
103
|
* @returns The TypeScript source to write.
|
|
99
104
|
*
|
|
100
105
|
* @public
|
|
@@ -102,16 +107,18 @@ interface RenderOptions {
|
|
|
102
107
|
declare function renderOperationTypes(manifest: OperationManifest, options?: RenderOptions): string;
|
|
103
108
|
|
|
104
109
|
/**
|
|
105
|
-
*
|
|
110
|
+
* The code generator appends this usage text to its error message when it cannot parse the arguments.
|
|
106
111
|
*
|
|
107
112
|
* @public
|
|
108
113
|
*/
|
|
109
|
-
declare const CODEGEN_USAGE = "sirannon-codegen --registry <module> --out <file> [--manifest <file>] [--export <name>] [--package <name>]\n\nReads the
|
|
114
|
+
declare const CODEGEN_USAGE = "sirannon-codegen --registry <module> --out <file> [--manifest <file>] [--export <name>] [--shared-export <name>] [--package <name>]\n\nReads the operations that you register with a server and writes the typed\nreferences through which a client calls them. The generator takes the\nper-database registry from the 'operations' export, or from the default\nexport, and the operations for every database from the 'sharedOperations'\nexport. The generator imports the registry module, so run it under a loader\nthat reads your source format when that format is not JavaScript.";
|
|
110
115
|
/**
|
|
111
|
-
*
|
|
116
|
+
* Writes typed operation references for the registry in the `--registry` module to the `--out` file.
|
|
117
|
+
*
|
|
118
|
+
* When you pass `--manifest`, the generator also writes the operation manifest to that file as JSON.
|
|
112
119
|
*
|
|
113
|
-
* @param argv -
|
|
114
|
-
* @throws
|
|
120
|
+
* @param argv - The command-line arguments that follow the executable and script names.
|
|
121
|
+
* @throws An `Error` when an argument is missing or unrecognised, when Node cannot import the registry module, when the module exports neither an operation registry nor shared operations, or when the module has no export of the name that `--export` or `--shared-export` gives.
|
|
115
122
|
*
|
|
116
123
|
* @public
|
|
117
124
|
*/
|
package/dist/codegen/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { CODEGEN_USAGE, OPERATION_MANIFEST_VERSION, buildOperationManifest, renderOperationTypes, runCodegen, selectColumns } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { CODEGEN_USAGE, OPERATION_MANIFEST_VERSION, buildOperationManifest, renderOperationTypes, runCodegen, selectColumns } from '../chunk-2ES3DT4A.mjs';
|
|
2
|
+
import '../chunk-ZYWI45EN.mjs';
|
|
3
|
+
import '../chunk-KB4OLJAD.mjs';
|
|
4
4
|
import '../chunk-GVCNMPOS.mjs';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-KINDFBQP.mjs';
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export { B as BackupCapabilities, a as BackupChainLocation, b as BackupRestorePlan, c as BackupSafeToDeleteOptions, d as backupPiecesSafeToDelete, p as planBackupRestore } from '../database-backup-
|
|
2
|
-
import { I as SQLiteConnection, U as SynchronousLevel, S as SQLiteDriver, D as DatabaseOptions, V as LifecycleConfig, M as Migration, W as MigrationResult, X as RollbackResult } from '../types-
|
|
3
|
-
export { A as AfterQueryHook, Y as AfterQueryHookContext, Z as AppliedMigrationEntry, g as BackupChain, h as BackupChainBase, i as BackupChainChange, j as BackupChainPosition, k as BackupChainRecord, m as BackupCycleError, n as BackupCycleOptions, o as BackupCycleStatus, B as BackupDestination, p as BackupFileReport, q as BackupGroupMembership, r as BackupGroupSource, s as BackupLogPosition, t as BackupNodePreference, u as BackupPiece, v as BackupProgress, f as BackupRunReport, O as BackupScheduleOptions, w as BackupSkip, x as BackupSkipReason, y as BackupToDestinationOptions, z as BackupVerifyResult, _ as BatchSummary, c as BeforeConnectHook, b as BeforeQueryHook,
|
|
4
|
-
import { B as BulkLoadDurability, a as BulkLoadResult, R as RequestContext } from '../server-options-
|
|
5
|
-
export { A as AppliedMigrationRow, b as AuthenticateHook, c as BulkLoadOptions, C as ClientOptions, d as ClusterStatusAuthorizer, e as CorsOptions, f as ReplicationStatusInfo, g as ServerExecutionTarget, h as ServerExecutionTargetResolver, S as ServerOptions, W as WSHandlerOptions } from '../server-options-
|
|
6
|
-
export { C as ChangeTracker, a as ChangeTrackerOptions } from '../change-tracker-
|
|
7
|
-
import { D as Database } from '../database-
|
|
8
|
-
export { C as ConnectionPool, b as ConnectionPoolOptions, c as DatabaseBackups, d as DatabaseLifecycle, a as HookDispose, e as HookEvent, f as HookEventContextMap, g as HookHandler, H as HookRegistry, M as MetricsCollector, S as SnapshotHookContext, h as SubscribeHookContext, i as execute, j as executeBatch, q as query, k as queryOne } from '../database-
|
|
9
|
-
export { B as BackupError, C as CDCError, a as ConnectionPoolError, D as DatabaseAlreadyExistsError, b as DatabaseNotFoundError, E as ExtensionError, F as ForbiddenSqlError, H as HookDeniedError, M as MaxDatabasesError, c as MigrationError, Q as QueryError, R as ReadOnlyError, d as RequestDeniedError, S as SirannonError, T as TransactionError, W as WriteOverloadError } from '../errors-
|
|
10
|
-
export { a as LiveQuery, L as LiveQueryOptions, b as LiveQueryState, c as LiveUpdate, R as ResultOp } from '../types-
|
|
11
|
-
import { B as BaselineFileOption } from '../baseline-
|
|
12
|
-
export { S as Sirannon } from '../sirannon-
|
|
13
|
-
export { C as ChangeEvent, b as ChangeOperation, E as ExecuteResult, P as Params, Q as QueryOptions, R as ReadConcern, a as ReadConcernLevel, S as Subscription, c as SubscriptionBuilder, d as SubscriptionOptions, W as WriteConcern, e as WriteConcernLevel } from '../query-types-
|
|
14
|
-
export { D as DatabaseOperations, b as OperationArguments, O as OperationRef, a as OperationRegistry, c as OperationStatement, R as ReadOperation, W as WriteOperation, o as operationName, d as operationRef } from '../operation-registry-
|
|
15
|
-
import '../types-
|
|
1
|
+
export { B as BackupCapabilities, a as BackupChainLocation, b as BackupRestorePlan, c as BackupSafeToDeleteOptions, d as backupPiecesSafeToDelete, p as planBackupRestore } from '../database-backup-DcLhxoa1.js';
|
|
2
|
+
import { I as SQLiteConnection, U as SynchronousLevel, S as SQLiteDriver, D as DatabaseOptions, V as LifecycleConfig, M as Migration, W as MigrationResult, X as RollbackResult } from '../types-Dc8oWlxj.js';
|
|
3
|
+
export { A as AfterQueryHook, Y as AfterQueryHookContext, Z as AppliedMigrationEntry, g as BackupChain, h as BackupChainBase, i as BackupChainChange, j as BackupChainPosition, k as BackupChainRecord, m as BackupCycleError, n as BackupCycleOptions, o as BackupCycleStatus, B as BackupDestination, p as BackupFileReport, q as BackupGroupMembership, r as BackupGroupSource, s as BackupLogPosition, t as BackupNodePreference, u as BackupPiece, v as BackupProgress, f as BackupRunReport, O as BackupScheduleOptions, w as BackupSkip, x as BackupSkipReason, y as BackupToDestinationOptions, z as BackupVerifyResult, _ as BatchSummary, c as BeforeConnectHook, $ as BeforePushHook, b as BeforeQueryHook, a0 as BeforeSnapshotHook, a1 as BeforeSubscribeHook, a2 as CDCMetrics, a3 as ClusterReadEndpointInfo, H as ClusterStatusInfo, a4 as ConnectionHookContext, a5 as ConnectionMetrics, C as DEFAULT_CHAIN_NAME, e as DatabaseCloseHook, a6 as DatabaseCopyRequest, a7 as DatabaseCopyStep, d as DatabaseOpenHook, P as DriverCapabilities, a8 as DriverWorkerEntry, a9 as HookConfig, aa as MIGRATION_NAME_RE, ab as MetricsConfig, ac as MigrationBaseline, ad as MigrationSource, ae as NODE_HEALTH_REASONS, af as NODE_HEALTH_STATES, N as NodeHealth, ag as NodeHealthReason, ah as NodeHealthState, ai as OpenOptions, aj as QueryHookContext, ak as QueryMetrics, al as RunResult, am as SQLiteStatement, a as SirannonOptions, T as Transaction, an as WriterWorkerOptions, F as readBackupChains } from '../types-Dc8oWlxj.js';
|
|
4
|
+
import { B as BulkLoadDurability, a as BulkLoadResult, R as RequestContext } from '../server-options-aYtCkefX.js';
|
|
5
|
+
export { A as AppliedMigrationRow, b as AuthenticateHook, c as BulkLoadOptions, C as ClientOptions, d as ClusterStatusAuthorizer, e as CorsOptions, f as ReplicationStatusInfo, g as ServerExecutionTarget, h as ServerExecutionTargetResolver, S as ServerOptions, W as WSHandlerOptions } from '../server-options-aYtCkefX.js';
|
|
6
|
+
export { C as ChangeTracker, a as ChangeTrackerOptions } from '../change-tracker-DqCdeEyx.js';
|
|
7
|
+
import { D as Database } from '../database-CGDsXW1K.js';
|
|
8
|
+
export { C as ConnectionPool, b as ConnectionPoolOptions, c as DatabaseBackups, d as DatabaseLifecycle, a as HookDispose, e as HookEvent, f as HookEventContextMap, g as HookHandler, H as HookRegistry, M as MetricsCollector, P as PushHookContext, S as SnapshotHookContext, h as SubscribeHookContext, i as execute, j as executeBatch, q as query, k as queryOne } from '../database-CGDsXW1K.js';
|
|
9
|
+
export { B as BackupError, C as CDCError, a as ConnectionPoolError, D as DatabaseAlreadyExistsError, b as DatabaseNotFoundError, E as ExtensionError, F as ForbiddenSqlError, H as HookDeniedError, M as MaxDatabasesError, c as MigrationError, Q as QueryError, R as ReadOnlyError, d as RequestDeniedError, S as SirannonError, T as TransactionError, W as WriteOverloadError } from '../errors-CJUkQ-KL.js';
|
|
10
|
+
export { a as LiveQuery, L as LiveQueryOptions, b as LiveQueryState, c as LiveUpdate, R as ResultOp } from '../types-CEJG0eFS.js';
|
|
11
|
+
import { B as BaselineFileOption } from '../baseline-Co3iIsN_.js';
|
|
12
|
+
export { S as Sirannon } from '../sirannon-J3EgPVD7.js';
|
|
13
|
+
export { C as ChangeEvent, b as ChangeOperation, E as ExecuteResult, P as Params, Q as QueryOptions, R as ReadConcern, a as ReadConcernLevel, S as Subscription, c as SubscriptionBuilder, d as SubscriptionOptions, W as WriteConcern, e as WriteConcernLevel } from '../query-types-5B02ixH0.js';
|
|
14
|
+
export { D as DatabaseOperations, b as OperationArguments, O as OperationRef, a as OperationRegistry, c as OperationStatement, R as ReadOperation, W as WriteOperation, o as operationName, d as operationRef } from '../operation-registry-CGhNT-Sn.js';
|
|
15
|
+
import '../types-DqODKeOq.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Returns true when the value is `'off'` or `'normal'`, the two durability levels that a bulk load accepts.
|
|
19
19
|
*
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
@@ -30,87 +30,92 @@ interface BulkLoadRun {
|
|
|
30
30
|
loadRows: () => Promise<BulkLoadResult>;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* operator
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* -
|
|
39
|
-
* configured level
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* the
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* file and
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* A
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* SQLite's automatic checkpoint keeps the WAL bounded
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* whatever the caller asked for
|
|
72
|
-
* SQLite overwrite the
|
|
73
|
-
*
|
|
33
|
+
* Executes a bulk load at a relaxed synchronous level, then restores the level
|
|
34
|
+
* that the operator configured. The caller must hold the writer lock for the
|
|
35
|
+
* whole call so that no other write commits at the relaxed level.
|
|
36
|
+
*
|
|
37
|
+
* Each failure leaves the database in a known state:
|
|
38
|
+
* - When a load statement fails, SQLite rolls the transaction back and this
|
|
39
|
+
* function restores the configured level, so the operator can re-run the load.
|
|
40
|
+
* - When the process crashes during a load, SQLite rolls the uncommitted
|
|
41
|
+
* transaction back from the WAL on the next open, and that open applies the
|
|
42
|
+
* configured level again, because SQLite keeps `PRAGMA synchronous` on the
|
|
43
|
+
* connection and never stores it in the file.
|
|
44
|
+
* - When the power fails or the operating system crashes during a load at
|
|
45
|
+
* 'off', SQLite documents that the file can be corrupted, so 'off' suits only
|
|
46
|
+
* a load that the operator can re-run from scratch, while 'normal' keeps the
|
|
47
|
+
* WAL safe from corruption.
|
|
48
|
+
*
|
|
49
|
+
* This function restores the level on the success path and on the failure
|
|
50
|
+
* path. When the restore fails after a committed load, it throws
|
|
51
|
+
* 'DURABILITY_RESTORE_FAILED' so that the operator knows that the load
|
|
52
|
+
* committed and must not be re-run; when the load itself failed, it rethrows
|
|
53
|
+
* the load error.
|
|
54
|
+
*
|
|
55
|
+
* After a load that committed and changed rows, this function checkpoints the
|
|
56
|
+
* WAL at the restored level, which copies the loaded pages into the main
|
|
57
|
+
* database file and fsyncs them. While a reader holds the WAL open, SQLite can
|
|
58
|
+
* leave pages uncopied, so this function tries the checkpoint up to three times
|
|
59
|
+
* and then returns without failing the committed load, leaving the remaining
|
|
60
|
+
* pages for a later checkpoint. On a driver that calls SQLite on the main
|
|
61
|
+
* thread, the checkpoint blocks the event loop for as long as the flush takes,
|
|
62
|
+
* which grows with the size of the load.
|
|
63
|
+
*
|
|
64
|
+
* A caller that imports in several batches should pass `checkpoint: false` on
|
|
65
|
+
* every load except the last, so that it pays for one fsyncing checkpoint at
|
|
66
|
+
* the end. Each of those loads still restores the configured level, while
|
|
67
|
+
* SQLite's automatic checkpoint keeps the WAL bounded at the relaxed level
|
|
68
|
+
* without an fsync.
|
|
69
|
+
*
|
|
70
|
+
* On a database that captures its own change log, this function skips the
|
|
71
|
+
* checkpoint whatever the caller asked for, because a checkpoint before the
|
|
72
|
+
* capture would let SQLite overwrite the frames that this load wrote. The
|
|
73
|
+
* backup cycle checkpoints once it has captured those frames.
|
|
74
74
|
*
|
|
75
75
|
* @internal
|
|
76
76
|
*/
|
|
77
77
|
declare function runBulkLoad(run: BulkLoadRun): Promise<BulkLoadResult>;
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* Returns a frozen {@link SQLiteDriver} that holds your implementation's capabilities, its `open` function, and only the optional members that Sirannon supports.
|
|
81
81
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @returns The driver,
|
|
82
|
+
* @param config - The driver implementation.
|
|
83
|
+
* @returns The driver, which you can pass to a `Sirannon` registry.
|
|
84
84
|
*
|
|
85
85
|
* @public
|
|
86
86
|
*/
|
|
87
87
|
declare function defineDriver(config: SQLiteDriver): SQLiteDriver;
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
90
|
+
* The writer durability level that Sirannon applies when you pass no `synchronous` option.
|
|
91
91
|
*
|
|
92
92
|
* @public
|
|
93
93
|
*/
|
|
94
94
|
declare const DEFAULT_SYNCHRONOUS: SynchronousLevel;
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
96
|
+
* Returns the `PRAGMA synchronous` argument for a durability level from a fixed
|
|
97
|
+
* lookup table, so that the SQL string can contain only `OFF`, `NORMAL`,
|
|
98
|
+
* `FULL`, or `EXTRA`.
|
|
99
|
+
*
|
|
100
|
+
* @param level - The durability level, or `undefined` for {@link DEFAULT_SYNCHRONOUS}.
|
|
101
|
+
* @returns The upper-case `PRAGMA synchronous` argument.
|
|
102
|
+
* @throws {@link SirannonError} with code `INVALID_SYNCHRONOUS` when `level` is none of the four levels.
|
|
98
103
|
*
|
|
99
104
|
* @public
|
|
100
105
|
*/
|
|
101
106
|
declare function synchronousPragmaValue(level: SynchronousLevel | undefined): string;
|
|
102
107
|
/**
|
|
103
|
-
*
|
|
108
|
+
* Returns `true` when a value is one of the durability levels that SQLite accepts for `PRAGMA synchronous`.
|
|
104
109
|
*
|
|
105
110
|
* @param value - The value to check.
|
|
106
|
-
* @returns
|
|
111
|
+
* @returns `true` when the value is `off`, `normal`, `full`, or `extra`.
|
|
107
112
|
*
|
|
108
113
|
* @public
|
|
109
114
|
*/
|
|
110
115
|
declare function isSynchronousLevel(value: unknown): value is SynchronousLevel;
|
|
111
116
|
|
|
112
117
|
/**
|
|
113
|
-
*
|
|
118
|
+
* The registry supplies these functions so that the lifecycle manager can open, close, count, and look up its databases.
|
|
114
119
|
*
|
|
115
120
|
* @internal
|
|
116
121
|
*/
|
|
@@ -121,7 +126,9 @@ interface LifecycleCallbacks {
|
|
|
121
126
|
has: (id: string) => boolean;
|
|
122
127
|
}
|
|
123
128
|
/**
|
|
124
|
-
* Opens
|
|
129
|
+
* Opens a database through the `autoOpen` resolver when the registry asks for it, and closes each database that stays idle for `idleTimeout` or longer.
|
|
130
|
+
*
|
|
131
|
+
* When one more open database would exceed `maxOpen`, the manager first closes the least recently used database.
|
|
125
132
|
*
|
|
126
133
|
* @internal
|
|
127
134
|
*/
|
|
@@ -145,50 +152,56 @@ declare class LifecycleManager {
|
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
/**
|
|
148
|
-
*
|
|
155
|
+
* Configures how {@link createTenantResolver} maps a tenant ID to a database file.
|
|
149
156
|
*
|
|
150
157
|
* @public
|
|
151
158
|
*/
|
|
152
159
|
interface TenantResolverOptions {
|
|
153
160
|
/**
|
|
154
|
-
*
|
|
161
|
+
* The directory that holds every tenant's database file.
|
|
155
162
|
*/
|
|
156
163
|
basePath: string;
|
|
157
164
|
/**
|
|
158
|
-
*
|
|
165
|
+
* The file extension that the resolver appends to the tenant ID, which defaults to `.db`.
|
|
159
166
|
*/
|
|
160
167
|
extension?: string;
|
|
161
168
|
/**
|
|
162
|
-
*
|
|
169
|
+
* The options with which Sirannon opens every tenant database.
|
|
163
170
|
*/
|
|
164
171
|
defaultOptions?: DatabaseOptions;
|
|
165
172
|
}
|
|
166
173
|
/**
|
|
167
|
-
*
|
|
174
|
+
* Returns a tenant ID unchanged when it is safe to use in a file name, which
|
|
175
|
+
* means 1 to 255 characters that start with a lowercase letter or a digit and
|
|
176
|
+
* continue with lowercase letters, digits, underscores, or hyphens.
|
|
177
|
+
*
|
|
178
|
+
* The function returns `undefined` for an ID with a capital letter, because on
|
|
179
|
+
* a file system that ignores case, such as the default one on macOS or
|
|
180
|
+
* Windows, `Acme.db` and `acme.db` name the same file.
|
|
168
181
|
*
|
|
169
|
-
* @param id - The
|
|
170
|
-
* @returns The
|
|
182
|
+
* @param id - The ID to check.
|
|
183
|
+
* @returns The ID when it is safe, or `undefined` otherwise.
|
|
171
184
|
*
|
|
172
185
|
* @public
|
|
173
186
|
*/
|
|
174
187
|
declare function sanitizeTenantId(id: string): string | undefined;
|
|
175
188
|
/**
|
|
176
|
-
*
|
|
189
|
+
* Returns the database file path for one tenant.
|
|
177
190
|
*
|
|
178
|
-
* @param basePath -
|
|
179
|
-
* @param tenantId -
|
|
180
|
-
* @param extension -
|
|
181
|
-
* @returns The full path
|
|
182
|
-
* @throws
|
|
191
|
+
* @param basePath - The directory that holds the file.
|
|
192
|
+
* @param tenantId - The tenant's ID.
|
|
193
|
+
* @param extension - The file extension to append, which defaults to `.db`.
|
|
194
|
+
* @returns The full path of that tenant's database file.
|
|
195
|
+
* @throws An `Error` when {@link sanitizeTenantId} refuses the ID, or when the file name exceeds 255 characters.
|
|
183
196
|
*
|
|
184
197
|
* @public
|
|
185
198
|
*/
|
|
186
199
|
declare function tenantPath(basePath: string, tenantId: string, extension?: string): string;
|
|
187
200
|
/**
|
|
188
|
-
*
|
|
201
|
+
* Returns a resolver for {@link LifecycleConfig.autoOpen} that turns a tenant ID into a database path.
|
|
189
202
|
*
|
|
190
|
-
* @param options -
|
|
191
|
-
* @returns A resolver that returns a path and options, or undefined for an
|
|
203
|
+
* @param options - The base directory, the file extension, and the options for each tenant database.
|
|
204
|
+
* @returns A resolver that returns a path and options, or `undefined` for an ID that {@link sanitizeTenantId} refuses or a file name over 255 characters.
|
|
192
205
|
*
|
|
193
206
|
* @public
|
|
194
207
|
*/
|
|
@@ -204,50 +217,50 @@ declare function createTenantResolver(options: TenantResolverOptions): (id: stri
|
|
|
204
217
|
*/
|
|
205
218
|
declare const MIGRATION_FILENAME_PATTERN: RegExp;
|
|
206
219
|
/**
|
|
207
|
-
*
|
|
220
|
+
* Holds the three parts of a migration file name.
|
|
208
221
|
*
|
|
209
222
|
* @public
|
|
210
223
|
*/
|
|
211
224
|
interface ParsedMigrationFilename {
|
|
212
225
|
/**
|
|
213
|
-
*
|
|
226
|
+
* The version number at the start of the file name.
|
|
214
227
|
*/
|
|
215
228
|
version: number;
|
|
216
229
|
/**
|
|
217
|
-
*
|
|
230
|
+
* The migration name between the version and the direction.
|
|
218
231
|
*/
|
|
219
232
|
name: string;
|
|
220
233
|
/**
|
|
221
|
-
*
|
|
234
|
+
* `up` for the SQL that applies the migration, or `down` for the SQL that undoes it.
|
|
222
235
|
*/
|
|
223
236
|
direction: 'up' | 'down';
|
|
224
237
|
}
|
|
225
238
|
/**
|
|
226
239
|
* Splits a migration file name into its version, name, and direction.
|
|
227
240
|
*
|
|
228
|
-
* @param filename -
|
|
229
|
-
* @returns The three parts, or null when the name
|
|
241
|
+
* @param filename - A file name such as `001_create_orders.up.sql`.
|
|
242
|
+
* @returns The three parts, or `null` when the name has another form.
|
|
230
243
|
*
|
|
231
244
|
* @public
|
|
232
245
|
*/
|
|
233
246
|
declare function parseMigrationFilename(filename: string): ParsedMigrationFilename | null;
|
|
234
247
|
|
|
235
248
|
/**
|
|
236
|
-
*
|
|
249
|
+
* Configures how {@link migrationsFromFiles} builds migrations from a set of files.
|
|
237
250
|
*
|
|
238
251
|
* @public
|
|
239
252
|
*/
|
|
240
253
|
interface MigrationsFromFilesOptions {
|
|
241
254
|
/**
|
|
242
|
-
* Marks
|
|
255
|
+
* Marks one migration as a baseline, which a new database runs in place of the earlier versions.
|
|
243
256
|
*/
|
|
244
257
|
baseline?: BaselineFileOption;
|
|
245
258
|
}
|
|
246
259
|
/**
|
|
247
|
-
*
|
|
260
|
+
* Returns migrations built from file contents that you already hold in memory, such as SQL that a bundler inlines.
|
|
248
261
|
*
|
|
249
|
-
* @param files -
|
|
250
|
-
* @param options - The baseline
|
|
262
|
+
* @param files - An object that maps each migration file name to its SQL text.
|
|
263
|
+
* @param options - The baseline, when one migration replaces the earlier versions for a new database.
|
|
251
264
|
* @returns The migrations, in ascending version order.
|
|
252
265
|
*
|
|
253
266
|
* @public
|
|
@@ -271,49 +284,51 @@ declare class MigrationRunner {
|
|
|
271
284
|
}
|
|
272
285
|
|
|
273
286
|
/**
|
|
274
|
-
*
|
|
287
|
+
* Encodes a credential as one WebSocket subprotocol that a handshake can offer.
|
|
275
288
|
*
|
|
276
|
-
* A browser sends no header on a WebSocket upgrade, so
|
|
277
|
-
*
|
|
278
|
-
* token allows. This encodes the credential
|
|
279
|
-
* and {@link readSubprotocolCredential}
|
|
289
|
+
* A browser sends no custom header on a WebSocket upgrade, so the client sends
|
|
290
|
+
* the credential as a subprotocol, which may contain only the characters that a
|
|
291
|
+
* header token allows. This function encodes the credential in base64url so
|
|
292
|
+
* that any text fits, and {@link readSubprotocolCredential} decodes it on the
|
|
293
|
+
* server.
|
|
280
294
|
*
|
|
281
|
-
* @param prefix -
|
|
282
|
-
* @param credential - The credential to
|
|
295
|
+
* @param prefix - The text that names the scheme, which the server matches on.
|
|
296
|
+
* @param credential - The credential to encode.
|
|
283
297
|
* @returns The subprotocol to pass as `webSocketProtocols`.
|
|
284
298
|
*
|
|
285
299
|
* @public
|
|
286
300
|
*/
|
|
287
301
|
declare function toSubprotocolCredential(prefix: string, credential: string): string;
|
|
288
302
|
/**
|
|
289
|
-
*
|
|
303
|
+
* Returns a header from a request, whatever the casing of the header name that the runtime reported.
|
|
290
304
|
*
|
|
291
|
-
* @param ctx - The request the `authenticate` hook
|
|
292
|
-
* @param name -
|
|
293
|
-
* @returns The header value, or undefined
|
|
305
|
+
* @param ctx - The request that Sirannon passed to the `authenticate` hook.
|
|
306
|
+
* @param name - The name of the header to return.
|
|
307
|
+
* @returns The header value, or undefined when the request has no such header.
|
|
294
308
|
*
|
|
295
309
|
* @public
|
|
296
310
|
*/
|
|
297
311
|
declare function readHeader(ctx: RequestContext, name: string): string | undefined;
|
|
298
312
|
/**
|
|
299
|
-
*
|
|
313
|
+
* Returns the token from a request's `Authorization: Bearer` header.
|
|
300
314
|
*
|
|
301
|
-
* @param ctx - The request the `authenticate` hook
|
|
302
|
-
* @returns The token, or undefined
|
|
315
|
+
* @param ctx - The request that Sirannon passed to the `authenticate` hook.
|
|
316
|
+
* @returns The token, or undefined when the request has no `Authorization` header, uses another scheme, or sends an empty token.
|
|
303
317
|
*
|
|
304
318
|
* @public
|
|
305
319
|
*/
|
|
306
320
|
declare function readBearerToken(ctx: RequestContext): string | undefined;
|
|
307
321
|
/**
|
|
308
|
-
*
|
|
322
|
+
* Returns the credential that a WebSocket upgrade offered under a prefix.
|
|
309
323
|
*
|
|
310
|
-
* The upgrade
|
|
311
|
-
* client sends ahead of its own entries, so
|
|
312
|
-
*
|
|
324
|
+
* The upgrade request lists every offered subprotocol, including the
|
|
325
|
+
* `sirannon.v1` identifier that the client sends ahead of its own entries, so
|
|
326
|
+
* this function takes the first entry that starts with the prefix and decodes
|
|
327
|
+
* what {@link toSubprotocolCredential} encoded there.
|
|
313
328
|
*
|
|
314
|
-
* @param ctx - The request the `authenticate` hook
|
|
315
|
-
* @param prefix - The same text passed to {@link toSubprotocolCredential}.
|
|
316
|
-
* @returns The credential, or undefined
|
|
329
|
+
* @param ctx - The request that Sirannon passed to the `authenticate` hook.
|
|
330
|
+
* @param prefix - The same text that you passed to {@link toSubprotocolCredential}.
|
|
331
|
+
* @returns The credential, or undefined when no offered subprotocol starts with that prefix or its value fails to decode.
|
|
317
332
|
*
|
|
318
333
|
* @public
|
|
319
334
|
*/
|