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