drizzle-kit 1.0.0-beta.2-4e5ecef → 1.0.0-beta.2-f9236e3
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 +417 -238
- package/api-postgres.mjs +417 -238
- package/api-sqlite.js +387 -200
- package/api-sqlite.mjs +387 -200
- package/bin.cjs +455 -347
- package/index.d.mts +1 -6
- package/index.d.ts +1 -6
- package/package.json +1 -3
package/api-postgres.mjs
CHANGED
|
@@ -15205,8 +15205,7 @@ var init_schemaValidator = __esm({
|
|
|
15205
15205
|
"singlestore",
|
|
15206
15206
|
"gel",
|
|
15207
15207
|
"mssql",
|
|
15208
|
-
"cockroach"
|
|
15209
|
-
"duckdb"
|
|
15208
|
+
"cockroach"
|
|
15210
15209
|
];
|
|
15211
15210
|
dialect = enumType(dialects);
|
|
15212
15211
|
}
|
|
@@ -25026,7 +25025,7 @@ var init_introspect = __esm({
|
|
|
25026
25025
|
let checksCount = 0;
|
|
25027
25026
|
let viewsCount = 0;
|
|
25028
25027
|
for (const seq of sequencesList) {
|
|
25029
|
-
const depend = dependList.find((it) =>
|
|
25028
|
+
const depend = dependList.find((it) => it.oid === seq.oid);
|
|
25030
25029
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
25031
25030
|
continue;
|
|
25032
25031
|
}
|
|
@@ -25092,22 +25091,22 @@ var init_introspect = __esm({
|
|
|
25092
25091
|
continue;
|
|
25093
25092
|
}
|
|
25094
25093
|
const expr = serialsList.find(
|
|
25095
|
-
(it) =>
|
|
25094
|
+
(it) => it.tableId === column8.tableId && it.ordinality === column8.ordinality
|
|
25096
25095
|
);
|
|
25097
25096
|
if (expr) {
|
|
25098
|
-
const table7 = tablesList.find((it) =>
|
|
25097
|
+
const table7 = tablesList.find((it) => it.oid === column8.tableId);
|
|
25099
25098
|
const isSerial = isSerialExpression(expr.expression, table7.schema);
|
|
25100
25099
|
column8.type = isSerial ? type === "bigint" ? "bigserial" : type === "integer" ? "serial" : "smallserial" : type;
|
|
25101
25100
|
}
|
|
25102
25101
|
}
|
|
25103
25102
|
for (const column8 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
25104
|
-
const table7 = tablesList.find((it) =>
|
|
25103
|
+
const table7 = tablesList.find((it) => it.oid === column8.tableId);
|
|
25105
25104
|
const enumType2 = column8.typeId in groupedEnums ? groupedEnums[column8.typeId] : column8.typeId in groupedArrEnums ? groupedArrEnums[column8.typeId] : null;
|
|
25106
25105
|
let columnTypeMapped = enumType2 ? enumType2.name : column8.type.replaceAll("[]", "");
|
|
25107
25106
|
columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char").replace("geometry(Point", "geometry(point");
|
|
25108
25107
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
|
25109
25108
|
const columnDefault = defaultsList.find(
|
|
25110
|
-
(it) =>
|
|
25109
|
+
(it) => it.tableId === column8.tableId && it.ordinality === column8.ordinality
|
|
25111
25110
|
);
|
|
25112
25111
|
const defaultValue = defaultForColumn(
|
|
25113
25112
|
columnTypeMapped,
|
|
@@ -25116,10 +25115,10 @@ var init_introspect = __esm({
|
|
|
25116
25115
|
Boolean(enumType2)
|
|
25117
25116
|
);
|
|
25118
25117
|
const unique = constraintsList.find((it) => {
|
|
25119
|
-
return it.type === "u" &&
|
|
25118
|
+
return it.type === "u" && it.tableId === column8.tableId && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column8.ordinality);
|
|
25120
25119
|
}) ?? null;
|
|
25121
25120
|
const pk = constraintsList.find((it) => {
|
|
25122
|
-
return it.type === "p" &&
|
|
25121
|
+
return it.type === "p" && it.tableId === column8.tableId && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column8.ordinality);
|
|
25123
25122
|
}) ?? null;
|
|
25124
25123
|
const metadata = column8.metadata;
|
|
25125
25124
|
if (column8.generatedType === "s" && (!metadata || !metadata.expression)) {
|
|
@@ -25134,7 +25133,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25134
25133
|
${JSON.stringify(column8.metadata)}`
|
|
25135
25134
|
);
|
|
25136
25135
|
}
|
|
25137
|
-
const sequence = metadata?.seqId ? sequencesList.find((it) =>
|
|
25136
|
+
const sequence = metadata?.seqId ? sequencesList.find((it) => it.oid === Number(metadata.seqId)) ?? null : null;
|
|
25138
25137
|
columns.push({
|
|
25139
25138
|
entityType: "columns",
|
|
25140
25139
|
schema: table7.schema,
|
|
@@ -25164,12 +25163,10 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25164
25163
|
});
|
|
25165
25164
|
}
|
|
25166
25165
|
for (const unique of constraintsList.filter((it) => it.type === "u")) {
|
|
25167
|
-
const table7 = tablesList.find((it) =>
|
|
25168
|
-
const schema6 = namespaces.find((it) =>
|
|
25166
|
+
const table7 = tablesList.find((it) => it.oid === unique.tableId);
|
|
25167
|
+
const schema6 = namespaces.find((it) => it.oid === unique.schemaId);
|
|
25169
25168
|
const columns2 = unique.columnsOrdinals.map((it) => {
|
|
25170
|
-
const column8 = columnsList.find(
|
|
25171
|
-
(column9) => Number(column9.tableId) === Number(unique.tableId) && column9.ordinality === it
|
|
25172
|
-
);
|
|
25169
|
+
const column8 = columnsList.find((column9) => column9.tableId === unique.tableId && column9.ordinality === it);
|
|
25173
25170
|
return column8.name;
|
|
25174
25171
|
});
|
|
25175
25172
|
uniques.push({
|
|
@@ -25183,12 +25180,10 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25183
25180
|
});
|
|
25184
25181
|
}
|
|
25185
25182
|
for (const pk of constraintsList.filter((it) => it.type === "p")) {
|
|
25186
|
-
const table7 = tablesList.find((it) =>
|
|
25187
|
-
const schema6 = namespaces.find((it) =>
|
|
25183
|
+
const table7 = tablesList.find((it) => it.oid === pk.tableId);
|
|
25184
|
+
const schema6 = namespaces.find((it) => it.oid === pk.schemaId);
|
|
25188
25185
|
const columns2 = pk.columnsOrdinals.map((it) => {
|
|
25189
|
-
const column8 = columnsList.find(
|
|
25190
|
-
(column9) => Number(column9.tableId) === Number(pk.tableId) && column9.ordinality === it
|
|
25191
|
-
);
|
|
25186
|
+
const column8 = columnsList.find((column9) => column9.tableId === pk.tableId && column9.ordinality === it);
|
|
25192
25187
|
return column8.name;
|
|
25193
25188
|
});
|
|
25194
25189
|
pks.push({
|
|
@@ -25201,19 +25196,15 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25201
25196
|
});
|
|
25202
25197
|
}
|
|
25203
25198
|
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) =>
|
|
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);
|
|
25207
25202
|
const columns2 = fk6.columnsOrdinals.map((it) => {
|
|
25208
|
-
const column8 = columnsList.find(
|
|
25209
|
-
(column9) => Number(column9.tableId) === Number(fk6.tableId) && column9.ordinality === it
|
|
25210
|
-
);
|
|
25203
|
+
const column8 = columnsList.find((column9) => column9.tableId === fk6.tableId && column9.ordinality === it);
|
|
25211
25204
|
return column8.name;
|
|
25212
25205
|
});
|
|
25213
25206
|
const columnsTo = fk6.columnsToOrdinals.map((it) => {
|
|
25214
|
-
const column8 = columnsList.find(
|
|
25215
|
-
(column9) => Number(column9.tableId) === Number(fk6.tableToId) && column9.ordinality === it
|
|
25216
|
-
);
|
|
25207
|
+
const column8 = columnsList.find((column9) => column9.tableId === fk6.tableToId && column9.ordinality === it);
|
|
25217
25208
|
return column8.name;
|
|
25218
25209
|
});
|
|
25219
25210
|
fks.push({
|
|
@@ -25231,8 +25222,8 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25231
25222
|
});
|
|
25232
25223
|
}
|
|
25233
25224
|
for (const check of constraintsList.filter((it) => it.type === "c")) {
|
|
25234
|
-
const table7 = tablesList.find((it) =>
|
|
25235
|
-
const schema6 = namespaces.find((it) =>
|
|
25225
|
+
const table7 = tablesList.find((it) => it.oid === check.tableId);
|
|
25226
|
+
const schema6 = namespaces.find((it) => it.oid === check.schemaId);
|
|
25236
25227
|
checks.push({
|
|
25237
25228
|
entityType: "checks",
|
|
25238
25229
|
schema: schema6.name,
|
|
@@ -25293,10 +25284,10 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25293
25284
|
});
|
|
25294
25285
|
for (const idx of idxs) {
|
|
25295
25286
|
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" &&
|
|
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);
|
|
25298
25289
|
const expr = splitExpressions(metadata.expression);
|
|
25299
|
-
const table7 = tablesList.find((it) =>
|
|
25290
|
+
const table7 = tablesList.find((it) => it.oid === idx.metadata.tableId);
|
|
25300
25291
|
const nonColumnsCount = metadata.columnOrdinals.reduce((acc, it) => {
|
|
25301
25292
|
if (it === 0) acc += 1;
|
|
25302
25293
|
return acc;
|
|
@@ -25328,7 +25319,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25328
25319
|
k6 += 1;
|
|
25329
25320
|
} else {
|
|
25330
25321
|
const column8 = columnsList.find((column9) => {
|
|
25331
|
-
return
|
|
25322
|
+
return column9.tableId === metadata.tableId && column9.ordinality === ordinal;
|
|
25332
25323
|
});
|
|
25333
25324
|
if (!column8) throw new Error(`missing column: ${metadata.tableId}:${ordinal}`);
|
|
25334
25325
|
const options = opts[i7];
|
|
@@ -25377,7 +25368,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25377
25368
|
progressCallback("indexes", indexesCount, "fetching");
|
|
25378
25369
|
progressCallback("tables", tableCount, "done");
|
|
25379
25370
|
for (const it of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
25380
|
-
const view6 = viewsList.find((x6) =>
|
|
25371
|
+
const view6 = viewsList.find((x6) => x6.oid === it.tableId);
|
|
25381
25372
|
const typeDimensions = it.type.split("[]").length - 1;
|
|
25382
25373
|
const enumType2 = it.typeId in groupedEnums ? groupedEnums[it.typeId] : it.typeId in groupedArrEnums ? groupedArrEnums[it.typeId] : null;
|
|
25383
25374
|
let columnTypeMapped = enumType2 ? enumType2.name : it.type.replace("[]", "");
|
|
@@ -25400,8 +25391,8 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25400
25391
|
}
|
|
25401
25392
|
for (const view6 of viewsList) {
|
|
25402
25393
|
tableCount += 1;
|
|
25403
|
-
const accessMethod =
|
|
25404
|
-
const tablespace =
|
|
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;
|
|
25405
25396
|
const definition = parseViewDefinition(view6.definition);
|
|
25406
25397
|
const withOpts = wrapRecord(
|
|
25407
25398
|
view6.options?.reduce((acc, it) => {
|
|
@@ -34440,7 +34431,7 @@ var require_websocket = __commonJS({
|
|
|
34440
34431
|
var EventEmitter = __require("events");
|
|
34441
34432
|
var https2 = __require("https");
|
|
34442
34433
|
var http3 = __require("http");
|
|
34443
|
-
var
|
|
34434
|
+
var net2 = __require("net");
|
|
34444
34435
|
var tls = __require("tls");
|
|
34445
34436
|
var { randomBytes, createHash: createHash5 } = __require("crypto");
|
|
34446
34437
|
var { Duplex, Readable: Readable6 } = __require("stream");
|
|
@@ -35171,12 +35162,12 @@ var require_websocket = __commonJS({
|
|
|
35171
35162
|
}
|
|
35172
35163
|
function netConnect(options) {
|
|
35173
35164
|
options.path = options.socketPath;
|
|
35174
|
-
return
|
|
35165
|
+
return net2.connect(options);
|
|
35175
35166
|
}
|
|
35176
35167
|
function tlsConnect(options) {
|
|
35177
35168
|
options.path = void 0;
|
|
35178
35169
|
if (!options.servername && options.servername !== "") {
|
|
35179
|
-
options.servername =
|
|
35170
|
+
options.servername = net2.isIP(options.host) ? "" : options.host;
|
|
35180
35171
|
}
|
|
35181
35172
|
return tls.connect(options);
|
|
35182
35173
|
}
|
|
@@ -39494,7 +39485,7 @@ var init_timing = __esm({
|
|
|
39494
39485
|
"../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
|
|
39495
39486
|
"use strict";
|
|
39496
39487
|
timing = {
|
|
39497
|
-
setTimeout: (cb,
|
|
39488
|
+
setTimeout: (cb, ms2) => setTimeout(cb, ms2),
|
|
39498
39489
|
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
39499
39490
|
};
|
|
39500
39491
|
}
|
|
@@ -41382,13 +41373,13 @@ var init_schema_date_utils = __esm({
|
|
|
41382
41373
|
if (!matches) {
|
|
41383
41374
|
throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
|
|
41384
41375
|
}
|
|
41385
|
-
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, ,
|
|
41376
|
+
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
|
|
41386
41377
|
range(monthStr, 1, 12);
|
|
41387
41378
|
range(dayStr, 1, 31);
|
|
41388
41379
|
range(hours, 0, 23);
|
|
41389
41380
|
range(minutes, 0, 59);
|
|
41390
41381
|
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(
|
|
41382
|
+
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
41383
|
date2.setUTCFullYear(Number(yearStr));
|
|
41393
41384
|
if (offsetStr.toUpperCase() != "Z") {
|
|
41394
41385
|
const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
|
|
@@ -61401,8 +61392,8 @@ var require_datetime2 = __commonJS({
|
|
|
61401
61392
|
if (!(object instanceof Date)) {
|
|
61402
61393
|
throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
|
|
61403
61394
|
}
|
|
61404
|
-
const
|
|
61405
|
-
const us =
|
|
61395
|
+
const ms2 = object.getTime() - TIMESHIFT;
|
|
61396
|
+
const us = ms2 * 1e3;
|
|
61406
61397
|
buf.writeInt32(8);
|
|
61407
61398
|
buf.writeInt64(us);
|
|
61408
61399
|
}
|
|
@@ -61412,12 +61403,12 @@ var require_datetime2 = __commonJS({
|
|
|
61412
61403
|
return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
|
|
61413
61404
|
}
|
|
61414
61405
|
const us = Number(buf.readBigInt64());
|
|
61415
|
-
let
|
|
61416
|
-
if (Math.abs(us % 1e3) === 500 && Math.abs(
|
|
61417
|
-
|
|
61406
|
+
let ms2 = Math.round(us / 1e3);
|
|
61407
|
+
if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
|
|
61408
|
+
ms2 -= 1;
|
|
61418
61409
|
}
|
|
61419
|
-
|
|
61420
|
-
return new Date(
|
|
61410
|
+
ms2 += TIMESHIFT;
|
|
61411
|
+
return new Date(ms2);
|
|
61421
61412
|
}
|
|
61422
61413
|
};
|
|
61423
61414
|
exports2.DateTimeCodec = DateTimeCodec;
|
|
@@ -61438,8 +61429,8 @@ var require_datetime2 = __commonJS({
|
|
|
61438
61429
|
if (!(object instanceof datetime_1.LocalDateTime)) {
|
|
61439
61430
|
throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
|
|
61440
61431
|
}
|
|
61441
|
-
const
|
|
61442
|
-
let us =
|
|
61432
|
+
const ms2 = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
|
|
61433
|
+
let us = ms2 * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
|
|
61443
61434
|
if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
|
|
61444
61435
|
us += 1n;
|
|
61445
61436
|
}
|
|
@@ -61453,13 +61444,13 @@ var require_datetime2 = __commonJS({
|
|
|
61453
61444
|
}
|
|
61454
61445
|
const bi_ms = bi_us / 1000n;
|
|
61455
61446
|
let us = Number(bi_us - bi_ms * 1000n);
|
|
61456
|
-
let
|
|
61447
|
+
let ms2 = Number(bi_ms);
|
|
61457
61448
|
if (us < 0) {
|
|
61458
61449
|
us += 1e3;
|
|
61459
|
-
|
|
61450
|
+
ms2 -= 1;
|
|
61460
61451
|
}
|
|
61461
|
-
|
|
61462
|
-
const date2 = new Date(
|
|
61452
|
+
ms2 += TIMESHIFT;
|
|
61453
|
+
const date2 = new Date(ms2);
|
|
61463
61454
|
return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
|
|
61464
61455
|
}
|
|
61465
61456
|
};
|
|
@@ -61521,13 +61512,13 @@ var require_datetime2 = __commonJS({
|
|
|
61521
61512
|
}
|
|
61522
61513
|
let us = Number(bius);
|
|
61523
61514
|
let seconds = Math.floor(us / 1e6);
|
|
61524
|
-
const
|
|
61525
|
-
us = us % 1e6 -
|
|
61515
|
+
const ms2 = Math.floor(us % 1e6 / 1e3);
|
|
61516
|
+
us = us % 1e6 - ms2 * 1e3;
|
|
61526
61517
|
let minutes = Math.floor(seconds / 60);
|
|
61527
61518
|
seconds = Math.floor(seconds % 60);
|
|
61528
61519
|
const hours = Math.floor(minutes / 60);
|
|
61529
61520
|
minutes = Math.floor(minutes % 60);
|
|
61530
|
-
return new datetime_1.LocalTime(hours, minutes, seconds,
|
|
61521
|
+
return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
|
|
61531
61522
|
}
|
|
61532
61523
|
};
|
|
61533
61524
|
exports2.LocalTimeCodec = LocalTimeCodec;
|
|
@@ -61604,14 +61595,14 @@ var require_datetime2 = __commonJS({
|
|
|
61604
61595
|
const biMillion = 1000000n;
|
|
61605
61596
|
const biSeconds = bius / biMillion;
|
|
61606
61597
|
let us = Number(bius - biSeconds * biMillion);
|
|
61607
|
-
const
|
|
61598
|
+
const ms2 = Math.floor(us / 1e3);
|
|
61608
61599
|
us = us % 1e3;
|
|
61609
61600
|
let seconds = Number(biSeconds);
|
|
61610
61601
|
let minutes = Math.floor(seconds / 60);
|
|
61611
61602
|
seconds = Math.floor(seconds % 60);
|
|
61612
61603
|
const hours = Math.floor(minutes / 60);
|
|
61613
61604
|
minutes = Math.floor(minutes % 60);
|
|
61614
|
-
return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2,
|
|
61605
|
+
return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
|
|
61615
61606
|
}
|
|
61616
61607
|
};
|
|
61617
61608
|
exports2.DurationCodec = DurationCodec;
|
|
@@ -61657,7 +61648,7 @@ var require_datetime2 = __commonJS({
|
|
|
61657
61648
|
const million = BigInt(1e6);
|
|
61658
61649
|
const biSeconds = bius / million;
|
|
61659
61650
|
let us = Number(bius - biSeconds * million);
|
|
61660
|
-
const
|
|
61651
|
+
const ms2 = Math.trunc(us / 1e3);
|
|
61661
61652
|
us = us % 1e3;
|
|
61662
61653
|
let seconds = Number(biSeconds);
|
|
61663
61654
|
let minutes = Math.trunc(seconds / 60);
|
|
@@ -61668,7 +61659,7 @@ var require_datetime2 = __commonJS({
|
|
|
61668
61659
|
days = Math.trunc(days % 7);
|
|
61669
61660
|
const years = Math.trunc(months2 / 12);
|
|
61670
61661
|
months2 = Math.trunc(months2 % 12);
|
|
61671
|
-
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2,
|
|
61662
|
+
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
|
|
61672
61663
|
}
|
|
61673
61664
|
};
|
|
61674
61665
|
exports2.RelativeDurationCodec = RelativeDurationCodec;
|
|
@@ -71832,41 +71823,41 @@ var require_ms = __commonJS({
|
|
|
71832
71823
|
return void 0;
|
|
71833
71824
|
}
|
|
71834
71825
|
}
|
|
71835
|
-
function fmtShort(
|
|
71836
|
-
var msAbs = Math.abs(
|
|
71826
|
+
function fmtShort(ms2) {
|
|
71827
|
+
var msAbs = Math.abs(ms2);
|
|
71837
71828
|
if (msAbs >= d6) {
|
|
71838
|
-
return Math.round(
|
|
71829
|
+
return Math.round(ms2 / d6) + "d";
|
|
71839
71830
|
}
|
|
71840
71831
|
if (msAbs >= h7) {
|
|
71841
|
-
return Math.round(
|
|
71832
|
+
return Math.round(ms2 / h7) + "h";
|
|
71842
71833
|
}
|
|
71843
71834
|
if (msAbs >= m7) {
|
|
71844
|
-
return Math.round(
|
|
71835
|
+
return Math.round(ms2 / m7) + "m";
|
|
71845
71836
|
}
|
|
71846
71837
|
if (msAbs >= s7) {
|
|
71847
|
-
return Math.round(
|
|
71838
|
+
return Math.round(ms2 / s7) + "s";
|
|
71848
71839
|
}
|
|
71849
|
-
return
|
|
71840
|
+
return ms2 + "ms";
|
|
71850
71841
|
}
|
|
71851
|
-
function fmtLong(
|
|
71852
|
-
var msAbs = Math.abs(
|
|
71842
|
+
function fmtLong(ms2) {
|
|
71843
|
+
var msAbs = Math.abs(ms2);
|
|
71853
71844
|
if (msAbs >= d6) {
|
|
71854
|
-
return plural2(
|
|
71845
|
+
return plural2(ms2, msAbs, d6, "day");
|
|
71855
71846
|
}
|
|
71856
71847
|
if (msAbs >= h7) {
|
|
71857
|
-
return plural2(
|
|
71848
|
+
return plural2(ms2, msAbs, h7, "hour");
|
|
71858
71849
|
}
|
|
71859
71850
|
if (msAbs >= m7) {
|
|
71860
|
-
return plural2(
|
|
71851
|
+
return plural2(ms2, msAbs, m7, "minute");
|
|
71861
71852
|
}
|
|
71862
71853
|
if (msAbs >= s7) {
|
|
71863
|
-
return plural2(
|
|
71854
|
+
return plural2(ms2, msAbs, s7, "second");
|
|
71864
71855
|
}
|
|
71865
|
-
return
|
|
71856
|
+
return ms2 + " ms";
|
|
71866
71857
|
}
|
|
71867
|
-
function plural2(
|
|
71858
|
+
function plural2(ms2, msAbs, n6, name) {
|
|
71868
71859
|
var isPlural = msAbs >= n6 * 1.5;
|
|
71869
|
-
return Math.round(
|
|
71860
|
+
return Math.round(ms2 / n6) + " " + name + (isPlural ? "s" : "");
|
|
71870
71861
|
}
|
|
71871
71862
|
}
|
|
71872
71863
|
});
|
|
@@ -71910,8 +71901,8 @@ var require_common2 = __commonJS({
|
|
|
71910
71901
|
}
|
|
71911
71902
|
const self2 = debug;
|
|
71912
71903
|
const curr = Number(/* @__PURE__ */ new Date());
|
|
71913
|
-
const
|
|
71914
|
-
self2.diff =
|
|
71904
|
+
const ms2 = curr - (prevTime || curr);
|
|
71905
|
+
self2.diff = ms2;
|
|
71915
71906
|
self2.prev = prevTime;
|
|
71916
71907
|
self2.curr = curr;
|
|
71917
71908
|
prevTime = curr;
|
|
@@ -87414,11 +87405,11 @@ var require_TokenExpiredError = __commonJS({
|
|
|
87414
87405
|
var require_timespan = __commonJS({
|
|
87415
87406
|
"../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module) {
|
|
87416
87407
|
"use strict";
|
|
87417
|
-
var
|
|
87408
|
+
var ms2 = require_ms();
|
|
87418
87409
|
module.exports = function(time2, iat) {
|
|
87419
87410
|
var timestamp = iat || Math.floor(Date.now() / 1e3);
|
|
87420
87411
|
if (typeof time2 === "string") {
|
|
87421
|
-
var milliseconds =
|
|
87412
|
+
var milliseconds = ms2(time2);
|
|
87422
87413
|
if (typeof milliseconds === "undefined") {
|
|
87423
87414
|
return;
|
|
87424
87415
|
}
|
|
@@ -101956,7 +101947,7 @@ var require_dist = __commonJS({
|
|
|
101956
101947
|
};
|
|
101957
101948
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
101958
101949
|
exports2.Agent = void 0;
|
|
101959
|
-
var
|
|
101950
|
+
var net2 = __importStar2(__require("net"));
|
|
101960
101951
|
var http3 = __importStar2(__require("http"));
|
|
101961
101952
|
var https_1 = __require("https");
|
|
101962
101953
|
__exportStar2(require_helpers2(), exports2);
|
|
@@ -101996,7 +101987,7 @@ var require_dist = __commonJS({
|
|
|
101996
101987
|
if (!this.sockets[name]) {
|
|
101997
101988
|
this.sockets[name] = [];
|
|
101998
101989
|
}
|
|
101999
|
-
const fakeSocket = new
|
|
101990
|
+
const fakeSocket = new net2.Socket({ writable: false });
|
|
102000
101991
|
this.sockets[name].push(fakeSocket);
|
|
102001
101992
|
this.totalSocketCount++;
|
|
102002
101993
|
return fakeSocket;
|
|
@@ -102208,7 +102199,7 @@ var require_dist2 = __commonJS({
|
|
|
102208
102199
|
};
|
|
102209
102200
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
102210
102201
|
exports2.HttpsProxyAgent = void 0;
|
|
102211
|
-
var
|
|
102202
|
+
var net2 = __importStar2(__require("net"));
|
|
102212
102203
|
var tls = __importStar2(__require("tls"));
|
|
102213
102204
|
var assert_1 = __importDefault2(__require("assert"));
|
|
102214
102205
|
var debug_1 = __importDefault2(require_src2());
|
|
@@ -102217,7 +102208,7 @@ var require_dist2 = __commonJS({
|
|
|
102217
102208
|
var parse_proxy_response_1 = require_parse_proxy_response();
|
|
102218
102209
|
var debug = (0, debug_1.default)("https-proxy-agent");
|
|
102219
102210
|
var setServernameFromNonIpHost = (options) => {
|
|
102220
|
-
if (options.servername === void 0 && options.host && !
|
|
102211
|
+
if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
|
|
102221
102212
|
return {
|
|
102222
102213
|
...options,
|
|
102223
102214
|
servername: options.host
|
|
@@ -102257,10 +102248,10 @@ var require_dist2 = __commonJS({
|
|
|
102257
102248
|
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
102258
102249
|
} else {
|
|
102259
102250
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
102260
|
-
socket =
|
|
102251
|
+
socket = net2.connect(this.connectOpts);
|
|
102261
102252
|
}
|
|
102262
102253
|
const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
|
|
102263
|
-
const host =
|
|
102254
|
+
const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
102264
102255
|
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
|
|
102265
102256
|
`;
|
|
102266
102257
|
if (proxy.username || proxy.password) {
|
|
@@ -102293,7 +102284,7 @@ var require_dist2 = __commonJS({
|
|
|
102293
102284
|
return socket;
|
|
102294
102285
|
}
|
|
102295
102286
|
socket.destroy();
|
|
102296
|
-
const fakeSocket = new
|
|
102287
|
+
const fakeSocket = new net2.Socket({ writable: false });
|
|
102297
102288
|
fakeSocket.readable = true;
|
|
102298
102289
|
req.once("socket", (s7) => {
|
|
102299
102290
|
debug("Replaying proxy buffer for failed request");
|
|
@@ -102358,7 +102349,7 @@ var require_dist3 = __commonJS({
|
|
|
102358
102349
|
};
|
|
102359
102350
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
102360
102351
|
exports2.HttpProxyAgent = void 0;
|
|
102361
|
-
var
|
|
102352
|
+
var net2 = __importStar2(__require("net"));
|
|
102362
102353
|
var tls = __importStar2(__require("tls"));
|
|
102363
102354
|
var debug_1 = __importDefault2(require_src2());
|
|
102364
102355
|
var events_1 = __require("events");
|
|
@@ -102431,7 +102422,7 @@ var require_dist3 = __commonJS({
|
|
|
102431
102422
|
socket = tls.connect(this.connectOpts);
|
|
102432
102423
|
} else {
|
|
102433
102424
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
102434
|
-
socket =
|
|
102425
|
+
socket = net2.connect(this.connectOpts);
|
|
102435
102426
|
}
|
|
102436
102427
|
await (0, events_1.once)(socket, "connect");
|
|
102437
102428
|
return socket;
|
|
@@ -141310,7 +141301,7 @@ var require_connection = __commonJS({
|
|
|
141310
141301
|
var _crypto = _interopRequireDefault(__require("crypto"));
|
|
141311
141302
|
var _os = _interopRequireDefault(__require("os"));
|
|
141312
141303
|
var tls = _interopRequireWildcard(__require("tls"));
|
|
141313
|
-
var
|
|
141304
|
+
var net2 = _interopRequireWildcard(__require("net"));
|
|
141314
141305
|
var _dns = _interopRequireDefault(__require("dns"));
|
|
141315
141306
|
var _constants = _interopRequireDefault(__require("constants"));
|
|
141316
141307
|
var _stream = __require("stream");
|
|
@@ -142359,7 +142350,7 @@ var require_connection = __commonJS({
|
|
|
142359
142350
|
async wrapWithTls(socket, signal) {
|
|
142360
142351
|
signal.throwIfAborted();
|
|
142361
142352
|
const secureContext = tls.createSecureContext(this.secureContextOptions);
|
|
142362
|
-
const serverName = !
|
|
142353
|
+
const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
|
|
142363
142354
|
const encryptOptions = {
|
|
142364
142355
|
host: this.config.server,
|
|
142365
142356
|
socket,
|
|
@@ -145265,10 +145256,10 @@ __export(connections_exports, {
|
|
|
145265
145256
|
connectToSQLite: () => connectToSQLite,
|
|
145266
145257
|
connectToSingleStore: () => connectToSingleStore,
|
|
145267
145258
|
prepareCockroach: () => prepareCockroach,
|
|
145268
|
-
prepareDuckDb: () => prepareDuckDb,
|
|
145269
145259
|
prepareGelDB: () => prepareGelDB,
|
|
145270
145260
|
preparePostgresDB: () => preparePostgresDB
|
|
145271
145261
|
});
|
|
145262
|
+
import net from "net";
|
|
145272
145263
|
function parseMssqlUrl(url) {
|
|
145273
145264
|
return {
|
|
145274
145265
|
user: url.username,
|
|
@@ -145282,7 +145273,7 @@ function parseMssqlUrl(url) {
|
|
|
145282
145273
|
}
|
|
145283
145274
|
};
|
|
145284
145275
|
}
|
|
145285
|
-
var normalisePGliteUrl, preparePostgresDB,
|
|
145276
|
+
var ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
|
|
145286
145277
|
var init_connections = __esm({
|
|
145287
145278
|
"src/cli/connections.ts"() {
|
|
145288
145279
|
"use strict";
|
|
@@ -145293,6 +145284,7 @@ var init_connections = __esm({
|
|
|
145293
145284
|
init_when_json_met_bigint();
|
|
145294
145285
|
init_utils3();
|
|
145295
145286
|
init_outputs();
|
|
145287
|
+
ms = (a6, b6) => Number(b6 - a6) / 1e6;
|
|
145296
145288
|
normalisePGliteUrl = (it) => {
|
|
145297
145289
|
if (it.startsWith("file:")) {
|
|
145298
145290
|
return it.substring(5);
|
|
@@ -145416,13 +145408,7 @@ var init_connections = __esm({
|
|
|
145416
145408
|
}
|
|
145417
145409
|
return results;
|
|
145418
145410
|
};
|
|
145419
|
-
return {
|
|
145420
|
-
packageName: "pglite",
|
|
145421
|
-
query,
|
|
145422
|
-
proxy,
|
|
145423
|
-
transactionProxy,
|
|
145424
|
-
migrate: migrateFn
|
|
145425
|
-
};
|
|
145411
|
+
return { packageName: "pglite", query, proxy, transactionProxy, migrate: migrateFn };
|
|
145426
145412
|
}
|
|
145427
145413
|
assertUnreachable(driver2);
|
|
145428
145414
|
}
|
|
@@ -145453,13 +145439,13 @@ var init_connections = __esm({
|
|
|
145453
145439
|
return pg.types.getTypeParser(typeId, format2);
|
|
145454
145440
|
}
|
|
145455
145441
|
};
|
|
145456
|
-
const
|
|
145457
|
-
const db = drizzle({ client });
|
|
145442
|
+
const pool = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
|
|
145443
|
+
const db = drizzle({ client: pool });
|
|
145458
145444
|
const migrateFn = async (config) => {
|
|
145459
145445
|
return migrate(db, config);
|
|
145460
145446
|
};
|
|
145461
145447
|
const query = async (sql, params) => {
|
|
145462
|
-
const result2 = await
|
|
145448
|
+
const result2 = await pool.query({
|
|
145463
145449
|
text: sql,
|
|
145464
145450
|
values: params ?? [],
|
|
145465
145451
|
types: types3
|
|
@@ -145469,7 +145455,7 @@ var init_connections = __esm({
|
|
|
145469
145455
|
return result2.rows;
|
|
145470
145456
|
};
|
|
145471
145457
|
const proxy = async (params) => {
|
|
145472
|
-
const result2 = await
|
|
145458
|
+
const result2 = await pool.query({
|
|
145473
145459
|
text: params.sql,
|
|
145474
145460
|
values: params.params,
|
|
145475
145461
|
...params.mode === "array" && { rowMode: "array" },
|
|
@@ -145481,7 +145467,7 @@ var init_connections = __esm({
|
|
|
145481
145467
|
};
|
|
145482
145468
|
const transactionProxy = async (queries) => {
|
|
145483
145469
|
const results = [];
|
|
145484
|
-
const tx = await
|
|
145470
|
+
const tx = await pool.connect();
|
|
145485
145471
|
try {
|
|
145486
145472
|
await tx.query("BEGIN");
|
|
145487
145473
|
for (const query2 of queries) {
|
|
@@ -145500,13 +145486,119 @@ var init_connections = __esm({
|
|
|
145500
145486
|
}
|
|
145501
145487
|
return results;
|
|
145502
145488
|
};
|
|
145503
|
-
|
|
145504
|
-
|
|
145505
|
-
|
|
145506
|
-
|
|
145507
|
-
|
|
145508
|
-
|
|
145489
|
+
const benchmarkQuery = async (client, sql, params) => {
|
|
145490
|
+
const explainResult = await pool.query({
|
|
145491
|
+
text: `EXPLAIN ANALYZE ${sql}`,
|
|
145492
|
+
values: params ?? [],
|
|
145493
|
+
types: types3
|
|
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
|
+
};
|
|
145509
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
|
+
};
|
|
145600
|
+
};
|
|
145601
|
+
return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
|
|
145510
145602
|
}
|
|
145511
145603
|
if (await checkPackage("postgres")) {
|
|
145512
145604
|
console.log(
|
|
@@ -145557,13 +145649,7 @@ var init_connections = __esm({
|
|
|
145557
145649
|
}
|
|
145558
145650
|
return results;
|
|
145559
145651
|
};
|
|
145560
|
-
return {
|
|
145561
|
-
packageName: "postgres",
|
|
145562
|
-
query,
|
|
145563
|
-
proxy,
|
|
145564
|
-
transactionProxy,
|
|
145565
|
-
migrate: migrateFn
|
|
145566
|
-
};
|
|
145652
|
+
return { packageName: "postgres", query, proxy, transactionProxy, migrate: migrateFn };
|
|
145567
145653
|
}
|
|
145568
145654
|
if (await checkPackage("@vercel/postgres")) {
|
|
145569
145655
|
console.log(
|
|
@@ -145644,13 +145730,7 @@ var init_connections = __esm({
|
|
|
145644
145730
|
}
|
|
145645
145731
|
return results;
|
|
145646
145732
|
};
|
|
145647
|
-
return {
|
|
145648
|
-
packageName: "@vercel/postgres",
|
|
145649
|
-
query,
|
|
145650
|
-
proxy,
|
|
145651
|
-
transactionProxy,
|
|
145652
|
-
migrate: migrateFn
|
|
145653
|
-
};
|
|
145733
|
+
return { packageName: "@vercel/postgres", query, proxy, transactionProxy, migrate: migrateFn };
|
|
145654
145734
|
}
|
|
145655
145735
|
if (await checkPackage("@neondatabase/serverless")) {
|
|
145656
145736
|
console.log(
|
|
@@ -145663,11 +145743,7 @@ var init_connections = __esm({
|
|
|
145663
145743
|
"'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
|
|
145664
145744
|
)
|
|
145665
145745
|
);
|
|
145666
|
-
const {
|
|
145667
|
-
Pool,
|
|
145668
|
-
neonConfig,
|
|
145669
|
-
types: pgTypes
|
|
145670
|
-
} = await import("@neondatabase/serverless");
|
|
145746
|
+
const { Pool, neonConfig, types: pgTypes } = await import("@neondatabase/serverless");
|
|
145671
145747
|
const { drizzle } = await import("drizzle-orm/neon-serverless");
|
|
145672
145748
|
const { migrate } = await import("drizzle-orm/neon-serverless/migrator");
|
|
145673
145749
|
const ssl = "ssl" in credentials ? credentials.ssl === "prefer" || credentials.ssl === "require" || credentials.ssl === "allow" ? { rejectUnauthorized: false } : credentials.ssl === "verify-full" ? {} : credentials.ssl : {};
|
|
@@ -145737,13 +145813,7 @@ var init_connections = __esm({
|
|
|
145737
145813
|
}
|
|
145738
145814
|
return results;
|
|
145739
145815
|
};
|
|
145740
|
-
return {
|
|
145741
|
-
packageName: "@neondatabase/serverless",
|
|
145742
|
-
query,
|
|
145743
|
-
proxy,
|
|
145744
|
-
transactionProxy,
|
|
145745
|
-
migrate: migrateFn
|
|
145746
|
-
};
|
|
145816
|
+
return { packageName: "@neondatabase/serverless", query, proxy, transactionProxy, migrate: migrateFn };
|
|
145747
145817
|
}
|
|
145748
145818
|
if (await checkPackage("bun")) {
|
|
145749
145819
|
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
@@ -145794,54 +145864,6 @@ var init_connections = __esm({
|
|
|
145794
145864
|
console.warn("For the 'bun' driver, run your script using: bun --bun");
|
|
145795
145865
|
process.exit(1);
|
|
145796
145866
|
};
|
|
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
145867
|
prepareCockroach = async (credentials) => {
|
|
145846
145868
|
if (await checkPackage("pg")) {
|
|
145847
145869
|
const { default: pg } = await import("pg");
|
|
@@ -145894,7 +145916,9 @@ var init_connections = __esm({
|
|
|
145894
145916
|
};
|
|
145895
145917
|
return { query, proxy, migrate: migrateFn };
|
|
145896
145918
|
}
|
|
145897
|
-
console.error(
|
|
145919
|
+
console.error(
|
|
145920
|
+
"To connect to Cockroach - please install 'pg' package"
|
|
145921
|
+
);
|
|
145898
145922
|
process.exit(1);
|
|
145899
145923
|
};
|
|
145900
145924
|
prepareGelDB = async (credentials) => {
|
|
@@ -145953,7 +145977,9 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
145953
145977
|
};
|
|
145954
145978
|
return { packageName: "gel", query, proxy, transactionProxy };
|
|
145955
145979
|
}
|
|
145956
|
-
console.error(
|
|
145980
|
+
console.error(
|
|
145981
|
+
"To connect to gel database - please install 'edgedb' driver"
|
|
145982
|
+
);
|
|
145957
145983
|
process.exit(1);
|
|
145958
145984
|
};
|
|
145959
145985
|
parseSingleStoreCredentials = (credentials) => {
|
|
@@ -146067,7 +146093,6 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146067
146093
|
}
|
|
146068
146094
|
return next();
|
|
146069
146095
|
};
|
|
146070
|
-
await connection.connect();
|
|
146071
146096
|
const query = async (sql, params) => {
|
|
146072
146097
|
const res = await connection.execute({
|
|
146073
146098
|
sql,
|
|
@@ -146107,11 +146132,156 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146107
146132
|
}
|
|
146108
146133
|
return results;
|
|
146109
146134
|
};
|
|
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
|
+
};
|
|
146110
146279
|
return {
|
|
146111
146280
|
db: { query },
|
|
146112
146281
|
packageName: "mysql2",
|
|
146113
146282
|
proxy,
|
|
146114
146283
|
transactionProxy,
|
|
146284
|
+
benchmarkProxy,
|
|
146115
146285
|
database: result2.database,
|
|
146116
146286
|
migrate: migrateFn
|
|
146117
146287
|
};
|
|
@@ -146261,7 +146431,9 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146261
146431
|
migrate: migrateFn
|
|
146262
146432
|
};
|
|
146263
146433
|
}
|
|
146264
|
-
console.error(
|
|
146434
|
+
console.error(
|
|
146435
|
+
"To connect to MsSQL database - please install 'mssql' driver"
|
|
146436
|
+
);
|
|
146265
146437
|
process.exit(1);
|
|
146266
146438
|
};
|
|
146267
146439
|
prepareSqliteParams = (params, driver2) => {
|
|
@@ -146366,10 +146538,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146366
146538
|
await remoteCallback(query2, [], "run");
|
|
146367
146539
|
};
|
|
146368
146540
|
const proxy = async (params) => {
|
|
146369
|
-
const preparedParams = prepareSqliteParams(
|
|
146370
|
-
params.params || [],
|
|
146371
|
-
"d1-http"
|
|
146372
|
-
);
|
|
146541
|
+
const preparedParams = prepareSqliteParams(params.params || [], "d1-http");
|
|
146373
146542
|
const result2 = await remoteCallback(
|
|
146374
146543
|
params.sql,
|
|
146375
146544
|
preparedParams,
|
|
@@ -146594,19 +146763,17 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146594
146763
|
};
|
|
146595
146764
|
const transactionProxy = async (queries) => {
|
|
146596
146765
|
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);
|
|
146766
|
+
const tx = sqlite.transaction((queries2) => {
|
|
146767
|
+
for (const query of queries2) {
|
|
146768
|
+
let result2 = [];
|
|
146769
|
+
if (query.method === "values" || query.method === "get" || query.method === "all") {
|
|
146770
|
+
result2 = sqlite.prepare(query.sql).all();
|
|
146771
|
+
} else {
|
|
146772
|
+
sqlite.prepare(query.sql).run();
|
|
146607
146773
|
}
|
|
146774
|
+
results.push(result2);
|
|
146608
146775
|
}
|
|
146609
|
-
);
|
|
146776
|
+
});
|
|
146610
146777
|
try {
|
|
146611
146778
|
tx(queries);
|
|
146612
146779
|
} catch (error3) {
|
|
@@ -146614,13 +146781,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146614
146781
|
}
|
|
146615
146782
|
return results;
|
|
146616
146783
|
};
|
|
146617
|
-
return {
|
|
146618
|
-
...db,
|
|
146619
|
-
packageName: "better-sqlite3",
|
|
146620
|
-
proxy,
|
|
146621
|
-
transactionProxy,
|
|
146622
|
-
migrate: migrateFn
|
|
146623
|
-
};
|
|
146784
|
+
return { ...db, packageName: "better-sqlite3", proxy, transactionProxy, migrate: migrateFn };
|
|
146624
146785
|
}
|
|
146625
146786
|
if (await checkPackage("bun")) {
|
|
146626
146787
|
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
@@ -148674,8 +148835,8 @@ ${sql}
|
|
|
148674
148835
|
`;
|
|
148675
148836
|
return content;
|
|
148676
148837
|
};
|
|
148677
|
-
prepareSnapshotFolderName = (
|
|
148678
|
-
const now =
|
|
148838
|
+
prepareSnapshotFolderName = (ms2) => {
|
|
148839
|
+
const now = ms2 ? new Date(ms2) : /* @__PURE__ */ new Date();
|
|
148679
148840
|
return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
|
|
148680
148841
|
now.getUTCDate()
|
|
148681
148842
|
)}${two(now.getUTCHours())}${two(now.getUTCMinutes())}${two(
|
|
@@ -152160,7 +152321,6 @@ var init_cors = __esm({
|
|
|
152160
152321
|
// src/cli/commands/studio.ts
|
|
152161
152322
|
var studio_exports = {};
|
|
152162
152323
|
__export(studio_exports, {
|
|
152163
|
-
drizzleForDuckDb: () => drizzleForDuckDb,
|
|
152164
152324
|
drizzleForLibSQL: () => drizzleForLibSQL,
|
|
152165
152325
|
drizzleForMySQL: () => drizzleForMySQL,
|
|
152166
152326
|
drizzleForPostgres: () => drizzleForPostgres,
|
|
@@ -152191,7 +152351,7 @@ import { getTableConfig as singlestoreTableConfig, SingleStoreTable } from "driz
|
|
|
152191
152351
|
import { getTableConfig as sqliteTableConfig, SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
152192
152352
|
import fs10 from "fs";
|
|
152193
152353
|
import { createServer } from "https";
|
|
152194
|
-
var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres,
|
|
152354
|
+
var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
|
|
152195
152355
|
var init_studio = __esm({
|
|
152196
152356
|
"src/cli/commands/studio.ts"() {
|
|
152197
152357
|
"use strict";
|
|
@@ -152405,6 +152565,7 @@ var init_studio = __esm({
|
|
|
152405
152565
|
packageName: db.packageName,
|
|
152406
152566
|
proxy: db.proxy,
|
|
152407
152567
|
transactionProxy: db.transactionProxy,
|
|
152568
|
+
benchmarkProxy: db.benchmarkProxy,
|
|
152408
152569
|
customDefaults,
|
|
152409
152570
|
schema: pgSchema2,
|
|
152410
152571
|
relations: relations2,
|
|
@@ -152412,26 +152573,9 @@ var init_studio = __esm({
|
|
|
152412
152573
|
casing: casing2
|
|
152413
152574
|
};
|
|
152414
152575
|
};
|
|
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
152576
|
drizzleForMySQL = async (credentials, mysqlSchema, relations2, schemaFiles, casing2) => {
|
|
152433
152577
|
const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
152434
|
-
const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
|
|
152578
|
+
const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);
|
|
152435
152579
|
const customDefaults = getCustomDefaults(mysqlSchema, casing2);
|
|
152436
152580
|
let dbUrl;
|
|
152437
152581
|
if ("url" in credentials) {
|
|
@@ -152447,6 +152591,7 @@ var init_studio = __esm({
|
|
|
152447
152591
|
databaseName: database,
|
|
152448
152592
|
proxy,
|
|
152449
152593
|
transactionProxy,
|
|
152594
|
+
benchmarkProxy,
|
|
152450
152595
|
customDefaults,
|
|
152451
152596
|
schema: mysqlSchema,
|
|
152452
152597
|
relations: relations2,
|
|
@@ -152616,6 +152761,23 @@ var init_studio = __esm({
|
|
|
152616
152761
|
]).optional()
|
|
152617
152762
|
}).array()
|
|
152618
152763
|
});
|
|
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
|
+
});
|
|
152619
152781
|
defaultsSchema = external_exports.object({
|
|
152620
152782
|
type: external_exports.literal("defaults"),
|
|
152621
152783
|
data: external_exports.array(
|
|
@@ -152630,6 +152792,7 @@ var init_studio = __esm({
|
|
|
152630
152792
|
init2,
|
|
152631
152793
|
proxySchema,
|
|
152632
152794
|
transactionProxySchema,
|
|
152795
|
+
benchmarkProxySchema,
|
|
152633
152796
|
defaultsSchema
|
|
152634
152797
|
]);
|
|
152635
152798
|
jsonStringify = (data) => {
|
|
@@ -152652,6 +152815,7 @@ var init_studio = __esm({
|
|
|
152652
152815
|
databaseName,
|
|
152653
152816
|
proxy,
|
|
152654
152817
|
transactionProxy,
|
|
152818
|
+
benchmarkProxy,
|
|
152655
152819
|
customDefaults,
|
|
152656
152820
|
schema: drizzleSchema,
|
|
152657
152821
|
relations: relations2,
|
|
@@ -152715,7 +152879,7 @@ var init_studio = __esm({
|
|
|
152715
152879
|
console.warn("Error message:", error3.message);
|
|
152716
152880
|
}
|
|
152717
152881
|
return c6.json({
|
|
152718
|
-
version: "6.
|
|
152882
|
+
version: "6.3",
|
|
152719
152883
|
dialect: dialect6,
|
|
152720
152884
|
driver: driver2,
|
|
152721
152885
|
packageName,
|
|
@@ -152753,6 +152917,21 @@ var init_studio = __esm({
|
|
|
152753
152917
|
}
|
|
152754
152918
|
);
|
|
152755
152919
|
}
|
|
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
|
+
}
|
|
152756
152935
|
if (type === "defaults") {
|
|
152757
152936
|
const columns = body.data;
|
|
152758
152937
|
const result2 = columns.map((column8) => {
|