@event-driven-io/dumbo 0.13.0-beta.21 → 0.13.0-beta.22

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 (62) hide show
  1. package/dist/{chunk-FC4JR2R3.js → chunk-56QRSCG5.js} +2 -2
  2. package/dist/{chunk-65DKXURG.js → chunk-5OX6NE4Z.js} +2 -2
  3. package/dist/{chunk-IVJ3SNPJ.js → chunk-5SCFH2HY.js} +2 -2
  4. package/dist/{chunk-AMACBMAZ.cjs → chunk-5YRHCEUE.cjs} +178 -94
  5. package/dist/chunk-5YRHCEUE.cjs.map +1 -0
  6. package/dist/{chunk-H7ZKIJHB.cjs → chunk-7RMJPFU5.cjs} +6 -6
  7. package/dist/{chunk-H7ZKIJHB.cjs.map → chunk-7RMJPFU5.cjs.map} +1 -1
  8. package/dist/{chunk-T4A6BQRA.js → chunk-D63MPAJC.js} +110 -26
  9. package/dist/chunk-D63MPAJC.js.map +1 -0
  10. package/dist/{chunk-7WEBHXZD.cjs → chunk-HXQYRDCR.cjs} +43 -43
  11. package/dist/{chunk-7WEBHXZD.cjs.map → chunk-HXQYRDCR.cjs.map} +1 -1
  12. package/dist/{chunk-XO5T5N5S.js → chunk-QUAG4MBP.js} +294 -14
  13. package/dist/chunk-QUAG4MBP.js.map +1 -0
  14. package/dist/{chunk-XOQHZABK.cjs → chunk-QVEVSWG6.cjs} +307 -27
  15. package/dist/chunk-QVEVSWG6.cjs.map +1 -0
  16. package/dist/{chunk-R7P7CNMK.cjs → chunk-TMFEMKPE.cjs} +4 -4
  17. package/dist/{chunk-R7P7CNMK.cjs.map → chunk-TMFEMKPE.cjs.map} +1 -1
  18. package/dist/cloudflare.cjs +66 -61
  19. package/dist/cloudflare.cjs.map +1 -1
  20. package/dist/cloudflare.d.cts +4 -4
  21. package/dist/cloudflare.d.ts +4 -4
  22. package/dist/cloudflare.js +9 -4
  23. package/dist/cloudflare.js.map +1 -1
  24. package/dist/{columnProcessors-Difrrk4c.d.cts → columnProcessors-CsQjv8si.d.cts} +1 -1
  25. package/dist/{columnProcessors-C7fRa54L.d.ts → columnProcessors-giHzjHuv.d.ts} +1 -1
  26. package/dist/{connectionString-oeg1LD5V.d.ts → connectionString-J4yRT71A.d.cts} +40 -31
  27. package/dist/{connectionString-oeg1LD5V.d.cts → connectionString-J4yRT71A.d.ts} +40 -31
  28. package/dist/index.cjs +7 -5
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +3 -3
  31. package/dist/index.d.ts +3 -3
  32. package/dist/index.js +5 -3
  33. package/dist/index.js.map +1 -1
  34. package/dist/pg.cjs +39 -38
  35. package/dist/pg.cjs.map +1 -1
  36. package/dist/pg.d.cts +7 -7
  37. package/dist/pg.d.ts +7 -7
  38. package/dist/pg.js +5 -4
  39. package/dist/pg.js.map +1 -1
  40. package/dist/postgresql.cjs +4 -4
  41. package/dist/postgresql.d.cts +2 -2
  42. package/dist/postgresql.d.ts +2 -2
  43. package/dist/postgresql.js +3 -3
  44. package/dist/sqlite.cjs +8 -4
  45. package/dist/sqlite.cjs.map +1 -1
  46. package/dist/sqlite.d.cts +48 -23
  47. package/dist/sqlite.d.ts +48 -23
  48. package/dist/sqlite.js +7 -3
  49. package/dist/sqlite3.cjs +65 -28
  50. package/dist/sqlite3.cjs.map +1 -1
  51. package/dist/sqlite3.d.cts +11 -11
  52. package/dist/sqlite3.d.ts +11 -11
  53. package/dist/sqlite3.js +48 -11
  54. package/dist/sqlite3.js.map +1 -1
  55. package/package.json +1 -1
  56. package/dist/chunk-AMACBMAZ.cjs.map +0 -1
  57. package/dist/chunk-T4A6BQRA.js.map +0 -1
  58. package/dist/chunk-XO5T5N5S.js.map +0 -1
  59. package/dist/chunk-XOQHZABK.cjs.map +0 -1
  60. /package/dist/{chunk-FC4JR2R3.js.map → chunk-56QRSCG5.js.map} +0 -0
  61. /package/dist/{chunk-65DKXURG.js.map → chunk-5OX6NE4Z.js.map} +0 -0
  62. /package/dist/{chunk-IVJ3SNPJ.js.map → chunk-5SCFH2HY.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SQL,
3
3
  exists
4
- } from "./chunk-XO5T5N5S.js";
4
+ } from "./chunk-QUAG4MBP.js";
5
5
 
6
6
  // src/storage/postgresql/core/connections/connectionString.ts
7
7
  var defaultPostgreSQLConnectionString = "postgresql://postgres@localhost:5432/postgres";
@@ -80,4 +80,4 @@ export {
80
80
  functionExists,
81
81
  postgreSQLMetadata
82
82
  };
