UNPKG

@adeze/raindrop-mcp

Version:

MCP Server for Raindrop.io bookmark management

1,515 lines (1,499 loc) 1.92 MB
import { createRequire } from "node:module"; var __create = Object.create; var __getProtoOf = Object.getPrototypeOf; var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __hasOwnProp = Object.prototype.hasOwnProperty; function __accessProp(key) { return this[key]; } var __toESMCache_node; var __toESMCache_esm; var __toESM = (mod, isNodeMode, target) => { var canCache = mod != null && typeof mod === "object"; if (canCache) { var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap; var cached = cache.get(mod); if (cached) return cached; } target = mod != null ? __create(__getProtoOf(mod)) : {}; const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target; for (let key of __getOwnPropNames(mod)) if (!__hasOwnProp.call(to, key)) __defProp(to, key, { get: __accessProp.bind(mod, key), enumerable: true }); if (canCache) cache.set(mod, to); return to; }; var __toCommonJS = (from) => { var entry = (__moduleCache ??= new WeakMap).get(from), desc; if (entry) return entry; entry = __defProp({}, "__esModule", { value: true }); if (from && typeof from === "object" || typeof from === "function") { for (var key of __getOwnPropNames(from)) if (!__hasOwnProp.call(entry, key)) __defProp(entry, key, { get: __accessProp.bind(from, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } __moduleCache.set(from, entry); return entry; }; var __moduleCache; var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); var __returnValue = (v) => v; function __exportSetter(name, newValue) { this[name] = __returnValue.bind(null, newValue); } var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true, configurable: true, set: __exportSetter.bind(all, name) }); }; var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res); var __require = /* @__PURE__ */ createRequire(import.meta.url); // node_modules/dotenv/package.json var require_package = __commonJS((exports, module) => { module.exports = { name: "dotenv", version: "17.3.1", description: "Loads environment variables from .env file", main: "lib/main.js", types: "lib/main.d.ts", exports: { ".": { types: "./lib/main.d.ts", require: "./lib/main.js", default: "./lib/main.js" }, "./config": "./config.js", "./config.js": "./config.js", "./lib/env-options": "./lib/env-options.js", "./lib/env-options.js": "./lib/env-options.js", "./lib/cli-options": "./lib/cli-options.js", "./lib/cli-options.js": "./lib/cli-options.js", "./package.json": "./package.json" }, scripts: { "dts-check": "tsc --project tests/types/tsconfig.json", lint: "standard", pretest: "npm run lint && npm run dts-check", test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000", "test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov", prerelease: "npm test", release: "standard-version" }, repository: { type: "git", url: "git://github.com/motdotla/dotenv.git" }, homepage: "https://github.com/motdotla/dotenv#readme", funding: "https://dotenvx.com", keywords: [ "dotenv", "env", ".env", "environment", "variables", "config", "settings" ], readmeFilename: "README.md", license: "BSD-2-Clause", devDependencies: { "@types/node": "^18.11.3", decache: "^4.6.2", sinon: "^14.0.1", standard: "^17.0.0", "standard-version": "^9.5.0", tap: "^19.2.0", typescript: "^4.8.4" }, engines: { node: ">=12" }, browser: { fs: false } }; }); // node_modules/dotenv/lib/main.js var require_main = __commonJS((exports, module) => { var fs = __require("fs"); var path = __require("path"); var os = __require("os"); var crypto3 = __require("crypto"); var packageJson = require_package(); var version2 = packageJson.version; var TIPS = [ "\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com", "\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit", "\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild", "\uD83E\uDD16 agentic secret storage: https://dotenvx.com/as2", "⚡️ secrets for agents: https://dotenvx.com/as2", "\uD83D\uDEE1️ auth for agents: https://vestauth.com", "\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`", "⚙️ specify custom .env file path with { path: '/custom/path/.env' }", "⚙️ enable debug logging with { debug: true }", "⚙️ override existing env vars with { override: true }", "⚙️ suppress all logs with { quiet: true }", "⚙️ write to custom object with { processEnv: myObject }", "⚙️ load multiple .env files with { path: ['.env.local', '.env'] }" ]; function _getRandomTip() { return TIPS[Math.floor(Math.random() * TIPS.length)]; } function parseBoolean(value) { if (typeof value === "string") { return !["false", "0", "no", "off", ""].includes(value.toLowerCase()); } return Boolean(value); } function supportsAnsi() { return process.stdout.isTTY; } function dim(text) { return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text; } var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg; function parse5(src) { const obj = {}; let lines = src.toString(); lines = lines.replace(/\r\n?/mg, ` `); let match; while ((match = LINE.exec(lines)) != null) { const key = match[1]; let value = match[2] || ""; value = value.trim(); const maybeQuote = value[0]; value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"); if (maybeQuote === '"') { value = value.replace(/\\n/g, ` `); value = value.replace(/\\r/g, "\r"); } obj[key] = value; } return obj; } function _parseVault(options) { options = options || {}; const vaultPath = _vaultPath(options); options.path = vaultPath; const result = DotenvModule.configDotenv(options); if (!result.parsed) { const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`); err.code = "MISSING_DATA"; throw err; } const keys = _dotenvKey(options).split(","); const length = keys.length; let decrypted; for (let i = 0;i < length; i++) { try { const key = keys[i].trim(); const attrs = _instructions(result, key); decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key); break; } catch (error48) { if (i + 1 >= length) { throw error48; } } } return DotenvModule.parse(decrypted); } function _warn(message) { console.error(`[dotenv@${version2}][WARN] ${message}`); } function _debug(message) { console.log(`[dotenv@${version2}][DEBUG] ${message}`); } function _log(message) { console.log(`[dotenv@${version2}] ${message}`); } function _dotenvKey(options) { if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) { return options.DOTENV_KEY; } if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) { return process.env.DOTENV_KEY; } return ""; } function _instructions(result, dotenvKey) { let uri; try { uri = new URL(dotenvKey); } catch (error48) { if (error48.code === "ERR_INVALID_URL") { const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development"); err.code = "INVALID_DOTENV_KEY"; throw err; } throw error48; } const key = uri.password; if (!key) { const err = new Error("INVALID_DOTENV_KEY: Missing key part"); err.code = "INVALID_DOTENV_KEY"; throw err; } const environment = uri.searchParams.get("environment"); if (!environment) { const err = new Error("INVALID_DOTENV_KEY: Missing environment part"); err.code = "INVALID_DOTENV_KEY"; throw err; } const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`; const ciphertext = result.parsed[environmentKey]; if (!ciphertext) { const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`); err.code = "NOT_FOUND_DOTENV_ENVIRONMENT"; throw err; } return { ciphertext, key }; } function _vaultPath(options) { let possibleVaultPath = null; if (options && options.path && options.path.length > 0) { if (Array.isArray(options.path)) { for (const filepath of options.path) { if (fs.existsSync(filepath)) { possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`; } } } else { possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`; } } else { possibleVaultPath = path.resolve(process.cwd(), ".env.vault"); } if (fs.existsSync(possibleVaultPath)) { return possibleVaultPath; } return null; } function _resolveHome(envPath) { return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath; } function _configVault(options) { const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug); const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet); if (debug || !quiet) { _log("Loading env from encrypted .env.vault"); } const parsed = DotenvModule._parseVault(options); let processEnv = process.env; if (options && options.processEnv != null) { processEnv = options.processEnv; } DotenvModule.populate(processEnv, parsed, options); return { parsed }; } function configDotenv(options) { const dotenvPath = path.resolve(process.cwd(), ".env"); let encoding = "utf8"; let processEnv = process.env; if (options && options.processEnv != null) { processEnv = options.processEnv; } let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug); let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet); if (options && options.encoding) { encoding = options.encoding; } else { if (debug) { _debug("No encoding is specified. UTF-8 is used by default"); } } let optionPaths = [dotenvPath]; if (options && options.path) { if (!Array.isArray(options.path)) { optionPaths = [_resolveHome(options.path)]; } else { optionPaths = []; for (const filepath of options.path) { optionPaths.push(_resolveHome(filepath)); } } } let lastError; const parsedAll = {}; for (const path2 of optionPaths) { try { const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding })); DotenvModule.populate(parsedAll, parsed, options); } catch (e) { if (debug) { _debug(`Failed to load ${path2} ${e.message}`); } lastError = e; } } const populated = DotenvModule.populate(processEnv, parsedAll, options); debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug); quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet); if (debug || !quiet) { const keysCount = Object.keys(populated).length; const shortPaths = []; for (const filePath of optionPaths) { try { const relative = path.relative(process.cwd(), filePath); shortPaths.push(relative); } catch (e) { if (debug) { _debug(`Failed to load ${filePath} ${e.message}`); } lastError = e; } } _log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`); } if (lastError) { return { parsed: parsedAll, error: lastError }; } else { return { parsed: parsedAll }; } } function config2(options) { if (_dotenvKey(options).length === 0) { return DotenvModule.configDotenv(options); } const vaultPath = _vaultPath(options); if (!vaultPath) { _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`); return DotenvModule.configDotenv(options); } return DotenvModule._configVault(options); } function decrypt(encrypted, keyStr) { const key = Buffer.from(keyStr.slice(-64), "hex"); let ciphertext = Buffer.from(encrypted, "base64"); const nonce = ciphertext.subarray(0, 12); const authTag = ciphertext.subarray(-16); ciphertext = ciphertext.subarray(12, -16); try { const aesgcm = crypto3.createDecipheriv("aes-256-gcm", key, nonce); aesgcm.setAuthTag(authTag); return `${aesgcm.update(ciphertext)}${aesgcm.final()}`; } catch (error48) { const isRange = error48 instanceof RangeError; const invalidKeyLength = error48.message === "Invalid key length"; const decryptionFailed = error48.message === "Unsupported state or unable to authenticate data"; if (isRange || invalidKeyLength) { const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)"); err.code = "INVALID_DOTENV_KEY"; throw err; } else if (decryptionFailed) { const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY"); err.code = "DECRYPTION_FAILED"; throw err; } else { throw error48; } } } function populate(processEnv, parsed, options = {}) { const debug = Boolean(options && options.debug); const override = Boolean(options && options.override); const populated = {}; if (typeof parsed !== "object") { const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate"); err.code = "OBJECT_REQUIRED"; throw err; } for (const key of Object.keys(parsed)) { if (Object.prototype.hasOwnProperty.call(processEnv, key)) { if (override === true) { processEnv[key] = parsed[key]; populated[key] = parsed[key]; } if (debug) { if (override === true) { _debug(`"${key}" is already defined and WAS overwritten`); } else { _debug(`"${key}" is already defined and was NOT overwritten`); } } } else { processEnv[key] = parsed[key]; populated[key] = parsed[key]; } } return populated; } var DotenvModule = { configDotenv, _configVault, _parseVault, config: config2, decrypt, parse: parse5, populate }; exports.configDotenv = DotenvModule.configDotenv; exports._configVault = DotenvModule._configVault; exports._parseVault = DotenvModule._parseVault; exports.config = DotenvModule.config; exports.decrypt = DotenvModule.decrypt; exports.parse = DotenvModule.parse; exports.populate = DotenvModule.populate; module.exports = DotenvModule; }); // node_modules/joi/node_modules/@hapi/hoek/lib/stringify.js var require_stringify = __commonJS((exports, module) => { module.exports = function(...args) { try { return JSON.stringify(...args); } catch (err) { return "[Cannot display object: " + err.message + "]"; } }; }); // node_modules/joi/node_modules/@hapi/hoek/lib/error.js var require_error = __commonJS((exports, module) => { var Stringify = require_stringify(); module.exports = class extends Error { constructor(args) { const msgs = args.filter((arg) => arg !== "").map((arg) => { return typeof arg === "string" ? arg : arg instanceof Error ? arg.message : Stringify(arg); }); super(msgs.join(" ") || "Unknown error"); if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, exports.assert); } } }; }); // node_modules/joi/node_modules/@hapi/hoek/lib/assert.js var require_assert = __commonJS((exports, module) => { var AssertError = require_error(); module.exports = function(condition, ...args) { if (condition) { return; } if (args.length === 1 && args[0] instanceof Error) { throw args[0]; } throw new AssertError(args); }; }); // node_modules/joi/node_modules/@hapi/hoek/lib/reach.js var require_reach = __commonJS((exports, module) => { var Assert = require_assert(); var internals = {}; module.exports = function(obj, chain, options) { if (chain === false || chain === null || chain === undefined) { return obj; } options = options || {}; if (typeof options === "string") { options = { separator: options }; } const isChainArray = Array.isArray(chain); Assert(!isChainArray || !options.separator, "Separator option is not valid for array-based chain"); const path = isChainArray ? chain : chain.split(options.separator || "."); let ref = obj; for (let i = 0;i < path.length; ++i) { let key = path[i]; const type = options.iterables && internals.iterables(ref); if (Array.isArray(ref) || type === "set") { const number4 = Number(key); if (Number.isInteger(number4)) { key = number4 < 0 ? ref.length + number4 : number4; } } if (!ref || typeof ref === "function" && options.functions === false || !type && ref[key] === undefined) { Assert(!options.strict || i + 1 === path.length, "Missing segment", key, "in reach path ", chain); Assert(typeof ref === "object" || options.functions === true || typeof ref !== "function", "Invalid segment", key, "in reach path ", chain); ref = options.default; break; } if (!type) { ref = ref[key]; } else if (type === "set") { ref = [...ref][key]; } else { ref = ref.get(key); } } return ref; }; internals.iterables = function(ref) { if (ref instanceof Set) { return "set"; } if (ref instanceof Map) { return "map"; } }; }); // node_modules/joi/node_modules/@hapi/hoek/lib/types.js var require_types = __commonJS((exports, module) => { var internals = {}; exports = module.exports = { array: Array.prototype, buffer: Buffer && Buffer.prototype, date: Date.prototype, error: Error.prototype, generic: Object.prototype, map: Map.prototype, promise: Promise.prototype, regex: RegExp.prototype, set: Set.prototype, weakMap: WeakMap.prototype, weakSet: WeakSet.prototype }; internals.typeMap = new Map([ ["[object Error]", exports.error], ["[object Map]", exports.map], ["[object Promise]", exports.promise], ["[object Set]", exports.set], ["[object WeakMap]", exports.weakMap], ["[object WeakSet]", exports.weakSet] ]); exports.getInternalProto = function(obj) { if (Array.isArray(obj)) { return exports.array; } if (Buffer && obj instanceof Buffer) { return exports.buffer; } if (obj instanceof Date) { return exports.date; } if (obj instanceof RegExp) { return exports.regex; } if (obj instanceof Error) { return exports.error; } const objName = Object.prototype.toString.call(obj); return internals.typeMap.get(objName) || exports.generic; }; }); // node_modules/joi/node_modules/@hapi/hoek/lib/utils.js var require_utils = __commonJS((exports) => { exports.keys = function(obj, options = {}) { return options.symbols !== false ? Reflect.ownKeys(obj) : Object.getOwnPropertyNames(obj); }; }); // node_modules/joi/node_modules/@hapi/hoek/lib/clone.js var require_clone = __commonJS((exports, module) => { var Reach = require_reach(); var Types = require_types(); var Utils = require_utils(); var internals = { needsProtoHack: new Set([Types.set, Types.map, Types.weakSet, Types.weakMap]) }; module.exports = internals.clone = function(obj, options = {}, _seen = null) { if (typeof obj !== "object" || obj === null) { return obj; } let clone2 = internals.clone; let seen = _seen; if (options.shallow) { if (options.shallow !== true) { return internals.cloneWithShallow(obj, options); } clone2 = (value) => value; } else if (seen) { const lookup = seen.get(obj); if (lookup) { return lookup; } } else { seen = new Map; } const baseProto = Types.getInternalProto(obj); if (baseProto === Types.buffer) { return Buffer && Buffer.from(obj); } if (baseProto === Types.date) { return new Date(obj.getTime()); } if (baseProto === Types.regex) { return new RegExp(obj); } const newObj = internals.base(obj, baseProto, options); if (newObj === obj) { return obj; } if (seen) { seen.set(obj, newObj); } if (baseProto === Types.set) { for (const value of obj) { newObj.add(clone2(value, options, seen)); } } else if (baseProto === Types.map) { for (const [key, value] of obj) { newObj.set(key, clone2(value, options, seen)); } } const keys = Utils.keys(obj, options); for (const key of keys) { if (key === "__proto__") { continue; } if (baseProto === Types.array && key === "length") { newObj.length = obj.length; continue; } const descriptor = Object.getOwnPropertyDescriptor(obj, key); if (descriptor) { if (descriptor.get || descriptor.set) { Object.defineProperty(newObj, key, descriptor); } else if (descriptor.enumerable) { newObj[key] = clone2(obj[key], options, seen); } else { Object.defineProperty(newObj, key, { enumerable: false, writable: true, configurable: true, value: clone2(obj[key], options, seen) }); } } else { Object.defineProperty(newObj, key, { enumerable: true, writable: true, configurable: true, value: clone2(obj[key], options, seen) }); } } return newObj; }; internals.cloneWithShallow = function(source, options) { const keys = options.shallow; options = Object.assign({}, options); options.shallow = false; const seen = new Map; for (const key of keys) { const ref = Reach(source, key); if (typeof ref === "object" || typeof ref === "function") { seen.set(ref, ref); } } return internals.clone(source, options, seen); }; internals.base = function(obj, baseProto, options) { if (options.prototype === false) { if (internals.needsProtoHack.has(baseProto)) { return new baseProto.constructor; } return baseProto === Types.array ? [] : {}; } const proto = Object.getPrototypeOf(obj); if (proto && proto.isImmutable) { return obj; } if (baseProto === Types.array) { const newObj = []; if (proto !== baseProto) { Object.setPrototypeOf(newObj, proto); } return newObj; } if (internals.needsProtoHack.has(baseProto)) { const newObj = new proto.constructor; if (proto !== baseProto) { Object.setPrototypeOf(newObj, proto); } return newObj; } return Object.create(proto); }; }); // node_modules/joi/package.json var require_package2 = __commonJS((exports, module) => { module.exports = { name: "joi", description: "Object schema validation", version: "17.13.3", repository: "git://github.com/hapijs/joi", main: "lib/index.js", types: "lib/index.d.ts", browser: "dist/joi-browser.min.js", files: [ "lib/**/*", "dist/*" ], keywords: [ "schema", "validation" ], dependencies: { "@hapi/hoek": "^9.3.0", "@hapi/topo": "^5.1.0", "@sideway/address": "^4.1.5", "@sideway/formula": "^3.0.1", "@sideway/pinpoint": "^2.0.0" }, devDependencies: { "@hapi/bourne": "2.x.x", "@hapi/code": "8.x.x", "@hapi/joi-legacy-test": "npm:@hapi/joi@15.x.x", "@hapi/lab": "^25.1.3", "@types/node": "^14.18.63", typescript: "4.3.x" }, scripts: { prepublishOnly: "cd browser && npm install && npm run build", test: "lab -t 100 -a @hapi/code -L -Y", "test-cov-html": "lab -r html -o coverage.html -a @hapi/code" }, license: "BSD-3-Clause" }; }); // node_modules/joi/lib/schemas.js var require_schemas = __commonJS((exports) => { var Joi = require_lib4(); var internals = {}; internals.wrap = Joi.string().min(1).max(2).allow(false); exports.preferences = Joi.object({ allowUnknown: Joi.boolean(), abortEarly: Joi.boolean(), artifacts: Joi.boolean(), cache: Joi.boolean(), context: Joi.object(), convert: Joi.boolean(), dateFormat: Joi.valid("date", "iso", "string", "time", "utc"), debug: Joi.boolean(), errors: { escapeHtml: Joi.boolean(), label: Joi.valid("path", "key", false), language: [ Joi.string(), Joi.object().ref() ], render: Joi.boolean(), stack: Joi.boolean(), wrap: { label: internals.wrap, array: internals.wrap, string: internals.wrap } }, externals: Joi.boolean(), messages: Joi.object(), noDefaults: Joi.boolean(), nonEnumerables: Joi.boolean(), presence: Joi.valid("required", "optional", "forbidden"), skipFunctions: Joi.boolean(), stripUnknown: Joi.object({ arrays: Joi.boolean(), objects: Joi.boolean() }).or("arrays", "objects").allow(true, false), warnings: Joi.boolean() }).strict(); internals.nameRx = /^[a-zA-Z0-9]\w*$/; internals.rule = Joi.object({ alias: Joi.array().items(Joi.string().pattern(internals.nameRx)).single(), args: Joi.array().items(Joi.string(), Joi.object({ name: Joi.string().pattern(internals.nameRx).required(), ref: Joi.boolean(), assert: Joi.alternatives([ Joi.function(), Joi.object().schema() ]).conditional("ref", { is: true, then: Joi.required() }), normalize: Joi.function(), message: Joi.string().when("assert", { is: Joi.function(), then: Joi.required() }) })), convert: Joi.boolean(), manifest: Joi.boolean(), method: Joi.function().allow(false), multi: Joi.boolean(), validate: Joi.function() }); exports.extension = Joi.object({ type: Joi.alternatives([ Joi.string(), Joi.object().regex() ]).required(), args: Joi.function(), cast: Joi.object().pattern(internals.nameRx, Joi.object({ from: Joi.function().maxArity(1).required(), to: Joi.function().minArity(1).maxArity(2).required() })), base: Joi.object().schema().when("type", { is: Joi.object().regex(), then: Joi.forbidden() }), coerce: [ Joi.function().maxArity(3), Joi.object({ method: Joi.function().maxArity(3).required(), from: Joi.array().items(Joi.string()).single() }) ], flags: Joi.object().pattern(internals.nameRx, Joi.object({ setter: Joi.string(), default: Joi.any() })), manifest: { build: Joi.function().arity(2) }, messages: [Joi.object(), Joi.string()], modifiers: Joi.object().pattern(internals.nameRx, Joi.function().minArity(1).maxArity(2)), overrides: Joi.object().pattern(internals.nameRx, Joi.function()), prepare: Joi.function().maxArity(3), rebuild: Joi.function().arity(1), rules: Joi.object().pattern(internals.nameRx, internals.rule), terms: Joi.object().pattern(internals.nameRx, Joi.object({ init: Joi.array().allow(null).required(), manifest: Joi.object().pattern(/.+/, [ Joi.valid("schema", "single"), Joi.object({ mapped: Joi.object({ from: Joi.string().required(), to: Joi.string().required() }).required() }) ]) })), validate: Joi.function().maxArity(3) }).strict(); exports.extensions = Joi.array().items(Joi.object(), Joi.function().arity(1)).strict(); internals.desc = { buffer: Joi.object({ buffer: Joi.string() }), func: Joi.object({ function: Joi.function().required(), options: { literal: true } }), override: Joi.object({ override: true }), ref: Joi.object({ ref: Joi.object({ type: Joi.valid("value", "global", "local"), path: Joi.array().required(), separator: Joi.string().length(1).allow(false), ancestor: Joi.number().min(0).integer().allow("root"), map: Joi.array().items(Joi.array().length(2)).min(1), adjust: Joi.function(), iterables: Joi.boolean(), in: Joi.boolean(), render: Joi.boolean() }).required() }), regex: Joi.object({ regex: Joi.string().min(3) }), special: Joi.object({ special: Joi.valid("deep").required() }), template: Joi.object({ template: Joi.string().required(), options: Joi.object() }), value: Joi.object({ value: Joi.alternatives([Joi.object(), Joi.array()]).required() }) }; internals.desc.entity = Joi.alternatives([ Joi.array().items(Joi.link("...")), Joi.boolean(), Joi.function(), Joi.number(), Joi.string(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.special, internals.desc.template, internals.desc.value, Joi.link("/") ]); internals.desc.values = Joi.array().items(null, Joi.boolean(), Joi.function(), Joi.number().allow(Infinity, -Infinity), Joi.string().allow(""), Joi.symbol(), internals.desc.buffer, internals.desc.func, internals.desc.override, internals.desc.ref, internals.desc.regex, internals.desc.template, internals.desc.value); internals.desc.messages = Joi.object().pattern(/.+/, [ Joi.string(), internals.desc.template, Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template]) ]); exports.description = Joi.object({ type: Joi.string().required(), flags: Joi.object({ cast: Joi.string(), default: Joi.any(), description: Joi.string(), empty: Joi.link("/"), failover: internals.desc.entity, id: Joi.string(), label: Joi.string(), only: true, presence: ["optional", "required", "forbidden"], result: ["raw", "strip"], strip: Joi.boolean(), unit: Joi.string() }).unknown(), preferences: { allowUnknown: Joi.boolean(), abortEarly: Joi.boolean(), artifacts: Joi.boolean(), cache: Joi.boolean(), convert: Joi.boolean(), dateFormat: ["date", "iso", "string", "time", "utc"], errors: { escapeHtml: Joi.boolean(), label: ["path", "key"], language: [ Joi.string(), internals.desc.ref ], wrap: { label: internals.wrap, array: internals.wrap } }, externals: Joi.boolean(), messages: internals.desc.messages, noDefaults: Joi.boolean(), nonEnumerables: Joi.boolean(), presence: ["required", "optional", "forbidden"], skipFunctions: Joi.boolean(), stripUnknown: Joi.object({ arrays: Joi.boolean(), objects: Joi.boolean() }).or("arrays", "objects").allow(true, false), warnings: Joi.boolean() }, allow: internals.desc.values, invalid: internals.desc.values, rules: Joi.array().min(1).items({ name: Joi.string().required(), args: Joi.object().min(1), keep: Joi.boolean(), message: [ Joi.string(), internals.desc.messages ], warn: Joi.boolean() }), keys: Joi.object().pattern(/.*/, Joi.link("/")), link: internals.desc.ref }).pattern(/^[a-z]\w*$/, Joi.any()); }); // node_modules/joi/node_modules/@hapi/hoek/lib/escapeHtml.js var require_escapeHtml = __commonJS((exports, module) => { var internals = {}; module.exports = function(input) { if (!input) { return ""; } let escaped = ""; for (let i = 0;i < input.length; ++i) { const charCode = input.charCodeAt(i); if (internals.isSafe(charCode)) { escaped += input[i]; } else { escaped += internals.escapeHtmlChar(charCode); } } return escaped; }; internals.escapeHtmlChar = function(charCode) { const namedEscape = internals.namedHtml.get(charCode); if (namedEscape) { return namedEscape; } if (charCode >= 256) { return "&#" + charCode + ";"; } const hexValue = charCode.toString(16).padStart(2, "0"); return `&#x${hexValue};`; }; internals.isSafe = function(charCode) { return internals.safeCharCodes.has(charCode); }; internals.namedHtml = new Map([ [38, "&amp;"], [60, "&lt;"], [62, "&gt;"], [34, "&quot;"], [160, "&nbsp;"], [162, "&cent;"], [163, "&pound;"], [164, "&curren;"], [169, "&copy;"], [174, "&reg;"] ]); internals.safeCharCodes = function() { const safe = new Set; for (let i = 32;i < 123; ++i) { if (i >= 97 || i >= 65 && i <= 90 || i >= 48 && i <= 57 || i === 32 || i === 46 || i === 44 || i === 45 || i === 58 || i === 95) { safe.add(i); } } return safe; }(); }); // node_modules/@sideway/formula/lib/index.js var require_lib = __commonJS((exports) => { var internals = { operators: ["!", "^", "*", "/", "%", "+", "-", "<", "<=", ">", ">=", "==", "!=", "&&", "||", "??"], operatorCharacters: ["!", "^", "*", "/", "%", "+", "-", "<", "=", ">", "&", "|", "?"], operatorsOrder: [["^"], ["*", "/", "%"], ["+", "-"], ["<", "<=", ">", ">="], ["==", "!="], ["&&"], ["||", "??"]], operatorsPrefix: ["!", "n"], literals: { '"': '"', "`": "`", "'": "'", "[": "]" }, numberRx: /^(?:[0-9]*(\.[0-9]*)?){1}$/, tokenRx: /^[\w\$\#\.\@\:\{\}]+$/, symbol: Symbol("formula"), settings: Symbol("settings") }; exports.Parser = class { constructor(string4, options = {}) { if (!options[internals.settings] && options.constants) { for (const constant in options.constants) { const value = options.constants[constant]; if (value !== null && !["boolean", "number", "string"].includes(typeof value)) { throw new Error(`Formula constant ${constant} contains invalid ${typeof value} value type`); } } } this.settings = options[internals.settings] ? options : Object.assign({ [internals.settings]: true, constants: {}, functions: {} }, options); this.single = null; this._parts = null; this._parse(string4); } _parse(string4) { let parts = []; let current = ""; let parenthesis = 0; let literal2 = false; const flush = (inner) => { if (parenthesis) { throw new Error("Formula missing closing parenthesis"); } const last = parts.length ? parts[parts.length - 1] : null; if (!literal2 && !current && !inner) { return; } if (last && last.type === "reference" && inner === ")") { last.type = "function"; last.value = this._subFormula(current, last.value); current = ""; return; } if (inner === ")") { const sub = new exports.Parser(current, this.settings); parts.push({ type: "segment", value: sub }); } else if (literal2) { if (literal2 === "]") { parts.push({ type: "reference", value: current }); current = ""; return; } parts.push({ type: "literal", value: current }); } else if (internals.operatorCharacters.includes(current)) { if (last && last.type === "operator" && internals.operators.includes(last.value + current)) { last.value += current; } else { parts.push({ type: "operator", value: current }); } } else if (current.match(internals.numberRx)) { parts.push({ type: "constant", value: parseFloat(current) }); } else if (this.settings.constants[current] !== undefined) { parts.push({ type: "constant", value: this.settings.constants[current] }); } else { if (!current.match(internals.tokenRx)) { throw new Error(`Formula contains invalid token: ${current}`); } parts.push({ type: "reference", value: current }); } current = ""; }; for (const c of string4) { if (literal2) { if (c === literal2) { flush(); literal2 = false; } else { current += c; } } else if (parenthesis) { if (c === "(") { current += c; ++parenthesis; } else if (c === ")") { --parenthesis; if (!parenthesis) { flush(c); } else { current += c; } } else { current += c; } } else if (c in internals.literals) { literal2 = internals.literals[c]; } else if (c === "(") { flush(); ++parenthesis; } else if (internals.operatorCharacters.includes(c)) { flush(); current = c; flush(); } else if (c !== " ") { current += c; } else { flush(); } } flush(); parts = parts.map((part, i) => { if (part.type !== "operator" || part.value !== "-" || i && parts[i - 1].type !== "operator") { return part; } return { type: "operator", value: "n" }; }); let operator = false; for (const part of parts) { if (part.type === "operator") { if (internals.operatorsPrefix.includes(part.value)) { continue; } if (!operator) { throw new Error("Formula contains an operator in invalid position"); } if (!internals.operators.includes(part.value)) { throw new Error(`Formula contains an unknown operator ${part.value}`); } } else if (operator) { throw new Error("Formula missing expected operator"); } operator = !operator; } if (!operator) { throw new Error("Formula contains invalid trailing operator"); } if (parts.length === 1 && ["reference", "literal", "constant"].includes(parts[0].type)) { this.single = { type: parts[0].type === "reference" ? "reference" : "value", value: parts[0].value }; } this._parts = parts.map((part) => { if (part.type === "operator") { return internals.operatorsPrefix.includes(part.value) ? part : part.value; } if (part.type !== "reference") { return part.value; } if (this.settings.tokenRx && !this.settings.tokenRx.test(part.value)) { throw new Error(`Formula contains invalid reference ${part.value}`); } if (this.settings.reference) { return this.settings.reference(part.value); } return internals.reference(part.value); }); } _subFormula(string4, name) { const method = this.settings.functions[name]; if (typeof method !== "function") { throw new Error(`Formula contains unknown function ${name}`); } let args = []; if (string4) { let current = ""; let parenthesis = 0; let literal2 = false; const flush = () => { if (!current) { throw new Error(`Formula contains function ${name} with invalid arguments ${string4}`); } args.push(current); current = ""; }; for (let i = 0;i < string4.length; ++i) { const c = string4[i]; if (literal2) { current += c; if (c === literal2) { literal2 = false; } } else if (c in internals.literals && !parenthesis) { current += c; literal2 = internals.literals[c]; } else if (c === "," && !parenthesis) { flush(); } else { current += c; if (c === "(") { ++parenthesis; } else if (c === ")") { --parenthesis; } } } flush(); } args = args.map((arg) => new exports.Parser(arg, this.settings)); return function(context) { const innerValues = []; for (const arg of args) { innerValues.push(arg.evaluate(context)); } return method.call(context, ...innerValues); }; } evaluate(context) { const parts = this._parts.slice(); for (let i = parts.length - 2;i >= 0; --i) { const part = parts[i]; if (part && part.type === "operator") { const current = parts[i + 1]; parts.splice(i + 1, 1); const value = internals.evaluate(current, context); parts[i] = internals.single(part.value, value); } } internals.operatorsOrder.forEach((set2) => { for (let i = 1;i < parts.length - 1; ) { if (set2.includes(parts[i])) { const operator = parts[i]; const left = internals.evaluate(parts[i - 1], context); const right = internals.evaluate(parts[i + 1], context); parts.splice(i, 2); const result = internals.calculate(operator, left, right); parts[i - 1] = result === 0 ? 0 : result; } else { i += 2; } } }); return internals.evaluate(parts[0], context); } }; exports.Parser.prototype[internals.symbol] = true; internals.reference = function(name) { return function(context) { return context && context[name] !== undefined ? context[name] : null; }; }; internals.evaluate = function(part, context) { if (part === null) { return null; } if (typeof part === "function") { return part(context); } if (part[internals.symbol]) { return part.evaluate(context); } return part; }; internals.single = function(operator, value) { if (operator === "!") { return value ? false : true; } const negative = -value; if (negative === 0) { return 0; } return negative; }; internals.calculate = function(operator, left, right) { if (operator === "??") { return internals.exists(left) ? left : right; } if (typeof left === "string" || typeof right === "string") { if (operator === "+") { left = internals.exists(left) ? left : ""; right = internals.exists(right) ? right : ""; return left + right; } } else { switch (operator) { case "^": return Math.pow(left, right); case "*": return left * right; case "/": return left / right; case "%": return left % right; case "+": return left + right; case "-": return left - right; } } switch (operator) { case "<": return left < right; case "<=": return left <= right; case ">": return left > right; case ">=": return left >= right; case "==": return left === right; case "!=": return left !== right; case "&&": return left && right; case "||": return left || right; } return null; }; internals.exists = function(value) { return value !== null && value !== undefined; }; }); // node_modules/joi/lib/annotate.js var require_annotate = __commonJS((exports) => { var Clone = require_clone(); var Common = require_common(); var internals = { annotations: Symbol("annotations") }; exports.error = function(stripColorCodes) { if (!this._original || typeof this._original !== "object") { return this.details[0].message; } const redFgEscape = stripColorCodes ? "" : "\x1B[31m"; const redBgEscape = stripColorCodes ? "" : "\x1B[41m"; const endColor = stripColorCodes ? "" : "\x1B[0m"; const obj = Clone(this._original); for (let i = this.details.length - 1;i >= 0; --i) { const pos = i + 1; const error48 = this.details[i]; const path = error48.path; let node = obj; for (let j = 0;; ++j) { const seg = path[j]; if (Common.isSchema(node)) { node = node.clone(); } if (j + 1 < path.length && typeof node[seg] !== "string") { node = node[seg]; } else { const refAnnotations = node[internals.annotations] || { errors: {}, missing: {} }; node[internals.annotations] = refAnnotations; const cacheKey2 = seg || error48.context.key; if (node[seg] !== undefined) { refAnnotations.errors[cacheKey2] = refAnnotations.errors[cacheKey2] || []; refAnnotations.errors[cacheKey2].push(pos); } else { refAnnotations.missing[cacheKey2] = pos; } break; } } } const replacers = { key: /_\$key\$_([, \d]+)_\$end\$_"/g, missing: /"_\$miss\$_([^|]+)\|(\d+)_\$end\$_": "__missing__"/g, arrayIndex: /\s*"_\$idx\$_([, \d]+)_\$end\$_",?\n(.*)/g, specials: /"\[(NaN|Symbol.*|-?Infinity|function.*|\(.*)]"/g }; let message = internals.safeStringify(obj, 2).replace(replacers.key, ($0, $1) => `" ${redFgEscape}[${$1}]${endColor}`).replace(replacers.missing, ($0, $1, $2) => `${redBgEscape}"${$1}"${endColor}${redFgEscape} [${$2}]: -- missing --${endColor}`).replace(replacers.arrayIndex, ($0, $1, $2) => ` ${$2} ${redFgEscape}[${$1}]${endColor}`).replace(replacers.specials, ($0, $1) => $1); message = `${message} ${redFgEscape}`; for (let i = 0;i < this.details.length; ++i) { const pos = i + 1; message = `${message} [${pos}] ${this.details[i].message}`; } message = message + endColor; return message; }; internals.safeStringify = function(obj, spaces) { return JSON.stringify(obj, internals.serializer(), spaces); }; internals.serializer = function() { const keys = []; const stack = []; const cycleReplacer = (key, value) => { if (stack[0] === value) { return "[Circular ~]"; } return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]"; }; return function(key, value) { if (stack.length > 0) { const thisPos = stack.indexOf(this); if (~thisPos) { stack.length = thisPos + 1; keys.length = thisPos + 1; keys[thisPos] = key; } else { stack.push(this); keys.push(key); } if (~stack.indexOf(value)) { value = cycleReplacer.call(this, key, value); } } else { stack.push(value); } if (value) { const annotations = value[internals.annotations]; if (annotations) { if (Array.isArray(value)) { const annotated = []; for (let i = 0;i < value.length; ++i) { if (annotations.errors[i]) { annotated.push(`_$idx$_${annotations.errors[i].sort().join(", ")}_$end$_`); } annotated.push(value[i]); } value = annotated; } else { for (const errorKey in annotations.errors) { value[`${errorKey}_$key$_${annotations.errors[errorKey].sort().join(", ")}_$end$_`] = value[errorKey]; value[errorKey] = undefined; } for (const missingKey in annotations.missing) { value[`_$miss$_${missingKey}|${annotations.missing[missingKey]}_$end$_`] = "__missing__"; } } return value; } } if (value === Infinity || value === -Infinity || Number.isNaN(value) || typeof value === "function" || typeof value === "symbol") { return "[" + value.toString() + "]"; } return value; }; }; }); // node_modules/joi/lib/errors.js var require_errors = __commonJS((exports) => { var Annotate = require_annotate(); var Common = require_common(); var Template = require_template(); exports.Report = class { constructor(code, value, local, flags, messages, state, prefs) { this.code = code; this.flags = flags; this.messages = messages; this.path = state.path; this.prefs = prefs; this.state = state; this.value = value; this.message = null; this.template = null; this.local = local || {}; this.local.label = exports.label(this.flags, this.state, this.prefs, this.messages); if (this.value !== undefined && !this.local.hasOwnProperty("value")) { this.local.value = this.value; } if (this.path.length) { const key = this.path[this.path.length - 1]; if (typeof key !== "object") {