@delali/sirannon-db 0.2.0 → 0.2.1
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/dist/backup-scheduler/index.d.ts +15 -1
- package/dist/backup-scheduler/index.mjs +2 -2
- package/dist/baseline-D93hcIEE.d.ts +17 -0
- package/dist/{change-tracker-DKRVUC3l.d.ts → change-tracker-DDmXB754.d.ts} +56 -8
- package/dist/{chunk-5NOIGN5Y.mjs → chunk-2QLXDHAP.mjs} +1 -1
- package/dist/{chunk-LNY2VVHE.mjs → chunk-7C36BCSN.mjs} +1 -1
- package/dist/{chunk-NVQS53NT.mjs → chunk-7FQRQH5Z.mjs} +53 -64
- package/dist/{chunk-D7LAYTKN.mjs → chunk-7R4ER4FB.mjs} +1 -1
- package/dist/{chunk-FHWTZFI4.mjs → chunk-BQFQ65OL.mjs} +1 -1
- package/dist/{chunk-O7SLN3GI.mjs → chunk-BTTFW4Z4.mjs} +1 -1
- package/dist/{chunk-H6PIVVDN.mjs → chunk-CCZK6LCB.mjs} +38 -25
- package/dist/{chunk-JZGINXTN.mjs → chunk-HCCGEIZ2.mjs} +2 -2
- package/dist/{chunk-67M7KAH6.mjs → chunk-IWGIYDMZ.mjs} +1 -1
- package/dist/{chunk-LFZ37BSX.mjs → chunk-OUSWVNWT.mjs} +1 -1
- package/dist/{chunk-HR5CWTLC.mjs → chunk-P2VJYRVY.mjs} +60 -7
- package/dist/{chunk-UC3SCMIN.mjs → chunk-PBRXXISQ.mjs} +3 -0
- package/dist/{chunk-JU64Y7HM.mjs → chunk-SBL6GN43.mjs} +1 -1
- package/dist/{chunk-EBJXPQQO.mjs → chunk-UPKKSUPA.mjs} +2 -2
- package/dist/{chunk-TJF5GZSV.mjs → chunk-VOSJBZ6Q.mjs} +1 -1
- package/dist/{chunk-PIKHN33N.mjs → chunk-VOYGMAU7.mjs} +9 -1
- package/dist/{chunk-H237TXZW.mjs → chunk-WJ67DTD6.mjs} +48 -6
- package/dist/{chunk-OQVZBEBY.mjs → chunk-XF2HH5E6.mjs} +4 -61
- package/dist/client/index.d.ts +211 -12
- package/dist/client/index.mjs +155 -67
- package/dist/client/topology.d.ts +55 -7
- package/dist/client/topology.mjs +20 -1
- package/dist/{client-base-CLWmH5Ln.d.ts → client-base-CmZO0v3m.d.ts} +133 -24
- package/dist/codegen/cli.mjs +3 -3
- package/dist/codegen/index.d.ts +92 -2
- package/dist/codegen/index.mjs +3 -3
- package/dist/core/index.d.ts +177 -15
- package/dist/core/index.mjs +2481 -2226
- package/dist/core/writer-worker.mjs +3 -3
- package/dist/database-B5Qv1-cU.d.ts +380 -0
- package/dist/driver/better-sqlite3.d.ts +18 -1
- package/dist/driver/better-sqlite3.mjs +5 -5
- package/dist/driver/bun.d.ts +28 -0
- package/dist/driver/expo.d.ts +17 -0
- package/dist/driver/node.d.ts +18 -1
- package/dist/driver/node.mjs +5 -5
- package/dist/driver/wa-sqlite.d.ts +18 -1
- package/dist/{errors-Bw5MdNCu.d.ts → errors-Dei4GdBb.d.ts} +80 -7
- package/dist/file-migrations/index.d.ts +54 -2
- package/dist/file-migrations/index.mjs +3 -3
- package/dist/{operation-registry-9DcvxcE5.d.ts → operation-registry-hlbhqu7q.d.ts} +50 -1
- package/dist/{primary-wins-DPAm2AKG.d.ts → primary-wins-B0np8JS3.d.ts} +25 -1
- package/dist/protocol-rqANt-9Q.d.ts +152 -0
- package/dist/query-types-DL3LtPvY.d.ts +95 -0
- package/dist/react/index.d.ts +58 -3
- package/dist/replication/coordinator/etcd.d.ts +63 -3
- package/dist/replication/coordinator/etcd.mjs +82 -46
- package/dist/replication/index.d.ts +329 -95
- package/dist/replication/index.mjs +256 -141
- package/dist/server/index.d.ts +230 -12
- package/dist/server/index.mjs +63 -50
- package/dist/{server-options-1JHu8pid.d.ts → server-options-Dab_Jvd_.d.ts} +96 -12
- package/dist/sirannon-CMhiJa5Y.d.ts +111 -0
- package/dist/transport/grpc.d.ts +93 -9
- package/dist/transport/grpc.mjs +63 -20
- package/dist/transport/memory.d.ts +50 -20
- package/dist/transport/memory.mjs +25 -0
- package/dist/{types-CL6piSnD.d.ts → types-BCejqzNA.d.ts} +20 -0
- package/dist/types-CMBcFPhb.d.ts +336 -0
- package/dist/types-CjhxcjhA.d.ts +123 -0
- package/dist/types-DyrCiWuc.d.ts +499 -0
- package/dist/types-rVZKnKN-.d.ts +591 -0
- package/package.json +7 -1
- package/dist/baseline-Br77Fnhb.d.ts +0 -6
- package/dist/database-BY0L5Q2n.d.ts +0 -172
- package/dist/protocol-6KrSq2Hy.d.ts +0 -66
- package/dist/sirannon-DaQSyhbJ.d.ts +0 -36
- package/dist/types-B7gmEsZW.d.ts +0 -221
- package/dist/types-BsVabqSI.d.ts +0 -139
- package/dist/types-C_D8IhpO.d.ts +0 -60
- package/dist/types-zhnRXrsb.d.ts +0 -384
package/dist/core/index.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import { e as SQLiteConnection,
|
|
2
|
-
export { A as AfterQueryHook,
|
|
3
|
-
import { B as BulkLoadDurability, a as BulkLoadResult } from '../server-options-
|
|
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-
|
|
5
|
-
export { C as ChangeTracker, a as ChangeTrackerOptions } from '../change-tracker-
|
|
6
|
-
import { D as Database } from '../database-
|
|
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-
|
|
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-
|
|
9
|
-
export { a as LiveQuery, L as LiveQueryOptions, b as LiveQueryState, c as LiveUpdate, R as ResultOp } from '../types-
|
|
10
|
-
import { B as BaselineFileOption } from '../baseline-
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
|
|
1
|
+
import { e as SQLiteConnection, n as SynchronousLevel, a as SQLiteDriver, W as WorkerHostOptions, D as DatabaseOptions, L as LifecycleConfig, M as Migration, m as MigrationResult, R as RollbackResult } from '../types-rVZKnKN-.js';
|
|
2
|
+
export { A as AfterQueryHook, o as AppliedMigration, p as AppliedMigrationEntry, f as BackupScheduleOptions, q as BatchSummary, b as BeforeConnectHook, B as BeforeQueryHook, h as BeforeSubscribeHook, l as CDCMetrics, r as ClusterReadEndpointInfo, C as ClusterStatusInfo, g as ConnectionHookContext, k as ConnectionMetrics, d as DatabaseCloseHook, c as DatabaseOpenHook, s as DriverCapabilities, t as DriverWorkerEntry, H as HookConfig, u as MIGRATION_NAME_RE, i as MetricsConfig, v as MigrationBaseline, w as MigrationSource, N as NodeHealth, x as NodeHealthReason, y as NodeHealthState, O as OpenOptions, Q as QueryHookContext, j as QueryMetrics, z as RunResult, E as SQLiteStatement, S as SirannonOptions, T as Transaction, F as WriterWorkerOptions } from '../types-rVZKnKN-.js';
|
|
3
|
+
import { B as BulkLoadDurability, a as BulkLoadResult } from '../server-options-Dab_Jvd_.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-Dab_Jvd_.js';
|
|
5
|
+
export { C as ChangeTracker, a as ChangeTrackerOptions } from '../change-tracker-DDmXB754.js';
|
|
6
|
+
import { D as Database } from '../database-B5Qv1-cU.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-B5Qv1-cU.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-Dei4GdBb.js';
|
|
9
|
+
export { a as LiveQuery, L as LiveQueryOptions, b as LiveQueryState, c as LiveUpdate, R as ResultOp } from '../types-BCejqzNA.js';
|
|
10
|
+
import { B as BaselineFileOption } from '../baseline-D93hcIEE.js';
|
|
11
|
+
import { P as Params, E as ExecuteResult } from '../query-types-DL3LtPvY.js';
|
|
12
|
+
export { C as ChangeEvent, b as ChangeOperation, Q as QueryOptions, R as ReadConcern, a as ReadConcernLevel, c as Subscription, S as SubscriptionBuilder, W as WriteConcern, d as WriteConcernLevel } from '../query-types-DL3LtPvY.js';
|
|
13
|
+
export { S as Sirannon } from '../sirannon-CMhiJa5Y.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-hlbhqu7q.js';
|
|
15
|
+
import '../types-CjhxcjhA.js';
|
|
14
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Reports whether a value is one of the durability levels a bulk load accepts.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
15
22
|
declare function isBulkLoadDurability(value: unknown): value is BulkLoadDurability;
|
|
16
23
|
interface BulkLoadRun {
|
|
17
24
|
writer: SQLiteConnection;
|
|
@@ -24,7 +31,7 @@ interface BulkLoadRun {
|
|
|
24
31
|
/**
|
|
25
32
|
* Run a bulk load with relaxed writer durability, then restore the
|
|
26
33
|
* operator-configured level. The caller must hold the database's writer lock
|
|
27
|
-
* for the whole call
|
|
34
|
+
* for the whole call so that no other write commits under the relaxed level.
|
|
28
35
|
*
|
|
29
36
|
* Interruption safety, by failure mode:
|
|
30
37
|
* - A load statement fails: the surrounding transaction rolls back, the
|
|
@@ -58,9 +65,16 @@ interface BulkLoadRun {
|
|
|
58
65
|
* batch; each intermediate load still restores the configured level, and
|
|
59
66
|
* SQLite's automatic checkpoint keeps the WAL bounded during the import at the
|
|
60
67
|
* relaxed level with no fsync of its own.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
61
70
|
*/
|
|
62
71
|
declare function runBulkLoad(run: BulkLoadRun): Promise<BulkLoadResult>;
|
|
63
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Settings a connection pool opens its writer and readers with.
|
|
75
|
+
*
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
64
78
|
interface ConnectionPoolOptions {
|
|
65
79
|
driver: SQLiteDriver;
|
|
66
80
|
path: string;
|
|
@@ -71,6 +85,11 @@ interface ConnectionPoolOptions {
|
|
|
71
85
|
useWriterWorker?: boolean;
|
|
72
86
|
workerHostOptions?: WorkerHostOptions;
|
|
73
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Holds one writer connection and a rotating set of reader connections for a single database file.
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
74
93
|
declare class ConnectionPool {
|
|
75
94
|
private readonly writer;
|
|
76
95
|
private readonly readers;
|
|
@@ -85,27 +104,80 @@ declare class ConnectionPool {
|
|
|
85
104
|
close(): Promise<void>;
|
|
86
105
|
}
|
|
87
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Runs a read on one connection and returns the rows with their values decoded.
|
|
109
|
+
*
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
88
112
|
declare function query<T = Record<string, unknown>>(conn: SQLiteConnection, sql: string, params?: Params): Promise<T[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Runs a read on one connection and returns the first row, or undefined when there is none.
|
|
115
|
+
*
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
89
118
|
declare function queryOne<T = Record<string, unknown>>(conn: SQLiteConnection, sql: string, params?: Params): Promise<T | undefined>;
|
|
119
|
+
/**
|
|
120
|
+
* Runs one write on a connection and returns the change count and last inserted row id.
|
|
121
|
+
*
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
90
124
|
declare function execute(conn: SQLiteConnection, sql: string, params?: Params, trusted?: boolean): Promise<ExecuteResult>;
|
|
125
|
+
/**
|
|
126
|
+
* Runs one statement over many parameter sets on a connection and returns a result per set.
|
|
127
|
+
*
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
91
130
|
declare function executeBatch(conn: SQLiteConnection, sql: string, paramsBatch: Params[]): Promise<ExecuteResult[]>;
|
|
92
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Builds a {@link SQLiteDriver} from an implementation, copying across only the optional members Sirannon supports.
|
|
134
|
+
*
|
|
135
|
+
* @param driver - The driver implementation.
|
|
136
|
+
* @returns The driver, ready to pass to a `Sirannon` registry.
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
93
140
|
declare function defineDriver(config: SQLiteDriver): SQLiteDriver;
|
|
94
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Writer durability a database opens at when you name none.
|
|
144
|
+
*
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
95
147
|
declare const DEFAULT_SYNCHRONOUS: SynchronousLevel;
|
|
96
148
|
/**
|
|
97
|
-
* Map a synchronous level to its PRAGMA argument through an allowlist
|
|
149
|
+
* Map a synchronous level to its PRAGMA argument through an allowlist so that a
|
|
98
150
|
* value smuggled past the type system can never reach SQL interpolation.
|
|
151
|
+
*
|
|
152
|
+
* @public
|
|
99
153
|
*/
|
|
100
154
|
declare function synchronousPragmaValue(level: SynchronousLevel | undefined): string;
|
|
155
|
+
/**
|
|
156
|
+
* Reports whether a value is one of the durability levels SQLite accepts.
|
|
157
|
+
*
|
|
158
|
+
* @param value - The value to check.
|
|
159
|
+
* @returns True when it is a valid level.
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
101
163
|
declare function isSynchronousLevel(value: unknown): value is SynchronousLevel;
|
|
102
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Operations the lifecycle manager calls back into on the owning registry.
|
|
167
|
+
*
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
103
170
|
interface LifecycleCallbacks {
|
|
104
171
|
open: (id: string, path: string, options?: DatabaseOptions) => Promise<Database>;
|
|
105
172
|
close: (id: string) => Promise<void>;
|
|
106
173
|
count: () => number;
|
|
107
174
|
has: (id: string) => boolean;
|
|
108
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Opens databases on demand, evicts idle ones, and enforces the configured open-database limit.
|
|
178
|
+
*
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
109
181
|
declare class LifecycleManager {
|
|
110
182
|
#private;
|
|
111
183
|
private readonly config;
|
|
@@ -125,31 +197,121 @@ declare class LifecycleManager {
|
|
|
125
197
|
private ensureNotDisposed;
|
|
126
198
|
}
|
|
127
199
|
|
|
200
|
+
/**
|
|
201
|
+
* How tenant identifiers map onto database files.
|
|
202
|
+
*
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
128
205
|
interface TenantResolverOptions {
|
|
206
|
+
/**
|
|
207
|
+
* Directory every tenant's database file is written to.
|
|
208
|
+
*/
|
|
129
209
|
basePath: string;
|
|
210
|
+
/**
|
|
211
|
+
* File extension appended to the tenant identifier. Default: '.db'.
|
|
212
|
+
*/
|
|
130
213
|
extension?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Options every tenant database opens with.
|
|
216
|
+
*/
|
|
131
217
|
defaultOptions?: DatabaseOptions;
|
|
132
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Checks a tenant identifier against the characters and length a file name may carry.
|
|
221
|
+
*
|
|
222
|
+
* @param id - The identifier to check.
|
|
223
|
+
* @returns The identifier when it is safe, and undefined when it is not.
|
|
224
|
+
*
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
133
227
|
declare function sanitizeTenantId(id: string): string | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* Builds the database file path for one tenant.
|
|
230
|
+
*
|
|
231
|
+
* @param basePath - Directory the file is written to.
|
|
232
|
+
* @param tenantId - Identifier of the tenant.
|
|
233
|
+
* @param extension - File extension to append. Default: '.db'.
|
|
234
|
+
* @returns The full path for that tenant's database file.
|
|
235
|
+
* @throws When the identifier is unsafe or the resulting file name is too long.
|
|
236
|
+
*
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
134
239
|
declare function tenantPath(basePath: string, tenantId: string, extension?: string): string;
|
|
240
|
+
/**
|
|
241
|
+
* Builds a resolver that turns a tenant identifier into a database path, for {@link LifecycleConfig.autoOpen}.
|
|
242
|
+
*
|
|
243
|
+
* @param options - Base directory, file extension, and the options each tenant database opens with.
|
|
244
|
+
* @returns A resolver that returns a path and options, or undefined for an unsafe identifier.
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
135
248
|
declare function createTenantResolver(options: TenantResolverOptions): (id: string) => {
|
|
136
249
|
path: string;
|
|
137
250
|
options?: DatabaseOptions;
|
|
138
251
|
} | undefined;
|
|
139
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Matches a migration file name of the form `001_create_orders.up.sql`.
|
|
255
|
+
*
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
140
258
|
declare const MIGRATION_FILENAME_PATTERN: RegExp;
|
|
259
|
+
/**
|
|
260
|
+
* The three parts of a migration file name.
|
|
261
|
+
*
|
|
262
|
+
* @public
|
|
263
|
+
*/
|
|
141
264
|
interface ParsedMigrationFilename {
|
|
265
|
+
/**
|
|
266
|
+
* Version number the file name starts with.
|
|
267
|
+
*/
|
|
142
268
|
version: number;
|
|
269
|
+
/**
|
|
270
|
+
* Migration name between the version and the direction.
|
|
271
|
+
*/
|
|
143
272
|
name: string;
|
|
273
|
+
/**
|
|
274
|
+
* Whether the file applies the migration or undoes it.
|
|
275
|
+
*/
|
|
144
276
|
direction: 'up' | 'down';
|
|
145
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Splits a migration file name into its version, name, and direction.
|
|
280
|
+
*
|
|
281
|
+
* @param filename - File name such as `001_create_orders.up.sql`.
|
|
282
|
+
* @returns The three parts, or null when the name does not match the expected form.
|
|
283
|
+
*
|
|
284
|
+
* @public
|
|
285
|
+
*/
|
|
146
286
|
declare function parseMigrationFilename(filename: string): ParsedMigrationFilename | null;
|
|
147
287
|
|
|
288
|
+
/**
|
|
289
|
+
* How a set of migration files is turned into migrations.
|
|
290
|
+
*
|
|
291
|
+
* @public
|
|
292
|
+
*/
|
|
148
293
|
interface MigrationsFromFilesOptions {
|
|
294
|
+
/**
|
|
295
|
+
* Marks the migration an existing database starts from.
|
|
296
|
+
*/
|
|
149
297
|
baseline?: BaselineFileOption;
|
|
150
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Builds migrations from file contents you have already read, which suits a bundler that inlines the SQL.
|
|
301
|
+
*
|
|
302
|
+
* @param files - Migration file names mapped to their SQL.
|
|
303
|
+
* @param options - The baseline to apply, when an existing database starts from one.
|
|
304
|
+
* @returns The migrations, in ascending version order.
|
|
305
|
+
*
|
|
306
|
+
* @public
|
|
307
|
+
*/
|
|
151
308
|
declare function migrationsFromFiles(files: Record<string, unknown>, options?: MigrationsFromFilesOptions): Migration[];
|
|
152
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Applies and rolls back migrations against one connection.
|
|
312
|
+
*
|
|
313
|
+
* @internal
|
|
314
|
+
*/
|
|
153
315
|
declare class MigrationRunner {
|
|
154
316
|
static run(conn: SQLiteConnection, migrations: Migration[]): Promise<MigrationResult>;
|
|
155
317
|
private static retryOnConcurrentConflict;
|