@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.
Files changed (108) hide show
  1. package/README.md +79 -56
  2. package/dist/backup/index.d.ts +44 -45
  3. package/dist/backup/index.mjs +7 -7
  4. package/dist/backup-scheduler/index.d.ts +42 -41
  5. package/dist/backup-scheduler/index.mjs +4 -4
  6. package/dist/baseline-Co3iIsN_.d.ts +19 -0
  7. package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
  8. package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
  9. package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
  10. package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
  11. package/dist/chunk-4KASJKKK.mjs +2501 -0
  12. package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
  13. package/dist/chunk-55YRLSM2.mjs +57 -0
  14. package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
  15. package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
  16. package/dist/chunk-ADNWEHGZ.mjs +299 -0
  17. package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
  18. package/dist/chunk-BVMZJOVM.mjs +5 -0
  19. package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
  20. package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
  21. package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
  22. package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
  23. package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
  24. package/dist/chunk-HR7K3GZW.mjs +36 -0
  25. package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
  26. package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
  27. package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
  28. package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
  29. package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
  30. package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
  31. package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
  32. package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
  33. package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
  34. package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
  35. package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
  36. package/dist/chunk-WOMADPM4.mjs +12 -0
  37. package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
  38. package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
  39. package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
  40. package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
  41. package/dist/client/index.d.ts +135 -137
  42. package/dist/client/index.mjs +177 -82
  43. package/dist/client/topology.d.ts +31 -31
  44. package/dist/client/topology.mjs +42 -23
  45. package/dist/client-base-BxTocU1x.d.ts +398 -0
  46. package/dist/client-streams-YKANXMWO.mjs +112 -0
  47. package/dist/codegen/cli.mjs +4 -4
  48. package/dist/codegen/index.d.ts +36 -29
  49. package/dist/codegen/index.mjs +4 -4
  50. package/dist/core/index.d.ts +130 -115
  51. package/dist/core/index.mjs +387 -297
  52. package/dist/core/writer-worker.mjs +3 -3
  53. package/dist/database-CGDsXW1K.d.ts +959 -0
  54. package/dist/database-backup-DcLhxoa1.d.ts +143 -0
  55. package/dist/driver/better-sqlite3.d.ts +11 -10
  56. package/dist/driver/better-sqlite3.mjs +11 -11
  57. package/dist/driver/bun.d.ts +9 -8
  58. package/dist/driver/expo.d.ts +6 -7
  59. package/dist/driver/node.d.ts +11 -10
  60. package/dist/driver/node.mjs +13 -11
  61. package/dist/driver/wa-sqlite.d.ts +6 -6
  62. package/dist/errors-CJUkQ-KL.d.ts +199 -0
  63. package/dist/file-migrations/index.d.ts +20 -18
  64. package/dist/file-migrations/index.mjs +3 -3
  65. package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
  66. package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
  67. package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
  68. package/dist/protocol-DFpNNsIT.d.ts +153 -0
  69. package/dist/query-types-5B02ixH0.d.ts +129 -0
  70. package/dist/react/index.d.ts +22 -22
  71. package/dist/replication/coordinator/etcd.d.ts +37 -31
  72. package/dist/replication/coordinator/etcd.mjs +296 -131
  73. package/dist/replication/index.d.ts +201 -161
  74. package/dist/replication/index.mjs +630 -529
  75. package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
  76. package/dist/server/index.d.ts +201 -191
  77. package/dist/server/index.mjs +736 -619
  78. package/dist/server-options-aYtCkefX.d.ts +317 -0
  79. package/dist/server-streams-24XL4T43.mjs +254 -0
  80. package/dist/sirannon-J3EgPVD7.d.ts +179 -0
  81. package/dist/transport/grpc.d.ts +37 -24
  82. package/dist/transport/grpc.mjs +83 -3199
  83. package/dist/transport/memory.d.ts +25 -26
  84. package/dist/transport/memory.mjs +18 -9
  85. package/dist/types-BrAiDGOb.d.ts +505 -0
  86. package/dist/types-CEJG0eFS.d.ts +88 -0
  87. package/dist/types-Dc8oWlxj.d.ts +1580 -0
  88. package/dist/types-DqODKeOq.d.ts +123 -0
  89. package/dist/types-guEKSzMr.d.ts +367 -0
  90. package/package.json +7 -7
  91. package/dist/baseline-D93hcIEE.d.ts +0 -17
  92. package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
  93. package/dist/client-base-Cmd9EVme.d.ts +0 -397
  94. package/dist/database-BLQvqjsw.d.ts +0 -917
  95. package/dist/database-backup-B7oszQ2n.d.ts +0 -141
  96. package/dist/errors-Dei4GdBb.d.ts +0 -196
  97. package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
  98. package/dist/primary-wins-B0np8JS3.d.ts +0 -85
  99. package/dist/protocol-HI-nY8DD.d.ts +0 -152
  100. package/dist/query-types-p1liOP-b.d.ts +0 -127
  101. package/dist/restore-options-CksYsH1l.d.ts +0 -83
  102. package/dist/server-options-Bj5iJnjx.d.ts +0 -292
  103. package/dist/sirannon-BPxC5tC2.d.ts +0 -178
  104. package/dist/types-B0EhgDbr.d.ts +0 -340
  105. package/dist/types-CbjfRwrK.d.ts +0 -499
  106. package/dist/types-CjhxcjhA.d.ts +0 -123
  107. package/dist/types-DPSmjU54.d.ts +0 -1518
  108. package/dist/types-DTO4CYhW.d.ts +0 -88
