drizzle-kit 1.0.0-beta.2-b705c25 → 1.0.0-beta.2-e689d82
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 +273 -68
- package/api-mysql.mjs +273 -68
- package/api-postgres.js +275 -70
- package/api-postgres.mjs +275 -70
- package/api-sqlite.js +273 -68
- package/api-sqlite.mjs +273 -68
- package/bin.cjs +275 -70
- package/package.json +1 -1
package/api-mysql.mjs
CHANGED
|
@@ -28729,7 +28729,7 @@ var require_websocket = __commonJS({
|
|
|
28729
28729
|
var EventEmitter = __require("events");
|
|
28730
28730
|
var https2 = __require("https");
|
|
28731
28731
|
var http3 = __require("http");
|
|
28732
|
-
var
|
|
28732
|
+
var net2 = __require("net");
|
|
28733
28733
|
var tls = __require("tls");
|
|
28734
28734
|
var { randomBytes, createHash: createHash5 } = __require("crypto");
|
|
28735
28735
|
var { Duplex, Readable: Readable6 } = __require("stream");
|
|
@@ -29460,12 +29460,12 @@ var require_websocket = __commonJS({
|
|
|
29460
29460
|
}
|
|
29461
29461
|
function netConnect(options) {
|
|
29462
29462
|
options.path = options.socketPath;
|
|
29463
|
-
return
|
|
29463
|
+
return net2.connect(options);
|
|
29464
29464
|
}
|
|
29465
29465
|
function tlsConnect(options) {
|
|
29466
29466
|
options.path = void 0;
|
|
29467
29467
|
if (!options.servername && options.servername !== "") {
|
|
29468
|
-
options.servername =
|
|
29468
|
+
options.servername = net2.isIP(options.host) ? "" : options.host;
|
|
29469
29469
|
}
|
|
29470
29470
|
return tls.connect(options);
|
|
29471
29471
|
}
|
|
@@ -33783,7 +33783,7 @@ var init_timing = __esm({
|
|
|
33783
33783
|
"../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
|
|
33784
33784
|
"use strict";
|
|
33785
33785
|
timing = {
|
|
33786
|
-
setTimeout: (cb,
|
|
33786
|
+
setTimeout: (cb, ms2) => setTimeout(cb, ms2),
|
|
33787
33787
|
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
33788
33788
|
};
|
|
33789
33789
|
}
|
|
@@ -35671,13 +35671,13 @@ var init_schema_date_utils = __esm({
|
|
|
35671
35671
|
if (!matches) {
|
|
35672
35672
|
throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
|
|
35673
35673
|
}
|
|
35674
|
-
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, ,
|
|
35674
|
+
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
|
|
35675
35675
|
range(monthStr, 1, 12);
|
|
35676
35676
|
range(dayStr, 1, 31);
|
|
35677
35677
|
range(hours, 0, 23);
|
|
35678
35678
|
range(minutes, 0, 59);
|
|
35679
35679
|
range(seconds, 0, 60);
|
|
35680
|
-
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(
|
|
35680
|
+
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));
|
|
35681
35681
|
date2.setUTCFullYear(Number(yearStr));
|
|
35682
35682
|
if (offsetStr.toUpperCase() != "Z") {
|
|
35683
35683
|
const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
|
|
@@ -55690,8 +55690,8 @@ var require_datetime2 = __commonJS({
|
|
|
55690
55690
|
if (!(object instanceof Date)) {
|
|
55691
55691
|
throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
|
|
55692
55692
|
}
|
|
55693
|
-
const
|
|
55694
|
-
const us =
|
|
55693
|
+
const ms2 = object.getTime() - TIMESHIFT;
|
|
55694
|
+
const us = ms2 * 1e3;
|
|
55695
55695
|
buf.writeInt32(8);
|
|
55696
55696
|
buf.writeInt64(us);
|
|
55697
55697
|
}
|
|
@@ -55701,12 +55701,12 @@ var require_datetime2 = __commonJS({
|
|
|
55701
55701
|
return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
|
|
55702
55702
|
}
|
|
55703
55703
|
const us = Number(buf.readBigInt64());
|
|
55704
|
-
let
|
|
55705
|
-
if (Math.abs(us % 1e3) === 500 && Math.abs(
|
|
55706
|
-
|
|
55704
|
+
let ms2 = Math.round(us / 1e3);
|
|
55705
|
+
if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
|
|
55706
|
+
ms2 -= 1;
|
|
55707
55707
|
}
|
|
55708
|
-
|
|
55709
|
-
return new Date(
|
|
55708
|
+
ms2 += TIMESHIFT;
|
|
55709
|
+
return new Date(ms2);
|
|
55710
55710
|
}
|
|
55711
55711
|
};
|
|
55712
55712
|
exports2.DateTimeCodec = DateTimeCodec;
|
|
@@ -55727,8 +55727,8 @@ var require_datetime2 = __commonJS({
|
|
|
55727
55727
|
if (!(object instanceof datetime_1.LocalDateTime)) {
|
|
55728
55728
|
throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
|
|
55729
55729
|
}
|
|
55730
|
-
const
|
|
55731
|
-
let us =
|
|
55730
|
+
const ms2 = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
|
|
55731
|
+
let us = ms2 * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
|
|
55732
55732
|
if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
|
|
55733
55733
|
us += 1n;
|
|
55734
55734
|
}
|
|
@@ -55742,13 +55742,13 @@ var require_datetime2 = __commonJS({
|
|
|
55742
55742
|
}
|
|
55743
55743
|
const bi_ms = bi_us / 1000n;
|
|
55744
55744
|
let us = Number(bi_us - bi_ms * 1000n);
|
|
55745
|
-
let
|
|
55745
|
+
let ms2 = Number(bi_ms);
|
|
55746
55746
|
if (us < 0) {
|
|
55747
55747
|
us += 1e3;
|
|
55748
|
-
|
|
55748
|
+
ms2 -= 1;
|
|
55749
55749
|
}
|
|
55750
|
-
|
|
55751
|
-
const date2 = new Date(
|
|
55750
|
+
ms2 += TIMESHIFT;
|
|
55751
|
+
const date2 = new Date(ms2);
|
|
55752
55752
|
return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
|
|
55753
55753
|
}
|
|
55754
55754
|
};
|
|
@@ -55810,13 +55810,13 @@ var require_datetime2 = __commonJS({
|
|
|
55810
55810
|
}
|
|
55811
55811
|
let us = Number(bius);
|
|
55812
55812
|
let seconds = Math.floor(us / 1e6);
|
|
55813
|
-
const
|
|
55814
|
-
us = us % 1e6 -
|
|
55813
|
+
const ms2 = Math.floor(us % 1e6 / 1e3);
|
|
55814
|
+
us = us % 1e6 - ms2 * 1e3;
|
|
55815
55815
|
let minutes = Math.floor(seconds / 60);
|
|
55816
55816
|
seconds = Math.floor(seconds % 60);
|
|
55817
55817
|
const hours = Math.floor(minutes / 60);
|
|
55818
55818
|
minutes = Math.floor(minutes % 60);
|
|
55819
|
-
return new datetime_1.LocalTime(hours, minutes, seconds,
|
|
55819
|
+
return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
|
|
55820
55820
|
}
|
|
55821
55821
|
};
|
|
55822
55822
|
exports2.LocalTimeCodec = LocalTimeCodec;
|
|
@@ -55893,14 +55893,14 @@ var require_datetime2 = __commonJS({
|
|
|
55893
55893
|
const biMillion = 1000000n;
|
|
55894
55894
|
const biSeconds = bius / biMillion;
|
|
55895
55895
|
let us = Number(bius - biSeconds * biMillion);
|
|
55896
|
-
const
|
|
55896
|
+
const ms2 = Math.floor(us / 1e3);
|
|
55897
55897
|
us = us % 1e3;
|
|
55898
55898
|
let seconds = Number(biSeconds);
|
|
55899
55899
|
let minutes = Math.floor(seconds / 60);
|
|
55900
55900
|
seconds = Math.floor(seconds % 60);
|
|
55901
55901
|
const hours = Math.floor(minutes / 60);
|
|
55902
55902
|
minutes = Math.floor(minutes % 60);
|
|
55903
|
-
return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2,
|
|
55903
|
+
return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
|
|
55904
55904
|
}
|
|
55905
55905
|
};
|
|
55906
55906
|
exports2.DurationCodec = DurationCodec;
|
|
@@ -55946,7 +55946,7 @@ var require_datetime2 = __commonJS({
|
|
|
55946
55946
|
const million = BigInt(1e6);
|
|
55947
55947
|
const biSeconds = bius / million;
|
|
55948
55948
|
let us = Number(bius - biSeconds * million);
|
|
55949
|
-
const
|
|
55949
|
+
const ms2 = Math.trunc(us / 1e3);
|
|
55950
55950
|
us = us % 1e3;
|
|
55951
55951
|
let seconds = Number(biSeconds);
|
|
55952
55952
|
let minutes = Math.trunc(seconds / 60);
|
|
@@ -55957,7 +55957,7 @@ var require_datetime2 = __commonJS({
|
|
|
55957
55957
|
days = Math.trunc(days % 7);
|
|
55958
55958
|
const years = Math.trunc(months2 / 12);
|
|
55959
55959
|
months2 = Math.trunc(months2 % 12);
|
|
55960
|
-
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2,
|
|
55960
|
+
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
|
|
55961
55961
|
}
|
|
55962
55962
|
};
|
|
55963
55963
|
exports2.RelativeDurationCodec = RelativeDurationCodec;
|
|
@@ -66121,41 +66121,41 @@ var require_ms = __commonJS({
|
|
|
66121
66121
|
return void 0;
|
|
66122
66122
|
}
|
|
66123
66123
|
}
|
|
66124
|
-
function fmtShort(
|
|
66125
|
-
var msAbs = Math.abs(
|
|
66124
|
+
function fmtShort(ms2) {
|
|
66125
|
+
var msAbs = Math.abs(ms2);
|
|
66126
66126
|
if (msAbs >= d6) {
|
|
66127
|
-
return Math.round(
|
|
66127
|
+
return Math.round(ms2 / d6) + "d";
|
|
66128
66128
|
}
|
|
66129
66129
|
if (msAbs >= h7) {
|
|
66130
|
-
return Math.round(
|
|
66130
|
+
return Math.round(ms2 / h7) + "h";
|
|
66131
66131
|
}
|
|
66132
66132
|
if (msAbs >= m7) {
|
|
66133
|
-
return Math.round(
|
|
66133
|
+
return Math.round(ms2 / m7) + "m";
|
|
66134
66134
|
}
|
|
66135
66135
|
if (msAbs >= s7) {
|
|
66136
|
-
return Math.round(
|
|
66136
|
+
return Math.round(ms2 / s7) + "s";
|
|
66137
66137
|
}
|
|
66138
|
-
return
|
|
66138
|
+
return ms2 + "ms";
|
|
66139
66139
|
}
|
|
66140
|
-
function fmtLong(
|
|
66141
|
-
var msAbs = Math.abs(
|
|
66140
|
+
function fmtLong(ms2) {
|
|
66141
|
+
var msAbs = Math.abs(ms2);
|
|
66142
66142
|
if (msAbs >= d6) {
|
|
66143
|
-
return plural(
|
|
66143
|
+
return plural(ms2, msAbs, d6, "day");
|
|
66144
66144
|
}
|
|
66145
66145
|
if (msAbs >= h7) {
|
|
66146
|
-
return plural(
|
|
66146
|
+
return plural(ms2, msAbs, h7, "hour");
|
|
66147
66147
|
}
|
|
66148
66148
|
if (msAbs >= m7) {
|
|
66149
|
-
return plural(
|
|
66149
|
+
return plural(ms2, msAbs, m7, "minute");
|
|
66150
66150
|
}
|
|
66151
66151
|
if (msAbs >= s7) {
|
|
66152
|
-
return plural(
|
|
66152
|
+
return plural(ms2, msAbs, s7, "second");
|
|
66153
66153
|
}
|
|
66154
|
-
return
|
|
66154
|
+
return ms2 + " ms";
|
|
66155
66155
|
}
|
|
66156
|
-
function plural(
|
|
66156
|
+
function plural(ms2, msAbs, n6, name) {
|
|
66157
66157
|
var isPlural = msAbs >= n6 * 1.5;
|
|
66158
|
-
return Math.round(
|
|
66158
|
+
return Math.round(ms2 / n6) + " " + name + (isPlural ? "s" : "");
|
|
66159
66159
|
}
|
|
66160
66160
|
}
|
|
66161
66161
|
});
|
|
@@ -66199,8 +66199,8 @@ var require_common2 = __commonJS({
|
|
|
66199
66199
|
}
|
|
66200
66200
|
const self2 = debug;
|
|
66201
66201
|
const curr = Number(/* @__PURE__ */ new Date());
|
|
66202
|
-
const
|
|
66203
|
-
self2.diff =
|
|
66202
|
+
const ms2 = curr - (prevTime || curr);
|
|
66203
|
+
self2.diff = ms2;
|
|
66204
66204
|
self2.prev = prevTime;
|
|
66205
66205
|
self2.curr = curr;
|
|
66206
66206
|
prevTime = curr;
|
|
@@ -81703,11 +81703,11 @@ var require_TokenExpiredError = __commonJS({
|
|
|
81703
81703
|
var require_timespan = __commonJS({
|
|
81704
81704
|
"../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module) {
|
|
81705
81705
|
"use strict";
|
|
81706
|
-
var
|
|
81706
|
+
var ms2 = require_ms();
|
|
81707
81707
|
module.exports = function(time2, iat) {
|
|
81708
81708
|
var timestamp = iat || Math.floor(Date.now() / 1e3);
|
|
81709
81709
|
if (typeof time2 === "string") {
|
|
81710
|
-
var milliseconds =
|
|
81710
|
+
var milliseconds = ms2(time2);
|
|
81711
81711
|
if (typeof milliseconds === "undefined") {
|
|
81712
81712
|
return;
|
|
81713
81713
|
}
|
|
@@ -96245,7 +96245,7 @@ var require_dist = __commonJS({
|
|
|
96245
96245
|
};
|
|
96246
96246
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
96247
96247
|
exports2.Agent = void 0;
|
|
96248
|
-
var
|
|
96248
|
+
var net2 = __importStar2(__require("net"));
|
|
96249
96249
|
var http3 = __importStar2(__require("http"));
|
|
96250
96250
|
var https_1 = __require("https");
|
|
96251
96251
|
__exportStar2(require_helpers2(), exports2);
|
|
@@ -96285,7 +96285,7 @@ var require_dist = __commonJS({
|
|
|
96285
96285
|
if (!this.sockets[name]) {
|
|
96286
96286
|
this.sockets[name] = [];
|
|
96287
96287
|
}
|
|
96288
|
-
const fakeSocket = new
|
|
96288
|
+
const fakeSocket = new net2.Socket({ writable: false });
|
|
96289
96289
|
this.sockets[name].push(fakeSocket);
|
|
96290
96290
|
this.totalSocketCount++;
|
|
96291
96291
|
return fakeSocket;
|
|
@@ -96497,7 +96497,7 @@ var require_dist2 = __commonJS({
|
|
|
96497
96497
|
};
|
|
96498
96498
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
96499
96499
|
exports2.HttpsProxyAgent = void 0;
|
|
96500
|
-
var
|
|
96500
|
+
var net2 = __importStar2(__require("net"));
|
|
96501
96501
|
var tls = __importStar2(__require("tls"));
|
|
96502
96502
|
var assert_1 = __importDefault2(__require("assert"));
|
|
96503
96503
|
var debug_1 = __importDefault2(require_src2());
|
|
@@ -96506,7 +96506,7 @@ var require_dist2 = __commonJS({
|
|
|
96506
96506
|
var parse_proxy_response_1 = require_parse_proxy_response();
|
|
96507
96507
|
var debug = (0, debug_1.default)("https-proxy-agent");
|
|
96508
96508
|
var setServernameFromNonIpHost = (options) => {
|
|
96509
|
-
if (options.servername === void 0 && options.host && !
|
|
96509
|
+
if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
|
|
96510
96510
|
return {
|
|
96511
96511
|
...options,
|
|
96512
96512
|
servername: options.host
|
|
@@ -96546,10 +96546,10 @@ var require_dist2 = __commonJS({
|
|
|
96546
96546
|
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
96547
96547
|
} else {
|
|
96548
96548
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
96549
|
-
socket =
|
|
96549
|
+
socket = net2.connect(this.connectOpts);
|
|
96550
96550
|
}
|
|
96551
96551
|
const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
|
|
96552
|
-
const host =
|
|
96552
|
+
const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
96553
96553
|
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
|
|
96554
96554
|
`;
|
|
96555
96555
|
if (proxy.username || proxy.password) {
|
|
@@ -96582,7 +96582,7 @@ var require_dist2 = __commonJS({
|
|
|
96582
96582
|
return socket;
|
|
96583
96583
|
}
|
|
96584
96584
|
socket.destroy();
|
|
96585
|
-
const fakeSocket = new
|
|
96585
|
+
const fakeSocket = new net2.Socket({ writable: false });
|
|
96586
96586
|
fakeSocket.readable = true;
|
|
96587
96587
|
req.once("socket", (s7) => {
|
|
96588
96588
|
debug("Replaying proxy buffer for failed request");
|
|
@@ -96647,7 +96647,7 @@ var require_dist3 = __commonJS({
|
|
|
96647
96647
|
};
|
|
96648
96648
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
96649
96649
|
exports2.HttpProxyAgent = void 0;
|
|
96650
|
-
var
|
|
96650
|
+
var net2 = __importStar2(__require("net"));
|
|
96651
96651
|
var tls = __importStar2(__require("tls"));
|
|
96652
96652
|
var debug_1 = __importDefault2(require_src2());
|
|
96653
96653
|
var events_1 = __require("events");
|
|
@@ -96720,7 +96720,7 @@ var require_dist3 = __commonJS({
|
|
|
96720
96720
|
socket = tls.connect(this.connectOpts);
|
|
96721
96721
|
} else {
|
|
96722
96722
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
96723
|
-
socket =
|
|
96723
|
+
socket = net2.connect(this.connectOpts);
|
|
96724
96724
|
}
|
|
96725
96725
|
await (0, events_1.once)(socket, "connect");
|
|
96726
96726
|
return socket;
|
|
@@ -135599,7 +135599,7 @@ var require_connection = __commonJS({
|
|
|
135599
135599
|
var _crypto = _interopRequireDefault(__require("crypto"));
|
|
135600
135600
|
var _os = _interopRequireDefault(__require("os"));
|
|
135601
135601
|
var tls = _interopRequireWildcard(__require("tls"));
|
|
135602
|
-
var
|
|
135602
|
+
var net2 = _interopRequireWildcard(__require("net"));
|
|
135603
135603
|
var _dns = _interopRequireDefault(__require("dns"));
|
|
135604
135604
|
var _constants = _interopRequireDefault(__require("constants"));
|
|
135605
135605
|
var _stream = __require("stream");
|
|
@@ -136648,7 +136648,7 @@ var require_connection = __commonJS({
|
|
|
136648
136648
|
async wrapWithTls(socket, signal) {
|
|
136649
136649
|
signal.throwIfAborted();
|
|
136650
136650
|
const secureContext = tls.createSecureContext(this.secureContextOptions);
|
|
136651
|
-
const serverName = !
|
|
136651
|
+
const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
|
|
136652
136652
|
const encryptOptions = {
|
|
136653
136653
|
host: this.config.server,
|
|
136654
136654
|
socket,
|
|
@@ -139557,6 +139557,7 @@ __export(connections_exports, {
|
|
|
139557
139557
|
prepareGelDB: () => prepareGelDB,
|
|
139558
139558
|
preparePostgresDB: () => preparePostgresDB
|
|
139559
139559
|
});
|
|
139560
|
+
import net from "net";
|
|
139560
139561
|
function parseMssqlUrl(url) {
|
|
139561
139562
|
return {
|
|
139562
139563
|
user: url.username,
|
|
@@ -139570,7 +139571,7 @@ function parseMssqlUrl(url) {
|
|
|
139570
139571
|
}
|
|
139571
139572
|
};
|
|
139572
139573
|
}
|
|
139573
|
-
var normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
|
|
139574
|
+
var ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
|
|
139574
139575
|
var init_connections = __esm({
|
|
139575
139576
|
"src/cli/connections.ts"() {
|
|
139576
139577
|
"use strict";
|
|
@@ -139581,6 +139582,7 @@ var init_connections = __esm({
|
|
|
139581
139582
|
init_when_json_met_bigint();
|
|
139582
139583
|
init_utils3();
|
|
139583
139584
|
init_outputs();
|
|
139585
|
+
ms = (a6, b6) => Number(b6 - a6) / 1e6;
|
|
139584
139586
|
normalisePGliteUrl = (it) => {
|
|
139585
139587
|
if (it.startsWith("file:")) {
|
|
139586
139588
|
return it.substring(5);
|
|
@@ -139735,13 +139737,13 @@ var init_connections = __esm({
|
|
|
139735
139737
|
return pg.types.getTypeParser(typeId, format2);
|
|
139736
139738
|
}
|
|
139737
139739
|
};
|
|
139738
|
-
const
|
|
139739
|
-
const db = drizzle({ client });
|
|
139740
|
+
const pool = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
|
|
139741
|
+
const db = drizzle({ client: pool });
|
|
139740
139742
|
const migrateFn = async (config) => {
|
|
139741
139743
|
return migrate(db, config);
|
|
139742
139744
|
};
|
|
139743
139745
|
const query = async (sql, params) => {
|
|
139744
|
-
const result2 = await
|
|
139746
|
+
const result2 = await pool.query({
|
|
139745
139747
|
text: sql,
|
|
139746
139748
|
values: params ?? [],
|
|
139747
139749
|
types: types3
|
|
@@ -139751,7 +139753,7 @@ var init_connections = __esm({
|
|
|
139751
139753
|
return result2.rows;
|
|
139752
139754
|
};
|
|
139753
139755
|
const proxy = async (params) => {
|
|
139754
|
-
const result2 = await
|
|
139756
|
+
const result2 = await pool.query({
|
|
139755
139757
|
text: params.sql,
|
|
139756
139758
|
values: params.params,
|
|
139757
139759
|
...params.mode === "array" && { rowMode: "array" },
|
|
@@ -139763,7 +139765,7 @@ var init_connections = __esm({
|
|
|
139763
139765
|
};
|
|
139764
139766
|
const transactionProxy = async (queries) => {
|
|
139765
139767
|
const results = [];
|
|
139766
|
-
const tx = await
|
|
139768
|
+
const tx = await pool.connect();
|
|
139767
139769
|
try {
|
|
139768
139770
|
await tx.query("BEGIN");
|
|
139769
139771
|
for (const query2 of queries) {
|
|
@@ -139782,7 +139784,72 @@ var init_connections = __esm({
|
|
|
139782
139784
|
}
|
|
139783
139785
|
return results;
|
|
139784
139786
|
};
|
|
139785
|
-
|
|
139787
|
+
const benchmarkQuery = async (sql, params) => {
|
|
139788
|
+
const explainResult = await pool.query({
|
|
139789
|
+
text: `EXPLAIN ANALYZE ${sql}`,
|
|
139790
|
+
values: params ?? [],
|
|
139791
|
+
types: types3
|
|
139792
|
+
});
|
|
139793
|
+
const stringifiedResult = JSON.stringify(explainResult.rows);
|
|
139794
|
+
const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
|
|
139795
|
+
const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
|
|
139796
|
+
const planningTime = Number(planningMatch[1]);
|
|
139797
|
+
const executionTime = Number(executionMatch[1]);
|
|
139798
|
+
let startAt = 0n;
|
|
139799
|
+
let tcpConnectedAt = 0n;
|
|
139800
|
+
let tlsConnectedAt = null;
|
|
139801
|
+
let dbReadyAt = 0n;
|
|
139802
|
+
let querySentAt = 0n;
|
|
139803
|
+
let firstDataAt = 0n;
|
|
139804
|
+
let lastDataAt = 0n;
|
|
139805
|
+
let bytesReceived = 0;
|
|
139806
|
+
const client = "url" in credentials ? new pg.Client({ connectionString: credentials.url }) : new pg.Client({ ...credentials, ssl });
|
|
139807
|
+
client.connection.once("connect", () => {
|
|
139808
|
+
tcpConnectedAt = process.hrtime.bigint();
|
|
139809
|
+
});
|
|
139810
|
+
client.connection.prependOnceListener("sslconnect", () => {
|
|
139811
|
+
tlsConnectedAt = process.hrtime.bigint();
|
|
139812
|
+
});
|
|
139813
|
+
client.connection.prependOnceListener("readyForQuery", () => {
|
|
139814
|
+
dbReadyAt = process.hrtime.bigint();
|
|
139815
|
+
});
|
|
139816
|
+
client.connection.addListener("rowDescription", (data) => {
|
|
139817
|
+
if (firstDataAt === 0n) {
|
|
139818
|
+
firstDataAt = process.hrtime.bigint();
|
|
139819
|
+
}
|
|
139820
|
+
bytesReceived += data.length;
|
|
139821
|
+
});
|
|
139822
|
+
client.connection.addListener("dataRow", (data) => {
|
|
139823
|
+
bytesReceived += data.length;
|
|
139824
|
+
});
|
|
139825
|
+
client.connection.addListener("commandComplete", () => {
|
|
139826
|
+
lastDataAt = process.hrtime.bigint();
|
|
139827
|
+
});
|
|
139828
|
+
startAt = process.hrtime.bigint();
|
|
139829
|
+
await client.connect();
|
|
139830
|
+
querySentAt = process.hrtime.bigint();
|
|
139831
|
+
await client.query(sql, params);
|
|
139832
|
+
await client.end();
|
|
139833
|
+
return {
|
|
139834
|
+
tcpHandshake: ms(startAt, tcpConnectedAt),
|
|
139835
|
+
tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
|
|
139836
|
+
dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
|
|
139837
|
+
planning: planningTime,
|
|
139838
|
+
execution: executionTime,
|
|
139839
|
+
dataDownload: ms(firstDataAt, lastDataAt) + ms(querySentAt, firstDataAt) - executionTime - planningTime,
|
|
139840
|
+
total: ms(startAt, lastDataAt),
|
|
139841
|
+
dataSize: bytesReceived
|
|
139842
|
+
};
|
|
139843
|
+
};
|
|
139844
|
+
const benchmarkProxy = async ({ sql, params }, repeats) => {
|
|
139845
|
+
const results = [];
|
|
139846
|
+
for (let i7 = 0; i7 < repeats; i7++) {
|
|
139847
|
+
const r7 = await benchmarkQuery(sql, params);
|
|
139848
|
+
results.push(r7);
|
|
139849
|
+
}
|
|
139850
|
+
return results;
|
|
139851
|
+
};
|
|
139852
|
+
return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
|
|
139786
139853
|
}
|
|
139787
139854
|
if (await checkPackage("postgres")) {
|
|
139788
139855
|
console.log(
|
|
@@ -140045,6 +140112,7 @@ var init_connections = __esm({
|
|
|
140045
140112
|
console.error(
|
|
140046
140113
|
"To connect to Postgres database - please install either of 'pg', 'postgres', 'bun', '@neondatabase/serverless' or '@vercel/postgres' drivers"
|
|
140047
140114
|
);
|
|
140115
|
+
console.warn("For the 'bun' driver, run your script using: bun --bun");
|
|
140048
140116
|
process.exit(1);
|
|
140049
140117
|
};
|
|
140050
140118
|
prepareCockroach = async (credentials) => {
|
|
@@ -140276,7 +140344,6 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
140276
140344
|
}
|
|
140277
140345
|
return next();
|
|
140278
140346
|
};
|
|
140279
|
-
await connection.connect();
|
|
140280
140347
|
const query = async (sql, params) => {
|
|
140281
140348
|
const res = await connection.execute({
|
|
140282
140349
|
sql,
|
|
@@ -140316,11 +140383,111 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
140316
140383
|
}
|
|
140317
140384
|
return results;
|
|
140318
140385
|
};
|
|
140386
|
+
const benchmarkQuery = async (sql, params) => {
|
|
140387
|
+
const { createConnection: createConnection2 } = await import("mysql2");
|
|
140388
|
+
const explainResult = await connection.query({
|
|
140389
|
+
sql: `EXPLAIN ANALYZE ${sql}`,
|
|
140390
|
+
values: params ?? [],
|
|
140391
|
+
typeCast
|
|
140392
|
+
});
|
|
140393
|
+
const stringifiedResult = JSON.stringify(explainResult[0]);
|
|
140394
|
+
const timeMatch = stringifiedResult.match(
|
|
140395
|
+
/actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
|
|
140396
|
+
);
|
|
140397
|
+
const lastRowTime = Number(timeMatch[2]);
|
|
140398
|
+
const executionTime = lastRowTime;
|
|
140399
|
+
let startAt = 0n;
|
|
140400
|
+
let tcpConnectedAt = 0n;
|
|
140401
|
+
let tlsConnectedAt = null;
|
|
140402
|
+
let querySentAt = 0n;
|
|
140403
|
+
let firstDataAt = 0n;
|
|
140404
|
+
let lastDataAt = 0n;
|
|
140405
|
+
let bytesReceived = 0;
|
|
140406
|
+
const createStream = ({ config }) => {
|
|
140407
|
+
let stream;
|
|
140408
|
+
if (config.socketPath) {
|
|
140409
|
+
stream = net.connect(config.socketPath);
|
|
140410
|
+
} else {
|
|
140411
|
+
stream = net.connect(config.port, config.host);
|
|
140412
|
+
}
|
|
140413
|
+
if (config.enableKeepAlive) {
|
|
140414
|
+
stream.on("connect", () => {
|
|
140415
|
+
stream.setKeepAlive(true, config.keepAliveInitialDelay);
|
|
140416
|
+
});
|
|
140417
|
+
}
|
|
140418
|
+
stream.setNoDelay(true);
|
|
140419
|
+
stream.once("connect", () => {
|
|
140420
|
+
tcpConnectedAt = process.hrtime.bigint();
|
|
140421
|
+
});
|
|
140422
|
+
return stream;
|
|
140423
|
+
};
|
|
140424
|
+
startAt = process.hrtime.bigint();
|
|
140425
|
+
const newConnection = result2.url ? createConnection2({
|
|
140426
|
+
// debug: true,
|
|
140427
|
+
uri: result2.url,
|
|
140428
|
+
stream: createStream
|
|
140429
|
+
}) : createConnection2({
|
|
140430
|
+
...result2.credentials,
|
|
140431
|
+
stream: createStream
|
|
140432
|
+
});
|
|
140433
|
+
await new Promise((resolve2, reject) => {
|
|
140434
|
+
newConnection.connect((err2) => {
|
|
140435
|
+
tlsConnectedAt = process.hrtime.bigint();
|
|
140436
|
+
if (err2) {
|
|
140437
|
+
reject(err2);
|
|
140438
|
+
} else {
|
|
140439
|
+
resolve2();
|
|
140440
|
+
}
|
|
140441
|
+
});
|
|
140442
|
+
});
|
|
140443
|
+
querySentAt = process.hrtime.bigint();
|
|
140444
|
+
await new Promise((resolve2, reject) => {
|
|
140445
|
+
const query2 = newConnection.query({
|
|
140446
|
+
sql,
|
|
140447
|
+
values: params ?? [],
|
|
140448
|
+
typeCast
|
|
140449
|
+
// rowsAsArray: true,
|
|
140450
|
+
});
|
|
140451
|
+
query2.on("error", (err2) => {
|
|
140452
|
+
reject(err2);
|
|
140453
|
+
});
|
|
140454
|
+
query2.on("fields", (fields) => {
|
|
140455
|
+
if (firstDataAt === 0n) {
|
|
140456
|
+
firstDataAt = process.hrtime.bigint();
|
|
140457
|
+
}
|
|
140458
|
+
bytesReceived += fields[0]._buf.length;
|
|
140459
|
+
});
|
|
140460
|
+
query2.on("end", () => {
|
|
140461
|
+
lastDataAt = process.hrtime.bigint();
|
|
140462
|
+
resolve2();
|
|
140463
|
+
newConnection.end();
|
|
140464
|
+
});
|
|
140465
|
+
});
|
|
140466
|
+
return {
|
|
140467
|
+
tcpHandshake: ms(startAt, tcpConnectedAt),
|
|
140468
|
+
tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
|
|
140469
|
+
dbHandshake: null,
|
|
140470
|
+
planning: null,
|
|
140471
|
+
execution: executionTime,
|
|
140472
|
+
dataDownload: ms(firstDataAt, lastDataAt) + ms(querySentAt, firstDataAt) - executionTime,
|
|
140473
|
+
total: ms(startAt, lastDataAt),
|
|
140474
|
+
dataSize: bytesReceived
|
|
140475
|
+
};
|
|
140476
|
+
};
|
|
140477
|
+
const benchmarkProxy = async ({ sql, params }, repeats) => {
|
|
140478
|
+
const results = [];
|
|
140479
|
+
for (let i7 = 0; i7 < repeats; i7++) {
|
|
140480
|
+
const r7 = await benchmarkQuery(sql, params);
|
|
140481
|
+
results.push(r7);
|
|
140482
|
+
}
|
|
140483
|
+
return results;
|
|
140484
|
+
};
|
|
140319
140485
|
return {
|
|
140320
140486
|
db: { query },
|
|
140321
140487
|
packageName: "mysql2",
|
|
140322
140488
|
proxy,
|
|
140323
140489
|
transactionProxy,
|
|
140490
|
+
benchmarkProxy,
|
|
140324
140491
|
database: result2.database,
|
|
140325
140492
|
migrate: migrateFn
|
|
140326
140493
|
};
|
|
@@ -140426,6 +140593,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
140426
140593
|
console.error(
|
|
140427
140594
|
"To connect to MySQL database - please install either of 'mysql2', 'bun' or '@planetscale/database' drivers"
|
|
140428
140595
|
);
|
|
140596
|
+
console.warn("For the 'bun' driver, run your script using: bun --bun");
|
|
140429
140597
|
process.exit(1);
|
|
140430
140598
|
};
|
|
140431
140599
|
parseMssqlCredentials = (credentials) => {
|
|
@@ -140874,6 +141042,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
140874
141042
|
console.log(
|
|
140875
141043
|
"Please install either 'better-sqlite3', 'bun', '@libsql/client' or '@tursodatabase/database' for Drizzle Kit to connect to SQLite databases"
|
|
140876
141044
|
);
|
|
141045
|
+
console.warn("For the 'bun' driver, run your script using: bun --bun");
|
|
140877
141046
|
process.exit(1);
|
|
140878
141047
|
};
|
|
140879
141048
|
connectToLibSQL = async (credentials) => {
|
|
@@ -140978,7 +141147,7 @@ import { getTableConfig as singlestoreTableConfig, SingleStoreTable } from "driz
|
|
|
140978
141147
|
import { getTableConfig as sqliteTableConfig, SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
140979
141148
|
import fs9 from "fs";
|
|
140980
141149
|
import { createServer } from "https";
|
|
140981
|
-
var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
|
|
141150
|
+
var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
|
|
140982
141151
|
var init_studio = __esm({
|
|
140983
141152
|
"src/cli/commands/studio.ts"() {
|
|
140984
141153
|
"use strict";
|
|
@@ -141192,6 +141361,7 @@ var init_studio = __esm({
|
|
|
141192
141361
|
packageName: db.packageName,
|
|
141193
141362
|
proxy: db.proxy,
|
|
141194
141363
|
transactionProxy: db.transactionProxy,
|
|
141364
|
+
benchmarkProxy: db.benchmarkProxy,
|
|
141195
141365
|
customDefaults,
|
|
141196
141366
|
schema: pgSchema2,
|
|
141197
141367
|
relations,
|
|
@@ -141201,7 +141371,7 @@ var init_studio = __esm({
|
|
|
141201
141371
|
};
|
|
141202
141372
|
drizzleForMySQL = async (credentials, mysqlSchema, relations, schemaFiles, casing2) => {
|
|
141203
141373
|
const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
141204
|
-
const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
|
|
141374
|
+
const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);
|
|
141205
141375
|
const customDefaults = getCustomDefaults(mysqlSchema, casing2);
|
|
141206
141376
|
let dbUrl;
|
|
141207
141377
|
if ("url" in credentials) {
|
|
@@ -141217,6 +141387,7 @@ var init_studio = __esm({
|
|
|
141217
141387
|
databaseName: database,
|
|
141218
141388
|
proxy,
|
|
141219
141389
|
transactionProxy,
|
|
141390
|
+
benchmarkProxy,
|
|
141220
141391
|
customDefaults,
|
|
141221
141392
|
schema: mysqlSchema,
|
|
141222
141393
|
relations,
|
|
@@ -141386,6 +141557,23 @@ var init_studio = __esm({
|
|
|
141386
141557
|
]).optional()
|
|
141387
141558
|
}).array()
|
|
141388
141559
|
});
|
|
141560
|
+
benchmarkProxySchema = external_exports.object({
|
|
141561
|
+
type: external_exports.literal("bproxy"),
|
|
141562
|
+
data: external_exports.object({
|
|
141563
|
+
query: external_exports.object({
|
|
141564
|
+
sql: external_exports.string(),
|
|
141565
|
+
params: external_exports.array(external_exports.any()).optional(),
|
|
141566
|
+
method: external_exports.union([
|
|
141567
|
+
external_exports.literal("values"),
|
|
141568
|
+
external_exports.literal("get"),
|
|
141569
|
+
external_exports.literal("all"),
|
|
141570
|
+
external_exports.literal("run"),
|
|
141571
|
+
external_exports.literal("execute")
|
|
141572
|
+
]).optional()
|
|
141573
|
+
}),
|
|
141574
|
+
repeats: external_exports.number().min(1).optional()
|
|
141575
|
+
})
|
|
141576
|
+
});
|
|
141389
141577
|
defaultsSchema = external_exports.object({
|
|
141390
141578
|
type: external_exports.literal("defaults"),
|
|
141391
141579
|
data: external_exports.array(
|
|
@@ -141400,6 +141588,7 @@ var init_studio = __esm({
|
|
|
141400
141588
|
init2,
|
|
141401
141589
|
proxySchema,
|
|
141402
141590
|
transactionProxySchema,
|
|
141591
|
+
benchmarkProxySchema,
|
|
141403
141592
|
defaultsSchema
|
|
141404
141593
|
]);
|
|
141405
141594
|
jsonStringify = (data) => {
|
|
@@ -141422,6 +141611,7 @@ var init_studio = __esm({
|
|
|
141422
141611
|
databaseName,
|
|
141423
141612
|
proxy,
|
|
141424
141613
|
transactionProxy,
|
|
141614
|
+
benchmarkProxy,
|
|
141425
141615
|
customDefaults,
|
|
141426
141616
|
schema: drizzleSchema,
|
|
141427
141617
|
relations,
|
|
@@ -141485,7 +141675,7 @@ var init_studio = __esm({
|
|
|
141485
141675
|
console.warn("Error message:", error3.message);
|
|
141486
141676
|
}
|
|
141487
141677
|
return c6.json({
|
|
141488
|
-
version: "6.
|
|
141678
|
+
version: "6.3",
|
|
141489
141679
|
dialect: dialect6,
|
|
141490
141680
|
driver: driver2,
|
|
141491
141681
|
packageName,
|
|
@@ -141523,6 +141713,21 @@ var init_studio = __esm({
|
|
|
141523
141713
|
}
|
|
141524
141714
|
);
|
|
141525
141715
|
}
|
|
141716
|
+
if (type === "bproxy") {
|
|
141717
|
+
if (!benchmarkProxy) {
|
|
141718
|
+
throw new Error("Benchmark proxy is not configured for this database.");
|
|
141719
|
+
}
|
|
141720
|
+
const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
|
|
141721
|
+
const res = jsonStringify(result2);
|
|
141722
|
+
return c6.body(
|
|
141723
|
+
res,
|
|
141724
|
+
{
|
|
141725
|
+
headers: {
|
|
141726
|
+
"Content-Type": "application/json"
|
|
141727
|
+
}
|
|
141728
|
+
}
|
|
141729
|
+
);
|
|
141730
|
+
}
|
|
141526
141731
|
if (type === "defaults") {
|
|
141527
141732
|
const columns = body.data;
|
|
141528
141733
|
const result2 = columns.map((column7) => {
|