@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/chunk-ISNF6USX.cjs
DELETED
|
@@ -1,688 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _chunkOJ34O3Q2cjs = require('./chunk-OJ34O3Q2.cjs');
|
|
22
|
-
|
|
23
|
-
// src/storage/postgresql/core/connections/connectionString.ts
|
|
24
|
-
var _pgconnectionstring = require('pg-connection-string'); var _pgconnectionstring2 = _interopRequireDefault(_pgconnectionstring);
|
|
25
|
-
|
|
26
|
-
// src/storage/postgresql/core/locks/advisoryLocks.ts
|
|
27
|
-
var tryAcquireAdvisoryLock = async (execute, options) => {
|
|
28
|
-
const timeoutMs = _nullishCoalesce(options.timeoutMs, () => ( _chunkOJ34O3Q2cjs.defaultDatabaseLockOptions.timeoutMs));
|
|
29
|
-
const advisoryLock2 = options.mode === "Permanent" ? "pg_advisory_lock" : "pg_advisory_xact_lock";
|
|
30
|
-
try {
|
|
31
|
-
await _chunkOJ34O3Q2cjs.single.call(void 0,
|
|
32
|
-
execute.query(
|
|
33
|
-
_chunkOJ34O3Q2cjs.SQL`SELECT ${_chunkOJ34O3Q2cjs.SQL.plain(advisoryLock2)}(${options.lockId}) AS locked`,
|
|
34
|
-
{ timeoutMs }
|
|
35
|
-
)
|
|
36
|
-
);
|
|
37
|
-
return true;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (error instanceof Error && "code" in error && error.code === "57014")
|
|
40
|
-
return false;
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var releaseAdvisoryLock = async (execute, options) => {
|
|
45
|
-
const timeoutMs = _nullishCoalesce(options.timeoutMs, () => ( _chunkOJ34O3Q2cjs.defaultDatabaseLockOptions.timeoutMs));
|
|
46
|
-
try {
|
|
47
|
-
await _chunkOJ34O3Q2cjs.single.call(void 0,
|
|
48
|
-
execute.query(
|
|
49
|
-
_chunkOJ34O3Q2cjs.SQL`SELECT pg_advisory_unlock(${options.lockId}) AS locked`,
|
|
50
|
-
{ timeoutMs }
|
|
51
|
-
)
|
|
52
|
-
);
|
|
53
|
-
return true;
|
|
54
|
-
} catch (error) {
|
|
55
|
-
if (error instanceof Error && "code" in error && error.code === "57014")
|
|
56
|
-
return false;
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var acquireAdvisoryLock = async (execute, options) => {
|
|
61
|
-
const lockAcquired = await tryAcquireAdvisoryLock(execute, options);
|
|
62
|
-
if (!lockAcquired) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
"Failed to acquire advisory lock within the specified timeout. Migration aborted."
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var AdvisoryLock = {
|
|
69
|
-
acquire: acquireAdvisoryLock,
|
|
70
|
-
tryAcquire: tryAcquireAdvisoryLock,
|
|
71
|
-
release: releaseAdvisoryLock,
|
|
72
|
-
withAcquire: async (execute, handle, options) => {
|
|
73
|
-
await acquireAdvisoryLock(execute, options);
|
|
74
|
-
try {
|
|
75
|
-
return await handle();
|
|
76
|
-
} finally {
|
|
77
|
-
if (options.mode === "Permanent")
|
|
78
|
-
await releaseAdvisoryLock(execute, options);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var advisoryLock = (execute, options) => ({
|
|
83
|
-
acquire: (acquireOptions) => acquireAdvisoryLock(execute, {
|
|
84
|
-
...options,
|
|
85
|
-
..._nullishCoalesce(acquireOptions, () => ( {}))
|
|
86
|
-
}),
|
|
87
|
-
tryAcquire: (acquireOptions) => tryAcquireAdvisoryLock(execute, {
|
|
88
|
-
...options,
|
|
89
|
-
..._nullishCoalesce(acquireOptions, () => ( {}))
|
|
90
|
-
}),
|
|
91
|
-
release: () => releaseAdvisoryLock(execute, options),
|
|
92
|
-
withAcquire: async (handle, acquireOptions) => {
|
|
93
|
-
await acquireAdvisoryLock(execute, {
|
|
94
|
-
...options,
|
|
95
|
-
..._nullishCoalesce(acquireOptions, () => ( {}))
|
|
96
|
-
});
|
|
97
|
-
try {
|
|
98
|
-
return await handle();
|
|
99
|
-
} finally {
|
|
100
|
-
await releaseAdvisoryLock(execute, options);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// src/storage/postgresql/core/schema/migrations.ts
|
|
106
|
-
var DefaultPostgreSQLMigratorOptions = {
|
|
107
|
-
lock: {
|
|
108
|
-
databaseLock: AdvisoryLock
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
_chunkOJ34O3Q2cjs.registerDefaultMigratorOptions.call(void 0, "PostgreSQL", DefaultPostgreSQLMigratorOptions);
|
|
112
|
-
|
|
113
|
-
// src/storage/postgresql/core/schema/schema.ts
|
|
114
|
-
var defaultPostgreSqlDatabase = "postgres";
|
|
115
|
-
var tableExistsSQL = (tableName) => _chunkOJ34O3Q2cjs.SQL`
|
|
116
|
-
SELECT EXISTS (
|
|
117
|
-
SELECT FROM pg_tables
|
|
118
|
-
WHERE tablename = ${tableName}
|
|
119
|
-
) AS exists;`;
|
|
120
|
-
var tableExists = async (pool, tableName) => _chunkOJ34O3Q2cjs.exists.call(void 0, pool.execute.query(tableExistsSQL(tableName)));
|
|
121
|
-
var functionExistsSQL = (functionName) => _chunkOJ34O3Q2cjs.SQL`
|
|
122
|
-
SELECT EXISTS (
|
|
123
|
-
SELECT FROM pg_proc
|
|
124
|
-
WHERE
|
|
125
|
-
proname = ${functionName}
|
|
126
|
-
) AS exists;`;
|
|
127
|
-
var functionExists = async (pool, tableName) => _chunkOJ34O3Q2cjs.exists.call(void 0, pool.execute.query(functionExistsSQL(tableName)));
|
|
128
|
-
|
|
129
|
-
// src/storage/postgresql/core/connections/connectionString.ts
|
|
130
|
-
var defaultPostgreSQLConnectionString = "postgresql://postgres@localhost:5432/postgres";
|
|
131
|
-
var getDatabaseNameOrDefault = (connectionString) => _nullishCoalesce(_pgconnectionstring2.default.parse(connectionString).database, () => ( defaultPostgreSqlDatabase));
|
|
132
|
-
var PostgreSQLConnectionString = (connectionString) => {
|
|
133
|
-
if (!connectionString.startsWith("postgresql://") && !connectionString.startsWith("postgres://")) {
|
|
134
|
-
throw new Error(
|
|
135
|
-
`Invalid PostgreSQL connection string: ${connectionString}. It should start with "postgresql://".`
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
return connectionString;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// src/storage/postgresql/core/sql/processors/columProcessors.ts
|
|
142
|
-
var mapColumnType = (token, { builder }) => {
|
|
143
|
-
let columnSQL;
|
|
144
|
-
const { sqlTokenType } = token;
|
|
145
|
-
switch (sqlTokenType) {
|
|
146
|
-
case "SQL_COLUMN_AUTO_INCREMENT":
|
|
147
|
-
columnSQL = `${token.bigint ? "BIGSERIAL" : "SERIAL"} ${token.primaryKey ? "PRIMARY KEY" : ""}`;
|
|
148
|
-
break;
|
|
149
|
-
case "SQL_COLUMN_BIGINT":
|
|
150
|
-
columnSQL = "BIGINT";
|
|
151
|
-
break;
|
|
152
|
-
case "SQL_COLUMN_SERIAL":
|
|
153
|
-
columnSQL = "SERIAL";
|
|
154
|
-
break;
|
|
155
|
-
case "SQL_COLUMN_INTEGER":
|
|
156
|
-
columnSQL = "INTEGER";
|
|
157
|
-
break;
|
|
158
|
-
case "SQL_COLUMN_JSONB":
|
|
159
|
-
columnSQL = "JSONB";
|
|
160
|
-
break;
|
|
161
|
-
case "SQL_COLUMN_BIGSERIAL":
|
|
162
|
-
columnSQL = "BIGSERIAL";
|
|
163
|
-
break;
|
|
164
|
-
case "SQL_COLUMN_TIMESTAMP":
|
|
165
|
-
columnSQL = "TIMESTAMP";
|
|
166
|
-
break;
|
|
167
|
-
case "SQL_COLUMN_TIMESTAMPTZ":
|
|
168
|
-
columnSQL = "TIMESTAMPTZ";
|
|
169
|
-
break;
|
|
170
|
-
case "SQL_COLUMN_VARCHAR":
|
|
171
|
-
columnSQL = `VARCHAR ${Number.isNaN(token.length) ? "" : `(${token.length})`}`;
|
|
172
|
-
break;
|
|
173
|
-
default: {
|
|
174
|
-
const exhaustiveCheck = sqlTokenType;
|
|
175
|
-
throw new Error(`Unknown column type: ${exhaustiveCheck}`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
builder.addSQL(columnSQL);
|
|
179
|
-
};
|
|
180
|
-
var postgreSQLColumnProcessors = _chunkOJ34O3Q2cjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
|
|
181
|
-
|
|
182
|
-
// src/storage/postgresql/core/sql/formatter/reserved.ts
|
|
183
|
-
var reservedMap = {
|
|
184
|
-
AES128: true,
|
|
185
|
-
AES256: true,
|
|
186
|
-
ALL: true,
|
|
187
|
-
ALLOWOVERWRITE: true,
|
|
188
|
-
ANALYSE: true,
|
|
189
|
-
ANALYZE: true,
|
|
190
|
-
AND: true,
|
|
191
|
-
ANY: true,
|
|
192
|
-
ARRAY: true,
|
|
193
|
-
AS: true,
|
|
194
|
-
ASC: true,
|
|
195
|
-
AUTHORIZATION: true,
|
|
196
|
-
BACKUP: true,
|
|
197
|
-
BETWEEN: true,
|
|
198
|
-
BINARY: true,
|
|
199
|
-
BLANKSASNULL: true,
|
|
200
|
-
BOTH: true,
|
|
201
|
-
BYTEDICT: true,
|
|
202
|
-
CASE: true,
|
|
203
|
-
CAST: true,
|
|
204
|
-
CHECK: true,
|
|
205
|
-
COLLATE: true,
|
|
206
|
-
COLUMN: true,
|
|
207
|
-
CONSTRAINT: true,
|
|
208
|
-
CREATE: true,
|
|
209
|
-
CREDENTIALS: true,
|
|
210
|
-
CROSS: true,
|
|
211
|
-
CURRENT_DATE: true,
|
|
212
|
-
CURRENT_TIME: true,
|
|
213
|
-
CURRENT_TIMESTAMP: true,
|
|
214
|
-
CURRENT_USER: true,
|
|
215
|
-
CURRENT_USER_ID: true,
|
|
216
|
-
DEFAULT: true,
|
|
217
|
-
DEFERRABLE: true,
|
|
218
|
-
DEFLATE: true,
|
|
219
|
-
DEFRAG: true,
|
|
220
|
-
DELTA: true,
|
|
221
|
-
DELTA32K: true,
|
|
222
|
-
DESC: true,
|
|
223
|
-
DISABLE: true,
|
|
224
|
-
DISTINCT: true,
|
|
225
|
-
DO: true,
|
|
226
|
-
ELSE: true,
|
|
227
|
-
EMPTYASNULL: true,
|
|
228
|
-
ENABLE: true,
|
|
229
|
-
ENCODE: true,
|
|
230
|
-
ENCRYPT: true,
|
|
231
|
-
ENCRYPTION: true,
|
|
232
|
-
END: true,
|
|
233
|
-
EXCEPT: true,
|
|
234
|
-
EXPLICIT: true,
|
|
235
|
-
FALSE: true,
|
|
236
|
-
FOR: true,
|
|
237
|
-
FOREIGN: true,
|
|
238
|
-
FREEZE: true,
|
|
239
|
-
FROM: true,
|
|
240
|
-
FULL: true,
|
|
241
|
-
GLOBALDICT256: true,
|
|
242
|
-
GLOBALDICT64K: true,
|
|
243
|
-
GRANT: true,
|
|
244
|
-
GROUP: true,
|
|
245
|
-
GZIP: true,
|
|
246
|
-
HAVING: true,
|
|
247
|
-
IDENTITY: true,
|
|
248
|
-
IGNORE: true,
|
|
249
|
-
ILIKE: true,
|
|
250
|
-
IN: true,
|
|
251
|
-
INITIALLY: true,
|
|
252
|
-
INNER: true,
|
|
253
|
-
INTERSECT: true,
|
|
254
|
-
INTO: true,
|
|
255
|
-
IS: true,
|
|
256
|
-
ISNULL: true,
|
|
257
|
-
JOIN: true,
|
|
258
|
-
LEADING: true,
|
|
259
|
-
LEFT: true,
|
|
260
|
-
LIKE: true,
|
|
261
|
-
LIMIT: true,
|
|
262
|
-
LOCALTIME: true,
|
|
263
|
-
LOCALTIMESTAMP: true,
|
|
264
|
-
LUN: true,
|
|
265
|
-
LUNS: true,
|
|
266
|
-
LZO: true,
|
|
267
|
-
LZOP: true,
|
|
268
|
-
MINUS: true,
|
|
269
|
-
MOSTLY13: true,
|
|
270
|
-
MOSTLY32: true,
|
|
271
|
-
MOSTLY8: true,
|
|
272
|
-
NATURAL: true,
|
|
273
|
-
NEW: true,
|
|
274
|
-
NOT: true,
|
|
275
|
-
NOTNULL: true,
|
|
276
|
-
NULL: true,
|
|
277
|
-
NULLS: true,
|
|
278
|
-
OFF: true,
|
|
279
|
-
OFFLINE: true,
|
|
280
|
-
OFFSET: true,
|
|
281
|
-
OLD: true,
|
|
282
|
-
ON: true,
|
|
283
|
-
ONLY: true,
|
|
284
|
-
OPEN: true,
|
|
285
|
-
OR: true,
|
|
286
|
-
ORDER: true,
|
|
287
|
-
OUTER: true,
|
|
288
|
-
OVERLAPS: true,
|
|
289
|
-
PARALLEL: true,
|
|
290
|
-
PARTITION: true,
|
|
291
|
-
PERCENT: true,
|
|
292
|
-
PLACING: true,
|
|
293
|
-
PRIMARY: true,
|
|
294
|
-
RAW: true,
|
|
295
|
-
READRATIO: true,
|
|
296
|
-
RECOVER: true,
|
|
297
|
-
REFERENCES: true,
|
|
298
|
-
REJECTLOG: true,
|
|
299
|
-
RESORT: true,
|
|
300
|
-
RESTORE: true,
|
|
301
|
-
RIGHT: true,
|
|
302
|
-
SELECT: true,
|
|
303
|
-
SESSION_USER: true,
|
|
304
|
-
SIMILAR: true,
|
|
305
|
-
SOME: true,
|
|
306
|
-
SYSDATE: true,
|
|
307
|
-
SYSTEM: true,
|
|
308
|
-
TABLE: true,
|
|
309
|
-
TAG: true,
|
|
310
|
-
TDES: true,
|
|
311
|
-
TEXT255: true,
|
|
312
|
-
TEXT32K: true,
|
|
313
|
-
THEN: true,
|
|
314
|
-
TO: true,
|
|
315
|
-
TOP: true,
|
|
316
|
-
TRAILING: true,
|
|
317
|
-
TRUE: true,
|
|
318
|
-
TRUNCATECOLUMNS: true,
|
|
319
|
-
UNION: true,
|
|
320
|
-
UNIQUE: true,
|
|
321
|
-
USER: true,
|
|
322
|
-
USING: true,
|
|
323
|
-
VERBOSE: true,
|
|
324
|
-
WALLET: true,
|
|
325
|
-
WHEN: true,
|
|
326
|
-
WHERE: true,
|
|
327
|
-
WITH: true,
|
|
328
|
-
WITHOUT: true
|
|
329
|
-
};
|
|
330
|
-
var reserved_default = reservedMap;
|
|
331
|
-
|
|
332
|
-
// src/storage/postgresql/core/sql/formatter/index.ts
|
|
333
|
-
var postgreSQLProcessorsRegistry = _chunkOJ34O3Q2cjs.SQLProcessorsRegistry.call(void 0, {
|
|
334
|
-
from: _chunkOJ34O3Q2cjs.defaultProcessorsRegistry
|
|
335
|
-
}).register(postgreSQLColumnProcessors);
|
|
336
|
-
var pgFormatter = _chunkOJ34O3Q2cjs.SQLFormatter.call(void 0, {
|
|
337
|
-
processorsRegistry: postgreSQLProcessorsRegistry,
|
|
338
|
-
valueMapper: {
|
|
339
|
-
mapDate: (value) => value.toISOString().replace("T", " ").replace("Z", "+00"),
|
|
340
|
-
mapPlaceholder: (index) => `$${index + 1}`,
|
|
341
|
-
mapIdentifier: (value) => _chunkOJ34O3Q2cjs.mapSQLIdentifier.call(void 0, value, { reservedWords: reserved_default })
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
_chunkOJ34O3Q2cjs.registerFormatter.call(void 0, "PostgreSQL", pgFormatter);
|
|
345
|
-
|
|
346
|
-
// src/storage/postgresql/core/index.ts
|
|
347
|
-
var PostgreSQLDatabaseName = "PostgreSQL";
|
|
348
|
-
|
|
349
|
-
// src/storage/postgresql/pg/connections/connection.ts
|
|
350
|
-
var _pg = require('pg'); var _pg2 = _interopRequireDefault(_pg);
|
|
351
|
-
|
|
352
|
-
// src/storage/postgresql/pg/execute/execute.ts
|
|
353
|
-
|
|
354
|
-
var isNodePostgresNativePool = (poolOrClient) => {
|
|
355
|
-
return poolOrClient instanceof _pg2.default.Pool;
|
|
356
|
-
};
|
|
357
|
-
var isNodePostgresClient = (poolOrClient) => poolOrClient instanceof _pg2.default.Client;
|
|
358
|
-
var isNodePostgresPoolClient = (poolOrClient) => "release" in poolOrClient && typeof poolOrClient.release === "function";
|
|
359
|
-
var nodePostgresExecute = async (poolOrClient, handle) => {
|
|
360
|
-
const client = isNodePostgresNativePool(poolOrClient) ? await poolOrClient.connect() : poolOrClient;
|
|
361
|
-
try {
|
|
362
|
-
return await handle(client);
|
|
363
|
-
} finally {
|
|
364
|
-
if (isNodePostgresNativePool(poolOrClient) && isNodePostgresPoolClient(client))
|
|
365
|
-
client.release();
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
var nodePostgresSQLExecutor = () => ({
|
|
369
|
-
driverType: NodePostgresDriverType,
|
|
370
|
-
query: batch,
|
|
371
|
-
batchQuery: batch,
|
|
372
|
-
command: batch,
|
|
373
|
-
batchCommand: batch,
|
|
374
|
-
formatter: pgFormatter
|
|
375
|
-
});
|
|
376
|
-
async function batch(client, sqlOrSqls, options) {
|
|
377
|
-
const sqls = Array.isArray(sqlOrSqls) ? sqlOrSqls : [sqlOrSqls];
|
|
378
|
-
const results = Array(
|
|
379
|
-
sqls.length
|
|
380
|
-
);
|
|
381
|
-
if (_optionalChain([options, 'optionalAccess', _ => _.timeoutMs])) {
|
|
382
|
-
await client.query(`SET statement_timeout = ${_optionalChain([options, 'optionalAccess', _2 => _2.timeoutMs])}`);
|
|
383
|
-
}
|
|
384
|
-
for (let i = 0; i < sqls.length; i++) {
|
|
385
|
-
const { query, params } = pgFormatter.format(sqls[i]);
|
|
386
|
-
_chunkOJ34O3Q2cjs.tracer.info("db:sql:query", {
|
|
387
|
-
query,
|
|
388
|
-
params,
|
|
389
|
-
debugSQL: pgFormatter.describe(sqls[i])
|
|
390
|
-
});
|
|
391
|
-
const result = await client.query(query, params);
|
|
392
|
-
results[i] = { rowCount: result.rowCount, rows: result.rows };
|
|
393
|
-
}
|
|
394
|
-
return Array.isArray(sqlOrSqls) ? results : results[0];
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// src/storage/postgresql/pg/connections/transaction.ts
|
|
398
|
-
var nodePostgresTransaction = (connection) => (getClient, options) => ({
|
|
399
|
-
connection: connection(),
|
|
400
|
-
driverType: NodePostgresDriverType,
|
|
401
|
-
begin: async () => {
|
|
402
|
-
const client = await getClient;
|
|
403
|
-
await client.query("BEGIN");
|
|
404
|
-
},
|
|
405
|
-
commit: async () => {
|
|
406
|
-
const client = await getClient;
|
|
407
|
-
try {
|
|
408
|
-
await client.query("COMMIT");
|
|
409
|
-
} finally {
|
|
410
|
-
if (_optionalChain([options, 'optionalAccess', _3 => _3.close])) await _optionalChain([options, 'optionalAccess', _4 => _4.close, 'call', _5 => _5(client)]);
|
|
411
|
-
}
|
|
412
|
-
},
|
|
413
|
-
rollback: async (error) => {
|
|
414
|
-
const client = await getClient;
|
|
415
|
-
try {
|
|
416
|
-
await client.query("ROLLBACK");
|
|
417
|
-
} finally {
|
|
418
|
-
if (_optionalChain([options, 'optionalAccess', _6 => _6.close])) await _optionalChain([options, 'optionalAccess', _7 => _7.close, 'call', _8 => _8(client, error)]);
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
execute: _chunkOJ34O3Q2cjs.sqlExecutor.call(void 0, nodePostgresSQLExecutor(), {
|
|
422
|
-
connect: () => getClient
|
|
423
|
-
})
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
// src/storage/postgresql/pg/connections/connection.ts
|
|
427
|
-
var NodePostgresDriverType = "PostgreSQL:pg";
|
|
428
|
-
var nodePostgresClientConnection = (options) => {
|
|
429
|
-
const { connect, close } = options;
|
|
430
|
-
return _chunkOJ34O3Q2cjs.createConnection.call(void 0, {
|
|
431
|
-
driverType: NodePostgresDriverType,
|
|
432
|
-
connect,
|
|
433
|
-
close,
|
|
434
|
-
initTransaction: (connection) => nodePostgresTransaction(connection),
|
|
435
|
-
executor: nodePostgresSQLExecutor
|
|
436
|
-
});
|
|
437
|
-
};
|
|
438
|
-
var nodePostgresPoolClientConnection = (options) => {
|
|
439
|
-
const { connect, close } = options;
|
|
440
|
-
return _chunkOJ34O3Q2cjs.createConnection.call(void 0, {
|
|
441
|
-
driverType: NodePostgresDriverType,
|
|
442
|
-
connect,
|
|
443
|
-
close,
|
|
444
|
-
initTransaction: (connection) => nodePostgresTransaction(connection),
|
|
445
|
-
executor: nodePostgresSQLExecutor
|
|
446
|
-
});
|
|
447
|
-
};
|
|
448
|
-
function nodePostgresConnection(options) {
|
|
449
|
-
return options.type === "Client" ? nodePostgresClientConnection(options) : nodePostgresPoolClientConnection(options);
|
|
450
|
-
}
|
|
451
|
-
var checkConnection = async (connectionString) => {
|
|
452
|
-
const client = new _pg2.default.Client({
|
|
453
|
-
connectionString
|
|
454
|
-
});
|
|
455
|
-
try {
|
|
456
|
-
await client.connect();
|
|
457
|
-
return { successful: true };
|
|
458
|
-
} catch (error) {
|
|
459
|
-
const code = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
460
|
-
return {
|
|
461
|
-
successful: false,
|
|
462
|
-
errorType: code === "ECONNREFUSED" ? "ConnectionRefused" : code === "28P01" ? "Authentication" : "Unknown",
|
|
463
|
-
code,
|
|
464
|
-
error
|
|
465
|
-
};
|
|
466
|
-
} finally {
|
|
467
|
-
await client.end();
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
// src/storage/postgresql/pg/connections/pool.ts
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
// src/storage/postgresql/pg/serialization/index.ts
|
|
475
|
-
|
|
476
|
-
var setNodePostgresTypeParser = (jsonSerializer) => {
|
|
477
|
-
_pg2.default.types.setTypeParser(20, (val) => BigInt(val));
|
|
478
|
-
_pg2.default.types.setTypeParser(3802, (val) => jsonSerializer.deserialize(val));
|
|
479
|
-
_pg2.default.types.setTypeParser(114, (val) => jsonSerializer.deserialize(val));
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
// src/storage/postgresql/pg/connections/pool.ts
|
|
483
|
-
var nodePostgresNativePool = (options) => {
|
|
484
|
-
const { connectionString, database } = options;
|
|
485
|
-
const pool = getPool({ connectionString, database });
|
|
486
|
-
const getConnection = () => nodePostgresConnection({
|
|
487
|
-
type: "PoolClient",
|
|
488
|
-
connect: () => pool.connect(),
|
|
489
|
-
close: (client) => Promise.resolve(client.release())
|
|
490
|
-
});
|
|
491
|
-
const open = () => Promise.resolve(getConnection());
|
|
492
|
-
const close = () => endPool({ connectionString, database });
|
|
493
|
-
return _chunkOJ34O3Q2cjs.createConnectionPool.call(void 0, {
|
|
494
|
-
driverType: NodePostgresDriverType,
|
|
495
|
-
connection: open,
|
|
496
|
-
close,
|
|
497
|
-
getConnection
|
|
498
|
-
});
|
|
499
|
-
};
|
|
500
|
-
var nodePostgresAmbientNativePool = (options) => {
|
|
501
|
-
const { pool } = options;
|
|
502
|
-
return _chunkOJ34O3Q2cjs.createConnectionPool.call(void 0, {
|
|
503
|
-
driverType: NodePostgresDriverType,
|
|
504
|
-
getConnection: () => nodePostgresConnection({
|
|
505
|
-
type: "PoolClient",
|
|
506
|
-
connect: () => pool.connect(),
|
|
507
|
-
close: (client) => Promise.resolve(client.release())
|
|
508
|
-
})
|
|
509
|
-
});
|
|
510
|
-
};
|
|
511
|
-
var nodePostgresAmbientConnectionPool = (options) => {
|
|
512
|
-
const { connection } = options;
|
|
513
|
-
return _chunkOJ34O3Q2cjs.createAmbientConnectionPool.call(void 0, {
|
|
514
|
-
driverType: NodePostgresDriverType,
|
|
515
|
-
connection
|
|
516
|
-
});
|
|
517
|
-
};
|
|
518
|
-
var nodePostgresClientPool = (options) => {
|
|
519
|
-
const { connectionString, database } = options;
|
|
520
|
-
return _chunkOJ34O3Q2cjs.createConnectionPool.call(void 0, {
|
|
521
|
-
driverType: NodePostgresDriverType,
|
|
522
|
-
getConnection: () => {
|
|
523
|
-
const connect = async () => {
|
|
524
|
-
const client = new _pg2.default.Client({ connectionString, database });
|
|
525
|
-
await client.connect();
|
|
526
|
-
return client;
|
|
527
|
-
};
|
|
528
|
-
return nodePostgresConnection({
|
|
529
|
-
type: "Client",
|
|
530
|
-
connect,
|
|
531
|
-
close: (client) => client.end()
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
};
|
|
536
|
-
var nodePostgresAmbientClientPool = (options) => {
|
|
537
|
-
const { client } = options;
|
|
538
|
-
const getConnection = () => {
|
|
539
|
-
const connect = () => Promise.resolve(client);
|
|
540
|
-
return nodePostgresConnection({
|
|
541
|
-
type: "Client",
|
|
542
|
-
connect,
|
|
543
|
-
close: () => Promise.resolve()
|
|
544
|
-
});
|
|
545
|
-
};
|
|
546
|
-
const open = () => Promise.resolve(getConnection());
|
|
547
|
-
const close = () => Promise.resolve();
|
|
548
|
-
return _chunkOJ34O3Q2cjs.createConnectionPool.call(void 0, {
|
|
549
|
-
driverType: NodePostgresDriverType,
|
|
550
|
-
connection: open,
|
|
551
|
-
close,
|
|
552
|
-
getConnection
|
|
553
|
-
});
|
|
554
|
-
};
|
|
555
|
-
function nodePostgresPool(options) {
|
|
556
|
-
const { connectionString, database, serializer } = options;
|
|
557
|
-
setNodePostgresTypeParser(_nullishCoalesce(serializer, () => ( _chunkOJ34O3Q2cjs.JSONSerializer)));
|
|
558
|
-
if ("client" in options && options.client)
|
|
559
|
-
return nodePostgresAmbientClientPool({ client: options.client });
|
|
560
|
-
if ("connection" in options && options.connection)
|
|
561
|
-
return nodePostgresAmbientConnectionPool({
|
|
562
|
-
connection: options.connection
|
|
563
|
-
});
|
|
564
|
-
if ("pooled" in options && options.pooled === false)
|
|
565
|
-
return nodePostgresClientPool({ connectionString, database });
|
|
566
|
-
if ("pool" in options && options.pool)
|
|
567
|
-
return nodePostgresAmbientNativePool({ pool: options.pool });
|
|
568
|
-
return nodePostgresNativePool({
|
|
569
|
-
connectionString,
|
|
570
|
-
database
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
var pools = /* @__PURE__ */ new Map();
|
|
574
|
-
var usageCounter = /* @__PURE__ */ new Map();
|
|
575
|
-
var getPool = (connectionStringOrOptions) => {
|
|
576
|
-
const connectionString = typeof connectionStringOrOptions === "string" ? connectionStringOrOptions : connectionStringOrOptions.connectionString;
|
|
577
|
-
const poolOptions = typeof connectionStringOrOptions === "string" ? { connectionString } : connectionStringOrOptions;
|
|
578
|
-
const database = _nullishCoalesce(poolOptions.database, () => ( (poolOptions.connectionString ? getDatabaseNameOrDefault(poolOptions.connectionString) : void 0)));
|
|
579
|
-
const lookupKey = key(connectionString, database);
|
|
580
|
-
updatePoolUsageCounter(lookupKey, 1);
|
|
581
|
-
return _nullishCoalesce(pools.get(lookupKey), () => ( pools.set(lookupKey, new _pg2.default.Pool(poolOptions)).get(lookupKey)));
|
|
582
|
-
};
|
|
583
|
-
var endPool = async ({
|
|
584
|
-
connectionString,
|
|
585
|
-
database,
|
|
586
|
-
force
|
|
587
|
-
}) => {
|
|
588
|
-
database = _nullishCoalesce(database, () => ( getDatabaseNameOrDefault(connectionString)));
|
|
589
|
-
const lookupKey = key(connectionString, database);
|
|
590
|
-
const pool = pools.get(lookupKey);
|
|
591
|
-
if (pool && (updatePoolUsageCounter(lookupKey, -1) <= 0 || force === true)) {
|
|
592
|
-
await onEndPool(lookupKey, pool);
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
var onEndPool = async (lookupKey, pool) => {
|
|
596
|
-
try {
|
|
597
|
-
await pool.end();
|
|
598
|
-
} catch (error) {
|
|
599
|
-
_chunkOJ34O3Q2cjs.tracer.error("connection-closing-error", { lookupKey, error });
|
|
600
|
-
}
|
|
601
|
-
pools.delete(lookupKey);
|
|
602
|
-
};
|
|
603
|
-
var endAllPools = () => Promise.all(
|
|
604
|
-
[...pools.entries()].map(([lookupKey, pool]) => onEndPool(lookupKey, pool))
|
|
605
|
-
);
|
|
606
|
-
var key = (connectionString, database) => `${connectionString}|${_nullishCoalesce(database, () => ( defaultPostgreSqlDatabase))}`;
|
|
607
|
-
var updatePoolUsageCounter = (lookupKey, by) => {
|
|
608
|
-
const currentCounter = _nullishCoalesce(usageCounter.get(lookupKey), () => ( 0));
|
|
609
|
-
const newCounter = currentCounter + by;
|
|
610
|
-
usageCounter.set(lookupKey, currentCounter + by);
|
|
611
|
-
return newCounter;
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
// src/storage/postgresql/pg/index.ts
|
|
615
|
-
var tryParseConnectionString = (connectionString) => {
|
|
616
|
-
try {
|
|
617
|
-
return PostgreSQLConnectionString(connectionString);
|
|
618
|
-
} catch (e) {
|
|
619
|
-
return null;
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
var pgDatabaseDriver = {
|
|
623
|
-
driverType: NodePostgresDriverType,
|
|
624
|
-
createPool: (options) => nodePostgresPool(options),
|
|
625
|
-
sqlFormatter: pgFormatter,
|
|
626
|
-
defaultMigratorOptions: DefaultPostgreSQLMigratorOptions,
|
|
627
|
-
getDatabaseNameOrDefault,
|
|
628
|
-
canHandle: _chunkOJ34O3Q2cjs.canHandleDriverWithConnectionString.call(void 0,
|
|
629
|
-
NodePostgresDriverType,
|
|
630
|
-
tryParseConnectionString
|
|
631
|
-
)
|
|
632
|
-
};
|
|
633
|
-
var usePgDatabaseDriver = () => {
|
|
634
|
-
_chunkOJ34O3Q2cjs.dumboDatabaseDriverRegistry.register(
|
|
635
|
-
NodePostgresDriverType,
|
|
636
|
-
pgDatabaseDriver
|
|
637
|
-
);
|
|
638
|
-
};
|
|
639
|
-
usePgDatabaseDriver();
|
|
640
|
-
var postgresPool = nodePostgresPool;
|
|
641
|
-
var connectionPool = postgresPool;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
exports.tryAcquireAdvisoryLock = tryAcquireAdvisoryLock; exports.releaseAdvisoryLock = releaseAdvisoryLock; exports.acquireAdvisoryLock = acquireAdvisoryLock; exports.AdvisoryLock = AdvisoryLock; exports.advisoryLock = advisoryLock; exports.DefaultPostgreSQLMigratorOptions = DefaultPostgreSQLMigratorOptions; exports.defaultPostgreSqlDatabase = defaultPostgreSqlDatabase; exports.tableExistsSQL = tableExistsSQL; exports.tableExists = tableExists; exports.functionExistsSQL = functionExistsSQL; exports.functionExists = functionExists; exports.defaultPostgreSQLConnectionString = defaultPostgreSQLConnectionString; exports.getDatabaseNameOrDefault = getDatabaseNameOrDefault; exports.PostgreSQLConnectionString = PostgreSQLConnectionString; exports.postgreSQLColumnProcessors = postgreSQLColumnProcessors; exports.pgFormatter = pgFormatter; exports.PostgreSQLDatabaseName = PostgreSQLDatabaseName; exports.isNodePostgresNativePool = isNodePostgresNativePool; exports.isNodePostgresClient = isNodePostgresClient; exports.isNodePostgresPoolClient = isNodePostgresPoolClient; exports.nodePostgresExecute = nodePostgresExecute; exports.nodePostgresSQLExecutor = nodePostgresSQLExecutor; exports.nodePostgresTransaction = nodePostgresTransaction; exports.NodePostgresDriverType = NodePostgresDriverType; exports.nodePostgresClientConnection = nodePostgresClientConnection; exports.nodePostgresPoolClientConnection = nodePostgresPoolClientConnection; exports.nodePostgresConnection = nodePostgresConnection; exports.checkConnection = checkConnection; exports.setNodePostgresTypeParser = setNodePostgresTypeParser; exports.nodePostgresNativePool = nodePostgresNativePool; exports.nodePostgresAmbientNativePool = nodePostgresAmbientNativePool; exports.nodePostgresAmbientConnectionPool = nodePostgresAmbientConnectionPool; exports.nodePostgresClientPool = nodePostgresClientPool; exports.nodePostgresAmbientClientPool = nodePostgresAmbientClientPool; exports.nodePostgresPool = nodePostgresPool; exports.getPool = getPool; exports.endPool = endPool; exports.onEndPool = onEndPool; exports.endAllPools = endAllPools; exports.pgDatabaseDriver = pgDatabaseDriver; exports.usePgDatabaseDriver = usePgDatabaseDriver; exports.postgresPool = postgresPool; exports.connectionPool = connectionPool;
|
|
688
|
-
//# sourceMappingURL=chunk-ISNF6USX.cjs.map
|