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.js
CHANGED
|
@@ -7723,10 +7723,11 @@ var init_grammar = __esm({
|
|
|
7723
7723
|
return {
|
|
7724
7724
|
bool: (key) => {
|
|
7725
7725
|
if (key in it) {
|
|
7726
|
-
|
|
7726
|
+
const value = it[key];
|
|
7727
|
+
if (value === "true" || value === "1" || value === "on" || value === "yes") {
|
|
7727
7728
|
return true;
|
|
7728
7729
|
}
|
|
7729
|
-
if (
|
|
7730
|
+
if (value === "false" || value === "0" || value === "off" || value === "no") {
|
|
7730
7731
|
return false;
|
|
7731
7732
|
}
|
|
7732
7733
|
throw new Error(`Invalid options boolean value for ${key}: ${it[key]}`);
|
|
@@ -15199,8 +15200,7 @@ var init_schemaValidator = __esm({
|
|
|
15199
15200
|
"singlestore",
|
|
15200
15201
|
"gel",
|
|
15201
15202
|
"mssql",
|
|
15202
|
-
"cockroach"
|
|
15203
|
-
"duckdb"
|
|
15203
|
+
"cockroach"
|
|
15204
15204
|
];
|
|
15205
15205
|
dialect = enumType(dialects);
|
|
15206
15206
|
}
|
|
@@ -24990,7 +24990,7 @@ var init_introspect = __esm({
|
|
|
24990
24990
|
let checksCount = 0;
|
|
24991
24991
|
let viewsCount = 0;
|
|
24992
24992
|
for (const seq of sequencesList) {
|
|
24993
|
-
const depend = dependList.find((it) =>
|
|
24993
|
+
const depend = dependList.find((it) => it.oid === seq.oid);
|
|
24994
24994
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
24995
24995
|
continue;
|
|
24996
24996
|
}
|
|
@@ -25056,22 +25056,22 @@ var init_introspect = __esm({
|
|
|
25056
25056
|
continue;
|
|
25057
25057
|
}
|
|
25058
25058
|
const expr = serialsList.find(
|
|
25059
|
-
(it) =>
|
|
25059
|
+
(it) => it.tableId === column8.tableId && it.ordinality === column8.ordinality
|
|
25060
25060
|
);
|
|
25061
25061
|
if (expr) {
|
|
25062
|
-
const table7 = tablesList.find((it) =>
|
|
25062
|
+
const table7 = tablesList.find((it) => it.oid === column8.tableId);
|
|
25063
25063
|
const isSerial = isSerialExpression(expr.expression, table7.schema);
|
|
25064
25064
|
column8.type = isSerial ? type === "bigint" ? "bigserial" : type === "integer" ? "serial" : "smallserial" : type;
|
|
25065
25065
|
}
|
|
25066
25066
|
}
|
|
25067
25067
|
for (const column8 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
25068
|
-
const table7 = tablesList.find((it) =>
|
|
25068
|
+
const table7 = tablesList.find((it) => it.oid === column8.tableId);
|
|
25069
25069
|
const enumType2 = column8.typeId in groupedEnums ? groupedEnums[column8.typeId] : column8.typeId in groupedArrEnums ? groupedArrEnums[column8.typeId] : null;
|
|
25070
25070
|
let columnTypeMapped = enumType2 ? enumType2.name : column8.type.replaceAll("[]", "");
|
|
25071
25071
|
columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char").replace("geometry(Point", "geometry(point");
|
|
25072
25072
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
|
25073
25073
|
const columnDefault = defaultsList.find(
|
|
25074
|
-
(it) =>
|
|
25074
|
+
(it) => it.tableId === column8.tableId && it.ordinality === column8.ordinality
|
|
25075
25075
|
);
|
|
25076
25076
|
const defaultValue = defaultForColumn(
|
|
25077
25077
|
columnTypeMapped,
|
|
@@ -25080,10 +25080,10 @@ var init_introspect = __esm({
|
|
|
25080
25080
|
Boolean(enumType2)
|
|
25081
25081
|
);
|
|
25082
25082
|
const unique = constraintsList.find((it) => {
|
|
25083
|
-
return it.type === "u" &&
|
|
25083
|
+
return it.type === "u" && it.tableId === column8.tableId && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column8.ordinality);
|
|
25084
25084
|
}) ?? null;
|
|
25085
25085
|
const pk = constraintsList.find((it) => {
|
|
25086
|
-
return it.type === "p" &&
|
|
25086
|
+
return it.type === "p" && it.tableId === column8.tableId && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column8.ordinality);
|
|
25087
25087
|
}) ?? null;
|
|
25088
25088
|
const metadata = column8.metadata;
|
|
25089
25089
|
if (column8.generatedType === "s" && (!metadata || !metadata.expression)) {
|
|
@@ -25098,7 +25098,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25098
25098
|
${JSON.stringify(column8.metadata)}`
|
|
25099
25099
|
);
|
|
25100
25100
|
}
|
|
25101
|
-
const sequence = metadata?.seqId ? sequencesList.find((it) =>
|
|
25101
|
+
const sequence = metadata?.seqId ? sequencesList.find((it) => it.oid === Number(metadata.seqId)) ?? null : null;
|
|
25102
25102
|
columns.push({
|
|
25103
25103
|
entityType: "columns",
|
|
25104
25104
|
schema: table7.schema,
|
|
@@ -25128,12 +25128,10 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25128
25128
|
});
|
|
25129
25129
|
}
|
|
25130
25130
|
for (const unique of constraintsList.filter((it) => it.type === "u")) {
|
|
25131
|
-
const table7 = tablesList.find((it) =>
|
|
25132
|
-
const schema6 = namespaces.find((it) =>
|
|
25131
|
+
const table7 = tablesList.find((it) => it.oid === unique.tableId);
|
|
25132
|
+
const schema6 = namespaces.find((it) => it.oid === unique.schemaId);
|
|
25133
25133
|
const columns2 = unique.columnsOrdinals.map((it) => {
|
|
25134
|
-
const column8 = columnsList.find(
|
|
25135
|
-
(column9) => Number(column9.tableId) === Number(unique.tableId) && column9.ordinality === it
|
|
25136
|
-
);
|
|
25134
|
+
const column8 = columnsList.find((column9) => column9.tableId === unique.tableId && column9.ordinality === it);
|
|
25137
25135
|
return column8.name;
|
|
25138
25136
|
});
|
|
25139
25137
|
uniques.push({
|
|
@@ -25147,12 +25145,10 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25147
25145
|
});
|
|
25148
25146
|
}
|
|
25149
25147
|
for (const pk of constraintsList.filter((it) => it.type === "p")) {
|
|
25150
|
-
const table7 = tablesList.find((it) =>
|
|
25151
|
-
const schema6 = namespaces.find((it) =>
|
|
25148
|
+
const table7 = tablesList.find((it) => it.oid === pk.tableId);
|
|
25149
|
+
const schema6 = namespaces.find((it) => it.oid === pk.schemaId);
|
|
25152
25150
|
const columns2 = pk.columnsOrdinals.map((it) => {
|
|
25153
|
-
const column8 = columnsList.find(
|
|
25154
|
-
(column9) => Number(column9.tableId) === Number(pk.tableId) && column9.ordinality === it
|
|
25155
|
-
);
|
|
25151
|
+
const column8 = columnsList.find((column9) => column9.tableId === pk.tableId && column9.ordinality === it);
|
|
25156
25152
|
return column8.name;
|
|
25157
25153
|
});
|
|
25158
25154
|
pks.push({
|
|
@@ -25165,19 +25161,15 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25165
25161
|
});
|
|
25166
25162
|
}
|
|
25167
25163
|
for (const fk6 of constraintsList.filter((it) => it.type === "f")) {
|
|
25168
|
-
const table7 = tablesList.find((it) =>
|
|
25169
|
-
const schema6 = namespaces.find((it) =>
|
|
25170
|
-
const tableTo = tablesList.find((it) =>
|
|
25164
|
+
const table7 = tablesList.find((it) => it.oid === fk6.tableId);
|
|
25165
|
+
const schema6 = namespaces.find((it) => it.oid === fk6.schemaId);
|
|
25166
|
+
const tableTo = tablesList.find((it) => it.oid === fk6.tableToId);
|
|
25171
25167
|
const columns2 = fk6.columnsOrdinals.map((it) => {
|
|
25172
|
-
const column8 = columnsList.find(
|
|
25173
|
-
(column9) => Number(column9.tableId) === Number(fk6.tableId) && column9.ordinality === it
|
|
25174
|
-
);
|
|
25168
|
+
const column8 = columnsList.find((column9) => column9.tableId === fk6.tableId && column9.ordinality === it);
|
|
25175
25169
|
return column8.name;
|
|
25176
25170
|
});
|
|
25177
25171
|
const columnsTo = fk6.columnsToOrdinals.map((it) => {
|
|
25178
|
-
const column8 = columnsList.find(
|
|
25179
|
-
(column9) => Number(column9.tableId) === Number(fk6.tableToId) && column9.ordinality === it
|
|
25180
|
-
);
|
|
25172
|
+
const column8 = columnsList.find((column9) => column9.tableId === fk6.tableToId && column9.ordinality === it);
|
|
25181
25173
|
return column8.name;
|
|
25182
25174
|
});
|
|
25183
25175
|
fks.push({
|
|
@@ -25195,8 +25187,8 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25195
25187
|
});
|
|
25196
25188
|
}
|
|
25197
25189
|
for (const check of constraintsList.filter((it) => it.type === "c")) {
|
|
25198
|
-
const table7 = tablesList.find((it) =>
|
|
25199
|
-
const schema6 = namespaces.find((it) =>
|
|
25190
|
+
const table7 = tablesList.find((it) => it.oid === check.tableId);
|
|
25191
|
+
const schema6 = namespaces.find((it) => it.oid === check.schemaId);
|
|
25200
25192
|
checks.push({
|
|
25201
25193
|
entityType: "checks",
|
|
25202
25194
|
schema: schema6.name,
|
|
@@ -25257,10 +25249,10 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25257
25249
|
});
|
|
25258
25250
|
for (const idx of idxs) {
|
|
25259
25251
|
const { metadata } = idx;
|
|
25260
|
-
const forUnique = metadata.isUnique && constraintsList.some((x6) => x6.type === "u" &&
|
|
25261
|
-
const forPK = metadata.isPrimary && constraintsList.some((x6) => x6.type === "p" &&
|
|
25252
|
+
const forUnique = metadata.isUnique && constraintsList.some((x6) => x6.type === "u" && x6.indexId === idx.oid);
|
|
25253
|
+
const forPK = metadata.isPrimary && constraintsList.some((x6) => x6.type === "p" && x6.indexId === idx.oid);
|
|
25262
25254
|
const expr = splitExpressions(metadata.expression);
|
|
25263
|
-
const table7 = tablesList.find((it) =>
|
|
25255
|
+
const table7 = tablesList.find((it) => it.oid === idx.metadata.tableId);
|
|
25264
25256
|
const nonColumnsCount = metadata.columnOrdinals.reduce((acc, it) => {
|
|
25265
25257
|
if (it === 0) acc += 1;
|
|
25266
25258
|
return acc;
|
|
@@ -25292,7 +25284,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25292
25284
|
k6 += 1;
|
|
25293
25285
|
} else {
|
|
25294
25286
|
const column8 = columnsList.find((column9) => {
|
|
25295
|
-
return
|
|
25287
|
+
return column9.tableId === metadata.tableId && column9.ordinality === ordinal;
|
|
25296
25288
|
});
|
|
25297
25289
|
if (!column8) throw new Error(`missing column: ${metadata.tableId}:${ordinal}`);
|
|
25298
25290
|
const options = opts[i7];
|
|
@@ -25341,7 +25333,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25341
25333
|
progressCallback("indexes", indexesCount, "fetching");
|
|
25342
25334
|
progressCallback("tables", tableCount, "done");
|
|
25343
25335
|
for (const it of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
25344
|
-
const view6 = viewsList.find((x6) =>
|
|
25336
|
+
const view6 = viewsList.find((x6) => x6.oid === it.tableId);
|
|
25345
25337
|
const typeDimensions = it.type.split("[]").length - 1;
|
|
25346
25338
|
const enumType2 = it.typeId in groupedEnums ? groupedEnums[it.typeId] : it.typeId in groupedArrEnums ? groupedArrEnums[it.typeId] : null;
|
|
25347
25339
|
let columnTypeMapped = enumType2 ? enumType2.name : it.type.replace("[]", "");
|
|
@@ -25364,8 +25356,8 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25364
25356
|
}
|
|
25365
25357
|
for (const view6 of viewsList) {
|
|
25366
25358
|
tableCount += 1;
|
|
25367
|
-
const accessMethod =
|
|
25368
|
-
const tablespace =
|
|
25359
|
+
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it) => it.oid === view6.accessMethod);
|
|
25360
|
+
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it) => it.oid === view6.tablespaceid).name;
|
|
25369
25361
|
const definition = parseViewDefinition(view6.definition);
|
|
25370
25362
|
const withOpts = wrapRecord(
|
|
25371
25363
|
view6.options?.reduce((acc, it) => {
|
|
@@ -34404,7 +34396,7 @@ var require_websocket = __commonJS({
|
|
|
34404
34396
|
var EventEmitter = require("events");
|
|
34405
34397
|
var https2 = require("https");
|
|
34406
34398
|
var http3 = require("http");
|
|
34407
|
-
var
|
|
34399
|
+
var net2 = require("net");
|
|
34408
34400
|
var tls = require("tls");
|
|
34409
34401
|
var { randomBytes, createHash: createHash5 } = require("crypto");
|
|
34410
34402
|
var { Duplex, Readable: Readable6 } = require("stream");
|
|
@@ -35135,12 +35127,12 @@ var require_websocket = __commonJS({
|
|
|
35135
35127
|
}
|
|
35136
35128
|
function netConnect(options) {
|
|
35137
35129
|
options.path = options.socketPath;
|
|
35138
|
-
return
|
|
35130
|
+
return net2.connect(options);
|
|
35139
35131
|
}
|
|
35140
35132
|
function tlsConnect(options) {
|
|
35141
35133
|
options.path = void 0;
|
|
35142
35134
|
if (!options.servername && options.servername !== "") {
|
|
35143
|
-
options.servername =
|
|
35135
|
+
options.servername = net2.isIP(options.host) ? "" : options.host;
|
|
35144
35136
|
}
|
|
35145
35137
|
return tls.connect(options);
|
|
35146
35138
|
}
|
|
@@ -39459,7 +39451,7 @@ var init_timing = __esm({
|
|
|
39459
39451
|
"../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
|
|
39460
39452
|
"use strict";
|
|
39461
39453
|
timing = {
|
|
39462
|
-
setTimeout: (cb,
|
|
39454
|
+
setTimeout: (cb, ms2) => setTimeout(cb, ms2),
|
|
39463
39455
|
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
39464
39456
|
};
|
|
39465
39457
|
}
|
|
@@ -41347,13 +41339,13 @@ var init_schema_date_utils = __esm({
|
|
|
41347
41339
|
if (!matches) {
|
|
41348
41340
|
throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
|
|
41349
41341
|
}
|
|
41350
|
-
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, ,
|
|
41342
|
+
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
|
|
41351
41343
|
range(monthStr, 1, 12);
|
|
41352
41344
|
range(dayStr, 1, 31);
|
|
41353
41345
|
range(hours, 0, 23);
|
|
41354
41346
|
range(minutes, 0, 59);
|
|
41355
41347
|
range(seconds, 0, 60);
|
|
41356
|
-
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(
|
|
41348
|
+
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));
|
|
41357
41349
|
date2.setUTCFullYear(Number(yearStr));
|
|
41358
41350
|
if (offsetStr.toUpperCase() != "Z") {
|
|
41359
41351
|
const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
|
|
@@ -61367,8 +61359,8 @@ var require_datetime2 = __commonJS({
|
|
|
61367
61359
|
if (!(object instanceof Date)) {
|
|
61368
61360
|
throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
|
|
61369
61361
|
}
|
|
61370
|
-
const
|
|
61371
|
-
const us =
|
|
61362
|
+
const ms2 = object.getTime() - TIMESHIFT;
|
|
61363
|
+
const us = ms2 * 1e3;
|
|
61372
61364
|
buf.writeInt32(8);
|
|
61373
61365
|
buf.writeInt64(us);
|
|
61374
61366
|
}
|
|
@@ -61378,12 +61370,12 @@ var require_datetime2 = __commonJS({
|
|
|
61378
61370
|
return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
|
|
61379
61371
|
}
|
|
61380
61372
|
const us = Number(buf.readBigInt64());
|
|
61381
|
-
let
|
|
61382
|
-
if (Math.abs(us % 1e3) === 500 && Math.abs(
|
|
61383
|
-
|
|
61373
|
+
let ms2 = Math.round(us / 1e3);
|
|
61374
|
+
if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
|
|
61375
|
+
ms2 -= 1;
|
|
61384
61376
|
}
|
|
61385
|
-
|
|
61386
|
-
return new Date(
|
|
61377
|
+
ms2 += TIMESHIFT;
|
|
61378
|
+
return new Date(ms2);
|
|
61387
61379
|
}
|
|
61388
61380
|
};
|
|
61389
61381
|
exports2.DateTimeCodec = DateTimeCodec;
|
|
@@ -61404,8 +61396,8 @@ var require_datetime2 = __commonJS({
|
|
|
61404
61396
|
if (!(object instanceof datetime_1.LocalDateTime)) {
|
|
61405
61397
|
throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
|
|
61406
61398
|
}
|
|
61407
|
-
const
|
|
61408
|
-
let us =
|
|
61399
|
+
const ms2 = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
|
|
61400
|
+
let us = ms2 * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
|
|
61409
61401
|
if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
|
|
61410
61402
|
us += 1n;
|
|
61411
61403
|
}
|
|
@@ -61419,13 +61411,13 @@ var require_datetime2 = __commonJS({
|
|
|
61419
61411
|
}
|
|
61420
61412
|
const bi_ms = bi_us / 1000n;
|
|
61421
61413
|
let us = Number(bi_us - bi_ms * 1000n);
|
|
61422
|
-
let
|
|
61414
|
+
let ms2 = Number(bi_ms);
|
|
61423
61415
|
if (us < 0) {
|
|
61424
61416
|
us += 1e3;
|
|
61425
|
-
|
|
61417
|
+
ms2 -= 1;
|
|
61426
61418
|
}
|
|
61427
|
-
|
|
61428
|
-
const date2 = new Date(
|
|
61419
|
+
ms2 += TIMESHIFT;
|
|
61420
|
+
const date2 = new Date(ms2);
|
|
61429
61421
|
return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
|
|
61430
61422
|
}
|
|
61431
61423
|
};
|
|
@@ -61487,13 +61479,13 @@ var require_datetime2 = __commonJS({
|
|
|
61487
61479
|
}
|
|
61488
61480
|
let us = Number(bius);
|
|
61489
61481
|
let seconds = Math.floor(us / 1e6);
|
|
61490
|
-
const
|
|
61491
|
-
us = us % 1e6 -
|
|
61482
|
+
const ms2 = Math.floor(us % 1e6 / 1e3);
|
|
61483
|
+
us = us % 1e6 - ms2 * 1e3;
|
|
61492
61484
|
let minutes = Math.floor(seconds / 60);
|
|
61493
61485
|
seconds = Math.floor(seconds % 60);
|
|
61494
61486
|
const hours = Math.floor(minutes / 60);
|
|
61495
61487
|
minutes = Math.floor(minutes % 60);
|
|
61496
|
-
return new datetime_1.LocalTime(hours, minutes, seconds,
|
|
61488
|
+
return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
|
|
61497
61489
|
}
|
|
61498
61490
|
};
|
|
61499
61491
|
exports2.LocalTimeCodec = LocalTimeCodec;
|
|
@@ -61570,14 +61562,14 @@ var require_datetime2 = __commonJS({
|
|
|
61570
61562
|
const biMillion = 1000000n;
|
|
61571
61563
|
const biSeconds = bius / biMillion;
|
|
61572
61564
|
let us = Number(bius - biSeconds * biMillion);
|
|
61573
|
-
const
|
|
61565
|
+
const ms2 = Math.floor(us / 1e3);
|
|
61574
61566
|
us = us % 1e3;
|
|
61575
61567
|
let seconds = Number(biSeconds);
|
|
61576
61568
|
let minutes = Math.floor(seconds / 60);
|
|
61577
61569
|
seconds = Math.floor(seconds % 60);
|
|
61578
61570
|
const hours = Math.floor(minutes / 60);
|
|
61579
61571
|
minutes = Math.floor(minutes % 60);
|
|
61580
|
-
return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2,
|
|
61572
|
+
return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
|
|
61581
61573
|
}
|
|
61582
61574
|
};
|
|
61583
61575
|
exports2.DurationCodec = DurationCodec;
|
|
@@ -61623,7 +61615,7 @@ var require_datetime2 = __commonJS({
|
|
|
61623
61615
|
const million = BigInt(1e6);
|
|
61624
61616
|
const biSeconds = bius / million;
|
|
61625
61617
|
let us = Number(bius - biSeconds * million);
|
|
61626
|
-
const
|
|
61618
|
+
const ms2 = Math.trunc(us / 1e3);
|
|
61627
61619
|
us = us % 1e3;
|
|
61628
61620
|
let seconds = Number(biSeconds);
|
|
61629
61621
|
let minutes = Math.trunc(seconds / 60);
|
|
@@ -61634,7 +61626,7 @@ var require_datetime2 = __commonJS({
|
|
|
61634
61626
|
days = Math.trunc(days % 7);
|
|
61635
61627
|
const years = Math.trunc(months2 / 12);
|
|
61636
61628
|
months2 = Math.trunc(months2 % 12);
|
|
61637
|
-
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2,
|
|
61629
|
+
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
|
|
61638
61630
|
}
|
|
61639
61631
|
};
|
|
61640
61632
|
exports2.RelativeDurationCodec = RelativeDurationCodec;
|
|
@@ -71798,41 +71790,41 @@ var require_ms = __commonJS({
|
|
|
71798
71790
|
return void 0;
|
|
71799
71791
|
}
|
|
71800
71792
|
}
|
|
71801
|
-
function fmtShort(
|
|
71802
|
-
var msAbs = Math.abs(
|
|
71793
|
+
function fmtShort(ms2) {
|
|
71794
|
+
var msAbs = Math.abs(ms2);
|
|
71803
71795
|
if (msAbs >= d6) {
|
|
71804
|
-
return Math.round(
|
|
71796
|
+
return Math.round(ms2 / d6) + "d";
|
|
71805
71797
|
}
|
|
71806
71798
|
if (msAbs >= h7) {
|
|
71807
|
-
return Math.round(
|
|
71799
|
+
return Math.round(ms2 / h7) + "h";
|
|
71808
71800
|
}
|
|
71809
71801
|
if (msAbs >= m7) {
|
|
71810
|
-
return Math.round(
|
|
71802
|
+
return Math.round(ms2 / m7) + "m";
|
|
71811
71803
|
}
|
|
71812
71804
|
if (msAbs >= s7) {
|
|
71813
|
-
return Math.round(
|
|
71805
|
+
return Math.round(ms2 / s7) + "s";
|
|
71814
71806
|
}
|
|
71815
|
-
return
|
|
71807
|
+
return ms2 + "ms";
|
|
71816
71808
|
}
|
|
71817
|
-
function fmtLong(
|
|
71818
|
-
var msAbs = Math.abs(
|
|
71809
|
+
function fmtLong(ms2) {
|
|
71810
|
+
var msAbs = Math.abs(ms2);
|
|
71819
71811
|
if (msAbs >= d6) {
|
|
71820
|
-
return plural2(
|
|
71812
|
+
return plural2(ms2, msAbs, d6, "day");
|
|
71821
71813
|
}
|
|
71822
71814
|
if (msAbs >= h7) {
|
|
71823
|
-
return plural2(
|
|
71815
|
+
return plural2(ms2, msAbs, h7, "hour");
|
|
71824
71816
|
}
|
|
71825
71817
|
if (msAbs >= m7) {
|
|
71826
|
-
return plural2(
|
|
71818
|
+
return plural2(ms2, msAbs, m7, "minute");
|
|
71827
71819
|
}
|
|
71828
71820
|
if (msAbs >= s7) {
|
|
71829
|
-
return plural2(
|
|
71821
|
+
return plural2(ms2, msAbs, s7, "second");
|
|
71830
71822
|
}
|
|
71831
|
-
return
|
|
71823
|
+
return ms2 + " ms";
|
|
71832
71824
|
}
|
|
71833
|
-
function plural2(
|
|
71825
|
+
function plural2(ms2, msAbs, n6, name) {
|
|
71834
71826
|
var isPlural = msAbs >= n6 * 1.5;
|
|
71835
|
-
return Math.round(
|
|
71827
|
+
return Math.round(ms2 / n6) + " " + name + (isPlural ? "s" : "");
|
|
71836
71828
|
}
|
|
71837
71829
|
}
|
|
71838
71830
|
});
|
|
@@ -71876,8 +71868,8 @@ var require_common2 = __commonJS({
|
|
|
71876
71868
|
}
|
|
71877
71869
|
const self2 = debug;
|
|
71878
71870
|
const curr = Number(/* @__PURE__ */ new Date());
|
|
71879
|
-
const
|
|
71880
|
-
self2.diff =
|
|
71871
|
+
const ms2 = curr - (prevTime || curr);
|
|
71872
|
+
self2.diff = ms2;
|
|
71881
71873
|
self2.prev = prevTime;
|
|
71882
71874
|
self2.curr = curr;
|
|
71883
71875
|
prevTime = curr;
|
|
@@ -87380,11 +87372,11 @@ var require_TokenExpiredError = __commonJS({
|
|
|
87380
87372
|
var require_timespan = __commonJS({
|
|
87381
87373
|
"../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module2) {
|
|
87382
87374
|
"use strict";
|
|
87383
|
-
var
|
|
87375
|
+
var ms2 = require_ms();
|
|
87384
87376
|
module2.exports = function(time2, iat) {
|
|
87385
87377
|
var timestamp = iat || Math.floor(Date.now() / 1e3);
|
|
87386
87378
|
if (typeof time2 === "string") {
|
|
87387
|
-
var milliseconds =
|
|
87379
|
+
var milliseconds = ms2(time2);
|
|
87388
87380
|
if (typeof milliseconds === "undefined") {
|
|
87389
87381
|
return;
|
|
87390
87382
|
}
|
|
@@ -101922,7 +101914,7 @@ var require_dist = __commonJS({
|
|
|
101922
101914
|
};
|
|
101923
101915
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
101924
101916
|
exports2.Agent = void 0;
|
|
101925
|
-
var
|
|
101917
|
+
var net2 = __importStar2(require("net"));
|
|
101926
101918
|
var http3 = __importStar2(require("http"));
|
|
101927
101919
|
var https_1 = require("https");
|
|
101928
101920
|
__exportStar2(require_helpers2(), exports2);
|
|
@@ -101962,7 +101954,7 @@ var require_dist = __commonJS({
|
|
|
101962
101954
|
if (!this.sockets[name]) {
|
|
101963
101955
|
this.sockets[name] = [];
|
|
101964
101956
|
}
|
|
101965
|
-
const fakeSocket = new
|
|
101957
|
+
const fakeSocket = new net2.Socket({ writable: false });
|
|
101966
101958
|
this.sockets[name].push(fakeSocket);
|
|
101967
101959
|
this.totalSocketCount++;
|
|
101968
101960
|
return fakeSocket;
|
|
@@ -102174,7 +102166,7 @@ var require_dist2 = __commonJS({
|
|
|
102174
102166
|
};
|
|
102175
102167
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
102176
102168
|
exports2.HttpsProxyAgent = void 0;
|
|
102177
|
-
var
|
|
102169
|
+
var net2 = __importStar2(require("net"));
|
|
102178
102170
|
var tls = __importStar2(require("tls"));
|
|
102179
102171
|
var assert_1 = __importDefault2(require("assert"));
|
|
102180
102172
|
var debug_1 = __importDefault2(require_src2());
|
|
@@ -102183,7 +102175,7 @@ var require_dist2 = __commonJS({
|
|
|
102183
102175
|
var parse_proxy_response_1 = require_parse_proxy_response();
|
|
102184
102176
|
var debug = (0, debug_1.default)("https-proxy-agent");
|
|
102185
102177
|
var setServernameFromNonIpHost = (options) => {
|
|
102186
|
-
if (options.servername === void 0 && options.host && !
|
|
102178
|
+
if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
|
|
102187
102179
|
return {
|
|
102188
102180
|
...options,
|
|
102189
102181
|
servername: options.host
|
|
@@ -102223,10 +102215,10 @@ var require_dist2 = __commonJS({
|
|
|
102223
102215
|
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
102224
102216
|
} else {
|
|
102225
102217
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
102226
|
-
socket =
|
|
102218
|
+
socket = net2.connect(this.connectOpts);
|
|
102227
102219
|
}
|
|
102228
102220
|
const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
|
|
102229
|
-
const host =
|
|
102221
|
+
const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
102230
102222
|
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
|
|
102231
102223
|
`;
|
|
102232
102224
|
if (proxy.username || proxy.password) {
|
|
@@ -102259,7 +102251,7 @@ var require_dist2 = __commonJS({
|
|
|
102259
102251
|
return socket;
|
|
102260
102252
|
}
|
|
102261
102253
|
socket.destroy();
|
|
102262
|
-
const fakeSocket = new
|
|
102254
|
+
const fakeSocket = new net2.Socket({ writable: false });
|
|
102263
102255
|
fakeSocket.readable = true;
|
|
102264
102256
|
req.once("socket", (s7) => {
|
|
102265
102257
|
debug("Replaying proxy buffer for failed request");
|
|
@@ -102324,7 +102316,7 @@ var require_dist3 = __commonJS({
|
|
|
102324
102316
|
};
|
|
102325
102317
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
102326
102318
|
exports2.HttpProxyAgent = void 0;
|
|
102327
|
-
var
|
|
102319
|
+
var net2 = __importStar2(require("net"));
|
|
102328
102320
|
var tls = __importStar2(require("tls"));
|
|
102329
102321
|
var debug_1 = __importDefault2(require_src2());
|
|
102330
102322
|
var events_1 = require("events");
|
|
@@ -102397,7 +102389,7 @@ var require_dist3 = __commonJS({
|
|
|
102397
102389
|
socket = tls.connect(this.connectOpts);
|
|
102398
102390
|
} else {
|
|
102399
102391
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
102400
|
-
socket =
|
|
102392
|
+
socket = net2.connect(this.connectOpts);
|
|
102401
102393
|
}
|
|
102402
102394
|
await (0, events_1.once)(socket, "connect");
|
|
102403
102395
|
return socket;
|
|
@@ -141277,7 +141269,7 @@ var require_connection = __commonJS({
|
|
|
141277
141269
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
141278
141270
|
var _os = _interopRequireDefault(require("os"));
|
|
141279
141271
|
var tls = _interopRequireWildcard(require("tls"));
|
|
141280
|
-
var
|
|
141272
|
+
var net2 = _interopRequireWildcard(require("net"));
|
|
141281
141273
|
var _dns = _interopRequireDefault(require("dns"));
|
|
141282
141274
|
var _constants = _interopRequireDefault(require("constants"));
|
|
141283
141275
|
var _stream = require("stream");
|
|
@@ -142326,7 +142318,7 @@ var require_connection = __commonJS({
|
|
|
142326
142318
|
async wrapWithTls(socket, signal) {
|
|
142327
142319
|
signal.throwIfAborted();
|
|
142328
142320
|
const secureContext = tls.createSecureContext(this.secureContextOptions);
|
|
142329
|
-
const serverName = !
|
|
142321
|
+
const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
|
|
142330
142322
|
const encryptOptions = {
|
|
142331
142323
|
host: this.config.server,
|
|
142332
142324
|
socket,
|
|
@@ -145232,7 +145224,6 @@ __export(connections_exports, {
|
|
|
145232
145224
|
connectToSQLite: () => connectToSQLite,
|
|
145233
145225
|
connectToSingleStore: () => connectToSingleStore,
|
|
145234
145226
|
prepareCockroach: () => prepareCockroach,
|
|
145235
|
-
prepareDuckDb: () => prepareDuckDb,
|
|
145236
145227
|
prepareGelDB: () => prepareGelDB,
|
|
145237
145228
|
preparePostgresDB: () => preparePostgresDB
|
|
145238
145229
|
});
|
|
@@ -145249,10 +145240,11 @@ function parseMssqlUrl(url) {
|
|
|
145249
145240
|
}
|
|
145250
145241
|
};
|
|
145251
145242
|
}
|
|
145252
|
-
var normalisePGliteUrl, preparePostgresDB,
|
|
145243
|
+
var import_net, ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
|
|
145253
145244
|
var init_connections = __esm({
|
|
145254
145245
|
"src/cli/connections.ts"() {
|
|
145255
145246
|
"use strict";
|
|
145247
|
+
import_net = __toESM(require("net"));
|
|
145256
145248
|
init_src();
|
|
145257
145249
|
init_wrapper();
|
|
145258
145250
|
init_utils();
|
|
@@ -145260,6 +145252,7 @@ var init_connections = __esm({
|
|
|
145260
145252
|
init_when_json_met_bigint();
|
|
145261
145253
|
init_utils3();
|
|
145262
145254
|
init_outputs();
|
|
145255
|
+
ms = (a6, b6) => Number(b6 - a6) / 1e6;
|
|
145263
145256
|
normalisePGliteUrl = (it) => {
|
|
145264
145257
|
if (it.startsWith("file:")) {
|
|
145265
145258
|
return it.substring(5);
|
|
@@ -145383,13 +145376,7 @@ var init_connections = __esm({
|
|
|
145383
145376
|
}
|
|
145384
145377
|
return results;
|
|
145385
145378
|
};
|
|
145386
|
-
return {
|
|
145387
|
-
packageName: "pglite",
|
|
145388
|
-
query,
|
|
145389
|
-
proxy,
|
|
145390
|
-
transactionProxy,
|
|
145391
|
-
migrate: migrateFn
|
|
145392
|
-
};
|
|
145379
|
+
return { packageName: "pglite", query, proxy, transactionProxy, migrate: migrateFn };
|
|
145393
145380
|
}
|
|
145394
145381
|
assertUnreachable(driver2);
|
|
145395
145382
|
}
|
|
@@ -145420,13 +145407,13 @@ var init_connections = __esm({
|
|
|
145420
145407
|
return pg.types.getTypeParser(typeId, format2);
|
|
145421
145408
|
}
|
|
145422
145409
|
};
|
|
145423
|
-
const
|
|
145424
|
-
const db = drizzle({ client });
|
|
145410
|
+
const pool = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
|
|
145411
|
+
const db = drizzle({ client: pool });
|
|
145425
145412
|
const migrateFn = async (config) => {
|
|
145426
145413
|
return migrate(db, config);
|
|
145427
145414
|
};
|
|
145428
145415
|
const query = async (sql, params) => {
|
|
145429
|
-
const result2 = await
|
|
145416
|
+
const result2 = await pool.query({
|
|
145430
145417
|
text: sql,
|
|
145431
145418
|
values: params ?? [],
|
|
145432
145419
|
types: types3
|
|
@@ -145436,7 +145423,7 @@ var init_connections = __esm({
|
|
|
145436
145423
|
return result2.rows;
|
|
145437
145424
|
};
|
|
145438
145425
|
const proxy = async (params) => {
|
|
145439
|
-
const result2 = await
|
|
145426
|
+
const result2 = await pool.query({
|
|
145440
145427
|
text: params.sql,
|
|
145441
145428
|
values: params.params,
|
|
145442
145429
|
...params.mode === "array" && { rowMode: "array" },
|
|
@@ -145448,7 +145435,7 @@ var init_connections = __esm({
|
|
|
145448
145435
|
};
|
|
145449
145436
|
const transactionProxy = async (queries) => {
|
|
145450
145437
|
const results = [];
|
|
145451
|
-
const tx = await
|
|
145438
|
+
const tx = await pool.connect();
|
|
145452
145439
|
try {
|
|
145453
145440
|
await tx.query("BEGIN");
|
|
145454
145441
|
for (const query2 of queries) {
|
|
@@ -145467,13 +145454,119 @@ var init_connections = __esm({
|
|
|
145467
145454
|
}
|
|
145468
145455
|
return results;
|
|
145469
145456
|
};
|
|
145470
|
-
|
|
145471
|
-
|
|
145472
|
-
|
|
145473
|
-
|
|
145474
|
-
|
|
145475
|
-
|
|
145457
|
+
const benchmarkQuery = async (client, sql, params) => {
|
|
145458
|
+
const explainResult = await pool.query({
|
|
145459
|
+
text: `EXPLAIN ANALYZE ${sql}`,
|
|
145460
|
+
values: params ?? [],
|
|
145461
|
+
types: types3
|
|
145462
|
+
});
|
|
145463
|
+
const stringifiedResult = JSON.stringify(explainResult.rows);
|
|
145464
|
+
const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
|
|
145465
|
+
const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
|
|
145466
|
+
let planningTime = Number(planningMatch[1]);
|
|
145467
|
+
let executionTime = Number(executionMatch[1]);
|
|
145468
|
+
let querySentAt = 0n;
|
|
145469
|
+
let firstDataAt = 0n;
|
|
145470
|
+
let lastDataAt = 0n;
|
|
145471
|
+
let lastRowParsedAt = 0n;
|
|
145472
|
+
let queryCompletedAt = 0n;
|
|
145473
|
+
let bytesReceived = 0;
|
|
145474
|
+
let rowCount = 0;
|
|
145475
|
+
let parseTime = 0;
|
|
145476
|
+
let lastParseTime = 0;
|
|
145477
|
+
const rowDescriptionListener = (data) => {
|
|
145478
|
+
if (firstDataAt === 0n) {
|
|
145479
|
+
firstDataAt = process.hrtime.bigint();
|
|
145480
|
+
}
|
|
145481
|
+
bytesReceived += data.length;
|
|
145482
|
+
};
|
|
145483
|
+
const originalRowListener = client.connection.listeners("dataRow")[0];
|
|
145484
|
+
const wrappedRowListener = (data) => {
|
|
145485
|
+
rowCount += 1;
|
|
145486
|
+
const start = process.hrtime.bigint();
|
|
145487
|
+
lastDataAt = start;
|
|
145488
|
+
originalRowListener.apply(client.connection, [data]);
|
|
145489
|
+
const end2 = process.hrtime.bigint();
|
|
145490
|
+
lastRowParsedAt = end2;
|
|
145491
|
+
lastParseTime = ms(start, end2);
|
|
145492
|
+
parseTime += lastParseTime;
|
|
145493
|
+
bytesReceived += data.length;
|
|
145494
|
+
};
|
|
145495
|
+
client.connection.removeAllListeners("dataRow");
|
|
145496
|
+
client.connection.addListener("dataRow", wrappedRowListener);
|
|
145497
|
+
client.connection.prependListener("rowDescription", rowDescriptionListener);
|
|
145498
|
+
querySentAt = process.hrtime.bigint();
|
|
145499
|
+
await client.query({
|
|
145500
|
+
text: sql,
|
|
145501
|
+
values: params,
|
|
145502
|
+
types: types3
|
|
145503
|
+
});
|
|
145504
|
+
queryCompletedAt = process.hrtime.bigint();
|
|
145505
|
+
client.connection.removeListener("rowDescription", rowDescriptionListener);
|
|
145506
|
+
client.connection.removeAllListeners("dataRow");
|
|
145507
|
+
client.connection.addListener("dataRow", originalRowListener);
|
|
145508
|
+
let querySentTime = ms(querySentAt, firstDataAt) - executionTime - planningTime;
|
|
145509
|
+
if (querySentTime < 0) {
|
|
145510
|
+
const percent = 0.1;
|
|
145511
|
+
const overflow = -querySentTime;
|
|
145512
|
+
const keepForSent = overflow * percent;
|
|
145513
|
+
const adjustedOverflow = overflow * (1 + percent);
|
|
145514
|
+
const total2 = planningTime + executionTime;
|
|
145515
|
+
const ratioPlanning = planningTime / total2;
|
|
145516
|
+
const ratioExecution = executionTime / total2;
|
|
145517
|
+
planningTime -= adjustedOverflow * ratioPlanning;
|
|
145518
|
+
executionTime -= adjustedOverflow * ratioExecution;
|
|
145519
|
+
querySentTime = keepForSent;
|
|
145520
|
+
}
|
|
145521
|
+
const networkLatencyBefore = querySentTime / 2;
|
|
145522
|
+
const networkLatencyAfter = querySentTime / 2;
|
|
145523
|
+
const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
|
|
145524
|
+
const total = ms(querySentAt, queryCompletedAt);
|
|
145525
|
+
const calculatedTotal = networkLatencyBefore + planningTime + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
|
|
145526
|
+
const errorMargin = Math.abs(total - calculatedTotal);
|
|
145527
|
+
return {
|
|
145528
|
+
networkLatencyBefore,
|
|
145529
|
+
planning: planningTime,
|
|
145530
|
+
execution: executionTime,
|
|
145531
|
+
networkLatencyAfter,
|
|
145532
|
+
dataDownload: downloadTime,
|
|
145533
|
+
dataParse: parseTime,
|
|
145534
|
+
total,
|
|
145535
|
+
errorMargin,
|
|
145536
|
+
dataSize: bytesReceived
|
|
145537
|
+
};
|
|
145476
145538
|
};
|
|
145539
|
+
const benchmarkProxy = async ({ sql, params }, repeats) => {
|
|
145540
|
+
let startAt = 0n;
|
|
145541
|
+
let tcpConnectedAt = 0n;
|
|
145542
|
+
let tlsConnectedAt = null;
|
|
145543
|
+
let dbReadyAt = 0n;
|
|
145544
|
+
const client = "url" in credentials ? new pg.Client({ connectionString: credentials.url }) : new pg.Client({ ...credentials, ssl });
|
|
145545
|
+
client.connection.once("connect", () => {
|
|
145546
|
+
tcpConnectedAt = process.hrtime.bigint();
|
|
145547
|
+
});
|
|
145548
|
+
client.connection.prependOnceListener("sslconnect", () => {
|
|
145549
|
+
tlsConnectedAt = process.hrtime.bigint();
|
|
145550
|
+
});
|
|
145551
|
+
client.connection.prependOnceListener("readyForQuery", () => {
|
|
145552
|
+
dbReadyAt = process.hrtime.bigint();
|
|
145553
|
+
});
|
|
145554
|
+
startAt = process.hrtime.bigint();
|
|
145555
|
+
await client.connect();
|
|
145556
|
+
const results = [];
|
|
145557
|
+
for (let i7 = 0; i7 < repeats; i7++) {
|
|
145558
|
+
const r7 = await benchmarkQuery(client, sql, params);
|
|
145559
|
+
results.push(r7);
|
|
145560
|
+
}
|
|
145561
|
+
await client.end();
|
|
145562
|
+
return {
|
|
145563
|
+
tcpHandshake: ms(startAt, tcpConnectedAt),
|
|
145564
|
+
tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
|
|
145565
|
+
dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
|
|
145566
|
+
queries: results
|
|
145567
|
+
};
|
|
145568
|
+
};
|
|
145569
|
+
return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
|
|
145477
145570
|
}
|
|
145478
145571
|
if (await checkPackage("postgres")) {
|
|
145479
145572
|
console.log(
|
|
@@ -145524,13 +145617,7 @@ var init_connections = __esm({
|
|
|
145524
145617
|
}
|
|
145525
145618
|
return results;
|
|
145526
145619
|
};
|
|
145527
|
-
return {
|
|
145528
|
-
packageName: "postgres",
|
|
145529
|
-
query,
|
|
145530
|
-
proxy,
|
|
145531
|
-
transactionProxy,
|
|
145532
|
-
migrate: migrateFn
|
|
145533
|
-
};
|
|
145620
|
+
return { packageName: "postgres", query, proxy, transactionProxy, migrate: migrateFn };
|
|
145534
145621
|
}
|
|
145535
145622
|
if (await checkPackage("@vercel/postgres")) {
|
|
145536
145623
|
console.log(
|
|
@@ -145611,13 +145698,7 @@ var init_connections = __esm({
|
|
|
145611
145698
|
}
|
|
145612
145699
|
return results;
|
|
145613
145700
|
};
|
|
145614
|
-
return {
|
|
145615
|
-
packageName: "@vercel/postgres",
|
|
145616
|
-
query,
|
|
145617
|
-
proxy,
|
|
145618
|
-
transactionProxy,
|
|
145619
|
-
migrate: migrateFn
|
|
145620
|
-
};
|
|
145701
|
+
return { packageName: "@vercel/postgres", query, proxy, transactionProxy, migrate: migrateFn };
|
|
145621
145702
|
}
|
|
145622
145703
|
if (await checkPackage("@neondatabase/serverless")) {
|
|
145623
145704
|
console.log(
|
|
@@ -145630,11 +145711,7 @@ var init_connections = __esm({
|
|
|
145630
145711
|
"'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
|
|
145631
145712
|
)
|
|
145632
145713
|
);
|
|
145633
|
-
const {
|
|
145634
|
-
Pool,
|
|
145635
|
-
neonConfig,
|
|
145636
|
-
types: pgTypes
|
|
145637
|
-
} = require("@neondatabase/serverless");
|
|
145714
|
+
const { Pool, neonConfig, types: pgTypes } = require("@neondatabase/serverless");
|
|
145638
145715
|
const { drizzle } = require("drizzle-orm/neon-serverless");
|
|
145639
145716
|
const { migrate } = require("drizzle-orm/neon-serverless/migrator");
|
|
145640
145717
|
const ssl = "ssl" in credentials ? credentials.ssl === "prefer" || credentials.ssl === "require" || credentials.ssl === "allow" ? { rejectUnauthorized: false } : credentials.ssl === "verify-full" ? {} : credentials.ssl : {};
|
|
@@ -145704,13 +145781,7 @@ var init_connections = __esm({
|
|
|
145704
145781
|
}
|
|
145705
145782
|
return results;
|
|
145706
145783
|
};
|
|
145707
|
-
return {
|
|
145708
|
-
packageName: "@neondatabase/serverless",
|
|
145709
|
-
query,
|
|
145710
|
-
proxy,
|
|
145711
|
-
transactionProxy,
|
|
145712
|
-
migrate: migrateFn
|
|
145713
|
-
};
|
|
145784
|
+
return { packageName: "@neondatabase/serverless", query, proxy, transactionProxy, migrate: migrateFn };
|
|
145714
145785
|
}
|
|
145715
145786
|
if (await checkPackage("bun")) {
|
|
145716
145787
|
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
@@ -145761,54 +145832,6 @@ var init_connections = __esm({
|
|
|
145761
145832
|
console.warn("For the 'bun' driver, run your script using: bun --bun");
|
|
145762
145833
|
process.exit(1);
|
|
145763
145834
|
};
|
|
145764
|
-
prepareDuckDb = async (credentials) => {
|
|
145765
|
-
if (await checkPackage("@duckdb/node-api")) {
|
|
145766
|
-
console.log(
|
|
145767
|
-
withStyle.info(`Using '@duckdb/node-api' driver for database querying`)
|
|
145768
|
-
);
|
|
145769
|
-
const { DuckDBInstance } = require("@duckdb/node-api");
|
|
145770
|
-
const instance = await DuckDBInstance.create(credentials.url);
|
|
145771
|
-
const client = await instance.connect();
|
|
145772
|
-
const query = async (sql, params = []) => {
|
|
145773
|
-
const result2 = await client.run(sql, params);
|
|
145774
|
-
const rows = await result2.getRowObjectsJson();
|
|
145775
|
-
return rows;
|
|
145776
|
-
};
|
|
145777
|
-
const proxy = async (params) => {
|
|
145778
|
-
const result2 = await client.run(params.sql, params.params);
|
|
145779
|
-
return params.mode === "array" ? await result2.getRowsJson() : await result2.getRowObjectsJson();
|
|
145780
|
-
};
|
|
145781
|
-
const transactionProxy = async (queries) => {
|
|
145782
|
-
const results = [];
|
|
145783
|
-
try {
|
|
145784
|
-
await client.run("BEGIN");
|
|
145785
|
-
for (const query2 of queries) {
|
|
145786
|
-
const result2 = await client.run(query2.sql);
|
|
145787
|
-
results.push(await result2.getRowObjectsJson());
|
|
145788
|
-
}
|
|
145789
|
-
await client.run("COMMIT");
|
|
145790
|
-
} catch (error3) {
|
|
145791
|
-
await client.run("ROLLBACK");
|
|
145792
|
-
results.push(error3);
|
|
145793
|
-
}
|
|
145794
|
-
return results;
|
|
145795
|
-
};
|
|
145796
|
-
return {
|
|
145797
|
-
packageName: "@duckdb/node-api",
|
|
145798
|
-
query,
|
|
145799
|
-
proxy,
|
|
145800
|
-
transactionProxy,
|
|
145801
|
-
migrate: () => {
|
|
145802
|
-
throw new Error("DuckDB does not support migrations");
|
|
145803
|
-
}
|
|
145804
|
-
};
|
|
145805
|
-
}
|
|
145806
|
-
console.error(
|
|
145807
|
-
// "To connect to DuckDb database - please install either of 'duckdb', '@duckdb/node-api' drivers",
|
|
145808
|
-
"To connect to DuckDb database - please install '@duckdb/node-api' driver"
|
|
145809
|
-
);
|
|
145810
|
-
process.exit(1);
|
|
145811
|
-
};
|
|
145812
145835
|
prepareCockroach = async (credentials) => {
|
|
145813
145836
|
if (await checkPackage("pg")) {
|
|
145814
145837
|
const { default: pg } = require("pg");
|
|
@@ -145861,7 +145884,9 @@ var init_connections = __esm({
|
|
|
145861
145884
|
};
|
|
145862
145885
|
return { query, proxy, migrate: migrateFn };
|
|
145863
145886
|
}
|
|
145864
|
-
console.error(
|
|
145887
|
+
console.error(
|
|
145888
|
+
"To connect to Cockroach - please install 'pg' package"
|
|
145889
|
+
);
|
|
145865
145890
|
process.exit(1);
|
|
145866
145891
|
};
|
|
145867
145892
|
prepareGelDB = async (credentials) => {
|
|
@@ -145920,7 +145945,9 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
145920
145945
|
};
|
|
145921
145946
|
return { packageName: "gel", query, proxy, transactionProxy };
|
|
145922
145947
|
}
|
|
145923
|
-
console.error(
|
|
145948
|
+
console.error(
|
|
145949
|
+
"To connect to gel database - please install 'edgedb' driver"
|
|
145950
|
+
);
|
|
145924
145951
|
process.exit(1);
|
|
145925
145952
|
};
|
|
145926
145953
|
parseSingleStoreCredentials = (credentials) => {
|
|
@@ -146034,7 +146061,6 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146034
146061
|
}
|
|
146035
146062
|
return next();
|
|
146036
146063
|
};
|
|
146037
|
-
await connection.connect();
|
|
146038
146064
|
const query = async (sql, params) => {
|
|
146039
146065
|
const res = await connection.execute({
|
|
146040
146066
|
sql,
|
|
@@ -146074,11 +146100,156 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146074
146100
|
}
|
|
146075
146101
|
return results;
|
|
146076
146102
|
};
|
|
146103
|
+
const benchmarkQuery = async (newConnection, sql, params) => {
|
|
146104
|
+
const explainResult = await connection.query({
|
|
146105
|
+
sql: `EXPLAIN ANALYZE ${sql}`,
|
|
146106
|
+
values: params ?? [],
|
|
146107
|
+
typeCast
|
|
146108
|
+
});
|
|
146109
|
+
const stringifiedResult = JSON.stringify(explainResult[0]);
|
|
146110
|
+
const timeMatch = stringifiedResult.match(
|
|
146111
|
+
/actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
|
|
146112
|
+
);
|
|
146113
|
+
const lastRowTime = Number(timeMatch[2]);
|
|
146114
|
+
let executionTime = lastRowTime;
|
|
146115
|
+
let querySentAt = 0n;
|
|
146116
|
+
let firstDataAt = 0n;
|
|
146117
|
+
let lastDataAt = 0n;
|
|
146118
|
+
let lastRowParsedAt = 0n;
|
|
146119
|
+
let queryCompletedAt = 0n;
|
|
146120
|
+
let bytesReceived = 0;
|
|
146121
|
+
let rowCount = 0;
|
|
146122
|
+
let parseTime = 0;
|
|
146123
|
+
let lastParseTime = 0;
|
|
146124
|
+
querySentAt = process.hrtime.bigint();
|
|
146125
|
+
await new Promise((resolve2, reject) => {
|
|
146126
|
+
const query2 = newConnection.query({
|
|
146127
|
+
sql,
|
|
146128
|
+
values: params ?? [],
|
|
146129
|
+
typeCast
|
|
146130
|
+
});
|
|
146131
|
+
const originalRowHandler = query2.row;
|
|
146132
|
+
let packets = 0;
|
|
146133
|
+
const wrappedRowListener = (packet, connection2) => {
|
|
146134
|
+
packets += 1;
|
|
146135
|
+
if (firstDataAt === 0n) {
|
|
146136
|
+
firstDataAt = process.hrtime.bigint();
|
|
146137
|
+
bytesReceived += packet.start;
|
|
146138
|
+
}
|
|
146139
|
+
const start = process.hrtime.bigint();
|
|
146140
|
+
lastDataAt = start;
|
|
146141
|
+
const res = originalRowHandler.apply(query2, [packet, connection2]);
|
|
146142
|
+
const end2 = process.hrtime.bigint();
|
|
146143
|
+
lastRowParsedAt = end2;
|
|
146144
|
+
lastParseTime = ms(start, end2);
|
|
146145
|
+
parseTime += lastParseTime;
|
|
146146
|
+
bytesReceived += packet.length();
|
|
146147
|
+
if (!res || packet.isEOF()) {
|
|
146148
|
+
return res;
|
|
146149
|
+
}
|
|
146150
|
+
return wrappedRowListener;
|
|
146151
|
+
};
|
|
146152
|
+
query2.row = wrappedRowListener;
|
|
146153
|
+
query2.on("result", () => {
|
|
146154
|
+
rowCount += 1;
|
|
146155
|
+
});
|
|
146156
|
+
query2.on("error", (err2) => {
|
|
146157
|
+
reject(err2);
|
|
146158
|
+
});
|
|
146159
|
+
query2.on("end", () => {
|
|
146160
|
+
resolve2();
|
|
146161
|
+
});
|
|
146162
|
+
});
|
|
146163
|
+
queryCompletedAt = process.hrtime.bigint();
|
|
146164
|
+
let querySentTime = ms(querySentAt, firstDataAt) - executionTime;
|
|
146165
|
+
if (querySentTime < 0) {
|
|
146166
|
+
const percent = 0.1;
|
|
146167
|
+
const overflow = -querySentTime;
|
|
146168
|
+
const keepForSent = overflow * percent;
|
|
146169
|
+
const adjustedOverflow = overflow * (1 + percent);
|
|
146170
|
+
const total2 = executionTime;
|
|
146171
|
+
const ratioExecution = executionTime / total2;
|
|
146172
|
+
executionTime -= adjustedOverflow * ratioExecution;
|
|
146173
|
+
querySentTime = keepForSent;
|
|
146174
|
+
}
|
|
146175
|
+
const networkLatencyBefore = querySentTime / 2;
|
|
146176
|
+
const networkLatencyAfter = querySentTime / 2;
|
|
146177
|
+
const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
|
|
146178
|
+
const total = ms(querySentAt, queryCompletedAt);
|
|
146179
|
+
const calculatedTotal = networkLatencyBefore + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
|
|
146180
|
+
const errorMargin = Math.abs(total - calculatedTotal);
|
|
146181
|
+
return {
|
|
146182
|
+
networkLatencyBefore,
|
|
146183
|
+
planning: null,
|
|
146184
|
+
execution: executionTime,
|
|
146185
|
+
networkLatencyAfter,
|
|
146186
|
+
dataDownload: downloadTime,
|
|
146187
|
+
dataParse: parseTime,
|
|
146188
|
+
total,
|
|
146189
|
+
errorMargin,
|
|
146190
|
+
dataSize: bytesReceived
|
|
146191
|
+
};
|
|
146192
|
+
};
|
|
146193
|
+
const benchmarkProxy = async ({ sql, params }, repeats) => {
|
|
146194
|
+
const { createConnection: createConnection2 } = require("mysql2");
|
|
146195
|
+
let startAt = 0n;
|
|
146196
|
+
let tcpConnectedAt = 0n;
|
|
146197
|
+
let tlsConnectedAt = null;
|
|
146198
|
+
const createStream = ({ config }) => {
|
|
146199
|
+
let stream;
|
|
146200
|
+
if (config.socketPath) {
|
|
146201
|
+
stream = import_net.default.connect(config.socketPath);
|
|
146202
|
+
} else {
|
|
146203
|
+
stream = import_net.default.connect(config.port, config.host);
|
|
146204
|
+
}
|
|
146205
|
+
if (config.enableKeepAlive) {
|
|
146206
|
+
stream.on("connect", () => {
|
|
146207
|
+
stream.setKeepAlive(true, config.keepAliveInitialDelay);
|
|
146208
|
+
});
|
|
146209
|
+
}
|
|
146210
|
+
stream.setNoDelay(true);
|
|
146211
|
+
stream.once("connect", () => {
|
|
146212
|
+
tcpConnectedAt = process.hrtime.bigint();
|
|
146213
|
+
});
|
|
146214
|
+
return stream;
|
|
146215
|
+
};
|
|
146216
|
+
startAt = process.hrtime.bigint();
|
|
146217
|
+
const connection2 = result2.url ? createConnection2({
|
|
146218
|
+
uri: result2.url,
|
|
146219
|
+
stream: createStream
|
|
146220
|
+
}) : createConnection2({
|
|
146221
|
+
...result2.credentials,
|
|
146222
|
+
stream: createStream
|
|
146223
|
+
});
|
|
146224
|
+
await new Promise((resolve2, reject) => {
|
|
146225
|
+
connection2.connect((err2) => {
|
|
146226
|
+
tlsConnectedAt = process.hrtime.bigint();
|
|
146227
|
+
if (err2) {
|
|
146228
|
+
reject(err2);
|
|
146229
|
+
} else {
|
|
146230
|
+
resolve2();
|
|
146231
|
+
}
|
|
146232
|
+
});
|
|
146233
|
+
});
|
|
146234
|
+
const results = [];
|
|
146235
|
+
for (let i7 = 0; i7 < repeats; i7++) {
|
|
146236
|
+
const r7 = await benchmarkQuery(connection2, sql, params);
|
|
146237
|
+
results.push(r7);
|
|
146238
|
+
}
|
|
146239
|
+
connection2.end();
|
|
146240
|
+
return {
|
|
146241
|
+
tcpHandshake: ms(startAt, tcpConnectedAt),
|
|
146242
|
+
tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
|
|
146243
|
+
dbHandshake: null,
|
|
146244
|
+
queries: results
|
|
146245
|
+
};
|
|
146246
|
+
};
|
|
146077
146247
|
return {
|
|
146078
146248
|
db: { query },
|
|
146079
146249
|
packageName: "mysql2",
|
|
146080
146250
|
proxy,
|
|
146081
146251
|
transactionProxy,
|
|
146252
|
+
benchmarkProxy,
|
|
146082
146253
|
database: result2.database,
|
|
146083
146254
|
migrate: migrateFn
|
|
146084
146255
|
};
|
|
@@ -146228,7 +146399,9 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146228
146399
|
migrate: migrateFn
|
|
146229
146400
|
};
|
|
146230
146401
|
}
|
|
146231
|
-
console.error(
|
|
146402
|
+
console.error(
|
|
146403
|
+
"To connect to MsSQL database - please install 'mssql' driver"
|
|
146404
|
+
);
|
|
146232
146405
|
process.exit(1);
|
|
146233
146406
|
};
|
|
146234
146407
|
prepareSqliteParams = (params, driver2) => {
|
|
@@ -146333,10 +146506,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146333
146506
|
await remoteCallback(query2, [], "run");
|
|
146334
146507
|
};
|
|
146335
146508
|
const proxy = async (params) => {
|
|
146336
|
-
const preparedParams = prepareSqliteParams(
|
|
146337
|
-
params.params || [],
|
|
146338
|
-
"d1-http"
|
|
146339
|
-
);
|
|
146509
|
+
const preparedParams = prepareSqliteParams(params.params || [], "d1-http");
|
|
146340
146510
|
const result2 = await remoteCallback(
|
|
146341
146511
|
params.sql,
|
|
146342
146512
|
preparedParams,
|
|
@@ -146561,19 +146731,17 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146561
146731
|
};
|
|
146562
146732
|
const transactionProxy = async (queries) => {
|
|
146563
146733
|
const results = [];
|
|
146564
|
-
const tx = sqlite.transaction(
|
|
146565
|
-
(queries2)
|
|
146566
|
-
|
|
146567
|
-
|
|
146568
|
-
|
|
146569
|
-
|
|
146570
|
-
|
|
146571
|
-
sqlite.prepare(query.sql).run();
|
|
146572
|
-
}
|
|
146573
|
-
results.push(result2);
|
|
146734
|
+
const tx = sqlite.transaction((queries2) => {
|
|
146735
|
+
for (const query of queries2) {
|
|
146736
|
+
let result2 = [];
|
|
146737
|
+
if (query.method === "values" || query.method === "get" || query.method === "all") {
|
|
146738
|
+
result2 = sqlite.prepare(query.sql).all();
|
|
146739
|
+
} else {
|
|
146740
|
+
sqlite.prepare(query.sql).run();
|
|
146574
146741
|
}
|
|
146742
|
+
results.push(result2);
|
|
146575
146743
|
}
|
|
146576
|
-
);
|
|
146744
|
+
});
|
|
146577
146745
|
try {
|
|
146578
146746
|
tx(queries);
|
|
146579
146747
|
} catch (error3) {
|
|
@@ -146581,13 +146749,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
146581
146749
|
}
|
|
146582
146750
|
return results;
|
|
146583
146751
|
};
|
|
146584
|
-
return {
|
|
146585
|
-
...db,
|
|
146586
|
-
packageName: "better-sqlite3",
|
|
146587
|
-
proxy,
|
|
146588
|
-
transactionProxy,
|
|
146589
|
-
migrate: migrateFn
|
|
146590
|
-
};
|
|
146752
|
+
return { ...db, packageName: "better-sqlite3", proxy, transactionProxy, migrate: migrateFn };
|
|
146591
146753
|
}
|
|
146592
146754
|
if (await checkPackage("bun")) {
|
|
146593
146755
|
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
@@ -148641,8 +148803,8 @@ ${sql}
|
|
|
148641
148803
|
`;
|
|
148642
148804
|
return content;
|
|
148643
148805
|
};
|
|
148644
|
-
prepareSnapshotFolderName = (
|
|
148645
|
-
const now =
|
|
148806
|
+
prepareSnapshotFolderName = (ms2) => {
|
|
148807
|
+
const now = ms2 ? new Date(ms2) : /* @__PURE__ */ new Date();
|
|
148646
148808
|
return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
|
|
148647
148809
|
now.getUTCDate()
|
|
148648
148810
|
)}${two(now.getUTCHours())}${two(now.getUTCMinutes())}${two(
|
|
@@ -152127,7 +152289,6 @@ var init_cors = __esm({
|
|
|
152127
152289
|
// src/cli/commands/studio.ts
|
|
152128
152290
|
var studio_exports = {};
|
|
152129
152291
|
__export(studio_exports, {
|
|
152130
|
-
drizzleForDuckDb: () => drizzleForDuckDb,
|
|
152131
152292
|
drizzleForLibSQL: () => drizzleForLibSQL,
|
|
152132
152293
|
drizzleForMySQL: () => drizzleForMySQL,
|
|
152133
152294
|
drizzleForPostgres: () => drizzleForPostgres,
|
|
@@ -152141,7 +152302,7 @@ __export(studio_exports, {
|
|
|
152141
152302
|
prepareServer: () => prepareServer,
|
|
152142
152303
|
prepareSingleStoreSchema: () => prepareSingleStoreSchema
|
|
152143
152304
|
});
|
|
152144
|
-
var import_crypto10, import_drizzle_orm3, import_relations3, import_mssql_core2, import_mysql_core2, import_pg_core3, import_singlestore_core, import_sqlite_core2, import_fs6, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres,
|
|
152305
|
+
var import_crypto10, import_drizzle_orm3, import_relations3, import_mssql_core2, import_mysql_core2, import_pg_core3, import_singlestore_core, import_sqlite_core2, import_fs6, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
|
|
152145
152306
|
var init_studio = __esm({
|
|
152146
152307
|
"src/cli/commands/studio.ts"() {
|
|
152147
152308
|
"use strict";
|
|
@@ -152365,6 +152526,7 @@ var init_studio = __esm({
|
|
|
152365
152526
|
packageName: db.packageName,
|
|
152366
152527
|
proxy: db.proxy,
|
|
152367
152528
|
transactionProxy: db.transactionProxy,
|
|
152529
|
+
benchmarkProxy: db.benchmarkProxy,
|
|
152368
152530
|
customDefaults,
|
|
152369
152531
|
schema: pgSchema2,
|
|
152370
152532
|
relations: relations2,
|
|
@@ -152372,26 +152534,9 @@ var init_studio = __esm({
|
|
|
152372
152534
|
casing: casing2
|
|
152373
152535
|
};
|
|
152374
152536
|
};
|
|
152375
|
-
drizzleForDuckDb = async (credentials) => {
|
|
152376
|
-
const { prepareDuckDb: prepareDuckDb2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
152377
|
-
const db = await prepareDuckDb2(credentials);
|
|
152378
|
-
const dbUrl = `duckdb://${credentials.url}`;
|
|
152379
|
-
const dbHash = (0, import_crypto10.createHash)("sha256").update(dbUrl).digest("hex");
|
|
152380
|
-
return {
|
|
152381
|
-
dbHash,
|
|
152382
|
-
dialect: "duckdb",
|
|
152383
|
-
driver: void 0,
|
|
152384
|
-
packageName: db.packageName,
|
|
152385
|
-
proxy: db.proxy,
|
|
152386
|
-
transactionProxy: db.transactionProxy,
|
|
152387
|
-
customDefaults: [],
|
|
152388
|
-
schema: {},
|
|
152389
|
-
relations: {}
|
|
152390
|
-
};
|
|
152391
|
-
};
|
|
152392
152537
|
drizzleForMySQL = async (credentials, mysqlSchema, relations2, schemaFiles, casing2) => {
|
|
152393
152538
|
const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
152394
|
-
const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
|
|
152539
|
+
const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);
|
|
152395
152540
|
const customDefaults = getCustomDefaults(mysqlSchema, casing2);
|
|
152396
152541
|
let dbUrl;
|
|
152397
152542
|
if ("url" in credentials) {
|
|
@@ -152407,6 +152552,7 @@ var init_studio = __esm({
|
|
|
152407
152552
|
databaseName: database,
|
|
152408
152553
|
proxy,
|
|
152409
152554
|
transactionProxy,
|
|
152555
|
+
benchmarkProxy,
|
|
152410
152556
|
customDefaults,
|
|
152411
152557
|
schema: mysqlSchema,
|
|
152412
152558
|
relations: relations2,
|
|
@@ -152576,6 +152722,23 @@ var init_studio = __esm({
|
|
|
152576
152722
|
]).optional()
|
|
152577
152723
|
}).array()
|
|
152578
152724
|
});
|
|
152725
|
+
benchmarkProxySchema = external_exports.object({
|
|
152726
|
+
type: external_exports.literal("bproxy"),
|
|
152727
|
+
data: external_exports.object({
|
|
152728
|
+
query: external_exports.object({
|
|
152729
|
+
sql: external_exports.string(),
|
|
152730
|
+
params: external_exports.array(external_exports.any()).optional(),
|
|
152731
|
+
method: external_exports.union([
|
|
152732
|
+
external_exports.literal("values"),
|
|
152733
|
+
external_exports.literal("get"),
|
|
152734
|
+
external_exports.literal("all"),
|
|
152735
|
+
external_exports.literal("run"),
|
|
152736
|
+
external_exports.literal("execute")
|
|
152737
|
+
]).optional()
|
|
152738
|
+
}),
|
|
152739
|
+
repeats: external_exports.number().min(1).optional()
|
|
152740
|
+
})
|
|
152741
|
+
});
|
|
152579
152742
|
defaultsSchema = external_exports.object({
|
|
152580
152743
|
type: external_exports.literal("defaults"),
|
|
152581
152744
|
data: external_exports.array(
|
|
@@ -152590,6 +152753,7 @@ var init_studio = __esm({
|
|
|
152590
152753
|
init2,
|
|
152591
152754
|
proxySchema,
|
|
152592
152755
|
transactionProxySchema,
|
|
152756
|
+
benchmarkProxySchema,
|
|
152593
152757
|
defaultsSchema
|
|
152594
152758
|
]);
|
|
152595
152759
|
jsonStringify = (data) => {
|
|
@@ -152612,6 +152776,7 @@ var init_studio = __esm({
|
|
|
152612
152776
|
databaseName,
|
|
152613
152777
|
proxy,
|
|
152614
152778
|
transactionProxy,
|
|
152779
|
+
benchmarkProxy,
|
|
152615
152780
|
customDefaults,
|
|
152616
152781
|
schema: drizzleSchema,
|
|
152617
152782
|
relations: relations2,
|
|
@@ -152675,7 +152840,7 @@ var init_studio = __esm({
|
|
|
152675
152840
|
console.warn("Error message:", error3.message);
|
|
152676
152841
|
}
|
|
152677
152842
|
return c6.json({
|
|
152678
|
-
version: "6.
|
|
152843
|
+
version: "6.3",
|
|
152679
152844
|
dialect: dialect6,
|
|
152680
152845
|
driver: driver2,
|
|
152681
152846
|
packageName,
|
|
@@ -152713,6 +152878,21 @@ var init_studio = __esm({
|
|
|
152713
152878
|
}
|
|
152714
152879
|
);
|
|
152715
152880
|
}
|
|
152881
|
+
if (type === "bproxy") {
|
|
152882
|
+
if (!benchmarkProxy) {
|
|
152883
|
+
throw new Error("Benchmark proxy is not configured for this database.");
|
|
152884
|
+
}
|
|
152885
|
+
const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
|
|
152886
|
+
const res = jsonStringify(result2);
|
|
152887
|
+
return c6.body(
|
|
152888
|
+
res,
|
|
152889
|
+
{
|
|
152890
|
+
headers: {
|
|
152891
|
+
"Content-Type": "application/json"
|
|
152892
|
+
}
|
|
152893
|
+
}
|
|
152894
|
+
);
|
|
152895
|
+
}
|
|
152716
152896
|
if (type === "defaults") {
|
|
152717
152897
|
const columns = body.data;
|
|
152718
152898
|
const result2 = columns.map((column8) => {
|