drizzle-kit 1.0.0-beta.2-01787d6 → 1.0.0-beta.2-7745ed5

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-postgres.js CHANGED
@@ -34395,7 +34395,7 @@ var require_websocket = __commonJS({
34395
34395
  var EventEmitter = require("events");
34396
34396
  var https2 = require("https");
34397
34397
  var http3 = require("http");
34398
- var net2 = require("net");
34398
+ var net = require("net");
34399
34399
  var tls = require("tls");
34400
34400
  var { randomBytes, createHash: createHash5 } = require("crypto");
34401
34401
  var { Duplex, Readable: Readable6 } = require("stream");
@@ -35126,12 +35126,12 @@ var require_websocket = __commonJS({
35126
35126
  }
35127
35127
  function netConnect(options) {
35128
35128
  options.path = options.socketPath;
35129
- return net2.connect(options);
35129
+ return net.connect(options);
35130
35130
  }
35131
35131
  function tlsConnect(options) {
35132
35132
  options.path = void 0;
35133
35133
  if (!options.servername && options.servername !== "") {
35134
- options.servername = net2.isIP(options.host) ? "" : options.host;
35134
+ options.servername = net.isIP(options.host) ? "" : options.host;
35135
35135
  }
35136
35136
  return tls.connect(options);
35137
35137
  }
@@ -39450,7 +39450,7 @@ var init_timing = __esm({
39450
39450
  "../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
39451
39451
  "use strict";
39452
39452
  timing = {
39453
- setTimeout: (cb, ms2) => setTimeout(cb, ms2),
39453
+ setTimeout: (cb, ms) => setTimeout(cb, ms),
39454
39454
  clearTimeout: (timeoutId) => clearTimeout(timeoutId)
39455
39455
  };
39456
39456
  }
@@ -41338,13 +41338,13 @@ var init_schema_date_utils = __esm({
41338
41338
  if (!matches) {
41339
41339
  throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
41340
41340
  }
41341
- const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
41341
+ const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
41342
41342
  range(monthStr, 1, 12);
41343
41343
  range(dayStr, 1, 31);
41344
41344
  range(hours, 0, 23);
41345
41345
  range(minutes, 0, 59);
41346
41346
  range(seconds, 0, 60);
41347
- 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));
41347
+ 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));
41348
41348
  date2.setUTCFullYear(Number(yearStr));
41349
41349
  if (offsetStr.toUpperCase() != "Z") {
41350
41350
  const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
@@ -61358,8 +61358,8 @@ var require_datetime2 = __commonJS({
61358
61358
  if (!(object instanceof Date)) {
61359
61359
  throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
61360
61360
  }
61361
- const ms2 = object.getTime() - TIMESHIFT;
61362
- const us = ms2 * 1e3;
61361
+ const ms = object.getTime() - TIMESHIFT;
61362
+ const us = ms * 1e3;
61363
61363
  buf.writeInt32(8);
61364
61364
  buf.writeInt64(us);
61365
61365
  }
@@ -61369,12 +61369,12 @@ var require_datetime2 = __commonJS({
61369
61369
  return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
61370
61370
  }
61371
61371
  const us = Number(buf.readBigInt64());
61372
- let ms2 = Math.round(us / 1e3);
61373
- if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
61374
- ms2 -= 1;
61372
+ let ms = Math.round(us / 1e3);
61373
+ if (Math.abs(us % 1e3) === 500 && Math.abs(ms) % 2 === 1) {
61374
+ ms -= 1;
61375
61375
  }
61376
- ms2 += TIMESHIFT;
61377
- return new Date(ms2);
61376
+ ms += TIMESHIFT;
61377
+ return new Date(ms);
61378
61378
  }
61379
61379
  };
61380
61380
  exports2.DateTimeCodec = DateTimeCodec;
@@ -61395,8 +61395,8 @@ var require_datetime2 = __commonJS({
61395
61395
  if (!(object instanceof datetime_1.LocalDateTime)) {
61396
61396
  throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
61397
61397
  }
61398
- const ms2 = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
61399
- let us = ms2 * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
61398
+ const ms = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
61399
+ let us = ms * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
61400
61400
  if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
61401
61401
  us += 1n;
61402
61402
  }
@@ -61410,13 +61410,13 @@ var require_datetime2 = __commonJS({
61410
61410
  }
61411
61411
  const bi_ms = bi_us / 1000n;
61412
61412
  let us = Number(bi_us - bi_ms * 1000n);
61413
- let ms2 = Number(bi_ms);
61413
+ let ms = Number(bi_ms);
61414
61414
  if (us < 0) {
61415
61415
  us += 1e3;
61416
- ms2 -= 1;
61416
+ ms -= 1;
61417
61417
  }
61418
- ms2 += TIMESHIFT;
61419
- const date2 = new Date(ms2);
61418
+ ms += TIMESHIFT;
61419
+ const date2 = new Date(ms);
61420
61420
  return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
61421
61421
  }
61422
61422
  };
@@ -61478,13 +61478,13 @@ var require_datetime2 = __commonJS({
61478
61478
  }
61479
61479
  let us = Number(bius);
61480
61480
  let seconds = Math.floor(us / 1e6);
61481
- const ms2 = Math.floor(us % 1e6 / 1e3);
61482
- us = us % 1e6 - ms2 * 1e3;
61481
+ const ms = Math.floor(us % 1e6 / 1e3);
61482
+ us = us % 1e6 - ms * 1e3;
61483
61483
  let minutes = Math.floor(seconds / 60);
61484
61484
  seconds = Math.floor(seconds % 60);
61485
61485
  const hours = Math.floor(minutes / 60);
61486
61486
  minutes = Math.floor(minutes % 60);
61487
- return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
61487
+ return new datetime_1.LocalTime(hours, minutes, seconds, ms, us);
61488
61488
  }
61489
61489
  };
61490
61490
  exports2.LocalTimeCodec = LocalTimeCodec;
@@ -61561,14 +61561,14 @@ var require_datetime2 = __commonJS({
61561
61561
  const biMillion = 1000000n;
61562
61562
  const biSeconds = bius / biMillion;
61563
61563
  let us = Number(bius - biSeconds * biMillion);
61564
- const ms2 = Math.floor(us / 1e3);
61564
+ const ms = Math.floor(us / 1e3);
61565
61565
  us = us % 1e3;
61566
61566
  let seconds = Number(biSeconds);
61567
61567
  let minutes = Math.floor(seconds / 60);
61568
61568
  seconds = Math.floor(seconds % 60);
61569
61569
  const hours = Math.floor(minutes / 60);
61570
61570
  minutes = Math.floor(minutes % 60);
61571
- return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
61571
+ return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
61572
61572
  }
61573
61573
  };
61574
61574
  exports2.DurationCodec = DurationCodec;
@@ -61614,7 +61614,7 @@ var require_datetime2 = __commonJS({
61614
61614
  const million = BigInt(1e6);
61615
61615
  const biSeconds = bius / million;
61616
61616
  let us = Number(bius - biSeconds * million);
61617
- const ms2 = Math.trunc(us / 1e3);
61617
+ const ms = Math.trunc(us / 1e3);
61618
61618
  us = us % 1e3;
61619
61619
  let seconds = Number(biSeconds);
61620
61620
  let minutes = Math.trunc(seconds / 60);
@@ -61625,7 +61625,7 @@ var require_datetime2 = __commonJS({
61625
61625
  days = Math.trunc(days % 7);
61626
61626
  const years = Math.trunc(months2 / 12);
61627
61627
  months2 = Math.trunc(months2 % 12);
61628
- return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
61628
+ return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
61629
61629
  }
61630
61630
  };
61631
61631
  exports2.RelativeDurationCodec = RelativeDurationCodec;
@@ -71789,41 +71789,41 @@ var require_ms = __commonJS({
71789
71789
  return void 0;
71790
71790
  }
71791
71791
  }
71792
- function fmtShort(ms2) {
71793
- var msAbs = Math.abs(ms2);
71792
+ function fmtShort(ms) {
71793
+ var msAbs = Math.abs(ms);
71794
71794
  if (msAbs >= d6) {
71795
- return Math.round(ms2 / d6) + "d";
71795
+ return Math.round(ms / d6) + "d";
71796
71796
  }
71797
71797
  if (msAbs >= h7) {
71798
- return Math.round(ms2 / h7) + "h";
71798
+ return Math.round(ms / h7) + "h";
71799
71799
  }
71800
71800
  if (msAbs >= m7) {
71801
- return Math.round(ms2 / m7) + "m";
71801
+ return Math.round(ms / m7) + "m";
71802
71802
  }
71803
71803
  if (msAbs >= s7) {
71804
- return Math.round(ms2 / s7) + "s";
71804
+ return Math.round(ms / s7) + "s";
71805
71805
  }
71806
- return ms2 + "ms";
71806
+ return ms + "ms";
71807
71807
  }
71808
- function fmtLong(ms2) {
71809
- var msAbs = Math.abs(ms2);
71808
+ function fmtLong(ms) {
71809
+ var msAbs = Math.abs(ms);
71810
71810
  if (msAbs >= d6) {
71811
- return plural2(ms2, msAbs, d6, "day");
71811
+ return plural2(ms, msAbs, d6, "day");
71812
71812
  }
71813
71813
  if (msAbs >= h7) {
71814
- return plural2(ms2, msAbs, h7, "hour");
71814
+ return plural2(ms, msAbs, h7, "hour");
71815
71815
  }
71816
71816
  if (msAbs >= m7) {
71817
- return plural2(ms2, msAbs, m7, "minute");
71817
+ return plural2(ms, msAbs, m7, "minute");
71818
71818
  }
71819
71819
  if (msAbs >= s7) {
71820
- return plural2(ms2, msAbs, s7, "second");
71820
+ return plural2(ms, msAbs, s7, "second");
71821
71821
  }
71822
- return ms2 + " ms";
71822
+ return ms + " ms";
71823
71823
  }
71824
- function plural2(ms2, msAbs, n6, name) {
71824
+ function plural2(ms, msAbs, n6, name) {
71825
71825
  var isPlural = msAbs >= n6 * 1.5;
71826
- return Math.round(ms2 / n6) + " " + name + (isPlural ? "s" : "");
71826
+ return Math.round(ms / n6) + " " + name + (isPlural ? "s" : "");
71827
71827
  }
71828
71828
  }
71829
71829
  });
@@ -71867,8 +71867,8 @@ var require_common2 = __commonJS({
71867
71867
  }
71868
71868
  const self2 = debug;
71869
71869
  const curr = Number(/* @__PURE__ */ new Date());
71870
- const ms2 = curr - (prevTime || curr);
71871
- self2.diff = ms2;
71870
+ const ms = curr - (prevTime || curr);
71871
+ self2.diff = ms;
71872
71872
  self2.prev = prevTime;
71873
71873
  self2.curr = curr;
71874
71874
  prevTime = curr;
@@ -87371,11 +87371,11 @@ var require_TokenExpiredError = __commonJS({
87371
87371
  var require_timespan = __commonJS({
87372
87372
  "../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module2) {
87373
87373
  "use strict";
87374
- var ms2 = require_ms();
87374
+ var ms = require_ms();
87375
87375
  module2.exports = function(time2, iat) {
87376
87376
  var timestamp = iat || Math.floor(Date.now() / 1e3);
87377
87377
  if (typeof time2 === "string") {
87378
- var milliseconds = ms2(time2);
87378
+ var milliseconds = ms(time2);
87379
87379
  if (typeof milliseconds === "undefined") {
87380
87380
  return;
87381
87381
  }
@@ -101913,7 +101913,7 @@ var require_dist = __commonJS({
101913
101913
  };
101914
101914
  Object.defineProperty(exports2, "__esModule", { value: true });
101915
101915
  exports2.Agent = void 0;
101916
- var net2 = __importStar2(require("net"));
101916
+ var net = __importStar2(require("net"));
101917
101917
  var http3 = __importStar2(require("http"));
101918
101918
  var https_1 = require("https");
101919
101919
  __exportStar2(require_helpers2(), exports2);
@@ -101953,7 +101953,7 @@ var require_dist = __commonJS({
101953
101953
  if (!this.sockets[name]) {
101954
101954
  this.sockets[name] = [];
101955
101955
  }
101956
- const fakeSocket = new net2.Socket({ writable: false });
101956
+ const fakeSocket = new net.Socket({ writable: false });
101957
101957
  this.sockets[name].push(fakeSocket);
101958
101958
  this.totalSocketCount++;
101959
101959
  return fakeSocket;
@@ -102165,7 +102165,7 @@ var require_dist2 = __commonJS({
102165
102165
  };
102166
102166
  Object.defineProperty(exports2, "__esModule", { value: true });
102167
102167
  exports2.HttpsProxyAgent = void 0;
102168
- var net2 = __importStar2(require("net"));
102168
+ var net = __importStar2(require("net"));
102169
102169
  var tls = __importStar2(require("tls"));
102170
102170
  var assert_1 = __importDefault2(require("assert"));
102171
102171
  var debug_1 = __importDefault2(require_src2());
@@ -102174,7 +102174,7 @@ var require_dist2 = __commonJS({
102174
102174
  var parse_proxy_response_1 = require_parse_proxy_response();
102175
102175
  var debug = (0, debug_1.default)("https-proxy-agent");
102176
102176
  var setServernameFromNonIpHost = (options) => {
102177
- if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
102177
+ if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
102178
102178
  return {
102179
102179
  ...options,
102180
102180
  servername: options.host
@@ -102214,10 +102214,10 @@ var require_dist2 = __commonJS({
102214
102214
  socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
102215
102215
  } else {
102216
102216
  debug("Creating `net.Socket`: %o", this.connectOpts);
102217
- socket = net2.connect(this.connectOpts);
102217
+ socket = net.connect(this.connectOpts);
102218
102218
  }
102219
102219
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
102220
- const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
102220
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
102221
102221
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
102222
102222
  `;
102223
102223
  if (proxy.username || proxy.password) {
@@ -102250,7 +102250,7 @@ var require_dist2 = __commonJS({
102250
102250
  return socket;
102251
102251
  }
102252
102252
  socket.destroy();
102253
- const fakeSocket = new net2.Socket({ writable: false });
102253
+ const fakeSocket = new net.Socket({ writable: false });
102254
102254
  fakeSocket.readable = true;
102255
102255
  req.once("socket", (s7) => {
102256
102256
  debug("Replaying proxy buffer for failed request");
@@ -102315,7 +102315,7 @@ var require_dist3 = __commonJS({
102315
102315
  };
102316
102316
  Object.defineProperty(exports2, "__esModule", { value: true });
102317
102317
  exports2.HttpProxyAgent = void 0;
102318
- var net2 = __importStar2(require("net"));
102318
+ var net = __importStar2(require("net"));
102319
102319
  var tls = __importStar2(require("tls"));
102320
102320
  var debug_1 = __importDefault2(require_src2());
102321
102321
  var events_1 = require("events");
@@ -102388,7 +102388,7 @@ var require_dist3 = __commonJS({
102388
102388
  socket = tls.connect(this.connectOpts);
102389
102389
  } else {
102390
102390
  debug("Creating `net.Socket`: %o", this.connectOpts);
102391
- socket = net2.connect(this.connectOpts);
102391
+ socket = net.connect(this.connectOpts);
102392
102392
  }
102393
102393
  await (0, events_1.once)(socket, "connect");
102394
102394
  return socket;
@@ -141268,7 +141268,7 @@ var require_connection = __commonJS({
141268
141268
  var _crypto = _interopRequireDefault(require("crypto"));
141269
141269
  var _os = _interopRequireDefault(require("os"));
141270
141270
  var tls = _interopRequireWildcard(require("tls"));
141271
- var net2 = _interopRequireWildcard(require("net"));
141271
+ var net = _interopRequireWildcard(require("net"));
141272
141272
  var _dns = _interopRequireDefault(require("dns"));
141273
141273
  var _constants = _interopRequireDefault(require("constants"));
141274
141274
  var _stream = require("stream");
@@ -142317,7 +142317,7 @@ var require_connection = __commonJS({
142317
142317
  async wrapWithTls(socket, signal) {
142318
142318
  signal.throwIfAborted();
142319
142319
  const secureContext = tls.createSecureContext(this.secureContextOptions);
142320
- const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
142320
+ const serverName = !net.isIP(this.config.server) ? this.config.server : "";
142321
142321
  const encryptOptions = {
142322
142322
  host: this.config.server,
142323
142323
  socket,
@@ -145239,11 +145239,10 @@ function parseMssqlUrl(url) {
145239
145239
  }
145240
145240
  };
145241
145241
  }
145242
- var import_net, ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
145242
+ var normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
145243
145243
  var init_connections = __esm({
145244
145244
  "src/cli/connections.ts"() {
145245
145245
  "use strict";
145246
- import_net = __toESM(require("net"));
145247
145246
  init_src();
145248
145247
  init_wrapper();
145249
145248
  init_utils();
@@ -145251,7 +145250,6 @@ var init_connections = __esm({
145251
145250
  init_when_json_met_bigint();
145252
145251
  init_utils3();
145253
145252
  init_outputs();
145254
- ms = (a6, b6) => Number(b6 - a6) / 1e6;
145255
145253
  normalisePGliteUrl = (it) => {
145256
145254
  if (it.startsWith("file:")) {
145257
145255
  return it.substring(5);
@@ -145406,13 +145404,13 @@ var init_connections = __esm({
145406
145404
  return pg.types.getTypeParser(typeId, format2);
145407
145405
  }
145408
145406
  };
145409
- const pool = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
145410
- const db = drizzle({ client: pool });
145407
+ const client = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
145408
+ const db = drizzle({ client });
145411
145409
  const migrateFn = async (config) => {
145412
145410
  return migrate(db, config);
145413
145411
  };
145414
145412
  const query = async (sql, params) => {
145415
- const result2 = await pool.query({
145413
+ const result2 = await client.query({
145416
145414
  text: sql,
145417
145415
  values: params ?? [],
145418
145416
  types: types3
@@ -145422,7 +145420,7 @@ var init_connections = __esm({
145422
145420
  return result2.rows;
145423
145421
  };
145424
145422
  const proxy = async (params) => {
145425
- const result2 = await pool.query({
145423
+ const result2 = await client.query({
145426
145424
  text: params.sql,
145427
145425
  values: params.params,
145428
145426
  ...params.mode === "array" && { rowMode: "array" },
@@ -145434,7 +145432,7 @@ var init_connections = __esm({
145434
145432
  };
145435
145433
  const transactionProxy = async (queries) => {
145436
145434
  const results = [];
145437
- const tx = await pool.connect();
145435
+ const tx = await client.connect();
145438
145436
  try {
145439
145437
  await tx.query("BEGIN");
145440
145438
  for (const query2 of queries) {
@@ -145453,119 +145451,7 @@ var init_connections = __esm({
145453
145451
  }
145454
145452
  return results;
145455
145453
  };
145456
- const benchmarkQuery = async (client, sql, params) => {
145457
- const explainResult = await pool.query({
145458
- text: `EXPLAIN ANALYZE ${sql}`,
145459
- values: params ?? [],
145460
- types: types3
145461
- });
145462
- const stringifiedResult = JSON.stringify(explainResult.rows);
145463
- const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
145464
- const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
145465
- let planningTime = Number(planningMatch[1]);
145466
- let executionTime = Number(executionMatch[1]);
145467
- let querySentAt = 0n;
145468
- let firstDataAt = 0n;
145469
- let lastDataAt = 0n;
145470
- let lastRowParsedAt = 0n;
145471
- let queryCompletedAt = 0n;
145472
- let bytesReceived = 0;
145473
- let rowCount = 0;
145474
- let parseTime = 0;
145475
- let lastParseTime = 0;
145476
- const rowDescriptionListener = (data) => {
145477
- if (firstDataAt === 0n) {
145478
- firstDataAt = process.hrtime.bigint();
145479
- }
145480
- bytesReceived += data.length;
145481
- };
145482
- const originalRowListener = client.connection.listeners("dataRow")[0];
145483
- const wrappedRowListener = (data) => {
145484
- rowCount += 1;
145485
- const start = process.hrtime.bigint();
145486
- lastDataAt = start;
145487
- originalRowListener.apply(client.connection, [data]);
145488
- const end2 = process.hrtime.bigint();
145489
- lastRowParsedAt = end2;
145490
- lastParseTime = ms(start, end2);
145491
- parseTime += lastParseTime;
145492
- bytesReceived += data.length;
145493
- };
145494
- client.connection.removeAllListeners("dataRow");
145495
- client.connection.addListener("dataRow", wrappedRowListener);
145496
- client.connection.prependListener("rowDescription", rowDescriptionListener);
145497
- querySentAt = process.hrtime.bigint();
145498
- await client.query({
145499
- text: sql,
145500
- values: params,
145501
- types: types3
145502
- });
145503
- queryCompletedAt = process.hrtime.bigint();
145504
- client.connection.removeListener("rowDescription", rowDescriptionListener);
145505
- client.connection.removeAllListeners("dataRow");
145506
- client.connection.addListener("dataRow", originalRowListener);
145507
- let querySentTime = ms(querySentAt, firstDataAt) - executionTime - planningTime;
145508
- if (querySentTime < 0) {
145509
- const percent = 0.1;
145510
- const overflow = -querySentTime;
145511
- const keepForSent = overflow * percent;
145512
- const adjustedOverflow = overflow * (1 + percent);
145513
- const total2 = planningTime + executionTime;
145514
- const ratioPlanning = planningTime / total2;
145515
- const ratioExecution = executionTime / total2;
145516
- planningTime -= adjustedOverflow * ratioPlanning;
145517
- executionTime -= adjustedOverflow * ratioExecution;
145518
- querySentTime = keepForSent;
145519
- }
145520
- const networkLatencyBefore = querySentTime / 2;
145521
- const networkLatencyAfter = querySentTime / 2;
145522
- const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
145523
- const total = ms(querySentAt, queryCompletedAt);
145524
- const calculatedTotal = networkLatencyBefore + planningTime + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
145525
- const errorMargin = Math.abs(total - calculatedTotal);
145526
- return {
145527
- networkLatencyBefore,
145528
- planning: planningTime,
145529
- execution: executionTime,
145530
- networkLatencyAfter,
145531
- dataDownload: downloadTime,
145532
- dataParse: parseTime,
145533
- total,
145534
- errorMargin,
145535
- dataSize: bytesReceived
145536
- };
145537
- };
145538
- const benchmarkProxy = async ({ sql, params }, repeats) => {
145539
- let startAt = 0n;
145540
- let tcpConnectedAt = 0n;
145541
- let tlsConnectedAt = null;
145542
- let dbReadyAt = 0n;
145543
- const client = "url" in credentials ? new pg.Client({ connectionString: credentials.url }) : new pg.Client({ ...credentials, ssl });
145544
- client.connection.once("connect", () => {
145545
- tcpConnectedAt = process.hrtime.bigint();
145546
- });
145547
- client.connection.prependOnceListener("sslconnect", () => {
145548
- tlsConnectedAt = process.hrtime.bigint();
145549
- });
145550
- client.connection.prependOnceListener("readyForQuery", () => {
145551
- dbReadyAt = process.hrtime.bigint();
145552
- });
145553
- startAt = process.hrtime.bigint();
145554
- await client.connect();
145555
- const results = [];
145556
- for (let i7 = 0; i7 < repeats; i7++) {
145557
- const r7 = await benchmarkQuery(client, sql, params);
145558
- results.push(r7);
145559
- }
145560
- await client.end();
145561
- return {
145562
- tcpHandshake: ms(startAt, tcpConnectedAt),
145563
- tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
145564
- dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
145565
- queries: results
145566
- };
145567
- };
145568
- return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
145454
+ return { packageName: "pg", query, proxy, transactionProxy, migrate: migrateFn };
145569
145455
  }
145570
145456
  if (await checkPackage("postgres")) {
145571
145457
  console.log(
@@ -146060,6 +145946,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146060
145946
  }
146061
145947
  return next();
146062
145948
  };
145949
+ await connection.connect();
146063
145950
  const query = async (sql, params) => {
146064
145951
  const res = await connection.execute({
146065
145952
  sql,
@@ -146099,156 +145986,11 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146099
145986
  }
146100
145987
  return results;
146101
145988
  };
146102
- const benchmarkQuery = async (newConnection, sql, params) => {
146103
- const explainResult = await connection.query({
146104
- sql: `EXPLAIN ANALYZE ${sql}`,
146105
- values: params ?? [],
146106
- typeCast
146107
- });
146108
- const stringifiedResult = JSON.stringify(explainResult[0]);
146109
- const timeMatch = stringifiedResult.match(
146110
- /actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
146111
- );
146112
- const lastRowTime = Number(timeMatch[2]);
146113
- let executionTime = lastRowTime;
146114
- let querySentAt = 0n;
146115
- let firstDataAt = 0n;
146116
- let lastDataAt = 0n;
146117
- let lastRowParsedAt = 0n;
146118
- let queryCompletedAt = 0n;
146119
- let bytesReceived = 0;
146120
- let rowCount = 0;
146121
- let parseTime = 0;
146122
- let lastParseTime = 0;
146123
- querySentAt = process.hrtime.bigint();
146124
- await new Promise((resolve2, reject) => {
146125
- const query2 = newConnection.query({
146126
- sql,
146127
- values: params ?? [],
146128
- typeCast
146129
- });
146130
- const originalRowHandler = query2.row;
146131
- let packets = 0;
146132
- const wrappedRowListener = (packet, connection2) => {
146133
- packets += 1;
146134
- if (firstDataAt === 0n) {
146135
- firstDataAt = process.hrtime.bigint();
146136
- bytesReceived += packet.start;
146137
- }
146138
- const start = process.hrtime.bigint();
146139
- lastDataAt = start;
146140
- const res = originalRowHandler.apply(query2, [packet, connection2]);
146141
- const end2 = process.hrtime.bigint();
146142
- lastRowParsedAt = end2;
146143
- lastParseTime = ms(start, end2);
146144
- parseTime += lastParseTime;
146145
- bytesReceived += packet.length();
146146
- if (!res || packet.isEOF()) {
146147
- return res;
146148
- }
146149
- return wrappedRowListener;
146150
- };
146151
- query2.row = wrappedRowListener;
146152
- query2.on("result", () => {
146153
- rowCount += 1;
146154
- });
146155
- query2.on("error", (err2) => {
146156
- reject(err2);
146157
- });
146158
- query2.on("end", () => {
146159
- resolve2();
146160
- });
146161
- });
146162
- queryCompletedAt = process.hrtime.bigint();
146163
- let querySentTime = ms(querySentAt, firstDataAt) - executionTime;
146164
- if (querySentTime < 0) {
146165
- const percent = 0.1;
146166
- const overflow = -querySentTime;
146167
- const keepForSent = overflow * percent;
146168
- const adjustedOverflow = overflow * (1 + percent);
146169
- const total2 = executionTime;
146170
- const ratioExecution = executionTime / total2;
146171
- executionTime -= adjustedOverflow * ratioExecution;
146172
- querySentTime = keepForSent;
146173
- }
146174
- const networkLatencyBefore = querySentTime / 2;
146175
- const networkLatencyAfter = querySentTime / 2;
146176
- const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
146177
- const total = ms(querySentAt, queryCompletedAt);
146178
- const calculatedTotal = networkLatencyBefore + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
146179
- const errorMargin = Math.abs(total - calculatedTotal);
146180
- return {
146181
- networkLatencyBefore,
146182
- planning: null,
146183
- execution: executionTime,
146184
- networkLatencyAfter,
146185
- dataDownload: downloadTime,
146186
- dataParse: parseTime,
146187
- total,
146188
- errorMargin,
146189
- dataSize: bytesReceived
146190
- };
146191
- };
146192
- const benchmarkProxy = async ({ sql, params }, repeats) => {
146193
- const { createConnection: createConnection2 } = require("mysql2");
146194
- let startAt = 0n;
146195
- let tcpConnectedAt = 0n;
146196
- let tlsConnectedAt = null;
146197
- const createStream = ({ config }) => {
146198
- let stream;
146199
- if (config.socketPath) {
146200
- stream = import_net.default.connect(config.socketPath);
146201
- } else {
146202
- stream = import_net.default.connect(config.port, config.host);
146203
- }
146204
- if (config.enableKeepAlive) {
146205
- stream.on("connect", () => {
146206
- stream.setKeepAlive(true, config.keepAliveInitialDelay);
146207
- });
146208
- }
146209
- stream.setNoDelay(true);
146210
- stream.once("connect", () => {
146211
- tcpConnectedAt = process.hrtime.bigint();
146212
- });
146213
- return stream;
146214
- };
146215
- startAt = process.hrtime.bigint();
146216
- const connection2 = result2.url ? createConnection2({
146217
- uri: result2.url,
146218
- stream: createStream
146219
- }) : createConnection2({
146220
- ...result2.credentials,
146221
- stream: createStream
146222
- });
146223
- await new Promise((resolve2, reject) => {
146224
- connection2.connect((err2) => {
146225
- tlsConnectedAt = process.hrtime.bigint();
146226
- if (err2) {
146227
- reject(err2);
146228
- } else {
146229
- resolve2();
146230
- }
146231
- });
146232
- });
146233
- const results = [];
146234
- for (let i7 = 0; i7 < repeats; i7++) {
146235
- const r7 = await benchmarkQuery(connection2, sql, params);
146236
- results.push(r7);
146237
- }
146238
- connection2.end();
146239
- return {
146240
- tcpHandshake: ms(startAt, tcpConnectedAt),
146241
- tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
146242
- dbHandshake: null,
146243
- queries: results
146244
- };
146245
- };
146246
145989
  return {
146247
145990
  db: { query },
146248
145991
  packageName: "mysql2",
146249
145992
  proxy,
146250
145993
  transactionProxy,
146251
- benchmarkProxy,
146252
145994
  database: result2.database,
146253
145995
  migrate: migrateFn
146254
145996
  };
@@ -148802,8 +148544,8 @@ ${sql}
148802
148544
  `;
148803
148545
  return content;
148804
148546
  };
148805
- prepareSnapshotFolderName = (ms2) => {
148806
- const now = ms2 ? new Date(ms2) : /* @__PURE__ */ new Date();
148547
+ prepareSnapshotFolderName = (ms) => {
148548
+ const now = ms ? new Date(ms) : /* @__PURE__ */ new Date();
148807
148549
  return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
148808
148550
  now.getUTCDate()
148809
148551
  )}${two(now.getUTCHours())}${two(now.getUTCMinutes())}${two(
@@ -152301,7 +152043,7 @@ __export(studio_exports, {
152301
152043
  prepareServer: () => prepareServer,
152302
152044
  prepareSingleStoreSchema: () => prepareSingleStoreSchema
152303
152045
  });
152304
- var import_crypto10, import_drizzle_orm3, import_relations3, import_mssql_core2, import_mysql_core2, import_pg_core3, import_singlestore_core, import_sqlite_core2, import_fs6, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
152046
+ var import_crypto10, import_drizzle_orm3, import_relations3, import_mssql_core2, import_mysql_core2, import_pg_core3, import_singlestore_core, import_sqlite_core2, import_fs6, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
152305
152047
  var init_studio = __esm({
152306
152048
  "src/cli/commands/studio.ts"() {
152307
152049
  "use strict";
@@ -152525,7 +152267,6 @@ var init_studio = __esm({
152525
152267
  packageName: db.packageName,
152526
152268
  proxy: db.proxy,
152527
152269
  transactionProxy: db.transactionProxy,
152528
- benchmarkProxy: db.benchmarkProxy,
152529
152270
  customDefaults,
152530
152271
  schema: pgSchema2,
152531
152272
  relations: relations2,
@@ -152535,7 +152276,7 @@ var init_studio = __esm({
152535
152276
  };
152536
152277
  drizzleForMySQL = async (credentials, mysqlSchema, relations2, schemaFiles, casing2) => {
152537
152278
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
152538
- const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);
152279
+ const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
152539
152280
  const customDefaults = getCustomDefaults(mysqlSchema, casing2);
152540
152281
  let dbUrl;
152541
152282
  if ("url" in credentials) {
@@ -152551,7 +152292,6 @@ var init_studio = __esm({
152551
152292
  databaseName: database,
152552
152293
  proxy,
152553
152294
  transactionProxy,
152554
- benchmarkProxy,
152555
152295
  customDefaults,
152556
152296
  schema: mysqlSchema,
152557
152297
  relations: relations2,
@@ -152721,23 +152461,6 @@ var init_studio = __esm({
152721
152461
  ]).optional()
152722
152462
  }).array()
152723
152463
  });
152724
- benchmarkProxySchema = external_exports.object({
152725
- type: external_exports.literal("bproxy"),
152726
- data: external_exports.object({
152727
- query: external_exports.object({
152728
- sql: external_exports.string(),
152729
- params: external_exports.array(external_exports.any()).optional(),
152730
- method: external_exports.union([
152731
- external_exports.literal("values"),
152732
- external_exports.literal("get"),
152733
- external_exports.literal("all"),
152734
- external_exports.literal("run"),
152735
- external_exports.literal("execute")
152736
- ]).optional()
152737
- }),
152738
- repeats: external_exports.number().min(1).optional()
152739
- })
152740
- });
152741
152464
  defaultsSchema = external_exports.object({
152742
152465
  type: external_exports.literal("defaults"),
152743
152466
  data: external_exports.array(
@@ -152752,7 +152475,6 @@ var init_studio = __esm({
152752
152475
  init2,
152753
152476
  proxySchema,
152754
152477
  transactionProxySchema,
152755
- benchmarkProxySchema,
152756
152478
  defaultsSchema
152757
152479
  ]);
152758
152480
  jsonStringify = (data) => {
@@ -152775,7 +152497,6 @@ var init_studio = __esm({
152775
152497
  databaseName,
152776
152498
  proxy,
152777
152499
  transactionProxy,
152778
- benchmarkProxy,
152779
152500
  customDefaults,
152780
152501
  schema: drizzleSchema,
152781
152502
  relations: relations2,
@@ -152839,7 +152560,7 @@ var init_studio = __esm({
152839
152560
  console.warn("Error message:", error3.message);
152840
152561
  }
152841
152562
  return c6.json({
152842
- version: "6.3",
152563
+ version: "6.2",
152843
152564
  dialect: dialect6,
152844
152565
  driver: driver2,
152845
152566
  packageName,
@@ -152877,21 +152598,6 @@ var init_studio = __esm({
152877
152598
  }
152878
152599
  );
152879
152600
  }
152880
- if (type === "bproxy") {
152881
- if (!benchmarkProxy) {
152882
- throw new Error("Benchmark proxy is not configured for this database.");
152883
- }
152884
- const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
152885
- const res = jsonStringify(result2);
152886
- return c6.body(
152887
- res,
152888
- {
152889
- headers: {
152890
- "Content-Type": "application/json"
152891
- }
152892
- }
152893
- );
152894
- }
152895
152601
  if (type === "defaults") {
152896
152602
  const columns = body.data;
152897
152603
  const result2 = columns.map((column8) => {