83
- //# sourceMappingURL=chunk-FC4JR2R3.js.map
83
+ //# sourceMappingURL=chunk-56QRSCG5.js.map
@@ -28,7 +28,7 @@ import {
28
28
  registerDefaultMigratorOptions,
29
29
  registerFormatter,
30
30
  single
31
- } from "./chunk-XO5T5N5S.js";
31
+ } from "./chunk-QUAG4MBP.js";
32
32
 
33
33
  // src/storage/postgresql/core/errors/errorMapper.ts
34
34
  var getPostgresErrorCode = (error) => {
@@ -478,4 +478,4 @@ export {
478
478
  pgFormatter,
479
479
  PostgreSQLDatabaseName
480
480
  };
481
- //# sourceMappingURL=chunk-65DKXURG.js.map
481
+ //# sourceMappingURL=chunk-5OX6NE4Z.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SQL,
3
3
  exists
4
- } from "./chunk-XO5T5N5S.js";
4
+ } from "./chunk-QUAG4MBP.js";
5
5
 
6
6
  // src/storage/sqlite/core/schema/schema.ts
7
7
  var defaultSQLiteDatabase = ":memory:";
@@ -31,4 +31,4 @@ export {
31
31
  tableExists,
32
32
  sqliteMetadata
33
33
  };
34
- //# sourceMappingURL=chunk-IVJ3SNPJ.js.map
34
+ //# sourceMappingURL=chunk-5SCFH2HY.js.map
@@ -28,7 +28,8 @@
28
28
 
29
29
 
30
30
 
31
- var _chunkXOQHZABKcjs = require('./chunk-XOQHZABK.cjs');
31
+
32
+ var _chunkQVEVSWG6cjs = require('./chunk-QVEVSWG6.cjs');
32
33
 
33
34
  // src/storage/sqlite/core/errors/errorMapper.ts
34
35
  var getSqliteErrorCode = (error) => {
@@ -42,20 +43,20 @@ var asError = (error) => error instanceof Error ? error : void 0;
42
43
  var mapConstraintError = (message, innerError) => {
43
44
  const upperMessage = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _ => _.toUpperCase, 'call', _2 => _2()]), () => ( ""));
44
45
  if (upperMessage.includes("UNIQUE") || upperMessage.includes("PRIMARY KEY"))
45
- return new (0, _chunkXOQHZABKcjs.UniqueConstraintError)(message, innerError);
46
+ return new (0, _chunkQVEVSWG6cjs.UniqueConstraintError)(message, innerError);
46
47
  if (upperMessage.includes("FOREIGN KEY"))
47
- return new (0, _chunkXOQHZABKcjs.ForeignKeyViolationError)(message, innerError);
48
+ return new (0, _chunkQVEVSWG6cjs.ForeignKeyViolationError)(message, innerError);
48
49
  if (upperMessage.includes("NOT NULL"))
49
- return new (0, _chunkXOQHZABKcjs.NotNullViolationError)(message, innerError);
50
+ return new (0, _chunkQVEVSWG6cjs.NotNullViolationError)(message, innerError);
50
51
  if (upperMessage.includes("CHECK"))
51
- return new (0, _chunkXOQHZABKcjs.CheckViolationError)(message, innerError);
52
- return new (0, _chunkXOQHZABKcjs.IntegrityConstraintViolationError)(message, innerError);
52
+ return new (0, _chunkQVEVSWG6cjs.CheckViolationError)(message, innerError);
53
+ return new (0, _chunkQVEVSWG6cjs.IntegrityConstraintViolationError)(message, innerError);
53
54
  };
