@event-driven-io/dumbo 0.13.0-beta.34 → 0.13.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare.cjs +379 -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 +343 -434
- package/dist/cloudflare.js.map +1 -1
- package/dist/core-BeyC5tHn.js +519 -0
- package/dist/core-BeyC5tHn.js.map +1 -0
- package/dist/core-Bf2ujUFy.js +379 -0
- package/dist/core-Bf2ujUFy.js.map +1 -0
- package/dist/core-BgYtAxCm.cjs +3237 -0
- package/dist/core-BgYtAxCm.cjs.map +1 -0
- package/dist/core-DDo4m0Z_.js +2262 -0
- package/dist/core-DDo4m0Z_.js.map +1 -0
- package/dist/core-DmbB4qMn.cjs +656 -0
- package/dist/core-DmbB4qMn.cjs.map +1 -0
- package/dist/core-Go_IA78L.cjs +450 -0
- package/dist/core-Go_IA78L.cjs.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-D1jryNqo.d.ts +198 -0
- package/dist/index-DaP2fTEX.d.ts +67 -0
- package/dist/index-DqVvUav9.d.cts +198 -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-LqX-Z_wo.cjs +118 -0
- package/dist/postgreSQLMetadata-LqX-Z_wo.cjs.map +1 -0
- package/dist/postgreSQLMetadata-zMq8yJo_.js +65 -0
- package/dist/postgreSQLMetadata-zMq8yJo_.js.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 +312 -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 +276 -378
- package/dist/sqlite3.js.map +1 -1
- package/dist/sqliteMetadata-BoQ7Sc9I.js +29 -0
- package/dist/sqliteMetadata-BoQ7Sc9I.js.map +1 -0
- package/dist/sqliteMetadata-D_2pKeCC.cjs +46 -0
- package/dist/sqliteMetadata-D_2pKeCC.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.js
CHANGED
|
@@ -1,394 +1,292 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
InMemorySQLiteDatabase,
|
|
5
|
-
SQLiteConnectionString,
|
|
6
|
-
SQLiteDatabaseName,
|
|
7
|
-
isInMemoryDatabase,
|
|
8
|
-
isSQLiteError,
|
|
9
|
-
mapSqliteError,
|
|
10
|
-
parsePragmasFromConnectionString,
|
|
11
|
-
sqliteAlwaysNewConnectionPool,
|
|
12
|
-
sqliteAmbientClientConnection,
|
|
13
|
-
sqliteAmbientConnectionPool,
|
|
14
|
-
sqliteClientConnection,
|
|
15
|
-
sqliteConnection,
|
|
16
|
-
sqliteExecute,
|
|
17
|
-
sqliteFormatter,
|
|
18
|
-
sqlitePool,
|
|
19
|
-
sqlitePoolClientConnection,
|
|
20
|
-
sqliteSQLExecutor,
|
|
21
|
-
sqliteSingletonConnectionPool,
|
|
22
|
-
sqliteTransaction,
|
|
23
|
-
toSqlitePoolOptions,
|
|
24
|
-
transactionNestingCounter
|
|
25
|
-
} from "./chunk-6HAHSSPW.js";
|
|
26
|
-
import {
|
|
27
|
-
defaultSQLiteDatabase,
|
|
28
|
-
sqliteMetadata,
|
|
29
|
-
tableExists
|
|
30
|
-
} from "./chunk-UK7MXVS2.js";
|
|
31
|
-
import {
|
|
32
|
-
BatchCommandNoChangesError,
|
|
33
|
-
JSONSerializer,
|
|
34
|
-
SQL,
|
|
35
|
-
canHandleDriverWithConnectionString,
|
|
36
|
-
dumboDatabaseDriverRegistry
|
|
37
|
-
} from "./chunk-H2JBS7HM.js";
|
|
38
|
-
|
|
39
|
-
// src/storage/sqlite/sqlite3/connections/connection.ts
|
|
1
|
+
import { Dn as canHandleDriverWithConnectionString, On as dumboDatabaseDriverRegistry, _ as BatchCommandNoChangesError, bt as SQL, rn as JSONSerializer } from "./core-DDo4m0Z_.js";
|
|
2
|
+
import { n as defaultSQLiteDatabase, r as tableExists, t as sqliteMetadata } from "./sqliteMetadata-BoQ7Sc9I.js";
|
|
3
|
+
import { C as mapSqliteError, S as sqliteFormatter, _ as SQLiteConnectionString, a as sqliteAmbientConnectionPool, b as sqliteExecute, c as toSqlitePoolOptions, d as isSQLiteError, f as sqliteAmbientClientConnection, g as transactionNestingCounter, h as sqlitePoolClientConnection, i as sqliteAlwaysNewConnectionPool, l as DEFAULT_SQLITE_PRAGMA_OPTIONS, m as sqliteConnection, n as DefaultSQLiteMigratorOptions, o as sqlitePool, p as sqliteClientConnection, r as isInMemoryDatabase, s as sqliteSingletonConnectionPool, t as SQLiteDatabaseName, u as InMemorySQLiteDatabase, v as parsePragmasFromConnectionString, x as sqliteSQLExecutor, y as sqliteTransaction } from "./core-BeyC5tHn.js";
|
|
40
4
|
import sqlite3 from "sqlite3";
|
|
41
5
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
6
|
+
//#region src/storage/sqlite/core/connections/pragmas.ts
|
|
7
|
+
const mergePragmaOptions = (connectionString, userOptions) => {
|
|
8
|
+
const connectionStringPragmas = parsePragmasFromConnectionString(connectionString);
|
|
9
|
+
return {
|
|
10
|
+
...DEFAULT_SQLITE_PRAGMA_OPTIONS,
|
|
11
|
+
...connectionStringPragmas,
|
|
12
|
+
...userOptions
|
|
13
|
+
};
|
|
50
14
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
15
|
+
const buildConnectionPragmaStatements = (pragmas) => [
|
|
16
|
+
{
|
|
17
|
+
pragma: "busy_timeout",
|
|
18
|
+
value: pragmas.busy_timeout
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
pragma: "synchronous",
|
|
22
|
+
value: pragmas.synchronous
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
pragma: "cache_size",
|
|
26
|
+
value: pragmas.cache_size
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
pragma: "foreign_keys",
|
|
30
|
+
value: pragmas.foreign_keys ? "ON" : "OFF"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pragma: "temp_store",
|
|
34
|
+
value: pragmas.temp_store
|
|
35
|
+
},
|
|
36
|
+
...pragmas.mmap_size !== void 0 ? [{
|
|
37
|
+
pragma: "mmap_size",
|
|
38
|
+
value: pragmas.mmap_size
|
|
39
|
+
}] : []
|
|
62
40
|
];
|
|
41
|
+
const buildDatabasePragmaStatements = (pragmas) => [{
|
|
42
|
+
pragma: "journal_mode",
|
|
43
|
+
value: pragmas.journal_mode
|
|
44
|
+
}];
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/storage/sqlite/sqlite3/connections/connection.ts
|
|
48
|
+
const SQLite3DriverType = "SQLite:sqlite3";
|
|
49
|
+
const hasReturningClause = (sql) => /\bRETURNING\b/i.test(sql);
|
|
50
|
+
const applyPragma = (database, pragma, value) => {
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
database.run(`PRAGMA ${pragma} = ${value};`, (err) => {
|
|
53
|
+
if (err) reject(err);
|
|
54
|
+
else resolve();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
74
57
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
else resolve(row?.[pragma] ?? "");
|
|
81
|
-
}
|
|
82
|
-
);
|
|
58
|
+
const queryPragma = (database, pragma) => new Promise((resolve, reject) => {
|
|
59
|
+
database.get(`PRAGMA ${pragma};`, (err, row) => {
|
|
60
|
+
if (err) reject(err);
|
|
61
|
+
else resolve(row?.[pragma] ?? "");
|
|
62
|
+
});
|
|
83
63
|
});
|
|
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 mapSqliteError(error);
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
command: async (sql, options2) => {
|
|
250
|
-
try {
|
|
251
|
-
const { query, params } = sqliteFormatter.format(sql, {
|
|
252
|
-
serializer
|
|
253
|
-
});
|
|
254
|
-
return await executeCommand(
|
|
255
|
-
query,
|
|
256
|
-
params,
|
|
257
|
-
options2
|
|
258
|
-
);
|
|
259
|
-
} catch (error) {
|
|
260
|
-
throw mapSqliteError(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 } = 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 (options2?.assertChanges && (result.rowCount ?? 0) === 0) {
|
|
277
|
-
throw new BatchCommandNoChangesError(i);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return results;
|
|
281
|
-
} catch (error) {
|
|
282
|
-
throw mapSqliteError(error);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
};
|
|
64
|
+
const applyPragmas = (database, pragmas) => pragmas.reduce((promise, { pragma, value }) => promise.then(() => applyPragma(database, pragma, value)), Promise.resolve());
|
|
65
|
+
const sqlite3Client = (options) => {
|
|
66
|
+
let db;
|
|
67
|
+
let isClosed = false;
|
|
68
|
+
const { serializer } = options;
|
|
69
|
+
const connectionString = options.fileName ?? options.connectionString ?? InMemorySQLiteDatabase;
|
|
70
|
+
const finalPragmas = mergePragmaOptions(String(connectionString), options.pragmaOptions);
|
|
71
|
+
const connectionPragmas = buildConnectionPragmaStatements(finalPragmas);
|
|
72
|
+
const connect = () => db ? Promise.resolve() : new Promise((resolve, reject) => {
|
|
73
|
+
try {
|
|
74
|
+
db = new sqlite3.Database(connectionString, sqlite3.OPEN_URI | sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE, (err) => {
|
|
75
|
+
if (err) {
|
|
76
|
+
reject(err);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const busyTimeout = finalPragmas.busy_timeout ?? DEFAULT_SQLITE_PRAGMA_OPTIONS.busy_timeout;
|
|
80
|
+
db.configure("busyTimeout", busyTimeout);
|
|
81
|
+
applyPragmas(db, connectionPragmas.filter((p) => p.pragma !== "busy_timeout")).then(async () => {
|
|
82
|
+
if (options.skipDatabasePragmas) return;
|
|
83
|
+
const databasePragmas = buildDatabasePragmaStatements(finalPragmas);
|
|
84
|
+
for (const { pragma, value } of databasePragmas) if ((await queryPragma(db, pragma)).toUpperCase() !== String(value).toUpperCase()) await applyPragma(db, pragma, value);
|
|
85
|
+
}).then(() => resolve()).catch(reject);
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const executeQuery = (sql, params) => new Promise((resolve, reject) => {
|
|
92
|
+
try {
|
|
93
|
+
db.all(sql, params ?? [], (err, result) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
reject(err);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
resolve(result);
|
|
99
|
+
});
|
|
100
|
+
} catch (error) {
|
|
101
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const executeCommand = (sql, params, options) => new Promise((resolve, reject) => {
|
|
105
|
+
try {
|
|
106
|
+
if (options?.ignoreChangesCount === true) {
|
|
107
|
+
db.run(sql, params ?? [], function(err, rows) {
|
|
108
|
+
if (err) {
|
|
109
|
+
reject(err);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
resolve({
|
|
113
|
+
rowCount: 0,
|
|
114
|
+
rows: rows ?? []
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (hasReturningClause(sql)) {
|
|
120
|
+
db.all(sql, params ?? [], (err, rows) => {
|
|
121
|
+
if (err) return reject(err);
|
|
122
|
+
resolve({
|
|
123
|
+
rowCount: rows.length,
|
|
124
|
+
rows
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
db.serialize(() => {
|
|
130
|
+
let hasFailed = false;
|
|
131
|
+
let resultRows = [];
|
|
132
|
+
db.all(sql, params ?? [], (err, rows) => {
|
|
133
|
+
if (err) {
|
|
134
|
+
hasFailed = true;
|
|
135
|
+
return reject(err);
|
|
136
|
+
}
|
|
137
|
+
resultRows = rows;
|
|
138
|
+
});
|
|
139
|
+
db.get("SELECT changes() as changes", (err, row) => {
|
|
140
|
+
if (hasFailed) return;
|
|
141
|
+
if (err) return reject(err);
|
|
142
|
+
resolve({
|
|
143
|
+
rowCount: row?.changes ?? 0,
|
|
144
|
+
rows: resultRows
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
} catch (error) {
|
|
149
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
connect,
|
|
154
|
+
close: async () => {
|
|
155
|
+
if (isClosed) return;
|
|
156
|
+
isClosed = true;
|
|
157
|
+
if (db) try {
|
|
158
|
+
await new Promise((resolve, reject) => {
|
|
159
|
+
db.close((err) => {
|
|
160
|
+
if (err) {
|
|
161
|
+
reject(err);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
resolve();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
} catch (error) {
|
|
168
|
+
throw mapSqliteError(error);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
query: async (sql, _options) => {
|
|
172
|
+
try {
|
|
173
|
+
const { query, params } = sqliteFormatter.format(sql, { serializer });
|
|
174
|
+
const result = await executeQuery(query, params);
|
|
175
|
+
return {
|
|
176
|
+
rowCount: result.length,
|
|
177
|
+
rows: result
|
|
178
|
+
};
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw mapSqliteError(error);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
batchQuery: async (sqls, _options) => {
|
|
184
|
+
try {
|
|
185
|
+
const results = [];
|
|
186
|
+
for (const sql of sqls) {
|
|
187
|
+
const { query, params } = sqliteFormatter.format(sql, { serializer });
|
|
188
|
+
const result = await executeQuery(query, params);
|
|
189
|
+
results.push({
|
|
190
|
+
rowCount: result.length,
|
|
191
|
+
rows: result
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return results;
|
|
195
|
+
} catch (error) {
|
|
196
|
+
throw mapSqliteError(error);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
command: async (sql, options) => {
|
|
200
|
+
try {
|
|
201
|
+
const { query, params } = sqliteFormatter.format(sql, { serializer });
|
|
202
|
+
return await executeCommand(query, params, options);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
throw mapSqliteError(error);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
batchCommand: async (sqls, options) => {
|
|
208
|
+
try {
|
|
209
|
+
const results = [];
|
|
210
|
+
for (let i = 0; i < sqls.length; i++) {
|
|
211
|
+
const { query, params } = sqliteFormatter.format(sqls[i], { serializer });
|
|
212
|
+
const result = await executeCommand(query, params, options);
|
|
213
|
+
results.push(result);
|
|
214
|
+
if (options?.assertChanges && (result.rowCount ?? 0) === 0) throw new BatchCommandNoChangesError(i);
|
|
215
|
+
}
|
|
216
|
+
return results;
|
|
217
|
+
} catch (error) {
|
|
218
|
+
throw mapSqliteError(error);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
286
222
|
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
223
|
+
const checkConnection = async (fileName, serializer) => {
|
|
224
|
+
const client = sqlite3Client({
|
|
225
|
+
fileName,
|
|
226
|
+
serializer
|
|
227
|
+
});
|
|
228
|
+
try {
|
|
229
|
+
await client.query(SQL`SELECT 1`);
|
|
230
|
+
return { successful: true };
|
|
231
|
+
} catch (error) {
|
|
232
|
+
const code = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
233
|
+
return {
|
|
234
|
+
successful: false,
|
|
235
|
+
errorType: code === "SQLITE_CANTOPEN" ? "ConnectionRefused" : code === "SQLITE_AUTH" ? "Authentication" : "Unknown",
|
|
236
|
+
code,
|
|
237
|
+
error
|
|
238
|
+
};
|
|
239
|
+
} finally {
|
|
240
|
+
await client.close();
|
|
241
|
+
}
|
|
306
242
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
connectionOptions: options,
|
|
320
|
-
serializer: options.serializer
|
|
243
|
+
const sqlite3Connection = (options) => sqliteConnection({
|
|
244
|
+
type: "Client",
|
|
245
|
+
driverType: SQLite3DriverType,
|
|
246
|
+
sqliteClientFactory: (connectionOptions) => {
|
|
247
|
+
if ("client" in connectionOptions && connectionOptions.client) return connectionOptions.client;
|
|
248
|
+
return sqlite3Client({
|
|
249
|
+
...connectionOptions,
|
|
250
|
+
serializer: options.serializer
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
connectionOptions: options,
|
|
254
|
+
serializer: options.serializer
|
|
321
255
|
});
|
|
322
256
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/storage/sqlite/sqlite3/index.ts
|
|
259
|
+
const sqlite3Pool = (options) => sqlitePool(toSqlitePoolOptions({
|
|
260
|
+
...options,
|
|
261
|
+
driverType: SQLite3DriverType,
|
|
262
|
+
..."connection" in options ? {} : {
|
|
263
|
+
connectionOptions: options,
|
|
264
|
+
sqliteConnectionFactory: (opts) => sqlite3Connection({
|
|
265
|
+
...opts,
|
|
266
|
+
serializer: options.serializer ?? JSONSerializer
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
}));
|
|
270
|
+
const tryParseConnectionString = (connectionString) => {
|
|
271
|
+
try {
|
|
272
|
+
return SQLiteConnectionString(connectionString);
|
|
273
|
+
} catch {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
343
276
|
};
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
tryParseConnectionString
|
|
352
|
-
),
|
|
353
|
-
databaseMetadata: sqliteMetadata
|
|
277
|
+
const sqlite3DumboDriver = {
|
|
278
|
+
driverType: SQLite3DriverType,
|
|
279
|
+
createPool: (options) => sqlite3Pool(options),
|
|
280
|
+
sqlFormatter: sqliteFormatter,
|
|
281
|
+
defaultMigratorOptions: DefaultSQLiteMigratorOptions,
|
|
282
|
+
canHandle: canHandleDriverWithConnectionString(SQLite3DriverType, tryParseConnectionString),
|
|
283
|
+
databaseMetadata: sqliteMetadata
|
|
354
284
|
};
|
|
355
|
-
|
|
356
|
-
|
|
285
|
+
const useSqlite3DumboDriver = () => {
|
|
286
|
+
dumboDatabaseDriverRegistry.register(SQLite3DriverType, sqlite3DumboDriver);
|
|
357
287
|
};
|
|
358
288
|
useSqlite3DumboDriver();
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
InMemorySQLiteDatabase,
|
|
363
|
-
SQLite3DriverType,
|
|
364
|
-
SQLiteConnectionString,
|
|
365
|
-
SQLiteDatabaseName,
|
|
366
|
-
checkConnection,
|
|
367
|
-
defaultSQLiteDatabase,
|
|
368
|
-
isInMemoryDatabase,
|
|
369
|
-
isSQLiteError,
|
|
370
|
-
mapSqliteError,
|
|
371
|
-
parsePragmasFromConnectionString,
|
|
372
|
-
sqlite3Client,
|
|
373
|
-
sqlite3Connection,
|
|
374
|
-
sqlite3DumboDriver,
|
|
375
|
-
sqlite3Pool,
|
|
376
|
-
sqliteAlwaysNewConnectionPool,
|
|
377
|
-
sqliteAmbientClientConnection,
|
|
378
|
-
sqliteAmbientConnectionPool,
|
|
379
|
-
sqliteClientConnection,
|
|
380
|
-
sqliteConnection,
|
|
381
|
-
sqliteExecute,
|
|
382
|
-
sqliteFormatter,
|
|
383
|
-
sqliteMetadata,
|
|
384
|
-
sqlitePool,
|
|
385
|
-
sqlitePoolClientConnection,
|
|
386
|
-
sqliteSQLExecutor,
|
|
387
|
-
sqliteSingletonConnectionPool,
|
|
388
|
-
sqliteTransaction,
|
|
389
|
-
tableExists,
|
|
390
|
-
toSqlitePoolOptions,
|
|
391
|
-
transactionNestingCounter,
|
|
392
|
-
useSqlite3DumboDriver
|
|
393
|
-
};
|
|
289
|
+
|
|
290
|
+
//#endregion
|
|
291
|
+
export { DEFAULT_SQLITE_PRAGMA_OPTIONS, DefaultSQLiteMigratorOptions, InMemorySQLiteDatabase, SQLite3DriverType, SQLiteConnectionString, SQLiteDatabaseName, checkConnection, defaultSQLiteDatabase, isInMemoryDatabase, isSQLiteError, mapSqliteError, parsePragmasFromConnectionString, sqlite3Client, sqlite3Connection, sqlite3DumboDriver, sqlite3Pool, sqliteAlwaysNewConnectionPool, sqliteAmbientClientConnection, sqliteAmbientConnectionPool, sqliteClientConnection, sqliteConnection, sqliteExecute, sqliteFormatter, sqliteMetadata, sqlitePool, sqlitePoolClientConnection, sqliteSQLExecutor, sqliteSingletonConnectionPool, sqliteTransaction, tableExists, toSqlitePoolOptions, transactionNestingCounter, useSqlite3DumboDriver };
|
|
394
292
|
//# sourceMappingURL=sqlite3.js.map
|