@event-driven-io/dumbo 0.12.1 → 0.13.0-alpha.2
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-2FKOO7MT.js +1 -0
- package/dist/chunk-2FKOO7MT.js.map +1 -0
- package/dist/chunk-3AZXA4Q4.cjs +1 -0
- package/dist/chunk-3AZXA4Q4.cjs.map +1 -0
- package/dist/chunk-55X4XXTZ.cjs +40 -0
- package/dist/chunk-55X4XXTZ.cjs.map +1 -0
- package/dist/chunk-72RN47FR.cjs +36 -0
- package/dist/chunk-72RN47FR.cjs.map +1 -0
- package/dist/chunk-DY2FMM5O.cjs +1 -0
- package/dist/chunk-DY2FMM5O.cjs.map +1 -0
- package/dist/chunk-DYX7V3LM.cjs +1409 -0
- package/dist/chunk-DYX7V3LM.cjs.map +1 -0
- package/dist/chunk-IIFZU7RA.js +1409 -0
- package/dist/chunk-IIFZU7RA.js.map +1 -0
- package/dist/chunk-KIWDFZ4Q.js +69 -0
- package/dist/chunk-KIWDFZ4Q.js.map +1 -0
- package/dist/chunk-L52DDJVT.js +1 -0
- package/dist/chunk-L52DDJVT.js.map +1 -0
- package/dist/chunk-LKLJL6B2.cjs +1 -0
- package/dist/chunk-LKLJL6B2.cjs.map +1 -0
- package/dist/chunk-ML7B25UO.js +40 -0
- package/dist/chunk-ML7B25UO.js.map +1 -0
- package/dist/chunk-PXIJTLLG.cjs +34 -0
- package/dist/chunk-PXIJTLLG.cjs.map +1 -0
- package/dist/chunk-QD3XOIUK.js +34 -0
- package/dist/chunk-QD3XOIUK.js.map +1 -0
- package/dist/chunk-SYFQT5SJ.js +1 -0
- package/dist/chunk-SYFQT5SJ.js.map +1 -0
- package/dist/chunk-TXXOMO2S.cjs +69 -0
- package/dist/chunk-TXXOMO2S.cjs.map +1 -0
- package/dist/chunk-VWPQS5RN.js +147 -0
- package/dist/chunk-VWPQS5RN.js.map +1 -0
- package/dist/chunk-Y7ETN53Q.cjs +147 -0
- package/dist/chunk-Y7ETN53Q.cjs.map +1 -0
- package/dist/chunk-YJF6HCJO.js +36 -0
- package/dist/chunk-YJF6HCJO.js.map +1 -0
- package/dist/connection-OKCNNQLA.cjs +17 -0
- package/dist/connection-OKCNNQLA.cjs.map +1 -0
- package/dist/connection-QSWKG7CD.js +17 -0
- package/dist/connection-QSWKG7CD.js.map +1 -0
- package/dist/connection.int.spec-4JZ5IO52.js +279 -0
- package/dist/connection.int.spec-4JZ5IO52.js.map +1 -0
- package/dist/connection.int.spec-WSLCBNOR.cjs +279 -0
- package/dist/connection.int.spec-WSLCBNOR.cjs.map +1 -0
- package/dist/connections-3374TYPY.js +20 -0
- package/dist/connections-3374TYPY.js.map +1 -0
- package/dist/connections-DM3XBOND.js +18 -0
- package/dist/connections-DM3XBOND.js.map +1 -0
- package/dist/connections-KNAIUBC5.cjs +18 -0
- package/dist/connections-KNAIUBC5.cjs.map +1 -0
- package/dist/connections-ROCX4PBC.cjs +20 -0
- package/dist/connections-ROCX4PBC.cjs.map +1 -0
- package/dist/core-FB34A5DC.js +38 -0
- package/dist/core-FB34A5DC.js.map +1 -0
- package/dist/core-ROYOQ2PP.cjs +38 -0
- package/dist/core-ROYOQ2PP.cjs.map +1 -0
- package/dist/execute-DVHVB627.cjs +10 -0
- package/dist/execute-DVHVB627.cjs.map +1 -0
- package/dist/execute-HCURO5PS.cjs +11 -0
- package/dist/execute-HCURO5PS.cjs.map +1 -0
- package/dist/execute-NABA4WBO.js +10 -0
- package/dist/execute-NABA4WBO.js.map +1 -0
- package/dist/execute-TDYAV2AC.js +11 -0
- package/dist/execute-TDYAV2AC.js.map +1 -0
- package/dist/index-C0xy8dwZ.d.cts +183 -0
- package/dist/index-C0xy8dwZ.d.ts +183 -0
- package/dist/index.cjs +91 -1294
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -169
- package/dist/index.d.ts +14 -169
- package/dist/index.js +92 -1295
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +79 -0
- package/dist/pg.cjs.map +1 -0
- package/dist/pg.d.cts +3 -0
- package/dist/pg.d.ts +3 -0
- package/dist/pg.js +79 -0
- package/dist/pg.js.map +1 -0
- package/dist/pool-4C3RXVW5.cjs +20 -0
- package/dist/pool-4C3RXVW5.cjs.map +1 -0
- package/dist/pool-72E2RZLT.js +20 -0
- package/dist/pool-72E2RZLT.js.map +1 -0
- package/dist/sqlite-6TQBKUQW.js +8 -0
- package/dist/sqlite-6TQBKUQW.js.map +1 -0
- package/dist/sqlite-V3G6SXM3.cjs +8 -0
- package/dist/sqlite-V3G6SXM3.cjs.map +1 -0
- package/dist/sqlite3-MGFULTOS.cjs +20 -0
- package/dist/sqlite3-MGFULTOS.cjs.map +1 -0
- package/dist/sqlite3-YRIOHH6U.js +20 -0
- package/dist/sqlite3-YRIOHH6U.js.map +1 -0
- package/dist/sqlite3.cjs +49 -0
- package/dist/sqlite3.cjs.map +1 -0
- package/dist/sqlite3.d.cts +125 -0
- package/dist/sqlite3.d.ts +125 -0
- package/dist/sqlite3.js +49 -0
- package/dist/sqlite3.js.map +1 -0
- package/dist/transactions-7RPMRDZJ.cjs +10 -0
- package/dist/transactions-7RPMRDZJ.cjs.map +1 -0
- package/dist/transactions-KIOZ2TLT.js +10 -0
- package/dist/transactions-KIOZ2TLT.js.map +1 -0
- package/package.json +43 -8
package/dist/index.js
CHANGED
|
@@ -1,1298 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
EXPLICIT: true,
|
|
91
|
-
FALSE: true,
|
|
92
|
-
FOR: true,
|
|
93
|
-
FOREIGN: true,
|
|
94
|
-
FREEZE: true,
|
|
95
|
-
FROM: true,
|
|
96
|
-
FULL: true,
|
|
97
|
-
GLOBALDICT256: true,
|
|
98
|
-
GLOBALDICT64K: true,
|
|
99
|
-
GRANT: true,
|
|
100
|
-
GROUP: true,
|
|
101
|
-
GZIP: true,
|
|
102
|
-
HAVING: true,
|
|
103
|
-
IDENTITY: true,
|
|
104
|
-
IGNORE: true,
|
|
105
|
-
ILIKE: true,
|
|
106
|
-
IN: true,
|
|
107
|
-
INITIALLY: true,
|
|
108
|
-
INNER: true,
|
|
109
|
-
INTERSECT: true,
|
|
110
|
-
INTO: true,
|
|
111
|
-
IS: true,
|
|
112
|
-
ISNULL: true,
|
|
113
|
-
JOIN: true,
|
|
114
|
-
LEADING: true,
|
|
115
|
-
LEFT: true,
|
|
116
|
-
LIKE: true,
|
|
117
|
-
LIMIT: true,
|
|
118
|
-
LOCALTIME: true,
|
|
119
|
-
LOCALTIMESTAMP: true,
|
|
120
|
-
LUN: true,
|
|
121
|
-
LUNS: true,
|
|
122
|
-
LZO: true,
|
|
123
|
-
LZOP: true,
|
|
124
|
-
MINUS: true,
|
|
125
|
-
MOSTLY13: true,
|
|
126
|
-
MOSTLY32: true,
|
|
127
|
-
MOSTLY8: true,
|
|
128
|
-
NATURAL: true,
|
|
129
|
-
NEW: true,
|
|
130
|
-
NOT: true,
|
|
131
|
-
NOTNULL: true,
|
|
132
|
-
NULL: true,
|
|
133
|
-
NULLS: true,
|
|
134
|
-
OFF: true,
|
|
135
|
-
OFFLINE: true,
|
|
136
|
-
OFFSET: true,
|
|
137
|
-
OLD: true,
|
|
138
|
-
ON: true,
|
|
139
|
-
ONLY: true,
|
|
140
|
-
OPEN: true,
|
|
141
|
-
OR: true,
|
|
142
|
-
ORDER: true,
|
|
143
|
-
OUTER: true,
|
|
144
|
-
OVERLAPS: true,
|
|
145
|
-
PARALLEL: true,
|
|
146
|
-
PARTITION: true,
|
|
147
|
-
PERCENT: true,
|
|
148
|
-
PLACING: true,
|
|
149
|
-
PRIMARY: true,
|
|
150
|
-
RAW: true,
|
|
151
|
-
READRATIO: true,
|
|
152
|
-
RECOVER: true,
|
|
153
|
-
REFERENCES: true,
|
|
154
|
-
REJECTLOG: true,
|
|
155
|
-
RESORT: true,
|
|
156
|
-
RESTORE: true,
|
|
157
|
-
RIGHT: true,
|
|
158
|
-
SELECT: true,
|
|
159
|
-
SESSION_USER: true,
|
|
160
|
-
SIMILAR: true,
|
|
161
|
-
SOME: true,
|
|
162
|
-
SYSDATE: true,
|
|
163
|
-
SYSTEM: true,
|
|
164
|
-
TABLE: true,
|
|
165
|
-
TAG: true,
|
|
166
|
-
TDES: true,
|
|
167
|
-
TEXT255: true,
|
|
168
|
-
TEXT32K: true,
|
|
169
|
-
THEN: true,
|
|
170
|
-
TO: true,
|
|
171
|
-
TOP: true,
|
|
172
|
-
TRAILING: true,
|
|
173
|
-
TRUE: true,
|
|
174
|
-
TRUNCATECOLUMNS: true,
|
|
175
|
-
UNION: true,
|
|
176
|
-
UNIQUE: true,
|
|
177
|
-
USER: true,
|
|
178
|
-
USING: true,
|
|
179
|
-
VERBOSE: true,
|
|
180
|
-
WALLET: true,
|
|
181
|
-
WHEN: true,
|
|
182
|
-
WHERE: true,
|
|
183
|
-
WITH: true,
|
|
184
|
-
WITHOUT: true
|
|
185
|
-
};
|
|
186
|
-
var reserved_default = reservedMap;
|
|
187
|
-
|
|
188
|
-
// src/core/sql/pg-format/index.ts
|
|
189
|
-
var fmtPattern = {
|
|
190
|
-
ident: "I",
|
|
191
|
-
literal: "L",
|
|
192
|
-
string: "s"
|
|
193
|
-
};
|
|
194
|
-
var formatDate = (date) => {
|
|
195
|
-
date = date.replace("T", " ");
|
|
196
|
-
date = date.replace("Z", "+00");
|
|
197
|
-
return date;
|
|
198
|
-
};
|
|
199
|
-
var isReserved = (value) => {
|
|
200
|
-
return !!reserved_default[value.toUpperCase()];
|
|
201
|
-
};
|
|
202
|
-
var arrayToList = (useSpace, array, formatter) => {
|
|
203
|
-
let sql2 = "";
|
|
204
|
-
sql2 += useSpace ? " (" : "(";
|
|
205
|
-
for (let i = 0; i < array.length; i++) {
|
|
206
|
-
sql2 += (i === 0 ? "" : ", ") + formatter(array[i]);
|
|
207
|
-
}
|
|
208
|
-
sql2 += ")";
|
|
209
|
-
return sql2;
|
|
210
|
-
};
|
|
211
|
-
var quoteIdent = (value) => {
|
|
212
|
-
if (value === void 0 || value === null) {
|
|
213
|
-
throw new Error("SQL identifier cannot be null or undefined");
|
|
214
|
-
} else if (value === false) {
|
|
215
|
-
return '"f"';
|
|
216
|
-
} else if (value === true) {
|
|
217
|
-
return '"t"';
|
|
218
|
-
} else if (value instanceof Date) {
|
|
219
|
-
return '"' + formatDate(value.toISOString()) + '"';
|
|
220
|
-
} else if (value instanceof Buffer) {
|
|
221
|
-
throw new Error("SQL identifier cannot be a buffer");
|
|
222
|
-
} else if (Array.isArray(value)) {
|
|
223
|
-
return value.map((v) => {
|
|
224
|
-
if (Array.isArray(v)) {
|
|
225
|
-
throw new Error(
|
|
226
|
-
"Nested array to grouped list conversion is not supported for SQL identifier"
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
return quoteIdent(v);
|
|
230
|
-
}).toString();
|
|
231
|
-
} else if (value === Object(value)) {
|
|
232
|
-
throw new Error("SQL identifier cannot be an object");
|
|
233
|
-
}
|
|
234
|
-
const ident = value.toString().slice(0);
|
|
235
|
-
if (/^[a-z_][a-z0-9_$]*$/.test(ident) && !isReserved(ident)) {
|
|
236
|
-
return ident;
|
|
237
|
-
}
|
|
238
|
-
let quoted = '"';
|
|
239
|
-
for (let i = 0; i < ident.length; i++) {
|
|
240
|
-
const c = ident[i];
|
|
241
|
-
quoted += c === '"' ? c + c : c;
|
|
242
|
-
}
|
|
243
|
-
quoted += '"';
|
|
244
|
-
return quoted;
|
|
245
|
-
};
|
|
246
|
-
var quoteLiteral = (value) => {
|
|
247
|
-
let literal2 = null;
|
|
248
|
-
let explicitCast = null;
|
|
249
|
-
if (value === void 0 || value === null) {
|
|
250
|
-
return "NULL";
|
|
251
|
-
} else if (value === false) {
|
|
252
|
-
return "'f'";
|
|
253
|
-
} else if (value === true) {
|
|
254
|
-
return "'t'";
|
|
255
|
-
} else if (value instanceof Date) {
|
|
256
|
-
return "'" + formatDate(value.toISOString()) + "'";
|
|
257
|
-
} else if (value instanceof Buffer) {
|
|
258
|
-
return "E'\\\\x" + value.toString("hex") + "'";
|
|
259
|
-
} else if (Array.isArray(value)) {
|
|
260
|
-
return value.map((v, i) => {
|
|
261
|
-
if (Array.isArray(v)) {
|
|
262
|
-
return arrayToList(i !== 0, v, quoteLiteral);
|
|
263
|
-
}
|
|
264
|
-
return quoteLiteral(v);
|
|
265
|
-
}).toString();
|
|
266
|
-
} else if (value === Object(value)) {
|
|
267
|
-
explicitCast = "jsonb";
|
|
268
|
-
literal2 = JSONSerializer.serialize(value);
|
|
269
|
-
} else {
|
|
270
|
-
literal2 = value.toString().slice(0);
|
|
271
|
-
}
|
|
272
|
-
let hasBackslash = false;
|
|
273
|
-
let quoted = "'";
|
|
274
|
-
for (let i = 0; i < literal2.length; i++) {
|
|
275
|
-
const c = literal2[i];
|
|
276
|
-
if (c === "'") {
|
|
277
|
-
quoted += c + c;
|
|
278
|
-
} else if (c === "\\") {
|
|
279
|
-
quoted += c + c;
|
|
280
|
-
hasBackslash = true;
|
|
281
|
-
} else {
|
|
282
|
-
quoted += c;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
quoted += "'";
|
|
286
|
-
if (hasBackslash) {
|
|
287
|
-
quoted = "E" + quoted;
|
|
288
|
-
}
|
|
289
|
-
if (explicitCast) {
|
|
290
|
-
quoted += "::" + explicitCast;
|
|
291
|
-
}
|
|
292
|
-
return quoted;
|
|
293
|
-
};
|
|
294
|
-
var quoteString = (value) => {
|
|
295
|
-
if (value === void 0 || value === null) {
|
|
296
|
-
return "";
|
|
297
|
-
} else if (value === false) {
|
|
298
|
-
return "f";
|
|
299
|
-
} else if (value === true) {
|
|
300
|
-
return "t";
|
|
301
|
-
} else if (value instanceof Date) {
|
|
302
|
-
return formatDate(value.toISOString());
|
|
303
|
-
} else if (value instanceof Buffer) {
|
|
304
|
-
return "\\x" + value.toString("hex");
|
|
305
|
-
} else if (Array.isArray(value)) {
|
|
306
|
-
return value.map((v, i) => {
|
|
307
|
-
if (v !== null && v !== void 0) {
|
|
308
|
-
if (Array.isArray(v)) {
|
|
309
|
-
return arrayToList(i !== 0, v, quoteString);
|
|
310
|
-
}
|
|
311
|
-
return quoteString(v);
|
|
312
|
-
}
|
|
313
|
-
return "";
|
|
314
|
-
}).filter((v) => v !== "").toString();
|
|
315
|
-
} else if (value === Object(value)) {
|
|
316
|
-
return JSONSerializer.serialize(value);
|
|
317
|
-
}
|
|
318
|
-
return value.toString().slice(0);
|
|
319
|
-
};
|
|
320
|
-
var config = (cfg) => {
|
|
321
|
-
fmtPattern.ident = "I";
|
|
322
|
-
fmtPattern.literal = "L";
|
|
323
|
-
fmtPattern.string = "s";
|
|
324
|
-
if (cfg && cfg.pattern) {
|
|
325
|
-
if (cfg.pattern.ident) {
|
|
326
|
-
fmtPattern.ident = cfg.pattern.ident;
|
|
327
|
-
}
|
|
328
|
-
if (cfg.pattern.literal) {
|
|
329
|
-
fmtPattern.literal = cfg.pattern.literal;
|
|
330
|
-
}
|
|
331
|
-
if (cfg.pattern.string) {
|
|
332
|
-
fmtPattern.string = cfg.pattern.string;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
var formatWithArray = (fmt, parameters) => {
|
|
337
|
-
let index = 0;
|
|
338
|
-
const params = parameters;
|
|
339
|
-
let re = "%(%|(\\d+\\$)?[";
|
|
340
|
-
re += fmtPattern.ident;
|
|
341
|
-
re += fmtPattern.literal;
|
|
342
|
-
re += fmtPattern.string;
|
|
343
|
-
re += "])";
|
|
344
|
-
re = new RegExp(re, "g");
|
|
345
|
-
return fmt.replace(re, (_, type) => {
|
|
346
|
-
if (type === "%") {
|
|
347
|
-
return "%";
|
|
348
|
-
}
|
|
349
|
-
let position = index;
|
|
350
|
-
const tokens = type.split("$");
|
|
351
|
-
if (tokens.length > 1) {
|
|
352
|
-
position = parseInt(tokens[0], 10) - 1;
|
|
353
|
-
type = tokens[1];
|
|
354
|
-
}
|
|
355
|
-
if (position < 0) {
|
|
356
|
-
throw new Error("specified argument 0 but arguments start at 1");
|
|
357
|
-
} else if (position > params.length - 1) {
|
|
358
|
-
throw new Error("too few arguments");
|
|
359
|
-
}
|
|
360
|
-
index = position + 1;
|
|
361
|
-
if (type === fmtPattern.ident) {
|
|
362
|
-
return quoteIdent(params[position]);
|
|
363
|
-
} else if (type === fmtPattern.literal) {
|
|
364
|
-
return quoteLiteral(params[position]);
|
|
365
|
-
} else if (type === fmtPattern.string) {
|
|
366
|
-
return quoteString(params[position]);
|
|
367
|
-
}
|
|
368
|
-
return void 0;
|
|
369
|
-
});
|
|
370
|
-
};
|
|
371
|
-
var format = (fmt, ...args) => {
|
|
372
|
-
return formatWithArray(fmt, args);
|
|
373
|
-
};
|
|
374
|
-
format.config = config;
|
|
375
|
-
format.format = format;
|
|
376
|
-
format.ident = quoteIdent;
|
|
377
|
-
format.literal = quoteLiteral;
|
|
378
|
-
format.string = quoteString;
|
|
379
|
-
format.withArray = formatWithArray;
|
|
380
|
-
var pg_format_default = format;
|
|
381
|
-
|
|
382
|
-
// src/core/sql/index.ts
|
|
383
|
-
var sql = (sqlQuery, ...params) => {
|
|
384
|
-
return pg_format_default(sqlQuery, ...params);
|
|
385
|
-
};
|
|
386
|
-
var rawSql = (sqlQuery) => {
|
|
387
|
-
return sqlQuery;
|
|
388
|
-
};
|
|
389
|
-
var isSQL = (literal2) => literal2 !== void 0 && literal2 !== null && typeof literal2 === "string";
|
|
390
|
-
var literal = (value) => ({ type: "literal", value });
|
|
391
|
-
var identifier = (value) => ({ type: "identifier", value });
|
|
392
|
-
var plainString = (value) => ({ type: "plainString", value });
|
|
393
|
-
var defaultFormat = (value) => {
|
|
394
|
-
if (typeof value === "string") {
|
|
395
|
-
return pg_format_default("%L", value);
|
|
396
|
-
} else if (typeof value === "number") {
|
|
397
|
-
return value.toString();
|
|
398
|
-
} else if (typeof value === "bigint") {
|
|
399
|
-
return pg_format_default("%L", value);
|
|
400
|
-
} else if (value instanceof Date) {
|
|
401
|
-
return pg_format_default("%L", value);
|
|
402
|
-
} else if (Array.isArray(value)) {
|
|
403
|
-
return pg_format_default("(%L)", value);
|
|
404
|
-
} else if (typeof value === "object") {
|
|
405
|
-
return pg_format_default("%s", JSON.stringify(value));
|
|
406
|
-
} else {
|
|
407
|
-
return pg_format_default("%L", value);
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
function SQL(strings, ...values) {
|
|
411
|
-
return strings.map((string, index) => {
|
|
412
|
-
let formattedValue = "";
|
|
413
|
-
if (index < values.length) {
|
|
414
|
-
const value = values[index];
|
|
415
|
-
if (value && typeof value === "object" && "type" in value && "value" in value) {
|
|
416
|
-
const sqlValue = value;
|
|
417
|
-
switch (sqlValue.type) {
|
|
418
|
-
case "literal":
|
|
419
|
-
formattedValue = pg_format_default("%L", sqlValue.value);
|
|
420
|
-
break;
|
|
421
|
-
case "identifier":
|
|
422
|
-
formattedValue = pg_format_default("%I", sqlValue.value);
|
|
423
|
-
break;
|
|
424
|
-
case "plainString":
|
|
425
|
-
formattedValue = sqlValue.value;
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
} else {
|
|
429
|
-
formattedValue = defaultFormat(value);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return string + formattedValue;
|
|
433
|
-
}).join("");
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// src/core/execute/execute.ts
|
|
437
|
-
var sqlExecutor = (sqlExecutor2, options) => ({
|
|
438
|
-
query: (sql2, queryOptions) => executeInNewDbClient(
|
|
439
|
-
(client) => sqlExecutor2.query(client, sql2, queryOptions),
|
|
440
|
-
options
|
|
441
|
-
),
|
|
442
|
-
batchQuery: (sqls, queryOptions) => executeInNewDbClient(
|
|
443
|
-
(client) => sqlExecutor2.batchQuery(client, sqls, queryOptions),
|
|
444
|
-
options
|
|
445
|
-
),
|
|
446
|
-
command: (sql2, commandOptions) => executeInNewDbClient(
|
|
447
|
-
(client) => sqlExecutor2.command(client, sql2, commandOptions),
|
|
448
|
-
options
|
|
449
|
-
),
|
|
450
|
-
batchCommand: (sqls, commandOptions) => executeInNewDbClient(
|
|
451
|
-
(client) => sqlExecutor2.batchQuery(client, sqls, commandOptions),
|
|
452
|
-
options
|
|
453
|
-
)
|
|
454
|
-
});
|
|
455
|
-
var sqlExecutorInNewConnection = (options) => ({
|
|
456
|
-
query: (sql2) => executeInNewConnection(
|
|
457
|
-
(connection) => connection.execute.query(sql2),
|
|
458
|
-
options
|
|
459
|
-
),
|
|
460
|
-
batchQuery: (sqls) => executeInNewConnection(
|
|
461
|
-
(connection) => connection.execute.batchQuery(sqls),
|
|
462
|
-
options
|
|
463
|
-
),
|
|
464
|
-
command: (sql2) => executeInNewConnection(
|
|
465
|
-
(connection) => connection.execute.command(sql2),
|
|
466
|
-
options
|
|
467
|
-
),
|
|
468
|
-
batchCommand: (sqls) => executeInNewConnection(
|
|
469
|
-
(connection) => connection.execute.batchCommand(sqls),
|
|
470
|
-
options
|
|
471
|
-
)
|
|
472
|
-
});
|
|
473
|
-
var executeInNewDbClient = async (handle, options) => {
|
|
474
|
-
const { connect, close } = options;
|
|
475
|
-
const client = await connect();
|
|
476
|
-
try {
|
|
477
|
-
return await handle(client);
|
|
478
|
-
} catch (error) {
|
|
479
|
-
if (close) await close(client, error);
|
|
480
|
-
throw error;
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
var executeInNewConnection = async (handle, options) => {
|
|
484
|
-
const connection = await options.connection();
|
|
485
|
-
try {
|
|
486
|
-
return await handle(connection);
|
|
487
|
-
} finally {
|
|
488
|
-
await connection.close();
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
// src/core/connections/transaction.ts
|
|
493
|
-
var toTransactionResult = (transactionResult) => transactionResult !== void 0 && transactionResult !== null && typeof transactionResult === "object" && "success" in transactionResult ? transactionResult : { success: true, result: transactionResult };
|
|
494
|
-
var executeInTransaction = async (transaction, handle) => {
|
|
495
|
-
await transaction.begin();
|
|
496
|
-
try {
|
|
497
|
-
const { success, result } = toTransactionResult(await handle(transaction));
|
|
498
|
-
if (success) await transaction.commit();
|
|
499
|
-
else await transaction.rollback();
|
|
500
|
-
return result;
|
|
501
|
-
} catch (e) {
|
|
502
|
-
await transaction.rollback();
|
|
503
|
-
throw e;
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
var transactionFactoryWithDbClient = (connect, initTransaction) => ({
|
|
507
|
-
transaction: () => initTransaction(connect()),
|
|
508
|
-
withTransaction: (handle) => executeInTransaction(initTransaction(connect()), handle)
|
|
509
|
-
});
|
|
510
|
-
var wrapInConnectionClosure = async (connection, handle) => {
|
|
511
|
-
try {
|
|
512
|
-
return await handle();
|
|
513
|
-
} finally {
|
|
514
|
-
await connection.close();
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
var transactionFactoryWithNewConnection = (connect) => ({
|
|
518
|
-
transaction: () => {
|
|
519
|
-
const connection = connect();
|
|
520
|
-
const transaction = connection.transaction();
|
|
521
|
-
return {
|
|
522
|
-
...transaction,
|
|
523
|
-
commit: () => wrapInConnectionClosure(connection, () => transaction.commit()),
|
|
524
|
-
rollback: () => wrapInConnectionClosure(connection, () => transaction.rollback())
|
|
525
|
-
};
|
|
526
|
-
},
|
|
527
|
-
withTransaction: (handle) => {
|
|
528
|
-
const connection = connect();
|
|
529
|
-
return wrapInConnectionClosure(
|
|
530
|
-
connection,
|
|
531
|
-
() => connection.withTransaction(handle)
|
|
532
|
-
);
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
// src/core/connections/connection.ts
|
|
537
|
-
var createConnection = (options) => {
|
|
538
|
-
const { type, connect, close, initTransaction, executor } = options;
|
|
539
|
-
let client = null;
|
|
540
|
-
const getClient = async () => client ?? (client = await connect);
|
|
541
|
-
const connection = {
|
|
542
|
-
type,
|
|
543
|
-
open: getClient,
|
|
544
|
-
close: () => client ? close(client) : Promise.resolve(),
|
|
545
|
-
...transactionFactoryWithDbClient(
|
|
546
|
-
getClient,
|
|
547
|
-
initTransaction(() => typedConnection)
|
|
548
|
-
),
|
|
549
|
-
execute: sqlExecutor(executor(), { connect: getClient })
|
|
550
|
-
};
|
|
551
|
-
const typedConnection = connection;
|
|
552
|
-
return typedConnection;
|
|
553
|
-
};
|
|
554
|
-
|
|
555
|
-
// src/core/connections/pool.ts
|
|
556
|
-
var createConnectionPool = (pool) => {
|
|
557
|
-
const { type, getConnection } = pool;
|
|
558
|
-
const connection = "connection" in pool ? pool.connection : () => Promise.resolve(getConnection());
|
|
559
|
-
const withConnection = "withConnection" in pool ? pool.withConnection : (handle) => executeInNewConnection(handle, {
|
|
560
|
-
connection
|
|
561
|
-
});
|
|
562
|
-
const close = "close" in pool ? pool.close : () => Promise.resolve();
|
|
563
|
-
const execute = "execute" in pool ? pool.execute : sqlExecutorInNewConnection({ connection });
|
|
564
|
-
const transaction = "transaction" in pool && "withTransaction" in pool ? {
|
|
565
|
-
transaction: pool.transaction,
|
|
566
|
-
withTransaction: pool.withTransaction
|
|
567
|
-
} : transactionFactoryWithNewConnection(getConnection);
|
|
568
|
-
const result = {
|
|
569
|
-
type,
|
|
570
|
-
connection,
|
|
571
|
-
withConnection,
|
|
572
|
-
close,
|
|
573
|
-
execute,
|
|
574
|
-
...transaction
|
|
575
|
-
};
|
|
576
|
-
return result;
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
// src/core/query/mappers.ts
|
|
580
|
-
var mapRows = async (getResult, map) => {
|
|
581
|
-
const result = await getResult;
|
|
582
|
-
return result.rows.map(map);
|
|
583
|
-
};
|
|
584
|
-
var toCamelCase = (snakeStr) => snakeStr.replace(/_([a-z])/g, (g) => g[1]?.toUpperCase() ?? "");
|
|
585
|
-
var mapToCamelCase = (obj) => {
|
|
586
|
-
const newObj = {};
|
|
587
|
-
for (const key2 in obj) {
|
|
588
|
-
if (Object.prototype.hasOwnProperty.call(obj, key2)) {
|
|
589
|
-
newObj[toCamelCase(key2)] = obj[key2];
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
return newObj;
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
// src/core/query/selectors.ts
|
|
596
|
-
var firstOrNull = async (getResult) => {
|
|
597
|
-
const result = await getResult;
|
|
598
|
-
return result.rows.length > 0 ? result.rows[0] ?? null : null;
|
|
599
|
-
};
|
|
600
|
-
var first = async (getResult) => {
|
|
601
|
-
const result = await getResult;
|
|
602
|
-
if (result.rows.length === 0)
|
|
603
|
-
throw new Error("Query didn't return any result");
|
|
604
|
-
return result.rows[0];
|
|
605
|
-
};
|
|
606
|
-
var singleOrNull = async (getResult) => {
|
|
607
|
-
const result = await getResult;
|
|
608
|
-
if (result.rows.length > 1) throw new Error("Query had more than one result");
|
|
609
|
-
return result.rows.length > 0 ? result.rows[0] ?? null : null;
|
|
610
|
-
};
|
|
611
|
-
var single = async (getResult) => {
|
|
612
|
-
const result = await getResult;
|
|
613
|
-
if (result.rows.length === 0)
|
|
614
|
-
throw new Error("Query didn't return any result");
|
|
615
|
-
if (result.rows.length > 1) throw new Error("Query had more than one result");
|
|
616
|
-
return result.rows[0];
|
|
617
|
-
};
|
|
618
|
-
var count = async (getResult) => {
|
|
619
|
-
const result = await single(getResult);
|
|
620
|
-
return result.count;
|
|
621
|
-
};
|
|
622
|
-
var exists = async (getResult) => {
|
|
623
|
-
const result = await single(getResult);
|
|
624
|
-
return result.exists === true;
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
// src/core/schema/migrations.ts
|
|
628
|
-
var sqlMigration = (name, sqls) => ({
|
|
629
|
-
name,
|
|
630
|
-
sqls
|
|
631
|
-
});
|
|
632
|
-
var MIGRATIONS_LOCK_ID = 999956789;
|
|
633
|
-
var runSQLMigrations = (pool, migrations, options) => pool.withTransaction(async ({ execute }) => {
|
|
634
|
-
const { databaseLock, ...rest } = options.lock;
|
|
635
|
-
const lockOptions = {
|
|
636
|
-
lockId: MIGRATIONS_LOCK_ID,
|
|
637
|
-
...rest
|
|
638
|
-
};
|
|
639
|
-
const coreMigrations = options.schema.migrationTable.migrations({
|
|
640
|
-
connector: "PostgreSQL:pg"
|
|
641
|
-
// TODO: This will need to change to support more connectors
|
|
642
|
-
});
|
|
643
|
-
await databaseLock.withAcquire(
|
|
644
|
-
execute,
|
|
645
|
-
async () => {
|
|
646
|
-
for (const migration of coreMigrations) {
|
|
647
|
-
const sql2 = combineMigrations(migration);
|
|
648
|
-
await execute.command(rawSql(sql2));
|
|
649
|
-
}
|
|
650
|
-
for (const migration of migrations) {
|
|
651
|
-
await runSQLMigration(execute, migration);
|
|
652
|
-
}
|
|
653
|
-
},
|
|
654
|
-
lockOptions
|
|
655
|
-
);
|
|
656
|
-
return { success: options.dryRun ? false : true, result: void 0 };
|
|
657
|
-
});
|
|
658
|
-
var runSQLMigration = async (execute, migration) => {
|
|
659
|
-
const sql2 = combineMigrations(migration);
|
|
660
|
-
const sqlHash = await getMigrationHash(sql2);
|
|
661
|
-
try {
|
|
662
|
-
const newMigration = {
|
|
663
|
-
name: migration.name,
|
|
664
|
-
sqlHash
|
|
665
|
-
};
|
|
666
|
-
const wasMigrationApplied = await ensureMigrationWasNotAppliedYet(
|
|
667
|
-
execute,
|
|
668
|
-
newMigration
|
|
669
|
-
);
|
|
670
|
-
if (wasMigrationApplied) return;
|
|
671
|
-
await execute.command(rawSql(sql2));
|
|
672
|
-
await recordMigration(execute, newMigration);
|
|
673
|
-
} catch (error) {
|
|
674
|
-
tracer.error("migration-error", {
|
|
675
|
-
migationName: migration.name,
|
|
676
|
-
error
|
|
677
|
-
});
|
|
678
|
-
throw error;
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
var getMigrationHash = async (content) => {
|
|
682
|
-
const encoder = new TextEncoder();
|
|
683
|
-
const data = encoder.encode(content);
|
|
684
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
685
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
686
|
-
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
687
|
-
};
|
|
688
|
-
var combineMigrations = (...migration) => migration.flatMap((m) => m.sqls).join("\n");
|
|
689
|
-
var ensureMigrationWasNotAppliedYet = async (execute, migration) => {
|
|
690
|
-
const result = await singleOrNull(
|
|
691
|
-
execute.query(
|
|
692
|
-
sql(`SELECT sql_hash FROM migrations WHERE name = %L`, migration.name)
|
|
693
|
-
)
|
|
694
|
-
);
|
|
695
|
-
if (result === null) return false;
|
|
696
|
-
const { sqlHash } = mapToCamelCase(result);
|
|
697
|
-
if (sqlHash !== migration.sqlHash) {
|
|
698
|
-
throw new Error(
|
|
699
|
-
`Migration hash mismatch for "${migration.name}". Aborting migration.`
|
|
700
|
-
);
|
|
701
|
-
}
|
|
702
|
-
return true;
|
|
703
|
-
};
|
|
704
|
-
var recordMigration = async (execute, migration) => {
|
|
705
|
-
await execute.command(
|
|
706
|
-
sql(
|
|
707
|
-
`
|
|
708
|
-
INSERT INTO migrations (name, sql_hash)
|
|
709
|
-
VALUES (%L, %L)
|
|
710
|
-
`,
|
|
711
|
-
migration.name,
|
|
712
|
-
migration.sqlHash
|
|
713
|
-
)
|
|
714
|
-
);
|
|
715
|
-
};
|
|
716
|
-
|
|
717
|
-
// src/core/schema/schemaComponent.ts
|
|
718
|
-
var schemaComponent = (type, migrationsOrComponents) => {
|
|
719
|
-
const components = "components" in migrationsOrComponents ? migrationsOrComponents.components : void 0;
|
|
720
|
-
const migrations = "migrations" in migrationsOrComponents ? migrationsOrComponents.migrations : void 0;
|
|
721
|
-
return {
|
|
722
|
-
schemaComponentType: type,
|
|
723
|
-
components,
|
|
724
|
-
migrations: (options) => [
|
|
725
|
-
...migrations ? migrations(options) : [],
|
|
726
|
-
...components ? components.flatMap((component) => component.migrations(options)) : []
|
|
727
|
-
]
|
|
728
|
-
};
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
// src/core/tracing/printing/color.ts
|
|
732
|
-
import ansis from "ansis";
|
|
733
|
-
var enableColors = true;
|
|
734
|
-
var color = {
|
|
735
|
-
set level(value) {
|
|
736
|
-
enableColors = value === 1;
|
|
737
|
-
},
|
|
738
|
-
hex: (value) => (text) => enableColors ? ansis.hex(value)(text) : text,
|
|
739
|
-
red: (value) => enableColors ? ansis.red(value) : value,
|
|
740
|
-
green: (value) => enableColors ? ansis.green(value) : value,
|
|
741
|
-
blue: (value) => enableColors ? ansis.blue(value) : value,
|
|
742
|
-
cyan: (value) => enableColors ? ansis.cyan(value) : value,
|
|
743
|
-
yellow: (value) => enableColors ? ansis.yellow(value) : value
|
|
744
|
-
};
|
|
745
|
-
var color_default = color;
|
|
746
|
-
|
|
747
|
-
// src/core/tracing/printing/pretty.ts
|
|
748
|
-
var TWO_SPACES = " ";
|
|
749
|
-
var COLOR_STRING = color_default.hex("#98c379");
|
|
750
|
-
var COLOR_KEY = color_default.hex("#61afef");
|
|
751
|
-
var COLOR_NUMBER_OR_DATE = color_default.hex("#d19a66");
|
|
752
|
-
var COLOR_BOOLEAN = color_default.hex("#c678dd");
|
|
753
|
-
var COLOR_NULL_OR_UNDEFINED = color_default.hex("#c678dd");
|
|
754
|
-
var COLOR_BRACKETS = color_default.hex("#abb2bf");
|
|
755
|
-
var processString = (str, indent, handleMultiline) => {
|
|
756
|
-
if (handleMultiline && str.includes("\n")) {
|
|
757
|
-
const lines = str.split("\n");
|
|
758
|
-
const indentedLines = lines.map(
|
|
759
|
-
(line) => indent + TWO_SPACES + COLOR_STRING(line)
|
|
760
|
-
);
|
|
761
|
-
return COLOR_STRING('"') + "\n" + indentedLines.join("\n") + "\n" + indent + COLOR_STRING('"');
|
|
762
|
-
}
|
|
763
|
-
return COLOR_STRING(`"${str}"`);
|
|
764
|
-
};
|
|
765
|
-
var shouldPrint = (obj) => typeof obj !== "function" && typeof obj !== "symbol";
|
|
766
|
-
var formatJson = (obj, indentLevel = 0, handleMultiline = false) => {
|
|
767
|
-
const indent = TWO_SPACES.repeat(indentLevel);
|
|
768
|
-
if (obj === null) return COLOR_NULL_OR_UNDEFINED("null");
|
|
769
|
-
if (obj === void 0) return COLOR_NULL_OR_UNDEFINED("undefined");
|
|
770
|
-
if (typeof obj === "string")
|
|
771
|
-
return processString(obj, indent, handleMultiline);
|
|
772
|
-
if (typeof obj === "number" || typeof obj === "bigint" || obj instanceof Date)
|
|
773
|
-
return COLOR_NUMBER_OR_DATE(String(obj));
|
|
774
|
-
if (typeof obj === "boolean") return COLOR_BOOLEAN(String(obj));
|
|
775
|
-
if (obj instanceof Error) {
|
|
776
|
-
const errorObj = {};
|
|
777
|
-
const propNames = Object.getOwnPropertyNames(obj);
|
|
778
|
-
propNames.forEach((key2) => {
|
|
779
|
-
errorObj[key2] = obj[key2];
|
|
780
|
-
});
|
|
781
|
-
return formatJson(errorObj, indentLevel, handleMultiline);
|
|
782
|
-
}
|
|
783
|
-
if (obj instanceof Promise) {
|
|
784
|
-
return COLOR_STRING("Promise {pending}");
|
|
785
|
-
}
|
|
786
|
-
if (Array.isArray(obj)) {
|
|
787
|
-
const arrayItems = obj.map(
|
|
788
|
-
(item) => formatJson(item, indentLevel + 1, handleMultiline)
|
|
789
|
-
);
|
|
790
|
-
return `${COLOR_BRACKETS("[")}
|
|
791
|
-
${indent} ${arrayItems.join(
|
|
792
|
-
`,
|
|
793
|
-
${indent} `
|
|
794
|
-
)}
|
|
795
|
-
${indent}${COLOR_BRACKETS("]")}`;
|
|
796
|
-
}
|
|
797
|
-
const entries = Object.entries(obj).filter(([_, value]) => shouldPrint(value)).map(
|
|
798
|
-
([key2, value]) => `${COLOR_KEY(`"${key2}"`)}: ${formatJson(
|
|
799
|
-
value,
|
|
800
|
-
indentLevel + 1,
|
|
801
|
-
handleMultiline
|
|
802
|
-
)}`
|
|
803
|
-
);
|
|
804
|
-
return `${COLOR_BRACKETS("{")}
|
|
805
|
-
${indent} ${entries.join(
|
|
806
|
-
`,
|
|
807
|
-
${indent} `
|
|
808
|
-
)}
|
|
809
|
-
${indent}${COLOR_BRACKETS("}")}`;
|
|
810
|
-
};
|
|
811
|
-
var prettyJson = (obj, options) => formatJson(obj, 0, options?.handleMultiline);
|
|
812
|
-
|
|
813
|
-
// src/core/tracing/index.ts
|
|
814
|
-
var tracer = () => {
|
|
815
|
-
};
|
|
816
|
-
var LogLevel = {
|
|
817
|
-
DISABLED: "DISABLED",
|
|
818
|
-
INFO: "INFO",
|
|
819
|
-
LOG: "LOG",
|
|
820
|
-
WARN: "WARN",
|
|
821
|
-
ERROR: "ERROR"
|
|
822
|
-
};
|
|
823
|
-
var LogStyle = {
|
|
824
|
-
RAW: "RAW",
|
|
825
|
-
PRETTY: "PRETTY"
|
|
826
|
-
};
|
|
827
|
-
var shouldLog = (logLevel) => {
|
|
828
|
-
const definedLogLevel = process.env.DUMBO_LOG_LEVEL ?? LogLevel.DISABLED;
|
|
829
|
-
if (definedLogLevel === LogLevel.ERROR && logLevel === LogLevel.ERROR)
|
|
830
|
-
return true;
|
|
831
|
-
if (definedLogLevel === LogLevel.WARN && [LogLevel.ERROR, LogLevel.WARN].includes(logLevel))
|
|
832
|
-
return true;
|
|
833
|
-
if (definedLogLevel === LogLevel.LOG && [LogLevel.ERROR, LogLevel.WARN, LogLevel.LOG].includes(logLevel))
|
|
834
|
-
return true;
|
|
835
|
-
if (definedLogLevel === LogLevel.INFO && [LogLevel.ERROR, LogLevel.WARN, LogLevel.LOG, LogLevel.INFO].includes(
|
|
836
|
-
logLevel
|
|
837
|
-
))
|
|
838
|
-
return true;
|
|
839
|
-
return false;
|
|
840
|
-
};
|
|
841
|
-
var nulloTraceEventRecorder = () => {
|
|
842
|
-
};
|
|
843
|
-
var getTraceEventFormatter = (logStyle) => (event) => {
|
|
844
|
-
switch (logStyle) {
|
|
845
|
-
case "RAW":
|
|
846
|
-
return JSONSerializer.serialize(event);
|
|
847
|
-
case "PRETTY":
|
|
848
|
-
return prettyJson(event, { handleMultiline: true });
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
var getTraceEventRecorder = (logLevel, logStyle) => {
|
|
852
|
-
const format2 = getTraceEventFormatter(logStyle);
|
|
853
|
-
switch (logLevel) {
|
|
854
|
-
case "DISABLED":
|
|
855
|
-
return nulloTraceEventRecorder;
|
|
856
|
-
case "INFO":
|
|
857
|
-
return (event) => console.info(format2(event));
|
|
858
|
-
case "LOG":
|
|
859
|
-
return (event) => console.log(format2(event));
|
|
860
|
-
case "WARN":
|
|
861
|
-
return (event) => console.warn(format2(event));
|
|
862
|
-
case "ERROR":
|
|
863
|
-
return (event) => console.error(format2(event));
|
|
864
|
-
}
|
|
865
|
-
};
|
|
866
|
-
var recordTraceEvent = (logLevel, eventName, attributes) => {
|
|
867
|
-
if (!shouldLog(LogLevel.LOG)) return;
|
|
868
|
-
const event = {
|
|
869
|
-
name: eventName,
|
|
870
|
-
timestamp: (/* @__PURE__ */ new Date()).getTime(),
|
|
871
|
-
...attributes
|
|
872
|
-
};
|
|
873
|
-
const record = getTraceEventRecorder(
|
|
874
|
-
logLevel,
|
|
875
|
-
process.env.DUMBO_LOG_STYLE ?? "RAW"
|
|
876
|
-
);
|
|
877
|
-
record(event);
|
|
878
|
-
};
|
|
879
|
-
tracer.info = (eventName, attributes) => recordTraceEvent(LogLevel.INFO, eventName, attributes);
|
|
880
|
-
tracer.warn = (eventName, attributes) => recordTraceEvent(LogLevel.WARN, eventName, attributes);
|
|
881
|
-
tracer.log = (eventName, attributes) => recordTraceEvent(LogLevel.LOG, eventName, attributes);
|
|
882
|
-
tracer.error = (eventName, attributes) => recordTraceEvent(LogLevel.ERROR, eventName, attributes);
|
|
883
|
-
|
|
884
|
-
// src/core/locks/databaseLock.ts
|
|
885
|
-
var defaultDatabaseLockOptions = {
|
|
886
|
-
timeoutMs: 1e4
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
// src/postgres/core/connections/connectionString.ts
|
|
890
|
-
import pgcs from "pg-connection-string";
|
|
891
|
-
|
|
892
|
-
// src/postgres/core/schema/migrations.ts
|
|
893
|
-
var migrationTableSQL = rawSql(`
|
|
894
|
-
CREATE TABLE IF NOT EXISTS migrations (
|
|
895
|
-
id SERIAL PRIMARY KEY,
|
|
896
|
-
name VARCHAR(255) NOT NULL UNIQUE,
|
|
897
|
-
application VARCHAR(255) NOT NULL DEFAULT 'default',
|
|
898
|
-
sql_hash VARCHAR(64) NOT NULL,
|
|
899
|
-
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
900
|
-
);
|
|
901
|
-
`);
|
|
902
|
-
var migrationTableSchemaComponent = schemaComponent(
|
|
903
|
-
"dumbo:schema-component:migrations-table",
|
|
904
|
-
{
|
|
905
|
-
migrations: () => [
|
|
906
|
-
sqlMigration("dumbo:migrationTable:001", [migrationTableSQL])
|
|
907
|
-
]
|
|
908
|
-
}
|
|
909
|
-
);
|
|
910
|
-
var runPostgreSQLMigrations = (pool, migrations, options) => runSQLMigrations(pool, migrations, {
|
|
911
|
-
schema: {
|
|
912
|
-
migrationTable: migrationTableSchemaComponent
|
|
913
|
-
},
|
|
914
|
-
lock: {
|
|
915
|
-
databaseLock: AdvisoryLock,
|
|
916
|
-
options: {
|
|
917
|
-
...options ?? {},
|
|
918
|
-
lockId: MIGRATIONS_LOCK_ID
|
|
919
|
-
}
|
|
920
|
-
},
|
|
921
|
-
dryRun: options?.dryRun
|
|
922
|
-
});
|
|
923
|
-
|
|
924
|
-
// src/postgres/core/schema/schema.ts
|
|
925
|
-
var defaultPostgreSqlDatabase = "postgres";
|
|
926
|
-
var tableExistsSQL = (tableName) => sql(
|
|
927
|
-
`
|
|
928
|
-
SELECT EXISTS (
|
|
929
|
-
SELECT FROM pg_tables
|
|
930
|
-
WHERE tablename = %L
|
|
931
|
-
) AS exists;`,
|
|
932
|
-
tableName
|
|
933
|
-
);
|
|
934
|
-
var tableExists = async (pool, tableName) => exists(pool.execute.query(tableExistsSQL(tableName)));
|
|
935
|
-
var functionExistsSQL = (functionName) => sql(
|
|
936
|
-
`
|
|
937
|
-
SELECT EXISTS (
|
|
938
|
-
SELECT FROM pg_proc
|
|
939
|
-
WHERE
|
|
940
|
-
proname = %L
|
|
941
|
-
) AS exists;
|
|
942
|
-
`,
|
|
943
|
-
functionName
|
|
944
|
-
);
|
|
945
|
-
var functionExists = async (pool, tableName) => exists(pool.execute.query(functionExistsSQL(tableName)));
|
|
946
|
-
|
|
947
|
-
// src/postgres/core/connections/connectionString.ts
|
|
948
|
-
var defaultPostgreSQLConenctionString = "postgresql://postgres@localhost:5432/postgres";
|
|
949
|
-
var getDatabaseNameOrDefault = (connectionString) => pgcs.parse(connectionString).database ?? defaultPostgreSqlDatabase;
|
|
950
|
-
|
|
951
|
-
// src/postgres/core/locks/advisoryLocks.ts
|
|
952
|
-
var tryAcquireAdvisoryLock = async (execute, options) => {
|
|
953
|
-
const timeoutMs = options.timeoutMs ?? defaultDatabaseLockOptions.timeoutMs;
|
|
954
|
-
const advisoryLock2 = options.mode === "Permanent" ? "pg_advisory_lock" : "pg_advisory_xact_lock";
|
|
955
|
-
try {
|
|
956
|
-
await single(
|
|
957
|
-
execute.query(
|
|
958
|
-
sql("SELECT %s(%s) AS locked", advisoryLock2, options.lockId),
|
|
959
|
-
{ timeoutMs }
|
|
960
|
-
)
|
|
961
|
-
);
|
|
962
|
-
return true;
|
|
963
|
-
} catch (error) {
|
|
964
|
-
if (error instanceof Error && "code" in error && error.code === "57014")
|
|
965
|
-
return false;
|
|
966
|
-
throw error;
|
|
967
|
-
}
|
|
968
|
-
};
|
|
969
|
-
var releaseAdvisoryLock = async (execute, options) => {
|
|
970
|
-
const timeoutMs = options.timeoutMs ?? defaultDatabaseLockOptions.timeoutMs;
|
|
971
|
-
try {
|
|
972
|
-
await single(
|
|
973
|
-
execute.query(
|
|
974
|
-
sql("SELECT pg_advisory_unlock(%s) AS locked", options.lockId),
|
|
975
|
-
{ timeoutMs }
|
|
976
|
-
)
|
|
977
|
-
);
|
|
978
|
-
return true;
|
|
979
|
-
} catch (error) {
|
|
980
|
-
if (error instanceof Error && "code" in error && error.code === "57014")
|
|
981
|
-
return false;
|
|
982
|
-
throw error;
|
|
983
|
-
}
|
|
984
|
-
};
|
|
985
|
-
var acquireAdvisoryLock = async (execute, options) => {
|
|
986
|
-
const lockAcquired = await tryAcquireAdvisoryLock(execute, options);
|
|
987
|
-
if (!lockAcquired) {
|
|
988
|
-
throw new Error(
|
|
989
|
-
"Failed to acquire advisory lock within the specified timeout. Migration aborted."
|
|
990
|
-
);
|
|
991
|
-
}
|
|
992
|
-
};
|
|
993
|
-
var AdvisoryLock = {
|
|
994
|
-
acquire: acquireAdvisoryLock,
|
|
995
|
-
tryAcquire: tryAcquireAdvisoryLock,
|
|
996
|
-
release: releaseAdvisoryLock,
|
|
997
|
-
withAcquire: async (execute, handle, options) => {
|
|
998
|
-
await acquireAdvisoryLock(execute, options);
|
|
999
|
-
try {
|
|
1000
|
-
return await handle();
|
|
1001
|
-
} finally {
|
|
1002
|
-
if (options.mode === "Permanent")
|
|
1003
|
-
await releaseAdvisoryLock(execute, options);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
var advisoryLock = (execute, options) => ({
|
|
1008
|
-
acquire: (acquireOptions) => acquireAdvisoryLock(execute, {
|
|
1009
|
-
...options,
|
|
1010
|
-
...acquireOptions ?? {}
|
|
1011
|
-
}),
|
|
1012
|
-
tryAcquire: (acquireOptions) => tryAcquireAdvisoryLock(execute, {
|
|
1013
|
-
...options,
|
|
1014
|
-
...acquireOptions ?? {}
|
|
1015
|
-
}),
|
|
1016
|
-
release: () => releaseAdvisoryLock(execute, options),
|
|
1017
|
-
withAcquire: async (handle, acquireOptions) => {
|
|
1018
|
-
await acquireAdvisoryLock(execute, {
|
|
1019
|
-
...options,
|
|
1020
|
-
...acquireOptions ?? {}
|
|
1021
|
-
});
|
|
1022
|
-
try {
|
|
1023
|
-
return await handle();
|
|
1024
|
-
} finally {
|
|
1025
|
-
await releaseAdvisoryLock(execute, options);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
});
|
|
1029
|
-
|
|
1030
|
-
// src/postgres/pg/connections/connection.ts
|
|
1031
|
-
import pg2 from "pg";
|
|
1032
|
-
|
|
1033
|
-
// src/postgres/pg/execute/execute.ts
|
|
1034
|
-
import pg from "pg";
|
|
1035
|
-
var isNodePostgresNativePool = (poolOrClient) => {
|
|
1036
|
-
return poolOrClient instanceof pg.Pool;
|
|
1037
|
-
};
|
|
1038
|
-
var isNodePostgresClient = (poolOrClient) => poolOrClient instanceof pg.Client;
|
|
1039
|
-
var isNodePostgresPoolClient = (poolOrClient) => "release" in poolOrClient && typeof poolOrClient.release === "function";
|
|
1040
|
-
var nodePostgresExecute = async (poolOrClient, handle) => {
|
|
1041
|
-
const client = isNodePostgresNativePool(poolOrClient) ? await poolOrClient.connect() : poolOrClient;
|
|
1042
|
-
try {
|
|
1043
|
-
return await handle(client);
|
|
1044
|
-
} finally {
|
|
1045
|
-
if (isNodePostgresNativePool(poolOrClient) && isNodePostgresPoolClient(client))
|
|
1046
|
-
client.release();
|
|
1047
|
-
}
|
|
1048
|
-
};
|
|
1049
|
-
var nodePostgresSQLExecutor = () => ({
|
|
1050
|
-
type: NodePostgresConnectorType,
|
|
1051
|
-
query: batch,
|
|
1052
|
-
batchQuery: batch,
|
|
1053
|
-
command: batch,
|
|
1054
|
-
batchCommand: batch
|
|
1055
|
-
});
|
|
1056
|
-
async function batch(client, sqlOrSqls, options) {
|
|
1057
|
-
const sqls = Array.isArray(sqlOrSqls) ? sqlOrSqls : [sqlOrSqls];
|
|
1058
|
-
const results = Array(
|
|
1059
|
-
sqls.length
|
|
1060
|
-
);
|
|
1061
|
-
if (options?.timeoutMs) {
|
|
1062
|
-
await client.query(`SET statement_timeout = ${options?.timeoutMs}`);
|
|
1063
|
-
}
|
|
1064
|
-
for (let i = 0; i < sqls.length; i++) {
|
|
1065
|
-
tracer.info("db:sql:query", { sql: sqls[i] });
|
|
1066
|
-
const result = await client.query(sqls[i]);
|
|
1067
|
-
results[i] = { rowCount: result.rowCount, rows: result.rows };
|
|
1068
|
-
}
|
|
1069
|
-
return Array.isArray(sqlOrSqls) ? results : results[0];
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
// src/postgres/pg/connections/transaction.ts
|
|
1073
|
-
var nodePostgresTransaction = (connection) => (getClient, options) => ({
|
|
1074
|
-
connection: connection(),
|
|
1075
|
-
type: NodePostgresConnectorType,
|
|
1076
|
-
begin: async () => {
|
|
1077
|
-
const client = await getClient;
|
|
1078
|
-
await client.query("BEGIN");
|
|
1079
|
-
},
|
|
1080
|
-
commit: async () => {
|
|
1081
|
-
const client = await getClient;
|
|
1082
|
-
await client.query("COMMIT");
|
|
1083
|
-
if (options?.close) await options?.close(client);
|
|
1084
|
-
},
|
|
1085
|
-
rollback: async (error) => {
|
|
1086
|
-
const client = await getClient;
|
|
1087
|
-
await client.query("ROLLBACK");
|
|
1088
|
-
if (options?.close) await options?.close(client, error);
|
|
1089
|
-
},
|
|
1090
|
-
execute: sqlExecutor(nodePostgresSQLExecutor(), {
|
|
1091
|
-
connect: () => getClient
|
|
1092
|
-
})
|
|
1093
|
-
});
|
|
1094
|
-
|
|
1095
|
-
// src/postgres/pg/connections/connection.ts
|
|
1096
|
-
var NodePostgresConnectorType = "PostgreSQL:pg";
|
|
1097
|
-
var nodePostgresClientConnection = (options) => {
|
|
1098
|
-
const { connect, close } = options;
|
|
1099
|
-
return createConnection({
|
|
1100
|
-
type: NodePostgresConnectorType,
|
|
1101
|
-
connect,
|
|
1102
|
-
close,
|
|
1103
|
-
initTransaction: (connection) => nodePostgresTransaction(connection),
|
|
1104
|
-
executor: nodePostgresSQLExecutor
|
|
1105
|
-
});
|
|
1106
|
-
};
|
|
1107
|
-
var nodePostgresPoolClientConnection = (options) => {
|
|
1108
|
-
const { connect, close } = options;
|
|
1109
|
-
return createConnection({
|
|
1110
|
-
type: NodePostgresConnectorType,
|
|
1111
|
-
connect,
|
|
1112
|
-
close,
|
|
1113
|
-
initTransaction: (connection) => nodePostgresTransaction(connection),
|
|
1114
|
-
executor: nodePostgresSQLExecutor
|
|
1115
|
-
});
|
|
1116
|
-
};
|
|
1117
|
-
function nodePostgresConnection(options) {
|
|
1118
|
-
return options.type === "Client" ? nodePostgresClientConnection(options) : nodePostgresPoolClientConnection(options);
|
|
1119
|
-
}
|
|
1120
|
-
var checkConnection = async (connectionString) => {
|
|
1121
|
-
const client = new pg2.Client({
|
|
1122
|
-
connectionString
|
|
1123
|
-
});
|
|
1124
|
-
try {
|
|
1125
|
-
await client.connect();
|
|
1126
|
-
return { successful: true };
|
|
1127
|
-
} catch (error) {
|
|
1128
|
-
const code = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
1129
|
-
return {
|
|
1130
|
-
successful: false,
|
|
1131
|
-
errorType: code === "ECONNREFUSED" ? "ConnectionRefused" : code === "28P01" ? "Authentication" : "Unknown",
|
|
1132
|
-
code,
|
|
1133
|
-
error
|
|
1134
|
-
};
|
|
1135
|
-
} finally {
|
|
1136
|
-
await client.end();
|
|
1137
|
-
}
|
|
1138
|
-
};
|
|
1139
|
-
|
|
1140
|
-
// src/postgres/pg/connections/pool.ts
|
|
1141
|
-
import pg4 from "pg";
|
|
1142
|
-
|
|
1143
|
-
// src/postgres/pg/serialization/index.ts
|
|
1144
|
-
import pg3 from "pg";
|
|
1145
|
-
var setNodePostgresTypeParser = (jsonSerializer2) => {
|
|
1146
|
-
pg3.types.setTypeParser(20, (val) => BigInt(val));
|
|
1147
|
-
pg3.types.setTypeParser(3802, (val) => jsonSerializer2.deserialize(val));
|
|
1148
|
-
pg3.types.setTypeParser(114, (val) => jsonSerializer2.deserialize(val));
|
|
1149
|
-
};
|
|
1150
|
-
|
|
1151
|
-
// src/postgres/pg/connections/pool.ts
|
|
1152
|
-
var nodePostgresNativePool = (options) => {
|
|
1153
|
-
const { connectionString, database } = options;
|
|
1154
|
-
const pool = getPool({ connectionString, database });
|
|
1155
|
-
const getConnection = () => nodePostgresConnection({
|
|
1156
|
-
type: "PoolClient",
|
|
1157
|
-
connect: pool.connect(),
|
|
1158
|
-
close: (client) => Promise.resolve(client.release())
|
|
1159
|
-
});
|
|
1160
|
-
const open = () => Promise.resolve(getConnection());
|
|
1161
|
-
const close = () => endPool({ connectionString, database });
|
|
1162
|
-
return createConnectionPool({
|
|
1163
|
-
type: NodePostgresConnectorType,
|
|
1164
|
-
connection: open,
|
|
1165
|
-
close,
|
|
1166
|
-
getConnection
|
|
1167
|
-
});
|
|
1168
|
-
};
|
|
1169
|
-
var nodePostgresAmbientNativePool = (options) => {
|
|
1170
|
-
const { pool } = options;
|
|
1171
|
-
return createConnectionPool({
|
|
1172
|
-
type: NodePostgresConnectorType,
|
|
1173
|
-
getConnection: () => nodePostgresConnection({
|
|
1174
|
-
type: "PoolClient",
|
|
1175
|
-
connect: pool.connect(),
|
|
1176
|
-
close: (client) => Promise.resolve(client.release())
|
|
1177
|
-
})
|
|
1178
|
-
});
|
|
1179
|
-
};
|
|
1180
|
-
var nodePostgresAmbientConnectionPool = (options) => {
|
|
1181
|
-
const { connection } = options;
|
|
1182
|
-
return createConnectionPool({
|
|
1183
|
-
type: NodePostgresConnectorType,
|
|
1184
|
-
getConnection: () => connection,
|
|
1185
|
-
execute: connection.execute,
|
|
1186
|
-
transaction: () => connection.transaction(),
|
|
1187
|
-
withTransaction: (handle) => connection.withTransaction(handle)
|
|
1188
|
-
});
|
|
1189
|
-
};
|
|
1190
|
-
var nodePostgresClientPool = (options) => {
|
|
1191
|
-
const { connectionString, database } = options;
|
|
1192
|
-
return createConnectionPool({
|
|
1193
|
-
type: NodePostgresConnectorType,
|
|
1194
|
-
getConnection: () => {
|
|
1195
|
-
const connect = Promise.resolve(
|
|
1196
|
-
new pg4.Client({ connectionString, database })
|
|
1197
|
-
).then(async (client) => {
|
|
1198
|
-
await client.connect();
|
|
1199
|
-
return client;
|
|
1200
|
-
});
|
|
1201
|
-
return nodePostgresConnection({
|
|
1202
|
-
type: "Client",
|
|
1203
|
-
connect,
|
|
1204
|
-
close: (client) => client.end()
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
});
|
|
1208
|
-
};
|
|
1209
|
-
var nodePostgresAmbientClientPool = (options) => {
|
|
1210
|
-
const { client } = options;
|
|
1211
|
-
const getConnection = () => {
|
|
1212
|
-
const connect = Promise.resolve(client);
|
|
1213
|
-
return nodePostgresConnection({
|
|
1214
|
-
type: "Client",
|
|
1215
|
-
connect,
|
|
1216
|
-
close: () => Promise.resolve()
|
|
1217
|
-
});
|
|
1218
|
-
};
|
|
1219
|
-
const open = () => Promise.resolve(getConnection());
|
|
1220
|
-
const close = () => Promise.resolve();
|
|
1221
|
-
return createConnectionPool({
|
|
1222
|
-
type: NodePostgresConnectorType,
|
|
1223
|
-
connection: open,
|
|
1224
|
-
close,
|
|
1225
|
-
getConnection
|
|
1226
|
-
});
|
|
1227
|
-
};
|
|
1228
|
-
function nodePostgresPool(options) {
|
|
1229
|
-
const { connectionString, database, serializer } = options;
|
|
1230
|
-
setNodePostgresTypeParser(serializer ?? JSONSerializer);
|
|
1231
|
-
if ("client" in options && options.client)
|
|
1232
|
-
return nodePostgresAmbientClientPool({ client: options.client });
|
|
1233
|
-
if ("connection" in options && options.connection)
|
|
1234
|
-
return nodePostgresAmbientConnectionPool({
|
|
1235
|
-
connection: options.connection
|
|
1236
|
-
});
|
|
1237
|
-
if ("pooled" in options && options.pooled === false)
|
|
1238
|
-
return nodePostgresClientPool({ connectionString, database });
|
|
1239
|
-
if ("pool" in options && options.pool)
|
|
1240
|
-
return nodePostgresAmbientNativePool({ pool: options.pool });
|
|
1241
|
-
return nodePostgresNativePool({
|
|
1242
|
-
connectionString,
|
|
1243
|
-
database
|
|
1244
|
-
});
|
|
1245
|
-
}
|
|
1246
|
-
var pools = /* @__PURE__ */ new Map();
|
|
1247
|
-
var usageCounter = /* @__PURE__ */ new Map();
|
|
1248
|
-
var getPool = (connectionStringOrOptions) => {
|
|
1249
|
-
const connectionString = typeof connectionStringOrOptions === "string" ? connectionStringOrOptions : connectionStringOrOptions.connectionString;
|
|
1250
|
-
const poolOptions = typeof connectionStringOrOptions === "string" ? { connectionString } : connectionStringOrOptions;
|
|
1251
|
-
const database = poolOptions.database ?? (poolOptions.connectionString ? getDatabaseNameOrDefault(poolOptions.connectionString) : void 0);
|
|
1252
|
-
const lookupKey = key(connectionString, database);
|
|
1253
|
-
updatePoolUsageCounter(lookupKey, 1);
|
|
1254
|
-
return pools.get(lookupKey) ?? pools.set(lookupKey, new pg4.Pool(poolOptions)).get(lookupKey);
|
|
1255
|
-
};
|
|
1256
|
-
var endPool = async ({
|
|
1257
|
-
connectionString,
|
|
1258
|
-
database,
|
|
1259
|
-
force
|
|
1260
|
-
}) => {
|
|
1261
|
-
database = database ?? getDatabaseNameOrDefault(connectionString);
|
|
1262
|
-
const lookupKey = key(connectionString, database);
|
|
1263
|
-
const pool = pools.get(lookupKey);
|
|
1264
|
-
if (pool && (updatePoolUsageCounter(lookupKey, -1) <= 0 || force === true)) {
|
|
1265
|
-
await onEndPool(lookupKey, pool);
|
|
1266
|
-
}
|
|
1267
|
-
};
|
|
1268
|
-
var onEndPool = async (lookupKey, pool) => {
|
|
1269
|
-
try {
|
|
1270
|
-
await pool.end();
|
|
1271
|
-
} catch (error) {
|
|
1272
|
-
tracer.error("connection-closing-error", { lookupKey, error });
|
|
1273
|
-
}
|
|
1274
|
-
pools.delete(lookupKey);
|
|
1275
|
-
};
|
|
1276
|
-
var endAllPools = () => Promise.all(
|
|
1277
|
-
[...pools.entries()].map(([lookupKey, pool]) => onEndPool(lookupKey, pool))
|
|
1278
|
-
);
|
|
1279
|
-
var key = (connectionString, database) => `${connectionString}|${database ?? defaultPostgreSqlDatabase}`;
|
|
1280
|
-
var updatePoolUsageCounter = (lookupKey, by) => {
|
|
1281
|
-
const currentCounter = usageCounter.get(lookupKey) ?? 0;
|
|
1282
|
-
const newCounter = currentCounter + by;
|
|
1283
|
-
usageCounter.set(lookupKey, currentCounter + by);
|
|
1284
|
-
return newCounter;
|
|
1285
|
-
};
|
|
1286
|
-
|
|
1287
|
-
// src/postgres/index.ts
|
|
1288
|
-
var postgresPool = nodePostgresPool;
|
|
1289
|
-
|
|
1290
|
-
// src/index.ts
|
|
1291
|
-
var connectionPool = (options) => (
|
|
1292
|
-
// TODO: this should have the pattern matching and verification
|
|
1293
|
-
postgresPool(options)
|
|
1294
|
-
);
|
|
1295
|
-
var dumbo = (options) => connectionPool(options);
|
|
1
|
+
import {
|
|
2
|
+
AdvisoryLock,
|
|
3
|
+
JSONReplacer,
|
|
4
|
+
JSONReplacers,
|
|
5
|
+
JSONReviver,
|
|
6
|
+
JSONRevivers,
|
|
7
|
+
JSONSerializer,
|
|
8
|
+
LogLevel,
|
|
9
|
+
LogStyle,
|
|
10
|
+
MIGRATIONS_LOCK_ID,
|
|
11
|
+
NodePostgresConnectorType,
|
|
12
|
+
RawJSONSerializer,
|
|
13
|
+
SQL,
|
|
14
|
+
acquireAdvisoryLock,
|
|
15
|
+
advisoryLock,
|
|
16
|
+
checkConnection,
|
|
17
|
+
color,
|
|
18
|
+
combineMigrations,
|
|
19
|
+
composeJSONReplacers,
|
|
20
|
+
composeJSONRevivers,
|
|
21
|
+
connectionPool,
|
|
22
|
+
count,
|
|
23
|
+
createConnection,
|
|
24
|
+
createConnectionPool,
|
|
25
|
+
defaultDatabaseLockOptions,
|
|
26
|
+
defaultPostgreSQLConenctionString,
|
|
27
|
+
defaultPostgreSqlDatabase,
|
|
28
|
+
dumbo,
|
|
29
|
+
endAllPools,
|
|
30
|
+
endPool,
|
|
31
|
+
executeInNewConnection,
|
|
32
|
+
executeInNewDbClient,
|
|
33
|
+
executeInTransaction,
|
|
34
|
+
exists,
|
|
35
|
+
first,
|
|
36
|
+
firstOrNull,
|
|
37
|
+
fromConnectorType,
|
|
38
|
+
functionExists,
|
|
39
|
+
functionExistsSQL,
|
|
40
|
+
getDatabaseNameOrDefault,
|
|
41
|
+
getDriverName,
|
|
42
|
+
getPool,
|
|
43
|
+
identifier,
|
|
44
|
+
isNodePostgresClient,
|
|
45
|
+
isNodePostgresNativePool,
|
|
46
|
+
isNodePostgresPoolClient,
|
|
47
|
+
isSQL,
|
|
48
|
+
jsonSerializer,
|
|
49
|
+
literal,
|
|
50
|
+
mapRows,
|
|
51
|
+
mapToCamelCase,
|
|
52
|
+
migrationTableSchemaComponent,
|
|
53
|
+
nodePostgresAmbientClientPool,
|
|
54
|
+
nodePostgresAmbientConnectionPool,
|
|
55
|
+
nodePostgresAmbientNativePool,
|
|
56
|
+
nodePostgresClientConnection,
|
|
57
|
+
nodePostgresClientPool,
|
|
58
|
+
nodePostgresConnection,
|
|
59
|
+
nodePostgresExecute,
|
|
60
|
+
nodePostgresNativePool,
|
|
61
|
+
nodePostgresPool,
|
|
62
|
+
nodePostgresPoolClientConnection,
|
|
63
|
+
nodePostgresSQLExecutor,
|
|
64
|
+
nodePostgresTransaction,
|
|
65
|
+
onEndPool,
|
|
66
|
+
plainString,
|
|
67
|
+
postgresPool,
|
|
68
|
+
prettyJson,
|
|
69
|
+
rawSql,
|
|
70
|
+
releaseAdvisoryLock,
|
|
71
|
+
runPostgreSQLMigrations,
|
|
72
|
+
runSQLMigrations,
|
|
73
|
+
schemaComponent,
|
|
74
|
+
setNodePostgresTypeParser,
|
|
75
|
+
single,
|
|
76
|
+
singleOrNull,
|
|
77
|
+
sql,
|
|
78
|
+
sqlExecutor,
|
|
79
|
+
sqlExecutorInNewConnection,
|
|
80
|
+
sqlMigration,
|
|
81
|
+
tableExists,
|
|
82
|
+
tableExistsSQL,
|
|
83
|
+
toCamelCase,
|
|
84
|
+
toConnectorType,
|
|
85
|
+
tracer,
|
|
86
|
+
transactionFactoryWithDbClient,
|
|
87
|
+
transactionFactoryWithNewConnection,
|
|
88
|
+
tryAcquireAdvisoryLock
|
|
89
|
+
} from "./chunk-IIFZU7RA.js";
|
|
1296
90
|
export {
|
|
1297
91
|
AdvisoryLock,
|
|
1298
92
|
JSONReplacer,
|
|
@@ -1329,9 +123,11 @@ export {
|
|
|
1329
123
|
exists,
|
|
1330
124
|
first,
|
|
1331
125
|
firstOrNull,
|
|
126
|
+
fromConnectorType,
|
|
1332
127
|
functionExists,
|
|
1333
128
|
functionExistsSQL,
|
|
1334
129
|
getDatabaseNameOrDefault,
|
|
130
|
+
getDriverName,
|
|
1335
131
|
getPool,
|
|
1336
132
|
identifier,
|
|
1337
133
|
isNodePostgresClient,
|
|
@@ -1374,6 +170,7 @@ export {
|
|
|
1374
170
|
tableExists,
|
|
1375
171
|
tableExistsSQL,
|
|
1376
172
|
toCamelCase,
|
|
173
|
+
toConnectorType,
|
|
1377
174
|
tracer,
|
|
1378
175
|
transactionFactoryWithDbClient,
|
|
1379
176
|
transactionFactoryWithNewConnection,
|