create-eliza
Version:
Initialize an Eliza project
1,514 lines (1,493 loc) • 2.55 MB
JavaScript
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
import {
require_main,
require_signal_exit
} from "./chunk-ZMJ3QLUC.js";
import {
require_buffer_from
} from "./chunk-RG4463OH.js";
import {
source_default
} from "./chunk-BY3DNMXE.js";
import {
DatabaseAdapter,
logger,
require_split2,
v4_default,
validateCharacterConfig
} from "./chunk-UIEY2LL5.js";
import {
require_call_bind_apply_helpers,
require_get_intrinsic,
require_mime_types,
require_type
} from "./chunk-JOY6AARI.js";
import {
require_has_flag,
require_ms
} from "./chunk-DT4FXRJL.js";
import {
require_prompts
} from "./chunk-OGSHIQ3J.js";
import {
__commonJS,
__esm,
__export,
__require,
__toCommonJS,
__toESM
} from "./chunk-WCMDOJQK.js";
// ../../node_modules/pg/node_modules/pg-types/node_modules/postgres-array/index.js
var require_postgres_array = __commonJS({
"../../node_modules/pg/node_modules/pg-types/node_modules/postgres-array/index.js"(exports) {
"use strict";
exports.parse = function(source, transform) {
return new ArrayParser(source, transform).parse();
};
var ArrayParser = class _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 character2 = this.source[this.position++];
if (character2 === "\\") {
return {
value: this.source[this.position++],
escaped: true
};
}
return {
value: character2,
escaped: false
};
}
record(character2) {
this.recorded.push(character2);
}
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 char2 = this.nextCharacter();
if (char2.value === "=") break;
}
}
}
parse(nested) {
var character2, parser, quote;
this.consumeDimensions();
while (!this.isEof()) {
character2 = this.nextCharacter();
if (character2.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 (character2.value === "}" && !quote) {
this.dimension--;
if (!this.dimension) {
this.newEntry();
if (nested) return this.entries;
}
} else if (character2.value === '"' && !character2.escaped) {
if (quote) this.newEntry(true);
quote = !quote;
} else if (character2.value === "," && !quote) {
this.newEntry();
} else {
this.record(character2.value);
}
}
if (this.dimension !== 0) {
throw new Error("array dimension not balanced");
}
return this.entries;
}
};
function identity(value) {
return value;
}
}
});
// ../../node_modules/pg/node_modules/pg-types/lib/arrayParser.js
var require_arrayParser = __commonJS({
"../../node_modules/pg/node_modules/pg-types/lib/arrayParser.js"(exports, module) {
var array = require_postgres_array();
module.exports = {
create: function(source, transform) {
return {
parse: function() {
return array.parse(source, transform);
}
};
}
};
}
});
// ../../node_modules/pg/node_modules/pg-types/node_modules/postgres-date/index.js
var require_postgres_date = __commonJS({
"../../node_modules/pg/node_modules/pg-types/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 = 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 date2;
var offset = timeZoneOffset(isoDate);
if (offset != null) {
date2 = new Date(Date.UTC(year, month, day, hour, minute, second, ms));
if (is0To99(year)) {
date2.setUTCFullYear(year);
}
if (offset !== 0) {
date2.setTime(date2.getTime() - offset);
}
} else {
date2 = new Date(year, month, day, hour, minute, second, ms);
if (is0To99(year)) {
date2.setFullYear(year);
}
}
return date2;
};
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 date2 = new Date(year, month, day);
if (is0To99(year)) {
date2.setFullYear(year);
}
return date2;
}
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;
}
function bcYearToNegativeYear(year) {
return -(year - 1);
}
function is0To99(num) {
return num >= 0 && num < 100;
}
}
});
// ../../node_modules/xtend/mutable.js
var require_mutable = __commonJS({
"../../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;
}
}
});
// ../../node_modules/pg/node_modules/pg-types/node_modules/postgres-interval/index.js
var require_postgres_interval = __commonJS({
"../../node_modules/pg/node_modules/pg-types/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));
}
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];
}
};
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;
}
function parse(interval2) {
if (!interval2) return {};
var matches = INTERVAL.exec(interval2);
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;
}, {});
}
}
});
// ../../node_modules/pg/node_modules/pg-types/node_modules/postgres-bytea/index.js
var require_postgres_bytea = __commonJS({
"../../node_modules/pg/node_modules/pg-types/node_modules/postgres-bytea/index.js"(exports, module) {
"use strict";
module.exports = function parseBytea(input) {
if (/^\\x/.test(input)) {
return new Buffer(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 new Buffer(output, "binary");
};
}
});
// ../../node_modules/pg/node_modules/pg-types/lib/textParsers.js
var require_textParsers = __commonJS({
"../../node_modules/pg/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 function nullAllowed(value) {
if (value === null) return value;
return fn(value);
};
}
function parseBool(value) {
if (value === null) return value;
return value === "TRUE" || value === "t" || value === "true" || value === "y" || value === "yes" || value === "on" || value === "1";
}
function parseBoolArray(value) {
if (!value) return null;
return array.parse(value, parseBool);
}
function parseBaseTenInt(string) {
return parseInt(string, 10);
}
function parseIntegerArray(value) {
if (!value) return null;
return array.parse(value, allowNull(parseBaseTenInt));
}
function parseBigIntegerArray(value) {
if (!value) return null;
return array.parse(value, allowNull(function(entry) {
return parseBigInteger(entry).trim();
}));
}
var parsePointArray = function(value) {
if (!value) {
return null;
}
var p = arrayParser.create(value, function(entry) {
if (entry !== null) {
entry = parsePoint(entry);
}
return entry;
});
return p.parse();
};
var parseFloatArray = function(value) {
if (!value) {
return null;
}
var p = arrayParser.create(value, function(entry) {
if (entry !== null) {
entry = parseFloat(entry);
}
return entry;
});
return p.parse();
};
var parseStringArray = function(value) {
if (!value) {
return null;
}
var p = arrayParser.create(value);
return p.parse();
};
var parseDateArray = function(value) {
if (!value) {
return null;
}
var p = arrayParser.create(value, function(entry) {
if (entry !== null) {
entry = parseDate(entry);
}
return entry;
});
return p.parse();
};
var parseIntervalArray = function(value) {
if (!value) {
return null;
}
var p = arrayParser.create(value, function(entry) {
if (entry !== null) {
entry = parseInterval(entry);
}
return entry;
});
return p.parse();
};
var parseByteAArray = function(value) {
if (!value) {
return null;
}
return array.parse(value, allowNull(parseByteA));
};
var parseInteger = function(value) {
return parseInt(value, 10);
};
var parseBigInteger = function(value) {
var valStr = String(value);
if (/^\d+$/.test(valStr)) {
return valStr;
}
return value;
};
var parseJsonArray = function(value) {
if (!value) {
return null;
}
return array.parse(value, allowNull(JSON.parse));
};
var parsePoint = function(value) {
if (value[0] !== "(") {
return null;
}
value = value.substring(1, value.length - 1).split(",");
return {
x: parseFloat(value[0]),
y: parseFloat(value[1])
};
};
var parseCircle = function(value) {
if (value[0] !== "<" && value[1] !== "(") {
return null;
}
var point2 = "(";
var radius = "";
var pointParsed = false;
for (var i = 2; i < value.length - 1; i++) {
if (!pointParsed) {
point2 += value[i];
}
if (value[i] === ")") {
pointParsed = true;
continue;
} else if (!pointParsed) {
continue;
}
if (value[i] === ",") {
continue;
}
radius += value[i];
}
var result = parsePoint(point2);
result.radius = parseFloat(radius);
return result;
};
var init = 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);
};
module.exports = {
init
};
}
});
// ../../node_modules/pg-int8/index.js
var require_pg_int8 = __commonJS({
"../../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;
}
}
module.exports = readInt8;
}
});
// ../../node_modules/pg/node_modules/pg-types/lib/binaryParsers.js
var require_binaryParsers = __commonJS({
"../../node_modules/pg/node_modules/pg-types/lib/binaryParsers.js"(exports, module) {
var parseInt64 = require_pg_int8();
var parseBits = 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 = function(value) {
if (invert) {
return ~value & 255;
}
return value;
};
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;
};
var parseFloatFromBits = 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 = 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;
};
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;
};
var parseInt16 = function(value) {
if (parseBits(value, 1) == 1) {
return -1 * (parseBits(value, 15, 1, true) + 1);
}
return parseBits(value, 15, 1);
};
var parseInt32 = function(value) {
if (parseBits(value, 1) == 1) {
return -1 * (parseBits(value, 31, 1, true) + 1);
}
return parseBits(value, 31, 1);
};
var parseFloat32 = function(value) {
return parseFloatFromBits(value, 23, 8);
};
var parseFloat64 = function(value) {
return parseFloatFromBits(value, 52, 11);
};
var parseNumeric = 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;
};
var parseDate = 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;
};
var parseArray = 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 = 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);
}
};
var parse = function(dimension, elementType2) {
var array = [];
var i2;
if (dimension.length > 1) {
var count2 = dimension.shift();
for (i2 = 0; i2 < count2; i2++) {
array[i2] = parse(dimension, elementType2);
}
dimension.unshift(count2);
} else {
for (i2 = 0; i2 < dimension[0]; i2++) {
array[i2] = parseElement(elementType2);
}
}
return array;
};
return parse(dims, elementType);
};
var parseText = function(value) {
return value.toString("utf8");
};
var parseBool = function(value) {
if (value === null) return null;
return parseBits(value, 8) > 0;
};
var init = 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);
};
module.exports = {
init
};
}
});
// ../../node_modules/pg/node_modules/pg-types/lib/builtins.js
var require_builtins = __commonJS({
"../../node_modules/pg/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/pg/node_modules/pg-types/index.js
var require_pg_types = __commonJS({
"../../node_modules/pg/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);
}
function getTypeParser(oid, format) {
format = format || "text";
if (!typeParsers[format]) {
return noParse;
}
return typeParsers[format][oid] || noParse;
}
function setTypeParser(oid, format, parseFn) {
if (typeof format == "function") {
parseFn = format;
format = "text";
}
typeParsers[format][oid] = parseFn;
}
textParsers.init(function(oid, converter) {
typeParsers.text[oid] = converter;
});
binaryParsers.init(function(oid, converter) {
typeParsers.binary[oid] = converter;
});
}
});
// ../../node_modules/pg/lib/defaults.js
var require_defaults = __commonJS({
"../../node_modules/pg/lib/defaults.js"(exports, module) {
"use strict";
module.exports = {
// database host. defaults to localhost
host: "localhost",
// database user's name
user: process.platform === "win32" ? process.env.USERNAME : process.env.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,
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/pg/lib/utils.js
var require_utils = __commonJS({
"../../node_modules/pg/lib/utils.js"(exports, module) {
"use strict";
var defaults = require_defaults();
function escapeElement(elementRepresentation) {
var escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
return '"' + escaped + '"';
}
function arrayString(val) {
var result = "{";
for (var i = 0; i < val.length; i++) {
if (i > 0) {
result = result + ",";
}
if (val[i] === null || typeof val[i] === "undefined") {
result = result + "NULL";
} else if (Array.isArray(val[i])) {
result = result + arrayString(val[i]);
} else if (ArrayBuffer.isView(val[i])) {
var item = val[i];
if (!(item instanceof Buffer)) {
var buf = Buffer.from(item.buffer, item.byteOffset, item.byteLength);
if (buf.length === item.byteLength) {
item = buf;
} else {
item = buf.slice(item.byteOffset, item.byteOffset + item.byteLength);
}
}
result += "\\\\x" + item.toString("hex");
} else {
result += escapeElement(prepareValue(val[i]));
}
}
result = result + "}";
return result;
}
var prepareValue = function(val, seen) {
if (val == null) {
return null;
}
if (typeof val === "object") {
if (val instanceof Buffer) {
return val;
}
if (ArrayBuffer.isView(val)) {
var buf = Buffer.from(val.buffer, val.byteOffset, val.byteLength);
if (buf.length === val.byteLength) {
return buf;
}
return buf.slice(val.byteOffset, val.byteOffset + val.byteLength);
}
if (val instanceof Date) {
if (defaults.parseInputDatesAsUTC) {
return dateToStringUTC(val);
} else {
return dateToString(val);
}
}
if (Array.isArray(val)) {
return arrayString(val);
}
return prepareObject(val, seen);
}
return val.toString();
};
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);
}
function dateToString(date2) {
var offset = -date2.getTimezoneOffset();
var year = date2.getFullYear();
var isBCYear = year < 1;
if (isBCYear) year = Math.abs(year) + 1;
var ret = String(year).padStart(4, "0") + "-" + String(date2.getMonth() + 1).padStart(2, "0") + "-" + String(date2.getDate()).padStart(2, "0") + "T" + String(date2.getHours()).padStart(2, "0") + ":" + String(date2.getMinutes()).padStart(2, "0") + ":" + String(date2.getSeconds()).padStart(2, "0") + "." + String(date2.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;
}
function dateToStringUTC(date2) {
var year = date2.getUTCFullYear();
var isBCYear = year < 1;
if (isBCYear) year = Math.abs(year) + 1;
var ret = String(year).padStart(4, "0") + "-" + String(date2.getUTCMonth() + 1).padStart(2, "0") + "-" + String(date2.getUTCDate()).padStart(2, "0") + "T" + String(date2.getUTCHours()).padStart(2, "0") + ":" + String(date2.getUTCMinutes()).padStart(2, "0") + ":" + String(date2.getUTCSeconds()).padStart(2, "0") + "." + String(date2.getUTCMilliseconds()).padStart(3, "0");
ret += "+00:00";
if (isBCYear) ret += " BC";
return ret;
}
function normalizeQueryConfig(config, values, callback) {
config = typeof config === "string" ? { text: config } : config;
if (values) {
if (typeof values === "function") {
config.callback = values;
} else {
config.values = values;
}
}
if (callback) {
config.callback = callback;
}
return config;
}
var escapeIdentifier = function(str) {
return '"' + str.replace(/"/g, '""') + '"';
};
var escapeLiteral = function(str) {
var hasBackslash = false;
var escaped = "'";
for (var i = 0; i < str.length; i++) {
var 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;
};
module.exports = {
prepareValue: function prepareValueWrapper(value) {
return prepareValue(value);
},
normalizeQueryConfig,
escapeIdentifier,
escapeLiteral
};
}
});
// ../../node_modules/pg/lib/crypto/utils-legacy.js
var require_utils_legacy = __commonJS({
"../../node_modules/pg/lib/crypto/utils-legacy.js"(exports, module) {
"use strict";
var nodeCrypto = __require("crypto");
function md5(string) {
return nodeCrypto.createHash("md5").update(string, "utf-8").digest("hex");
}
function postgresMd5PasswordHash(user, password, salt) {
var inner = md5(password + user);
var outer = md5(Buffer.concat([Buffer.from(inner), salt]));
return "md5" + outer;
}
function sha256(text2) {
return nodeCrypto.createHash("sha256").update(text2).digest();
}
function hmacSha256(key, msg) {
return nodeCrypto.createHmac("sha256", key).update(msg).digest();
}
async function deriveKey(password, salt, iterations) {
return nodeCrypto.pbkdf2Sync(password, salt, iterations, 32, "sha256");
}
module.exports = {
postgresMd5PasswordHash,
randomBytes: nodeCrypto.randomBytes,
deriveKey,
sha256,
hmacSha256,
md5
};
}
});
// ../../node_modules/pg/lib/crypto/utils-webcrypto.js
var require_utils_webcrypto = __commonJS({
"../../node_modules/pg/lib/crypto/utils-webcrypto.js"(exports, module) {
var nodeCrypto = __require("crypto");
module.exports = {
postgresMd5PasswordHash,
randomBytes,
deriveKey,
sha256,
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));
}
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("");
}
}
async function postgresMd5PasswordHash(user, password, salt) {
var inner = await md5(password + user);
var outer = await md5(Buffer.concat([Buffer.from(inner), salt]));
return "md5" + outer;
}
async function sha256(text2) {
return await subtleCrypto.digest("SHA-256", text2);
}
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));
}
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"]);
}
}
});
// ../../node_modules/pg/lib/crypto/utils.js
var require_utils2 = __commonJS({
"../../node_modules/pg/lib/crypto/utils.js"(exports, module) {
"use strict";
var useLegacyCrypto = parseInt(process.versions && process.versions.node && process.versions.node.split(".")[0]) < 15;
if (useLegacyCrypto) {
module.exports = require_utils_legacy();
} else {
module.exports = require_utils_webcrypto();
}
}
});
// ../../node_modules/pg/lib/crypto/sasl.js
var require_sasl = __commonJS({
"../../node_modules/pg/lib/crypto/sasl.js"(exports, module) {
"use strict";
var crypto2 = require_utils2();
function startSession(mechanisms) {
if (mechanisms.indexOf("SCRAM-SHA-256") === -1) {
throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");
}
const clientNonce = crypto2.randomBytes(18).toString("base64");
return {
mechanism: "SCRAM-SHA-256",
clientNonce,
response: "n,,n=*,r=" + clientNonce,
message: "SASLInitialResponse"
};
}
async function continueSession(session, password, serverData) {
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");
}
var clientFirstMessageBare = "n=*,r=" + session.clientNonce;
var serverFirstMessage = "r=" + sv.nonce + ",s=" + sv.salt + ",i=" + sv.iteration;
var clientFinalMessageWithoutProof = "c=biws,r=" + sv.nonce;
var authMessage = clientFirstMessageBare + "," + serverFirstMessage + "," + clientFinalMessageWithoutProof;
var saltBytes = Buffer.from(sv.salt, "base64");
var saltedPassword = await crypto2.deriveKey(password, saltBytes, sv.iteration);
var clientKey = await crypto2.hmacSha256(saltedPassword, "Client Key");
var storedKey = await crypto2.sha256(clientKey);
var clientSignature = await crypto2.hmacSha256(storedKey, authMessage);
var clientProof = xorBuffers(Buffer.from(clientKey), Buffer.from(clientSignature)).toString("base64");
var serverKey = await crypto2.hmacSha256(saltedPassword, "Server Key");
var serverSignatureBytes = await crypto2.hmacSha256(serverKey, authMessage);
session.message = "SASLResponse";
session.serverSignature = Buffer.from(serverSignatureBytes).toString("base64");
session.response = clientFinalMessageWithoutProof + ",p=" + clientProof;
}
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");
}
}
function isPrintableChars(text2) {
if (typeof text2 !== "string") {
throw new TypeError("SASL: text must be a string");
}
return text2.split("").map((_, i) => text2.charCodeAt(i)).every((c) => c >= 33 && c <= 43 || c >= 45 && c <= 126);
}
function isBase64(text2) {
return /^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(text2);
}
function parseAttributePairs(text2) {
if (typeof text2 !== "string") {
throw new TypeError("SASL: attribute pairs text must be a string");
}
return new Map(
text2.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];
})
);
}
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
};
}
function parseServerFinalMessage(serverData) {
const attrPairs = parseAttributePairs(serverData);
const serverSignature = attrPairs.get("v");
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
};
}
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]));
}
module.exports = {
startSession,
continueSession,
finalizeSession
};
}
});
// ../../node_modules/pg/lib/type-overrides.js
var require_type_overrides = __commonJS({
"../../node_modules/pg/lib/type-overrides.js"(exports, module) {
"use strict";
var types3 = require_pg_types();
function TypeOverrides(userTypes) {
this._types = userTypes || types3;
this.text = {};
this.binary = {};
}
TypeOverrides.prototype.getOverrides = function(format) {
switch (format) {
case "text":
return this.text;
case "binary":
return this.binary;
default:
return {};
}
};
TypeOverrides.prototype.setTypeParser = function(oid, format, parseFn) {
if (typeof format === "function") {
parseFn = format;
format = "text";
}
this.getOverrides(format)[oid] = parseFn;
};
TypeOverrides.prototype.getTypeParser = function(oid, format) {
format = format || "text";
return this.getOverrides(format)[oid] || this._types.getTypeParser(oid, format);
};
module.exports = TypeOverrides;
}
});
// ../../node_modules/pg-connection-string/index.js
var require_pg_connection_string = __commonJS({
"../../node_modules/pg-connection-string/index.js"(exports, module) {
"use strict";
function parse(str) {
if (str.charAt(0) === "/") {
const config2 = str.split(" ");
return { host: config2[0], database: config2[1] };
}
const config = {};
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 {
result = new URL(str, "postgres://base");
} catch (e) {
result = new URL(str.replace("@/", "@___DUMMY___/"), "postgres://base");
dummyHost = true;
}
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;
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 || confi