@event-driven-io/dumbo 0.13.0-beta.4 → 0.13.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare.cjs +397 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +99 -0
- package/dist/cloudflare.d.ts +99 -0
- package/dist/cloudflare.js +361 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/core-BMeDuqBQ.js +2265 -0
- package/dist/core-BMeDuqBQ.js.map +1 -0
- package/dist/core-BPNgo5b6.js +379 -0
- package/dist/core-BPNgo5b6.js.map +1 -0
- package/dist/core-CIVu4cNp.cjs +588 -0
- package/dist/core-CIVu4cNp.cjs.map +1 -0
- package/dist/core-D5W_5J8k.cjs +3246 -0
- package/dist/core-D5W_5J8k.cjs.map +1 -0
- package/dist/core-DqUjje4u.cjs +450 -0
- package/dist/core-DqUjje4u.cjs.map +1 -0
- package/dist/core-gu5fi784.js +451 -0
- package/dist/core-gu5fi784.js.map +1 -0
- package/dist/{index-C2z_XBn6.d.ts → index-B-q2er0S.d.cts} +122 -75
- package/dist/{index-C0h0c380.d.cts → index-B5qbt5nP.d.ts} +122 -75
- package/dist/index-BJJAkyuJ.d.ts +68 -0
- package/dist/index-CRbkvVjT.d.ts +1587 -0
- package/dist/index-Cmdlb0KP.d.cts +1587 -0
- package/dist/index-D7qxqMf9.d.cts +67 -0
- package/dist/index-DtRCGhFP.d.cts +68 -0
- package/dist/index-m5LDyNNF.d.ts +67 -0
- package/dist/index.cjs +219 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -127
- package/dist/index.d.ts +3 -127
- package/dist/index.js +56 -269
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +373 -659
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +140 -153
- package/dist/pg.d.ts +140 -153
- package/dist/pg.js +326 -658
- package/dist/pg.js.map +1 -1
- package/dist/postgreSQLMetadata-Khf1e9CT.js +65 -0
- package/dist/postgreSQLMetadata-Khf1e9CT.js.map +1 -0
- package/dist/postgreSQLMetadata-Ri_p5u6i.cjs +118 -0
- package/dist/postgreSQLMetadata-Ri_p5u6i.cjs.map +1 -0
- package/dist/postgresql.cjs +25 -0
- package/dist/postgresql.d.cts +3 -0
- package/dist/postgresql.d.ts +3 -0
- package/dist/postgresql.js +4 -0
- package/dist/sqlite.cjs +30 -0
- package/dist/sqlite.d.cts +3 -0
- package/dist/sqlite.d.ts +3 -0
- package/dist/sqlite.js +4 -0
- package/dist/sqlite3.cjs +437 -273
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +92 -70
- package/dist/sqlite3.d.ts +92 -70
- package/dist/sqlite3.js +402 -272
- package/dist/sqlite3.js.map +1 -1
- package/dist/sqliteMetadata-CpmoZxqb.cjs +46 -0
- package/dist/sqliteMetadata-CpmoZxqb.cjs.map +1 -0
- package/dist/sqliteMetadata-viYmVwA5.js +29 -0
- package/dist/sqliteMetadata-viYmVwA5.js.map +1 -0
- package/package.json +60 -37
- package/dist/chunk-32AL3EAS.cjs +0 -47
- package/dist/chunk-32AL3EAS.cjs.map +0 -1
- package/dist/chunk-6IHCIJ7S.js +0 -47
- package/dist/chunk-6IHCIJ7S.js.map +0 -1
- package/dist/chunk-IYEHOE4S.cjs +0 -405
- package/dist/chunk-IYEHOE4S.cjs.map +0 -1
- package/dist/chunk-N7RWT46K.js +0 -2011
- package/dist/chunk-N7RWT46K.js.map +0 -1
- package/dist/chunk-OJ34O3Q2.cjs +0 -2011
- package/dist/chunk-OJ34O3Q2.cjs.map +0 -1
- package/dist/chunk-XVV3OOQX.js +0 -405
- package/dist/chunk-XVV3OOQX.js.map +0 -1
- package/dist/columnProcessors-BX-sH7ah.d.cts +0 -8
- package/dist/columnProcessors-DMPpTPqM.d.ts +0 -8
- package/dist/connectionString-B1wm0TFc.d.cts +0 -1271
- package/dist/connectionString-B1wm0TFc.d.ts +0 -1271
- 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.js
CHANGED
|
@@ -1,688 +1,356 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
SQLFormatter,
|
|
5
|
-
SQLProcessorsRegistry,
|
|
6
|
-
canHandleDriverWithConnectionString,
|
|
7
|
-
createAmbientConnectionPool,
|
|
8
|
-
createConnection,
|
|
9
|
-
createConnectionPool,
|
|
10
|
-
defaultDatabaseLockOptions,
|
|
11
|
-
defaultProcessorsRegistry,
|
|
12
|
-
dumboDatabaseDriverRegistry,
|
|
13
|
-
exists,
|
|
14
|
-
mapDefaultSQLColumnProcessors,
|
|
15
|
-
mapSQLIdentifier,
|
|
16
|
-
registerDefaultMigratorOptions,
|
|
17
|
-
registerFormatter,
|
|
18
|
-
single,
|
|
19
|
-
sqlExecutor,
|
|
20
|
-
tracer
|
|
21
|
-
} from "./chunk-N7RWT46K.js";
|
|
22
|
-
|
|
23
|
-
// src/storage/postgresql/core/connections/connectionString.ts
|
|
24
|
-
import pgcs from "pg-connection-string";
|
|
25
|
-
|
|
26
|
-
// src/storage/postgresql/core/locks/advisoryLocks.ts
|
|
27
|
-
var tryAcquireAdvisoryLock = async (execute, options) => {
|
|
28
|
-
const timeoutMs = options.timeoutMs ?? defaultDatabaseLockOptions.timeoutMs;
|
|
29
|
-
const advisoryLock2 = options.mode === "Permanent" ? "pg_advisory_lock" : "pg_advisory_xact_lock";
|
|
30
|
-
try {
|
|
31
|
-
await single(
|
|
32
|
-
execute.query(
|
|
33
|
-
SQL`SELECT ${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 = options.timeoutMs ?? defaultDatabaseLockOptions.timeoutMs;
|
|
46
|
-
try {
|
|
47
|
-
await single(
|
|
48
|
-
execute.query(
|
|
49
|
-
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
|
-
...acquireOptions ?? {}
|
|
86
|
-
}),
|
|
87
|
-
tryAcquire: (acquireOptions) => tryAcquireAdvisoryLock(execute, {
|
|
88
|
-
...options,
|
|
89
|
-
...acquireOptions ?? {}
|
|
90
|
-
}),
|
|
91
|
-
release: () => releaseAdvisoryLock(execute, options),
|
|
92
|
-
withAcquire: async (handle, acquireOptions) => {
|
|
93
|
-
await acquireAdvisoryLock(execute, {
|
|
94
|
-
...options,
|
|
95
|
-
...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
|
-
registerDefaultMigratorOptions("PostgreSQL", DefaultPostgreSQLMigratorOptions);
|
|
112
|
-
|
|
113
|
-
// src/storage/postgresql/core/schema/schema.ts
|
|
114
|
-
var defaultPostgreSqlDatabase = "postgres";
|
|
115
|
-
var tableExistsSQL = (tableName) => SQL`
|
|
116
|
-
SELECT EXISTS (
|
|
117
|
-
SELECT FROM pg_tables
|
|
118
|
-
WHERE tablename = ${tableName}
|
|
119
|
-
) AS exists;`;
|
|
120
|
-
var tableExists = async (pool, tableName) => exists(pool.execute.query(tableExistsSQL(tableName)));
|
|
121
|
-
var functionExistsSQL = (functionName) => SQL`
|
|
122
|
-
SELECT EXISTS (
|
|
123
|
-
SELECT FROM pg_proc
|
|
124
|
-
WHERE
|
|
125
|
-
proname = ${functionName}
|
|
126
|
-
) AS exists;`;
|
|
127
|
-
var functionExists = async (pool, tableName) => exists(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) => pgcs.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 = mapDefaultSQLColumnProcessors(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 = SQLProcessorsRegistry({
|
|
334
|
-
from: defaultProcessorsRegistry
|
|
335
|
-
}).register(postgreSQLColumnProcessors);
|
|
336
|
-
var pgFormatter = SQLFormatter({
|
|
337
|
-
processorsRegistry: postgreSQLProcessorsRegistry,
|
|
338
|
-
valueMapper: {
|
|
339
|
-
mapDate: (value) => value.toISOString().replace("T", " ").replace("Z", "+00"),
|
|
340
|
-
mapPlaceholder: (index) => `$${index + 1}`,
|
|
341
|
-
mapIdentifier: (value) => mapSQLIdentifier(value, { reservedWords: reserved_default })
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
registerFormatter("PostgreSQL", pgFormatter);
|
|
345
|
-
|
|
346
|
-
// src/storage/postgresql/core/index.ts
|
|
347
|
-
var PostgreSQLDatabaseName = "PostgreSQL";
|
|
348
|
-
|
|
349
|
-
// src/storage/postgresql/pg/connections/connection.ts
|
|
350
|
-
import pg2 from "pg";
|
|
351
|
-
|
|
352
|
-
// src/storage/postgresql/pg/execute/execute.ts
|
|
1
|
+
import { E as sqlExecutor, On as canHandleDriverWithConnectionString, T as mapSQLQueryResult, i as createConnectionPool, in as JSONSerializer, it as tracer, kn as dumboDatabaseDriverRegistry, n as createAmbientConnectionPool, u as createConnection, v as BatchCommandNoChangesError } from "./core-BMeDuqBQ.js";
|
|
2
|
+
import { a as tableExists, c as defaultPostgreSQLConnectionString, i as functionExistsSQL, l as parseDatabaseName, n as defaultPostgreSqlDatabase, o as tableExistsSQL, r as functionExists, s as PostgreSQLConnectionString, t as postgreSQLMetadata } from "./postgreSQLMetadata-Khf1e9CT.js";
|
|
3
|
+
import { a as PostgreSQLExpandSQLInProcessor, c as acquireAdvisoryLock, d as tryAcquireAdvisoryLock, f as mapPostgresError, i as PostgreSQLArrayProcessor, l as advisoryLock, n as pgFormatter, o as DefaultPostgreSQLMigratorOptions, r as postgreSQLColumnProcessors, s as AdvisoryLock, t as PostgreSQLDatabaseName, u as releaseAdvisoryLock } from "./core-BPNgo5b6.js";
|
|
353
4
|
import pg from "pg";
|
|
354
|
-
|
|
355
|
-
|
|
5
|
+
|
|
6
|
+
//#region src/storage/postgresql/pg/execute/execute.ts
|
|
7
|
+
const isPgNativePool = (poolOrClient) => {
|
|
8
|
+
return poolOrClient instanceof pg.Pool;
|
|
356
9
|
};
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
10
|
+
const isPgClient = (poolOrClient) => poolOrClient instanceof pg.Client;
|
|
11
|
+
const isPgPoolClient = (poolOrClient) => "release" in poolOrClient && typeof poolOrClient.release === "function";
|
|
12
|
+
const pgExecute = async (poolOrClient, handle) => {
|
|
13
|
+
const client = isPgNativePool(poolOrClient) ? await poolOrClient.connect() : poolOrClient;
|
|
14
|
+
try {
|
|
15
|
+
return await handle(client);
|
|
16
|
+
} finally {
|
|
17
|
+
if (isPgNativePool(poolOrClient) && isPgPoolClient(client)) client.release();
|
|
18
|
+
}
|
|
367
19
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
20
|
+
const pgSQLExecutor = ({ serializer }) => ({
|
|
21
|
+
driverType: PgDriverType,
|
|
22
|
+
query: async (client, sql, options) => {
|
|
23
|
+
return (await batchQuery(client, [sql], serializer, options))[0];
|
|
24
|
+
},
|
|
25
|
+
batchQuery: (client, sqls, options) => batchQuery(client, sqls, serializer, options),
|
|
26
|
+
command: async (client, sql, options) => {
|
|
27
|
+
return (await batchCommand(client, [sql], serializer, options))[0];
|
|
28
|
+
},
|
|
29
|
+
batchCommand: (client, sqls, options) => batchCommand(client, sqls, serializer, options),
|
|
30
|
+
formatter: pgFormatter
|
|
375
31
|
});
|
|
376
|
-
async function
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
32
|
+
async function batchQuery(client, sqls, serializer, options) {
|
|
33
|
+
const results = Array(sqls.length);
|
|
34
|
+
if (options?.timeoutMs) await client.query(`SET statement_timeout = ${options.timeoutMs}`);
|
|
35
|
+
for (let i = 0; i < sqls.length; i++) {
|
|
36
|
+
const { query, params } = pgFormatter.format(sqls[i], { serializer });
|
|
37
|
+
tracer.info("db:sql:query", {
|
|
38
|
+
query,
|
|
39
|
+
params,
|
|
40
|
+
debugSQL: pgFormatter.describe(sqls[i], { serializer })
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
let result = params.length > 0 ? await client.query(query, params) : await client.query(query);
|
|
44
|
+
if (options?.mapping) result = {
|
|
45
|
+
...result,
|
|
46
|
+
rows: result.rows.map((row) => mapSQLQueryResult(row, options.mapping))
|
|
47
|
+
};
|
|
48
|
+
results[i] = {
|
|
49
|
+
rowCount: result.rowCount,
|
|
50
|
+
rows: result.rows
|
|
51
|
+
};
|
|
52
|
+
} catch (error) {
|
|
53
|
+
tracer.error("db:sql:batch_query:execute:error", { error });
|
|
54
|
+
throw mapPostgresError(error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return results;
|
|
58
|
+
}
|
|
59
|
+
async function batchCommand(client, sqls, serializer, options) {
|
|
60
|
+
const results = Array(sqls.length);
|
|
61
|
+
if (options?.timeoutMs) await client.query(`SET statement_timeout = ${options.timeoutMs}`);
|
|
62
|
+
for (let i = 0; i < sqls.length; i++) {
|
|
63
|
+
const { query, params } = pgFormatter.format(sqls[i], { serializer });
|
|
64
|
+
tracer.info("db:sql:command", {
|
|
65
|
+
query,
|
|
66
|
+
params,
|
|
67
|
+
debugSQL: pgFormatter.describe(sqls[i], { serializer })
|
|
68
|
+
});
|
|
69
|
+
try {
|
|
70
|
+
let result = params.length > 0 ? await client.query(query, params) : await client.query(query);
|
|
71
|
+
if (options?.mapping) result = {
|
|
72
|
+
...result,
|
|
73
|
+
rows: result.rows.map((row) => mapSQLQueryResult(row, options.mapping))
|
|
74
|
+
};
|
|
75
|
+
results[i] = {
|
|
76
|
+
rowCount: result.rowCount,
|
|
77
|
+
rows: result.rows
|
|
78
|
+
};
|
|
79
|
+
if (options?.assertChanges && (results[i].rowCount ?? 0) === 0) throw new BatchCommandNoChangesError(i);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
tracer.error("db:sql:batch_command:execute:error", { error });
|
|
82
|
+
throw mapPostgresError(error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return results;
|
|
395
86
|
}
|
|
396
87
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/storage/postgresql/pg/connections/transaction.ts
|
|
90
|
+
const pgTransaction = (connection, serializer) => (getClient, options) => ({
|
|
91
|
+
connection: connection(),
|
|
92
|
+
driverType: PgDriverType,
|
|
93
|
+
begin: async () => {
|
|
94
|
+
const client = await getClient;
|
|
95
|
+
const parts = ["BEGIN"];
|
|
96
|
+
if (options?.isolationLevel) parts.push(`ISOLATION LEVEL ${options.isolationLevel}`);
|
|
97
|
+
if (options?.readonly) parts.push("READ ONLY");
|
|
98
|
+
await client.query(parts.join(" "));
|
|
99
|
+
},
|
|
100
|
+
commit: async () => {
|
|
101
|
+
const client = await getClient;
|
|
102
|
+
try {
|
|
103
|
+
await client.query("COMMIT");
|
|
104
|
+
} finally {
|
|
105
|
+
if (options?.close) await options?.close(client);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
rollback: async (error) => {
|
|
109
|
+
const client = await getClient;
|
|
110
|
+
try {
|
|
111
|
+
await client.query("ROLLBACK");
|
|
112
|
+
} finally {
|
|
113
|
+
if (options?.close) await options?.close(client, error);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
execute: sqlExecutor(pgSQLExecutor({ serializer }), { connect: () => getClient }),
|
|
117
|
+
_transactionOptions: options ?? {}
|
|
424
118
|
});
|
|
425
119
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/storage/postgresql/pg/connections/connection.ts
|
|
122
|
+
const PgDriverType = "PostgreSQL:pg";
|
|
123
|
+
const pgClientConnection = (options) => {
|
|
124
|
+
const { connect, close } = options;
|
|
125
|
+
return createConnection({
|
|
126
|
+
driverType: PgDriverType,
|
|
127
|
+
connect,
|
|
128
|
+
close,
|
|
129
|
+
initTransaction: (connection) => pgTransaction(connection, options.serializer),
|
|
130
|
+
executor: pgSQLExecutor,
|
|
131
|
+
serializer: options.serializer
|
|
132
|
+
});
|
|
437
133
|
};
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
134
|
+
const pgPoolClientConnection = (options) => {
|
|
135
|
+
const { connect, close } = options;
|
|
136
|
+
return createConnection({
|
|
137
|
+
driverType: PgDriverType,
|
|
138
|
+
connect,
|
|
139
|
+
close,
|
|
140
|
+
initTransaction: (connection) => pgTransaction(connection, options.serializer),
|
|
141
|
+
executor: pgSQLExecutor,
|
|
142
|
+
serializer: options.serializer
|
|
143
|
+
});
|
|
447
144
|
};
|
|
448
|
-
function
|
|
449
|
-
|
|
145
|
+
function pgConnection(options) {
|
|
146
|
+
return options.type === "Client" ? pgClientConnection(options) : pgPoolClientConnection(options);
|
|
450
147
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
await client.end();
|
|
468
|
-
}
|
|
148
|
+
const checkConnection = async (connectionString) => {
|
|
149
|
+
const client = new pg.Client({ connectionString });
|
|
150
|
+
try {
|
|
151
|
+
await client.connect();
|
|
152
|
+
return { successful: true };
|
|
153
|
+
} catch (error) {
|
|
154
|
+
const code = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
155
|
+
return {
|
|
156
|
+
successful: false,
|
|
157
|
+
errorType: code === "ECONNREFUSED" ? "ConnectionRefused" : code === "28P01" ? "Authentication" : "Unknown",
|
|
158
|
+
code,
|
|
159
|
+
error
|
|
160
|
+
};
|
|
161
|
+
} finally {
|
|
162
|
+
await client.end();
|
|
163
|
+
}
|
|
469
164
|
};
|
|
470
165
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
pg3.types.setTypeParser(114, (val) => jsonSerializer.deserialize(val));
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/storage/postgresql/pg/serialization/index.ts
|
|
168
|
+
const setPgTypeParser = (client, options) => {
|
|
169
|
+
if (options?.parseBigInts === true) client.setTypeParser(20, (val) => BigInt(val));
|
|
170
|
+
if (options?.serializer) {
|
|
171
|
+
client.setTypeParser(3802, (val) => options.serializer.deserialize(val));
|
|
172
|
+
client.setTypeParser(114, (val) => options.serializer.deserialize(val));
|
|
173
|
+
}
|
|
480
174
|
};
|
|
481
175
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/storage/postgresql/pg/connections/pool.ts
|
|
178
|
+
const pgNativePool = (options) => {
|
|
179
|
+
const { connectionString, database } = options;
|
|
180
|
+
const pool = getPgPool({
|
|
181
|
+
connectionString,
|
|
182
|
+
database
|
|
183
|
+
});
|
|
184
|
+
const getConnection = () => pgConnection({
|
|
185
|
+
type: "PoolClient",
|
|
186
|
+
connect: async () => {
|
|
187
|
+
const client = await pool.connect();
|
|
188
|
+
setPgTypeParser(client, {
|
|
189
|
+
parseBigInts: true,
|
|
190
|
+
serializer: options.serializer
|
|
191
|
+
});
|
|
192
|
+
return client;
|
|
193
|
+
},
|
|
194
|
+
close: (client) => Promise.resolve(client.release()),
|
|
195
|
+
serializer: options.serializer
|
|
196
|
+
});
|
|
197
|
+
const open = () => Promise.resolve(getConnection());
|
|
198
|
+
const close = () => endPgPool({
|
|
199
|
+
connectionString,
|
|
200
|
+
database
|
|
201
|
+
});
|
|
202
|
+
return createConnectionPool({
|
|
203
|
+
driverType: PgDriverType,
|
|
204
|
+
connection: open,
|
|
205
|
+
close,
|
|
206
|
+
getConnection
|
|
207
|
+
});
|
|
499
208
|
};
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
209
|
+
const pgAmbientNativePool = (options) => {
|
|
210
|
+
const { pool } = options;
|
|
211
|
+
return createConnectionPool({
|
|
212
|
+
driverType: PgDriverType,
|
|
213
|
+
getConnection: () => pgConnection({
|
|
214
|
+
type: "PoolClient",
|
|
215
|
+
connect: () => pool.connect(),
|
|
216
|
+
close: (client) => Promise.resolve(client.release()),
|
|
217
|
+
serializer: options.serializer
|
|
218
|
+
})
|
|
219
|
+
});
|
|
510
220
|
};
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
221
|
+
const pgAmbientConnectionPool = (options) => {
|
|
222
|
+
const { connection } = options;
|
|
223
|
+
return createAmbientConnectionPool({
|
|
224
|
+
driverType: PgDriverType,
|
|
225
|
+
connection
|
|
226
|
+
});
|
|
517
227
|
};
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
228
|
+
const pgClientPool = (options) => {
|
|
229
|
+
const { connectionString, database } = options;
|
|
230
|
+
return createConnectionPool({
|
|
231
|
+
driverType: PgDriverType,
|
|
232
|
+
getConnection: () => {
|
|
233
|
+
const connect = async () => {
|
|
234
|
+
const client = new pg.Client({
|
|
235
|
+
connectionString,
|
|
236
|
+
database
|
|
237
|
+
});
|
|
238
|
+
setPgTypeParser(client, {
|
|
239
|
+
parseBigInts: true,
|
|
240
|
+
serializer: options.serializer
|
|
241
|
+
});
|
|
242
|
+
await client.connect();
|
|
243
|
+
return client;
|
|
244
|
+
};
|
|
245
|
+
return pgConnection({
|
|
246
|
+
type: "Client",
|
|
247
|
+
connect,
|
|
248
|
+
close: (client) => client.end(),
|
|
249
|
+
serializer: options.serializer
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
});
|
|
535
253
|
};
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
254
|
+
const pgAmbientClientPool = (options) => {
|
|
255
|
+
const { client } = options;
|
|
256
|
+
const getConnection = () => {
|
|
257
|
+
const connect = () => Promise.resolve(client);
|
|
258
|
+
return pgConnection({
|
|
259
|
+
type: "Client",
|
|
260
|
+
connect,
|
|
261
|
+
close: () => Promise.resolve(),
|
|
262
|
+
serializer: options.serializer
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
const open = () => Promise.resolve(getConnection());
|
|
266
|
+
const close = () => Promise.resolve();
|
|
267
|
+
return createConnectionPool({
|
|
268
|
+
driverType: PgDriverType,
|
|
269
|
+
connection: open,
|
|
270
|
+
close,
|
|
271
|
+
getConnection
|
|
272
|
+
});
|
|
554
273
|
};
|
|
555
|
-
function
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
274
|
+
function pgPool(options) {
|
|
275
|
+
const { connectionString, database } = options;
|
|
276
|
+
const serializer = options.serialization?.serializer ?? JSONSerializer;
|
|
277
|
+
if ("client" in options && options.client) return pgAmbientClientPool({
|
|
278
|
+
client: options.client,
|
|
279
|
+
serializer
|
|
280
|
+
});
|
|
281
|
+
if ("connection" in options && options.connection) return pgAmbientConnectionPool({ connection: options.connection });
|
|
282
|
+
if ("pooled" in options && options.pooled === false) return pgClientPool({
|
|
283
|
+
connectionString,
|
|
284
|
+
database,
|
|
285
|
+
serializer
|
|
286
|
+
});
|
|
287
|
+
if ("pool" in options && options.pool) return pgAmbientNativePool({
|
|
288
|
+
pool: options.pool,
|
|
289
|
+
serializer
|
|
290
|
+
});
|
|
291
|
+
return pgNativePool({
|
|
292
|
+
connectionString,
|
|
293
|
+
database,
|
|
294
|
+
serializer
|
|
295
|
+
});
|
|
572
296
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return pools.get(lookupKey) ?? pools.set(lookupKey, new pg4.Pool(poolOptions)).get(lookupKey);
|
|
297
|
+
const pools = /* @__PURE__ */ new Map();
|
|
298
|
+
const usageCounter = /* @__PURE__ */ new Map();
|
|
299
|
+
const getPgPool = (connectionStringOrOptions) => {
|
|
300
|
+
const connectionString = typeof connectionStringOrOptions === "string" ? connectionStringOrOptions : connectionStringOrOptions.connectionString;
|
|
301
|
+
const poolOptions = typeof connectionStringOrOptions === "string" ? { connectionString } : connectionStringOrOptions;
|
|
302
|
+
const lookupKey = key(connectionString, poolOptions.database ?? (poolOptions.connectionString ? parseDatabaseName(poolOptions.connectionString) ?? "postgres" : void 0));
|
|
303
|
+
updatePoolUsageCounter(lookupKey, 1);
|
|
304
|
+
return pools.get(lookupKey) ?? pools.set(lookupKey, new pg.Pool(poolOptions)).get(lookupKey);
|
|
582
305
|
};
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
database = 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
|
-
}
|
|
306
|
+
const endPgPool = async ({ connectionString, database, force }) => {
|
|
307
|
+
database = database ?? parseDatabaseName(connectionString) ?? void 0;
|
|
308
|
+
const lookupKey = key(connectionString, database);
|
|
309
|
+
const pool = pools.get(lookupKey);
|
|
310
|
+
if (pool && (updatePoolUsageCounter(lookupKey, -1) <= 0 || force === true)) await onEndPool(lookupKey, pool);
|
|
594
311
|
};
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
312
|
+
const onEndPool = async (lookupKey, pool) => {
|
|
313
|
+
try {
|
|
314
|
+
await pool.end();
|
|
315
|
+
} catch (error) {
|
|
316
|
+
tracer.error("connection-closing-error", {
|
|
317
|
+
lookupKey,
|
|
318
|
+
error
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
pools.delete(lookupKey);
|
|
602
322
|
};
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
)
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
usageCounter.set(lookupKey, currentCounter + by);
|
|
611
|
-
return newCounter;
|
|
323
|
+
const endAllPgPools = () => Promise.all([...pools.entries()].map(([lookupKey, pool]) => onEndPool(lookupKey, pool)));
|
|
324
|
+
const key = (connectionString, database) => `${connectionString}|${database ?? "postgres"}`;
|
|
325
|
+
const updatePoolUsageCounter = (lookupKey, by) => {
|
|
326
|
+
const currentCounter = usageCounter.get(lookupKey) ?? 0;
|
|
327
|
+
const newCounter = currentCounter + by;
|
|
328
|
+
usageCounter.set(lookupKey, currentCounter + by);
|
|
329
|
+
return newCounter;
|
|
612
330
|
};
|
|
613
331
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
}
|
|
622
|
-
var pgDatabaseDriver = {
|
|
623
|
-
driverType: NodePostgresDriverType,
|
|
624
|
-
createPool: (options) => nodePostgresPool(options),
|
|
625
|
-
sqlFormatter: pgFormatter,
|
|
626
|
-
defaultMigratorOptions: DefaultPostgreSQLMigratorOptions,
|
|
627
|
-
getDatabaseNameOrDefault,
|
|
628
|
-
canHandle: canHandleDriverWithConnectionString(
|
|
629
|
-
NodePostgresDriverType,
|
|
630
|
-
tryParseConnectionString
|
|
631
|
-
)
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/storage/postgresql/pg/index.ts
|
|
334
|
+
const tryParseConnectionString = (connectionString) => {
|
|
335
|
+
try {
|
|
336
|
+
return PostgreSQLConnectionString(connectionString);
|
|
337
|
+
} catch {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
632
340
|
};
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
341
|
+
const pgDumboDriver = {
|
|
342
|
+
driverType: PgDriverType,
|
|
343
|
+
createPool: (options) => pgPool(options),
|
|
344
|
+
sqlFormatter: pgFormatter,
|
|
345
|
+
defaultMigratorOptions: DefaultPostgreSQLMigratorOptions,
|
|
346
|
+
canHandle: canHandleDriverWithConnectionString(PgDriverType, tryParseConnectionString),
|
|
347
|
+
databaseMetadata: postgreSQLMetadata
|
|
638
348
|
};
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
var connectionPool = postgresPool;
|
|
642
|
-
export {
|
|
643
|
-
AdvisoryLock,
|
|
644
|
-
DefaultPostgreSQLMigratorOptions,
|
|
645
|
-
NodePostgresDriverType,
|
|
646
|
-
PostgreSQLConnectionString,
|
|
647
|
-
PostgreSQLDatabaseName,
|
|
648
|
-
acquireAdvisoryLock,
|
|
649
|
-
advisoryLock,
|
|
650
|
-
checkConnection,
|
|
651
|
-
connectionPool,
|
|
652
|
-
pgDatabaseDriver as databaseDriver,
|
|
653
|
-
defaultPostgreSQLConnectionString,
|
|
654
|
-
defaultPostgreSqlDatabase,
|
|
655
|
-
endAllPools,
|
|
656
|
-
endPool,
|
|
657
|
-
functionExists,
|
|
658
|
-
functionExistsSQL,
|
|
659
|
-
getDatabaseNameOrDefault,
|
|
660
|
-
getPool,
|
|
661
|
-
isNodePostgresClient,
|
|
662
|
-
isNodePostgresNativePool,
|
|
663
|
-
isNodePostgresPoolClient,
|
|
664
|
-
nodePostgresAmbientClientPool,
|
|
665
|
-
nodePostgresAmbientConnectionPool,
|
|
666
|
-
nodePostgresAmbientNativePool,
|
|
667
|
-
nodePostgresClientConnection,
|
|
668
|
-
nodePostgresClientPool,
|
|
669
|
-
nodePostgresConnection,
|
|
670
|
-
nodePostgresExecute,
|
|
671
|
-
nodePostgresNativePool,
|
|
672
|
-
nodePostgresPool,
|
|
673
|
-
nodePostgresPoolClientConnection,
|
|
674
|
-
nodePostgresSQLExecutor,
|
|
675
|
-
nodePostgresTransaction,
|
|
676
|
-
onEndPool,
|
|
677
|
-
pgDatabaseDriver,
|
|
678
|
-
pgFormatter,
|
|
679
|
-
postgreSQLColumnProcessors,
|
|
680
|
-
postgresPool,
|
|
681
|
-
releaseAdvisoryLock,
|
|
682
|
-
setNodePostgresTypeParser,
|
|
683
|
-
tableExists,
|
|
684
|
-
tableExistsSQL,
|
|
685
|
-
tryAcquireAdvisoryLock,
|
|
686
|
-
usePgDatabaseDriver
|
|
349
|
+
const usePgDumboDriver = () => {
|
|
350
|
+
dumboDatabaseDriverRegistry.register(PgDriverType, pgDumboDriver);
|
|
687
351
|
};
|
|
352
|
+
usePgDumboDriver();
|
|
353
|
+
|
|
354
|
+
//#endregion
|
|
355
|
+
export { AdvisoryLock, DefaultPostgreSQLMigratorOptions, PgDriverType, PostgreSQLArrayProcessor, PostgreSQLConnectionString, PostgreSQLDatabaseName, PostgreSQLExpandSQLInProcessor, acquireAdvisoryLock, advisoryLock, checkConnection, defaultPostgreSQLConnectionString, defaultPostgreSqlDatabase, endAllPgPools, endPgPool, functionExists, functionExistsSQL, getPgPool, isPgClient, isPgNativePool, isPgPoolClient, mapPostgresError, onEndPool, parseDatabaseName, pgAmbientClientPool, pgAmbientConnectionPool, pgAmbientNativePool, pgClientConnection, pgClientPool, pgConnection, pgDumboDriver, pgExecute, pgFormatter, pgNativePool, pgPool, pgPoolClientConnection, pgSQLExecutor, pgTransaction, postgreSQLColumnProcessors, postgreSQLMetadata, releaseAdvisoryLock, setPgTypeParser, tableExists, tableExistsSQL, tryAcquireAdvisoryLock, usePgDumboDriver };
|
|
688
356
|
//# sourceMappingURL=pg.js.map
|