@delali/sirannon-db 0.1.7 → 0.2.0

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 (72) hide show
  1. package/README.md +117 -969
  2. package/dist/backup-scheduler/index.d.ts +1 -1
  3. package/dist/backup-scheduler/index.mjs +2 -2
  4. package/dist/baseline-Br77Fnhb.d.ts +6 -0
  5. package/dist/{change-tracker-CbmaMO-N.d.ts → change-tracker-DKRVUC3l.d.ts} +5 -8
  6. package/dist/{chunk-DJLX6CAE.mjs → chunk-4ISB7XMA.mjs} +2 -1
  7. package/dist/chunk-5NOIGN5Y.mjs +18 -0
  8. package/dist/chunk-67M7KAH6.mjs +90 -0
  9. package/dist/{chunk-GEZUUIKV.mjs → chunk-D7LAYTKN.mjs} +5 -2
  10. package/dist/{chunk-4IGMIJQK.mjs → chunk-EBJXPQQO.mjs} +59 -20
  11. package/dist/{chunk-BNUTBHHH.mjs → chunk-FHWTZFI4.mjs} +1 -1
  12. package/dist/chunk-GVCNMPOS.mjs +130 -0
  13. package/dist/chunk-H237TXZW.mjs +1407 -0
  14. package/dist/{chunk-HHRMRFFR.mjs → chunk-H6PIVVDN.mjs} +353 -142
  15. package/dist/chunk-HR5CWTLC.mjs +661 -0
  16. package/dist/chunk-JU64Y7HM.mjs +299 -0
  17. package/dist/{chunk-CW6S3WL5.mjs → chunk-JZGINXTN.mjs} +7 -5
  18. package/dist/{chunk-CJLYFDP5.mjs → chunk-LFZ37BSX.mjs} +1 -1
  19. package/dist/chunk-LNY2VVHE.mjs +18 -0
  20. package/dist/chunk-NVQS53NT.mjs +665 -0
  21. package/dist/{chunk-H5AB6NIR.mjs → chunk-O7SLN3GI.mjs} +2 -15
  22. package/dist/chunk-OQVZBEBY.mjs +283 -0
  23. package/dist/{chunk-VLTICJOD.mjs → chunk-PIKHN33N.mjs} +1 -1
  24. package/dist/chunk-TJF5GZSV.mjs +187 -0
  25. package/dist/chunk-TUD5CJ76.mjs +126 -0
  26. package/dist/{chunk-YPYVQJ4C.mjs → chunk-UC3SCMIN.mjs} +9 -1
  27. package/dist/client/index.d.ts +216 -321
  28. package/dist/client/index.mjs +1192 -1342
  29. package/dist/client/topology.d.ts +61 -0
  30. package/dist/client/topology.mjs +682 -0
  31. package/dist/client-base-CLWmH5Ln.d.ts +234 -0
  32. package/dist/codegen/cli.d.ts +2 -0
  33. package/dist/codegen/cli.mjs +11 -0
  34. package/dist/codegen/index.d.ts +30 -0
  35. package/dist/codegen/index.mjs +5 -0
  36. package/dist/core/index.d.ts +37 -16
  37. package/dist/core/index.mjs +2322 -298
  38. package/dist/core/writer-worker.mjs +28 -6
  39. package/dist/{database-DuGp0Rtr.d.ts → database-BY0L5Q2n.d.ts} +59 -14
  40. package/dist/driver/better-sqlite3.d.ts +1 -1
  41. package/dist/driver/better-sqlite3.mjs +6 -6
  42. package/dist/driver/node.d.ts +1 -1
  43. package/dist/driver/node.mjs +6 -6
  44. package/dist/driver/wa-sqlite.d.ts +1 -136
  45. package/dist/{errors-5Nf5ZAEC.d.ts → errors-Bw5MdNCu.d.ts} +5 -1
  46. package/dist/file-migrations/index.d.ts +7 -5
  47. package/dist/file-migrations/index.mjs +42 -37
  48. package/dist/operation-registry-9DcvxcE5.d.ts +45 -0
  49. package/dist/primary-wins-DPAm2AKG.d.ts +61 -0
  50. package/dist/protocol-6KrSq2Hy.d.ts +66 -0
  51. package/dist/react/index.d.ts +20 -0
  52. package/dist/react/index.mjs +137 -0
  53. package/dist/replication/coordinator/etcd.d.ts +5 -3
  54. package/dist/replication/coordinator/etcd.mjs +554 -462
  55. package/dist/replication/index.d.ts +51 -105
  56. package/dist/replication/index.mjs +1415 -2061
  57. package/dist/server/index.d.ts +111 -87
  58. package/dist/server/index.mjs +1917 -489
  59. package/dist/server-options-1JHu8pid.d.ts +191 -0
  60. package/dist/{sirannon-4SspRvP5.d.ts → sirannon-DaQSyhbJ.d.ts} +7 -2
  61. package/dist/transport/grpc.d.ts +7 -4
  62. package/dist/transport/grpc.mjs +191 -97
  63. package/dist/transport/memory.d.ts +5 -134
  64. package/dist/transport/memory.mjs +3 -1
  65. package/dist/{types-BsjobKbl.d.ts → types-B7gmEsZW.d.ts} +8 -61
  66. package/dist/{types-BEu1I_9_.d.ts → types-BsVabqSI.d.ts} +1 -1
  67. package/dist/types-CL6piSnD.d.ts +43 -0
  68. package/dist/types-C_D8IhpO.d.ts +60 -0
  69. package/dist/{types-D_hQW1hr.d.ts → types-zhnRXrsb.d.ts} +55 -165
  70. package/package.json +44 -6
  71. package/dist/chunk-TKGHYWQ6.mjs +0 -35
  72. package/dist/types-D4p4UyDK.d.ts +0 -26
