import { createRequire as __bundleCreateRequire } from "node:module"; const require = __bundleCreateRequire(import.meta.url); import { __commonJS, __name, __require, __toESM } from "./chunk-T6GW54FI.js"; // ../../node_modules/.pnpm/postgres-array@2.0.0/node_modules/postgres-array/index.js var require_postgres_array = __commonJS({ "../../node_modules/.pnpm/postgres-array@2.0.0/node_modules/postgres-array/index.js"(exports) { "use strict"; exports.parse = function(source, transform) { return new ArrayParser(source, transform).parse(); }; var ArrayParser = class _ArrayParser { static { __name(this, "ArrayParser"); } constructor(source, transform) { this.source = source; this.transform = transform || identity; this.position = 0; this.entries = []; this.recorded = []; this.dimension = 0; } isEof() { return this.position >= this.source.length; } nextCharacter() { var character = this.source[this.position++]; if (character === "\\") { return { value: this.source[this.position++], escaped: true }; } return { value: character, escaped: false }; } record(character) { this.recorded.push(character); } newEntry(includeEmpty) { var entry; if (this.recorded.length > 0 || includeEmpty) { entry = this.recorded.join(""); if (entry === "NULL" && !includeEmpty) { entry = null; } if (entry !== null) entry = this.transform(entry); this.entries.push(entry); this.recorded = []; } } consumeDimensions() { if (this.source[0] === "[") { while (!this.isEof()) { var char = this.nextCharacter(); if (char.value === "=") break; } } } parse(nested) { var character, parser, quote; this.consumeDimensions(); while (!this.isEof()) { character = this.nextCharacter(); if (character.value === "{" && !quote) { this.dimension++; if (this.dimension > 1) { parser = new _ArrayParser(this.source.substr(this.position - 1), this.transform); this.entries.push(parser.parse(true)); this.position += parser.position - 2; } } else if (character.value === "}" && !quote) { this.dimension--; if (!this.dimension) { this.newEntry(); if (nested) return this.entries; } } else if (character.value === '"' && !character.escaped) { if (quote) this.newEntry(true); quote = !quote; } else if (character.value === "," && !quote) { this.newEntry(); } else { this.record(character.value); } } if (this.dimension !== 0) { throw new Error("array dimension not balanced"); } return this.entries; } }; function identity(value) { return value; } __name(identity, "identity"); } }); // ../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/arrayParser.js var require_arrayParser = __commonJS({ "../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/arrayParser.js"(exports, module) { var array = require_postgres_array(); module.exports = { create: /* @__PURE__ */ __name(function(source, transform) { return { parse: /* @__PURE__ */ __name(function() { return array.parse(source, transform); }, "parse") }; }, "create") }; } }); // ../../node_modules/.pnpm/postgres-date@1.0.7/node_modules/postgres-date/index.js var require_postgres_date = __commonJS({ "../../node_modules/.pnpm/postgres-date@1.0.7/node_modules/postgres-date/index.js"(exports, module) { "use strict"; var DATE_TIME = /(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/; var DATE = /^(\d{1,})-(\d{2})-(\d{2})( BC)?$/; var TIME_ZONE = /([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/; var INFINITY = /^-?infinity$/; module.exports = /* @__PURE__ */ __name(function parseDate(isoDate) { if (INFINITY.test(isoDate)) { return Number(isoDate.replace("i", "I")); } var matches = DATE_TIME.exec(isoDate); if (!matches) { return getDate(isoDate) || null; } var isBC = !!matches[8]; var year = parseInt(matches[1], 10); if (isBC) { year = bcYearToNegativeYear(year); } var month = parseInt(matches[2], 10) - 1; var day = matches[3]; var hour = parseInt(matches[4], 10); var minute = parseInt(matches[5], 10); var second = parseInt(matches[6], 10); var ms = matches[7]; ms = ms ? 1e3 * parseFloat(ms) : 0; var date; var offset = timeZoneOffset(isoDate); if (offset != null) { date = new Date(Date.UTC(year, month, day, hour, minute, second, ms)); if (is0To99(year)) { date.setUTCFullYear(year); } if (offset !== 0) { date.setTime(date.getTime() - offset); } } else { date = new Date(year, month, day, hour, minute, second, ms); if (is0To99(year)) { date.setFullYear(year); } } return date; }, "parseDate"); function getDate(isoDate) { var matches = DATE.exec(isoDate); if (!matches) { return; } var year = parseInt(matches[1], 10); var isBC = !!matches[4]; if (isBC) { year = bcYearToNegativeYear(year); } var month = parseInt(matches[2], 10) - 1; var day = matches[3]; var date = new Date(year, month, day); if (is0To99(year)) { date.setFullYear(year); } return date; } __name(getDate, "getDate"); function timeZoneOffset(isoDate) { if (isoDate.endsWith("+00")) { return 0; } var zone = TIME_ZONE.exec(isoDate.split(" ")[1]); if (!zone) return; var type = zone[1]; if (type === "Z") { return 0; } var sign = type === "-" ? -1 : 1; var offset = parseInt(zone[2], 10) * 3600 + parseInt(zone[3] || 0, 10) * 60 + parseInt(zone[4] || 0, 10); return offset * sign * 1e3; } __name(timeZoneOffset, "timeZoneOffset"); function bcYearToNegativeYear(year) { return -(year - 1); } __name(bcYearToNegativeYear, "bcYearToNegativeYear"); function is0To99(num) { return num >= 0 && num < 100; } __name(is0To99, "is0To99"); } }); // ../../node_modules/.pnpm/xtend@4.0.2/node_modules/xtend/mutable.js var require_mutable = __commonJS({ "../../node_modules/.pnpm/xtend@4.0.2/node_modules/xtend/mutable.js"(exports, module) { module.exports = extend; var hasOwnProperty = Object.prototype.hasOwnProperty; function extend(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; } __name(extend, "extend"); } }); // ../../node_modules/.pnpm/postgres-interval@1.2.0/node_modules/postgres-interval/index.js var require_postgres_interval = __commonJS({ "../../node_modules/.pnpm/postgres-interval@1.2.0/node_modules/postgres-interval/index.js"(exports, module) { "use strict"; var extend = require_mutable(); module.exports = PostgresInterval; function PostgresInterval(raw) { if (!(this instanceof PostgresInterval)) { return new PostgresInterval(raw); } extend(this, parse(raw)); } __name(PostgresInterval, "PostgresInterval"); var properties = ["seconds", "minutes", "hours", "days", "months", "years"]; PostgresInterval.prototype.toPostgres = function() { var filtered = properties.filter(this.hasOwnProperty, this); if (this.milliseconds && filtered.indexOf("seconds") < 0) { filtered.push("seconds"); } if (filtered.length === 0) return "0"; return filtered.map(function(property) { var value = this[property] || 0; if (property === "seconds" && this.milliseconds) { value = (value + this.milliseconds / 1e3).toFixed(6).replace(/\.?0+$/, ""); } return value + " " + property; }, this).join(" "); }; var propertiesISOEquivalent = { years: "Y", months: "M", days: "D", hours: "H", minutes: "M", seconds: "S" }; var dateProperties = ["years", "months", "days"]; var timeProperties = ["hours", "minutes", "seconds"]; PostgresInterval.prototype.toISOString = PostgresInterval.prototype.toISO = function() { var datePart = dateProperties.map(buildProperty, this).join(""); var timePart = timeProperties.map(buildProperty, this).join(""); return "P" + datePart + "T" + timePart; function buildProperty(property) { var value = this[property] || 0; if (property === "seconds" && this.milliseconds) { value = (value + this.milliseconds / 1e3).toFixed(6).replace(/0+$/, ""); } return value + propertiesISOEquivalent[property]; } __name(buildProperty, "buildProperty"); }; var NUMBER = "([+-]?\\d+)"; var YEAR = NUMBER + "\\s+years?"; var MONTH = NUMBER + "\\s+mons?"; var DAY = NUMBER + "\\s+days?"; var TIME = "([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?"; var INTERVAL = new RegExp([YEAR, MONTH, DAY, TIME].map(function(regexString) { return "(" + regexString + ")?"; }).join("\\s*")); var positions = { years: 2, months: 4, days: 6, hours: 9, minutes: 10, seconds: 11, milliseconds: 12 }; var negatives = ["hours", "minutes", "seconds", "milliseconds"]; function parseMilliseconds(fraction) { var microseconds = fraction + "000000".slice(fraction.length); return parseInt(microseconds, 10) / 1e3; } __name(parseMilliseconds, "parseMilliseconds"); function parse(interval) { if (!interval) return {}; var matches = INTERVAL.exec(interval); var isNegative = matches[8] === "-"; return Object.keys(positions).reduce(function(parsed, property) { var position = positions[property]; var value = matches[position]; if (!value) return parsed; value = property === "milliseconds" ? parseMilliseconds(value) : parseInt(value, 10); if (!value) return parsed; if (isNegative && ~negatives.indexOf(property)) { value *= -1; } parsed[property] = value; return parsed; }, {}); } __name(parse, "parse"); } }); // ../../node_modules/.pnpm/postgres-bytea@1.0.1/node_modules/postgres-bytea/index.js var require_postgres_bytea = __commonJS({ "../../node_modules/.pnpm/postgres-bytea@1.0.1/node_modules/postgres-bytea/index.js"(exports, module) { "use strict"; var bufferFrom = Buffer.from || Buffer; module.exports = /* @__PURE__ */ __name(function parseBytea(input) { if (/^\\x/.test(input)) { return bufferFrom(input.substr(2), "hex"); } var output = ""; var i = 0; while (i < input.length) { if (input[i] !== "\\") { output += input[i]; ++i; } else { if (/[0-7]{3}/.test(input.substr(i + 1, 3))) { output += String.fromCharCode(parseInt(input.substr(i + 1, 3), 8)); i += 4; } else { var backslashes = 1; while (i + backslashes < input.length && input[i + backslashes] === "\\") { backslashes++; } for (var k = 0; k < Math.floor(backslashes / 2); ++k) { output += "\\"; } i += Math.floor(backslashes / 2) * 2; } } } return bufferFrom(output, "binary"); }, "parseBytea"); } }); // ../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/textParsers.js var require_textParsers = __commonJS({ "../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/textParsers.js"(exports, module) { var array = require_postgres_array(); var arrayParser = require_arrayParser(); var parseDate = require_postgres_date(); var parseInterval = require_postgres_interval(); var parseByteA = require_postgres_bytea(); function allowNull(fn) { return /* @__PURE__ */ __name(function nullAllowed(value) { if (value === null) return value; return fn(value); }, "nullAllowed"); } __name(allowNull, "allowNull"); function parseBool(value) { if (value === null) return value; return value === "TRUE" || value === "t" || value === "true" || value === "y" || value === "yes" || value === "on" || value === "1"; } __name(parseBool, "parseBool"); function parseBoolArray(value) { if (!value) return null; return array.parse(value, parseBool); } __name(parseBoolArray, "parseBoolArray"); function parseBaseTenInt(string) { return parseInt(string, 10); } __name(parseBaseTenInt, "parseBaseTenInt"); function parseIntegerArray(value) { if (!value) return null; return array.parse(value, allowNull(parseBaseTenInt)); } __name(parseIntegerArray, "parseIntegerArray"); function parseBigIntegerArray(value) { if (!value) return null; return array.parse(value, allowNull(function(entry) { return parseBigInteger(entry).trim(); })); } __name(parseBigIntegerArray, "parseBigIntegerArray"); var parsePointArray = /* @__PURE__ */ __name(function(value) { if (!value) { return null; } var p = arrayParser.create(value, function(entry) { if (entry !== null) { entry = parsePoint(entry); } return entry; }); return p.parse(); }, "parsePointArray"); var parseFloatArray = /* @__PURE__ */ __name(function(value) { if (!value) { return null; } var p = arrayParser.create(value, function(entry) { if (entry !== null) { entry = parseFloat(entry); } return entry; }); return p.parse(); }, "parseFloatArray"); var parseStringArray = /* @__PURE__ */ __name(function(value) { if (!value) { return null; } var p = arrayParser.create(value); return p.parse(); }, "parseStringArray"); var parseDateArray = /* @__PURE__ */ __name(function(value) { if (!value) { return null; } var p = arrayParser.create(value, function(entry) { if (entry !== null) { entry = parseDate(entry); } return entry; }); return p.parse(); }, "parseDateArray"); var parseIntervalArray = /* @__PURE__ */ __name(function(value) { if (!value) { return null; } var p = arrayParser.create(value, function(entry) { if (entry !== null) { entry = parseInterval(entry); } return entry; }); return p.parse(); }, "parseIntervalArray"); var parseByteAArray = /* @__PURE__ */ __name(function(value) { if (!value) { return null; } return array.parse(value, allowNull(parseByteA)); }, "parseByteAArray"); var parseInteger = /* @__PURE__ */ __name(function(value) { return parseInt(value, 10); }, "parseInteger"); var parseBigInteger = /* @__PURE__ */ __name(function(value) { var valStr = String(value); if (/^\d+$/.test(valStr)) { return valStr; } return value; }, "parseBigInteger"); var parseJsonArray = /* @__PURE__ */ __name(function(value) { if (!value) { return null; } return array.parse(value, allowNull(JSON.parse)); }, "parseJsonArray"); var parsePoint = /* @__PURE__ */ __name(function(value) { if (value[0] !== "(") { return null; } value = value.substring(1, value.length - 1).split(","); return { x: parseFloat(value[0]), y: parseFloat(value[1]) }; }, "parsePoint"); var parseCircle = /* @__PURE__ */ __name(function(value) { if (value[0] !== "<" && value[1] !== "(") { return null; } var point = "("; var radius = ""; var pointParsed = false; for (var i = 2; i < value.length - 1; i++) { if (!pointParsed) { point += value[i]; } if (value[i] === ")") { pointParsed = true; continue; } else if (!pointParsed) { continue; } if (value[i] === ",") { continue; } radius += value[i]; } var result = parsePoint(point); result.radius = parseFloat(radius); return result; }, "parseCircle"); var init = /* @__PURE__ */ __name(function(register) { register(20, parseBigInteger); register(21, parseInteger); register(23, parseInteger); register(26, parseInteger); register(700, parseFloat); register(701, parseFloat); register(16, parseBool); register(1082, parseDate); register(1114, parseDate); register(1184, parseDate); register(600, parsePoint); register(651, parseStringArray); register(718, parseCircle); register(1e3, parseBoolArray); register(1001, parseByteAArray); register(1005, parseIntegerArray); register(1007, parseIntegerArray); register(1028, parseIntegerArray); register(1016, parseBigIntegerArray); register(1017, parsePointArray); register(1021, parseFloatArray); register(1022, parseFloatArray); register(1231, parseFloatArray); register(1014, parseStringArray); register(1015, parseStringArray); register(1008, parseStringArray); register(1009, parseStringArray); register(1040, parseStringArray); register(1041, parseStringArray); register(1115, parseDateArray); register(1182, parseDateArray); register(1185, parseDateArray); register(1186, parseInterval); register(1187, parseIntervalArray); register(17, parseByteA); register(114, JSON.parse.bind(JSON)); register(3802, JSON.parse.bind(JSON)); register(199, parseJsonArray); register(3807, parseJsonArray); register(3907, parseStringArray); register(2951, parseStringArray); register(791, parseStringArray); register(1183, parseStringArray); register(1270, parseStringArray); }, "init"); module.exports = { init }; } }); // ../../node_modules/.pnpm/pg-int8@1.0.1/node_modules/pg-int8/index.js var require_pg_int8 = __commonJS({ "../../node_modules/.pnpm/pg-int8@1.0.1/node_modules/pg-int8/index.js"(exports, module) { "use strict"; var BASE = 1e6; function readInt8(buffer) { var high = buffer.readInt32BE(0); var low = buffer.readUInt32BE(4); var sign = ""; if (high < 0) { high = ~high + (low === 0); low = ~low + 1 >>> 0; sign = "-"; } var result = ""; var carry; var t; var digits; var pad; var l; var i; { carry = high % BASE; high = high / BASE >>> 0; t = 4294967296 * carry + low; low = t / BASE >>> 0; digits = "" + (t - BASE * low); if (low === 0 && high === 0) { return sign + digits + result; } pad = ""; l = 6 - digits.length; for (i = 0; i < l; i++) { pad += "0"; } result = pad + digits + result; } { carry = high % BASE; high = high / BASE >>> 0; t = 4294967296 * carry + low; low = t / BASE >>> 0; digits = "" + (t - BASE * low); if (low === 0 && high === 0) { return sign + digits + result; } pad = ""; l = 6 - digits.length; for (i = 0; i < l; i++) { pad += "0"; } result = pad + digits + result; } { carry = high % BASE; high = high / BASE >>> 0; t = 4294967296 * carry + low; low = t / BASE >>> 0; digits = "" + (t - BASE * low); if (low === 0 && high === 0) { return sign + digits + result; } pad = ""; l = 6 - digits.length; for (i = 0; i < l; i++) { pad += "0"; } result = pad + digits + result; } { carry = high % BASE; t = 4294967296 * carry + low; digits = "" + t % BASE; return sign + digits + result; } } __name(readInt8, "readInt8"); module.exports = readInt8; } }); // ../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/binaryParsers.js var require_binaryParsers = __commonJS({ "../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/binaryParsers.js"(exports, module) { var parseInt64 = require_pg_int8(); var parseBits = /* @__PURE__ */ __name(function(data, bits, offset, invert, callback) { offset = offset || 0; invert = invert || false; callback = callback || function(lastValue, newValue, bits2) { return lastValue * Math.pow(2, bits2) + newValue; }; var offsetBytes = offset >> 3; var inv = /* @__PURE__ */ __name(function(value) { if (invert) { return ~value & 255; } return value; }, "inv"); var mask = 255; var firstBits = 8 - offset % 8; if (bits < firstBits) { mask = 255 << 8 - bits & 255; firstBits = bits; } if (offset) { mask = mask >> offset % 8; } var result = 0; if (offset % 8 + bits >= 8) { result = callback(0, inv(data[offsetBytes]) & mask, firstBits); } var bytes = bits + offset >> 3; for (var i = offsetBytes + 1; i < bytes; i++) { result = callback(result, inv(data[i]), 8); } var lastBits = (bits + offset) % 8; if (lastBits > 0) { result = callback(result, inv(data[bytes]) >> 8 - lastBits, lastBits); } return result; }, "parseBits"); var parseFloatFromBits = /* @__PURE__ */ __name(function(data, precisionBits, exponentBits) { var bias = Math.pow(2, exponentBits - 1) - 1; var sign = parseBits(data, 1); var exponent = parseBits(data, exponentBits, 1); if (exponent === 0) { return 0; } var precisionBitsCounter = 1; var parsePrecisionBits = /* @__PURE__ */ __name(function(lastValue, newValue, bits) { if (lastValue === 0) { lastValue = 1; } for (var i = 1; i <= bits; i++) { precisionBitsCounter /= 2; if ((newValue & 1 << bits - i) > 0) { lastValue += precisionBitsCounter; } } return lastValue; }, "parsePrecisionBits"); var mantissa = parseBits(data, precisionBits, exponentBits + 1, false, parsePrecisionBits); if (exponent == Math.pow(2, exponentBits + 1) - 1) { if (mantissa === 0) { return sign === 0 ? Infinity : -Infinity; } return NaN; } return (sign === 0 ? 1 : -1) * Math.pow(2, exponent - bias) * mantissa; }, "parseFloatFromBits"); var parseInt16 = /* @__PURE__ */ __name(function(value) { if (parseBits(value, 1) == 1) { return -1 * (parseBits(value, 15, 1, true) + 1); } return parseBits(value, 15, 1); }, "parseInt16"); var parseInt32 = /* @__PURE__ */ __name(function(value) { if (parseBits(value, 1) == 1) { return -1 * (parseBits(value, 31, 1, true) + 1); } return parseBits(value, 31, 1); }, "parseInt32"); var parseFloat32 = /* @__PURE__ */ __name(function(value) { return parseFloatFromBits(value, 23, 8); }, "parseFloat32"); var parseFloat64 = /* @__PURE__ */ __name(function(value) { return parseFloatFromBits(value, 52, 11); }, "parseFloat64"); var parseNumeric = /* @__PURE__ */ __name(function(value) { var sign = parseBits(value, 16, 32); if (sign == 49152) { return NaN; } var weight = Math.pow(1e4, parseBits(value, 16, 16)); var result = 0; var digits = []; var ndigits = parseBits(value, 16); for (var i = 0; i < ndigits; i++) { result += parseBits(value, 16, 64 + 16 * i) * weight; weight /= 1e4; } var scale = Math.pow(10, parseBits(value, 16, 48)); return (sign === 0 ? 1 : -1) * Math.round(result * scale) / scale; }, "parseNumeric"); var parseDate = /* @__PURE__ */ __name(function(isUTC, value) { var sign = parseBits(value, 1); var rawValue = parseBits(value, 63, 1); var result = new Date((sign === 0 ? 1 : -1) * rawValue / 1e3 + 9466848e5); if (!isUTC) { result.setTime(result.getTime() + result.getTimezoneOffset() * 6e4); } result.usec = rawValue % 1e3; result.getMicroSeconds = function() { return this.usec; }; result.setMicroSeconds = function(value2) { this.usec = value2; }; result.getUTCMicroSeconds = function() { return this.usec; }; return result; }, "parseDate"); var parseArray = /* @__PURE__ */ __name(function(value) { var dim = parseBits(value, 32); var flags = parseBits(value, 32, 32); var elementType = parseBits(value, 32, 64); var offset = 96; var dims = []; for (var i = 0; i < dim; i++) { dims[i] = parseBits(value, 32, offset); offset += 32; offset += 32; } var parseElement = /* @__PURE__ */ __name(function(elementType2) { var length = parseBits(value, 32, offset); offset += 32; if (length == 4294967295) { return null; } var result; if (elementType2 == 23 || elementType2 == 20) { result = parseBits(value, length * 8, offset); offset += length * 8; return result; } else if (elementType2 == 25) { result = value.toString(this.encoding, offset >> 3, (offset += length << 3) >> 3); return result; } else { console.log("ERROR: ElementType not implemented: " + elementType2); } }, "parseElement"); var parse = /* @__PURE__ */ __name(function(dimension, elementType2) { var array = []; var i2; if (dimension.length > 1) { var count = dimension.shift(); for (i2 = 0; i2 < count; i2++) { array[i2] = parse(dimension, elementType2); } dimension.unshift(count); } else { for (i2 = 0; i2 < dimension[0]; i2++) { array[i2] = parseElement(elementType2); } } return array; }, "parse"); return parse(dims, elementType); }, "parseArray"); var parseText = /* @__PURE__ */ __name(function(value) { return value.toString("utf8"); }, "parseText"); var parseBool = /* @__PURE__ */ __name(function(value) { if (value === null) return null; return parseBits(value, 8) > 0; }, "parseBool"); var init = /* @__PURE__ */ __name(function(register) { register(20, parseInt64); register(21, parseInt16); register(23, parseInt32); register(26, parseInt32); register(1700, parseNumeric); register(700, parseFloat32); register(701, parseFloat64); register(16, parseBool); register(1114, parseDate.bind(null, false)); register(1184, parseDate.bind(null, true)); register(1e3, parseArray); register(1007, parseArray); register(1016, parseArray); register(1008, parseArray); register(1009, parseArray); register(25, parseText); }, "init"); module.exports = { init }; } }); // ../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/builtins.js var require_builtins = __commonJS({ "../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/builtins.js"(exports, module) { module.exports = { BOOL: 16, BYTEA: 17, CHAR: 18, INT8: 20, INT2: 21, INT4: 23, REGPROC: 24, TEXT: 25, OID: 26, TID: 27, XID: 28, CID: 29, JSON: 114, XML: 142, PG_NODE_TREE: 194, SMGR: 210, PATH: 602, POLYGON: 604, CIDR: 650, FLOAT4: 700, FLOAT8: 701, ABSTIME: 702, RELTIME: 703, TINTERVAL: 704, CIRCLE: 718, MACADDR8: 774, MONEY: 790, MACADDR: 829, INET: 869, ACLITEM: 1033, BPCHAR: 1042, VARCHAR: 1043, DATE: 1082, TIME: 1083, TIMESTAMP: 1114, TIMESTAMPTZ: 1184, INTERVAL: 1186, TIMETZ: 1266, BIT: 1560, VARBIT: 1562, NUMERIC: 1700, REFCURSOR: 1790, REGPROCEDURE: 2202, REGOPER: 2203, REGOPERATOR: 2204, REGCLASS: 2205, REGTYPE: 2206, UUID: 2950, TXID_SNAPSHOT: 2970, PG_LSN: 3220, PG_NDISTINCT: 3361, PG_DEPENDENCIES: 3402, TSVECTOR: 3614, TSQUERY: 3615, GTSVECTOR: 3642, REGCONFIG: 3734, REGDICTIONARY: 3769, JSONB: 3802, REGNAMESPACE: 4089, REGROLE: 4096 }; } }); // ../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/index.js var require_pg_types = __commonJS({ "../../node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/index.js"(exports) { var textParsers = require_textParsers(); var binaryParsers = require_binaryParsers(); var arrayParser = require_arrayParser(); var builtinTypes = require_builtins(); exports.getTypeParser = getTypeParser; exports.setTypeParser = setTypeParser; exports.arrayParser = arrayParser; exports.builtins = builtinTypes; var typeParsers = { text: {}, binary: {} }; function noParse(val) { return String(val); } __name(noParse, "noParse"); function getTypeParser(oid, format) { format = format || "text"; if (!typeParsers[format]) { return noParse; } return typeParsers[format][oid] || noParse; } __name(getTypeParser, "getTypeParser"); function setTypeParser(oid, format, parseFn) { if (typeof format == "function") { parseFn = format; format = "text"; } typeParsers[format][oid] = parseFn; } __name(setTypeParser, "setTypeParser"); textParsers.init(function(oid, converter) { typeParsers.text[oid] = converter; }); binaryParsers.init(function(oid, converter) { typeParsers.binary[oid] = converter; }); } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/defaults.js var require_defaults = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/defaults.js"(exports, module) { "use strict"; var user; try { user = process.platform === "win32" ? process.env.USERNAME : process.env.USER; } catch { } module.exports = { // database host. defaults to localhost host: "localhost", // database user's name user, // name of database to connect database: void 0, // database user's password password: null, // a Postgres connection string to be used instead of setting individual connection items // NOTE: Setting this value will cause it to override any other value (such as database or user) defined // in the defaults object. connectionString: void 0, // database port port: 5432, // number of rows to return at a time from a prepared statement's // portal. 0 will return all rows at once rows: 0, // binary result mode binary: false, // Connection pool options - see https://github.com/brianc/node-pg-pool // number of connections to use in connection pool // 0 will disable connection pooling max: 10, // max milliseconds a client can go unused before it is removed // from the pool and destroyed idleTimeoutMillis: 3e4, client_encoding: "", ssl: false, // SSL negotiation style: 'postgres' (traditional SSLRequest) or 'direct' sslnegotiation: void 0, application_name: void 0, fallback_application_name: void 0, options: void 0, parseInputDatesAsUTC: false, // max milliseconds any query using this connection will execute for before timing out in error. // false=unlimited statement_timeout: false, // Abort any statement that waits longer than the specified duration in milliseconds while attempting to acquire a lock. // false=unlimited lock_timeout: false, // Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds // false=unlimited idle_in_transaction_session_timeout: false, // max milliseconds to wait for query to complete (client side) query_timeout: false, connect_timeout: 0, keepalives: 1, keepalives_idle: 0 }; var pgTypes = require_pg_types(); var parseBigInteger = pgTypes.getTypeParser(20, "text"); var parseBigIntegerArray = pgTypes.getTypeParser(1016, "text"); module.exports.__defineSetter__("parseInt8", function(val) { pgTypes.setTypeParser(20, "text", val ? pgTypes.getTypeParser(23, "text") : parseBigInteger); pgTypes.setTypeParser(1016, "text", val ? pgTypes.getTypeParser(1007, "text") : parseBigIntegerArray); }); } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/utils.js var require_utils = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/utils.js"(exports, module) { "use strict"; var defaults2 = require_defaults(); var nodeUtils = __require("util"); var { isDate } = __require("util/types"); var invalidDateDeprecationNotice = nodeUtils.deprecate( () => { }, "Sending an invalid date to Postgres is deprecated and will throw an error in the next major version of pg. Ensure any Date object passed as a query parameter is valid.", "PG_INVALID_DATE" ); function escapeElement(elementRepresentation) { const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"'); return '"' + escaped + '"'; } __name(escapeElement, "escapeElement"); function arrayString(val) { let result = "{"; for (let i = 0; i < val.length; i++) { if (i > 0) { result += ","; } let item = val[i]; if (item == null) { result += "NULL"; } else if (Array.isArray(item)) { result += arrayString(item); } else if (ArrayBuffer.isView(item)) { if (!(item instanceof Buffer)) { item = Buffer.from(item.buffer, item.byteOffset, item.byteLength); } result += "\\\\x" + item.toString("hex"); } else { result += escapeElement(prepareValue(item)); } } result += "}"; return result; } __name(arrayString, "arrayString"); var prepareValue = /* @__PURE__ */ __name(function(val, seen) { if (val == null) { return null; } if (typeof val === "object") { if (val instanceof Buffer) { return val; } if (ArrayBuffer.isView(val)) { return Buffer.from(val.buffer, val.byteOffset, val.byteLength); } if (isDate(val)) { if (isNaN(val.getTime())) { invalidDateDeprecationNotice(); } if (defaults2.parseInputDatesAsUTC) { return dateToStringUTC(val); } else { return dateToString(val); } } if (Array.isArray(val)) { return arrayString(val); } return prepareObject(val, seen); } return val.toString(); }, "prepareValue"); function prepareObject(val, seen) { if (val && typeof val.toPostgres === "function") { seen = seen || []; if (seen.indexOf(val) !== -1) { throw new Error('circular reference detected while preparing "' + val + '" for query'); } seen.push(val); return prepareValue(val.toPostgres(prepareValue), seen); } return JSON.stringify(val); } __name(prepareObject, "prepareObject"); function dateToString(date) { let offset = -date.getTimezoneOffset(); let year = date.getFullYear(); const isBCYear = year < 1; if (isBCYear) year = Math.abs(year) + 1; let ret = String(year).padStart(4, "0") + "-" + String(date.getMonth() + 1).padStart(2, "0") + "-" + String(date.getDate()).padStart(2, "0") + "T" + String(date.getHours()).padStart(2, "0") + ":" + String(date.getMinutes()).padStart(2, "0") + ":" + String(date.getSeconds()).padStart(2, "0") + "." + String(date.getMilliseconds()).padStart(3, "0"); if (offset < 0) { ret += "-"; offset *= -1; } else { ret += "+"; } ret += String(Math.floor(offset / 60)).padStart(2, "0") + ":" + String(offset % 60).padStart(2, "0"); if (isBCYear) ret += " BC"; return ret; } __name(dateToString, "dateToString"); function dateToStringUTC(date) { let year = date.getUTCFullYear(); const isBCYear = year < 1; if (isBCYear) year = Math.abs(year) + 1; let ret = String(year).padStart(4, "0") + "-" + String(date.getUTCMonth() + 1).padStart(2, "0") + "-" + String(date.getUTCDate()).padStart(2, "0") + "T" + String(date.getUTCHours()).padStart(2, "0") + ":" + String(date.getUTCMinutes()).padStart(2, "0") + ":" + String(date.getUTCSeconds()).padStart(2, "0") + "." + String(date.getUTCMilliseconds()).padStart(3, "0"); ret += "+00:00"; if (isBCYear) ret += " BC"; return ret; } __name(dateToStringUTC, "dateToStringUTC"); function normalizeQueryConfig(config, values, callback) { config = typeof config === "string" ? { text: config } : cloneQueryConfig(config); if (values) { if (typeof values === "function") { config.callback = values; } else { config.values = values; } } if (callback) { config.callback = callback; } return config; } __name(normalizeQueryConfig, "normalizeQueryConfig"); function cloneQueryConfig(config) { if (config == null) { return config; } return Object.defineProperties(Object.create(Object.getPrototypeOf(config)), Object.getOwnPropertyDescriptors(config)); } __name(cloneQueryConfig, "cloneQueryConfig"); var escapeIdentifier2 = /* @__PURE__ */ __name(function(str) { return '"' + str.replace(/"/g, '""') + '"'; }, "escapeIdentifier"); var escapeLiteral2 = /* @__PURE__ */ __name(function(str) { let hasBackslash = false; let escaped = "'"; if (str == null) { return "''"; } if (typeof str !== "string") { return "''"; } for (let i = 0; i < str.length; i++) { const c = str[i]; if (c === "'") { escaped += c + c; } else if (c === "\\") { escaped += c + c; hasBackslash = true; } else { escaped += c; } } escaped += "'"; if (hasBackslash === true) { escaped = " E" + escaped; } return escaped; }, "escapeLiteral"); module.exports = { prepareValue: /* @__PURE__ */ __name(function prepareValueWrapper(value) { return prepareValue(value); }, "prepareValueWrapper"), normalizeQueryConfig, escapeIdentifier: escapeIdentifier2, escapeLiteral: escapeLiteral2 }; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/crypto/utils.js var require_utils2 = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/crypto/utils.js"(exports, module) { var nodeCrypto = __require("crypto"); module.exports = { postgresMd5PasswordHash, randomBytes, deriveKey, sha256, hashByName, hmacSha256, md5 }; var webCrypto = nodeCrypto.webcrypto || globalThis.crypto; var subtleCrypto = webCrypto.subtle; var textEncoder = new TextEncoder(); function randomBytes(length) { return webCrypto.getRandomValues(Buffer.alloc(length)); } __name(randomBytes, "randomBytes"); async function md5(string) { try { return nodeCrypto.createHash("md5").update(string, "utf-8").digest("hex"); } catch (e) { const data = typeof string === "string" ? textEncoder.encode(string) : string; const hash = await subtleCrypto.digest("MD5", data); return Array.from(new Uint8Array(hash)).map((b) => b.toString(16).padStart(2, "0")).join(""); } } __name(md5, "md5"); async function postgresMd5PasswordHash(user, password, salt) { const inner = await md5(password + user); const outer = await md5(Buffer.concat([Buffer.from(inner), salt])); return "md5" + outer; } __name(postgresMd5PasswordHash, "postgresMd5PasswordHash"); async function sha256(text) { return await subtleCrypto.digest("SHA-256", text); } __name(sha256, "sha256"); async function hashByName(hashName, text) { return await subtleCrypto.digest(hashName, text); } __name(hashByName, "hashByName"); async function hmacSha256(keyBuffer, msg) { const key = await subtleCrypto.importKey("raw", keyBuffer, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]); return await subtleCrypto.sign("HMAC", key, textEncoder.encode(msg)); } __name(hmacSha256, "hmacSha256"); async function deriveKey(password, salt, iterations) { const key = await subtleCrypto.importKey("raw", textEncoder.encode(password), "PBKDF2", false, ["deriveBits"]); const params = { name: "PBKDF2", hash: "SHA-256", salt, iterations }; return await subtleCrypto.deriveBits(params, key, 32 * 8, ["deriveBits"]); } __name(deriveKey, "deriveKey"); } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/crypto/cert-signatures.js var require_cert_signatures = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/crypto/cert-signatures.js"(exports, module) { function x509Error(msg, cert) { return new Error("SASL channel binding: " + msg + " when parsing public certificate " + cert.toString("base64")); } __name(x509Error, "x509Error"); function readASN1Length(data, index) { let length = data[index++]; if (length < 128) return { length, index }; const lengthBytes = length & 127; if (lengthBytes > 4) throw x509Error("bad length", data); length = 0; for (let i = 0; i < lengthBytes; i++) { length = length << 8 | data[index++]; } return { length, index }; } __name(readASN1Length, "readASN1Length"); function readASN1OID(data, index) { if (data[index++] !== 6) throw x509Error("non-OID data", data); const { length: OIDLength, index: indexAfterOIDLength } = readASN1Length(data, index); index = indexAfterOIDLength; const lastIndex = index + OIDLength; const byte1 = data[index++]; let oid = (byte1 / 40 >> 0) + "." + byte1 % 40; while (index < lastIndex) { let value = 0; while (index < lastIndex) { const nextByte = data[index++]; value = value << 7 | nextByte & 127; if (nextByte < 128) break; } oid += "." + value; } return { oid, index }; } __name(readASN1OID, "readASN1OID"); function expectASN1Seq(data, index) { if (data[index++] !== 48) throw x509Error("non-sequence data", data); return readASN1Length(data, index); } __name(expectASN1Seq, "expectASN1Seq"); function signatureAlgorithmHashFromCertificate(data, index) { if (index === void 0) index = 0; index = expectASN1Seq(data, index).index; const { length: certInfoLength, index: indexAfterCertInfoLength } = expectASN1Seq(data, index); index = indexAfterCertInfoLength + certInfoLength; index = expectASN1Seq(data, index).index; const { oid, index: indexAfterOID } = readASN1OID(data, index); switch (oid) { // RSA case "1.2.840.113549.1.1.4": return "MD5"; case "1.2.840.113549.1.1.5": return "SHA-1"; case "1.2.840.113549.1.1.11": return "SHA-256"; case "1.2.840.113549.1.1.12": return "SHA-384"; case "1.2.840.113549.1.1.13": return "SHA-512"; case "1.2.840.113549.1.1.14": return "SHA-224"; case "1.2.840.113549.1.1.15": return "SHA512-224"; case "1.2.840.113549.1.1.16": return "SHA512-256"; // ECDSA case "1.2.840.10045.4.1": return "SHA-1"; case "1.2.840.10045.4.3.1": return "SHA-224"; case "1.2.840.10045.4.3.2": return "SHA-256"; case "1.2.840.10045.4.3.3": return "SHA-384"; case "1.2.840.10045.4.3.4": return "SHA-512"; // RSASSA-PSS: hash is indicated separately case "1.2.840.113549.1.1.10": { index = indexAfterOID; index = expectASN1Seq(data, index).index; if (data[index++] !== 160) throw x509Error("non-tag data", data); index = readASN1Length(data, index).index; index = expectASN1Seq(data, index).index; const { oid: hashOID } = readASN1OID(data, index); switch (hashOID) { // standalone hash OIDs case "1.2.840.113549.2.5": return "MD5"; case "1.3.14.3.2.26": return "SHA-1"; case "2.16.840.1.101.3.4.2.1": return "SHA-256"; case "2.16.840.1.101.3.4.2.2": return "SHA-384"; case "2.16.840.1.101.3.4.2.3": return "SHA-512"; } throw x509Error("unknown hash OID " + hashOID, data); } // Ed25519 -- see https://github.com/openssl/openssl/issues/15477 case "1.3.101.110": case "1.3.101.112": return "SHA-512"; // Ed448 -- still not in pg 17.2 (if supported, digest would be SHAKE256 x 64 bytes) case "1.3.101.111": case "1.3.101.113": throw x509Error("Ed448 certificate channel binding is not currently supported by Postgres"); } throw x509Error("unknown OID " + oid, data); } __name(signatureAlgorithmHashFromCertificate, "signatureAlgorithmHashFromCertificate"); module.exports = { signatureAlgorithmHashFromCertificate }; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/crypto/sasl.js var require_sasl = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/crypto/sasl.js"(exports, module) { "use strict"; var crypto = require_utils2(); var { signatureAlgorithmHashFromCertificate } = require_cert_signatures(); function saslprep(password) { const nonAsciiSpace = /[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g; const mappedToNothing = /[\u00AD\u034F\u1806\u180B\u180C\u180D\u200C\u200D\u2060\uFE00-\uFE0F\uFEFF]/g; return password.replace(nonAsciiSpace, " ").replace(mappedToNothing, "").normalize("NFKC"); } __name(saslprep, "saslprep"); var DEFAULT_MAX_SCRAM_ITERATIONS = 1e5; function startSession(mechanisms, stream, scramMaxIterations = DEFAULT_MAX_SCRAM_ITERATIONS) { const candidates = ["SCRAM-SHA-256"]; if (stream) candidates.unshift("SCRAM-SHA-256-PLUS"); const mechanism = candidates.find((candidate) => mechanisms.includes(candidate)); if (!mechanism) { throw new Error("SASL: Only mechanism(s) " + candidates.join(" and ") + " are supported"); } if (mechanism === "SCRAM-SHA-256-PLUS" && typeof stream.getPeerCertificate !== "function") { throw new Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate"); } const clientNonce = crypto.randomBytes(18).toString("base64"); const gs2Header = mechanism === "SCRAM-SHA-256-PLUS" ? "p=tls-server-end-point" : stream ? "y" : "n"; return { mechanism, clientNonce, response: gs2Header + ",,n=*,r=" + clientNonce, message: "SASLInitialResponse", scramMaxIterations }; } __name(startSession, "startSession"); async function continueSession(session, password, serverData, stream) { if (session.message !== "SASLInitialResponse") { throw new Error("SASL: Last message was not SASLInitialResponse"); } if (typeof password !== "string") { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string"); } if (password === "") { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string"); } if (typeof serverData !== "string") { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string"); } const sv = parseServerFirstMessage(serverData); if (!sv.nonce.startsWith(session.clientNonce)) { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce"); } else if (sv.nonce.length === session.clientNonce.length) { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short"); } const scramMaxIterations = typeof session.scramMaxIterations === "number" ? session.scramMaxIterations : DEFAULT_MAX_SCRAM_ITERATIONS; if (scramMaxIterations !== 0 && sv.iteration > scramMaxIterations) { throw new Error( "SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count " + sv.iteration + " exceeds scramMaxIterations of " + scramMaxIterations ); } const clientFirstMessageBare = "n=*,r=" + session.clientNonce; const serverFirstMessage = "r=" + sv.nonce + ",s=" + sv.salt + ",i=" + sv.iteration; let channelBinding = stream ? "eSws" : "biws"; if (session.mechanism === "SCRAM-SHA-256-PLUS") { const peerCert = stream.getPeerCertificate().raw; let hashName = signatureAlgorithmHashFromCertificate(peerCert); if (hashName === "MD5" || hashName === "SHA-1") hashName = "SHA-256"; const certHash = await crypto.hashByName(hashName, peerCert); const bindingData = Buffer.concat([Buffer.from("p=tls-server-end-point,,"), Buffer.from(certHash)]); channelBinding = bindingData.toString("base64"); } const clientFinalMessageWithoutProof = "c=" + channelBinding + ",r=" + sv.nonce; const authMessage = clientFirstMessageBare + "," + serverFirstMessage + "," + clientFinalMessageWithoutProof; const saltBytes = Buffer.from(sv.salt, "base64"); const saltedPassword = await crypto.deriveKey(saslprep(password), saltBytes, sv.iteration); const clientKey = await crypto.hmacSha256(saltedPassword, "Client Key"); const storedKey = await crypto.sha256(clientKey); const clientSignature = await crypto.hmacSha256(storedKey, authMessage); const clientProof = xorBuffers(Buffer.from(clientKey), Buffer.from(clientSignature)).toString("base64"); const serverKey = await crypto.hmacSha256(saltedPassword, "Server Key"); const serverSignatureBytes = await crypto.hmacSha256(serverKey, authMessage); session.message = "SASLResponse"; session.serverSignature = Buffer.from(serverSignatureBytes).toString("base64"); session.response = clientFinalMessageWithoutProof + ",p=" + clientProof; } __name(continueSession, "continueSession"); function finalizeSession(session, serverData) { if (session.message !== "SASLResponse") { throw new Error("SASL: Last message was not SASLResponse"); } if (typeof serverData !== "string") { throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string"); } const { serverSignature } = parseServerFinalMessage(serverData); if (serverSignature !== session.serverSignature) { throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match"); } } __name(finalizeSession, "finalizeSession"); function isPrintableChars(text) { if (typeof text !== "string") { throw new TypeError("SASL: text must be a string"); } return text.split("").map((_, i) => text.charCodeAt(i)).every((c) => c >= 33 && c <= 43 || c >= 45 && c <= 126); } __name(isPrintableChars, "isPrintableChars"); function isBase64(text) { return /^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(text); } __name(isBase64, "isBase64"); function parseAttributePairs(text) { if (typeof text !== "string") { throw new TypeError("SASL: attribute pairs text must be a string"); } return new Map( text.split(",").map((attrValue) => { if (!/^.=/.test(attrValue)) { throw new Error("SASL: Invalid attribute pair entry"); } const name = attrValue[0]; const value = attrValue.substring(2); return [name, value]; }) ); } __name(parseAttributePairs, "parseAttributePairs"); function parseServerFirstMessage(data) { const attrPairs = parseAttributePairs(data); const nonce = attrPairs.get("r"); if (!nonce) { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing"); } else if (!isPrintableChars(nonce)) { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters"); } const salt = attrPairs.get("s"); if (!salt) { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing"); } else if (!isBase64(salt)) { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64"); } const iterationText = attrPairs.get("i"); if (!iterationText) { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing"); } else if (!/^[1-9][0-9]*$/.test(iterationText)) { throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count"); } const iteration = parseInt(iterationText, 10); return { nonce, salt, iteration }; } __name(parseServerFirstMessage, "parseServerFirstMessage"); function parseServerFinalMessage(serverData) { const attrPairs = parseAttributePairs(serverData); const error = attrPairs.get("e"); const serverSignature = attrPairs.get("v"); if (error) { throw new Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${error}"`); } if (!serverSignature) { throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing"); } else if (!isBase64(serverSignature)) { throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64"); } return { serverSignature }; } __name(parseServerFinalMessage, "parseServerFinalMessage"); function xorBuffers(a, b) { if (!Buffer.isBuffer(a)) { throw new TypeError("first argument must be a Buffer"); } if (!Buffer.isBuffer(b)) { throw new TypeError("second argument must be a Buffer"); } if (a.length !== b.length) { throw new Error("Buffer lengths must match"); } if (a.length === 0) { throw new Error("Buffers cannot be empty"); } return Buffer.from(a.map((_, i) => a[i] ^ b[i])); } __name(xorBuffers, "xorBuffers"); module.exports = { startSession, continueSession, finalizeSession, DEFAULT_MAX_SCRAM_ITERATIONS }; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/type-overrides.js var require_type_overrides = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/type-overrides.js"(exports, module) { "use strict"; var types2 = require_pg_types(); function TypeOverrides2(userTypes) { this._types = userTypes || types2; this.text = {}; this.binary = {}; } __name(TypeOverrides2, "TypeOverrides"); TypeOverrides2.prototype.getOverrides = function(format) { switch (format) { case "text": return this.text; case "binary": return this.binary; default: return {}; } }; TypeOverrides2.prototype.setTypeParser = function(oid, format, parseFn) { if (typeof format === "function") { parseFn = format; format = "text"; } this.getOverrides(format)[oid] = parseFn; }; TypeOverrides2.prototype.getTypeParser = function(oid, format) { format = format || "text"; return this.getOverrides(format)[oid] || this._types.getTypeParser(oid, format); }; module.exports = TypeOverrides2; } }); // ../../node_modules/.pnpm/pg-connection-string@2.14.1/node_modules/pg-connection-string/index.js var require_pg_connection_string = __commonJS({ "../../node_modules/.pnpm/pg-connection-string@2.14.1/node_modules/pg-connection-string/index.js"(exports, module) { "use strict"; function parse(str, options = {}) { if (str.charAt(0) === "/") { const config2 = str.split(" "); return { host: config2[0], database: config2[1] }; } const config = /* @__PURE__ */ Object.create(null); let result; let dummyHost = false; if (/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str)) { str = encodeURI(str).replace(/%25(\d\d)/g, "%$1"); } try { try { result = new URL(str, "postgres://base"); } catch (e) { result = new URL(str.replace("@/", "@___DUMMY___/"), "postgres://base"); dummyHost = true; } } catch (err) { err.input && (err.input = "*****REDACTED*****"); throw err; } for (const entry of result.searchParams.entries()) { config[entry[0]] = entry[1]; } config.user = config.user || decodeURIComponent(result.username); config.password = config.password || decodeURIComponent(result.password); if (result.protocol == "socket:") { config.host = decodeURI(result.pathname); config.database = result.searchParams.get("db"); config.client_encoding = result.searchParams.get("encoding"); return config; } const hostname = (dummyHost ? "" : result.hostname).replace(/^\[(.+)\]$/, "$1"); if (!config.host) { config.host = decodeURIComponent(hostname); } else if (hostname && /^%2f/i.test(hostname)) { result.pathname = hostname + result.pathname; } if (!config.port) { config.port = result.port; } const pathname = result.pathname.slice(1) || null; config.database = pathname ? decodeURI(pathname) : null; if (config.ssl === "true" || config.ssl === "1") { config.ssl = true; } if (config.ssl === "0") { config.ssl = false; } if (config.sslcert || config.sslkey || config.sslrootcert || config.sslmode) { config.ssl = {}; } if (config.sslnegotiation === "direct" && config.ssl === void 0) { config.ssl = true; } const fs = config.sslcert || config.sslkey || config.sslrootcert ? __require("fs") : null; if (config.sslcert) { config.ssl.cert = fs.readFileSync(config.sslcert).toString(); } if (config.sslkey) { config.ssl.key = fs.readFileSync(config.sslkey).toString(); } if (config.sslrootcert) { config.ssl.ca = fs.readFileSync(config.sslrootcert).toString(); } if (options.useLibpqCompat && config.uselibpqcompat) { throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them."); } if (config.uselibpqcompat === "true" || options.useLibpqCompat) { switch (config.sslmode) { case "disable": { config.ssl = false; break; } case "prefer": { config.ssl.rejectUnauthorized = false; break; } case "require": { if (config.sslrootcert) { config.ssl.checkServerIdentity = function() { }; } else { config.ssl.rejectUnauthorized = false; } break; } case "verify-ca": { if (!config.ssl.ca) { throw new Error( "SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security." ); } config.ssl.checkServerIdentity = function() { }; break; } case "verify-full": { break; } } } else { switch (config.sslmode) { case "disable": { config.ssl = false; break; } case "prefer": case "require": case "verify-ca": case "verify-full": { if (config.sslmode !== "verify-full") { deprecatedSslModeWarning(config.sslmode); } break; } case "no-verify": { config.ssl.rejectUnauthorized = false; break; } } } return config; } __name(parse, "parse"); function toConnectionOptions(sslConfig) { const connectionOptions = Object.entries(sslConfig).reduce((c, [key, value]) => { if (value !== void 0 && value !== null) { c[key] = value; } return c; }, /* @__PURE__ */ Object.create(null)); return connectionOptions; } __name(toConnectionOptions, "toConnectionOptions"); function toClientConfig(config) { const poolConfig = Object.entries(config).reduce((c, [key, value]) => { if (key === "ssl") { const sslConfig = value; if (typeof sslConfig === "boolean") { c[key] = sslConfig; } if (typeof sslConfig === "object") { c[key] = toConnectionOptions(sslConfig); } } else if (value !== void 0 && value !== null) { if (key === "port") { if (value !== "") { const v = parseInt(value, 10); if (isNaN(v)) { throw new Error(`Invalid ${key}: ${value}`); } c[key] = v; } } else { c[key] = value; } } return c; }, /* @__PURE__ */ Object.create(null)); return poolConfig; } __name(toClientConfig, "toClientConfig"); function parseIntoClientConfig(str) { return toClientConfig(parse(str)); } __name(parseIntoClientConfig, "parseIntoClientConfig"); function deprecatedSslModeWarning(sslmode) { if (!deprecatedSslModeWarning.warned && typeof process !== "undefined" && process.emitWarning) { deprecatedSslModeWarning.warned = true; process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'. In the next major version (pg-connection-string v3.0.0 and pg v9.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees. To prepare for this change: - If you want the current behavior, explicitly use 'sslmode=verify-full' - If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${sslmode}' See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`); } } __name(deprecatedSslModeWarning, "deprecatedSslModeWarning"); module.exports = parse; parse.parse = parse; parse.toClientConfig = toClientConfig; parse.parseIntoClientConfig = parseIntoClientConfig; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/connection-parameters.js var require_connection_parameters = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/connection-parameters.js"(exports, module) { "use strict"; var dns = __require("dns"); var defaults2 = require_defaults(); var parse = require_pg_connection_string().parse; var val = /* @__PURE__ */ __name(function(key, config, envVar) { if (config[key]) { return config[key]; } if (envVar === void 0) { envVar = process.env["PG" + key.toUpperCase()]; } else if (envVar === false) { } else { envVar = process.env[envVar]; } return envVar || defaults2[key]; }, "val"); var readSSLConfigFromEnvironment = /* @__PURE__ */ __name(function() { switch (process.env.PGSSLMODE) { case "disable": return false; case "prefer": case "require": case "verify-ca": case "verify-full": return true; case "no-verify": return { rejectUnauthorized: false }; } return defaults2.ssl; }, "readSSLConfigFromEnvironment"); var quoteParamValue = /* @__PURE__ */ __name(function(value) { return "'" + ("" + value).replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'"; }, "quoteParamValue"); var add = /* @__PURE__ */ __name(function(params, config, paramName) { const value = config[paramName]; if (value !== void 0 && value !== null) { params.push(paramName + "=" + quoteParamValue(value)); } }, "add"); var ConnectionParameters = class { static { __name(this, "ConnectionParameters"); } constructor(config) { config = typeof config === "string" ? parse(config) : config || {}; if (config.connectionString) { config = Object.assign({}, config, parse(config.connectionString)); } this.user = val("user", config); this.database = val("database", config); if (this.database === void 0) { this.database = this.user; } this.port = parseInt(val("port", config), 10); this.host = val("host", config); Object.defineProperty(this, "password", { configurable: true, enumerable: false, writable: true, value: val("password", config) }); this.binary = val("binary", config); this.options = val("options", config); this.ssl = typeof config.ssl === "undefined" ? readSSLConfigFromEnvironment() : config.ssl; if (typeof this.ssl === "string") { if (this.ssl === "true") { this.ssl = true; } } if (this.ssl === "no-verify") { this.ssl = { rejectUnauthorized: false }; } if (this.ssl && this.ssl.key) { Object.defineProperty(this.ssl, "key", { enumerable: false }); } this.sslnegotiation = val("sslnegotiation", config, "PGSSLNEGOTIATION"); if (this.sslnegotiation !== void 0 && this.sslnegotiation !== "postgres" && this.sslnegotiation !== "direct") { throw new Error( `Invalid sslnegotiation value: "${this.sslnegotiation}". Valid values are "postgres" and "direct".` ); } if (this.sslnegotiation === "direct" && !this.ssl) { throw new Error("sslnegotiation=direct requires SSL to be enabled"); } this.client_encoding = val("client_encoding", config); this.replication = val("replication", config); this.isDomainSocket = !(this.host || "").indexOf("/"); this.application_name = val("application_name", config, "PGAPPNAME"); this.fallback_application_name = val("fallback_application_name", config, false); this.statement_timeout = val("statement_timeout", config, false); this.lock_timeout = val("lock_timeout", config, false); this.idle_in_transaction_session_timeout = val("idle_in_transaction_session_timeout", config, false); this.query_timeout = val("query_timeout", config, false); if (config.connectionTimeoutMillis === void 0) { this.connect_timeout = process.env.PGCONNECT_TIMEOUT || 0; } else { this.connect_timeout = Math.floor(config.connectionTimeoutMillis / 1e3); } if (config.keepAlive === false) { this.keepalives = 0; } else if (config.keepAlive === true) { this.keepalives = 1; } if (typeof config.keepAliveInitialDelayMillis === "number") { this.keepalives_idle = Math.floor(config.keepAliveInitialDelayMillis / 1e3); } } getLibpqConnectionString(cb) { const params = []; add(params, this, "user"); add(params, this, "password"); add(params, this, "port"); add(params, this, "application_name"); add(params, this, "fallback_application_name"); add(params, this, "connect_timeout"); add(params, this, "options"); const ssl = typeof this.ssl === "object" ? this.ssl : this.ssl ? { sslmode: this.ssl } : {}; add(params, ssl, "sslmode"); add(params, ssl, "sslca"); add(params, ssl, "sslkey"); add(params, ssl, "sslcert"); add(params, ssl, "sslrootcert"); add(params, this, "sslnegotiation"); if (this.database) { params.push("dbname=" + quoteParamValue(this.database)); } if (this.replication) { params.push("replication=" + quoteParamValue(this.replication)); } if (this.host) { params.push("host=" + quoteParamValue(this.host)); } if (this.isDomainSocket) { return cb(null, params.join(" ")); } if (this.client_encoding) { params.push("client_encoding=" + quoteParamValue(this.client_encoding)); } dns.lookup(this.host, function(err, address) { if (err) return cb(err, null); params.push("hostaddr=" + quoteParamValue(address)); return cb(null, params.join(" ")); }); } }; module.exports = ConnectionParameters; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/result.js var require_result = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/result.js"(exports, module) { "use strict"; var types2 = require_pg_types(); var matchRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/; var Result2 = class { static { __name(this, "Result"); } constructor(rowMode, types3) { this.command = null; this.rowCount = null; this.oid = null; this.rows = []; this.fields = []; this._parsers = void 0; this._types = types3; this.RowCtor = null; this.rowAsArray = rowMode === "array"; if (this.rowAsArray) { this.parseRow = this._parseRowAsArray; } this._prebuiltEmptyResultObject = null; } // adds a command complete message addCommandComplete(msg) { let match; if (msg.text) { match = matchRegexp.exec(msg.text); } else { match = matchRegexp.exec(msg.command); } if (match) { this.command = match[1]; if (match[3]) { this.oid = parseInt(match[2], 10); this.rowCount = parseInt(match[3], 10); } else if (match[2]) { this.rowCount = parseInt(match[2], 10); } } } _parseRowAsArray(rowData) { const row = new Array(rowData.length); for (let i = 0, len = rowData.length; i < len; i++) { const rawValue = rowData[i]; if (rawValue !== null) { row[i] = this._parsers[i](rawValue); } else { row[i] = null; } } return row; } parseRow(rowData) { const row = { ...this._prebuiltEmptyResultObject }; for (let i = 0, len = rowData.length; i < len; i++) { const rawValue = rowData[i]; const field = this.fields[i].name; if (rawValue !== null) { const v = this.fields[i].format === "binary" ? Buffer.from(rawValue) : rawValue; row[field] = this._parsers[i](v); } else { row[field] = null; } } return row; } addRow(row) { this.rows.push(row); } addFields(fieldDescriptions) { this.fields = fieldDescriptions; if (this.fields.length) { this._parsers = new Array(fieldDescriptions.length); } const row = /* @__PURE__ */ Object.create(null); for (let i = 0; i < fieldDescriptions.length; i++) { const desc = fieldDescriptions[i]; row[desc.name] = null; if (this._types) { this._parsers[i] = this._types.getTypeParser(desc.dataTypeID, desc.format || "text"); } else { this._parsers[i] = types2.getTypeParser(desc.dataTypeID, desc.format || "text"); } } this._prebuiltEmptyResultObject = { ...row }; } }; module.exports = Result2; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/query.js var require_query = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/query.js"(exports, module) { "use strict"; var { EventEmitter } = __require("events"); var Result2 = require_result(); var utils = require_utils(); var Query2 = class extends EventEmitter { static { __name(this, "Query"); } constructor(config, values, callback) { super(); config = utils.normalizeQueryConfig(config, values, callback); this.text = config.text; this.values = config.values; this.rows = config.rows; this.types = config.types; this.name = config.name; this.queryMode = config.queryMode; this.binary = config.binary; this.portal = config.portal || ""; this.callback = config.callback; this._rowMode = config.rowMode; if (process.domain && config.callback) { this.callback = process.domain.bind(config.callback); } this._result = new Result2(this._rowMode, this.types); this._results = this._result; this._canceledDueToError = false; } requiresPreparation() { if (this.queryMode === "extended") { return true; } if (this.name) { return true; } if (this.rows) { return true; } if (!this.text) { return false; } if (!this.values) { return false; } return this.values.length > 0; } _checkForMultirow() { if (this._result.command) { if (!Array.isArray(this._results)) { this._results = [this._result]; } this._result = new Result2(this._rowMode, this._result._types); this._results.push(this._result); } } // associates row metadata from the supplied // message with this query object // metadata used when parsing row results handleRowDescription(msg) { this._checkForMultirow(); this._result.addFields(msg.fields); this._accumulateRows = this.callback || !this.listeners("row").length; } handleDataRow(msg) { let row; if (this._canceledDueToError) { return; } try { row = this._result.parseRow(msg.fields); } catch (err) { this._canceledDueToError = err; return; } this.emit("row", row, this._result); if (this._accumulateRows) { this._result.addRow(row); } } handleCommandComplete(msg, connection) { this._checkForMultirow(); this._result.addCommandComplete(msg); if (this.rows) { connection.sync(); } } // if a named prepared statement is created with empty query text // the backend will send an emptyQuery message but *not* a command complete message // since we pipeline sync immediately after execute we don't need to do anything here // unless we have rows specified, in which case we did not pipeline the initial sync call handleEmptyQuery(connection) { if (this.rows) { connection.sync(); } } handleError(err, connection) { if (this._canceledDueToError) { err = this._canceledDueToError; this._canceledDueToError = false; } if (this.callback) { return this.callback(err); } this.emit("error", err); } handleReadyForQuery(con) { if (this._canceledDueToError) { return this.handleError(this._canceledDueToError, con); } if (this.callback) { try { this.callback(null, this._results); } catch (err) { process.nextTick(() => { throw err; }); } } this.emit("end", this._results); } submit(connection) { if (typeof this.text !== "string" && typeof this.name !== "string") { return new Error("A query must have either text or a name. Supplying neither is unsupported."); } const previous = connection.parsedStatements[this.name] || connection.submittedNamedStatements[this.name]; if (this.text && previous && this.text !== previous) { return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`); } if (this.values && !Array.isArray(this.values)) { return new Error("Query values must be an array"); } if (this.requiresPreparation()) { connection.stream.cork && connection.stream.cork(); try { this.prepare(connection); } finally { connection.stream.uncork && connection.stream.uncork(); } } else { connection.query(this.text); } return null; } hasBeenParsed(connection) { return this.name && (connection.parsedStatements[this.name] !== void 0 || connection.submittedNamedStatements[this.name] !== void 0); } handlePortalSuspended(connection) { this._getRows(connection, this.rows); } _getRows(connection, rows) { connection.execute({ portal: this.portal, rows }); if (!rows) { connection.sync(); } else { connection.flush(); } } // http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY prepare(connection) { if (!this.hasBeenParsed(connection)) { connection.parse({ text: this.text, name: this.name, types: this.types }); if (this.name) { connection.submittedNamedStatements[this.name] = this.text; } } try { connection.bind({ portal: this.portal, statement: this.name, values: this.values, binary: this.binary, valueMapper: utils.prepareValue }); } catch (err) { connection.close({ type: "S", name: this.name }); connection.sync(); this.handleError(err, connection); return; } connection.describe({ type: "P", name: this.portal || "" }); this._getRows(connection, this.rows); } handleCopyInResponse(connection) { connection.sendCopyFail("No source stream defined"); } handleCopyData(msg, connection) { } }; module.exports = Query2; } }); // ../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/messages.js var require_messages = __commonJS({ "../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/messages.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NoticeMessage = exports.DataRowMessage = exports.CommandCompleteMessage = exports.ReadyForQueryMessage = exports.NotificationResponseMessage = exports.BackendKeyDataMessage = exports.AuthenticationMD5Password = exports.ParameterStatusMessage = exports.ParameterDescriptionMessage = exports.RowDescriptionMessage = exports.Field = exports.CopyResponse = exports.CopyDataMessage = exports.DatabaseError = exports.copyDone = exports.emptyQuery = exports.replicationStart = exports.portalSuspended = exports.noData = exports.closeComplete = exports.bindComplete = exports.parseComplete = void 0; exports.parseComplete = { name: "parseComplete", length: 5 }; exports.bindComplete = { name: "bindComplete", length: 5 }; exports.closeComplete = { name: "closeComplete", length: 5 }; exports.noData = { name: "noData", length: 5 }; exports.portalSuspended = { name: "portalSuspended", length: 5 }; exports.replicationStart = { name: "replicationStart", length: 4 }; exports.emptyQuery = { name: "emptyQuery", length: 4 }; exports.copyDone = { name: "copyDone", length: 4 }; var DatabaseError2 = class extends Error { static { __name(this, "DatabaseError"); } constructor(message, length, name) { super(message); this.length = length; this.name = name; } }; exports.DatabaseError = DatabaseError2; var CopyDataMessage = class { static { __name(this, "CopyDataMessage"); } constructor(length, chunk) { this.length = length; this.chunk = chunk; this.name = "copyData"; } }; exports.CopyDataMessage = CopyDataMessage; var CopyResponse = class { static { __name(this, "CopyResponse"); } constructor(length, name, binary, columnCount) { this.length = length; this.name = name; this.binary = binary; this.columnTypes = new Array(columnCount); } }; exports.CopyResponse = CopyResponse; var Field = class { static { __name(this, "Field"); } constructor(name, tableID, columnID, dataTypeID, dataTypeSize, dataTypeModifier, format) { this.name = name; this.tableID = tableID; this.columnID = columnID; this.dataTypeID = dataTypeID; this.dataTypeSize = dataTypeSize; this.dataTypeModifier = dataTypeModifier; this.format = format; } }; exports.Field = Field; var RowDescriptionMessage = class { static { __name(this, "RowDescriptionMessage"); } constructor(length, fieldCount) { this.length = length; this.fieldCount = fieldCount; this.name = "rowDescription"; this.fields = new Array(this.fieldCount); } }; exports.RowDescriptionMessage = RowDescriptionMessage; var ParameterDescriptionMessage = class { static { __name(this, "ParameterDescriptionMessage"); } constructor(length, parameterCount) { this.length = length; this.parameterCount = parameterCount; this.name = "parameterDescription"; this.dataTypeIDs = new Array(this.parameterCount); } }; exports.ParameterDescriptionMessage = ParameterDescriptionMessage; var ParameterStatusMessage = class { static { __name(this, "ParameterStatusMessage"); } constructor(length, parameterName, parameterValue) { this.length = length; this.parameterName = parameterName; this.parameterValue = parameterValue; this.name = "parameterStatus"; } }; exports.ParameterStatusMessage = ParameterStatusMessage; var AuthenticationMD5Password = class { static { __name(this, "AuthenticationMD5Password"); } constructor(length, salt) { this.length = length; this.salt = salt; this.name = "authenticationMD5Password"; } }; exports.AuthenticationMD5Password = AuthenticationMD5Password; var BackendKeyDataMessage = class { static { __name(this, "BackendKeyDataMessage"); } constructor(length, processID, secretKey) { this.length = length; this.processID = processID; this.secretKey = secretKey; this.name = "backendKeyData"; } }; exports.BackendKeyDataMessage = BackendKeyDataMessage; var NotificationResponseMessage = class { static { __name(this, "NotificationResponseMessage"); } constructor(length, processId, channel, payload) { this.length = length; this.processId = processId; this.channel = channel; this.payload = payload; this.name = "notification"; } }; exports.NotificationResponseMessage = NotificationResponseMessage; var ReadyForQueryMessage = class { static { __name(this, "ReadyForQueryMessage"); } constructor(length, status) { this.length = length; this.status = status; this.name = "readyForQuery"; } }; exports.ReadyForQueryMessage = ReadyForQueryMessage; var CommandCompleteMessage = class { static { __name(this, "CommandCompleteMessage"); } constructor(length, text) { this.length = length; this.text = text; this.name = "commandComplete"; } }; exports.CommandCompleteMessage = CommandCompleteMessage; var DataRowMessage = class { static { __name(this, "DataRowMessage"); } constructor(length, fields) { this.length = length; this.fields = fields; this.name = "dataRow"; this.fieldCount = fields.length; } }; exports.DataRowMessage = DataRowMessage; var NoticeMessage = class { static { __name(this, "NoticeMessage"); } constructor(length, message) { this.length = length; this.message = message; this.name = "notice"; } }; exports.NoticeMessage = NoticeMessage; } }); // ../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/buffer-writer.js var require_buffer_writer = __commonJS({ "../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/buffer-writer.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Writer = void 0; var Writer = class { static { __name(this, "Writer"); } constructor(size = 256) { this.size = size; this.offset = 5; this.headerPosition = 0; this.buffer = Buffer.allocUnsafe(size); } ensure(size) { const remaining = this.buffer.length - this.offset; if (remaining < size) { const oldBuffer = this.buffer; const newSize = oldBuffer.length + (oldBuffer.length >> 1) + size; this.buffer = Buffer.allocUnsafe(newSize); oldBuffer.copy(this.buffer, 0, 0, this.offset); } } addInt32(num) { this.ensure(4); this.buffer[this.offset++] = num >>> 24 & 255; this.buffer[this.offset++] = num >>> 16 & 255; this.buffer[this.offset++] = num >>> 8 & 255; this.buffer[this.offset++] = num >>> 0 & 255; return this; } addInt16(num) { this.ensure(2); this.buffer[this.offset++] = num >>> 8 & 255; this.buffer[this.offset++] = num >>> 0 & 255; return this; } addCString(string) { if (!string) { this.ensure(1); } else { const len = Buffer.byteLength(string); this.ensure(len + 1); this.buffer.write(string, this.offset, "utf-8"); this.offset += len; } this.buffer[this.offset++] = 0; return this; } addString(string = "") { const len = Buffer.byteLength(string); this.ensure(len); this.buffer.write(string, this.offset); this.offset += len; return this; } // Write an Int32 byte-length prefix immediately followed by the string's UTF-8 // bytes. Postgres' Bind wire format prefixes every parameter with its length, // and doing it in one method computes Buffer.byteLength ONCE — the previous // `addInt32(Buffer.byteLength(s)).addString(s)` pairing scanned the string // three times (byteLength for the prefix, byteLength again inside addString, // then the encode), which is costly for large text parameters. addInt32PrefixedString(string) { const len = Buffer.byteLength(string); this.ensure(4 + len); const buffer = this.buffer; let offset = this.offset; buffer[offset++] = len >>> 24 & 255; buffer[offset++] = len >>> 16 & 255; buffer[offset++] = len >>> 8 & 255; buffer[offset++] = len >>> 0 & 255; buffer.write(string, offset, "utf-8"); this.offset = offset + len; return this; } add(otherBuffer) { this.ensure(otherBuffer.length); otherBuffer.copy(this.buffer, this.offset); this.offset += otherBuffer.length; return this; } /** * Appends an uninitialized block of {@link size} bytes to the buffer and returns its offset. */ reserveUnsafe(size) { const offset = this.offset; this.ensure(size); this.offset += size; return offset; } join(code) { if (code) { this.buffer[this.headerPosition] = code; const length = this.offset - (this.headerPosition + 1); this.buffer.writeInt32BE(length, this.headerPosition + 1); } return this.buffer.slice(code ? 0 : 5, this.offset); } flush(code) { const result = this.join(code); this.offset = 5; this.headerPosition = 0; this.buffer = Buffer.allocUnsafe(this.size); return result; } clear() { this.offset = 5; this.headerPosition = 0; } }; exports.Writer = Writer; } }); // ../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/serializer.js var require_serializer = __commonJS({ "../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/serializer.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.serialize = void 0; var buffer_writer_1 = require_buffer_writer(); var writer = new buffer_writer_1.Writer(); var startup = /* @__PURE__ */ __name((opts) => { writer.addInt16(3).addInt16(0); for (const key of Object.keys(opts)) { writer.addCString(key).addCString(opts[key]); } writer.addCString("client_encoding").addCString("UTF8"); const bodyBuffer = writer.addCString("").flush(); const length = bodyBuffer.length + 4; return new buffer_writer_1.Writer().addInt32(length).add(bodyBuffer).flush(); }, "startup"); var requestSsl = /* @__PURE__ */ __name(() => { const response = Buffer.allocUnsafe(8); response.writeInt32BE(8, 0); response.writeInt32BE(80877103, 4); return response; }, "requestSsl"); var password = /* @__PURE__ */ __name((password2) => { return writer.addCString(password2).flush( 112 /* code.startup */ ); }, "password"); var sendSASLInitialResponseMessage = /* @__PURE__ */ __name(function(mechanism, initialResponse) { writer.addCString(mechanism).addInt32PrefixedString(initialResponse); return writer.flush( 112 /* code.startup */ ); }, "sendSASLInitialResponseMessage"); var sendSCRAMClientFinalMessage = /* @__PURE__ */ __name(function(additionalData) { return writer.addString(additionalData).flush( 112 /* code.startup */ ); }, "sendSCRAMClientFinalMessage"); var query = /* @__PURE__ */ __name((text) => { return writer.addCString(text).flush( 81 /* code.query */ ); }, "query"); var emptyArray = []; var parse = /* @__PURE__ */ __name((query2) => { const name = query2.name || ""; if (name.length > 63) { console.error("Warning! Postgres only supports 63 characters for query names."); console.error("You supplied %s (%s)", name, name.length); console.error("This can cause conflicts and silent errors executing queries"); } const types2 = query2.types || emptyArray; const len = types2.length; const buffer = writer.addCString(name).addCString(query2.text).addInt16(len); for (let i = 0; i < len; i++) { buffer.addInt32(types2[i]); } return writer.flush( 80 /* code.parse */ ); }, "parse"); var writeValues = /* @__PURE__ */ __name(function(values, valueMapper, formatsOffset) { const len = values.length; for (let i = 0; i < len; i++) { const mappedVal = valueMapper ? valueMapper(values[i], i) : values[i]; let formatByte = 0; if (mappedVal == null) { writer.addInt32(-1); } else if (mappedVal instanceof Buffer) { formatByte = 1; writer.addInt32(mappedVal.length); writer.add(mappedVal); } else { writer.addInt32PrefixedString(mappedVal); } const buf = writer.buffer; buf[formatsOffset++] = 0; buf[formatsOffset++] = formatByte; } }, "writeValues"); var bind = /* @__PURE__ */ __name((config = {}) => { const portal = config.portal || ""; const statement = config.statement || ""; const binary = config.binary || false; const values = config.values || emptyArray; const len = values.length; writer.addCString(portal).addCString(statement); writer.addInt16(len); const formatsOffset = writer.reserveUnsafe(len * 2); writer.addInt16(len); try { writeValues(values, config.valueMapper, formatsOffset); } catch (err) { writer.clear(); throw err; } writer.addInt16(1); writer.addInt16( binary ? 1 : 0 /* ParamType.STRING */ ); return writer.flush( 66 /* code.bind */ ); }, "bind"); var emptyExecute = Buffer.from([69, 0, 0, 0, 9, 0, 0, 0, 0, 0]); var execute = /* @__PURE__ */ __name((config) => { if (!config || !config.portal && !config.rows) { return emptyExecute; } const portal = config.portal || ""; const rows = config.rows || 0; const portalLength = Buffer.byteLength(portal); const len = 4 + portalLength + 1 + 4; const buff = Buffer.allocUnsafe(1 + len); buff[0] = 69; buff.writeInt32BE(len, 1); buff.write(portal, 5, "utf-8"); buff[portalLength + 5] = 0; buff.writeUInt32BE(rows, buff.length - 4); return buff; }, "execute"); var cancel = /* @__PURE__ */ __name((processID, secretKey) => { const buffer = Buffer.allocUnsafe(16); buffer.writeInt32BE(16, 0); buffer.writeInt16BE(1234, 4); buffer.writeInt16BE(5678, 6); buffer.writeInt32BE(processID, 8); buffer.writeInt32BE(secretKey, 12); return buffer; }, "cancel"); var cstringMessage = /* @__PURE__ */ __name((code, string) => { const stringLen = Buffer.byteLength(string); const len = 4 + stringLen + 1; const buffer = Buffer.allocUnsafe(1 + len); buffer[0] = code; buffer.writeInt32BE(len, 1); buffer.write(string, 5, "utf-8"); buffer[len] = 0; return buffer; }, "cstringMessage"); var emptyDescribePortal = writer.addCString("P").flush( 68 /* code.describe */ ); var emptyDescribeStatement = writer.addCString("S").flush( 68 /* code.describe */ ); var describe = /* @__PURE__ */ __name((msg) => { return msg.name ? cstringMessage(68, `${msg.type}${msg.name || ""}`) : msg.type === "P" ? emptyDescribePortal : emptyDescribeStatement; }, "describe"); var close = /* @__PURE__ */ __name((msg) => { const text = `${msg.type}${msg.name || ""}`; return cstringMessage(67, text); }, "close"); var copyData = /* @__PURE__ */ __name((chunk) => { return writer.add(chunk).flush( 100 /* code.copyFromChunk */ ); }, "copyData"); var copyFail = /* @__PURE__ */ __name((message) => { return cstringMessage(102, message); }, "copyFail"); var codeOnlyBuffer = /* @__PURE__ */ __name((code) => Buffer.from([code, 0, 0, 0, 4]), "codeOnlyBuffer"); var flushBuffer = codeOnlyBuffer( 72 /* code.flush */ ); var syncBuffer = codeOnlyBuffer( 83 /* code.sync */ ); var endBuffer = codeOnlyBuffer( 88 /* code.end */ ); var copyDoneBuffer = codeOnlyBuffer( 99 /* code.copyDone */ ); var serialize = { startup, password, requestSsl, sendSASLInitialResponseMessage, sendSCRAMClientFinalMessage, query, parse, bind, execute, describe, close, flush: /* @__PURE__ */ __name(() => flushBuffer, "flush"), sync: /* @__PURE__ */ __name(() => syncBuffer, "sync"), end: /* @__PURE__ */ __name(() => endBuffer, "end"), copyData, copyDone: /* @__PURE__ */ __name(() => copyDoneBuffer, "copyDone"), copyFail, cancel }; exports.serialize = serialize; } }); // ../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/buffer-reader.js var require_buffer_reader = __commonJS({ "../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/buffer-reader.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BufferReader = void 0; var BufferReader = class { static { __name(this, "BufferReader"); } constructor(offset = 0) { this.offset = offset; this.buffer = Buffer.allocUnsafe(0); this.encoding = "utf-8"; } setBuffer(offset, buffer) { this.offset = offset; this.buffer = buffer; } int16() { const result = this.buffer.readInt16BE(this.offset); this.offset += 2; return result; } byte() { const result = this.buffer[this.offset]; this.offset++; return result; } int32() { const result = this.buffer.readInt32BE(this.offset); this.offset += 4; return result; } uint32() { const result = this.buffer.readUInt32BE(this.offset); this.offset += 4; return result; } string(length) { const result = this.buffer.toString(this.encoding, this.offset, this.offset + length); this.offset += length; return result; } cstring() { const start = this.offset; let end = start; while (this.buffer[end++]) { } this.offset = end; return this.buffer.toString(this.encoding, start, end - 1); } bytes(length) { const result = this.buffer.slice(this.offset, this.offset + length); this.offset += length; return result; } }; exports.BufferReader = BufferReader; } }); // ../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/parser.js var require_parser = __commonJS({ "../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/parser.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Parser = void 0; var messages_1 = require_messages(); var buffer_reader_1 = require_buffer_reader(); var CODE_LENGTH = 1; var LEN_LENGTH = 4; var HEADER_LENGTH = CODE_LENGTH + LEN_LENGTH; var LATEINIT_LENGTH = -1; var emptyBuffer = Buffer.allocUnsafe(0); var Parser = class { static { __name(this, "Parser"); } constructor(opts) { this.buffer = emptyBuffer; this.bufferLength = 0; this.bufferOffset = 0; this.reader = new buffer_reader_1.BufferReader(); if ((opts === null || opts === void 0 ? void 0 : opts.mode) === "binary") { throw new Error("Binary mode not supported yet"); } this.mode = (opts === null || opts === void 0 ? void 0 : opts.mode) || "text"; } parse(buffer, callback) { this.mergeBuffer(buffer); const bufferFullLength = this.bufferOffset + this.bufferLength; let offset = this.bufferOffset; while (offset + HEADER_LENGTH <= bufferFullLength) { const code = this.buffer[offset]; const length = this.buffer.readUInt32BE(offset + CODE_LENGTH); const fullMessageLength = CODE_LENGTH + length; if (fullMessageLength + offset <= bufferFullLength) { const message = this.handlePacket(offset + HEADER_LENGTH, code, length, this.buffer); callback(message); offset += fullMessageLength; } else { break; } } if (offset === bufferFullLength) { this.buffer = emptyBuffer; this.bufferLength = 0; this.bufferOffset = 0; } else { this.bufferLength = bufferFullLength - offset; this.bufferOffset = offset; } } mergeBuffer(buffer) { if (this.bufferLength > 0) { const newLength = this.bufferLength + buffer.byteLength; const newFullLength = newLength + this.bufferOffset; if (newFullLength > this.buffer.byteLength) { let newBuffer; if (newLength <= this.buffer.byteLength && this.bufferOffset >= this.bufferLength) { newBuffer = this.buffer; } else { let newBufferLength = this.buffer.byteLength * 2; while (newLength >= newBufferLength) { newBufferLength *= 2; } newBuffer = Buffer.allocUnsafe(newBufferLength); } this.buffer.copy(newBuffer, 0, this.bufferOffset, this.bufferOffset + this.bufferLength); this.buffer = newBuffer; this.bufferOffset = 0; } buffer.copy(this.buffer, this.bufferOffset + this.bufferLength); this.bufferLength = newLength; } else { this.buffer = buffer; this.bufferOffset = 0; this.bufferLength = buffer.byteLength; } } handlePacket(offset, code, length, bytes) { const { reader } = this; reader.setBuffer(offset, bytes); let message; switch (code) { case 50: message = messages_1.bindComplete; break; case 49: message = messages_1.parseComplete; break; case 51: message = messages_1.closeComplete; break; case 110: message = messages_1.noData; break; case 115: message = messages_1.portalSuspended; break; case 99: message = messages_1.copyDone; break; case 87: message = messages_1.replicationStart; break; case 73: message = messages_1.emptyQuery; break; case 68: message = parseDataRowMessage(reader); break; case 67: message = parseCommandCompleteMessage(reader); break; case 90: message = parseReadyForQueryMessage(reader); break; case 65: message = parseNotificationMessage(reader); break; case 82: message = parseAuthenticationResponse(reader, length); break; case 83: message = parseParameterStatusMessage(reader); break; case 75: message = parseBackendKeyData(reader); break; case 69: message = parseErrorMessage(reader, "error"); break; case 78: message = parseErrorMessage(reader, "notice"); break; case 84: message = parseRowDescriptionMessage(reader); break; case 116: message = parseParameterDescriptionMessage(reader); break; case 71: message = parseCopyInMessage(reader); break; case 72: message = parseCopyOutMessage(reader); break; case 100: message = parseCopyData(reader, length); break; default: return new messages_1.DatabaseError("received invalid response: " + code.toString(16), length, "error"); } reader.setBuffer(0, emptyBuffer); message.length = length; return message; } }; exports.Parser = Parser; var parseReadyForQueryMessage = /* @__PURE__ */ __name((reader) => { const status = reader.string(1); return new messages_1.ReadyForQueryMessage(LATEINIT_LENGTH, status); }, "parseReadyForQueryMessage"); var parseCommandCompleteMessage = /* @__PURE__ */ __name((reader) => { const text = reader.cstring(); return new messages_1.CommandCompleteMessage(LATEINIT_LENGTH, text); }, "parseCommandCompleteMessage"); var parseCopyData = /* @__PURE__ */ __name((reader, length) => { const chunk = reader.bytes(length - 4); return new messages_1.CopyDataMessage(LATEINIT_LENGTH, chunk); }, "parseCopyData"); var parseCopyInMessage = /* @__PURE__ */ __name((reader) => parseCopyMessage(reader, "copyInResponse"), "parseCopyInMessage"); var parseCopyOutMessage = /* @__PURE__ */ __name((reader) => parseCopyMessage(reader, "copyOutResponse"), "parseCopyOutMessage"); var parseCopyMessage = /* @__PURE__ */ __name((reader, messageName) => { const isBinary = reader.byte() !== 0; const columnCount = reader.int16(); const message = new messages_1.CopyResponse(LATEINIT_LENGTH, messageName, isBinary, columnCount); for (let i = 0; i < columnCount; i++) { message.columnTypes[i] = reader.int16(); } return message; }, "parseCopyMessage"); var parseNotificationMessage = /* @__PURE__ */ __name((reader) => { const processId = reader.int32(); const channel = reader.cstring(); const payload = reader.cstring(); return new messages_1.NotificationResponseMessage(LATEINIT_LENGTH, processId, channel, payload); }, "parseNotificationMessage"); var parseRowDescriptionMessage = /* @__PURE__ */ __name((reader) => { const fieldCount = reader.int16(); const message = new messages_1.RowDescriptionMessage(LATEINIT_LENGTH, fieldCount); for (let i = 0; i < fieldCount; i++) { message.fields[i] = parseField(reader); } return message; }, "parseRowDescriptionMessage"); var parseField = /* @__PURE__ */ __name((reader) => { const name = reader.cstring(); const tableID = reader.uint32(); const columnID = reader.int16(); const dataTypeID = reader.uint32(); const dataTypeSize = reader.int16(); const dataTypeModifier = reader.int32(); const mode = reader.int16() === 0 ? "text" : "binary"; return new messages_1.Field(name, tableID, columnID, dataTypeID, dataTypeSize, dataTypeModifier, mode); }, "parseField"); var parseParameterDescriptionMessage = /* @__PURE__ */ __name((reader) => { const parameterCount = reader.int16(); const message = new messages_1.ParameterDescriptionMessage(LATEINIT_LENGTH, parameterCount); for (let i = 0; i < parameterCount; i++) { message.dataTypeIDs[i] = reader.uint32(); } return message; }, "parseParameterDescriptionMessage"); var parseDataRowMessage = /* @__PURE__ */ __name((reader) => { const fieldCount = reader.int16(); const fields = new Array(fieldCount); for (let i = 0; i < fieldCount; i++) { const len = reader.int32(); fields[i] = len === -1 ? null : reader.string(len); } return new messages_1.DataRowMessage(LATEINIT_LENGTH, fields); }, "parseDataRowMessage"); var parseParameterStatusMessage = /* @__PURE__ */ __name((reader) => { const name = reader.cstring(); const value = reader.cstring(); return new messages_1.ParameterStatusMessage(LATEINIT_LENGTH, name, value); }, "parseParameterStatusMessage"); var parseBackendKeyData = /* @__PURE__ */ __name((reader) => { const processID = reader.int32(); const secretKey = reader.int32(); return new messages_1.BackendKeyDataMessage(LATEINIT_LENGTH, processID, secretKey); }, "parseBackendKeyData"); var parseAuthenticationResponse = /* @__PURE__ */ __name((reader, length) => { const code = reader.int32(); const message = { name: "authenticationOk", length }; switch (code) { case 0: break; case 3: if (message.length === 8) { message.name = "authenticationCleartextPassword"; } break; case 5: if (message.length === 12) { message.name = "authenticationMD5Password"; const salt = reader.bytes(4); return new messages_1.AuthenticationMD5Password(LATEINIT_LENGTH, salt); } break; case 10: { message.name = "authenticationSASL"; message.mechanisms = []; let mechanism; do { mechanism = reader.cstring(); if (mechanism) { message.mechanisms.push(mechanism); } } while (mechanism); } break; case 11: message.name = "authenticationSASLContinue"; message.data = reader.string(length - 8); break; case 12: message.name = "authenticationSASLFinal"; message.data = reader.string(length - 8); break; default: throw new Error("Unknown authenticationOk message type " + code); } return message; }, "parseAuthenticationResponse"); var parseErrorMessage = /* @__PURE__ */ __name((reader, name) => { const fields = {}; let fieldType = reader.string(1); while (fieldType !== "\0") { fields[fieldType] = reader.cstring(); fieldType = reader.string(1); } const messageValue = fields.M; const message = name === "notice" ? new messages_1.NoticeMessage(LATEINIT_LENGTH, messageValue) : new messages_1.DatabaseError(messageValue, LATEINIT_LENGTH, name); message.severity = fields.S; message.code = fields.C; message.detail = fields.D; message.hint = fields.H; message.position = fields.P; message.internalPosition = fields.p; message.internalQuery = fields.q; message.where = fields.W; message.schema = fields.s; message.table = fields.t; message.column = fields.c; message.dataType = fields.d; message.constraint = fields.n; message.file = fields.F; message.line = fields.L; message.routine = fields.R; return message; }, "parseErrorMessage"); } }); // ../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/index.js var require_dist = __commonJS({ "../../node_modules/.pnpm/pg-protocol@1.16.1/node_modules/pg-protocol/dist/index.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DatabaseError = exports.serialize = void 0; exports.parse = parse; var messages_1 = require_messages(); Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: /* @__PURE__ */ __name(function() { return messages_1.DatabaseError; }, "get") }); var serializer_1 = require_serializer(); Object.defineProperty(exports, "serialize", { enumerable: true, get: /* @__PURE__ */ __name(function() { return serializer_1.serialize; }, "get") }); var parser_1 = require_parser(); function parse(stream, callback) { const parser = new parser_1.Parser(); stream.on("data", (buffer) => parser.parse(buffer, callback)); return new Promise((resolve) => stream.on("end", () => resolve())); } __name(parse, "parse"); } }); // ../../node_modules/.pnpm/pg-cloudflare@1.4.1/node_modules/pg-cloudflare/dist/empty.js var require_empty = __commonJS({ "../../node_modules/.pnpm/pg-cloudflare@1.4.1/node_modules/pg-cloudflare/dist/empty.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = {}; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/stream.js var require_stream = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/stream.js"(exports, module) { var { getStream, getSecureStream } = getStreamFuncs(); module.exports = { /** * Get a socket stream compatible with the current runtime environment. * @returns {Duplex} */ getStream, /** * Get a TLS secured socket, compatible with the current environment, * using the socket and other settings given in `options`. * @returns {Duplex} */ getSecureStream }; function getNodejsStreamFuncs() { function getStream2(ssl) { const net = __require("net"); return new net.Socket(); } __name(getStream2, "getStream"); function getSecureStream2(options) { const tls = __require("tls"); return tls.connect(options); } __name(getSecureStream2, "getSecureStream"); return { getStream: getStream2, getSecureStream: getSecureStream2 }; } __name(getNodejsStreamFuncs, "getNodejsStreamFuncs"); function getCloudflareStreamFuncs() { function getStream2(ssl) { const { CloudflareSocket } = require_empty(); return new CloudflareSocket(ssl); } __name(getStream2, "getStream"); function getSecureStream2(options) { options.socket.startTls(options); return options.socket; } __name(getSecureStream2, "getSecureStream"); return { getStream: getStream2, getSecureStream: getSecureStream2 }; } __name(getCloudflareStreamFuncs, "getCloudflareStreamFuncs"); function isCloudflareRuntime() { if (typeof navigator === "object" && navigator !== null && typeof navigator.userAgent === "string") { return navigator.userAgent === "Cloudflare-Workers"; } if (typeof Response === "function") { const resp = new Response(null, { cf: { thing: true } }); if (typeof resp.cf === "object" && resp.cf !== null && resp.cf.thing) { return true; } } return false; } __name(isCloudflareRuntime, "isCloudflareRuntime"); function getStreamFuncs() { if (isCloudflareRuntime()) { return getCloudflareStreamFuncs(); } return getNodejsStreamFuncs(); } __name(getStreamFuncs, "getStreamFuncs"); } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/connection.js var require_connection = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/connection.js"(exports, module) { "use strict"; var EventEmitter = __require("events").EventEmitter; var { parse, serialize } = require_dist(); var stream = require_stream(); var { getStream } = stream; var flushBuffer = serialize.flush(); var syncBuffer = serialize.sync(); var endBuffer = serialize.end(); var Connection2 = class extends EventEmitter { static { __name(this, "Connection"); } constructor(config) { super(); config = config || {}; this.stream = config.stream || getStream(config.ssl); if (typeof this.stream === "function") { this.stream = this.stream(config); } this._keepAlive = config.keepAlive; this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis; this.parsedStatements = {}; this.submittedNamedStatements = {}; this.ssl = config.ssl || false; this.sslNegotiation = config.sslNegotiation || "postgres"; this._ending = false; this._emitMessage = false; const self = this; this.on("newListener", function(eventName) { if (eventName === "message") { self._emitMessage = true; } }); } connect(port, host) { const self = this; this._connecting = true; this.stream.setNoDelay(true); this.stream.connect(port, host); this.stream.once("connect", function() { if (self._keepAlive) { self.stream.setKeepAlive(true, self._keepAliveInitialDelayMillis); } self.emit("connect"); }); const reportStreamError = /* @__PURE__ */ __name(function(error) { if (self._ending && (error.code === "ECONNRESET" || error.code === "EPIPE")) { return; } self.emit("error", error); }, "reportStreamError"); this.stream.on("error", reportStreamError); this.stream.on("close", function() { self.emit("end"); }); if (!this.ssl) { return this.attachListeners(this.stream); } if (this.sslNegotiation === "direct") { return this.stream.once("connect", function() { self.upgradeToSSL(host, reportStreamError); }); } this.stream.once("data", function(buffer) { const responseCode = buffer.toString("utf8"); switch (responseCode) { case "S": break; case "N": self.stream.end(); return self.emit("error", new Error("The server does not support SSL connections")); default: self.stream.end(); return self.emit("error", new Error("There was an error establishing an SSL connection")); } self.upgradeToSSL(host, reportStreamError); }); } upgradeToSSL(host, reportStreamError) { const self = this; const options = { socket: self.stream, // tls.connect checks the server identity against `servername`, falling // back to `host` and then to 'localhost'. `servername` must stay unset // for IP addresses (see below), so `host` is needed to keep certificate // validation working when connecting to an IP address. host }; if (self.ssl !== true) { Object.assign(options, self.ssl); if ("key" in self.ssl) { options.key = self.ssl.key; } } if (self.sslNegotiation === "direct") { options.ALPNProtocols = ["postgresql"]; } const net = __require("net"); if (net.isIP && net.isIP(host) === 0) { options.servername = host; } try { self.stream = stream.getSecureStream(options); } catch (err) { return self.emit("error", err); } self.attachListeners(self.stream); self.stream.on("error", reportStreamError); self.emit("sslconnect"); } attachListeners(stream2) { parse(stream2, (msg) => { const eventName = msg.name === "error" ? "errorMessage" : msg.name; if (this._emitMessage) { this.emit("message", msg); } this.emit(eventName, msg); }); } requestSsl() { this.stream.write(serialize.requestSsl()); } startup(config) { this.stream.write(serialize.startup(config)); } cancel(processID, secretKey) { this._send(serialize.cancel(processID, secretKey)); } password(password) { this._send(serialize.password(password)); } sendSASLInitialResponseMessage(mechanism, initialResponse) { this._send(serialize.sendSASLInitialResponseMessage(mechanism, initialResponse)); } sendSCRAMClientFinalMessage(additionalData) { this._send(serialize.sendSCRAMClientFinalMessage(additionalData)); } _send(buffer) { if (!this.stream.writable) { return false; } return this.stream.write(buffer); } query(text) { this._send(serialize.query(text)); } // send parse message parse(query) { this._send(serialize.parse(query)); } // send bind message bind(config) { this._send(serialize.bind(config)); } // send execute message execute(config) { this._send(serialize.execute(config)); } flush() { if (this.stream.writable) { this.stream.write(flushBuffer); } } sync() { this._send(syncBuffer); } ref() { this.stream.ref(); } unref() { this.stream.unref(); } end() { this._ending = true; if (!this._connecting || !this.stream.writable) { this.stream.end(); return; } return this.stream.write(endBuffer, () => { this.stream.end(); }); } close(msg) { this._send(serialize.close(msg)); } describe(msg) { this._send(serialize.describe(msg)); } sendCopyFromChunk(chunk) { this._send(serialize.copyData(chunk)); } endCopyFrom() { this._send(serialize.copyDone()); } sendCopyFail(msg) { this._send(serialize.copyFail(msg)); } }; module.exports = Connection2; } }); // ../../node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js var require_split2 = __commonJS({ "../../node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js"(exports, module) { "use strict"; var { Transform } = __require("stream"); var { StringDecoder } = __require("string_decoder"); var kLast = /* @__PURE__ */ Symbol("last"); var kDecoder = /* @__PURE__ */ Symbol("decoder"); function transform(chunk, enc, cb) { let list; if (this.overflow) { const buf = this[kDecoder].write(chunk); list = buf.split(this.matcher); if (list.length === 1) return cb(); list.shift(); this.overflow = false; } else { this[kLast] += this[kDecoder].write(chunk); list = this[kLast].split(this.matcher); } this[kLast] = list.pop(); for (let i = 0; i < list.length; i++) { try { push(this, this.mapper(list[i])); } catch (error) { return cb(error); } } this.overflow = this[kLast].length > this.maxLength; if (this.overflow && !this.skipOverflow) { cb(new Error("maximum buffer reached")); return; } cb(); } __name(transform, "transform"); function flush(cb) { this[kLast] += this[kDecoder].end(); if (this[kLast]) { try { push(this, this.mapper(this[kLast])); } catch (error) { return cb(error); } } cb(); } __name(flush, "flush"); function push(self, val) { if (val !== void 0) { self.push(val); } } __name(push, "push"); function noop(incoming) { return incoming; } __name(noop, "noop"); function split(matcher, mapper, options) { matcher = matcher || /\r?\n/; mapper = mapper || noop; options = options || {}; switch (arguments.length) { case 1: if (typeof matcher === "function") { mapper = matcher; matcher = /\r?\n/; } else if (typeof matcher === "object" && !(matcher instanceof RegExp) && !matcher[Symbol.split]) { options = matcher; matcher = /\r?\n/; } break; case 2: if (typeof matcher === "function") { options = mapper; mapper = matcher; matcher = /\r?\n/; } else if (typeof mapper === "object") { options = mapper; mapper = noop; } } options = Object.assign({}, options); options.autoDestroy = true; options.transform = transform; options.flush = flush; options.readableObjectMode = true; const stream = new Transform(options); stream[kLast] = ""; stream[kDecoder] = new StringDecoder("utf8"); stream.matcher = matcher; stream.mapper = mapper; stream.maxLength = options.maxLength; stream.skipOverflow = options.skipOverflow || false; stream.overflow = false; stream._destroy = function(err, cb) { this._writableState.errorEmitted = false; cb(err); }; return stream; } __name(split, "split"); module.exports = split; } }); // ../../node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js var require_helper = __commonJS({ "../../node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js"(exports, module) { "use strict"; var path = __require("path"); var Stream = __require("stream").Stream; var split = require_split2(); var util = __require("util"); var defaultPort = 5432; var isWin = process.platform === "win32"; var warnStream = process.stderr; var S_IRWXG = 56; var S_IRWXO = 7; var S_IFMT = 61440; var S_IFREG = 32768; function isRegFile(mode) { return (mode & S_IFMT) == S_IFREG; } __name(isRegFile, "isRegFile"); var fieldNames = ["host", "port", "database", "user", "password"]; var nrOfFields = fieldNames.length; var passKey = fieldNames[nrOfFields - 1]; function warn() { var isWritable = warnStream instanceof Stream && true === warnStream.writable; if (isWritable) { var args = Array.prototype.slice.call(arguments).concat("\n"); warnStream.write(util.format.apply(util, args)); } } __name(warn, "warn"); Object.defineProperty(module.exports, "isWin", { get: /* @__PURE__ */ __name(function() { return isWin; }, "get"), set: /* @__PURE__ */ __name(function(val) { isWin = val; }, "set") }); module.exports.warnTo = function(stream) { var old = warnStream; warnStream = stream; return old; }; module.exports.getFileName = function(rawEnv) { var env = rawEnv || process.env; var file = env.PGPASSFILE || (isWin ? path.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path.join(env.HOME || "./", ".pgpass")); return file; }; module.exports.usePgPass = function(stats, fname) { if (Object.prototype.hasOwnProperty.call(process.env, "PGPASSWORD")) { return false; } if (isWin) { return true; } fname = fname || ""; if (!isRegFile(stats.mode)) { warn('WARNING: password file "%s" is not a plain file', fname); return false; } if (stats.mode & (S_IRWXG | S_IRWXO)) { warn('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less', fname); return false; } return true; }; var matcher = module.exports.match = function(connInfo, entry) { return fieldNames.slice(0, -1).reduce(function(prev, field, idx) { if (idx == 1) { if (Number(connInfo[field] || defaultPort) === Number(entry[field])) { return prev && true; } } return prev && (entry[field] === "*" || entry[field] === connInfo[field]); }, true); }; module.exports.getPassword = function(connInfo, stream, cb) { var pass; var lineStream = stream.pipe(split()); function onLine(line) { var entry = parseLine(line); if (entry && isValidEntry(entry) && matcher(connInfo, entry)) { pass = entry[passKey]; lineStream.end(); } } __name(onLine, "onLine"); var onEnd = /* @__PURE__ */ __name(function() { stream.destroy(); cb(pass); }, "onEnd"); var onErr = /* @__PURE__ */ __name(function(err) { stream.destroy(); warn("WARNING: error on reading file: %s", err); cb(void 0); }, "onErr"); stream.on("error", onErr); lineStream.on("data", onLine).on("end", onEnd).on("error", onErr); }; var parseLine = module.exports.parseLine = function(line) { if (line.length < 11 || line.match(/^\s+#/)) { return null; } var curChar = ""; var prevChar = ""; var fieldIdx = 0; var startIdx = 0; var endIdx = 0; var obj = {}; var isLastField = false; var addToObj = /* @__PURE__ */ __name(function(idx, i0, i1) { var field = line.substring(i0, i1); if (!Object.hasOwnProperty.call(process.env, "PGPASS_NO_DEESCAPE")) { field = field.replace(/\\([:\\])/g, "$1"); } obj[fieldNames[idx]] = field; }, "addToObj"); for (var i = 0; i < line.length - 1; i += 1) { curChar = line.charAt(i + 1); prevChar = line.charAt(i); isLastField = fieldIdx == nrOfFields - 1; if (isLastField) { addToObj(fieldIdx, startIdx); break; } if (i >= 0 && curChar == ":" && prevChar !== "\\") { addToObj(fieldIdx, startIdx, i + 1); startIdx = i + 2; fieldIdx += 1; } } obj = Object.keys(obj).length === nrOfFields ? obj : null; return obj; }; var isValidEntry = module.exports.isValidEntry = function(entry) { var rules = { // host 0: function(x) { return x.length > 0; }, // port 1: function(x) { if (x === "*") { return true; } x = Number(x); return isFinite(x) && x > 0 && x < 9007199254740992 && Math.floor(x) === x; }, // database 2: function(x) { return x.length > 0; }, // username 3: function(x) { return x.length > 0; }, // password 4: function(x) { return x.length > 0; } }; for (var idx = 0; idx < fieldNames.length; idx += 1) { var rule = rules[idx]; var value = entry[fieldNames[idx]] || ""; var res = rule(value); if (!res) { return false; } } return true; }; } }); // ../../node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js var require_lib = __commonJS({ "../../node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module) { "use strict"; var path = __require("path"); var fs = __require("fs"); var helper = require_helper(); module.exports = function(connInfo, cb) { var file = helper.getFileName(); fs.stat(file, function(err, stat) { if (err || !helper.usePgPass(stat, file)) { return cb(void 0); } var st = fs.createReadStream(file); helper.getPassword(connInfo, st, cb); }); }; module.exports.warnTo = helper.warnTo; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/client.js var require_client = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/client.js"(exports, module) { var EventEmitter = __require("events").EventEmitter; var utils = require_utils(); var nodeUtils = __require("util"); var sasl = require_sasl(); var TypeOverrides2 = require_type_overrides(); var ConnectionParameters = require_connection_parameters(); var Query2 = require_query(); var defaults2 = require_defaults(); var Connection2 = require_connection(); var crypto = require_utils2(); var activeQueryDeprecationNotice = nodeUtils.deprecate( () => { }, "Client.activeQuery is deprecated and will be removed in pg@9.0" ); var queryQueueDeprecationNotice = nodeUtils.deprecate( () => { }, "Client.queryQueue is deprecated and will be removed in pg@9.0." ); var pgPassDeprecationNotice = nodeUtils.deprecate( () => { }, "pgpass support is deprecated and will be removed in pg@9.0. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code." ); var byoPromiseDeprecationNotice = nodeUtils.deprecate( () => { }, "Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0." ); var queryQueueLengthDeprecationNotice = nodeUtils.deprecate( () => { }, "Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead." ); function coerceNumberOrDefault(value, defaultValue) { if (typeof value === "number") { return Number.isFinite(value) ? value : defaultValue; } if (typeof value === "string" && value.trim() !== "") { const n = Number(value); return Number.isFinite(n) ? n : defaultValue; } return defaultValue; } __name(coerceNumberOrDefault, "coerceNumberOrDefault"); var Client2 = class extends EventEmitter { static { __name(this, "Client"); } constructor(config) { super(); this.connectionParameters = new ConnectionParameters(config); this.user = this.connectionParameters.user; this.database = this.connectionParameters.database; this.port = this.connectionParameters.port; this.host = this.connectionParameters.host; Object.defineProperty(this, "password", { configurable: true, enumerable: false, writable: true, value: this.connectionParameters.password }); this.replication = this.connectionParameters.replication; const c = config || {}; if (c.Promise) { byoPromiseDeprecationNotice(); } this._Promise = c.Promise || global.Promise; this._types = new TypeOverrides2(c.types); this._ending = false; this._ended = false; this._connecting = false; this._connected = false; this._connectionError = false; this._queryable = true; this._activeQuery = null; this._txStatus = null; this.enableChannelBinding = Boolean(c.enableChannelBinding); this.scramMaxIterations = coerceNumberOrDefault(c.scramMaxIterations, sasl.DEFAULT_MAX_SCRAM_ITERATIONS); this.connection = c.connection || new Connection2({ stream: c.stream, ssl: this.connectionParameters.ssl, sslNegotiation: this.connectionParameters.sslnegotiation, keepAlive: c.keepAlive || false, keepAliveInitialDelayMillis: c.keepAliveInitialDelayMillis || 0, encoding: this.connectionParameters.client_encoding || "utf8" }); this._queryQueue = []; this._sentQueryQueue = []; this.pipeline = Boolean(c.pipeline); this.binary = c.binary || defaults2.binary; this.processID = null; this.secretKey = null; this.ssl = this.connectionParameters.ssl || false; this.sslNegotiation = this.connectionParameters.sslnegotiation || "postgres"; if (this.ssl && this.ssl.key) { Object.defineProperty(this.ssl, "key", { enumerable: false }); } this._connectionTimeoutMillis = c.connectionTimeoutMillis || 0; } get activeQuery() { activeQueryDeprecationNotice(); return this._activeQuery; } set activeQuery(val) { activeQueryDeprecationNotice(); this._activeQuery = val; } _getActiveQuery() { return this._activeQuery; } _errorAllQueries(err) { const enqueueError = /* @__PURE__ */ __name((query) => { process.nextTick(() => { query.handleError(err, this.connection); }); }, "enqueueError"); const activeQuery = this._getActiveQuery(); if (activeQuery) { enqueueError(activeQuery); this._activeQuery = null; } this._sentQueryQueue.forEach(enqueueError); this._sentQueryQueue.length = 0; this._queryQueue.forEach(enqueueError); this._queryQueue.length = 0; } _connect(callback) { const self = this; const con = this.connection; this._connectionCallback = callback; if (this._connecting || this._connected) { const err = new Error("Client has already been connected. You cannot reuse a client."); process.nextTick(() => { callback(err); }); return; } this._connecting = true; if (this._connectionTimeoutMillis > 0) { this.connectionTimeoutHandle = setTimeout(() => { con._ending = true; con.stream.destroy(new Error("timeout expired")); }, this._connectionTimeoutMillis); if (this.connectionTimeoutHandle.unref) { this.connectionTimeoutHandle.unref(); } } if (this.host && this.host.indexOf("/") === 0) { con.connect(this.host + "/.s.PGSQL." + this.port); } else { con.connect(this.port, this.host); } con.on("connect", function() { if (self.ssl) { if (self.sslNegotiation !== "direct") { con.requestSsl(); } } else { con.startup(self.getStartupConf()); } }); con.on("sslconnect", function() { con.startup(self.getStartupConf()); }); this._attachListeners(con); con.once("end", () => { const error = this._ending ? new Error("Connection terminated") : new Error("Connection terminated unexpectedly"); clearTimeout(this.connectionTimeoutHandle); this._errorAllQueries(error); this._ended = true; if (!this._ending) { if (this._connecting && !this._connectionError) { if (this._connectionCallback) { this._connectionCallback(error); } else { this._handleErrorEvent(error); } } else if (!this._connectionError) { this._handleErrorEvent(error); } } process.nextTick(() => { this.emit("end"); }); }); } connect(callback) { if (callback) { this._connect(callback); return; } return new this._Promise((resolve, reject) => { this._connect((error) => { if (error) { reject(error); } else { resolve(this); } }); }); } _attachListeners(con) { con.on("authenticationCleartextPassword", this._handleAuthCleartextPassword.bind(this)); con.on("authenticationMD5Password", this._handleAuthMD5Password.bind(this)); con.on("authenticationSASL", this._handleAuthSASL.bind(this)); con.on("authenticationSASLContinue", this._handleAuthSASLContinue.bind(this)); con.on("authenticationSASLFinal", this._handleAuthSASLFinal.bind(this)); con.on("backendKeyData", this._handleBackendKeyData.bind(this)); con.on("error", this._handleErrorEvent.bind(this)); con.on("errorMessage", this._handleErrorMessage.bind(this)); con.on("readyForQuery", this._handleReadyForQuery.bind(this)); con.on("notice", this._handleNotice.bind(this)); con.on("rowDescription", this._handleRowDescription.bind(this)); con.on("dataRow", this._handleDataRow.bind(this)); con.on("portalSuspended", this._handlePortalSuspended.bind(this)); con.on("emptyQuery", this._handleEmptyQuery.bind(this)); con.on("commandComplete", this._handleCommandComplete.bind(this)); con.on("parseComplete", this._handleParseComplete.bind(this)); con.on("copyInResponse", this._handleCopyInResponse.bind(this)); con.on("copyData", this._handleCopyData.bind(this)); con.on("notification", this._handleNotification.bind(this)); } _getPassword(cb) { const con = this.connection; if (typeof this.password === "function") { this._Promise.resolve().then(() => this.password(this.connectionParameters)).then((pass) => { if (pass !== void 0) { if (typeof pass !== "string") { con.emit("error", new TypeError("Password must be a string")); return; } this.connectionParameters.password = this.password = pass; } else { this.connectionParameters.password = this.password = null; } cb(); }).catch((err) => { con.emit("error", err); }); } else if (this.password !== null) { cb(); } else { try { const pgPass = require_lib(); pgPass(this.connectionParameters, (pass) => { if (void 0 !== pass) { pgPassDeprecationNotice(); this.connectionParameters.password = this.password = pass; } cb(); }); } catch (e) { this.emit("error", e); } } } _handleAuthCleartextPassword(msg) { this._getPassword(() => { this.connection.password(this.password); }); } _handleAuthMD5Password(msg) { this._getPassword(async () => { try { const hashedPassword = await crypto.postgresMd5PasswordHash(this.user, this.password, msg.salt); this.connection.password(hashedPassword); } catch (e) { this.emit("error", e); } }); } _handleAuthSASL(msg) { this._getPassword(() => { try { this.saslSession = sasl.startSession( msg.mechanisms, this.enableChannelBinding && this.connection.stream, this.scramMaxIterations ); this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response); } catch (err) { this.connection.emit("error", err); } }); } async _handleAuthSASLContinue(msg) { try { await sasl.continueSession( this.saslSession, this.password, msg.data, this.enableChannelBinding && this.connection.stream ); this.connection.sendSCRAMClientFinalMessage(this.saslSession.response); } catch (err) { this.connection.emit("error", err); } } _handleAuthSASLFinal(msg) { try { sasl.finalizeSession(this.saslSession, msg.data); this.saslSession = null; } catch (err) { this.connection.emit("error", err); } } _handleBackendKeyData(msg) { this.processID = msg.processID; this.secretKey = msg.secretKey; } _handleReadyForQuery(msg) { if (this._connecting) { this._connecting = false; this._connected = true; clearTimeout(this.connectionTimeoutHandle); if (this._connectionCallback) { this._connectionCallback(null, this); this._connectionCallback = null; } this.emit("connect"); } const activeQuery = this._getActiveQuery(); this._activeQuery = null; this._txStatus = msg?.status ?? null; this.readyForQuery = true; if (activeQuery) { activeQuery.handleReadyForQuery(this.connection); } this._pulseQueryQueue(); } // if we receive an error event or error message // during the connection process we handle it here _handleErrorWhileConnecting(err) { if (this._connectionError) { return; } this._connectionError = true; clearTimeout(this.connectionTimeoutHandle); if (this._connectionCallback) { return this._connectionCallback(err); } this.emit("error", err); } // if we're connected and we receive an error event from the connection // this means the socket is dead - do a hard abort of all queries and emit // the socket error on the client as well _handleErrorEvent(err) { if (this._connecting) { return this._handleErrorWhileConnecting(err); } this._queryable = false; this._errorAllQueries(err); this.emit("error", err); } // handle error messages from the postgres backend _handleErrorMessage(msg) { if (this._connecting) { return this._handleErrorWhileConnecting(msg); } const activeQuery = this._getActiveQuery(); if (!activeQuery) { this._handleErrorEvent(msg); return; } this._activeQuery = null; if (activeQuery.name) { delete this.connection.submittedNamedStatements[activeQuery.name]; } activeQuery.handleError(msg, this.connection); } _handleRowDescription(msg) { const activeQuery = this._getActiveQuery(); if (activeQuery == null) { const error = new Error("Received unexpected rowDescription message from backend."); this._handleErrorEvent(error); return; } activeQuery.handleRowDescription(msg); } _handleDataRow(msg) { const activeQuery = this._getActiveQuery(); if (activeQuery == null) { const error = new Error("Received unexpected dataRow message from backend."); this._handleErrorEvent(error); return; } activeQuery.handleDataRow(msg); } _handlePortalSuspended(msg) { const activeQuery = this._getActiveQuery(); if (activeQuery == null) { const error = new Error("Received unexpected portalSuspended message from backend."); this._handleErrorEvent(error); return; } activeQuery.handlePortalSuspended(this.connection); } _handleEmptyQuery(msg) { const activeQuery = this._getActiveQuery(); if (activeQuery == null) { const error = new Error("Received unexpected emptyQuery message from backend."); this._handleErrorEvent(error); return; } activeQuery.handleEmptyQuery(this.connection); } _handleCommandComplete(msg) { const activeQuery = this._getActiveQuery(); if (activeQuery == null) { const error = new Error("Received unexpected commandComplete message from backend."); this._handleErrorEvent(error); return; } activeQuery.handleCommandComplete(msg, this.connection); } _handleParseComplete() { const activeQuery = this._getActiveQuery(); if (activeQuery == null) { const error = new Error("Received unexpected parseComplete message from backend."); this._handleErrorEvent(error); return; } if (activeQuery.name) { this.connection.parsedStatements[activeQuery.name] = activeQuery.text; delete this.connection.submittedNamedStatements[activeQuery.name]; } } _handleCopyInResponse(msg) { const activeQuery = this._getActiveQuery(); if (activeQuery == null) { const error = new Error("Received unexpected copyInResponse message from backend."); this._handleErrorEvent(error); return; } activeQuery.handleCopyInResponse(this.connection); } _handleCopyData(msg) { const activeQuery = this._getActiveQuery(); if (activeQuery == null) { const error = new Error("Received unexpected copyData message from backend."); this._handleErrorEvent(error); return; } activeQuery.handleCopyData(msg, this.connection); } _handleNotification(msg) { this.emit("notification", msg); } _handleNotice(msg) { this.emit("notice", msg); } getStartupConf() { const params = this.connectionParameters; const data = { user: params.user, database: params.database }; const appName = params.application_name || params.fallback_application_name; if (appName) { data.application_name = appName; } if (params.replication) { data.replication = "" + params.replication; } if (params.statement_timeout) { data.statement_timeout = String(parseInt(params.statement_timeout, 10)); } if (params.lock_timeout) { data.lock_timeout = String(parseInt(params.lock_timeout, 10)); } if (params.idle_in_transaction_session_timeout) { data.idle_in_transaction_session_timeout = String(parseInt(params.idle_in_transaction_session_timeout, 10)); } if (params.options) { data.options = params.options; } return data; } cancel(client, query) { if (client.activeQuery === query) { const con = this.connection; if (this.host && this.host.indexOf("/") === 0) { con.connect(this.host + "/.s.PGSQL." + this.port); } else { con.connect(this.port, this.host); } con.on("connect", function() { con.cancel(client.processID, client.secretKey); }); } else if (client._queryQueue.indexOf(query) !== -1) { client._queryQueue.splice(client._queryQueue.indexOf(query), 1); } else if (client._sentQueryQueue.indexOf(query) !== -1) { query.callback = () => { }; } } setTypeParser(oid, format, parseFn) { return this._types.setTypeParser(oid, format, parseFn); } getTypeParser(oid, format) { return this._types.getTypeParser(oid, format); } // escapeIdentifier and escapeLiteral moved to utility functions & exported // on PG // re-exported here for backwards compatibility escapeIdentifier(str) { return utils.escapeIdentifier(str); } escapeLiteral(str) { return utils.escapeLiteral(str); } _pulseQueryQueue() { if (this.pipeline) { this._pulsePipelinedQueryQueue(); return; } if (this.readyForQuery === true) { this._activeQuery = this._queryQueue.shift(); const activeQuery = this._getActiveQuery(); if (activeQuery) { this.readyForQuery = false; this.hasExecuted = true; const queryError = activeQuery.submit(this.connection); if (queryError) { process.nextTick(() => { activeQuery.handleError(queryError, this.connection); this.readyForQuery = true; this._pulseQueryQueue(); }); } } else if (this.hasExecuted) { this._activeQuery = null; this.emit("drain"); } } } _pulsePipelinedQueryQueue() { if (!this._connected || !this._queryable) { return; } while (this._queryQueue.length > 0) { const query = this._queryQueue.shift(); this.hasExecuted = true; const queryError = query.submit(this.connection); if (queryError) { process.nextTick(() => { query.handleError(queryError, this.connection); }); continue; } this._sentQueryQueue.push(query); } if (this.readyForQuery && !this._activeQuery && this._sentQueryQueue.length > 0) { this._activeQuery = this._sentQueryQueue.shift(); this.readyForQuery = false; } if (!this._activeQuery && this._sentQueryQueue.length === 0 && this._queryQueue.length === 0 && this.hasExecuted) { this.emit("drain"); } } query(config, values, callback) { let query; let result; if (config == null) { throw new TypeError("Client was passed a null or undefined query"); } if (typeof config.submit === "function") { result = query = config; if (!query.callback) { if (typeof values === "function") { query.callback = values; } else if (callback) { query.callback = callback; } } } else { query = new Query2(config, values, callback); if (!query.callback) { result = new this._Promise((resolve, reject) => { query.callback = (err, res) => err ? reject(err) : resolve(res); }).catch((err) => { Error.captureStackTrace(err); throw err; }); } else if (typeof query.callback !== "function") { throw new TypeError("callback is not a function"); } } const readTimeout = config.query_timeout || this.connectionParameters.query_timeout; if (readTimeout) { const queryCallback = query.callback || (() => { }); const readTimeoutTimer = setTimeout(() => { const error = new Error("Query read timeout"); process.nextTick(() => { query.handleError(error, this.connection); }); queryCallback(error); query.callback = () => { }; const index = this._queryQueue.indexOf(query); if (index > -1) { this._queryQueue.splice(index, 1); } else if (this.pipeline) { this.connection.stream.destroy(); return; } this._pulseQueryQueue(); }, readTimeout); query.callback = (err, res) => { clearTimeout(readTimeoutTimer); queryCallback(err, res); }; } if (this.binary && !query.binary) { query.binary = true; } if (query._result && !query._result._types) { query._result._types = this._types; } if (this.pipeline) { const portalQuery = typeof config.submit === "function" && !(query instanceof Query2) ? "Custom query classes such as pg-cursor and pg-query-stream are" : query.rows ? "The `rows` option is" : null; if (portalQuery) { process.nextTick(() => { query.handleError(new Error(`${portalQuery} not supported in pipeline mode`), this.connection); }); return result; } } if (!this._queryable) { process.nextTick(() => { query.handleError(new Error("Client has encountered a connection error and is not queryable"), this.connection); }); return result; } if (this._ending) { process.nextTick(() => { query.handleError(new Error("Client was closed and is not queryable"), this.connection); }); return result; } if (this._queryQueue.length > 0 && !this.pipeline) { queryQueueLengthDeprecationNotice(); } this._queryQueue.push(query); this._pulseQueryQueue(); return result; } ref() { this.connection.ref(); } unref() { this.connection.unref(); } getTransactionStatus() { return this._txStatus; } end(cb) { this._ending = true; if (!this.connection._connecting || this._ended) { if (cb) { cb(); return; } else { return this._Promise.resolve(); } } if (!this._queryable) { this.connection.stream.destroy(); } else if (this.pipeline && (this._getActiveQuery() || this._sentQueryQueue.length > 0 || this._queryQueue.length > 0)) { this.once("drain", () => this.connection.end()); } else if (this._getActiveQuery()) { this.connection.stream.destroy(); } else { this.connection.end(); } if (cb) { this.connection.once("end", cb); } else { return new this._Promise((resolve) => { this.connection.once("end", resolve); }); } } get queryQueue() { queryQueueDeprecationNotice(); return this._queryQueue; } }; Client2.Query = Query2; module.exports = Client2; } }); // ../../node_modules/.pnpm/pg-pool@3.14.0_pg@8.23.1/node_modules/pg-pool/index.js var require_pg_pool = __commonJS({ "../../node_modules/.pnpm/pg-pool@3.14.0_pg@8.23.1/node_modules/pg-pool/index.js"(exports, module) { "use strict"; var EventEmitter = __require("events").EventEmitter; var NOOP = /* @__PURE__ */ __name(function() { }, "NOOP"); var removeWhere = /* @__PURE__ */ __name((list, predicate) => { const i = list.findIndex(predicate); return i === -1 ? void 0 : list.splice(i, 1)[0]; }, "removeWhere"); var IdleItem = class { static { __name(this, "IdleItem"); } constructor(client, idleListener, timeoutId) { this.client = client; this.idleListener = idleListener; this.timeoutId = timeoutId; } }; var PendingItem = class { static { __name(this, "PendingItem"); } constructor(callback) { this.callback = callback; } }; function throwOnDoubleRelease() { throw new Error("Release called on client which has already been released to the pool."); } __name(throwOnDoubleRelease, "throwOnDoubleRelease"); function promisify(Promise2, callback) { if (callback) { return { callback, result: void 0 }; } let rej; let res; const cb = /* @__PURE__ */ __name(function(err, client) { err ? rej(err) : res(client); }, "cb"); const result = new Promise2(function(resolve, reject) { res = resolve; rej = reject; }).catch((err) => { Error.captureStackTrace(err); throw err; }); return { callback: cb, result }; } __name(promisify, "promisify"); function makeIdleListener(pool, client) { return /* @__PURE__ */ __name(function idleListener(err) { err.client = client; client.removeListener("error", idleListener); client.on("error", () => { pool.log("additional client error after disconnection due to error", err); }); pool._remove(client); pool.emit("error", err, client); }, "idleListener"); } __name(makeIdleListener, "makeIdleListener"); var Pool2 = class extends EventEmitter { static { __name(this, "Pool"); } constructor(options, Client2) { super(); this.options = Object.assign({}, options); if (options != null && "password" in options) { Object.defineProperty(this.options, "password", { configurable: true, enumerable: false, writable: true, value: options.password }); } if (options != null && options.ssl && options.ssl.key) { Object.defineProperty(this.options.ssl, "key", { enumerable: false }); } this.options.max = this.options.max || this.options.poolSize || 10; this.options.min = this.options.min || 0; this.options.maxUses = this.options.maxUses || Infinity; this.options.allowExitOnIdle = this.options.allowExitOnIdle || false; this.options.maxLifetimeSeconds = this.options.maxLifetimeSeconds || 0; this.log = this.options.log || function() { }; this.Client = this.options.Client || Client2 || require_lib2().Client; this.Promise = this.options.Promise || global.Promise; if (typeof this.options.idleTimeoutMillis === "undefined") { this.options.idleTimeoutMillis = 1e4; } this._clients = []; this._idle = []; this._expired = /* @__PURE__ */ new WeakSet(); this._pendingQueue = []; this._endCallback = void 0; this.ending = false; this.ended = false; } _promiseTry(f) { const Promise2 = this.Promise; if (typeof Promise2.try === "function") { return Promise2.try(f); } return new Promise2((resolve) => resolve(f())); } _isFull() { return this._clients.length >= this.options.max; } _isAboveMin() { return this._clients.length > this.options.min; } _pulseQueue() { this.log("pulse queue"); if (this.ended) { this.log("pulse queue ended"); return; } if (this.ending) { this.log("pulse queue on ending"); if (this._idle.length) { this._idle.slice().map((item) => { this._remove(item.client); }); } if (!this._clients.length) { this.ended = true; this._endCallback(); } return; } if (!this._pendingQueue.length) { this.log("no queued requests"); return; } if (!this._idle.length && this._isFull()) { return; } const pendingItem = this._pendingQueue.shift(); if (this._idle.length) { const idleItem = this._idle.pop(); clearTimeout(idleItem.timeoutId); const client = idleItem.client; client.ref && client.ref(); const idleListener = idleItem.idleListener; return this._acquireClient(client, pendingItem, idleListener, false); } if (!this._isFull()) { return this.newClient(pendingItem); } throw new Error("unexpected condition"); } _remove(client, callback) { const removed = removeWhere(this._idle, (item) => item.client === client); if (removed !== void 0) { clearTimeout(removed.timeoutId); } this._clients = this._clients.filter((c) => c !== client); const context = this; client.end(() => { context.emit("remove", client); if (typeof callback === "function") { callback(); } }); } connect(cb) { if (this.ending) { const err = new Error("Cannot use a pool after calling end on the pool"); return cb ? cb(err) : this.Promise.reject(err); } const response = promisify(this.Promise, cb); const result = response.result; if (this._isFull() || this._idle.length) { if (this._idle.length) { process.nextTick(() => this._pulseQueue()); } if (!this.options.connectionTimeoutMillis) { this._pendingQueue.push(new PendingItem(response.callback)); return result; } const queueCallback = /* @__PURE__ */ __name((err, res, done) => { clearTimeout(tid); response.callback(err, res, done); }, "queueCallback"); const pendingItem = new PendingItem(queueCallback); const tid = setTimeout(() => { removeWhere(this._pendingQueue, (i) => i.callback === queueCallback); pendingItem.timedOut = true; response.callback(new Error("timeout exceeded when trying to connect")); }, this.options.connectionTimeoutMillis); if (tid.unref) { tid.unref(); } this._pendingQueue.push(pendingItem); return result; } this.newClient(new PendingItem(response.callback)); return result; } newClient(pendingItem) { const client = new this.Client(this.options); this._clients.push(client); const idleListener = makeIdleListener(this, client); this.log("checking client timeout"); let tid; let timeoutHit = false; if (this.options.connectionTimeoutMillis) { tid = setTimeout(() => { if (client.connection) { this.log("ending client due to timeout"); timeoutHit = true; client.connection.stream.destroy(); } else if (!client.isConnected()) { this.log("ending client due to timeout"); timeoutHit = true; client.end(); } }, this.options.connectionTimeoutMillis); } this.log("connecting new client"); client.connect((err) => { if (tid) { clearTimeout(tid); } client.on("error", idleListener); if (err) { this.log("client failed to connect", err); this._clients = this._clients.filter((c) => c !== client); if (timeoutHit) { err = new Error("Connection terminated due to connection timeout", { cause: err }); } this._pulseQueue(); if (!pendingItem.timedOut) { pendingItem.callback(err, void 0, NOOP); } } else { this.log("new client connected"); if (this.options.onConnect) { this._promiseTry(() => this.options.onConnect(client)).then( () => { this._afterConnect(client, pendingItem, idleListener); }, (hookErr) => { this._clients = this._clients.filter((c) => c !== client); client.end(() => { this._pulseQueue(); if (!pendingItem.timedOut) { pendingItem.callback(hookErr, void 0, NOOP); } }); } ); return; } return this._afterConnect(client, pendingItem, idleListener); } }); } _afterConnect(client, pendingItem, idleListener) { if (this.options.maxLifetimeSeconds !== 0) { const maxLifetimeTimeout = setTimeout(() => { this.log("ending client due to expired lifetime"); this._expired.add(client); const idleIndex = this._idle.findIndex((idleItem) => idleItem.client === client); if (idleIndex !== -1) { this._acquireClient( client, new PendingItem((err, client2, clientRelease) => clientRelease()), idleListener, false ); } }, this.options.maxLifetimeSeconds * 1e3); maxLifetimeTimeout.unref(); client.once("end", () => clearTimeout(maxLifetimeTimeout)); } return this._acquireClient(client, pendingItem, idleListener, true); } // acquire a client for a pending work item _acquireClient(client, pendingItem, idleListener, isNew) { if (isNew) { this.emit("connect", client); } this.emit("acquire", client); client.release = this._releaseOnce(client, idleListener); client.removeListener("error", idleListener); if (!pendingItem.timedOut) { if (isNew && this.options.verify) { this.options.verify(client, (err) => { if (err) { client.release(err); return pendingItem.callback(err, void 0, NOOP); } pendingItem.callback(void 0, client, client.release); }); } else { pendingItem.callback(void 0, client, client.release); } } else { if (isNew && this.options.verify) { this.options.verify(client, client.release); } else { client.release(); } } } // returns a function that wraps _release and throws if called more than once _releaseOnce(client, idleListener) { let released = false; return (err) => { if (released) { throwOnDoubleRelease(); } released = true; this._release(client, idleListener, err); }; } // release a client back to the poll, include an error // to remove it from the pool _release(client, idleListener, err) { client.on("error", idleListener); client._poolUseCount = (client._poolUseCount || 0) + 1; this.emit("release", err, client); if (err || this.ending || !client._queryable || client._ending || client._poolUseCount >= this.options.maxUses) { if (client._poolUseCount >= this.options.maxUses) { this.log("remove expended client"); } return this._remove(client, this._pulseQueue.bind(this)); } const isExpired = this._expired.has(client); if (isExpired) { this.log("remove expired client"); this._expired.delete(client); return this._remove(client, this._pulseQueue.bind(this)); } let tid; if (this.options.idleTimeoutMillis && this._isAboveMin()) { tid = setTimeout(() => { if (this._isAboveMin()) { this.log("remove idle client"); this._remove(client, this._pulseQueue.bind(this)); } }, this.options.idleTimeoutMillis); if (this.options.allowExitOnIdle) { tid.unref(); } } if (this.options.allowExitOnIdle) { client.unref(); } this._idle.push(new IdleItem(client, idleListener, tid)); this._pulseQueue(); } query(text, values, cb) { if (typeof text === "function") { const response2 = promisify(this.Promise, text); setImmediate(function() { return response2.callback(new Error("Passing a function as the first parameter to pool.query is not supported")); }); return response2.result; } if (typeof values === "function") { cb = values; values = void 0; } const response = promisify(this.Promise, cb); cb = response.callback; this.connect((err, client) => { if (err) { return cb(err); } let clientReleased = false; const onError = /* @__PURE__ */ __name((err2) => { if (clientReleased) { return; } clientReleased = true; client.release(err2); cb(err2); }, "onError"); client.once("error", onError); this.log("dispatching query"); try { client.query(text, values, (err2, res) => { this.log("query dispatched"); client.removeListener("error", onError); if (clientReleased) { return; } clientReleased = true; client.release(err2); if (err2) { return cb(err2); } return cb(void 0, res); }); } catch (err2) { client.release(err2); return cb(err2); } }); return response.result; } end(cb) { this.log("ending"); if (this.ending) { const err = new Error("Called end on pool more than once"); return cb ? cb(err) : this.Promise.reject(err); } this.ending = true; const promised = promisify(this.Promise, cb); this._endCallback = promised.callback; this._pulseQueue(); return promised.result; } get waitingCount() { return this._pendingQueue.length; } get idleCount() { return this._idle.length; } get expiredCount() { return this._clients.reduce((acc, client) => acc + (this._expired.has(client) ? 1 : 0), 0); } get totalCount() { return this._clients.length; } }; module.exports = Pool2; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/native/query.js var require_query2 = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/native/query.js"(exports, module) { "use strict"; var EventEmitter = __require("events").EventEmitter; var util = __require("util"); var utils = require_utils(); var NativeQuery = module.exports = function(config, values, callback) { EventEmitter.call(this); config = utils.normalizeQueryConfig(config, values, callback); this.text = config.text; this.values = config.values; this.name = config.name; this.queryMode = config.queryMode; this.callback = config.callback; this.state = "new"; this._arrayMode = config.rowMode === "array"; this._emitRowEvents = false; this.on( "newListener", function(event) { if (event === "row") this._emitRowEvents = true; }.bind(this) ); }; util.inherits(NativeQuery, EventEmitter); var errorFieldMap = { sqlState: "code", statementPosition: "position", messagePrimary: "message", messageDetail: "detail", messageHint: "hint", context: "where", schemaName: "schema", tableName: "table", columnName: "column", dataTypeName: "dataType", constraintName: "constraint", sourceFile: "file", sourceLine: "line", sourceFunction: "routine" }; NativeQuery.prototype.handleError = function(err) { const fields = this.native && this.native.pq.resultErrorFields(); if (fields) { for (const key in fields) { const normalizedFieldName = errorFieldMap[key] || key; err[normalizedFieldName] = fields[key]; } } if (this.callback) { this.callback(err); } else { this.emit("error", err); } this.state = "error"; }; NativeQuery.prototype.then = function(onSuccess, onFailure) { return this._getPromise().then(onSuccess, onFailure); }; NativeQuery.prototype.catch = function(callback) { return this._getPromise().catch(callback); }; NativeQuery.prototype._getPromise = function() { if (this._promise) return this._promise; this._promise = new Promise( function(resolve, reject) { this._once("end", resolve); this._once("error", reject); }.bind(this) ); return this._promise; }; NativeQuery.prototype.submit = function(client) { this.state = "running"; const self = this; this.native = client.native; client.native.arrayMode = this._arrayMode; let after = /* @__PURE__ */ __name(function(err, rows, results) { client.native.arrayMode = false; setImmediate(function() { self.emit("_done"); }); if (err) { return self.handleError(err); } if (self._emitRowEvents) { if (results.length > 1) { rows.forEach((rowOfRows, i) => { rowOfRows.forEach((row) => { self.emit("row", row, results[i]); }); }); } else { rows.forEach(function(row) { self.emit("row", row, results); }); } } self.state = "end"; self.emit("end", results); if (self.callback) { self.callback(null, results); } }, "after"); if (process.domain) { after = process.domain.bind(after); } if (this.name) { if (this.name.length > 63) { console.error("Warning! Postgres only supports 63 characters for query names."); console.error("You supplied %s (%s)", this.name, this.name.length); console.error("This can cause conflicts and silent errors executing queries"); } const values = (this.values || []).map(utils.prepareValue); if (client.namedQueries[this.name] !== void 0) { if (this.text && client.namedQueries[this.name] !== this.text) { const err = new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`); return after(err); } return client.native.execute(this.name, values, after); } return client.native.prepare(this.name, this.text, values.length, function(err) { if (err) return after(err); client.namedQueries[self.name] = self.text; return self.native.execute(self.name, values, after); }); } else if (this.values) { if (!Array.isArray(this.values)) { const err = new Error("Query values must be an array"); return after(err); } const vals = this.values.map(utils.prepareValue); client.native.query(this.text, vals, after); } else if (this.queryMode === "extended") { client.native.query(this.text, [], after); } else { client.native.query(this.text, after); } }; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/native/client.js var require_client2 = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/native/client.js"(exports, module) { var nodeUtils = __require("util"); var Native; try { Native = __require("pg-native"); } catch (e) { throw e; } var TypeOverrides2 = require_type_overrides(); var EventEmitter = __require("events").EventEmitter; var util = __require("util"); var ConnectionParameters = require_connection_parameters(); var NativeQuery = require_query2(); var queryQueueLengthDeprecationNotice = nodeUtils.deprecate( () => { }, "Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead." ); var Client2 = module.exports = function(config) { EventEmitter.call(this); config = config || {}; this._Promise = config.Promise || global.Promise; this._types = new TypeOverrides2(config.types); this.native = new Native({ types: this._types }); this._queryQueue = []; this._ending = false; this._connecting = false; this._connected = false; this._queryable = true; this.pipeline = Boolean(config.pipeline); this._pipelineInFlight = false; const cp = this.connectionParameters = new ConnectionParameters(config); if (config.nativeConnectionString) cp.nativeConnectionString = config.nativeConnectionString; this.user = cp.user; Object.defineProperty(this, "password", { configurable: true, enumerable: false, writable: true, value: cp.password }); this.database = cp.database; this.host = cp.host; this.port = cp.port; this.namedQueries = {}; }; Client2.Query = NativeQuery; util.inherits(Client2, EventEmitter); Client2.prototype._errorAllQueries = function(err) { const enqueueError = /* @__PURE__ */ __name((query) => { process.nextTick(() => { query.native = this.native; query.handleError(err); }); }, "enqueueError"); if (this._hasActiveQuery()) { enqueueError(this._activeQuery); this._activeQuery = null; } this._queryQueue.forEach(enqueueError); this._queryQueue.length = 0; }; Client2.prototype._connect = function(cb) { const self = this; if (this._connecting) { process.nextTick(() => cb(new Error("Client has already been connected. You cannot reuse a client."))); return; } this._connecting = true; this.connectionParameters.getLibpqConnectionString(function(err, conString) { if (self.connectionParameters.nativeConnectionString) conString = self.connectionParameters.nativeConnectionString; if (err) return cb(err); self.native.connect(conString, function(err2) { if (err2) { self.native.end(); return cb(err2); } self._connected = true; self.native.on("error", function(err3) { self._queryable = false; self._errorAllQueries(err3); self.emit("error", err3); }); self.native.on("notification", function(msg) { self.emit("notification", { channel: msg.relname, payload: msg.extra }); }); self.emit("connect"); self._pulseQueryQueue(true); cb(null, this); }); }); }; Client2.prototype.connect = function(callback) { if (callback) { this._connect(callback); return; } return new this._Promise((resolve, reject) => { this._connect((error) => { if (error) { reject(error); } else { resolve(this); } }); }); }; Client2.prototype.query = function(config, values, callback) { let query; let result; let readTimeout; let readTimeoutTimer; let queryCallback; if (config === null || config === void 0) { throw new TypeError("Client was passed a null or undefined query"); } else if (typeof config.submit === "function") { readTimeout = config.query_timeout || this.connectionParameters.query_timeout; result = query = config; if (typeof values === "function") { config.callback = values; } } else { readTimeout = config.query_timeout || this.connectionParameters.query_timeout; query = new NativeQuery(config, values, callback); if (!query.callback) { let resolveOut, rejectOut; result = new this._Promise((resolve, reject) => { resolveOut = resolve; rejectOut = reject; }).catch((err) => { Error.captureStackTrace(err); throw err; }); query.callback = (err, res) => err ? rejectOut(err) : resolveOut(res); } } if (readTimeout) { queryCallback = query.callback || (() => { }); readTimeoutTimer = setTimeout(() => { const error = new Error("Query read timeout"); process.nextTick(() => { query.handleError(error, this.connection); }); queryCallback(error); query.callback = () => { }; const index = this._queryQueue.indexOf(query); if (index > -1) { this._queryQueue.splice(index, 1); } this._pulseQueryQueue(); }, readTimeout); query.callback = (err, res) => { clearTimeout(readTimeoutTimer); queryCallback(err, res); }; } if (!this._queryable) { query.native = this.native; process.nextTick(() => { query.handleError(new Error("Client has encountered a connection error and is not queryable")); }); return result; } if (this._ending) { query.native = this.native; process.nextTick(() => { query.handleError(new Error("Client was closed and is not queryable")); }); return result; } if (this._queryQueue.length > 0 && !this.pipeline) { queryQueueLengthDeprecationNotice(); } this._queryQueue.push(query); this._pulseQueryQueue(); return result; }; Client2.prototype.end = function(cb) { const self = this; this._ending = true; if (this._connecting && !this._connected) { this.once("connect", () => { this.end(() => { }); }); } let result; if (!cb) { result = new this._Promise(function(resolve, reject) { cb = /* @__PURE__ */ __name((err) => err ? reject(err) : resolve(), "cb"); }); } const doEnd = /* @__PURE__ */ __name(function() { self.native.end(function() { self._connected = false; self._errorAllQueries(new Error("Connection terminated")); process.nextTick(() => { self.emit("end"); if (cb) cb(); }); }); }, "doEnd"); if (this.pipeline && (this._pipelineInFlight || this._queryQueue.length > 0)) { this.once("drain", doEnd); } else { doEnd(); } return result; }; Client2.prototype._hasActiveQuery = function() { return this._activeQuery && this._activeQuery.state !== "error" && this._activeQuery.state !== "end"; }; Client2.prototype._pulseQueryQueue = function(initialConnection) { if (!this._connected) { return; } if (this.pipeline && !initialConnection) { return this._pulsePipelinedQueryQueue(); } if (this._hasActiveQuery()) { return; } const query = this._queryQueue.shift(); if (!query) { if (!initialConnection) { this.emit("drain"); } return; } this._activeQuery = query; query.submit(this); const self = this; query.once("_done", function() { self._pulseQueryQueue(); }); }; Client2.prototype._pulsePipelinedQueryQueue = function() { if (!this._connected || this._pipelineInFlight) { return; } if (this._queryQueue.length === 0) { if (this.hasExecuted) { this.emit("drain"); } return; } this._pipelineInFlight = true; const self = this; const queries = []; const nativeQueries = []; const utils = require_utils(); while (this._queryQueue.length > 0) { const query = this._queryQueue.shift(); this.hasExecuted = true; nativeQueries.push(query); const values = query.values ? query.values.map(utils.prepareValue) : null; const pipelineEntry = { text: query.text, name: query.name, arrayMode: query._arrayMode }; if (values) { pipelineEntry.values = values; } if (query.name && this.namedQueries[query.name]) { pipelineEntry._alreadyPrepared = true; } queries.push(pipelineEntry); } this.native.pipeline(queries, function(err, results) { self._pipelineInFlight = false; if (err) { self._connected = false; self._queryable = false; for (let i = 0; i < nativeQueries.length; i++) { const q = nativeQueries[i]; q.native = self.native; q.handleError(err); } self._errorAllQueries(err); self.emit("error", err); self.emit("end"); return; } for (let i = 0; i < nativeQueries.length; i++) { const q = nativeQueries[i]; const r = results[i]; q.native = self.native; if (r.err) { q.handleError(r.err); } else { if (q.name) { self.namedQueries[q.name] = q.text; } q.state = "end"; q.emit("end", r.result); if (q.callback) { q.callback(null, r.result); } } setImmediate(function() { q.emit("_done"); }); } self._pulsePipelinedQueryQueue(); }); }; Client2.prototype.cancel = function(query) { if (this._activeQuery === query) { this.native.cancel(function() { }); } else if (this._queryQueue.indexOf(query) !== -1) { this._queryQueue.splice(this._queryQueue.indexOf(query), 1); } }; Client2.prototype.ref = function() { }; Client2.prototype.unref = function() { }; Client2.prototype.setTypeParser = function(oid, format, parseFn) { return this._types.setTypeParser(oid, format, parseFn); }; Client2.prototype.getTypeParser = function(oid, format) { return this._types.getTypeParser(oid, format); }; Client2.prototype.isConnected = function() { return this._connected; }; Client2.prototype.getTransactionStatus = function() { return this.native.getTransactionStatus(); }; } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/native/index.js var require_native = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/native/index.js"(exports, module) { "use strict"; module.exports = require_client2(); } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/index.js var require_lib2 = __commonJS({ "../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/lib/index.js"(exports, module) { "use strict"; var Client2 = require_client(); var defaults2 = require_defaults(); var Connection2 = require_connection(); var Result2 = require_result(); var utils = require_utils(); var Pool2 = require_pg_pool(); var TypeOverrides2 = require_type_overrides(); var { DatabaseError: DatabaseError2 } = require_dist(); var { escapeIdentifier: escapeIdentifier2, escapeLiteral: escapeLiteral2 } = require_utils(); var poolFactory = /* @__PURE__ */ __name((Client3) => { return class BoundPool extends Pool2 { static { __name(this, "BoundPool"); } constructor(options) { super(options, Client3); } }; }, "poolFactory"); var PG = /* @__PURE__ */ __name(function(clientConstructor2) { this.defaults = defaults2; this.Client = clientConstructor2; this.Query = this.Client.Query; this.Pool = poolFactory(this.Client); this._pools = []; this.Connection = Connection2; this.types = require_pg_types(); this.DatabaseError = DatabaseError2; this.TypeOverrides = TypeOverrides2; this.escapeIdentifier = escapeIdentifier2; this.escapeLiteral = escapeLiteral2; this.Result = Result2; this.utils = utils; }, "PG"); var clientConstructor = Client2; var forceNative = false; try { forceNative = !!process.env.NODE_PG_FORCE_NATIVE; } catch { } if (forceNative) { clientConstructor = require_native(); } module.exports = new PG(clientConstructor); Object.defineProperty(module.exports, "native", { configurable: true, enumerable: false, get() { let native = null; try { native = new PG(require_native()); } catch (err) { if (err.code !== "MODULE_NOT_FOUND") { throw err; } } Object.defineProperty(module.exports, "native", { value: native }); return native; } }); } }); // ../../node_modules/.pnpm/pg@8.23.1/node_modules/pg/esm/index.mjs var import_lib = __toESM(require_lib2(), 1); var Client = import_lib.default.Client; var Pool = import_lib.default.Pool; var Connection = import_lib.default.Connection; var types = import_lib.default.types; var Query = import_lib.default.Query; var DatabaseError = import_lib.default.DatabaseError; var escapeIdentifier = import_lib.default.escapeIdentifier; var escapeLiteral = import_lib.default.escapeLiteral; var Result = import_lib.default.Result; var TypeOverrides = import_lib.default.TypeOverrides; var defaults = import_lib.default.defaults; var esm_default = import_lib.default; export { esm_default };