@event-driven-io/dumbo 0.13.0-beta.35 → 0.13.0-beta.37
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/cloudflare.cjs +375 -434
- package/dist/cloudflare.cjs.map +1 -1
- package/dist/cloudflare.d.cts +36 -29
- package/dist/cloudflare.d.ts +36 -29
- package/dist/cloudflare.js +339 -434
- package/dist/cloudflare.js.map +1 -1
- package/dist/core-BG__WVn6.js +2262 -0
- package/dist/core-BG__WVn6.js.map +1 -0
- package/dist/core-BchvTX3G.js +379 -0
- package/dist/core-BchvTX3G.js.map +1 -0
- package/dist/core-CWZb0zOY.cjs +588 -0
- package/dist/core-CWZb0zOY.cjs.map +1 -0
- package/dist/core-D-smW7cm.cjs +3243 -0
- package/dist/core-D-smW7cm.cjs.map +1 -0
- package/dist/core-DXCRR5A9.cjs +450 -0
- package/dist/core-DXCRR5A9.cjs.map +1 -0
- package/dist/core-DlV8ua1P.js +451 -0
- package/dist/core-DlV8ua1P.js.map +1 -0
- package/dist/{connectionString-Dch_MIRU.d.cts → index-BDSQvDH2.d.cts} +1010 -922
- package/dist/index-BdWFmDhJ.d.cts +68 -0
- package/dist/index-BgFHGsuP.d.ts +186 -0
- package/dist/index-DaP2fTEX.d.ts +67 -0
- package/dist/index-N2ly5shv.d.cts +186 -0
- package/dist/index-S_wp0Eaf.d.cts +67 -0
- package/dist/index-cxtbLiju.d.ts +68 -0
- package/dist/{connectionString-Dch_MIRU.d.ts → index-zkszkJqP.d.ts} +1010 -922
- package/dist/index.cjs +212 -359
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -132
- package/dist/index.d.ts +3 -132
- package/dist/index.js +52 -361
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +366 -431
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +83 -72
- package/dist/pg.d.ts +83 -72
- package/dist/pg.js +320 -431
- package/dist/pg.js.map +1 -1
- package/dist/postgreSQLMetadata-BTz6vdwE.js +65 -0
- package/dist/postgreSQLMetadata-BTz6vdwE.js.map +1 -0
- package/dist/postgreSQLMetadata-WGXySO7a.cjs +118 -0
- package/dist/postgreSQLMetadata-WGXySO7a.cjs.map +1 -0
- package/dist/postgresql.cjs +25 -50
- package/dist/postgresql.d.cts +3 -61
- package/dist/postgresql.d.ts +3 -61
- package/dist/postgresql.js +4 -50
- package/dist/sqlite.cjs +30 -60
- package/dist/sqlite.d.cts +3 -190
- package/dist/sqlite.d.ts +3 -190
- package/dist/sqlite.js +4 -60
- package/dist/sqlite3.cjs +432 -380
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +79 -77
- package/dist/sqlite3.d.ts +79 -77
- package/dist/sqlite3.js +396 -378
- package/dist/sqlite3.js.map +1 -1
- package/dist/sqliteMetadata-7qBjsMBN.js +29 -0
- package/dist/sqliteMetadata-7qBjsMBN.js.map +1 -0
- package/dist/sqliteMetadata-PJTRPIZ1.cjs +46 -0
- package/dist/sqliteMetadata-PJTRPIZ1.cjs.map +1 -0
- package/package.json +12 -12
- package/dist/chunk-33P5766L.js +0 -83
- package/dist/chunk-33P5766L.js.map +0 -1
- package/dist/chunk-4MMMEDQ7.cjs +0 -2944
- package/dist/chunk-4MMMEDQ7.cjs.map +0 -1
- package/dist/chunk-6HAHSSPW.js +0 -701
- package/dist/chunk-6HAHSSPW.js.map +0 -1
- package/dist/chunk-GNH5XC6D.cjs +0 -481
- package/dist/chunk-GNH5XC6D.cjs.map +0 -1
- package/dist/chunk-H2JBS7HM.js +0 -2944
- package/dist/chunk-H2JBS7HM.js.map +0 -1
- package/dist/chunk-JIZGCEPE.cjs +0 -701
- package/dist/chunk-JIZGCEPE.cjs.map +0 -1
- package/dist/chunk-NJI6PJFZ.cjs +0 -83
- package/dist/chunk-NJI6PJFZ.cjs.map +0 -1
- package/dist/chunk-RQ3KKMTP.cjs +0 -34
- package/dist/chunk-RQ3KKMTP.cjs.map +0 -1
- package/dist/chunk-UK7MXVS2.js +0 -34
- package/dist/chunk-UK7MXVS2.js.map +0 -1
- package/dist/chunk-Y5TD53QE.js +0 -481
- package/dist/chunk-Y5TD53QE.js.map +0 -1
- package/dist/columnProcessors-Be2uMYjS.d.cts +0 -8
- package/dist/columnProcessors-D0ivj_SU.d.ts +0 -8
- package/dist/postgresql.cjs.map +0 -1
- package/dist/postgresql.js.map +0 -1
- package/dist/sqlite.cjs.map +0 -1
- package/dist/sqlite.js.map +0 -1
package/dist/sqlite3.cjs
CHANGED
|
@@ -1,394 +1,446 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var _chunkJIZGCEPEcjs = require('./chunk-JIZGCEPE.cjs');
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var _chunkRQ3KKMTPcjs = require('./chunk-RQ3KKMTP.cjs');
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _chunk4MMMEDQ7cjs = require('./chunk-4MMMEDQ7.cjs');
|
|
38
|
-
|
|
39
|
-
// src/storage/sqlite/sqlite3/connections/connection.ts
|
|
40
|
-
var _sqlite3 = require('sqlite3'); var _sqlite32 = _interopRequireDefault(_sqlite3);
|
|
41
|
-
|
|
42
|
-
// src/storage/sqlite/core/connections/pragmas.ts
|
|
43
|
-
var mergePragmaOptions = (connectionString, userOptions) => {
|
|
44
|
-
const connectionStringPragmas = _chunkJIZGCEPEcjs.parsePragmasFromConnectionString.call(void 0, connectionString);
|
|
45
|
-
return {
|
|
46
|
-
..._chunkJIZGCEPEcjs.DEFAULT_SQLITE_PRAGMA_OPTIONS,
|
|
47
|
-
...connectionStringPragmas,
|
|
48
|
-
...userOptions
|
|
49
|
-
};
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_core = require('./core-D-smW7cm.cjs');
|
|
3
|
+
const require_sqliteMetadata = require('./sqliteMetadata-PJTRPIZ1.cjs');
|
|
4
|
+
const require_core$1 = require('./core-CWZb0zOY.cjs');
|
|
5
|
+
let sqlite3 = require("sqlite3");
|
|
6
|
+
sqlite3 = require_core.__toESM(sqlite3, 1);
|
|
7
|
+
let os = require("os");
|
|
8
|
+
let node_async_hooks = require("node:async_hooks");
|
|
9
|
+
|
|
10
|
+
//#region src/storage/sqlite/core/connections/pragmas.ts
|
|
11
|
+
const mergePragmaOptions = (connectionString, userOptions) => {
|
|
12
|
+
const connectionStringPragmas = require_core$1.parsePragmasFromConnectionString(connectionString);
|
|
13
|
+
return {
|
|
14
|
+
...require_core$1.DEFAULT_SQLITE_PRAGMA_OPTIONS,
|
|
15
|
+
...connectionStringPragmas,
|
|
16
|
+
...userOptions
|
|
17
|
+
};
|
|
50
18
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
19
|
+
const buildConnectionPragmaStatements = (pragmas) => [
|
|
20
|
+
{
|
|
21
|
+
pragma: "busy_timeout",
|
|
22
|
+
value: pragmas.busy_timeout
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
pragma: "synchronous",
|
|
26
|
+
value: pragmas.synchronous
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
pragma: "cache_size",
|
|
30
|
+
value: pragmas.cache_size
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pragma: "foreign_keys",
|
|
34
|
+
value: pragmas.foreign_keys ? "ON" : "OFF"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
pragma: "temp_store",
|
|
38
|
+
value: pragmas.temp_store
|
|
39
|
+
},
|
|
40
|
+
...pragmas.mmap_size !== void 0 ? [{
|
|
41
|
+
pragma: "mmap_size",
|
|
42
|
+
value: pragmas.mmap_size
|
|
43
|
+
}] : []
|
|
62
44
|
];
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
45
|
+
const buildDatabasePragmaStatements = (pragmas) => [{
|
|
46
|
+
pragma: "journal_mode",
|
|
47
|
+
value: pragmas.journal_mode
|
|
48
|
+
}];
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/storage/sqlite/sqlite3/connections/connection.ts
|
|
52
|
+
const SQLite3DriverType = "SQLite:sqlite3";
|
|
53
|
+
const hasReturningClause = (sql) => /\bRETURNING\b/i.test(sql);
|
|
54
|
+
const applyPragma = (database, pragma, value) => {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
database.run(`PRAGMA ${pragma} = ${value};`, (err) => {
|
|
57
|
+
if (err) reject(err);
|
|
58
|
+
else resolve();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
74
61
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
else resolve(_nullishCoalesce(_optionalChain([row, 'optionalAccess', _ => _[pragma]]), () => ( "")));
|
|
81
|
-
}
|
|
82
|
-
);
|
|
62
|
+
const queryPragma = (database, pragma) => new Promise((resolve, reject) => {
|
|
63
|
+
database.get(`PRAGMA ${pragma};`, (err, row) => {
|
|
64
|
+
if (err) reject(err);
|
|
65
|
+
else resolve(row?.[pragma] ?? "");
|
|
66
|
+
});
|
|
83
67
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
results.push({ rowCount: result.length, rows: result });
|
|
243
|
-
}
|
|
244
|
-
return results;
|
|
245
|
-
} catch (error) {
|
|
246
|
-
throw _chunkJIZGCEPEcjs.mapSqliteError.call(void 0, error);
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
command: async (sql, options2) => {
|
|
250
|
-
try {
|
|
251
|
-
const { query, params } = _chunkJIZGCEPEcjs.sqliteFormatter.format(sql, {
|
|
252
|
-
serializer
|
|
253
|
-
});
|
|
254
|
-
return await executeCommand(
|
|
255
|
-
query,
|
|
256
|
-
params,
|
|
257
|
-
options2
|
|
258
|
-
);
|
|
259
|
-
} catch (error) {
|
|
260
|
-
throw _chunkJIZGCEPEcjs.mapSqliteError.call(void 0, error);
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
batchCommand: async (sqls, options2) => {
|
|
264
|
-
try {
|
|
265
|
-
const results = [];
|
|
266
|
-
for (let i = 0; i < sqls.length; i++) {
|
|
267
|
-
const { query, params } = _chunkJIZGCEPEcjs.sqliteFormatter.format(sqls[i], {
|
|
268
|
-
serializer
|
|
269
|
-
});
|
|
270
|
-
const result = await executeCommand(
|
|
271
|
-
query,
|
|
272
|
-
params,
|
|
273
|
-
options2
|
|
274
|
-
);
|
|
275
|
-
results.push(result);
|
|
276
|
-
if (_optionalChain([options2, 'optionalAccess', _4 => _4.assertChanges]) && (_nullishCoalesce(result.rowCount, () => ( 0))) === 0) {
|
|
277
|
-
throw new (0, _chunk4MMMEDQ7cjs.BatchCommandNoChangesError)(i);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return results;
|
|
281
|
-
} catch (error) {
|
|
282
|
-
throw _chunkJIZGCEPEcjs.mapSqliteError.call(void 0, error);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
};
|
|
68
|
+
const applyPragmas = (database, pragmas) => pragmas.reduce((promise, { pragma, value }) => promise.then(() => applyPragma(database, pragma, value)), Promise.resolve());
|
|
69
|
+
const sqlite3Client = (options) => {
|
|
70
|
+
let db;
|
|
71
|
+
let isClosed = false;
|
|
72
|
+
const { serializer } = options;
|
|
73
|
+
const connectionString = options.fileName ?? options.connectionString ?? require_core$1.InMemorySQLiteDatabase;
|
|
74
|
+
const finalPragmas = mergePragmaOptions(String(connectionString), options.pragmaOptions);
|
|
75
|
+
const connectionPragmas = buildConnectionPragmaStatements(finalPragmas);
|
|
76
|
+
const connect = () => db ? Promise.resolve() : new Promise((resolve, reject) => {
|
|
77
|
+
try {
|
|
78
|
+
db = new sqlite3.default.Database(connectionString, sqlite3.default.OPEN_URI | sqlite3.default.OPEN_READWRITE | sqlite3.default.OPEN_CREATE, (err) => {
|
|
79
|
+
if (err) {
|
|
80
|
+
reject(err);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const busyTimeout = finalPragmas.busy_timeout ?? require_core$1.DEFAULT_SQLITE_PRAGMA_OPTIONS.busy_timeout;
|
|
84
|
+
db.configure("busyTimeout", busyTimeout);
|
|
85
|
+
applyPragmas(db, connectionPragmas.filter((p) => p.pragma !== "busy_timeout")).then(async () => {
|
|
86
|
+
if (options.skipDatabasePragmas) return;
|
|
87
|
+
const databasePragmas = buildDatabasePragmaStatements(finalPragmas);
|
|
88
|
+
for (const { pragma, value } of databasePragmas) if ((await queryPragma(db, pragma)).toUpperCase() !== String(value).toUpperCase()) await applyPragma(db, pragma, value);
|
|
89
|
+
}).then(() => resolve()).catch(reject);
|
|
90
|
+
});
|
|
91
|
+
} catch (error) {
|
|
92
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const executeQuery = (sql, params) => new Promise((resolve, reject) => {
|
|
96
|
+
try {
|
|
97
|
+
db.all(sql, params ?? [], (err, result) => {
|
|
98
|
+
if (err) {
|
|
99
|
+
reject(err);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
resolve(result);
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const executeCommand = (sql, params, options) => new Promise((resolve, reject) => {
|
|
109
|
+
try {
|
|
110
|
+
if (options?.ignoreChangesCount === true) {
|
|
111
|
+
db.run(sql, params ?? [], function(err, rows) {
|
|
112
|
+
if (err) {
|
|
113
|
+
reject(err);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
resolve({
|
|
117
|
+
rowCount: 0,
|
|
118
|
+
rows: rows ?? []
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (hasReturningClause(sql)) {
|
|
124
|
+
db.all(sql, params ?? [], (err, rows) => {
|
|
125
|
+
if (err) return reject(err);
|
|
126
|
+
resolve({
|
|
127
|
+
rowCount: rows.length,
|
|
128
|
+
rows
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
db.serialize(() => {
|
|
134
|
+
let hasFailed = false;
|
|
135
|
+
let resultRows = [];
|
|
136
|
+
db.all(sql, params ?? [], (err, rows) => {
|
|
137
|
+
if (err) {
|
|
138
|
+
hasFailed = true;
|
|
139
|
+
return reject(err);
|
|
140
|
+
}
|
|
141
|
+
resultRows = rows;
|
|
142
|
+
});
|
|
143
|
+
db.get("SELECT changes() as changes", (err, row) => {
|
|
144
|
+
if (hasFailed) return;
|
|
145
|
+
if (err) return reject(err);
|
|
146
|
+
resolve({
|
|
147
|
+
rowCount: row?.changes ?? 0,
|
|
148
|
+
rows: resultRows
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
} catch (error) {
|
|
153
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return {
|
|
157
|
+
connect,
|
|
158
|
+
close: async () => {
|
|
159
|
+
if (isClosed) return;
|
|
160
|
+
isClosed = true;
|
|
161
|
+
if (db) try {
|
|
162
|
+
await new Promise((resolve, reject) => {
|
|
163
|
+
db.close((err) => {
|
|
164
|
+
if (err) {
|
|
165
|
+
reject(err);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
resolve();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
} catch (error) {
|
|
172
|
+
throw require_core$1.mapSqliteError(error);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
query: async (sql, _options) => {
|
|
176
|
+
try {
|
|
177
|
+
const { query, params } = require_core$1.sqliteFormatter.format(sql, { serializer });
|
|
178
|
+
const result = await executeQuery(query, params);
|
|
179
|
+
return {
|
|
180
|
+
rowCount: result.length,
|
|
181
|
+
rows: result
|
|
182
|
+
};
|
|
183
|
+
} catch (error) {
|
|
184
|
+
throw require_core$1.mapSqliteError(error);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
batchQuery: async (sqls, _options) => {
|
|
188
|
+
try {
|
|
189
|
+
const results = [];
|
|
190
|
+
for (const sql of sqls) {
|
|
191
|
+
const { query, params } = require_core$1.sqliteFormatter.format(sql, { serializer });
|
|
192
|
+
const result = await executeQuery(query, params);
|
|
193
|
+
results.push({
|
|
194
|
+
rowCount: result.length,
|
|
195
|
+
rows: result
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return results;
|
|
199
|
+
} catch (error) {
|
|
200
|
+
throw require_core$1.mapSqliteError(error);
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
command: async (sql, options) => {
|
|
204
|
+
try {
|
|
205
|
+
const { query, params } = require_core$1.sqliteFormatter.format(sql, { serializer });
|
|
206
|
+
return await executeCommand(query, params, options);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
throw require_core$1.mapSqliteError(error);
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
batchCommand: async (sqls, options) => {
|
|
212
|
+
try {
|
|
213
|
+
const results = [];
|
|
214
|
+
for (let i = 0; i < sqls.length; i++) {
|
|
215
|
+
const { query, params } = require_core$1.sqliteFormatter.format(sqls[i], { serializer });
|
|
216
|
+
const result = await executeCommand(query, params, options);
|
|
217
|
+
results.push(result);
|
|
218
|
+
if (options?.assertChanges && (result.rowCount ?? 0) === 0) throw new require_core.BatchCommandNoChangesError(i);
|
|
219
|
+
}
|
|
220
|
+
return results;
|
|
221
|
+
} catch (error) {
|
|
222
|
+
throw require_core$1.mapSqliteError(error);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
286
226
|
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
227
|
+
const checkConnection = async (fileName, serializer) => {
|
|
228
|
+
const client = sqlite3Client({
|
|
229
|
+
fileName,
|
|
230
|
+
serializer
|
|
231
|
+
});
|
|
232
|
+
try {
|
|
233
|
+
await client.query(require_core.SQL`SELECT 1`);
|
|
234
|
+
return { successful: true };
|
|
235
|
+
} catch (error) {
|
|
236
|
+
const code = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
237
|
+
return {
|
|
238
|
+
successful: false,
|
|
239
|
+
errorType: code === "SQLITE_CANTOPEN" ? "ConnectionRefused" : code === "SQLITE_AUTH" ? "Authentication" : "Unknown",
|
|
240
|
+
code,
|
|
241
|
+
error
|
|
242
|
+
};
|
|
243
|
+
} finally {
|
|
244
|
+
await client.close();
|
|
245
|
+
}
|
|
306
246
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
connectionOptions: options,
|
|
320
|
-
serializer: options.serializer
|
|
247
|
+
const sqlite3Connection = (options) => require_core$1.sqliteConnection({
|
|
248
|
+
type: "Client",
|
|
249
|
+
driverType: SQLite3DriverType,
|
|
250
|
+
sqliteClientFactory: (connectionOptions) => {
|
|
251
|
+
if ("client" in connectionOptions && connectionOptions.client) return connectionOptions.client;
|
|
252
|
+
return sqlite3Client({
|
|
253
|
+
...connectionOptions,
|
|
254
|
+
serializer: options.serializer
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
connectionOptions: options,
|
|
258
|
+
serializer: options.serializer
|
|
321
259
|
});
|
|
322
260
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/storage/sqlite/sqlite3/pool/singletonPool.ts
|
|
263
|
+
const sqlite3SingletonPool = (options) => {
|
|
264
|
+
const inner = require_core.createSingletonConnectionPool({
|
|
265
|
+
driverType: options.driverType,
|
|
266
|
+
getConnection: options.getConnection,
|
|
267
|
+
...options.closeConnection ? { closeConnection: options.closeConnection } : {}
|
|
268
|
+
});
|
|
269
|
+
const taskProcessor = new require_core.TaskProcessor({
|
|
270
|
+
maxActiveTasks: 1,
|
|
271
|
+
maxQueueSize: options.maxQueueSize ?? 1e3
|
|
272
|
+
});
|
|
273
|
+
const insideWriterTask = new node_async_hooks.AsyncLocalStorage();
|
|
274
|
+
const enqueue = (op) => {
|
|
275
|
+
if (insideWriterTask.getStore() === true) return op();
|
|
276
|
+
return taskProcessor.enqueue(({ ack }) => insideWriterTask.run(true, async () => {
|
|
277
|
+
try {
|
|
278
|
+
return await op();
|
|
279
|
+
} finally {
|
|
280
|
+
ack();
|
|
281
|
+
}
|
|
282
|
+
}));
|
|
283
|
+
};
|
|
284
|
+
return {
|
|
285
|
+
driverType: inner.driverType,
|
|
286
|
+
connection: inner.connection.bind(inner),
|
|
287
|
+
transaction: inner.transaction.bind(inner),
|
|
288
|
+
withConnection: (handle, connectionOptions) => enqueue(() => inner.withConnection(handle, connectionOptions)),
|
|
289
|
+
withTransaction: (handle, transactionOptions) => enqueue(() => inner.withTransaction(handle, transactionOptions)),
|
|
290
|
+
execute: {
|
|
291
|
+
query: (sql, queryOptions) => enqueue(() => inner.execute.query(sql, queryOptions)),
|
|
292
|
+
batchQuery: (sqls, queryOptions) => enqueue(() => inner.execute.batchQuery(sqls, queryOptions)),
|
|
293
|
+
command: (sql, commandOptions) => enqueue(() => inner.execute.command(sql, commandOptions)),
|
|
294
|
+
batchCommand: (sqls, commandOptions) => enqueue(() => inner.execute.batchCommand(sqls, commandOptions))
|
|
295
|
+
},
|
|
296
|
+
close: async () => {
|
|
297
|
+
await taskProcessor.stop();
|
|
298
|
+
await inner.close();
|
|
299
|
+
}
|
|
300
|
+
};
|
|
343
301
|
};
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
302
|
+
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/storage/sqlite/sqlite3/pool/dualPool.ts
|
|
305
|
+
const sqliteDualConnectionPool = (options) => {
|
|
306
|
+
const { sqliteConnectionFactory, connectionOptions } = options;
|
|
307
|
+
const readerPoolSize = options.readerPoolSize ?? Math.max(4, (0, os.cpus)().length);
|
|
308
|
+
let databaseInitPromise = null;
|
|
309
|
+
const guardSingleConnection = require_core.guardInitializedOnce(async () => {
|
|
310
|
+
if (databaseInitPromise !== null) return databaseInitPromise;
|
|
311
|
+
const initConnection = sqliteConnectionFactory({
|
|
312
|
+
...connectionOptions,
|
|
313
|
+
skipDatabasePragmas: false,
|
|
314
|
+
readonly: false
|
|
315
|
+
});
|
|
316
|
+
const initPromise = initConnection.open();
|
|
317
|
+
databaseInitPromise = initPromise;
|
|
318
|
+
try {
|
|
319
|
+
await initPromise;
|
|
320
|
+
await initConnection.close();
|
|
321
|
+
} catch (error) {
|
|
322
|
+
databaseInitPromise = null;
|
|
323
|
+
await initConnection.close();
|
|
324
|
+
throw require_core$1.mapSqliteError(error);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
const ensureDatabaseInitialized = async () => {
|
|
328
|
+
if (databaseInitPromise !== null) return databaseInitPromise;
|
|
329
|
+
return guardSingleConnection.ensureInitialized();
|
|
330
|
+
};
|
|
331
|
+
const wrappedConnectionFactory = async (readonly, connectionOptions) => {
|
|
332
|
+
await ensureDatabaseInitialized();
|
|
333
|
+
const connection = sqliteConnectionFactory({
|
|
334
|
+
...connectionOptions,
|
|
335
|
+
skipDatabasePragmas: true,
|
|
336
|
+
readonly
|
|
337
|
+
});
|
|
338
|
+
await connection.open();
|
|
339
|
+
return connection;
|
|
340
|
+
};
|
|
341
|
+
const writerPool = sqlite3SingletonPool({
|
|
342
|
+
driverType: options.driverType,
|
|
343
|
+
getConnection: () => wrappedConnectionFactory(false, connectionOptions)
|
|
344
|
+
});
|
|
345
|
+
const readerPool = require_core.createBoundedConnectionPool({
|
|
346
|
+
driverType: options.driverType,
|
|
347
|
+
getConnection: () => wrappedConnectionFactory(true, connectionOptions),
|
|
348
|
+
maxConnections: readerPoolSize
|
|
349
|
+
});
|
|
350
|
+
return {
|
|
351
|
+
driverType: options.driverType,
|
|
352
|
+
connection: (connectionOptions) => connectionOptions?.readonly ? readerPool.connection(connectionOptions) : writerPool.connection(connectionOptions),
|
|
353
|
+
execute: {
|
|
354
|
+
query: (...args) => readerPool.execute.query(...args),
|
|
355
|
+
batchQuery: (...args) => readerPool.execute.batchQuery(...args),
|
|
356
|
+
command: (...args) => writerPool.execute.command(...args),
|
|
357
|
+
batchCommand: (...args) => writerPool.execute.batchCommand(...args)
|
|
358
|
+
},
|
|
359
|
+
withConnection: (handle, connectionOptions) => connectionOptions?.readonly ? readerPool.withConnection(handle, connectionOptions) : writerPool.withConnection(handle, connectionOptions),
|
|
360
|
+
transaction: writerPool.transaction,
|
|
361
|
+
withTransaction: writerPool.withTransaction,
|
|
362
|
+
close: async () => {
|
|
363
|
+
await guardSingleConnection.stop();
|
|
364
|
+
await Promise.all([writerPool.close(), readerPool.close()]);
|
|
365
|
+
}
|
|
366
|
+
};
|
|
354
367
|
};
|
|
355
|
-
|
|
356
|
-
|
|
368
|
+
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/storage/sqlite/sqlite3/index.ts
|
|
371
|
+
const sqlite3Pool = (options) => {
|
|
372
|
+
if ("connection" in options && options.connection) return require_core$1.sqlitePool(require_core$1.toSqlitePoolOptions({
|
|
373
|
+
...options,
|
|
374
|
+
driverType: SQLite3DriverType
|
|
375
|
+
}));
|
|
376
|
+
const sqliteConnectionFactory = (opts) => sqlite3Connection({
|
|
377
|
+
...opts,
|
|
378
|
+
serializer: options.serializer ?? require_core.JSONSerializer
|
|
379
|
+
});
|
|
380
|
+
if (require_core$1.isInMemoryDatabase(options) || "client" in options && Boolean(options.client) || options.singleton === true) return sqlite3SingletonPool({
|
|
381
|
+
driverType: SQLite3DriverType,
|
|
382
|
+
getConnection: () => sqliteConnectionFactory(options)
|
|
383
|
+
});
|
|
384
|
+
const readerPoolSize = options.readerPoolSize;
|
|
385
|
+
return sqliteDualConnectionPool({
|
|
386
|
+
driverType: SQLite3DriverType,
|
|
387
|
+
sqliteConnectionFactory,
|
|
388
|
+
connectionOptions: options,
|
|
389
|
+
...readerPoolSize !== void 0 ? { readerPoolSize } : {}
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
const tryParseConnectionString = (connectionString) => {
|
|
393
|
+
try {
|
|
394
|
+
return require_core$1.SQLiteConnectionString(connectionString);
|
|
395
|
+
} catch {
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const sqlite3DumboDriver = {
|
|
400
|
+
driverType: SQLite3DriverType,
|
|
401
|
+
createPool: (options) => sqlite3Pool(options),
|
|
402
|
+
sqlFormatter: require_core$1.sqliteFormatter,
|
|
403
|
+
defaultMigratorOptions: require_core$1.DefaultSQLiteMigratorOptions,
|
|
404
|
+
canHandle: require_core.canHandleDriverWithConnectionString(SQLite3DriverType, tryParseConnectionString),
|
|
405
|
+
databaseMetadata: require_sqliteMetadata.sqliteMetadata
|
|
406
|
+
};
|
|
407
|
+
const useSqlite3DumboDriver = () => {
|
|
408
|
+
require_core.dumboDatabaseDriverRegistry.register(SQLite3DriverType, sqlite3DumboDriver);
|
|
357
409
|
};
|
|
358
410
|
useSqlite3DumboDriver();
|
|
359
411
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
exports.
|
|
412
|
+
//#endregion
|
|
413
|
+
exports.DEFAULT_SQLITE_PRAGMA_OPTIONS = require_core$1.DEFAULT_SQLITE_PRAGMA_OPTIONS;
|
|
414
|
+
exports.DefaultSQLiteMigratorOptions = require_core$1.DefaultSQLiteMigratorOptions;
|
|
415
|
+
exports.InMemorySQLiteDatabase = require_core$1.InMemorySQLiteDatabase;
|
|
416
|
+
exports.SQLite3DriverType = SQLite3DriverType;
|
|
417
|
+
exports.SQLiteConnectionString = require_core$1.SQLiteConnectionString;
|
|
418
|
+
exports.SQLiteDatabaseName = require_core$1.SQLiteDatabaseName;
|
|
419
|
+
exports.checkConnection = checkConnection;
|
|
420
|
+
exports.defaultSQLiteDatabase = require_sqliteMetadata.defaultSQLiteDatabase;
|
|
421
|
+
exports.isInMemoryDatabase = require_core$1.isInMemoryDatabase;
|
|
422
|
+
exports.isSQLiteError = require_core$1.isSQLiteError;
|
|
423
|
+
exports.mapSqliteError = require_core$1.mapSqliteError;
|
|
424
|
+
exports.parsePragmasFromConnectionString = require_core$1.parsePragmasFromConnectionString;
|
|
425
|
+
exports.sqlite3Client = sqlite3Client;
|
|
426
|
+
exports.sqlite3Connection = sqlite3Connection;
|
|
427
|
+
exports.sqlite3DumboDriver = sqlite3DumboDriver;
|
|
428
|
+
exports.sqlite3Pool = sqlite3Pool;
|
|
429
|
+
exports.sqliteAlwaysNewConnectionPool = require_core$1.sqliteAlwaysNewConnectionPool;
|
|
430
|
+
exports.sqliteAmbientClientConnection = require_core$1.sqliteAmbientClientConnection;
|
|
431
|
+
exports.sqliteAmbientConnectionPool = require_core$1.sqliteAmbientConnectionPool;
|
|
432
|
+
exports.sqliteClientConnection = require_core$1.sqliteClientConnection;
|
|
433
|
+
exports.sqliteConnection = require_core$1.sqliteConnection;
|
|
434
|
+
exports.sqliteExecute = require_core$1.sqliteExecute;
|
|
435
|
+
exports.sqliteFormatter = require_core$1.sqliteFormatter;
|
|
436
|
+
exports.sqliteMetadata = require_sqliteMetadata.sqliteMetadata;
|
|
437
|
+
exports.sqlitePool = require_core$1.sqlitePool;
|
|
438
|
+
exports.sqlitePoolClientConnection = require_core$1.sqlitePoolClientConnection;
|
|
439
|
+
exports.sqliteSQLExecutor = require_core$1.sqliteSQLExecutor;
|
|
440
|
+
exports.sqliteSingletonConnectionPool = require_core$1.sqliteSingletonConnectionPool;
|
|
441
|
+
exports.sqliteTransaction = require_core$1.sqliteTransaction;
|
|
442
|
+
exports.tableExists = require_sqliteMetadata.tableExists;
|
|
443
|
+
exports.toSqlitePoolOptions = require_core$1.toSqlitePoolOptions;
|
|
444
|
+
exports.transactionNestingCounter = require_core$1.transactionNestingCounter;
|
|
445
|
+
exports.useSqlite3DumboDriver = useSqlite3DumboDriver;
|
|
394
446
|
//# sourceMappingURL=sqlite3.cjs.map
|