@event-driven-io/dumbo 0.13.0-beta.34 → 0.13.0-beta.36

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 (87) hide show
  1. package/dist/cloudflare.cjs +379 -434
  2. package/dist/cloudflare.cjs.map +1 -1
  3. package/dist/cloudflare.d.cts +36 -29
  4. package/dist/cloudflare.d.ts +36 -29
  5. package/dist/cloudflare.js +343 -434
  6. package/dist/cloudflare.js.map +1 -1
  7. package/dist/core-BeyC5tHn.js +519 -0
  8. package/dist/core-BeyC5tHn.js.map +1 -0
  9. package/dist/core-Bf2ujUFy.js +379 -0
  10. package/dist/core-Bf2ujUFy.js.map +1 -0
  11. package/dist/core-BgYtAxCm.cjs +3237 -0
  12. package/dist/core-BgYtAxCm.cjs.map +1 -0
  13. package/dist/core-DDo4m0Z_.js +2262 -0
  14. package/dist/core-DDo4m0Z_.js.map +1 -0
  15. package/dist/core-DmbB4qMn.cjs +656 -0
  16. package/dist/core-DmbB4qMn.cjs.map +1 -0
  17. package/dist/core-Go_IA78L.cjs +450 -0
  18. package/dist/core-Go_IA78L.cjs.map +1 -0
  19. package/dist/{connectionString-Dch_MIRU.d.cts → index-BDSQvDH2.d.cts} +1010 -922
  20. package/dist/index-BdWFmDhJ.d.cts +68 -0
  21. package/dist/index-D1jryNqo.d.ts +198 -0
  22. package/dist/index-DaP2fTEX.d.ts +67 -0
  23. package/dist/index-DqVvUav9.d.cts +198 -0
  24. package/dist/index-S_wp0Eaf.d.cts +67 -0
  25. package/dist/index-cxtbLiju.d.ts +68 -0
  26. package/dist/{connectionString-Dch_MIRU.d.ts → index-zkszkJqP.d.ts} +1010 -922
  27. package/dist/index.cjs +212 -359
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +3 -132
  30. package/dist/index.d.ts +3 -132
  31. package/dist/index.js +52 -361
  32. package/dist/index.js.map +1 -1
  33. package/dist/pg.cjs +366 -431
  34. package/dist/pg.cjs.map +1 -1
  35. package/dist/pg.d.cts +83 -72
  36. package/dist/pg.d.ts +83 -72
  37. package/dist/pg.js +320 -431
  38. package/dist/pg.js.map +1 -1
  39. package/dist/postgreSQLMetadata-LqX-Z_wo.cjs +118 -0
  40. package/dist/postgreSQLMetadata-LqX-Z_wo.cjs.map +1 -0
  41. package/dist/postgreSQLMetadata-zMq8yJo_.js +65 -0
  42. package/dist/postgreSQLMetadata-zMq8yJo_.js.map +1 -0
  43. package/dist/postgresql.cjs +25 -50
  44. package/dist/postgresql.d.cts +3 -61
  45. package/dist/postgresql.d.ts +3 -61
  46. package/dist/postgresql.js +4 -50
  47. package/dist/sqlite.cjs +30 -60
  48. package/dist/sqlite.d.cts +3 -190
  49. package/dist/sqlite.d.ts +3 -190
  50. package/dist/sqlite.js +4 -60
  51. package/dist/sqlite3.cjs +312 -380
  52. package/dist/sqlite3.cjs.map +1 -1
  53. package/dist/sqlite3.d.cts +79 -77
  54. package/dist/sqlite3.d.ts +79 -77
  55. package/dist/sqlite3.js +276 -378
  56. package/dist/sqlite3.js.map +1 -1
  57. package/dist/sqliteMetadata-BoQ7Sc9I.js +29 -0
  58. package/dist/sqliteMetadata-BoQ7Sc9I.js.map +1 -0
  59. package/dist/sqliteMetadata-D_2pKeCC.cjs +46 -0
  60. package/dist/sqliteMetadata-D_2pKeCC.cjs.map +1 -0
  61. package/package.json +12 -12
  62. package/dist/chunk-33P5766L.js +0 -83
  63. package/dist/chunk-33P5766L.js.map +0 -1
  64. package/dist/chunk-4MMMEDQ7.cjs +0 -2944
  65. package/dist/chunk-4MMMEDQ7.cjs.map +0 -1
  66. package/dist/chunk-6HAHSSPW.js +0 -701
  67. package/dist/chunk-6HAHSSPW.js.map +0 -1
  68. package/dist/chunk-GNH5XC6D.cjs +0 -481
  69. package/dist/chunk-GNH5XC6D.cjs.map +0 -1
  70. package/dist/chunk-H2JBS7HM.js +0 -2944
  71. package/dist/chunk-H2JBS7HM.js.map +0 -1
  72. package/dist/chunk-JIZGCEPE.cjs +0 -701
  73. package/dist/chunk-JIZGCEPE.cjs.map +0 -1
  74. package/dist/chunk-NJI6PJFZ.cjs +0 -83
  75. package/dist/chunk-NJI6PJFZ.cjs.map +0 -1
  76. package/dist/chunk-RQ3KKMTP.cjs +0 -34
  77. package/dist/chunk-RQ3KKMTP.cjs.map +0 -1
  78. package/dist/chunk-UK7MXVS2.js +0 -34
  79. package/dist/chunk-UK7MXVS2.js.map +0 -1
  80. package/dist/chunk-Y5TD53QE.js +0 -481
  81. package/dist/chunk-Y5TD53QE.js.map +0 -1
  82. package/dist/columnProcessors-Be2uMYjS.d.cts +0 -8
  83. package/dist/columnProcessors-D0ivj_SU.d.ts +0 -8
  84. package/dist/postgresql.cjs.map +0 -1
  85. package/dist/postgresql.js.map +0 -1
  86. package/dist/sqlite.cjs.map +0 -1
  87. package/dist/sqlite.js.map +0 -1
