drizzle-kit 1.0.0-beta.2-278d7e6 → 1.0.0-beta.2-9848003
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/api-mysql.js +257 -387
- package/api-mysql.mjs +257 -387
- package/api-postgres.js +295 -417
- package/api-postgres.mjs +295 -417
- package/api-sqlite.js +257 -387
- package/api-sqlite.mjs +257 -387
- package/bin.cjs +404 -448
- package/index.d.mts +6 -1
- package/index.d.ts +6 -1
- package/package.json +3 -1
package/api-postgres.mjs
CHANGED
|
@@ -15205,7 +15205,8 @@ var init_schemaValidator = __esm({
|
|
|
15205
15205
|
"singlestore",
|
|
15206
15206
|
"gel",
|
|
15207
15207
|
"mssql",
|
|
15208
|
-
"cockroach"
|
|
15208
|
+
"cockroach",
|
|
15209
|
+
"duckdb"
|
|
15209
15210
|
];
|
|
15210
15211
|
dialect = enumType(dialects);
|
|
15211
15212
|
}
|
|
@@ -25025,7 +25026,7 @@ var init_introspect = __esm({
|
|
|
25025
25026
|
let checksCount = 0;
|
|
25026
25027
|
let viewsCount = 0;
|
|
25027
25028
|
for (const seq of sequencesList) {
|
|
25028
|
-
const depend = dependList.find((it) => it.oid === seq.oid);
|
|
25029
|
+
const depend = dependList.find((it) => Number(it.oid) === Number(seq.oid));
|
|
25029
25030
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
25030
25031
|
continue;
|
|
25031
25032
|
}
|
|
@@ -25091,22 +25092,22 @@ var init_introspect = __esm({
|
|
|
25091
25092
|
continue;
|
|
25092
25093
|
}
|
|
25093
25094
|
const expr = serialsList.find(
|
|
25094
|
-
(it) => it.tableId === column8.tableId && it.ordinality === column8.ordinality
|
|
25095
|
+
(it) => Number(it.tableId) === Number(column8.tableId) && it.ordinality === column8.ordinality
|
|
25095
25096
|
);
|
|
25096
25097
|
if (expr) {
|
|
25097
|
-
const table7 = tablesList.find((it) => it.oid === column8.tableId);
|
|
25098
|
+
const table7 = tablesList.find((it) => Number(it.oid) === Number(column8.tableId));
|
|
25098
25099
|
const isSerial = isSerialExpression(expr.expression, table7.schema);
|
|
25099
25100
|
column8.type = isSerial ? type === "bigint" ? "bigserial" : type === "integer" ? "serial" : "smallserial" : type;
|
|
25100
25101
|
}
|
|
25101
25102
|
}
|
|
25102
25103
|
for (const column8 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
25103
|
-
const table7 = tablesList.find((it) => it.oid === column8.tableId);
|
|
25104
|
+
const table7 = tablesList.find((it) => Number(it.oid) === Number(column8.tableId));
|
|
25104
25105
|
const enumType2 = column8.typeId in groupedEnums ? groupedEnums[column8.typeId] : column8.typeId in groupedArrEnums ? groupedArrEnums[column8.typeId] : null;
|
|
25105
25106
|
let columnTypeMapped = enumType2 ? enumType2.name : column8.type.replaceAll("[]", "");
|
|
25106
25107
|
columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char").replace("geometry(Point", "geometry(point");
|
|
25107
25108
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
|
25108
25109
|
const columnDefault = defaultsList.find(
|
|
25109
|
-
(it) => it.tableId === column8.tableId && it.ordinality === column8.ordinality
|
|
25110
|
+
(it) => Number(it.tableId) === Number(column8.tableId) && it.ordinality === column8.ordinality
|
|
25110
25111
|
);
|
|
25111
25112
|
const defaultValue = defaultForColumn(
|
|
25112
25113
|
columnTypeMapped,
|
|
@@ -25115,10 +25116,10 @@ var init_introspect = __esm({
|
|
|
25115
25116
|
Boolean(enumType2)
|
|
25116
25117
|
);
|
|
25117
25118
|
const unique = constraintsList.find((it) => {
|
|
25118
|
-
return it.type === "u" && it.tableId === column8.tableId && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column8.ordinality);
|
|
25119
|
+
return it.type === "u" && Number(it.tableId) === Number(column8.tableId) && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column8.ordinality);
|
|
25119
25120
|
}) ?? null;
|
|
25120
25121
|
const pk = constraintsList.find((it) => {
|
|
25121
|
-
return it.type === "p" && it.tableId === column8.tableId && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column8.ordinality);
|
|
25122
|
+
return it.type === "p" && Number(it.tableId) === Number(column8.tableId) && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column8.ordinality);
|
|
25122
25123
|
}) ?? null;
|
|
25123
25124
|
const metadata = column8.metadata;
|
|
25124
25125
|
if (column8.generatedType === "s" && (!metadata || !metadata.expression)) {
|
|
@@ -25133,7 +25134,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25133
25134
|
${JSON.stringify(column8.metadata)}`
|
|
25134
25135
|
);
|
|
25135
25136
|
}
|
|
25136
|
-
const sequence = metadata?.seqId ? sequencesList.find((it) => it.oid === Number(metadata.seqId)) ?? null : null;
|
|
25137
|
+
const sequence = metadata?.seqId ? sequencesList.find((it) => Number(it.oid) === Number(metadata.seqId)) ?? null : null;
|
|
25137
25138
|
columns.push({
|
|
25138
25139
|
entityType: "columns",
|
|
25139
25140
|
schema: table7.schema,
|
|
@@ -25163,10 +25164,12 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25163
25164
|
});
|
|
25164
25165
|
}
|
|
25165
25166
|
for (const unique of constraintsList.filter((it) => it.type === "u")) {
|
|
25166
|
-
const table7 = tablesList.find((it) => it.oid === unique.tableId);
|
|
25167
|
-
const schema6 = namespaces.find((it) => it.oid === unique.schemaId);
|
|
25167
|
+
const table7 = tablesList.find((it) => Number(it.oid) === Number(unique.tableId));
|
|
25168
|
+
const schema6 = namespaces.find((it) => Number(it.oid) === Number(unique.schemaId));
|
|
25168
25169
|
const columns2 = unique.columnsOrdinals.map((it) => {
|
|
25169
|
-
const column8 = columnsList.find(
|
|
25170
|
+
const column8 = columnsList.find(
|
|
25171
|
+
(column9) => Number(column9.tableId) === Number(unique.tableId) && column9.ordinality === it
|
|
25172
|
+
);
|
|
25170
25173
|
return column8.name;
|
|
25171
25174
|
});
|
|
25172
25175
|
uniques.push({
|
|
@@ -25180,10 +25183,12 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25180
25183
|
});
|
|
25181
25184
|
}
|
|
25182
25185
|
for (const pk of constraintsList.filter((it) => it.type === "p")) {
|
|
25183
|
-
const table7 = tablesList.find((it) => it.oid === pk.tableId);
|
|
25184
|
-
const schema6 = namespaces.find((it) => it.oid === pk.schemaId);
|
|
25186
|
+
const table7 = tablesList.find((it) => Number(it.oid) === Number(pk.tableId));
|
|
25187
|
+
const schema6 = namespaces.find((it) => Number(it.oid) === Number(pk.schemaId));
|
|
25185
25188
|
const columns2 = pk.columnsOrdinals.map((it) => {
|
|
25186
|
-
const column8 = columnsList.find(
|
|
25189
|
+
const column8 = columnsList.find(
|
|
25190
|
+
(column9) => Number(column9.tableId) === Number(pk.tableId) && column9.ordinality === it
|
|
25191
|
+
);
|
|
25187
25192
|
return column8.name;
|
|
25188
25193
|
});
|
|
25189
25194
|
pks.push({
|
|
@@ -25196,15 +25201,19 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25196
25201
|
});
|
|
25197
25202
|
}
|
|
25198
25203
|
for (const fk6 of constraintsList.filter((it) => it.type === "f")) {
|
|
25199
|
-
const table7 = tablesList.find((it) => it.oid === fk6.tableId);
|
|
25200
|
-
const schema6 = namespaces.find((it) => it.oid === fk6.schemaId);
|
|
25201
|
-
const tableTo = tablesList.find((it) => it.oid === fk6.tableToId);
|
|
25204
|
+
const table7 = tablesList.find((it) => Number(it.oid) === Number(fk6.tableId));
|
|
25205
|
+
const schema6 = namespaces.find((it) => Number(it.oid) === Number(fk6.schemaId));
|
|
25206
|
+
const tableTo = tablesList.find((it) => Number(it.oid) === Number(fk6.tableToId));
|
|
25202
25207
|
const columns2 = fk6.columnsOrdinals.map((it) => {
|
|
25203
|
-
const column8 = columnsList.find(
|
|
25208
|
+
const column8 = columnsList.find(
|
|
25209
|
+
(column9) => Number(column9.tableId) === Number(fk6.tableId) && column9.ordinality === it
|
|
25210
|
+
);
|
|
25204
25211
|
return column8.name;
|
|
25205
25212
|
});
|
|
25206
25213
|
const columnsTo = fk6.columnsToOrdinals.map((it) => {
|
|
25207
|
-
const column8 = columnsList.find(
|
|
25214
|
+
const column8 = columnsList.find(
|
|
25215
|
+
(column9) => Number(column9.tableId) === Number(fk6.tableToId) && column9.ordinality === it
|
|
25216
|
+
);
|
|
25208
25217
|
return column8.name;
|
|
25209
25218
|
});
|
|
25210
25219
|
fks.push({
|
|
@@ -25222,8 +25231,8 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25222
25231
|
});
|
|
25223
25232
|
}
|
|
25224
25233
|
for (const check of constraintsList.filter((it) => it.type === "c")) {
|
|
25225
|
-
const table7 = tablesList.find((it) => it.oid === check.tableId);
|
|
25226
|
-
const schema6 = namespaces.find((it) => it.oid === check.schemaId);
|
|
25234
|
+
const table7 = tablesList.find((it) => Number(it.oid) === Number(check.tableId));
|
|
25235
|
+
const schema6 = namespaces.find((it) => Number(it.oid) === Number(check.schemaId));
|
|
25227
25236
|
checks.push({
|
|
25228
25237
|
entityType: "checks",
|
|
25229
25238
|
schema: schema6.name,
|
|
@@ -25284,10 +25293,10 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25284
25293
|
});
|
|
25285
25294
|
for (const idx of idxs) {
|
|
25286
25295
|
const { metadata } = idx;
|
|
25287
|
-
const forUnique = metadata.isUnique && constraintsList.some((x6) => x6.type === "u" && x6.indexId === idx.oid);
|
|
25288
|
-
const forPK = metadata.isPrimary && constraintsList.some((x6) => x6.type === "p" && x6.indexId === idx.oid);
|
|
25296
|
+
const forUnique = metadata.isUnique && constraintsList.some((x6) => x6.type === "u" && Number(x6.indexId) === Number(idx.oid));
|
|
25297
|
+
const forPK = metadata.isPrimary && constraintsList.some((x6) => x6.type === "p" && Number(x6.indexId) === Number(idx.oid));
|
|
25289
25298
|
const expr = splitExpressions(metadata.expression);
|
|
25290
|
-
const table7 = tablesList.find((it) => it.oid === idx.metadata.tableId);
|
|
25299
|
+
const table7 = tablesList.find((it) => Number(it.oid) === Number(idx.metadata.tableId));
|
|
25291
25300
|
const nonColumnsCount = metadata.columnOrdinals.reduce((acc, it) => {
|
|
25292
25301
|
if (it === 0) acc += 1;
|
|
25293
25302
|
return acc;
|
|
@@ -25319,7 +25328,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25319
25328
|
k6 += 1;
|
|
25320
25329
|
} else {
|
|
25321
25330
|
const column8 = columnsList.find((column9) => {
|
|
25322
|
-
return column9.tableId === metadata.tableId && column9.ordinality === ordinal;
|
|
25331
|
+
return Number(column9.tableId) === Number(metadata.tableId) && column9.ordinality === ordinal;
|
|
25323
25332
|
});
|
|
25324
25333
|
if (!column8) throw new Error(`missing column: ${metadata.tableId}:${ordinal}`);
|
|
25325
25334
|
const options = opts[i7];
|
|
@@ -25368,7 +25377,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25368
25377
|
progressCallback("indexes", indexesCount, "fetching");
|
|
25369
25378
|
progressCallback("tables", tableCount, "done");
|
|
25370
25379
|
for (const it of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
25371
|
-
const view6 = viewsList.find((x6) => x6.oid === it.tableId);
|
|
25380
|
+
const view6 = viewsList.find((x6) => Number(x6.oid) === Number(it.tableId));
|
|
25372
25381
|
const typeDimensions = it.type.split("[]").length - 1;
|
|
25373
25382
|
const enumType2 = it.typeId in groupedEnums ? groupedEnums[it.typeId] : it.typeId in groupedArrEnums ? groupedArrEnums[it.typeId] : null;
|
|
25374
25383
|
let columnTypeMapped = enumType2 ? enumType2.name : it.type.replace("[]", "");
|
|
@@ -25391,8 +25400,8 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25391
25400
|
}
|
|
25392
25401
|
for (const view6 of viewsList) {
|
|
25393
25402
|
tableCount += 1;
|
|
25394
|
-
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it) => it.oid === view6.accessMethod);
|
|
25395
|
-
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it) => it.oid === view6.tablespaceid).name;
|
|
25403
|
+
const accessMethod = Number(view6.accessMethod) === 0 ? null : ams.find((it) => Number(it.oid) === Number(view6.accessMethod));
|
|
25404
|
+
const tablespace = Number(view6.tablespaceid) === 0 ? null : tablespaces.find((it) => Number(it.oid) === Number(view6.tablespaceid)).name;
|
|
25396
25405
|
const definition = parseViewDefinition(view6.definition);
|
|
25397
25406
|
const withOpts = wrapRecord(
|
|
25398
25407
|
view6.options?.reduce((acc, it) => {
|
|
@@ -34431,7 +34440,7 @@ var require_websocket = __commonJS({
|
|
|
34431
34440
|
var EventEmitter = __require("events");
|
|
34432
34441
|
var https2 = __require("https");
|
|
34433
34442
|
var http3 = __require("http");
|
|
34434
|
-
var
|
|
34443
|
+
var net = __require("net");
|
|
34435
34444
|
var tls = __require("tls");
|
|
34436
34445
|
var { randomBytes, createHash: createHash5 } = __require("crypto");
|
|
34437
34446
|
var { Duplex, Readable: Readable6 } = __require("stream");
|
|
@@ -35162,12 +35171,12 @@ var require_websocket = __commonJS({
|
|
|
35162
35171
|
}
|
|
35163
35172
|
function netConnect(options) {
|
|
35164
35173
|
options.path = options.socketPath;
|
|
35165
|
-
return
|
|
35174
|
+
return net.connect(options);
|
|
35166
35175
|
}
|
|
35167
35176
|
function tlsConnect(options) {
|
|
35168
35177
|
options.path = void 0;
|
|
35169
35178
|
if (!options.servername && options.servername !== "") {
|
|
35170
|
-
options.servername =
|
|
35179
|
+
options.servername = net.isIP(options.host) ? "" : options.host;
|
|
35171
35180
|
}
|
|
35172
35181
|
return tls.connect(options);
|
|
35173
35182
|
}
|
|
@@ -39485,7 +39494,7 @@ var init_timing = __esm({
|
|
|
39485
39494
|
"../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
|
|
39486
39495
|
"use strict";
|
|
39487
39496
|
timing = {
|
|
39488
|
-
setTimeout: (cb,
|
|
39497
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
39489
39498
|
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
39490
39499
|
};
|
|
39491
39500
|
}
|
|
@@ -41373,13 +41382,13 @@ var init_schema_date_utils = __esm({
|
|
|
41373
41382
|
if (!matches) {
|
|
41374
41383
|
throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
|
|
41375
41384
|
}
|
|
41376
|
-
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, ,
|
|
41385
|
+
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
|
|
41377
41386
|
range(monthStr, 1, 12);
|
|
41378
41387
|
range(dayStr, 1, 31);
|
|
41379
41388
|
range(hours, 0, 23);
|
|
41380
41389
|
range(minutes, 0, 59);
|
|
41381
41390
|
range(seconds, 0, 60);
|
|
41382
|
-
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(
|
|
41391
|
+
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1e3) : 0));
|
|
41383
41392
|
date2.setUTCFullYear(Number(yearStr));
|
|
41384
41393
|
if (offsetStr.toUpperCase() != "Z") {
|
|
41385
41394
|
const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
|
|
@@ -61392,8 +61401,8 @@ var require_datetime2 = __commonJS({
|
|
|
61392
61401
|
if (!(object instanceof Date)) {
|
|
61393
61402
|
throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
|
|
61394
61403
|
}
|
|
61395
|
-
const
|
|
61396
|
-
const us =
|
|
61404
|
+
const ms = object.getTime() - TIMESHIFT;
|
|
61405
|
+
const us = ms * 1e3;
|
|
61397
61406
|
buf.writeInt32(8);
|
|
61398
61407
|
buf.writeInt64(us);
|
|
61399
61408
|
}
|
|
@@ -61403,12 +61412,12 @@ var require_datetime2 = __commonJS({
|
|
|
61403
61412
|
return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
|
|
61404
61413
|
}
|
|
61405
61414
|
const us = Number(buf.readBigInt64());
|
|
61406
|
-
let
|
|
61407
|
-
if (Math.abs(us % 1e3) === 500 && Math.abs(
|
|
61408
|
-
|
|
61415
|
+
let ms = Math.round(us / 1e3);
|
|
61416
|
+
if (Math.abs(us % 1e3) === 500 && Math.abs(ms) % 2 === 1) {
|
|
61417
|
+
ms -= 1;
|
|
61409
61418
|
}
|
|
61410
|
-
|
|
61411
|
-
return new Date(
|
|
61419
|
+
ms += TIMESHIFT;
|
|
61420
|
+
return new Date(ms);
|
|
61412
61421
|
}
|
|
61413
61422
|
};
|
|
61414
61423
|
exports2.DateTimeCodec = DateTimeCodec;
|
|
@@ -61429,8 +61438,8 @@ var require_datetime2 = __commonJS({
|
|
|
61429
61438
|
if (!(object instanceof datetime_1.LocalDateTime)) {
|
|
61430
61439
|
throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
|
|
61431
61440
|
}
|
|
61432
|
-
const
|
|
61433
|
-
let us =
|
|
61441
|
+
const ms = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
|
|
61442
|
+
let us = ms * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
|
|
61434
61443
|
if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
|
|
61435
61444
|
us += 1n;
|
|
61436
61445
|
}
|
|
@@ -61444,13 +61453,13 @@ var require_datetime2 = __commonJS({
|
|
|
61444
61453
|
}
|
|
61445
61454
|
const bi_ms = bi_us / 1000n;
|
|
61446
61455
|
let us = Number(bi_us - bi_ms * 1000n);
|
|
61447
|
-
let
|
|
61456
|
+
let ms = Number(bi_ms);
|
|
61448
61457
|
if (us < 0) {
|
|
61449
61458
|
us += 1e3;
|
|
61450
|
-
|
|
61459
|
+
ms -= 1;
|
|
61451
61460
|
}
|
|
61452
|
-
|
|
61453
|
-
const date2 = new Date(
|
|
61461
|
+
ms += TIMESHIFT;
|
|
61462
|
+
const date2 = new Date(ms);
|
|
61454
61463
|
return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
|
|
61455
61464
|
}
|
|
61456
61465
|
};
|
|
@@ -61512,13 +61521,13 @@ var require_datetime2 = __commonJS({
|
|
|
61512
61521
|
}
|
|
61513
61522
|
let us = Number(bius);
|
|
61514
61523
|
let seconds = Math.floor(us / 1e6);
|
|
61515
|
-
const
|
|
61516
|
-
us = us % 1e6 -
|
|
61524
|
+
const ms = Math.floor(us % 1e6 / 1e3);
|
|
61525
|
+
us = us % 1e6 - ms * 1e3;
|
|
61517
61526
|
let minutes = Math.floor(seconds / 60);
|
|
61518
61527
|
seconds = Math.floor(seconds % 60);
|
|
61519
61528
|
const hours = Math.floor(minutes / 60);
|
|
61520
61529
|
minutes = Math.floor(minutes % 60);
|
|
61521
|
-
return new datetime_1.LocalTime(hours, minutes, seconds,
|
|
61530
|
+
return new datetime_1.LocalTime(hours, minutes, seconds, ms, us);
|
|
61522
61531
|
}
|
|
61523
61532
|
};
|
|
61524
61533
|
exports2.LocalTimeCodec = LocalTimeCodec;
|
|
@@ -61595,14 +61604,14 @@ var require_datetime2 = __commonJS({
|
|
|
61595
61604
|
const biMillion = 1000000n;
|
|
61596
61605
|
const biSeconds = bius / biMillion;
|
|
61597
61606
|
let us = Number(bius - biSeconds * biMillion);
|
|
61598
|
-
const
|
|
61607
|
+
const ms = Math.floor(us / 1e3);
|
|
61599
61608
|
us = us % 1e3;
|
|
61600
61609
|
let seconds = Number(biSeconds);
|
|
61601
61610
|
let minutes = Math.floor(seconds / 60);
|
|
61602
61611
|
seconds = Math.floor(seconds % 60);
|
|
61603
61612
|
const hours = Math.floor(minutes / 60);
|
|
61604
61613
|
minutes = Math.floor(minutes % 60);
|
|
61605
|
-
return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2,
|
|
61614
|
+
return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
|
|
61606
61615
|
}
|
|
61607
61616
|
};
|
|
61608
61617
|
exports2.DurationCodec = DurationCodec;
|
|
@@ -61648,7 +61657,7 @@ var require_datetime2 = __commonJS({
|
|
|
61648
61657
|
const million = BigInt(1e6);
|
|
61649
61658
|
const biSeconds = bius / million;
|
|
61650
61659
|
let us = Number(bius - biSeconds * million);
|
|
61651
|
-
const
|
|
61660
|
+
const ms = Math.trunc(us / 1e3);
|
|
61652
61661
|
us = us % 1e3;
|
|
61653
61662
|
let seconds = Number(biSeconds);
|
|
61654
61663
|
let minutes = Math.trunc(seconds / 60);
|
|
@@ -61659,7 +61668,7 @@ var require_datetime2 = __commonJS({
|
|
|
61659
61668
|
days = Math.trunc(days % 7);
|
|
61660
61669
|
const years = Math.trunc(months2 / 12);
|
|
61661
61670
|
months2 = Math.trunc(months2 % 12);
|
|
61662
|
-
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2,
|
|
61671
|
+
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
|
|
61663
61672
|
}
|
|
61664
61673
|
};
|
|
61665
61674
|
exports2.RelativeDurationCodec = RelativeDurationCodec;
|
|
@@ -71823,41 +71832,41 @@ var require_ms = __commonJS({
|
|
|
71823
71832
|
return void 0;
|
|
71824
71833
|
}
|
|
71825
71834
|
}
|
|
71826
|
-
function fmtShort(
|
|
71827
|
-
var msAbs = Math.abs(
|
|
71835
|
+
function fmtShort(ms) {
|
|
71836
|
+
var msAbs = Math.abs(ms);
|
|
71828
71837
|
if (msAbs >= d6) {
|
|
71829
|
-
return Math.round(
|
|
71838
|
+
return Math.round(ms / d6) + "d";
|
|
71830
71839
|
}
|
|
71831
71840
|
if (msAbs >= h7) {
|
|
71832
|
-
return Math.round(
|
|
71841
|
+
return Math.round(ms / h7) + "h";
|
|
71833
71842
|
}
|
|
71834
71843
|
if (msAbs >= m7) {
|
|
71835
|
-
return Math.round(
|
|
71844
|
+
return Math.round(ms / m7) + "m";
|
|
71836
71845
|
}
|
|
71837
71846
|
if (msAbs >= s7) {
|
|
71838
|
-
return Math.round(
|
|
71847
|
+
return Math.round(ms / s7) + "s";
|
|
71839
71848
|
}
|
|
71840
|
-
return
|
|
71849
|
+
return ms + "ms";
|
|
71841
71850
|
}
|
|
71842
|
-
function fmtLong(
|
|
71843
|
-
var msAbs = Math.abs(
|
|
71851
|
+
function fmtLong(ms) {
|
|
71852
|
+
var msAbs = Math.abs(ms);
|
|
71844
71853
|
if (msAbs >= d6) {
|
|
71845
|
-
return plural2(
|
|
71854
|
+
return plural2(ms, msAbs, d6, "day");
|
|
71846
71855
|
}
|
|
71847
71856
|
if (msAbs >= h7) {
|
|
71848
|
-
return plural2(
|
|
71857
|
+
return plural2(ms, msAbs, h7, "hour");
|
|
71849
71858
|
}
|
|
71850
71859
|
if (msAbs >= m7) {
|
|
71851
|
-
return plural2(
|
|
71860
|
+
return plural2(ms, msAbs, m7, "minute");
|
|
71852
71861
|
}
|
|
71853
71862
|
if (msAbs >= s7) {
|
|
71854
|
-
return plural2(
|
|
71863
|
+
return plural2(ms, msAbs, s7, "second");
|
|
71855
71864
|
}
|
|
71856
|
-
return
|
|
71865
|
+
return ms + " ms";
|
|
71857
71866
|
}
|
|
71858
|
-
function plural2(
|
|
71867
|
+
function plural2(ms, msAbs, n6, name) {
|
|
71859
71868
|
var isPlural = msAbs >= n6 * 1.5;
|
|
71860
|
-
return Math.round(
|
|
71869
|
+
return Math.round(ms / n6) + " " + name + (isPlural ? "s" : "");
|
|
71861
71870
|
}
|
|
71862
71871
|
}
|
|
71863
71872
|
});
|
|
@@ -71901,8 +71910,8 @@ var require_common2 = __commonJS({
|
|
|
71901
71910
|
}
|
|
71902
71911
|
const self2 = debug;
|
|
71903
71912
|
const curr = Number(/* @__PURE__ */ new Date());
|
|
71904
|
-
const
|
|
71905
|
-
self2.diff =
|
|
71913
|
+
const ms = curr - (prevTime || curr);
|
|
71914
|
+
self2.diff = ms;
|
|
71906
71915
|
self2.prev = prevTime;
|
|
71907
71916
|
self2.curr = curr;
|
|
71908
71917
|
prevTime = curr;
|
|
@@ -87405,11 +87414,11 @@ var require_TokenExpiredError = __commonJS({
|
|
|
87405
87414
|
var require_timespan = __commonJS({
|
|
87406
87415
|
"../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module) {
|
|
87407
87416
|
"use strict";
|
|
87408
|
-
var
|
|
87417
|
+
var ms = require_ms();
|
|
87409
87418
|
module.exports = function(time2, iat) {
|
|
87410
87419
|
var timestamp = iat || Math.floor(Date.now() / 1e3);
|
|
87411
87420
|
if (typeof time2 === "string") {
|
|
87412
|
-
var milliseconds =
|
|
87421
|
+
var milliseconds = ms(time2);
|
|
87413
87422
|
if (typeof milliseconds === "undefined") {
|
|
87414
87423
|
return;
|
|
87415
87424
|
}
|
|
@@ -101947,7 +101956,7 @@ var require_dist = __commonJS({
|
|
|
101947
101956
|
};
|
|
101948
101957
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
101949
101958
|
exports2.Agent = void 0;
|
|
101950
|
-
var
|
|
101959
|
+
var net = __importStar2(__require("net"));
|
|
101951
101960
|
var http3 = __importStar2(__require("http"));
|
|
101952
101961
|
var https_1 = __require("https");
|
|
101953
101962
|
__exportStar2(require_helpers2(), exports2);
|
|
@@ -101987,7 +101996,7 @@ var require_dist = __commonJS({
|
|
|
101987
101996
|
if (!this.sockets[name]) {
|
|
101988
101997
|
this.sockets[name] = [];
|
|
101989
101998
|
}
|
|
101990
|
-
const fakeSocket = new
|
|
101999
|
+
const fakeSocket = new net.Socket({ writable: false });
|
|
101991
102000
|
this.sockets[name].push(fakeSocket);
|
|
101992
102001
|
this.totalSocketCount++;
|
|
101993
102002
|
return fakeSocket;
|
|
@@ -102199,7 +102208,7 @@ var require_dist2 = __commonJS({
|
|
|
102199
102208
|
};
|
|
102200
102209
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
102201
102210
|
exports2.HttpsProxyAgent = void 0;
|
|
102202
|
-
var
|
|
102211
|
+
var net = __importStar2(__require("net"));
|
|
102203
102212
|
var tls = __importStar2(__require("tls"));
|
|
102204
102213
|
var assert_1 = __importDefault2(__require("assert"));
|
|
102205
102214
|
var debug_1 = __importDefault2(require_src2());
|
|
@@ -102208,7 +102217,7 @@ var require_dist2 = __commonJS({
|
|
|
102208
102217
|
var parse_proxy_response_1 = require_parse_proxy_response();
|
|
102209
102218
|
var debug = (0, debug_1.default)("https-proxy-agent");
|
|
102210
102219
|
var setServernameFromNonIpHost = (options) => {
|
|
102211
|
-
if (options.servername === void 0 && options.host && !
|
|
102220
|
+
if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
|
|
102212
102221
|
return {
|
|
102213
102222
|
...options,
|
|
102214
102223
|
servername: options.host
|
|
@@ -102248,10 +102257,10 @@ var require_dist2 = __commonJS({
|
|
|
102248
102257
|
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
102249
102258
|
} else {
|
|
102250
102259
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
102251
|
-
socket =
|
|
102260
|
+
socket = net.connect(this.connectOpts);
|
|
102252
102261
|
}
|
|
102253
102262
|
const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
|
|
102254
|
-
const host =
|
|
102263
|
+
const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
102255
102264
|
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
|
|
102256
102265
|
`;
|
|
102257
102266
|
if (proxy.username || proxy.password) {
|
|
@@ -102284,7 +102293,7 @@ var require_dist2 = __commonJS({
|
|
|
102284
102293
|
return socket;
|
|
102285
102294
|
}
|
|
102286
102295
|
socket.destroy();
|
|
102287
|
-
const fakeSocket = new
|
|
102296
|
+
const fakeSocket = new net.Socket({ writable: false });
|
|
102288
102297
|
fakeSocket.readable = true;
|
|
102289
102298
|
req.once("socket", (s7) => {
|
|
102290
102299
|
debug("Replaying proxy buffer for failed request");
|
|
@@ -102349,7 +102358,7 @@ var require_dist3 = __commonJS({
|
|
|
102349
102358
|
};
|
|
102350
102359
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
102351
102360
|
exports2.HttpProxyAgent = void 0;
|
|
102352
|
-
var
|
|
102361
|
+
var net = __importStar2(__require("net"));
|
|
102353
102362
|
var tls = __importStar2(__require("tls"));
|
|
102354
102363
|
var debug_1 = __importDefault2(require_src2());
|
|
102355
102364
|
var events_1 = __require("events");
|
|
@@ -102422,7 +102431,7 @@ var require_dist3 = __commonJS({
|
|
|
102422
102431
|
socket = tls.connect(this.connectOpts);
|
|
102423
102432
|
} else {
|
|
102424
102433
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
102425
|
-
socket =
|
|
102434
|
+
socket = net.connect(this.connectOpts);
|
|
102426
102435
|
}
|
|
102427
102436
|
await (0, events_1.once)(socket, "connect");
|
|
102428
102437
|
return socket;
|
|
@@ -141301,7 +141310,7 @@ var require_connection = __commonJS({
|
|
|
141301
141310
|
var _crypto = _interopRequireDefault(__require("crypto"));
|
|
141302
141311
|
var _os = _interopRequireDefault(__require("os"));
|
|
141303
141312
|
var tls = _interopRequireWildcard(__require("tls"));
|
|
141304
|
-
var
|
|
141313
|
+
var net = _interopRequireWildcard(__require("net"));
|
|
141305
141314
|
var _dns = _interopRequireDefault(__require("dns"));
|
|
141306
141315
|
var _constants = _interopRequireDefault(__require("constants"));
|
|
141307
141316
|
var _stream = __require("stream");
|
|
@@ -142350,7 +142359,7 @@ var require_connection = __commonJS({
|
|
|
142350
142359
|
async wrapWithTls(socket, signal) {
|
|
142351
142360
|
signal.throwIfAborted();
|
|
142352
142361
|
const secureContext = tls.createSecureContext(this.secureContextOptions);
|
|
142353
|
-
const serverName = !
|
|
142362
|
+
const serverName = !net.isIP(this.config.server) ? this.config.server : "";
|
|
142354
142363
|
const encryptOptions = {
|
|
142355
142364
|
host: this.config.server,
|
|
142356
142365
|
socket,
|
|
@@ -145256,10 +145265,10 @@ __export(connections_exports, {
|
|
|
145256
145265
|
connectToSQLite: () => connectToSQLite,
|
|
145257
145266
|
connectToSingleStore: () => connectToSingleStore,
|
|
145258
145267
|
prepareCockroach: () => prepareCockroach,
|
|
145268
|
+
prepareDuckDb: () => prepareDuckDb,
|
|
145259
145269
|
prepareGelDB: () => prepareGelDB,
|
|
145260
145270
|
preparePostgresDB: () => preparePostgresDB
|
|
145261
145271
|
});
|
|
145262
|
-
import net from "net";
|
|
145263
145272
|
function parseMssqlUrl(url) {
|
|
145264
145273
|
return {
|
|
145265
145274
|
user: url.username,
|
|
@@ -145273,7 +145282,7 @@ function parseMssqlUrl(url) {
|
|
|
145273
145282
|
}
|
|
145274
145283
|
};
|
|
145275
145284
|
}
|
|
145276
|
-
var
|
|
145285
|
+
var normalisePGliteUrl, preparePostgresDB, prepareDuckDb, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
|
|
145277
145286
|
var init_connections = __esm({
|
|
145278
145287
|
"src/cli/connections.ts"() {
|
|
145279
145288
|
"use strict";
|
|
@@ -145284,7 +145293,6 @@ var init_connections = __esm({
|
|
|
145284
145293
|
init_when_json_met_bigint();
|
|
145285
145294
|
init_utils3();
|
|
145286
145295
|
init_outputs();
|
|
145287
|
-
ms = (a6, b6) => Number(b6 - a6) / 1e6;
|
|
145288
145296
|
normalisePGliteUrl = (it) => {
|
|
145289
145297
|
if (it.startsWith("file:")) {
|
|
145290
145298
|
return it.substring(5);
|
|
@@ -145408,7 +145416,13 @@ var init_connections = __esm({
|
|
|
145408
145416
|
}
|
|
145409
145417
|
return results;
|
|
145410
145418
|
};
|
|
145411
|
-
return {
|
|
145419
|
+
return {
|
|
145420
|
+
packageName: "pglite",
|
|
145421
|
+
query,
|
|
145422
|
+
proxy,
|
|
145423
|
+
transactionProxy,
|
|
145424
|
+
migrate: migrateFn
|
|
145425
|
+
};
|
|
145412
145426
|
}
|
|
145413
145427
|
assertUnreachable(driver2);
|
|
145414
145428
|
}
|
|
@@ -145439,13 +145453,13 @@ var init_connections = __esm({
|
|
|
145439
145453
|
return pg.types.getTypeParser(typeId, format2);
|
|
145440
145454
|
}
|
|
145441
145455
|
};
|
|
145442
|
-
const
|
|
145443
|
-
const db = drizzle({ client
|
|
145456
|
+
const client = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
|
|
145457
|
+
const db = drizzle({ client });
|
|
145444
145458
|
const migrateFn = async (config) => {
|
|
145445
145459
|
return migrate(db, config);
|
|
145446
145460
|
};
|
|
145447
145461
|
const query = async (sql, params) => {
|
|
145448
|
-
const result2 = await
|
|
145462
|
+
const result2 = await client.query({
|
|
145449
145463
|
text: sql,
|
|
145450
145464
|
values: params ?? [],
|
|
145451
145465
|
types: types3
|
|
@@ -145455,7 +145469,7 @@ var init_connections = __esm({
|
|
|
145455
145469
|
return result2.rows;
|
|
145456
145470
|
};
|
|
145457
145471
|
const proxy = async (params) => {
|
|
145458
|
-
const result2 = await
|
|
145472
|
+
const result2 = await client.query({
|
|
145459
145473
|
text: params.sql,
|
|
145460
145474
|
values: params.params,
|
|
145461
145475
|
...params.mode === "array" && { rowMode: "array" },
|
|
@@ -145467,7 +145481,7 @@ var init_connections = __esm({
|
|
|
145467
145481
|
};
|
|
145468
145482
|
const transactionProxy = async (queries) => {
|
|
145469
145483
|
const results = [];
|
|
145470
|
-
const tx = await
|
|
145484
|
+
const tx = await client.connect();
|
|
145471
145485
|
try {
|
|
145472
145486
|
await tx.query("BEGIN");
|
|
145473
145487
|
for (const query2 of queries) {
|
|
@@ -145486,119 +145500,13 @@ var init_connections = __esm({
|
|
|
145486
145500
|
}
|
|
145487
145501
|
return results;
|
|
145488
145502
|
};
|
|
145489
|
-
|
|
145490
|
-
|
|
145491
|
-
|
|
145492
|
-
|
|
145493
|
-
|
|
145494
|
-
|
|
145495
|
-
const stringifiedResult = JSON.stringify(explainResult.rows);
|
|
145496
|
-
const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
|
|
145497
|
-
const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
|
|
145498
|
-
let planningTime = Number(planningMatch[1]);
|
|
145499
|
-
let executionTime = Number(executionMatch[1]);
|
|
145500
|
-
let querySentAt = 0n;
|
|
145501
|
-
let firstDataAt = 0n;
|
|
145502
|
-
let lastDataAt = 0n;
|
|
145503
|
-
let lastRowParsedAt = 0n;
|
|
145504
|
-
let queryCompletedAt = 0n;
|
|
145505
|
-
let bytesReceived = 0;
|
|
145506
|
-
let rowCount = 0;
|
|
145507
|
-
let parseTime = 0;
|
|
145508
|
-
let lastParseTime = 0;
|
|
145509
|
-
const rowDescriptionListener = (data) => {
|
|
145510
|
-
if (firstDataAt === 0n) {
|
|
145511
|
-
firstDataAt = process.hrtime.bigint();
|
|
145512
|
-
}
|
|
145513
|
-
bytesReceived += data.length;
|
|
145514
|
-
};
|
|
145515
|
-
const originalRowListener = client.connection.listeners("dataRow")[0];
|
|
145516
|
-
const wrappedRowListener = (data) => {
|
|
145517
|
-
rowCount += 1;
|
|
145518
|
-
const start = process.hrtime.bigint();
|
|
145519
|
-
lastDataAt = start;
|
|
145520
|
-
originalRowListener.apply(client.connection, [data]);
|
|
145521
|
-
const end2 = process.hrtime.bigint();
|
|
145522
|
-
lastRowParsedAt = end2;
|
|
145523
|
-
lastParseTime = ms(start, end2);
|
|
145524
|
-
parseTime += lastParseTime;
|
|
145525
|
-
bytesReceived += data.length;
|
|
145526
|
-
};
|
|
145527
|
-
client.connection.removeAllListeners("dataRow");
|
|
145528
|
-
client.connection.addListener("dataRow", wrappedRowListener);
|
|
145529
|
-
client.connection.prependListener("rowDescription", rowDescriptionListener);
|
|
145530
|
-
querySentAt = process.hrtime.bigint();
|
|
145531
|
-
await client.query({
|
|
145532
|
-
text: sql,
|
|
145533
|
-
values: params,
|
|
145534
|
-
types: types3
|
|
145535
|
-
});
|
|
145536
|
-
queryCompletedAt = process.hrtime.bigint();
|
|
145537
|
-
client.connection.removeListener("rowDescription", rowDescriptionListener);
|
|
145538
|
-
client.connection.removeAllListeners("dataRow");
|
|
145539
|
-
client.connection.addListener("dataRow", originalRowListener);
|
|
145540
|
-
let querySentTime = ms(querySentAt, firstDataAt) - executionTime - planningTime;
|
|
145541
|
-
if (querySentTime < 0) {
|
|
145542
|
-
const percent = 0.1;
|
|
145543
|
-
const overflow = -querySentTime;
|
|
145544
|
-
const keepForSent = overflow * percent;
|
|
145545
|
-
const adjustedOverflow = overflow * (1 + percent);
|
|
145546
|
-
const total2 = planningTime + executionTime;
|
|
145547
|
-
const ratioPlanning = planningTime / total2;
|
|
145548
|
-
const ratioExecution = executionTime / total2;
|
|
145549
|
-
planningTime -= adjustedOverflow * ratioPlanning;
|
|
145550
|
-
executionTime -= adjustedOverflow * ratioExecution;
|
|
145551
|
-
querySentTime = keepForSent;
|
|
145552
|
-
}
|
|
145553
|
-
const networkLatencyBefore = querySentTime / 2;
|
|
145554
|
-
const networkLatencyAfter = querySentTime / 2;
|
|
145555
|
-
const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
|
|
145556
|
-
const total = ms(querySentAt, queryCompletedAt);
|
|
145557
|
-
const calculatedTotal = networkLatencyBefore + planningTime + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
|
|
145558
|
-
const errorMargin = Math.abs(total - calculatedTotal);
|
|
145559
|
-
return {
|
|
145560
|
-
networkLatencyBefore,
|
|
145561
|
-
planning: planningTime,
|
|
145562
|
-
execution: executionTime,
|
|
145563
|
-
networkLatencyAfter,
|
|
145564
|
-
dataDownload: downloadTime,
|
|
145565
|
-
dataParse: parseTime,
|
|
145566
|
-
total,
|
|
145567
|
-
errorMargin,
|
|
145568
|
-
dataSize: bytesReceived
|
|
145569
|
-
};
|
|
145570
|
-
};
|
|
145571
|
-
const benchmarkProxy = async ({ sql, params }, repeats) => {
|
|
145572
|
-
let startAt = 0n;
|
|
145573
|
-
let tcpConnectedAt = 0n;
|
|
145574
|
-
let tlsConnectedAt = null;
|
|
145575
|
-
let dbReadyAt = 0n;
|
|
145576
|
-
const client = "url" in credentials ? new pg.Client({ connectionString: credentials.url }) : new pg.Client({ ...credentials, ssl });
|
|
145577
|
-
client.connection.once("connect", () => {
|
|
145578
|
-
tcpConnectedAt = process.hrtime.bigint();
|
|
145579
|
-
});
|
|
145580
|
-
client.connection.prependOnceListener("sslconnect", () => {
|
|
145581
|
-
tlsConnectedAt = process.hrtime.bigint();
|
|
145582
|
-
});
|
|
145583
|
-
client.connection.prependOnceListener("readyForQuery", () => {
|
|
145584
|
-
dbReadyAt = process.hrtime.bigint();
|
|
145585
|
-
});
|
|
145586
|
-
startAt = process.hrtime.bigint();
|
|
145587
|
-
await client.connect();
|
|
145588
|
-
const results = [];
|
|
145589
|
-
for (let i7 = 0; i7 < repeats; i7++) {
|
|
145590
|
-
const r7 = await benchmarkQuery(client, sql, params);
|
|
145591
|
-
results.push(r7);
|
|
145592
|
-
}
|
|
145593
|
-
await client.end();
|
|
145594
|
-
return {
|
|
145595
|
-
tcpHandshake: ms(startAt, tcpConnectedAt),
|
|
145596
|
-
tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
|
|
145597
|
-
dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
|
|
145598
|
-
queries: results
|
|
145599
|
-
};
|
|
145503
|
+
return {
|
|
145504
|
+
packageName: "pg",
|
|
145505
|
+
query,
|
|
145506
|
+
proxy,
|
|
145507
|
+
transactionProxy,
|
|
145508
|
+
migrate: migrateFn
|
|
145600
145509
|
};
|
|
145601
|
-
return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
|
|
145602
145510
|
}
|
|
145603
145511
|
if (await checkPackage("postgres")) {
|
|
145604
145512
|
console.log(
|
|
@@ -145649,7 +145557,13 @@ var init_connections = __esm({
|
|
|
145649
145557
|
}
|
|
145650
145558
|
return results;
|
|
145651
145559
|
};
|
|
145652
|
-
return {
|
|
145560
|
+
return {
|
|
145561
|
+
packageName: "postgres",
|
|
145562
|
+
query,
|
|
145563
|
+
proxy,
|
|
145564
|
+
transactionProxy,
|
|
145565
|
+
migrate: migrateFn
|
|
145566
|
+
};
|
|
145653
145567
|
}
|
|
145654
145568
|
if (await checkPackage("@vercel/postgres")) {
|
|
145655
145569
|
console.log(
|
|
@@ -145730,7 +145644,13 @@ var init_connections = __esm({
|
|
|
145730
145644
|
}
|
|
145731
145645
|
return results;
|
|
145732
145646
|
};
|
|
145733
|
-
return {
|
|
145647
|
+
return {
|
|
145648
|
+
packageName: "@vercel/postgres",
|
|
145649
|
+
query,
|
|
145650
|
+
proxy,
|
|
145651
|
+
transactionProxy,
|
|
145652
|
+
migrate: migrateFn
|
|
145653
|
+
};
|
|
145734
145654
|
}
|
|
145735
145655
|
if (await checkPackage("@neondatabase/serverless")) {
|
|
145736
145656
|
console.log(
|
|
@@ -145743,7 +145663,11 @@ var init_connections = __esm({
|
|
|
145743
145663
|
"'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
|
|
145744
145664
|
)
|
|
145745
145665
|
);
|
|
145746
|
-
const {
|
|
145666
|
+
const {
|
|
145667
|
+
Pool,
|
|
145668
|
+
neonConfig,
|
|
145669
|
+
types: pgTypes
|
|
145670
|
+
} = await import("@neondatabase/serverless");
|
|
145747
145671
|
const { drizzle } = await import("drizzle-orm/neon-serverless");
|
|
145748
145672
|
const { migrate } = await import("drizzle-orm/neon-serverless/migrator");
|
|
145749
145673
|
const ssl = "ssl" in credentials ? credentials.ssl === "prefer" || credentials.ssl === "require" || credentials.ssl === "allow" ? { rejectUnauthorized: false } : credentials.ssl === "verify-full" ? {} : credentials.ssl : {};
|
|
@@ -145813,7 +145737,13 @@ var init_connections = __esm({
|
|
|
145813
145737
|
}
|
|
145814
145738
|
return results;
|
|
145815
145739
|
};
|
|
145816
|
-
return {
|
|
145740
|
+
return {
|
|
145741
|
+
packageName: "@neondatabase/serverless",
|
|
145742
|
+
query,
|
|
145743
|
+
proxy,
|
|
145744
|
+
transactionProxy,
|
|
145745
|
+
migrate: migrateFn
|
|
145746
|
+
};
|
|
145817
145747
|
}
|
|
145818
145748
|
if (await checkPackage("bun")) {
|
|
145819
145749
|
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
@@ -145864,6 +145794,111 @@ var init_connections = __esm({
|
|
|
145864
145794
|
console.warn("For the 'bun' driver, run your script using: bun --bun");
|
|
145865
145795
|
process.exit(1);
|
|
145866
145796
|
};
|
|
145797
|
+
prepareDuckDb = async (credentials) => {
|
|
145798
|
+
if (await checkPackage("duckdb")) {
|
|
145799
|
+
console.log(withStyle.info(`Using 'duckdb' driver for database querying`));
|
|
145800
|
+
const duckdb = await import("duckdb");
|
|
145801
|
+
const client = await new Promise((resolve2, reject) => {
|
|
145802
|
+
const db = new duckdb.Database(credentials.url, (err2) => {
|
|
145803
|
+
if (err2) {
|
|
145804
|
+
reject(err2);
|
|
145805
|
+
}
|
|
145806
|
+
resolve2(db);
|
|
145807
|
+
});
|
|
145808
|
+
});
|
|
145809
|
+
const query = async (sql, params = []) => new Promise((resolve2, reject) => {
|
|
145810
|
+
client.all(sql, ...params, (err2, rows) => {
|
|
145811
|
+
if (err2) {
|
|
145812
|
+
reject(err2);
|
|
145813
|
+
}
|
|
145814
|
+
resolve2(rows);
|
|
145815
|
+
});
|
|
145816
|
+
});
|
|
145817
|
+
const proxy = async (params) => {
|
|
145818
|
+
const rows = await query(params.sql, params.params);
|
|
145819
|
+
return params.mode === "array" ? rows.map((row) => Object.values(row)) : rows;
|
|
145820
|
+
};
|
|
145821
|
+
const transactionProxy = async (queries) => {
|
|
145822
|
+
const results = [];
|
|
145823
|
+
const tx = client.connect();
|
|
145824
|
+
try {
|
|
145825
|
+
tx.run("BEGIN");
|
|
145826
|
+
for (const query2 of queries) {
|
|
145827
|
+
const rows = await new Promise((resolve2, reject) => {
|
|
145828
|
+
client.all(query2.sql, (err2, rows2) => {
|
|
145829
|
+
if (err2) {
|
|
145830
|
+
reject(err2);
|
|
145831
|
+
}
|
|
145832
|
+
resolve2(rows2);
|
|
145833
|
+
});
|
|
145834
|
+
});
|
|
145835
|
+
results.push(rows);
|
|
145836
|
+
}
|
|
145837
|
+
tx.run("COMMIT");
|
|
145838
|
+
} catch (error3) {
|
|
145839
|
+
tx.run("ROLLBACK");
|
|
145840
|
+
results.push(error3);
|
|
145841
|
+
} finally {
|
|
145842
|
+
tx.close();
|
|
145843
|
+
}
|
|
145844
|
+
return results;
|
|
145845
|
+
};
|
|
145846
|
+
return {
|
|
145847
|
+
packageName: "duckdb",
|
|
145848
|
+
query,
|
|
145849
|
+
proxy,
|
|
145850
|
+
transactionProxy,
|
|
145851
|
+
migrate: () => {
|
|
145852
|
+
throw new Error("DuckDB does not support migrations");
|
|
145853
|
+
}
|
|
145854
|
+
};
|
|
145855
|
+
}
|
|
145856
|
+
if (await checkPackage("@duckdb/node-api")) {
|
|
145857
|
+
console.log(
|
|
145858
|
+
withStyle.info(`Using '@duckdb/node-api' driver for database querying`)
|
|
145859
|
+
);
|
|
145860
|
+
const { DuckDBInstance } = await import("@duckdb/node-api");
|
|
145861
|
+
const instance = await DuckDBInstance.create(credentials.url);
|
|
145862
|
+
const client = await instance.connect();
|
|
145863
|
+
const query = async (sql, params = []) => {
|
|
145864
|
+
const result2 = await client.run(sql, params);
|
|
145865
|
+
const rows = await result2.getRowObjectsJson();
|
|
145866
|
+
return rows;
|
|
145867
|
+
};
|
|
145868
|
+
const proxy = async (params) => {
|
|
145869
|
+
const result2 = await client.run(params.sql, params.params);
|
|
145870
|
+
return params.mode === "array" ? await result2.getRowsJson() : await result2.getRowObjectsJson();
|
|
145871
|
+
};
|
|
145872
|
+
const transactionProxy = async (queries) => {
|
|
145873
|
+
const results = [];
|
|
145874
|
+
try {
|
|
145875
|
+
await client.run("BEGIN");
|
|
145876
|
+
for (const query2 of queries) {
|
|
145877
|
+
const result2 = await client.run(query2.sql);
|
|
145878
|
+
results.push(await result2.getRowObjectsJson());
|
|
145879
|
+
}
|
|
145880
|
+
await client.run("COMMIT");
|
|
145881
|
+
} catch (error3) {
|
|
145882
|
+
await client.run("ROLLBACK");
|
|
145883
|
+
results.push(error3);
|
|
145884
|
+
}
|
|
145885
|
+
return results;
|
|
145886
|
+
};
|
|
145887
|
+
return {
|
|
145888
|
+
packageName: "@duckdb/node-api",
|
|
145889
|
+
query,
|
|
145890
|
+
proxy,
|
|
145891
|
+
transactionProxy,
|
|
145892
|
+
migrate: () => {
|
|
145893
|
+
throw new Error("DuckDB does not support migrations");
|
|
145894
|
+
}
|
|
145895
|
+
};
|
|
145896
|
+
}
|
|
145897
|
+
console.error(
|
|
145898
|
+
"To connect to DuckDb database - please install either of 'duckdb', '@duckdb/node-api' drivers"
|
|
145899
|
+
);
|
|
145900
|
+
process.exit(1);
|
|
145901
|
+
};
|
|
145867
145902
|
prepareCockroach = async (credentials) => {
|
|
145868
145903
|
if (await checkPackage("pg")) {
|
|
145869
145904
|
const { default: pg } = await import("pg");
|
|
@@ -145916,9 +145951,7 @@ var init_connections = __esm({
|
|
|
145916
145951
|
};
|
|
145917
145952
|
return { query, proxy, migrate: migrateFn };
|
|
145918
145953
|
}
|
|
145919
|
-
console.error(
|
|
145920
|
-
"To connect to Cockroach - please install 'pg' package"
|
|
145921
|
-
);
|
|
145954
|
+
console.error("To connect to Cockroach - please install 'pg' package");
|
|
145922
145955
|
process.exit(1);
|
|
145923
145956
|
};
|
|
145924
145957
|
prepareGelDB = async (credentials) => {
|
|
@@ -145977,9 +146010,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
145977
146010
|
};
|
|
145978
146011
|
return { packageName: "gel", query, proxy, transactionProxy };
|
|
145979
146012
|
}
|
|
145980
|
-
console.error(
|
|
145981
|
-
"To connect to gel database - please install 'edgedb' driver"
|
|
145982
|
-
);
|
|
146013
|
+
console.error("To connect to gel database - please install 'edgedb' driver");
|
|
145983
146014
|
process.exit(1);
|
|
145984
146015
|
};
|
|
145985
146016
|
parseSingleStoreCredentials = (credentials) => {
|
|
@@ -146093,6 +146124,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146093
146124
|
}
|
|
146094
146125
|
return next();
|
|
146095
146126
|
};
|
|
146127
|
+
await connection.connect();
|
|
146096
146128
|
const query = async (sql, params) => {
|
|
146097
146129
|
const res = await connection.execute({
|
|
146098
146130
|
sql,
|
|
@@ -146132,156 +146164,11 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146132
146164
|
}
|
|
146133
146165
|
return results;
|
|
146134
146166
|
};
|
|
146135
|
-
const benchmarkQuery = async (newConnection, sql, params) => {
|
|
146136
|
-
const explainResult = await connection.query({
|
|
146137
|
-
sql: `EXPLAIN ANALYZE ${sql}`,
|
|
146138
|
-
values: params ?? [],
|
|
146139
|
-
typeCast
|
|
146140
|
-
});
|
|
146141
|
-
const stringifiedResult = JSON.stringify(explainResult[0]);
|
|
146142
|
-
const timeMatch = stringifiedResult.match(
|
|
146143
|
-
/actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
|
|
146144
|
-
);
|
|
146145
|
-
const lastRowTime = Number(timeMatch[2]);
|
|
146146
|
-
let executionTime = lastRowTime;
|
|
146147
|
-
let querySentAt = 0n;
|
|
146148
|
-
let firstDataAt = 0n;
|
|
146149
|
-
let lastDataAt = 0n;
|
|
146150
|
-
let lastRowParsedAt = 0n;
|
|
146151
|
-
let queryCompletedAt = 0n;
|
|
146152
|
-
let bytesReceived = 0;
|
|
146153
|
-
let rowCount = 0;
|
|
146154
|
-
let parseTime = 0;
|
|
146155
|
-
let lastParseTime = 0;
|
|
146156
|
-
querySentAt = process.hrtime.bigint();
|
|
146157
|
-
await new Promise((resolve2, reject) => {
|
|
146158
|
-
const query2 = newConnection.query({
|
|
146159
|
-
sql,
|
|
146160
|
-
values: params ?? [],
|
|
146161
|
-
typeCast
|
|
146162
|
-
});
|
|
146163
|
-
const originalRowHandler = query2.row;
|
|
146164
|
-
let packets = 0;
|
|
146165
|
-
const wrappedRowListener = (packet, connection2) => {
|
|
146166
|
-
packets += 1;
|
|
146167
|
-
if (firstDataAt === 0n) {
|
|
146168
|
-
firstDataAt = process.hrtime.bigint();
|
|
146169
|
-
bytesReceived += packet.start;
|
|
146170
|
-
}
|
|
146171
|
-
const start = process.hrtime.bigint();
|
|
146172
|
-
lastDataAt = start;
|
|
146173
|
-
const res = originalRowHandler.apply(query2, [packet, connection2]);
|
|
146174
|
-
const end2 = process.hrtime.bigint();
|
|
146175
|
-
lastRowParsedAt = end2;
|
|
146176
|
-
lastParseTime = ms(start, end2);
|
|
146177
|
-
parseTime += lastParseTime;
|
|
146178
|
-
bytesReceived += packet.length();
|
|
146179
|
-
if (!res || packet.isEOF()) {
|
|
146180
|
-
return res;
|
|
146181
|
-
}
|
|
146182
|
-
return wrappedRowListener;
|
|
146183
|
-
};
|
|
146184
|
-
query2.row = wrappedRowListener;
|
|
146185
|
-
query2.on("result", () => {
|
|
146186
|
-
rowCount += 1;
|
|
146187
|
-
});
|
|
146188
|
-
query2.on("error", (err2) => {
|
|
146189
|
-
reject(err2);
|
|
146190
|
-
});
|
|
146191
|
-
query2.on("end", () => {
|
|
146192
|
-
resolve2();
|
|
146193
|
-
});
|
|
146194
|
-
});
|
|
146195
|
-
queryCompletedAt = process.hrtime.bigint();
|
|
146196
|
-
let querySentTime = ms(querySentAt, firstDataAt) - executionTime;
|
|
146197
|
-
if (querySentTime < 0) {
|
|
146198
|
-
const percent = 0.1;
|
|
146199
|
-
const overflow = -querySentTime;
|
|
146200
|
-
const keepForSent = overflow * percent;
|
|
146201
|
-
const adjustedOverflow = overflow * (1 + percent);
|
|
146202
|
-
const total2 = executionTime;
|
|
146203
|
-
const ratioExecution = executionTime / total2;
|
|
146204
|
-
executionTime -= adjustedOverflow * ratioExecution;
|
|
146205
|
-
querySentTime = keepForSent;
|
|
146206
|
-
}
|
|
146207
|
-
const networkLatencyBefore = querySentTime / 2;
|
|
146208
|
-
const networkLatencyAfter = querySentTime / 2;
|
|
146209
|
-
const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
|
|
146210
|
-
const total = ms(querySentAt, queryCompletedAt);
|
|
146211
|
-
const calculatedTotal = networkLatencyBefore + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
|
|
146212
|
-
const errorMargin = Math.abs(total - calculatedTotal);
|
|
146213
|
-
return {
|
|
146214
|
-
networkLatencyBefore,
|
|
146215
|
-
planning: null,
|
|
146216
|
-
execution: executionTime,
|
|
146217
|
-
networkLatencyAfter,
|
|
146218
|
-
dataDownload: downloadTime,
|
|
146219
|
-
dataParse: parseTime,
|
|
146220
|
-
total,
|
|
146221
|
-
errorMargin,
|
|
146222
|
-
dataSize: bytesReceived
|
|
146223
|
-
};
|
|
146224
|
-
};
|
|
146225
|
-
const benchmarkProxy = async ({ sql, params }, repeats) => {
|
|
146226
|
-
const { createConnection: createConnection2 } = await import("mysql2");
|
|
146227
|
-
let startAt = 0n;
|
|
146228
|
-
let tcpConnectedAt = 0n;
|
|
146229
|
-
let tlsConnectedAt = null;
|
|
146230
|
-
const createStream = ({ config }) => {
|
|
146231
|
-
let stream;
|
|
146232
|
-
if (config.socketPath) {
|
|
146233
|
-
stream = net.connect(config.socketPath);
|
|
146234
|
-
} else {
|
|
146235
|
-
stream = net.connect(config.port, config.host);
|
|
146236
|
-
}
|
|
146237
|
-
if (config.enableKeepAlive) {
|
|
146238
|
-
stream.on("connect", () => {
|
|
146239
|
-
stream.setKeepAlive(true, config.keepAliveInitialDelay);
|
|
146240
|
-
});
|
|
146241
|
-
}
|
|
146242
|
-
stream.setNoDelay(true);
|
|
146243
|
-
stream.once("connect", () => {
|
|
146244
|
-
tcpConnectedAt = process.hrtime.bigint();
|
|
146245
|
-
});
|
|
146246
|
-
return stream;
|
|
146247
|
-
};
|
|
146248
|
-
startAt = process.hrtime.bigint();
|
|
146249
|
-
const connection2 = result2.url ? createConnection2({
|
|
146250
|
-
uri: result2.url,
|
|
146251
|
-
stream: createStream
|
|
146252
|
-
}) : createConnection2({
|
|
146253
|
-
...result2.credentials,
|
|
146254
|
-
stream: createStream
|
|
146255
|
-
});
|
|
146256
|
-
await new Promise((resolve2, reject) => {
|
|
146257
|
-
connection2.connect((err2) => {
|
|
146258
|
-
tlsConnectedAt = process.hrtime.bigint();
|
|
146259
|
-
if (err2) {
|
|
146260
|
-
reject(err2);
|
|
146261
|
-
} else {
|
|
146262
|
-
resolve2();
|
|
146263
|
-
}
|
|
146264
|
-
});
|
|
146265
|
-
});
|
|
146266
|
-
const results = [];
|
|
146267
|
-
for (let i7 = 0; i7 < repeats; i7++) {
|
|
146268
|
-
const r7 = await benchmarkQuery(connection2, sql, params);
|
|
146269
|
-
results.push(r7);
|
|
146270
|
-
}
|
|
146271
|
-
connection2.end();
|
|
146272
|
-
return {
|
|
146273
|
-
tcpHandshake: ms(startAt, tcpConnectedAt),
|
|
146274
|
-
tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
|
|
146275
|
-
dbHandshake: null,
|
|
146276
|
-
queries: results
|
|
146277
|
-
};
|
|
146278
|
-
};
|
|
146279
146167
|
return {
|
|
146280
146168
|
db: { query },
|
|
146281
146169
|
packageName: "mysql2",
|
|
146282
146170
|
proxy,
|
|
146283
146171
|
transactionProxy,
|
|
146284
|
-
benchmarkProxy,
|
|
146285
146172
|
database: result2.database,
|
|
146286
146173
|
migrate: migrateFn
|
|
146287
146174
|
};
|
|
@@ -146431,9 +146318,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146431
146318
|
migrate: migrateFn
|
|
146432
146319
|
};
|
|
146433
146320
|
}
|
|
146434
|
-
console.error(
|
|
146435
|
-
"To connect to MsSQL database - please install 'mssql' driver"
|
|
146436
|
-
);
|
|
146321
|
+
console.error("To connect to MsSQL database - please install 'mssql' driver");
|
|
146437
146322
|
process.exit(1);
|
|
146438
146323
|
};
|
|
146439
146324
|
prepareSqliteParams = (params, driver2) => {
|
|
@@ -146538,7 +146423,10 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146538
146423
|
await remoteCallback(query2, [], "run");
|
|
146539
146424
|
};
|
|
146540
146425
|
const proxy = async (params) => {
|
|
146541
|
-
const preparedParams = prepareSqliteParams(
|
|
146426
|
+
const preparedParams = prepareSqliteParams(
|
|
146427
|
+
params.params || [],
|
|
146428
|
+
"d1-http"
|
|
146429
|
+
);
|
|
146542
146430
|
const result2 = await remoteCallback(
|
|
146543
146431
|
params.sql,
|
|
146544
146432
|
preparedParams,
|
|
@@ -146763,17 +146651,19 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146763
146651
|
};
|
|
146764
146652
|
const transactionProxy = async (queries) => {
|
|
146765
146653
|
const results = [];
|
|
146766
|
-
const tx = sqlite.transaction(
|
|
146767
|
-
|
|
146768
|
-
|
|
146769
|
-
|
|
146770
|
-
|
|
146771
|
-
|
|
146772
|
-
|
|
146654
|
+
const tx = sqlite.transaction(
|
|
146655
|
+
(queries2) => {
|
|
146656
|
+
for (const query of queries2) {
|
|
146657
|
+
let result2 = [];
|
|
146658
|
+
if (query.method === "values" || query.method === "get" || query.method === "all") {
|
|
146659
|
+
result2 = sqlite.prepare(query.sql).all();
|
|
146660
|
+
} else {
|
|
146661
|
+
sqlite.prepare(query.sql).run();
|
|
146662
|
+
}
|
|
146663
|
+
results.push(result2);
|
|
146773
146664
|
}
|
|
146774
|
-
results.push(result2);
|
|
146775
146665
|
}
|
|
146776
|
-
|
|
146666
|
+
);
|
|
146777
146667
|
try {
|
|
146778
146668
|
tx(queries);
|
|
146779
146669
|
} catch (error3) {
|
|
@@ -146781,7 +146671,13 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146781
146671
|
}
|
|
146782
146672
|
return results;
|
|
146783
146673
|
};
|
|
146784
|
-
return {
|
|
146674
|
+
return {
|
|
146675
|
+
...db,
|
|
146676
|
+
packageName: "better-sqlite3",
|
|
146677
|
+
proxy,
|
|
146678
|
+
transactionProxy,
|
|
146679
|
+
migrate: migrateFn
|
|
146680
|
+
};
|
|
146785
146681
|
}
|
|
146786
146682
|
if (await checkPackage("bun")) {
|
|
146787
146683
|
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
@@ -148835,8 +148731,8 @@ ${sql}
|
|
|
148835
148731
|
`;
|
|
148836
148732
|
return content;
|
|
148837
148733
|
};
|
|
148838
|
-
prepareSnapshotFolderName = (
|
|
148839
|
-
const now =
|
|
148734
|
+
prepareSnapshotFolderName = (ms) => {
|
|
148735
|
+
const now = ms ? new Date(ms) : /* @__PURE__ */ new Date();
|
|
148840
148736
|
return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
|
|
148841
148737
|
now.getUTCDate()
|
|
148842
148738
|
)}${two(now.getUTCHours())}${two(now.getUTCMinutes())}${two(
|
|
@@ -152321,6 +152217,7 @@ var init_cors = __esm({
|
|
|
152321
152217
|
// src/cli/commands/studio.ts
|
|
152322
152218
|
var studio_exports = {};
|
|
152323
152219
|
__export(studio_exports, {
|
|
152220
|
+
drizzleForDuckDb: () => drizzleForDuckDb,
|
|
152324
152221
|
drizzleForLibSQL: () => drizzleForLibSQL,
|
|
152325
152222
|
drizzleForMySQL: () => drizzleForMySQL,
|
|
152326
152223
|
drizzleForPostgres: () => drizzleForPostgres,
|
|
@@ -152351,7 +152248,7 @@ import { getTableConfig as singlestoreTableConfig, SingleStoreTable } from "driz
|
|
|
152351
152248
|
import { getTableConfig as sqliteTableConfig, SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
152352
152249
|
import fs10 from "fs";
|
|
152353
152250
|
import { createServer } from "https";
|
|
152354
|
-
var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema,
|
|
152251
|
+
var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForDuckDb, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
|
|
152355
152252
|
var init_studio = __esm({
|
|
152356
152253
|
"src/cli/commands/studio.ts"() {
|
|
152357
152254
|
"use strict";
|
|
@@ -152565,7 +152462,6 @@ var init_studio = __esm({
|
|
|
152565
152462
|
packageName: db.packageName,
|
|
152566
152463
|
proxy: db.proxy,
|
|
152567
152464
|
transactionProxy: db.transactionProxy,
|
|
152568
|
-
benchmarkProxy: db.benchmarkProxy,
|
|
152569
152465
|
customDefaults,
|
|
152570
152466
|
schema: pgSchema2,
|
|
152571
152467
|
relations: relations2,
|
|
@@ -152573,9 +152469,26 @@ var init_studio = __esm({
|
|
|
152573
152469
|
casing: casing2
|
|
152574
152470
|
};
|
|
152575
152471
|
};
|
|
152472
|
+
drizzleForDuckDb = async (credentials) => {
|
|
152473
|
+
const { prepareDuckDb: prepareDuckDb2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
152474
|
+
const db = await prepareDuckDb2(credentials);
|
|
152475
|
+
const dbUrl = `duckdb://${credentials.url}`;
|
|
152476
|
+
const dbHash = createHash4("sha256").update(dbUrl).digest("hex");
|
|
152477
|
+
return {
|
|
152478
|
+
dbHash,
|
|
152479
|
+
dialect: "duckdb",
|
|
152480
|
+
driver: void 0,
|
|
152481
|
+
packageName: db.packageName,
|
|
152482
|
+
proxy: db.proxy,
|
|
152483
|
+
transactionProxy: db.transactionProxy,
|
|
152484
|
+
customDefaults: [],
|
|
152485
|
+
schema: {},
|
|
152486
|
+
relations: {}
|
|
152487
|
+
};
|
|
152488
|
+
};
|
|
152576
152489
|
drizzleForMySQL = async (credentials, mysqlSchema, relations2, schemaFiles, casing2) => {
|
|
152577
152490
|
const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
152578
|
-
const { proxy, transactionProxy,
|
|
152491
|
+
const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
|
|
152579
152492
|
const customDefaults = getCustomDefaults(mysqlSchema, casing2);
|
|
152580
152493
|
let dbUrl;
|
|
152581
152494
|
if ("url" in credentials) {
|
|
@@ -152591,7 +152504,6 @@ var init_studio = __esm({
|
|
|
152591
152504
|
databaseName: database,
|
|
152592
152505
|
proxy,
|
|
152593
152506
|
transactionProxy,
|
|
152594
|
-
benchmarkProxy,
|
|
152595
152507
|
customDefaults,
|
|
152596
152508
|
schema: mysqlSchema,
|
|
152597
152509
|
relations: relations2,
|
|
@@ -152761,23 +152673,6 @@ var init_studio = __esm({
|
|
|
152761
152673
|
]).optional()
|
|
152762
152674
|
}).array()
|
|
152763
152675
|
});
|
|
152764
|
-
benchmarkProxySchema = external_exports.object({
|
|
152765
|
-
type: external_exports.literal("bproxy"),
|
|
152766
|
-
data: external_exports.object({
|
|
152767
|
-
query: external_exports.object({
|
|
152768
|
-
sql: external_exports.string(),
|
|
152769
|
-
params: external_exports.array(external_exports.any()).optional(),
|
|
152770
|
-
method: external_exports.union([
|
|
152771
|
-
external_exports.literal("values"),
|
|
152772
|
-
external_exports.literal("get"),
|
|
152773
|
-
external_exports.literal("all"),
|
|
152774
|
-
external_exports.literal("run"),
|
|
152775
|
-
external_exports.literal("execute")
|
|
152776
|
-
]).optional()
|
|
152777
|
-
}),
|
|
152778
|
-
repeats: external_exports.number().min(1).optional()
|
|
152779
|
-
})
|
|
152780
|
-
});
|
|
152781
152676
|
defaultsSchema = external_exports.object({
|
|
152782
152677
|
type: external_exports.literal("defaults"),
|
|
152783
152678
|
data: external_exports.array(
|
|
@@ -152792,7 +152687,6 @@ var init_studio = __esm({
|
|
|
152792
152687
|
init2,
|
|
152793
152688
|
proxySchema,
|
|
152794
152689
|
transactionProxySchema,
|
|
152795
|
-
benchmarkProxySchema,
|
|
152796
152690
|
defaultsSchema
|
|
152797
152691
|
]);
|
|
152798
152692
|
jsonStringify = (data) => {
|
|
@@ -152815,7 +152709,6 @@ var init_studio = __esm({
|
|
|
152815
152709
|
databaseName,
|
|
152816
152710
|
proxy,
|
|
152817
152711
|
transactionProxy,
|
|
152818
|
-
benchmarkProxy,
|
|
152819
152712
|
customDefaults,
|
|
152820
152713
|
schema: drizzleSchema,
|
|
152821
152714
|
relations: relations2,
|
|
@@ -152879,7 +152772,7 @@ var init_studio = __esm({
|
|
|
152879
152772
|
console.warn("Error message:", error3.message);
|
|
152880
152773
|
}
|
|
152881
152774
|
return c6.json({
|
|
152882
|
-
version: "6.
|
|
152775
|
+
version: "6.2",
|
|
152883
152776
|
dialect: dialect6,
|
|
152884
152777
|
driver: driver2,
|
|
152885
152778
|
packageName,
|
|
@@ -152917,21 +152810,6 @@ var init_studio = __esm({
|
|
|
152917
152810
|
}
|
|
152918
152811
|
);
|
|
152919
152812
|
}
|
|
152920
|
-
if (type === "bproxy") {
|
|
152921
|
-
if (!benchmarkProxy) {
|
|
152922
|
-
throw new Error("Benchmark proxy is not configured for this database.");
|
|
152923
|
-
}
|
|
152924
|
-
const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
|
|
152925
|
-
const res = jsonStringify(result2);
|
|
152926
|
-
return c6.body(
|
|
152927
|
-
res,
|
|
152928
|
-
{
|
|
152929
|
-
headers: {
|
|
152930
|
-
"Content-Type": "application/json"
|
|
152931
|
-
}
|
|
152932
|
-
}
|
|
152933
|
-
);
|
|
152934
|
-
}
|
|
152935
152813
|
if (type === "defaults") {
|
|
152936
152814
|
const columns = body.data;
|
|
152937
152815
|
const result2 = columns.map((column8) => {
|