drizzle-kit 1.0.0-beta.2-0f918b0 → 1.0.0-beta.2-09cddcb

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-sqlite.js CHANGED
@@ -28717,7 +28717,7 @@ var require_websocket = __commonJS({
28717
28717
  var EventEmitter = require("events");
28718
28718
  var https2 = require("https");
28719
28719
  var http3 = require("http");
28720
- var net2 = require("net");
28720
+ var net = require("net");
28721
28721
  var tls = require("tls");
28722
28722
  var { randomBytes, createHash: createHash5 } = require("crypto");
28723
28723
  var { Duplex, Readable: Readable6 } = require("stream");
@@ -29448,12 +29448,12 @@ var require_websocket = __commonJS({
29448
29448
  }
29449
29449
  function netConnect(options) {
29450
29450
  options.path = options.socketPath;
29451
- return net2.connect(options);
29451
+ return net.connect(options);
29452
29452
  }
29453
29453
  function tlsConnect(options) {
29454
29454
  options.path = void 0;
29455
29455
  if (!options.servername && options.servername !== "") {
29456
- options.servername = net2.isIP(options.host) ? "" : options.host;
29456
+ options.servername = net.isIP(options.host) ? "" : options.host;
29457
29457
  }
29458
29458
  return tls.connect(options);
29459
29459
  }
@@ -33772,7 +33772,7 @@ var init_timing = __esm({
33772
33772
  "../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
33773
33773
  "use strict";
33774
33774
  timing = {
33775
- setTimeout: (cb, ms2) => setTimeout(cb, ms2),
33775
+ setTimeout: (cb, ms) => setTimeout(cb, ms),
33776
33776
  clearTimeout: (timeoutId) => clearTimeout(timeoutId)
33777
33777
  };
33778
33778
  }
@@ -35660,13 +35660,13 @@ var init_schema_date_utils = __esm({
35660
35660
  if (!matches) {
35661
35661
  throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
35662
35662
  }
35663
- const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
35663
+ const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
35664
35664
  range(monthStr, 1, 12);
35665
35665
  range(dayStr, 1, 31);
35666
35666
  range(hours, 0, 23);
35667
35667
  range(minutes, 0, 59);
35668
35668
  range(seconds, 0, 60);
35669
- 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));
35669
+ 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));
35670
35670
  date2.setUTCFullYear(Number(yearStr));
35671
35671
  if (offsetStr.toUpperCase() != "Z") {
35672
35672
  const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
@@ -55680,8 +55680,8 @@ var require_datetime2 = __commonJS({
55680
55680
  if (!(object instanceof Date)) {
55681
55681
  throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
55682
55682
  }
55683
- const ms2 = object.getTime() - TIMESHIFT;
55684
- const us = ms2 * 1e3;
55683
+ const ms = object.getTime() - TIMESHIFT;
55684
+ const us = ms * 1e3;
55685
55685
  buf.writeInt32(8);
55686
55686
  buf.writeInt64(us);
55687
55687
  }
@@ -55691,12 +55691,12 @@ var require_datetime2 = __commonJS({
55691
55691
  return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
55692
55692
  }
55693
55693
  const us = Number(buf.readBigInt64());
55694
- let ms2 = Math.round(us / 1e3);
55695
- if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
55696
- ms2 -= 1;
55694
+ let ms = Math.round(us / 1e3);
55695
+ if (Math.abs(us % 1e3) === 500 && Math.abs(ms) % 2 === 1) {
55696
+ ms -= 1;
55697
55697
  }
55698
- ms2 += TIMESHIFT;
55699
- return new Date(ms2);
55698
+ ms += TIMESHIFT;
55699
+ return new Date(ms);
55700
55700
  }
55701
55701
  };
55702
55702
  exports2.DateTimeCodec = DateTimeCodec;
@@ -55717,8 +55717,8 @@ var require_datetime2 = __commonJS({
55717
55717
  if (!(object instanceof datetime_1.LocalDateTime)) {
55718
55718
  throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
55719
55719
  }
55720
- const ms2 = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
55721
- let us = ms2 * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
55720
+ const ms = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
55721
+ let us = ms * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
55722
55722
  if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
55723
55723
  us += 1n;
55724
55724
  }
@@ -55732,13 +55732,13 @@ var require_datetime2 = __commonJS({
55732
55732
  }
55733
55733
  const bi_ms = bi_us / 1000n;
55734
55734
  let us = Number(bi_us - bi_ms * 1000n);
55735
- let ms2 = Number(bi_ms);
55735
+ let ms = Number(bi_ms);
55736
55736
  if (us < 0) {
55737
55737
  us += 1e3;
55738
- ms2 -= 1;
55738
+ ms -= 1;
55739
55739
  }
55740
- ms2 += TIMESHIFT;
55741
- const date2 = new Date(ms2);
55740
+ ms += TIMESHIFT;
55741
+ const date2 = new Date(ms);
55742
55742
  return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
55743
55743
  }
55744
55744
  };
@@ -55800,13 +55800,13 @@ var require_datetime2 = __commonJS({
55800
55800
  }
55801
55801
  let us = Number(bius);
55802
55802
  let seconds = Math.floor(us / 1e6);
55803
- const ms2 = Math.floor(us % 1e6 / 1e3);
55804
- us = us % 1e6 - ms2 * 1e3;
55803
+ const ms = Math.floor(us % 1e6 / 1e3);
55804
+ us = us % 1e6 - ms * 1e3;
55805
55805
  let minutes = Math.floor(seconds / 60);
55806
55806
  seconds = Math.floor(seconds % 60);
55807
55807
  const hours = Math.floor(minutes / 60);
55808
55808
  minutes = Math.floor(minutes % 60);
55809
- return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
55809
+ return new datetime_1.LocalTime(hours, minutes, seconds, ms, us);
55810
55810
  }
55811
55811
  };
55812
55812
  exports2.LocalTimeCodec = LocalTimeCodec;
@@ -55883,14 +55883,14 @@ var require_datetime2 = __commonJS({
55883
55883
  const biMillion = 1000000n;
55884
55884
  const biSeconds = bius / biMillion;
55885
55885
  let us = Number(bius - biSeconds * biMillion);
55886
- const ms2 = Math.floor(us / 1e3);
55886
+ const ms = Math.floor(us / 1e3);
55887
55887
  us = us % 1e3;
55888
55888
  let seconds = Number(biSeconds);
55889
55889
  let minutes = Math.floor(seconds / 60);
55890
55890
  seconds = Math.floor(seconds % 60);
55891
55891
  const hours = Math.floor(minutes / 60);
55892
55892
  minutes = Math.floor(minutes % 60);
55893
- return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
55893
+ return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
55894
55894
  }
55895
55895
  };
55896
55896
  exports2.DurationCodec = DurationCodec;
@@ -55936,7 +55936,7 @@ var require_datetime2 = __commonJS({
55936
55936
  const million = BigInt(1e6);
55937
55937
  const biSeconds = bius / million;
55938
55938
  let us = Number(bius - biSeconds * million);
55939
- const ms2 = Math.trunc(us / 1e3);
55939
+ const ms = Math.trunc(us / 1e3);
55940
55940
  us = us % 1e3;
55941
55941
  let seconds = Number(biSeconds);
55942
55942
  let minutes = Math.trunc(seconds / 60);
@@ -55947,7 +55947,7 @@ var require_datetime2 = __commonJS({
55947
55947
  days = Math.trunc(days % 7);
55948
55948
  const years = Math.trunc(months2 / 12);
55949
55949
  months2 = Math.trunc(months2 % 12);
55950
- return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
55950
+ return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
55951
55951
  }
55952
55952
  };
55953
55953
  exports2.RelativeDurationCodec = RelativeDurationCodec;
@@ -66111,41 +66111,41 @@ var require_ms = __commonJS({
66111
66111
  return void 0;
66112
66112
  }
66113
66113
  }
66114
- function fmtShort(ms2) {
66115
- var msAbs = Math.abs(ms2);
66114
+ function fmtShort(ms) {
66115
+ var msAbs = Math.abs(ms);
66116
66116
  if (msAbs >= d6) {
66117
- return Math.round(ms2 / d6) + "d";
66117
+ return Math.round(ms / d6) + "d";
66118
66118
  }
66119
66119
  if (msAbs >= h7) {
66120
- return Math.round(ms2 / h7) + "h";
66120
+ return Math.round(ms / h7) + "h";
66121
66121
  }
66122
66122
  if (msAbs >= m7) {
66123
- return Math.round(ms2 / m7) + "m";
66123
+ return Math.round(ms / m7) + "m";
66124
66124
  }
66125
66125
  if (msAbs >= s7) {
66126
- return Math.round(ms2 / s7) + "s";
66126
+ return Math.round(ms / s7) + "s";
66127
66127
  }
66128
- return ms2 + "ms";
66128
+ return ms + "ms";
66129
66129
  }
66130
- function fmtLong(ms2) {
66131
- var msAbs = Math.abs(ms2);
66130
+ function fmtLong(ms) {
66131
+ var msAbs = Math.abs(ms);
66132
66132
  if (msAbs >= d6) {
66133
- return plural(ms2, msAbs, d6, "day");
66133
+ return plural(ms, msAbs, d6, "day");
66134
66134
  }
66135
66135
  if (msAbs >= h7) {
66136
- return plural(ms2, msAbs, h7, "hour");
66136
+ return plural(ms, msAbs, h7, "hour");
66137
66137
  }
66138
66138
  if (msAbs >= m7) {
66139
- return plural(ms2, msAbs, m7, "minute");
66139
+ return plural(ms, msAbs, m7, "minute");
66140
66140
  }
66141
66141
  if (msAbs >= s7) {
66142
- return plural(ms2, msAbs, s7, "second");
66142
+ return plural(ms, msAbs, s7, "second");
66143
66143
  }
66144
- return ms2 + " ms";
66144
+ return ms + " ms";
66145
66145
  }
66146
- function plural(ms2, msAbs, n6, name) {
66146
+ function plural(ms, msAbs, n6, name) {
66147
66147
  var isPlural = msAbs >= n6 * 1.5;
66148
- return Math.round(ms2 / n6) + " " + name + (isPlural ? "s" : "");
66148
+ return Math.round(ms / n6) + " " + name + (isPlural ? "s" : "");
66149
66149
  }
66150
66150
  }
66151
66151
  });
@@ -66189,8 +66189,8 @@ var require_common2 = __commonJS({
66189
66189
  }
66190
66190
  const self2 = debug;
66191
66191
  const curr = Number(/* @__PURE__ */ new Date());
66192
- const ms2 = curr - (prevTime || curr);
66193
- self2.diff = ms2;
66192
+ const ms = curr - (prevTime || curr);
66193
+ self2.diff = ms;
66194
66194
  self2.prev = prevTime;
66195
66195
  self2.curr = curr;
66196
66196
  prevTime = curr;
@@ -81693,11 +81693,11 @@ var require_TokenExpiredError = __commonJS({
81693
81693
  var require_timespan = __commonJS({
81694
81694
  "../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module2) {
81695
81695
  "use strict";
81696
- var ms2 = require_ms();
81696
+ var ms = require_ms();
81697
81697
  module2.exports = function(time2, iat) {
81698
81698
  var timestamp = iat || Math.floor(Date.now() / 1e3);
81699
81699
  if (typeof time2 === "string") {
81700
- var milliseconds = ms2(time2);
81700
+ var milliseconds = ms(time2);
81701
81701
  if (typeof milliseconds === "undefined") {
81702
81702
  return;
81703
81703
  }
@@ -96235,7 +96235,7 @@ var require_dist = __commonJS({
96235
96235
  };
96236
96236
  Object.defineProperty(exports2, "__esModule", { value: true });
96237
96237
  exports2.Agent = void 0;
96238
- var net2 = __importStar2(require("net"));
96238
+ var net = __importStar2(require("net"));
96239
96239
  var http3 = __importStar2(require("http"));
96240
96240
  var https_1 = require("https");
96241
96241
  __exportStar2(require_helpers2(), exports2);
@@ -96275,7 +96275,7 @@ var require_dist = __commonJS({
96275
96275
  if (!this.sockets[name]) {
96276
96276
  this.sockets[name] = [];
96277
96277
  }
96278
- const fakeSocket = new net2.Socket({ writable: false });
96278
+ const fakeSocket = new net.Socket({ writable: false });
96279
96279
  this.sockets[name].push(fakeSocket);
96280
96280
  this.totalSocketCount++;
96281
96281
  return fakeSocket;
@@ -96487,7 +96487,7 @@ var require_dist2 = __commonJS({
96487
96487
  };
96488
96488
  Object.defineProperty(exports2, "__esModule", { value: true });
96489
96489
  exports2.HttpsProxyAgent = void 0;
96490
- var net2 = __importStar2(require("net"));
96490
+ var net = __importStar2(require("net"));
96491
96491
  var tls = __importStar2(require("tls"));
96492
96492
  var assert_1 = __importDefault2(require("assert"));
96493
96493
  var debug_1 = __importDefault2(require_src2());
@@ -96496,7 +96496,7 @@ var require_dist2 = __commonJS({
96496
96496
  var parse_proxy_response_1 = require_parse_proxy_response();
96497
96497
  var debug = (0, debug_1.default)("https-proxy-agent");
96498
96498
  var setServernameFromNonIpHost = (options) => {
96499
- if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
96499
+ if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
96500
96500
  return {
96501
96501
  ...options,
96502
96502
  servername: options.host
@@ -96536,10 +96536,10 @@ var require_dist2 = __commonJS({
96536
96536
  socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
96537
96537
  } else {
96538
96538
  debug("Creating `net.Socket`: %o", this.connectOpts);
96539
- socket = net2.connect(this.connectOpts);
96539
+ socket = net.connect(this.connectOpts);
96540
96540
  }
96541
96541
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
96542
- const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
96542
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
96543
96543
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
96544
96544
  `;
96545
96545
  if (proxy.username || proxy.password) {
@@ -96572,7 +96572,7 @@ var require_dist2 = __commonJS({
96572
96572
  return socket;
96573
96573
  }
96574
96574
  socket.destroy();
96575
- const fakeSocket = new net2.Socket({ writable: false });
96575
+ const fakeSocket = new net.Socket({ writable: false });
96576
96576
  fakeSocket.readable = true;
96577
96577
  req.once("socket", (s7) => {
96578
96578
  debug("Replaying proxy buffer for failed request");
@@ -96637,7 +96637,7 @@ var require_dist3 = __commonJS({
96637
96637
  };
96638
96638
  Object.defineProperty(exports2, "__esModule", { value: true });
96639
96639
  exports2.HttpProxyAgent = void 0;
96640
- var net2 = __importStar2(require("net"));
96640
+ var net = __importStar2(require("net"));
96641
96641
  var tls = __importStar2(require("tls"));
96642
96642
  var debug_1 = __importDefault2(require_src2());
96643
96643
  var events_1 = require("events");
@@ -96710,7 +96710,7 @@ var require_dist3 = __commonJS({
96710
96710
  socket = tls.connect(this.connectOpts);
96711
96711
  } else {
96712
96712
  debug("Creating `net.Socket`: %o", this.connectOpts);
96713
- socket = net2.connect(this.connectOpts);
96713
+ socket = net.connect(this.connectOpts);
96714
96714
  }
96715
96715
  await (0, events_1.once)(socket, "connect");
96716
96716
  return socket;
@@ -135590,7 +135590,7 @@ var require_connection = __commonJS({
135590
135590
  var _crypto = _interopRequireDefault(require("crypto"));
135591
135591
  var _os = _interopRequireDefault(require("os"));
135592
135592
  var tls = _interopRequireWildcard(require("tls"));
135593
- var net2 = _interopRequireWildcard(require("net"));
135593
+ var net = _interopRequireWildcard(require("net"));
135594
135594
  var _dns = _interopRequireDefault(require("dns"));
135595
135595
  var _constants = _interopRequireDefault(require("constants"));
135596
135596
  var _stream = require("stream");
@@ -136639,7 +136639,7 @@ var require_connection = __commonJS({
136639
136639
  async wrapWithTls(socket, signal) {
136640
136640
  signal.throwIfAborted();
136641
136641
  const secureContext = tls.createSecureContext(this.secureContextOptions);
136642
- const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
136642
+ const serverName = !net.isIP(this.config.server) ? this.config.server : "";
136643
136643
  const encryptOptions = {
136644
136644
  host: this.config.server,
136645
136645
  socket,
@@ -139561,11 +139561,10 @@ function parseMssqlUrl(url) {
139561
139561
  }
139562
139562
  };
139563
139563
  }
139564
- var import_net, ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
139564
+ var normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
139565
139565
  var init_connections = __esm({
139566
139566
  "src/cli/connections.ts"() {
139567
139567
  "use strict";
139568
- import_net = __toESM(require("net"));
139569
139568
  init_src();
139570
139569
  init_wrapper();
139571
139570
  init_utils();
@@ -139573,7 +139572,6 @@ var init_connections = __esm({
139573
139572
  init_when_json_met_bigint();
139574
139573
  init_utils3();
139575
139574
  init_outputs();
139576
- ms = (a6, b6) => Number(b6 - a6) / 1e6;
139577
139575
  normalisePGliteUrl = (it) => {
139578
139576
  if (it.startsWith("file:")) {
139579
139577
  return it.substring(5);
@@ -139728,13 +139726,13 @@ var init_connections = __esm({
139728
139726
  return pg.types.getTypeParser(typeId, format2);
139729
139727
  }
139730
139728
  };
139731
- const pool = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
139732
- const db = drizzle({ client: pool });
139729
+ const client = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
139730
+ const db = drizzle({ client });
139733
139731
  const migrateFn = async (config) => {
139734
139732
  return migrate(db, config);
139735
139733
  };
139736
139734
  const query = async (sql, params) => {
139737
- const result2 = await pool.query({
139735
+ const result2 = await client.query({
139738
139736
  text: sql,
139739
139737
  values: params ?? [],
139740
139738
  types: types3
@@ -139744,7 +139742,7 @@ var init_connections = __esm({
139744
139742
  return result2.rows;
139745
139743
  };
139746
139744
  const proxy = async (params) => {
139747
- const result2 = await pool.query({
139745
+ const result2 = await client.query({
139748
139746
  text: params.sql,
139749
139747
  values: params.params,
139750
139748
  ...params.mode === "array" && { rowMode: "array" },
@@ -139756,7 +139754,7 @@ var init_connections = __esm({
139756
139754
  };
139757
139755
  const transactionProxy = async (queries) => {
139758
139756
  const results = [];
139759
- const tx = await pool.connect();
139757
+ const tx = await client.connect();
139760
139758
  try {
139761
139759
  await tx.query("BEGIN");
139762
139760
  for (const query2 of queries) {
@@ -139775,77 +139773,7 @@ var init_connections = __esm({
139775
139773
  }
139776
139774
  return results;
139777
139775
  };
139778
- const benchmarkQuery = async (client, sql, params) => {
139779
- const explainResult = await pool.query({
139780
- text: `EXPLAIN ANALYZE ${sql}`,
139781
- values: params ?? [],
139782
- types: types3
139783
- });
139784
- const stringifiedResult = JSON.stringify(explainResult.rows);
139785
- const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
139786
- const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
139787
- const planningTime = Number(planningMatch[1]);
139788
- const executionTime = Number(executionMatch[1]);
139789
- let querySentAt = 0n;
139790
- let firstDataAt = 0n;
139791
- let lastDataAt = 0n;
139792
- let bytesReceived = 0;
139793
- client.connection.addListener("rowDescription", (data) => {
139794
- if (firstDataAt === 0n) {
139795
- firstDataAt = process.hrtime.bigint();
139796
- }
139797
- bytesReceived += data.length;
139798
- });
139799
- client.connection.addListener("dataRow", (data) => {
139800
- bytesReceived += data.length;
139801
- });
139802
- client.connection.addListener("commandComplete", () => {
139803
- lastDataAt = process.hrtime.bigint();
139804
- });
139805
- querySentAt = process.hrtime.bigint();
139806
- await client.query(sql, params);
139807
- client.connection.removeAllListeners("rowDescription");
139808
- client.connection.removeAllListeners("dataRow");
139809
- client.connection.removeAllListeners("commandComplete");
139810
- return {
139811
- planning: planningTime,
139812
- execution: executionTime,
139813
- dataDownload: ms(firstDataAt, lastDataAt) + ms(querySentAt, firstDataAt) - executionTime - planningTime,
139814
- total: ms(querySentAt, lastDataAt),
139815
- dataSize: bytesReceived
139816
- };
139817
- };
139818
- const benchmarkProxy = async ({ sql, params }, repeats) => {
139819
- let startAt = 0n;
139820
- let tcpConnectedAt = 0n;
139821
- let tlsConnectedAt = null;
139822
- let dbReadyAt = 0n;
139823
- const client = "url" in credentials ? new pg.Client({ connectionString: credentials.url }) : new pg.Client({ ...credentials, ssl });
139824
- client.connection.once("connect", () => {
139825
- tcpConnectedAt = process.hrtime.bigint();
139826
- });
139827
- client.connection.prependOnceListener("sslconnect", () => {
139828
- tlsConnectedAt = process.hrtime.bigint();
139829
- });
139830
- client.connection.prependOnceListener("readyForQuery", () => {
139831
- dbReadyAt = process.hrtime.bigint();
139832
- });
139833
- startAt = process.hrtime.bigint();
139834
- await client.connect();
139835
- const results = [];
139836
- for (let i7 = 0; i7 < repeats; i7++) {
139837
- const r7 = await benchmarkQuery(client, sql, params);
139838
- results.push(r7);
139839
- }
139840
- await client.end();
139841
- return {
139842
- tcpHandshake: ms(startAt, tcpConnectedAt),
139843
- tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
139844
- dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
139845
- queries: results
139846
- };
139847
- };
139848
- return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
139776
+ return { packageName: "pg", query, proxy, transactionProxy, migrate: migrateFn };
139849
139777
  }
139850
139778
  if (await checkPackage("postgres")) {
139851
139779
  console.log(
@@ -140340,6 +140268,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140340
140268
  }
140341
140269
  return next();
140342
140270
  };
140271
+ await connection.connect();
140343
140272
  const query = async (sql, params) => {
140344
140273
  const res = await connection.execute({
140345
140274
  sql,
@@ -140379,112 +140308,11 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140379
140308
  }
140380
140309
  return results;
140381
140310
  };
140382
- const benchmarkQuery = async (newConnection, sql, params) => {
140383
- const explainResult = await connection.query({
140384
- sql: `EXPLAIN ANALYZE ${sql}`,
140385
- values: params ?? [],
140386
- typeCast
140387
- });
140388
- const stringifiedResult = JSON.stringify(explainResult[0]);
140389
- const timeMatch = stringifiedResult.match(
140390
- /actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
140391
- );
140392
- const lastRowTime = Number(timeMatch[2]);
140393
- const executionTime = lastRowTime;
140394
- let querySentAt = 0n;
140395
- let firstDataAt = 0n;
140396
- let lastDataAt = 0n;
140397
- let bytesReceived = 0;
140398
- querySentAt = process.hrtime.bigint();
140399
- await new Promise((resolve2, reject) => {
140400
- const query2 = newConnection.query({
140401
- sql,
140402
- values: params ?? [],
140403
- typeCast
140404
- // rowsAsArray: true,
140405
- });
140406
- query2.on("error", (err2) => {
140407
- reject(err2);
140408
- });
140409
- query2.on("fields", (fields) => {
140410
- if (firstDataAt === 0n) {
140411
- firstDataAt = process.hrtime.bigint();
140412
- }
140413
- bytesReceived += fields[0]._buf.length;
140414
- });
140415
- query2.on("end", () => {
140416
- lastDataAt = process.hrtime.bigint();
140417
- resolve2();
140418
- });
140419
- });
140420
- return {
140421
- planning: null,
140422
- execution: executionTime,
140423
- dataDownload: ms(firstDataAt, lastDataAt) + ms(querySentAt, firstDataAt) - executionTime,
140424
- total: ms(querySentAt, lastDataAt),
140425
- dataSize: bytesReceived
140426
- };
140427
- };
140428
- const benchmarkProxy = async ({ sql, params }, repeats) => {
140429
- const { createConnection: createConnection2 } = require("mysql2");
140430
- let startAt = 0n;
140431
- let tcpConnectedAt = 0n;
140432
- let tlsConnectedAt = null;
140433
- const createStream = ({ config }) => {
140434
- let stream;
140435
- if (config.socketPath) {
140436
- stream = import_net.default.connect(config.socketPath);
140437
- } else {
140438
- stream = import_net.default.connect(config.port, config.host);
140439
- }
140440
- if (config.enableKeepAlive) {
140441
- stream.on("connect", () => {
140442
- stream.setKeepAlive(true, config.keepAliveInitialDelay);
140443
- });
140444
- }
140445
- stream.setNoDelay(true);
140446
- stream.once("connect", () => {
140447
- tcpConnectedAt = process.hrtime.bigint();
140448
- });
140449
- return stream;
140450
- };
140451
- startAt = process.hrtime.bigint();
140452
- const connection2 = result2.url ? createConnection2({
140453
- uri: result2.url,
140454
- stream: createStream
140455
- }) : createConnection2({
140456
- ...result2.credentials,
140457
- stream: createStream
140458
- });
140459
- await new Promise((resolve2, reject) => {
140460
- connection2.connect((err2) => {
140461
- tlsConnectedAt = process.hrtime.bigint();
140462
- if (err2) {
140463
- reject(err2);
140464
- } else {
140465
- resolve2();
140466
- }
140467
- });
140468
- });
140469
- const results = [];
140470
- for (let i7 = 0; i7 < repeats; i7++) {
140471
- const r7 = await benchmarkQuery(connection2, sql, params);
140472
- results.push(r7);
140473
- }
140474
- connection2.end();
140475
- return {
140476
- tcpHandshake: ms(startAt, tcpConnectedAt),
140477
- tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
140478
- dbHandshake: null,
140479
- queries: results
140480
- };
140481
- };
140482
140311
  return {
140483
140312
  db: { query },
140484
140313
  packageName: "mysql2",
140485
140314
  proxy,
140486
140315
  transactionProxy,
140487
- benchmarkProxy,
140488
140316
  database: result2.database,
140489
140317
  migrate: migrateFn
140490
140318
  };
@@ -141127,7 +140955,7 @@ __export(studio_exports, {
141127
140955
  prepareServer: () => prepareServer,
141128
140956
  prepareSingleStoreSchema: () => prepareSingleStoreSchema
141129
140957
  });
141130
- var import_crypto9, import_drizzle_orm, import_relations, import_mssql_core2, import_mysql_core2, import_pg_core2, import_singlestore_core, import_sqlite_core2, import_fs4, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
140958
+ var import_crypto9, import_drizzle_orm, import_relations, import_mssql_core2, import_mysql_core2, import_pg_core2, import_singlestore_core, import_sqlite_core2, import_fs4, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
141131
140959
  var init_studio = __esm({
141132
140960
  "src/cli/commands/studio.ts"() {
141133
140961
  "use strict";
@@ -141351,7 +141179,6 @@ var init_studio = __esm({
141351
141179
  packageName: db.packageName,
141352
141180
  proxy: db.proxy,
141353
141181
  transactionProxy: db.transactionProxy,
141354
- benchmarkProxy: db.benchmarkProxy,
141355
141182
  customDefaults,
141356
141183
  schema: pgSchema2,
141357
141184
  relations,
@@ -141361,7 +141188,7 @@ var init_studio = __esm({
141361
141188
  };
141362
141189
  drizzleForMySQL = async (credentials, mysqlSchema, relations, schemaFiles, casing2) => {
141363
141190
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
141364
- const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);
141191
+ const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
141365
141192
  const customDefaults = getCustomDefaults(mysqlSchema, casing2);
141366
141193
  let dbUrl;
141367
141194
  if ("url" in credentials) {
@@ -141377,7 +141204,6 @@ var init_studio = __esm({
141377
141204
  databaseName: database,
141378
141205
  proxy,
141379
141206
  transactionProxy,
141380
- benchmarkProxy,
141381
141207
  customDefaults,
141382
141208
  schema: mysqlSchema,
141383
141209
  relations,
@@ -141547,23 +141373,6 @@ var init_studio = __esm({
141547
141373
  ]).optional()
141548
141374
  }).array()
141549
141375
  });
141550
- benchmarkProxySchema = external_exports.object({
141551
- type: external_exports.literal("bproxy"),
141552
- data: external_exports.object({
141553
- query: external_exports.object({
141554
- sql: external_exports.string(),
141555
- params: external_exports.array(external_exports.any()).optional(),
141556
- method: external_exports.union([
141557
- external_exports.literal("values"),
141558
- external_exports.literal("get"),
141559
- external_exports.literal("all"),
141560
- external_exports.literal("run"),
141561
- external_exports.literal("execute")
141562
- ]).optional()
141563
- }),
141564
- repeats: external_exports.number().min(1).optional()
141565
- })
141566
- });
141567
141376
  defaultsSchema = external_exports.object({
141568
141377
  type: external_exports.literal("defaults"),
141569
141378
  data: external_exports.array(
@@ -141578,7 +141387,6 @@ var init_studio = __esm({
141578
141387
  init2,
141579
141388
  proxySchema,
141580
141389
  transactionProxySchema,
141581
- benchmarkProxySchema,
141582
141390
  defaultsSchema
141583
141391
  ]);
141584
141392
  jsonStringify = (data) => {
@@ -141601,7 +141409,6 @@ var init_studio = __esm({
141601
141409
  databaseName,
141602
141410
  proxy,
141603
141411
  transactionProxy,
141604
- benchmarkProxy,
141605
141412
  customDefaults,
141606
141413
  schema: drizzleSchema,
141607
141414
  relations,
@@ -141665,7 +141472,7 @@ var init_studio = __esm({
141665
141472
  console.warn("Error message:", error3.message);
141666
141473
  }
141667
141474
  return c6.json({
141668
- version: "6.3",
141475
+ version: "6.2",
141669
141476
  dialect: dialect6,
141670
141477
  driver: driver2,
141671
141478
  packageName,
@@ -141703,21 +141510,6 @@ var init_studio = __esm({
141703
141510
  }
141704
141511
  );
141705
141512
  }
141706
- if (type === "bproxy") {
141707
- if (!benchmarkProxy) {
141708
- throw new Error("Benchmark proxy is not configured for this database.");
141709
- }
141710
- const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
141711
- const res = jsonStringify(result2);
141712
- return c6.body(
141713
- res,
141714
- {
141715
- headers: {
141716
- "Content-Type": "application/json"
141717
- }
141718
- }
141719
- );
141720
- }
141721
141513
  if (type === "defaults") {
141722
141514
  const columns = body.data;
141723
141515
  const result2 = columns.map((column7) => {