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

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 (39) hide show
  1. package/dist/{chunk-4SM4JJJZ.js → chunk-33P5766L.js} +2 -2
  2. package/dist/{chunk-GVR3PSDL.cjs → chunk-4MMMEDQ7.cjs} +180 -85
  3. package/dist/chunk-4MMMEDQ7.cjs.map +1 -0
  4. package/dist/{chunk-CMHMR5VO.js → chunk-6HAHSSPW.js} +158 -168
  5. package/dist/chunk-6HAHSSPW.js.map +1 -0
  6. package/dist/{chunk-UA542GT3.cjs → chunk-GNH5XC6D.cjs} +43 -43
  7. package/dist/{chunk-UA542GT3.cjs.map → chunk-GNH5XC6D.cjs.map} +1 -1
  8. package/dist/{chunk-JKE6SULM.js → chunk-H2JBS7HM.js} +163 -68
  9. package/dist/chunk-H2JBS7HM.js.map +1 -0
  10. package/dist/{chunk-J2S3DPDR.cjs → chunk-JIZGCEPE.cjs} +216 -226
  11. package/dist/chunk-JIZGCEPE.cjs.map +1 -0
  12. package/dist/{chunk-MOPKHYYU.cjs → chunk-NJI6PJFZ.cjs} +6 -6
  13. package/dist/{chunk-MOPKHYYU.cjs.map → chunk-NJI6PJFZ.cjs.map} +1 -1
  14. package/dist/{chunk-HZM7GDOT.cjs → chunk-RQ3KKMTP.cjs} +4 -4
  15. package/dist/{chunk-HZM7GDOT.cjs.map → chunk-RQ3KKMTP.cjs.map} +1 -1
  16. package/dist/{chunk-WLWELSA2.js → chunk-UK7MXVS2.js} +2 -2
  17. package/dist/{chunk-RA2L3FQW.js → chunk-Y5TD53QE.js} +2 -2
  18. package/dist/cloudflare.cjs +60 -60
  19. package/dist/cloudflare.js +3 -3
  20. package/dist/index.cjs +5 -5
  21. package/dist/index.js +3 -3
  22. package/dist/pg.cjs +37 -37
  23. package/dist/pg.js +3 -3
  24. package/dist/postgresql.cjs +4 -4
  25. package/dist/postgresql.js +3 -3
  26. package/dist/sqlite.cjs +4 -4
  27. package/dist/sqlite.d.cts +16 -15
  28. package/dist/sqlite.d.ts +16 -15
  29. package/dist/sqlite.js +3 -3
  30. package/dist/sqlite3.cjs +29 -29
  31. package/dist/sqlite3.js +3 -3
  32. package/package.json +15 -14
  33. package/dist/chunk-CMHMR5VO.js.map +0 -1
  34. package/dist/chunk-GVR3PSDL.cjs.map +0 -1
  35. package/dist/chunk-J2S3DPDR.cjs.map +0 -1
  36. package/dist/chunk-JKE6SULM.js.map +0 -1
  37. /package/dist/{chunk-4SM4JJJZ.js.map → chunk-33P5766L.js.map} +0 -0
  38. /package/dist/{chunk-WLWELSA2.js.map → chunk-UK7MXVS2.js.map} +0 -0
  39. /package/dist/{chunk-RA2L3FQW.js.map → chunk-Y5TD53QE.js.map} +0 -0
@@ -30,7 +30,7 @@
30
30
 
31
31
 
32
32
 
33
- var _chunkGVR3PSDLcjs = require('./chunk-GVR3PSDL.cjs');
33
+ var _chunk4MMMEDQ7cjs = require('./chunk-4MMMEDQ7.cjs');
34
34
 
35
35
  // src/storage/sqlite/core/errors/errorMapper.ts
36
36
  var getSqliteErrorCode = (error) => {
@@ -44,20 +44,20 @@ var asError = (error) => error instanceof Error ? error : void 0;
44
44
  var mapConstraintError = (message, innerError) => {
45
45
  const upperMessage = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _ => _.toUpperCase, 'call', _2 => _2()]), () => ( ""));
46
46
  if (upperMessage.includes("UNIQUE") || upperMessage.includes("PRIMARY KEY"))
47
- return new (0, _chunkGVR3PSDLcjs.UniqueConstraintError)(message, innerError);
47
+ return new (0, _chunk4MMMEDQ7cjs.UniqueConstraintError)(message, innerError);
48
48
  if (upperMessage.includes("FOREIGN KEY"))
49
- return new (0, _chunkGVR3PSDLcjs.ForeignKeyViolationError)(message, innerError);
49
+ return new (0, _chunk4MMMEDQ7cjs.ForeignKeyViolationError)(message, innerError);
50
50
  if (upperMessage.includes("NOT NULL"))
51
- return new (0, _chunkGVR3PSDLcjs.NotNullViolationError)(message, innerError);
51
+ return new (0, _chunk4MMMEDQ7cjs.NotNullViolationError)(message, innerError);
52
52
  if (upperMessage.includes("CHECK"))
