drizzle-kit 0.20.0-13160ca → 0.20.0-3d76318

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/index.cjs CHANGED
@@ -4542,6 +4542,9 @@ Is ${source_default.bold.blue(
4542
4542
  });
4543
4543
 
4544
4544
  // src/global.ts
4545
+ function assertUnreachable(x) {
4546
+ throw new Error("Didn't expect to get here");
4547
+ }
4545
4548
  var originUUID, snapshotVersion;
4546
4549
  var init_global = __esm({
4547
4550
  "src/global.ts"() {
@@ -11480,7 +11483,7 @@ var init_outputs = __esm({
11480
11483
  connection: {
11481
11484
  driver: () => withStyle.error(`Only "mysql2" is available options for "--driver"`),
11482
11485
  required: () => withStyle.error(
11483
- `Either "connectionString" or "host", "database" are required for database connection`
11486
+ `Either "uri" or "host", "database" are required for database connection`
11484
11487
  )
11485
11488
  }
11486
11489
  },
@@ -21593,9 +21596,9 @@ var require_pg_types = __commonJS({
21593
21596
  }
21594
21597
  });
21595
21598
 
21596
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/defaults.js
21599
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/defaults.js
21597
21600
  var require_defaults = __commonJS({
21598
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/defaults.js"(exports, module2) {
21601
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/defaults.js"(exports, module2) {
21599
21602
  "use strict";
21600
21603
  module2.exports = {
21601
21604
  // database host. defaults to localhost
@@ -21655,11 +21658,10 @@ var require_defaults = __commonJS({
21655
21658
  }
21656
21659
  });
21657
21660
 
21658
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/utils.js
21661
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/utils.js
21659
21662
  var require_utils2 = __commonJS({
21660
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/utils.js"(exports, module2) {
21663
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/utils.js"(exports, module2) {
21661
21664
  "use strict";
21662
- var crypto = require("crypto");
21663
21665
  var defaults3 = require_defaults();
21664
21666
  function escapeElement(elementRepresentation) {
21665
21667
  var escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
@@ -21774,30 +21776,138 @@ var require_utils2 = __commonJS({
21774
21776
  }
21775
21777
  return config;
21776
21778
  }
21777
- var md5 = function(string) {
21778
- return crypto.createHash("md5").update(string, "utf-8").digest("hex");
21779
+ var escapeIdentifier = function(str) {
21780
+ return '"' + str.replace(/"/g, '""') + '"';
21779
21781
  };
21780
- var postgresMd5PasswordHash = function(user, password, salt) {
21781
- var inner = md5(password + user);
21782
- var outer = md5(Buffer.concat([Buffer.from(inner), salt]));
21783
- return "md5" + outer;
21782
+ var escapeLiteral = function(str) {
21783
+ var hasBackslash = false;
21784
+ var escaped = "'";
21785
+ for (var i = 0; i < str.length; i++) {
21786
+ var c = str[i];
21787
+ if (c === "'") {
21788
+ escaped += c + c;
21789
+ } else if (c === "\\") {
21790
+ escaped += c + c;
21791
+ hasBackslash = true;
21792
+ } else {
21793
+ escaped += c;
21794
+ }
21795
+ }
21796
+ escaped += "'";
21797
+ if (hasBackslash === true) {
21798
+ escaped = " E" + escaped;
21799
+ }
21800
+ return escaped;
21784
21801
  };
21785
21802
  module2.exports = {
21786
21803
  prepareValue: function prepareValueWrapper(value) {
21787
21804
  return prepareValue(value);
21788
21805
  },
21789
21806
  normalizeQueryConfig,
21807
+ escapeIdentifier,
21808
+ escapeLiteral
21809
+ };
21810
+ }
21811
+ });
21812
+
21813
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/crypto/utils-legacy.js
21814
+ var require_utils_legacy = __commonJS({
21815
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/crypto/utils-legacy.js"(exports, module2) {
21816
+ "use strict";
21817
+ var nodeCrypto = require("crypto");
21818
+ function md5(string) {
21819
+ return nodeCrypto.createHash("md5").update(string, "utf-8").digest("hex");
21820
+ }
21821
+ function postgresMd5PasswordHash(user, password, salt) {
21822
+ var inner = md5(password + user);
21823
+ var outer = md5(Buffer.concat([Buffer.from(inner), salt]));
21824
+ return "md5" + outer;
21825
+ }
21826
+ function sha256(text) {
21827
+ return nodeCrypto.createHash("sha256").update(text).digest();
21828
+ }
21829
+ function hmacSha256(key, msg) {
21830
+ return nodeCrypto.createHmac("sha256", key).update(msg).digest();
21831
+ }
21832
+ async function deriveKey(password, salt, iterations) {
21833
+ return nodeCrypto.pbkdf2Sync(password, salt, iterations, 32, "sha256");
21834
+ }
21835
+ module2.exports = {
21836
+ postgresMd5PasswordHash,
21837
+ randomBytes: nodeCrypto.randomBytes,
21838
+ deriveKey,
21839
+ sha256,
21840
+ hmacSha256,
21841
+ md5
21842
+ };
21843
+ }
21844
+ });
21845
+
21846
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/crypto/utils-webcrypto.js
21847
+ var require_utils_webcrypto = __commonJS({
21848
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/crypto/utils-webcrypto.js"(exports, module2) {
21849
+ var nodeCrypto = require("crypto");
21850
+ module2.exports = {
21790
21851
  postgresMd5PasswordHash,
21852
+ randomBytes,
21853
+ deriveKey,
21854
+ sha256,
21855
+ hmacSha256,
21791
21856
  md5
21792
21857
  };
21858
+ var webCrypto = nodeCrypto.webcrypto || globalThis.crypto;
21859
+ var subtleCrypto = webCrypto.subtle;
21860
+ var textEncoder = new TextEncoder();
21861
+ function randomBytes(length) {
21862
+ return webCrypto.getRandomValues(Buffer.alloc(length));
21863
+ }
21864
+ async function md5(string) {
21865
+ try {
21866
+ return nodeCrypto.createHash("md5").update(string, "utf-8").digest("hex");
21867
+ } catch (e) {
21868
+ const data = typeof string === "string" ? textEncoder.encode(string) : string;
21869
+ const hash = await subtleCrypto.digest("MD5", data);
21870
+ return Array.from(new Uint8Array(hash)).map((b) => b.toString(16).padStart(2, "0")).join("");
21871
+ }
21872
+ }
21873
+ async function postgresMd5PasswordHash(user, password, salt) {
21874
+ var inner = await md5(password + user);
21875
+ var outer = await md5(Buffer.concat([Buffer.from(inner), salt]));
21876
+ return "md5" + outer;
21877
+ }
21878
+ async function sha256(text) {
21879
+ return await subtleCrypto.digest("SHA-256", text);
21880
+ }
21881
+ async function hmacSha256(keyBuffer, msg) {
21882
+ const key = await subtleCrypto.importKey("raw", keyBuffer, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
21883
+ return await subtleCrypto.sign("HMAC", key, textEncoder.encode(msg));
21884
+ }
21885
+ async function deriveKey(password, salt, iterations) {
21886
+ const key = await subtleCrypto.importKey("raw", textEncoder.encode(password), "PBKDF2", false, ["deriveBits"]);
21887
+ const params = { name: "PBKDF2", hash: "SHA-256", salt, iterations };
21888
+ return await subtleCrypto.deriveBits(params, key, 32 * 8, ["deriveBits"]);
21889
+ }
21793
21890
  }
21794
21891
  });
21795
21892
 
21796
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/sasl.js
21893
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/crypto/utils.js
21894
+ var require_utils3 = __commonJS({
21895
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/crypto/utils.js"(exports, module2) {
21896
+ "use strict";
21897
+ var useLegacyCrypto = parseInt(process.versions && process.versions.node && process.versions.node.split(".")[0]) < 15;
21898
+ if (useLegacyCrypto) {
21899
+ module2.exports = require_utils_legacy();
21900
+ } else {
21901
+ module2.exports = require_utils_webcrypto();
21902
+ }
21903
+ }
21904
+ });
21905
+
21906
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/crypto/sasl.js
21797
21907
  var require_sasl = __commonJS({
21798
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/sasl.js"(exports, module2) {
21908
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/crypto/sasl.js"(exports, module2) {
21799
21909
  "use strict";
21800
- var crypto = require("crypto");
21910
+ var crypto = require_utils3();
21801
21911
  function startSession(mechanisms) {
21802
21912
  if (mechanisms.indexOf("SCRAM-SHA-256") === -1) {
21803
21913
  throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");
@@ -21810,13 +21920,16 @@ var require_sasl = __commonJS({
21810
21920
  message: "SASLInitialResponse"
21811
21921
  };
21812
21922
  }
21813
- function continueSession(session, password, serverData) {
21923
+ async function continueSession(session, password, serverData) {
21814
21924
  if (session.message !== "SASLInitialResponse") {
21815
21925
  throw new Error("SASL: Last message was not SASLInitialResponse");
21816
21926
  }
21817
21927
  if (typeof password !== "string") {
21818
21928
  throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");
21819
21929
  }
21930
+ if (password === "") {
21931
+ throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");
21932
+ }
21820
21933
  if (typeof serverData !== "string") {
21821
21934
  throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");
21822
21935
  }
@@ -21826,21 +21939,20 @@ var require_sasl = __commonJS({
21826
21939
  } else if (sv.nonce.length === session.clientNonce.length) {
21827
21940
  throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");
21828
21941
  }
21829
- var saltBytes = Buffer.from(sv.salt, "base64");
21830
- var saltedPassword = Hi(password, saltBytes, sv.iteration);
21831
- var clientKey = hmacSha256(saltedPassword, "Client Key");
21832
- var storedKey = sha256(clientKey);
21833
21942
  var clientFirstMessageBare = "n=*,r=" + session.clientNonce;
21834
21943
  var serverFirstMessage = "r=" + sv.nonce + ",s=" + sv.salt + ",i=" + sv.iteration;
21835
21944
  var clientFinalMessageWithoutProof = "c=biws,r=" + sv.nonce;
21836
21945
  var authMessage = clientFirstMessageBare + "," + serverFirstMessage + "," + clientFinalMessageWithoutProof;
21837
- var clientSignature = hmacSha256(storedKey, authMessage);
21838
- var clientProofBytes = xorBuffers(clientKey, clientSignature);
21839
- var clientProof = clientProofBytes.toString("base64");
21840
- var serverKey = hmacSha256(saltedPassword, "Server Key");
21841
- var serverSignatureBytes = hmacSha256(serverKey, authMessage);
21946
+ var saltBytes = Buffer.from(sv.salt, "base64");
21947
+ var saltedPassword = await crypto.deriveKey(password, saltBytes, sv.iteration);
21948
+ var clientKey = await crypto.hmacSha256(saltedPassword, "Client Key");
21949
+ var storedKey = await crypto.sha256(clientKey);
21950
+ var clientSignature = await crypto.hmacSha256(storedKey, authMessage);
21951
+ var clientProof = xorBuffers(Buffer.from(clientKey), Buffer.from(clientSignature)).toString("base64");
21952
+ var serverKey = await crypto.hmacSha256(saltedPassword, "Server Key");
21953
+ var serverSignatureBytes = await crypto.hmacSha256(serverKey, authMessage);
21842
21954
  session.message = "SASLResponse";
21843
- session.serverSignature = serverSignatureBytes.toString("base64");
21955
+ session.serverSignature = Buffer.from(serverSignatureBytes).toString("base64");
21844
21956
  session.response = clientFinalMessageWithoutProof + ",p=" + clientProof;
21845
21957
  }
21846
21958
  function finalizeSession(session, serverData) {
@@ -21933,21 +22045,6 @@ var require_sasl = __commonJS({
21933
22045
  }
21934
22046
  return Buffer.from(a.map((_, i) => a[i] ^ b[i]));
21935
22047
  }
21936
- function sha256(text) {
21937
- return crypto.createHash("sha256").update(text).digest();
21938
- }
21939
- function hmacSha256(key, msg) {
21940
- return crypto.createHmac("sha256", key).update(msg).digest();
21941
- }
21942
- function Hi(password, saltBytes, iterations) {
21943
- var ui1 = hmacSha256(password, Buffer.concat([saltBytes, Buffer.from([0, 0, 0, 1])]));
21944
- var ui = ui1;
21945
- for (var i = 0; i < iterations - 1; i++) {
21946
- ui1 = hmacSha256(password, ui1);
21947
- ui = xorBuffers(ui, ui1);
21948
- }
21949
- return ui;
21950
- }
21951
22048
  module2.exports = {
21952
22049
  startSession,
21953
22050
  continueSession,
@@ -21956,303 +22053,9 @@ var require_sasl = __commonJS({
21956
22053
  }
21957
22054
  });
21958
22055
 
21959
- // node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js
21960
- var require_split2 = __commonJS({
21961
- "node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js"(exports, module2) {
21962
- "use strict";
21963
- var { Transform: Transform2 } = require("stream");
21964
- var { StringDecoder } = require("string_decoder");
21965
- var kLast = Symbol("last");
21966
- var kDecoder = Symbol("decoder");
21967
- function transform(chunk, enc, cb) {
21968
- let list;
21969
- if (this.overflow) {
21970
- const buf = this[kDecoder].write(chunk);
21971
- list = buf.split(this.matcher);
21972
- if (list.length === 1)
21973
- return cb();
21974
- list.shift();
21975
- this.overflow = false;
21976
- } else {
21977
- this[kLast] += this[kDecoder].write(chunk);
21978
- list = this[kLast].split(this.matcher);
21979
- }
21980
- this[kLast] = list.pop();
21981
- for (let i = 0; i < list.length; i++) {
21982
- try {
21983
- push(this, this.mapper(list[i]));
21984
- } catch (error2) {
21985
- return cb(error2);
21986
- }
21987
- }
21988
- this.overflow = this[kLast].length > this.maxLength;
21989
- if (this.overflow && !this.skipOverflow) {
21990
- cb(new Error("maximum buffer reached"));
21991
- return;
21992
- }
21993
- cb();
21994
- }
21995
- function flush(cb) {
21996
- this[kLast] += this[kDecoder].end();
21997
- if (this[kLast]) {
21998
- try {
21999
- push(this, this.mapper(this[kLast]));
22000
- } catch (error2) {
22001
- return cb(error2);
22002
- }
22003
- }
22004
- cb();
22005
- }
22006
- function push(self2, val) {
22007
- if (val !== void 0) {
22008
- self2.push(val);
22009
- }
22010
- }
22011
- function noop2(incoming) {
22012
- return incoming;
22013
- }
22014
- function split(matcher, mapper, options) {
22015
- matcher = matcher || /\r?\n/;
22016
- mapper = mapper || noop2;
22017
- options = options || {};
22018
- switch (arguments.length) {
22019
- case 1:
22020
- if (typeof matcher === "function") {
22021
- mapper = matcher;
22022
- matcher = /\r?\n/;
22023
- } else if (typeof matcher === "object" && !(matcher instanceof RegExp) && !matcher[Symbol.split]) {
22024
- options = matcher;
22025
- matcher = /\r?\n/;
22026
- }
22027
- break;
22028
- case 2:
22029
- if (typeof matcher === "function") {
22030
- options = mapper;
22031
- mapper = matcher;
22032
- matcher = /\r?\n/;
22033
- } else if (typeof mapper === "object") {
22034
- options = mapper;
22035
- mapper = noop2;
22036
- }
22037
- }
22038
- options = Object.assign({}, options);
22039
- options.autoDestroy = true;
22040
- options.transform = transform;
22041
- options.flush = flush;
22042
- options.readableObjectMode = true;
22043
- const stream = new Transform2(options);
22044
- stream[kLast] = "";
22045
- stream[kDecoder] = new StringDecoder("utf8");
22046
- stream.matcher = matcher;
22047
- stream.mapper = mapper;
22048
- stream.maxLength = options.maxLength;
22049
- stream.skipOverflow = options.skipOverflow || false;
22050
- stream.overflow = false;
22051
- stream._destroy = function(err2, cb) {
22052
- this._writableState.errorEmitted = false;
22053
- cb(err2);
22054
- };
22055
- return stream;
22056
- }
22057
- module2.exports = split;
22058
- }
22059
- });
22060
-
22061
- // node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js
22062
- var require_helper = __commonJS({
22063
- "node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js"(exports, module2) {
22064
- "use strict";
22065
- var path4 = require("path");
22066
- var Stream = require("stream").Stream;
22067
- var split = require_split2();
22068
- var util2 = require("util");
22069
- var defaultPort = 5432;
22070
- var isWin = process.platform === "win32";
22071
- var warnStream = process.stderr;
22072
- var S_IRWXG = 56;
22073
- var S_IRWXO = 7;
22074
- var S_IFMT = 61440;
22075
- var S_IFREG = 32768;
22076
- function isRegFile(mode) {
22077
- return (mode & S_IFMT) == S_IFREG;
22078
- }
22079
- var fieldNames = ["host", "port", "database", "user", "password"];
22080
- var nrOfFields = fieldNames.length;
22081
- var passKey = fieldNames[nrOfFields - 1];
22082
- function warn() {
22083
- var isWritable = warnStream instanceof Stream && true === warnStream.writable;
22084
- if (isWritable) {
22085
- var args = Array.prototype.slice.call(arguments).concat("\n");
22086
- warnStream.write(util2.format.apply(util2, args));
22087
- }
22088
- }
22089
- Object.defineProperty(module2.exports, "isWin", {
22090
- get: function() {
22091
- return isWin;
22092
- },
22093
- set: function(val) {
22094
- isWin = val;
22095
- }
22096
- });
22097
- module2.exports.warnTo = function(stream) {
22098
- var old = warnStream;
22099
- warnStream = stream;
22100
- return old;
22101
- };
22102
- module2.exports.getFileName = function(rawEnv) {
22103
- var env2 = rawEnv || process.env;
22104
- var file = env2.PGPASSFILE || (isWin ? path4.join(env2.APPDATA || "./", "postgresql", "pgpass.conf") : path4.join(env2.HOME || "./", ".pgpass"));
22105
- return file;
22106
- };
22107
- module2.exports.usePgPass = function(stats, fname) {
22108
- if (Object.prototype.hasOwnProperty.call(process.env, "PGPASSWORD")) {
22109
- return false;
22110
- }
22111
- if (isWin) {
22112
- return true;
22113
- }
22114
- fname = fname || "<unkn>";
22115
- if (!isRegFile(stats.mode)) {
22116
- warn('WARNING: password file "%s" is not a plain file', fname);
22117
- return false;
22118
- }
22119
- if (stats.mode & (S_IRWXG | S_IRWXO)) {
22120
- warn('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less', fname);
22121
- return false;
22122
- }
22123
- return true;
22124
- };
22125
- var matcher = module2.exports.match = function(connInfo, entry) {
22126
- return fieldNames.slice(0, -1).reduce(function(prev, field, idx) {
22127
- if (idx == 1) {
22128
- if (Number(connInfo[field] || defaultPort) === Number(entry[field])) {
22129
- return prev && true;
22130
- }
22131
- }
22132
- return prev && (entry[field] === "*" || entry[field] === connInfo[field]);
22133
- }, true);
22134
- };
22135
- module2.exports.getPassword = function(connInfo, stream, cb) {
22136
- var pass;
22137
- var lineStream = stream.pipe(split());
22138
- function onLine(line) {
22139
- var entry = parseLine(line);
22140
- if (entry && isValidEntry(entry) && matcher(connInfo, entry)) {
22141
- pass = entry[passKey];
22142
- lineStream.end();
22143
- }
22144
- }
22145
- var onEnd = function() {
22146
- stream.destroy();
22147
- cb(pass);
22148
- };
22149
- var onErr = function(err2) {
22150
- stream.destroy();
22151
- warn("WARNING: error on reading file: %s", err2);
22152
- cb(void 0);
22153
- };
22154
- stream.on("error", onErr);
22155
- lineStream.on("data", onLine).on("end", onEnd).on("error", onErr);
22156
- };
22157
- var parseLine = module2.exports.parseLine = function(line) {
22158
- if (line.length < 11 || line.match(/^\s+#/)) {
22159
- return null;
22160
- }
22161
- var curChar = "";
22162
- var prevChar = "";
22163
- var fieldIdx = 0;
22164
- var startIdx = 0;
22165
- var endIdx = 0;
22166
- var obj = {};
22167
- var isLastField = false;
22168
- var addToObj = function(idx, i0, i1) {
22169
- var field = line.substring(i0, i1);
22170
- if (!Object.hasOwnProperty.call(process.env, "PGPASS_NO_DEESCAPE")) {
22171
- field = field.replace(/\\([:\\])/g, "$1");
22172
- }
22173
- obj[fieldNames[idx]] = field;
22174
- };
22175
- for (var i = 0; i < line.length - 1; i += 1) {
22176
- curChar = line.charAt(i + 1);
22177
- prevChar = line.charAt(i);
22178
- isLastField = fieldIdx == nrOfFields - 1;
22179
- if (isLastField) {
22180
- addToObj(fieldIdx, startIdx);
22181
- break;
22182
- }
22183
- if (i >= 0 && curChar == ":" && prevChar !== "\\") {
22184
- addToObj(fieldIdx, startIdx, i + 1);
22185
- startIdx = i + 2;
22186
- fieldIdx += 1;
22187
- }
22188
- }
22189
- obj = Object.keys(obj).length === nrOfFields ? obj : null;
22190
- return obj;
22191
- };
22192
- var isValidEntry = module2.exports.isValidEntry = function(entry) {
22193
- var rules = {
22194
- // host
22195
- 0: function(x) {
22196
- return x.length > 0;
22197
- },
22198
- // port
22199
- 1: function(x) {
22200
- if (x === "*") {
22201
- return true;
22202
- }
22203
- x = Number(x);
22204
- return isFinite(x) && x > 0 && x < 9007199254740992 && Math.floor(x) === x;
22205
- },
22206
- // database
22207
- 2: function(x) {
22208
- return x.length > 0;
22209
- },
22210
- // username
22211
- 3: function(x) {
22212
- return x.length > 0;
22213
- },
22214
- // password
22215
- 4: function(x) {
22216
- return x.length > 0;
22217
- }
22218
- };
22219
- for (var idx = 0; idx < fieldNames.length; idx += 1) {
22220
- var rule = rules[idx];
22221
- var value = entry[fieldNames[idx]] || "";
22222
- var res = rule(value);
22223
- if (!res) {
22224
- return false;
22225
- }
22226
- }
22227
- return true;
22228
- };
22229
- }
22230
- });
22231
-
22232
- // node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js
22233
- var require_lib = __commonJS({
22234
- "node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module2) {
22235
- "use strict";
22236
- var path4 = require("path");
22237
- var fs8 = require("fs");
22238
- var helper = require_helper();
22239
- module2.exports = function(connInfo, cb) {
22240
- var file = helper.getFileName();
22241
- fs8.stat(file, function(err2, stat) {
22242
- if (err2 || !helper.usePgPass(stat, file)) {
22243
- return cb(void 0);
22244
- }
22245
- var st = fs8.createReadStream(file);
22246
- helper.getPassword(connInfo, st, cb);
22247
- });
22248
- };
22249
- module2.exports.warnTo = helper.warnTo;
22250
- }
22251
- });
22252
-
22253
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/type-overrides.js
22056
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/type-overrides.js
22254
22057
  var require_type_overrides = __commonJS({
22255
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/type-overrides.js"(exports, module2) {
22058
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/type-overrides.js"(exports, module2) {
22256
22059
  "use strict";
22257
22060
  var types = require_pg_types();
22258
22061
  function TypeOverrides(userTypes) {
@@ -22370,9 +22173,9 @@ var require_pg_connection_string = __commonJS({
22370
22173
  }
22371
22174
  });
22372
22175
 
22373
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/connection-parameters.js
22176
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/connection-parameters.js
22374
22177
  var require_connection_parameters = __commonJS({
22375
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/connection-parameters.js"(exports, module2) {
22178
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/connection-parameters.js"(exports, module2) {
22376
22179
  "use strict";
22377
22180
  var dns = require("dns");
22378
22181
  var defaults3 = require_defaults();
@@ -22509,9 +22312,9 @@ var require_connection_parameters = __commonJS({
22509
22312
  }
22510
22313
  });
22511
22314
 
22512
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/result.js
22315
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/result.js
22513
22316
  var require_result = __commonJS({
22514
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/result.js"(exports, module2) {
22317
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/result.js"(exports, module2) {
22515
22318
  "use strict";
22516
22319
  var types = require_pg_types();
22517
22320
  var matchRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;
@@ -22529,6 +22332,7 @@ var require_result = __commonJS({
22529
22332
  if (this.rowAsArray) {
22530
22333
  this.parseRow = this._parseRowAsArray;
22531
22334
  }
22335
+ this._prebuiltEmptyResultObject = null;
22532
22336
  }
22533
22337
  // adds a command complete message
22534
22338
  addCommandComplete(msg) {
@@ -22561,14 +22365,12 @@ var require_result = __commonJS({
22561
22365
  return row;
22562
22366
  }
22563
22367
  parseRow(rowData) {
22564
- var row = {};
22368
+ var row = { ...this._prebuiltEmptyResultObject };
22565
22369
  for (var i = 0, len = rowData.length; i < len; i++) {
22566
22370
  var rawValue = rowData[i];
22567
22371
  var field = this.fields[i].name;
22568
22372
  if (rawValue !== null) {
22569
22373
  row[field] = this._parsers[i](rawValue);
22570
- } else {
22571
- row[field] = null;
22572
22374
  }
22573
22375
  }
22574
22376
  return row;
@@ -22589,15 +22391,23 @@ var require_result = __commonJS({
22589
22391
  this._parsers[i] = types.getTypeParser(desc.dataTypeID, desc.format || "text");
22590
22392
  }
22591
22393
  }
22394
+ this._createPrebuiltEmptyResultObject();
22395
+ }
22396
+ _createPrebuiltEmptyResultObject() {
22397
+ var row = {};
22398
+ for (var i = 0; i < this.fields.length; i++) {
22399
+ row[this.fields[i].name] = null;
22400
+ }
22401
+ this._prebuiltEmptyResultObject = { ...row };
22592
22402
  }
22593
22403
  };
22594
22404
  module2.exports = Result;
22595
22405
  }
22596
22406
  });
22597
22407
 
22598
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/query.js
22408
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/query.js
22599
22409
  var require_query = __commonJS({
22600
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/query.js"(exports, module2) {
22410
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/query.js"(exports, module2) {
22601
22411
  "use strict";
22602
22412
  var { EventEmitter } = require("events");
22603
22413
  var Result = require_result();
@@ -23623,13 +23433,50 @@ var require_dist = __commonJS({
23623
23433
  }
23624
23434
  });
23625
23435
 
23626
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/connection.js
23436
+ // node_modules/.pnpm/pg-cloudflare@1.1.1/node_modules/pg-cloudflare/dist/empty.js
23437
+ var empty_exports = {};
23438
+ __export(empty_exports, {
23439
+ default: () => empty_default
23440
+ });
23441
+ var empty_default;
23442
+ var init_empty = __esm({
23443
+ "node_modules/.pnpm/pg-cloudflare@1.1.1/node_modules/pg-cloudflare/dist/empty.js"() {
23444
+ empty_default = {};
23445
+ }
23446
+ });
23447
+
23448
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/stream.js
23449
+ var require_stream = __commonJS({
23450
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/stream.js"(exports, module2) {
23451
+ module2.exports.getStream = function getStream(ssl) {
23452
+ const net = require("net");
23453
+ if (typeof net.Socket === "function") {
23454
+ return new net.Socket();
23455
+ } else {
23456
+ const { CloudflareSocket } = (init_empty(), __toCommonJS(empty_exports));
23457
+ return new CloudflareSocket(ssl);
23458
+ }
23459
+ };
23460
+ module2.exports.getSecureStream = function getSecureStream(options) {
23461
+ var tls = require("tls");
23462
+ if (tls.connect) {
23463
+ return tls.connect(options);
23464
+ } else {
23465
+ options.socket.startTls(options);
23466
+ return options.socket;
23467
+ }
23468
+ };
23469
+ }
23470
+ });
23471
+
23472
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/connection.js
23627
23473
  var require_connection = __commonJS({
23628
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/connection.js"(exports, module2) {
23474
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/connection.js"(exports, module2) {
23629
23475
  "use strict";
23630
23476
  var net = require("net");
23631
23477
  var EventEmitter = require("events").EventEmitter;
23632
23478
  var { parse, serialize } = require_dist();
23479
+ var { getStream, getSecureStream } = require_stream();
23633
23480
  var flushBuffer = serialize.flush();
23634
23481
  var syncBuffer = serialize.sync();
23635
23482
  var endBuffer = serialize.end();
@@ -23637,7 +23484,10 @@ var require_connection = __commonJS({
23637
23484
  constructor(config) {
23638
23485
  super();
23639
23486
  config = config || {};
23640
- this.stream = config.stream || new net.Socket();
23487
+ this.stream = config.stream || getStream(config.ssl);
23488
+ if (typeof this.stream === "function") {
23489
+ this.stream = this.stream(config);
23490
+ }
23641
23491
  this._keepAlive = config.keepAlive;
23642
23492
  this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis;
23643
23493
  this.lastBuffer = false;
@@ -23688,7 +23538,6 @@ var require_connection = __commonJS({
23688
23538
  self2.stream.end();
23689
23539
  return self2.emit("error", new Error("There was an error establishing an SSL connection"));
23690
23540
  }
23691
- var tls = require("tls");
23692
23541
  const options = {
23693
23542
  socket: self2.stream
23694
23543
  };
@@ -23698,11 +23547,12 @@ var require_connection = __commonJS({
23698
23547
  options.key = self2.ssl.key;
23699
23548
  }
23700
23549
  }
23701
- if (net.isIP(host) === 0) {
23550
+ var net2 = require("net");
23551
+ if (net2.isIP && net2.isIP(host) === 0) {
23702
23552
  options.servername = host;
23703
23553
  }
23704
23554
  try {
23705
- self2.stream = tls.connect(options);
23555
+ self2.stream = getSecureStream(options);
23706
23556
  } catch (err2) {
23707
23557
  return self2.emit("error", err2);
23708
23558
  }
@@ -23712,9 +23562,6 @@ var require_connection = __commonJS({
23712
23562
  });
23713
23563
  }
23714
23564
  attachListeners(stream) {
23715
- stream.on("end", () => {
23716
- this.emit("end");
23717
- });
23718
23565
  parse(stream, (msg) => {
23719
23566
  var eventName = msg.name === "error" ? "errorMessage" : msg.name;
23720
23567
  if (this._emitMessage) {
@@ -23769,7 +23616,6 @@ var require_connection = __commonJS({
23769
23616
  }
23770
23617
  sync() {
23771
23618
  this._ending = true;
23772
- this._send(flushBuffer);
23773
23619
  this._send(syncBuffer);
23774
23620
  }
23775
23621
  ref() {
@@ -23808,20 +23654,313 @@ var require_connection = __commonJS({
23808
23654
  }
23809
23655
  });
23810
23656
 
23811
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/client.js
23657
+ // node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js
23658
+ var require_split2 = __commonJS({
23659
+ "node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js"(exports, module2) {
23660
+ "use strict";
23661
+ var { Transform: Transform2 } = require("stream");
23662
+ var { StringDecoder } = require("string_decoder");
23663
+ var kLast = Symbol("last");
23664
+ var kDecoder = Symbol("decoder");
23665
+ function transform(chunk, enc, cb) {
23666
+ let list;
23667
+ if (this.overflow) {
23668
+ const buf = this[kDecoder].write(chunk);
23669
+ list = buf.split(this.matcher);
23670
+ if (list.length === 1)
23671
+ return cb();
23672
+ list.shift();
23673
+ this.overflow = false;
23674
+ } else {
23675
+ this[kLast] += this[kDecoder].write(chunk);
23676
+ list = this[kLast].split(this.matcher);
23677
+ }
23678
+ this[kLast] = list.pop();
23679
+ for (let i = 0; i < list.length; i++) {
23680
+ try {
23681
+ push(this, this.mapper(list[i]));
23682
+ } catch (error2) {
23683
+ return cb(error2);
23684
+ }
23685
+ }
23686
+ this.overflow = this[kLast].length > this.maxLength;
23687
+ if (this.overflow && !this.skipOverflow) {
23688
+ cb(new Error("maximum buffer reached"));
23689
+ return;
23690
+ }
23691
+ cb();
23692
+ }
23693
+ function flush(cb) {
23694
+ this[kLast] += this[kDecoder].end();
23695
+ if (this[kLast]) {
23696
+ try {
23697
+ push(this, this.mapper(this[kLast]));
23698
+ } catch (error2) {
23699
+ return cb(error2);
23700
+ }
23701
+ }
23702
+ cb();
23703
+ }
23704
+ function push(self2, val) {
23705
+ if (val !== void 0) {
23706
+ self2.push(val);
23707
+ }
23708
+ }
23709
+ function noop2(incoming) {
23710
+ return incoming;
23711
+ }
23712
+ function split(matcher, mapper, options) {
23713
+ matcher = matcher || /\r?\n/;
23714
+ mapper = mapper || noop2;
23715
+ options = options || {};
23716
+ switch (arguments.length) {
23717
+ case 1:
23718
+ if (typeof matcher === "function") {
23719
+ mapper = matcher;
23720
+ matcher = /\r?\n/;
23721
+ } else if (typeof matcher === "object" && !(matcher instanceof RegExp) && !matcher[Symbol.split]) {
23722
+ options = matcher;
23723
+ matcher = /\r?\n/;
23724
+ }
23725
+ break;
23726
+ case 2:
23727
+ if (typeof matcher === "function") {
23728
+ options = mapper;
23729
+ mapper = matcher;
23730
+ matcher = /\r?\n/;
23731
+ } else if (typeof mapper === "object") {
23732
+ options = mapper;
23733
+ mapper = noop2;
23734
+ }
23735
+ }
23736
+ options = Object.assign({}, options);
23737
+ options.autoDestroy = true;
23738
+ options.transform = transform;
23739
+ options.flush = flush;
23740
+ options.readableObjectMode = true;
23741
+ const stream = new Transform2(options);
23742
+ stream[kLast] = "";
23743
+ stream[kDecoder] = new StringDecoder("utf8");
23744
+ stream.matcher = matcher;
23745
+ stream.mapper = mapper;
23746
+ stream.maxLength = options.maxLength;
23747
+ stream.skipOverflow = options.skipOverflow || false;
23748
+ stream.overflow = false;
23749
+ stream._destroy = function(err2, cb) {
23750
+ this._writableState.errorEmitted = false;
23751
+ cb(err2);
23752
+ };
23753
+ return stream;
23754
+ }
23755
+ module2.exports = split;
23756
+ }
23757
+ });
23758
+
23759
+ // node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js
23760
+ var require_helper = __commonJS({
23761
+ "node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js"(exports, module2) {
23762
+ "use strict";
23763
+ var path4 = require("path");
23764
+ var Stream = require("stream").Stream;
23765
+ var split = require_split2();
23766
+ var util2 = require("util");
23767
+ var defaultPort = 5432;
23768
+ var isWin = process.platform === "win32";
23769
+ var warnStream = process.stderr;
23770
+ var S_IRWXG = 56;
23771
+ var S_IRWXO = 7;
23772
+ var S_IFMT = 61440;
23773
+ var S_IFREG = 32768;
23774
+ function isRegFile(mode) {
23775
+ return (mode & S_IFMT) == S_IFREG;
23776
+ }
23777
+ var fieldNames = ["host", "port", "database", "user", "password"];
23778
+ var nrOfFields = fieldNames.length;
23779
+ var passKey = fieldNames[nrOfFields - 1];
23780
+ function warn() {
23781
+ var isWritable = warnStream instanceof Stream && true === warnStream.writable;
23782
+ if (isWritable) {
23783
+ var args = Array.prototype.slice.call(arguments).concat("\n");
23784
+ warnStream.write(util2.format.apply(util2, args));
23785
+ }
23786
+ }
23787
+ Object.defineProperty(module2.exports, "isWin", {
23788
+ get: function() {
23789
+ return isWin;
23790
+ },
23791
+ set: function(val) {
23792
+ isWin = val;
23793
+ }
23794
+ });
23795
+ module2.exports.warnTo = function(stream) {
23796
+ var old = warnStream;
23797
+ warnStream = stream;
23798
+ return old;
23799
+ };
23800
+ module2.exports.getFileName = function(rawEnv) {
23801
+ var env2 = rawEnv || process.env;
23802
+ var file = env2.PGPASSFILE || (isWin ? path4.join(env2.APPDATA || "./", "postgresql", "pgpass.conf") : path4.join(env2.HOME || "./", ".pgpass"));
23803
+ return file;
23804
+ };
23805
+ module2.exports.usePgPass = function(stats, fname) {
23806
+ if (Object.prototype.hasOwnProperty.call(process.env, "PGPASSWORD")) {
23807
+ return false;
23808
+ }
23809
+ if (isWin) {
23810
+ return true;
23811
+ }
23812
+ fname = fname || "<unkn>";
23813
+ if (!isRegFile(stats.mode)) {
23814
+ warn('WARNING: password file "%s" is not a plain file', fname);
23815
+ return false;
23816
+ }
23817
+ if (stats.mode & (S_IRWXG | S_IRWXO)) {
23818
+ warn('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less', fname);
23819
+ return false;
23820
+ }
23821
+ return true;
23822
+ };
23823
+ var matcher = module2.exports.match = function(connInfo, entry) {
23824
+ return fieldNames.slice(0, -1).reduce(function(prev, field, idx) {
23825
+ if (idx == 1) {
23826
+ if (Number(connInfo[field] || defaultPort) === Number(entry[field])) {
23827
+ return prev && true;
23828
+ }
23829
+ }
23830
+ return prev && (entry[field] === "*" || entry[field] === connInfo[field]);
23831
+ }, true);
23832
+ };
23833
+ module2.exports.getPassword = function(connInfo, stream, cb) {
23834
+ var pass;
23835
+ var lineStream = stream.pipe(split());
23836
+ function onLine(line) {
23837
+ var entry = parseLine(line);
23838
+ if (entry && isValidEntry(entry) && matcher(connInfo, entry)) {
23839
+ pass = entry[passKey];
23840
+ lineStream.end();
23841
+ }
23842
+ }
23843
+ var onEnd = function() {
23844
+ stream.destroy();
23845
+ cb(pass);
23846
+ };
23847
+ var onErr = function(err2) {
23848
+ stream.destroy();
23849
+ warn("WARNING: error on reading file: %s", err2);
23850
+ cb(void 0);
23851
+ };
23852
+ stream.on("error", onErr);
23853
+ lineStream.on("data", onLine).on("end", onEnd).on("error", onErr);
23854
+ };
23855
+ var parseLine = module2.exports.parseLine = function(line) {
23856
+ if (line.length < 11 || line.match(/^\s+#/)) {
23857
+ return null;
23858
+ }
23859
+ var curChar = "";
23860
+ var prevChar = "";
23861
+ var fieldIdx = 0;
23862
+ var startIdx = 0;
23863
+ var endIdx = 0;
23864
+ var obj = {};
23865
+ var isLastField = false;
23866
+ var addToObj = function(idx, i0, i1) {
23867
+ var field = line.substring(i0, i1);
23868
+ if (!Object.hasOwnProperty.call(process.env, "PGPASS_NO_DEESCAPE")) {
23869
+ field = field.replace(/\\([:\\])/g, "$1");
23870
+ }
23871
+ obj[fieldNames[idx]] = field;
23872
+ };
23873
+ for (var i = 0; i < line.length - 1; i += 1) {
23874
+ curChar = line.charAt(i + 1);
23875
+ prevChar = line.charAt(i);
23876
+ isLastField = fieldIdx == nrOfFields - 1;
23877
+ if (isLastField) {
23878
+ addToObj(fieldIdx, startIdx);
23879
+ break;
23880
+ }
23881
+ if (i >= 0 && curChar == ":" && prevChar !== "\\") {
23882
+ addToObj(fieldIdx, startIdx, i + 1);
23883
+ startIdx = i + 2;
23884
+ fieldIdx += 1;
23885
+ }
23886
+ }
23887
+ obj = Object.keys(obj).length === nrOfFields ? obj : null;
23888
+ return obj;
23889
+ };
23890
+ var isValidEntry = module2.exports.isValidEntry = function(entry) {
23891
+ var rules = {
23892
+ // host
23893
+ 0: function(x) {
23894
+ return x.length > 0;
23895
+ },
23896
+ // port
23897
+ 1: function(x) {
23898
+ if (x === "*") {
23899
+ return true;
23900
+ }
23901
+ x = Number(x);
23902
+ return isFinite(x) && x > 0 && x < 9007199254740992 && Math.floor(x) === x;
23903
+ },
23904
+ // database
23905
+ 2: function(x) {
23906
+ return x.length > 0;
23907
+ },
23908
+ // username
23909
+ 3: function(x) {
23910
+ return x.length > 0;
23911
+ },
23912
+ // password
23913
+ 4: function(x) {
23914
+ return x.length > 0;
23915
+ }
23916
+ };
23917
+ for (var idx = 0; idx < fieldNames.length; idx += 1) {
23918
+ var rule = rules[idx];
23919
+ var value = entry[fieldNames[idx]] || "";
23920
+ var res = rule(value);
23921
+ if (!res) {
23922
+ return false;
23923
+ }
23924
+ }
23925
+ return true;
23926
+ };
23927
+ }
23928
+ });
23929
+
23930
+ // node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js
23931
+ var require_lib = __commonJS({
23932
+ "node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module2) {
23933
+ "use strict";
23934
+ var path4 = require("path");
23935
+ var fs8 = require("fs");
23936
+ var helper = require_helper();
23937
+ module2.exports = function(connInfo, cb) {
23938
+ var file = helper.getFileName();
23939
+ fs8.stat(file, function(err2, stat) {
23940
+ if (err2 || !helper.usePgPass(stat, file)) {
23941
+ return cb(void 0);
23942
+ }
23943
+ var st = fs8.createReadStream(file);
23944
+ helper.getPassword(connInfo, st, cb);
23945
+ });
23946
+ };
23947
+ module2.exports.warnTo = helper.warnTo;
23948
+ }
23949
+ });
23950
+
23951
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/client.js
23812
23952
  var require_client = __commonJS({
23813
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/client.js"(exports, module2) {
23953
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/client.js"(exports, module2) {
23814
23954
  "use strict";
23815
23955
  var EventEmitter = require("events").EventEmitter;
23816
- var util2 = require("util");
23817
23956
  var utils = require_utils2();
23818
23957
  var sasl = require_sasl();
23819
- var pgPass = require_lib();
23820
23958
  var TypeOverrides = require_type_overrides();
23821
23959
  var ConnectionParameters = require_connection_parameters();
23822
23960
  var Query = require_query();
23823
23961
  var defaults3 = require_defaults();
23824
23962
  var Connection2 = require_connection();
23963
+ var crypto = require_utils3();
23825
23964
  var Client2 = class extends EventEmitter {
23826
23965
  constructor(config) {
23827
23966
  super();
@@ -23841,6 +23980,7 @@ var require_client = __commonJS({
23841
23980
  this._Promise = c.Promise || global.Promise;
23842
23981
  this._types = new TypeOverrides(c.types);
23843
23982
  this._ending = false;
23983
+ this._ended = false;
23844
23984
  this._connecting = false;
23845
23985
  this._connected = false;
23846
23986
  this._connectionError = false;
@@ -23916,6 +24056,7 @@ var require_client = __commonJS({
23916
24056
  const error2 = this._ending ? new Error("Connection terminated") : new Error("Connection terminated unexpectedly");
23917
24057
  clearTimeout(this.connectionTimeoutHandle);
23918
24058
  this._errorAllQueries(error2);
24059
+ this._ended = true;
23919
24060
  if (!this._ending) {
23920
24061
  if (this._connecting && !this._connectionError) {
23921
24062
  if (this._connectionCallback) {
@@ -23990,12 +24131,17 @@ var require_client = __commonJS({
23990
24131
  } else if (this.password !== null) {
23991
24132
  cb();
23992
24133
  } else {
23993
- pgPass(this.connectionParameters, (pass) => {
23994
- if (void 0 !== pass) {
23995
- this.connectionParameters.password = this.password = pass;
23996
- }
23997
- cb();
23998
- });
24134
+ try {
24135
+ const pgPass = require_lib();
24136
+ pgPass(this.connectionParameters, (pass) => {
24137
+ if (void 0 !== pass) {
24138
+ this.connectionParameters.password = this.password = pass;
24139
+ }
24140
+ cb();
24141
+ });
24142
+ } catch (e) {
24143
+ this.emit("error", e);
24144
+ }
23999
24145
  }
24000
24146
  }
24001
24147
  _handleAuthCleartextPassword(msg) {
@@ -24004,24 +24150,40 @@ var require_client = __commonJS({
24004
24150
  });
24005
24151
  }
24006
24152
  _handleAuthMD5Password(msg) {
24007
- this._checkPgPass(() => {
24008
- const hashedPassword = utils.postgresMd5PasswordHash(this.user, this.password, msg.salt);
24009
- this.connection.password(hashedPassword);
24153
+ this._checkPgPass(async () => {
24154
+ try {
24155
+ const hashedPassword = await crypto.postgresMd5PasswordHash(this.user, this.password, msg.salt);
24156
+ this.connection.password(hashedPassword);
24157
+ } catch (e) {
24158
+ this.emit("error", e);
24159
+ }
24010
24160
  });
24011
24161
  }
24012
24162
  _handleAuthSASL(msg) {
24013
24163
  this._checkPgPass(() => {
24014
- this.saslSession = sasl.startSession(msg.mechanisms);
24015
- this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response);
24164
+ try {
24165
+ this.saslSession = sasl.startSession(msg.mechanisms);
24166
+ this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response);
24167
+ } catch (err2) {
24168
+ this.connection.emit("error", err2);
24169
+ }
24016
24170
  });
24017
24171
  }
24018
- _handleAuthSASLContinue(msg) {
24019
- sasl.continueSession(this.saslSession, this.password, msg.data);
24020
- this.connection.sendSCRAMClientFinalMessage(this.saslSession.response);
24172
+ async _handleAuthSASLContinue(msg) {
24173
+ try {
24174
+ await sasl.continueSession(this.saslSession, this.password, msg.data);
24175
+ this.connection.sendSCRAMClientFinalMessage(this.saslSession.response);
24176
+ } catch (err2) {
24177
+ this.connection.emit("error", err2);
24178
+ }
24021
24179
  }
24022
24180
  _handleAuthSASLFinal(msg) {
24023
- sasl.finalizeSession(this.saslSession, msg.data);
24024
- this.saslSession = null;
24181
+ try {
24182
+ sasl.finalizeSession(this.saslSession, msg.data);
24183
+ this.saslSession = null;
24184
+ } catch (err2) {
24185
+ this.connection.emit("error", err2);
24186
+ }
24025
24187
  }
24026
24188
  _handleBackendKeyData(msg) {
24027
24189
  this.processID = msg.processID;
@@ -24163,30 +24325,14 @@ var require_client = __commonJS({
24163
24325
  getTypeParser(oid, format) {
24164
24326
  return this._types.getTypeParser(oid, format);
24165
24327
  }
24166
- // Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
24328
+ // escapeIdentifier and escapeLiteral moved to utility functions & exported
24329
+ // on PG
24330
+ // re-exported here for backwards compatibility
24167
24331
  escapeIdentifier(str) {
24168
- return '"' + str.replace(/"/g, '""') + '"';
24332
+ return utils.escapeIdentifier(str);
24169
24333
  }
24170
- // Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
24171
24334
  escapeLiteral(str) {
24172
- var hasBackslash = false;
24173
- var escaped = "'";
24174
- for (var i = 0; i < str.length; i++) {
24175
- var c = str[i];
24176
- if (c === "'") {
24177
- escaped += c + c;
24178
- } else if (c === "\\") {
24179
- escaped += c + c;
24180
- hasBackslash = true;
24181
- } else {
24182
- escaped += c;
24183
- }
24184
- }
24185
- escaped += "'";
24186
- if (hasBackslash === true) {
24187
- escaped = " E" + escaped;
24188
- }
24189
- return escaped;
24335
+ return utils.escapeLiteral(str);
24190
24336
  }
24191
24337
  _pulseQueryQueue() {
24192
24338
  if (this.readyForQuery === true) {
@@ -24228,6 +24374,9 @@ var require_client = __commonJS({
24228
24374
  if (!query.callback) {
24229
24375
  result = new this._Promise((resolve2, reject) => {
24230
24376
  query.callback = (err2, res) => err2 ? reject(err2) : resolve2(res);
24377
+ }).catch((err2) => {
24378
+ Error.captureStackTrace(err2);
24379
+ throw err2;
24231
24380
  });
24232
24381
  }
24233
24382
  }
@@ -24282,7 +24431,7 @@ var require_client = __commonJS({
24282
24431
  }
24283
24432
  end(cb) {
24284
24433
  this._ending = true;
24285
- if (!this.connection._connecting) {
24434
+ if (!this.connection._connecting || this._ended) {
24286
24435
  if (cb) {
24287
24436
  cb();
24288
24437
  } else {
@@ -24308,9 +24457,9 @@ var require_client = __commonJS({
24308
24457
  }
24309
24458
  });
24310
24459
 
24311
- // node_modules/.pnpm/pg-pool@3.6.1_pg@8.8.0/node_modules/pg-pool/index.js
24460
+ // node_modules/.pnpm/pg-pool@3.6.1_pg@8.11.3/node_modules/pg-pool/index.js
24312
24461
  var require_pg_pool = __commonJS({
24313
- "node_modules/.pnpm/pg-pool@3.6.1_pg@8.8.0/node_modules/pg-pool/index.js"(exports, module2) {
24462
+ "node_modules/.pnpm/pg-pool@3.6.1_pg@8.11.3/node_modules/pg-pool/index.js"(exports, module2) {
24314
24463
  "use strict";
24315
24464
  var EventEmitter = require("events").EventEmitter;
24316
24465
  var NOOP = function() {
@@ -24691,72 +24840,9 @@ var require_pg_pool = __commonJS({
24691
24840
  }
24692
24841
  });
24693
24842
 
24694
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/package.json
24695
- var require_package = __commonJS({
24696
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/package.json"(exports, module2) {
24697
- module2.exports = {
24698
- name: "pg",
24699
- version: "8.8.0",
24700
- description: "PostgreSQL client - pure javascript & libpq with the same API",
24701
- keywords: [
24702
- "database",
24703
- "libpq",
24704
- "pg",
24705
- "postgre",
24706
- "postgres",
24707
- "postgresql",
24708
- "rdbms"
24709
- ],
24710
- homepage: "https://github.com/brianc/node-postgres",
24711
- repository: {
24712
- type: "git",
24713
- url: "git://github.com/brianc/node-postgres.git",
24714
- directory: "packages/pg"
24715
- },
24716
- author: "Brian Carlson <brian.m.carlson@gmail.com>",
24717
- main: "./lib",
24718
- dependencies: {
24719
- "buffer-writer": "2.0.0",
24720
- "packet-reader": "1.0.0",
24721
- "pg-connection-string": "^2.5.0",
24722
- "pg-pool": "^3.5.2",
24723
- "pg-protocol": "^1.5.0",
24724
- "pg-types": "^2.1.0",
24725
- pgpass: "1.x"
24726
- },
24727
- devDependencies: {
24728
- async: "2.6.4",
24729
- bluebird: "3.5.2",
24730
- co: "4.6.0",
24731
- "pg-copy-streams": "0.3.0"
24732
- },
24733
- peerDependencies: {
24734
- "pg-native": ">=3.0.1"
24735
- },
24736
- peerDependenciesMeta: {
24737
- "pg-native": {
24738
- optional: true
24739
- }
24740
- },
24741
- scripts: {
24742
- test: "make test-all"
24743
- },
24744
- files: [
24745
- "lib",
24746
- "SPONSORS.md"
24747
- ],
24748
- license: "MIT",
24749
- engines: {
24750
- node: ">= 8.0.0"
24751
- },
24752
- gitHead: "c99fb2c127ddf8d712500db2c7b9a5491a178655"
24753
- };
24754
- }
24755
- });
24756
-
24757
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/native/query.js
24843
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/native/query.js
24758
24844
  var require_query2 = __commonJS({
24759
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/native/query.js"(exports, module2) {
24845
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/native/query.js"(exports, module2) {
24760
24846
  "use strict";
24761
24847
  var EventEmitter = require("events").EventEmitter;
24762
24848
  var util2 = require("util");
@@ -24896,13 +24982,17 @@ var require_query2 = __commonJS({
24896
24982
  }
24897
24983
  });
24898
24984
 
24899
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/native/client.js
24985
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/native/client.js
24900
24986
  var require_client2 = __commonJS({
24901
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/native/client.js"(exports, module2) {
24987
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/native/client.js"(exports, module2) {
24902
24988
  "use strict";
24903
- var Native = require("pg-native");
24989
+ var Native;
24990
+ try {
24991
+ Native = require("pg-native");
24992
+ } catch (e) {
24993
+ throw e;
24994
+ }
24904
24995
  var TypeOverrides = require_type_overrides();
24905
- var pkg = require_package();
24906
24996
  var EventEmitter = require("events").EventEmitter;
24907
24997
  var util2 = require("util");
24908
24998
  var ConnectionParameters = require_connection_parameters();
@@ -24921,6 +25011,8 @@ var require_client2 = __commonJS({
24921
25011
  this._connected = false;
24922
25012
  this._queryable = true;
24923
25013
  var cp = this.connectionParameters = new ConnectionParameters(config);
25014
+ if (config.nativeConnectionString)
25015
+ cp.nativeConnectionString = config.nativeConnectionString;
24924
25016
  this.user = cp.user;
24925
25017
  Object.defineProperty(this, "password", {
24926
25018
  configurable: true,
@@ -24957,6 +25049,8 @@ var require_client2 = __commonJS({
24957
25049
  }
24958
25050
  this._connecting = true;
24959
25051
  this.connectionParameters.getLibpqConnectionString(function(err2, conString) {
25052
+ if (self2.connectionParameters.nativeConnectionString)
25053
+ conString = self2.connectionParameters.nativeConnectionString;
24960
25054
  if (err2)
24961
25055
  return cb(err2);
24962
25056
  self2.native.connect(conString, function(err3) {
@@ -25019,6 +25113,9 @@ var require_client2 = __commonJS({
25019
25113
  result = new this._Promise((resolve2, reject) => {
25020
25114
  resolveOut = resolve2;
25021
25115
  rejectOut = reject;
25116
+ }).catch((err2) => {
25117
+ Error.captureStackTrace(err2);
25118
+ throw err2;
25022
25119
  });
25023
25120
  query.callback = (err2, res) => err2 ? rejectOut(err2) : resolveOut(res);
25024
25121
  }
@@ -25129,23 +25226,24 @@ var require_client2 = __commonJS({
25129
25226
  }
25130
25227
  });
25131
25228
 
25132
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/native/index.js
25229
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/native/index.js
25133
25230
  var require_native = __commonJS({
25134
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/native/index.js"(exports, module2) {
25231
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/native/index.js"(exports, module2) {
25135
25232
  "use strict";
25136
25233
  module2.exports = require_client2();
25137
25234
  }
25138
25235
  });
25139
25236
 
25140
- // node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/index.js
25237
+ // node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/index.js
25141
25238
  var require_lib2 = __commonJS({
25142
- "node_modules/.pnpm/pg@8.8.0/node_modules/pg/lib/index.js"(exports, module2) {
25239
+ "node_modules/.pnpm/pg@8.11.3/node_modules/pg/lib/index.js"(exports, module2) {
25143
25240
  "use strict";
25144
25241
  var Client2 = require_client();
25145
25242
  var defaults3 = require_defaults();
25146
25243
  var Connection2 = require_connection();
25147
25244
  var Pool = require_pg_pool();
25148
25245
  var { DatabaseError } = require_dist();
25246
+ var { escapeIdentifier, escapeLiteral } = require_utils2();
25149
25247
  var poolFactory = (Client3) => {
25150
25248
  return class BoundPool extends Pool {
25151
25249
  constructor(options) {
@@ -25162,6 +25260,8 @@ var require_lib2 = __commonJS({
25162
25260
  this.Connection = Connection2;
25163
25261
  this.types = require_pg_types();
25164
25262
  this.DatabaseError = DatabaseError;
25263
+ this.escapeIdentifier = escapeIdentifier;
25264
+ this.escapeLiteral = escapeLiteral;
25165
25265
  };
25166
25266
  if (typeof process.env.NODE_PG_FORCE_NATIVE !== "undefined") {
25167
25267
  module2.exports = new PG(require_native());
@@ -25992,14 +26092,10 @@ var init_sqliteIntrospect = __esm({
25992
26092
  });
25993
26093
 
25994
26094
  // src/cli/utils.ts
25995
- var assertExists, assertPackages, requiredApiVersion, assertOrmCoreVersion, ormCoreVersions;
26095
+ var assertPackages, requiredApiVersion, assertOrmCoreVersion, ormCoreVersions;
25996
26096
  var init_utils3 = __esm({
25997
26097
  "src/cli/utils.ts"() {
25998
26098
  init_views();
25999
- assertExists = (it) => {
26000
- if (!it)
26001
- throw new Error();
26002
- };
26003
26099
  assertPackages = async (...pkgs) => {
26004
26100
  try {
26005
26101
  for (let i = 0; i < pkgs.length; i++) {
@@ -26013,7 +26109,7 @@ var init_utils3 = __esm({
26013
26109
  process.exit(1);
26014
26110
  }
26015
26111
  };
26016
- requiredApiVersion = 5;
26112
+ requiredApiVersion = 6;
26017
26113
  assertOrmCoreVersion = async () => {
26018
26114
  try {
26019
26115
  const { compatibilityVersion } = await import("drizzle-orm/version");
@@ -42636,9 +42732,12 @@ var init_session = __esm({
42636
42732
  };
42637
42733
  _a = import_drizzle_orm9.entityKind;
42638
42734
  SQLiteWranglerD1Session[_a] = "SQLiteD1Session";
42639
- PreparedQuery = class extends import_sqlite_core3.PreparedQuery {
42735
+ PreparedQuery = class extends import_sqlite_core3.SQLitePreparedQuery {
42640
42736
  constructor(stmt, configPath, dbName, queryString, params, logger, fields, executeMethod, customResultMapper) {
42641
- super("async", executeMethod);
42737
+ super("async", executeMethod, {
42738
+ sql: queryString,
42739
+ params
42740
+ });
42642
42741
  this.stmt = stmt;
42643
42742
  this.configPath = configPath;
42644
42743
  this.dbName = dbName;
@@ -42697,7 +42796,11 @@ var init_session = __esm({
42697
42796
  async values(placeholderValues) {
42698
42797
  const params = (0, import_drizzle_orm11.fillPlaceholders)(this.params, placeholderValues ?? {});
42699
42798
  this.logger.logQuery(this.queryString, params);
42700
- const wranglerRes = await this.stmt(this.queryString, this.configPath, this.dbName);
42799
+ const wranglerRes = await this.stmt(
42800
+ this.queryString,
42801
+ this.configPath,
42802
+ this.dbName
42803
+ );
42701
42804
  return this.d1ToRawMapping(wranglerRes.results);
42702
42805
  }
42703
42806
  };
@@ -44810,7 +44913,7 @@ var require_glob_parent = __commonJS({
44810
44913
  });
44811
44914
 
44812
44915
  // node_modules/.pnpm/braces@3.0.2/node_modules/braces/lib/utils.js
44813
- var require_utils3 = __commonJS({
44916
+ var require_utils4 = __commonJS({
44814
44917
  "node_modules/.pnpm/braces@3.0.2/node_modules/braces/lib/utils.js"(exports) {
44815
44918
  "use strict";
44816
44919
  exports.isInteger = (num) => {
@@ -44897,7 +45000,7 @@ var require_utils3 = __commonJS({
44897
45000
  var require_stringify = __commonJS({
44898
45001
  "node_modules/.pnpm/braces@3.0.2/node_modules/braces/lib/stringify.js"(exports, module2) {
44899
45002
  "use strict";
44900
- var utils = require_utils3();
45003
+ var utils = require_utils4();
44901
45004
  module2.exports = (ast, options = {}) => {
44902
45005
  let stringify = (node, parent = {}) => {
44903
45006
  let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
@@ -45363,7 +45466,7 @@ var require_compile = __commonJS({
45363
45466
  "node_modules/.pnpm/braces@3.0.2/node_modules/braces/lib/compile.js"(exports, module2) {
45364
45467
  "use strict";
45365
45468
  var fill = require_fill_range();
45366
- var utils = require_utils3();
45469
+ var utils = require_utils4();
45367
45470
  var compile = (ast, options = {}) => {
45368
45471
  let walk = (node, parent = {}) => {
45369
45472
  let invalidBlock = utils.isInvalidBrace(parent);
@@ -45415,7 +45518,7 @@ var require_expand = __commonJS({
45415
45518
  "use strict";
45416
45519
  var fill = require_fill_range();
45417
45520
  var stringify = require_stringify();
45418
- var utils = require_utils3();
45521
+ var utils = require_utils4();
45419
45522
  var append = (queue = "", stash = "", enclose = false) => {
45420
45523
  let result = [];
45421
45524
  queue = [].concat(queue);
@@ -46112,7 +46215,7 @@ var require_constants2 = __commonJS({
46112
46215
  });
46113
46216
 
46114
46217
  // node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
46115
- var require_utils4 = __commonJS({
46218
+ var require_utils5 = __commonJS({
46116
46219
  "node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js"(exports) {
46117
46220
  "use strict";
46118
46221
  var path4 = require("path");
@@ -46178,7 +46281,7 @@ var require_utils4 = __commonJS({
46178
46281
  var require_scan = __commonJS({
46179
46282
  "node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/scan.js"(exports, module2) {
46180
46283
  "use strict";
46181
- var utils = require_utils4();
46284
+ var utils = require_utils5();
46182
46285
  var {
46183
46286
  CHAR_ASTERISK,
46184
46287
  /* * */
@@ -46512,7 +46615,7 @@ var require_parse2 = __commonJS({
46512
46615
  "node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/parse.js"(exports, module2) {
46513
46616
  "use strict";
46514
46617
  var constants = require_constants2();
46515
- var utils = require_utils4();
46618
+ var utils = require_utils5();
46516
46619
  var {
46517
46620
  MAX_LENGTH,
46518
46621
  POSIX_REGEX_SOURCE,
@@ -47295,7 +47398,7 @@ var require_picomatch = __commonJS({
47295
47398
  var path4 = require("path");
47296
47399
  var scan = require_scan();
47297
47400
  var parse = require_parse2();
47298
- var utils = require_utils4();
47401
+ var utils = require_utils5();
47299
47402
  var constants = require_constants2();
47300
47403
  var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
47301
47404
  var picomatch = (glob2, options, returnState = false) => {
@@ -47447,7 +47550,7 @@ var require_micromatch = __commonJS({
47447
47550
  var util2 = require("util");
47448
47551
  var braces = require_braces();
47449
47552
  var picomatch = require_picomatch2();
47450
- var utils = require_utils4();
47553
+ var utils = require_utils5();
47451
47554
  var isEmptyString = (val) => val === "" || val === "./";
47452
47555
  var micromatch = (list, patterns, options) => {
47453
47556
  patterns = [].concat(patterns);
@@ -47751,7 +47854,7 @@ var require_pattern = __commonJS({
47751
47854
  });
47752
47855
 
47753
47856
  // node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/utils/stream.js
47754
- var require_stream = __commonJS({
47857
+ var require_stream2 = __commonJS({
47755
47858
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/utils/stream.js"(exports) {
47756
47859
  "use strict";
47757
47860
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -47791,7 +47894,7 @@ var require_string2 = __commonJS({
47791
47894
  });
47792
47895
 
47793
47896
  // node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/utils/index.js
47794
- var require_utils5 = __commonJS({
47897
+ var require_utils6 = __commonJS({
47795
47898
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/utils/index.js"(exports) {
47796
47899
  "use strict";
47797
47900
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -47806,7 +47909,7 @@ var require_utils5 = __commonJS({
47806
47909
  exports.path = path4;
47807
47910
  var pattern = require_pattern();
47808
47911
  exports.pattern = pattern;
47809
- var stream = require_stream();
47912
+ var stream = require_stream2();
47810
47913
  exports.stream = stream;
47811
47914
  var string = require_string2();
47812
47915
  exports.string = string;
@@ -47819,7 +47922,7 @@ var require_tasks = __commonJS({
47819
47922
  "use strict";
47820
47923
  Object.defineProperty(exports, "__esModule", { value: true });
47821
47924
  exports.convertPatternGroupToTask = exports.convertPatternGroupsToTasks = exports.groupPatternsByBaseDirectory = exports.getNegativePatternsAsPositive = exports.getPositivePatterns = exports.convertPatternsToTasks = exports.generate = void 0;
47822
- var utils = require_utils5();
47925
+ var utils = require_utils6();
47823
47926
  function generate(input, settings) {
47824
47927
  const patterns = processPatterns(input, settings);
47825
47928
  const ignore = processPatterns(settings.ignore, settings);
@@ -48165,7 +48268,7 @@ var require_fs3 = __commonJS({
48165
48268
  });
48166
48269
 
48167
48270
  // node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/utils/index.js
48168
- var require_utils6 = __commonJS({
48271
+ var require_utils7 = __commonJS({
48169
48272
  "node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/utils/index.js"(exports) {
48170
48273
  "use strict";
48171
48274
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -48200,7 +48303,7 @@ var require_async2 = __commonJS({
48200
48303
  var fsStat = require_out();
48201
48304
  var rpl = require_run_parallel();
48202
48305
  var constants_1 = require_constants3();
48203
- var utils = require_utils6();
48306
+ var utils = require_utils7();
48204
48307
  var common = require_common2();
48205
48308
  function read(directory, settings, callback) {
48206
48309
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
@@ -48309,7 +48412,7 @@ var require_sync2 = __commonJS({
48309
48412
  exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
48310
48413
  var fsStat = require_out();
48311
48414
  var constants_1 = require_constants3();
48312
- var utils = require_utils6();
48415
+ var utils = require_utils7();
48313
48416
  var common = require_common2();
48314
48417
  function read(directory, settings) {
48315
48418
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
@@ -48910,7 +49013,7 @@ var require_async4 = __commonJS({
48910
49013
  });
48911
49014
 
48912
49015
  // node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/stream.js
48913
- var require_stream2 = __commonJS({
49016
+ var require_stream3 = __commonJS({
48914
49017
  "node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/stream.js"(exports) {
48915
49018
  "use strict";
48916
49019
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -49073,7 +49176,7 @@ var require_out3 = __commonJS({
49073
49176
  Object.defineProperty(exports, "__esModule", { value: true });
49074
49177
  exports.Settings = exports.walkStream = exports.walkSync = exports.walk = void 0;
49075
49178
  var async_1 = require_async4();
49076
- var stream_1 = require_stream2();
49179
+ var stream_1 = require_stream3();
49077
49180
  var sync_1 = require_sync4();
49078
49181
  var settings_1 = require_settings3();
49079
49182
  exports.Settings = settings_1.default;
@@ -49113,7 +49216,7 @@ var require_reader2 = __commonJS({
49113
49216
  Object.defineProperty(exports, "__esModule", { value: true });
49114
49217
  var path4 = require("path");
49115
49218
  var fsStat = require_out();
49116
- var utils = require_utils5();
49219
+ var utils = require_utils6();
49117
49220
  var Reader = class {
49118
49221
  constructor(_settings) {
49119
49222
  this._settings = _settings;
@@ -49146,7 +49249,7 @@ var require_reader2 = __commonJS({
49146
49249
  });
49147
49250
 
49148
49251
  // node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/readers/stream.js
49149
- var require_stream3 = __commonJS({
49252
+ var require_stream4 = __commonJS({
49150
49253
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/readers/stream.js"(exports) {
49151
49254
  "use strict";
49152
49255
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -49209,7 +49312,7 @@ var require_async5 = __commonJS({
49209
49312
  Object.defineProperty(exports, "__esModule", { value: true });
49210
49313
  var fsWalk = require_out3();
49211
49314
  var reader_1 = require_reader2();
49212
- var stream_1 = require_stream3();
49315
+ var stream_1 = require_stream4();
49213
49316
  var ReaderAsync = class extends reader_1.default {
49214
49317
  constructor() {
49215
49318
  super(...arguments);
@@ -49246,7 +49349,7 @@ var require_matcher = __commonJS({
49246
49349
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/providers/matchers/matcher.js"(exports) {
49247
49350
  "use strict";
49248
49351
  Object.defineProperty(exports, "__esModule", { value: true });
49249
- var utils = require_utils5();
49352
+ var utils = require_utils6();
49250
49353
  var Matcher = class {
49251
49354
  constructor(_patterns, _settings, _micromatchOptions) {
49252
49355
  this._patterns = _patterns;
@@ -49334,7 +49437,7 @@ var require_deep = __commonJS({
49334
49437
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/providers/filters/deep.js"(exports) {
49335
49438
  "use strict";
49336
49439
  Object.defineProperty(exports, "__esModule", { value: true });
49337
- var utils = require_utils5();
49440
+ var utils = require_utils6();
49338
49441
  var partial_1 = require_partial();
49339
49442
  var DeepFilter = class {
49340
49443
  constructor(_settings, _micromatchOptions) {
@@ -49399,7 +49502,7 @@ var require_entry = __commonJS({
49399
49502
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/providers/filters/entry.js"(exports) {
49400
49503
  "use strict";
49401
49504
  Object.defineProperty(exports, "__esModule", { value: true });
49402
- var utils = require_utils5();
49505
+ var utils = require_utils6();
49403
49506
  var EntryFilter = class {
49404
49507
  constructor(_settings, _micromatchOptions) {
49405
49508
  this._settings = _settings;
@@ -49465,7 +49568,7 @@ var require_error = __commonJS({
49465
49568
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/providers/filters/error.js"(exports) {
49466
49569
  "use strict";
49467
49570
  Object.defineProperty(exports, "__esModule", { value: true });
49468
- var utils = require_utils5();
49571
+ var utils = require_utils6();
49469
49572
  var ErrorFilter = class {
49470
49573
  constructor(_settings) {
49471
49574
  this._settings = _settings;
@@ -49486,7 +49589,7 @@ var require_entry2 = __commonJS({
49486
49589
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/providers/transformers/entry.js"(exports) {
49487
49590
  "use strict";
49488
49591
  Object.defineProperty(exports, "__esModule", { value: true });
49489
- var utils = require_utils5();
49592
+ var utils = require_utils6();
49490
49593
  var EntryTransformer = class {
49491
49594
  constructor(_settings) {
49492
49595
  this._settings = _settings;
@@ -49597,12 +49700,12 @@ var require_async6 = __commonJS({
49597
49700
  });
49598
49701
 
49599
49702
  // node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/providers/stream.js
49600
- var require_stream4 = __commonJS({
49703
+ var require_stream5 = __commonJS({
49601
49704
  "node_modules/.pnpm/fast-glob@3.3.1/node_modules/fast-glob/out/providers/stream.js"(exports) {
49602
49705
  "use strict";
49603
49706
  Object.defineProperty(exports, "__esModule", { value: true });
49604
49707
  var stream_1 = require("stream");
49605
- var stream_2 = require_stream3();
49708
+ var stream_2 = require_stream4();
49606
49709
  var provider_1 = require_provider();
49607
49710
  var ProviderStream = class extends provider_1.default {
49608
49711
  constructor() {
@@ -49773,10 +49876,10 @@ var require_out4 = __commonJS({
49773
49876
  "use strict";
49774
49877
  var taskManager = require_tasks();
49775
49878
  var async_1 = require_async6();
49776
- var stream_1 = require_stream4();
49879
+ var stream_1 = require_stream5();
49777
49880
  var sync_1 = require_sync6();
49778
49881
  var settings_1 = require_settings4();
49779
- var utils = require_utils5();
49882
+ var utils = require_utils6();
49780
49883
  async function FastGlob(source, options) {
49781
49884
  assertPatternsInput2(source);
49782
49885
  const works = getWorks(source, async_1.default, options);
@@ -58077,10 +58180,15 @@ var init_wrangler_client = __esm({
58077
58180
  var studioUtils_exports = {};
58078
58181
  __export(studioUtils_exports, {
58079
58182
  drizzleDb: () => drizzleDb,
58183
+ drizzleForMySQL: () => drizzleForMySQL,
58080
58184
  drizzleForPostgres: () => drizzleForPostgres,
58081
- prepareModels: () => prepareModels
58185
+ drizzleForSQLite: () => drizzleForSQLite,
58186
+ prepareModels: () => prepareModels,
58187
+ prepareMySqlSchema: () => prepareMySqlSchema,
58188
+ preparePgSchema: () => preparePgSchema,
58189
+ prepareSQLiteSchema: () => prepareSQLiteSchema
58082
58190
  });
58083
- var import_drizzle_orm14, import_mysql_core4, import_pg_core4, import_sqlite_core5, prepareModels, drizzleForPostgres, drizzleDb;
58191
+ var import_drizzle_orm14, import_mysql_core4, import_pg_core4, import_sqlite_core5, preparePgSchema, prepareMySqlSchema, prepareSQLiteSchema, prepareModels, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleDb;
58084
58192
  var init_studioUtils = __esm({
58085
58193
  "src/serializer/studioUtils.ts"() {
58086
58194
  import_drizzle_orm14 = require("drizzle-orm");
@@ -58089,7 +58197,75 @@ var init_studioUtils = __esm({
58089
58197
  import_sqlite_core5 = require("drizzle-orm/sqlite-core");
58090
58198
  init_utils();
58091
58199
  init_utils3();
58200
+ init_global();
58092
58201
  init_serializer();
58202
+ preparePgSchema = async (path4) => {
58203
+ const imports = prepareFilenames(path4);
58204
+ const pgSchema4 = {};
58205
+ const relations4 = {};
58206
+ const { unregister } = await safeRegister();
58207
+ for (let i = 0; i < imports.length; i++) {
58208
+ const it = imports[i];
58209
+ const i0 = require(`${it}`);
58210
+ const i0values = Object.entries(i0);
58211
+ i0values.forEach(([k, t]) => {
58212
+ if ((0, import_drizzle_orm14.is)(t, import_pg_core4.PgTable)) {
58213
+ const schema4 = (0, import_pg_core4.getTableConfig)(t).schema || "public";
58214
+ pgSchema4[schema4] = pgSchema4[schema4] || {};
58215
+ pgSchema4[schema4][k] = t;
58216
+ }
58217
+ if ((0, import_drizzle_orm14.is)(t, import_drizzle_orm14.Relations)) {
58218
+ relations4[k] = t;
58219
+ }
58220
+ });
58221
+ }
58222
+ unregister();
58223
+ return { schema: pgSchema4, relations: relations4 };
58224
+ };
58225
+ prepareMySqlSchema = async (path4) => {
58226
+ const imports = prepareFilenames(path4);
58227
+ const mysqlSchema4 = {};
58228
+ const relations4 = {};
58229
+ const { unregister } = await safeRegister();
58230
+ for (let i = 0; i < imports.length; i++) {
58231
+ const it = imports[i];
58232
+ const i0 = require(`${it}`);
58233
+ const i0values = Object.entries(i0);
58234
+ i0values.forEach(([k, t]) => {
58235
+ if ((0, import_drizzle_orm14.is)(t, import_mysql_core4.MySqlTable)) {
58236
+ const schema4 = (0, import_mysql_core4.getTableConfig)(t).schema || "public";
58237
+ mysqlSchema4[schema4][k] = t;
58238
+ }
58239
+ if ((0, import_drizzle_orm14.is)(t, import_drizzle_orm14.Relations)) {
58240
+ relations4[k] = t;
58241
+ }
58242
+ });
58243
+ }
58244
+ unregister();
58245
+ return { schema: mysqlSchema4, relations: relations4 };
58246
+ };
58247
+ prepareSQLiteSchema = async (path4) => {
58248
+ const imports = prepareFilenames(path4);
58249
+ const sqliteSchema2 = {};
58250
+ const relations4 = {};
58251
+ const { unregister } = await safeRegister();
58252
+ for (let i = 0; i < imports.length; i++) {
58253
+ const it = imports[i];
58254
+ const i0 = require(`${it}`);
58255
+ const i0values = Object.entries(i0);
58256
+ i0values.forEach(([k, t]) => {
58257
+ if ((0, import_drizzle_orm14.is)(t, import_sqlite_core5.SQLiteTable)) {
58258
+ const schema4 = "public";
58259
+ sqliteSchema2[schema4][k] = t;
58260
+ }
58261
+ if ((0, import_drizzle_orm14.is)(t, import_drizzle_orm14.Relations)) {
58262
+ relations4[k] = t;
58263
+ }
58264
+ });
58265
+ }
58266
+ unregister();
58267
+ return { schema: sqliteSchema2, relations: relations4 };
58268
+ };
58093
58269
  prepareModels = async (path4) => {
58094
58270
  const imports = prepareFilenames(path4);
58095
58271
  const sqliteSchema2 = {};
@@ -58120,26 +58296,88 @@ var init_studioUtils = __esm({
58120
58296
  unregister();
58121
58297
  return { pgSchema: pgSchema4, mysqlSchema: mysqlSchema4, sqliteSchema: sqliteSchema2 };
58122
58298
  };
58123
- drizzleForPostgres = async (connectionConfig, pgSchema4, verbose) => {
58299
+ drizzleForPostgres = async (connectionConfig, pgSchema4, relations4, verbose) => {
58124
58300
  assertPackages("pg");
58125
58301
  const { drizzle: drizzle2 } = await import("drizzle-orm/node-postgres");
58126
- const { Pool } = await Promise.resolve().then(() => __toESM(require_lib2()));
58127
- const db = drizzle2(new Pool(connectionConfig.dbCredentials), {
58302
+ const pg = await Promise.resolve().then(() => __toESM(require_lib2()));
58303
+ const db = drizzle2(new pg.default.Pool(connectionConfig.dbCredentials), {
58128
58304
  logger: verbose
58129
58305
  });
58130
58306
  return {
58131
58307
  type: "pg",
58132
58308
  db,
58133
- schema: pgSchema4
58309
+ schema: pgSchema4,
58310
+ relations: relations4
58311
+ };
58312
+ };
58313
+ drizzleForMySQL = async (config, mysqlSchema4, relations4, verbose) => {
58314
+ assertPackages("mysql2");
58315
+ const { drizzle: drizzle2 } = await import("drizzle-orm/mysql2");
58316
+ const { createPool } = await Promise.resolve().then(() => __toESM(require_promise()));
58317
+ const client = createPool({ ...config.dbCredentials, connectionLimit: 1 });
58318
+ const db = drizzle2(client, { logger: verbose });
58319
+ return {
58320
+ type: "mysql",
58321
+ db,
58322
+ schema: mysqlSchema4,
58323
+ relations: relations4
58134
58324
  };
58135
58325
  };
58136
- drizzleDb = async (drizzleConfig, models, logger, pgClient) => {
58326
+ drizzleForSQLite = async (config, sqliteSchema2, relations4, verbose) => {
58327
+ const { driver, dbCredentials: creds } = config;
58328
+ if (driver === "d1") {
58329
+ const { drizzle: drizzle2 } = await Promise.resolve().then(() => (init_driver(), driver_exports));
58330
+ const { execute: execute2 } = await Promise.resolve().then(() => (init_wrangler_client(), wrangler_client_exports));
58331
+ const db = drizzle2(execute2, creds.wranglerConfigPath, creds.dbName, {
58332
+ logger: verbose
58333
+ });
58334
+ return {
58335
+ type: "sqlite",
58336
+ db,
58337
+ schema: sqliteSchema2,
58338
+ relations: relations4
58339
+ };
58340
+ }
58341
+ if (driver === "better-sqlite") {
58342
+ assertPackages("better-sqlite3");
58343
+ const { drizzle: drizzle2 } = await import("drizzle-orm/better-sqlite3");
58344
+ const Database = await import("better-sqlite3");
58345
+ const client = new Database.default(creds.url);
58346
+ const db = drizzle2(client, { logger: verbose });
58347
+ return {
58348
+ type: "sqlite",
58349
+ db,
58350
+ schema: sqliteSchema2,
58351
+ relations: relations4
58352
+ };
58353
+ }
58354
+ if (driver === "libsql" || driver === "turso") {
58355
+ assertPackages("@libsql/client");
58356
+ const { drizzle: drizzle2 } = await import("drizzle-orm/libsql");
58357
+ const { createClient } = await import("@libsql/client");
58358
+ const client = createClient(creds);
58359
+ const db = drizzle2(
58360
+ client,
58361
+ { logger: verbose }
58362
+ );
58363
+ return {
58364
+ type: "sqlite",
58365
+ db,
58366
+ schema: sqliteSchema2,
58367
+ relations: relations4
58368
+ };
58369
+ }
58370
+ assertUnreachable(driver);
58371
+ };
58372
+ drizzleDb = async (drizzleConfig, models, logger) => {
58137
58373
  if (drizzleConfig.driver === "pg") {
58138
58374
  const { drizzle: drizzle2 } = await import("drizzle-orm/node-postgres");
58139
- if (!pgClient)
58140
- throw new Error("pg client not provided");
58375
+ const pg = await Promise.resolve().then(() => __toESM(require_lib2()));
58376
+ const db = drizzle2(new pg.default.Pool(drizzleConfig.dbCredentials), {
58377
+ logger
58378
+ });
58141
58379
  return {
58142
- db: drizzle2(pgClient, { logger }),
58380
+ db,
58143
58381
  type: "pg",
58144
58382
  schema: models.pgSchema
58145
58383
  };
@@ -58147,12 +58385,7 @@ var init_studioUtils = __esm({
58147
58385
  const { drizzle: drizzle2 } = await import("drizzle-orm/mysql2");
58148
58386
  const { createPool } = await Promise.resolve().then(() => __toESM(require_promise()));
58149
58387
  const client = createPool({
58150
- uri: drizzleConfig.dbCredentials.type === "url" ? drizzleConfig.dbCredentials.connectionString : void 0,
58151
- host: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.host : void 0,
58152
- port: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.port : void 0,
58153
- user: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.user : void 0,
58154
- database: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.database : void 0,
58155
- password: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.password : void 0,
58388
+ ...drizzleConfig.dbCredentials,
58156
58389
  connectionLimit: 1
58157
58390
  });
58158
58391
  return {
@@ -58792,7 +59025,7 @@ var init_pg = __esm({
58792
59025
  });
58793
59026
 
58794
59027
  // src/cli/validations/mysql.ts
58795
- var mysqlConnectionCli, mysqlConnectionConfig, mysqlConfigIntrospectSchema, mysqlCliIntrospectParams, mysqlCliPushParams, mysqlConfigPushParams, printCliConnectionIssues3, printConfigConnectionIssues3, validateMySqlIntrospect, validateMySqlPush;
59028
+ var mysqlConnectionCli, mysql2credentials, mysqlConnectionConfig, mysqlConfigIntrospectSchema, mysqlCliIntrospectParams, mysqlCliPushParams, mysqlConfigPushParams, printCliConnectionIssues3, printConfigConnectionIssues3, validateMySqlIntrospect, validateMySqlPush;
58796
59029
  var init_mysql = __esm({
58797
59030
  "src/cli/validations/mysql.ts"() {
58798
59031
  init_lib();
@@ -58806,35 +59039,31 @@ var init_mysql = __esm({
58806
59039
  port: coerce.number().optional(),
58807
59040
  user: stringType().default("mysql"),
58808
59041
  password: stringType().optional(),
58809
- database: stringType(),
58810
- type: literalType("params").default("params")
59042
+ database: stringType()
58811
59043
  }),
58812
59044
  objectType({
58813
59045
  driver: literalType("mysql2"),
58814
- connectionString: stringType(),
58815
- type: literalType("url").default("url")
59046
+ uri: stringType()
59047
+ // TODO: change docs
58816
59048
  })
58817
59049
  ]);
58818
- mysqlConnectionConfig = unionType([
59050
+ mysql2credentials = unionType([
58819
59051
  objectType({
58820
- driver: literalType("mysql2"),
58821
- dbCredentials: objectType({
58822
- host: stringType(),
58823
- port: coerce.number().optional(),
58824
- user: stringType().default("mysql"),
58825
- password: stringType().optional(),
58826
- database: stringType(),
58827
- type: literalType("params").default("params")
58828
- })
59052
+ host: stringType(),
59053
+ port: coerce.number().optional(),
59054
+ user: stringType().default("mysql"),
59055
+ password: stringType().optional(),
59056
+ database: stringType()
58829
59057
  }),
58830
59058
  objectType({
58831
- driver: literalType("mysql2"),
58832
- dbCredentials: objectType({
58833
- connectionString: stringType(),
58834
- type: literalType("url").default("url")
58835
- })
59059
+ uri: stringType()
59060
+ // TODO: change docs
58836
59061
  })
58837
59062
  ]);
59063
+ mysqlConnectionConfig = objectType({
59064
+ driver: literalType("mysql2"),
59065
+ dbCredentials: mysql2credentials
59066
+ });
58838
59067
  mysqlConfigIntrospectSchema = intersectionType(
58839
59068
  configIntrospectSchema,
58840
59069
  mysqlConnectionConfig
@@ -58852,22 +59081,22 @@ var init_mysql = __esm({
58852
59081
  mysqlConnectionConfig
58853
59082
  );
58854
59083
  printCliConnectionIssues3 = (options) => {
58855
- if (options.driver === "mysql2") {
58856
- if (typeof options.connectionString === "undefined" && (typeof options.host === "undefined" || typeof options.database === "undefined")) {
58857
- console.log(outputs.mysql.connection.required());
58858
- }
58859
- } else {
59084
+ const { driver, uri, host, database } = options || {};
59085
+ if (driver !== "mysql2") {
58860
59086
  console.log(outputs.mysql.connection.driver());
58861
59087
  }
59088
+ if (!uri && (!host || !database)) {
59089
+ console.log(outputs.mysql.connection.required());
59090
+ }
58862
59091
  };
58863
59092
  printConfigConnectionIssues3 = (options) => {
58864
- if (options.driver === "mysql2") {
58865
- if (typeof options.dbCredentials.connectionString === "undefined" && (typeof options.dbCredentials.host === "undefined" || typeof options.dbCredentials.database === "undefined")) {
58866
- console.log(outputs.mysql.connection.required());
58867
- }
58868
- } else {
59093
+ if (options.driver !== "mysql2") {
58869
59094
  console.log(outputs.mysql.connection.driver());
58870
59095
  }
59096
+ const { uri, host, database } = options.dbCredentials || {};
59097
+ if (!uri && (!host || !database)) {
59098
+ console.log(outputs.mysql.connection.required());
59099
+ }
58871
59100
  };
58872
59101
  validateMySqlIntrospect = async (options) => {
58873
59102
  const collisionRes = checkCollisions(options, "introspect:mysql");
@@ -58889,28 +59118,25 @@ var init_mysql = __esm({
58889
59118
  printCliConnectionIssues3(options);
58890
59119
  process.exit(1);
58891
59120
  }
58892
- if (cliRes.data.type === "url") {
58893
- const { connectionString, introspectCasing: introspectCasing3, type: type2, ...rest2 } = cliRes.data;
58894
- return {
58895
- ...rest2,
58896
- dbCredentials: { connectionString, type: type2 },
58897
- introspect: { casing: introspectCasing3 }
58898
- };
58899
- }
58900
59121
  const {
58901
- host,
58902
- password,
58903
- port,
58904
- database,
58905
- user,
58906
- type,
59122
+ out,
59123
+ schema: schema4,
59124
+ driver,
59125
+ schemaFilter,
59126
+ tablesFilter,
59127
+ breakpoints,
58907
59128
  introspectCasing: introspectCasing2,
58908
59129
  ...rest
58909
59130
  } = cliRes.data;
58910
59131
  return {
58911
- ...rest,
58912
- dbCredentials: { host, password, port, database, user, type },
58913
- introspect: { casing: introspectCasing2 }
59132
+ out,
59133
+ schema: schema4,
59134
+ driver,
59135
+ schemaFilter,
59136
+ tablesFilter,
59137
+ breakpoints,
59138
+ introspect: { casing: introspectCasing2 },
59139
+ dbCredentials: rest
58914
59140
  };
58915
59141
  };
58916
59142
  validateMySqlPush = async (options) => {
@@ -58937,24 +59163,30 @@ var init_mysql = __esm({
58937
59163
  printCliConnectionIssues3(options);
58938
59164
  process.exit(1);
58939
59165
  }
58940
- if (cliRes.data.type === "url") {
58941
- const { connectionString, type: type2, ...rest2 } = cliRes.data;
58942
- return {
58943
- ...rest2,
58944
- dbCredentials: { connectionString, type: type2 }
58945
- };
58946
- }
58947
- const { host, password, port, database, user, type, ...rest } = cliRes.data;
59166
+ const {
59167
+ strict,
59168
+ verbose,
59169
+ schema: schema4,
59170
+ driver,
59171
+ schemaFilter,
59172
+ tablesFilter,
59173
+ ...rest
59174
+ } = cliRes.data;
58948
59175
  return {
58949
- ...rest,
58950
- dbCredentials: { host, password, port, database, user, type }
59176
+ driver,
59177
+ schema: schema4,
59178
+ strict,
59179
+ verbose,
59180
+ tablesFilter,
59181
+ schemaFilter,
59182
+ dbCredentials: rest
58951
59183
  };
58952
59184
  };
58953
59185
  }
58954
59186
  });
58955
59187
 
58956
59188
  // node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/package.json
58957
- var require_package2 = __commonJS({
59189
+ var require_package = __commonJS({
58958
59190
  "node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/package.json"(exports, module2) {
58959
59191
  module2.exports = {
58960
59192
  name: "dotenv",
@@ -59025,7 +59257,7 @@ var require_main = __commonJS({
59025
59257
  var fs8 = require("fs");
59026
59258
  var path4 = require("path");
59027
59259
  var os2 = require("os");
59028
- var packageJson = require_package2();
59260
+ var packageJson = require_package();
59029
59261
  var version = packageJson.version;
59030
59262
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
59031
59263
  function parse(src) {
@@ -59782,9 +60014,10 @@ __export(studio_exports, {
59782
60014
  studioConfidConnections: () => studioConfidConnections,
59783
60015
  studioConfigSchema: () => studioConfigSchema,
59784
60016
  studioSpecificConnections: () => studioSpecificConnections,
60017
+ stuioSqliteConnectionConfig: () => stuioSqliteConnectionConfig,
59785
60018
  validateStudio: () => validateStudio
59786
60019
  });
59787
- var studioSpecificConnections, studioConfidConnections, studioConfigSchema, printDriverIssues, validateStudio;
60020
+ var studioSpecificConnections, stuioSqliteConnectionConfig, studioConfidConnections, studioConfigSchema, printDriverIssues, validateStudio;
59788
60021
  var init_studio = __esm({
59789
60022
  "src/cli/validations/studio.ts"() {
59790
60023
  init_lib();
@@ -59803,6 +60036,7 @@ var init_studio = __esm({
59803
60036
  dbName: stringType()
59804
60037
  })
59805
60038
  });
60039
+ stuioSqliteConnectionConfig = unionType([sqliteConnectionSchema, studioSpecificConnections]);
59806
60040
  studioConfidConnections = unionType([mysqlConnectionConfig, pgConnectionConfig, sqliteConnectionSchema, studioSpecificConnections]);
59807
60041
  studioConfigSchema = intersectionType(
59808
60042
  objectType({
@@ -59943,7 +60177,8 @@ var package_default = {
59943
60177
  packit: "pnpm build && cp package.json dist/ && cd dist && pnpm pack",
59944
60178
  tsc: "tsc -p tsconfig.build.json",
59945
60179
  pub: "cp package.json readme.md dist/ && cd dist && npm publish",
59946
- studio: "./dist/index.cjs studio --verbose"
60180
+ studio: "./dist/index.cjs studio --verbose",
60181
+ "studio:dev": "tsx ./src/cli/index.ts studio --verbose"
59947
60182
  },
59948
60183
  ava: {
59949
60184
  files: [
@@ -59957,7 +60192,7 @@ var package_default = {
59957
60192
  ]
59958
60193
  },
59959
60194
  dependencies: {
59960
- "@drizzle-team/studio": "^0.0.17",
60195
+ "@drizzle-team/studio": "^0.0.27",
59961
60196
  "@esbuild-kit/esm-loader": "^2.5.5",
59962
60197
  camelcase: "^7.0.1",
59963
60198
  chalk: "^5.2.0",
@@ -59979,20 +60214,20 @@ var package_default = {
59979
60214
  "@types/glob": "^8.1.0",
59980
60215
  "@types/minimatch": "^5.1.2",
59981
60216
  "@types/node": "^18.11.15",
59982
- "@types/pg": "^8.6.5",
60217
+ "@types/pg": "^8.10.7",
59983
60218
  "@typescript-eslint/eslint-plugin": "^5.46.1",
59984
60219
  "@typescript-eslint/parser": "^5.46.1",
59985
60220
  ava: "^5.1.0",
59986
60221
  "better-sqlite3": "^8.4.0",
59987
60222
  dockerode: "^3.3.4",
59988
60223
  dotenv: "^16.0.3",
59989
- "drizzle-orm": "0.28.7-4e094f0",
60224
+ "drizzle-orm": "0.29.0-d3b1c58",
59990
60225
  eslint: "^8.29.0",
59991
60226
  "eslint-config-prettier": "^8.5.0",
59992
60227
  "eslint-plugin-prettier": "^4.2.1",
59993
60228
  "get-port": "^6.1.2",
59994
60229
  mysql2: "2.3.3",
59995
- pg: "^8.8.0",
60230
+ pg: "^8.11.3",
59996
60231
  postgres: "^3.3.5",
59997
60232
  prettier: "^2.8.1",
59998
60233
  tsx: "^3.12.1",
@@ -60620,6 +60855,7 @@ init_sqlgenerator();
60620
60855
 
60621
60856
  // src/cli/index.ts
60622
60857
  init_selector_ui();
60858
+ init_global();
60623
60859
  var printVersions = async () => {
60624
60860
  const v = await versions();
60625
60861
  console.log(`${source_default.gray(v)}
@@ -61310,18 +61546,42 @@ var dropCommand = new import_commander.Command("drop").option("--out <out>", `Ou
61310
61546
  var studioCommand = new import_commander.Command("studio").option("--port <port>", "Custom port for drizzle studio [default=4983]").option("--host <host>", "Custom host for drizzle studio [default=0.0.0.0]").option("--verbose", "Print all stataments that are executed by Studio").option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
61311
61547
  const { validateStudio: validateStudio2 } = await Promise.resolve().then(() => (init_studio(), studio_exports));
61312
61548
  const drizzleConfig = await validateStudio2(options);
61313
- const { prepareModels: prepareModels2, drizzleDb: drizzleDb2, drizzleForPostgres: drizzleForPostgres2 } = await Promise.resolve().then(() => (init_studioUtils(), studioUtils_exports));
61314
- const models = await prepareModels2(drizzleConfig.schema);
61549
+ const {
61550
+ drizzleForPostgres: drizzleForPostgres2,
61551
+ preparePgSchema: preparePgSchema2,
61552
+ prepareMySqlSchema: prepareMySqlSchema2,
61553
+ drizzleForMySQL: drizzleForMySQL2,
61554
+ prepareSQLiteSchema: prepareSQLiteSchema2,
61555
+ drizzleForSQLite: drizzleForSQLite2
61556
+ } = await Promise.resolve().then(() => (init_studioUtils(), studioUtils_exports));
61557
+ const { driver, schema: schemaPath } = drizzleConfig;
61315
61558
  let setup;
61316
- if (drizzleConfig.driver === "pg") {
61317
- assertExists(models.pgSchema);
61318
- setup = await drizzleForPostgres2(drizzleConfig, models.pgSchema, options.verbose);
61319
- } else {
61320
- setup = await drizzleDb2(
61559
+ if (driver === "pg") {
61560
+ const { schema: schema4, relations: relations4 } = await preparePgSchema2(schemaPath);
61561
+ setup = await drizzleForPostgres2(
61321
61562
  drizzleConfig,
61322
- models,
61323
- options.verbose
61563
+ schema4,
61564
+ relations4,
61565
+ Boolean(options.verbose)
61566
+ );
61567
+ } else if (driver === "mysql2") {
61568
+ const { schema: schema4, relations: relations4 } = await prepareMySqlSchema2(schemaPath);
61569
+ setup = await drizzleForMySQL2(
61570
+ drizzleConfig,
61571
+ schema4,
61572
+ relations4,
61573
+ Boolean(options.verbose)
61324
61574
  );
61575
+ } else if (driver === "better-sqlite" || driver === "d1" || driver === "libsql" || driver === "turso") {
61576
+ const { schema: schema4, relations: relations4 } = await prepareSQLiteSchema2(schemaPath);
61577
+ setup = await drizzleForSQLite2(
61578
+ drizzleConfig,
61579
+ schema4,
61580
+ relations4,
61581
+ Boolean(options.verbose)
61582
+ );
61583
+ } else {
61584
+ assertUnreachable(driver);
61325
61585
  }
61326
61586
  const server = await (0, import_server.prepareServer)(setup);
61327
61587
  const port = options.port ?? 4983;