@@ -0,0 +1,519 @@
1
+ import { B as LockNotAvailableError, Et as SQLProcessorsRegistry, I as ForeignKeyViolationError, K as UniqueConstraintError, L as InsufficientResourcesError, M as DataError, N as DeadlockError, P as DumboError, R as IntegrityConstraintViolationError, T as sqlExecutor, Tt as mapDefaultSQLColumnProcessors, U as SerializationError, V as NotNullViolationError, W as SystemError, X as registerDefaultMigratorOptions, bt as SQL, c as createAmbientConnection, j as ConnectionError, k as CheckViolationError, l as createConnection, n as createAmbientConnectionPool, o as createSingletonConnectionPool, ot as SQLFormatter, r as createBoundedConnectionPool, rt as tracer, s as guardInitializedOnce, t as createAlwaysNewConnectionPool, ut as registerFormatter, w as mapSQLQueryResult, wt as defaultProcessorsRegistry, z as InvalidOperationError } from "./core-DDo4m0Z_.js";
2
+ import "./sqliteMetadata-BoQ7Sc9I.js";
3
+ import { cpus } from "os";
4
+
5
+ //#region src/storage/sqlite/core/errors/errorMapper.ts
6
+ /**
7
+ * Extracts the SQLite error code string from a `sqlite3` driver error.
8
+ *
9
+ * The `sqlite3` (node-sqlite3) driver sets `error.code` to a string like
10
+ * `'SQLITE_CONSTRAINT'` and `error.errno` to the numeric result code.
11
+ * See: https://github.com/TryGhost/node-sqlite3
12
+ */
13
+ const getSqliteErrorCode = (error) => {
14
+ if (error instanceof Error && "code" in error && typeof error.code === "string") return error.code;
15
+ };
16
+ const getErrorMessage = (error) => error instanceof Error ? error.message : void 0;
17
+ const asError = (error) => error instanceof Error ? error : void 0;
18
+ /**
19
+ * Maps a constraint error to a specific DumboError subtype by inspecting the
20
+ * error message. The `sqlite3` driver only exposes the primary result code
21
+ * `SQLITE_CONSTRAINT` — the constraint subtype (UNIQUE, FOREIGN KEY, etc.)
22
+ * is embedded in the message string by SQLite, e.g.:
23
+ * "SQLITE_CONSTRAINT: UNIQUE constraint failed: users.email"
24
+ *
25
+ * Reference: https://www.sqlite.org/rescode.html (extended result codes 275–3091)
26
+ */
27
+ const mapConstraintError = (message, innerError) => {
28
+ const upperMessage = message?.toUpperCase() ?? "";
29
+ if (upperMessage.includes("UNIQUE") || upperMessage.includes("PRIMARY KEY")) return new UniqueConstraintError(message, innerError);
30
+ if (upperMessage.includes("FOREIGN KEY")) return new ForeignKeyViolationError(message, innerError);
31
+ if (upperMessage.includes("NOT NULL")) return new NotNullViolationError(message, innerError);
32
+ if (upperMessage.includes("CHECK")) return new CheckViolationError(message, innerError);
33
+ return new IntegrityConstraintViolationError(message, innerError);
34
+ };
35
+ /**
36
+ * Maps a SQLite error (from the `sqlite3` / node-sqlite3 driver) to a typed
37
+ * DumboError based on the SQLite result code.
38
+ *
39
+ * Result code reference: https://www.sqlite.org/rescode.html
40
+ *
41
+ * Falls back to a generic DumboError (500) if the error is not a recognized SQLite error.
42
+ */
43
+ const mapSqliteError = (error) => {
44
+ if (DumboError.isInstanceOf(error)) return error;
45
+ const code = getSqliteErrorCode(error);
46
+ if (!code) return new DumboError({
47
+ errorCode: 500,
48
+ message: getErrorMessage(error),
49
+ innerError: asError(error)
50
+ });
51
+ const message = getErrorMessage(error);
52
+ const innerError = asError(error);
53
+ switch (code) {
54
+ case "SQLITE_CONSTRAINT": return mapConstraintError(message, innerError);
55
+ case "SQLITE_BUSY": return new LockNotAvailableError(message, innerError);
56
+ case "SQLITE_LOCKED": return new DeadlockError(message, innerError);
57
+ case "SQLITE_PROTOCOL": return new LockNotAvailableError(message, innerError);
58
+ case "SQLITE_CANTOPEN": return new ConnectionError(message, innerError);
59
+ case "SQLITE_NOTADB": return new ConnectionError(message, innerError);
60
+ case "SQLITE_NOMEM": return new InsufficientResourcesError(message, innerError);
61
+ case "SQLITE_FULL": return new InsufficientResourcesError(message, innerError);
62
+ case "SQLITE_IOERR": return new SystemError(message, innerError);
63
+ case "SQLITE_CORRUPT": return new SystemError(message, innerError);
64
+ case "SQLITE_INTERNAL": return new SystemError(message, innerError);
65
+ case "SQLITE_NOLFS": return new SystemError(message, innerError);
66
+ case "SQLITE_TOOBIG": return new DataError(message, innerError);
67
+ case "SQLITE_MISMATCH": return new DataError(message, innerError);
68
+ case "SQLITE_RANGE": return new DataError(message, innerError);
69
+ case "SQLITE_ERROR": return new InvalidOperationError(message, innerError);
70
+ case "SQLITE_READONLY": return new InvalidOperationError(message, innerError);
71
+ case "SQLITE_MISUSE": return new InvalidOperationError(message, innerError);
72
+ case "SQLITE_AUTH": return new InvalidOperationError(message, innerError);
73
+ case "SQLITE_PERM": return new InvalidOperationError(message, innerError);
74
+ case "SQLITE_SCHEMA": return new InvalidOperationError(message, innerError);
75
+ case "SQLITE_ABORT": return new SerializationError(message, innerError);
76
+ case "SQLITE_INTERRUPT": return new SerializationError(message, innerError);
77
+ }
78
+ return new DumboError({
79
+ errorCode: 500,
80
+ message,
81
+ innerError
82
+ });
83
+ };
84
+
85
+ //#endregion
86
+ //#region src/storage/sqlite/core/sql/processors/columProcessors.ts
87
+ const mapColumnType = (token, { builder }) => {
88
+ let columnSQL;
89
+ const { sqlTokenType } = token;
90
+ switch (sqlTokenType) {
91
+ case "SQL_COLUMN_AUTO_INCREMENT":
92
+ columnSQL = `INTEGER ${token.primaryKey ? "PRIMARY KEY" : ""} AUTOINCREMENT`;
93
+ break;
94
+ case "SQL_COLUMN_BIGINT":
95
+ columnSQL = "INTEGER";
96
+ break;
97
+ case "SQL_COLUMN_SERIAL":
98
+ columnSQL = "INTEGER";
99
+ break;
100
+ case "SQL_COLUMN_INTEGER":
101
+ columnSQL = "INTEGER";
102
+ break;
103
+ case "SQL_COLUMN_JSONB":
104
+ columnSQL = "BLOB";
105
+ break;
106
+ case "SQL_COLUMN_BIGSERIAL":
107
+ columnSQL = "INTEGER";
108
+ break;
109
+ case "SQL_COLUMN_TIMESTAMP":
110
+ columnSQL = "DATETIME";
111
+ break;
112
+ case "SQL_COLUMN_TIMESTAMPTZ":
113
+ columnSQL = "DATETIME";
114
+ break;
115
+ case "SQL_COLUMN_VARCHAR":
116
+ columnSQL = `VARCHAR ${Number.isNaN(token.length) ? "" : `(${token.length})`}`;
117
+ break;
118
+ default: throw new Error(`Unknown column type: ${sqlTokenType}`);
119
+ }
120
+ builder.addSQL(columnSQL);
121
+ };
122
+ const sqliteColumnProcessors = mapDefaultSQLColumnProcessors(mapColumnType);
123
+
124
+ //#endregion
125
+ //#region src/storage/sqlite/core/sql/formatter/index.ts
126
+ const sqliteFormatter = SQLFormatter({ processorsRegistry: SQLProcessorsRegistry({ from: defaultProcessorsRegistry }).register(sqliteColumnProcessors) });
127
+ registerFormatter("SQLite", sqliteFormatter);
128
+
129
+ //#endregion
130
+ //#region src/storage/sqlite/core/execute/execute.ts
131
+ const sqliteExecute = async (database, handle) => {
132
+ try {
133
+ return await handle(database);
134
+ } finally {
135
+ await database.close();
136
+ }
137
+ };
138
+ const sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
139
+ driverType,
140
+ query: async (client, sql, options) => {
141
+ tracer.info("db:sql:query", {
142
+ query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,
143
+ params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,
144
+ debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer })
145
+ });
146
+ try {
147
+ let result = await client.query(sql, options);
148
+ if (options?.mapping) result = {
149
+ ...result,
150
+ rows: result.rows.map((row) => mapSQLQueryResult(row, options.mapping))
151
+ };
152
+ return result;
153
+ } catch (error) {
154
+ tracer.error("db:sql:query:execute:error", { error });
155
+ throw (errorMapper ?? mapSqliteError)(error);
156
+ }
157
+ },
158
+ batchQuery: async (client, sqls, options) => {
159
+ try {
160
+ const results = await client.batchQuery(sqls, options);
161
+ if (options?.mapping) return results.map((result) => ({
162
+ ...result,
163
+ rows: result.rows.map((row) => mapSQLQueryResult(row, options.mapping))
164
+ }));
165
+ return results;
166
+ } catch (error) {
167
+ tracer.error("db:sql:batch_query:execute:error", { error });
168
+ throw (errorMapper ?? mapSqliteError)(error);
169
+ }
170
+ },
171
+ command: async (client, sql, options) => {
172
+ tracer.info("db:sql:command", {
173
+ query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,
174
+ params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,
175
+ debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer })
176
+ });
177
+ try {
178
+ return await client.command(sql, options);
179
+ } catch (error) {
180
+ tracer.error("db:sql:command:execute:error", { error });
181
+ throw (errorMapper ?? mapSqliteError)(error);
182
+ }
183
+ },
184
+ batchCommand: async (client, sqls, options) => {
185
+ try {
186
+ return await client.batchCommand(sqls, options);
187
+ } catch (error) {
188
+ tracer.error("db:sql:batch_command:execute:error", { error });
189
+ throw (errorMapper ?? mapSqliteError)(error);
190
+ }
191
+ },
192
+ formatter: formatter ?? sqliteFormatter
193
+ });
194
+
195
+ //#endregion
196
+ //#region src/storage/sqlite/core/transactions/index.ts
197
+ const sqliteTransaction = (driverType, connection, allowNestedTransactions, serializer, defaultTransactionMode) => (getClient, options) => {
198
+ const transactionCounter = transactionNestingCounter();
199
+ allowNestedTransactions = options?.allowNestedTransactions ?? allowNestedTransactions;
200
+ return {
201
+ connection: connection(),
202
+ driverType,
203
+ begin: async function() {
204
+ const client = await getClient;
205
+ if (allowNestedTransactions) {
206
+ if (transactionCounter.level >= 1) {
207
+ transactionCounter.increment();
208
+ if (options?.useSavepoints) await client.command(SQL`SAVEPOINT transaction${SQL.plain(transactionCounter.level.toString())}`);
209
+ return;
210
+ }
211
+ transactionCounter.increment();
212
+ }
213
+ const mode = options?.mode ?? defaultTransactionMode ?? "IMMEDIATE";
214
+ await client.command(SQL`BEGIN ${SQL.plain(mode)} TRANSACTION`);
215
+ },
216
+ commit: async function() {
217
+ const client = await getClient;
218
+ try {
219
+ if (allowNestedTransactions) {
220
+ if (transactionCounter.level > 1) {
221
+ if (options?.useSavepoints) await client.command(SQL`RELEASE transaction${SQL.plain(transactionCounter.level.toString())}`);
222
+ transactionCounter.decrement();
223
+ return;
224
+ }
225
+ transactionCounter.reset();
226
+ }
227
+ await client.command(SQL`COMMIT`);
228
+ } finally {
229
+ if (options?.close) await options?.close(client);
230
+ }
231
+ },
232
+ rollback: async function(error) {
233
+ const client = await getClient;
234
+ try {
235
+ if (allowNestedTransactions) {
236
+ if (transactionCounter.level > 1) {
237
+ transactionCounter.decrement();
238
+ return;
239
+ }
240
+ }
241
+ await client.command(SQL`ROLLBACK`);
242
+ } finally {
243
+ if (options?.close) await options?.close(client, error);
244
+ }
245
+ },
246
+ execute: sqlExecutor(sqliteSQLExecutor(driverType, serializer), { connect: () => getClient }),
247
+ _transactionOptions: options ?? {}
248
+ };
249
+ };
250
+
251
+ //#endregion
252
+ //#region src/storage/sqlite/core/connections/connectionString.ts
253
+ const SQLiteConnectionString = (connectionString) => {
254
+ if (!connectionString.startsWith("file:") && connectionString !== ":memory:" && !connectionString.startsWith("/") && !connectionString.startsWith("./")) throw new Error(`Invalid SQLite connection string: ${connectionString}. It should start with "file:", ":memory:", "/", or "./".`);
255
+ return connectionString;
256
+ };
257
+ const parsePragmasFromConnectionString = (connectionString) => {
258
+ const str = String(connectionString);
259
+ if (!str.startsWith("file:")) return {};
260
+ const params = new URL(str).searchParams;
261
+ const pragmas = {};
262
+ const journalMode = params.get("journal_mode");
263
+ if (journalMode !== null) pragmas.journal_mode = journalMode;
264
+ const synchronous = params.get("synchronous");
265
+ if (synchronous !== null) pragmas.synchronous = synchronous;
266
+ const cacheSize = params.get("cache_size");
267
+ if (cacheSize !== null) pragmas.cache_size = parseInt(cacheSize, 10);
268
+ const foreignKeys = params.get("foreign_keys");
269
+ if (foreignKeys !== null) {
270
+ const val = foreignKeys.toLowerCase();
271
+ pragmas.foreign_keys = val === "true" || val === "on" || val === "1";
272
+ }
273
+ const tempStore = params.get("temp_store");
274
+ if (tempStore !== null) pragmas.temp_store = tempStore.toUpperCase();
275
+ const busyTimeout = params.get("busy_timeout");
276
+ if (busyTimeout !== null) pragmas.busy_timeout = parseInt(busyTimeout, 10);
277
+ const mmapSize = params.get("mmap_size");
278
+ if (mmapSize !== null) pragmas.mmap_size = parseInt(mmapSize, 10);
279
+ return pragmas;
280
+ };
281
+
282
+ //#endregion
283
+ //#region src/storage/sqlite/core/connections/index.ts
284
+ const isSQLiteError = (error) => {
285
+ if (error instanceof Error && "code" in error) return true;
286
+ return false;
287
+ };
288
+ const transactionNestingCounter = () => {
289
+ let transactionLevel = 0;
290
+ return {
291
+ reset: () => {
292
+ transactionLevel = 0;
293
+ },
294
+ increment: () => {
295
+ transactionLevel++;
296
+ },
297
+ decrement: () => {
298
+ transactionLevel--;
299
+ if (transactionLevel < 0) throw new Error("Transaction level is out of bounds");
300
+ },
301
+ get level() {
302
+ return transactionLevel;
303
+ }
304
+ };
305
+ };
306
+ const sqliteAmbientClientConnection = (options) => {
307
+ const { client, driverType, initTransaction, allowNestedTransactions, defaultTransactionMode, serializer, errorMapper } = options;
308
+ return createAmbientConnection({
309
+ driverType,
310
+ client,
311
+ initTransaction: initTransaction ?? ((connection) => sqliteTransaction(driverType, connection, allowNestedTransactions ?? false, serializer, defaultTransactionMode)),
312
+ executor: ({ serializer }) => sqliteSQLExecutor(driverType, serializer, void 0, errorMapper),
313
+ serializer
314
+ });
315
+ };
316
+ const sqliteClientConnection = (options) => {
317
+ const { connectionOptions, sqliteClientFactory, serializer } = options;
318
+ let client = null;
319
+ const connect = async () => {
320
+ if (client) return Promise.resolve(client);
321
+ client = sqliteClientFactory(connectionOptions);
322
+ if (client && "connect" in client && typeof client.connect === "function") try {
323
+ await client.connect();
324
+ } catch (error) {
325
+ throw mapSqliteError(error);
326
+ }
327
+ return client;
328
+ };
329
+ return createConnection({
330
+ driverType: options.driverType,
331
+ connect,
332
+ close: async () => {
333
+ if (client && "close" in client && typeof client.close === "function") await client.close();
334
+ else if (client && "release" in client && typeof client.release === "function") client.release();
335
+ },
336
+ initTransaction: (connection) => sqliteTransaction(options.driverType, connection, connectionOptions.transactionOptions?.allowNestedTransactions ?? false, serializer, connectionOptions.defaultTransactionMode),
337
+ executor: ({ serializer }) => sqliteSQLExecutor(options.driverType, serializer),
338
+ serializer
339
+ });
340
+ };
341
+ const sqlitePoolClientConnection = (options) => {
342
+ const { connectionOptions, sqliteClientFactory, serializer } = options;
343
+ let client = null;
344
+ const connect = async () => {
345
+ if (client) return Promise.resolve(client);
346
+ client = sqliteClientFactory(connectionOptions);
347
+ try {
348
+ await client.connect();
349
+ } catch (error) {
350
+ throw mapSqliteError(error);
351
+ }
352
+ return client;
353
+ };
354
+ return createConnection({
355
+ driverType: options.driverType,
356
+ connect,
357
+ close: () => client !== null ? Promise.resolve(client.release()) : Promise.resolve(),
358
+ initTransaction: (connection) => sqliteTransaction(options.driverType, connection, connectionOptions.transactionOptions?.allowNestedTransactions ?? false, serializer, connectionOptions.defaultTransactionMode),
359
+ executor: ({ serializer }) => sqliteSQLExecutor(options.driverType, serializer),
360
+ serializer
361
+ });
362
+ };
363
+ function sqliteConnection(options) {
364
+ return options.type === "Client" ? sqliteClientConnection(options) : sqlitePoolClientConnection(options);
365
+ }
366
+ const InMemorySQLiteDatabase = SQLiteConnectionString(":memory:");
367
+ const DEFAULT_SQLITE_PRAGMA_OPTIONS = {
368
+ journal_mode: "WAL",
369
+ synchronous: "NORMAL",
370
+ cache_size: -1e6,
371
+ foreign_keys: true,
372
+ temp_store: "MEMORY",
373
+ busy_timeout: 5e3,
374
+ mmap_size: 268435456
375
+ };
376
+
377
+ //#endregion
378
+ //#region src/storage/sqlite/core/pool/dualPool.ts
379
+ const sqliteDualConnectionPool = (options) => {
380
+ const { sqliteConnectionFactory, connectionOptions } = options;
381
+ const readerPoolSize = options.readerPoolSize ?? Math.max(4, cpus().length);
382
+ let databaseInitPromise = null;
383
+ const guardSingleConnection = guardInitializedOnce(async () => {
384
+ if (databaseInitPromise !== null) return databaseInitPromise;
385
+ const initConnection = sqliteConnectionFactory({
386
+ ...connectionOptions,
387
+ skipDatabasePragmas: false,
388
+ readonly: false
389
+ });
390
+ const initPromise = initConnection.open();
391
+ databaseInitPromise = initPromise;
392
+ try {
393
+ await initPromise;
394
+ await initConnection.close();
395
+ } catch (error) {
396
+ databaseInitPromise = null;
397
+ await initConnection.close();
398
+ throw mapSqliteError(error);
399
+ }
400
+ });
401
+ const ensureDatabaseInitialized = async () => {
402
+ if (databaseInitPromise !== null) return databaseInitPromise;
403
+ return guardSingleConnection.ensureInitialized();
404
+ };
405
+ const wrappedConnectionFactory = async (readonly, connectionOptions) => {
406
+ await ensureDatabaseInitialized();
407
+ const connection = sqliteConnectionFactory({
408
+ ...connectionOptions,
409
+ skipDatabasePragmas: true,
410
+ readonly
411
+ });
412
+ await connection.open();
413
+ return connection;
414
+ };
415
+ const writerPool = createSingletonConnectionPool({
416
+ driverType: options.driverType,
417
+ getConnection: () => wrappedConnectionFactory(false, connectionOptions)
418
+ });
419
+ const readerPool = createBoundedConnectionPool({
420
+ driverType: options.driverType,
421
+ getConnection: () => wrappedConnectionFactory(true, connectionOptions),
422
+ maxConnections: readerPoolSize
423
+ });
424
+ return {
425
+ driverType: options.driverType,
426
+ connection: (connectionOptions) => connectionOptions?.readonly ? readerPool.connection(connectionOptions) : writerPool.connection(connectionOptions),
427
+ execute: {
428
+ query: (...args) => readerPool.execute.query(...args),
429
+ batchQuery: (...args) => readerPool.execute.batchQuery(...args),
430
+ command: (...args) => writerPool.execute.command(...args),
431
+ batchCommand: (...args) => writerPool.execute.batchCommand(...args)
432
+ },
433
+ withConnection: (handle, connectionOptions) => connectionOptions?.readonly ? readerPool.withConnection(handle, connectionOptions) : writerPool.withConnection(handle, connectionOptions),
434
+ transaction: writerPool.transaction,
435
+ withTransaction: writerPool.withTransaction,
436
+ close: async () => {
437
+ await guardSingleConnection.stop();
438
+ await Promise.all([writerPool.close(), readerPool.close()]);
439
+ }
440
+ };
441
+ };
442
+
443
+ //#endregion
444
+ //#region src/storage/sqlite/core/pool/pool.ts
445
+ const isInMemoryDatabase = (options) => {
446
+ if ("fileName" in options) return options.fileName === InMemorySQLiteDatabase;
447
+ if ("connectionString" in options) return options.connectionString === InMemorySQLiteDatabase;
448
+ return false;
449
+ };
450
+ const sqliteAmbientConnectionPool = (options) => {
451
+ const { connection, driverType } = options;
452
+ return createAmbientConnectionPool({
453
+ driverType,
454
+ connection
455
+ });
456
+ };
457
+ const sqliteSingletonConnectionPool = (options) => {
458
+ const { driverType, sqliteConnectionFactory, connectionOptions } = options;
459
+ return createSingletonConnectionPool({
460
+ driverType,
461
+ getConnection: () => sqliteConnectionFactory(connectionOptions)
462
+ });
463
+ };
464
+ const sqliteAlwaysNewConnectionPool = (options) => {
465
+ const { driverType, sqliteConnectionFactory, connectionOptions } = options;
466
+ return createAlwaysNewConnectionPool({
467
+ driverType,
468
+ getConnection: () => sqliteConnectionFactory(connectionOptions)
469
+ });
470
+ };
471
+ const toSqlitePoolOptions = (options) => {
472
+ const { singleton, ...rest } = options;
473
+ const isInMemory = isInMemoryDatabase(options);
474
+ if ("client" in options && options.client) return {
475
+ ...rest,
476
+ singleton: true
477
+ };
478
+ if (isInMemory) return {
479
+ ...rest,
480
+ singleton: true
481
+ };
482
+ if (singleton === true) return {
483
+ ...rest,
484
+ singleton: true
485
+ };
486
+ return {
487
+ ...rest,
488
+ dual: true
489
+ };
490
+ };
491
+ function sqlitePool(options) {
492
+ const { driverType } = options;
493
+ if (options.connection) return createAmbientConnectionPool({
494
+ driverType,
495
+ connection: options.connection
496
+ });
497
+ if ("dual" in options && options.dual) return sqliteDualConnectionPool(options);
498
+ if (options.singleton === true && options.sqliteConnectionFactory) return createSingletonConnectionPool({
499
+ driverType,
500
+ getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
501
+ });
502
+ return createAlwaysNewConnectionPool({
503
+ driverType,
504
+ getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
505
+ });
506
+ }
507
+
508
+ //#endregion
509
+ //#region src/storage/sqlite/core/schema/migrations.ts
510
+ const DefaultSQLiteMigratorOptions = {};
511
+ registerDefaultMigratorOptions("SQLite", DefaultSQLiteMigratorOptions);
512
+
513
+ //#endregion
514
+ //#region src/storage/sqlite/core/index.ts
515
+ const SQLiteDatabaseName = "SQLite";
516
+
517
+ //#endregion
518
+ export { mapSqliteError as C, sqliteFormatter as S, SQLiteConnectionString as _, sqliteAmbientConnectionPool as a, sqliteExecute as b, toSqlitePoolOptions as c, isSQLiteError as d, sqliteAmbientClientConnection as f, transactionNestingCounter as g, sqlitePoolClientConnection as h, sqliteAlwaysNewConnectionPool as i, DEFAULT_SQLITE_PRAGMA_OPTIONS as l, sqliteConnection as m, DefaultSQLiteMigratorOptions as n, sqlitePool as o, sqliteClientConnection as p, isInMemoryDatabase as r, sqliteSingletonConnectionPool as s, SQLiteDatabaseName as t, InMemorySQLiteDatabase as u, parsePragmasFromConnectionString as v, sqliteSQLExecutor as x, sqliteTransaction as y };
519
+ //# sourceMappingURL=core-BeyC5tHn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-BeyC5tHn.js","names":[],"sources":["../src/storage/sqlite/core/errors/errorMapper.ts","../src/storage/sqlite/core/sql/processors/columProcessors.ts","../src/storage/sqlite/core/sql/formatter/index.ts","../src/storage/sqlite/core/execute/execute.ts","../src/storage/sqlite/core/transactions/index.ts","../src/storage/sqlite/core/connections/connectionString.ts","../src/storage/sqlite/core/connections/index.ts","../src/storage/sqlite/core/pool/dualPool.ts","../src/storage/sqlite/core/pool/pool.ts","../src/storage/sqlite/core/schema/migrations.ts","../src/storage/sqlite/core/index.ts"],"sourcesContent":["import {\n CheckViolationError,\n ConnectionError,\n DataError,\n DeadlockError,\n DumboError,\n ForeignKeyViolationError,\n InsufficientResourcesError,\n IntegrityConstraintViolationError,\n InvalidOperationError,\n LockNotAvailableError,\n NotNullViolationError,\n SerializationError,\n SystemError,\n UniqueConstraintError,\n} from '../../../../core/errors';\n\n/**\n * Extracts the SQLite error code string from a `sqlite3` driver error.\n *\n * The `sqlite3` (node-sqlite3) driver sets `error.code` to a string like\n * `'SQLITE_CONSTRAINT'` and `error.errno` to the numeric result code.\n * See: https://github.com/TryGhost/node-sqlite3\n */\nconst getSqliteErrorCode = (error: unknown): string | undefined => {\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof (error as Record<string, unknown>).code === 'string'\n ) {\n return (error as Record<string, unknown>).code as string;\n }\n return undefined;\n};\n\nconst getErrorMessage = (error: unknown): string | undefined =>\n error instanceof Error ? error.message : undefined;\n\nconst asError = (error: unknown): Error | undefined =>\n error instanceof Error ? error : undefined;\n\n/**\n * Maps a constraint error to a specific DumboError subtype by inspecting the\n * error message. The `sqlite3` driver only exposes the primary result code\n * `SQLITE_CONSTRAINT` — the constraint subtype (UNIQUE, FOREIGN KEY, etc.)\n * is embedded in the message string by SQLite, e.g.:\n * \"SQLITE_CONSTRAINT: UNIQUE constraint failed: users.email\"\n *\n * Reference: https://www.sqlite.org/rescode.html (extended result codes 275–3091)\n */\nconst mapConstraintError = (\n message: string | undefined,\n innerError: Error | undefined,\n): DumboError => {\n const upperMessage = message?.toUpperCase() ?? '';\n\n // SQLITE_CONSTRAINT_UNIQUE (2067) / SQLITE_CONSTRAINT_PRIMARYKEY (1555)\n if (upperMessage.includes('UNIQUE') || upperMessage.includes('PRIMARY KEY'))\n return new UniqueConstraintError(message, innerError);\n\n // SQLITE_CONSTRAINT_FOREIGNKEY (787)\n if (upperMessage.includes('FOREIGN KEY'))\n return new ForeignKeyViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_NOTNULL (1299)\n if (upperMessage.includes('NOT NULL'))\n return new NotNullViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_CHECK (275)\n if (upperMessage.includes('CHECK'))\n return new CheckViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_ROWID (2579), SQLITE_CONSTRAINT_TRIGGER (1811),\n // SQLITE_CONSTRAINT_COMMITHOOK (531), SQLITE_CONSTRAINT_PINNED (2835),\n // SQLITE_CONSTRAINT_DATATYPE (3091), etc.\n return new IntegrityConstraintViolationError(message, innerError);\n};\n\n/**\n * Maps a SQLite error (from the `sqlite3` / node-sqlite3 driver) to a typed\n * DumboError based on the SQLite result code.\n *\n * Result code reference: https://www.sqlite.org/rescode.html\n *\n * Falls back to a generic DumboError (500) if the error is not a recognized SQLite error.\n */\nexport const mapSqliteError = (error: unknown): DumboError => {\n if (DumboError.isInstanceOf<DumboError>(error)) return error;\n\n const code = getSqliteErrorCode(error);\n if (!code)\n return new DumboError({\n errorCode: 500,\n message: getErrorMessage(error),\n innerError: asError(error),\n });\n\n const message = getErrorMessage(error);\n const innerError = asError(error);\n\n switch (code) {\n // ── Constraint violations (19) ──\n // node-sqlite3 only exposes the primary code; subtype is in the message.\n case 'SQLITE_CONSTRAINT':\n return mapConstraintError(message, innerError);\n\n // ── Busy / lock contention ──\n // SQLITE_BUSY (5): conflict with a separate database connection\n case 'SQLITE_BUSY':\n return new LockNotAvailableError(message, innerError);\n\n // SQLITE_LOCKED (6): conflict within the same connection or shared cache\n case 'SQLITE_LOCKED':\n return new DeadlockError(message, innerError);\n\n // SQLITE_PROTOCOL (15): WAL locking race condition\n case 'SQLITE_PROTOCOL':\n return new LockNotAvailableError(message, innerError);\n\n // ── Connection / open errors ──\n // SQLITE_CANTOPEN (14): unable to open database file\n case 'SQLITE_CANTOPEN':\n return new ConnectionError(message, innerError);\n\n // SQLITE_NOTADB (26): file is not a database\n case 'SQLITE_NOTADB':\n return new ConnectionError(message, innerError);\n\n // ── Resource exhaustion ──\n // SQLITE_NOMEM (7): out of memory\n case 'SQLITE_NOMEM':\n return new InsufficientResourcesError(message, innerError);\n\n // SQLITE_FULL (13): disk full\n case 'SQLITE_FULL':\n return new InsufficientResourcesError(message, innerError);\n\n // ── System / I/O errors ──\n // SQLITE_IOERR (10): operating system I/O error\n case 'SQLITE_IOERR':\n return new SystemError(message, innerError);\n\n // SQLITE_CORRUPT (11): database file is corrupted\n case 'SQLITE_CORRUPT':\n return new SystemError(message, innerError);\n\n // SQLITE_INTERNAL (2): internal SQLite malfunction\n case 'SQLITE_INTERNAL':\n return new SystemError(message, innerError);\n\n // SQLITE_NOLFS (22): large file support unavailable\n case 'SQLITE_NOLFS':\n return new SystemError(message, innerError);\n\n // ── Data errors ──\n // SQLITE_TOOBIG (18): string or BLOB too large\n case 'SQLITE_TOOBIG':\n return new DataError(message, innerError);\n\n // SQLITE_MISMATCH (20): datatype mismatch\n case 'SQLITE_MISMATCH':\n return new DataError(message, innerError);\n\n // SQLITE_RANGE (25): bind parameter index out of range\n case 'SQLITE_RANGE':\n return new DataError(message, innerError);\n\n // ── Invalid operations ──\n // SQLITE_ERROR (1): generic SQL error (syntax errors, missing tables, etc.)\n case 'SQLITE_ERROR':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_READONLY (8): attempt to write to a read-only database\n case 'SQLITE_READONLY':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_MISUSE (21): API misuse\n case 'SQLITE_MISUSE':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_AUTH (23): authorization denied\n case 'SQLITE_AUTH':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_PERM (3): access permission denied\n case 'SQLITE_PERM':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_SCHEMA (17): schema changed, statement needs re-preparation\n case 'SQLITE_SCHEMA':\n return new InvalidOperationError(message, innerError);\n\n // ── Transaction / abort ──\n // SQLITE_ABORT (4): operation aborted (e.g. by rollback)\n case 'SQLITE_ABORT':\n return new SerializationError(message, innerError);\n\n // SQLITE_INTERRUPT (9): operation interrupted\n case 'SQLITE_INTERRUPT':\n return new SerializationError(message, innerError);\n }\n\n return new DumboError({\n errorCode: 500,\n message,\n innerError,\n });\n};\n","import {\n mapDefaultSQLColumnProcessors,\n type DefaultSQLColumnProcessors,\n type DefaultSQLColumnToken,\n type SQLProcessorContext,\n} from '../../../../../core';\n\nconst mapColumnType = (\n token: DefaultSQLColumnToken,\n { builder }: SQLProcessorContext,\n): void => {\n let columnSQL: string;\n const { sqlTokenType } = token;\n switch (sqlTokenType) {\n case 'SQL_COLUMN_AUTO_INCREMENT':\n columnSQL = `INTEGER ${token.primaryKey ? 'PRIMARY KEY' : ''} AUTOINCREMENT`;\n break;\n case 'SQL_COLUMN_BIGINT':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_SERIAL':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_INTEGER':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_JSONB':\n columnSQL = 'BLOB';\n break;\n case 'SQL_COLUMN_BIGSERIAL':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_TIMESTAMP':\n columnSQL = 'DATETIME';\n break;\n case 'SQL_COLUMN_TIMESTAMPTZ':\n columnSQL = 'DATETIME';\n break;\n case 'SQL_COLUMN_VARCHAR':\n columnSQL = `VARCHAR ${Number.isNaN(token.length) ? '' : `(${token.length})`}`;\n break;\n default: {\n const exhaustiveCheck: never = sqlTokenType;\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unknown column type: ${exhaustiveCheck}`);\n }\n }\n builder.addSQL(columnSQL);\n};\n\nexport const sqliteColumnProcessors: DefaultSQLColumnProcessors =\n mapDefaultSQLColumnProcessors(mapColumnType);\n","import {\n defaultProcessorsRegistry,\n registerFormatter,\n SQLFormatter,\n SQLProcessorsRegistry,\n} from '../../../../../core/sql';\nimport { sqliteColumnProcessors } from '../processors';\n\nconst sqliteSQLProcessorsRegistry = SQLProcessorsRegistry({\n from: defaultProcessorsRegistry,\n}).register(sqliteColumnProcessors);\n\nconst sqliteFormatter: SQLFormatter = SQLFormatter({\n processorsRegistry: sqliteSQLProcessorsRegistry,\n});\n\nregisterFormatter('SQLite', sqliteFormatter);\n\nexport { sqliteFormatter };\n","import type { SQLiteDriverType } from '..';\nimport type { JSONSerializer, SQLFormatter, SQL } from '../../../../core';\nimport {\n mapSQLQueryResult,\n tracer,\n type BatchSQLCommandOptions,\n type DbSQLExecutor,\n type QueryResult,\n type QueryResultRow,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport type { DumboError } from '../../../../core/errors';\nimport type { SQLiteClient } from '../connections';\nimport { mapSqliteError } from '../errors/errorMapper';\nimport { sqliteFormatter } from '../sql/formatter';\n\nexport type SQLiteErrorMapper = (error: unknown) => DumboError;\n\nexport const sqliteExecute = async <Result = void>(\n database: SQLiteClient,\n handle: (client: SQLiteClient) => Promise<Result>,\n) => {\n try {\n return await handle(database);\n } finally {\n await database.close();\n }\n};\n\nexport type SQLiteSQLExecutor<\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n> = DbSQLExecutor<DriverType, SQLiteClient>;\n\nexport const sqliteSQLExecutor = <\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n>(\n driverType: DriverType,\n serializer: JSONSerializer,\n formatter?: SQLFormatter,\n errorMapper?: SQLiteErrorMapper,\n): SQLiteSQLExecutor<DriverType> => ({\n driverType,\n query: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>> => {\n tracer.info('db:sql:query', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n try {\n let result = await client.query<Result>(sql, options);\n\n if (options?.mapping) {\n result = {\n ...result,\n rows: result.rows.map((row) =>\n mapSQLQueryResult(row, options.mapping!),\n ),\n };\n }\n\n return result;\n } catch (error) {\n tracer.error('db:sql:query:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\n const results = await client.batchQuery<Result>(sqls, options);\n\n if (options?.mapping) {\n return results.map((result) => ({\n ...result,\n rows: result.rows.map((row) =>\n mapSQLQueryResult(row, options.mapping!),\n ),\n }));\n }\n\n return results;\n } catch (error) {\n tracer.error('db:sql:batch_query:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n command: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n tracer.info('db:sql:command', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n try {\n return await client.command<Result>(sql, options);\n } catch (error) {\n tracer.error('db:sql:command:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: BatchSQLCommandOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\n return await client.batchCommand<Result>(sqls, options);\n } catch (error) {\n tracer.error('db:sql:batch_command:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n formatter: formatter ?? sqliteFormatter,\n});\n","import type {\n InferTransactionFromConnection,\n JSONSerializer,\n} from '../../../../core';\nimport {\n SQL,\n sqlExecutor,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n type InferDbClientFromConnection,\n} from '../../../../core';\nimport { sqliteSQLExecutor } from '../../core/execute';\nimport {\n transactionNestingCounter,\n type AnySQLiteConnection,\n type SQLiteClientOrPoolClient,\n} from '../connections';\n\nexport type SQLiteTransaction<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n TransactionOptions extends SQLiteTransactionOptions =\n SQLiteTransactionOptions,\n> = DatabaseTransaction<ConnectionType, TransactionOptions>;\n\nexport type SQLiteTransactionMode = 'DEFERRED' | 'IMMEDIATE' | 'EXCLUSIVE';\n\nexport type SQLiteTransactionOptions = DatabaseTransactionOptions & {\n mode?: SQLiteTransactionMode;\n useSavepoints?: boolean;\n};\n\nexport const sqliteTransaction =\n <ConnectionType extends AnySQLiteConnection = AnySQLiteConnection>(\n driverType: ConnectionType['driverType'],\n connection: () => ConnectionType,\n allowNestedTransactions: boolean,\n serializer: JSONSerializer,\n defaultTransactionMode?: 'IMMEDIATE' | 'DEFERRED' | 'EXCLUSIVE',\n ) =>\n (\n getClient: Promise<InferDbClientFromConnection<ConnectionType>>,\n options?: {\n close: (\n client: InferDbClientFromConnection<ConnectionType>,\n error?: unknown,\n ) => Promise<void>;\n } & SQLiteTransactionOptions,\n ): InferTransactionFromConnection<ConnectionType> => {\n const transactionCounter = transactionNestingCounter();\n allowNestedTransactions =\n options?.allowNestedTransactions ?? allowNestedTransactions;\n\n const transaction: DatabaseTransaction<ConnectionType> = {\n connection: connection(),\n driverType,\n begin: async function () {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n\n if (allowNestedTransactions) {\n if (transactionCounter.level >= 1) {\n transactionCounter.increment();\n if (options?.useSavepoints) {\n await client.command(\n SQL`SAVEPOINT transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n }\n return;\n }\n\n transactionCounter.increment();\n }\n\n const mode = options?.mode ?? defaultTransactionMode ?? 'IMMEDIATE';\n await client.command(SQL`BEGIN ${SQL.plain(mode)} TRANSACTION`);\n },\n commit: async function () {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n if (options?.useSavepoints) {\n await client.command(\n SQL`RELEASE transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n }\n transactionCounter.decrement();\n\n return;\n }\n\n transactionCounter.reset();\n }\n await client.command(SQL`COMMIT`);\n } finally {\n if (options?.close)\n await options?.close(\n client as InferDbClientFromConnection<ConnectionType>,\n );\n }\n },\n rollback: async function (error?: unknown) {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n transactionCounter.decrement();\n return;\n }\n }\n\n await client.command(SQL`ROLLBACK`);\n } finally {\n if (options?.close)\n await options?.close(\n client as InferDbClientFromConnection<ConnectionType>,\n error,\n );\n }\n },\n execute: sqlExecutor(sqliteSQLExecutor(driverType, serializer), {\n connect: () => getClient,\n }),\n _transactionOptions: options ?? {},\n };\n\n return transaction as InferTransactionFromConnection<ConnectionType>;\n };\n","import type { DatabaseConnectionString } from '../../../all';\n\nexport type SQLitePragmaOptions = {\n journal_mode?: 'DELETE' | 'TRUNCATE' | 'PERSIST' | 'MEMORY' | 'WAL' | 'OFF';\n synchronous?: 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';\n cache_size?: number;\n foreign_keys?: boolean;\n temp_store?: 'DEFAULT' | 'FILE' | 'MEMORY';\n busy_timeout?: number;\n mmap_size?: number;\n};\n\nexport type SQLiteConnectionString = DatabaseConnectionString<\n 'SQLite',\n `file:${string}` | `:memory:` | `/${string}` | `./${string}`\n>;\n\nexport const SQLiteConnectionString = (\n connectionString: string,\n): SQLiteConnectionString => {\n if (\n !connectionString.startsWith('file:') &&\n connectionString !== ':memory:' &&\n !connectionString.startsWith('/') &&\n !connectionString.startsWith('./')\n ) {\n throw new Error(\n `Invalid SQLite connection string: ${connectionString}. It should start with \"file:\", \":memory:\", \"/\", or \"./\".`,\n );\n }\n return connectionString as SQLiteConnectionString;\n};\n\nexport const parsePragmasFromConnectionString = (\n connectionString: string | SQLiteConnectionString,\n): Partial<SQLitePragmaOptions> => {\n const str = String(connectionString);\n\n if (!str.startsWith('file:')) {\n return {};\n }\n\n const url = new URL(str);\n const params = url.searchParams;\n const pragmas: Partial<SQLitePragmaOptions> = {};\n\n const journalMode = params.get('journal_mode');\n if (journalMode !== null) {\n pragmas.journal_mode = journalMode as\n | 'DELETE'\n | 'TRUNCATE'\n | 'PERSIST'\n | 'MEMORY'\n | 'WAL'\n | 'OFF';\n }\n\n const synchronous = params.get('synchronous');\n if (synchronous !== null) {\n pragmas.synchronous = synchronous as 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';\n }\n\n const cacheSize = params.get('cache_size');\n if (cacheSize !== null) {\n pragmas.cache_size = parseInt(cacheSize, 10);\n }\n\n const foreignKeys = params.get('foreign_keys');\n if (foreignKeys !== null) {\n const val = foreignKeys.toLowerCase();\n pragmas.foreign_keys = val === 'true' || val === 'on' || val === '1';\n }\n\n const tempStore = params.get('temp_store');\n if (tempStore !== null) {\n pragmas.temp_store = tempStore.toUpperCase() as\n | 'DEFAULT'\n | 'FILE'\n | 'MEMORY';\n }\n\n const busyTimeout = params.get('busy_timeout');\n if (busyTimeout !== null) {\n pragmas.busy_timeout = parseInt(busyTimeout, 10);\n }\n\n const mmapSize = params.get('mmap_size');\n if (mmapSize !== null) {\n pragmas.mmap_size = parseInt(mmapSize, 10);\n }\n\n return pragmas;\n};\n","import type { SQLiteDriverType } from '..';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n createAmbientConnection,\n createConnection,\n type AnyConnection,\n type BatchSQLCommandOptions,\n type Connection,\n type ConnectionOptions,\n type DatabaseTransaction,\n type InferDbClientFromConnection,\n type InferDriverTypeFromConnection,\n type InitTransaction,\n type SQLCommandOptions,\n type SQLExecutor,\n} from '../../../../core';\nimport { mapSqliteError } from '../errors';\nimport { sqliteSQLExecutor, type SQLiteErrorMapper } from '../execute';\nimport { sqliteTransaction, type SQLiteTransactionMode } from '../transactions';\nimport {\n SQLiteConnectionString,\n type SQLitePragmaOptions,\n} from './connectionString';\n\nexport type SQLiteCommandOptions = SQLCommandOptions & {\n ignoreChangesCount?: boolean;\n};\n\nexport type BatchSQLiteCommandOptions = SQLiteCommandOptions &\n BatchSQLCommandOptions;\n\nexport type SQLiteParameters =\n | object\n | string\n | bigint\n | number\n | boolean\n | null;\n\nexport type SQLiteClient = {\n connect: () => Promise<void>;\n close: () => Promise<void>;\n} & SQLExecutor;\n\nexport type SQLitePoolClient = {\n release: () => void;\n} & SQLExecutor;\n\nexport type SQLiteClientFactory<\n SQLiteClientType extends SQLiteClient = SQLiteClient,\n ClientOptions = SQLiteClientOptions,\n> = (options: ClientOptions) => SQLiteClientType;\n\nexport type SQLiteClientOrPoolClient = SQLitePoolClient | SQLiteClient;\n\nexport interface SQLiteError extends Error {\n errno: number;\n}\n\nexport const isSQLiteError = (error: unknown): error is SQLiteError => {\n if (error instanceof Error && 'code' in error) {\n return true;\n }\n\n return false;\n};\n\nexport type SQLiteClientConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLiteClientType extends SQLiteClient = SQLiteClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n> = Connection<Self, DriverType, SQLiteClientType, TransactionType>;\n\nexport type SQLitePoolClientConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLitePoolClientType extends SQLitePoolClient = SQLitePoolClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n> = Connection<Self, DriverType, SQLitePoolClientType, TransactionType>;\n\nexport type SQLiteConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLiteClientType extends SQLiteClientOrPoolClient =\n | SQLiteClient\n | SQLitePoolClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n> =\n | (SQLiteClientType extends SQLiteClient\n ? SQLiteClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType\n >\n : never)\n | (SQLiteClientType extends SQLitePoolClient\n ? SQLitePoolClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType\n >\n : never);\n\nexport type AnySQLiteClientConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteClientConnection<any, any>;\n\nexport type AnySQLitePoolClientConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLitePoolClientConnection<any, any, any, any>;\n\nexport type AnySQLiteConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteConnection<any, any, any, any>;\n\nexport type SQLiteConnectionOptions<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionOptions<ConnectionType> & SQLiteClientOptions;\n\nexport type SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ConnectionOptions = SQLiteConnectionOptions,\n> = {\n driverType: InferDriverTypeFromConnection<SQLiteConnectionType>;\n type: 'Client';\n sqliteClientFactory: SQLiteClientFactory<\n InferDbClientFromConnection<SQLiteConnectionType>,\n ConnectionOptions\n >;\n connectionOptions: SQLiteConnectionOptions<SQLiteConnectionType>;\n serializer: JSONSerializer;\n};\n\nexport type SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n AnySQLitePoolClientConnection,\n ConnectionOptions = SQLiteConnectionOptions,\n> = {\n driverType: InferDriverTypeFromConnection<SQLiteConnectionType>;\n type: 'PoolClient';\n sqliteClientFactory: SQLiteClientFactory<\n InferDbClientFromConnection<SQLiteConnectionType>,\n ConnectionOptions\n >;\n connectionOptions: SQLiteConnectionOptions<SQLiteConnectionType>;\n serializer: JSONSerializer;\n};\n\nexport type SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n AnySQLitePoolClientConnection,\n ClientOptions = SQLiteClientOptions,\n> =\n | SQLiteClientConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>\n | SQLitePoolConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>;\n\nexport type SQLiteConnectionFactory<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = (options: ConnectionOptions) => SQLiteConnectionType;\n\nexport type TransactionNestingCounter = {\n increment: () => void;\n decrement: () => void;\n reset: () => void;\n level: number;\n};\n\nexport const transactionNestingCounter = (): TransactionNestingCounter => {\n let transactionLevel = 0;\n\n return {\n reset: () => {\n transactionLevel = 0;\n },\n increment: () => {\n transactionLevel++;\n },\n decrement: () => {\n transactionLevel--;\n\n if (transactionLevel < 0) {\n throw new Error('Transaction level is out of bounds');\n }\n },\n get level() {\n return transactionLevel;\n },\n };\n};\n\nexport type SqliteAmbientClientConnectionOptions<\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n client: InferDbClientFromConnection<SQLiteConnectionType>;\n initTransaction?: InitTransaction<SQLiteConnectionType>;\n allowNestedTransactions?: boolean;\n defaultTransactionMode?: SQLiteTransactionMode;\n serializer: JSONSerializer;\n errorMapper?: SQLiteErrorMapper;\n};\n\nexport const sqliteAmbientClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n>(\n options: SqliteAmbientClientConnectionOptions<SQLiteConnectionType>,\n) => {\n const {\n client,\n driverType,\n initTransaction,\n allowNestedTransactions,\n defaultTransactionMode,\n serializer,\n errorMapper,\n } = options;\n\n return createAmbientConnection<SQLiteConnectionType>({\n driverType,\n client,\n initTransaction:\n initTransaction ??\n ((connection) =>\n sqliteTransaction(\n driverType,\n connection,\n allowNestedTransactions ?? false,\n serializer,\n defaultTransactionMode,\n )),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(driverType, serializer, undefined, errorMapper),\n serializer,\n });\n};\n\nexport const sqliteClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = options;\n\n let client: InferDbClientFromConnection<SQLiteConnectionType> | null = null;\n\n const connect = async (): Promise<\n InferDbClientFromConnection<SQLiteConnectionType>\n > => {\n if (client) return Promise.resolve(client);\n\n client = sqliteClientFactory(connectionOptions as ClientOptions);\n\n if (client && 'connect' in client && typeof client.connect === 'function') {\n try {\n await client.connect();\n } catch (error) {\n throw mapSqliteError(error);\n }\n }\n\n return client;\n };\n\n return createConnection({\n driverType: options.driverType,\n connect,\n close: async () => {\n if (client && 'close' in client && typeof client.close === 'function')\n await client.close();\n else if (\n client &&\n 'release' in client &&\n typeof client.release === 'function'\n )\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n client.release();\n },\n initTransaction: (connection) =>\n sqliteTransaction(\n options.driverType,\n connection,\n connectionOptions.transactionOptions?.allowNestedTransactions ?? false,\n serializer,\n connectionOptions.defaultTransactionMode,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\n });\n};\n\nexport const sqlitePoolClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = options;\n\n let client: InferDbClientFromConnection<SQLiteConnectionType> | null = null;\n\n const connect = async (): Promise<\n InferDbClientFromConnection<SQLiteConnectionType>\n > => {\n if (client) return Promise.resolve(client);\n\n client = sqliteClientFactory(connectionOptions as ClientOptions);\n\n try {\n await client.connect();\n } catch (error) {\n throw mapSqliteError(error);\n }\n\n return client;\n };\n\n return createConnection({\n driverType: options.driverType,\n connect,\n close: () =>\n client !== null\n ? Promise.resolve((client as unknown as SQLitePoolClient).release())\n : Promise.resolve(),\n initTransaction: (connection) =>\n sqliteTransaction(\n options.driverType,\n connection,\n connectionOptions.transactionOptions?.allowNestedTransactions ?? false,\n serializer,\n connectionOptions.defaultTransactionMode,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\n });\n};\n\nexport function sqliteConnection<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType {\n return options.type === 'Client'\n ? sqliteClientConnection(options)\n : sqlitePoolClientConnection(options);\n}\n\nexport type InMemorySQLiteDatabase = ':memory:';\nexport const InMemorySQLiteDatabase = SQLiteConnectionString(':memory:');\n\nexport type { SQLitePragmaOptions } from './connectionString';\n\nexport const DEFAULT_SQLITE_PRAGMA_OPTIONS: SQLitePragmaOptions = {\n journal_mode: 'WAL',\n synchronous: 'NORMAL',\n cache_size: -1000000,\n foreign_keys: true,\n temp_store: 'MEMORY',\n busy_timeout: 5000,\n mmap_size: 268435456,\n};\n\nexport type SQLiteClientOptions = {\n pragmaOptions?: Partial<SQLitePragmaOptions>;\n defaultTransactionMode?: SQLiteTransactionMode;\n skipDatabasePragmas?: boolean;\n readonly?: boolean;\n};\n\nexport * from './connectionString';\n","import { cpus } from 'os';\nimport {\n createBoundedConnectionPool,\n createSingletonConnectionPool,\n} from '../../../../core';\nimport { guardInitializedOnce } from '../../../../core/taskProcessing';\nimport type {\n AnySQLiteConnection,\n SQLiteConnectionFactory,\n SQLiteConnectionOptions,\n} from '../connections';\nimport { mapSqliteError } from '../errors';\nimport type { SQLitePool } from './pool';\n\nexport type SQLiteDualPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n dual?: true;\n singleton?: false;\n pooled?: true;\n connection?: never;\n readerPoolSize?: number;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connectionOptions?: ConnectionOptions;\n};\n\nexport const sqliteDualConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n>(\n options: SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePool<SQLiteConnectionType> => {\n const { sqliteConnectionFactory, connectionOptions } = options;\n const readerPoolSize = options.readerPoolSize ?? Math.max(4, cpus().length);\n\n let databaseInitPromise: Promise<void> | null = null;\n\n const guardSingleConnection = guardInitializedOnce(async () => {\n if (databaseInitPromise !== null) {\n return databaseInitPromise;\n }\n\n const initConnection = sqliteConnectionFactory({\n ...connectionOptions,\n skipDatabasePragmas: false,\n readonly: false,\n } as ConnectionOptions);\n\n const initPromise = initConnection.open();\n databaseInitPromise = initPromise;\n\n try {\n await initPromise;\n await initConnection.close();\n } catch (error) {\n databaseInitPromise = null;\n await initConnection.close();\n throw mapSqliteError(error);\n }\n });\n\n const ensureDatabaseInitialized = async (): Promise<void> => {\n if (databaseInitPromise !== null) {\n return databaseInitPromise;\n }\n\n return guardSingleConnection.ensureInitialized();\n };\n\n const wrappedConnectionFactory = async (\n readonly: boolean,\n connectionOptions: ConnectionOptions | undefined,\n ): Promise<SQLiteConnectionType> => {\n await ensureDatabaseInitialized();\n\n const connection = sqliteConnectionFactory({\n ...connectionOptions,\n skipDatabasePragmas: true,\n readonly,\n } as ConnectionOptions);\n\n await connection.open();\n\n return connection;\n };\n\n const writerPool = createSingletonConnectionPool({\n driverType: options.driverType,\n getConnection: () => wrappedConnectionFactory(false, connectionOptions),\n });\n\n const readerPool = createBoundedConnectionPool({\n driverType: options.driverType,\n getConnection: () => wrappedConnectionFactory(true, connectionOptions),\n maxConnections: readerPoolSize,\n });\n\n return {\n driverType: options.driverType,\n connection: (connectionOptions) =>\n connectionOptions?.readonly\n ? readerPool.connection(connectionOptions)\n : writerPool.connection(connectionOptions),\n execute: {\n query: (...args) => readerPool.execute.query(...args),\n batchQuery: (...args) => readerPool.execute.batchQuery(...args),\n command: (...args) => writerPool.execute.command(...args),\n batchCommand: (...args) => writerPool.execute.batchCommand(...args),\n },\n withConnection: (handle, connectionOptions) =>\n connectionOptions?.readonly\n ? readerPool.withConnection(handle, connectionOptions)\n : writerPool.withConnection(handle, connectionOptions),\n transaction: writerPool.transaction,\n withTransaction: writerPool.withTransaction,\n close: async () => {\n await guardSingleConnection.stop();\n await Promise.all([writerPool.close(), readerPool.close()]);\n },\n };\n};\n","import type { SQLiteConnectionString } from '../connections/connectionString';\nimport {\n InMemorySQLiteDatabase,\n type AnySQLiteConnection,\n type SQLiteConnectionFactory,\n type SQLiteConnectionOptions,\n} from '../connections';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n createAlwaysNewConnectionPool,\n createAmbientConnectionPool,\n createSingletonConnectionPool,\n type ConnectionPool,\n} from '../../../../core';\nimport {\n sqliteDualConnectionPool,\n type SQLiteDualPoolOptions,\n} from './dualPool';\n\nexport type SQLiteFileNameOrConnectionString =\n | {\n fileName: string | SQLiteConnectionString;\n connectionString?: never;\n }\n | {\n connectionString: string | SQLiteConnectionString;\n fileName?: never;\n };\n\nexport const isInMemoryDatabase = (\n options: Record<string, unknown>,\n): boolean => {\n if ('fileName' in options) {\n return options.fileName === InMemorySQLiteDatabase;\n }\n if ('connectionString' in options) {\n return options.connectionString === InMemorySQLiteDatabase;\n }\n return false;\n};\n\nexport type SQLiteAmbientConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\ntype SQLiteAmbientConnectionPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = {\n singleton?: true;\n pooled?: false;\n sqliteConnectionFactory?: never;\n connection: SQLiteConnectionType;\n connectionOptions?: never;\n};\n\nexport const sqliteAmbientConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType['driverType']>,\n): SQLiteAmbientConnectionPool<SQLiteConnectionType['driverType']> => {\n const { connection, driverType } = options;\n\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: connection,\n });\n};\n\ntype SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = {\n singleton: true;\n pooled?: true;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connection?: never;\n connectionOptions: ConnectionOptions;\n};\n\nexport type SQLiteSingletonConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\nexport const sqliteSingletonConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions & Record<string, unknown> =\n SQLiteConnectionOptions & Record<string, unknown>,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >,\n): SQLiteSingletonConnectionPool<SQLiteConnectionType> => {\n const { driverType, sqliteConnectionFactory, connectionOptions } = options;\n\n return createSingletonConnectionPool<SQLiteConnectionType>({\n driverType,\n getConnection: () => sqliteConnectionFactory(connectionOptions),\n });\n};\n\ntype SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = {\n singleton?: false;\n pooled?: true;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connection?: never;\n connectionOptions: ConnectionOptions;\n};\n\nexport type SQLiteAlwaysNewConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\nexport const sqliteAlwaysNewConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions & Record<string, unknown> =\n SQLiteConnectionOptions & Record<string, unknown>,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteAlwaysNewPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLiteAlwaysNewConnectionPool<SQLiteConnectionType> => {\n const { driverType, sqliteConnectionFactory, connectionOptions } = options;\n\n return createAlwaysNewConnectionPool<SQLiteConnectionType>({\n driverType,\n getConnection: () => sqliteConnectionFactory(connectionOptions),\n });\n};\n\nexport type SQLitePoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = (\n | SQLiteAlwaysNewPoolOptions<SQLiteConnectionType, ConnectionOptions>\n | SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >\n | SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType>\n | SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>\n) & {\n driverType: SQLiteConnectionType['driverType'];\n serializer?: JSONSerializer;\n};\n\nexport type SQLitePool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> =\n | SQLiteAmbientConnectionPool<SQLiteConnectionType>\n | SQLiteSingletonConnectionPool<SQLiteConnectionType>\n | SQLiteAlwaysNewConnectionPool<SQLiteConnectionType>;\n\nexport type SQLitePoolFactoryOptions<\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n> = Omit<\n SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>,\n 'singleton'\n> & {\n singleton?: boolean;\n};\n\nexport const toSqlitePoolOptions = <\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n>(\n options: SQLitePoolFactoryOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions> => {\n const { singleton, ...rest } = options;\n const isInMemory = isInMemoryDatabase(options);\n\n if ('client' in options && options.client) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n if (isInMemory) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n if (singleton === true) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n return { ...rest, dual: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n};\n\nexport function sqlitePool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n>(\n options: SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePool<SQLiteConnectionType> {\n const { driverType } = options;\n\n if (\n (\n options as SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType> & {\n driverType: SQLiteConnectionType['driverType'];\n }\n ).connection\n )\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: (\n options as SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType> & {\n driverType: SQLiteConnectionType['driverType'];\n }\n ).connection,\n });\n\n if ('dual' in options && options.dual) {\n return sqliteDualConnectionPool(\n options as SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n );\n }\n\n if (\n options.singleton === true &&\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory\n ) {\n return createSingletonConnectionPool({\n driverType,\n getConnection: () =>\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory(\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).connectionOptions,\n ),\n });\n }\n\n return createAlwaysNewConnectionPool({\n driverType,\n getConnection: () =>\n (\n options as SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory(\n (\n options as SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).connectionOptions,\n ),\n });\n}\n","import {\n registerDefaultMigratorOptions,\n type MigratorOptions,\n} from '../../../../core';\n\nexport const DefaultSQLiteMigratorOptions: MigratorOptions = {};\n\nregisterDefaultMigratorOptions('SQLite', DefaultSQLiteMigratorOptions);\n","import type { DatabaseDriverType } from '../../..';\n\nexport * from './connections';\nexport * from './errors';\nexport * from './execute';\nexport * from './pool';\nexport * from './schema';\nexport * from './sql';\nexport * from './transactions';\n\nexport type SQLiteDatabaseName = 'SQLite';\nexport const SQLiteDatabaseName = 'SQLite';\n\nexport type SQLiteDriverType<DriverName extends string = string> =\n DatabaseDriverType<SQLiteDatabaseName, DriverName>;\n\nexport type SQLiteDatabaseType = 'SQLite';\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,sBAAsB,UAAuC;AACjE,KACE,iBAAiB,SACjB,UAAU,SACV,OAAQ,MAAkC,SAAS,SAEnD,QAAQ,MAAkC;;AAK9C,MAAM,mBAAmB,UACvB,iBAAiB,QAAQ,MAAM,U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