53
- return new (0, _chunkGVR3PSDLcjs.CheckViolationError)(message, innerError);
54
- return new (0, _chunkGVR3PSDLcjs.IntegrityConstraintViolationError)(message, innerError);
53
+ return new (0, _chunk4MMMEDQ7cjs.CheckViolationError)(message, innerError);
54
+ return new (0, _chunk4MMMEDQ7cjs.IntegrityConstraintViolationError)(message, innerError);
55
55
  };
56
56
  var mapSqliteError = (error) => {
57
- if (_chunkGVR3PSDLcjs.DumboError.isInstanceOf(error)) return error;
57
+ if (_chunk4MMMEDQ7cjs.DumboError.isInstanceOf(error)) return error;
58
58
  const code = getSqliteErrorCode(error);
59
59
  if (!code)
60
- return new (0, _chunkGVR3PSDLcjs.DumboError)({
60
+ return new (0, _chunk4MMMEDQ7cjs.DumboError)({
61
61
  errorCode: 500,
62
62
  message: getErrorMessage(error),
63
63
  innerError: asError(error)
@@ -72,78 +72,78 @@ var mapSqliteError = (error) => {
72
72
  // ── Busy / lock contention ──
73
73
  // SQLITE_BUSY (5): conflict with a separate database connection
74
74
  case "SQLITE_BUSY":
75
- return new (0, _chunkGVR3PSDLcjs.LockNotAvailableError)(message, innerError);
75
+ return new (0, _chunk4MMMEDQ7cjs.LockNotAvailableError)(message, innerError);
76
76
  // SQLITE_LOCKED (6): conflict within the same connection or shared cache
77
77
  case "SQLITE_LOCKED":
78
- return new (0, _chunkGVR3PSDLcjs.DeadlockError)(message, innerError);
78
+ return new (0, _chunk4MMMEDQ7cjs.DeadlockError)(message, innerError);
79
79
  // SQLITE_PROTOCOL (15): WAL locking race condition
80
80
  case "SQLITE_PROTOCOL":
81
- return new (0, _chunkGVR3PSDLcjs.LockNotAvailableError)(message, innerError);
81
+ return new (0, _chunk4MMMEDQ7cjs.LockNotAvailableError)(message, innerError);
82
82
  // ── Connection / open errors ──
83
83
  // SQLITE_CANTOPEN (14): unable to open database file
84
84
  case "SQLITE_CANTOPEN":
85
- return new (0, _chunkGVR3PSDLcjs.ConnectionError)(message, innerError);
85
+ return new (0, _chunk4MMMEDQ7cjs.ConnectionError)(message, innerError);
86
86
  // SQLITE_NOTADB (26): file is not a database
87
87
  case "SQLITE_NOTADB":
88
- return new (0, _chunkGVR3PSDLcjs.ConnectionError)(message, innerError);
88
+ return new (0, _chunk4MMMEDQ7cjs.ConnectionError)(message, innerError);
89
89
  // ── Resource exhaustion ──
90
90
  // SQLITE_NOMEM (7): out of memory
91
91
  case "SQLITE_NOMEM":
92
- return new (0, _chunkGVR3PSDLcjs.InsufficientResourcesError)(message, innerError);
92
+ return new (0, _chunk4MMMEDQ7cjs.InsufficientResourcesError)(message, innerError);
93
93
  // SQLITE_FULL (13): disk full
94
94
  case "SQLITE_FULL":
95
- return new (0, _chunkGVR3PSDLcjs.InsufficientResourcesError)(message, innerError);
95
+ return new (0, _chunk4MMMEDQ7cjs.InsufficientResourcesError)(message, innerError);
96
96
  // ── System / I/O errors ──
97
97
  // SQLITE_IOERR (10): operating system I/O error
98
98
  case "SQLITE_IOERR":
99
- return new (0, _chunkGVR3PSDLcjs.SystemError)(message, innerError);
99
+ return new (0, _chunk4MMMEDQ7cjs.SystemError)(message, innerError);
100
100
  // SQLITE_CORRUPT (11): database file is corrupted
101
101
  case "SQLITE_CORRUPT":
102
- return new (0, _chunkGVR3PSDLcjs.SystemError)(message, innerError);
102
+ return new (0, _chunk4MMMEDQ7cjs.SystemError)(message, innerError);
103
103
  // SQLITE_INTERNAL (2): internal SQLite malfunction
104
104
  case "SQLITE_INTERNAL":
105
- return new (0, _chunkGVR3PSDLcjs.SystemError)(message, innerError);
105
+ return new (0, _chunk4MMMEDQ7cjs.SystemError)(message, innerError);
106
106
  // SQLITE_NOLFS (22): large file support unavailable
107
107
  case "SQLITE_NOLFS":
108
- return new (0, _chunkGVR3PSDLcjs.SystemError)(message, innerError);
108
+ return new (0, _chunk4MMMEDQ7cjs.SystemError)(message, innerError);
109
109
  // ── Data errors ──
110
110
  // SQLITE_TOOBIG (18): string or BLOB too large
111
111
  case "SQLITE_TOOBIG":
112
- return new (0, _chunkGVR3PSDLcjs.DataError)(message, innerError);
112
+ return new (0, _chunk4MMMEDQ7cjs.DataError)(message, innerError);
113
113
  // SQLITE_MISMATCH (20): datatype mismatch
114
114
  case "SQLITE_MISMATCH":
115
- return new (0, _chunkGVR3PSDLcjs.DataError)(message, innerError);
115
+ return new (0, _chunk4MMMEDQ7cjs.DataError)(message, innerError);
116
116
  // SQLITE_RANGE (25): bind parameter index out of range
117
117
  case "SQLITE_RANGE":
118
- return new (0, _chunkGVR3PSDLcjs.DataError)(message, innerError);
118
+ return new (0, _chunk4MMMEDQ7cjs.DataError)(message, innerError);
119
119
  // ── Invalid operations ──
120
120
  // SQLITE_ERROR (1): generic SQL error (syntax errors, missing tables, etc.)
121
121
  case "SQLITE_ERROR":
122
- return new (0, _chunkGVR3PSDLcjs.InvalidOperationError)(message, innerError);
122
+ return new (0, _chunk4MMMEDQ7cjs.InvalidOperationError)(message, innerError);
123
123
  // SQLITE_READONLY (8): attempt to write to a read-only database
124
124
  case "SQLITE_READONLY":
125
- return new (0, _chunkGVR3PSDLcjs.InvalidOperationError)(message, innerError);
125
+ return new (0, _chunk4MMMEDQ7cjs.InvalidOperationError)(message, innerError);
126
126
  // SQLITE_MISUSE (21): API misuse
127
127
  case "SQLITE_MISUSE":
128
- return new (0, _chunkGVR3PSDLcjs.InvalidOperationError)(message, innerError);
128
+ return new (0, _chunk4MMMEDQ7cjs.InvalidOperationError)(message, innerError);
129
129
  // SQLITE_AUTH (23): authorization denied
130
130
  case "SQLITE_AUTH":
131
- return new (0, _chunkGVR3PSDLcjs.InvalidOperationError)(message, innerError);
131
+ return new (0, _chunk4MMMEDQ7cjs.InvalidOperationError)(message, innerError);
132
132
  // SQLITE_PERM (3): access permission denied
133
133
  case "SQLITE_PERM":
134
- return new (0, _chunkGVR3PSDLcjs.InvalidOperationError)(message, innerError);
134
+ return new (0, _chunk4MMMEDQ7cjs.InvalidOperationError)(message, innerError);
135
135
  // SQLITE_SCHEMA (17): schema changed, statement needs re-preparation
136
136
  case "SQLITE_SCHEMA":
137
- return new (0, _chunkGVR3PSDLcjs.InvalidOperationError)(message, innerError);
137
+ return new (0, _chunk4MMMEDQ7cjs.InvalidOperationError)(message, innerError);
138
138
  // ── Transaction / abort ──
139
139
  // SQLITE_ABORT (4): operation aborted (e.g. by rollback)
140
140
  case "SQLITE_ABORT":
141
- return new (0, _chunkGVR3PSDLcjs.SerializationError)(message, innerError);
141
+ return new (0, _chunk4MMMEDQ7cjs.SerializationError)(message, innerError);
142
142
  // SQLITE_INTERRUPT (9): operation interrupted
143
143
  case "SQLITE_INTERRUPT":
144
- return new (0, _chunkGVR3PSDLcjs.SerializationError)(message, innerError);
144
+ return new (0, _chunk4MMMEDQ7cjs.SerializationError)(message, innerError);
145
145
  }
146
- return new (0, _chunkGVR3PSDLcjs.DumboError)({
146
+ return new (0, _chunk4MMMEDQ7cjs.DumboError)({
147
147
  errorCode: 500,
148
148
  message,
149
149
  innerError
@@ -189,16 +189,16 @@ var mapColumnType = (token, { builder }) => {
189
189
  }
190
190
  builder.addSQL(columnSQL);
191
191
  };
192
- var sqliteColumnProcessors = _chunkGVR3PSDLcjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
192
+ var sqliteColumnProcessors = _chunk4MMMEDQ7cjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
193
193
 
194
194
  // src/storage/sqlite/core/sql/formatter/index.ts
195
- var sqliteSQLProcessorsRegistry = _chunkGVR3PSDLcjs.SQLProcessorsRegistry.call(void 0, {
196
- from: _chunkGVR3PSDLcjs.defaultProcessorsRegistry
195
+ var sqliteSQLProcessorsRegistry = _chunk4MMMEDQ7cjs.SQLProcessorsRegistry.call(void 0, {
196
+ from: _chunk4MMMEDQ7cjs.defaultProcessorsRegistry
197
197
  }).register(sqliteColumnProcessors);
198
- var sqliteFormatter = _chunkGVR3PSDLcjs.SQLFormatter.call(void 0, {
198
+ var sqliteFormatter = _chunk4MMMEDQ7cjs.SQLFormatter.call(void 0, {
199
199
  processorsRegistry: sqliteSQLProcessorsRegistry
200
200
  });
201
- _chunkGVR3PSDLcjs.registerFormatter.call(void 0, "SQLite", sqliteFormatter);
201
+ _chunk4MMMEDQ7cjs.registerFormatter.call(void 0, "SQLite", sqliteFormatter);
202
202
 
203
203
  // src/storage/sqlite/core/execute/execute.ts
204
204
  var sqliteExecute = async (database, handle) => {
@@ -211,7 +211,7 @@ var sqliteExecute = async (database, handle) => {
211
211
  var sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
212
212
  driverType,
213
213
  query: async (client, sql, options) => {
214
- _chunkGVR3PSDLcjs.tracer.info("db:sql:query", {
214
+ _chunk4MMMEDQ7cjs.tracer.info("db:sql:query", {
215
215
  query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).query,
216
216
  params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).params,
217
217
  debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql, { serializer })
@@ -222,13 +222,13 @@ var sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
222
222
  result = {
223
223
  ...result,
224
224
  rows: result.rows.map(
225
- (row) => _chunkGVR3PSDLcjs.mapSQLQueryResult.call(void 0, row, options.mapping)
225
+ (row) => _chunk4MMMEDQ7cjs.mapSQLQueryResult.call(void 0, row, options.mapping)
226
226
  )
227
227
  };
228
228
  }
229
229
  return result;
230
230
  } catch (error) {
231
- _chunkGVR3PSDLcjs.tracer.error("db:sql:query:execute:error", { error });
231
+ _chunk4MMMEDQ7cjs.tracer.error("db:sql:query:execute:error", { error });
232
232
  throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
233
233
  }
234
234
  },
@@ -239,18 +239,18 @@ var sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
239
239
  return results.map((result) => ({
240
240
  ...result,
241
241
  rows: result.rows.map(
242
- (row) => _chunkGVR3PSDLcjs.mapSQLQueryResult.call(void 0, row, options.mapping)
242
+ (row) => _chunk4MMMEDQ7cjs.mapSQLQueryResult.call(void 0, row, options.mapping)
243
243
  )
244
244
  }));
245
245
  }
246
246
  return results;
247
247
  } catch (error) {
248
- _chunkGVR3PSDLcjs.tracer.error("db:sql:batch_query:execute:error", { error });
248
+ _chunk4MMMEDQ7cjs.tracer.error("db:sql:batch_query:execute:error", { error });
249
249
  throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
250
250
  }
251
251
  },
252
252
  command: async (client, sql, options) => {
253
- _chunkGVR3PSDLcjs.tracer.info("db:sql:command", {
253
+ _chunk4MMMEDQ7cjs.tracer.info("db:sql:command", {
254
254
  query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).query,
255
255
  params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).params,
256
256
  debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql, { serializer })
@@ -258,7 +258,7 @@ var sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
258
258
  try {
259
259
  return await client.command(sql, options);
260
260
  } catch (error) {
261
- _chunkGVR3PSDLcjs.tracer.error("db:sql:command:execute:error", { error });
261
+ _chunk4MMMEDQ7cjs.tracer.error("db:sql:command:execute:error", { error });
262
262
  throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
263
263
  }
264
264
  },
@@ -266,173 +266,13 @@ var sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
266
266
  try {
267
267
  return await client.batchCommand(sqls, options);
268
268
  } catch (error) {
269
- _chunkGVR3PSDLcjs.tracer.error("db:sql:batch_command:execute:error", { error });
269
+ _chunk4MMMEDQ7cjs.tracer.error("db:sql:batch_command:execute:error", { error });
270
270
  throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
271
271
  }
272
272
  },
273
273
  formatter: _nullishCoalesce(formatter, () => ( sqliteFormatter))
274
274
  });
275
275
 
276
- // src/storage/sqlite/core/pool/dualPool.ts
277
- var _os = require('os');
278
- var sqliteDualConnectionPool = (options) => {
279
- const { sqliteConnectionFactory, connectionOptions } = options;
280
- const readerPoolSize = _nullishCoalesce(options.readerPoolSize, () => ( Math.max(4, _os.cpus.call(void 0, ).length)));
281
- let databaseInitPromise = null;
282
- const initTaskProcessor = new (0, _chunkGVR3PSDLcjs.TaskProcessor)({
283
- maxActiveTasks: 1,
284
- maxQueueSize: 1e3
285
- });
286
- const ensureDatabaseInitialized = async (connectionOptions2, retryCount = 0) => {
287
- if (databaseInitPromise !== null) {
288
- return databaseInitPromise;
289
- }
290
- return initTaskProcessor.enqueue(
291
- async ({ ack }) => {
292
- if (databaseInitPromise !== null) {
293
- ack();
294
- return databaseInitPromise;
295
- }
296
- const initConnection = sqliteConnectionFactory({
297
- ...connectionOptions2,
298
- skipDatabasePragmas: false,
299
- readonly: false
300
- });
301
- const initPromise = initConnection.open();
302
- databaseInitPromise = initPromise;
303
- try {
304
- await initPromise;
305
- await initConnection.close();
306
- ack();
307
- } catch (error) {
308
- databaseInitPromise = null;
309
- await initConnection.close();
310
- ack();
311
- if (retryCount < 3) {
312
- return ensureDatabaseInitialized(connectionOptions2, retryCount + 1);
313
- }
314
- throw mapSqliteError(error);
315
- }
316
- },
317
- { taskGroupId: "db-init" }
318
- );
319
- };
320
- const wrappedConnectionFactory = async (readonly, connectionOptions2) => {
321
- await ensureDatabaseInitialized(connectionOptions2);
322
- const connection = sqliteConnectionFactory({
323
- ...connectionOptions2,
324
- skipDatabasePragmas: true,
325
- readonly
326
- });
327
- await connection.open();
328
- return connection;
329
- };
330
- const writerPool = _chunkGVR3PSDLcjs.createSingletonConnectionPool.call(void 0, {
331
- driverType: options.driverType,
332
- getConnection: () => wrappedConnectionFactory(false, connectionOptions)
333
- });
334
- const readerPool = _chunkGVR3PSDLcjs.createBoundedConnectionPool.call(void 0, {
335
- driverType: options.driverType,
336
- getConnection: () => wrappedConnectionFactory(true, connectionOptions),
337
- maxConnections: readerPoolSize
338
- });
339
- return {
340
- driverType: options.driverType,
341
- connection: (connectionOptions2) => _optionalChain([connectionOptions2, 'optionalAccess', _5 => _5.readonly]) ? readerPool.connection(connectionOptions2) : writerPool.connection(connectionOptions2),
342
- execute: {
343
- query: (...args) => readerPool.execute.query(...args),
344
- batchQuery: (...args) => readerPool.execute.batchQuery(...args),
345
- command: (...args) => writerPool.execute.command(...args),
346
- batchCommand: (...args) => writerPool.execute.batchCommand(...args)
347
- },
348
- withConnection: (handle, connectionOptions2) => _optionalChain([connectionOptions2, 'optionalAccess', _6 => _6.readonly]) ? readerPool.withConnection(handle, connectionOptions2) : writerPool.withConnection(handle, connectionOptions2),
349
- transaction: writerPool.transaction,
350
- withTransaction: writerPool.withTransaction,
351
- close: () => Promise.all([writerPool.close(), readerPool.close()]).then(() => {
352
- })
353
- };
354
- };
355
-
356
- // src/storage/sqlite/core/pool/pool.ts
357
- var isInMemoryDatabase = (options) => {
358
- if ("fileName" in options) {
359
- return options.fileName === InMemorySQLiteDatabase;
360
- }
361
- if ("connectionString" in options) {
362
- return options.connectionString === InMemorySQLiteDatabase;
363
- }
364
- return false;
365
- };
366
- var sqliteAmbientConnectionPool = (options) => {
367
- const { connection, driverType } = options;
368
- return _chunkGVR3PSDLcjs.createAmbientConnectionPool.call(void 0, {
369
- driverType,
370
- connection
371
- });
372
- };
373
- var sqliteSingletonConnectionPool = (options) => {
374
- const { driverType, sqliteConnectionFactory, connectionOptions } = options;
375
- return _chunkGVR3PSDLcjs.createSingletonConnectionPool.call(void 0, {
376
- driverType,
377
- getConnection: () => sqliteConnectionFactory(connectionOptions)
378
- });
379
- };
380
- var sqliteAlwaysNewConnectionPool = (options) => {
381
- const { driverType, sqliteConnectionFactory, connectionOptions } = options;
382
- return _chunkGVR3PSDLcjs.createAlwaysNewConnectionPool.call(void 0, {
383
- driverType,
384
- getConnection: () => sqliteConnectionFactory(connectionOptions)
385
- });
386
- };
387
- var toSqlitePoolOptions = (options) => {
388
- const { singleton, ...rest } = options;
389
- const isInMemory = isInMemoryDatabase(options);
390
- if ("client" in options && options.client) {
391
- return { ...rest, singleton: true };
392
- }
393
- if (isInMemory) {
394
- return { ...rest, singleton: true };
395
- }
396
- if (singleton === true) {
397
- return { ...rest, singleton: true };
398
- }
399
- return { ...rest, dual: true };
400
- };
401
- function sqlitePool(options) {
402
- const { driverType } = options;
403
- if (options.connection)
404
- return _chunkGVR3PSDLcjs.createAmbientConnectionPool.call(void 0, {
405
- driverType,
406
- connection: options.connection
407
- });
408
- if ("dual" in options && options.dual) {
409
- return sqliteDualConnectionPool(
410
- options
411
- );
412
- }
413
- if (options.singleton === true && options.sqliteConnectionFactory) {
414
- return _chunkGVR3PSDLcjs.createSingletonConnectionPool.call(void 0, {
415
- driverType,
416
- getConnection: () => options.sqliteConnectionFactory(
417
- options.connectionOptions
418
- )
419
- });
420
- }
421
- return _chunkGVR3PSDLcjs.createAlwaysNewConnectionPool.call(void 0, {
422
- driverType,
423
- getConnection: () => options.sqliteConnectionFactory(
424
- options.connectionOptions
425
- )
426
- });
427
- }
428
-
429
- // src/storage/sqlite/core/schema/migrations.ts
430
- var DefaultSQLiteMigratorOptions = {};
431
- _chunkGVR3PSDLcjs.registerDefaultMigratorOptions.call(void 0, "SQLite", DefaultSQLiteMigratorOptions);
432
-
433
- // src/storage/sqlite/core/index.ts
434
- var SQLiteDatabaseName = "SQLite";
435
-
436
276
  // src/storage/sqlite/core/connections/connectionString.ts
437
277
  var SQLiteConnectionString = (connectionString) => {
438
278
  if (!connectionString.startsWith("file:") && connectionString !== ":memory:" && !connectionString.startsWith("/") && !connectionString.startsWith("./")) {
@@ -519,7 +359,7 @@ var sqliteAmbientClientConnection = (options) => {
519
359
  serializer,
520
360
  errorMapper
521
361
  } = options;
522
- return _chunkGVR3PSDLcjs.createAmbientConnection.call(void 0, {
362
+ return _chunk4MMMEDQ7cjs.createAmbientConnection.call(void 0, {
523
363
  driverType,
524
364
  client,
525
365
  initTransaction: _nullishCoalesce(initTransaction, () => ( ((connection) => sqliteTransaction(
@@ -548,7 +388,7 @@ var sqliteClientConnection = (options) => {
548
388
  }
549
389
  return client;
550
390
  };
551
- return _chunkGVR3PSDLcjs.createConnection.call(void 0, {
391
+ return _chunk4MMMEDQ7cjs.createConnection.call(void 0, {
552
392
  driverType: options.driverType,
553
393
  connect,
554
394
  close: async () => {
@@ -560,7 +400,7 @@ var sqliteClientConnection = (options) => {
560
400
  initTransaction: (connection) => sqliteTransaction(
561
401
  options.driverType,
562
402
  connection,
563
- _nullishCoalesce(_optionalChain([connectionOptions, 'access', _7 => _7.transactionOptions, 'optionalAccess', _8 => _8.allowNestedTransactions]), () => ( false)),
403
+ _nullishCoalesce(_optionalChain([connectionOptions, 'access', _5 => _5.transactionOptions, 'optionalAccess', _6 => _6.allowNestedTransactions]), () => ( false)),
564
404
  serializer,
565
405
  connectionOptions.defaultTransactionMode
566
406
  ),
@@ -581,14 +421,14 @@ var sqlitePoolClientConnection = (options) => {
581
421
  }
582
422
  return client;
583
423
  };
584
- return _chunkGVR3PSDLcjs.createConnection.call(void 0, {
424
+ return _chunk4MMMEDQ7cjs.createConnection.call(void 0, {
585
425
  driverType: options.driverType,
586
426
  connect,
587
427
  close: () => client !== null ? Promise.resolve(client.release()) : Promise.resolve(),
588
428
  initTransaction: (connection) => sqliteTransaction(
589
429
  options.driverType,
590
430
  connection,
591
- _nullishCoalesce(_optionalChain([connectionOptions, 'access', _9 => _9.transactionOptions, 'optionalAccess', _10 => _10.allowNestedTransactions]), () => ( false)),
431
+ _nullishCoalesce(_optionalChain([connectionOptions, 'access', _7 => _7.transactionOptions, 'optionalAccess', _8 => _8.allowNestedTransactions]), () => ( false)),
592
432
  serializer,
593
433
  connectionOptions.defaultTransactionMode
594
434
  ),
@@ -613,7 +453,7 @@ var DEFAULT_SQLITE_PRAGMA_OPTIONS = {
613
453
  // src/storage/sqlite/core/transactions/index.ts
614
454
  var sqliteTransaction = (driverType, connection, allowNestedTransactions, serializer, defaultTransactionMode) => (getClient, options) => {
615
455
  const transactionCounter = transactionNestingCounter();
616
- allowNestedTransactions = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.allowNestedTransactions]), () => ( allowNestedTransactions));
456
+ allowNestedTransactions = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.allowNestedTransactions]), () => ( allowNestedTransactions));
617
457
  const transaction = {
618
458
  connection: connection(),
619
459
  driverType,
@@ -622,26 +462,26 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
622
462
  if (allowNestedTransactions) {
623
463
  if (transactionCounter.level >= 1) {
624
464
  transactionCounter.increment();
625
- if (_optionalChain([options, 'optionalAccess', _12 => _12.useSavepoints])) {
626
- await client.query(
627
- _chunkGVR3PSDLcjs.SQL`SAVEPOINT transaction${_chunkGVR3PSDLcjs.SQL.plain(transactionCounter.level.toString())}`
465
+ if (_optionalChain([options, 'optionalAccess', _10 => _10.useSavepoints])) {
466
+ await client.command(
467
+ _chunk4MMMEDQ7cjs.SQL`SAVEPOINT transaction${_chunk4MMMEDQ7cjs.SQL.plain(transactionCounter.level.toString())}`
628
468
  );
629
469
  }
630
470
  return;
631
471
  }
632
472
  transactionCounter.increment();
633
473
  }
634
- const mode = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.mode]), () => ( defaultTransactionMode)), () => ( "IMMEDIATE"));
635
- await client.query(_chunkGVR3PSDLcjs.SQL`BEGIN ${_chunkGVR3PSDLcjs.SQL.plain(mode)} TRANSACTION`);
474
+ const mode = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.mode]), () => ( defaultTransactionMode)), () => ( "IMMEDIATE"));
475
+ await client.command(_chunk4MMMEDQ7cjs.SQL`BEGIN ${_chunk4MMMEDQ7cjs.SQL.plain(mode)} TRANSACTION`);
636
476
  },
637
477
  commit: async function() {
638
478
  const client = await getClient;
639
479
  try {
640
480
  if (allowNestedTransactions) {
641
481
  if (transactionCounter.level > 1) {
642
- if (_optionalChain([options, 'optionalAccess', _14 => _14.useSavepoints])) {
643
- await client.query(
644
- _chunkGVR3PSDLcjs.SQL`RELEASE transaction${_chunkGVR3PSDLcjs.SQL.plain(transactionCounter.level.toString())}`
482
+ if (_optionalChain([options, 'optionalAccess', _12 => _12.useSavepoints])) {
483
+ await client.command(
484
+ _chunk4MMMEDQ7cjs.SQL`RELEASE transaction${_chunk4MMMEDQ7cjs.SQL.plain(transactionCounter.level.toString())}`
645
485
  );
646
486
  }
647
487
  transactionCounter.decrement();
@@ -649,10 +489,10 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
649
489
  }
650
490
  transactionCounter.reset();
651
491
  }
652
- await client.query(_chunkGVR3PSDLcjs.SQL`COMMIT`);
492
+ await client.command(_chunk4MMMEDQ7cjs.SQL`COMMIT`);
653
493
  } finally {
654
- if (_optionalChain([options, 'optionalAccess', _15 => _15.close]))
655
- await _optionalChain([options, 'optionalAccess', _16 => _16.close, 'call', _17 => _17(
494
+ if (_optionalChain([options, 'optionalAccess', _13 => _13.close]))
495
+ await _optionalChain([options, 'optionalAccess', _14 => _14.close, 'call', _15 => _15(
656
496
  client
657
497
  )]);
658
498
  }
@@ -666,16 +506,16 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
666
506
  return;
667
507
  }
668
508
  }
669
- await client.query(_chunkGVR3PSDLcjs.SQL`ROLLBACK`);
509
+ await client.command(_chunk4MMMEDQ7cjs.SQL`ROLLBACK`);
670
510
  } finally {
671
- if (_optionalChain([options, 'optionalAccess', _18 => _18.close]))
672
- await _optionalChain([options, 'optionalAccess', _19 => _19.close, 'call', _20 => _20(
511
+ if (_optionalChain([options, 'optionalAccess', _16 => _16.close]))
512
+ await _optionalChain([options, 'optionalAccess', _17 => _17.close, 'call', _18 => _18(
673
513
  client,
674
514
  error
675
515
  )]);
676
516
  }
677
517
  },
678
- execute: _chunkGVR3PSDLcjs.sqlExecutor.call(void 0, sqliteSQLExecutor(driverType, serializer), {
518
+ execute: _chunk4MMMEDQ7cjs.sqlExecutor.call(void 0, sqliteSQLExecutor(driverType, serializer), {
679
519
  connect: () => getClient
680
520
  }),
681
521
  _transactionOptions: _nullishCoalesce(options, () => ( {}))
@@ -683,6 +523,156 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
683
523
  return transaction;
684
524
  };
685
525
 
526
+ // src/storage/sqlite/core/pool/dualPool.ts
527
+ var _os = require('os');
528
+ var sqliteDualConnectionPool = (options) => {
529
+ const { sqliteConnectionFactory, connectionOptions } = options;
530
+ const readerPoolSize = _nullishCoalesce(options.readerPoolSize, () => ( Math.max(4, _os.cpus.call(void 0, ).length)));
531
+ let databaseInitPromise = null;
532
+ const guardSingleConnection = _chunk4MMMEDQ7cjs.guardInitializedOnce.call(void 0, async () => {
533
+ if (databaseInitPromise !== null) {
534
+ return databaseInitPromise;
535
+ }
536
+ const initConnection = sqliteConnectionFactory({
537
+ ...connectionOptions,
538
+ skipDatabasePragmas: false,
539
+ readonly: false
540
+ });
541
+ const initPromise = initConnection.open();
542
+ databaseInitPromise = initPromise;
543
+ try {
544
+ await initPromise;
545
+ await initConnection.close();
546
+ } catch (error) {
547
+ databaseInitPromise = null;
548
+ await initConnection.close();
549
+ throw mapSqliteError(error);
550
+ }
551
+ });
552
+ const ensureDatabaseInitialized = async () => {
553
+ if (databaseInitPromise !== null) {
554
+ return databaseInitPromise;
555
+ }
556
+ return guardSingleConnection.ensureInitialized();
557
+ };
558
+ const wrappedConnectionFactory = async (readonly, connectionOptions2) => {
559
+ await ensureDatabaseInitialized();
560
+ const connection = sqliteConnectionFactory({
561
+ ...connectionOptions2,
562
+ skipDatabasePragmas: true,
563
+ readonly
564
+ });
565
+ await connection.open();
566
+ return connection;
567
+ };
568
+ const writerPool = _chunk4MMMEDQ7cjs.createSingletonConnectionPool.call(void 0, {
569
+ driverType: options.driverType,
570
+ getConnection: () => wrappedConnectionFactory(false, connectionOptions)
571
+ });
572
+ const readerPool = _chunk4MMMEDQ7cjs.createBoundedConnectionPool.call(void 0, {
573
+ driverType: options.driverType,
574
+ getConnection: () => wrappedConnectionFactory(true, connectionOptions),
575
+ maxConnections: readerPoolSize
576
+ });
577
+ return {
578
+ driverType: options.driverType,
579
+ connection: (connectionOptions2) => _optionalChain([connectionOptions2, 'optionalAccess', _19 => _19.readonly]) ? readerPool.connection(connectionOptions2) : writerPool.connection(connectionOptions2),
580
+ execute: {
581
+ query: (...args) => readerPool.execute.query(...args),
582
+ batchQuery: (...args) => readerPool.execute.batchQuery(...args),
583
+ command: (...args) => writerPool.execute.command(...args),
584
+ batchCommand: (...args) => writerPool.execute.batchCommand(...args)
585
+ },
586
+ withConnection: (handle, connectionOptions2) => _optionalChain([connectionOptions2, 'optionalAccess', _20 => _20.readonly]) ? readerPool.withConnection(handle, connectionOptions2) : writerPool.withConnection(handle, connectionOptions2),
587
+ transaction: writerPool.transaction,
588
+ withTransaction: writerPool.withTransaction,
589
+ close: async () => {
590
+ await guardSingleConnection.stop();
591
+ await Promise.all([writerPool.close(), readerPool.close()]);
592
+ }
593
+ };
594
+ };
595
+
596
+ // src/storage/sqlite/core/pool/pool.ts
597
+ var isInMemoryDatabase = (options) => {
598
+ if ("fileName" in options) {
599
+ return options.fileName === InMemorySQLiteDatabase;
600
+ }
601
+ if ("connectionString" in options) {
602
+ return options.connectionString === InMemorySQLiteDatabase;
603
+ }
604
+ return false;
605
+ };
606
+ var sqliteAmbientConnectionPool = (options) => {
607
+ const { connection, driverType } = options;
608
+ return _chunk4MMMEDQ7cjs.createAmbientConnectionPool.call(void 0, {
609
+ driverType,
610
+ connection
611
+ });
612
+ };
613
+ var sqliteSingletonConnectionPool = (options) => {
614
+ const { driverType, sqliteConnectionFactory, connectionOptions } = options;
615
+ return _chunk4MMMEDQ7cjs.createSingletonConnectionPool.call(void 0, {
616
+ driverType,
617
+ getConnection: () => sqliteConnectionFactory(connectionOptions)
618
+ });
619
+ };
620
+ var sqliteAlwaysNewConnectionPool = (options) => {
621
+ const { driverType, sqliteConnectionFactory, connectionOptions } = options;
622
+ return _chunk4MMMEDQ7cjs.createAlwaysNewConnectionPool.call(void 0, {
623
+ driverType,
624
+ getConnection: () => sqliteConnectionFactory(connectionOptions)
625
+ });
626
+ };
627
+ var toSqlitePoolOptions = (options) => {
628
+ const { singleton, ...rest } = options;
629
+ const isInMemory = isInMemoryDatabase(options);
630
+ if ("client" in options && options.client) {
631
+ return { ...rest, singleton: true };
632
+ }
633
+ if (isInMemory) {
634
+ return { ...rest, singleton: true };
635
+ }
636
+ if (singleton === true) {
637
+ return { ...rest, singleton: true };
638
+ }
639
+ return { ...rest, dual: true };
640
+ };
641
+ function sqlitePool(options) {
642
+ const { driverType } = options;
643
+ if (options.connection)
644
+ return _chunk4MMMEDQ7cjs.createAmbientConnectionPool.call(void 0, {
645
+ driverType,
646
+ connection: options.connection
647
+ });
648
+ if ("dual" in options && options.dual) {
649
+ return sqliteDualConnectionPool(
650
+ options
651
+ );
652
+ }
653
+ if (options.singleton === true && options.sqliteConnectionFactory) {
654
+ return _chunk4MMMEDQ7cjs.createSingletonConnectionPool.call(void 0, {
655
+ driverType,
656
+ getConnection: () => options.sqliteConnectionFactory(
657
+ options.connectionOptions
658
+ )
659
+ });
660
+ }
661
+ return _chunk4MMMEDQ7cjs.createAlwaysNewConnectionPool.call(void 0, {
662
+ driverType,
663
+ getConnection: () => options.sqliteConnectionFactory(
664
+ options.connectionOptions
665
+ )
666
+ });
667
+ }
668
+
669
+ // src/storage/sqlite/core/schema/migrations.ts
670
+ var DefaultSQLiteMigratorOptions = {};
671
+ _chunk4MMMEDQ7cjs.registerDefaultMigratorOptions.call(void 0, "SQLite", DefaultSQLiteMigratorOptions);
672
+
673
+ // src/storage/sqlite/core/index.ts
674
+ var SQLiteDatabaseName = "SQLite";
675
+
686
676
 
687
677
 
688
678
 
@@ -708,4 +698,4 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
708
698
 
709
699
 
710
700
  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;
711
- //# sourceMappingURL=chunk-J2S3DPDR.cjs.map
701
+ //# sourceMappingURL=chunk-JIZGCEPE.cjs.map