@event-driven-io/dumbo 0.13.0-beta.13 → 0.13.0-beta.15
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-DZIR7MO6.js → chunk-2P3EJGSV.js} +2 -2
- package/dist/chunk-2P3EJGSV.js.map +1 -0
- package/dist/{chunk-VWGLHK7D.cjs → chunk-GTTOLSV6.cjs} +3 -3
- package/dist/{chunk-VWGLHK7D.cjs.map → chunk-GTTOLSV6.cjs.map} +1 -1
- package/dist/{chunk-U3F55PXF.cjs → chunk-I6WQ6ILG.cjs} +62 -50
- package/dist/chunk-I6WQ6ILG.cjs.map +1 -0
- package/dist/{chunk-VF2TZQ6W.cjs → chunk-J5BB5WSH.cjs} +268 -103
- package/dist/chunk-J5BB5WSH.cjs.map +1 -0
- package/dist/{chunk-PRWAQUUZ.js → chunk-JZS74K5L.js} +32 -20
- package/dist/chunk-JZS74K5L.js.map +1 -0
- package/dist/{chunk-YYVFWVJY.js → chunk-LKUVAHI7.js} +247 -82
- package/dist/chunk-LKUVAHI7.js.map +1 -0
- package/dist/cloudflare.cjs +36 -21
- package/dist/cloudflare.cjs.map +1 -1
- package/dist/cloudflare.d.cts +6 -5
- package/dist/cloudflare.d.ts +6 -5
- package/dist/cloudflare.js +28 -13
- package/dist/cloudflare.js.map +1 -1
- package/dist/{columnProcessors-C-XOoC4h.d.cts → columnProcessors-BTltQv2d.d.cts} +1 -1
- package/dist/{columnProcessors-BtO0Ebie.d.ts → columnProcessors-CSjguQe9.d.ts} +1 -1
- package/dist/{connectionString-D0_iOILV.d.ts → connectionString-Cn7dKOIw.d.cts} +114 -63
- package/dist/{connectionString-D0_iOILV.d.cts → connectionString-Cn7dKOIw.d.ts} +114 -63
- package/dist/{index-C6FIVKrD.d.cts → index-BIH9BOl_.d.ts} +6 -3
- package/dist/{index-ClSDX7i7.d.ts → index-C75hGagy.d.cts} +6 -3
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -4
- package/dist/pg.cjs +124 -78
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +30 -16
- package/dist/pg.d.ts +30 -16
- package/dist/pg.js +94 -48
- package/dist/pg.js.map +1 -1
- package/dist/sqlite3.cjs +42 -24
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +25 -7
- package/dist/sqlite3.d.ts +25 -7
- package/dist/sqlite3.js +30 -12
- package/dist/sqlite3.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-DZIR7MO6.js.map +0 -1
- package/dist/chunk-PRWAQUUZ.js.map +0 -1
- package/dist/chunk-U3F55PXF.cjs.map +0 -1
- package/dist/chunk-VF2TZQ6W.cjs.map +0 -1
- package/dist/chunk-YYVFWVJY.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dumboDatabaseDriverRegistry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LKUVAHI7.js";
|
|
4
4
|
|
|
5
5
|
// src/storage/all/connections/connectionString.ts
|
|
6
6
|
var parseConnectionString = (connectionString) => {
|
|
@@ -44,4 +44,4 @@ export {
|
|
|
44
44
|
parseConnectionString,
|
|
45
45
|
dumbo
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-2P3EJGSV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/storage/all/connections/connectionString.ts","../src/storage/all/index.ts"],"sourcesContent":["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 ExtractDumboDatabaseDriverOptions,\n type ExtractDumboTypeFromDriver,\n type JSONSerializationOptions,\n} from '../../core';\n\nexport * from './connections';\n\nexport function dumbo<Driver extends AnyDumboDatabaseDriver>(\n options: ExtractDumboDatabaseDriverOptions<Driver> & {\n driver: Driver;\n } & JSONSerializationOptions,\n): ExtractDumboTypeFromDriver<Driver>;\n\nexport function dumbo<\n DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver,\n ConnectionOptions extends DumboConnectionOptions<DatabaseDriver> =\n DumboConnectionOptions<DatabaseDriver>,\n>(\n options: ConnectionOptions & { driver?: never },\n): ExtractDumboTypeFromDriver<DatabaseDriver>;\n\nexport function dumbo<\n DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver,\n>(\n options: DumboConnectionOptions<DatabaseDriver>,\n): 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"],"mappings":";;;;;AASO,IAAM,wBAAwB,CACnC,qBAC4B;AAC5B,MACE,iBAAiB,WAAW,eAAe,KAC3C,iBAAiB,WAAW,aAAa,GACzC;AACA,WAAO;AAAA,MACL,cAAc;AAAA,MACd,YAAY;AAAA,IACd;AAAA,EACF;AAEA,MACE,iBAAiB,WAAW,OAAO,KACnC,qBAAqB,cACrB,iBAAiB,WAAW,GAAG,KAC/B,iBAAiB,WAAW,IAAI,GAChC;AACA,WAAO;AAAA,MACL,cAAc;AAAA,MACd,YAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI,iBAAiB,WAAW,KAAK,GAAG;AACtC,WAAO;AAAA,MACL,cAAc;AAAA,MACd,YAAY;AAAA,IACd;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR,2CAA2C,gBAAgB;AAAA,EAC7D;AACF;;;ACnBO,SAAS,MAGd,SAC4C;AAC5C,QAAM,EAAE,WAAW,IAAI;AAEvB,QAAM,SACJ,QAAQ,UACR,4BAA4B,OAAuB,OAAO;AAE5D,MAAI,WAAW,MAAM;AACnB,UAAM,IAAI,MAAM,oCAAoC,UAAU,EAAE;AAAA,EAClE;AAEA,SAAO,OAAO,WAAW;AAAA,IACvB,GAAG;AAAA,IACH,YAAY,OAAO;AAAA,EACrB,CAAC;AACH;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkJ5BB5WSHcjs = require('./chunk-J5BB5WSH.cjs');
|
|
4
4
|
|
|
5
5
|
// src/storage/all/connections/connectionString.ts
|
|
6
6
|
var parseConnectionString = (connectionString) => {
|
|
@@ -30,7 +30,7 @@ var parseConnectionString = (connectionString) => {
|
|
|
30
30
|
// src/storage/all/index.ts
|
|
31
31
|
function dumbo(options) {
|
|
32
32
|
const { driverType } = options;
|
|
33
|
-
const driver = _nullishCoalesce(options.driver, () => (
|
|
33
|
+
const driver = _nullishCoalesce(options.driver, () => ( _chunkJ5BB5WSHcjs.dumboDatabaseDriverRegistry.tryGet(options)));
|
|
34
34
|
if (driver === null) {
|
|
35
35
|
throw new Error(`No plugin found for driver type: ${driverType}`);
|
|
36
36
|
}
|
|
@@ -44,4 +44,4 @@ function dumbo(options) {
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
exports.parseConnectionString = parseConnectionString; exports.dumbo = dumbo;
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-GTTOLSV6.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-GTTOLSV6.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;AEJO;AAKL,EAAA;AAEA,EAAA;AAIA,EAAA;AACE,IAAA;AAAgE,EAAA;AAGlE,EAAA;AAAyB,IAAA;AACpB,IAAA;AACgB,EAAA;AAEvB;AFHA;AACA;AACA;AACA;AACA","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-GTTOLSV6.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 ExtractDumboDatabaseDriverOptions,\n type ExtractDumboTypeFromDriver,\n type JSONSerializationOptions,\n} from '../../core';\n\nexport * from './connections';\n\nexport function dumbo<Driver extends AnyDumboDatabaseDriver>(\n options: ExtractDumboDatabaseDriverOptions<Driver> & {\n driver: Driver;\n } & JSONSerializationOptions,\n): ExtractDumboTypeFromDriver<Driver>;\n\nexport function dumbo<\n DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver,\n ConnectionOptions extends DumboConnectionOptions<DatabaseDriver> =\n DumboConnectionOptions<DatabaseDriver>,\n>(\n options: ConnectionOptions & { driver?: never },\n): ExtractDumboTypeFromDriver<DatabaseDriver>;\n\nexport function dumbo<\n DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver,\n>(\n options: DumboConnectionOptions<DatabaseDriver>,\n): 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"]}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkJ5BB5WSHcjs = require('./chunk-J5BB5WSH.cjs');
|
|
19
19
|
|
|
20
20
|
// src/storage/sqlite/core/sql/processors/columProcessors.ts
|
|
21
21
|
var mapColumnType = (token, { builder }) => {
|
|
@@ -56,16 +56,16 @@ var mapColumnType = (token, { builder }) => {
|
|
|
56
56
|
}
|
|
57
57
|
builder.addSQL(columnSQL);
|
|
58
58
|
};
|
|
59
|
-
var sqliteColumnProcessors =
|
|
59
|
+
var sqliteColumnProcessors = _chunkJ5BB5WSHcjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
|
|
60
60
|
|
|
61
61
|
// src/storage/sqlite/core/sql/formatter/index.ts
|
|
62
|
-
var sqliteSQLProcessorsRegistry =
|
|
63
|
-
from:
|
|
62
|
+
var sqliteSQLProcessorsRegistry = _chunkJ5BB5WSHcjs.SQLProcessorsRegistry.call(void 0, {
|
|
63
|
+
from: _chunkJ5BB5WSHcjs.defaultProcessorsRegistry
|
|
64
64
|
}).register(sqliteColumnProcessors);
|
|
65
|
-
var sqliteFormatter =
|
|
65
|
+
var sqliteFormatter = _chunkJ5BB5WSHcjs.SQLFormatter.call(void 0, {
|
|
66
66
|
processorsRegistry: sqliteSQLProcessorsRegistry
|
|
67
67
|
});
|
|
68
|
-
|
|
68
|
+
_chunkJ5BB5WSHcjs.registerFormatter.call(void 0, "SQLite", sqliteFormatter);
|
|
69
69
|
|
|
70
70
|
// src/storage/sqlite/core/execute/execute.ts
|
|
71
71
|
var sqliteExecute = async (database, handle) => {
|
|
@@ -75,23 +75,23 @@ var sqliteExecute = async (database, handle) => {
|
|
|
75
75
|
await database.close();
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
var sqliteSQLExecutor = (driverType, formatter) => ({
|
|
78
|
+
var sqliteSQLExecutor = (driverType, serializer, formatter) => ({
|
|
79
79
|
driverType,
|
|
80
80
|
query: async (client, sql, options) => {
|
|
81
81
|
if (_optionalChain([options, 'optionalAccess', _ => _.timeoutMs])) {
|
|
82
|
-
await client.query(
|
|
82
|
+
await client.query(_chunkJ5BB5WSHcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql).query,
|
|
86
|
-
params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql).params,
|
|
87
|
-
debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql)
|
|
84
|
+
_chunkJ5BB5WSHcjs.tracer.info("db:sql:query", {
|
|
85
|
+
query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).query,
|
|
86
|
+
params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).params,
|
|
87
|
+
debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql, { serializer })
|
|
88
88
|
});
|
|
89
89
|
let result = await client.query(sql, options);
|
|
90
90
|
if (_optionalChain([options, 'optionalAccess', _2 => _2.mapping])) {
|
|
91
91
|
result = {
|
|
92
92
|
...result,
|
|
93
93
|
rows: result.rows.map(
|
|
94
|
-
(row) =>
|
|
94
|
+
(row) => _chunkJ5BB5WSHcjs.mapSQLQueryResult.call(void 0, row, options.mapping)
|
|
95
95
|
)
|
|
96
96
|
};
|
|
97
97
|
}
|
|
@@ -99,14 +99,14 @@ var sqliteSQLExecutor = (driverType, formatter) => ({
|
|
|
99
99
|
},
|
|
100
100
|
batchQuery: async (client, sqls, options) => {
|
|
101
101
|
if (_optionalChain([options, 'optionalAccess', _3 => _3.timeoutMs])) {
|
|
102
|
-
await client.query(
|
|
102
|
+
await client.query(_chunkJ5BB5WSHcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
|
|
103
103
|
}
|
|
104
104
|
const results = await client.batchQuery(sqls, options);
|
|
105
105
|
if (_optionalChain([options, 'optionalAccess', _4 => _4.mapping])) {
|
|
106
106
|
return results.map((result) => ({
|
|
107
107
|
...result,
|
|
108
108
|
rows: result.rows.map(
|
|
109
|
-
(row) =>
|
|
109
|
+
(row) => _chunkJ5BB5WSHcjs.mapSQLQueryResult.call(void 0, row, options.mapping)
|
|
110
110
|
)
|
|
111
111
|
}));
|
|
112
112
|
}
|
|
@@ -114,18 +114,18 @@ var sqliteSQLExecutor = (driverType, formatter) => ({
|
|
|
114
114
|
},
|
|
115
115
|
command: async (client, sql, options) => {
|
|
116
116
|
if (_optionalChain([options, 'optionalAccess', _5 => _5.timeoutMs])) {
|
|
117
|
-
await client.query(
|
|
117
|
+
await client.query(_chunkJ5BB5WSHcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql).query,
|
|
121
|
-
params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql).params,
|
|
122
|
-
debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql)
|
|
119
|
+
_chunkJ5BB5WSHcjs.tracer.info("db:sql:command", {
|
|
120
|
+
query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).query,
|
|
121
|
+
params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).params,
|
|
122
|
+
debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql, { serializer })
|
|
123
123
|
});
|
|
124
124
|
return await client.command(sql, options);
|
|
125
125
|
},
|
|
126
126
|
batchCommand: async (client, sqls, options) => {
|
|
127
127
|
if (_optionalChain([options, 'optionalAccess', _6 => _6.timeoutMs])) {
|
|
128
|
-
await client.query(
|
|
128
|
+
await client.query(_chunkJ5BB5WSHcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
|
|
129
129
|
}
|
|
130
130
|
return await client.batchCommand(sqls, options);
|
|
131
131
|
},
|
|
@@ -144,21 +144,21 @@ var isInMemoryDatabase = (options) => {
|
|
|
144
144
|
};
|
|
145
145
|
var sqliteAmbientConnectionPool = (options) => {
|
|
146
146
|
const { connection, driverType } = options;
|
|
147
|
-
return
|
|
147
|
+
return _chunkJ5BB5WSHcjs.createAmbientConnectionPool.call(void 0, {
|
|
148
148
|
driverType,
|
|
149
149
|
connection
|
|
150
150
|
});
|
|
151
151
|
};
|
|
152
152
|
var sqliteSingletonConnectionPool = (options) => {
|
|
153
153
|
const { driverType, sqliteConnectionFactory, connectionOptions } = options;
|
|
154
|
-
return
|
|
154
|
+
return _chunkJ5BB5WSHcjs.createSingletonConnectionPool.call(void 0, {
|
|
155
155
|
driverType,
|
|
156
156
|
getConnection: () => sqliteConnectionFactory(connectionOptions)
|
|
157
157
|
});
|
|
158
158
|
};
|
|
159
159
|
var sqliteAlwaysNewConnectionPool = (options) => {
|
|
160
160
|
const { driverType, sqliteConnectionFactory, connectionOptions } = options;
|
|
161
|
-
return
|
|
161
|
+
return _chunkJ5BB5WSHcjs.createAlwaysNewConnectionPool.call(void 0, {
|
|
162
162
|
driverType,
|
|
163
163
|
getConnection: () => sqliteConnectionFactory(connectionOptions)
|
|
164
164
|
});
|
|
@@ -174,17 +174,17 @@ var toSqlitePoolOptions = (options) => {
|
|
|
174
174
|
function sqlitePool(options) {
|
|
175
175
|
const { driverType } = options;
|
|
176
176
|
if (options.connection)
|
|
177
|
-
return
|
|
177
|
+
return _chunkJ5BB5WSHcjs.createAmbientConnectionPool.call(void 0, {
|
|
178
178
|
driverType,
|
|
179
179
|
connection: options.connection
|
|
180
180
|
});
|
|
181
181
|
if (options.singleton === true && options.sqliteConnectionFactory) {
|
|
182
|
-
return
|
|
182
|
+
return _chunkJ5BB5WSHcjs.createSingletonConnectionPool.call(void 0, {
|
|
183
183
|
driverType,
|
|
184
184
|
getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
return
|
|
187
|
+
return _chunkJ5BB5WSHcjs.createAlwaysNewConnectionPool.call(void 0, {
|
|
188
188
|
driverType,
|
|
189
189
|
getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
|
|
190
190
|
});
|
|
@@ -192,18 +192,18 @@ function sqlitePool(options) {
|
|
|
192
192
|
|
|
193
193
|
// src/storage/sqlite/core/schema/migrations.ts
|
|
194
194
|
var DefaultSQLiteMigratorOptions = {};
|
|
195
|
-
|
|
195
|
+
_chunkJ5BB5WSHcjs.registerDefaultMigratorOptions.call(void 0, "SQLite", DefaultSQLiteMigratorOptions);
|
|
196
196
|
|
|
197
197
|
// src/storage/sqlite/core/schema/schema.ts
|
|
198
198
|
var defaultPostgreSqlDatabase = "postgres";
|
|
199
|
-
var tableExistsSQL = (tableName) =>
|
|
199
|
+
var tableExistsSQL = (tableName) => _chunkJ5BB5WSHcjs.SQL`
|
|
200
200
|
SELECT EXISTS (
|
|
201
201
|
SELECT 1
|
|
202
202
|
FROM sqlite_master
|
|
203
203
|
WHERE type = 'table' AND name = ${tableName}
|
|
204
204
|
) AS "exists"
|
|
205
205
|
`;
|
|
206
|
-
var tableExists = async (pool, tableName) =>
|
|
206
|
+
var tableExists = async (pool, tableName) => _chunkJ5BB5WSHcjs.exists.call(void 0, pool.execute.query(tableExistsSQL(tableName)));
|
|
207
207
|
|
|
208
208
|
// src/storage/sqlite/core/index.ts
|
|
209
209
|
var SQLiteDatabaseName = "SQLite";
|
|
@@ -246,20 +246,28 @@ var transactionNestingCounter = () => {
|
|
|
246
246
|
};
|
|
247
247
|
};
|
|
248
248
|
var sqliteAmbientClientConnection = (options) => {
|
|
249
|
-
const {
|
|
250
|
-
|
|
249
|
+
const {
|
|
250
|
+
client,
|
|
251
|
+
driverType,
|
|
252
|
+
initTransaction,
|
|
253
|
+
allowNestedTransactions,
|
|
254
|
+
serializer
|
|
255
|
+
} = options;
|
|
256
|
+
return _chunkJ5BB5WSHcjs.createAmbientConnection.call(void 0, {
|
|
251
257
|
driverType,
|
|
252
258
|
client,
|
|
253
259
|
initTransaction: _nullishCoalesce(initTransaction, () => ( ((connection) => sqliteTransaction(
|
|
254
260
|
driverType,
|
|
255
261
|
connection,
|
|
256
|
-
_nullishCoalesce(allowNestedTransactions, () => ( false))
|
|
262
|
+
_nullishCoalesce(allowNestedTransactions, () => ( false)),
|
|
263
|
+
serializer
|
|
257
264
|
)))),
|
|
258
|
-
executor: () => sqliteSQLExecutor(driverType)
|
|
265
|
+
executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(driverType, serializer2),
|
|
266
|
+
serializer
|
|
259
267
|
});
|
|
260
268
|
};
|
|
261
269
|
var sqliteClientConnection = (options) => {
|
|
262
|
-
const { connectionOptions, sqliteClientFactory } = options;
|
|
270
|
+
const { connectionOptions, sqliteClientFactory, serializer } = options;
|
|
263
271
|
let client = null;
|
|
264
272
|
const connect = async () => {
|
|
265
273
|
if (client) return Promise.resolve(client);
|
|
@@ -268,7 +276,7 @@ var sqliteClientConnection = (options) => {
|
|
|
268
276
|
await client.connect();
|
|
269
277
|
return client;
|
|
270
278
|
};
|
|
271
|
-
return
|
|
279
|
+
return _chunkJ5BB5WSHcjs.createConnection.call(void 0, {
|
|
272
280
|
driverType: options.driverType,
|
|
273
281
|
connect,
|
|
274
282
|
close: async () => {
|
|
@@ -280,13 +288,15 @@ var sqliteClientConnection = (options) => {
|
|
|
280
288
|
initTransaction: (connection) => sqliteTransaction(
|
|
281
289
|
options.driverType,
|
|
282
290
|
connection,
|
|
283
|
-
_nullishCoalesce(_optionalChain([connectionOptions, 'access', _7 => _7.transactionOptions, 'optionalAccess', _8 => _8.allowNestedTransactions]), () => ( false))
|
|
291
|
+
_nullishCoalesce(_optionalChain([connectionOptions, 'access', _7 => _7.transactionOptions, 'optionalAccess', _8 => _8.allowNestedTransactions]), () => ( false)),
|
|
292
|
+
serializer
|
|
284
293
|
),
|
|
285
|
-
executor: () => sqliteSQLExecutor(options.driverType)
|
|
294
|
+
executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(options.driverType, serializer2),
|
|
295
|
+
serializer
|
|
286
296
|
});
|
|
287
297
|
};
|
|
288
298
|
var sqlitePoolClientConnection = (options) => {
|
|
289
|
-
const { connectionOptions, sqliteClientFactory } = options;
|
|
299
|
+
const { connectionOptions, sqliteClientFactory, serializer } = options;
|
|
290
300
|
let client = null;
|
|
291
301
|
const connect = async () => {
|
|
292
302
|
if (client) return Promise.resolve(client);
|
|
@@ -294,16 +304,18 @@ var sqlitePoolClientConnection = (options) => {
|
|
|
294
304
|
await client.connect();
|
|
295
305
|
return client;
|
|
296
306
|
};
|
|
297
|
-
return
|
|
307
|
+
return _chunkJ5BB5WSHcjs.createConnection.call(void 0, {
|
|
298
308
|
driverType: options.driverType,
|
|
299
309
|
connect,
|
|
300
310
|
close: () => client !== null ? Promise.resolve(client.release()) : Promise.resolve(),
|
|
301
311
|
initTransaction: (connection) => sqliteTransaction(
|
|
302
312
|
options.driverType,
|
|
303
313
|
connection,
|
|
304
|
-
_nullishCoalesce(_optionalChain([connectionOptions, 'access', _9 => _9.transactionOptions, 'optionalAccess', _10 => _10.allowNestedTransactions]), () => ( false))
|
|
314
|
+
_nullishCoalesce(_optionalChain([connectionOptions, 'access', _9 => _9.transactionOptions, 'optionalAccess', _10 => _10.allowNestedTransactions]), () => ( false)),
|
|
315
|
+
serializer
|
|
305
316
|
),
|
|
306
|
-
executor: () => sqliteSQLExecutor(options.driverType)
|
|
317
|
+
executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(options.driverType, serializer2),
|
|
318
|
+
serializer
|
|
307
319
|
});
|
|
308
320
|
};
|
|
309
321
|
function sqliteConnection(options) {
|
|
@@ -312,7 +324,7 @@ function sqliteConnection(options) {
|
|
|
312
324
|
var InMemorySQLiteDatabase = SQLiteConnectionString2(":memory:");
|
|
313
325
|
|
|
314
326
|
// src/storage/sqlite/core/transactions/index.ts
|
|
315
|
-
var sqliteTransaction = (driverType, connection, allowNestedTransactions) => (getClient, options) => {
|
|
327
|
+
var sqliteTransaction = (driverType, connection, allowNestedTransactions, serializer) => (getClient, options) => {
|
|
316
328
|
const transactionCounter = transactionNestingCounter();
|
|
317
329
|
allowNestedTransactions = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.allowNestedTransactions]), () => ( allowNestedTransactions));
|
|
318
330
|
return {
|
|
@@ -324,13 +336,13 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions) => (ge
|
|
|
324
336
|
if (transactionCounter.level >= 1) {
|
|
325
337
|
transactionCounter.increment();
|
|
326
338
|
await client.query(
|
|
327
|
-
|
|
339
|
+
_chunkJ5BB5WSHcjs.SQL`SAVEPOINT transaction${_chunkJ5BB5WSHcjs.SQL.plain(transactionCounter.level.toString())}`
|
|
328
340
|
);
|
|
329
341
|
return;
|
|
330
342
|
}
|
|
331
343
|
transactionCounter.increment();
|
|
332
344
|
}
|
|
333
|
-
await client.query(
|
|
345
|
+
await client.query(_chunkJ5BB5WSHcjs.SQL`BEGIN TRANSACTION`);
|
|
334
346
|
},
|
|
335
347
|
commit: async function() {
|
|
336
348
|
const client = await getClient;
|
|
@@ -338,14 +350,14 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions) => (ge
|
|
|
338
350
|
if (allowNestedTransactions) {
|
|
339
351
|
if (transactionCounter.level > 1) {
|
|
340
352
|
await client.query(
|
|
341
|
-
|
|
353
|
+
_chunkJ5BB5WSHcjs.SQL`RELEASE transaction${_chunkJ5BB5WSHcjs.SQL.plain(transactionCounter.level.toString())}`
|
|
342
354
|
);
|
|
343
355
|
transactionCounter.decrement();
|
|
344
356
|
return;
|
|
345
357
|
}
|
|
346
358
|
transactionCounter.reset();
|
|
347
359
|
}
|
|
348
|
-
await client.query(
|
|
360
|
+
await client.query(_chunkJ5BB5WSHcjs.SQL`COMMIT`);
|
|
349
361
|
} finally {
|
|
350
362
|
if (_optionalChain([options, 'optionalAccess', _12 => _12.close]))
|
|
351
363
|
await _optionalChain([options, 'optionalAccess', _13 => _13.close, 'call', _14 => _14(
|
|
@@ -362,7 +374,7 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions) => (ge
|
|
|
362
374
|
return;
|
|
363
375
|
}
|
|
364
376
|
}
|
|
365
|
-
await client.query(
|
|
377
|
+
await client.query(_chunkJ5BB5WSHcjs.SQL`ROLLBACK`);
|
|
366
378
|
} finally {
|
|
367
379
|
if (_optionalChain([options, 'optionalAccess', _15 => _15.close]))
|
|
368
380
|
await _optionalChain([options, 'optionalAccess', _16 => _16.close, 'call', _17 => _17(
|
|
@@ -371,7 +383,7 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions) => (ge
|
|
|
371
383
|
)]);
|
|
372
384
|
}
|
|
373
385
|
},
|
|
374
|
-
execute:
|
|
386
|
+
execute: _chunkJ5BB5WSHcjs.sqlExecutor.call(void 0, sqliteSQLExecutor(driverType, serializer), {
|
|
375
387
|
connect: () => getClient
|
|
376
388
|
})
|
|
377
389
|
};
|
|
@@ -402,4 +414,4 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions) => (ge
|
|
|
402
414
|
|
|
403
415
|
|
|
404
416
|
exports.sqliteFormatter = sqliteFormatter; exports.sqliteExecute = sqliteExecute; exports.sqliteSQLExecutor = sqliteSQLExecutor; exports.sqliteTransaction = sqliteTransaction; exports.SQLiteConnectionString = SQLiteConnectionString2; exports.isSQLiteError = isSQLiteError; exports.transactionNestingCounter = transactionNestingCounter; exports.sqliteAmbientClientConnection = sqliteAmbientClientConnection; exports.sqliteClientConnection = sqliteClientConnection; exports.sqlitePoolClientConnection = sqlitePoolClientConnection; exports.sqliteConnection = sqliteConnection; exports.InMemorySQLiteDatabase = InMemorySQLiteDatabase; exports.isInMemoryDatabase = isInMemoryDatabase; exports.sqliteAmbientConnectionPool = sqliteAmbientConnectionPool; exports.sqliteSingletonConnectionPool = sqliteSingletonConnectionPool; exports.sqliteAlwaysNewConnectionPool = sqliteAlwaysNewConnectionPool; exports.toSqlitePoolOptions = toSqlitePoolOptions; exports.sqlitePool = sqlitePool; exports.DefaultSQLiteMigratorOptions = DefaultSQLiteMigratorOptions; exports.defaultPostgreSqlDatabase = defaultPostgreSqlDatabase; exports.tableExistsSQL = tableExistsSQL; exports.tableExists = tableExists; exports.SQLiteDatabaseName = SQLiteDatabaseName;
|
|
405
|
-
//# sourceMappingURL=chunk-
|
|
417
|
+
//# sourceMappingURL=chunk-I6WQ6ILG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-I6WQ6ILG.cjs","../src/storage/sqlite/core/sql/processors/columProcessors.ts","../src/storage/sqlite/core/sql/formatter/index.ts","../src/storage/sqlite/core/execute/execute.ts","../src/storage/sqlite/core/pool/pool.ts","../src/storage/sqlite/core/schema/migrations.ts","../src/storage/sqlite/core/schema/schema.ts","../src/storage/sqlite/core/index.ts","../src/storage/sqlite/core/connections/connectionString.ts","../src/storage/sqlite/core/connections/index.ts","../src/storage/sqlite/core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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-I6WQ6ILG.cjs","sourcesContent":[null,"import {\n mapDefaultSQLColumnProcessors,\n type DefaultSQLColumnProcessors,\n type DefaultSQLColumnToken,\n type SQLProcessorContext,\n} from '../../../../../core';\n\nconst mapColumnType = (\n token: DefaultSQLColumnToken,\n { builder }: SQLProcessorContext,\n): void => {\n let columnSQL: string;\n const { sqlTokenType } = token;\n switch (sqlTokenType) {\n case 'SQL_COLUMN_AUTO_INCREMENT':\n columnSQL = `INTEGER ${token.primaryKey ? 'PRIMARY KEY' : ''} AUTOINCREMENT`;\n break;\n case 'SQL_COLUMN_BIGINT':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_SERIAL':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_INTEGER':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_JSONB':\n columnSQL = 'BLOB';\n break;\n case 'SQL_COLUMN_BIGSERIAL':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_TIMESTAMP':\n columnSQL = 'DATETIME';\n break;\n case 'SQL_COLUMN_TIMESTAMPTZ':\n columnSQL = 'DATETIME';\n break;\n case 'SQL_COLUMN_VARCHAR':\n columnSQL = `VARCHAR ${Number.isNaN(token.length) ? '' : `(${token.length})`}`;\n break;\n default: {\n const exhaustiveCheck: never = sqlTokenType;\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unknown column type: ${exhaustiveCheck}`);\n }\n }\n builder.addSQL(columnSQL);\n};\n\nexport const sqliteColumnProcessors: DefaultSQLColumnProcessors =\n mapDefaultSQLColumnProcessors(mapColumnType);\n","import {\n defaultProcessorsRegistry,\n registerFormatter,\n SQLFormatter,\n SQLProcessorsRegistry,\n} from '../../../../../core/sql';\nimport { sqliteColumnProcessors } from '../processors';\n\nconst sqliteSQLProcessorsRegistry = SQLProcessorsRegistry({\n from: defaultProcessorsRegistry,\n}).register(sqliteColumnProcessors);\n\nconst sqliteFormatter: SQLFormatter = SQLFormatter({\n processorsRegistry: sqliteSQLProcessorsRegistry,\n});\n\nregisterFormatter('SQLite', sqliteFormatter);\n\nexport { sqliteFormatter };\n","import type { SQLiteDriverType } from '..';\nimport {\n JSONSerializer,\n mapSQLQueryResult,\n SQL,\n SQLFormatter,\n tracer,\n type DbSQLExecutor,\n type QueryResult,\n type QueryResultRow,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport type { SQLiteClient } from '../connections';\nimport { sqliteFormatter } from '../sql/formatter';\n\nexport const sqliteExecute = async <Result = void>(\n database: SQLiteClient,\n handle: (client: SQLiteClient) => Promise<Result>,\n) => {\n try {\n return await handle(database);\n } finally {\n await database.close();\n }\n};\n\nexport type SQLiteSQLExecutor<\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n> = DbSQLExecutor<DriverType, SQLiteClient>;\n\nexport const sqliteSQLExecutor = <\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n>(\n driverType: DriverType,\n serializer: JSONSerializer,\n formatter?: SQLFormatter,\n): SQLiteSQLExecutor<DriverType> => ({\n driverType,\n query: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>> => {\n if (options?.timeoutMs) {\n await client.query(SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);\n }\n\n tracer.info('db:sql:query', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n let result = await client.query<Result>(sql, options);\n\n if (options?.mapping) {\n result = {\n ...result,\n rows: result.rows.map((row) =>\n mapSQLQueryResult(row, options.mapping!),\n ),\n };\n }\n\n return result;\n },\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n if (options?.timeoutMs) {\n await client.query(SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);\n }\n\n const results = await client.batchQuery<Result>(sqls, options);\n\n if (options?.mapping) {\n return results.map((result) => ({\n ...result,\n rows: result.rows.map((row) =>\n mapSQLQueryResult(row, options.mapping!),\n ),\n }));\n }\n\n return results;\n },\n command: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n if (options?.timeoutMs) {\n await client.query(SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);\n }\n\n tracer.info('db:sql:command', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n return await client.command<Result>(sql, options);\n },\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>[]> => {\n if (options?.timeoutMs) {\n await client.query(SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);\n }\n\n return await client.batchCommand<Result>(sqls, options);\n },\n formatter: formatter ?? sqliteFormatter,\n});\n","import {\n InMemorySQLiteDatabase,\n SQLiteConnectionString,\n type AnySQLiteConnection,\n type SQLiteConnectionFactory,\n type SQLiteConnectionOptions,\n} from '..';\nimport {\n createAlwaysNewConnectionPool,\n createAmbientConnectionPool,\n createSingletonConnectionPool,\n JSONSerializer,\n type ConnectionPool,\n} from '../../../../core';\n\nexport type SQLiteFileNameOrConnectionString =\n | {\n fileName: string | SQLiteConnectionString;\n connectionString?: never;\n }\n | {\n connectionString: string | SQLiteConnectionString;\n fileName?: never;\n };\n\nexport const isInMemoryDatabase = (\n options: Record<string, unknown>,\n): boolean => {\n if ('fileName' in options) {\n return options.fileName === InMemorySQLiteDatabase;\n }\n if ('connectionString' in options) {\n return options.connectionString === InMemorySQLiteDatabase;\n }\n return false;\n};\n\nexport type SQLiteAmbientConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\ntype SQLiteAmbientConnectionPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = {\n singleton?: true;\n pooled?: false;\n sqliteConnectionFactory?: never;\n connection: SQLiteConnectionType;\n connectionOptions?: never;\n};\n\nexport const sqliteAmbientConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType['driverType']>,\n): SQLiteAmbientConnectionPool<SQLiteConnectionType['driverType']> => {\n const { connection, driverType } = options;\n\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: connection,\n });\n};\n\ntype SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = {\n singleton: true;\n pooled?: true;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connection?: never;\n connectionOptions: ConnectionOptions;\n};\n\nexport type SQLiteSingletonConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\nexport const sqliteSingletonConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions & Record<string, unknown> =\n SQLiteConnectionOptions & Record<string, unknown>,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >,\n): SQLiteSingletonConnectionPool<SQLiteConnectionType> => {\n const { driverType, sqliteConnectionFactory, connectionOptions } = options;\n\n return createSingletonConnectionPool<SQLiteConnectionType>({\n driverType,\n getConnection: () => sqliteConnectionFactory(connectionOptions),\n });\n};\n\ntype SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = {\n singleton?: false;\n pooled?: true;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connection?: never;\n connectionOptions: ConnectionOptions;\n};\n\nexport type SQLiteAlwaysNewConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\nexport const sqliteAlwaysNewConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions & Record<string, unknown> =\n SQLiteConnectionOptions & Record<string, unknown>,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteAlwaysNewPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLiteAlwaysNewConnectionPool<SQLiteConnectionType> => {\n const { driverType, sqliteConnectionFactory, connectionOptions } = options;\n\n return createAlwaysNewConnectionPool<SQLiteConnectionType>({\n driverType,\n getConnection: () => sqliteConnectionFactory(connectionOptions),\n });\n};\n\nexport type SQLitePoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = (\n | SQLiteAlwaysNewPoolOptions<SQLiteConnectionType, ConnectionOptions>\n | SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >\n | SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType>\n) & {\n driverType: SQLiteConnectionType['driverType'];\n serializer?: JSONSerializer;\n};\n\nexport type SQLitePool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> =\n | SQLiteAmbientConnectionPool<SQLiteConnectionType>\n | SQLiteSingletonConnectionPool<SQLiteConnectionType>\n | SQLiteAlwaysNewConnectionPool<SQLiteConnectionType>;\n\nexport type SQLitePoolFactoryOptions<\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n> = Omit<\n SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>,\n 'singleton'\n> & {\n singleton?: boolean;\n};\n\nexport const toSqlitePoolOptions = <\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n>(\n options: SQLitePoolFactoryOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions> => {\n const { singleton, ...rest } = options;\n const useSingleton = singleton ?? isInMemoryDatabase(options);\n\n if (useSingleton) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n return { ...rest, singleton: false } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n};\n\nexport function sqlitePool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n>(\n options: SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePool<SQLiteConnectionType> {\n const { driverType } = options;\n\n // TODO: Handle dates and bigints\n // setSQLiteTypeParser(serializer ?? JSONSerializer);\n\n if (options.connection)\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: options.connection,\n });\n\n if (options.singleton === true && options.sqliteConnectionFactory) {\n return createSingletonConnectionPool({\n driverType,\n getConnection: () =>\n options.sqliteConnectionFactory(options.connectionOptions),\n });\n }\n\n return createAlwaysNewConnectionPool({\n driverType,\n getConnection: () =>\n options.sqliteConnectionFactory!(options.connectionOptions!),\n });\n}\n","import {\n registerDefaultMigratorOptions,\n type MigratorOptions,\n} from '../../../../core';\n\nexport const DefaultSQLiteMigratorOptions: MigratorOptions = {};\n\nregisterDefaultMigratorOptions('SQLite', DefaultSQLiteMigratorOptions);\n","import { exists, SQL, type ConnectionPool } from '../../../../core';\nexport * from './schema';\n\nexport const defaultPostgreSqlDatabase = 'postgres';\n\nexport const tableExistsSQL = (tableName: string): SQL =>\n SQL`\n SELECT EXISTS (\n SELECT 1\n FROM sqlite_master\n WHERE type = 'table' AND name = ${tableName}\n ) AS \"exists\"\n `;\n\nexport const tableExists = async (\n pool: ConnectionPool,\n tableName: string,\n): Promise<boolean> => exists(pool.execute.query(tableExistsSQL(tableName)));\n","import { type DatabaseDriverType } from '../../..';\n\nexport * from './connections';\nexport * from './execute';\nexport * from './pool';\nexport * from './schema';\nexport * from './sql';\nexport * from './transactions';\n\nexport type SQLiteDatabaseName = 'SQLite';\nexport const SQLiteDatabaseName = 'SQLite';\n\nexport type SQLiteDriverType<DriverName extends string = string> =\n DatabaseDriverType<SQLiteDatabaseName, DriverName>;\n\nexport type SQLiteDatabaseType = 'SQLite';\n","import type { DatabaseConnectionString } from '../../../all';\n\nexport type SQLiteConnectionString = DatabaseConnectionString<\n 'SQLite',\n `file:${string}` | `:memory:` | `/${string}` | `./${string}`\n>;\n\nexport const SQLiteConnectionString = (\n connectionString: string,\n): SQLiteConnectionString => {\n if (\n !connectionString.startsWith('file:') &&\n connectionString !== ':memory:' &&\n !connectionString.startsWith('/') &&\n !connectionString.startsWith('./')\n ) {\n throw new Error(\n `Invalid SQLite connection string: ${connectionString}. It should start with \"file:\", \":memory:\", \"/\", or \"./\".`,\n );\n }\n return connectionString as SQLiteConnectionString;\n};\n","import {\n SQLiteConnectionString,\n sqliteSQLExecutor,\n type SQLiteDriverType,\n} from '..';\nimport {\n createAmbientConnection,\n createConnection,\n JSONSerializer,\n type AnyConnection,\n type Connection,\n type ConnectionOptions,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n type InferDbClientFromConnection,\n type InferDriverTypeFromConnection,\n type InitTransaction,\n type SQLCommandOptions,\n type SQLExecutor,\n} from '../../../../core';\nimport { sqliteTransaction } from '../transactions';\n\nexport type SQLiteCommandOptions = SQLCommandOptions & {\n ignoreChangesCount?: boolean;\n};\n\nexport type SQLiteParameters =\n | object\n | string\n | bigint\n | number\n | boolean\n | null;\n\nexport type SQLiteClient = {\n connect: () => Promise<void>;\n close: () => Promise<void>;\n} & SQLExecutor;\n\nexport type SQLitePoolClient = {\n release: () => void;\n} & SQLExecutor;\n\nexport type SQLiteClientFactory<\n SQLiteClientType extends SQLiteClient = SQLiteClient,\n ClientOptions = SQLiteClientOptions,\n> = (options: ClientOptions) => SQLiteClientType;\n\nexport type SQLiteClientOrPoolClient = SQLitePoolClient | SQLiteClient;\n\nexport interface SQLiteError extends Error {\n errno: number;\n}\n\nexport const isSQLiteError = (error: unknown): error is SQLiteError => {\n if (error instanceof Error && 'code' in error) {\n return true;\n }\n\n return false;\n};\n\nexport type SQLiteClientConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLiteClientType extends SQLiteClient = SQLiteClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n TransactionOptionsType extends DatabaseTransactionOptions =\n DatabaseTransactionOptions,\n> = Connection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType,\n TransactionOptionsType\n>;\n\nexport type SQLitePoolClientConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLitePoolClientType extends SQLitePoolClient = SQLitePoolClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n TransactionOptionsType extends DatabaseTransactionOptions =\n DatabaseTransactionOptions,\n> = Connection<\n Self,\n DriverType,\n SQLitePoolClientType,\n TransactionType,\n TransactionOptionsType\n>;\n\nexport type SQLiteConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLiteClientType extends SQLiteClientOrPoolClient =\n | SQLiteClient\n | SQLitePoolClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n TransactionOptionsType extends DatabaseTransactionOptions =\n DatabaseTransactionOptions,\n> =\n | (SQLiteClientType extends SQLiteClient\n ? SQLiteClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType,\n TransactionOptionsType\n >\n : never)\n | (SQLiteClientType extends SQLitePoolClient\n ? SQLitePoolClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType,\n TransactionOptionsType\n >\n : never);\n\nexport type AnySQLiteClientConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteClientConnection<any, any>;\n\nexport type AnySQLitePoolClientConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLitePoolClientConnection<any, any, any, any, any>;\n\nexport type AnySQLiteConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteConnection<any, any, any, any, any>;\n\nexport type SQLiteConnectionOptions<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionOptions<ConnectionType> & SQLiteClientOptions;\n\nexport type SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ConnectionOptions = SQLiteConnectionOptions,\n> = {\n driverType: InferDriverTypeFromConnection<SQLiteConnectionType>;\n type: 'Client';\n sqliteClientFactory: SQLiteClientFactory<\n InferDbClientFromConnection<SQLiteConnectionType>,\n ConnectionOptions\n >;\n connectionOptions: SQLiteConnectionOptions<SQLiteConnectionType>;\n serializer: JSONSerializer;\n};\n\nexport type SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n AnySQLitePoolClientConnection,\n ConnectionOptions = SQLiteConnectionOptions,\n> = {\n driverType: InferDriverTypeFromConnection<SQLiteConnectionType>;\n type: 'PoolClient';\n sqliteClientFactory: SQLiteClientFactory<\n InferDbClientFromConnection<SQLiteConnectionType>,\n ConnectionOptions\n >;\n connectionOptions: SQLiteConnectionOptions<SQLiteConnectionType>;\n serializer: JSONSerializer;\n};\n\nexport type SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n AnySQLitePoolClientConnection,\n ClientOptions = SQLiteClientOptions,\n> =\n | SQLiteClientConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>\n | SQLitePoolConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>;\n\nexport type SQLiteConnectionFactory<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = (options: ConnectionOptions) => SQLiteConnectionType;\n\nexport type TransactionNestingCounter = {\n increment: () => void;\n decrement: () => void;\n reset: () => void;\n level: number;\n};\n\nexport const transactionNestingCounter = (): TransactionNestingCounter => {\n let transactionLevel = 0;\n\n return {\n reset: () => {\n transactionLevel = 0;\n },\n increment: () => {\n transactionLevel++;\n },\n decrement: () => {\n transactionLevel--;\n\n if (transactionLevel < 0) {\n throw new Error('Transaction level is out of bounds');\n }\n },\n get level() {\n return transactionLevel;\n },\n };\n};\n\nexport type SqliteAmbientClientConnectionOptions<\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n TransactionType extends DatabaseTransaction<SQLiteConnectionType> =\n DatabaseTransaction<SQLiteConnectionType>,\n TransactionOptionsType extends DatabaseTransactionOptions =\n DatabaseTransactionOptions,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n client: InferDbClientFromConnection<SQLiteConnectionType>;\n initTransaction?: InitTransaction<\n SQLiteConnectionType,\n TransactionType,\n TransactionOptionsType\n >;\n allowNestedTransactions?: boolean;\n serializer: JSONSerializer;\n};\n\nexport const sqliteAmbientClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n>(\n options: SqliteAmbientClientConnectionOptions<SQLiteConnectionType>,\n) => {\n const {\n client,\n driverType,\n initTransaction,\n allowNestedTransactions,\n serializer,\n } = options;\n\n return createAmbientConnection<SQLiteConnectionType>({\n driverType,\n client,\n initTransaction:\n initTransaction ??\n ((connection) =>\n sqliteTransaction(\n driverType,\n connection,\n allowNestedTransactions ?? false,\n serializer,\n )),\n executor: ({ serializer }) => sqliteSQLExecutor(driverType, serializer),\n serializer,\n });\n};\n\nexport const sqliteClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = options;\n\n let client: InferDbClientFromConnection<SQLiteConnectionType> | null = null;\n\n const connect = async (): Promise<\n InferDbClientFromConnection<SQLiteConnectionType>\n > => {\n if (client) return Promise.resolve(client);\n\n client = sqliteClientFactory(connectionOptions as ClientOptions);\n\n if (client && 'connect' in client && typeof client.connect === 'function')\n await client.connect();\n\n return client;\n };\n\n return createConnection({\n driverType: options.driverType,\n connect,\n close: async () => {\n if (client && 'close' in client && typeof client.close === 'function')\n await client.close();\n else if (\n client &&\n 'release' in client &&\n typeof client.release === 'function'\n )\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n client.release();\n },\n initTransaction: (connection) =>\n sqliteTransaction(\n options.driverType,\n connection,\n connectionOptions.transactionOptions?.allowNestedTransactions ?? false,\n serializer,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\n });\n};\n\nexport const sqlitePoolClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = options;\n\n let client: InferDbClientFromConnection<SQLiteConnectionType> | null = null;\n\n const connect = async (): Promise<\n InferDbClientFromConnection<SQLiteConnectionType>\n > => {\n if (client) return Promise.resolve(client);\n\n client = sqliteClientFactory(connectionOptions as ClientOptions);\n\n await client.connect();\n\n return client;\n };\n\n return createConnection({\n driverType: options.driverType,\n connect,\n close: () =>\n client !== null\n ? Promise.resolve((client as unknown as SQLitePoolClient).release())\n : Promise.resolve(),\n initTransaction: (connection) =>\n sqliteTransaction(\n options.driverType,\n connection,\n connectionOptions.transactionOptions?.allowNestedTransactions ?? false,\n serializer,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\n });\n};\n\nexport function sqliteConnection<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType {\n return options.type === 'Client'\n ? sqliteClientConnection(options)\n : sqlitePoolClientConnection(options);\n}\n\nexport type InMemorySQLiteDatabase = ':memory:';\nexport const InMemorySQLiteDatabase = SQLiteConnectionString(':memory:');\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type SQLiteClientOptions = {};\n\nexport * from './connectionString';\n","import {\n JSONSerializer,\n SQL,\n sqlExecutor,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n type InferDbClientFromConnection,\n} from '../../../../core';\nimport { sqliteSQLExecutor } from '../../core/execute';\nimport {\n transactionNestingCounter,\n type AnySQLiteConnection,\n type SQLiteClientOrPoolClient,\n} from '../connections';\n\nexport type SQLiteTransaction<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = DatabaseTransaction<ConnectionType>;\n\nexport const sqliteTransaction =\n <ConnectionType extends AnySQLiteConnection = AnySQLiteConnection>(\n driverType: ConnectionType['driverType'],\n connection: () => ConnectionType,\n allowNestedTransactions: boolean,\n serializer: JSONSerializer,\n ) =>\n (\n getClient: Promise<InferDbClientFromConnection<ConnectionType>>,\n options?: {\n close: (\n client: InferDbClientFromConnection<ConnectionType>,\n error?: unknown,\n ) => Promise<void>;\n } & DatabaseTransactionOptions,\n ): DatabaseTransaction<ConnectionType> => {\n const transactionCounter = transactionNestingCounter();\n allowNestedTransactions =\n options?.allowNestedTransactions ?? allowNestedTransactions;\n\n return {\n connection: connection(),\n driverType,\n begin: async function () {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n\n if (allowNestedTransactions) {\n if (transactionCounter.level >= 1) {\n transactionCounter.increment();\n await client.query(\n SQL`SAVEPOINT transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n return;\n }\n\n transactionCounter.increment();\n }\n\n await client.query(SQL`BEGIN TRANSACTION`);\n },\n commit: async function () {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n await client.query(\n SQL`RELEASE transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n transactionCounter.decrement();\n\n return;\n }\n\n transactionCounter.reset();\n }\n await client.query(SQL`COMMIT`);\n } finally {\n if (options?.close)\n await options?.close(\n client as InferDbClientFromConnection<ConnectionType>,\n );\n }\n },\n rollback: async function (error?: unknown) {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n transactionCounter.decrement();\n return;\n }\n }\n\n await client.query(SQL`ROLLBACK`);\n } finally {\n if (options?.close)\n await options?.close(\n client as InferDbClientFromConnection<ConnectionType>,\n error,\n );\n }\n },\n execute: sqlExecutor(sqliteSQLExecutor(driverType, serializer), {\n connect: () => getClient,\n }),\n };\n };\n"]}
|