drizzle-kit 1.0.0-beta.2-31baa2b → 1.0.0-beta.2-f9236e3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api-sqlite.js CHANGED
@@ -17324,8 +17324,7 @@ var init_schemaValidator = __esm({
17324
17324
  "singlestore",
17325
17325
  "gel",
17326
17326
  "mssql",
17327
- "cockroach",
17328
- "duckdb"
17327
+ "cockroach"
17329
17328
  ];
17330
17329
  dialect3 = enumType(dialects);
17331
17330
  }
@@ -28718,7 +28717,7 @@ var require_websocket = __commonJS({
28718
28717
  var EventEmitter = require("events");
28719
28718
  var https2 = require("https");
28720
28719
  var http3 = require("http");
28721
- var net = require("net");
28720
+ var net2 = require("net");
28722
28721
  var tls = require("tls");
28723
28722
  var { randomBytes, createHash: createHash5 } = require("crypto");
28724
28723
  var { Duplex, Readable: Readable6 } = require("stream");
@@ -29449,12 +29448,12 @@ var require_websocket = __commonJS({
29449
29448
  }
29450
29449
  function netConnect(options) {
29451
29450
  options.path = options.socketPath;
29452
- return net.connect(options);
29451
+ return net2.connect(options);
29453
29452
  }
29454
29453
  function tlsConnect(options) {
29455
29454
  options.path = void 0;
29456
29455
  if (!options.servername && options.servername !== "") {
29457
- options.servername = net.isIP(options.host) ? "" : options.host;
29456
+ options.servername = net2.isIP(options.host) ? "" : options.host;
29458
29457
  }
29459
29458
  return tls.connect(options);
29460
29459
  }
@@ -33773,7 +33772,7 @@ var init_timing = __esm({
33773
33772
  "../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
33774
33773
  "use strict";
33775
33774
  timing = {
33776
- setTimeout: (cb, ms) => setTimeout(cb, ms),
33775
+ setTimeout: (cb, ms2) => setTimeout(cb, ms2),
33777
33776
  clearTimeout: (timeoutId) => clearTimeout(timeoutId)
33778
33777
  };
33779
33778
  }
@@ -35661,13 +35660,13 @@ var init_schema_date_utils = __esm({
35661
35660
  if (!matches) {
35662
35661
  throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
35663
35662
  }
35664
- const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
35663
+ const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
35665
35664
  range(monthStr, 1, 12);
35666
35665
  range(dayStr, 1, 31);
35667
35666
  range(hours, 0, 23);
35668
35667
  range(minutes, 0, 59);
35669
35668
  range(seconds, 0, 60);
35670
- 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));
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));
35671
35670
  date2.setUTCFullYear(Number(yearStr));
35672
35671
  if (offsetStr.toUpperCase() != "Z") {
35673
35672
  const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
@@ -55681,8 +55680,8 @@ var require_datetime2 = __commonJS({
55681
55680
  if (!(object instanceof Date)) {
55682
55681
  throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
55683
55682
  }
55684
- const ms = object.getTime() - TIMESHIFT;
55685
- const us = ms * 1e3;
55683
+ const ms2 = object.getTime() - TIMESHIFT;
55684
+ const us = ms2 * 1e3;
55686
55685
  buf.writeInt32(8);
55687
55686
  buf.writeInt64(us);
55688
55687
  }
@@ -55692,12 +55691,12 @@ var require_datetime2 = __commonJS({
55692
55691
  return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
55693
55692
  }
55694
55693
  const us = Number(buf.readBigInt64());
55695
- let ms = Math.round(us / 1e3);
55696
- if (Math.abs(us % 1e3) === 500 && Math.abs(ms) % 2 === 1) {
55697
- ms -= 1;
55694
+ let ms2 = Math.round(us / 1e3);
55695
+ if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
55696
+ ms2 -= 1;
55698
55697
  }
55699
- ms += TIMESHIFT;
55700
- return new Date(ms);
55698
+ ms2 += TIMESHIFT;
55699
+ return new Date(ms2);
55701
55700
  }
55702
55701
  };
55703
55702
  exports2.DateTimeCodec = DateTimeCodec;
@@ -55718,8 +55717,8 @@ var require_datetime2 = __commonJS({
55718
55717
  if (!(object instanceof datetime_1.LocalDateTime)) {
55719
55718
  throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
55720
55719
  }
55721
- const ms = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
55722
- let us = ms * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
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);
55723
55722
  if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
55724
55723
  us += 1n;
55725
55724
  }
@@ -55733,13 +55732,13 @@ var require_datetime2 = __commonJS({
55733
55732
  }
55734
55733
  const bi_ms = bi_us / 1000n;
55735
55734
  let us = Number(bi_us - bi_ms * 1000n);
55736
- let ms = Number(bi_ms);
55735
+ let ms2 = Number(bi_ms);
55737
55736
  if (us < 0) {
55738
55737
  us += 1e3;
55739
- ms -= 1;
55738
+ ms2 -= 1;
55740
55739
  }
55741
- ms += TIMESHIFT;
55742
- const date2 = new Date(ms);
55740
+ ms2 += TIMESHIFT;
55741
+ const date2 = new Date(ms2);
55743
55742
  return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
55744
55743
  }
55745
55744
  };
@@ -55801,13 +55800,13 @@ var require_datetime2 = __commonJS({
55801
55800
  }
55802
55801
  let us = Number(bius);
55803
55802
  let seconds = Math.floor(us / 1e6);
55804
- const ms = Math.floor(us % 1e6 / 1e3);
55805
- us = us % 1e6 - ms * 1e3;
55803
+ const ms2 = Math.floor(us % 1e6 / 1e3);
55804
+ us = us % 1e6 - ms2 * 1e3;
55806
55805
  let minutes = Math.floor(seconds / 60);
55807
55806
  seconds = Math.floor(seconds % 60);
55808
55807
  const hours = Math.floor(minutes / 60);
55809
55808
  minutes = Math.floor(minutes % 60);
55810
- return new datetime_1.LocalTime(hours, minutes, seconds, ms, us);
55809
+ return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
55811
55810
  }
55812
55811
  };
55813
55812
  exports2.LocalTimeCodec = LocalTimeCodec;
@@ -55884,14 +55883,14 @@ var require_datetime2 = __commonJS({
55884
55883
  const biMillion = 1000000n;
55885
55884
  const biSeconds = bius / biMillion;
55886
55885
  let us = Number(bius - biSeconds * biMillion);
55887
- const ms = Math.floor(us / 1e3);
55886
+ const ms2 = Math.floor(us / 1e3);
55888
55887
  us = us % 1e3;
55889
55888
  let seconds = Number(biSeconds);
55890
55889
  let minutes = Math.floor(seconds / 60);
55891
55890
  seconds = Math.floor(seconds % 60);
55892
55891
  const hours = Math.floor(minutes / 60);
55893
55892
  minutes = Math.floor(minutes % 60);
55894
- return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
55893
+ return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
55895
55894
  }
55896
55895
  };
55897
55896
  exports2.DurationCodec = DurationCodec;
@@ -55937,7 +55936,7 @@ var require_datetime2 = __commonJS({
55937
55936
  const million = BigInt(1e6);
55938
55937
  const biSeconds = bius / million;
55939
55938
  let us = Number(bius - biSeconds * million);
55940
- const ms = Math.trunc(us / 1e3);
55939
+ const ms2 = Math.trunc(us / 1e3);
55941
55940
  us = us % 1e3;
55942
55941
  let seconds = Number(biSeconds);
55943
55942
  let minutes = Math.trunc(seconds / 60);
@@ -55948,7 +55947,7 @@ var require_datetime2 = __commonJS({
55948
55947
  days = Math.trunc(days % 7);
55949
55948
  const years = Math.trunc(months2 / 12);
55950
55949
  months2 = Math.trunc(months2 % 12);
55951
- return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
55950
+ return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
55952
55951
  }
55953
55952
  };
55954
55953
  exports2.RelativeDurationCodec = RelativeDurationCodec;
@@ -66112,41 +66111,41 @@ var require_ms = __commonJS({
66112
66111
  return void 0;
66113
66112
  }
66114
66113
  }
66115
- function fmtShort(ms) {
66116
- var msAbs = Math.abs(ms);
66114
+ function fmtShort(ms2) {
66115
+ var msAbs = Math.abs(ms2);
66117
66116
  if (msAbs >= d6) {
66118
- return Math.round(ms / d6) + "d";
66117
+ return Math.round(ms2 / d6) + "d";
66119
66118
  }
66120
66119
  if (msAbs >= h7) {
66121
- return Math.round(ms / h7) + "h";
66120
+ return Math.round(ms2 / h7) + "h";
66122
66121
  }
66123
66122
  if (msAbs >= m7) {
66124
- return Math.round(ms / m7) + "m";
66123
+ return Math.round(ms2 / m7) + "m";
66125
66124
  }
66126
66125
  if (msAbs >= s7) {
66127
- return Math.round(ms / s7) + "s";
66126
+ return Math.round(ms2 / s7) + "s";
66128
66127
  }
66129
- return ms + "ms";
66128
+ return ms2 + "ms";
66130
66129
  }
66131
- function fmtLong(ms) {
66132
- var msAbs = Math.abs(ms);
66130
+ function fmtLong(ms2) {
66131
+ var msAbs = Math.abs(ms2);
66133
66132
  if (msAbs >= d6) {
66134
- return plural(ms, msAbs, d6, "day");
66133
+ return plural(ms2, msAbs, d6, "day");
66135
66134
  }
66136
66135
  if (msAbs >= h7) {
66137
- return plural(ms, msAbs, h7, "hour");
66136
+ return plural(ms2, msAbs, h7, "hour");
66138
66137
  }
66139
66138
  if (msAbs >= m7) {
66140
- return plural(ms, msAbs, m7, "minute");
66139
+ return plural(ms2, msAbs, m7, "minute");
66141
66140
  }
66142
66141
  if (msAbs >= s7) {
66143
- return plural(ms, msAbs, s7, "second");
66142
+ return plural(ms2, msAbs, s7, "second");
66144
66143
  }
66145
- return ms + " ms";
66144
+ return ms2 + " ms";
66146
66145
  }
66147
- function plural(ms, msAbs, n6, name) {
66146
+ function plural(ms2, msAbs, n6, name) {
66148
66147
  var isPlural = msAbs >= n6 * 1.5;
66149
- return Math.round(ms / n6) + " " + name + (isPlural ? "s" : "");
66148
+ return Math.round(ms2 / n6) + " " + name + (isPlural ? "s" : "");
66150
66149
  }
66151
66150
  }
66152
66151
  });
@@ -66190,8 +66189,8 @@ var require_common2 = __commonJS({
66190
66189
  }
66191
66190
  const self2 = debug;
66192
66191
  const curr = Number(/* @__PURE__ */ new Date());
66193
- const ms = curr - (prevTime || curr);
66194
- self2.diff = ms;
66192
+ const ms2 = curr - (prevTime || curr);
66193
+ self2.diff = ms2;
66195
66194
  self2.prev = prevTime;
66196
66195
  self2.curr = curr;
66197
66196
  prevTime = curr;
@@ -81694,11 +81693,11 @@ var require_TokenExpiredError = __commonJS({
81694
81693
  var require_timespan = __commonJS({
81695
81694
  "../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module2) {
81696
81695
  "use strict";
81697
- var ms = require_ms();
81696
+ var ms2 = require_ms();
81698
81697
  module2.exports = function(time2, iat) {
81699
81698
  var timestamp = iat || Math.floor(Date.now() / 1e3);
81700
81699
  if (typeof time2 === "string") {
81701
- var milliseconds = ms(time2);
81700
+ var milliseconds = ms2(time2);
81702
81701
  if (typeof milliseconds === "undefined") {
81703
81702
  return;
81704
81703
  }
@@ -96236,7 +96235,7 @@ var require_dist = __commonJS({
96236
96235
  };
96237
96236
  Object.defineProperty(exports2, "__esModule", { value: true });
96238
96237
  exports2.Agent = void 0;
96239
- var net = __importStar2(require("net"));
96238
+ var net2 = __importStar2(require("net"));
96240
96239
  var http3 = __importStar2(require("http"));
96241
96240
  var https_1 = require("https");
96242
96241
  __exportStar2(require_helpers2(), exports2);
@@ -96276,7 +96275,7 @@ var require_dist = __commonJS({
96276
96275
  if (!this.sockets[name]) {
96277
96276
  this.sockets[name] = [];
96278
96277
  }
96279
- const fakeSocket = new net.Socket({ writable: false });
96278
+ const fakeSocket = new net2.Socket({ writable: false });
96280
96279
  this.sockets[name].push(fakeSocket);
96281
96280
  this.totalSocketCount++;
96282
96281
  return fakeSocket;
@@ -96488,7 +96487,7 @@ var require_dist2 = __commonJS({
96488
96487
  };
96489
96488
  Object.defineProperty(exports2, "__esModule", { value: true });
96490
96489
  exports2.HttpsProxyAgent = void 0;
96491
- var net = __importStar2(require("net"));
96490
+ var net2 = __importStar2(require("net"));
96492
96491
  var tls = __importStar2(require("tls"));
96493
96492
  var assert_1 = __importDefault2(require("assert"));
96494
96493
  var debug_1 = __importDefault2(require_src2());
@@ -96497,7 +96496,7 @@ var require_dist2 = __commonJS({
96497
96496
  var parse_proxy_response_1 = require_parse_proxy_response();
96498
96497
  var debug = (0, debug_1.default)("https-proxy-agent");
96499
96498
  var setServernameFromNonIpHost = (options) => {
96500
- if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
96499
+ if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
96501
96500
  return {
96502
96501
  ...options,
96503
96502
  servername: options.host
@@ -96537,10 +96536,10 @@ var require_dist2 = __commonJS({
96537
96536
  socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
96538
96537
  } else {
96539
96538
  debug("Creating `net.Socket`: %o", this.connectOpts);
96540
- socket = net.connect(this.connectOpts);
96539
+ socket = net2.connect(this.connectOpts);
96541
96540
  }
96542
96541
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
96543
- const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
96542
+ const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
96544
96543
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
96545
96544
  `;
96546
96545
  if (proxy.username || proxy.password) {
@@ -96573,7 +96572,7 @@ var require_dist2 = __commonJS({
96573
96572
  return socket;
96574
96573
  }
96575
96574
  socket.destroy();
96576
- const fakeSocket = new net.Socket({ writable: false });
96575
+ const fakeSocket = new net2.Socket({ writable: false });
96577
96576
  fakeSocket.readable = true;
96578
96577
  req.once("socket", (s7) => {
96579
96578
  debug("Replaying proxy buffer for failed request");
@@ -96638,7 +96637,7 @@ var require_dist3 = __commonJS({
96638
96637
  };
96639
96638
  Object.defineProperty(exports2, "__esModule", { value: true });
96640
96639
  exports2.HttpProxyAgent = void 0;
96641
- var net = __importStar2(require("net"));
96640
+ var net2 = __importStar2(require("net"));
96642
96641
  var tls = __importStar2(require("tls"));
96643
96642
  var debug_1 = __importDefault2(require_src2());
96644
96643
  var events_1 = require("events");
@@ -96711,7 +96710,7 @@ var require_dist3 = __commonJS({
96711
96710
  socket = tls.connect(this.connectOpts);
96712
96711
  } else {
96713
96712
  debug("Creating `net.Socket`: %o", this.connectOpts);
96714
- socket = net.connect(this.connectOpts);
96713
+ socket = net2.connect(this.connectOpts);
96715
96714
  }
96716
96715
  await (0, events_1.once)(socket, "connect");
96717
96716
  return socket;
@@ -135591,7 +135590,7 @@ var require_connection = __commonJS({
135591
135590
  var _crypto = _interopRequireDefault(require("crypto"));
135592
135591
  var _os = _interopRequireDefault(require("os"));
135593
135592
  var tls = _interopRequireWildcard(require("tls"));
135594
- var net = _interopRequireWildcard(require("net"));
135593
+ var net2 = _interopRequireWildcard(require("net"));
135595
135594
  var _dns = _interopRequireDefault(require("dns"));
135596
135595
  var _constants = _interopRequireDefault(require("constants"));
135597
135596
  var _stream = require("stream");
@@ -136640,7 +136639,7 @@ var require_connection = __commonJS({
136640
136639
  async wrapWithTls(socket, signal) {
136641
136640
  signal.throwIfAborted();
136642
136641
  const secureContext = tls.createSecureContext(this.secureContextOptions);
136643
- const serverName = !net.isIP(this.config.server) ? this.config.server : "";
136642
+ const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
136644
136643
  const encryptOptions = {
136645
136644
  host: this.config.server,
136646
136645
  socket,
@@ -139546,7 +139545,6 @@ __export(connections_exports, {
139546
139545
  connectToSQLite: () => connectToSQLite,
139547
139546
  connectToSingleStore: () => connectToSingleStore,
139548
139547
  prepareCockroach: () => prepareCockroach,
139549
- prepareDuckDb: () => prepareDuckDb,
139550
139548
  prepareGelDB: () => prepareGelDB,
139551
139549
  preparePostgresDB: () => preparePostgresDB
139552
139550
  });
@@ -139563,10 +139561,11 @@ function parseMssqlUrl(url) {
139563
139561
  }
139564
139562
  };
139565
139563
  }
139566
- var normalisePGliteUrl, preparePostgresDB, prepareDuckDb, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
139564
+ var import_net, ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
139567
139565
  var init_connections = __esm({
139568
139566
  "src/cli/connections.ts"() {
139569
139567
  "use strict";
139568
+ import_net = __toESM(require("net"));
139570
139569
  init_src();
139571
139570
  init_wrapper();
139572
139571
  init_utils();
@@ -139574,6 +139573,7 @@ var init_connections = __esm({
139574
139573
  init_when_json_met_bigint();
139575
139574
  init_utils3();
139576
139575
  init_outputs();
139576
+ ms = (a6, b6) => Number(b6 - a6) / 1e6;
139577
139577
  normalisePGliteUrl = (it) => {
139578
139578
  if (it.startsWith("file:")) {
139579
139579
  return it.substring(5);
@@ -139697,13 +139697,7 @@ var init_connections = __esm({
139697
139697
  }
139698
139698
  return results;
139699
139699
  };
139700
- return {
139701
- packageName: "pglite",
139702
- query,
139703
- proxy,
139704
- transactionProxy,
139705
- migrate: migrateFn
139706
- };
139700
+ return { packageName: "pglite", query, proxy, transactionProxy, migrate: migrateFn };
139707
139701
  }
139708
139702
  assertUnreachable(driver2);
139709
139703
  }
@@ -139734,13 +139728,13 @@ var init_connections = __esm({
139734
139728
  return pg.types.getTypeParser(typeId, format2);
139735
139729
  }
139736
139730
  };
139737
- const client = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
139738
- const db = drizzle({ client });
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 });
139739
139733
  const migrateFn = async (config) => {
139740
139734
  return migrate(db, config);
139741
139735
  };
139742
139736
  const query = async (sql, params) => {
139743
- const result2 = await client.query({
139737
+ const result2 = await pool.query({
139744
139738
  text: sql,
139745
139739
  values: params ?? [],
139746
139740
  types: types3
@@ -139750,7 +139744,7 @@ var init_connections = __esm({
139750
139744
  return result2.rows;
139751
139745
  };
139752
139746
  const proxy = async (params) => {
139753
- const result2 = await client.query({
139747
+ const result2 = await pool.query({
139754
139748
  text: params.sql,
139755
139749
  values: params.params,
139756
139750
  ...params.mode === "array" && { rowMode: "array" },
@@ -139762,7 +139756,7 @@ var init_connections = __esm({
139762
139756
  };
139763
139757
  const transactionProxy = async (queries) => {
139764
139758
  const results = [];
139765
- const tx = await client.connect();
139759
+ const tx = await pool.connect();
139766
139760
  try {
139767
139761
  await tx.query("BEGIN");
139768
139762
  for (const query2 of queries) {
@@ -139781,13 +139775,119 @@ var init_connections = __esm({
139781
139775
  }
139782
139776
  return results;
139783
139777
  };
139784
- return {
139785
- packageName: "pg",
139786
- query,
139787
- proxy,
139788
- transactionProxy,
139789
- migrate: migrateFn
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
+ let planningTime = Number(planningMatch[1]);
139788
+ let executionTime = Number(executionMatch[1]);
139789
+ let querySentAt = 0n;
139790
+ let firstDataAt = 0n;
139791
+ let lastDataAt = 0n;
139792
+ let lastRowParsedAt = 0n;
139793
+ let queryCompletedAt = 0n;
139794
+ let bytesReceived = 0;
139795
+ let rowCount = 0;
139796
+ let parseTime = 0;
139797
+ let lastParseTime = 0;
139798
+ const rowDescriptionListener = (data) => {
139799
+ if (firstDataAt === 0n) {
139800
+ firstDataAt = process.hrtime.bigint();
139801
+ }
139802
+ bytesReceived += data.length;
139803
+ };
139804
+ const originalRowListener = client.connection.listeners("dataRow")[0];
139805
+ const wrappedRowListener = (data) => {
139806
+ rowCount += 1;
139807
+ const start = process.hrtime.bigint();
139808
+ lastDataAt = start;
139809
+ originalRowListener.apply(client.connection, [data]);
139810
+ const end2 = process.hrtime.bigint();
139811
+ lastRowParsedAt = end2;
139812
+ lastParseTime = ms(start, end2);
139813
+ parseTime += lastParseTime;
139814
+ bytesReceived += data.length;
139815
+ };
139816
+ client.connection.removeAllListeners("dataRow");
139817
+ client.connection.addListener("dataRow", wrappedRowListener);
139818
+ client.connection.prependListener("rowDescription", rowDescriptionListener);
139819
+ querySentAt = process.hrtime.bigint();
139820
+ await client.query({
139821
+ text: sql,
139822
+ values: params,
139823
+ types: types3
139824
+ });
139825
+ queryCompletedAt = process.hrtime.bigint();
139826
+ client.connection.removeListener("rowDescription", rowDescriptionListener);
139827
+ client.connection.removeAllListeners("dataRow");
139828
+ client.connection.addListener("dataRow", originalRowListener);
139829
+ let querySentTime = ms(querySentAt, firstDataAt) - executionTime - planningTime;
139830
+ if (querySentTime < 0) {
139831
+ const percent = 0.1;
139832
+ const overflow = -querySentTime;
139833
+ const keepForSent = overflow * percent;
139834
+ const adjustedOverflow = overflow * (1 + percent);
139835
+ const total2 = planningTime + executionTime;
139836
+ const ratioPlanning = planningTime / total2;
139837
+ const ratioExecution = executionTime / total2;
139838
+ planningTime -= adjustedOverflow * ratioPlanning;
139839
+ executionTime -= adjustedOverflow * ratioExecution;
139840
+ querySentTime = keepForSent;
139841
+ }
139842
+ const networkLatencyBefore = querySentTime / 2;
139843
+ const networkLatencyAfter = querySentTime / 2;
139844
+ const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
139845
+ const total = ms(querySentAt, queryCompletedAt);
139846
+ const calculatedTotal = networkLatencyBefore + planningTime + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
139847
+ const errorMargin = Math.abs(total - calculatedTotal);
139848
+ return {
139849
+ networkLatencyBefore,
139850
+ planning: planningTime,
139851
+ execution: executionTime,
139852
+ networkLatencyAfter,
139853
+ dataDownload: downloadTime,
139854
+ dataParse: parseTime,
139855
+ total,
139856
+ errorMargin,
139857
+ dataSize: bytesReceived
139858
+ };
139859
+ };
139860
+ const benchmarkProxy = async ({ sql, params }, repeats) => {
139861
+ let startAt = 0n;
139862
+ let tcpConnectedAt = 0n;
139863
+ let tlsConnectedAt = null;
139864
+ let dbReadyAt = 0n;
139865
+ const client = "url" in credentials ? new pg.Client({ connectionString: credentials.url }) : new pg.Client({ ...credentials, ssl });
139866
+ client.connection.once("connect", () => {
139867
+ tcpConnectedAt = process.hrtime.bigint();
139868
+ });
139869
+ client.connection.prependOnceListener("sslconnect", () => {
139870
+ tlsConnectedAt = process.hrtime.bigint();
139871
+ });
139872
+ client.connection.prependOnceListener("readyForQuery", () => {
139873
+ dbReadyAt = process.hrtime.bigint();
139874
+ });
139875
+ startAt = process.hrtime.bigint();
139876
+ await client.connect();
139877
+ const results = [];
139878
+ for (let i7 = 0; i7 < repeats; i7++) {
139879
+ const r7 = await benchmarkQuery(client, sql, params);
139880
+ results.push(r7);
139881
+ }
139882
+ await client.end();
139883
+ return {
139884
+ tcpHandshake: ms(startAt, tcpConnectedAt),
139885
+ tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
139886
+ dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
139887
+ queries: results
139888
+ };
139790
139889
  };
139890
+ return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
139791
139891
  }
139792
139892
  if (await checkPackage("postgres")) {
139793
139893
  console.log(
@@ -139838,13 +139938,7 @@ var init_connections = __esm({
139838
139938
  }
139839
139939
  return results;
139840
139940
  };
139841
- return {
139842
- packageName: "postgres",
139843
- query,
139844
- proxy,
139845
- transactionProxy,
139846
- migrate: migrateFn
139847
- };
139941
+ return { packageName: "postgres", query, proxy, transactionProxy, migrate: migrateFn };
139848
139942
  }
139849
139943
  if (await checkPackage("@vercel/postgres")) {
139850
139944
  console.log(
@@ -139925,13 +140019,7 @@ var init_connections = __esm({
139925
140019
  }
139926
140020
  return results;
139927
140021
  };
139928
- return {
139929
- packageName: "@vercel/postgres",
139930
- query,
139931
- proxy,
139932
- transactionProxy,
139933
- migrate: migrateFn
139934
- };
140022
+ return { packageName: "@vercel/postgres", query, proxy, transactionProxy, migrate: migrateFn };
139935
140023
  }
139936
140024
  if (await checkPackage("@neondatabase/serverless")) {
139937
140025
  console.log(
@@ -139944,11 +140032,7 @@ var init_connections = __esm({
139944
140032
  "'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
139945
140033
  )
139946
140034
  );
139947
- const {
139948
- Pool,
139949
- neonConfig,
139950
- types: pgTypes
139951
- } = require("@neondatabase/serverless");
140035
+ const { Pool, neonConfig, types: pgTypes } = require("@neondatabase/serverless");
139952
140036
  const { drizzle } = require("drizzle-orm/neon-serverless");
139953
140037
  const { migrate } = require("drizzle-orm/neon-serverless/migrator");
139954
140038
  const ssl = "ssl" in credentials ? credentials.ssl === "prefer" || credentials.ssl === "require" || credentials.ssl === "allow" ? { rejectUnauthorized: false } : credentials.ssl === "verify-full" ? {} : credentials.ssl : {};
@@ -140018,13 +140102,7 @@ var init_connections = __esm({
140018
140102
  }
140019
140103
  return results;
140020
140104
  };
140021
- return {
140022
- packageName: "@neondatabase/serverless",
140023
- query,
140024
- proxy,
140025
- transactionProxy,
140026
- migrate: migrateFn
140027
- };
140105
+ return { packageName: "@neondatabase/serverless", query, proxy, transactionProxy, migrate: migrateFn };
140028
140106
  }
140029
140107
  if (await checkPackage("bun")) {
140030
140108
  console.log(withStyle.info(`Using 'bun' driver for database querying`));
@@ -140075,54 +140153,6 @@ var init_connections = __esm({
140075
140153
  console.warn("For the 'bun' driver, run your script using: bun --bun");
140076
140154
  process.exit(1);
140077
140155
  };
140078
- prepareDuckDb = async (credentials) => {
140079
- if (await checkPackage("@duckdb/node-api")) {
140080
- console.log(
140081
- withStyle.info(`Using '@duckdb/node-api' driver for database querying`)
140082
- );
140083
- const { DuckDBInstance } = require("@duckdb/node-api");
140084
- const instance = await DuckDBInstance.create(credentials.url);
140085
- const client = await instance.connect();
140086
- const query = async (sql, params = []) => {
140087
- const result2 = await client.run(sql, params);
140088
- const rows = await result2.getRowObjectsJson();
140089
- return rows;
140090
- };
140091
- const proxy = async (params) => {
140092
- const result2 = await client.run(params.sql, params.params);
140093
- return params.mode === "array" ? await result2.getRowsJson() : await result2.getRowObjectsJson();
140094
- };
140095
- const transactionProxy = async (queries) => {
140096
- const results = [];
140097
- try {
140098
- await client.run("BEGIN");
140099
- for (const query2 of queries) {
140100
- const result2 = await client.run(query2.sql);
140101
- results.push(await result2.getRowObjectsJson());
140102
- }
140103
- await client.run("COMMIT");
140104
- } catch (error3) {
140105
- await client.run("ROLLBACK");
140106
- results.push(error3);
140107
- }
140108
- return results;
140109
- };
140110
- return {
140111
- packageName: "@duckdb/node-api",
140112
- query,
140113
- proxy,
140114
- transactionProxy,
140115
- migrate: () => {
140116
- throw new Error("DuckDB does not support migrations");
140117
- }
140118
- };
140119
- }
140120
- console.error(
140121
- // "To connect to DuckDb database - please install either of 'duckdb', '@duckdb/node-api' drivers",
140122
- "To connect to DuckDb database - please install '@duckdb/node-api' driver"
140123
- );
140124
- process.exit(1);
140125
- };
140126
140156
  prepareCockroach = async (credentials) => {
140127
140157
  if (await checkPackage("pg")) {
140128
140158
  const { default: pg } = require("pg");
@@ -140175,7 +140205,9 @@ var init_connections = __esm({
140175
140205
  };
140176
140206
  return { query, proxy, migrate: migrateFn };
140177
140207
  }
140178
- console.error("To connect to Cockroach - please install 'pg' package");
140208
+ console.error(
140209
+ "To connect to Cockroach - please install 'pg' package"
140210
+ );
140179
140211
  process.exit(1);
140180
140212
  };
140181
140213
  prepareGelDB = async (credentials) => {
@@ -140234,7 +140266,9 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140234
140266
  };
140235
140267
  return { packageName: "gel", query, proxy, transactionProxy };
140236
140268
  }
140237
- console.error("To connect to gel database - please install 'edgedb' driver");
140269
+ console.error(
140270
+ "To connect to gel database - please install 'edgedb' driver"
140271
+ );
140238
140272
  process.exit(1);
140239
140273
  };
140240
140274
  parseSingleStoreCredentials = (credentials) => {
@@ -140348,7 +140382,6 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140348
140382
  }
140349
140383
  return next();
140350
140384
  };
140351
- await connection.connect();
140352
140385
  const query = async (sql, params) => {
140353
140386
  const res = await connection.execute({
140354
140387
  sql,
@@ -140388,11 +140421,156 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140388
140421
  }
140389
140422
  return results;
140390
140423
  };
140424
+ const benchmarkQuery = async (newConnection, sql, params) => {
140425
+ const explainResult = await connection.query({
140426
+ sql: `EXPLAIN ANALYZE ${sql}`,
140427
+ values: params ?? [],
140428
+ typeCast
140429
+ });
140430
+ const stringifiedResult = JSON.stringify(explainResult[0]);
140431
+ const timeMatch = stringifiedResult.match(
140432
+ /actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
140433
+ );
140434
+ const lastRowTime = Number(timeMatch[2]);
140435
+ let executionTime = lastRowTime;
140436
+ let querySentAt = 0n;
140437
+ let firstDataAt = 0n;
140438
+ let lastDataAt = 0n;
140439
+ let lastRowParsedAt = 0n;
140440
+ let queryCompletedAt = 0n;
140441
+ let bytesReceived = 0;
140442
+ let rowCount = 0;
140443
+ let parseTime = 0;
140444
+ let lastParseTime = 0;
140445
+ querySentAt = process.hrtime.bigint();
140446
+ await new Promise((resolve2, reject) => {
140447
+ const query2 = newConnection.query({
140448
+ sql,
140449
+ values: params ?? [],
140450
+ typeCast
140451
+ });
140452
+ const originalRowHandler = query2.row;
140453
+ let packets = 0;
140454
+ const wrappedRowListener = (packet, connection2) => {
140455
+ packets += 1;
140456
+ if (firstDataAt === 0n) {
140457
+ firstDataAt = process.hrtime.bigint();
140458
+ bytesReceived += packet.start;
140459
+ }
140460
+ const start = process.hrtime.bigint();
140461
+ lastDataAt = start;
140462
+ const res = originalRowHandler.apply(query2, [packet, connection2]);
140463
+ const end2 = process.hrtime.bigint();
140464
+ lastRowParsedAt = end2;
140465
+ lastParseTime = ms(start, end2);
140466
+ parseTime += lastParseTime;
140467
+ bytesReceived += packet.length();
140468
+ if (!res || packet.isEOF()) {
140469
+ return res;
140470
+ }
140471
+ return wrappedRowListener;
140472
+ };
140473
+ query2.row = wrappedRowListener;
140474
+ query2.on("result", () => {
140475
+ rowCount += 1;
140476
+ });
140477
+ query2.on("error", (err2) => {
140478
+ reject(err2);
140479
+ });
140480
+ query2.on("end", () => {
140481
+ resolve2();
140482
+ });
140483
+ });
140484
+ queryCompletedAt = process.hrtime.bigint();
140485
+ let querySentTime = ms(querySentAt, firstDataAt) - executionTime;
140486
+ if (querySentTime < 0) {
140487
+ const percent = 0.1;
140488
+ const overflow = -querySentTime;
140489
+ const keepForSent = overflow * percent;
140490
+ const adjustedOverflow = overflow * (1 + percent);
140491
+ const total2 = executionTime;
140492
+ const ratioExecution = executionTime / total2;
140493
+ executionTime -= adjustedOverflow * ratioExecution;
140494
+ querySentTime = keepForSent;
140495
+ }
140496
+ const networkLatencyBefore = querySentTime / 2;
140497
+ const networkLatencyAfter = querySentTime / 2;
140498
+ const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
140499
+ const total = ms(querySentAt, queryCompletedAt);
140500
+ const calculatedTotal = networkLatencyBefore + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
140501
+ const errorMargin = Math.abs(total - calculatedTotal);
140502
+ return {
140503
+ networkLatencyBefore,
140504
+ planning: null,
140505
+ execution: executionTime,
140506
+ networkLatencyAfter,
140507
+ dataDownload: downloadTime,
140508
+ dataParse: parseTime,
140509
+ total,
140510
+ errorMargin,
140511
+ dataSize: bytesReceived
140512
+ };
140513
+ };
140514
+ const benchmarkProxy = async ({ sql, params }, repeats) => {
140515
+ const { createConnection: createConnection2 } = require("mysql2");
140516
+ let startAt = 0n;
140517
+ let tcpConnectedAt = 0n;
140518
+ let tlsConnectedAt = null;
140519
+ const createStream = ({ config }) => {
140520
+ let stream;
140521
+ if (config.socketPath) {
140522
+ stream = import_net.default.connect(config.socketPath);
140523
+ } else {
140524
+ stream = import_net.default.connect(config.port, config.host);
140525
+ }
140526
+ if (config.enableKeepAlive) {
140527
+ stream.on("connect", () => {
140528
+ stream.setKeepAlive(true, config.keepAliveInitialDelay);
140529
+ });
140530
+ }
140531
+ stream.setNoDelay(true);
140532
+ stream.once("connect", () => {
140533
+ tcpConnectedAt = process.hrtime.bigint();
140534
+ });
140535
+ return stream;
140536
+ };
140537
+ startAt = process.hrtime.bigint();
140538
+ const connection2 = result2.url ? createConnection2({
140539
+ uri: result2.url,
140540
+ stream: createStream
140541
+ }) : createConnection2({
140542
+ ...result2.credentials,
140543
+ stream: createStream
140544
+ });
140545
+ await new Promise((resolve2, reject) => {
140546
+ connection2.connect((err2) => {
140547
+ tlsConnectedAt = process.hrtime.bigint();
140548
+ if (err2) {
140549
+ reject(err2);
140550
+ } else {
140551
+ resolve2();
140552
+ }
140553
+ });
140554
+ });
140555
+ const results = [];
140556
+ for (let i7 = 0; i7 < repeats; i7++) {
140557
+ const r7 = await benchmarkQuery(connection2, sql, params);
140558
+ results.push(r7);
140559
+ }
140560
+ connection2.end();
140561
+ return {
140562
+ tcpHandshake: ms(startAt, tcpConnectedAt),
140563
+ tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
140564
+ dbHandshake: null,
140565
+ queries: results
140566
+ };
140567
+ };
140391
140568
  return {
140392
140569
  db: { query },
140393
140570
  packageName: "mysql2",
140394
140571
  proxy,
140395
140572
  transactionProxy,
140573
+ benchmarkProxy,
140396
140574
  database: result2.database,
140397
140575
  migrate: migrateFn
140398
140576
  };
@@ -140542,7 +140720,9 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140542
140720
  migrate: migrateFn
140543
140721
  };
140544
140722
  }
140545
- console.error("To connect to MsSQL database - please install 'mssql' driver");
140723
+ console.error(
140724
+ "To connect to MsSQL database - please install 'mssql' driver"
140725
+ );
140546
140726
  process.exit(1);
140547
140727
  };
140548
140728
  prepareSqliteParams = (params, driver2) => {
@@ -140647,10 +140827,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140647
140827
  await remoteCallback(query2, [], "run");
140648
140828
  };
140649
140829
  const proxy = async (params) => {
140650
- const preparedParams = prepareSqliteParams(
140651
- params.params || [],
140652
- "d1-http"
140653
- );
140830
+ const preparedParams = prepareSqliteParams(params.params || [], "d1-http");
140654
140831
  const result2 = await remoteCallback(
140655
140832
  params.sql,
140656
140833
  preparedParams,
@@ -140875,19 +141052,17 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140875
141052
  };
140876
141053
  const transactionProxy = async (queries) => {
140877
141054
  const results = [];
140878
- const tx = sqlite.transaction(
140879
- (queries2) => {
140880
- for (const query of queries2) {
140881
- let result2 = [];
140882
- if (query.method === "values" || query.method === "get" || query.method === "all") {
140883
- result2 = sqlite.prepare(query.sql).all();
140884
- } else {
140885
- sqlite.prepare(query.sql).run();
140886
- }
140887
- results.push(result2);
141055
+ const tx = sqlite.transaction((queries2) => {
141056
+ for (const query of queries2) {
141057
+ let result2 = [];
141058
+ if (query.method === "values" || query.method === "get" || query.method === "all") {
141059
+ result2 = sqlite.prepare(query.sql).all();
141060
+ } else {
141061
+ sqlite.prepare(query.sql).run();
140888
141062
  }
141063
+ results.push(result2);
140889
141064
  }
140890
- );
141065
+ });
140891
141066
  try {
140892
141067
  tx(queries);
140893
141068
  } catch (error3) {
@@ -140895,13 +141070,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140895
141070
  }
140896
141071
  return results;
140897
141072
  };
140898
- return {
140899
- ...db,
140900
- packageName: "better-sqlite3",
140901
- proxy,
140902
- transactionProxy,
140903
- migrate: migrateFn
140904
- };
141073
+ return { ...db, packageName: "better-sqlite3", proxy, transactionProxy, migrate: migrateFn };
140905
141074
  }
140906
141075
  if (await checkPackage("bun")) {
140907
141076
  console.log(withStyle.info(`Using 'bun' driver for database querying`));
@@ -141031,7 +141200,6 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
141031
141200
  // src/cli/commands/studio.ts
141032
141201
  var studio_exports = {};
141033
141202
  __export(studio_exports, {
141034
- drizzleForDuckDb: () => drizzleForDuckDb,
141035
141203
  drizzleForLibSQL: () => drizzleForLibSQL,
141036
141204
  drizzleForMySQL: () => drizzleForMySQL,
141037
141205
  drizzleForPostgres: () => drizzleForPostgres,
@@ -141045,7 +141213,7 @@ __export(studio_exports, {
141045
141213
  prepareServer: () => prepareServer,
141046
141214
  prepareSingleStoreSchema: () => prepareSingleStoreSchema
141047
141215
  });
141048
- 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, drizzleForDuckDb, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
141216
+ 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;
141049
141217
  var init_studio = __esm({
141050
141218
  "src/cli/commands/studio.ts"() {
141051
141219
  "use strict";
@@ -141269,6 +141437,7 @@ var init_studio = __esm({
141269
141437
  packageName: db.packageName,
141270
141438
  proxy: db.proxy,
141271
141439
  transactionProxy: db.transactionProxy,
141440
+ benchmarkProxy: db.benchmarkProxy,
141272
141441
  customDefaults,
141273
141442
  schema: pgSchema2,
141274
141443
  relations,
@@ -141276,26 +141445,9 @@ var init_studio = __esm({
141276
141445
  casing: casing2
141277
141446
  };
141278
141447
  };
141279
- drizzleForDuckDb = async (credentials) => {
141280
- const { prepareDuckDb: prepareDuckDb2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
141281
- const db = await prepareDuckDb2(credentials);
141282
- const dbUrl = `duckdb://${credentials.url}`;
141283
- const dbHash = (0, import_crypto9.createHash)("sha256").update(dbUrl).digest("hex");
141284
- return {
141285
- dbHash,
141286
- dialect: "duckdb",
141287
- driver: void 0,
141288
- packageName: db.packageName,
141289
- proxy: db.proxy,
141290
- transactionProxy: db.transactionProxy,
141291
- customDefaults: [],
141292
- schema: {},
141293
- relations: {}
141294
- };
141295
- };
141296
141448
  drizzleForMySQL = async (credentials, mysqlSchema, relations, schemaFiles, casing2) => {
141297
141449
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
141298
- const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
141450
+ const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);
141299
141451
  const customDefaults = getCustomDefaults(mysqlSchema, casing2);
141300
141452
  let dbUrl;
141301
141453
  if ("url" in credentials) {
@@ -141311,6 +141463,7 @@ var init_studio = __esm({
141311
141463
  databaseName: database,
141312
141464
  proxy,
141313
141465
  transactionProxy,
141466
+ benchmarkProxy,
141314
141467
  customDefaults,
141315
141468
  schema: mysqlSchema,
141316
141469
  relations,
@@ -141480,6 +141633,23 @@ var init_studio = __esm({
141480
141633
  ]).optional()
141481
141634
  }).array()
141482
141635
  });
141636
+ benchmarkProxySchema = external_exports.object({
141637
+ type: external_exports.literal("bproxy"),
141638
+ data: external_exports.object({
141639
+ query: external_exports.object({
141640
+ sql: external_exports.string(),
141641
+ params: external_exports.array(external_exports.any()).optional(),
141642
+ method: external_exports.union([
141643
+ external_exports.literal("values"),
141644
+ external_exports.literal("get"),
141645
+ external_exports.literal("all"),
141646
+ external_exports.literal("run"),
141647
+ external_exports.literal("execute")
141648
+ ]).optional()
141649
+ }),
141650
+ repeats: external_exports.number().min(1).optional()
141651
+ })
141652
+ });
141483
141653
  defaultsSchema = external_exports.object({
141484
141654
  type: external_exports.literal("defaults"),
141485
141655
  data: external_exports.array(
@@ -141494,6 +141664,7 @@ var init_studio = __esm({
141494
141664
  init2,
141495
141665
  proxySchema,
141496
141666
  transactionProxySchema,
141667
+ benchmarkProxySchema,
141497
141668
  defaultsSchema
141498
141669
  ]);
141499
141670
  jsonStringify = (data) => {
@@ -141516,6 +141687,7 @@ var init_studio = __esm({
141516
141687
  databaseName,
141517
141688
  proxy,
141518
141689
  transactionProxy,
141690
+ benchmarkProxy,
141519
141691
  customDefaults,
141520
141692
  schema: drizzleSchema,
141521
141693
  relations,
@@ -141579,7 +141751,7 @@ var init_studio = __esm({
141579
141751
  console.warn("Error message:", error3.message);
141580
141752
  }
141581
141753
  return c6.json({
141582
- version: "6.2",
141754
+ version: "6.3",
141583
141755
  dialect: dialect6,
141584
141756
  driver: driver2,
141585
141757
  packageName,
@@ -141617,6 +141789,21 @@ var init_studio = __esm({
141617
141789
  }
141618
141790
  );
141619
141791
  }
141792
+ if (type === "bproxy") {
141793
+ if (!benchmarkProxy) {
141794
+ throw new Error("Benchmark proxy is not configured for this database.");
141795
+ }
141796
+ const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
141797
+ const res = jsonStringify(result2);
141798
+ return c6.body(
141799
+ res,
141800
+ {
141801
+ headers: {
141802
+ "Content-Type": "application/json"
141803
+ }
141804
+ }
141805
+ );
141806
+ }
141620
141807
  if (type === "defaults") {
141621
141808
  const columns = body.data;
141622
141809
  const result2 = columns.map((column7) => {