UNPKG

cdk-rds-sql

Version:

A CDK construct that allows creating roles or users and databases an on Aurora Serverless Postgresql or Mysql/MariaDB cluster.

1,455 lines (1,440 loc) 1.57 MB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // node_modules/exponential-backoff/dist/options.js var require_options = __commonJS({ "node_modules/exponential-backoff/dist/options.js"(exports2) { "use strict"; var __assign = exports2 && exports2.__assign || function() { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports2, "__esModule", { value: true }); var defaultOptions = { delayFirstAttempt: false, jitter: "none", maxDelay: Infinity, numOfAttempts: 10, retry: function() { return true; }, startingDelay: 100, timeMultiple: 2 }; function getSanitizedOptions(options) { var sanitized = __assign(__assign({}, defaultOptions), options); if (sanitized.numOfAttempts < 1) { sanitized.numOfAttempts = 1; } return sanitized; } exports2.getSanitizedOptions = getSanitizedOptions; } }); // node_modules/exponential-backoff/dist/jitter/full/full.jitter.js var require_full_jitter = __commonJS({ "node_modules/exponential-backoff/dist/jitter/full/full.jitter.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); function fullJitter(delay) { var jitteredDelay = Math.random() * delay; return Math.round(jitteredDelay); } exports2.fullJitter = fullJitter; } }); // node_modules/exponential-backoff/dist/jitter/no/no.jitter.js var require_no_jitter = __commonJS({ "node_modules/exponential-backoff/dist/jitter/no/no.jitter.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); function noJitter(delay) { return delay; } exports2.noJitter = noJitter; } }); // node_modules/exponential-backoff/dist/jitter/jitter.factory.js var require_jitter_factory = __commonJS({ "node_modules/exponential-backoff/dist/jitter/jitter.factory.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); var full_jitter_1 = require_full_jitter(); var no_jitter_1 = require_no_jitter(); function JitterFactory(options) { switch (options.jitter) { case "full": return full_jitter_1.fullJitter; case "none": default: return no_jitter_1.noJitter; } } exports2.JitterFactory = JitterFactory; } }); // node_modules/exponential-backoff/dist/delay/delay.base.js var require_delay_base = __commonJS({ "node_modules/exponential-backoff/dist/delay/delay.base.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); var jitter_factory_1 = require_jitter_factory(); var Delay = ( /** @class */ function() { function Delay2(options) { this.options = options; this.attempt = 0; } Delay2.prototype.apply = function() { var _this = this; return new Promise(function(resolve) { return setTimeout(resolve, _this.jitteredDelay); }); }; Delay2.prototype.setAttemptNumber = function(attempt) { this.attempt = attempt; }; Object.defineProperty(Delay2.prototype, "jitteredDelay", { get: function() { var jitter = jitter_factory_1.JitterFactory(this.options); return jitter(this.delay); }, enumerable: true, configurable: true }); Object.defineProperty(Delay2.prototype, "delay", { get: function() { var constant = this.options.startingDelay; var base = this.options.timeMultiple; var power = this.numOfDelayedAttempts; var delay = constant * Math.pow(base, power); return Math.min(delay, this.options.maxDelay); }, enumerable: true, configurable: true }); Object.defineProperty(Delay2.prototype, "numOfDelayedAttempts", { get: function() { return this.attempt; }, enumerable: true, configurable: true }); return Delay2; }() ); exports2.Delay = Delay; } }); // node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js var require_skip_first_delay = __commonJS({ "node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js"(exports2) { "use strict"; var __extends = exports2 && exports2.__extends || /* @__PURE__ */ function() { var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p]; }; return extendStatics(d, b); }; return function(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); }); } return new (P || (P = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function(v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(exports2, "__esModule", { value: true }); var delay_base_1 = require_delay_base(); var SkipFirstDelay = ( /** @class */ function(_super) { __extends(SkipFirstDelay2, _super); function SkipFirstDelay2() { return _super !== null && _super.apply(this, arguments) || this; } SkipFirstDelay2.prototype.apply = function() { return __awaiter(this, void 0, void 0, function() { return __generator(this, function(_a) { return [2, this.isFirstAttempt ? true : _super.prototype.apply.call(this)]; }); }); }; Object.defineProperty(SkipFirstDelay2.prototype, "isFirstAttempt", { get: function() { return this.attempt === 0; }, enumerable: true, configurable: true }); Object.defineProperty(SkipFirstDelay2.prototype, "numOfDelayedAttempts", { get: function() { return this.attempt - 1; }, enumerable: true, configurable: true }); return SkipFirstDelay2; }(delay_base_1.Delay) ); exports2.SkipFirstDelay = SkipFirstDelay; } }); // node_modules/exponential-backoff/dist/delay/always/always.delay.js var require_always_delay = __commonJS({ "node_modules/exponential-backoff/dist/delay/always/always.delay.js"(exports2) { "use strict"; var __extends = exports2 && exports2.__extends || /* @__PURE__ */ function() { var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p]; }; return extendStatics(d, b); }; return function(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); Object.defineProperty(exports2, "__esModule", { value: true }); var delay_base_1 = require_delay_base(); var AlwaysDelay = ( /** @class */ function(_super) { __extends(AlwaysDelay2, _super); function AlwaysDelay2() { return _super !== null && _super.apply(this, arguments) || this; } return AlwaysDelay2; }(delay_base_1.Delay) ); exports2.AlwaysDelay = AlwaysDelay; } }); // node_modules/exponential-backoff/dist/delay/delay.factory.js var require_delay_factory = __commonJS({ "node_modules/exponential-backoff/dist/delay/delay.factory.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); var skip_first_delay_1 = require_skip_first_delay(); var always_delay_1 = require_always_delay(); function DelayFactory(options, attempt) { var delay = initDelayClass(options); delay.setAttemptNumber(attempt); return delay; } exports2.DelayFactory = DelayFactory; function initDelayClass(options) { if (!options.delayFirstAttempt) { return new skip_first_delay_1.SkipFirstDelay(options); } return new always_delay_1.AlwaysDelay(options); } } }); // node_modules/exponential-backoff/dist/backoff.js var require_backoff = __commonJS({ "node_modules/exponential-backoff/dist/backoff.js"(exports2) { "use strict"; var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); }); } return new (P || (P = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function(v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(exports2, "__esModule", { value: true }); var options_1 = require_options(); var delay_factory_1 = require_delay_factory(); function backOff2(request, options) { if (options === void 0) { options = {}; } return __awaiter(this, void 0, void 0, function() { var sanitizedOptions, backOff3; return __generator(this, function(_a) { switch (_a.label) { case 0: sanitizedOptions = options_1.getSanitizedOptions(options); backOff3 = new BackOff(request, sanitizedOptions); return [4, backOff3.execute()]; case 1: return [2, _a.sent()]; } }); }); } exports2.backOff = backOff2; var BackOff = ( /** @class */ function() { function BackOff2(request, options) { this.request = request; this.options = options; this.attemptNumber = 0; } BackOff2.prototype.execute = function() { return __awaiter(this, void 0, void 0, function() { var e_1, shouldRetry; return __generator(this, function(_a) { switch (_a.label) { case 0: if (!!this.attemptLimitReached) return [3, 7]; _a.label = 1; case 1: _a.trys.push([1, 4, , 6]); return [4, this.applyDelay()]; case 2: _a.sent(); return [4, this.request()]; case 3: return [2, _a.sent()]; case 4: e_1 = _a.sent(); this.attemptNumber++; return [4, this.options.retry(e_1, this.attemptNumber)]; case 5: shouldRetry = _a.sent(); if (!shouldRetry || this.attemptLimitReached) { throw e_1; } return [3, 6]; case 6: return [3, 0]; case 7: throw new Error("Something went wrong."); } }); }); }; Object.defineProperty(BackOff2.prototype, "attemptLimitReached", { get: function() { return this.attemptNumber >= this.options.numOfAttempts; }, enumerable: true, configurable: true }); BackOff2.prototype.applyDelay = function() { return __awaiter(this, void 0, void 0, function() { var delay; return __generator(this, function(_a) { switch (_a.label) { case 0: delay = delay_factory_1.DelayFactory(this.options, this.attemptNumber); return [4, delay.apply()]; case 1: _a.sent(); return [ 2 /*return*/ ]; } }); }); }; return BackOff2; }() ); } }); // node_modules/sqlstring/lib/SqlString.js var require_SqlString = __commonJS({ "node_modules/sqlstring/lib/SqlString.js"(exports2) { var SqlString = exports2; var ID_GLOBAL_REGEXP = /`/g; var QUAL_GLOBAL_REGEXP = /\./g; var CHARS_GLOBAL_REGEXP = /[\0\b\t\n\r\x1a\"\'\\]/g; var CHARS_ESCAPE_MAP = { "\0": "\\0", "\b": "\\b", " ": "\\t", "\n": "\\n", "\r": "\\r", "": "\\Z", '"': '\\"', "'": "\\'", "\\": "\\\\" }; SqlString.escapeId = function escapeId(val, forbidQualified) { if (Array.isArray(val)) { var sql = ""; for (var i = 0; i < val.length; i++) { sql += (i === 0 ? "" : ", ") + SqlString.escapeId(val[i], forbidQualified); } return sql; } else if (forbidQualified) { return "`" + String(val).replace(ID_GLOBAL_REGEXP, "``") + "`"; } else { return "`" + String(val).replace(ID_GLOBAL_REGEXP, "``").replace(QUAL_GLOBAL_REGEXP, "`.`") + "`"; } }; SqlString.escape = function escape(val, stringifyObjects, timeZone) { if (val === void 0 || val === null) { return "NULL"; } switch (typeof val) { case "boolean": return val ? "true" : "false"; case "number": return val + ""; case "object": if (Object.prototype.toString.call(val) === "[object Date]") { return SqlString.dateToString(val, timeZone || "local"); } else if (Array.isArray(val)) { return SqlString.arrayToList(val, timeZone); } else if (Buffer.isBuffer(val)) { return SqlString.bufferToString(val); } else if (typeof val.toSqlString === "function") { return String(val.toSqlString()); } else if (stringifyObjects) { return escapeString(val.toString()); } else { return SqlString.objectToValues(val, timeZone); } default: return escapeString(val); } }; SqlString.arrayToList = function arrayToList(array, timeZone) { var sql = ""; for (var i = 0; i < array.length; i++) { var val = array[i]; if (Array.isArray(val)) { sql += (i === 0 ? "" : ", ") + "(" + SqlString.arrayToList(val, timeZone) + ")"; } else { sql += (i === 0 ? "" : ", ") + SqlString.escape(val, true, timeZone); } } return sql; }; SqlString.format = function format(sql, values, stringifyObjects, timeZone) { if (values == null) { return sql; } if (!Array.isArray(values)) { values = [values]; } var chunkIndex = 0; var placeholdersRegex = /\?+/g; var result = ""; var valuesIndex = 0; var match; while (valuesIndex < values.length && (match = placeholdersRegex.exec(sql))) { var len = match[0].length; if (len > 2) { continue; } var value = len === 2 ? SqlString.escapeId(values[valuesIndex]) : SqlString.escape(values[valuesIndex], stringifyObjects, timeZone); result += sql.slice(chunkIndex, match.index) + value; chunkIndex = placeholdersRegex.lastIndex; valuesIndex++; } if (chunkIndex === 0) { return sql; } if (chunkIndex < sql.length) { return result + sql.slice(chunkIndex); } return result; }; SqlString.dateToString = function dateToString(date, timeZone) { var dt = new Date(date); if (isNaN(dt.getTime())) { return "NULL"; } var year; var month; var day; var hour; var minute; var second; var millisecond; if (timeZone === "local") { year = dt.getFullYear(); month = dt.getMonth() + 1; day = dt.getDate(); hour = dt.getHours(); minute = dt.getMinutes(); second = dt.getSeconds(); millisecond = dt.getMilliseconds(); } else { var tz = convertTimezone(timeZone); if (tz !== false && tz !== 0) { dt.setTime(dt.getTime() + tz * 6e4); } year = dt.getUTCFullYear(); month = dt.getUTCMonth() + 1; day = dt.getUTCDate(); hour = dt.getUTCHours(); minute = dt.getUTCMinutes(); second = dt.getUTCSeconds(); millisecond = dt.getUTCMilliseconds(); } var str = zeroPad(year, 4) + "-" + zeroPad(month, 2) + "-" + zeroPad(day, 2) + " " + zeroPad(hour, 2) + ":" + zeroPad(minute, 2) + ":" + zeroPad(second, 2) + "." + zeroPad(millisecond, 3); return escapeString(str); }; SqlString.bufferToString = function bufferToString(buffer) { return "X" + escapeString(buffer.toString("hex")); }; SqlString.objectToValues = function objectToValues(object, timeZone) { var sql = ""; for (var key in object) { var val = object[key]; if (typeof val === "function") { continue; } sql += (sql.length === 0 ? "" : ", ") + SqlString.escapeId(key) + " = " + SqlString.escape(val, true, timeZone); } return sql; }; SqlString.raw = function raw(sql) { if (typeof sql !== "string") { throw new TypeError("argument sql must be a string"); } return { toSqlString: function toSqlString() { return sql; } }; }; function escapeString(val) { var chunkIndex = CHARS_GLOBAL_REGEXP.lastIndex = 0; var escapedVal = ""; var match; while (match = CHARS_GLOBAL_REGEXP.exec(val)) { escapedVal += val.slice(chunkIndex, match.index) + CHARS_ESCAPE_MAP[match[0]]; chunkIndex = CHARS_GLOBAL_REGEXP.lastIndex; } if (chunkIndex === 0) { return "'" + val + "'"; } if (chunkIndex < val.length) { return "'" + escapedVal + val.slice(chunkIndex) + "'"; } return "'" + escapedVal + "'"; } function zeroPad(number, length) { number = number.toString(); while (number.length < length) { number = "0" + number; } return number; } function convertTimezone(tz) { if (tz === "Z") { return 0; } var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/); if (m) { return (m[1] === "-" ? -1 : 1) * (parseInt(m[2], 10) + (m[3] ? parseInt(m[3], 10) : 0) / 60) * 60; } return false; } } }); // node_modules/sqlstring/index.js var require_sqlstring = __commonJS({ "node_modules/sqlstring/index.js"(exports2, module2) { module2.exports = require_SqlString(); } }); // node_modules/lru.min/lib/index.js var require_lib = __commonJS({ "node_modules/lru.min/lib/index.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.createLRU = void 0; var createLRU = (options) => { let { max } = options; if (!(Number.isInteger(max) && max > 0)) throw new TypeError("`max` must be a positive integer"); let size = 0; let head = 0; let tail = 0; let free = []; const { onEviction } = options; const keyMap = /* @__PURE__ */ new Map(); const keyList = new Array(max).fill(void 0); const valList = new Array(max).fill(void 0); const next = new Array(max).fill(0); const prev = new Array(max).fill(0); const setTail = (index, type) => { if (index === tail) return; const nextIndex = next[index]; const prevIndex = prev[index]; if (index === head) head = nextIndex; else if (type === "get" || prevIndex !== 0) next[prevIndex] = nextIndex; if (nextIndex !== 0) prev[nextIndex] = prevIndex; next[tail] = index; prev[index] = tail; next[index] = 0; tail = index; }; const _evict = () => { const evictHead = head; const key = keyList[evictHead]; onEviction === null || onEviction === void 0 ? void 0 : onEviction(key, valList[evictHead]); keyMap.delete(key); keyList[evictHead] = void 0; valList[evictHead] = void 0; head = next[evictHead]; if (head !== 0) prev[head] = 0; size--; if (size === 0) head = tail = 0; free.push(evictHead); return evictHead; }; return { /** Adds a key-value pair to the cache. Updates the value if the key already exists. */ set(key, value) { if (key === void 0) return; let index = keyMap.get(key); if (index === void 0) { index = size === max ? _evict() : free.length > 0 ? free.pop() : size; keyMap.set(key, index); keyList[index] = key; size++; } else onEviction === null || onEviction === void 0 ? void 0 : onEviction(key, valList[index]); valList[index] = value; if (size === 1) head = tail = index; else setTail(index, "set"); }, /** Retrieves the value for a given key and moves the key to the most recent position. */ get(key) { const index = keyMap.get(key); if (index === void 0) return; if (index !== tail) setTail(index, "get"); return valList[index]; }, /** Retrieves the value for a given key without changing its position. */ peek: (key) => { const index = keyMap.get(key); return index !== void 0 ? valList[index] : void 0; }, /** Checks if a key exists in the cache. */ has: (key) => keyMap.has(key), /** Iterates over all keys in the cache, from most recent to least recent. */ *keys() { let current = tail; for (let i = 0; i < size; i++) { yield keyList[current]; current = prev[current]; } }, /** Iterates over all values in the cache, from most recent to least recent. */ *values() { let current = tail; for (let i = 0; i < size; i++) { yield valList[current]; current = prev[current]; } }, /** Iterates over `[key, value]` pairs in the cache, from most recent to least recent. */ *entries() { let current = tail; for (let i = 0; i < size; i++) { yield [keyList[current], valList[current]]; current = prev[current]; } }, /** Iterates over each value-key pair in the cache, from most recent to least recent. */ forEach: (callback) => { let current = tail; for (let i = 0; i < size; i++) { const key = keyList[current]; const value = valList[current]; callback(value, key); current = prev[current]; } }, /** Deletes a key-value pair from the cache. */ delete(key) { const index = keyMap.get(key); if (index === void 0) return false; onEviction === null || onEviction === void 0 ? void 0 : onEviction(key, valList[index]); keyMap.delete(key); free.push(index); keyList[index] = void 0; valList[index] = void 0; const prevIndex = prev[index]; const nextIndex = next[index]; if (prevIndex !== 0) next[prevIndex] = nextIndex; if (nextIndex !== 0) prev[nextIndex] = prevIndex; if (index === head) head = nextIndex; if (index === tail) tail = prevIndex; size--; return true; }, /** Evicts the oldest item or the specified number of the oldest items from the cache. */ evict: (number) => { let toPrune = Math.min(number, size); while (toPrune > 0) { _evict(); toPrune--; } }, /** Clears all key-value pairs from the cache. */ clear() { if (typeof onEviction === "function") { const iterator = keyMap.values(); for (let result = iterator.next(); !result.done; result = iterator.next()) onEviction(keyList[result.value], valList[result.value]); } keyMap.clear(); keyList.fill(void 0); valList.fill(void 0); free = []; size = 0; head = tail = 0; }, /** Resizes the cache to a new maximum size, evicting items if necessary. */ resize: (newMax) => { if (!(Number.isInteger(newMax) && newMax > 0)) throw new TypeError("`max` must be a positive integer"); if (newMax === max) return; if (newMax < max) { let current = tail; const preserve = Math.min(size, newMax); const remove = size - preserve; const newKeyList = new Array(newMax); const newValList = new Array(newMax); const newNext = new Array(newMax); const newPrev = new Array(newMax); for (let i = 1; i <= remove; i++) onEviction === null || onEviction === void 0 ? void 0 : onEviction(keyList[i], valList[i]); for (let i = preserve - 1; i >= 0; i--) { newKeyList[i] = keyList[current]; newValList[i] = valList[current]; newNext[i] = i + 1; newPrev[i] = i - 1; keyMap.set(newKeyList[i], i); current = prev[current]; } head = 0; tail = preserve - 1; size = preserve; keyList.length = newMax; valList.length = newMax; next.length = newMax; prev.length = newMax; for (let i = 0; i < preserve; i++) { keyList[i] = newKeyList[i]; valList[i] = newValList[i]; next[i] = newNext[i]; prev[i] = newPrev[i]; } free = []; for (let i = preserve; i < newMax; i++) free.push(i); } else { const fill = newMax - max; keyList.push(...new Array(fill).fill(void 0)); valList.push(...new Array(fill).fill(void 0)); next.push(...new Array(fill).fill(0)); prev.push(...new Array(fill).fill(0)); } max = newMax; }, /** Returns the maximum number of items that can be stored in the cache. */ get max() { return max; }, /** Returns the number of items currently stored in the cache. */ get size() { return size; }, /** Returns the number of currently available slots in the cache before reaching the maximum size. */ get available() { return max - size; } }; }; exports2.createLRU = createLRU; } }); // node_modules/mysql2/lib/parsers/parser_cache.js var require_parser_cache = __commonJS({ "node_modules/mysql2/lib/parsers/parser_cache.js"(exports2, module2) { "use strict"; var { createLRU } = require_lib(); var parserCache = createLRU({ max: 15e3 }); function keyFromFields(type, fields, options, config) { const res = [ type, typeof options.nestTables, options.nestTables, Boolean(options.rowsAsArray), Boolean(options.supportBigNumbers || config.supportBigNumbers), Boolean(options.bigNumberStrings || config.bigNumberStrings), typeof options.typeCast, options.timezone || config.timezone, Boolean(options.decimalNumbers), options.dateStrings ]; for (let i = 0; i < fields.length; ++i) { const field = fields[i]; res.push([ field.name, field.columnType, field.length, field.schema, field.table, field.flags, field.characterSet ]); } return JSON.stringify(res, null, 0); } function getParser(type, fields, options, config, compiler) { const key = keyFromFields(type, fields, options, config); let parser = parserCache.get(key); if (parser) { return parser; } parser = compiler(fields, options, config); parserCache.set(key, parser); return parser; } function setMaxCache(max) { parserCache.resize(max); } function clearCache() { parserCache.clear(); } module2.exports = { getParser, setMaxCache, clearCache, _keyFromFields: keyFromFields }; } }); // node_modules/denque/index.js var require_denque = __commonJS({ "node_modules/denque/index.js"(exports2, module2) { "use strict"; function Denque(array, options) { var options = options || {}; this._capacity = options.capacity; this._head = 0; this._tail = 0; if (Array.isArray(array)) { this._fromArray(array); } else { this._capacityMask = 3; this._list = new Array(4); } } Denque.prototype.peekAt = function peekAt(index) { var i = index; if (i !== (i | 0)) { return void 0; } var len = this.size(); if (i >= len || i < -len) return void 0; if (i < 0) i += len; i = this._head + i & this._capacityMask; return this._list[i]; }; Denque.prototype.get = function get(i) { return this.peekAt(i); }; Denque.prototype.peek = function peek() { if (this._head === this._tail) return void 0; return this._list[this._head]; }; Denque.prototype.peekFront = function peekFront() { return this.peek(); }; Denque.prototype.peekBack = function peekBack() { return this.peekAt(-1); }; Object.defineProperty(Denque.prototype, "length", { get: function length() { return this.size(); } }); Denque.prototype.size = function size() { if (this._head === this._tail) return 0; if (this._head < this._tail) return this._tail - this._head; else return this._capacityMask + 1 - (this._head - this._tail); }; Denque.prototype.unshift = function unshift(item) { if (arguments.length === 0) return this.size(); var len = this._list.length; this._head = this._head - 1 + len & this._capacityMask; this._list[this._head] = item; if (this._tail === this._head) this._growArray(); if (this._capacity && this.size() > this._capacity) this.pop(); if (this._head < this._tail) return this._tail - this._head; else return this._capacityMask + 1 - (this._head - this._tail); }; Denque.prototype.shift = function shift() { var head = this._head; if (head === this._tail) return void 0; var item = this._list[head]; this._list[head] = void 0; this._head = head + 1 & this._capacityMask; if (head < 2 && this._tail > 1e4 && this._tail <= this._list.length >>> 2) this._shrinkArray(); return item; }; Denque.prototype.push = function push(item) { if (arguments.length === 0) return this.size(); var tail = this._tail; this._list[tail] = item; this._tail = tail + 1 & this._capacityMask; if (this._tail === this._head) { this._growArray(); } if (this._capacity && this.size() > this._capacity) { this.shift(); } if (this._head < this._tail) return this._tail - this._head; else return this._capacityMask + 1 - (this._head - this._tail); }; Denque.prototype.pop = function pop() { var tail = this._tail; if (tail === this._head) return void 0; var len = this._list.length; this._tail = tail - 1 + len & this._capacityMask; var item = this._list[this._tail]; this._list[this._tail] = void 0; if (this._head < 2 && tail > 1e4 && tail <= len >>> 2) this._shrinkArray(); return item; }; Denque.prototype.removeOne = function removeOne(index) { var i = index; if (i !== (i | 0)) { return void 0; } if (this._head === this._tail) return void 0; var size = this.size(); var len = this._list.length; if (i >= size || i < -size) return void 0; if (i < 0) i += size; i = this._head + i & this._capacityMask; var item = this._list[i]; var k; if (index < size / 2) { for (k = index; k > 0; k--) { this._list[i] = this._list[i = i - 1 + len & this._capacityMask]; } this._list[i] = void 0; this._head = this._head + 1 + len & this._capacityMask; } else { for (k = size - 1 - index; k > 0; k--) { this._list[i] = this._list[i = i + 1 + len & this._capacityMask]; } this._list[i] = void 0; this._tail = this._tail - 1 + len & this._capacityMask; } return item; }; Denque.prototype.remove = function remove(index, count) { var i = index; var removed; var del_count = count; if (i !== (i | 0)) { return void 0; } if (this._head === this._tail) return void 0; var size = this.size(); var len = this._list.length; if (i >= size || i < -size || count < 1) return void 0; if (i < 0) i += size; if (count === 1 || !count) { removed = new Array(1); removed[0] = this.removeOne(i); return removed; } if (i === 0 && i + count >= size) { removed = this.toArray(); this.clear(); return removed; } if (i + count > size) count = size - i; var k; removed = new Array(count); for (k = 0; k < count; k++) { removed[k] = this._list[this._head + i + k & this._capacityMask]; } i = this._head + i & this._capacityMask; if (index + count === size) { this._tail = this._tail - count + len & this._capacityMask; for (k = count; k > 0; k--) { this._list[i = i + 1 + len & this._capacityMask] = void 0; } return removed; } if (index === 0) { this._head = this._head + count + len & this._capacityMask; for (k = count - 1; k > 0; k--) { this._list[i = i + 1 + len & this._capacityMask] = void 0; } return removed; } if (i < size / 2) { this._head = this._head + index + count + len & this._capacityMask; for (k = index; k > 0; k--) { this.unshift(this._list[i = i - 1 + len & this._capacityMask]); } i = this._head - 1 + len & this._capacityMask; while (del_count > 0) { this._list[i = i - 1 + len & this._capacityMask] = void 0; del_count--; } if (index < 0) this._tail = i; } else { this._tail = i; i = i + count + len & this._capacityMask; for (k = size - (count + index); k > 0; k--) { this.push(this._list[i++]); } i = this._tail; while (del_count > 0) { this._list[i = i + 1 + len & this._capacityMask] = void 0; del_count--; } } if (this._head < 2 && this._tail > 1e4 && this._tail <= len >>> 2) this._shrinkArray(); return removed; }; Denque.prototype.splice = function splice(index, count) { var i = index; if (i !== (i | 0)) { return void 0; } var size = this.size(); if (i < 0) i += size; if (i > size) return void 0; if (arguments.length > 2) { var k; var temp; var removed; var arg_len = arguments.length; var len = this._list.length; var arguments_index = 2; if (!size || i < size / 2) { temp = new Array(i); for (k = 0; k < i; k++) { temp[k] = this._list[this._head + k & this._capacityMask]; } if (count === 0) { removed = []; if (i > 0) { this._head = this._head + i + len & this._capacityMask; } } else { removed = this.remove(i, count); this._head = this._head + i + len & this._capacityMask; } while (arg_len > arguments_index) { this.unshift(arguments[--arg_len]); } for (k = i; k > 0; k--) { this.unshift(temp[k - 1]); } } else { temp = new Array(size - (i + count)); var leng = temp.length; for (k = 0; k < leng; k++) { temp[k] = this._list[this._head + i + count + k & this._capacityMask]; } if (count === 0) { removed = []; if (i != size) { this._tail = this._head + i + len & this._capacityMask; } } else { removed = this.remove(i, count); this._tail = this._tail - leng + len & this._capacityMask; } while (arguments_index < arg_len) { this.push(arguments[arguments_index++]); } for (k = 0; k < leng; k++) { this.push(temp[k]); } } return removed; } else { return this.remove(i, count); } }; Denque.prototype.clear = function clear() { this._list = new Array(this._list.length); this._head = 0; this._tail = 0; }; Denque.prototype.isEmpty = function isEmpty() { return this._head === this._tail; }; Denque.prototype.toArray = function toArray() { return this._copyArray(false); }; Denque.prototype._fromArray = function _fromArray(array) { var length = array.length; var capacity = this._nextPowerOf2(length); this._list = new Array(capacity); this._capacityMask = capacity - 1; this._tail = length; for (var i = 0; i < length; i++) this._list[i] = array[i]; }; Denque.prototype._copyArray = function _copyArray(fullCopy, size) { var src = this._list; var capacity = src.length; var length = this.length; size = size | length; if (size == length && this._head < this._tail) { return this._list.slice(this._head, this._tail); } var dest = new Array(size); var k = 0; var i; if (fullCopy || this._head > this._tail) { for (i = this._head; i < capacity; i++) dest[k++] = src[i]; for (i = 0; i < this._tail; i++) dest[k++] = src[i]; } else { for (i = this._head; i < this._tail; i++) dest[k++] = src[i]; } return dest; }; Denque.prototype._growArray = function _growArray() { if (this._head != 0) { var newList = this._copyArray(true, this._list.length << 1); this._tail = this._list.length; this._head = 0; this._list = newList; } else { this._tail = this._list.length; this._list.length <<= 1; } this._capacityMask = this._capacityMask << 1 | 1; }; Denque.prototype._shrinkArray = function _shrinkArray() { this._list.length >>>= 1; this._capacityMask >>>= 1; }; Denque.prototype._nextPowerOf2 = function _nextPowerOf2(num) { var log2 = Math.log(num) / Math.log(2); var nextPow2 = 1 << log2 + 1; return Math.max(nextPow2, 4); }; module2.exports = Denque; } }); // node_modules/mysql2/lib/constants/errors.js var require_errors = __commonJS({ "node_modules/mysql2/lib/constants/errors.js"(exports2) { "use strict"; exports2.EE_CANTCREATEFILE = 1; exports2.EE_READ = 2; exports2.EE_WRITE = 3; exports2.EE_BADCLOSE = 4; exports2.EE_OUTOFMEMORY = 5; exports2.EE_DELETE = 6; exports2.EE_LINK = 7; exports2.EE_EOFERR = 9; exports2.EE_CANTLOCK = 10; exports2.EE_CANTUNLOCK = 11; exports2.EE_DIR = 12; exports2.EE_STAT = 13; exports2.EE_CANT_CHSIZE = 14; exports2.EE_CANT_OPEN_STREAM = 15; exports2.EE_GETWD = 16; exports2.EE_SETWD = 17; exports2.EE_LINK_WARNING = 18; exports2.EE_OPEN_WARNING = 19; exports2.EE_DISK_FULL = 20; exports2.EE_CANT_MKDIR = 21; exports2.EE_UNKNOWN_CHARSET = 22; exports2.EE_OUT_OF_FILERESOURCES = 23; exports2.EE_CANT_READLINK = 24; exports2.EE_CANT_SYMLINK = 25; exports2.EE_REALPATH = 26; exports2.EE_SYNC = 27; exports2.EE_UNKNOWN_COLLATION = 28; exports2.EE_FILENOTFOUND = 29; exports2.EE_FILE_NOT_CLOSED = 30; exports2.EE_CHANGE_OWNERSHIP = 31; exports2.EE_CHANGE_PERMISSIONS = 32; exports2.EE_CANT_SEEK = 33; exports2.EE_CAPACITY_EXCEEDED = 34; exports2.EE_DISK_FULL_WITH_RETRY_MSG = 35; exports2.EE_FAILED_TO_CREATE_TIMER = 36; exports2.EE_FAILED_TO_DELETE_TIMER = 37; exports2.EE_FAILED_TO_CREATE_TIMER_QUEUE = 38; exports2.EE_FAILED_TO_START_TIMER_NOTIFY_THREAD = 39; exports2.EE_FAILED_TO_CREATE_TIMER_NOTIFY_THREAD_INTERRUPT_EVENT = 40; exports2.EE_EXITING_TIMER_NOTIFY_THREAD = 41; exports2.EE_WIN_LIBRARY_LOAD_FAILED = 42; exports2.EE_WIN_RUN_TIME_ERROR_CHECK = 43; exports2.EE_FAILED_TO_DETERMINE_LARGE_PAGE_SIZE = 44; exports2.EE_FAILED_TO_KILL_ALL_THREADS = 45; exports2.EE_FAILED_TO_CREATE_IO_COMPLETION_PORT = 46; exports2.EE_FAILED_TO_OPEN_DEFAULTS_FILE = 47; exports2.EE_FAILED_TO_HANDLE_DEFAULTS_FILE = 48; exports2.EE_WRONG_DIRECTIVE_IN_CONFIG_FILE = 49; exports2.EE_SKIPPING_DIRECTIVE_DUE_TO_MAX_INCLUDE_RECURSION = 50; exports2.EE_INCORRECT_GRP_DEFINITION_IN_CONFIG_FILE = 51; exports2.EE_OPTION_WITHOUT_GRP_IN_CONFIG_FILE = 52; exports2.EE_CONFIG_FILE_PERMISSION_ERROR = 53; exports2.EE_IGNORE_WORLD_WRITABLE_CONFIG_FILE = 54; exports2.EE_USING_DISABLED_OPTION = 55; exports2.EE_USING_DISABLED_SHORT_OPTION = 56; exports2.EE_USING_PASSWORD_ON_CLI_IS_INSECURE = 57; exports2.EE_UNKNOWN_SUFFIX_FOR_VARIABLE = 58; exports2.EE_SSL_ERROR_FROM_FILE = 59; exports2.EE_SSL_ERROR = 60; exports2.EE_NET_SEND_ERROR_IN_BOOTSTRAP = 61; exports2.EE_PACKETS_OUT_OF_ORDER = 62; export