drizzle-kit 1.0.0-beta.2-278d7e6 → 1.0.0-beta.2-9848003
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-mysql.js +257 -387
- package/api-mysql.mjs +257 -387
- package/api-postgres.js +295 -417
- package/api-postgres.mjs +295 -417
- package/api-sqlite.js +257 -387
- package/api-sqlite.mjs +257 -387
- package/bin.cjs +404 -448
- package/index.d.mts +6 -1
- package/index.d.ts +6 -1
- package/package.json +3 -1
package/bin.cjs
CHANGED
|
@@ -5892,7 +5892,8 @@ var init_schemaValidator = __esm({
|
|
|
5892
5892
|
"singlestore",
|
|
5893
5893
|
"gel",
|
|
5894
5894
|
"mssql",
|
|
5895
|
-
"cockroach"
|
|
5895
|
+
"cockroach",
|
|
5896
|
+
"duckdb"
|
|
5896
5897
|
];
|
|
5897
5898
|
dialect = enumType(dialects);
|
|
5898
5899
|
}
|
|
@@ -28623,41 +28624,41 @@ var require_ms = __commonJS({
|
|
|
28623
28624
|
return void 0;
|
|
28624
28625
|
}
|
|
28625
28626
|
}
|
|
28626
|
-
function fmtShort(
|
|
28627
|
-
var msAbs = Math.abs(
|
|
28627
|
+
function fmtShort(ms) {
|
|
28628
|
+
var msAbs = Math.abs(ms);
|
|
28628
28629
|
if (msAbs >= d5) {
|
|
28629
|
-
return Math.round(
|
|
28630
|
+
return Math.round(ms / d5) + "d";
|
|
28630
28631
|
}
|
|
28631
28632
|
if (msAbs >= h6) {
|
|
28632
|
-
return Math.round(
|
|
28633
|
+
return Math.round(ms / h6) + "h";
|
|
28633
28634
|
}
|
|
28634
28635
|
if (msAbs >= m6) {
|
|
28635
|
-
return Math.round(
|
|
28636
|
+
return Math.round(ms / m6) + "m";
|
|
28636
28637
|
}
|
|
28637
28638
|
if (msAbs >= s6) {
|
|
28638
|
-
return Math.round(
|
|
28639
|
+
return Math.round(ms / s6) + "s";
|
|
28639
28640
|
}
|
|
28640
|
-
return
|
|
28641
|
+
return ms + "ms";
|
|
28641
28642
|
}
|
|
28642
|
-
function fmtLong(
|
|
28643
|
-
var msAbs = Math.abs(
|
|
28643
|
+
function fmtLong(ms) {
|
|
28644
|
+
var msAbs = Math.abs(ms);
|
|
28644
28645
|
if (msAbs >= d5) {
|
|
28645
|
-
return plural2(
|
|
28646
|
+
return plural2(ms, msAbs, d5, "day");
|
|
28646
28647
|
}
|
|
28647
28648
|
if (msAbs >= h6) {
|
|
28648
|
-
return plural2(
|
|
28649
|
+
return plural2(ms, msAbs, h6, "hour");
|
|
28649
28650
|
}
|
|
28650
28651
|
if (msAbs >= m6) {
|
|
28651
|
-
return plural2(
|
|
28652
|
+
return plural2(ms, msAbs, m6, "minute");
|
|
28652
28653
|
}
|
|
28653
28654
|
if (msAbs >= s6) {
|
|
28654
|
-
return plural2(
|
|
28655
|
+
return plural2(ms, msAbs, s6, "second");
|
|
28655
28656
|
}
|
|
28656
|
-
return
|
|
28657
|
+
return ms + " ms";
|
|
28657
28658
|
}
|
|
28658
|
-
function plural2(
|
|
28659
|
+
function plural2(ms, msAbs, n5, name) {
|
|
28659
28660
|
var isPlural = msAbs >= n5 * 1.5;
|
|
28660
|
-
return Math.round(
|
|
28661
|
+
return Math.round(ms / n5) + " " + name + (isPlural ? "s" : "");
|
|
28661
28662
|
}
|
|
28662
28663
|
}
|
|
28663
28664
|
});
|
|
@@ -28700,8 +28701,8 @@ var require_common2 = __commonJS({
|
|
|
28700
28701
|
}
|
|
28701
28702
|
const self2 = debug;
|
|
28702
28703
|
const curr = Number(/* @__PURE__ */ new Date());
|
|
28703
|
-
const
|
|
28704
|
-
self2.diff =
|
|
28704
|
+
const ms = curr - (prevTime || curr);
|
|
28705
|
+
self2.diff = ms;
|
|
28705
28706
|
self2.prev = prevTime;
|
|
28706
28707
|
self2.curr = curr;
|
|
28707
28708
|
prevTime = curr;
|
|
@@ -34304,6 +34305,9 @@ var init_utils_node = __esm({
|
|
|
34304
34305
|
case "gel":
|
|
34305
34306
|
throw Error("gel validator is not implemented yet");
|
|
34306
34307
|
// TODO
|
|
34308
|
+
case "duckdb":
|
|
34309
|
+
throw Error("duckdb validator is not implemented yet");
|
|
34310
|
+
// TODO
|
|
34307
34311
|
default:
|
|
34308
34312
|
assertUnreachable(dialect6);
|
|
34309
34313
|
}
|
|
@@ -35839,8 +35843,8 @@ ${sql}
|
|
|
35839
35843
|
`;
|
|
35840
35844
|
return content;
|
|
35841
35845
|
};
|
|
35842
|
-
prepareSnapshotFolderName = (
|
|
35843
|
-
const now =
|
|
35846
|
+
prepareSnapshotFolderName = (ms) => {
|
|
35847
|
+
const now = ms ? new Date(ms) : /* @__PURE__ */ new Date();
|
|
35844
35848
|
return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
|
|
35845
35849
|
now.getUTCDate()
|
|
35846
35850
|
)}${two(now.getUTCHours())}${two(now.getUTCMinutes())}${two(
|
|
@@ -55589,7 +55593,7 @@ var require_websocket = __commonJS({
|
|
|
55589
55593
|
var EventEmitter = require("events");
|
|
55590
55594
|
var https2 = require("https");
|
|
55591
55595
|
var http3 = require("http");
|
|
55592
|
-
var
|
|
55596
|
+
var net = require("net");
|
|
55593
55597
|
var tls = require("tls");
|
|
55594
55598
|
var { randomBytes, createHash: createHash2 } = require("crypto");
|
|
55595
55599
|
var { Duplex, Readable: Readable2 } = require("stream");
|
|
@@ -56320,12 +56324,12 @@ var require_websocket = __commonJS({
|
|
|
56320
56324
|
}
|
|
56321
56325
|
function netConnect(options) {
|
|
56322
56326
|
options.path = options.socketPath;
|
|
56323
|
-
return
|
|
56327
|
+
return net.connect(options);
|
|
56324
56328
|
}
|
|
56325
56329
|
function tlsConnect(options) {
|
|
56326
56330
|
options.path = void 0;
|
|
56327
56331
|
if (!options.servername && options.servername !== "") {
|
|
56328
|
-
options.servername =
|
|
56332
|
+
options.servername = net.isIP(options.host) ? "" : options.host;
|
|
56329
56333
|
}
|
|
56330
56334
|
return tls.connect(options);
|
|
56331
56335
|
}
|
|
@@ -58616,7 +58620,7 @@ var require_dist_cjs14 = __commonJS({
|
|
|
58616
58620
|
return transformedHeaders;
|
|
58617
58621
|
};
|
|
58618
58622
|
var timing = {
|
|
58619
|
-
setTimeout: (cb,
|
|
58623
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
58620
58624
|
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
58621
58625
|
};
|
|
58622
58626
|
var DEFER_EVENT_LISTENER_TIME$2 = 1e3;
|
|
@@ -61675,13 +61679,13 @@ var init_schema_date_utils = __esm({
|
|
|
61675
61679
|
if (!matches) {
|
|
61676
61680
|
throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
|
|
61677
61681
|
}
|
|
61678
|
-
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, ,
|
|
61682
|
+
const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
|
|
61679
61683
|
range(monthStr, 1, 12);
|
|
61680
61684
|
range(dayStr, 1, 31);
|
|
61681
61685
|
range(hours, 0, 23);
|
|
61682
61686
|
range(minutes, 0, 59);
|
|
61683
61687
|
range(seconds, 0, 60);
|
|
61684
|
-
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(
|
|
61688
|
+
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1e3) : 0));
|
|
61685
61689
|
date2.setUTCFullYear(Number(yearStr));
|
|
61686
61690
|
if (offsetStr.toUpperCase() != "Z") {
|
|
61687
61691
|
const [, sign, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
|
|
@@ -81572,8 +81576,8 @@ var require_datetime2 = __commonJS({
|
|
|
81572
81576
|
if (!(object instanceof Date)) {
|
|
81573
81577
|
throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
|
|
81574
81578
|
}
|
|
81575
|
-
const
|
|
81576
|
-
const us =
|
|
81579
|
+
const ms = object.getTime() - TIMESHIFT;
|
|
81580
|
+
const us = ms * 1e3;
|
|
81577
81581
|
buf.writeInt32(8);
|
|
81578
81582
|
buf.writeInt64(us);
|
|
81579
81583
|
}
|
|
@@ -81583,12 +81587,12 @@ var require_datetime2 = __commonJS({
|
|
|
81583
81587
|
return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
|
|
81584
81588
|
}
|
|
81585
81589
|
const us = Number(buf.readBigInt64());
|
|
81586
|
-
let
|
|
81587
|
-
if (Math.abs(us % 1e3) === 500 && Math.abs(
|
|
81588
|
-
|
|
81590
|
+
let ms = Math.round(us / 1e3);
|
|
81591
|
+
if (Math.abs(us % 1e3) === 500 && Math.abs(ms) % 2 === 1) {
|
|
81592
|
+
ms -= 1;
|
|
81589
81593
|
}
|
|
81590
|
-
|
|
81591
|
-
return new Date(
|
|
81594
|
+
ms += TIMESHIFT;
|
|
81595
|
+
return new Date(ms);
|
|
81592
81596
|
}
|
|
81593
81597
|
};
|
|
81594
81598
|
exports2.DateTimeCodec = DateTimeCodec;
|
|
@@ -81609,8 +81613,8 @@ var require_datetime2 = __commonJS({
|
|
|
81609
81613
|
if (!(object instanceof datetime_1.LocalDateTime)) {
|
|
81610
81614
|
throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
|
|
81611
81615
|
}
|
|
81612
|
-
const
|
|
81613
|
-
let us =
|
|
81616
|
+
const ms = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
|
|
81617
|
+
let us = ms * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
|
|
81614
81618
|
if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
|
|
81615
81619
|
us += 1n;
|
|
81616
81620
|
}
|
|
@@ -81624,13 +81628,13 @@ var require_datetime2 = __commonJS({
|
|
|
81624
81628
|
}
|
|
81625
81629
|
const bi_ms = bi_us / 1000n;
|
|
81626
81630
|
let us = Number(bi_us - bi_ms * 1000n);
|
|
81627
|
-
let
|
|
81631
|
+
let ms = Number(bi_ms);
|
|
81628
81632
|
if (us < 0) {
|
|
81629
81633
|
us += 1e3;
|
|
81630
|
-
|
|
81634
|
+
ms -= 1;
|
|
81631
81635
|
}
|
|
81632
|
-
|
|
81633
|
-
const date2 = new Date(
|
|
81636
|
+
ms += TIMESHIFT;
|
|
81637
|
+
const date2 = new Date(ms);
|
|
81634
81638
|
return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
|
|
81635
81639
|
}
|
|
81636
81640
|
};
|
|
@@ -81692,13 +81696,13 @@ var require_datetime2 = __commonJS({
|
|
|
81692
81696
|
}
|
|
81693
81697
|
let us = Number(bius);
|
|
81694
81698
|
let seconds = Math.floor(us / 1e6);
|
|
81695
|
-
const
|
|
81696
|
-
us = us % 1e6 -
|
|
81699
|
+
const ms = Math.floor(us % 1e6 / 1e3);
|
|
81700
|
+
us = us % 1e6 - ms * 1e3;
|
|
81697
81701
|
let minutes = Math.floor(seconds / 60);
|
|
81698
81702
|
seconds = Math.floor(seconds % 60);
|
|
81699
81703
|
const hours = Math.floor(minutes / 60);
|
|
81700
81704
|
minutes = Math.floor(minutes % 60);
|
|
81701
|
-
return new datetime_1.LocalTime(hours, minutes, seconds,
|
|
81705
|
+
return new datetime_1.LocalTime(hours, minutes, seconds, ms, us);
|
|
81702
81706
|
}
|
|
81703
81707
|
};
|
|
81704
81708
|
exports2.LocalTimeCodec = LocalTimeCodec;
|
|
@@ -81775,14 +81779,14 @@ var require_datetime2 = __commonJS({
|
|
|
81775
81779
|
const biMillion = 1000000n;
|
|
81776
81780
|
const biSeconds = bius / biMillion;
|
|
81777
81781
|
let us = Number(bius - biSeconds * biMillion);
|
|
81778
|
-
const
|
|
81782
|
+
const ms = Math.floor(us / 1e3);
|
|
81779
81783
|
us = us % 1e3;
|
|
81780
81784
|
let seconds = Number(biSeconds);
|
|
81781
81785
|
let minutes = Math.floor(seconds / 60);
|
|
81782
81786
|
seconds = Math.floor(seconds % 60);
|
|
81783
81787
|
const hours = Math.floor(minutes / 60);
|
|
81784
81788
|
minutes = Math.floor(minutes % 60);
|
|
81785
|
-
return new datetime_1.Duration(0, 0, 0, 0, hours * sign, minutes * sign, seconds * sign,
|
|
81789
|
+
return new datetime_1.Duration(0, 0, 0, 0, hours * sign, minutes * sign, seconds * sign, ms * sign, us * sign);
|
|
81786
81790
|
}
|
|
81787
81791
|
};
|
|
81788
81792
|
exports2.DurationCodec = DurationCodec;
|
|
@@ -81828,7 +81832,7 @@ var require_datetime2 = __commonJS({
|
|
|
81828
81832
|
const million = BigInt(1e6);
|
|
81829
81833
|
const biSeconds = bius / million;
|
|
81830
81834
|
let us = Number(bius - biSeconds * million);
|
|
81831
|
-
const
|
|
81835
|
+
const ms = Math.trunc(us / 1e3);
|
|
81832
81836
|
us = us % 1e3;
|
|
81833
81837
|
let seconds = Number(biSeconds);
|
|
81834
81838
|
let minutes = Math.trunc(seconds / 60);
|
|
@@ -81839,7 +81843,7 @@ var require_datetime2 = __commonJS({
|
|
|
81839
81843
|
days = Math.trunc(days % 7);
|
|
81840
81844
|
const years = Math.trunc(months2 / 12);
|
|
81841
81845
|
months2 = Math.trunc(months2 % 12);
|
|
81842
|
-
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign, minutes * sign, seconds * sign,
|
|
81846
|
+
return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign, minutes * sign, seconds * sign, ms * sign, us * sign);
|
|
81843
81847
|
}
|
|
81844
81848
|
};
|
|
81845
81849
|
exports2.RelativeDurationCodec = RelativeDurationCodec;
|
|
@@ -106326,11 +106330,11 @@ var require_TokenExpiredError = __commonJS({
|
|
|
106326
106330
|
// ../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js
|
|
106327
106331
|
var require_timespan = __commonJS({
|
|
106328
106332
|
"../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module2) {
|
|
106329
|
-
var
|
|
106333
|
+
var ms = require_ms();
|
|
106330
106334
|
module2.exports = function(time2, iat) {
|
|
106331
106335
|
var timestamp = iat || Math.floor(Date.now() / 1e3);
|
|
106332
106336
|
if (typeof time2 === "string") {
|
|
106333
|
-
var milliseconds =
|
|
106337
|
+
var milliseconds = ms(time2);
|
|
106334
106338
|
if (typeof milliseconds === "undefined") {
|
|
106335
106339
|
return;
|
|
106336
106340
|
}
|
|
@@ -120917,7 +120921,7 @@ var require_dist = __commonJS({
|
|
|
120917
120921
|
};
|
|
120918
120922
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
120919
120923
|
exports2.Agent = void 0;
|
|
120920
|
-
var
|
|
120924
|
+
var net = __importStar2(require("net"));
|
|
120921
120925
|
var http3 = __importStar2(require("http"));
|
|
120922
120926
|
var https_1 = require("https");
|
|
120923
120927
|
__exportStar2(require_helpers2(), exports2);
|
|
@@ -120957,7 +120961,7 @@ var require_dist = __commonJS({
|
|
|
120957
120961
|
if (!this.sockets[name]) {
|
|
120958
120962
|
this.sockets[name] = [];
|
|
120959
120963
|
}
|
|
120960
|
-
const fakeSocket = new
|
|
120964
|
+
const fakeSocket = new net.Socket({ writable: false });
|
|
120961
120965
|
this.sockets[name].push(fakeSocket);
|
|
120962
120966
|
this.totalSocketCount++;
|
|
120963
120967
|
return fakeSocket;
|
|
@@ -121169,7 +121173,7 @@ var require_dist2 = __commonJS({
|
|
|
121169
121173
|
};
|
|
121170
121174
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
121171
121175
|
exports2.HttpsProxyAgent = void 0;
|
|
121172
|
-
var
|
|
121176
|
+
var net = __importStar2(require("net"));
|
|
121173
121177
|
var tls = __importStar2(require("tls"));
|
|
121174
121178
|
var assert_1 = __importDefault2(require("assert"));
|
|
121175
121179
|
var debug_1 = __importDefault2(require_src2());
|
|
@@ -121178,7 +121182,7 @@ var require_dist2 = __commonJS({
|
|
|
121178
121182
|
var parse_proxy_response_1 = require_parse_proxy_response();
|
|
121179
121183
|
var debug = (0, debug_1.default)("https-proxy-agent");
|
|
121180
121184
|
var setServernameFromNonIpHost = (options) => {
|
|
121181
|
-
if (options.servername === void 0 && options.host && !
|
|
121185
|
+
if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
|
|
121182
121186
|
return {
|
|
121183
121187
|
...options,
|
|
121184
121188
|
servername: options.host
|
|
@@ -121218,10 +121222,10 @@ var require_dist2 = __commonJS({
|
|
|
121218
121222
|
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
121219
121223
|
} else {
|
|
121220
121224
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
121221
|
-
socket =
|
|
121225
|
+
socket = net.connect(this.connectOpts);
|
|
121222
121226
|
}
|
|
121223
121227
|
const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
|
|
121224
|
-
const host =
|
|
121228
|
+
const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
121225
121229
|
let payload2 = `CONNECT ${host}:${opts.port} HTTP/1.1\r
|
|
121226
121230
|
`;
|
|
121227
121231
|
if (proxy.username || proxy.password) {
|
|
@@ -121254,7 +121258,7 @@ var require_dist2 = __commonJS({
|
|
|
121254
121258
|
return socket;
|
|
121255
121259
|
}
|
|
121256
121260
|
socket.destroy();
|
|
121257
|
-
const fakeSocket = new
|
|
121261
|
+
const fakeSocket = new net.Socket({ writable: false });
|
|
121258
121262
|
fakeSocket.readable = true;
|
|
121259
121263
|
req.once("socket", (s6) => {
|
|
121260
121264
|
debug("Replaying proxy buffer for failed request");
|
|
@@ -121319,7 +121323,7 @@ var require_dist3 = __commonJS({
|
|
|
121319
121323
|
};
|
|
121320
121324
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
121321
121325
|
exports2.HttpProxyAgent = void 0;
|
|
121322
|
-
var
|
|
121326
|
+
var net = __importStar2(require("net"));
|
|
121323
121327
|
var tls = __importStar2(require("tls"));
|
|
121324
121328
|
var debug_1 = __importDefault2(require_src2());
|
|
121325
121329
|
var events_1 = require("events");
|
|
@@ -121392,7 +121396,7 @@ var require_dist3 = __commonJS({
|
|
|
121392
121396
|
socket = tls.connect(this.connectOpts);
|
|
121393
121397
|
} else {
|
|
121394
121398
|
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
121395
|
-
socket =
|
|
121399
|
+
socket = net.connect(this.connectOpts);
|
|
121396
121400
|
}
|
|
121397
121401
|
await (0, events_1.once)(socket, "connect");
|
|
121398
121402
|
return socket;
|
|
@@ -160306,7 +160310,7 @@ var require_connection = __commonJS({
|
|
|
160306
160310
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
160307
160311
|
var _os = _interopRequireDefault(require("os"));
|
|
160308
160312
|
var tls = _interopRequireWildcard(require("tls"));
|
|
160309
|
-
var
|
|
160313
|
+
var net = _interopRequireWildcard(require("net"));
|
|
160310
160314
|
var _dns = _interopRequireDefault(require("dns"));
|
|
160311
160315
|
var _constants = _interopRequireDefault(require("constants"));
|
|
160312
160316
|
var _stream = require("stream");
|
|
@@ -161355,7 +161359,7 @@ var require_connection = __commonJS({
|
|
|
161355
161359
|
async wrapWithTls(socket, signal) {
|
|
161356
161360
|
signal.throwIfAborted();
|
|
161357
161361
|
const secureContext = tls.createSecureContext(this.secureContextOptions);
|
|
161358
|
-
const serverName = !
|
|
161362
|
+
const serverName = !net.isIP(this.config.server) ? this.config.server : "";
|
|
161359
161363
|
const encryptOptions = {
|
|
161360
161364
|
host: this.config.server,
|
|
161361
161365
|
socket,
|
|
@@ -164266,6 +164270,7 @@ __export(connections_exports, {
|
|
|
164266
164270
|
connectToSQLite: () => connectToSQLite,
|
|
164267
164271
|
connectToSingleStore: () => connectToSingleStore,
|
|
164268
164272
|
prepareCockroach: () => prepareCockroach,
|
|
164273
|
+
prepareDuckDb: () => prepareDuckDb,
|
|
164269
164274
|
prepareGelDB: () => prepareGelDB,
|
|
164270
164275
|
preparePostgresDB: () => preparePostgresDB
|
|
164271
164276
|
});
|
|
@@ -164282,11 +164287,10 @@ function parseMssqlUrl(url) {
|
|
|
164282
164287
|
}
|
|
164283
164288
|
};
|
|
164284
164289
|
}
|
|
164285
|
-
var
|
|
164290
|
+
var normalisePGliteUrl, preparePostgresDB, prepareDuckDb, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
|
|
164286
164291
|
var init_connections = __esm({
|
|
164287
164292
|
"src/cli/connections.ts"() {
|
|
164288
164293
|
"use strict";
|
|
164289
|
-
import_net = __toESM(require("net"));
|
|
164290
164294
|
init_src();
|
|
164291
164295
|
init_wrapper();
|
|
164292
164296
|
init_utils2();
|
|
@@ -164294,7 +164298,6 @@ var init_connections = __esm({
|
|
|
164294
164298
|
init_when_json_met_bigint();
|
|
164295
164299
|
init_utils4();
|
|
164296
164300
|
init_outputs();
|
|
164297
|
-
ms = (a5, b5) => Number(b5 - a5) / 1e6;
|
|
164298
164301
|
normalisePGliteUrl = (it2) => {
|
|
164299
164302
|
if (it2.startsWith("file:")) {
|
|
164300
164303
|
return it2.substring(5);
|
|
@@ -164418,7 +164421,13 @@ var init_connections = __esm({
|
|
|
164418
164421
|
}
|
|
164419
164422
|
return results;
|
|
164420
164423
|
};
|
|
164421
|
-
return {
|
|
164424
|
+
return {
|
|
164425
|
+
packageName: "pglite",
|
|
164426
|
+
query,
|
|
164427
|
+
proxy,
|
|
164428
|
+
transactionProxy,
|
|
164429
|
+
migrate: migrateFn
|
|
164430
|
+
};
|
|
164422
164431
|
}
|
|
164423
164432
|
assertUnreachable(driver2);
|
|
164424
164433
|
}
|
|
@@ -164449,13 +164458,13 @@ var init_connections = __esm({
|
|
|
164449
164458
|
return pg.types.getTypeParser(typeId, format2);
|
|
164450
164459
|
}
|
|
164451
164460
|
};
|
|
164452
|
-
const
|
|
164453
|
-
const db = drizzle({ client
|
|
164461
|
+
const client = "url" in credentials2 ? new pg.Pool({ connectionString: credentials2.url, max: 1 }) : new pg.Pool({ ...credentials2, ssl, max: 1 });
|
|
164462
|
+
const db = drizzle({ client });
|
|
164454
164463
|
const migrateFn = async (config) => {
|
|
164455
164464
|
return migrate2(db, config);
|
|
164456
164465
|
};
|
|
164457
164466
|
const query = async (sql, params) => {
|
|
164458
|
-
const result2 = await
|
|
164467
|
+
const result2 = await client.query({
|
|
164459
164468
|
text: sql,
|
|
164460
164469
|
values: params ?? [],
|
|
164461
164470
|
types: types3
|
|
@@ -164465,7 +164474,7 @@ var init_connections = __esm({
|
|
|
164465
164474
|
return result2.rows;
|
|
164466
164475
|
};
|
|
164467
164476
|
const proxy = async (params) => {
|
|
164468
|
-
const result2 = await
|
|
164477
|
+
const result2 = await client.query({
|
|
164469
164478
|
text: params.sql,
|
|
164470
164479
|
values: params.params,
|
|
164471
164480
|
...params.mode === "array" && { rowMode: "array" },
|
|
@@ -164477,7 +164486,7 @@ var init_connections = __esm({
|
|
|
164477
164486
|
};
|
|
164478
164487
|
const transactionProxy = async (queries) => {
|
|
164479
164488
|
const results = [];
|
|
164480
|
-
const tx = await
|
|
164489
|
+
const tx = await client.connect();
|
|
164481
164490
|
try {
|
|
164482
164491
|
await tx.query("BEGIN");
|
|
164483
164492
|
for (const query2 of queries) {
|
|
@@ -164496,119 +164505,13 @@ var init_connections = __esm({
|
|
|
164496
164505
|
}
|
|
164497
164506
|
return results;
|
|
164498
164507
|
};
|
|
164499
|
-
|
|
164500
|
-
|
|
164501
|
-
|
|
164502
|
-
|
|
164503
|
-
|
|
164504
|
-
|
|
164505
|
-
const stringifiedResult = JSON.stringify(explainResult.rows);
|
|
164506
|
-
const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
|
|
164507
|
-
const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
|
|
164508
|
-
let planningTime = Number(planningMatch[1]);
|
|
164509
|
-
let executionTime = Number(executionMatch[1]);
|
|
164510
|
-
let querySentAt = 0n;
|
|
164511
|
-
let firstDataAt = 0n;
|
|
164512
|
-
let lastDataAt = 0n;
|
|
164513
|
-
let lastRowParsedAt = 0n;
|
|
164514
|
-
let queryCompletedAt = 0n;
|
|
164515
|
-
let bytesReceived = 0;
|
|
164516
|
-
let rowCount = 0;
|
|
164517
|
-
let parseTime = 0;
|
|
164518
|
-
let lastParseTime = 0;
|
|
164519
|
-
const rowDescriptionListener = (data2) => {
|
|
164520
|
-
if (firstDataAt === 0n) {
|
|
164521
|
-
firstDataAt = process.hrtime.bigint();
|
|
164522
|
-
}
|
|
164523
|
-
bytesReceived += data2.length;
|
|
164524
|
-
};
|
|
164525
|
-
const originalRowListener = client.connection.listeners("dataRow")[0];
|
|
164526
|
-
const wrappedRowListener = (data2) => {
|
|
164527
|
-
rowCount += 1;
|
|
164528
|
-
const start = process.hrtime.bigint();
|
|
164529
|
-
lastDataAt = start;
|
|
164530
|
-
originalRowListener.apply(client.connection, [data2]);
|
|
164531
|
-
const end2 = process.hrtime.bigint();
|
|
164532
|
-
lastRowParsedAt = end2;
|
|
164533
|
-
lastParseTime = ms(start, end2);
|
|
164534
|
-
parseTime += lastParseTime;
|
|
164535
|
-
bytesReceived += data2.length;
|
|
164536
|
-
};
|
|
164537
|
-
client.connection.removeAllListeners("dataRow");
|
|
164538
|
-
client.connection.addListener("dataRow", wrappedRowListener);
|
|
164539
|
-
client.connection.prependListener("rowDescription", rowDescriptionListener);
|
|
164540
|
-
querySentAt = process.hrtime.bigint();
|
|
164541
|
-
await client.query({
|
|
164542
|
-
text: sql,
|
|
164543
|
-
values: params,
|
|
164544
|
-
types: types3
|
|
164545
|
-
});
|
|
164546
|
-
queryCompletedAt = process.hrtime.bigint();
|
|
164547
|
-
client.connection.removeListener("rowDescription", rowDescriptionListener);
|
|
164548
|
-
client.connection.removeAllListeners("dataRow");
|
|
164549
|
-
client.connection.addListener("dataRow", originalRowListener);
|
|
164550
|
-
let querySentTime = ms(querySentAt, firstDataAt) - executionTime - planningTime;
|
|
164551
|
-
if (querySentTime < 0) {
|
|
164552
|
-
const percent = 0.1;
|
|
164553
|
-
const overflow = -querySentTime;
|
|
164554
|
-
const keepForSent = overflow * percent;
|
|
164555
|
-
const adjustedOverflow = overflow * (1 + percent);
|
|
164556
|
-
const total2 = planningTime + executionTime;
|
|
164557
|
-
const ratioPlanning = planningTime / total2;
|
|
164558
|
-
const ratioExecution = executionTime / total2;
|
|
164559
|
-
planningTime -= adjustedOverflow * ratioPlanning;
|
|
164560
|
-
executionTime -= adjustedOverflow * ratioExecution;
|
|
164561
|
-
querySentTime = keepForSent;
|
|
164562
|
-
}
|
|
164563
|
-
const networkLatencyBefore = querySentTime / 2;
|
|
164564
|
-
const networkLatencyAfter = querySentTime / 2;
|
|
164565
|
-
const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
|
|
164566
|
-
const total = ms(querySentAt, queryCompletedAt);
|
|
164567
|
-
const calculatedTotal = networkLatencyBefore + planningTime + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
|
|
164568
|
-
const errorMargin = Math.abs(total - calculatedTotal);
|
|
164569
|
-
return {
|
|
164570
|
-
networkLatencyBefore,
|
|
164571
|
-
planning: planningTime,
|
|
164572
|
-
execution: executionTime,
|
|
164573
|
-
networkLatencyAfter,
|
|
164574
|
-
dataDownload: downloadTime,
|
|
164575
|
-
dataParse: parseTime,
|
|
164576
|
-
total,
|
|
164577
|
-
errorMargin,
|
|
164578
|
-
dataSize: bytesReceived
|
|
164579
|
-
};
|
|
164580
|
-
};
|
|
164581
|
-
const benchmarkProxy = async ({ sql, params }, repeats) => {
|
|
164582
|
-
let startAt = 0n;
|
|
164583
|
-
let tcpConnectedAt = 0n;
|
|
164584
|
-
let tlsConnectedAt = null;
|
|
164585
|
-
let dbReadyAt = 0n;
|
|
164586
|
-
const client = "url" in credentials2 ? new pg.Client({ connectionString: credentials2.url }) : new pg.Client({ ...credentials2, ssl });
|
|
164587
|
-
client.connection.once("connect", () => {
|
|
164588
|
-
tcpConnectedAt = process.hrtime.bigint();
|
|
164589
|
-
});
|
|
164590
|
-
client.connection.prependOnceListener("sslconnect", () => {
|
|
164591
|
-
tlsConnectedAt = process.hrtime.bigint();
|
|
164592
|
-
});
|
|
164593
|
-
client.connection.prependOnceListener("readyForQuery", () => {
|
|
164594
|
-
dbReadyAt = process.hrtime.bigint();
|
|
164595
|
-
});
|
|
164596
|
-
startAt = process.hrtime.bigint();
|
|
164597
|
-
await client.connect();
|
|
164598
|
-
const results = [];
|
|
164599
|
-
for (let i6 = 0; i6 < repeats; i6++) {
|
|
164600
|
-
const r6 = await benchmarkQuery(client, sql, params);
|
|
164601
|
-
results.push(r6);
|
|
164602
|
-
}
|
|
164603
|
-
await client.end();
|
|
164604
|
-
return {
|
|
164605
|
-
tcpHandshake: ms(startAt, tcpConnectedAt),
|
|
164606
|
-
tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
|
|
164607
|
-
dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
|
|
164608
|
-
queries: results
|
|
164609
|
-
};
|
|
164508
|
+
return {
|
|
164509
|
+
packageName: "pg",
|
|
164510
|
+
query,
|
|
164511
|
+
proxy,
|
|
164512
|
+
transactionProxy,
|
|
164513
|
+
migrate: migrateFn
|
|
164610
164514
|
};
|
|
164611
|
-
return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
|
|
164612
164515
|
}
|
|
164613
164516
|
if (await checkPackage("postgres")) {
|
|
164614
164517
|
console.log(
|
|
@@ -164659,7 +164562,13 @@ var init_connections = __esm({
|
|
|
164659
164562
|
}
|
|
164660
164563
|
return results;
|
|
164661
164564
|
};
|
|
164662
|
-
return {
|
|
164565
|
+
return {
|
|
164566
|
+
packageName: "postgres",
|
|
164567
|
+
query,
|
|
164568
|
+
proxy,
|
|
164569
|
+
transactionProxy,
|
|
164570
|
+
migrate: migrateFn
|
|
164571
|
+
};
|
|
164663
164572
|
}
|
|
164664
164573
|
if (await checkPackage("@vercel/postgres")) {
|
|
164665
164574
|
console.log(
|
|
@@ -164740,7 +164649,13 @@ var init_connections = __esm({
|
|
|
164740
164649
|
}
|
|
164741
164650
|
return results;
|
|
164742
164651
|
};
|
|
164743
|
-
return {
|
|
164652
|
+
return {
|
|
164653
|
+
packageName: "@vercel/postgres",
|
|
164654
|
+
query,
|
|
164655
|
+
proxy,
|
|
164656
|
+
transactionProxy,
|
|
164657
|
+
migrate: migrateFn
|
|
164658
|
+
};
|
|
164744
164659
|
}
|
|
164745
164660
|
if (await checkPackage("@neondatabase/serverless")) {
|
|
164746
164661
|
console.log(
|
|
@@ -164753,7 +164668,11 @@ var init_connections = __esm({
|
|
|
164753
164668
|
"'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
|
|
164754
164669
|
)
|
|
164755
164670
|
);
|
|
164756
|
-
const {
|
|
164671
|
+
const {
|
|
164672
|
+
Pool,
|
|
164673
|
+
neonConfig,
|
|
164674
|
+
types: pgTypes
|
|
164675
|
+
} = await import("@neondatabase/serverless");
|
|
164757
164676
|
const { drizzle } = await import("drizzle-orm/neon-serverless");
|
|
164758
164677
|
const { migrate: migrate2 } = await import("drizzle-orm/neon-serverless/migrator");
|
|
164759
164678
|
const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? { rejectUnauthorized: false } : credentials2.ssl === "verify-full" ? {} : credentials2.ssl : {};
|
|
@@ -164823,7 +164742,13 @@ var init_connections = __esm({
|
|
|
164823
164742
|
}
|
|
164824
164743
|
return results;
|
|
164825
164744
|
};
|
|
164826
|
-
return {
|
|
164745
|
+
return {
|
|
164746
|
+
packageName: "@neondatabase/serverless",
|
|
164747
|
+
query,
|
|
164748
|
+
proxy,
|
|
164749
|
+
transactionProxy,
|
|
164750
|
+
migrate: migrateFn
|
|
164751
|
+
};
|
|
164827
164752
|
}
|
|
164828
164753
|
if (await checkPackage("bun")) {
|
|
164829
164754
|
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
@@ -164874,6 +164799,111 @@ var init_connections = __esm({
|
|
|
164874
164799
|
console.warn("For the 'bun' driver, run your script using: bun --bun");
|
|
164875
164800
|
process.exit(1);
|
|
164876
164801
|
};
|
|
164802
|
+
prepareDuckDb = async (credentials2) => {
|
|
164803
|
+
if (await checkPackage("duckdb")) {
|
|
164804
|
+
console.log(withStyle.info(`Using 'duckdb' driver for database querying`));
|
|
164805
|
+
const duckdb = await import("duckdb");
|
|
164806
|
+
const client = await new Promise((resolve3, reject) => {
|
|
164807
|
+
const db = new duckdb.Database(credentials2.url, (err2) => {
|
|
164808
|
+
if (err2) {
|
|
164809
|
+
reject(err2);
|
|
164810
|
+
}
|
|
164811
|
+
resolve3(db);
|
|
164812
|
+
});
|
|
164813
|
+
});
|
|
164814
|
+
const query = async (sql, params = []) => new Promise((resolve3, reject) => {
|
|
164815
|
+
client.all(sql, ...params, (err2, rows) => {
|
|
164816
|
+
if (err2) {
|
|
164817
|
+
reject(err2);
|
|
164818
|
+
}
|
|
164819
|
+
resolve3(rows);
|
|
164820
|
+
});
|
|
164821
|
+
});
|
|
164822
|
+
const proxy = async (params) => {
|
|
164823
|
+
const rows = await query(params.sql, params.params);
|
|
164824
|
+
return params.mode === "array" ? rows.map((row) => Object.values(row)) : rows;
|
|
164825
|
+
};
|
|
164826
|
+
const transactionProxy = async (queries) => {
|
|
164827
|
+
const results = [];
|
|
164828
|
+
const tx = client.connect();
|
|
164829
|
+
try {
|
|
164830
|
+
tx.run("BEGIN");
|
|
164831
|
+
for (const query2 of queries) {
|
|
164832
|
+
const rows = await new Promise((resolve3, reject) => {
|
|
164833
|
+
client.all(query2.sql, (err2, rows2) => {
|
|
164834
|
+
if (err2) {
|
|
164835
|
+
reject(err2);
|
|
164836
|
+
}
|
|
164837
|
+
resolve3(rows2);
|
|
164838
|
+
});
|
|
164839
|
+
});
|
|
164840
|
+
results.push(rows);
|
|
164841
|
+
}
|
|
164842
|
+
tx.run("COMMIT");
|
|
164843
|
+
} catch (error4) {
|
|
164844
|
+
tx.run("ROLLBACK");
|
|
164845
|
+
results.push(error4);
|
|
164846
|
+
} finally {
|
|
164847
|
+
tx.close();
|
|
164848
|
+
}
|
|
164849
|
+
return results;
|
|
164850
|
+
};
|
|
164851
|
+
return {
|
|
164852
|
+
packageName: "duckdb",
|
|
164853
|
+
query,
|
|
164854
|
+
proxy,
|
|
164855
|
+
transactionProxy,
|
|
164856
|
+
migrate: () => {
|
|
164857
|
+
throw new Error("DuckDB does not support migrations");
|
|
164858
|
+
}
|
|
164859
|
+
};
|
|
164860
|
+
}
|
|
164861
|
+
if (await checkPackage("@duckdb/node-api")) {
|
|
164862
|
+
console.log(
|
|
164863
|
+
withStyle.info(`Using '@duckdb/node-api' driver for database querying`)
|
|
164864
|
+
);
|
|
164865
|
+
const { DuckDBInstance } = await import("@duckdb/node-api");
|
|
164866
|
+
const instance = await DuckDBInstance.create(credentials2.url);
|
|
164867
|
+
const client = await instance.connect();
|
|
164868
|
+
const query = async (sql, params = []) => {
|
|
164869
|
+
const result2 = await client.run(sql, params);
|
|
164870
|
+
const rows = await result2.getRowObjectsJson();
|
|
164871
|
+
return rows;
|
|
164872
|
+
};
|
|
164873
|
+
const proxy = async (params) => {
|
|
164874
|
+
const result2 = await client.run(params.sql, params.params);
|
|
164875
|
+
return params.mode === "array" ? await result2.getRowsJson() : await result2.getRowObjectsJson();
|
|
164876
|
+
};
|
|
164877
|
+
const transactionProxy = async (queries) => {
|
|
164878
|
+
const results = [];
|
|
164879
|
+
try {
|
|
164880
|
+
await client.run("BEGIN");
|
|
164881
|
+
for (const query2 of queries) {
|
|
164882
|
+
const result2 = await client.run(query2.sql);
|
|
164883
|
+
results.push(await result2.getRowObjectsJson());
|
|
164884
|
+
}
|
|
164885
|
+
await client.run("COMMIT");
|
|
164886
|
+
} catch (error4) {
|
|
164887
|
+
await client.run("ROLLBACK");
|
|
164888
|
+
results.push(error4);
|
|
164889
|
+
}
|
|
164890
|
+
return results;
|
|
164891
|
+
};
|
|
164892
|
+
return {
|
|
164893
|
+
packageName: "@duckdb/node-api",
|
|
164894
|
+
query,
|
|
164895
|
+
proxy,
|
|
164896
|
+
transactionProxy,
|
|
164897
|
+
migrate: () => {
|
|
164898
|
+
throw new Error("DuckDB does not support migrations");
|
|
164899
|
+
}
|
|
164900
|
+
};
|
|
164901
|
+
}
|
|
164902
|
+
console.error(
|
|
164903
|
+
"To connect to DuckDb database - please install either of 'duckdb', '@duckdb/node-api' drivers"
|
|
164904
|
+
);
|
|
164905
|
+
process.exit(1);
|
|
164906
|
+
};
|
|
164877
164907
|
prepareCockroach = async (credentials2) => {
|
|
164878
164908
|
if (await checkPackage("pg")) {
|
|
164879
164909
|
const { default: pg } = await import("pg");
|
|
@@ -164926,9 +164956,7 @@ var init_connections = __esm({
|
|
|
164926
164956
|
};
|
|
164927
164957
|
return { query, proxy, migrate: migrateFn };
|
|
164928
164958
|
}
|
|
164929
|
-
console.error(
|
|
164930
|
-
"To connect to Cockroach - please install 'pg' package"
|
|
164931
|
-
);
|
|
164959
|
+
console.error("To connect to Cockroach - please install 'pg' package");
|
|
164932
164960
|
process.exit(1);
|
|
164933
164961
|
};
|
|
164934
164962
|
prepareGelDB = async (credentials2) => {
|
|
@@ -164987,9 +165015,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
164987
165015
|
};
|
|
164988
165016
|
return { packageName: "gel", query, proxy, transactionProxy };
|
|
164989
165017
|
}
|
|
164990
|
-
console.error(
|
|
164991
|
-
"To connect to gel database - please install 'edgedb' driver"
|
|
164992
|
-
);
|
|
165018
|
+
console.error("To connect to gel database - please install 'edgedb' driver");
|
|
164993
165019
|
process.exit(1);
|
|
164994
165020
|
};
|
|
164995
165021
|
parseSingleStoreCredentials = (credentials2) => {
|
|
@@ -165103,6 +165129,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
165103
165129
|
}
|
|
165104
165130
|
return next();
|
|
165105
165131
|
};
|
|
165132
|
+
await connection.connect();
|
|
165106
165133
|
const query = async (sql, params) => {
|
|
165107
165134
|
const res = await connection.execute({
|
|
165108
165135
|
sql,
|
|
@@ -165142,156 +165169,11 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
165142
165169
|
}
|
|
165143
165170
|
return results;
|
|
165144
165171
|
};
|
|
165145
|
-
const benchmarkQuery = async (newConnection, sql, params) => {
|
|
165146
|
-
const explainResult = await connection.query({
|
|
165147
|
-
sql: `EXPLAIN ANALYZE ${sql}`,
|
|
165148
|
-
values: params ?? [],
|
|
165149
|
-
typeCast
|
|
165150
|
-
});
|
|
165151
|
-
const stringifiedResult = JSON.stringify(explainResult[0]);
|
|
165152
|
-
const timeMatch = stringifiedResult.match(
|
|
165153
|
-
/actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
|
|
165154
|
-
);
|
|
165155
|
-
const lastRowTime = Number(timeMatch[2]);
|
|
165156
|
-
let executionTime = lastRowTime;
|
|
165157
|
-
let querySentAt = 0n;
|
|
165158
|
-
let firstDataAt = 0n;
|
|
165159
|
-
let lastDataAt = 0n;
|
|
165160
|
-
let lastRowParsedAt = 0n;
|
|
165161
|
-
let queryCompletedAt = 0n;
|
|
165162
|
-
let bytesReceived = 0;
|
|
165163
|
-
let rowCount = 0;
|
|
165164
|
-
let parseTime = 0;
|
|
165165
|
-
let lastParseTime = 0;
|
|
165166
|
-
querySentAt = process.hrtime.bigint();
|
|
165167
|
-
await new Promise((resolve3, reject) => {
|
|
165168
|
-
const query2 = newConnection.query({
|
|
165169
|
-
sql,
|
|
165170
|
-
values: params ?? [],
|
|
165171
|
-
typeCast
|
|
165172
|
-
});
|
|
165173
|
-
const originalRowHandler = query2.row;
|
|
165174
|
-
let packets = 0;
|
|
165175
|
-
const wrappedRowListener = (packet, connection2) => {
|
|
165176
|
-
packets += 1;
|
|
165177
|
-
if (firstDataAt === 0n) {
|
|
165178
|
-
firstDataAt = process.hrtime.bigint();
|
|
165179
|
-
bytesReceived += packet.start;
|
|
165180
|
-
}
|
|
165181
|
-
const start = process.hrtime.bigint();
|
|
165182
|
-
lastDataAt = start;
|
|
165183
|
-
const res = originalRowHandler.apply(query2, [packet, connection2]);
|
|
165184
|
-
const end2 = process.hrtime.bigint();
|
|
165185
|
-
lastRowParsedAt = end2;
|
|
165186
|
-
lastParseTime = ms(start, end2);
|
|
165187
|
-
parseTime += lastParseTime;
|
|
165188
|
-
bytesReceived += packet.length();
|
|
165189
|
-
if (!res || packet.isEOF()) {
|
|
165190
|
-
return res;
|
|
165191
|
-
}
|
|
165192
|
-
return wrappedRowListener;
|
|
165193
|
-
};
|
|
165194
|
-
query2.row = wrappedRowListener;
|
|
165195
|
-
query2.on("result", () => {
|
|
165196
|
-
rowCount += 1;
|
|
165197
|
-
});
|
|
165198
|
-
query2.on("error", (err2) => {
|
|
165199
|
-
reject(err2);
|
|
165200
|
-
});
|
|
165201
|
-
query2.on("end", () => {
|
|
165202
|
-
resolve3();
|
|
165203
|
-
});
|
|
165204
|
-
});
|
|
165205
|
-
queryCompletedAt = process.hrtime.bigint();
|
|
165206
|
-
let querySentTime = ms(querySentAt, firstDataAt) - executionTime;
|
|
165207
|
-
if (querySentTime < 0) {
|
|
165208
|
-
const percent = 0.1;
|
|
165209
|
-
const overflow = -querySentTime;
|
|
165210
|
-
const keepForSent = overflow * percent;
|
|
165211
|
-
const adjustedOverflow = overflow * (1 + percent);
|
|
165212
|
-
const total2 = executionTime;
|
|
165213
|
-
const ratioExecution = executionTime / total2;
|
|
165214
|
-
executionTime -= adjustedOverflow * ratioExecution;
|
|
165215
|
-
querySentTime = keepForSent;
|
|
165216
|
-
}
|
|
165217
|
-
const networkLatencyBefore = querySentTime / 2;
|
|
165218
|
-
const networkLatencyAfter = querySentTime / 2;
|
|
165219
|
-
const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
|
|
165220
|
-
const total = ms(querySentAt, queryCompletedAt);
|
|
165221
|
-
const calculatedTotal = networkLatencyBefore + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
|
|
165222
|
-
const errorMargin = Math.abs(total - calculatedTotal);
|
|
165223
|
-
return {
|
|
165224
|
-
networkLatencyBefore,
|
|
165225
|
-
planning: null,
|
|
165226
|
-
execution: executionTime,
|
|
165227
|
-
networkLatencyAfter,
|
|
165228
|
-
dataDownload: downloadTime,
|
|
165229
|
-
dataParse: parseTime,
|
|
165230
|
-
total,
|
|
165231
|
-
errorMargin,
|
|
165232
|
-
dataSize: bytesReceived
|
|
165233
|
-
};
|
|
165234
|
-
};
|
|
165235
|
-
const benchmarkProxy = async ({ sql, params }, repeats) => {
|
|
165236
|
-
const { createConnection: createConnection2 } = await import("mysql2");
|
|
165237
|
-
let startAt = 0n;
|
|
165238
|
-
let tcpConnectedAt = 0n;
|
|
165239
|
-
let tlsConnectedAt = null;
|
|
165240
|
-
const createStream = ({ config }) => {
|
|
165241
|
-
let stream;
|
|
165242
|
-
if (config.socketPath) {
|
|
165243
|
-
stream = import_net.default.connect(config.socketPath);
|
|
165244
|
-
} else {
|
|
165245
|
-
stream = import_net.default.connect(config.port, config.host);
|
|
165246
|
-
}
|
|
165247
|
-
if (config.enableKeepAlive) {
|
|
165248
|
-
stream.on("connect", () => {
|
|
165249
|
-
stream.setKeepAlive(true, config.keepAliveInitialDelay);
|
|
165250
|
-
});
|
|
165251
|
-
}
|
|
165252
|
-
stream.setNoDelay(true);
|
|
165253
|
-
stream.once("connect", () => {
|
|
165254
|
-
tcpConnectedAt = process.hrtime.bigint();
|
|
165255
|
-
});
|
|
165256
|
-
return stream;
|
|
165257
|
-
};
|
|
165258
|
-
startAt = process.hrtime.bigint();
|
|
165259
|
-
const connection2 = result2.url ? createConnection2({
|
|
165260
|
-
uri: result2.url,
|
|
165261
|
-
stream: createStream
|
|
165262
|
-
}) : createConnection2({
|
|
165263
|
-
...result2.credentials,
|
|
165264
|
-
stream: createStream
|
|
165265
|
-
});
|
|
165266
|
-
await new Promise((resolve3, reject) => {
|
|
165267
|
-
connection2.connect((err2) => {
|
|
165268
|
-
tlsConnectedAt = process.hrtime.bigint();
|
|
165269
|
-
if (err2) {
|
|
165270
|
-
reject(err2);
|
|
165271
|
-
} else {
|
|
165272
|
-
resolve3();
|
|
165273
|
-
}
|
|
165274
|
-
});
|
|
165275
|
-
});
|
|
165276
|
-
const results = [];
|
|
165277
|
-
for (let i6 = 0; i6 < repeats; i6++) {
|
|
165278
|
-
const r6 = await benchmarkQuery(connection2, sql, params);
|
|
165279
|
-
results.push(r6);
|
|
165280
|
-
}
|
|
165281
|
-
connection2.end();
|
|
165282
|
-
return {
|
|
165283
|
-
tcpHandshake: ms(startAt, tcpConnectedAt),
|
|
165284
|
-
tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
|
|
165285
|
-
dbHandshake: null,
|
|
165286
|
-
queries: results
|
|
165287
|
-
};
|
|
165288
|
-
};
|
|
165289
165172
|
return {
|
|
165290
165173
|
db: { query },
|
|
165291
165174
|
packageName: "mysql2",
|
|
165292
165175
|
proxy,
|
|
165293
165176
|
transactionProxy,
|
|
165294
|
-
benchmarkProxy,
|
|
165295
165177
|
database: result2.database,
|
|
165296
165178
|
migrate: migrateFn
|
|
165297
165179
|
};
|
|
@@ -165441,9 +165323,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
165441
165323
|
migrate: migrateFn
|
|
165442
165324
|
};
|
|
165443
165325
|
}
|
|
165444
|
-
console.error(
|
|
165445
|
-
"To connect to MsSQL database - please install 'mssql' driver"
|
|
165446
|
-
);
|
|
165326
|
+
console.error("To connect to MsSQL database - please install 'mssql' driver");
|
|
165447
165327
|
process.exit(1);
|
|
165448
165328
|
};
|
|
165449
165329
|
prepareSqliteParams = (params, driver2) => {
|
|
@@ -165548,7 +165428,10 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
165548
165428
|
await remoteCallback(query2, [], "run");
|
|
165549
165429
|
};
|
|
165550
165430
|
const proxy = async (params) => {
|
|
165551
|
-
const preparedParams = prepareSqliteParams(
|
|
165431
|
+
const preparedParams = prepareSqliteParams(
|
|
165432
|
+
params.params || [],
|
|
165433
|
+
"d1-http"
|
|
165434
|
+
);
|
|
165552
165435
|
const result2 = await remoteCallback(
|
|
165553
165436
|
params.sql,
|
|
165554
165437
|
preparedParams,
|
|
@@ -165773,17 +165656,19 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
165773
165656
|
};
|
|
165774
165657
|
const transactionProxy = async (queries) => {
|
|
165775
165658
|
const results = [];
|
|
165776
|
-
const tx = sqlite.transaction(
|
|
165777
|
-
|
|
165778
|
-
|
|
165779
|
-
|
|
165780
|
-
|
|
165781
|
-
|
|
165782
|
-
|
|
165659
|
+
const tx = sqlite.transaction(
|
|
165660
|
+
(queries2) => {
|
|
165661
|
+
for (const query of queries2) {
|
|
165662
|
+
let result2 = [];
|
|
165663
|
+
if (query.method === "values" || query.method === "get" || query.method === "all") {
|
|
165664
|
+
result2 = sqlite.prepare(query.sql).all();
|
|
165665
|
+
} else {
|
|
165666
|
+
sqlite.prepare(query.sql).run();
|
|
165667
|
+
}
|
|
165668
|
+
results.push(result2);
|
|
165783
165669
|
}
|
|
165784
|
-
results.push(result2);
|
|
165785
165670
|
}
|
|
165786
|
-
|
|
165671
|
+
);
|
|
165787
165672
|
try {
|
|
165788
165673
|
tx(queries);
|
|
165789
165674
|
} catch (error4) {
|
|
@@ -165791,7 +165676,13 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
|
|
|
165791
165676
|
}
|
|
165792
165677
|
return results;
|
|
165793
165678
|
};
|
|
165794
|
-
return {
|
|
165679
|
+
return {
|
|
165680
|
+
...db,
|
|
165681
|
+
packageName: "better-sqlite3",
|
|
165682
|
+
proxy,
|
|
165683
|
+
transactionProxy,
|
|
165684
|
+
migrate: migrateFn
|
|
165685
|
+
};
|
|
165795
165686
|
}
|
|
165796
165687
|
if (await checkPackage("bun")) {
|
|
165797
165688
|
console.log(withStyle.info(`Using 'bun' driver for database querying`));
|
|
@@ -169559,7 +169450,7 @@ var init_introspect2 = __esm({
|
|
|
169559
169450
|
let checksCount = 0;
|
|
169560
169451
|
let viewsCount = 0;
|
|
169561
169452
|
for (const seq of sequencesList) {
|
|
169562
|
-
const depend = dependList.find((it2) => it2.oid === seq.oid);
|
|
169453
|
+
const depend = dependList.find((it2) => Number(it2.oid) === Number(seq.oid));
|
|
169563
169454
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
169564
169455
|
continue;
|
|
169565
169456
|
}
|
|
@@ -169625,22 +169516,22 @@ var init_introspect2 = __esm({
|
|
|
169625
169516
|
continue;
|
|
169626
169517
|
}
|
|
169627
169518
|
const expr = serialsList.find(
|
|
169628
|
-
(it2) => it2.tableId === column12.tableId && it2.ordinality === column12.ordinality
|
|
169519
|
+
(it2) => Number(it2.tableId) === Number(column12.tableId) && it2.ordinality === column12.ordinality
|
|
169629
169520
|
);
|
|
169630
169521
|
if (expr) {
|
|
169631
|
-
const table7 = tablesList.find((it2) => it2.oid === column12.tableId);
|
|
169522
|
+
const table7 = tablesList.find((it2) => Number(it2.oid) === Number(column12.tableId));
|
|
169632
169523
|
const isSerial = isSerialExpression(expr.expression, table7.schema);
|
|
169633
169524
|
column12.type = isSerial ? type === "bigint" ? "bigserial" : type === "integer" ? "serial" : "smallserial" : type;
|
|
169634
169525
|
}
|
|
169635
169526
|
}
|
|
169636
169527
|
for (const column12 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
169637
|
-
const table7 = tablesList.find((it2) => it2.oid === column12.tableId);
|
|
169528
|
+
const table7 = tablesList.find((it2) => Number(it2.oid) === Number(column12.tableId));
|
|
169638
169529
|
const enumType2 = column12.typeId in groupedEnums ? groupedEnums[column12.typeId] : column12.typeId in groupedArrEnums ? groupedArrEnums[column12.typeId] : null;
|
|
169639
169530
|
let columnTypeMapped = enumType2 ? enumType2.name : column12.type.replaceAll("[]", "");
|
|
169640
169531
|
columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char").replace("geometry(Point", "geometry(point");
|
|
169641
169532
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
|
169642
169533
|
const columnDefault = defaultsList.find(
|
|
169643
|
-
(it2) => it2.tableId === column12.tableId && it2.ordinality === column12.ordinality
|
|
169534
|
+
(it2) => Number(it2.tableId) === Number(column12.tableId) && it2.ordinality === column12.ordinality
|
|
169644
169535
|
);
|
|
169645
169536
|
const defaultValue = defaultForColumn(
|
|
169646
169537
|
columnTypeMapped,
|
|
@@ -169649,10 +169540,10 @@ var init_introspect2 = __esm({
|
|
|
169649
169540
|
Boolean(enumType2)
|
|
169650
169541
|
);
|
|
169651
169542
|
const unique = constraintsList.find((it2) => {
|
|
169652
|
-
return it2.type === "u" && it2.tableId === column12.tableId && it2.columnsOrdinals.length === 1 && it2.columnsOrdinals.includes(column12.ordinality);
|
|
169543
|
+
return it2.type === "u" && Number(it2.tableId) === Number(column12.tableId) && it2.columnsOrdinals.length === 1 && it2.columnsOrdinals.includes(column12.ordinality);
|
|
169653
169544
|
}) ?? null;
|
|
169654
169545
|
const pk = constraintsList.find((it2) => {
|
|
169655
|
-
return it2.type === "p" && it2.tableId === column12.tableId && it2.columnsOrdinals.length === 1 && it2.columnsOrdinals.includes(column12.ordinality);
|
|
169546
|
+
return it2.type === "p" && Number(it2.tableId) === Number(column12.tableId) && it2.columnsOrdinals.length === 1 && it2.columnsOrdinals.includes(column12.ordinality);
|
|
169656
169547
|
}) ?? null;
|
|
169657
169548
|
const metadata = column12.metadata;
|
|
169658
169549
|
if (column12.generatedType === "s" && (!metadata || !metadata.expression)) {
|
|
@@ -169667,7 +169558,7 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169667
169558
|
${JSON.stringify(column12.metadata)}`
|
|
169668
169559
|
);
|
|
169669
169560
|
}
|
|
169670
|
-
const sequence = (metadata == null ? void 0 : metadata.seqId) ? sequencesList.find((it2) => it2.oid === Number(metadata.seqId)) ?? null : null;
|
|
169561
|
+
const sequence = (metadata == null ? void 0 : metadata.seqId) ? sequencesList.find((it2) => Number(it2.oid) === Number(metadata.seqId)) ?? null : null;
|
|
169671
169562
|
columns.push({
|
|
169672
169563
|
entityType: "columns",
|
|
169673
169564
|
schema: table7.schema,
|
|
@@ -169697,10 +169588,12 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169697
169588
|
});
|
|
169698
169589
|
}
|
|
169699
169590
|
for (const unique of constraintsList.filter((it2) => it2.type === "u")) {
|
|
169700
|
-
const table7 = tablesList.find((it2) => it2.oid === unique.tableId);
|
|
169701
|
-
const schema6 = namespaces.find((it2) => it2.oid === unique.schemaId);
|
|
169591
|
+
const table7 = tablesList.find((it2) => Number(it2.oid) === Number(unique.tableId));
|
|
169592
|
+
const schema6 = namespaces.find((it2) => Number(it2.oid) === Number(unique.schemaId));
|
|
169702
169593
|
const columns2 = unique.columnsOrdinals.map((it2) => {
|
|
169703
|
-
const column12 = columnsList.find(
|
|
169594
|
+
const column12 = columnsList.find(
|
|
169595
|
+
(column13) => Number(column13.tableId) === Number(unique.tableId) && column13.ordinality === it2
|
|
169596
|
+
);
|
|
169704
169597
|
return column12.name;
|
|
169705
169598
|
});
|
|
169706
169599
|
uniques.push({
|
|
@@ -169714,10 +169607,12 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169714
169607
|
});
|
|
169715
169608
|
}
|
|
169716
169609
|
for (const pk of constraintsList.filter((it2) => it2.type === "p")) {
|
|
169717
|
-
const table7 = tablesList.find((it2) => it2.oid === pk.tableId);
|
|
169718
|
-
const schema6 = namespaces.find((it2) => it2.oid === pk.schemaId);
|
|
169610
|
+
const table7 = tablesList.find((it2) => Number(it2.oid) === Number(pk.tableId));
|
|
169611
|
+
const schema6 = namespaces.find((it2) => Number(it2.oid) === Number(pk.schemaId));
|
|
169719
169612
|
const columns2 = pk.columnsOrdinals.map((it2) => {
|
|
169720
|
-
const column12 = columnsList.find(
|
|
169613
|
+
const column12 = columnsList.find(
|
|
169614
|
+
(column13) => Number(column13.tableId) === Number(pk.tableId) && column13.ordinality === it2
|
|
169615
|
+
);
|
|
169721
169616
|
return column12.name;
|
|
169722
169617
|
});
|
|
169723
169618
|
pks.push({
|
|
@@ -169730,15 +169625,19 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169730
169625
|
});
|
|
169731
169626
|
}
|
|
169732
169627
|
for (const fk6 of constraintsList.filter((it2) => it2.type === "f")) {
|
|
169733
|
-
const table7 = tablesList.find((it2) => it2.oid === fk6.tableId);
|
|
169734
|
-
const schema6 = namespaces.find((it2) => it2.oid === fk6.schemaId);
|
|
169735
|
-
const tableTo = tablesList.find((it2) => it2.oid === fk6.tableToId);
|
|
169628
|
+
const table7 = tablesList.find((it2) => Number(it2.oid) === Number(fk6.tableId));
|
|
169629
|
+
const schema6 = namespaces.find((it2) => Number(it2.oid) === Number(fk6.schemaId));
|
|
169630
|
+
const tableTo = tablesList.find((it2) => Number(it2.oid) === Number(fk6.tableToId));
|
|
169736
169631
|
const columns2 = fk6.columnsOrdinals.map((it2) => {
|
|
169737
|
-
const column12 = columnsList.find(
|
|
169632
|
+
const column12 = columnsList.find(
|
|
169633
|
+
(column13) => Number(column13.tableId) === Number(fk6.tableId) && column13.ordinality === it2
|
|
169634
|
+
);
|
|
169738
169635
|
return column12.name;
|
|
169739
169636
|
});
|
|
169740
169637
|
const columnsTo = fk6.columnsToOrdinals.map((it2) => {
|
|
169741
|
-
const column12 = columnsList.find(
|
|
169638
|
+
const column12 = columnsList.find(
|
|
169639
|
+
(column13) => Number(column13.tableId) === Number(fk6.tableToId) && column13.ordinality === it2
|
|
169640
|
+
);
|
|
169742
169641
|
return column12.name;
|
|
169743
169642
|
});
|
|
169744
169643
|
fks.push({
|
|
@@ -169756,8 +169655,8 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169756
169655
|
});
|
|
169757
169656
|
}
|
|
169758
169657
|
for (const check2 of constraintsList.filter((it2) => it2.type === "c")) {
|
|
169759
|
-
const table7 = tablesList.find((it2) => it2.oid === check2.tableId);
|
|
169760
|
-
const schema6 = namespaces.find((it2) => it2.oid === check2.schemaId);
|
|
169658
|
+
const table7 = tablesList.find((it2) => Number(it2.oid) === Number(check2.tableId));
|
|
169659
|
+
const schema6 = namespaces.find((it2) => Number(it2.oid) === Number(check2.schemaId));
|
|
169761
169660
|
checks.push({
|
|
169762
169661
|
entityType: "checks",
|
|
169763
169662
|
schema: schema6.name,
|
|
@@ -169818,10 +169717,10 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169818
169717
|
});
|
|
169819
169718
|
for (const idx of idxs) {
|
|
169820
169719
|
const { metadata } = idx;
|
|
169821
|
-
const forUnique = metadata.isUnique && constraintsList.some((x6) => x6.type === "u" && x6.indexId === idx.oid);
|
|
169822
|
-
const forPK = metadata.isPrimary && constraintsList.some((x6) => x6.type === "p" && x6.indexId === idx.oid);
|
|
169720
|
+
const forUnique = metadata.isUnique && constraintsList.some((x6) => x6.type === "u" && Number(x6.indexId) === Number(idx.oid));
|
|
169721
|
+
const forPK = metadata.isPrimary && constraintsList.some((x6) => x6.type === "p" && Number(x6.indexId) === Number(idx.oid));
|
|
169823
169722
|
const expr = splitExpressions(metadata.expression);
|
|
169824
|
-
const table7 = tablesList.find((it2) => it2.oid === idx.metadata.tableId);
|
|
169723
|
+
const table7 = tablesList.find((it2) => Number(it2.oid) === Number(idx.metadata.tableId));
|
|
169825
169724
|
const nonColumnsCount = metadata.columnOrdinals.reduce((acc, it2) => {
|
|
169826
169725
|
if (it2 === 0) acc += 1;
|
|
169827
169726
|
return acc;
|
|
@@ -169853,7 +169752,7 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169853
169752
|
k5 += 1;
|
|
169854
169753
|
} else {
|
|
169855
169754
|
const column12 = columnsList.find((column13) => {
|
|
169856
|
-
return column13.tableId === metadata.tableId && column13.ordinality === ordinal;
|
|
169755
|
+
return Number(column13.tableId) === Number(metadata.tableId) && column13.ordinality === ordinal;
|
|
169857
169756
|
});
|
|
169858
169757
|
if (!column12) throw new Error(`missing column: ${metadata.tableId}:${ordinal}`);
|
|
169859
169758
|
const options = opts[i6];
|
|
@@ -169902,7 +169801,7 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169902
169801
|
progressCallback("indexes", indexesCount, "fetching");
|
|
169903
169802
|
progressCallback("tables", tableCount, "done");
|
|
169904
169803
|
for (const it2 of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
169905
|
-
const view6 = viewsList.find((x6) => x6.oid === it2.tableId);
|
|
169804
|
+
const view6 = viewsList.find((x6) => Number(x6.oid) === Number(it2.tableId));
|
|
169906
169805
|
const typeDimensions = it2.type.split("[]").length - 1;
|
|
169907
169806
|
const enumType2 = it2.typeId in groupedEnums ? groupedEnums[it2.typeId] : it2.typeId in groupedArrEnums ? groupedArrEnums[it2.typeId] : null;
|
|
169908
169807
|
let columnTypeMapped = enumType2 ? enumType2.name : it2.type.replace("[]", "");
|
|
@@ -169925,8 +169824,8 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169925
169824
|
}
|
|
169926
169825
|
for (const view6 of viewsList) {
|
|
169927
169826
|
tableCount += 1;
|
|
169928
|
-
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it2) => it2.oid === view6.accessMethod);
|
|
169929
|
-
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it2) => it2.oid === view6.tablespaceid).name;
|
|
169827
|
+
const accessMethod = Number(view6.accessMethod) === 0 ? null : ams.find((it2) => Number(it2.oid) === Number(view6.accessMethod));
|
|
169828
|
+
const tablespace = Number(view6.tablespaceid) === 0 ? null : tablespaces.find((it2) => Number(it2.oid) === Number(view6.tablespaceid)).name;
|
|
169930
169829
|
const definition = parseViewDefinition(view6.definition);
|
|
169931
169830
|
const withOpts = wrapRecord(
|
|
169932
169831
|
((_b = view6.options) == null ? void 0 : _b.reduce((acc, it2) => {
|
|
@@ -176933,6 +176832,7 @@ var init_cors = __esm({
|
|
|
176933
176832
|
// src/cli/commands/studio.ts
|
|
176934
176833
|
var studio_exports = {};
|
|
176935
176834
|
__export(studio_exports, {
|
|
176835
|
+
drizzleForDuckDb: () => drizzleForDuckDb,
|
|
176936
176836
|
drizzleForLibSQL: () => drizzleForLibSQL,
|
|
176937
176837
|
drizzleForMySQL: () => drizzleForMySQL,
|
|
176938
176838
|
drizzleForPostgres: () => drizzleForPostgres,
|
|
@@ -176946,7 +176846,7 @@ __export(studio_exports, {
|
|
|
176946
176846
|
prepareServer: () => prepareServer,
|
|
176947
176847
|
prepareSingleStoreSchema: () => prepareSingleStoreSchema
|
|
176948
176848
|
});
|
|
176949
|
-
var import_crypto11, import_drizzle_orm8, import_relations8, import_mssql_core3, import_mysql_core3, import_pg_core3, import_singlestore_core2, import_sqlite_core3, import_fs16, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init, proxySchema, transactionProxySchema,
|
|
176849
|
+
var import_crypto11, import_drizzle_orm8, import_relations8, import_mssql_core3, import_mysql_core3, import_pg_core3, import_singlestore_core2, import_sqlite_core3, import_fs16, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForDuckDb, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
|
|
176950
176850
|
var init_studio = __esm({
|
|
176951
176851
|
"src/cli/commands/studio.ts"() {
|
|
176952
176852
|
"use strict";
|
|
@@ -177170,7 +177070,6 @@ var init_studio = __esm({
|
|
|
177170
177070
|
packageName: db.packageName,
|
|
177171
177071
|
proxy: db.proxy,
|
|
177172
177072
|
transactionProxy: db.transactionProxy,
|
|
177173
|
-
benchmarkProxy: db.benchmarkProxy,
|
|
177174
177073
|
customDefaults,
|
|
177175
177074
|
schema: pgSchema2,
|
|
177176
177075
|
relations: relations5,
|
|
@@ -177178,9 +177077,26 @@ var init_studio = __esm({
|
|
|
177178
177077
|
casing: casing2
|
|
177179
177078
|
};
|
|
177180
177079
|
};
|
|
177080
|
+
drizzleForDuckDb = async (credentials2) => {
|
|
177081
|
+
const { prepareDuckDb: prepareDuckDb2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
177082
|
+
const db = await prepareDuckDb2(credentials2);
|
|
177083
|
+
const dbUrl = `duckdb://${credentials2.url}`;
|
|
177084
|
+
const dbHash = (0, import_crypto11.createHash)("sha256").update(dbUrl).digest("hex");
|
|
177085
|
+
return {
|
|
177086
|
+
dbHash,
|
|
177087
|
+
dialect: "duckdb",
|
|
177088
|
+
driver: void 0,
|
|
177089
|
+
packageName: db.packageName,
|
|
177090
|
+
proxy: db.proxy,
|
|
177091
|
+
transactionProxy: db.transactionProxy,
|
|
177092
|
+
customDefaults: [],
|
|
177093
|
+
schema: {},
|
|
177094
|
+
relations: {}
|
|
177095
|
+
};
|
|
177096
|
+
};
|
|
177181
177097
|
drizzleForMySQL = async (credentials2, mysqlSchema, relations5, schemaFiles, casing2) => {
|
|
177182
177098
|
const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
177183
|
-
const { proxy, transactionProxy,
|
|
177099
|
+
const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials2);
|
|
177184
177100
|
const customDefaults = getCustomDefaults(mysqlSchema, casing2);
|
|
177185
177101
|
let dbUrl;
|
|
177186
177102
|
if ("url" in credentials2) {
|
|
@@ -177196,7 +177112,6 @@ var init_studio = __esm({
|
|
|
177196
177112
|
databaseName: database,
|
|
177197
177113
|
proxy,
|
|
177198
177114
|
transactionProxy,
|
|
177199
|
-
benchmarkProxy,
|
|
177200
177115
|
customDefaults,
|
|
177201
177116
|
schema: mysqlSchema,
|
|
177202
177117
|
relations: relations5,
|
|
@@ -177366,23 +177281,6 @@ var init_studio = __esm({
|
|
|
177366
177281
|
]).optional()
|
|
177367
177282
|
}).array()
|
|
177368
177283
|
});
|
|
177369
|
-
benchmarkProxySchema = external_exports.object({
|
|
177370
|
-
type: external_exports.literal("bproxy"),
|
|
177371
|
-
data: external_exports.object({
|
|
177372
|
-
query: external_exports.object({
|
|
177373
|
-
sql: external_exports.string(),
|
|
177374
|
-
params: external_exports.array(external_exports.any()).optional(),
|
|
177375
|
-
method: external_exports.union([
|
|
177376
|
-
external_exports.literal("values"),
|
|
177377
|
-
external_exports.literal("get"),
|
|
177378
|
-
external_exports.literal("all"),
|
|
177379
|
-
external_exports.literal("run"),
|
|
177380
|
-
external_exports.literal("execute")
|
|
177381
|
-
]).optional()
|
|
177382
|
-
}),
|
|
177383
|
-
repeats: external_exports.number().min(1).optional()
|
|
177384
|
-
})
|
|
177385
|
-
});
|
|
177386
177284
|
defaultsSchema = external_exports.object({
|
|
177387
177285
|
type: external_exports.literal("defaults"),
|
|
177388
177286
|
data: external_exports.array(
|
|
@@ -177397,7 +177295,6 @@ var init_studio = __esm({
|
|
|
177397
177295
|
init,
|
|
177398
177296
|
proxySchema,
|
|
177399
177297
|
transactionProxySchema,
|
|
177400
|
-
benchmarkProxySchema,
|
|
177401
177298
|
defaultsSchema
|
|
177402
177299
|
]);
|
|
177403
177300
|
jsonStringify = (data2) => {
|
|
@@ -177420,7 +177317,6 @@ var init_studio = __esm({
|
|
|
177420
177317
|
databaseName,
|
|
177421
177318
|
proxy,
|
|
177422
177319
|
transactionProxy,
|
|
177423
|
-
benchmarkProxy,
|
|
177424
177320
|
customDefaults,
|
|
177425
177321
|
schema: drizzleSchema,
|
|
177426
177322
|
relations: relations5,
|
|
@@ -177484,7 +177380,7 @@ var init_studio = __esm({
|
|
|
177484
177380
|
console.warn("Error message:", error4.message);
|
|
177485
177381
|
}
|
|
177486
177382
|
return c5.json({
|
|
177487
|
-
version: "6.
|
|
177383
|
+
version: "6.2",
|
|
177488
177384
|
dialect: dialect6,
|
|
177489
177385
|
driver: driver2,
|
|
177490
177386
|
packageName,
|
|
@@ -177522,21 +177418,6 @@ var init_studio = __esm({
|
|
|
177522
177418
|
}
|
|
177523
177419
|
);
|
|
177524
177420
|
}
|
|
177525
|
-
if (type === "bproxy") {
|
|
177526
|
-
if (!benchmarkProxy) {
|
|
177527
|
-
throw new Error("Benchmark proxy is not configured for this database.");
|
|
177528
|
-
}
|
|
177529
|
-
const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
|
|
177530
|
-
const res = jsonStringify(result2);
|
|
177531
|
-
return c5.body(
|
|
177532
|
-
res,
|
|
177533
|
-
{
|
|
177534
|
-
headers: {
|
|
177535
|
-
"Content-Type": "application/json"
|
|
177536
|
-
}
|
|
177537
|
-
}
|
|
177538
|
-
);
|
|
177539
|
-
}
|
|
177540
177421
|
if (type === "defaults") {
|
|
177541
177422
|
const columns = body.data;
|
|
177542
177423
|
const result2 = columns.map((column12) => {
|
|
@@ -179474,6 +179355,25 @@ var printConfigConnectionIssues = (options) => {
|
|
|
179474
179355
|
// src/cli/commands/utils.ts
|
|
179475
179356
|
init_common3();
|
|
179476
179357
|
|
|
179358
|
+
// src/cli/validations/duckdb.ts
|
|
179359
|
+
init_esm();
|
|
179360
|
+
init_views();
|
|
179361
|
+
init_common3();
|
|
179362
|
+
var duckdbCredentials = objectType({
|
|
179363
|
+
driver: undefinedType(),
|
|
179364
|
+
url: stringType().min(1)
|
|
179365
|
+
}).transform((o5) => {
|
|
179366
|
+
delete o5.driver;
|
|
179367
|
+
return o5;
|
|
179368
|
+
});
|
|
179369
|
+
var printConfigConnectionIssues2 = (options) => {
|
|
179370
|
+
const text = `Please provide required params:
|
|
179371
|
+
`;
|
|
179372
|
+
console.log(error2(text));
|
|
179373
|
+
console.log(wrapParam("url", options.url));
|
|
179374
|
+
process.exit(1);
|
|
179375
|
+
};
|
|
179376
|
+
|
|
179477
179377
|
// src/cli/validations/gel.ts
|
|
179478
179378
|
init_esm();
|
|
179479
179379
|
init_views();
|
|
@@ -179514,7 +179414,7 @@ var gelCredentials = unionType([
|
|
|
179514
179414
|
}).transform(() => {
|
|
179515
179415
|
})
|
|
179516
179416
|
]);
|
|
179517
|
-
var
|
|
179417
|
+
var printConfigConnectionIssues3 = (options) => {
|
|
179518
179418
|
if ("url" in options) {
|
|
179519
179419
|
let text = `Please provide required params for Gel driver:
|
|
179520
179420
|
`;
|
|
@@ -179550,7 +179450,7 @@ var libSQLCredentials = objectType({
|
|
|
179550
179450
|
url: stringType().min(1),
|
|
179551
179451
|
authToken: stringType().min(1).optional()
|
|
179552
179452
|
});
|
|
179553
|
-
var
|
|
179453
|
+
var printConfigConnectionIssues4 = (options, _command) => {
|
|
179554
179454
|
let text = `Please provide required params for 'turso' dialect:
|
|
179555
179455
|
`;
|
|
179556
179456
|
console.log(error2(text));
|
|
@@ -179580,7 +179480,7 @@ var mssqlCredentials = unionType([
|
|
|
179580
179480
|
url: stringType().min(1)
|
|
179581
179481
|
})
|
|
179582
179482
|
]);
|
|
179583
|
-
var
|
|
179483
|
+
var printConfigConnectionIssues5 = (options) => {
|
|
179584
179484
|
if ("url" in options) {
|
|
179585
179485
|
let text2 = `Please provide required params for MsSQL driver:
|
|
179586
179486
|
`;
|
|
@@ -179629,7 +179529,7 @@ var mysqlCredentials = unionType([
|
|
|
179629
179529
|
url: stringType().min(1)
|
|
179630
179530
|
})
|
|
179631
179531
|
]);
|
|
179632
|
-
var
|
|
179532
|
+
var printConfigConnectionIssues6 = (options) => {
|
|
179633
179533
|
if ("url" in options) {
|
|
179634
179534
|
let text2 = `Please provide required params for MySQL driver:
|
|
179635
179535
|
`;
|
|
@@ -179694,7 +179594,7 @@ var postgresCredentials = unionType([
|
|
|
179694
179594
|
url: stringType().min(1)
|
|
179695
179595
|
})
|
|
179696
179596
|
]);
|
|
179697
|
-
var
|
|
179597
|
+
var printConfigConnectionIssues7 = (options) => {
|
|
179698
179598
|
if (options.driver === "aws-data-api") {
|
|
179699
179599
|
let text = `Please provide required params for AWS Data API driver:
|
|
179700
179600
|
`;
|
|
@@ -179761,7 +179661,7 @@ var singlestoreCredentials = unionType([
|
|
|
179761
179661
|
url: stringType().min(1)
|
|
179762
179662
|
})
|
|
179763
179663
|
]);
|
|
179764
|
-
var
|
|
179664
|
+
var printConfigConnectionIssues8 = (options) => {
|
|
179765
179665
|
if ("url" in options) {
|
|
179766
179666
|
let text2 = `Please provide required params for SingleStore driver:
|
|
179767
179667
|
`;
|
|
@@ -179810,7 +179710,7 @@ var sqliteCredentials = unionType([
|
|
|
179810
179710
|
return o5;
|
|
179811
179711
|
})
|
|
179812
179712
|
]);
|
|
179813
|
-
var
|
|
179713
|
+
var printConfigConnectionIssues9 = (options, command2) => {
|
|
179814
179714
|
const parsedDriver = sqliteDriver.safeParse(options.driver);
|
|
179815
179715
|
const driver2 = parsedDriver.success ? parsedDriver.data : "";
|
|
179816
179716
|
if (driver2 === "expo") {
|
|
@@ -180014,7 +179914,7 @@ var preparePushConfig = async (options, from) => {
|
|
|
180014
179914
|
if (config.dialect === "postgresql") {
|
|
180015
179915
|
const parsed2 = postgresCredentials.safeParse(config);
|
|
180016
179916
|
if (!parsed2.success) {
|
|
180017
|
-
|
|
179917
|
+
printConfigConnectionIssues7(config);
|
|
180018
179918
|
process.exit(1);
|
|
180019
179919
|
}
|
|
180020
179920
|
return {
|
|
@@ -180031,7 +179931,7 @@ var preparePushConfig = async (options, from) => {
|
|
|
180031
179931
|
if (config.dialect === "mysql") {
|
|
180032
179932
|
const parsed2 = mysqlCredentials.safeParse(config);
|
|
180033
179933
|
if (!parsed2.success) {
|
|
180034
|
-
|
|
179934
|
+
printConfigConnectionIssues6(config);
|
|
180035
179935
|
process.exit(1);
|
|
180036
179936
|
}
|
|
180037
179937
|
return {
|
|
@@ -180048,7 +179948,7 @@ var preparePushConfig = async (options, from) => {
|
|
|
180048
179948
|
if (config.dialect === "singlestore") {
|
|
180049
179949
|
const parsed2 = singlestoreCredentials.safeParse(config);
|
|
180050
179950
|
if (!parsed2.success) {
|
|
180051
|
-
|
|
179951
|
+
printConfigConnectionIssues8(config);
|
|
180052
179952
|
process.exit(1);
|
|
180053
179953
|
}
|
|
180054
179954
|
return {
|
|
@@ -180064,7 +179964,7 @@ var preparePushConfig = async (options, from) => {
|
|
|
180064
179964
|
if (config.dialect === "sqlite") {
|
|
180065
179965
|
const parsed2 = sqliteCredentials.safeParse(config);
|
|
180066
179966
|
if (!parsed2.success) {
|
|
180067
|
-
|
|
179967
|
+
printConfigConnectionIssues9(config, "push");
|
|
180068
179968
|
process.exit(1);
|
|
180069
179969
|
}
|
|
180070
179970
|
return {
|
|
@@ -180081,7 +179981,7 @@ var preparePushConfig = async (options, from) => {
|
|
|
180081
179981
|
if (config.dialect === "turso") {
|
|
180082
179982
|
const parsed2 = libSQLCredentials.safeParse(config);
|
|
180083
179983
|
if (!parsed2.success) {
|
|
180084
|
-
|
|
179984
|
+
printConfigConnectionIssues9(config, "push");
|
|
180085
179985
|
process.exit(1);
|
|
180086
179986
|
}
|
|
180087
179987
|
return {
|
|
@@ -180136,6 +180036,14 @@ var preparePushConfig = async (options, from) => {
|
|
|
180136
180036
|
explain: false
|
|
180137
180037
|
};
|
|
180138
180038
|
}
|
|
180039
|
+
if (config.dialect === "duckdb") {
|
|
180040
|
+
console.log(
|
|
180041
|
+
error2(
|
|
180042
|
+
`You can't use 'push' command with DuckDb dialect`
|
|
180043
|
+
)
|
|
180044
|
+
);
|
|
180045
|
+
process.exit(1);
|
|
180046
|
+
}
|
|
180139
180047
|
assertUnreachable(config.dialect);
|
|
180140
180048
|
};
|
|
180141
180049
|
var preparePullConfig = async (options, from) => {
|
|
@@ -180161,7 +180069,7 @@ var preparePullConfig = async (options, from) => {
|
|
|
180161
180069
|
if (dialect6 === "postgresql") {
|
|
180162
180070
|
const parsed2 = postgresCredentials.safeParse(config);
|
|
180163
180071
|
if (!parsed2.success) {
|
|
180164
|
-
|
|
180072
|
+
printConfigConnectionIssues7(config);
|
|
180165
180073
|
process.exit(1);
|
|
180166
180074
|
}
|
|
180167
180075
|
return {
|
|
@@ -180180,7 +180088,7 @@ var preparePullConfig = async (options, from) => {
|
|
|
180180
180088
|
if (dialect6 === "mysql") {
|
|
180181
180089
|
const parsed2 = mysqlCredentials.safeParse(config);
|
|
180182
180090
|
if (!parsed2.success) {
|
|
180183
|
-
|
|
180091
|
+
printConfigConnectionIssues6(config);
|
|
180184
180092
|
process.exit(1);
|
|
180185
180093
|
}
|
|
180186
180094
|
return {
|
|
@@ -180199,7 +180107,7 @@ var preparePullConfig = async (options, from) => {
|
|
|
180199
180107
|
if (dialect6 === "singlestore") {
|
|
180200
180108
|
const parsed2 = singlestoreCredentials.safeParse(config);
|
|
180201
180109
|
if (!parsed2.success) {
|
|
180202
|
-
|
|
180110
|
+
printConfigConnectionIssues8(config);
|
|
180203
180111
|
process.exit(1);
|
|
180204
180112
|
}
|
|
180205
180113
|
return {
|
|
@@ -180218,7 +180126,7 @@ var preparePullConfig = async (options, from) => {
|
|
|
180218
180126
|
if (dialect6 === "sqlite") {
|
|
180219
180127
|
const parsed2 = sqliteCredentials.safeParse(config);
|
|
180220
180128
|
if (!parsed2.success) {
|
|
180221
|
-
|
|
180129
|
+
printConfigConnectionIssues9(config, "pull");
|
|
180222
180130
|
process.exit(1);
|
|
180223
180131
|
}
|
|
180224
180132
|
return {
|
|
@@ -180237,7 +180145,7 @@ var preparePullConfig = async (options, from) => {
|
|
|
180237
180145
|
if (dialect6 === "turso") {
|
|
180238
180146
|
const parsed2 = libSQLCredentials.safeParse(config);
|
|
180239
180147
|
if (!parsed2.success) {
|
|
180240
|
-
|
|
180148
|
+
printConfigConnectionIssues4(config, "pull");
|
|
180241
180149
|
process.exit(1);
|
|
180242
180150
|
}
|
|
180243
180151
|
return {
|
|
@@ -180256,7 +180164,7 @@ var preparePullConfig = async (options, from) => {
|
|
|
180256
180164
|
if (dialect6 === "gel") {
|
|
180257
180165
|
const parsed2 = gelCredentials.safeParse(config);
|
|
180258
180166
|
if (!parsed2.success) {
|
|
180259
|
-
|
|
180167
|
+
printConfigConnectionIssues3(config);
|
|
180260
180168
|
process.exit(1);
|
|
180261
180169
|
}
|
|
180262
180170
|
return {
|
|
@@ -180309,6 +180217,14 @@ var preparePullConfig = async (options, from) => {
|
|
|
180309
180217
|
migrationsTable: table7
|
|
180310
180218
|
};
|
|
180311
180219
|
}
|
|
180220
|
+
if (dialect6 === "duckdb") {
|
|
180221
|
+
console.log(
|
|
180222
|
+
error2(
|
|
180223
|
+
`You can't use 'pull' command with DuckDb dialect`
|
|
180224
|
+
)
|
|
180225
|
+
);
|
|
180226
|
+
process.exit(1);
|
|
180227
|
+
}
|
|
180312
180228
|
assertUnreachable(dialect6);
|
|
180313
180229
|
};
|
|
180314
180230
|
var prepareStudioConfig = async (options) => {
|
|
@@ -180331,7 +180247,7 @@ var prepareStudioConfig = async (options) => {
|
|
|
180331
180247
|
if (dialect6 === "postgresql") {
|
|
180332
180248
|
const parsed = postgresCredentials.safeParse(flattened);
|
|
180333
180249
|
if (!parsed.success) {
|
|
180334
|
-
|
|
180250
|
+
printConfigConnectionIssues7(flattened);
|
|
180335
180251
|
process.exit(1);
|
|
180336
180252
|
}
|
|
180337
180253
|
const credentials2 = parsed.data;
|
|
@@ -180347,7 +180263,7 @@ var prepareStudioConfig = async (options) => {
|
|
|
180347
180263
|
if (dialect6 === "mysql") {
|
|
180348
180264
|
const parsed = mysqlCredentials.safeParse(flattened);
|
|
180349
180265
|
if (!parsed.success) {
|
|
180350
|
-
|
|
180266
|
+
printConfigConnectionIssues6(flattened);
|
|
180351
180267
|
process.exit(1);
|
|
180352
180268
|
}
|
|
180353
180269
|
const credentials2 = parsed.data;
|
|
@@ -180363,7 +180279,7 @@ var prepareStudioConfig = async (options) => {
|
|
|
180363
180279
|
if (dialect6 === "singlestore") {
|
|
180364
180280
|
const parsed = singlestoreCredentials.safeParse(flattened);
|
|
180365
180281
|
if (!parsed.success) {
|
|
180366
|
-
|
|
180282
|
+
printConfigConnectionIssues8(flattened);
|
|
180367
180283
|
process.exit(1);
|
|
180368
180284
|
}
|
|
180369
180285
|
const credentials2 = parsed.data;
|
|
@@ -180379,7 +180295,7 @@ var prepareStudioConfig = async (options) => {
|
|
|
180379
180295
|
if (dialect6 === "sqlite") {
|
|
180380
180296
|
const parsed = sqliteCredentials.safeParse(flattened);
|
|
180381
180297
|
if (!parsed.success) {
|
|
180382
|
-
|
|
180298
|
+
printConfigConnectionIssues9(flattened, "studio");
|
|
180383
180299
|
process.exit(1);
|
|
180384
180300
|
}
|
|
180385
180301
|
const credentials2 = parsed.data;
|
|
@@ -180395,7 +180311,7 @@ var prepareStudioConfig = async (options) => {
|
|
|
180395
180311
|
if (dialect6 === "turso") {
|
|
180396
180312
|
const parsed = libSQLCredentials.safeParse(flattened);
|
|
180397
180313
|
if (!parsed.success) {
|
|
180398
|
-
|
|
180314
|
+
printConfigConnectionIssues4(flattened, "studio");
|
|
180399
180315
|
process.exit(1);
|
|
180400
180316
|
}
|
|
180401
180317
|
const credentials2 = parsed.data;
|
|
@@ -180429,6 +180345,21 @@ var prepareStudioConfig = async (options) => {
|
|
|
180429
180345
|
if (dialect6 === "mssql") {
|
|
180430
180346
|
throw new Error(`You can't use 'studio' command with MsSql dialect yet`);
|
|
180431
180347
|
}
|
|
180348
|
+
if (dialect6 === "duckdb") {
|
|
180349
|
+
const parsed = duckdbCredentials.safeParse(flattened);
|
|
180350
|
+
if (!parsed.success) {
|
|
180351
|
+
printConfigConnectionIssues2(flattened);
|
|
180352
|
+
process.exit(1);
|
|
180353
|
+
}
|
|
180354
|
+
const credentials2 = parsed.data;
|
|
180355
|
+
return {
|
|
180356
|
+
dialect: dialect6,
|
|
180357
|
+
schema: schema6,
|
|
180358
|
+
host,
|
|
180359
|
+
port,
|
|
180360
|
+
credentials: credentials2
|
|
180361
|
+
};
|
|
180362
|
+
}
|
|
180432
180363
|
assertUnreachable(dialect6);
|
|
180433
180364
|
};
|
|
180434
180365
|
var migrateConfig = objectType({
|
|
@@ -180450,7 +180381,7 @@ var prepareMigrateConfig = async (configPath) => {
|
|
|
180450
180381
|
if (dialect6 === "postgresql") {
|
|
180451
180382
|
const parsed2 = postgresCredentials.safeParse(flattened);
|
|
180452
180383
|
if (!parsed2.success) {
|
|
180453
|
-
|
|
180384
|
+
printConfigConnectionIssues7(flattened);
|
|
180454
180385
|
process.exit(1);
|
|
180455
180386
|
}
|
|
180456
180387
|
const credentials2 = parsed2.data;
|
|
@@ -180465,7 +180396,7 @@ var prepareMigrateConfig = async (configPath) => {
|
|
|
180465
180396
|
if (dialect6 === "mysql") {
|
|
180466
180397
|
const parsed2 = mysqlCredentials.safeParse(flattened);
|
|
180467
180398
|
if (!parsed2.success) {
|
|
180468
|
-
|
|
180399
|
+
printConfigConnectionIssues6(flattened);
|
|
180469
180400
|
process.exit(1);
|
|
180470
180401
|
}
|
|
180471
180402
|
const credentials2 = parsed2.data;
|
|
@@ -180480,7 +180411,7 @@ var prepareMigrateConfig = async (configPath) => {
|
|
|
180480
180411
|
if (dialect6 === "singlestore") {
|
|
180481
180412
|
const parsed2 = singlestoreCredentials.safeParse(flattened);
|
|
180482
180413
|
if (!parsed2.success) {
|
|
180483
|
-
|
|
180414
|
+
printConfigConnectionIssues8(flattened);
|
|
180484
180415
|
process.exit(1);
|
|
180485
180416
|
}
|
|
180486
180417
|
const credentials2 = parsed2.data;
|
|
@@ -180495,7 +180426,7 @@ var prepareMigrateConfig = async (configPath) => {
|
|
|
180495
180426
|
if (dialect6 === "sqlite") {
|
|
180496
180427
|
const parsed2 = sqliteCredentials.safeParse(flattened);
|
|
180497
180428
|
if (!parsed2.success) {
|
|
180498
|
-
|
|
180429
|
+
printConfigConnectionIssues9(flattened, "migrate");
|
|
180499
180430
|
process.exit(1);
|
|
180500
180431
|
}
|
|
180501
180432
|
const credentials2 = parsed2.data;
|
|
@@ -180510,7 +180441,7 @@ var prepareMigrateConfig = async (configPath) => {
|
|
|
180510
180441
|
if (dialect6 === "turso") {
|
|
180511
180442
|
const parsed2 = libSQLCredentials.safeParse(flattened);
|
|
180512
180443
|
if (!parsed2.success) {
|
|
180513
|
-
|
|
180444
|
+
printConfigConnectionIssues4(flattened, "migrate");
|
|
180514
180445
|
process.exit(1);
|
|
180515
180446
|
}
|
|
180516
180447
|
const credentials2 = parsed2.data;
|
|
@@ -180533,7 +180464,7 @@ var prepareMigrateConfig = async (configPath) => {
|
|
|
180533
180464
|
if (dialect6 === "mssql") {
|
|
180534
180465
|
const parsed2 = mssqlCredentials.safeParse(flattened);
|
|
180535
180466
|
if (!parsed2.success) {
|
|
180536
|
-
|
|
180467
|
+
printConfigConnectionIssues5(flattened);
|
|
180537
180468
|
process.exit(1);
|
|
180538
180469
|
}
|
|
180539
180470
|
const credentials2 = parsed2.data;
|
|
@@ -180560,6 +180491,14 @@ var prepareMigrateConfig = async (configPath) => {
|
|
|
180560
180491
|
table: table7
|
|
180561
180492
|
};
|
|
180562
180493
|
}
|
|
180494
|
+
if (dialect6 === "duckdb") {
|
|
180495
|
+
console.log(
|
|
180496
|
+
error2(
|
|
180497
|
+
`You can't use 'migrate' command with DuckDb dialect`
|
|
180498
|
+
)
|
|
180499
|
+
);
|
|
180500
|
+
process.exit(1);
|
|
180501
|
+
}
|
|
180563
180502
|
assertUnreachable(dialect6);
|
|
180564
180503
|
};
|
|
180565
180504
|
var drizzleConfigFromFile = async (configPath, isExport) => {
|
|
@@ -181435,7 +181374,7 @@ init_common3();
|
|
|
181435
181374
|
init_outputs();
|
|
181436
181375
|
init_views();
|
|
181437
181376
|
var optionDialect = string("dialect").enum(...dialects).desc(
|
|
181438
|
-
`Database dialect: 'gel', 'postgresql', 'mysql', 'sqlite', 'turso', 'singlestore' or 'mssql'`
|
|
181377
|
+
`Database dialect: 'gel', 'postgresql', 'mysql', 'sqlite', 'turso', 'singlestore', 'duckdb' or 'mssql'`
|
|
181439
181378
|
);
|
|
181440
181379
|
var optionOut = string().desc("Output folder, 'drizzle' by default");
|
|
181441
181380
|
var optionConfig = string().desc("Path to drizzle config file");
|
|
@@ -181496,6 +181435,13 @@ var generate = command({
|
|
|
181496
181435
|
} else if (dialect6 === "cockroach") {
|
|
181497
181436
|
const { handle: handle21 } = await Promise.resolve().then(() => (init_generate_cockroach(), generate_cockroach_exports));
|
|
181498
181437
|
await handle21(opts);
|
|
181438
|
+
} else if (dialect6 === "duckdb") {
|
|
181439
|
+
console.log(
|
|
181440
|
+
error2(
|
|
181441
|
+
`You can't use 'generate' command with DuckDb dialect`
|
|
181442
|
+
)
|
|
181443
|
+
);
|
|
181444
|
+
process.exit(1);
|
|
181499
181445
|
} else {
|
|
181500
181446
|
assertUnreachable(dialect6);
|
|
181501
181447
|
}
|
|
@@ -181959,7 +181905,8 @@ var studio = command({
|
|
|
181959
181905
|
drizzleForSQLite: drizzleForSQLite2,
|
|
181960
181906
|
prepareSingleStoreSchema: prepareSingleStoreSchema2,
|
|
181961
181907
|
drizzleForSingleStore: drizzleForSingleStore2,
|
|
181962
|
-
drizzleForLibSQL: drizzleForLibSQL2
|
|
181908
|
+
drizzleForLibSQL: drizzleForLibSQL2,
|
|
181909
|
+
drizzleForDuckDb: drizzleForDuckDb2
|
|
181963
181910
|
// drizzleForMsSQL,
|
|
181964
181911
|
} = await Promise.resolve().then(() => (init_studio(), studio_exports));
|
|
181965
181912
|
let setup;
|
|
@@ -182004,6 +181951,8 @@ var studio = command({
|
|
|
182004
181951
|
files,
|
|
182005
181952
|
casing2
|
|
182006
181953
|
);
|
|
181954
|
+
} else if (dialect6 === "duckdb") {
|
|
181955
|
+
setup = await drizzleForDuckDb2(credentials2);
|
|
182007
181956
|
} else if (dialect6 === "cockroach") {
|
|
182008
181957
|
throw new Error(`You can't use 'studio' command with 'cockroach' dialect`);
|
|
182009
181958
|
} else {
|
|
@@ -182089,6 +182038,13 @@ var exportRaw = command({
|
|
|
182089
182038
|
} else if (dialect6 === "cockroach") {
|
|
182090
182039
|
const { handleExport: handleExport7 } = await Promise.resolve().then(() => (init_generate_cockroach(), generate_cockroach_exports));
|
|
182091
182040
|
await handleExport7(opts);
|
|
182041
|
+
} else if (dialect6 === "duckdb") {
|
|
182042
|
+
console.log(
|
|
182043
|
+
error2(
|
|
182044
|
+
`You can't use 'export' command with DuckDb dialect`
|
|
182045
|
+
)
|
|
182046
|
+
);
|
|
182047
|
+
process.exit(1);
|
|
182092
182048
|
} else {
|
|
182093
182049
|
assertUnreachable(dialect6);
|
|
182094
182050
|
}
|