54
55
  var mapSqliteError = (error) => {
55
- if (_chunkXOQHZABKcjs.DumboError.isInstanceOf(error)) return error;
56
+ if (_chunkQVEVSWG6cjs.DumboError.isInstanceOf(error)) return error;
56
57
  const code = getSqliteErrorCode(error);
57
58
  if (!code)
58
- return new (0, _chunkXOQHZABKcjs.DumboError)({
59
+ return new (0, _chunkQVEVSWG6cjs.DumboError)({
59
60
  errorCode: 500,
60
61
  message: getErrorMessage(error),
61
62
  innerError: asError(error)
@@ -70,78 +71,78 @@ var mapSqliteError = (error) => {
70
71
  // ── Busy / lock contention ──
71
72
  // SQLITE_BUSY (5): conflict with a separate database connection
72
73
  case "SQLITE_BUSY":
73
- return new (0, _chunkXOQHZABKcjs.LockNotAvailableError)(message, innerError);
74
+ return new (0, _chunkQVEVSWG6cjs.LockNotAvailableError)(message, innerError);
74
75
  // SQLITE_LOCKED (6): conflict within the same connection or shared cache
75
76
  case "SQLITE_LOCKED":
76
- return new (0, _chunkXOQHZABKcjs.DeadlockError)(message, innerError);
77
+ return new (0, _chunkQVEVSWG6cjs.DeadlockError)(message, innerError);
77
78
  // SQLITE_PROTOCOL (15): WAL locking race condition
78
79
  case "SQLITE_PROTOCOL":
79
- return new (0, _chunkXOQHZABKcjs.LockNotAvailableError)(message, innerError);
80
+ return new (0, _chunkQVEVSWG6cjs.LockNotAvailableError)(message, innerError);
80
81
  // ── Connection / open errors ──
81
82
  // SQLITE_CANTOPEN (14): unable to open database file
82
83
  case "SQLITE_CANTOPEN":
83
- return new (0, _chunkXOQHZABKcjs.ConnectionError)(message, innerError);
84
+ return new (0, _chunkQVEVSWG6cjs.ConnectionError)(message, innerError);
84
85
  // SQLITE_NOTADB (26): file is not a database
85
86
  case "SQLITE_NOTADB":
86
- return new (0, _chunkXOQHZABKcjs.ConnectionError)(message, innerError);
87
+ return new (0, _chunkQVEVSWG6cjs.ConnectionError)(message, innerError);
87
88
  // ── Resource exhaustion ──
88
89
  // SQLITE_NOMEM (7): out of memory
89
90
  case "SQLITE_NOMEM":
90
- return new (0, _chunkXOQHZABKcjs.InsufficientResourcesError)(message, innerError);
91
+ return new (0, _chunkQVEVSWG6cjs.InsufficientResourcesError)(message, innerError);
91
92
  // SQLITE_FULL (13): disk full
92
93
  case "SQLITE_FULL":
93
- return new (0, _chunkXOQHZABKcjs.InsufficientResourcesError)(message, innerError);
94
+ return new (0, _chunkQVEVSWG6cjs.InsufficientResourcesError)(message, innerError);
94
95
  // ── System / I/O errors ──
95
96
  // SQLITE_IOERR (10): operating system I/O error
96
97
  case "SQLITE_IOERR":
97
- return new (0, _chunkXOQHZABKcjs.SystemError)(message, innerError);
98
+ return new (0, _chunkQVEVSWG6cjs.SystemError)(message, innerError);
98
99
  // SQLITE_CORRUPT (11): database file is corrupted
99
100
  case "SQLITE_CORRUPT":
100
- return new (0, _chunkXOQHZABKcjs.SystemError)(message, innerError);
101
+ return new (0, _chunkQVEVSWG6cjs.SystemError)(message, innerError);
101
102
  // SQLITE_INTERNAL (2): internal SQLite malfunction
102
103
  case "SQLITE_INTERNAL":
103
- return new (0, _chunkXOQHZABKcjs.SystemError)(message, innerError);
104
+ return new (0, _chunkQVEVSWG6cjs.SystemError)(message, innerError);
104
105
  // SQLITE_NOLFS (22): large file support unavailable
105
106
  case "SQLITE_NOLFS":
106
- return new (0, _chunkXOQHZABKcjs.SystemError)(message, innerError);
107
+ return new (0, _chunkQVEVSWG6cjs.SystemError)(message, innerError);
107
108
  // ── Data errors ──
108
109
  // SQLITE_TOOBIG (18): string or BLOB too large
109
110
  case "SQLITE_TOOBIG":
110
- return new (0, _chunkXOQHZABKcjs.DataError)(message, innerError);
111
+ return new (0, _chunkQVEVSWG6cjs.DataError)(message, innerError);
111
112
  // SQLITE_MISMATCH (20): datatype mismatch
112
113
  case "SQLITE_MISMATCH":
113
- return new (0, _chunkXOQHZABKcjs.DataError)(message, innerError);
114
+ return new (0, _chunkQVEVSWG6cjs.DataError)(message, innerError);
114
115
  // SQLITE_RANGE (25): bind parameter index out of range
115
116
  case "SQLITE_RANGE":
116
- return new (0, _chunkXOQHZABKcjs.DataError)(message, innerError);
117
+ return new (0, _chunkQVEVSWG6cjs.DataError)(message, innerError);
117
118
  // ── Invalid operations ──
118
119
  // SQLITE_ERROR (1): generic SQL error (syntax errors, missing tables, etc.)
119
120
  case "SQLITE_ERROR":
120
- return new (0, _chunkXOQHZABKcjs.InvalidOperationError)(message, innerError);
121
+ return new (0, _chunkQVEVSWG6cjs.InvalidOperationError)(message, innerError);
121
122
  // SQLITE_READONLY (8): attempt to write to a read-only database
122
123
  case "SQLITE_READONLY":
123
- return new (0, _chunkXOQHZABKcjs.InvalidOperationError)(message, innerError);
124
+ return new (0, _chunkQVEVSWG6cjs.InvalidOperationError)(message, innerError);
124
125
  // SQLITE_MISUSE (21): API misuse
125
126
  case "SQLITE_MISUSE":
126
- return new (0, _chunkXOQHZABKcjs.InvalidOperationError)(message, innerError);
127
+ return new (0, _chunkQVEVSWG6cjs.InvalidOperationError)(message, innerError);
127
128
  // SQLITE_AUTH (23): authorization denied
128
129
  case "SQLITE_AUTH":
129
- return new (0, _chunkXOQHZABKcjs.InvalidOperationError)(message, innerError);
130
+ return new (0, _chunkQVEVSWG6cjs.InvalidOperationError)(message, innerError);
130
131
  // SQLITE_PERM (3): access permission denied
131
132
  case "SQLITE_PERM":
132
- return new (0, _chunkXOQHZABKcjs.InvalidOperationError)(message, innerError);
133
+ return new (0, _chunkQVEVSWG6cjs.InvalidOperationError)(message, innerError);
133
134
  // SQLITE_SCHEMA (17): schema changed, statement needs re-preparation
134
135
  case "SQLITE_SCHEMA":
135
- return new (0, _chunkXOQHZABKcjs.InvalidOperationError)(message, innerError);
136
+ return new (0, _chunkQVEVSWG6cjs.InvalidOperationError)(message, innerError);
136
137
  // ── Transaction / abort ──
137
138
  // SQLITE_ABORT (4): operation aborted (e.g. by rollback)
138
139
  case "SQLITE_ABORT":
139
- return new (0, _chunkXOQHZABKcjs.SerializationError)(message, innerError);
140
+ return new (0, _chunkQVEVSWG6cjs.SerializationError)(message, innerError);
140
141
  // SQLITE_INTERRUPT (9): operation interrupted
141
142
  case "SQLITE_INTERRUPT":
142
- return new (0, _chunkXOQHZABKcjs.SerializationError)(message, innerError);
143
+ return new (0, _chunkQVEVSWG6cjs.SerializationError)(message, innerError);
143
144
  }
144
- return new (0, _chunkXOQHZABKcjs.DumboError)({
145
+ return new (0, _chunkQVEVSWG6cjs.DumboError)({
145
146
  errorCode: 500,
146
147
  message,
147
148
  innerError
@@ -187,16 +188,16 @@ var mapColumnType = (token, { builder }) => {
187
188
  }
188
189
  builder.addSQL(columnSQL);
189
190
  };
190
- var sqliteColumnProcessors = _chunkXOQHZABKcjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
191
+ var sqliteColumnProcessors = _chunkQVEVSWG6cjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
191
192
 
192
193
  // src/storage/sqlite/core/sql/formatter/index.ts
193
- var sqliteSQLProcessorsRegistry = _chunkXOQHZABKcjs.SQLProcessorsRegistry.call(void 0, {
194
- from: _chunkXOQHZABKcjs.defaultProcessorsRegistry
194
+ var sqliteSQLProcessorsRegistry = _chunkQVEVSWG6cjs.SQLProcessorsRegistry.call(void 0, {
195
+ from: _chunkQVEVSWG6cjs.defaultProcessorsRegistry
195
196
  }).register(sqliteColumnProcessors);
196
- var sqliteFormatter = _chunkXOQHZABKcjs.SQLFormatter.call(void 0, {
197
+ var sqliteFormatter = _chunkQVEVSWG6cjs.SQLFormatter.call(void 0, {
197
198
  processorsRegistry: sqliteSQLProcessorsRegistry
198
199
  });
199
- _chunkXOQHZABKcjs.registerFormatter.call(void 0, "SQLite", sqliteFormatter);
200
+ _chunkQVEVSWG6cjs.registerFormatter.call(void 0, "SQLite", sqliteFormatter);
200
201
 
201
202
  // src/storage/sqlite/core/execute/execute.ts
202
203
  var sqliteExecute = async (database, handle) => {
@@ -209,55 +210,46 @@ var sqliteExecute = async (database, handle) => {
209
210
  var sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
210
211
  driverType,
211
212
  query: async (client, sql, options) => {
212
- if (_optionalChain([options, 'optionalAccess', _3 => _3.timeoutMs])) {
213
- await client.query(_chunkXOQHZABKcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
214
- }
215
- _chunkXOQHZABKcjs.tracer.info("db:sql:query", {
213
+ _chunkQVEVSWG6cjs.tracer.info("db:sql:query", {
216
214
  query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).query,
217
215
  params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).params,
218
216
  debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql, { serializer })
219
217
  });
220
218
  try {
221
219
  let result = await client.query(sql, options);
222
- if (_optionalChain([options, 'optionalAccess', _4 => _4.mapping])) {
220
+ if (_optionalChain([options, 'optionalAccess', _3 => _3.mapping])) {
223
221
  result = {
224
222
  ...result,
225
223
  rows: result.rows.map(
226
- (row) => _chunkXOQHZABKcjs.mapSQLQueryResult.call(void 0, row, options.mapping)
224
+ (row) => _chunkQVEVSWG6cjs.mapSQLQueryResult.call(void 0, row, options.mapping)
227
225
  )
228
226
  };
229
227
  }
230
228
  return result;
231
229
  } catch (error) {
232
- _chunkXOQHZABKcjs.tracer.error("db:sql:query:execute:error", { error });
230
+ _chunkQVEVSWG6cjs.tracer.error("db:sql:query:execute:error", { error });
233
231
  throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
234
232
  }
235
233
  },
236
234
  batchQuery: async (client, sqls, options) => {
237
- if (_optionalChain([options, 'optionalAccess', _5 => _5.timeoutMs])) {
238
- await client.query(_chunkXOQHZABKcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
239
- }
240
235
  try {
241
236
  const results = await client.batchQuery(sqls, options);
242
- if (_optionalChain([options, 'optionalAccess', _6 => _6.mapping])) {
237
+ if (_optionalChain([options, 'optionalAccess', _4 => _4.mapping])) {
243
238
  return results.map((result) => ({
244
239
  ...result,
245
240
  rows: result.rows.map(
246
- (row) => _chunkXOQHZABKcjs.mapSQLQueryResult.call(void 0, row, options.mapping)
241
+ (row) => _chunkQVEVSWG6cjs.mapSQLQueryResult.call(void 0, row, options.mapping)
247
242
  )
248
243
  }));
249
244
  }
250
245
  return results;
251
246
  } catch (error) {
252
- _chunkXOQHZABKcjs.tracer.error("db:sql:batch_query:execute:error", { error });
247
+ _chunkQVEVSWG6cjs.tracer.error("db:sql:batch_query:execute:error", { error });
253
248
  throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
254
249
  }
255
250
  },
256
251
  command: async (client, sql, options) => {
257
- if (_optionalChain([options, 'optionalAccess', _7 => _7.timeoutMs])) {
258
- await client.query(_chunkXOQHZABKcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
259
- }
260
- _chunkXOQHZABKcjs.tracer.info("db:sql:command", {
252
+ _chunkQVEVSWG6cjs.tracer.info("db:sql:command", {
261
253
  query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).query,
262
254
  params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).params,
263
255
  debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql, { serializer })
@@ -265,24 +257,52 @@ var sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
265
257
  try {
266
258
  return await client.command(sql, options);
267
259
  } catch (error) {
268
- _chunkXOQHZABKcjs.tracer.error("db:sql:command:execute:error", { error });
260
+ _chunkQVEVSWG6cjs.tracer.error("db:sql:command:execute:error", { error });
269
261
  throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
270
262
  }
271
263
  },
272
264
  batchCommand: async (client, sqls, options) => {
273
- if (_optionalChain([options, 'optionalAccess', _8 => _8.timeoutMs])) {
274
- await client.query(_chunkXOQHZABKcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
275
- }
276
265
  try {
277
266
  return await client.batchCommand(sqls, options);
278
267
  } catch (error) {
279
- _chunkXOQHZABKcjs.tracer.error("db:sql:batch_command:execute:error", { error });
268
+ _chunkQVEVSWG6cjs.tracer.error("db:sql:batch_command:execute:error", { error });
280
269
  throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
281
270
  }
282
271
  },
283
272
  formatter: _nullishCoalesce(formatter, () => ( sqliteFormatter))
284
273
  });
285
274
 
275
+ // src/storage/sqlite/core/pool/dualPool.ts
276
+ var _os = require('os');
277
+ var sqliteDualConnectionPool = (options) => {
278
+ const { sqliteConnectionFactory, connectionOptions } = options;
279
+ const readerPoolSize = _nullishCoalesce(options.readerPoolSize, () => ( Math.max(4, _os.cpus.call(void 0, ).length)));
280
+ const writerPool = _chunkQVEVSWG6cjs.createSingletonConnectionPool.call(void 0, {
281
+ driverType: options.driverType,
282
+ getConnection: () => sqliteConnectionFactory(connectionOptions)
283
+ });
284
+ const readerPool = _chunkQVEVSWG6cjs.createBoundedConnectionPool.call(void 0, {
285
+ driverType: options.driverType,
286
+ getConnection: () => sqliteConnectionFactory(connectionOptions),
287
+ maxConnections: readerPoolSize
288
+ });
289
+ return {
290
+ driverType: options.driverType,
291
+ connection: (connectionOptions2) => _optionalChain([connectionOptions2, 'optionalAccess', _5 => _5.readonly]) ? readerPool.connection(connectionOptions2) : writerPool.connection(connectionOptions2),
292
+ execute: {
293
+ query: (...args) => readerPool.execute.query(...args),
294
+ batchQuery: (...args) => readerPool.execute.batchQuery(...args),
295
+ command: (...args) => writerPool.execute.command(...args),
296
+ batchCommand: (...args) => writerPool.execute.batchCommand(...args)
297
+ },
298
+ withConnection: (handle, connectionOptions2) => _optionalChain([connectionOptions2, 'optionalAccess', _6 => _6.readonly]) ? readerPool.withConnection(handle, connectionOptions2) : writerPool.withConnection(handle, connectionOptions2),
299
+ transaction: writerPool.transaction,
300
+ withTransaction: writerPool.withTransaction,
301
+ close: () => Promise.all([writerPool.close(), readerPool.close()]).then(() => {
302
+ })
303
+ };
304
+ };
305
+
286
306
  // src/storage/sqlite/core/pool/pool.ts
287
307
  var isInMemoryDatabase = (options) => {
288
308
  if ("fileName" in options) {
@@ -295,55 +315,67 @@ var isInMemoryDatabase = (options) => {
295
315
  };
296
316
  var sqliteAmbientConnectionPool = (options) => {
297
317
  const { connection, driverType } = options;
298
- return _chunkXOQHZABKcjs.createAmbientConnectionPool.call(void 0, {
318
+ return _chunkQVEVSWG6cjs.createAmbientConnectionPool.call(void 0, {
299
319
  driverType,
300
320
  connection
301
321
  });
302
322
  };
303
323
  var sqliteSingletonConnectionPool = (options) => {
304
324
  const { driverType, sqliteConnectionFactory, connectionOptions } = options;
305
- return _chunkXOQHZABKcjs.createSingletonConnectionPool.call(void 0, {
325
+ return _chunkQVEVSWG6cjs.createSingletonConnectionPool.call(void 0, {
306
326
  driverType,
307
327
  getConnection: () => sqliteConnectionFactory(connectionOptions)
308
328
  });
309
329
  };
310
330
  var sqliteAlwaysNewConnectionPool = (options) => {
311
331
  const { driverType, sqliteConnectionFactory, connectionOptions } = options;
312
- return _chunkXOQHZABKcjs.createAlwaysNewConnectionPool.call(void 0, {
332
+ return _chunkQVEVSWG6cjs.createAlwaysNewConnectionPool.call(void 0, {
313
333
  driverType,
314
334
  getConnection: () => sqliteConnectionFactory(connectionOptions)
315
335
  });
316
336
  };
317
337
  var toSqlitePoolOptions = (options) => {
318
338
  const { singleton, ...rest } = options;
319
- const useSingleton = _nullishCoalesce(singleton, () => ( isInMemoryDatabase(options)));
320
- if (useSingleton) {
339
+ const isInMemory = isInMemoryDatabase(options);
340
+ if (isInMemory) {
321
341
  return { ...rest, singleton: true };
322
342
  }
323
- return { ...rest, singleton: false };
343
+ if (singleton === true) {
344
+ return { ...rest, singleton: true };
345
+ }
346
+ return { ...rest, dual: true };
324
347
  };
325
348
  function sqlitePool(options) {
326
349
  const { driverType } = options;
327
350
  if (options.connection)
328
- return _chunkXOQHZABKcjs.createAmbientConnectionPool.call(void 0, {
351
+ return _chunkQVEVSWG6cjs.createAmbientConnectionPool.call(void 0, {
329
352
  driverType,
330
353
  connection: options.connection
331
354
  });
355
+ if ("dual" in options && options.dual) {
356
+ return sqliteDualConnectionPool(
357
+ options
358
+ );
359
+ }
332
360
  if (options.singleton === true && options.sqliteConnectionFactory) {
333
- return _chunkXOQHZABKcjs.createSingletonConnectionPool.call(void 0, {
361
+ return _chunkQVEVSWG6cjs.createSingletonConnectionPool.call(void 0, {
334
362
  driverType,
335
- getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
363
+ getConnection: () => options.sqliteConnectionFactory(
364
+ options.connectionOptions
365
+ )
336
366
  });
337
367
  }
338
- return _chunkXOQHZABKcjs.createAlwaysNewConnectionPool.call(void 0, {
368
+ return _chunkQVEVSWG6cjs.createAlwaysNewConnectionPool.call(void 0, {
339
369
  driverType,
340
- getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
370
+ getConnection: () => options.sqliteConnectionFactory(
371
+ options.connectionOptions
372
+ )
341
373
  });
342
374
  }
343
375
 
344
376
  // src/storage/sqlite/core/schema/migrations.ts
345
377
  var DefaultSQLiteMigratorOptions = {};
346
- _chunkXOQHZABKcjs.registerDefaultMigratorOptions.call(void 0, "SQLite", DefaultSQLiteMigratorOptions);
378
+ _chunkQVEVSWG6cjs.registerDefaultMigratorOptions.call(void 0, "SQLite", DefaultSQLiteMigratorOptions);
347
379
 
348
380
  // src/storage/sqlite/core/index.ts
349
381
  var SQLiteDatabaseName = "SQLite";
@@ -357,6 +389,41 @@ var SQLiteConnectionString = (connectionString) => {
357
389
  }
358
390
  return connectionString;
359
391
  };
392
+ var parsePragmasFromConnectionString = (connectionString) => {
393
+ const str = String(connectionString);
394
+ if (!str.startsWith("file:")) {
395
+ return {};
396
+ }
397
+ const url = new URL(str);
398
+ const params = url.searchParams;
399
+ const pragmas = {};
400
+ const journalMode = params.get("journal_mode");
401
+ if (journalMode !== null) {
402
+ pragmas.journal_mode = journalMode;
403
+ }
404
+ const synchronous = params.get("synchronous");
405
+ if (synchronous !== null) {
406
+ pragmas.synchronous = synchronous;
407
+ }
408
+ const cacheSize = params.get("cache_size");
409
+ if (cacheSize !== null) {
410
+ pragmas.cache_size = parseInt(cacheSize, 10);
411
+ }
412
+ const foreignKeys = params.get("foreign_keys");
413
+ if (foreignKeys !== null) {
414
+ const val = foreignKeys.toLowerCase();
415
+ pragmas.foreign_keys = val === "true" || val === "on" || val === "1";
416
+ }
417
+ const tempStore = params.get("temp_store");
418
+ if (tempStore !== null) {
419
+ pragmas.temp_store = tempStore.toUpperCase();
420
+ }
421
+ const busyTimeout = params.get("busy_timeout");
422
+ if (busyTimeout !== null) {
423
+ pragmas.busy_timeout = parseInt(busyTimeout, 10);
424
+ }
425
+ return pragmas;
426
+ };
360
427
 
361
428
  // src/storage/sqlite/core/connections/index.ts
362
429
  var isSQLiteError = (error) => {
@@ -391,17 +458,19 @@ var sqliteAmbientClientConnection = (options) => {
391
458
  driverType,
392
459
  initTransaction,
393
460
  allowNestedTransactions,
461
+ defaultTransactionMode,
394
462
  serializer,
395
463
  errorMapper
396
464
  } = options;
397
- return _chunkXOQHZABKcjs.createAmbientConnection.call(void 0, {
465
+ return _chunkQVEVSWG6cjs.createAmbientConnection.call(void 0, {
398
466
  driverType,
399
467
  client,
400
468
  initTransaction: _nullishCoalesce(initTransaction, () => ( ((connection) => sqliteTransaction(
401
469
  driverType,
402
470
  connection,
403
471
  _nullishCoalesce(allowNestedTransactions, () => ( false)),
404
- serializer
472
+ serializer,
473
+ defaultTransactionMode
405
474
  )))),
406
475
  executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(driverType, serializer2, void 0, errorMapper),
407
476
  serializer
@@ -417,7 +486,7 @@ var sqliteClientConnection = (options) => {
417
486
  await client.connect();
418
487
  return client;
419
488
  };
420
- return _chunkXOQHZABKcjs.createConnection.call(void 0, {
489
+ return _chunkQVEVSWG6cjs.createConnection.call(void 0, {
421
490
  driverType: options.driverType,
422
491
  connect,
423
492
  close: async () => {
@@ -429,8 +498,9 @@ var sqliteClientConnection = (options) => {
429
498
  initTransaction: (connection) => sqliteTransaction(
430
499
  options.driverType,
431
500
  connection,
432
- _nullishCoalesce(_optionalChain([connectionOptions, 'access', _9 => _9.transactionOptions, 'optionalAccess', _10 => _10.allowNestedTransactions]), () => ( false)),
433
- serializer
501
+ _nullishCoalesce(_optionalChain([connectionOptions, 'access', _7 => _7.transactionOptions, 'optionalAccess', _8 => _8.allowNestedTransactions]), () => ( false)),
502
+ serializer,
503
+ connectionOptions.defaultTransactionMode
434
504
  ),
435
505
  executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(options.driverType, serializer2),
436
506
  serializer
@@ -445,15 +515,16 @@ var sqlitePoolClientConnection = (options) => {
445
515
  await client.connect();
446
516
  return client;
447
517
  };
448
- return _chunkXOQHZABKcjs.createConnection.call(void 0, {
518
+ return _chunkQVEVSWG6cjs.createConnection.call(void 0, {
449
519
  driverType: options.driverType,
450
520
  connect,
451
521
  close: () => client !== null ? Promise.resolve(client.release()) : Promise.resolve(),
452
522
  initTransaction: (connection) => sqliteTransaction(
453
523
  options.driverType,
454
524
  connection,
455
- _nullishCoalesce(_optionalChain([connectionOptions, 'access', _11 => _11.transactionOptions, 'optionalAccess', _12 => _12.allowNestedTransactions]), () => ( false)),
456
- serializer
525
+ _nullishCoalesce(_optionalChain([connectionOptions, 'access', _9 => _9.transactionOptions, 'optionalAccess', _10 => _10.allowNestedTransactions]), () => ( false)),
526
+ serializer,
527
+ connectionOptions.defaultTransactionMode
457
528
  ),
458
529
  executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(options.driverType, serializer2),
459
530
  serializer
@@ -463,12 +534,20 @@ function sqliteConnection(options) {
463
534
  return options.type === "Client" ? sqliteClientConnection(options) : sqlitePoolClientConnection(options);
464
535
  }
465
536
  var InMemorySQLiteDatabase = SQLiteConnectionString(":memory:");
537
+ var DEFAULT_SQLITE_PRAGMA_OPTIONS = {
538
+ journal_mode: "WAL",
539
+ synchronous: "NORMAL",
540
+ cache_size: -1e6,
541
+ foreign_keys: true,
542
+ temp_store: "MEMORY",
543
+ busy_timeout: 5e3
544
+ };
466
545
 
467
546
  // src/storage/sqlite/core/transactions/index.ts
468
- var sqliteTransaction = (driverType, connection, allowNestedTransactions, serializer) => (getClient, options) => {
547
+ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serializer, defaultTransactionMode) => (getClient, options) => {
469
548
  const transactionCounter = transactionNestingCounter();
470
- allowNestedTransactions = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.allowNestedTransactions]), () => ( allowNestedTransactions));
471
- return {
549
+ allowNestedTransactions = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.allowNestedTransactions]), () => ( allowNestedTransactions));
550
+ const transaction = {
472
551
  connection: connection(),
473
552
  driverType,
474
553
  begin: async function() {
@@ -477,13 +556,14 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
477
556
  if (transactionCounter.level >= 1) {
478
557
  transactionCounter.increment();
479
558
  await client.query(
480
- _chunkXOQHZABKcjs.SQL`SAVEPOINT transaction${_chunkXOQHZABKcjs.SQL.plain(transactionCounter.level.toString())}`
559
+ _chunkQVEVSWG6cjs.SQL`SAVEPOINT transaction${_chunkQVEVSWG6cjs.SQL.plain(transactionCounter.level.toString())}`
481
560
  );
482
561
  return;
483
562
  }
484
563
  transactionCounter.increment();
485
564
  }
486
- await client.query(_chunkXOQHZABKcjs.SQL`BEGIN TRANSACTION`);
565
+ const mode = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _12 => _12.mode]), () => ( defaultTransactionMode)), () => ( "IMMEDIATE"));
566
+ await client.query(_chunkQVEVSWG6cjs.SQL`BEGIN ${_chunkQVEVSWG6cjs.SQL.plain(mode)} TRANSACTION`);
487
567
  },
488
568
  commit: async function() {
489
569
  const client = await getClient;
@@ -491,17 +571,17 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
491
571
  if (allowNestedTransactions) {
492
572
  if (transactionCounter.level > 1) {
493
573
  await client.query(
494
- _chunkXOQHZABKcjs.SQL`RELEASE transaction${_chunkXOQHZABKcjs.SQL.plain(transactionCounter.level.toString())}`
574
+ _chunkQVEVSWG6cjs.SQL`RELEASE transaction${_chunkQVEVSWG6cjs.SQL.plain(transactionCounter.level.toString())}`
495
575
  );
496
576
  transactionCounter.decrement();
497
577
  return;
498
578
  }
499
579
  transactionCounter.reset();
500
580
  }
501
- await client.query(_chunkXOQHZABKcjs.SQL`COMMIT`);
581
+ await client.query(_chunkQVEVSWG6cjs.SQL`COMMIT`);
502
582
  } finally {
503
- if (_optionalChain([options, 'optionalAccess', _14 => _14.close]))
504
- await _optionalChain([options, 'optionalAccess', _15 => _15.close, 'call', _16 => _16(
583
+ if (_optionalChain([options, 'optionalAccess', _13 => _13.close]))
584
+ await _optionalChain([options, 'optionalAccess', _14 => _14.close, 'call', _15 => _15(
505
585
  client
506
586
  )]);
507
587
  }
@@ -515,19 +595,21 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
515
595
  return;
516
596
  }
517
597
  }
518
- await client.query(_chunkXOQHZABKcjs.SQL`ROLLBACK`);
598
+ await client.query(_chunkQVEVSWG6cjs.SQL`ROLLBACK`);
519
599
  } finally {
520
- if (_optionalChain([options, 'optionalAccess', _17 => _17.close]))
521
- await _optionalChain([options, 'optionalAccess', _18 => _18.close, 'call', _19 => _19(
600
+ if (_optionalChain([options, 'optionalAccess', _16 => _16.close]))
601
+ await _optionalChain([options, 'optionalAccess', _17 => _17.close, 'call', _18 => _18(
522
602
  client,
523
603
  error
524
604
  )]);
525
605
  }
526
606
  },
527
- execute: _chunkXOQHZABKcjs.sqlExecutor.call(void 0, sqliteSQLExecutor(driverType, serializer), {
607
+ execute: _chunkQVEVSWG6cjs.sqlExecutor.call(void 0, sqliteSQLExecutor(driverType, serializer), {
528
608
  connect: () => getClient
529
- })
609
+ }),
610
+ _transactionOptions: _nullishCoalesce(options, () => ( {}))
530
611
  };
612
+ return transaction;
531
613
  };
532
614
 
533
615
 
@@ -552,5 +634,7 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
552
634
 
553
635
 
554
636
 
555
- exports.mapSqliteError = mapSqliteError; exports.sqliteFormatter = sqliteFormatter; exports.sqliteExecute = sqliteExecute; exports.sqliteSQLExecutor = sqliteSQLExecutor; exports.sqliteTransaction = sqliteTransaction; exports.SQLiteConnectionString = SQLiteConnectionString; exports.isSQLiteError = isSQLiteError; exports.transactionNestingCounter = transactionNestingCounter; exports.sqliteAmbientClientConnection = sqliteAmbientClientConnection; exports.sqliteClientConnection = sqliteClientConnection; exports.sqlitePoolClientConnection = sqlitePoolClientConnection; exports.sqliteConnection = sqliteConnection; exports.InMemorySQLiteDatabase = InMemorySQLiteDatabase; exports.isInMemoryDatabase = isInMemoryDatabase; exports.sqliteAmbientConnectionPool = sqliteAmbientConnectionPool; exports.sqliteSingletonConnectionPool = sqliteSingletonConnectionPool; exports.sqliteAlwaysNewConnectionPool = sqliteAlwaysNewConnectionPool; exports.toSqlitePoolOptions = toSqlitePoolOptions; exports.sqlitePool = sqlitePool; exports.DefaultSQLiteMigratorOptions = DefaultSQLiteMigratorOptions; exports.SQLiteDatabaseName = SQLiteDatabaseName;
556
- //# sourceMappingURL=chunk-AMACBMAZ.cjs.map
637
+
638
+
639
+ exports.mapSqliteError = mapSqliteError; exports.sqliteFormatter = sqliteFormatter; exports.sqliteExecute = sqliteExecute; exports.sqliteSQLExecutor = sqliteSQLExecutor; exports.sqliteTransaction = sqliteTransaction; exports.SQLiteConnectionString = SQLiteConnectionString; exports.parsePragmasFromConnectionString = parsePragmasFromConnectionString; exports.isSQLiteError = isSQLiteError; exports.transactionNestingCounter = transactionNestingCounter; exports.sqliteAmbientClientConnection = sqliteAmbientClientConnection; exports.sqliteClientConnection = sqliteClientConnection; exports.sqlitePoolClientConnection = sqlitePoolClientConnection; exports.sqliteConnection = sqliteConnection; exports.InMemorySQLiteDatabase = InMemorySQLiteDatabase; exports.DEFAULT_SQLITE_PRAGMA_OPTIONS = DEFAULT_SQLITE_PRAGMA_OPTIONS; exports.isInMemoryDatabase = isInMemoryDatabase; exports.sqliteAmbientConnectionPool = sqliteAmbientConnectionPool; exports.sqliteSingletonConnectionPool = sqliteSingletonConnectionPool; exports.sqliteAlwaysNewConnectionPool = sqliteAlwaysNewConnectionPool; exports.toSqlitePoolOptions = toSqlitePoolOptions; exports.sqlitePool = sqlitePool; exports.DefaultSQLiteMigratorOptions = DefaultSQLiteMigratorOptions; exports.SQLiteDatabaseName = SQLiteDatabaseName;
640
+ //# sourceMappingURL=chunk-5YRHCEUE.cjs.map