@event-driven-io/dumbo 0.13.0-beta.21 → 0.13.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-FC4JR2R3.js → chunk-56QRSCG5.js} +2 -2
- package/dist/{chunk-65DKXURG.js → chunk-5OX6NE4Z.js} +2 -2
- package/dist/{chunk-IVJ3SNPJ.js → chunk-5SCFH2HY.js} +2 -2
- package/dist/{chunk-AMACBMAZ.cjs → chunk-7D7WADBK.cjs} +186 -98
- package/dist/chunk-7D7WADBK.cjs.map +1 -0
- package/dist/{chunk-H7ZKIJHB.cjs → chunk-7RMJPFU5.cjs} +6 -6
- package/dist/{chunk-H7ZKIJHB.cjs.map → chunk-7RMJPFU5.cjs.map} +1 -1
- package/dist/{chunk-7WEBHXZD.cjs → chunk-HXQYRDCR.cjs} +43 -43
- package/dist/{chunk-7WEBHXZD.cjs.map → chunk-HXQYRDCR.cjs.map} +1 -1
- package/dist/{chunk-T4A6BQRA.js → chunk-LPIIB75Q.js} +120 -32
- package/dist/chunk-LPIIB75Q.js.map +1 -0
- package/dist/{chunk-XO5T5N5S.js → chunk-QUAG4MBP.js} +294 -14
- package/dist/chunk-QUAG4MBP.js.map +1 -0
- package/dist/{chunk-XOQHZABK.cjs → chunk-QVEVSWG6.cjs} +307 -27
- package/dist/chunk-QVEVSWG6.cjs.map +1 -0
- package/dist/{chunk-R7P7CNMK.cjs → chunk-TMFEMKPE.cjs} +4 -4
- package/dist/{chunk-R7P7CNMK.cjs.map → chunk-TMFEMKPE.cjs.map} +1 -1
- package/dist/cloudflare.cjs +66 -61
- package/dist/cloudflare.cjs.map +1 -1
- package/dist/cloudflare.d.cts +4 -4
- package/dist/cloudflare.d.ts +4 -4
- package/dist/cloudflare.js +9 -4
- package/dist/cloudflare.js.map +1 -1
- package/dist/{columnProcessors-Difrrk4c.d.cts → columnProcessors-CsQjv8si.d.cts} +1 -1
- package/dist/{columnProcessors-C7fRa54L.d.ts → columnProcessors-giHzjHuv.d.ts} +1 -1
- package/dist/{connectionString-oeg1LD5V.d.ts → connectionString-J4yRT71A.d.cts} +40 -31
- package/dist/{connectionString-oeg1LD5V.d.cts → connectionString-J4yRT71A.d.ts} +40 -31
- package/dist/index.cjs +7 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +39 -38
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +7 -7
- package/dist/pg.d.ts +7 -7
- package/dist/pg.js +5 -4
- package/dist/pg.js.map +1 -1
- package/dist/postgresql.cjs +4 -4
- package/dist/postgresql.d.cts +2 -2
- package/dist/postgresql.d.ts +2 -2
- package/dist/postgresql.js +3 -3
- package/dist/sqlite.cjs +8 -4
- package/dist/sqlite.cjs.map +1 -1
- package/dist/sqlite.d.cts +49 -23
- package/dist/sqlite.d.ts +49 -23
- package/dist/sqlite.js +7 -3
- package/dist/sqlite3.cjs +65 -28
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +11 -11
- package/dist/sqlite3.d.ts +11 -11
- package/dist/sqlite3.js +48 -11
- package/dist/sqlite3.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AMACBMAZ.cjs.map +0 -1
- package/dist/chunk-T4A6BQRA.js.map +0 -1
- package/dist/chunk-XO5T5N5S.js.map +0 -1
- package/dist/chunk-XOQHZABK.cjs.map +0 -1
- /package/dist/{chunk-FC4JR2R3.js.map → chunk-56QRSCG5.js.map} +0 -0
- /package/dist/{chunk-65DKXURG.js.map → chunk-5OX6NE4Z.js.map} +0 -0
- /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-
|
|
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-
|
|
83
|
+
//# sourceMappingURL=chunk-56QRSCG5.js.map
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
registerDefaultMigratorOptions,
|
|
29
29
|
registerFormatter,
|
|
30
30
|
single
|
|
31
|
-
} from "./chunk-
|
|
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-
|
|
481
|
+
//# sourceMappingURL=chunk-5OX6NE4Z.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SQL,
|
|
3
3
|
exists
|
|
4
|
-
} from "./chunk-
|
|
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-
|
|
34
|
+
//# sourceMappingURL=chunk-5SCFH2HY.js.map
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
|
|
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,
|
|
46
|
+
return new (0, _chunkQVEVSWG6cjs.UniqueConstraintError)(message, innerError);
|
|
46
47
|
if (upperMessage.includes("FOREIGN KEY"))
|
|
47
|
-
return new (0,
|
|
48
|
+
return new (0, _chunkQVEVSWG6cjs.ForeignKeyViolationError)(message, innerError);
|
|
48
49
|
if (upperMessage.includes("NOT NULL"))
|
|
49
|
-
return new (0,
|
|
50
|
+
return new (0, _chunkQVEVSWG6cjs.NotNullViolationError)(message, innerError);
|
|
50
51
|
if (upperMessage.includes("CHECK"))
|
|
51
|
-
return new (0,
|
|
52
|
-
return new (0,
|
|
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 (
|
|
56
|
+
if (_chunkQVEVSWG6cjs.DumboError.isInstanceOf(error)) return error;
|
|
56
57
|
const code = getSqliteErrorCode(error);
|
|
57
58
|
if (!code)
|
|
58
|
-
return new (0,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
91
|
+
return new (0, _chunkQVEVSWG6cjs.InsufficientResourcesError)(message, innerError);
|
|
91
92
|
// SQLITE_FULL (13): disk full
|
|
92
93
|
case "SQLITE_FULL":
|
|
93
|
-
return new (0,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
111
|
+
return new (0, _chunkQVEVSWG6cjs.DataError)(message, innerError);
|
|
111
112
|
// SQLITE_MISMATCH (20): datatype mismatch
|
|
112
113
|
case "SQLITE_MISMATCH":
|
|
113
|
-
return new (0,
|
|
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,
|
|
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,
|
|
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,
|
|
124
|
+
return new (0, _chunkQVEVSWG6cjs.InvalidOperationError)(message, innerError);
|
|
124
125
|
// SQLITE_MISUSE (21): API misuse
|
|
125
126
|
case "SQLITE_MISUSE":
|
|
126
|
-
return new (0,
|
|
127
|
+
return new (0, _chunkQVEVSWG6cjs.InvalidOperationError)(message, innerError);
|
|
127
128
|
// SQLITE_AUTH (23): authorization denied
|
|
128
129
|
case "SQLITE_AUTH":
|
|
129
|
-
return new (0,
|
|
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,
|
|
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,
|
|
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,
|
|
140
|
+
return new (0, _chunkQVEVSWG6cjs.SerializationError)(message, innerError);
|
|
140
141
|
// SQLITE_INTERRUPT (9): operation interrupted
|
|
141
142
|
case "SQLITE_INTERRUPT":
|
|
142
|
-
return new (0,
|
|
143
|
+
return new (0, _chunkQVEVSWG6cjs.SerializationError)(message, innerError);
|
|
143
144
|
}
|
|
144
|
-
return new (0,
|
|
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 =
|
|
191
|
+
var sqliteColumnProcessors = _chunkQVEVSWG6cjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
|
|
191
192
|
|
|
192
193
|
// src/storage/sqlite/core/sql/formatter/index.ts
|
|
193
|
-
var sqliteSQLProcessorsRegistry =
|
|
194
|
-
from:
|
|
194
|
+
var sqliteSQLProcessorsRegistry = _chunkQVEVSWG6cjs.SQLProcessorsRegistry.call(void 0, {
|
|
195
|
+
from: _chunkQVEVSWG6cjs.defaultProcessorsRegistry
|
|
195
196
|
}).register(sqliteColumnProcessors);
|
|
196
|
-
var sqliteFormatter =
|
|
197
|
+
var sqliteFormatter = _chunkQVEVSWG6cjs.SQLFormatter.call(void 0, {
|
|
197
198
|
processorsRegistry: sqliteSQLProcessorsRegistry
|
|
198
199
|
});
|
|
199
|
-
|
|
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
|
-
|
|
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',
|
|
220
|
+
if (_optionalChain([options, 'optionalAccess', _3 => _3.mapping])) {
|
|
223
221
|
result = {
|
|
224
222
|
...result,
|
|
225
223
|
rows: result.rows.map(
|
|
226
|
-
(row) =>
|
|
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
|
-
|
|
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',
|
|
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) =>
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
320
|
-
if (
|
|
339
|
+
const isInMemory = isInMemoryDatabase(options);
|
|
340
|
+
if (isInMemory) {
|
|
321
341
|
return { ...rest, singleton: true };
|
|
322
342
|
}
|
|
323
|
-
|
|
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
|
|
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
|
|
361
|
+
return _chunkQVEVSWG6cjs.createSingletonConnectionPool.call(void 0, {
|
|
334
362
|
driverType,
|
|
335
|
-
getConnection: () => options.sqliteConnectionFactory(
|
|
363
|
+
getConnection: () => options.sqliteConnectionFactory(
|
|
364
|
+
options.connectionOptions
|
|
365
|
+
)
|
|
336
366
|
});
|
|
337
367
|
}
|
|
338
|
-
return
|
|
368
|
+
return _chunkQVEVSWG6cjs.createAlwaysNewConnectionPool.call(void 0, {
|
|
339
369
|
driverType,
|
|
340
|
-
getConnection: () => options.sqliteConnectionFactory(
|
|
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
|
-
|
|
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
|
|
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
|
|
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',
|
|
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
|
|
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',
|
|
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',
|
|
471
|
-
|
|
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() {
|
|
@@ -476,32 +555,37 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
|
|
|
476
555
|
if (allowNestedTransactions) {
|
|
477
556
|
if (transactionCounter.level >= 1) {
|
|
478
557
|
transactionCounter.increment();
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
558
|
+
if (_optionalChain([options, 'optionalAccess', _12 => _12.useSavepoints])) {
|
|
559
|
+
await client.query(
|
|
560
|
+
_chunkQVEVSWG6cjs.SQL`SAVEPOINT transaction${_chunkQVEVSWG6cjs.SQL.plain(transactionCounter.level.toString())}`
|
|
561
|
+
);
|
|
562
|
+
}
|
|
482
563
|
return;
|
|
483
564
|
}
|
|
484
565
|
transactionCounter.increment();
|
|
485
566
|
}
|
|
486
|
-
|
|
567
|
+
const mode = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.mode]), () => ( defaultTransactionMode)), () => ( "IMMEDIATE"));
|
|
568
|
+
await client.query(_chunkQVEVSWG6cjs.SQL`BEGIN ${_chunkQVEVSWG6cjs.SQL.plain(mode)} TRANSACTION`);
|
|
487
569
|
},
|
|
488
570
|
commit: async function() {
|
|
489
571
|
const client = await getClient;
|
|
490
572
|
try {
|
|
491
573
|
if (allowNestedTransactions) {
|
|
492
574
|
if (transactionCounter.level > 1) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
575
|
+
if (_optionalChain([options, 'optionalAccess', _14 => _14.useSavepoints])) {
|
|
576
|
+
await client.query(
|
|
577
|
+
_chunkQVEVSWG6cjs.SQL`RELEASE transaction${_chunkQVEVSWG6cjs.SQL.plain(transactionCounter.level.toString())}`
|
|
578
|
+
);
|
|
579
|
+
}
|
|
496
580
|
transactionCounter.decrement();
|
|
497
581
|
return;
|
|
498
582
|
}
|
|
499
583
|
transactionCounter.reset();
|
|
500
584
|
}
|
|
501
|
-
await client.query(
|
|
585
|
+
await client.query(_chunkQVEVSWG6cjs.SQL`COMMIT`);
|
|
502
586
|
} finally {
|
|
503
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
504
|
-
await _optionalChain([options, 'optionalAccess',
|
|
587
|
+
if (_optionalChain([options, 'optionalAccess', _15 => _15.close]))
|
|
588
|
+
await _optionalChain([options, 'optionalAccess', _16 => _16.close, 'call', _17 => _17(
|
|
505
589
|
client
|
|
506
590
|
)]);
|
|
507
591
|
}
|
|
@@ -515,19 +599,21 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
|
|
|
515
599
|
return;
|
|
516
600
|
}
|
|
517
601
|
}
|
|
518
|
-
await client.query(
|
|
602
|
+
await client.query(_chunkQVEVSWG6cjs.SQL`ROLLBACK`);
|
|
519
603
|
} finally {
|
|
520
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
521
|
-
await _optionalChain([options, 'optionalAccess',
|
|
604
|
+
if (_optionalChain([options, 'optionalAccess', _18 => _18.close]))
|
|
605
|
+
await _optionalChain([options, 'optionalAccess', _19 => _19.close, 'call', _20 => _20(
|
|
522
606
|
client,
|
|
523
607
|
error
|
|
524
608
|
)]);
|
|
525
609
|
}
|
|
526
610
|
},
|
|
527
|
-
execute:
|
|
611
|
+
execute: _chunkQVEVSWG6cjs.sqlExecutor.call(void 0, sqliteSQLExecutor(driverType, serializer), {
|
|
528
612
|
connect: () => getClient
|
|
529
|
-
})
|
|
613
|
+
}),
|
|
614
|
+
_transactionOptions: _nullishCoalesce(options, () => ( {}))
|
|
530
615
|
};
|
|
616
|
+
return transaction;
|
|
531
617
|
};
|
|
532
618
|
|
|
533
619
|
|
|
@@ -552,5 +638,7 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
|
|
|
552
638
|
|
|
553
639
|
|
|
554
640
|
|
|
555
|
-
|
|
556
|
-
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
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;
|
|
644
|
+
//# sourceMappingURL=chunk-7D7WADBK.cjs.map
|