@@ -0,0 +1,234 @@
1
+ import { B as BulkLoadDurability, a as BulkLoadResult, C as ClientOptions } from './server-options-1JHu8pid.js';
2
+ import { R as ResultOp, a as LiveQuery } from './types-CL6piSnD.js';
3
+ import { O as OperationRef, b as OperationArguments } from './operation-registry-9DcvxcE5.js';
4
+ import { P as Params, R as ReadConcern, W as WriteConcern, h as ChangeEvent, Q as QueryOptions } from './types-zhnRXrsb.js';
5
+ import { Q as QueryResponse, E as ExecuteResponse, a as TransactionResponse, B as BatchResponse, L as LoadResponse } from './protocol-6KrSq2Hy.js';
6
+
7
+ /** What a server announces: the capability tokens and the operation registry it serves. */
8
+ interface CapabilityReport {
9
+ capabilities: string[];
10
+ registryDigest: string | undefined;
11
+ }
12
+
13
+ declare const SQL_REFUSED_MESSAGE = "This server does not accept SQL over the network. Call a registered operation by name, or start the server with acceptSql: true.";
14
+ interface ServerCapabilityCheck {
15
+ assertSqlAccepted(): Promise<void>;
16
+ registryDigest(refresh?: boolean): Promise<string | undefined>;
17
+ }
18
+ declare class ServerCapabilities implements ServerCapabilityCheck {
19
+ private readonly resolveUrl;
20
+ private readonly headers;
21
+ private readonly requestTimeoutMs;
22
+ private pending;
23
+ constructor(resolveUrl: () => string | Promise<string>, headers: Record<string, string> | undefined, requestTimeoutMs?: number);
24
+ read(refresh?: boolean): Promise<CapabilityReport>;
25
+ registryDigest(refresh?: boolean): Promise<string | undefined>;
26
+ assertSqlAccepted(): Promise<void>;
27
+ private fetch;
28
+ }
29
+
30
+ /** Optional behaviours for a CDC subscription. */
31
+ interface SubscribeOptions {
32
+ /**
33
+ * Invoked when a reconnect cannot replay missed changes because they fell
34
+ * outside the server's retained history. The subscription continues live
35
+ * from the current moment; treat any prior state as stale and re-read.
36
+ */
37
+ onReset?: () => void;
38
+ deviceId?: string;
39
+ tables?: readonly string[];
40
+ schemaVersion?: number;
41
+ getResumeSeq?: () => bigint | undefined;
42
+ sinceSeq?: bigint;
43
+ epoch?: string;
44
+ /**
45
+ * Declares that this device stages pulled changes durably and
46
+ * acknowledges staged sequences, so the server may pack several events
47
+ * per frame and pace the delivery window continuously. Send only to a
48
+ * server that announces the `sync.staged-stream` capability.
49
+ */
50
+ stagedStream?: boolean;
51
+ onSubscribed?: (info: {
52
+ seq: bigint | undefined;
53
+ epoch: string | undefined;
54
+ resync: boolean;
55
+ maxUnacknowledgedChanges: number | undefined;
56
+ }) => void;
57
+ }
58
+ interface LiveHandlers<T = Record<string, unknown>> {
59
+ onRows(rows: T[]): void;
60
+ onOps(ops: ResultOp<T>[]): void;
61
+ onRevalidating(): void;
62
+ onError(error: RemoteError): void;
63
+ }
64
+ type RegistryDigestSource = (refresh: boolean) => Promise<string | undefined>;
65
+ /**
66
+ * Transport layer for communicating with a sirannon-db server.
67
+ * Each transport instance is bound to a specific database.
68
+ */
69
+ interface Transport {
70
+ /**
71
+ * Whether a read concern passed to {@link Transport.query} or
72
+ * {@link Transport.queryNamed} reaches the server. Topology routing applies
73
+ * the client-wide setting when it chooses a node, so it leaves this unset and
74
+ * a caller asking for a per-read concern is refused rather than served a read
75
+ * at another level.
76
+ */
77
+ readonly carriesReadConcern?: boolean;
78
+ query(sql: string, params?: Params, readConcern?: ReadConcern): Promise<QueryResponse>;
79
+ execute(sql: string, params?: Params): Promise<ExecuteResponse>;
80
+ transaction(statements: Array<{
81
+ sql: string;
82
+ params?: Params;
83
+ }>): Promise<TransactionResponse>;
84
+ batch(sql: string, paramsBatch: Params[], writeConcern?: WriteConcern): Promise<BatchResponse>;
85
+ load(sql: string, paramsBatch: Params[], durability?: BulkLoadDurability, checkpoint?: boolean): Promise<LoadResponse>;
86
+ queryNamed(name: string, args?: Record<string, unknown>, readConcern?: ReadConcern): Promise<QueryResponse>;
87
+ executeNamed(name: string, args?: Record<string, unknown>, writeConcern?: WriteConcern): Promise<TransactionResponse>;
88
+ liveSubscribe(name: string, args: Record<string, unknown> | undefined, handlers: LiveHandlers, registryDigest?: RegistryDigestSource): Promise<RemoteSubscription>;
89
+ subscribe(table: string, filter: Record<string, unknown> | undefined, callback: (event: ChangeEvent) => void, options?: SubscribeOptions): Promise<RemoteSubscription>;
90
+ close(): void;
91
+ }
92
+ /** Handle for an active remote subscription. */
93
+ interface RemoteSubscription {
94
+ unsubscribe(): void;
95
+ }
96
+ /** Builder for creating remote CDC subscriptions with optional filters. */
97
+ interface RemoteSubscriptionBuilder {
98
+ filter(conditions: Record<string, unknown>): RemoteSubscriptionBuilder;
99
+ subscribe(callback: (event: ChangeEvent) => void, options?: SubscribeOptions): Promise<RemoteSubscription>;
100
+ }
101
+ /**
102
+ * Error originating from a remote sirannon-db server.
103
+ * Carries the machine-readable error code from the server's error response.
104
+ */
105
+ declare class RemoteError extends Error {
106
+ readonly code: string;
107
+ constructor(code: string, message: string);
108
+ }
109
+
110
+ /** Options for {@link RemoteDatabase.loadAll}. */
111
+ interface LoadAllOptions {
112
+ /**
113
+ * Rows per batch sent to the server. Each batch is one request, so it must
114
+ * fit under the server's `maxBodyBytes`; widen that cap or lower this for
115
+ * wide rows. Default: 1000.
116
+ */
117
+ batchSize?: number;
118
+ /** Durability during the load. Default: 'off'. */
119
+ durability?: BulkLoadDurability;
120
+ }
121
+ /**
122
+ * Proxy for a remote sirannon-db database. Mirrors the core
123
+ * {@link Database} query interface with async methods that send
124
+ * requests to the server via the configured transport.
125
+ */
126
+ declare class RemoteDatabase {
127
+ readonly id: string;
128
+ private readonly transport;
129
+ private readonly capabilities;
130
+ private readonly onDispose?;
131
+ constructor(id: string, transport: Transport, capabilities: ServerCapabilityCheck, onDispose?: (() => void) | undefined);
132
+ query<T = Record<string, unknown>>(sql: string, params?: Params, options?: QueryOptions): Promise<T[]>;
133
+ query<Args, Row>(operation: OperationRef<Args, Row>, args: Args, options?: QueryOptions): Promise<Row[]>;
134
+ private assertReadConcernReaches;
135
+ execute(sql: string, params?: Params): Promise<ExecuteResponse>;
136
+ execute<Args>(operation: OperationRef<Args, unknown>, args: Args, writeConcern?: WriteConcern): Promise<ExecuteResponse[]>;
137
+ live<T = Record<string, unknown>>(name: string, args?: OperationArguments): Promise<LiveQuery<T>>;
138
+ live<Args, Row>(operation: OperationRef<Args, Row>, args: Args): Promise<LiveQuery<Row>>;
139
+ /**
140
+ * Execute multiple statements as a single atomic transaction.
141
+ * Returns an array of results, one per statement.
142
+ *
143
+ * The whole list travels in one request and commits or rolls back as a
144
+ * unit, so the client is never in the loop between statements.
145
+ */
146
+ transaction(statements: Array<{
147
+ sql: string;
148
+ params?: Params;
149
+ }>): Promise<ExecuteResponse[]>;
150
+ /**
151
+ * Run the same statement once per parameter set as a single atomic
152
+ * transaction that commits with one fsync. Returns one result per
153
+ * parameter set, in order. Use this for a burst of same-shape writes
154
+ * (an import, a bulk insert) that must all commit or all roll back.
155
+ */
156
+ batch(sql: string, paramsBatch: Params[], writeConcern?: WriteConcern): Promise<ExecuteResponse[]>;
157
+ /**
158
+ * Load a whole dataset through the same statement, batching it into requests
159
+ * for you and paying the one fsyncing WAL checkpoint once, after the final
160
+ * batch. The configured durability is restored after every batch, so an
161
+ * import that stops partway never leaves the writer at the relaxed level.
162
+ * Prefer this over {@link load} for anything larger than a single request:
163
+ * it runs the finalize itself, so there is no checkpoint flag to forget.
164
+ *
165
+ * Accepts a synchronous or asynchronous iterable of parameter sets, so rows
166
+ * can stream from a file or the network without being held in memory at
167
+ * once. Returns the total rows loaded and changes applied.
168
+ *
169
+ * ```ts
170
+ * const summary = await db.loadAll(
171
+ * 'INSERT INTO events (id, payload) VALUES (?, ?)',
172
+ * rowStream,
173
+ * { batchSize: 5000, durability: 'off' },
174
+ * )
175
+ * ```
176
+ */
177
+ loadAll(sql: string, rows: Iterable<Params> | AsyncIterable<Params>, options?: LoadAllOptions): Promise<BulkLoadResult>;
178
+ /**
179
+ * Load one batch of rows through the same statement with writer durability
180
+ * relaxed for the duration, then restored before this resolves. This is the
181
+ * low-level primitive; prefer {@link loadAll} for a dataset that spans more
182
+ * than one request, since it runs the finalize itself rather than relying on
183
+ * a `checkpoint` flag.
184
+ *
185
+ * Returns the total rows loaded and changes applied. When splitting a dataset
186
+ * across many `load` calls by hand, pass `checkpoint: false` on every call
187
+ * but the last so the one fsyncing WAL checkpoint runs once at the end; the
188
+ * configured durability is restored after each call regardless.
189
+ */
190
+ load(sql: string, paramsBatch: Params[], durability?: BulkLoadDurability, checkpoint?: boolean): Promise<BulkLoadResult>;
191
+ /**
192
+ * Start building a CDC subscription for the given table.
193
+ * Chain `.filter()` to narrow the events, then call `.subscribe()`
194
+ * with a callback to begin receiving real-time change events.
195
+ *
196
+ * ```ts
197
+ * const sub = await db
198
+ * .on('orders')
199
+ * .filter({ status: 'pending' })
200
+ * .subscribe(event => console.log(event))
201
+ *
202
+ * // Later:
203
+ * sub.unsubscribe()
204
+ * ```
205
+ */
206
+ on(table: string): RemoteSubscriptionBuilder;
207
+ /**
208
+ * Close the transport for this database. After calling `close()`,
209
+ * all pending requests are rejected and new calls will throw.
210
+ */
211
+ close(): void;
212
+ }
213
+
214
+ interface TransportSettings {
215
+ transport: 'websocket' | 'http';
216
+ headers: Record<string, string> | undefined;
217
+ webSocketProtocols: string | string[] | undefined;
218
+ autoReconnect: boolean;
219
+ reconnectInterval: number;
220
+ requestTimeout: number | undefined;
221
+ }
222
+ declare abstract class DatabaseClient {
223
+ protected readonly settings: TransportSettings;
224
+ private readonly databases;
225
+ private closed;
226
+ constructor(options?: ClientOptions);
227
+ database(id: string): RemoteDatabase;
228
+ protected createCapabilities(databaseId: string): ServerCapabilities;
229
+ close(): void;
230
+ protected abstract createTransport(databaseId: string): Transport;
231
+ protected abstract resolveServerUrl(databaseId: string): string | Promise<string>;
232
+ }
233
+
234
+ export { DatabaseClient as D, type LiveHandlers as L, type RemoteSubscription as R, type SubscribeOptions as S, type Transport as T, type RemoteSubscriptionBuilder as a, type RegistryDigestSource as b, type LoadAllOptions as c, RemoteDatabase as d, RemoteError as e, SQL_REFUSED_MESSAGE as f, ServerCapabilities as g, type ServerCapabilityCheck as h };
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,11 @@
1
+ import { runCodegen } from '../chunk-TJF5GZSV.mjs';
2
+ import '../chunk-JU64Y7HM.mjs';
3
+ import '../chunk-TUD5CJ76.mjs';
4
+ import '../chunk-GVCNMPOS.mjs';
5
+ import '../chunk-UC3SCMIN.mjs';
6
+
7
+ // src/codegen/cli.ts
8
+ runCodegen(process.argv.slice(2)).catch((err) => {
9
+ process.exitCode = 1;
10
+ console.error(err instanceof Error ? err.message : String(err));
11
+ });
@@ -0,0 +1,30 @@
1
+ import { a as OperationRegistry } from '../operation-registry-9DcvxcE5.js';
2
+ import '../types-zhnRXrsb.js';
3
+
4
+ declare const OPERATION_MANIFEST_VERSION = 1;
5
+ interface OperationShape {
6
+ args: string[];
7
+ identityArgs: string[];
8
+ columns: string[] | null;
9
+ }
10
+ interface DatabaseManifest {
11
+ reads: Record<string, OperationShape>;
12
+ writes: Record<string, OperationShape>;
13
+ }
14
+ interface OperationManifest {
15
+ version: number;
16
+ digest: string | undefined;
17
+ databases: Record<string, DatabaseManifest>;
18
+ }
19
+ declare function buildOperationManifest<I>(registry: OperationRegistry<I>): OperationManifest;
20
+ declare function selectColumns(sql: string): string[] | null;
21
+
22
+ interface RenderOptions {
23
+ packageName?: string;
24
+ }
25
+ declare function renderOperationTypes(manifest: OperationManifest, options?: RenderOptions): string;
26
+
27
+ 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.";
28
+ declare function runCodegen(argv: readonly string[]): Promise<void>;
29
+
30
+ export { CODEGEN_USAGE, type DatabaseManifest, OPERATION_MANIFEST_VERSION, type OperationManifest, type OperationShape, type RenderOptions, buildOperationManifest, renderOperationTypes, runCodegen, selectColumns };
@@ -0,0 +1,5 @@
1
+ export { CODEGEN_USAGE, OPERATION_MANIFEST_VERSION, buildOperationManifest, renderOperationTypes, runCodegen, selectColumns } from '../chunk-TJF5GZSV.mjs';
2
+ import '../chunk-JU64Y7HM.mjs';
3
+ import '../chunk-TUD5CJ76.mjs';
4
+ import '../chunk-GVCNMPOS.mjs';
5
+ import '../chunk-UC3SCMIN.mjs';
@@ -1,12 +1,16 @@
1
- import { g as BulkLoadDurability, e as SQLiteConnection, s as SynchronousLevel, h as BulkLoadResult, a as SQLiteDriver, t as WorkerHostOptions, D as DatabaseOptions, L as LifecycleConfig, P as Params, E as ExecuteResult } from '../types-D_hQW1hr.js';
2
- export { A as AfterQueryHook, f as BackupScheduleOptions, u as BatchSummary, b as BeforeConnectHook, B as BeforeQueryHook, l as BeforeSubscribeHook, q as BulkLoadOptions, o as CDCMetrics, C as ChangeEvent, v as ChangeOperation, w as ClientOptions, x as ClusterReadEndpointInfo, y as ClusterStatusInfo, k as ConnectionHookContext, n as ConnectionMetrics, z as CorsOptions, d as DatabaseCloseHook, c as DatabaseOpenHook, F as DriverCapabilities, G as DriverWorkerEntry, H as HookConfig, M as MetricsConfig, O as OnRequestHook, I as OpenOptions, Q as QueryHookContext, m as QueryMetrics, p as QueryOptions, R as ReadConcern, J as ReadConcernLevel, K as ReplicationStatusInfo, N as RequestContext, U as RequestDenial, V as RunResult, X as SQLiteStatement, Y as ServerExecutionTarget, Z as ServerExecutionTargetResolver, i as ServerOptions, S as SirannonOptions, _ as Subscription, r as SubscriptionBuilder, T as Transaction, j as WSHandlerOptions, W as WriteConcern, $ as WriteConcernLevel, a0 as WriterWorkerOptions } from '../types-D_hQW1hr.js';
3
- export { C as ChangeTracker, a as ChangeTrackerOptions } from '../change-tracker-CbmaMO-N.js';
4
- import { D as Database } from '../database-DuGp0Rtr.js';
5
- export { H as HookDispose, a as HookEvent, b as HookEventContextMap, c as HookHandler, d as HookRegistry, M as MetricsCollector, S as SubscribeHookContext } from '../database-DuGp0Rtr.js';
6
- 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, S as SirannonError, T as TransactionError, W as WriteOverloadError } from '../errors-5Nf5ZAEC.js';
7
- import { M as Migration, a as MigrationResult, R as RollbackResult } from '../types-D4p4UyDK.js';
8
- export { A as AppliedMigration, b as AppliedMigrationEntry } from '../types-D4p4UyDK.js';
9
- export { S as Sirannon } from '../sirannon-4SspRvP5.js';
1
+ import { e as SQLiteConnection, s as SynchronousLevel, a as SQLiteDriver, t as WorkerHostOptions, P as Params, E as ExecuteResult, D as DatabaseOptions, L as LifecycleConfig, M as Migration, q as MigrationResult, r as RollbackResult } from '../types-zhnRXrsb.js';
2
+ export { A as AfterQueryHook, u as AppliedMigration, v as AppliedMigrationEntry, f as BackupScheduleOptions, w as BatchSummary, b as BeforeConnectHook, B as BeforeQueryHook, k as BeforeSubscribeHook, o as CDCMetrics, h as ChangeEvent, x as ChangeOperation, y as ClusterReadEndpointInfo, C as ClusterStatusInfo, j as ConnectionHookContext, n as ConnectionMetrics, d as DatabaseCloseHook, c as DatabaseOpenHook, z as DriverCapabilities, F as DriverWorkerEntry, H as HookConfig, G as MIGRATION_NAME_RE, l as MetricsConfig, I as MigrationBaseline, J as MigrationSource, N as NodeHealth, K as NodeHealthReason, O as NodeHealthState, U as OpenOptions, i as QueryHookContext, m as QueryMetrics, Q as QueryOptions, R as ReadConcern, g as ReadConcernLevel, V as RunResult, X as SQLiteStatement, S as SirannonOptions, Y as Subscription, p as SubscriptionBuilder, T as Transaction, W as WriteConcern, Z as WriteConcernLevel, _ as WriterWorkerOptions } from '../types-zhnRXrsb.js';
3
+ import { B as BulkLoadDurability, a as BulkLoadResult } from '../server-options-1JHu8pid.js';
4
+ export { c as AuthenticateHook, b as BulkLoadOptions, C as ClientOptions, d as ClusterStatusAuthorizer, e as CorsOptions, R as ReplicationStatusInfo, f as RequestContext, g as ServerExecutionTarget, h as ServerExecutionTargetResolver, S as ServerOptions, W as WSHandlerOptions } from '../server-options-1JHu8pid.js';
5
+ export { C as ChangeTracker, a as ChangeTrackerOptions } from '../change-tracker-DKRVUC3l.js';
6
+ import { D as Database } from '../database-BY0L5Q2n.js';
7
+ export { H as HookDispose, a as HookEvent, b as HookEventContextMap, c as HookHandler, d as HookRegistry, M as MetricsCollector, S as SubscribeHookContext } from '../database-BY0L5Q2n.js';
8
+ 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-Bw5MdNCu.js';
9
+ export { a as LiveQuery, L as LiveQueryOptions, b as LiveQueryState, c as LiveUpdate, R as ResultOp } from '../types-CL6piSnD.js';
10
+ import { B as BaselineFileOption } from '../baseline-Br77Fnhb.js';
11
+ export { S as Sirannon } from '../sirannon-DaQSyhbJ.js';
12
+ 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-9DcvxcE5.js';
13
+ import '../types-C_D8IhpO.js';
10
14
 
