UNPKG

lakutata

Version:

An IoC-based universal application framework.

1,624 lines (1,514 loc) 372 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const e = require("../../../vendor/Package.5.cjs"); require("../../../vendor/Package.11.cjs"); const t = require("url"); require("../../../vendor/Package.10.cjs"); const r = require("util"); const n = require("../../exceptions/dto/InvalidValueException.cjs"); const s = require("../helpers/As.cjs"); require("../base/abstracts/Exception.cjs"); require("../base/internal/BasicInfo.cjs"); require("../../../vendor/Package.6.cjs"); require("../../../vendor/Package.7.cjs"); require("../base/internal/ThrowWarning.cjs"); require("../helpers/Templating.cjs"); require("../base/internal/CamelCase.cjs"); require("../helpers/NoCase.cjs"); const i = e => e && e.__esModule ? e : { default: e }; const a = i(t); const o = i(r); var l = { exports: {} }; "use strict"; const c = {}; var u = function(...e) { try { return JSON.stringify(...e); } catch (e) { return "[Cannot display object: " + e.message + "]"; } }; const f = e.getDefaultExportFromCjs(u); var d = l.exports; (function(e, t) { "use strict"; const r = u; const n = {}; e.exports = class extends Error { constructor(e) { const n = e.filter((e => e !== "")).map((e => typeof e === "string" ? e : e instanceof Error ? e.message : r(e))); super(n.join(" ") || "Unknown error"); if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, t.assert); } } }; })(l, l.exports); var m = l.exports; const h = e.getDefaultExportFromCjs(m); "use strict"; const p = m; const g = {}; var y = function(e, ...t) { if (e) { return; } if (t.length === 1 && t[0] instanceof Error) { throw t[0]; } throw new p(t); }; const b = e.getDefaultExportFromCjs(y); "use strict"; const _ = y; const v = {}; var A = function(e, t, r) { if (t === false || t === null || t === undefined) { return e; } r = r || {}; if (typeof r === "string") { r = { separator: r }; } const n = Array.isArray(t); _(!n || !r.separator, "Separator option is not valid for array-based chain"); const s = n ? t : t.split(r.separator || "."); let i = e; for (let e = 0; e < s.length; ++e) { let n = s[e]; const a = r.iterables && v.iterables(i); if (Array.isArray(i) || a === "set") { const e = Number(n); if (Number.isInteger(e)) { n = e < 0 ? i.length + e : e; } } if (!i || typeof i === "function" && r.functions === false || !a && i[n] === undefined) { _(!r.strict || e + 1 === s.length, "Missing segment", n, "in reach path ", t); _(typeof i === "object" || r.functions === true || typeof i !== "function", "Invalid segment", n, "in reach path ", t); i = r.default; break; } if (!a) { i = i[n]; } else if (a === "set") { i = [ ...i ][n]; } else { i = i.get(n); } } return i; }; v.iterables = function(e) { if (e instanceof Set) { return "set"; } if (e instanceof Map) { return "map"; } }; const E = e.getDefaultExportFromCjs(A); var R = { exports: {} }; var S = R.exports; (function(e, t) { "use strict"; const r = {}; t = e.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 }; r.typeMap = new Map([ [ "[object Error]", t.error ], [ "[object Map]", t.map ], [ "[object Promise]", t.promise ], [ "[object Set]", t.set ], [ "[object WeakMap]", t.weakMap ], [ "[object WeakSet]", t.weakSet ] ]); t.getInternalProto = function(e) { if (Array.isArray(e)) { return t.array; } if (Buffer && e instanceof Buffer) { return t.buffer; } if (e instanceof Date) { return t.date; } if (e instanceof RegExp) { return t.regex; } if (e instanceof Error) { return t.error; } const n = Object.prototype.toString.call(e); return r.typeMap.get(n) || t.generic; }; })(R, R.exports); var O = R.exports; const N = e.getDefaultExportFromCjs(O); var I = {}; "use strict"; const w = {}; var $ = I.keys = function(e, t = {}) { return t.symbols !== false ? Reflect.ownKeys(e) : Object.getOwnPropertyNames(e); }; "use strict"; const C = A; const T = O; const x = I; const L = { needsProtoHack: new Set([ T.set, T.map, T.weakSet, T.weakMap ]) }; var D = L.clone = function(e, t = {}, r = null) { if (typeof e !== "object" || e === null) { return e; } let n = L.clone; let s = r; if (t.shallow) { if (t.shallow !== true) { return L.cloneWithShallow(e, t); } n = e => e; } else if (s) { const t = s.get(e); if (t) { return t; } } else { s = new Map; } const i = T.getInternalProto(e); if (i === T.buffer) { return Buffer && Buffer.from(e); } if (i === T.date) { return new Date(e.getTime()); } if (i === T.regex) { return new RegExp(e); } const a = L.base(e, i, t); if (a === e) { return e; } if (s) { s.set(e, a); } if (i === T.set) { for (const r of e) { a.add(n(r, t, s)); } } else if (i === T.map) { for (const [r, i] of e) { a.set(r, n(i, t, s)); } } const o = x.keys(e, t); for (const r of o) { if (r === "__proto__") { continue; } if (i === T.array && r === "length") { a.length = e.length; continue; } const o = Object.getOwnPropertyDescriptor(e, r); if (o) { if (o.get || o.set) { Object.defineProperty(a, r, o); } else if (o.enumerable) { a[r] = n(e[r], t, s); } else { Object.defineProperty(a, r, { enumerable: false, writable: true, configurable: true, value: n(e[r], t, s) }); } } else { Object.defineProperty(a, r, { enumerable: true, writable: true, configurable: true, value: n(e[r], t, s) }); } } return a; }; L.cloneWithShallow = function(e, t) { const r = t.shallow; t = Object.assign({}, t); t.shallow = false; const n = new Map; for (const t of r) { const r = C(e, t); if (typeof r === "object" || typeof r === "function") { n.set(r, r); } } return L.clone(e, t, n); }; L.base = function(e, t, r) { if (r.prototype === false) { if (L.needsProtoHack.has(t)) { return new t.constructor; } return t === T.array ? [] : {}; } const n = Object.getPrototypeOf(e); if (n && n.isImmutable) { return e; } if (t === T.array) { const e = []; if (n !== t) { Object.setPrototypeOf(e, n); } return e; } if (L.needsProtoHack.has(t)) { const e = new n.constructor; if (n !== t) { Object.setPrototypeOf(e, n); } return e; } return Object.create(n); }; const M = e.getDefaultExportFromCjs(D); var j = {}; var k = {}; var B = "joi"; var P = "Object schema validation"; var U = "17.13.3"; var G = "git://github.com/hapijs/joi"; var F = "lib/index.js"; var X = "lib/index.d.ts"; var H = "dist/joi-browser.min.js"; var K = [ "lib/**/*", "dist/*" ]; var V = [ "schema", "validation" ]; var Y = { "@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" }; var W = { "@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" }; var q = { 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" }; var z = "BSD-3-Clause"; const Z = { name: B, description: P, version: U, repository: G, main: F, types: X, browser: H, files: K, keywords: V, dependencies: Y, devDependencies: W, scripts: q, license: z }; var J = {}; var Q; function ee() { if (Q) return J; Q = 1; "use strict"; const e = Gr(); const t = {}; t.wrap = e.string().min(1).max(2).allow(false); J.preferences = e.object({ allowUnknown: e.boolean(), abortEarly: e.boolean(), artifacts: e.boolean(), cache: e.boolean(), context: e.object(), convert: e.boolean(), dateFormat: e.valid("date", "iso", "string", "time", "utc"), debug: e.boolean(), errors: { escapeHtml: e.boolean(), label: e.valid("path", "key", false), language: [ e.string(), e.object().ref() ], render: e.boolean(), stack: e.boolean(), wrap: { label: t.wrap, array: t.wrap, string: t.wrap } }, externals: e.boolean(), messages: e.object(), noDefaults: e.boolean(), nonEnumerables: e.boolean(), presence: e.valid("required", "optional", "forbidden"), skipFunctions: e.boolean(), stripUnknown: e.object({ arrays: e.boolean(), objects: e.boolean() }).or("arrays", "objects").allow(true, false), warnings: e.boolean() }).strict(); t.nameRx = /^[a-zA-Z0-9]\w*$/; t.rule = e.object({ alias: e.array().items(e.string().pattern(t.nameRx)).single(), args: e.array().items(e.string(), e.object({ name: e.string().pattern(t.nameRx).required(), ref: e.boolean(), assert: e.alternatives([ e.function(), e.object().schema() ]).conditional("ref", { is: true, then: e.required() }), normalize: e.function(), message: e.string().when("assert", { is: e.function(), then: e.required() }) })), convert: e.boolean(), manifest: e.boolean(), method: e.function().allow(false), multi: e.boolean(), validate: e.function() }); J.extension = e.object({ type: e.alternatives([ e.string(), e.object().regex() ]).required(), args: e.function(), cast: e.object().pattern(t.nameRx, e.object({ from: e.function().maxArity(1).required(), to: e.function().minArity(1).maxArity(2).required() })), base: e.object().schema().when("type", { is: e.object().regex(), then: e.forbidden() }), coerce: [ e.function().maxArity(3), e.object({ method: e.function().maxArity(3).required(), from: e.array().items(e.string()).single() }) ], flags: e.object().pattern(t.nameRx, e.object({ setter: e.string(), default: e.any() })), manifest: { build: e.function().arity(2) }, messages: [ e.object(), e.string() ], modifiers: e.object().pattern(t.nameRx, e.function().minArity(1).maxArity(2)), overrides: e.object().pattern(t.nameRx, e.function()), prepare: e.function().maxArity(3), rebuild: e.function().arity(1), rules: e.object().pattern(t.nameRx, t.rule), terms: e.object().pattern(t.nameRx, e.object({ init: e.array().allow(null).required(), manifest: e.object().pattern(/.+/, [ e.valid("schema", "single"), e.object({ mapped: e.object({ from: e.string().required(), to: e.string().required() }).required() }) ]) })), validate: e.function().maxArity(3) }).strict(); J.extensions = e.array().items(e.object(), e.function().arity(1)).strict(); t.desc = { buffer: e.object({ buffer: e.string() }), func: e.object({ function: e.function().required(), options: { literal: true } }), override: e.object({ override: true }), ref: e.object({ ref: e.object({ type: e.valid("value", "global", "local"), path: e.array().required(), separator: e.string().length(1).allow(false), ancestor: e.number().min(0).integer().allow("root"), map: e.array().items(e.array().length(2)).min(1), adjust: e.function(), iterables: e.boolean(), in: e.boolean(), render: e.boolean() }).required() }), regex: e.object({ regex: e.string().min(3) }), special: e.object({ special: e.valid("deep").required() }), template: e.object({ template: e.string().required(), options: e.object() }), value: e.object({ value: e.alternatives([ e.object(), e.array() ]).required() }) }; t.desc.entity = e.alternatives([ e.array().items(e.link("...")), e.boolean(), e.function(), e.number(), e.string(), t.desc.buffer, t.desc.func, t.desc.ref, t.desc.regex, t.desc.special, t.desc.template, t.desc.value, e.link("/") ]); t.desc.values = e.array().items(null, e.boolean(), e.function(), e.number().allow(Infinity, -Infinity), e.string().allow(""), e.symbol(), t.desc.buffer, t.desc.func, t.desc.override, t.desc.ref, t.desc.regex, t.desc.template, t.desc.value); t.desc.messages = e.object().pattern(/.+/, [ e.string(), t.desc.template, e.object().pattern(/.+/, [ e.string(), t.desc.template ]) ]); J.description = e.object({ type: e.string().required(), flags: e.object({ cast: e.string(), default: e.any(), description: e.string(), empty: e.link("/"), failover: t.desc.entity, id: e.string(), label: e.string(), only: true, presence: [ "optional", "required", "forbidden" ], result: [ "raw", "strip" ], strip: e.boolean(), unit: e.string() }).unknown(), preferences: { allowUnknown: e.boolean(), abortEarly: e.boolean(), artifacts: e.boolean(), cache: e.boolean(), convert: e.boolean(), dateFormat: [ "date", "iso", "string", "time", "utc" ], errors: { escapeHtml: e.boolean(), label: [ "path", "key" ], language: [ e.string(), t.desc.ref ], wrap: { label: t.wrap, array: t.wrap } }, externals: e.boolean(), messages: t.desc.messages, noDefaults: e.boolean(), nonEnumerables: e.boolean(), presence: [ "required", "optional", "forbidden" ], skipFunctions: e.boolean(), stripUnknown: e.object({ arrays: e.boolean(), objects: e.boolean() }).or("arrays", "objects").allow(true, false), warnings: e.boolean() }, allow: t.desc.values, invalid: t.desc.values, rules: e.array().min(1).items({ name: e.string().required(), args: e.object().min(1), keep: e.boolean(), message: [ e.string(), t.desc.messages ], warn: e.boolean() }), keys: e.object().pattern(/.*/, e.link("/")), link: t.desc.ref }).pattern(/^[a-z]\w*$/, e.any()); return J; } var te = {}; var re = { exports: {} }; "use strict"; const ne = {}; var se = function(e) { if (!e) { return ""; } let t = ""; for (let r = 0; r < e.length; ++r) { const n = e.charCodeAt(r); if (ne.isSafe(n)) { t += e[r]; } else { t += ne.escapeHtmlChar(n); } } return t; }; ne.escapeHtmlChar = function(e) { const t = ne.namedHtml.get(e); if (t) { return t; } if (e >= 256) { return "&#" + e + ";"; } const r = e.toString(16).padStart(2, "0"); return `&#x${r};`; }; ne.isSafe = function(e) { return ne.safeCharCodes.has(e); }; ne.namedHtml = new Map([ [ 38, "&amp;" ], [ 60, "&lt;" ], [ 62, "&gt;" ], [ 34, "&quot;" ], [ 160, "&nbsp;" ], [ 162, "&cent;" ], [ 163, "&pound;" ], [ 164, "&curren;" ], [ 169, "&copy;" ], [ 174, "&reg;" ] ]); ne.safeCharCodes = function() { const e = new Set; for (let t = 32; t < 123; ++t) { if (t >= 97 || t >= 65 && t <= 90 || t >= 48 && t <= 57 || t === 32 || t === 46 || t === 44 || t === 45 || t === 58 || t === 95) { e.add(t); } } return e; }(); const ie = e.getDefaultExportFromCjs(se); var ae = {}; (function(e) { "use strict"; const t = { operators: [ "!", "^", "*", "/", "%", "+", "-", "<", "<=", ">", ">=", "==", "!=", "&&", "||", "??" ], operatorCharacters: [ "!", "^", "*", "/", "%", "+", "-", "<", "=", ">", "&", "|", "?" ], operatorsOrder: [ [ "^" ], [ "*", "/", "%" ], [ "+", "-" ], [ "<", "<=", ">", ">=" ], [ "==", "!=" ], [ "&&" ], [ "||", "??" ] ], operatorsPrefix: [ "!", "n" ], literals: { '"': '"', "`": "`", "'": "'", "[": "]" }, numberRx: /^(?:[0-9]*(\.[0-9]*)?){1}$/, tokenRx: /^[\w\$\#\.\@\:\{\}]+$/, symbol: Symbol("formula"), settings: Symbol("settings") }; e.Parser = class { constructor(e, r = {}) { if (!r[t.settings] && r.constants) { for (const e in r.constants) { const t = r.constants[e]; if (t !== null && ![ "boolean", "number", "string" ].includes(typeof t)) { throw new Error(`Formula constant ${e} contains invalid ${typeof t} value type`); } } } this.settings = r[t.settings] ? r : Object.assign({ [t.settings]: true, constants: {}, functions: {} }, r); this.single = null; this._parts = null; this._parse(e); } _parse(r) { let n = []; let s = ""; let i = 0; let a = false; const o = r => { if (i) { throw new Error("Formula missing closing parenthesis"); } const o = n.length ? n[n.length - 1] : null; if (!a && !s && !r) { return; } if (o && o.type === "reference" && r === ")") { o.type = "function"; o.value = this._subFormula(s, o.value); s = ""; return; } if (r === ")") { const t = new e.Parser(s, this.settings); n.push({ type: "segment", value: t }); } else if (a) { if (a === "]") { n.push({ type: "reference", value: s }); s = ""; return; } n.push({ type: "literal", value: s }); } else if (t.operatorCharacters.includes(s)) { if (o && o.type === "operator" && t.operators.includes(o.value + s)) { o.value += s; } else { n.push({ type: "operator", value: s }); } } else if (s.match(t.numberRx)) { n.push({ type: "constant", value: parseFloat(s) }); } else if (this.settings.constants[s] !== undefined) { n.push({ type: "constant", value: this.settings.constants[s] }); } else { if (!s.match(t.tokenRx)) { throw new Error(`Formula contains invalid token: ${s}`); } n.push({ type: "reference", value: s }); } s = ""; }; for (const e of r) { if (a) { if (e === a) { o(); a = false; } else { s += e; } } else if (i) { if (e === "(") { s += e; ++i; } else if (e === ")") { --i; if (!i) { o(e); } else { s += e; } } else { s += e; } } else if (e in t.literals) { a = t.literals[e]; } else if (e === "(") { o(); ++i; } else if (t.operatorCharacters.includes(e)) { o(); s = e; o(); } else if (e !== " ") { s += e; } else { o(); } } o(); n = n.map(((e, t) => { if (e.type !== "operator" || e.value !== "-" || t && n[t - 1].type !== "operator") { return e; } return { type: "operator", value: "n" }; })); let l = false; for (const e of n) { if (e.type === "operator") { if (t.operatorsPrefix.includes(e.value)) { continue; } if (!l) { throw new Error("Formula contains an operator in invalid position"); } if (!t.operators.includes(e.value)) { throw new Error(`Formula contains an unknown operator ${e.value}`); } } else if (l) { throw new Error("Formula missing expected operator"); } l = !l; } if (!l) { throw new Error("Formula contains invalid trailing operator"); } if (n.length === 1 && [ "reference", "literal", "constant" ].includes(n[0].type)) { this.single = { type: n[0].type === "reference" ? "reference" : "value", value: n[0].value }; } this._parts = n.map((e => { if (e.type === "operator") { return t.operatorsPrefix.includes(e.value) ? e : e.value; } if (e.type !== "reference") { return e.value; } if (this.settings.tokenRx && !this.settings.tokenRx.test(e.value)) { throw new Error(`Formula contains invalid reference ${e.value}`); } if (this.settings.reference) { return this.settings.reference(e.value); } return t.reference(e.value); })); } _subFormula(r, n) { const s = this.settings.functions[n]; if (typeof s !== "function") { throw new Error(`Formula contains unknown function ${n}`); } let i = []; if (r) { let e = ""; let s = 0; let a = false; const o = () => { if (!e) { throw new Error(`Formula contains function ${n} with invalid arguments ${r}`); } i.push(e); e = ""; }; for (let n = 0; n < r.length; ++n) { const i = r[n]; if (a) { e += i; if (i === a) { a = false; } } else if (i in t.literals && !s) { e += i; a = t.literals[i]; } else if (i === "," && !s) { o(); } else { e += i; if (i === "(") { ++s; } else if (i === ")") { --s; } } } o(); } i = i.map((t => new e.Parser(t, this.settings))); return function(e) { const t = []; for (const r of i) { t.push(r.evaluate(e)); } return s.call(e, ...t); }; } evaluate(e) { const r = this._parts.slice(); for (let n = r.length - 2; n >= 0; --n) { const s = r[n]; if (s && s.type === "operator") { const i = r[n + 1]; r.splice(n + 1, 1); const a = t.evaluate(i, e); r[n] = t.single(s.value, a); } } t.operatorsOrder.forEach((n => { for (let s = 1; s < r.length - 1; ) { if (n.includes(r[s])) { const n = r[s]; const i = t.evaluate(r[s - 1], e); const a = t.evaluate(r[s + 1], e); r.splice(s, 2); const o = t.calculate(n, i, a); r[s - 1] = o === 0 ? 0 : o; } else { s += 2; } } })); return t.evaluate(r[0], e); } }; e.Parser.prototype[t.symbol] = true; t.reference = function(e) { return function(t) { return t && t[e] !== undefined ? t[e] : null; }; }; t.evaluate = function(e, r) { if (e === null) { return null; } if (typeof e === "function") { return e(r); } if (e[t.symbol]) { return e.evaluate(r); } return e; }; t.single = function(e, t) { if (e === "!") { return t ? false : true; } const r = -t; if (r === 0) { return 0; } return r; }; t.calculate = function(e, r, n) { if (e === "??") { return t.exists(r) ? r : n; } if (typeof r === "string" || typeof n === "string") { if (e === "+") { r = t.exists(r) ? r : ""; n = t.exists(n) ? n : ""; return r + n; } } else { switch (e) { case "^": return Math.pow(r, n); case "*": return r * n; case "/": return r / n; case "%": return r % n; case "+": return r + n; case "-": return r - n; } } switch (e) { case "<": return r < n; case "<=": return r <= n; case ">": return r > n; case ">=": return r >= n; case "==": return r === n; case "!=": return r !== n; case "&&": return r && n; case "||": return r || n; } return null; }; t.exists = function(e) { return e !== null && e !== undefined; }; })(ae); const oe = e.getDefaultExportFromCjs(ae); var le = {}; var ce = {}; var ue; function fe() { if (ue) return ce; ue = 1; "use strict"; const e = D; const t = Re(); const r = { annotations: Symbol("annotations") }; ce.error = function(n) { if (!this._original || typeof this._original !== "object") { return this.details[0].message; } const s = n ? "" : ""; const i = n ? "" : ""; const a = n ? "" : ""; const o = e(this._original); for (let e = this.details.length - 1; e >= 0; --e) { const n = e + 1; const s = this.details[e]; const i = s.path; let a = o; for (let e = 0; ;++e) { const o = i[e]; if (t.isSchema(a)) { a = a.clone(); } if (e + 1 < i.length && typeof a[o] !== "string") { a = a[o]; } else { const e = a[r.annotations] || { errors: {}, missing: {} }; a[r.annotations] = e; const t = o || s.context.key; if (a[o] !== undefined) { e.errors[t] = e.errors[t] || []; e.errors[t].push(n); } else { e.missing[t] = n; } break; } } } const l = { 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 c = r.safeStringify(o, 2).replace(l.key, ((e, t) => `" ${s}[${t}]${a}`)).replace(l.missing, ((e, t, r) => `${i}"${t}"${a}${s} [${r}]: -- missing --${a}`)).replace(l.arrayIndex, ((e, t, r) => `\n${r} ${s}[${t}]${a}`)).replace(l.specials, ((e, t) => t)); c = `${c}\n${s}`; for (let e = 0; e < this.details.length; ++e) { const t = e + 1; c = `${c}\n[${t}] ${this.details[e].message}`; } c = c + a; return c; }; r.safeStringify = function(e, t) { return JSON.stringify(e, r.serializer(), t); }; r.serializer = function() { const e = []; const t = []; const n = (r, n) => { if (t[0] === n) { return "[Circular ~]"; } return "[Circular ~." + e.slice(0, t.indexOf(n)).join(".") + "]"; }; return function(s, i) { if (t.length > 0) { const r = t.indexOf(this); if (~r) { t.length = r + 1; e.length = r + 1; e[r] = s; } else { t.push(this); e.push(s); } if (~t.indexOf(i)) { i = n.call(this, s, i); } } else { t.push(i); } if (i) { const e = i[r.annotations]; if (e) { if (Array.isArray(i)) { const t = []; for (let r = 0; r < i.length; ++r) { if (e.errors[r]) { t.push(`_$idx$_${e.errors[r].sort().join(", ")}_$end$_`); } t.push(i[r]); } i = t; } else { for (const t in e.errors) { i[`${t}_$key$_${e.errors[t].sort().join(", ")}_$end$_`] = i[t]; i[t] = undefined; } for (const t in e.missing) { i[`_$miss$_${t}|${e.missing[t]}_$end$_`] = "__missing__"; } } return i; } } if (i === Infinity || i === -Infinity || Number.isNaN(i) || typeof i === "function" || typeof i === "symbol") { return "[" + i.toString() + "]"; } return i; }; }; return ce; } var de; function me() { if (de) return le; de = 1; (function(e) { "use strict"; const t = fe(); const r = Re(); const n = _e(); const s = {}; e.Report = class { constructor(t, r, n, s, i, a, o) { this.code = t; this.flags = s; this.messages = i; this.path = a.path; this.prefs = o; this.state = a; this.value = r; this.message = null; this.template = null; this.local = n || {}; this.local.label = e.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 e = this.path[this.path.length - 1]; if (typeof e !== "object") { this.local.key = e; } } } _setTemplate(e) { this.template = e; if (!this.flags.label && this.path.length === 0) { const e = this._template(this.template, "root"); if (e) { this.local.label = e; } } } toString() { if (this.message) { return this.message; } const e = this.code; if (!this.prefs.errors.render) { return this.code; } const t = this._template(this.template) || this._template(this.prefs.messages) || this._template(this.messages); if (t === undefined) { return `Error code "${e}" is not defined, your custom type is missing the correct messages definition`; } this.message = t.render(this.value, this.state, this.prefs, this.local, { errors: this.prefs.errors, messages: [ this.prefs.messages, this.messages ] }); if (!this.prefs.errors.label) { this.message = this.message.replace(/^"" /, "").trim(); } return this.message; } _template(t, r) { return e.template(this.value, t, r || this.code, this.state, this.prefs); } }; e.path = function(e) { let t = ""; for (const r of e) { if (typeof r === "object") { continue; } if (typeof r === "string") { if (t) { t += "."; } t += r; } else { t += `[${r}]`; } } return t; }; e.template = function(e, t, s, i, a) { if (!t) { return; } if (n.isTemplate(t)) { return s !== "root" ? t : null; } let o = a.errors.language; if (r.isResolvable(o)) { o = o.resolve(e, i, a); } if (o && t[o]) { if (t[o][s] !== undefined) { return t[o][s]; } if (t[o]["*"] !== undefined) { return t[o]["*"]; } } if (!t[s]) { return t["*"]; } return t[s]; }; e.label = function(t, r, n, s) { if (!n.errors.label) { return ""; } if (t.label) { return t.label; } let i = r.path; if (n.errors.label === "key" && r.path.length > 1) { i = r.path.slice(-1); } const a = e.path(i); if (a) { return a; } return e.template(null, n.messages, "root", r, n) || s && e.template(null, s, "root", r, n) || "value"; }; e.process = function(t, r, n) { if (!t) { return null; } const {override: s, message: i, details: a} = e.details(t); if (s) { return s; } if (n.errors.stack) { return new e.ValidationError(i, a, r); } const o = Error.stackTraceLimit; Error.stackTraceLimit = 0; const l = new e.ValidationError(i, a, r); Error.stackTraceLimit = o; return l; }; e.details = function(e, t = {}) { let r = []; const n = []; for (const s of e) { if (s instanceof Error) { if (t.override !== false) { return { override: s }; } const e = s.toString(); r.push(e); n.push({ message: e, type: "override", context: { error: s } }); continue; } const e = s.toString(); r.push(e); n.push({ message: e, path: s.path.filter((e => typeof e !== "object")), type: s.code, context: s.local }); } if (r.length > 1) { r = [ ...new Set(r) ]; } return { message: r.join(". "), details: n }; }; e.ValidationError = class extends Error { constructor(e, t, r) { super(e); this._original = r; this.details = t; } static isError(t) { return t instanceof e.ValidationError; } }; e.ValidationError.prototype.isJoi = true; e.ValidationError.prototype.name = "ValidationError"; e.ValidationError.prototype.annotate = t.error; })(le); return le; } var he = {}; var pe; function ge() { if (pe) return he; pe = 1; (function(e) { "use strict"; const t = y; const r = D; const n = A; const s = Re(); let i; const a = { symbol: Symbol("ref"), defaults: { adjust: null, in: false, iterables: null, map: null, separator: ".", type: "value" } }; e.create = function(e, r = {}) { t(typeof e === "string", "Invalid reference key:", e); s.assertOptions(r, [ "adjust", "ancestor", "in", "iterables", "map", "prefix", "render", "separator" ]); t(!r.prefix || typeof r.prefix === "object", "options.prefix must be of type object"); const n = Object.assign({}, a.defaults, r); delete n.prefix; const i = n.separator; const o = a.context(e, i, r.prefix); n.type = o.type; e = o.key; if (n.type === "value") { if (o.root) { t(!i || e[0] !== i, "Cannot specify relative path with root prefix"); n.ancestor = "root"; if (!e) { e = null; } } if (i && i === e) { e = null; n.ancestor = 0; } else { if (n.ancestor !== undefined) { t(!i || !e || e[0] !== i, "Cannot combine prefix with ancestor option"); } else { const [t, r] = a.ancestor(e, i); if (r) { e = e.slice(r); if (e === "") { e = null; } } n.ancestor = t; } } } n.path = i ? e === null ? [] : e.split(i) : [ e ]; return new a.Ref(n); }; e.in = function(t, r = {}) { return e.create(t, { ...r, in: true }); }; e.isRef = function(e) { return e ? !!e[s.symbols.ref] : false; }; a.Ref = class { constructor(e) { t(typeof e === "object", "Invalid reference construction"); s.assertOptions(e, [ "adjust", "ancestor", "in", "iterables", "map", "path", "render", "separator", "type", "depth", "key", "root", "display" ]); t([ false, undefined ].includes(e.separator) || typeof e.separator === "string" && e.separator.length === 1, "Invalid separator"); t(!e.adjust || typeof e.adjust === "function", "options.adjust must be a function"); t(!e.map || Array.isArray(e.map), "options.map must be an array"); t(!e.map || !e.adjust, "Cannot set both map and adjust options"); Object.assign(this, a.defaults, e); t(this.type === "value" || this.ancestor === undefined, "Non-value references cannot reference ancestors"); if (Array.isArray(this.map)) { this.map = new Map(this.map); } this.depth = this.path.length; this.key = this.path.length ? this.path.join(this.separator) : null; this.root = this.path[0]; this.updateDisplay(); } resolve(e, r, n, s, i = {}) { t(!this.in || i.in, "Invalid in() reference usage"); if (this.type === "global") { return this._resolve(n.context, r, i); } if (this.type === "local") { return this._resolve(s, r, i); } if (!this.ancestor) { return this._resolve(e, r, i); } if (this.ancestor === "root") { return this._resolve(r.ancestors[r.ancestors.length - 1], r, i); } t(this.ancestor <= r.ancestors.length, "Invalid reference exceeds the schema root:", this.display); return this._resolve(r.ancestors[this.ancestor - 1], r, i); } _resolve(e, t, r) { let s; if (this.type === "value" && t.mainstay.shadow && r.shadow !== false) { s = t.mainstay.shadow.get(this.absolute(t)); } if (s === undefined) { s = n(e, this.path, { iterables: this.iterables, functions: true }); } if (this.adjust) { s = this.adjust(s); } if (this.map) { const e = this.map.get(s); if (e !== undefined) { s = e; } } if (t.mainstay) { t.mainstay.tracer.resolve(t, this, s); } return s; } toString() { return this.display; } absolute(e) { return [ ...e.path.slice(0, -this.ancestor), ...this.path ]; } clone() { return new a.Ref(this); } describe() { const e = { path: this.path }; if (this.type !== "value") { e.type = this.type; } if (this.separator !== ".") { e.separator = this.separator; } if (this.type === "value" && this.ancestor !== 1) { e.ancestor = this.ancestor; } if (this.map) { e.map = [ ...this.map ]; } for (const t of [ "adjust", "iterables", "render" ]) { if (this[t] !== null && this[t] !== undefined) { e[t] = this[t]; } } if (this.in !== false) { e.in = true; } return { ref: e }; } updateDisplay() { const e = this.key !== null ? this.key : ""; if (this.type !== "value") { this.display = `ref:${this.type}:${e}`; return; } if (!this.separator) { this.display = `ref:${e}`; return; } if (!this.ancestor) { this.display = `ref:${this.separator}${e}`; return; } if (this.ancestor === "root") { this.display = `ref:root:${e}`; return; } if (this.ancestor === 1) { this.display = `ref:${e || ".."}`; return; } const t = new Array(this.ancestor + 1).fill(this.separator).join(""); this.display = `ref:${t}${e || ""}`; } }; a.Ref.prototype[s.symbols.ref] = true; e.build = function(e) { e = Object.assign({}, a.defaults, e); if (e.type === "value" && e.ancestor === undefined) { e.ancestor = 1; } return new a.Ref(e); }; a.context = function(e, t, r = {}) { e = e.trim(); if (r) { const n = r.global === undefined ? "$" : r.global; if (n !== t && e.startsWith(n)) { return { key: e.slice(n.length), type: "global" }; } const s = r.local === undefined ? "#" : r.local; if (s !== t && e.startsWith(s)) { return { key: e.slice(s.length), type: "local" }; } const i = r.root === undefined ? "/" : r.root; if (i !== t && e.startsWith(i)) { return { key: e.slice(i.length), type: "value", root: true }; } } return { key: e, type: "value" }; }; a.ancestor = function(e, t) { if (!t) { return [ 1, 0 ]; } if (e[0] !== t) { return [ 1, 0 ]; } if (e[1] !== t) { return [ 0, 1 ]; } let r = 2; while (e[r] === t) { ++r; } return [ r - 1, r ]; }; e.toSibling = 0;