@@ -1,8 +1,8 @@
1
- import { runCodegen } from '../chunk-VOSJBZ6Q.mjs';
2
- import '../chunk-SBL6GN43.mjs';
3
- import '../chunk-TUD5CJ76.mjs';
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-PBRXXISQ.mjs';
5
+ import '../chunk-KINDFBQP.mjs';
6
6
 
7
7
  // src/codegen/cli.ts
8
8
  runCodegen(process.argv.slice(2)).catch((err) => {
@@ -1,100 +1,105 @@
1
- import { a as OperationRegistry } from '../operation-registry-oiPuSYI6.js';
2
- import '../query-types-p1liOP-b.js';
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
- * Version of the manifest format the generator writes.
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
- * The arguments and columns of one registered operation, as code generation reads them.
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
- * Argument names the caller supplies.
17
+ * The names of the arguments that the caller supplies.
18
18
  */
19
19
  args: string[];
20
20
  /**
21
- * Argument names the server fills from the authenticated identity.
21
+ * The names of the arguments that the server sets from the authenticated identity.
22
22
  */
23
23
  identityArgs: string[];
24
24
  /**
25
- * Columns every row of a read carries, or null when the generator cannot tell.
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
- * The reads and writes one database exposes by name.
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
- * Registered reads, keyed by operation name.
36
+ * The registered reads, keyed by operation name.
37
37
  */
38
38
  reads: Record<string, OperationShape>;
39
39
  /**
40
- * Registered writes, keyed by operation name.
40
+ * The registered writes, keyed by operation name.
41
41
  */
42
42
  writes: Record<string, OperationShape>;
43
43
  }
44
44
  /**
45
- * Every database's registered operations, in the form code generation reads.
45
+ * Describes every database's registered operations for code generation.
46
46
  *
47
47
  * @public
48
48
  */
49
49
  interface OperationManifest {
50
50
  /**
51
- * Version of the manifest format.
51
+ * The version of the manifest format.
52
52
  */
53
53
  version: number;
54
54
  /**
55
- * Digest of the registry, which a client compares against the server's.
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 per database, keyed by database identifier.
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
- * Reads a registry and describes each operation's arguments and columns.
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
- * @returns The manifest code generation renders types from.
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
- * Reads the column names a SELECT statement produces.
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 statement's columns cannot be read from its text.
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
- * How the generated TypeScript is written.
88
+ * Settings for the TypeScript source that {@link renderOperationTypes} returns.
84
89
  *
85
90
  * @public
86
91
  */
87
92
  interface RenderOptions {
88
93
  /**
89
- * Package the generated file imports its types from. Default: `@delali/sirannon-db`.
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
- * Renders typed references for every operation in a manifest.
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
- * Usage text the code generator prints when its arguments do not parse.
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 operation registry a server is built from and writes the typed\nreferences a client calls it through. The registry module is imported, so run\nit under a loader that reads your source format when it is not JavaScript.";
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
- * Runs the code generator: it loads a registry module, builds the manifest, and writes the typed references.
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 - Command-line arguments, without the executable and script names.
114
- * @throws When an argument is missing or the registry module cannot be loaded.
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
  */
@@ -1,5 +1,5 @@
1
- export { CODEGEN_USAGE, OPERATION_MANIFEST_VERSION, buildOperationManifest, renderOperationTypes, runCodegen, selectColumns } from '../chunk-VOSJBZ6Q.mjs';
2
- import '../chunk-SBL6GN43.mjs';
3
- import '../chunk-TUD5CJ76.mjs';
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-PBRXXISQ.mjs';
5
+ import '../chunk-KINDFBQP.mjs';
@@ -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-B7oszQ2n.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-DPSmjU54.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, b as BeforeQueryHook, $ as BeforeSnapshotHook, a0 as BeforeSubscribeHook, a1 as CDCMetrics, a2 as ClusterReadEndpointInfo, H as ClusterStatusInfo, a3 as ConnectionHookContext, a4 as ConnectionMetrics, C as DEFAULT_CHAIN_NAME, e as DatabaseCloseHook, a5 as DatabaseCopyRequest, a6 as DatabaseCopyStep, d as DatabaseOpenHook, P as DriverCapabilities, a7 as DriverWorkerEntry, a8 as HookConfig, a9 as MIGRATION_NAME_RE, aa as MetricsConfig, ab as MigrationBaseline, ac as MigrationSource, ad as NODE_HEALTH_REASONS, ae as NODE_HEALTH_STATES, N as NodeHealth, af as NodeHealthReason, ag as NodeHealthState, ah as OpenOptions, ai as QueryHookContext, aj as QueryMetrics, ak as RunResult, al as SQLiteStatement, a as SirannonOptions, T as Transaction, am as WriterWorkerOptions, F as readBackupChains } from '../types-DPSmjU54.js';
4
- import { B as BulkLoadDurability, a as BulkLoadResult, R as RequestContext } from '../server-options-Bj5iJnjx.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-Bj5iJnjx.js';
6
- export { C as ChangeTracker, a as ChangeTrackerOptions } from '../change-tracker-CjRFuZdB.js';
7
- import { D as Database } from '../database-BLQvqjsw.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, S as SnapshotHookContext, h as SubscribeHookContext, i as execute, j as executeBatch, q as query, k as queryOne } from '../database-BLQvqjsw.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-Dei4GdBb.js';
10
- export { a as LiveQuery, L as LiveQueryOptions, b as LiveQueryState, c as LiveUpdate, R as ResultOp } from '../types-DTO4CYhW.js';
11
- import { B as BaselineFileOption } from '../baseline-D93hcIEE.js';
12
- export { S as Sirannon } from '../sirannon-BPxC5tC2.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-p1liOP-b.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-oiPuSYI6.js';
15
- import '../types-CjhxcjhA.js';
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
- * Reports whether a value is one of the durability levels a bulk load accepts.
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
- * Run a bulk load with relaxed writer durability, then restore the
34
- * operator-configured level. The caller must hold the database's writer lock
35
- * for the whole call so that no other write commits under the relaxed level.
36
- *
37
- * Interruption safety, by failure mode:
38
- * - A load statement fails: the surrounding transaction rolls back, the
39
- * configured level is restored, and the database is exactly as it was before
40
- * the load; the operator recovers by re-running the load.
41
- * - The process crashes mid-load: `PRAGMA synchronous` is connection state
42
- * that SQLite never stores in the database file, so the next open re-applies
43
- * the configured level, and the uncommitted transaction rolls back from the
44
- * WAL on open.
45
- * - Power loss or an OS crash during a load at 'off': SQLite documents that
46
- * the file may be corrupted, which is why 'off' fits only a load the
47
- * operator can re-run from scratch; 'normal' keeps WAL corruption safety.
48
- *
49
- * The restore runs on both the success and the failure path. A restore pragma
50
- * only fails when the writer connection itself is gone, so on a committed load
51
- * that failure is reported as 'DURABILITY_RESTORE_FAILED', which tells the
52
- * operator the load committed and must not be re-run; on a failed load the
53
- * original load error stays dominant.
54
- *
55
- * On success, and only when the load changed rows, the WAL is checkpointed
56
- * after the restore so the loaded pages are written into the main database
57
- * file and fsync'd at the restored synchronous level. A reader holding the WAL
58
- * can defer that transfer: the checkpoint retries a few times and then leaves
59
- * the remaining pages for a later checkpoint rather than failing a load that
60
- * has already committed, so those pages stay in the WAL until then. The
61
- * checkpoint runs synchronously in the engine and blocks the event loop for
62
- * the flush, which grows with the size of the load.
63
- *
64
- * A multi-batch import passes `checkpoint: false` on every load but the last so
65
- * the one fsyncing checkpoint is paid once at the end instead of once per
66
- * batch; each intermediate load still restores the configured level, and
67
- * SQLite's automatic checkpoint keeps the WAL bounded during the import at the
68
- * relaxed level with no fsync of its own.
69
- *
70
- * A database that captures its own change log runs no checkpoint here at all,
71
- * whatever the caller asked for. A checkpoint ahead of the capture would let
72
- * SQLite overwrite the very frames this load wrote. Its cycle checkpoints
73
- * instead, once it has those frames.
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
- * Builds a {@link SQLiteDriver} from an implementation, copying across only the optional members Sirannon supports.
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 driver - The driver implementation.
83
- * @returns The driver, ready to pass to a `Sirannon` registry.
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
- * Writer durability a database opens at when you name none.
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
- * Map a synchronous level to its PRAGMA argument through an allowlist so that a
97
- * value smuggled past the type system can never reach SQL interpolation.
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
- * Reports whether a value is one of the durability levels SQLite accepts.
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 True when it is a valid level.
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
- * Operations the lifecycle manager calls back into on the owning registry.
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 databases on demand, evicts idle ones, and enforces the configured open-database limit.
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
- * How tenant identifiers map onto database files.
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
- * Directory every tenant's database file is written to.
161
+ * The directory that holds every tenant's database file.
155
162
  */
156
163
  basePath: string;
157
164
  /**
158
- * File extension appended to the tenant identifier. Default: '.db'.
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
- * Options every tenant database opens with.
169
+ * The options with which Sirannon opens every tenant database.
163
170
  */
164
171
  defaultOptions?: DatabaseOptions;
165
172
  }
166
173
  /**
167
- * Checks a tenant identifier against the characters and length a file name may carry.
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 identifier to check.
170
- * @returns The identifier when it is safe, and undefined when it is not.
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
- * Builds the database file path for one tenant.
189
+ * Returns the database file path for one tenant.
177
190
  *
178
- * @param basePath - Directory the file is written to.
179
- * @param tenantId - Identifier of the tenant.
180
- * @param extension - File extension to append. Default: '.db'.
181
- * @returns The full path for that tenant's database file.
182
- * @throws When the identifier is unsafe or the resulting file name is too long.
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
- * Builds a resolver that turns a tenant identifier into a database path, for {@link LifecycleConfig.autoOpen}.
201
+ * Returns a resolver for {@link LifecycleConfig.autoOpen} that turns a tenant ID into a database path.
189
202
  *
190
- * @param options - Base directory, file extension, and the options each tenant database opens with.
191
- * @returns A resolver that returns a path and options, or undefined for an unsafe identifier.
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
- * The three parts of a migration file name.
220
+ * Holds the three parts of a migration file name.
208
221
  *
209
222
  * @public
210
223
  */
211
224
  interface ParsedMigrationFilename {
212
225
  /**
213
- * Version number the file name starts with.
226
+ * The version number at the start of the file name.
214
227
  */
215
228
  version: number;
216
229
  /**
217
- * Migration name between the version and the direction.
230
+ * The migration name between the version and the direction.
218
231
  */
219
232
  name: string;
220
233
  /**
221
- * Whether the file applies the migration or undoes it.
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 - File name such as `001_create_orders.up.sql`.
229
- * @returns The three parts, or null when the name does not match the expected form.
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
- * How a set of migration files is turned into migrations.
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 the migration an existing database starts from.
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
- * Builds migrations from file contents you have already read, which suits a bundler that inlines the SQL.
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 - Migration file names mapped to their SQL.
250
- * @param options - The baseline to apply, when an existing database starts from one.
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
- * Packs a credential into one WebSocket subprotocol a handshake can offer.
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 a credential travels as a
277
- * subprotocol instead, and a subprotocol accepts only the characters a header
278
- * token allows. This encodes the credential so that any text survives the trip,
279
- * and {@link readSubprotocolCredential} reads it back on the server.
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 - Text naming the scheme, which the server matches on.
282
- * @param credential - The credential to carry.
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
- * Reads a header from a request, whatever casing the runtime reported it under.
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 received.
292
- * @param name - Name of the header to read.
293
- * @returns The header value, or undefined where the request carries none.
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
- * Reads the token from a request's `Authorization: Bearer` header.
313
+ * Returns the token from a request's `Authorization: Bearer` header.
300
314
  *
301
- * @param ctx - The request the `authenticate` hook received.
302
- * @returns The token, or undefined where the request carries another scheme or none.
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
- * Reads the credential a WebSocket upgrade offered under a prefix.
322
+ * Returns the credential that a WebSocket upgrade offered under a prefix.
309
323
  *
310
- * The upgrade carries the whole offer, including the `sirannon.v1` identifier the
311
- * client sends ahead of its own entries, so this picks the first entry under the
312
- * prefix and unpacks what {@link toSubprotocolCredential} put there.
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 received.
315
- * @param prefix - The same text passed to {@link toSubprotocolCredential}.
316
- * @returns The credential, or undefined where the offer carries none under that prefix.
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
  */