11
15
  declare function isBulkLoadDurability(value: unknown): value is BulkLoadDurability;
12
16
  interface BulkLoadRun {
@@ -81,6 +85,11 @@ declare class ConnectionPool {
81
85
  close(): Promise<void>;
82
86
  }
83
87
 
88
+ declare function query<T = Record<string, unknown>>(conn: SQLiteConnection, sql: string, params?: Params): Promise<T[]>;
89
+ declare function queryOne<T = Record<string, unknown>>(conn: SQLiteConnection, sql: string, params?: Params): Promise<T | undefined>;
90
+ declare function execute(conn: SQLiteConnection, sql: string, params?: Params, trusted?: boolean): Promise<ExecuteResult>;
91
+ declare function executeBatch(conn: SQLiteConnection, sql: string, paramsBatch: Params[]): Promise<ExecuteResult[]>;
92
+
84
93
  declare function defineDriver(config: SQLiteDriver): SQLiteDriver;
85
94
 
86
95
  declare const DEFAULT_SYNCHRONOUS: SynchronousLevel;
@@ -128,16 +137,28 @@ declare function createTenantResolver(options: TenantResolverOptions): (id: stri
128
137
  options?: DatabaseOptions;
129
138
  } | undefined;
130
139
 
140
+ declare const MIGRATION_FILENAME_PATTERN: RegExp;
141
+ interface ParsedMigrationFilename {
142
+ version: number;
143
+ name: string;
144
+ direction: 'up' | 'down';
145
+ }
146
+ declare function parseMigrationFilename(filename: string): ParsedMigrationFilename | null;
147
+
148
+ interface MigrationsFromFilesOptions {
149
+ baseline?: BaselineFileOption;
150
+ }
151
+ declare function migrationsFromFiles(files: Record<string, unknown>, options?: MigrationsFromFilesOptions): Migration[];
152
+
131
153
  declare class MigrationRunner {
132
154
  static run(conn: SQLiteConnection, migrations: Migration[]): Promise<MigrationResult>;
155
+ private static retryOnConcurrentConflict;
156
+ private static applyPending;
133
157
  static rollback(conn: SQLiteConnection, migrations: Migration[], version?: number): Promise<RollbackResult>;
158
+ private static resolveDownMigration;
134
159
  private static validateMigrations;
135
- private static getAppliedVersions;
160
+ private static highestVersion;
161
+ private static getAppliedRows;
136
162
  }
137
163
 
138
- declare function query<T = Record<string, unknown>>(conn: SQLiteConnection, sql: string, params?: Params): Promise<T[]>;
139
- declare function queryOne<T = Record<string, unknown>>(conn: SQLiteConnection, sql: string, params?: Params): Promise<T | undefined>;
140
- declare function execute(conn: SQLiteConnection, sql: string, params?: Params): Promise<ExecuteResult>;
141
- declare function executeBatch(conn: SQLiteConnection, sql: string, paramsBatch: Params[]): Promise<ExecuteResult[]>;
142
-
143
- export { BulkLoadDurability, BulkLoadResult, ConnectionPool, type ConnectionPoolOptions, DEFAULT_SYNCHRONOUS, Database, DatabaseOptions, ExecuteResult, type LifecycleCallbacks, LifecycleConfig, LifecycleManager, Migration, MigrationResult, MigrationRunner, Params, RollbackResult, SQLiteConnection, SQLiteDriver, SynchronousLevel, type TenantResolverOptions, createTenantResolver, defineDriver, execute, executeBatch, isBulkLoadDurability, isSynchronousLevel, query, queryOne, runBulkLoad, sanitizeTenantId, synchronousPragmaValue, tenantPath };
164
+ export { BaselineFileOption, BulkLoadDurability, BulkLoadResult, ConnectionPool, type ConnectionPoolOptions, DEFAULT_SYNCHRONOUS, Database, DatabaseOptions, ExecuteResult, type LifecycleCallbacks, LifecycleConfig, LifecycleManager, MIGRATION_FILENAME_PATTERN, Migration, MigrationResult, MigrationRunner, type MigrationsFromFilesOptions, Params, type ParsedMigrationFilename, RollbackResult, SQLiteConnection, SQLiteDriver, SynchronousLevel, type TenantResolverOptions, createTenantResolver, defineDriver, execute, executeBatch, isBulkLoadDurability, isSynchronousLevel, migrationsFromFiles, parseMigrationFilename, query, queryOne, runBulkLoad, sanitizeTenantId, synchronousPragmaValue, tenantPath };