@event-driven-io/dumbo 0.13.0-beta.2 → 0.13.0-beta.21
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-65DKXURG.js +481 -0
- package/dist/chunk-65DKXURG.js.map +1 -0
- package/dist/chunk-7WEBHXZD.cjs +481 -0
- package/dist/chunk-7WEBHXZD.cjs.map +1 -0
- package/dist/chunk-AMACBMAZ.cjs +556 -0
- package/dist/chunk-AMACBMAZ.cjs.map +1 -0
- package/dist/chunk-FC4JR2R3.js +83 -0
- package/dist/chunk-FC4JR2R3.js.map +1 -0
- package/dist/chunk-H7ZKIJHB.cjs +83 -0
- package/dist/chunk-H7ZKIJHB.cjs.map +1 -0
- package/dist/chunk-IVJ3SNPJ.js +34 -0
- package/dist/chunk-IVJ3SNPJ.js.map +1 -0
- package/dist/chunk-R7P7CNMK.cjs +34 -0
- package/dist/chunk-R7P7CNMK.cjs.map +1 -0
- package/dist/{chunk-XVV3OOQX.js → chunk-T4A6BQRA.js} +209 -58
- package/dist/chunk-T4A6BQRA.js.map +1 -0
- package/dist/{chunk-N7RWT46K.js → chunk-XO5T5N5S.js} +2135 -1613
- package/dist/chunk-XO5T5N5S.js.map +1 -0
- package/dist/{chunk-OJ34O3Q2.cjs → chunk-XOQHZABK.cjs} +2161 -1639
- package/dist/chunk-XOQHZABK.cjs.map +1 -0
- package/dist/cloudflare.cjs +451 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +92 -0
- package/dist/cloudflare.d.ts +92 -0
- package/dist/cloudflare.js +451 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/{columnProcessors-DMPpTPqM.d.ts → columnProcessors-C7fRa54L.d.ts} +1 -1
- package/dist/{columnProcessors-BX-sH7ah.d.cts → columnProcessors-Difrrk4c.d.cts} +1 -1
- package/dist/{connectionString-B1wm0TFc.d.cts → connectionString-oeg1LD5V.d.cts} +352 -137
- package/dist/{connectionString-B1wm0TFc.d.ts → connectionString-oeg1LD5V.d.ts} +352 -137
- package/dist/index.cjs +96 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -18
- package/dist/index.d.ts +23 -18
- package/dist/index.js +101 -9
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +382 -9
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +81 -105
- package/dist/pg.d.ts +81 -105
- package/dist/pg.js +434 -61
- package/dist/pg.js.map +1 -1
- package/dist/postgresql.cjs +50 -0
- package/dist/postgresql.cjs.map +1 -0
- package/dist/postgresql.d.cts +61 -0
- package/dist/postgresql.d.ts +61 -0
- package/dist/postgresql.js +50 -0
- package/dist/sqlite.cjs +56 -0
- package/dist/sqlite.cjs.map +1 -0
- package/dist/{index-C0h0c380.d.cts → sqlite.d.cts} +31 -10
- package/dist/{index-C2z_XBn6.d.ts → sqlite.d.ts} +31 -10
- package/dist/sqlite.js +56 -0
- package/dist/sqlite3.cjs +240 -11
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +39 -19
- package/dist/sqlite3.d.ts +39 -19
- package/dist/sqlite3.js +251 -22
- package/dist/sqlite3.js.map +1 -1
- package/package.json +69 -29
- package/dist/chunk-A7TC7IOP.cjs +0 -55
- package/dist/chunk-A7TC7IOP.cjs.map +0 -1
- package/dist/chunk-F7JQ7BX7.js +0 -240
- package/dist/chunk-F7JQ7BX7.js.map +0 -1
- package/dist/chunk-I34X53VL.js +0 -688
- package/dist/chunk-I34X53VL.js.map +0 -1
- package/dist/chunk-ISNF6USX.cjs +0 -688
- package/dist/chunk-ISNF6USX.cjs.map +0 -1
- package/dist/chunk-IYEHOE4S.cjs +0 -405
- package/dist/chunk-IYEHOE4S.cjs.map +0 -1
- package/dist/chunk-L2YZQAG3.cjs +0 -240
- package/dist/chunk-L2YZQAG3.cjs.map +0 -1
- package/dist/chunk-N7RWT46K.js.map +0 -1
- package/dist/chunk-OJ34O3Q2.cjs.map +0 -1
- package/dist/chunk-TXSETOGH.js +0 -55
- package/dist/chunk-TXSETOGH.js.map +0 -1
- package/dist/chunk-XVV3OOQX.js.map +0 -1
- package/dist/d1.cjs +0 -277
- package/dist/d1.cjs.map +0 -1
- package/dist/d1.d.cts +0 -72
- package/dist/d1.d.ts +0 -72
- package/dist/d1.js +0 -277
- package/dist/d1.js.map +0 -1
- package/dist/pg-3ACXFMU4.cjs +0 -59
- package/dist/pg-3ACXFMU4.cjs.map +0 -1
- package/dist/pg-GHOW3XSG.js +0 -59
- package/dist/sqlite3-EEIKQCJR.js +0 -25
- package/dist/sqlite3-SE4DDYZE.cjs +0 -25
- package/dist/sqlite3-SE4DDYZE.cjs.map +0 -1
- /package/dist/{pg-GHOW3XSG.js.map → postgresql.js.map} +0 -0
- /package/dist/{sqlite3-EEIKQCJR.js.map → sqlite.js.map} +0 -0
package/dist/sqlite3.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SQLite3DriverType,
|
|
3
|
-
checkConnection,
|
|
4
|
-
sqlite3Client,
|
|
5
|
-
sqlite3Connection,
|
|
6
|
-
sqlite3DatabaseDriver,
|
|
7
|
-
sqlite3Pool,
|
|
8
|
-
useSqlite3DatabaseDriver
|
|
9
|
-
} from "./chunk-F7JQ7BX7.js";
|
|
10
1
|
import {
|
|
11
2
|
DefaultSQLiteMigratorOptions,
|
|
12
3
|
InMemorySQLiteDatabase,
|
|
13
4
|
SQLiteConnectionString,
|
|
14
5
|
SQLiteDatabaseName,
|
|
15
|
-
defaultPostgreSqlDatabase,
|
|
16
6
|
isInMemoryDatabase,
|
|
17
7
|
isSQLiteError,
|
|
8
|
+
mapSqliteError,
|
|
18
9
|
sqliteAlwaysNewConnectionPool,
|
|
19
10
|
sqliteAmbientClientConnection,
|
|
20
11
|
sqliteAmbientConnectionPool,
|
|
@@ -27,13 +18,253 @@ import {
|
|
|
27
18
|
sqliteSQLExecutor,
|
|
28
19
|
sqliteSingletonConnectionPool,
|
|
29
20
|
sqliteTransaction,
|
|
30
|
-
tableExists,
|
|
31
|
-
tableExistsSQL,
|
|
32
21
|
toSqlitePoolOptions,
|
|
33
22
|
transactionNestingCounter
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import
|
|
36
|
-
|
|
23
|
+
} from "./chunk-T4A6BQRA.js";
|
|
24
|
+
import {
|
|
25
|
+
defaultSQLiteDatabase,
|
|
26
|
+
sqliteMetadata,
|
|
27
|
+
tableExists
|
|
28
|
+
} from "./chunk-IVJ3SNPJ.js";
|
|
29
|
+
import {
|
|
30
|
+
BatchCommandNoChangesError,
|
|
31
|
+
JSONSerializer,
|
|
32
|
+
SQL,
|
|
33
|
+
canHandleDriverWithConnectionString,
|
|
34
|
+
dumboDatabaseDriverRegistry
|
|
35
|
+
} from "./chunk-XO5T5N5S.js";
|
|
36
|
+
|
|
37
|
+
// src/storage/sqlite/sqlite3/connections/connection.ts
|
|
38
|
+
import sqlite3 from "sqlite3";
|
|
39
|
+
var SQLite3DriverType = "SQLite:sqlite3";
|
|
40
|
+
var sqlite3Client = (options) => {
|
|
41
|
+
let db;
|
|
42
|
+
let isClosed = false;
|
|
43
|
+
const { serializer } = options;
|
|
44
|
+
const connect = () => db ? Promise.resolve() : new Promise((resolve, reject) => {
|
|
45
|
+
try {
|
|
46
|
+
db = new sqlite3.Database(
|
|
47
|
+
options.fileName ?? options.connectionString ?? InMemorySQLiteDatabase,
|
|
48
|
+
sqlite3.OPEN_URI | sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE,
|
|
49
|
+
(err) => {
|
|
50
|
+
if (err) {
|
|
51
|
+
reject(err);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
db.run("PRAGMA journal_mode = WAL;", (err) => {
|
|
57
|
+
if (err) {
|
|
58
|
+
reject(err);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
resolve();
|
|
62
|
+
});
|
|
63
|
+
} catch (error) {
|
|
64
|
+
reject(error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const executeQuery = (sql, params) => new Promise((resolve, reject) => {
|
|
68
|
+
try {
|
|
69
|
+
db.all(sql, params ?? [], (err, result) => {
|
|
70
|
+
if (err) {
|
|
71
|
+
reject(err);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
resolve(result);
|
|
75
|
+
});
|
|
76
|
+
} catch (error) {
|
|
77
|
+
reject(error);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const executeCommand = (sql, params, options2) => new Promise((resolve, reject) => {
|
|
81
|
+
try {
|
|
82
|
+
if (options2?.ignoreChangesCount === true) {
|
|
83
|
+
db.run(
|
|
84
|
+
sql,
|
|
85
|
+
params ?? [],
|
|
86
|
+
function(err, rows) {
|
|
87
|
+
if (err) {
|
|
88
|
+
reject(err);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
resolve({
|
|
92
|
+
rowCount: 0,
|
|
93
|
+
rows: rows ?? []
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
db.serialize(() => {
|
|
99
|
+
db.all(sql, params ?? [], (err, rows) => {
|
|
100
|
+
if (err) {
|
|
101
|
+
reject(err);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
db.get(
|
|
105
|
+
"SELECT changes() as changes",
|
|
106
|
+
(changesErr, row) => {
|
|
107
|
+
if (changesErr) {
|
|
108
|
+
reject(changesErr);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
resolve({
|
|
112
|
+
rowCount: row?.changes ?? 0,
|
|
113
|
+
rows: rows ?? []
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
} catch (error) {
|
|
120
|
+
reject(error);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
connect,
|
|
125
|
+
close: () => {
|
|
126
|
+
if (isClosed) {
|
|
127
|
+
return Promise.resolve();
|
|
128
|
+
}
|
|
129
|
+
isClosed = true;
|
|
130
|
+
if (db)
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
db.close((err) => {
|
|
133
|
+
if (err) {
|
|
134
|
+
reject(err);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
resolve();
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
return Promise.resolve();
|
|
141
|
+
},
|
|
142
|
+
query: async (sql, _options) => {
|
|
143
|
+
const { query, params } = sqliteFormatter.format(sql, {
|
|
144
|
+
serializer
|
|
145
|
+
});
|
|
146
|
+
const result = await executeQuery(
|
|
147
|
+
query,
|
|
148
|
+
params
|
|
149
|
+
);
|
|
150
|
+
return { rowCount: result.length, rows: result };
|
|
151
|
+
},
|
|
152
|
+
batchQuery: async (sqls, _options) => {
|
|
153
|
+
const results = [];
|
|
154
|
+
for (const sql of sqls) {
|
|
155
|
+
const { query, params } = sqliteFormatter.format(sql, {
|
|
156
|
+
serializer
|
|
157
|
+
});
|
|
158
|
+
const result = await executeQuery(
|
|
159
|
+
query,
|
|
160
|
+
params
|
|
161
|
+
);
|
|
162
|
+
results.push({ rowCount: result.length, rows: result });
|
|
163
|
+
}
|
|
164
|
+
return results;
|
|
165
|
+
},
|
|
166
|
+
command: async (sql, options2) => {
|
|
167
|
+
const { query, params } = sqliteFormatter.format(sql, {
|
|
168
|
+
serializer
|
|
169
|
+
});
|
|
170
|
+
return executeCommand(
|
|
171
|
+
query,
|
|
172
|
+
params,
|
|
173
|
+
options2
|
|
174
|
+
);
|
|
175
|
+
},
|
|
176
|
+
batchCommand: async (sqls, options2) => {
|
|
177
|
+
const results = [];
|
|
178
|
+
for (let i = 0; i < sqls.length; i++) {
|
|
179
|
+
const { query, params } = sqliteFormatter.format(sqls[i], {
|
|
180
|
+
serializer
|
|
181
|
+
});
|
|
182
|
+
const result = await executeCommand(
|
|
183
|
+
query,
|
|
184
|
+
params,
|
|
185
|
+
options2
|
|
186
|
+
);
|
|
187
|
+
results.push(result);
|
|
188
|
+
if (options2?.assertChanges && (result.rowCount ?? 0) === 0) {
|
|
189
|
+
throw new BatchCommandNoChangesError(i);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return results;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
var checkConnection = async (fileName, serializer) => {
|
|
197
|
+
const client = sqlite3Client({
|
|
198
|
+
fileName,
|
|
199
|
+
serializer
|
|
200
|
+
});
|
|
201
|
+
try {
|
|
202
|
+
await client.query(SQL`SELECT 1`);
|
|
203
|
+
return { successful: true };
|
|
204
|
+
} catch (error) {
|
|
205
|
+
const code = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
206
|
+
return {
|
|
207
|
+
successful: false,
|
|
208
|
+
errorType: code === "SQLITE_CANTOPEN" ? "ConnectionRefused" : code === "SQLITE_AUTH" ? "Authentication" : "Unknown",
|
|
209
|
+
code,
|
|
210
|
+
error
|
|
211
|
+
};
|
|
212
|
+
} finally {
|
|
213
|
+
await client.close();
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var sqlite3Connection = (options) => sqliteConnection({
|
|
217
|
+
type: "Client",
|
|
218
|
+
driverType: SQLite3DriverType,
|
|
219
|
+
sqliteClientFactory: (connectionOptions) => {
|
|
220
|
+
if ("client" in connectionOptions && connectionOptions.client) {
|
|
221
|
+
return connectionOptions.client;
|
|
222
|
+
}
|
|
223
|
+
return sqlite3Client({
|
|
224
|
+
...connectionOptions,
|
|
225
|
+
serializer: options.serializer
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
connectionOptions: options,
|
|
229
|
+
serializer: options.serializer
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// src/storage/sqlite/sqlite3/index.ts
|
|
233
|
+
var sqlite3Pool = (options) => sqlitePool(
|
|
234
|
+
toSqlitePoolOptions({
|
|
235
|
+
...options,
|
|
236
|
+
driverType: SQLite3DriverType,
|
|
237
|
+
..."connection" in options ? {} : {
|
|
238
|
+
connectionOptions: options,
|
|
239
|
+
sqliteConnectionFactory: (opts) => sqlite3Connection({
|
|
240
|
+
...opts,
|
|
241
|
+
serializer: options.serializer ?? JSONSerializer
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
);
|
|
246
|
+
var tryParseConnectionString = (connectionString) => {
|
|
247
|
+
try {
|
|
248
|
+
return SQLiteConnectionString(connectionString);
|
|
249
|
+
} catch {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
var sqlite3DumboDriver = {
|
|
254
|
+
driverType: SQLite3DriverType,
|
|
255
|
+
createPool: (options) => sqlite3Pool(options),
|
|
256
|
+
sqlFormatter: sqliteFormatter,
|
|
257
|
+
defaultMigratorOptions: DefaultSQLiteMigratorOptions,
|
|
258
|
+
canHandle: canHandleDriverWithConnectionString(
|
|
259
|
+
SQLite3DriverType,
|
|
260
|
+
tryParseConnectionString
|
|
261
|
+
),
|
|
262
|
+
databaseMetadata: sqliteMetadata
|
|
263
|
+
};
|
|
264
|
+
var useSqlite3DumboDriver = () => {
|
|
265
|
+
dumboDatabaseDriverRegistry.register(SQLite3DriverType, sqlite3DumboDriver);
|
|
266
|
+
};
|
|
267
|
+
useSqlite3DumboDriver();
|
|
37
268
|
export {
|
|
38
269
|
DefaultSQLiteMigratorOptions,
|
|
39
270
|
InMemorySQLiteDatabase,
|
|
@@ -41,32 +272,30 @@ export {
|
|
|
41
272
|
SQLiteConnectionString,
|
|
42
273
|
SQLiteDatabaseName,
|
|
43
274
|
checkConnection,
|
|
44
|
-
|
|
45
|
-
sqlite3DatabaseDriver as databaseDriver,
|
|
46
|
-
defaultPostgreSqlDatabase,
|
|
275
|
+
defaultSQLiteDatabase,
|
|
47
276
|
isInMemoryDatabase,
|
|
48
277
|
isSQLiteError,
|
|
278
|
+
mapSqliteError,
|
|
49
279
|
sqlite3Client,
|
|
50
280
|
sqlite3Connection,
|
|
51
|
-
|
|
281
|
+
sqlite3DumboDriver,
|
|
52
282
|
sqlite3Pool,
|
|
53
283
|
sqliteAlwaysNewConnectionPool,
|
|
54
284
|
sqliteAmbientClientConnection,
|
|
55
285
|
sqliteAmbientConnectionPool,
|
|
56
|
-
sqlite3Client as sqliteClient,
|
|
57
286
|
sqliteClientConnection,
|
|
58
287
|
sqliteConnection,
|
|
59
288
|
sqliteExecute,
|
|
60
289
|
sqliteFormatter,
|
|
290
|
+
sqliteMetadata,
|
|
61
291
|
sqlitePool,
|
|
62
292
|
sqlitePoolClientConnection,
|
|
63
293
|
sqliteSQLExecutor,
|
|
64
294
|
sqliteSingletonConnectionPool,
|
|
65
295
|
sqliteTransaction,
|
|
66
296
|
tableExists,
|
|
67
|
-
tableExistsSQL,
|
|
68
297
|
toSqlitePoolOptions,
|
|
69
298
|
transactionNestingCounter,
|
|
70
|
-
|
|
299
|
+
useSqlite3DumboDriver
|
|
71
300
|
};
|
|
72
301
|
//# sourceMappingURL=sqlite3.js.map
|
package/dist/sqlite3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/storage/sqlite/sqlite3/connections/connection.ts","../src/storage/sqlite/sqlite3/index.ts"],"sourcesContent":["import sqlite3 from 'sqlite3';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n BatchCommandNoChangesError,\n SQL,\n type Connection,\n type QueryResult,\n type QueryResultRow,\n type SQLQueryOptions,\n} from '../../../../core';\nimport type {\n SQLiteClient,\n SQLiteClientOrPoolClient,\n SQLiteConnectionOptions,\n SQLiteDriverType,\n SQLiteFileNameOrConnectionString,\n SQLiteTransaction,\n SQLiteTransactionOptions,\n} from '../../core';\nimport {\n InMemorySQLiteDatabase,\n sqliteConnection,\n type BatchSQLiteCommandOptions,\n type SQLiteClientOptions,\n type SQLiteCommandOptions,\n type SQLiteParameters,\n} from '../../core/connections';\nimport { sqliteFormatter } from '../../core/sql/formatter';\n\nexport type SQLite3DriverType = SQLiteDriverType<'sqlite3'>;\nexport const SQLite3DriverType: SQLite3DriverType = 'SQLite:sqlite3';\n\nexport type ConnectionCheckResult =\n | { successful: true }\n | {\n successful: false;\n code: string | undefined;\n errorType: 'ConnectionRefused' | 'Authentication' | 'Unknown';\n error: unknown;\n };\n\nexport type SQLite3ClientOptions = SQLiteClientOptions &\n SQLiteFileNameOrConnectionString;\n\nexport type SQLite3Client = SQLiteClientOrPoolClient;\n\nexport type SQLite3ConnectionOptions = SQLiteConnectionOptions &\n ((SQLite3ClientOptions & { client?: never }) | { client: SQLite3Client });\n\nexport type SQLite3Connection<\n ClientType extends SQLiteClientOrPoolClient = SQLiteClientOrPoolClient,\n> = Connection<\n SQLite3Connection,\n SQLite3DriverType,\n ClientType,\n SQLiteTransaction<SQLite3Connection>,\n SQLiteTransactionOptions\n>;\n\nexport const sqlite3Client = (\n options: SQLite3ClientOptions & {\n serializer: JSONSerializer;\n },\n): SQLiteClient => {\n let db: sqlite3.Database;\n\n let isClosed = false;\n\n const { serializer } = options;\n\n const connect: () => Promise<void> = () =>\n db\n ? Promise.resolve() // If db is already initialized, resolve immediately\n : new Promise((resolve, reject) => {\n try {\n db = new sqlite3.Database(\n options.fileName ??\n options.connectionString ??\n InMemorySQLiteDatabase,\n sqlite3.OPEN_URI | sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE,\n (err) => {\n if (err) {\n reject(err);\n return;\n }\n },\n );\n db.run('PRAGMA journal_mode = WAL;', (err) => {\n if (err) {\n reject(err);\n return;\n }\n\n resolve();\n });\n } catch (error) {\n reject(error as Error);\n }\n });\n\n const executeQuery = <T>(\n sql: string,\n params?: SQLiteParameters[],\n ): Promise<T[]> =>\n new Promise((resolve, reject) => {\n try {\n db.all(sql, params ?? [], (err: Error | null, result: T[]) => {\n if (err) {\n reject(err);\n return;\n }\n\n resolve(result);\n });\n } catch (error) {\n reject(error as Error);\n }\n });\n\n const executeCommand = <Result extends QueryResultRow = QueryResultRow>(\n sql: string,\n params?: SQLiteParameters[],\n options?: SQLiteCommandOptions,\n ): Promise<QueryResult<Result>> =>\n new Promise((resolve, reject) => {\n try {\n if (options?.ignoreChangesCount === true) {\n db.run(\n sql,\n params ?? [],\n function (err: Error | null, rows: Result[]) {\n if (err) {\n reject(err);\n return;\n }\n resolve({\n rowCount: 0,\n rows: rows ?? [],\n });\n },\n );\n }\n // OD: 2026-01-21\n // This is needed as SQLite does not return changes count properly\n // We need to query it separately with SELECT changes()\n // This may be fixed eventually in sqlite3 library as Node.js team did here:\n // https://github.com/nodejs/node/issues/57344\n // But for now, we do it manually, as a workaround\n // We also serialize it to avoid race conditions\n db.serialize(() => {\n db.all(sql, params ?? [], (err: Error | null, rows: Result[]) => {\n if (err) {\n reject(err);\n return;\n }\n db.get(\n 'SELECT changes() as changes',\n (changesErr: Error | null, row: { changes: number } | null) => {\n if (changesErr) {\n reject(changesErr);\n return;\n }\n resolve({\n rowCount: row?.changes ?? 0,\n rows: rows ?? [],\n });\n },\n );\n });\n });\n } catch (error) {\n reject(error as Error);\n }\n });\n\n return {\n connect,\n close: (): Promise<void> => {\n if (isClosed) {\n return Promise.resolve();\n }\n isClosed = true;\n if (db)\n return new Promise((resolve, reject) => {\n db.close((err: Error | null) => {\n if (err) {\n reject(err);\n return;\n }\n\n resolve();\n });\n });\n return Promise.resolve();\n },\n query: async <Result extends QueryResultRow = QueryResultRow>(\n sql: SQL,\n _options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>> => {\n const { query, params } = sqliteFormatter.format(sql, {\n serializer,\n });\n const result = await executeQuery<Result>(\n query,\n params as SQLiteParameters[],\n );\n return { rowCount: result.length, rows: result };\n },\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n sqls: SQL[],\n _options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n const results: QueryResult<Result>[] = [];\n for (const sql of sqls) {\n const { query, params } = sqliteFormatter.format(sql, {\n serializer,\n });\n const result = await executeQuery<Result>(\n query,\n params as SQLiteParameters[],\n );\n results.push({ rowCount: result.length, rows: result });\n }\n return results;\n },\n command: async <Result extends QueryResultRow = QueryResultRow>(\n sql: SQL,\n options?: SQLiteCommandOptions,\n ): Promise<QueryResult<Result>> => {\n const { query, params } = sqliteFormatter.format(sql, {\n serializer,\n });\n\n return executeCommand<Result>(\n query,\n params as SQLiteParameters[],\n options,\n );\n },\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n sqls: SQL[],\n options?: BatchSQLiteCommandOptions,\n ): Promise<QueryResult<Result>[]> => {\n const results: QueryResult<Result>[] = [];\n\n for (let i = 0; i < sqls.length; i++) {\n const { query, params } = sqliteFormatter.format(sqls[i]!, {\n serializer,\n });\n const result = await executeCommand<Result>(\n query,\n params as SQLiteParameters[],\n options,\n );\n results.push(result);\n\n if (options?.assertChanges && (result.rowCount ?? 0) === 0) {\n throw new BatchCommandNoChangesError(i);\n }\n }\n return results;\n },\n };\n};\n\nexport const checkConnection = async (\n fileName: string,\n serializer: JSONSerializer,\n): Promise<ConnectionCheckResult> => {\n const client = sqlite3Client({\n fileName,\n serializer,\n });\n\n try {\n await client.query(SQL`SELECT 1`);\n return { successful: true };\n } catch (error) {\n const code =\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string'\n ? error.code\n : undefined;\n\n return {\n successful: false,\n errorType:\n code === 'SQLITE_CANTOPEN'\n ? 'ConnectionRefused'\n : code === 'SQLITE_AUTH'\n ? 'Authentication'\n : 'Unknown',\n code,\n error,\n };\n } finally {\n await client.close();\n }\n};\n\nexport const sqlite3Connection = (\n options: SQLite3ConnectionOptions & { serializer: JSONSerializer },\n) =>\n sqliteConnection<SQLite3Connection, SQLite3ConnectionOptions>({\n type: 'Client',\n driverType: SQLite3DriverType,\n sqliteClientFactory: (connectionOptions) => {\n if ('client' in connectionOptions && connectionOptions.client) {\n return connectionOptions.client;\n }\n return sqlite3Client({\n ...connectionOptions,\n serializer: options.serializer,\n });\n },\n connectionOptions: options,\n serializer: options.serializer,\n });\n","export * from './connections';\nimport {\n canHandleDriverWithConnectionString,\n dumboDatabaseDriverRegistry,\n JSONSerializer,\n type DumboConnectionOptions,\n type DumboDatabaseDriver,\n} from '../../../core';\nimport {\n DefaultSQLiteMigratorOptions,\n SQLiteConnectionString,\n sqliteFormatter,\n sqliteMetadata,\n sqlitePool,\n toSqlitePoolOptions,\n type SQLitePool,\n type SQLitePoolOptions,\n} from '../core';\nimport {\n sqlite3Connection,\n SQLite3DriverType,\n type SQLite3Connection,\n type SQLite3ConnectionOptions,\n} from './connections';\n\nexport type SQLite3DumboOptions = Omit<\n SQLitePoolOptions<SQLite3Connection, SQLite3ConnectionOptions>,\n 'driverType'\n> &\n SQLite3ConnectionOptions & { serializer?: JSONSerializer };\n\nexport type SQLite3PoolOptions = SQLite3DumboOptions;\n\nexport type Sqlite3Pool = SQLitePool<SQLite3Connection>;\n\nexport const sqlite3Pool = (options: SQLite3DumboOptions) =>\n sqlitePool(\n toSqlitePoolOptions({\n ...options,\n driverType: SQLite3DriverType,\n ...('connection' in options\n ? {}\n : {\n connectionOptions: options as SQLite3ConnectionOptions,\n sqliteConnectionFactory: (opts: SQLite3ConnectionOptions) =>\n sqlite3Connection({\n ...opts,\n serializer: options.serializer ?? JSONSerializer,\n }),\n }),\n }),\n );\n\nconst tryParseConnectionString = (connectionString: string) => {\n try {\n return SQLiteConnectionString(connectionString);\n } catch {\n return null;\n }\n};\n\nexport const sqlite3DumboDriver = {\n driverType: SQLite3DriverType,\n createPool: (options) => sqlite3Pool(options as SQLite3DumboOptions),\n sqlFormatter: sqliteFormatter,\n defaultMigratorOptions: DefaultSQLiteMigratorOptions,\n canHandle: canHandleDriverWithConnectionString(\n SQLite3DriverType,\n tryParseConnectionString,\n ),\n databaseMetadata: sqliteMetadata,\n} satisfies DumboDatabaseDriver<\n SQLite3Connection,\n SQLite3DumboOptions,\n Sqlite3Pool\n>;\n\nexport const useSqlite3DumboDriver = () => {\n dumboDatabaseDriverRegistry.register(SQLite3DriverType, sqlite3DumboDriver);\n};\n\nexport type SQLite3DumboConnectionOptions = DumboConnectionOptions<\n typeof sqlite3DumboDriver\n> & { connectionString: string | SQLiteConnectionString };\n\nuseSqlite3DumboDriver();\n\nexport * from './connections';\nexport * from './formatter';\nexport * from './transactions';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,aAAa;AA8Bb,IAAM,oBAAuC;AA6B7C,IAAM,gBAAgB,CAC3B,YAGiB;AACjB,MAAI;AAEJ,MAAI,WAAW;AAEf,QAAM,EAAE,WAAW,IAAI;AAEvB,QAAM,UAA+B,MACnC,KACI,QAAQ,QAAQ,IAChB,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,QAAI;AACF,WAAK,IAAI,QAAQ;AAAA,QACf,QAAQ,YACN,QAAQ,oBACR;AAAA,QACF,QAAQ,WAAW,QAAQ,iBAAiB,QAAQ;AAAA,QACpD,CAAC,QAAQ;AACP,cAAI,KAAK;AACP,mBAAO,GAAG;AACV;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,SAAG,IAAI,8BAA8B,CAAC,QAAQ;AAC5C,YAAI,KAAK;AACP,iBAAO,GAAG;AACV;AAAA,QACF;AAEA,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,SAAS,OAAO;AACd,aAAO,KAAc;AAAA,IACvB;AAAA,EACF,CAAC;AAEP,QAAM,eAAe,CACnB,KACA,WAEA,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,QAAI;AACF,SAAG,IAAI,KAAK,UAAU,CAAC,GAAG,CAAC,KAAmB,WAAgB;AAC5D,YAAI,KAAK;AACP,iBAAO,GAAG;AACV;AAAA,QACF;AAEA,gBAAQ,MAAM;AAAA,MAChB,CAAC;AAAA,IACH,SAAS,OAAO;AACd,aAAO,KAAc;AAAA,IACvB;AAAA,EACF,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;AAAA,IACT;AAAA,IACA;AAAA,EACF;AAAA,EACA,kBAAkB;AACpB;AAMO,IAAM,wBAAwB,MAAM;AACzC,8BAA4B,SAAS,mBAAmB,kBAAkB;AAC5E;AAMA,sBAAsB;","names":["options"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-driven-io/dumbo",
|
|
3
|
-
"version": "0.13.0-beta.
|
|
3
|
+
"version": "0.13.0-beta.21",
|
|
4
4
|
"description": "Dumbo - tools for dealing with Relational Databases",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"test": "run-s test:unit test:int test:e2e",
|
|
11
11
|
"test:postgresql": "run-s test:unit:postgresql test:int:postgresql test:e2e:postgresql",
|
|
12
12
|
"test:sqlite": "run-s test:unit:sqlite test:int:sqlite test:e2e:sqlite",
|
|
13
|
-
"test:unit": "glob -c \"node --import tsx --test\" **/*.unit.spec.ts",
|
|
14
|
-
"test:unit:postgresql": "glob -c \"node --import tsx --test\" **/postgresql/**/*unit.spec.ts",
|
|
15
|
-
"test:unit:sqlite": "glob -c \"node --import tsx --test\" **/sqlite/**/*unit.spec.ts",
|
|
16
|
-
"test:int": "glob -c \"node --import tsx --test\" **/*.int.spec.ts",
|
|
17
|
-
"test:int:postgresql": "glob -c \"node --import tsx --test\" **/postgresql/**/*int.spec.ts",
|
|
18
|
-
"test:int:sqlite": "glob -c \"node --import tsx --test\" **/sqlite/**/*int.spec.ts",
|
|
19
|
-
"test:e2e": "glob -c \"node --import tsx --test\" **/*.e2e.spec.ts",
|
|
20
|
-
"test:e2e:postgresql": "glob -c \"node --import tsx --test\" **/postgresql/**/*e2e.spec.ts",
|
|
21
|
-
"test:e2e:sqlite": "glob -c \"node --import tsx --test\" **/sqlite/**/*e2e.spec.ts",
|
|
13
|
+
"test:unit": "glob-bin -d -c \"node --import tsx --test\" **/*.unit.spec.ts",
|
|
14
|
+
"test:unit:postgresql": "glob-bin -d -c \"node --import tsx --test\" **/postgresql/**/*unit.spec.ts",
|
|
15
|
+
"test:unit:sqlite": "glob-bin -d -c \"node --import tsx --test\" **/sqlite/**/*unit.spec.ts",
|
|
16
|
+
"test:int": "glob-bin -d -c \"node --import tsx --test\" **/*.int.spec.ts",
|
|
17
|
+
"test:int:postgresql": "glob-bin -d -c \"node --import tsx --test\" **/postgresql/**/*int.spec.ts",
|
|
18
|
+
"test:int:sqlite": "glob-bin -d -c \"node --import tsx --test\" **/sqlite/**/*int.spec.ts",
|
|
19
|
+
"test:e2e": "glob-bin -d -c \"node --import tsx --test\" **/*.e2e.spec.ts",
|
|
20
|
+
"test:e2e:postgresql": "glob-bin -d -c \"node --import tsx --test\" **/postgresql/**/*e2e.spec.ts",
|
|
21
|
+
"test:e2e:sqlite": "glob-bin -d -c \"node --import tsx --test\" **/sqlite/**/*e2e.spec.ts",
|
|
22
22
|
"test:watch": "node --import tsx --test --watch",
|
|
23
|
-
"test:unit:watch": "glob -c \"node --import tsx --test --watch\" **/*.unit.spec.ts",
|
|
24
|
-
"test:int:watch": "glob -c \"node --import tsx --test --watch\" **/*.int.spec.ts",
|
|
25
|
-
"test:e2e:watch": "glob -c \"node --import tsx --test --watch\" **/*.e2e.spec.ts",
|
|
23
|
+
"test:unit:watch": "glob-bin -d -c \"node --import tsx --test --watch\" **/*.unit.spec.ts",
|
|
24
|
+
"test:int:watch": "glob-bin -d -c \"node --import tsx --test --watch\" **/*.int.spec.ts",
|
|
25
|
+
"test:e2e:watch": "glob-bin -d -c \"node --import tsx --test --watch\" **/*.e2e.spec.ts",
|
|
26
26
|
"benchmark": "node --import tsx src/benchmarks/index.ts"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
@@ -48,6 +48,16 @@
|
|
|
48
48
|
"default": "./dist/index.cjs"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
+
"./postgresql": {
|
|
52
|
+
"import": {
|
|
53
|
+
"types": "./dist/postgresql.d.ts",
|
|
54
|
+
"default": "./dist/postgresql.js"
|
|
55
|
+
},
|
|
56
|
+
"require": {
|
|
57
|
+
"types": "./dist/postgresql.d.cts",
|
|
58
|
+
"default": "./dist/postgresql.cjs"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
51
61
|
"./pg": {
|
|
52
62
|
"import": {
|
|
53
63
|
"types": "./dist/pg.d.ts",
|
|
@@ -58,6 +68,16 @@
|
|
|
58
68
|
"default": "./dist/pg.cjs"
|
|
59
69
|
}
|
|
60
70
|
},
|
|
71
|
+
"./sqlite": {
|
|
72
|
+
"import": {
|
|
73
|
+
"types": "./dist/sqlite.d.ts",
|
|
74
|
+
"default": "./dist/sqlite.js"
|
|
75
|
+
},
|
|
76
|
+
"require": {
|
|
77
|
+
"types": "./dist/sqlite.d.cts",
|
|
78
|
+
"default": "./dist/sqlite.cjs"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
61
81
|
"./sqlite3": {
|
|
62
82
|
"import": {
|
|
63
83
|
"types": "./dist/sqlite3.d.ts",
|
|
@@ -68,30 +88,33 @@
|
|
|
68
88
|
"default": "./dist/sqlite3.cjs"
|
|
69
89
|
}
|
|
70
90
|
},
|
|
71
|
-
"./
|
|
91
|
+
"./cloudflare": {
|
|
72
92
|
"import": {
|
|
73
|
-
"types": "./dist/
|
|
74
|
-
"default": "./dist/
|
|
93
|
+
"types": "./dist/cloudflare.d.ts",
|
|
94
|
+
"default": "./dist/cloudflare.js"
|
|
75
95
|
},
|
|
76
96
|
"require": {
|
|
77
|
-
"types": "./dist/
|
|
78
|
-
"default": "./dist/
|
|
97
|
+
"types": "./dist/cloudflare.d.cts",
|
|
98
|
+
"default": "./dist/cloudflare.cjs"
|
|
79
99
|
}
|
|
80
100
|
}
|
|
81
101
|
},
|
|
82
102
|
"typesVersions": {
|
|
83
103
|
"*": {
|
|
84
|
-
"
|
|
85
|
-
"./dist/
|
|
104
|
+
"postgresql": [
|
|
105
|
+
"./dist/postgresql.d.ts"
|
|
86
106
|
],
|
|
87
107
|
"pg": [
|
|
88
108
|
"./dist/pg.d.ts"
|
|
89
109
|
],
|
|
110
|
+
"sqlite": [
|
|
111
|
+
"./dist/sqlite.d.ts"
|
|
112
|
+
],
|
|
90
113
|
"sqlite3": [
|
|
91
114
|
"./dist/sqlite3.d.ts"
|
|
92
115
|
],
|
|
93
|
-
"
|
|
94
|
-
"./dist/
|
|
116
|
+
"cloudflare": [
|
|
117
|
+
"./dist/cloudflare.d.ts"
|
|
95
118
|
]
|
|
96
119
|
}
|
|
97
120
|
},
|
|
@@ -102,16 +125,33 @@
|
|
|
102
125
|
"dist"
|
|
103
126
|
],
|
|
104
127
|
"dependencies": {
|
|
105
|
-
"
|
|
106
|
-
"sqlite3": "^5.1.7"
|
|
128
|
+
"uuid": "^13.0.0"
|
|
107
129
|
},
|
|
108
130
|
"peerDependencies": {
|
|
109
|
-
"@types
|
|
110
|
-
"pg": "^8.16.
|
|
111
|
-
"pg
|
|
112
|
-
"
|
|
131
|
+
"@cloudflare/workers-types": "^4.20260127.0",
|
|
132
|
+
"@types/pg": "^8.16.0",
|
|
133
|
+
"pg": "^8.17.2",
|
|
134
|
+
"sqlite3": "^5.1.7"
|
|
135
|
+
},
|
|
136
|
+
"peerDependenciesMeta": {
|
|
137
|
+
"@types/pg": {
|
|
138
|
+
"optional": true
|
|
139
|
+
},
|
|
140
|
+
"pg": {
|
|
141
|
+
"optional": true
|
|
142
|
+
},
|
|
143
|
+
"sqlite3": {
|
|
144
|
+
"optional": true
|
|
145
|
+
},
|
|
146
|
+
"@cloudflare/workers-types": {
|
|
147
|
+
"optional": true
|
|
148
|
+
}
|
|
113
149
|
},
|
|
114
150
|
"devDependencies": {
|
|
115
|
-
"@types
|
|
151
|
+
"@cloudflare/workers-types": "^4.20260127.0",
|
|
152
|
+
"@types/node": "^25.0.10",
|
|
153
|
+
"@types/pg": "^8.16.0",
|
|
154
|
+
"pg": "^8.17.2",
|
|
155
|
+
"sqlite3": "^5.1.7"
|
|
116
156
|
}
|
|
117
157
|
}
|
package/dist/chunk-A7TC7IOP.cjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
var _chunkOJ34O3Q2cjs = require('./chunk-OJ34O3Q2.cjs');
|
|
4
|
-
|
|
5
|
-
// src/storage/all/connections/connectionString.ts
|
|
6
|
-
var parseConnectionString = (connectionString) => {
|
|
7
|
-
if (connectionString.startsWith("postgresql://") || connectionString.startsWith("postgres://")) {
|
|
8
|
-
return {
|
|
9
|
-
databaseType: "PostgreSQL",
|
|
10
|
-
driverName: "pg"
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
if (connectionString.startsWith("file:") || connectionString === ":memory:" || connectionString.startsWith("/") || connectionString.startsWith("./")) {
|
|
14
|
-
return {
|
|
15
|
-
databaseType: "SQLite",
|
|
16
|
-
driverName: "sqlite3"
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
if (connectionString.startsWith("d1:")) {
|
|
20
|
-
return {
|
|
21
|
-
databaseType: "SQLite",
|
|
22
|
-
driverName: "d1"
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
throw new Error(
|
|
26
|
-
`Unsupported database connection string: ${connectionString}`
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// src/storage/all/index.ts
|
|
31
|
-
_chunkOJ34O3Q2cjs.dumboDatabaseDriverRegistry.register(
|
|
32
|
-
"PostgreSQL:pg",
|
|
33
|
-
() => Promise.resolve().then(() => _interopRequireWildcard(require("./pg-3ACXFMU4.cjs"))).then((m) => m.databaseDriver)
|
|
34
|
-
);
|
|
35
|
-
_chunkOJ34O3Q2cjs.dumboDatabaseDriverRegistry.register(
|
|
36
|
-
"SQLite:sqlite3",
|
|
37
|
-
() => Promise.resolve().then(() => _interopRequireWildcard(require("./sqlite3-SE4DDYZE.cjs"))).then((m) => m.databaseDriver)
|
|
38
|
-
);
|
|
39
|
-
function dumbo(options) {
|
|
40
|
-
const { driverType } = options;
|
|
41
|
-
const driver = _nullishCoalesce(options.driver, () => ( _chunkOJ34O3Q2cjs.dumboDatabaseDriverRegistry.tryGet(options)));
|
|
42
|
-
if (driver === null) {
|
|
43
|
-
throw new Error(`No plugin found for driver type: ${driverType}`);
|
|
44
|
-
}
|
|
45
|
-
return driver.createPool({
|
|
46
|
-
...options,
|
|
47
|
-
driverType: driver.driverType
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
exports.parseConnectionString = parseConnectionString; exports.dumbo = dumbo;
|
|
55
|
-
//# sourceMappingURL=chunk-A7TC7IOP.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-A7TC7IOP.cjs","../src/storage/all/connections/connectionString.ts","../src/storage/all/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACKO,IAAM,sBAAA,EAAwB,CACnC,gBAAA,EAAA,GAC4B;AAC5B,EAAA,GAAA,CACE,gBAAA,CAAiB,UAAA,CAAW,eAAe,EAAA,GAC3C,gBAAA,CAAiB,UAAA,CAAW,aAAa,CAAA,EACzC;AACA,IAAA,OAAO;AAAA,MACL,YAAA,EAAc,YAAA;AAAA,MACd,UAAA,EAAY;AAAA,IACd,CAAA;AAAA,EACF;AAEA,EAAA,GAAA,CACE,gBAAA,CAAiB,UAAA,CAAW,OAAO,EAAA,GACnC,iBAAA,IAAqB,WAAA,GACrB,gBAAA,CAAiB,UAAA,CAAW,GAAG,EAAA,GAC/B,gBAAA,CAAiB,UAAA,CAAW,IAAI,CAAA,EAChC;AACA,IAAA,OAAO;AAAA,MACL,YAAA,EAAc,QAAA;AAAA,MACd,UAAA,EAAY;AAAA,IACd,CAAA;AAAA,EACF;AAEA,EAAA,GAAA,CAAI,gBAAA,CAAiB,UAAA,CAAW,KAAK,CAAA,EAAG;AACtC,IAAA,OAAO;AAAA,MACL,YAAA,EAAc,QAAA;AAAA,MACd,UAAA,EAAY;AAAA,IACd,CAAA;AAAA,EACF;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,wCAAA,EAA2C,gBAAgB,CAAA;AAAA,EAAA;AAE/D;ADhBA;AACA;AEpBA;AAA4B,EAAA;AAAS,EAAA;AAErC;AAEA;AAA4B,EAAA;AAAS,EAAA;AAErC;AAEO;AAKL,EAAA;AAEA,EAAA;AAIA,EAAA;AACE,IAAA;AAAgE,EAAA;AAGlE,EAAA;AAAyB,IAAA;AACpB,IAAA;AACgB,EAAA;AAEvB;AFaA;AACA;AACA;AACA;AACA","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-A7TC7IOP.cjs","sourcesContent":[null,"import type { DatabaseDriverTypeParts, DatabaseType } from '../../../core';\n\nexport type DatabaseConnectionString<\n DatabaseTypeName extends DatabaseType = DatabaseType,\n Format extends string = string,\n> = Format & {\n _databaseType: DatabaseTypeName;\n};\n\nexport const parseConnectionString = (\n connectionString: DatabaseConnectionString | string,\n): DatabaseDriverTypeParts => {\n if (\n connectionString.startsWith('postgresql://') ||\n connectionString.startsWith('postgres://')\n ) {\n return {\n databaseType: 'PostgreSQL',\n driverName: 'pg',\n };\n }\n\n if (\n connectionString.startsWith('file:') ||\n connectionString === ':memory:' ||\n connectionString.startsWith('/') ||\n connectionString.startsWith('./')\n ) {\n return {\n databaseType: 'SQLite',\n driverName: 'sqlite3',\n };\n }\n\n if (connectionString.startsWith('d1:')) {\n return {\n databaseType: 'SQLite',\n driverName: 'd1',\n };\n }\n\n throw new Error(\n `Unsupported database connection string: ${connectionString}`,\n );\n};\n","import {\n dumboDatabaseDriverRegistry,\n type AnyDumboDatabaseDriver,\n type DumboConnectionOptions,\n type ExtractDumboTypeFromDriver,\n} from '../../core';\n\nexport * from './connections';\n\ndumboDatabaseDriverRegistry.register('PostgreSQL:pg', () =>\n import('../postgresql/pg').then((m) => m.databaseDriver),\n);\n\ndumboDatabaseDriverRegistry.register('SQLite:sqlite3', () =>\n import('../sqlite/sqlite3').then((m) => m.databaseDriver),\n);\n\nexport function dumbo<\n DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver,\n ConnectionOptions extends\n DumboConnectionOptions<DatabaseDriver> = DumboConnectionOptions<DatabaseDriver>,\n>(options: ConnectionOptions): ExtractDumboTypeFromDriver<DatabaseDriver> {\n const { driverType } = options;\n\n const driver =\n options.driver ??\n dumboDatabaseDriverRegistry.tryGet<DatabaseDriver>(options);\n\n if (driver === null) {\n throw new Error(`No plugin found for driver type: ${driverType}`);\n }\n\n return driver.createPool({\n ...options,\n driverType: driver.driverType,\n }) as ExtractDumboTypeFromDriver<DatabaseDriver>;\n}\n"]}
|