| 1 |
var __create = Object.create; |
| 2 |
var __defProp = Object.defineProperty; |
| 3 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 4 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 5 |
var __getProtoOf = Object.getPrototypeOf; |
| 6 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 7 |
var __commonJS = (cb, mod) => function __require() { |
| 8 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; |
| 9 |
}; |
| 10 |
var __export = (target, all) => { |
| 11 |
for (var name in all) |
| 12 |
__defProp(target, name, { get: all[name], enumerable: true }); |
| 13 |
}; |
| 14 |
var __copyProps = (to, from, except, desc) => { |
| 15 |
if (from && typeof from === "object" || typeof from === "function") { |
| 16 |
for (let key of __getOwnPropNames(from)) |
| 17 |
if (!__hasOwnProp.call(to, key) && key !== except) |
| 18 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
| 19 |
} |
| 20 |
return to; |
| 21 |
}; |
| 22 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
| 23 |
// If the importer is in node compatibility mode or this is not an ESM |
| 24 |
// file that has been converted to a CommonJS file using a Babel- |
| 25 |
// compatible transform (i.e. "__esModule" has not been set), then set |
| 26 |
// "default" to the CommonJS "module.exports" for node compatibility. |
| 27 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
| 28 |
mod |
| 29 |
)); |
| 30 |
|
| 31 |
// package-external:@wordpress/data |
| 32 |
var require_data = __commonJS({ |
| 33 |
"package-external:@wordpress/data"(exports, module) { |
| 34 |
module.exports = window.wp.data; |
| 35 |
} |
| 36 |
}); |
| 37 |
|
| 38 |
// package-external:@wordpress/i18n |
| 39 |
var require_i18n = __commonJS({ |
| 40 |
"package-external:@wordpress/i18n"(exports, module) { |
| 41 |
module.exports = window.wp.i18n; |
| 42 |
} |
| 43 |
}); |
| 44 |
|
| 45 |
// node_modules/ajv/dist/compile/codegen/code.js |
| 46 |
var require_code = __commonJS({ |
| 47 |
"node_modules/ajv/dist/compile/codegen/code.js"(exports) { |
| 48 |
"use strict"; |
| 49 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 50 |
exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0; |
| 51 |
var _CodeOrName = class { |
| 52 |
}; |
| 53 |
exports._CodeOrName = _CodeOrName; |
| 54 |
exports.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i; |
| 55 |
var Name = class extends _CodeOrName { |
| 56 |
constructor(s) { |
| 57 |
super(); |
| 58 |
if (!exports.IDENTIFIER.test(s)) |
| 59 |
throw new Error("CodeGen: name must be a valid identifier"); |
| 60 |
this.str = s; |
| 61 |
} |
| 62 |
toString() { |
| 63 |
return this.str; |
| 64 |
} |
| 65 |
emptyStr() { |
| 66 |
return false; |
| 67 |
} |
| 68 |
get names() { |
| 69 |
return { [this.str]: 1 }; |
| 70 |
} |
| 71 |
}; |
| 72 |
exports.Name = Name; |
| 73 |
var _Code = class extends _CodeOrName { |
| 74 |
constructor(code) { |
| 75 |
super(); |
| 76 |
this._items = typeof code === "string" ? [code] : code; |
| 77 |
} |
| 78 |
toString() { |
| 79 |
return this.str; |
| 80 |
} |
| 81 |
emptyStr() { |
| 82 |
if (this._items.length > 1) |
| 83 |
return false; |
| 84 |
const item = this._items[0]; |
| 85 |
return item === "" || item === '""'; |
| 86 |
} |
| 87 |
get str() { |
| 88 |
var _a; |
| 89 |
return (_a = this._str) !== null && _a !== void 0 ? _a : this._str = this._items.reduce((s, c) => `${s}${c}`, ""); |
| 90 |
} |
| 91 |
get names() { |
| 92 |
var _a; |
| 93 |
return (_a = this._names) !== null && _a !== void 0 ? _a : this._names = this._items.reduce((names, c) => { |
| 94 |
if (c instanceof Name) |
| 95 |
names[c.str] = (names[c.str] || 0) + 1; |
| 96 |
return names; |
| 97 |
}, {}); |
| 98 |
} |
| 99 |
}; |
| 100 |
exports._Code = _Code; |
| 101 |
exports.nil = new _Code(""); |
| 102 |
function _(strs, ...args) { |
| 103 |
const code = [strs[0]]; |
| 104 |
let i = 0; |
| 105 |
while (i < args.length) { |
| 106 |
addCodeArg(code, args[i]); |
| 107 |
code.push(strs[++i]); |
| 108 |
} |
| 109 |
return new _Code(code); |
| 110 |
} |
| 111 |
exports._ = _; |
| 112 |
var plus = new _Code("+"); |
| 113 |
function str(strs, ...args) { |
| 114 |
const expr = [safeStringify(strs[0])]; |
| 115 |
let i = 0; |
| 116 |
while (i < args.length) { |
| 117 |
expr.push(plus); |
| 118 |
addCodeArg(expr, args[i]); |
| 119 |
expr.push(plus, safeStringify(strs[++i])); |
| 120 |
} |
| 121 |
optimize(expr); |
| 122 |
return new _Code(expr); |
| 123 |
} |
| 124 |
exports.str = str; |
| 125 |
function addCodeArg(code, arg) { |
| 126 |
if (arg instanceof _Code) |
| 127 |
code.push(...arg._items); |
| 128 |
else if (arg instanceof Name) |
| 129 |
code.push(arg); |
| 130 |
else |
| 131 |
code.push(interpolate(arg)); |
| 132 |
} |
| 133 |
exports.addCodeArg = addCodeArg; |
| 134 |
function optimize(expr) { |
| 135 |
let i = 1; |
| 136 |
while (i < expr.length - 1) { |
| 137 |
if (expr[i] === plus) { |
| 138 |
const res = mergeExprItems(expr[i - 1], expr[i + 1]); |
| 139 |
if (res !== void 0) { |
| 140 |
expr.splice(i - 1, 3, res); |
| 141 |
continue; |
| 142 |
} |
| 143 |
expr[i++] = "+"; |
| 144 |
} |
| 145 |
i++; |
| 146 |
} |
| 147 |
} |
| 148 |
function mergeExprItems(a, b) { |
| 149 |
if (b === '""') |
| 150 |
return a; |
| 151 |
if (a === '""') |
| 152 |
return b; |
| 153 |
if (typeof a == "string") { |
| 154 |
if (b instanceof Name || a[a.length - 1] !== '"') |
| 155 |
return; |
| 156 |
if (typeof b != "string") |
| 157 |
return `${a.slice(0, -1)}${b}"`; |
| 158 |
if (b[0] === '"') |
| 159 |
return a.slice(0, -1) + b.slice(1); |
| 160 |
return; |
| 161 |
} |
| 162 |
if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) |
| 163 |
return `"${a}${b.slice(1)}`; |
| 164 |
return; |
| 165 |
} |
| 166 |
function strConcat(c1, c2) { |
| 167 |
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str`${c1}${c2}`; |
| 168 |
} |
| 169 |
exports.strConcat = strConcat; |
| 170 |
function interpolate(x) { |
| 171 |
return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify(Array.isArray(x) ? x.join(",") : x); |
| 172 |
} |
| 173 |
function stringify(x) { |
| 174 |
return new _Code(safeStringify(x)); |
| 175 |
} |
| 176 |
exports.stringify = stringify; |
| 177 |
function safeStringify(x) { |
| 178 |
return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"); |
| 179 |
} |
| 180 |
exports.safeStringify = safeStringify; |
| 181 |
function getProperty(key) { |
| 182 |
return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _`[${key}]`; |
| 183 |
} |
| 184 |
exports.getProperty = getProperty; |
| 185 |
function getEsmExportName(key) { |
| 186 |
if (typeof key == "string" && exports.IDENTIFIER.test(key)) { |
| 187 |
return new _Code(`${key}`); |
| 188 |
} |
| 189 |
throw new Error(`CodeGen: invalid export name: ${key}, use explicit $id name mapping`); |
| 190 |
} |
| 191 |
exports.getEsmExportName = getEsmExportName; |
| 192 |
function regexpCode(rx) { |
| 193 |
return new _Code(rx.toString()); |
| 194 |
} |
| 195 |
exports.regexpCode = regexpCode; |
| 196 |
} |
| 197 |
}); |
| 198 |
|
| 199 |
// node_modules/ajv/dist/compile/codegen/scope.js |
| 200 |
var require_scope = __commonJS({ |
| 201 |
"node_modules/ajv/dist/compile/codegen/scope.js"(exports) { |
| 202 |
"use strict"; |
| 203 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 204 |
exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0; |
| 205 |
var code_1 = require_code(); |
| 206 |
var ValueError = class extends Error { |
| 207 |
constructor(name) { |
| 208 |
super(`CodeGen: "code" for ${name} not defined`); |
| 209 |
this.value = name.value; |
| 210 |
} |
| 211 |
}; |
| 212 |
var UsedValueState; |
| 213 |
(function(UsedValueState2) { |
| 214 |
UsedValueState2[UsedValueState2["Started"] = 0] = "Started"; |
| 215 |
UsedValueState2[UsedValueState2["Completed"] = 1] = "Completed"; |
| 216 |
})(UsedValueState || (exports.UsedValueState = UsedValueState = {})); |
| 217 |
exports.varKinds = { |
| 218 |
const: new code_1.Name("const"), |
| 219 |
let: new code_1.Name("let"), |
| 220 |
var: new code_1.Name("var") |
| 221 |
}; |
| 222 |
var Scope = class { |
| 223 |
constructor({ prefixes, parent } = {}) { |
| 224 |
this._names = {}; |
| 225 |
this._prefixes = prefixes; |
| 226 |
this._parent = parent; |
| 227 |
} |
| 228 |
toName(nameOrPrefix) { |
| 229 |
return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix); |
| 230 |
} |
| 231 |
name(prefix) { |
| 232 |
return new code_1.Name(this._newName(prefix)); |
| 233 |
} |
| 234 |
_newName(prefix) { |
| 235 |
const ng = this._names[prefix] || this._nameGroup(prefix); |
| 236 |
return `${prefix}${ng.index++}`; |
| 237 |
} |
| 238 |
_nameGroup(prefix) { |
| 239 |
var _a, _b; |
| 240 |
if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) { |
| 241 |
throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`); |
| 242 |
} |
| 243 |
return this._names[prefix] = { prefix, index: 0 }; |
| 244 |
} |
| 245 |
}; |
| 246 |
exports.Scope = Scope; |
| 247 |
var ValueScopeName = class extends code_1.Name { |
| 248 |
constructor(prefix, nameStr) { |
| 249 |
super(nameStr); |
| 250 |
this.prefix = prefix; |
| 251 |
} |
| 252 |
setValue(value, { property, itemIndex }) { |
| 253 |
this.value = value; |
| 254 |
this.scopePath = (0, code_1._)`.${new code_1.Name(property)}[${itemIndex}]`; |
| 255 |
} |
| 256 |
}; |
| 257 |
exports.ValueScopeName = ValueScopeName; |
| 258 |
var line = (0, code_1._)`\n`; |
| 259 |
var ValueScope = class extends Scope { |
| 260 |
constructor(opts) { |
| 261 |
super(opts); |
| 262 |
this._values = {}; |
| 263 |
this._scope = opts.scope; |
| 264 |
this.opts = { ...opts, _n: opts.lines ? line : code_1.nil }; |
| 265 |
} |
| 266 |
get() { |
| 267 |
return this._scope; |
| 268 |
} |
| 269 |
name(prefix) { |
| 270 |
return new ValueScopeName(prefix, this._newName(prefix)); |
| 271 |
} |
| 272 |
value(nameOrPrefix, value) { |
| 273 |
var _a; |
| 274 |
if (value.ref === void 0) |
| 275 |
throw new Error("CodeGen: ref must be passed in value"); |
| 276 |
const name = this.toName(nameOrPrefix); |
| 277 |
const { prefix } = name; |
| 278 |
const valueKey = (_a = value.key) !== null && _a !== void 0 ? _a : value.ref; |
| 279 |
let vs = this._values[prefix]; |
| 280 |
if (vs) { |
| 281 |
const _name = vs.get(valueKey); |
| 282 |
if (_name) |
| 283 |
return _name; |
| 284 |
} else { |
| 285 |
vs = this._values[prefix] = /* @__PURE__ */ new Map(); |
| 286 |
} |
| 287 |
vs.set(valueKey, name); |
| 288 |
const s = this._scope[prefix] || (this._scope[prefix] = []); |
| 289 |
const itemIndex = s.length; |
| 290 |
s[itemIndex] = value.ref; |
| 291 |
name.setValue(value, { property: prefix, itemIndex }); |
| 292 |
return name; |
| 293 |
} |
| 294 |
getValue(prefix, keyOrRef) { |
| 295 |
const vs = this._values[prefix]; |
| 296 |
if (!vs) |
| 297 |
return; |
| 298 |
return vs.get(keyOrRef); |
| 299 |
} |
| 300 |
scopeRefs(scopeName, values = this._values) { |
| 301 |
return this._reduceValues(values, (name) => { |
| 302 |
if (name.scopePath === void 0) |
| 303 |
throw new Error(`CodeGen: name "${name}" has no value`); |
| 304 |
return (0, code_1._)`${scopeName}${name.scopePath}`; |
| 305 |
}); |
| 306 |
} |
| 307 |
scopeCode(values = this._values, usedValues, getCode) { |
| 308 |
return this._reduceValues(values, (name) => { |
| 309 |
if (name.value === void 0) |
| 310 |
throw new Error(`CodeGen: name "${name}" has no value`); |
| 311 |
return name.value.code; |
| 312 |
}, usedValues, getCode); |
| 313 |
} |
| 314 |
_reduceValues(values, valueCode, usedValues = {}, getCode) { |
| 315 |
let code = code_1.nil; |
| 316 |
for (const prefix in values) { |
| 317 |
const vs = values[prefix]; |
| 318 |
if (!vs) |
| 319 |
continue; |
| 320 |
const nameSet = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map(); |
| 321 |
vs.forEach((name) => { |
| 322 |
if (nameSet.has(name)) |
| 323 |
return; |
| 324 |
nameSet.set(name, UsedValueState.Started); |
| 325 |
let c = valueCode(name); |
| 326 |
if (c) { |
| 327 |
const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const; |
| 328 |
code = (0, code_1._)`${code}${def} ${name} = ${c};${this.opts._n}`; |
| 329 |
} else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name)) { |
| 330 |
code = (0, code_1._)`${code}${c}${this.opts._n}`; |
| 331 |
} else { |
| 332 |
throw new ValueError(name); |
| 333 |
} |
| 334 |
nameSet.set(name, UsedValueState.Completed); |
| 335 |
}); |
| 336 |
} |
| 337 |
return code; |
| 338 |
} |
| 339 |
}; |
| 340 |
exports.ValueScope = ValueScope; |
| 341 |
} |
| 342 |
}); |
| 343 |
|
| 344 |
// node_modules/ajv/dist/compile/codegen/index.js |
| 345 |
var require_codegen = __commonJS({ |
| 346 |
"node_modules/ajv/dist/compile/codegen/index.js"(exports) { |
| 347 |
"use strict"; |
| 348 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 349 |
exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0; |
| 350 |
var code_1 = require_code(); |
| 351 |
var scope_1 = require_scope(); |
| 352 |
var code_2 = require_code(); |
| 353 |
Object.defineProperty(exports, "_", { enumerable: true, get: function() { |
| 354 |
return code_2._; |
| 355 |
} }); |
| 356 |
Object.defineProperty(exports, "str", { enumerable: true, get: function() { |
| 357 |
return code_2.str; |
| 358 |
} }); |
| 359 |
Object.defineProperty(exports, "strConcat", { enumerable: true, get: function() { |
| 360 |
return code_2.strConcat; |
| 361 |
} }); |
| 362 |
Object.defineProperty(exports, "nil", { enumerable: true, get: function() { |
| 363 |
return code_2.nil; |
| 364 |
} }); |
| 365 |
Object.defineProperty(exports, "getProperty", { enumerable: true, get: function() { |
| 366 |
return code_2.getProperty; |
| 367 |
} }); |
| 368 |
Object.defineProperty(exports, "stringify", { enumerable: true, get: function() { |
| 369 |
return code_2.stringify; |
| 370 |
} }); |
| 371 |
Object.defineProperty(exports, "regexpCode", { enumerable: true, get: function() { |
| 372 |
return code_2.regexpCode; |
| 373 |
} }); |
| 374 |
Object.defineProperty(exports, "Name", { enumerable: true, get: function() { |
| 375 |
return code_2.Name; |
| 376 |
} }); |
| 377 |
var scope_2 = require_scope(); |
| 378 |
Object.defineProperty(exports, "Scope", { enumerable: true, get: function() { |
| 379 |
return scope_2.Scope; |
| 380 |
} }); |
| 381 |
Object.defineProperty(exports, "ValueScope", { enumerable: true, get: function() { |
| 382 |
return scope_2.ValueScope; |
| 383 |
} }); |
| 384 |
Object.defineProperty(exports, "ValueScopeName", { enumerable: true, get: function() { |
| 385 |
return scope_2.ValueScopeName; |
| 386 |
} }); |
| 387 |
Object.defineProperty(exports, "varKinds", { enumerable: true, get: function() { |
| 388 |
return scope_2.varKinds; |
| 389 |
} }); |
| 390 |
exports.operators = { |
| 391 |
GT: new code_1._Code(">"), |
| 392 |
GTE: new code_1._Code(">="), |
| 393 |
LT: new code_1._Code("<"), |
| 394 |
LTE: new code_1._Code("<="), |
| 395 |
EQ: new code_1._Code("==="), |
| 396 |
NEQ: new code_1._Code("!=="), |
| 397 |
NOT: new code_1._Code("!"), |
| 398 |
OR: new code_1._Code("||"), |
| 399 |
AND: new code_1._Code("&&"), |
| 400 |
ADD: new code_1._Code("+") |
| 401 |
}; |
| 402 |
var Node = class { |
| 403 |
optimizeNodes() { |
| 404 |
return this; |
| 405 |
} |
| 406 |
optimizeNames(_names, _constants) { |
| 407 |
return this; |
| 408 |
} |
| 409 |
}; |
| 410 |
var Def = class extends Node { |
| 411 |
constructor(varKind, name, rhs) { |
| 412 |
super(); |
| 413 |
this.varKind = varKind; |
| 414 |
this.name = name; |
| 415 |
this.rhs = rhs; |
| 416 |
} |
| 417 |
render({ es5, _n }) { |
| 418 |
const varKind = es5 ? scope_1.varKinds.var : this.varKind; |
| 419 |
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`; |
| 420 |
return `${varKind} ${this.name}${rhs};` + _n; |
| 421 |
} |
| 422 |
optimizeNames(names, constants) { |
| 423 |
if (!names[this.name.str]) |
| 424 |
return; |
| 425 |
if (this.rhs) |
| 426 |
this.rhs = optimizeExpr(this.rhs, names, constants); |
| 427 |
return this; |
| 428 |
} |
| 429 |
get names() { |
| 430 |
return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {}; |
| 431 |
} |
| 432 |
}; |
| 433 |
var Assign = class extends Node { |
| 434 |
constructor(lhs, rhs, sideEffects) { |
| 435 |
super(); |
| 436 |
this.lhs = lhs; |
| 437 |
this.rhs = rhs; |
| 438 |
this.sideEffects = sideEffects; |
| 439 |
} |
| 440 |
render({ _n }) { |
| 441 |
return `${this.lhs} = ${this.rhs};` + _n; |
| 442 |
} |
| 443 |
optimizeNames(names, constants) { |
| 444 |
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) |
| 445 |
return; |
| 446 |
this.rhs = optimizeExpr(this.rhs, names, constants); |
| 447 |
return this; |
| 448 |
} |
| 449 |
get names() { |
| 450 |
const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names }; |
| 451 |
return addExprNames(names, this.rhs); |
| 452 |
} |
| 453 |
}; |
| 454 |
var AssignOp = class extends Assign { |
| 455 |
constructor(lhs, op, rhs, sideEffects) { |
| 456 |
super(lhs, rhs, sideEffects); |
| 457 |
this.op = op; |
| 458 |
} |
| 459 |
render({ _n }) { |
| 460 |
return `${this.lhs} ${this.op}= ${this.rhs};` + _n; |
| 461 |
} |
| 462 |
}; |
| 463 |
var Label = class extends Node { |
| 464 |
constructor(label) { |
| 465 |
super(); |
| 466 |
this.label = label; |
| 467 |
this.names = {}; |
| 468 |
} |
| 469 |
render({ _n }) { |
| 470 |
return `${this.label}:` + _n; |
| 471 |
} |
| 472 |
}; |
| 473 |
var Break = class extends Node { |
| 474 |
constructor(label) { |
| 475 |
super(); |
| 476 |
this.label = label; |
| 477 |
this.names = {}; |
| 478 |
} |
| 479 |
render({ _n }) { |
| 480 |
const label = this.label ? ` ${this.label}` : ""; |
| 481 |
return `break${label};` + _n; |
| 482 |
} |
| 483 |
}; |
| 484 |
var Throw = class extends Node { |
| 485 |
constructor(error) { |
| 486 |
super(); |
| 487 |
this.error = error; |
| 488 |
} |
| 489 |
render({ _n }) { |
| 490 |
return `throw ${this.error};` + _n; |
| 491 |
} |
| 492 |
get names() { |
| 493 |
return this.error.names; |
| 494 |
} |
| 495 |
}; |
| 496 |
var AnyCode = class extends Node { |
| 497 |
constructor(code) { |
| 498 |
super(); |
| 499 |
this.code = code; |
| 500 |
} |
| 501 |
render({ _n }) { |
| 502 |
return `${this.code};` + _n; |
| 503 |
} |
| 504 |
optimizeNodes() { |
| 505 |
return `${this.code}` ? this : void 0; |
| 506 |
} |
| 507 |
optimizeNames(names, constants) { |
| 508 |
this.code = optimizeExpr(this.code, names, constants); |
| 509 |
return this; |
| 510 |
} |
| 511 |
get names() { |
| 512 |
return this.code instanceof code_1._CodeOrName ? this.code.names : {}; |
| 513 |
} |
| 514 |
}; |
| 515 |
var ParentNode = class extends Node { |
| 516 |
constructor(nodes = []) { |
| 517 |
super(); |
| 518 |
this.nodes = nodes; |
| 519 |
} |
| 520 |
render(opts) { |
| 521 |
return this.nodes.reduce((code, n) => code + n.render(opts), ""); |
| 522 |
} |
| 523 |
optimizeNodes() { |
| 524 |
const { nodes } = this; |
| 525 |
let i = nodes.length; |
| 526 |
while (i--) { |
| 527 |
const n = nodes[i].optimizeNodes(); |
| 528 |
if (Array.isArray(n)) |
| 529 |
nodes.splice(i, 1, ...n); |
| 530 |
else if (n) |
| 531 |
nodes[i] = n; |
| 532 |
else |
| 533 |
nodes.splice(i, 1); |
| 534 |
} |
| 535 |
return nodes.length > 0 ? this : void 0; |
| 536 |
} |
| 537 |
optimizeNames(names, constants) { |
| 538 |
const { nodes } = this; |
| 539 |
let i = nodes.length; |
| 540 |
while (i--) { |
| 541 |
const n = nodes[i]; |
| 542 |
if (n.optimizeNames(names, constants)) |
| 543 |
continue; |
| 544 |
subtractNames(names, n.names); |
| 545 |
nodes.splice(i, 1); |
| 546 |
} |
| 547 |
return nodes.length > 0 ? this : void 0; |
| 548 |
} |
| 549 |
get names() { |
| 550 |
return this.nodes.reduce((names, n) => addNames(names, n.names), {}); |
| 551 |
} |
| 552 |
}; |
| 553 |
var BlockNode = class extends ParentNode { |
| 554 |
render(opts) { |
| 555 |
return "{" + opts._n + super.render(opts) + "}" + opts._n; |
| 556 |
} |
| 557 |
}; |
| 558 |
var Root = class extends ParentNode { |
| 559 |
}; |
| 560 |
var Else = class extends BlockNode { |
| 561 |
}; |
| 562 |
Else.kind = "else"; |
| 563 |
var If = class _If extends BlockNode { |
| 564 |
constructor(condition, nodes) { |
| 565 |
super(nodes); |
| 566 |
this.condition = condition; |
| 567 |
} |
| 568 |
render(opts) { |
| 569 |
let code = `if(${this.condition})` + super.render(opts); |
| 570 |
if (this.else) |
| 571 |
code += "else " + this.else.render(opts); |
| 572 |
return code; |
| 573 |
} |
| 574 |
optimizeNodes() { |
| 575 |
super.optimizeNodes(); |
| 576 |
const cond = this.condition; |
| 577 |
if (cond === true) |
| 578 |
return this.nodes; |
| 579 |
let e = this.else; |
| 580 |
if (e) { |
| 581 |
const ns = e.optimizeNodes(); |
| 582 |
e = this.else = Array.isArray(ns) ? new Else(ns) : ns; |
| 583 |
} |
| 584 |
if (e) { |
| 585 |
if (cond === false) |
| 586 |
return e instanceof _If ? e : e.nodes; |
| 587 |
if (this.nodes.length) |
| 588 |
return this; |
| 589 |
return new _If(not(cond), e instanceof _If ? [e] : e.nodes); |
| 590 |
} |
| 591 |
if (cond === false || !this.nodes.length) |
| 592 |
return void 0; |
| 593 |
return this; |
| 594 |
} |
| 595 |
optimizeNames(names, constants) { |
| 596 |
var _a; |
| 597 |
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants); |
| 598 |
if (!(super.optimizeNames(names, constants) || this.else)) |
| 599 |
return; |
| 600 |
this.condition = optimizeExpr(this.condition, names, constants); |
| 601 |
return this; |
| 602 |
} |
| 603 |
get names() { |
| 604 |
const names = super.names; |
| 605 |
addExprNames(names, this.condition); |
| 606 |
if (this.else) |
| 607 |
addNames(names, this.else.names); |
| 608 |
return names; |
| 609 |
} |
| 610 |
}; |
| 611 |
If.kind = "if"; |
| 612 |
var For = class extends BlockNode { |
| 613 |
}; |
| 614 |
For.kind = "for"; |
| 615 |
var ForLoop = class extends For { |
| 616 |
constructor(iteration) { |
| 617 |
super(); |
| 618 |
this.iteration = iteration; |
| 619 |
} |
| 620 |
render(opts) { |
| 621 |
return `for(${this.iteration})` + super.render(opts); |
| 622 |
} |
| 623 |
optimizeNames(names, constants) { |
| 624 |
if (!super.optimizeNames(names, constants)) |
| 625 |
return; |
| 626 |
this.iteration = optimizeExpr(this.iteration, names, constants); |
| 627 |
return this; |
| 628 |
} |
| 629 |
get names() { |
| 630 |
return addNames(super.names, this.iteration.names); |
| 631 |
} |
| 632 |
}; |
| 633 |
var ForRange = class extends For { |
| 634 |
constructor(varKind, name, from, to) { |
| 635 |
super(); |
| 636 |
this.varKind = varKind; |
| 637 |
this.name = name; |
| 638 |
this.from = from; |
| 639 |
this.to = to; |
| 640 |
} |
| 641 |
render(opts) { |
| 642 |
const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind; |
| 643 |
const { name, from, to } = this; |
| 644 |
return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts); |
| 645 |
} |
| 646 |
get names() { |
| 647 |
const names = addExprNames(super.names, this.from); |
| 648 |
return addExprNames(names, this.to); |
| 649 |
} |
| 650 |
}; |
| 651 |
var ForIter = class extends For { |
| 652 |
constructor(loop, varKind, name, iterable) { |
| 653 |
super(); |
| 654 |
this.loop = loop; |
| 655 |
this.varKind = varKind; |
| 656 |
this.name = name; |
| 657 |
this.iterable = iterable; |
| 658 |
} |
| 659 |
render(opts) { |
| 660 |
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts); |
| 661 |
} |
| 662 |
optimizeNames(names, constants) { |
| 663 |
if (!super.optimizeNames(names, constants)) |
| 664 |
return; |
| 665 |
this.iterable = optimizeExpr(this.iterable, names, constants); |
| 666 |
return this; |
| 667 |
} |
| 668 |
get names() { |
| 669 |
return addNames(super.names, this.iterable.names); |
| 670 |
} |
| 671 |
}; |
| 672 |
var Func = class extends BlockNode { |
| 673 |
constructor(name, args, async) { |
| 674 |
super(); |
| 675 |
this.name = name; |
| 676 |
this.args = args; |
| 677 |
this.async = async; |
| 678 |
} |
| 679 |
render(opts) { |
| 680 |
const _async = this.async ? "async " : ""; |
| 681 |
return `${_async}function ${this.name}(${this.args})` + super.render(opts); |
| 682 |
} |
| 683 |
}; |
| 684 |
Func.kind = "func"; |
| 685 |
var Return = class extends ParentNode { |
| 686 |
render(opts) { |
| 687 |
return "return " + super.render(opts); |
| 688 |
} |
| 689 |
}; |
| 690 |
Return.kind = "return"; |
| 691 |
var Try = class extends BlockNode { |
| 692 |
render(opts) { |
| 693 |
let code = "try" + super.render(opts); |
| 694 |
if (this.catch) |
| 695 |
code += this.catch.render(opts); |
| 696 |
if (this.finally) |
| 697 |
code += this.finally.render(opts); |
| 698 |
return code; |
| 699 |
} |
| 700 |
optimizeNodes() { |
| 701 |
var _a, _b; |
| 702 |
super.optimizeNodes(); |
| 703 |
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes(); |
| 704 |
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes(); |
| 705 |
return this; |
| 706 |
} |
| 707 |
optimizeNames(names, constants) { |
| 708 |
var _a, _b; |
| 709 |
super.optimizeNames(names, constants); |
| 710 |
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants); |
| 711 |
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants); |
| 712 |
return this; |
| 713 |
} |
| 714 |
get names() { |
| 715 |
const names = super.names; |
| 716 |
if (this.catch) |
| 717 |
addNames(names, this.catch.names); |
| 718 |
if (this.finally) |
| 719 |
addNames(names, this.finally.names); |
| 720 |
return names; |
| 721 |
} |
| 722 |
}; |
| 723 |
var Catch = class extends BlockNode { |
| 724 |
constructor(error) { |
| 725 |
super(); |
| 726 |
this.error = error; |
| 727 |
} |
| 728 |
render(opts) { |
| 729 |
return `catch(${this.error})` + super.render(opts); |
| 730 |
} |
| 731 |
}; |
| 732 |
Catch.kind = "catch"; |
| 733 |
var Finally = class extends BlockNode { |
| 734 |
render(opts) { |
| 735 |
return "finally" + super.render(opts); |
| 736 |
} |
| 737 |
}; |
| 738 |
Finally.kind = "finally"; |
| 739 |
var CodeGen = class { |
| 740 |
constructor(extScope, opts = {}) { |
| 741 |
this._values = {}; |
| 742 |
this._blockStarts = []; |
| 743 |
this._constants = {}; |
| 744 |
this.opts = { ...opts, _n: opts.lines ? "\n" : "" }; |
| 745 |
this._extScope = extScope; |
| 746 |
this._scope = new scope_1.Scope({ parent: extScope }); |
| 747 |
this._nodes = [new Root()]; |
| 748 |
} |
| 749 |
toString() { |
| 750 |
return this._root.render(this.opts); |
| 751 |
} |
| 752 |
// returns unique name in the internal scope |
| 753 |
name(prefix) { |
| 754 |
return this._scope.name(prefix); |
| 755 |
} |
| 756 |
// reserves unique name in the external scope |
| 757 |
scopeName(prefix) { |
| 758 |
return this._extScope.name(prefix); |
| 759 |
} |
| 760 |
// reserves unique name in the external scope and assigns value to it |
| 761 |
scopeValue(prefixOrName, value) { |
| 762 |
const name = this._extScope.value(prefixOrName, value); |
| 763 |
const vs = this._values[name.prefix] || (this._values[name.prefix] = /* @__PURE__ */ new Set()); |
| 764 |
vs.add(name); |
| 765 |
return name; |
| 766 |
} |
| 767 |
getScopeValue(prefix, keyOrRef) { |
| 768 |
return this._extScope.getValue(prefix, keyOrRef); |
| 769 |
} |
| 770 |
// return code that assigns values in the external scope to the names that are used internally |
| 771 |
// (same names that were returned by gen.scopeName or gen.scopeValue) |
| 772 |
scopeRefs(scopeName) { |
| 773 |
return this._extScope.scopeRefs(scopeName, this._values); |
| 774 |
} |
| 775 |
scopeCode() { |
| 776 |
return this._extScope.scopeCode(this._values); |
| 777 |
} |
| 778 |
_def(varKind, nameOrPrefix, rhs, constant) { |
| 779 |
const name = this._scope.toName(nameOrPrefix); |
| 780 |
if (rhs !== void 0 && constant) |
| 781 |
this._constants[name.str] = rhs; |
| 782 |
this._leafNode(new Def(varKind, name, rhs)); |
| 783 |
return name; |
| 784 |
} |
| 785 |
// `const` declaration (`var` in es5 mode) |
| 786 |
const(nameOrPrefix, rhs, _constant) { |
| 787 |
return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant); |
| 788 |
} |
| 789 |
// `let` declaration with optional assignment (`var` in es5 mode) |
| 790 |
let(nameOrPrefix, rhs, _constant) { |
| 791 |
return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant); |
| 792 |
} |
| 793 |
// `var` declaration with optional assignment |
| 794 |
var(nameOrPrefix, rhs, _constant) { |
| 795 |
return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant); |
| 796 |
} |
| 797 |
// assignment code |
| 798 |
assign(lhs, rhs, sideEffects) { |
| 799 |
return this._leafNode(new Assign(lhs, rhs, sideEffects)); |
| 800 |
} |
| 801 |
// `+=` code |
| 802 |
add(lhs, rhs) { |
| 803 |
return this._leafNode(new AssignOp(lhs, exports.operators.ADD, rhs)); |
| 804 |
} |
| 805 |
// appends passed SafeExpr to code or executes Block |
| 806 |
code(c) { |
| 807 |
if (typeof c == "function") |
| 808 |
c(); |
| 809 |
else if (c !== code_1.nil) |
| 810 |
this._leafNode(new AnyCode(c)); |
| 811 |
return this; |
| 812 |
} |
| 813 |
// returns code for object literal for the passed argument list of key-value pairs |
| 814 |
object(...keyValues) { |
| 815 |
const code = ["{"]; |
| 816 |
for (const [key, value] of keyValues) { |
| 817 |
if (code.length > 1) |
| 818 |
code.push(","); |
| 819 |
code.push(key); |
| 820 |
if (key !== value || this.opts.es5) { |
| 821 |
code.push(":"); |
| 822 |
(0, code_1.addCodeArg)(code, value); |
| 823 |
} |
| 824 |
} |
| 825 |
code.push("}"); |
| 826 |
return new code_1._Code(code); |
| 827 |
} |
| 828 |
// `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed) |
| 829 |
if(condition, thenBody, elseBody) { |
| 830 |
this._blockNode(new If(condition)); |
| 831 |
if (thenBody && elseBody) { |
| 832 |
this.code(thenBody).else().code(elseBody).endIf(); |
| 833 |
} else if (thenBody) { |
| 834 |
this.code(thenBody).endIf(); |
| 835 |
} else if (elseBody) { |
| 836 |
throw new Error('CodeGen: "else" body without "then" body'); |
| 837 |
} |
| 838 |
return this; |
| 839 |
} |
| 840 |
// `else if` clause - invalid without `if` or after `else` clauses |
| 841 |
elseIf(condition) { |
| 842 |
return this._elseNode(new If(condition)); |
| 843 |
} |
| 844 |
// `else` clause - only valid after `if` or `else if` clauses |
| 845 |
else() { |
| 846 |
return this._elseNode(new Else()); |
| 847 |
} |
| 848 |
// end `if` statement (needed if gen.if was used only with condition) |
| 849 |
endIf() { |
| 850 |
return this._endBlockNode(If, Else); |
| 851 |
} |
| 852 |
_for(node, forBody) { |
| 853 |
this._blockNode(node); |
| 854 |
if (forBody) |
| 855 |
this.code(forBody).endFor(); |
| 856 |
return this; |
| 857 |
} |
| 858 |
// a generic `for` clause (or statement if `forBody` is passed) |
| 859 |
for(iteration, forBody) { |
| 860 |
return this._for(new ForLoop(iteration), forBody); |
| 861 |
} |
| 862 |
// `for` statement for a range of values |
| 863 |
forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) { |
| 864 |
const name = this._scope.toName(nameOrPrefix); |
| 865 |
return this._for(new ForRange(varKind, name, from, to), () => forBody(name)); |
| 866 |
} |
| 867 |
// `for-of` statement (in es5 mode replace with a normal for loop) |
| 868 |
forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) { |
| 869 |
const name = this._scope.toName(nameOrPrefix); |
| 870 |
if (this.opts.es5) { |
| 871 |
const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable); |
| 872 |
return this.forRange("_i", 0, (0, code_1._)`${arr}.length`, (i) => { |
| 873 |
this.var(name, (0, code_1._)`${arr}[${i}]`); |
| 874 |
forBody(name); |
| 875 |
}); |
| 876 |
} |
| 877 |
return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name)); |
| 878 |
} |
| 879 |
// `for-in` statement. |
| 880 |
// With option `ownProperties` replaced with a `for-of` loop for object keys |
| 881 |
forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) { |
| 882 |
if (this.opts.ownProperties) { |
| 883 |
return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj})`, forBody); |
| 884 |
} |
| 885 |
const name = this._scope.toName(nameOrPrefix); |
| 886 |
return this._for(new ForIter("in", varKind, name, obj), () => forBody(name)); |
| 887 |
} |
| 888 |
// end `for` loop |
| 889 |
endFor() { |
| 890 |
return this._endBlockNode(For); |
| 891 |
} |
| 892 |
// `label` statement |
| 893 |
label(label) { |
| 894 |
return this._leafNode(new Label(label)); |
| 895 |
} |
| 896 |
// `break` statement |
| 897 |
break(label) { |
| 898 |
return this._leafNode(new Break(label)); |
| 899 |
} |
| 900 |
// `return` statement |
| 901 |
return(value) { |
| 902 |
const node = new Return(); |
| 903 |
this._blockNode(node); |
| 904 |
this.code(value); |
| 905 |
if (node.nodes.length !== 1) |
| 906 |
throw new Error('CodeGen: "return" should have one node'); |
| 907 |
return this._endBlockNode(Return); |
| 908 |
} |
| 909 |
// `try` statement |
| 910 |
try(tryBody, catchCode, finallyCode) { |
| 911 |
if (!catchCode && !finallyCode) |
| 912 |
throw new Error('CodeGen: "try" without "catch" and "finally"'); |
| 913 |
const node = new Try(); |
| 914 |
this._blockNode(node); |
| 915 |
this.code(tryBody); |
| 916 |
if (catchCode) { |
| 917 |
const error = this.name("e"); |
| 918 |
this._currNode = node.catch = new Catch(error); |
| 919 |
catchCode(error); |
| 920 |
} |
| 921 |
if (finallyCode) { |
| 922 |
this._currNode = node.finally = new Finally(); |
| 923 |
this.code(finallyCode); |
| 924 |
} |
| 925 |
return this._endBlockNode(Catch, Finally); |
| 926 |
} |
| 927 |
// `throw` statement |
| 928 |
throw(error) { |
| 929 |
return this._leafNode(new Throw(error)); |
| 930 |
} |
| 931 |
// start self-balancing block |
| 932 |
block(body, nodeCount) { |
| 933 |
this._blockStarts.push(this._nodes.length); |
| 934 |
if (body) |
| 935 |
this.code(body).endBlock(nodeCount); |
| 936 |
return this; |
| 937 |
} |
| 938 |
// end the current self-balancing block |
| 939 |
endBlock(nodeCount) { |
| 940 |
const len = this._blockStarts.pop(); |
| 941 |
if (len === void 0) |
| 942 |
throw new Error("CodeGen: not in self-balancing block"); |
| 943 |
const toClose = this._nodes.length - len; |
| 944 |
if (toClose < 0 || nodeCount !== void 0 && toClose !== nodeCount) { |
| 945 |
throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`); |
| 946 |
} |
| 947 |
this._nodes.length = len; |
| 948 |
return this; |
| 949 |
} |
| 950 |
// `function` heading (or definition if funcBody is passed) |
| 951 |
func(name, args = code_1.nil, async, funcBody) { |
| 952 |
this._blockNode(new Func(name, args, async)); |
| 953 |
if (funcBody) |
| 954 |
this.code(funcBody).endFunc(); |
| 955 |
return this; |
| 956 |
} |
| 957 |
// end function definition |
| 958 |
endFunc() { |
| 959 |
return this._endBlockNode(Func); |
| 960 |
} |
| 961 |
optimize(n = 1) { |
| 962 |
while (n-- > 0) { |
| 963 |
this._root.optimizeNodes(); |
| 964 |
this._root.optimizeNames(this._root.names, this._constants); |
| 965 |
} |
| 966 |
} |
| 967 |
_leafNode(node) { |
| 968 |
this._currNode.nodes.push(node); |
| 969 |
return this; |
| 970 |
} |
| 971 |
_blockNode(node) { |
| 972 |
this._currNode.nodes.push(node); |
| 973 |
this._nodes.push(node); |
| 974 |
} |
| 975 |
_endBlockNode(N1, N2) { |
| 976 |
const n = this._currNode; |
| 977 |
if (n instanceof N1 || N2 && n instanceof N2) { |
| 978 |
this._nodes.pop(); |
| 979 |
return this; |
| 980 |
} |
| 981 |
throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`); |
| 982 |
} |
| 983 |
_elseNode(node) { |
| 984 |
const n = this._currNode; |
| 985 |
if (!(n instanceof If)) { |
| 986 |
throw new Error('CodeGen: "else" without "if"'); |
| 987 |
} |
| 988 |
this._currNode = n.else = node; |
| 989 |
return this; |
| 990 |
} |
| 991 |
get _root() { |
| 992 |
return this._nodes[0]; |
| 993 |
} |
| 994 |
get _currNode() { |
| 995 |
const ns = this._nodes; |
| 996 |
return ns[ns.length - 1]; |
| 997 |
} |
| 998 |
set _currNode(node) { |
| 999 |
const ns = this._nodes; |
| 1000 |
ns[ns.length - 1] = node; |
| 1001 |
} |
| 1002 |
}; |
| 1003 |
exports.CodeGen = CodeGen; |
| 1004 |
function addNames(names, from) { |
| 1005 |
for (const n in from) |
| 1006 |
names[n] = (names[n] || 0) + (from[n] || 0); |
| 1007 |
return names; |
| 1008 |
} |
| 1009 |
function addExprNames(names, from) { |
| 1010 |
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names; |
| 1011 |
} |
| 1012 |
function optimizeExpr(expr, names, constants) { |
| 1013 |
if (expr instanceof code_1.Name) |
| 1014 |
return replaceName(expr); |
| 1015 |
if (!canOptimize(expr)) |
| 1016 |
return expr; |
| 1017 |
return new code_1._Code(expr._items.reduce((items, c) => { |
| 1018 |
if (c instanceof code_1.Name) |
| 1019 |
c = replaceName(c); |
| 1020 |
if (c instanceof code_1._Code) |
| 1021 |
items.push(...c._items); |
| 1022 |
else |
| 1023 |
items.push(c); |
| 1024 |
return items; |
| 1025 |
}, [])); |
| 1026 |
function replaceName(n) { |
| 1027 |
const c = constants[n.str]; |
| 1028 |
if (c === void 0 || names[n.str] !== 1) |
| 1029 |
return n; |
| 1030 |
delete names[n.str]; |
| 1031 |
return c; |
| 1032 |
} |
| 1033 |
function canOptimize(e) { |
| 1034 |
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0); |
| 1035 |
} |
| 1036 |
} |
| 1037 |
function subtractNames(names, from) { |
| 1038 |
for (const n in from) |
| 1039 |
names[n] = (names[n] || 0) - (from[n] || 0); |
| 1040 |
} |
| 1041 |
function not(x) { |
| 1042 |
return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`; |
| 1043 |
} |
| 1044 |
exports.not = not; |
| 1045 |
var andCode = mappend(exports.operators.AND); |
| 1046 |
function and(...args) { |
| 1047 |
return args.reduce(andCode); |
| 1048 |
} |
| 1049 |
exports.and = and; |
| 1050 |
var orCode = mappend(exports.operators.OR); |
| 1051 |
function or(...args) { |
| 1052 |
return args.reduce(orCode); |
| 1053 |
} |
| 1054 |
exports.or = or; |
| 1055 |
function mappend(op) { |
| 1056 |
return (x, y) => x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._)`${par(x)} ${op} ${par(y)}`; |
| 1057 |
} |
| 1058 |
function par(x) { |
| 1059 |
return x instanceof code_1.Name ? x : (0, code_1._)`(${x})`; |
| 1060 |
} |
| 1061 |
} |
| 1062 |
}); |
| 1063 |
|
| 1064 |
// node_modules/ajv/dist/compile/util.js |
| 1065 |
var require_util = __commonJS({ |
| 1066 |
"node_modules/ajv/dist/compile/util.js"(exports) { |
| 1067 |
"use strict"; |
| 1068 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1069 |
exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = void 0; |
| 1070 |
var codegen_1 = require_codegen(); |
| 1071 |
var code_1 = require_code(); |
| 1072 |
function toHash(arr) { |
| 1073 |
const hash = {}; |
| 1074 |
for (const item of arr) |
| 1075 |
hash[item] = true; |
| 1076 |
return hash; |
| 1077 |
} |
| 1078 |
exports.toHash = toHash; |
| 1079 |
function alwaysValidSchema(it, schema) { |
| 1080 |
if (typeof schema == "boolean") |
| 1081 |
return schema; |
| 1082 |
if (Object.keys(schema).length === 0) |
| 1083 |
return true; |
| 1084 |
checkUnknownRules(it, schema); |
| 1085 |
return !schemaHasRules(schema, it.self.RULES.all); |
| 1086 |
} |
| 1087 |
exports.alwaysValidSchema = alwaysValidSchema; |
| 1088 |
function checkUnknownRules(it, schema = it.schema) { |
| 1089 |
const { opts, self } = it; |
| 1090 |
if (!opts.strictSchema) |
| 1091 |
return; |
| 1092 |
if (typeof schema === "boolean") |
| 1093 |
return; |
| 1094 |
const rules = self.RULES.keywords; |
| 1095 |
for (const key in schema) { |
| 1096 |
if (!rules[key]) |
| 1097 |
checkStrictMode(it, `unknown keyword: "${key}"`); |
| 1098 |
} |
| 1099 |
} |
| 1100 |
exports.checkUnknownRules = checkUnknownRules; |
| 1101 |
function schemaHasRules(schema, rules) { |
| 1102 |
if (typeof schema == "boolean") |
| 1103 |
return !schema; |
| 1104 |
for (const key in schema) |
| 1105 |
if (rules[key]) |
| 1106 |
return true; |
| 1107 |
return false; |
| 1108 |
} |
| 1109 |
exports.schemaHasRules = schemaHasRules; |
| 1110 |
function schemaHasRulesButRef(schema, RULES) { |
| 1111 |
if (typeof schema == "boolean") |
| 1112 |
return !schema; |
| 1113 |
for (const key in schema) |
| 1114 |
if (key !== "$ref" && RULES.all[key]) |
| 1115 |
return true; |
| 1116 |
return false; |
| 1117 |
} |
| 1118 |
exports.schemaHasRulesButRef = schemaHasRulesButRef; |
| 1119 |
function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword, $data) { |
| 1120 |
if (!$data) { |
| 1121 |
if (typeof schema == "number" || typeof schema == "boolean") |
| 1122 |
return schema; |
| 1123 |
if (typeof schema == "string") |
| 1124 |
return (0, codegen_1._)`${schema}`; |
| 1125 |
} |
| 1126 |
return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`; |
| 1127 |
} |
| 1128 |
exports.schemaRefOrVal = schemaRefOrVal; |
| 1129 |
function unescapeFragment(str) { |
| 1130 |
return unescapeJsonPointer(decodeURIComponent(str)); |
| 1131 |
} |
| 1132 |
exports.unescapeFragment = unescapeFragment; |
| 1133 |
function escapeFragment(str) { |
| 1134 |
return encodeURIComponent(escapeJsonPointer(str)); |
| 1135 |
} |
| 1136 |
exports.escapeFragment = escapeFragment; |
| 1137 |
function escapeJsonPointer(str) { |
| 1138 |
if (typeof str == "number") |
| 1139 |
return `${str}`; |
| 1140 |
return str.replace(/~/g, "~0").replace(/\//g, "~1"); |
| 1141 |
} |
| 1142 |
exports.escapeJsonPointer = escapeJsonPointer; |
| 1143 |
function unescapeJsonPointer(str) { |
| 1144 |
return str.replace(/~1/g, "/").replace(/~0/g, "~"); |
| 1145 |
} |
| 1146 |
exports.unescapeJsonPointer = unescapeJsonPointer; |
| 1147 |
function eachItem(xs, f) { |
| 1148 |
if (Array.isArray(xs)) { |
| 1149 |
for (const x of xs) |
| 1150 |
f(x); |
| 1151 |
} else { |
| 1152 |
f(xs); |
| 1153 |
} |
| 1154 |
} |
| 1155 |
exports.eachItem = eachItem; |
| 1156 |
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) { |
| 1157 |
return (gen, from, to, toName) => { |
| 1158 |
const res = to === void 0 ? from : to instanceof codegen_1.Name ? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to); |
| 1159 |
return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res; |
| 1160 |
}; |
| 1161 |
} |
| 1162 |
exports.mergeEvaluated = { |
| 1163 |
props: makeMergeEvaluated({ |
| 1164 |
mergeNames: (gen, from, to) => gen.if((0, codegen_1._)`${to} !== true && ${from} !== undefined`, () => { |
| 1165 |
gen.if((0, codegen_1._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1._)`${to} || {}`).code((0, codegen_1._)`Object.assign(${to}, ${from})`)); |
| 1166 |
}), |
| 1167 |
mergeToName: (gen, from, to) => gen.if((0, codegen_1._)`${to} !== true`, () => { |
| 1168 |
if (from === true) { |
| 1169 |
gen.assign(to, true); |
| 1170 |
} else { |
| 1171 |
gen.assign(to, (0, codegen_1._)`${to} || {}`); |
| 1172 |
setEvaluated(gen, to, from); |
| 1173 |
} |
| 1174 |
}), |
| 1175 |
mergeValues: (from, to) => from === true ? true : { ...from, ...to }, |
| 1176 |
resultToName: evaluatedPropsToName |
| 1177 |
}), |
| 1178 |
items: makeMergeEvaluated({ |
| 1179 |
mergeNames: (gen, from, to) => gen.if((0, codegen_1._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)), |
| 1180 |
mergeToName: (gen, from, to) => gen.if((0, codegen_1._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1._)`${to} > ${from} ? ${to} : ${from}`)), |
| 1181 |
mergeValues: (from, to) => from === true ? true : Math.max(from, to), |
| 1182 |
resultToName: (gen, items) => gen.var("items", items) |
| 1183 |
}) |
| 1184 |
}; |
| 1185 |
function evaluatedPropsToName(gen, ps) { |
| 1186 |
if (ps === true) |
| 1187 |
return gen.var("props", true); |
| 1188 |
const props = gen.var("props", (0, codegen_1._)`{}`); |
| 1189 |
if (ps !== void 0) |
| 1190 |
setEvaluated(gen, props, ps); |
| 1191 |
return props; |
| 1192 |
} |
| 1193 |
exports.evaluatedPropsToName = evaluatedPropsToName; |
| 1194 |
function setEvaluated(gen, props, ps) { |
| 1195 |
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1._)`${props}${(0, codegen_1.getProperty)(p)}`, true)); |
| 1196 |
} |
| 1197 |
exports.setEvaluated = setEvaluated; |
| 1198 |
var snippets = {}; |
| 1199 |
function useFunc(gen, f) { |
| 1200 |
return gen.scopeValue("func", { |
| 1201 |
ref: f, |
| 1202 |
code: snippets[f.code] || (snippets[f.code] = new code_1._Code(f.code)) |
| 1203 |
}); |
| 1204 |
} |
| 1205 |
exports.useFunc = useFunc; |
| 1206 |
var Type; |
| 1207 |
(function(Type2) { |
| 1208 |
Type2[Type2["Num"] = 0] = "Num"; |
| 1209 |
Type2[Type2["Str"] = 1] = "Str"; |
| 1210 |
})(Type || (exports.Type = Type = {})); |
| 1211 |
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) { |
| 1212 |
if (dataProp instanceof codegen_1.Name) { |
| 1213 |
const isNumber = dataPropType === Type.Num; |
| 1214 |
return jsPropertySyntax ? isNumber ? (0, codegen_1._)`"[" + ${dataProp} + "]"` : (0, codegen_1._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1._)`"/" + ${dataProp}` : (0, codegen_1._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`; |
| 1215 |
} |
| 1216 |
return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp); |
| 1217 |
} |
| 1218 |
exports.getErrorPath = getErrorPath; |
| 1219 |
function checkStrictMode(it, msg, mode = it.opts.strictSchema) { |
| 1220 |
if (!mode) |
| 1221 |
return; |
| 1222 |
msg = `strict mode: ${msg}`; |
| 1223 |
if (mode === true) |
| 1224 |
throw new Error(msg); |
| 1225 |
it.self.logger.warn(msg); |
| 1226 |
} |
| 1227 |
exports.checkStrictMode = checkStrictMode; |
| 1228 |
} |
| 1229 |
}); |
| 1230 |
|
| 1231 |
// node_modules/ajv/dist/compile/names.js |
| 1232 |
var require_names = __commonJS({ |
| 1233 |
"node_modules/ajv/dist/compile/names.js"(exports) { |
| 1234 |
"use strict"; |
| 1235 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1236 |
var codegen_1 = require_codegen(); |
| 1237 |
var names = { |
| 1238 |
// validation function arguments |
| 1239 |
data: new codegen_1.Name("data"), |
| 1240 |
// data passed to validation function |
| 1241 |
// args passed from referencing schema |
| 1242 |
valCxt: new codegen_1.Name("valCxt"), |
| 1243 |
// validation/data context - should not be used directly, it is destructured to the names below |
| 1244 |
instancePath: new codegen_1.Name("instancePath"), |
| 1245 |
parentData: new codegen_1.Name("parentData"), |
| 1246 |
parentDataProperty: new codegen_1.Name("parentDataProperty"), |
| 1247 |
rootData: new codegen_1.Name("rootData"), |
| 1248 |
// root data - same as the data passed to the first/top validation function |
| 1249 |
dynamicAnchors: new codegen_1.Name("dynamicAnchors"), |
| 1250 |
// used to support recursiveRef and dynamicRef |
| 1251 |
// function scoped variables |
| 1252 |
vErrors: new codegen_1.Name("vErrors"), |
| 1253 |
// null or array of validation errors |
| 1254 |
errors: new codegen_1.Name("errors"), |
| 1255 |
// counter of validation errors |
| 1256 |
this: new codegen_1.Name("this"), |
| 1257 |
// "globals" |
| 1258 |
self: new codegen_1.Name("self"), |
| 1259 |
scope: new codegen_1.Name("scope"), |
| 1260 |
// JTD serialize/parse name for JSON string and position |
| 1261 |
json: new codegen_1.Name("json"), |
| 1262 |
jsonPos: new codegen_1.Name("jsonPos"), |
| 1263 |
jsonLen: new codegen_1.Name("jsonLen"), |
| 1264 |
jsonPart: new codegen_1.Name("jsonPart") |
| 1265 |
}; |
| 1266 |
exports.default = names; |
| 1267 |
} |
| 1268 |
}); |
| 1269 |
|
| 1270 |
// node_modules/ajv/dist/compile/errors.js |
| 1271 |
var require_errors = __commonJS({ |
| 1272 |
"node_modules/ajv/dist/compile/errors.js"(exports) { |
| 1273 |
"use strict"; |
| 1274 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1275 |
exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0; |
| 1276 |
var codegen_1 = require_codegen(); |
| 1277 |
var util_1 = require_util(); |
| 1278 |
var names_1 = require_names(); |
| 1279 |
exports.keywordError = { |
| 1280 |
message: ({ keyword }) => (0, codegen_1.str)`must pass "${keyword}" keyword validation` |
| 1281 |
}; |
| 1282 |
exports.keyword$DataError = { |
| 1283 |
message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)` |
| 1284 |
}; |
| 1285 |
function reportError(cxt, error = exports.keywordError, errorPaths, overrideAllErrors) { |
| 1286 |
const { it } = cxt; |
| 1287 |
const { gen, compositeRule, allErrors } = it; |
| 1288 |
const errObj = errorObjectCode(cxt, error, errorPaths); |
| 1289 |
if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : compositeRule || allErrors) { |
| 1290 |
addError(gen, errObj); |
| 1291 |
} else { |
| 1292 |
returnErrors(it, (0, codegen_1._)`[${errObj}]`); |
| 1293 |
} |
| 1294 |
} |
| 1295 |
exports.reportError = reportError; |
| 1296 |
function reportExtraError(cxt, error = exports.keywordError, errorPaths) { |
| 1297 |
const { it } = cxt; |
| 1298 |
const { gen, compositeRule, allErrors } = it; |
| 1299 |
const errObj = errorObjectCode(cxt, error, errorPaths); |
| 1300 |
addError(gen, errObj); |
| 1301 |
if (!(compositeRule || allErrors)) { |
| 1302 |
returnErrors(it, names_1.default.vErrors); |
| 1303 |
} |
| 1304 |
} |
| 1305 |
exports.reportExtraError = reportExtraError; |
| 1306 |
function resetErrorsCount(gen, errsCount) { |
| 1307 |
gen.assign(names_1.default.errors, errsCount); |
| 1308 |
gen.if((0, codegen_1._)`${names_1.default.vErrors} !== null`, () => gen.if(errsCount, () => gen.assign((0, codegen_1._)`${names_1.default.vErrors}.length`, errsCount), () => gen.assign(names_1.default.vErrors, null))); |
| 1309 |
} |
| 1310 |
exports.resetErrorsCount = resetErrorsCount; |
| 1311 |
function extendErrors({ gen, keyword, schemaValue, data, errsCount, it }) { |
| 1312 |
if (errsCount === void 0) |
| 1313 |
throw new Error("ajv implementation error"); |
| 1314 |
const err = gen.name("err"); |
| 1315 |
gen.forRange("i", errsCount, names_1.default.errors, (i) => { |
| 1316 |
gen.const(err, (0, codegen_1._)`${names_1.default.vErrors}[${i}]`); |
| 1317 |
gen.if((0, codegen_1._)`${err}.instancePath === undefined`, () => gen.assign((0, codegen_1._)`${err}.instancePath`, (0, codegen_1.strConcat)(names_1.default.instancePath, it.errorPath))); |
| 1318 |
gen.assign((0, codegen_1._)`${err}.schemaPath`, (0, codegen_1.str)`${it.errSchemaPath}/${keyword}`); |
| 1319 |
if (it.opts.verbose) { |
| 1320 |
gen.assign((0, codegen_1._)`${err}.schema`, schemaValue); |
| 1321 |
gen.assign((0, codegen_1._)`${err}.data`, data); |
| 1322 |
} |
| 1323 |
}); |
| 1324 |
} |
| 1325 |
exports.extendErrors = extendErrors; |
| 1326 |
function addError(gen, errObj) { |
| 1327 |
const err = gen.const("err", errObj); |
| 1328 |
gen.if((0, codegen_1._)`${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._)`[${err}]`), (0, codegen_1._)`${names_1.default.vErrors}.push(${err})`); |
| 1329 |
gen.code((0, codegen_1._)`${names_1.default.errors}++`); |
| 1330 |
} |
| 1331 |
function returnErrors(it, errs) { |
| 1332 |
const { gen, validateName, schemaEnv } = it; |
| 1333 |
if (schemaEnv.$async) { |
| 1334 |
gen.throw((0, codegen_1._)`new ${it.ValidationError}(${errs})`); |
| 1335 |
} else { |
| 1336 |
gen.assign((0, codegen_1._)`${validateName}.errors`, errs); |
| 1337 |
gen.return(false); |
| 1338 |
} |
| 1339 |
} |
| 1340 |
var E = { |
| 1341 |
keyword: new codegen_1.Name("keyword"), |
| 1342 |
schemaPath: new codegen_1.Name("schemaPath"), |
| 1343 |
// also used in JTD errors |
| 1344 |
params: new codegen_1.Name("params"), |
| 1345 |
propertyName: new codegen_1.Name("propertyName"), |
| 1346 |
message: new codegen_1.Name("message"), |
| 1347 |
schema: new codegen_1.Name("schema"), |
| 1348 |
parentSchema: new codegen_1.Name("parentSchema") |
| 1349 |
}; |
| 1350 |
function errorObjectCode(cxt, error, errorPaths) { |
| 1351 |
const { createErrors } = cxt.it; |
| 1352 |
if (createErrors === false) |
| 1353 |
return (0, codegen_1._)`{}`; |
| 1354 |
return errorObject(cxt, error, errorPaths); |
| 1355 |
} |
| 1356 |
function errorObject(cxt, error, errorPaths = {}) { |
| 1357 |
const { gen, it } = cxt; |
| 1358 |
const keyValues = [ |
| 1359 |
errorInstancePath(it, errorPaths), |
| 1360 |
errorSchemaPath(cxt, errorPaths) |
| 1361 |
]; |
| 1362 |
extraErrorProps(cxt, error, keyValues); |
| 1363 |
return gen.object(...keyValues); |
| 1364 |
} |
| 1365 |
function errorInstancePath({ errorPath }, { instancePath }) { |
| 1366 |
const instPath = instancePath ? (0, codegen_1.str)`${errorPath}${(0, util_1.getErrorPath)(instancePath, util_1.Type.Str)}` : errorPath; |
| 1367 |
return [names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, instPath)]; |
| 1368 |
} |
| 1369 |
function errorSchemaPath({ keyword, it: { errSchemaPath } }, { schemaPath, parentSchema }) { |
| 1370 |
let schPath = parentSchema ? errSchemaPath : (0, codegen_1.str)`${errSchemaPath}/${keyword}`; |
| 1371 |
if (schemaPath) { |
| 1372 |
schPath = (0, codegen_1.str)`${schPath}${(0, util_1.getErrorPath)(schemaPath, util_1.Type.Str)}`; |
| 1373 |
} |
| 1374 |
return [E.schemaPath, schPath]; |
| 1375 |
} |
| 1376 |
function extraErrorProps(cxt, { params, message }, keyValues) { |
| 1377 |
const { keyword, data, schemaValue, it } = cxt; |
| 1378 |
const { opts, propertyName, topSchemaRef, schemaPath } = it; |
| 1379 |
keyValues.push([E.keyword, keyword], [E.params, typeof params == "function" ? params(cxt) : params || (0, codegen_1._)`{}`]); |
| 1380 |
if (opts.messages) { |
| 1381 |
keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]); |
| 1382 |
} |
| 1383 |
if (opts.verbose) { |
| 1384 |
keyValues.push([E.schema, schemaValue], [E.parentSchema, (0, codegen_1._)`${topSchemaRef}${schemaPath}`], [names_1.default.data, data]); |
| 1385 |
} |
| 1386 |
if (propertyName) |
| 1387 |
keyValues.push([E.propertyName, propertyName]); |
| 1388 |
} |
| 1389 |
} |
| 1390 |
}); |
| 1391 |
|
| 1392 |
// node_modules/ajv/dist/compile/validate/boolSchema.js |
| 1393 |
var require_boolSchema = __commonJS({ |
| 1394 |
"node_modules/ajv/dist/compile/validate/boolSchema.js"(exports) { |
| 1395 |
"use strict"; |
| 1396 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1397 |
exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0; |
| 1398 |
var errors_1 = require_errors(); |
| 1399 |
var codegen_1 = require_codegen(); |
| 1400 |
var names_1 = require_names(); |
| 1401 |
var boolError = { |
| 1402 |
message: "boolean schema is false" |
| 1403 |
}; |
| 1404 |
function topBoolOrEmptySchema(it) { |
| 1405 |
const { gen, schema, validateName } = it; |
| 1406 |
if (schema === false) { |
| 1407 |
falseSchemaError(it, false); |
| 1408 |
} else if (typeof schema == "object" && schema.$async === true) { |
| 1409 |
gen.return(names_1.default.data); |
| 1410 |
} else { |
| 1411 |
gen.assign((0, codegen_1._)`${validateName}.errors`, null); |
| 1412 |
gen.return(true); |
| 1413 |
} |
| 1414 |
} |
| 1415 |
exports.topBoolOrEmptySchema = topBoolOrEmptySchema; |
| 1416 |
function boolOrEmptySchema(it, valid) { |
| 1417 |
const { gen, schema } = it; |
| 1418 |
if (schema === false) { |
| 1419 |
gen.var(valid, false); |
| 1420 |
falseSchemaError(it); |
| 1421 |
} else { |
| 1422 |
gen.var(valid, true); |
| 1423 |
} |
| 1424 |
} |
| 1425 |
exports.boolOrEmptySchema = boolOrEmptySchema; |
| 1426 |
function falseSchemaError(it, overrideAllErrors) { |
| 1427 |
const { gen, data } = it; |
| 1428 |
const cxt = { |
| 1429 |
gen, |
| 1430 |
keyword: "false schema", |
| 1431 |
data, |
| 1432 |
schema: false, |
| 1433 |
schemaCode: false, |
| 1434 |
schemaValue: false, |
| 1435 |
params: {}, |
| 1436 |
it |
| 1437 |
}; |
| 1438 |
(0, errors_1.reportError)(cxt, boolError, void 0, overrideAllErrors); |
| 1439 |
} |
| 1440 |
} |
| 1441 |
}); |
| 1442 |
|
| 1443 |
// node_modules/ajv/dist/compile/rules.js |
| 1444 |
var require_rules = __commonJS({ |
| 1445 |
"node_modules/ajv/dist/compile/rules.js"(exports) { |
| 1446 |
"use strict"; |
| 1447 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1448 |
exports.getRules = exports.isJSONType = void 0; |
| 1449 |
var _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"]; |
| 1450 |
var jsonTypes = new Set(_jsonTypes); |
| 1451 |
function isJSONType(x) { |
| 1452 |
return typeof x == "string" && jsonTypes.has(x); |
| 1453 |
} |
| 1454 |
exports.isJSONType = isJSONType; |
| 1455 |
function getRules() { |
| 1456 |
const groups = { |
| 1457 |
number: { type: "number", rules: [] }, |
| 1458 |
string: { type: "string", rules: [] }, |
| 1459 |
array: { type: "array", rules: [] }, |
| 1460 |
object: { type: "object", rules: [] } |
| 1461 |
}; |
| 1462 |
return { |
| 1463 |
types: { ...groups, integer: true, boolean: true, null: true }, |
| 1464 |
rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object], |
| 1465 |
post: { rules: [] }, |
| 1466 |
all: {}, |
| 1467 |
keywords: {} |
| 1468 |
}; |
| 1469 |
} |
| 1470 |
exports.getRules = getRules; |
| 1471 |
} |
| 1472 |
}); |
| 1473 |
|
| 1474 |
// node_modules/ajv/dist/compile/validate/applicability.js |
| 1475 |
var require_applicability = __commonJS({ |
| 1476 |
"node_modules/ajv/dist/compile/validate/applicability.js"(exports) { |
| 1477 |
"use strict"; |
| 1478 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1479 |
exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0; |
| 1480 |
function schemaHasRulesForType({ schema, self }, type) { |
| 1481 |
const group = self.RULES.types[type]; |
| 1482 |
return group && group !== true && shouldUseGroup(schema, group); |
| 1483 |
} |
| 1484 |
exports.schemaHasRulesForType = schemaHasRulesForType; |
| 1485 |
function shouldUseGroup(schema, group) { |
| 1486 |
return group.rules.some((rule) => shouldUseRule(schema, rule)); |
| 1487 |
} |
| 1488 |
exports.shouldUseGroup = shouldUseGroup; |
| 1489 |
function shouldUseRule(schema, rule) { |
| 1490 |
var _a; |
| 1491 |
return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0)); |
| 1492 |
} |
| 1493 |
exports.shouldUseRule = shouldUseRule; |
| 1494 |
} |
| 1495 |
}); |
| 1496 |
|
| 1497 |
// node_modules/ajv/dist/compile/validate/dataType.js |
| 1498 |
var require_dataType = __commonJS({ |
| 1499 |
"node_modules/ajv/dist/compile/validate/dataType.js"(exports) { |
| 1500 |
"use strict"; |
| 1501 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1502 |
exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0; |
| 1503 |
var rules_1 = require_rules(); |
| 1504 |
var applicability_1 = require_applicability(); |
| 1505 |
var errors_1 = require_errors(); |
| 1506 |
var codegen_1 = require_codegen(); |
| 1507 |
var util_1 = require_util(); |
| 1508 |
var DataType; |
| 1509 |
(function(DataType2) { |
| 1510 |
DataType2[DataType2["Correct"] = 0] = "Correct"; |
| 1511 |
DataType2[DataType2["Wrong"] = 1] = "Wrong"; |
| 1512 |
})(DataType || (exports.DataType = DataType = {})); |
| 1513 |
function getSchemaTypes(schema) { |
| 1514 |
const types = getJSONTypes(schema.type); |
| 1515 |
const hasNull = types.includes("null"); |
| 1516 |
if (hasNull) { |
| 1517 |
if (schema.nullable === false) |
| 1518 |
throw new Error("type: null contradicts nullable: false"); |
| 1519 |
} else { |
| 1520 |
if (!types.length && schema.nullable !== void 0) { |
| 1521 |
throw new Error('"nullable" cannot be used without "type"'); |
| 1522 |
} |
| 1523 |
if (schema.nullable === true) |
| 1524 |
types.push("null"); |
| 1525 |
} |
| 1526 |
return types; |
| 1527 |
} |
| 1528 |
exports.getSchemaTypes = getSchemaTypes; |
| 1529 |
function getJSONTypes(ts) { |
| 1530 |
const types = Array.isArray(ts) ? ts : ts ? [ts] : []; |
| 1531 |
if (types.every(rules_1.isJSONType)) |
| 1532 |
return types; |
| 1533 |
throw new Error("type must be JSONType or JSONType[]: " + types.join(",")); |
| 1534 |
} |
| 1535 |
exports.getJSONTypes = getJSONTypes; |
| 1536 |
function coerceAndCheckDataType(it, types) { |
| 1537 |
const { gen, data, opts } = it; |
| 1538 |
const coerceTo = coerceToTypes(types, opts.coerceTypes); |
| 1539 |
const checkTypes = types.length > 0 && !(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0])); |
| 1540 |
if (checkTypes) { |
| 1541 |
const wrongType = checkDataTypes(types, data, opts.strictNumbers, DataType.Wrong); |
| 1542 |
gen.if(wrongType, () => { |
| 1543 |
if (coerceTo.length) |
| 1544 |
coerceData(it, types, coerceTo); |
| 1545 |
else |
| 1546 |
reportTypeError(it); |
| 1547 |
}); |
| 1548 |
} |
| 1549 |
return checkTypes; |
| 1550 |
} |
| 1551 |
exports.coerceAndCheckDataType = coerceAndCheckDataType; |
| 1552 |
var COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]); |
| 1553 |
function coerceToTypes(types, coerceTypes) { |
| 1554 |
return coerceTypes ? types.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : []; |
| 1555 |
} |
| 1556 |
function coerceData(it, types, coerceTo) { |
| 1557 |
const { gen, data, opts } = it; |
| 1558 |
const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data}`); |
| 1559 |
const coerced = gen.let("coerced", (0, codegen_1._)`undefined`); |
| 1560 |
if (opts.coerceTypes === "array") { |
| 1561 |
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types, data, opts.strictNumbers), () => gen.assign(coerced, data))); |
| 1562 |
} |
| 1563 |
gen.if((0, codegen_1._)`${coerced} !== undefined`); |
| 1564 |
for (const t of coerceTo) { |
| 1565 |
if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") { |
| 1566 |
coerceSpecificType(t); |
| 1567 |
} |
| 1568 |
} |
| 1569 |
gen.else(); |
| 1570 |
reportTypeError(it); |
| 1571 |
gen.endIf(); |
| 1572 |
gen.if((0, codegen_1._)`${coerced} !== undefined`, () => { |
| 1573 |
gen.assign(data, coerced); |
| 1574 |
assignParentData(it, coerced); |
| 1575 |
}); |
| 1576 |
function coerceSpecificType(t) { |
| 1577 |
switch (t) { |
| 1578 |
case "string": |
| 1579 |
gen.elseIf((0, codegen_1._)`${dataType} == "number" || ${dataType} == "boolean"`).assign(coerced, (0, codegen_1._)`"" + ${data}`).elseIf((0, codegen_1._)`${data} === null`).assign(coerced, (0, codegen_1._)`""`); |
| 1580 |
return; |
| 1581 |
case "number": |
| 1582 |
gen.elseIf((0, codegen_1._)`${dataType} == "boolean" || ${data} === null |
| 1583 |
|| (${dataType} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1._)`+${data}`); |
| 1584 |
return; |
| 1585 |
case "integer": |
| 1586 |
gen.elseIf((0, codegen_1._)`${dataType} === "boolean" || ${data} === null |
| 1587 |
|| (${dataType} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1._)`+${data}`); |
| 1588 |
return; |
| 1589 |
case "boolean": |
| 1590 |
gen.elseIf((0, codegen_1._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1._)`${data} === "true" || ${data} === 1`).assign(coerced, true); |
| 1591 |
return; |
| 1592 |
case "null": |
| 1593 |
gen.elseIf((0, codegen_1._)`${data} === "" || ${data} === 0 || ${data} === false`); |
| 1594 |
gen.assign(coerced, null); |
| 1595 |
return; |
| 1596 |
case "array": |
| 1597 |
gen.elseIf((0, codegen_1._)`${dataType} === "string" || ${dataType} === "number" |
| 1598 |
|| ${dataType} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1._)`[${data}]`); |
| 1599 |
} |
| 1600 |
} |
| 1601 |
} |
| 1602 |
function assignParentData({ gen, parentData, parentDataProperty }, expr) { |
| 1603 |
gen.if((0, codegen_1._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1._)`${parentData}[${parentDataProperty}]`, expr)); |
| 1604 |
} |
| 1605 |
function checkDataType(dataType, data, strictNums, correct = DataType.Correct) { |
| 1606 |
const EQ = correct === DataType.Correct ? codegen_1.operators.EQ : codegen_1.operators.NEQ; |
| 1607 |
let cond; |
| 1608 |
switch (dataType) { |
| 1609 |
case "null": |
| 1610 |
return (0, codegen_1._)`${data} ${EQ} null`; |
| 1611 |
case "array": |
| 1612 |
cond = (0, codegen_1._)`Array.isArray(${data})`; |
| 1613 |
break; |
| 1614 |
case "object": |
| 1615 |
cond = (0, codegen_1._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`; |
| 1616 |
break; |
| 1617 |
case "integer": |
| 1618 |
cond = numCond((0, codegen_1._)`!(${data} % 1) && !isNaN(${data})`); |
| 1619 |
break; |
| 1620 |
case "number": |
| 1621 |
cond = numCond(); |
| 1622 |
break; |
| 1623 |
default: |
| 1624 |
return (0, codegen_1._)`typeof ${data} ${EQ} ${dataType}`; |
| 1625 |
} |
| 1626 |
return correct === DataType.Correct ? cond : (0, codegen_1.not)(cond); |
| 1627 |
function numCond(_cond = codegen_1.nil) { |
| 1628 |
return (0, codegen_1.and)((0, codegen_1._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1._)`isFinite(${data})` : codegen_1.nil); |
| 1629 |
} |
| 1630 |
} |
| 1631 |
exports.checkDataType = checkDataType; |
| 1632 |
function checkDataTypes(dataTypes, data, strictNums, correct) { |
| 1633 |
if (dataTypes.length === 1) { |
| 1634 |
return checkDataType(dataTypes[0], data, strictNums, correct); |
| 1635 |
} |
| 1636 |
let cond; |
| 1637 |
const types = (0, util_1.toHash)(dataTypes); |
| 1638 |
if (types.array && types.object) { |
| 1639 |
const notObj = (0, codegen_1._)`typeof ${data} != "object"`; |
| 1640 |
cond = types.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`; |
| 1641 |
delete types.null; |
| 1642 |
delete types.array; |
| 1643 |
delete types.object; |
| 1644 |
} else { |
| 1645 |
cond = codegen_1.nil; |
| 1646 |
} |
| 1647 |
if (types.number) |
| 1648 |
delete types.integer; |
| 1649 |
for (const t in types) |
| 1650 |
cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct)); |
| 1651 |
return cond; |
| 1652 |
} |
| 1653 |
exports.checkDataTypes = checkDataTypes; |
| 1654 |
var typeError = { |
| 1655 |
message: ({ schema }) => `must be ${schema}`, |
| 1656 |
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1._)`{type: ${schema}}` : (0, codegen_1._)`{type: ${schemaValue}}` |
| 1657 |
}; |
| 1658 |
function reportTypeError(it) { |
| 1659 |
const cxt = getTypeErrorContext(it); |
| 1660 |
(0, errors_1.reportError)(cxt, typeError); |
| 1661 |
} |
| 1662 |
exports.reportTypeError = reportTypeError; |
| 1663 |
function getTypeErrorContext(it) { |
| 1664 |
const { gen, data, schema } = it; |
| 1665 |
const schemaCode = (0, util_1.schemaRefOrVal)(it, schema, "type"); |
| 1666 |
return { |
| 1667 |
gen, |
| 1668 |
keyword: "type", |
| 1669 |
data, |
| 1670 |
schema: schema.type, |
| 1671 |
schemaCode, |
| 1672 |
schemaValue: schemaCode, |
| 1673 |
parentSchema: schema, |
| 1674 |
params: {}, |
| 1675 |
it |
| 1676 |
}; |
| 1677 |
} |
| 1678 |
} |
| 1679 |
}); |
| 1680 |
|
| 1681 |
// node_modules/ajv/dist/compile/validate/defaults.js |
| 1682 |
var require_defaults = __commonJS({ |
| 1683 |
"node_modules/ajv/dist/compile/validate/defaults.js"(exports) { |
| 1684 |
"use strict"; |
| 1685 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1686 |
exports.assignDefaults = void 0; |
| 1687 |
var codegen_1 = require_codegen(); |
| 1688 |
var util_1 = require_util(); |
| 1689 |
function assignDefaults(it, ty) { |
| 1690 |
const { properties, items } = it.schema; |
| 1691 |
if (ty === "object" && properties) { |
| 1692 |
for (const key in properties) { |
| 1693 |
assignDefault(it, key, properties[key].default); |
| 1694 |
} |
| 1695 |
} else if (ty === "array" && Array.isArray(items)) { |
| 1696 |
items.forEach((sch, i) => assignDefault(it, i, sch.default)); |
| 1697 |
} |
| 1698 |
} |
| 1699 |
exports.assignDefaults = assignDefaults; |
| 1700 |
function assignDefault(it, prop, defaultValue) { |
| 1701 |
const { gen, compositeRule, data, opts } = it; |
| 1702 |
if (defaultValue === void 0) |
| 1703 |
return; |
| 1704 |
const childData = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(prop)}`; |
| 1705 |
if (compositeRule) { |
| 1706 |
(0, util_1.checkStrictMode)(it, `default is ignored for: ${childData}`); |
| 1707 |
return; |
| 1708 |
} |
| 1709 |
let condition = (0, codegen_1._)`${childData} === undefined`; |
| 1710 |
if (opts.useDefaults === "empty") { |
| 1711 |
condition = (0, codegen_1._)`${condition} || ${childData} === null || ${childData} === ""`; |
| 1712 |
} |
| 1713 |
gen.if(condition, (0, codegen_1._)`${childData} = ${(0, codegen_1.stringify)(defaultValue)}`); |
| 1714 |
} |
| 1715 |
} |
| 1716 |
}); |
| 1717 |
|
| 1718 |
// node_modules/ajv/dist/vocabularies/code.js |
| 1719 |
var require_code2 = __commonJS({ |
| 1720 |
"node_modules/ajv/dist/vocabularies/code.js"(exports) { |
| 1721 |
"use strict"; |
| 1722 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1723 |
exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0; |
| 1724 |
var codegen_1 = require_codegen(); |
| 1725 |
var util_1 = require_util(); |
| 1726 |
var names_1 = require_names(); |
| 1727 |
var util_2 = require_util(); |
| 1728 |
function checkReportMissingProp(cxt, prop) { |
| 1729 |
const { gen, data, it } = cxt; |
| 1730 |
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => { |
| 1731 |
cxt.setParams({ missingProperty: (0, codegen_1._)`${prop}` }, true); |
| 1732 |
cxt.error(); |
| 1733 |
}); |
| 1734 |
} |
| 1735 |
exports.checkReportMissingProp = checkReportMissingProp; |
| 1736 |
function checkMissingProp({ gen, data, it: { opts } }, properties, missing) { |
| 1737 |
return (0, codegen_1.or)(...properties.map((prop) => (0, codegen_1.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1._)`${missing} = ${prop}`))); |
| 1738 |
} |
| 1739 |
exports.checkMissingProp = checkMissingProp; |
| 1740 |
function reportMissingProp(cxt, missing) { |
| 1741 |
cxt.setParams({ missingProperty: missing }, true); |
| 1742 |
cxt.error(); |
| 1743 |
} |
| 1744 |
exports.reportMissingProp = reportMissingProp; |
| 1745 |
function hasPropFunc(gen) { |
| 1746 |
return gen.scopeValue("func", { |
| 1747 |
// eslint-disable-next-line @typescript-eslint/unbound-method |
| 1748 |
ref: Object.prototype.hasOwnProperty, |
| 1749 |
code: (0, codegen_1._)`Object.prototype.hasOwnProperty` |
| 1750 |
}); |
| 1751 |
} |
| 1752 |
exports.hasPropFunc = hasPropFunc; |
| 1753 |
function isOwnProperty(gen, data, property) { |
| 1754 |
return (0, codegen_1._)`${hasPropFunc(gen)}.call(${data}, ${property})`; |
| 1755 |
} |
| 1756 |
exports.isOwnProperty = isOwnProperty; |
| 1757 |
function propertyInData(gen, data, property, ownProperties) { |
| 1758 |
const cond = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(property)} !== undefined`; |
| 1759 |
return ownProperties ? (0, codegen_1._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond; |
| 1760 |
} |
| 1761 |
exports.propertyInData = propertyInData; |
| 1762 |
function noPropertyInData(gen, data, property, ownProperties) { |
| 1763 |
const cond = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(property)} === undefined`; |
| 1764 |
return ownProperties ? (0, codegen_1.or)(cond, (0, codegen_1.not)(isOwnProperty(gen, data, property))) : cond; |
| 1765 |
} |
| 1766 |
exports.noPropertyInData = noPropertyInData; |
| 1767 |
function allSchemaProperties(schemaMap) { |
| 1768 |
return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : []; |
| 1769 |
} |
| 1770 |
exports.allSchemaProperties = allSchemaProperties; |
| 1771 |
function schemaProperties(it, schemaMap) { |
| 1772 |
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p])); |
| 1773 |
} |
| 1774 |
exports.schemaProperties = schemaProperties; |
| 1775 |
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) { |
| 1776 |
const dataAndSchema = passSchema ? (0, codegen_1._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data; |
| 1777 |
const valCxt = [ |
| 1778 |
[names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, errorPath)], |
| 1779 |
[names_1.default.parentData, it.parentData], |
| 1780 |
[names_1.default.parentDataProperty, it.parentDataProperty], |
| 1781 |
[names_1.default.rootData, names_1.default.rootData] |
| 1782 |
]; |
| 1783 |
if (it.opts.dynamicRef) |
| 1784 |
valCxt.push([names_1.default.dynamicAnchors, names_1.default.dynamicAnchors]); |
| 1785 |
const args = (0, codegen_1._)`${dataAndSchema}, ${gen.object(...valCxt)}`; |
| 1786 |
return context !== codegen_1.nil ? (0, codegen_1._)`${func}.call(${context}, ${args})` : (0, codegen_1._)`${func}(${args})`; |
| 1787 |
} |
| 1788 |
exports.callValidateCode = callValidateCode; |
| 1789 |
var newRegExp = (0, codegen_1._)`new RegExp`; |
| 1790 |
function usePattern({ gen, it: { opts } }, pattern) { |
| 1791 |
const u = opts.unicodeRegExp ? "u" : ""; |
| 1792 |
const { regExp } = opts.code; |
| 1793 |
const rx = regExp(pattern, u); |
| 1794 |
return gen.scopeValue("pattern", { |
| 1795 |
key: rx.toString(), |
| 1796 |
ref: rx, |
| 1797 |
code: (0, codegen_1._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2.useFunc)(gen, regExp)}(${pattern}, ${u})` |
| 1798 |
}); |
| 1799 |
} |
| 1800 |
exports.usePattern = usePattern; |
| 1801 |
function validateArray(cxt) { |
| 1802 |
const { gen, data, keyword, it } = cxt; |
| 1803 |
const valid = gen.name("valid"); |
| 1804 |
if (it.allErrors) { |
| 1805 |
const validArr = gen.let("valid", true); |
| 1806 |
validateItems(() => gen.assign(validArr, false)); |
| 1807 |
return validArr; |
| 1808 |
} |
| 1809 |
gen.var(valid, true); |
| 1810 |
validateItems(() => gen.break()); |
| 1811 |
return valid; |
| 1812 |
function validateItems(notValid) { |
| 1813 |
const len = gen.const("len", (0, codegen_1._)`${data}.length`); |
| 1814 |
gen.forRange("i", 0, len, (i) => { |
| 1815 |
cxt.subschema({ |
| 1816 |
keyword, |
| 1817 |
dataProp: i, |
| 1818 |
dataPropType: util_1.Type.Num |
| 1819 |
}, valid); |
| 1820 |
gen.if((0, codegen_1.not)(valid), notValid); |
| 1821 |
}); |
| 1822 |
} |
| 1823 |
} |
| 1824 |
exports.validateArray = validateArray; |
| 1825 |
function validateUnion(cxt) { |
| 1826 |
const { gen, schema, keyword, it } = cxt; |
| 1827 |
if (!Array.isArray(schema)) |
| 1828 |
throw new Error("ajv implementation error"); |
| 1829 |
const alwaysValid = schema.some((sch) => (0, util_1.alwaysValidSchema)(it, sch)); |
| 1830 |
if (alwaysValid && !it.opts.unevaluated) |
| 1831 |
return; |
| 1832 |
const valid = gen.let("valid", false); |
| 1833 |
const schValid = gen.name("_valid"); |
| 1834 |
gen.block(() => schema.forEach((_sch, i) => { |
| 1835 |
const schCxt = cxt.subschema({ |
| 1836 |
keyword, |
| 1837 |
schemaProp: i, |
| 1838 |
compositeRule: true |
| 1839 |
}, schValid); |
| 1840 |
gen.assign(valid, (0, codegen_1._)`${valid} || ${schValid}`); |
| 1841 |
const merged = cxt.mergeValidEvaluated(schCxt, schValid); |
| 1842 |
if (!merged) |
| 1843 |
gen.if((0, codegen_1.not)(valid)); |
| 1844 |
})); |
| 1845 |
cxt.result(valid, () => cxt.reset(), () => cxt.error(true)); |
| 1846 |
} |
| 1847 |
exports.validateUnion = validateUnion; |
| 1848 |
} |
| 1849 |
}); |
| 1850 |
|
| 1851 |
// node_modules/ajv/dist/compile/validate/keyword.js |
| 1852 |
var require_keyword = __commonJS({ |
| 1853 |
"node_modules/ajv/dist/compile/validate/keyword.js"(exports) { |
| 1854 |
"use strict"; |
| 1855 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1856 |
exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0; |
| 1857 |
var codegen_1 = require_codegen(); |
| 1858 |
var names_1 = require_names(); |
| 1859 |
var code_1 = require_code2(); |
| 1860 |
var errors_1 = require_errors(); |
| 1861 |
function macroKeywordCode(cxt, def) { |
| 1862 |
const { gen, keyword, schema, parentSchema, it } = cxt; |
| 1863 |
const macroSchema = def.macro.call(it.self, schema, parentSchema, it); |
| 1864 |
const schemaRef = useKeyword(gen, keyword, macroSchema); |
| 1865 |
if (it.opts.validateSchema !== false) |
| 1866 |
it.self.validateSchema(macroSchema, true); |
| 1867 |
const valid = gen.name("valid"); |
| 1868 |
cxt.subschema({ |
| 1869 |
schema: macroSchema, |
| 1870 |
schemaPath: codegen_1.nil, |
| 1871 |
errSchemaPath: `${it.errSchemaPath}/${keyword}`, |
| 1872 |
topSchemaRef: schemaRef, |
| 1873 |
compositeRule: true |
| 1874 |
}, valid); |
| 1875 |
cxt.pass(valid, () => cxt.error(true)); |
| 1876 |
} |
| 1877 |
exports.macroKeywordCode = macroKeywordCode; |
| 1878 |
function funcKeywordCode(cxt, def) { |
| 1879 |
var _a; |
| 1880 |
const { gen, keyword, schema, parentSchema, $data, it } = cxt; |
| 1881 |
checkAsyncKeyword(it, def); |
| 1882 |
const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate; |
| 1883 |
const validateRef = useKeyword(gen, keyword, validate); |
| 1884 |
const valid = gen.let("valid"); |
| 1885 |
cxt.block$data(valid, validateKeyword); |
| 1886 |
cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid); |
| 1887 |
function validateKeyword() { |
| 1888 |
if (def.errors === false) { |
| 1889 |
assignValid(); |
| 1890 |
if (def.modifying) |
| 1891 |
modifyData(cxt); |
| 1892 |
reportErrs(() => cxt.error()); |
| 1893 |
} else { |
| 1894 |
const ruleErrs = def.async ? validateAsync() : validateSync(); |
| 1895 |
if (def.modifying) |
| 1896 |
modifyData(cxt); |
| 1897 |
reportErrs(() => addErrs(cxt, ruleErrs)); |
| 1898 |
} |
| 1899 |
} |
| 1900 |
function validateAsync() { |
| 1901 |
const ruleErrs = gen.let("ruleErrs", null); |
| 1902 |
gen.try(() => assignValid((0, codegen_1._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1._)`${e}.errors`), () => gen.throw(e))); |
| 1903 |
return ruleErrs; |
| 1904 |
} |
| 1905 |
function validateSync() { |
| 1906 |
const validateErrs = (0, codegen_1._)`${validateRef}.errors`; |
| 1907 |
gen.assign(validateErrs, null); |
| 1908 |
assignValid(codegen_1.nil); |
| 1909 |
return validateErrs; |
| 1910 |
} |
| 1911 |
function assignValid(_await = def.async ? (0, codegen_1._)`await ` : codegen_1.nil) { |
| 1912 |
const passCxt = it.opts.passContext ? names_1.default.this : names_1.default.self; |
| 1913 |
const passSchema = !("compile" in def && !$data || def.schema === false); |
| 1914 |
gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying); |
| 1915 |
} |
| 1916 |
function reportErrs(errors) { |
| 1917 |
var _a2; |
| 1918 |
gen.if((0, codegen_1.not)((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors); |
| 1919 |
} |
| 1920 |
} |
| 1921 |
exports.funcKeywordCode = funcKeywordCode; |
| 1922 |
function modifyData(cxt) { |
| 1923 |
const { gen, data, it } = cxt; |
| 1924 |
gen.if(it.parentData, () => gen.assign(data, (0, codegen_1._)`${it.parentData}[${it.parentDataProperty}]`)); |
| 1925 |
} |
| 1926 |
function addErrs(cxt, errs) { |
| 1927 |
const { gen } = cxt; |
| 1928 |
gen.if((0, codegen_1._)`Array.isArray(${errs})`, () => { |
| 1929 |
gen.assign(names_1.default.vErrors, (0, codegen_1._)`${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`).assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`); |
| 1930 |
(0, errors_1.extendErrors)(cxt); |
| 1931 |
}, () => cxt.error()); |
| 1932 |
} |
| 1933 |
function checkAsyncKeyword({ schemaEnv }, def) { |
| 1934 |
if (def.async && !schemaEnv.$async) |
| 1935 |
throw new Error("async keyword in sync schema"); |
| 1936 |
} |
| 1937 |
function useKeyword(gen, keyword, result) { |
| 1938 |
if (result === void 0) |
| 1939 |
throw new Error(`keyword "${keyword}" failed to compile`); |
| 1940 |
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1.stringify)(result) }); |
| 1941 |
} |
| 1942 |
function validSchemaType(schema, schemaType, allowUndefined = false) { |
| 1943 |
return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined"); |
| 1944 |
} |
| 1945 |
exports.validSchemaType = validSchemaType; |
| 1946 |
function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def, keyword) { |
| 1947 |
if (Array.isArray(def.keyword) ? !def.keyword.includes(keyword) : def.keyword !== keyword) { |
| 1948 |
throw new Error("ajv implementation error"); |
| 1949 |
} |
| 1950 |
const deps = def.dependencies; |
| 1951 |
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) { |
| 1952 |
throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`); |
| 1953 |
} |
| 1954 |
if (def.validateSchema) { |
| 1955 |
const valid = def.validateSchema(schema[keyword]); |
| 1956 |
if (!valid) { |
| 1957 |
const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def.validateSchema.errors); |
| 1958 |
if (opts.validateSchema === "log") |
| 1959 |
self.logger.error(msg); |
| 1960 |
else |
| 1961 |
throw new Error(msg); |
| 1962 |
} |
| 1963 |
} |
| 1964 |
} |
| 1965 |
exports.validateKeywordUsage = validateKeywordUsage; |
| 1966 |
} |
| 1967 |
}); |
| 1968 |
|
| 1969 |
// node_modules/ajv/dist/compile/validate/subschema.js |
| 1970 |
var require_subschema = __commonJS({ |
| 1971 |
"node_modules/ajv/dist/compile/validate/subschema.js"(exports) { |
| 1972 |
"use strict"; |
| 1973 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 1974 |
exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0; |
| 1975 |
var codegen_1 = require_codegen(); |
| 1976 |
var util_1 = require_util(); |
| 1977 |
function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) { |
| 1978 |
if (keyword !== void 0 && schema !== void 0) { |
| 1979 |
throw new Error('both "keyword" and "schema" passed, only one allowed'); |
| 1980 |
} |
| 1981 |
if (keyword !== void 0) { |
| 1982 |
const sch = it.schema[keyword]; |
| 1983 |
return schemaProp === void 0 ? { |
| 1984 |
schema: sch, |
| 1985 |
schemaPath: (0, codegen_1._)`${it.schemaPath}${(0, codegen_1.getProperty)(keyword)}`, |
| 1986 |
errSchemaPath: `${it.errSchemaPath}/${keyword}` |
| 1987 |
} : { |
| 1988 |
schema: sch[schemaProp], |
| 1989 |
schemaPath: (0, codegen_1._)`${it.schemaPath}${(0, codegen_1.getProperty)(keyword)}${(0, codegen_1.getProperty)(schemaProp)}`, |
| 1990 |
errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1.escapeFragment)(schemaProp)}` |
| 1991 |
}; |
| 1992 |
} |
| 1993 |
if (schema !== void 0) { |
| 1994 |
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) { |
| 1995 |
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"'); |
| 1996 |
} |
| 1997 |
return { |
| 1998 |
schema, |
| 1999 |
schemaPath, |
| 2000 |
topSchemaRef, |
| 2001 |
errSchemaPath |
| 2002 |
}; |
| 2003 |
} |
| 2004 |
throw new Error('either "keyword" or "schema" must be passed'); |
| 2005 |
} |
| 2006 |
exports.getSubschema = getSubschema; |
| 2007 |
function extendSubschemaData(subschema, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) { |
| 2008 |
if (data !== void 0 && dataProp !== void 0) { |
| 2009 |
throw new Error('both "data" and "dataProp" passed, only one allowed'); |
| 2010 |
} |
| 2011 |
const { gen } = it; |
| 2012 |
if (dataProp !== void 0) { |
| 2013 |
const { errorPath, dataPathArr, opts } = it; |
| 2014 |
const nextData = gen.let("data", (0, codegen_1._)`${it.data}${(0, codegen_1.getProperty)(dataProp)}`, true); |
| 2015 |
dataContextProps(nextData); |
| 2016 |
subschema.errorPath = (0, codegen_1.str)`${errorPath}${(0, util_1.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`; |
| 2017 |
subschema.parentDataProperty = (0, codegen_1._)`${dataProp}`; |
| 2018 |
subschema.dataPathArr = [...dataPathArr, subschema.parentDataProperty]; |
| 2019 |
} |
| 2020 |
if (data !== void 0) { |
| 2021 |
const nextData = data instanceof codegen_1.Name ? data : gen.let("data", data, true); |
| 2022 |
dataContextProps(nextData); |
| 2023 |
if (propertyName !== void 0) |
| 2024 |
subschema.propertyName = propertyName; |
| 2025 |
} |
| 2026 |
if (dataTypes) |
| 2027 |
subschema.dataTypes = dataTypes; |
| 2028 |
function dataContextProps(_nextData) { |
| 2029 |
subschema.data = _nextData; |
| 2030 |
subschema.dataLevel = it.dataLevel + 1; |
| 2031 |
subschema.dataTypes = []; |
| 2032 |
it.definedProperties = /* @__PURE__ */ new Set(); |
| 2033 |
subschema.parentData = it.data; |
| 2034 |
subschema.dataNames = [...it.dataNames, _nextData]; |
| 2035 |
} |
| 2036 |
} |
| 2037 |
exports.extendSubschemaData = extendSubschemaData; |
| 2038 |
function extendSubschemaMode(subschema, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) { |
| 2039 |
if (compositeRule !== void 0) |
| 2040 |
subschema.compositeRule = compositeRule; |
| 2041 |
if (createErrors !== void 0) |
| 2042 |
subschema.createErrors = createErrors; |
| 2043 |
if (allErrors !== void 0) |
| 2044 |
subschema.allErrors = allErrors; |
| 2045 |
subschema.jtdDiscriminator = jtdDiscriminator; |
| 2046 |
subschema.jtdMetadata = jtdMetadata; |
| 2047 |
} |
| 2048 |
exports.extendSubschemaMode = extendSubschemaMode; |
| 2049 |
} |
| 2050 |
}); |
| 2051 |
|
| 2052 |
// node_modules/fast-deep-equal/index.js |
| 2053 |
var require_fast_deep_equal = __commonJS({ |
| 2054 |
"node_modules/fast-deep-equal/index.js"(exports, module) { |
| 2055 |
"use strict"; |
| 2056 |
module.exports = function equal(a, b) { |
| 2057 |
if (a === b) return true; |
| 2058 |
if (a && b && typeof a == "object" && typeof b == "object") { |
| 2059 |
if (a.constructor !== b.constructor) return false; |
| 2060 |
var length, i, keys; |
| 2061 |
if (Array.isArray(a)) { |
| 2062 |
length = a.length; |
| 2063 |
if (length != b.length) return false; |
| 2064 |
for (i = length; i-- !== 0; ) |
| 2065 |
if (!equal(a[i], b[i])) return false; |
| 2066 |
return true; |
| 2067 |
} |
| 2068 |
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; |
| 2069 |
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); |
| 2070 |
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); |
| 2071 |
keys = Object.keys(a); |
| 2072 |
length = keys.length; |
| 2073 |
if (length !== Object.keys(b).length) return false; |
| 2074 |
for (i = length; i-- !== 0; ) |
| 2075 |
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; |
| 2076 |
for (i = length; i-- !== 0; ) { |
| 2077 |
var key = keys[i]; |
| 2078 |
if (!equal(a[key], b[key])) return false; |
| 2079 |
} |
| 2080 |
return true; |
| 2081 |
} |
| 2082 |
return a !== a && b !== b; |
| 2083 |
}; |
| 2084 |
} |
| 2085 |
}); |
| 2086 |
|
| 2087 |
// node_modules/ajv/node_modules/json-schema-traverse/index.js |
| 2088 |
var require_json_schema_traverse = __commonJS({ |
| 2089 |
"node_modules/ajv/node_modules/json-schema-traverse/index.js"(exports, module) { |
| 2090 |
"use strict"; |
| 2091 |
var traverse = module.exports = function(schema, opts, cb) { |
| 2092 |
if (typeof opts == "function") { |
| 2093 |
cb = opts; |
| 2094 |
opts = {}; |
| 2095 |
} |
| 2096 |
cb = opts.cb || cb; |
| 2097 |
var pre = typeof cb == "function" ? cb : cb.pre || function() { |
| 2098 |
}; |
| 2099 |
var post = cb.post || function() { |
| 2100 |
}; |
| 2101 |
_traverse(opts, pre, post, schema, "", schema); |
| 2102 |
}; |
| 2103 |
traverse.keywords = { |
| 2104 |
additionalItems: true, |
| 2105 |
items: true, |
| 2106 |
contains: true, |
| 2107 |
additionalProperties: true, |
| 2108 |
propertyNames: true, |
| 2109 |
not: true, |
| 2110 |
if: true, |
| 2111 |
then: true, |
| 2112 |
else: true |
| 2113 |
}; |
| 2114 |
traverse.arrayKeywords = { |
| 2115 |
items: true, |
| 2116 |
allOf: true, |
| 2117 |
anyOf: true, |
| 2118 |
oneOf: true |
| 2119 |
}; |
| 2120 |
traverse.propsKeywords = { |
| 2121 |
$defs: true, |
| 2122 |
definitions: true, |
| 2123 |
properties: true, |
| 2124 |
patternProperties: true, |
| 2125 |
dependencies: true |
| 2126 |
}; |
| 2127 |
traverse.skipKeywords = { |
| 2128 |
default: true, |
| 2129 |
enum: true, |
| 2130 |
const: true, |
| 2131 |
required: true, |
| 2132 |
maximum: true, |
| 2133 |
minimum: true, |
| 2134 |
exclusiveMaximum: true, |
| 2135 |
exclusiveMinimum: true, |
| 2136 |
multipleOf: true, |
| 2137 |
maxLength: true, |
| 2138 |
minLength: true, |
| 2139 |
pattern: true, |
| 2140 |
format: true, |
| 2141 |
maxItems: true, |
| 2142 |
minItems: true, |
| 2143 |
uniqueItems: true, |
| 2144 |
maxProperties: true, |
| 2145 |
minProperties: true |
| 2146 |
}; |
| 2147 |
function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) { |
| 2148 |
if (schema && typeof schema == "object" && !Array.isArray(schema)) { |
| 2149 |
pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex); |
| 2150 |
for (var key in schema) { |
| 2151 |
var sch = schema[key]; |
| 2152 |
if (Array.isArray(sch)) { |
| 2153 |
if (key in traverse.arrayKeywords) { |
| 2154 |
for (var i = 0; i < sch.length; i++) |
| 2155 |
_traverse(opts, pre, post, sch[i], jsonPtr + "/" + key + "/" + i, rootSchema, jsonPtr, key, schema, i); |
| 2156 |
} |
| 2157 |
} else if (key in traverse.propsKeywords) { |
| 2158 |
if (sch && typeof sch == "object") { |
| 2159 |
for (var prop in sch) |
| 2160 |
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop); |
| 2161 |
} |
| 2162 |
} else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) { |
| 2163 |
_traverse(opts, pre, post, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema); |
| 2164 |
} |
| 2165 |
} |
| 2166 |
post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex); |
| 2167 |
} |
| 2168 |
} |
| 2169 |
function escapeJsonPtr(str) { |
| 2170 |
return str.replace(/~/g, "~0").replace(/\//g, "~1"); |
| 2171 |
} |
| 2172 |
} |
| 2173 |
}); |
| 2174 |
|
| 2175 |
// node_modules/ajv/dist/compile/resolve.js |
| 2176 |
var require_resolve = __commonJS({ |
| 2177 |
"node_modules/ajv/dist/compile/resolve.js"(exports) { |
| 2178 |
"use strict"; |
| 2179 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 2180 |
exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0; |
| 2181 |
var util_1 = require_util(); |
| 2182 |
var equal = require_fast_deep_equal(); |
| 2183 |
var traverse = require_json_schema_traverse(); |
| 2184 |
var SIMPLE_INLINED = /* @__PURE__ */ new Set([ |
| 2185 |
"type", |
| 2186 |
"format", |
| 2187 |
"pattern", |
| 2188 |
"maxLength", |
| 2189 |
"minLength", |
| 2190 |
"maxProperties", |
| 2191 |
"minProperties", |
| 2192 |
"maxItems", |
| 2193 |
"minItems", |
| 2194 |
"maximum", |
| 2195 |
"minimum", |
| 2196 |
"uniqueItems", |
| 2197 |
"multipleOf", |
| 2198 |
"required", |
| 2199 |
"enum", |
| 2200 |
"const" |
| 2201 |
]); |
| 2202 |
function inlineRef(schema, limit = true) { |
| 2203 |
if (typeof schema == "boolean") |
| 2204 |
return true; |
| 2205 |
if (limit === true) |
| 2206 |
return !hasRef(schema); |
| 2207 |
if (!limit) |
| 2208 |
return false; |
| 2209 |
return countKeys(schema) <= limit; |
| 2210 |
} |
| 2211 |
exports.inlineRef = inlineRef; |
| 2212 |
var REF_KEYWORDS = /* @__PURE__ */ new Set([ |
| 2213 |
"$ref", |
| 2214 |
"$recursiveRef", |
| 2215 |
"$recursiveAnchor", |
| 2216 |
"$dynamicRef", |
| 2217 |
"$dynamicAnchor" |
| 2218 |
]); |
| 2219 |
function hasRef(schema) { |
| 2220 |
for (const key in schema) { |
| 2221 |
if (REF_KEYWORDS.has(key)) |
| 2222 |
return true; |
| 2223 |
const sch = schema[key]; |
| 2224 |
if (Array.isArray(sch) && sch.some(hasRef)) |
| 2225 |
return true; |
| 2226 |
if (typeof sch == "object" && hasRef(sch)) |
| 2227 |
return true; |
| 2228 |
} |
| 2229 |
return false; |
| 2230 |
} |
| 2231 |
function countKeys(schema) { |
| 2232 |
let count = 0; |
| 2233 |
for (const key in schema) { |
| 2234 |
if (key === "$ref") |
| 2235 |
return Infinity; |
| 2236 |
count++; |
| 2237 |
if (SIMPLE_INLINED.has(key)) |
| 2238 |
continue; |
| 2239 |
if (typeof schema[key] == "object") { |
| 2240 |
(0, util_1.eachItem)(schema[key], (sch) => count += countKeys(sch)); |
| 2241 |
} |
| 2242 |
if (count === Infinity) |
| 2243 |
return Infinity; |
| 2244 |
} |
| 2245 |
return count; |
| 2246 |
} |
| 2247 |
function getFullPath(resolver, id = "", normalize) { |
| 2248 |
if (normalize !== false) |
| 2249 |
id = normalizeId(id); |
| 2250 |
const p = resolver.parse(id); |
| 2251 |
return _getFullPath(resolver, p); |
| 2252 |
} |
| 2253 |
exports.getFullPath = getFullPath; |
| 2254 |
function _getFullPath(resolver, p) { |
| 2255 |
const serialized = resolver.serialize(p); |
| 2256 |
return serialized.split("#")[0] + "#"; |
| 2257 |
} |
| 2258 |
exports._getFullPath = _getFullPath; |
| 2259 |
var TRAILING_SLASH_HASH = /#\/?$/; |
| 2260 |
function normalizeId(id) { |
| 2261 |
return id ? id.replace(TRAILING_SLASH_HASH, "") : ""; |
| 2262 |
} |
| 2263 |
exports.normalizeId = normalizeId; |
| 2264 |
function resolveUrl(resolver, baseId, id) { |
| 2265 |
id = normalizeId(id); |
| 2266 |
return resolver.resolve(baseId, id); |
| 2267 |
} |
| 2268 |
exports.resolveUrl = resolveUrl; |
| 2269 |
var ANCHOR = /^[a-z_][-a-z0-9._]*$/i; |
| 2270 |
function getSchemaRefs(schema, baseId) { |
| 2271 |
if (typeof schema == "boolean") |
| 2272 |
return {}; |
| 2273 |
const { schemaId, uriResolver } = this.opts; |
| 2274 |
const schId = normalizeId(schema[schemaId] || baseId); |
| 2275 |
const baseIds = { "": schId }; |
| 2276 |
const pathPrefix = getFullPath(uriResolver, schId, false); |
| 2277 |
const localRefs = {}; |
| 2278 |
const schemaRefs = /* @__PURE__ */ new Set(); |
| 2279 |
traverse(schema, { allKeys: true }, (sch, jsonPtr, _, parentJsonPtr) => { |
| 2280 |
if (parentJsonPtr === void 0) |
| 2281 |
return; |
| 2282 |
const fullPath = pathPrefix + jsonPtr; |
| 2283 |
let innerBaseId = baseIds[parentJsonPtr]; |
| 2284 |
if (typeof sch[schemaId] == "string") |
| 2285 |
innerBaseId = addRef.call(this, sch[schemaId]); |
| 2286 |
addAnchor.call(this, sch.$anchor); |
| 2287 |
addAnchor.call(this, sch.$dynamicAnchor); |
| 2288 |
baseIds[jsonPtr] = innerBaseId; |
| 2289 |
function addRef(ref) { |
| 2290 |
const _resolve = this.opts.uriResolver.resolve; |
| 2291 |
ref = normalizeId(innerBaseId ? _resolve(innerBaseId, ref) : ref); |
| 2292 |
if (schemaRefs.has(ref)) |
| 2293 |
throw ambiguos(ref); |
| 2294 |
schemaRefs.add(ref); |
| 2295 |
let schOrRef = this.refs[ref]; |
| 2296 |
if (typeof schOrRef == "string") |
| 2297 |
schOrRef = this.refs[schOrRef]; |
| 2298 |
if (typeof schOrRef == "object") { |
| 2299 |
checkAmbiguosRef(sch, schOrRef.schema, ref); |
| 2300 |
} else if (ref !== normalizeId(fullPath)) { |
| 2301 |
if (ref[0] === "#") { |
| 2302 |
checkAmbiguosRef(sch, localRefs[ref], ref); |
| 2303 |
localRefs[ref] = sch; |
| 2304 |
} else { |
| 2305 |
this.refs[ref] = fullPath; |
| 2306 |
} |
| 2307 |
} |
| 2308 |
return ref; |
| 2309 |
} |
| 2310 |
function addAnchor(anchor) { |
| 2311 |
if (typeof anchor == "string") { |
| 2312 |
if (!ANCHOR.test(anchor)) |
| 2313 |
throw new Error(`invalid anchor "${anchor}"`); |
| 2314 |
addRef.call(this, `#${anchor}`); |
| 2315 |
} |
| 2316 |
} |
| 2317 |
}); |
| 2318 |
return localRefs; |
| 2319 |
function checkAmbiguosRef(sch1, sch2, ref) { |
| 2320 |
if (sch2 !== void 0 && !equal(sch1, sch2)) |
| 2321 |
throw ambiguos(ref); |
| 2322 |
} |
| 2323 |
function ambiguos(ref) { |
| 2324 |
return new Error(`reference "${ref}" resolves to more than one schema`); |
| 2325 |
} |
| 2326 |
} |
| 2327 |
exports.getSchemaRefs = getSchemaRefs; |
| 2328 |
} |
| 2329 |
}); |
| 2330 |
|
| 2331 |
// node_modules/ajv/dist/compile/validate/index.js |
| 2332 |
var require_validate = __commonJS({ |
| 2333 |
"node_modules/ajv/dist/compile/validate/index.js"(exports) { |
| 2334 |
"use strict"; |
| 2335 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 2336 |
exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0; |
| 2337 |
var boolSchema_1 = require_boolSchema(); |
| 2338 |
var dataType_1 = require_dataType(); |
| 2339 |
var applicability_1 = require_applicability(); |
| 2340 |
var dataType_2 = require_dataType(); |
| 2341 |
var defaults_1 = require_defaults(); |
| 2342 |
var keyword_1 = require_keyword(); |
| 2343 |
var subschema_1 = require_subschema(); |
| 2344 |
var codegen_1 = require_codegen(); |
| 2345 |
var names_1 = require_names(); |
| 2346 |
var resolve_1 = require_resolve(); |
| 2347 |
var util_1 = require_util(); |
| 2348 |
var errors_1 = require_errors(); |
| 2349 |
function validateFunctionCode(it) { |
| 2350 |
if (isSchemaObj(it)) { |
| 2351 |
checkKeywords(it); |
| 2352 |
if (schemaCxtHasRules(it)) { |
| 2353 |
topSchemaObjCode(it); |
| 2354 |
return; |
| 2355 |
} |
| 2356 |
} |
| 2357 |
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it)); |
| 2358 |
} |
| 2359 |
exports.validateFunctionCode = validateFunctionCode; |
| 2360 |
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) { |
| 2361 |
if (opts.code.es5) { |
| 2362 |
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => { |
| 2363 |
gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema, opts)}`); |
| 2364 |
destructureValCxtES5(gen, opts); |
| 2365 |
gen.code(body); |
| 2366 |
}); |
| 2367 |
} else { |
| 2368 |
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body)); |
| 2369 |
} |
| 2370 |
} |
| 2371 |
function destructureValCxt(opts) { |
| 2372 |
return (0, codegen_1._)`{${names_1.default.instancePath}="", ${names_1.default.parentData}, ${names_1.default.parentDataProperty}, ${names_1.default.rootData}=${names_1.default.data}${opts.dynamicRef ? (0, codegen_1._)`, ${names_1.default.dynamicAnchors}={}` : codegen_1.nil}}={}`; |
| 2373 |
} |
| 2374 |
function destructureValCxtES5(gen, opts) { |
| 2375 |
gen.if(names_1.default.valCxt, () => { |
| 2376 |
gen.var(names_1.default.instancePath, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.instancePath}`); |
| 2377 |
gen.var(names_1.default.parentData, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.parentData}`); |
| 2378 |
gen.var(names_1.default.parentDataProperty, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.parentDataProperty}`); |
| 2379 |
gen.var(names_1.default.rootData, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.rootData}`); |
| 2380 |
if (opts.dynamicRef) |
| 2381 |
gen.var(names_1.default.dynamicAnchors, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.dynamicAnchors}`); |
| 2382 |
}, () => { |
| 2383 |
gen.var(names_1.default.instancePath, (0, codegen_1._)`""`); |
| 2384 |
gen.var(names_1.default.parentData, (0, codegen_1._)`undefined`); |
| 2385 |
gen.var(names_1.default.parentDataProperty, (0, codegen_1._)`undefined`); |
| 2386 |
gen.var(names_1.default.rootData, names_1.default.data); |
| 2387 |
if (opts.dynamicRef) |
| 2388 |
gen.var(names_1.default.dynamicAnchors, (0, codegen_1._)`{}`); |
| 2389 |
}); |
| 2390 |
} |
| 2391 |
function topSchemaObjCode(it) { |
| 2392 |
const { schema, opts, gen } = it; |
| 2393 |
validateFunction(it, () => { |
| 2394 |
if (opts.$comment && schema.$comment) |
| 2395 |
commentKeyword(it); |
| 2396 |
checkNoDefault(it); |
| 2397 |
gen.let(names_1.default.vErrors, null); |
| 2398 |
gen.let(names_1.default.errors, 0); |
| 2399 |
if (opts.unevaluated) |
| 2400 |
resetEvaluated(it); |
| 2401 |
typeAndKeywords(it); |
| 2402 |
returnResults(it); |
| 2403 |
}); |
| 2404 |
return; |
| 2405 |
} |
| 2406 |
function resetEvaluated(it) { |
| 2407 |
const { gen, validateName } = it; |
| 2408 |
it.evaluated = gen.const("evaluated", (0, codegen_1._)`${validateName}.evaluated`); |
| 2409 |
gen.if((0, codegen_1._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._)`${it.evaluated}.props`, (0, codegen_1._)`undefined`)); |
| 2410 |
gen.if((0, codegen_1._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._)`${it.evaluated}.items`, (0, codegen_1._)`undefined`)); |
| 2411 |
} |
| 2412 |
function funcSourceUrl(schema, opts) { |
| 2413 |
const schId = typeof schema == "object" && schema[opts.schemaId]; |
| 2414 |
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)`/*# sourceURL=${schId} */` : codegen_1.nil; |
| 2415 |
} |
| 2416 |
function subschemaCode(it, valid) { |
| 2417 |
if (isSchemaObj(it)) { |
| 2418 |
checkKeywords(it); |
| 2419 |
if (schemaCxtHasRules(it)) { |
| 2420 |
subSchemaObjCode(it, valid); |
| 2421 |
return; |
| 2422 |
} |
| 2423 |
} |
| 2424 |
(0, boolSchema_1.boolOrEmptySchema)(it, valid); |
| 2425 |
} |
| 2426 |
function schemaCxtHasRules({ schema, self }) { |
| 2427 |
if (typeof schema == "boolean") |
| 2428 |
return !schema; |
| 2429 |
for (const key in schema) |
| 2430 |
if (self.RULES.all[key]) |
| 2431 |
return true; |
| 2432 |
return false; |
| 2433 |
} |
| 2434 |
function isSchemaObj(it) { |
| 2435 |
return typeof it.schema != "boolean"; |
| 2436 |
} |
| 2437 |
function subSchemaObjCode(it, valid) { |
| 2438 |
const { schema, gen, opts } = it; |
| 2439 |
if (opts.$comment && schema.$comment) |
| 2440 |
commentKeyword(it); |
| 2441 |
updateContext(it); |
| 2442 |
checkAsyncSchema(it); |
| 2443 |
const errsCount = gen.const("_errs", names_1.default.errors); |
| 2444 |
typeAndKeywords(it, errsCount); |
| 2445 |
gen.var(valid, (0, codegen_1._)`${errsCount} === ${names_1.default.errors}`); |
| 2446 |
} |
| 2447 |
function checkKeywords(it) { |
| 2448 |
(0, util_1.checkUnknownRules)(it); |
| 2449 |
checkRefsAndKeywords(it); |
| 2450 |
} |
| 2451 |
function typeAndKeywords(it, errsCount) { |
| 2452 |
if (it.opts.jtd) |
| 2453 |
return schemaKeywords(it, [], false, errsCount); |
| 2454 |
const types = (0, dataType_1.getSchemaTypes)(it.schema); |
| 2455 |
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types); |
| 2456 |
schemaKeywords(it, types, !checkedTypes, errsCount); |
| 2457 |
} |
| 2458 |
function checkRefsAndKeywords(it) { |
| 2459 |
const { schema, errSchemaPath, opts, self } = it; |
| 2460 |
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self.RULES)) { |
| 2461 |
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`); |
| 2462 |
} |
| 2463 |
} |
| 2464 |
function checkNoDefault(it) { |
| 2465 |
const { schema, opts } = it; |
| 2466 |
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) { |
| 2467 |
(0, util_1.checkStrictMode)(it, "default is ignored in the schema root"); |
| 2468 |
} |
| 2469 |
} |
| 2470 |
function updateContext(it) { |
| 2471 |
const schId = it.schema[it.opts.schemaId]; |
| 2472 |
if (schId) |
| 2473 |
it.baseId = (0, resolve_1.resolveUrl)(it.opts.uriResolver, it.baseId, schId); |
| 2474 |
} |
| 2475 |
function checkAsyncSchema(it) { |
| 2476 |
if (it.schema.$async && !it.schemaEnv.$async) |
| 2477 |
throw new Error("async schema in sync schema"); |
| 2478 |
} |
| 2479 |
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) { |
| 2480 |
const msg = schema.$comment; |
| 2481 |
if (opts.$comment === true) { |
| 2482 |
gen.code((0, codegen_1._)`${names_1.default.self}.logger.log(${msg})`); |
| 2483 |
} else if (typeof opts.$comment == "function") { |
| 2484 |
const schemaPath = (0, codegen_1.str)`${errSchemaPath}/$comment`; |
| 2485 |
const rootName = gen.scopeValue("root", { ref: schemaEnv.root }); |
| 2486 |
gen.code((0, codegen_1._)`${names_1.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`); |
| 2487 |
} |
| 2488 |
} |
| 2489 |
function returnResults(it) { |
| 2490 |
const { gen, schemaEnv, validateName, ValidationError, opts } = it; |
| 2491 |
if (schemaEnv.$async) { |
| 2492 |
gen.if((0, codegen_1._)`${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw((0, codegen_1._)`new ${ValidationError}(${names_1.default.vErrors})`)); |
| 2493 |
} else { |
| 2494 |
gen.assign((0, codegen_1._)`${validateName}.errors`, names_1.default.vErrors); |
| 2495 |
if (opts.unevaluated) |
| 2496 |
assignEvaluated(it); |
| 2497 |
gen.return((0, codegen_1._)`${names_1.default.errors} === 0`); |
| 2498 |
} |
| 2499 |
} |
| 2500 |
function assignEvaluated({ gen, evaluated, props, items }) { |
| 2501 |
if (props instanceof codegen_1.Name) |
| 2502 |
gen.assign((0, codegen_1._)`${evaluated}.props`, props); |
| 2503 |
if (items instanceof codegen_1.Name) |
| 2504 |
gen.assign((0, codegen_1._)`${evaluated}.items`, items); |
| 2505 |
} |
| 2506 |
function schemaKeywords(it, types, typeErrors, errsCount) { |
| 2507 |
const { gen, schema, data, allErrors, opts, self } = it; |
| 2508 |
const { RULES } = self; |
| 2509 |
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) { |
| 2510 |
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition)); |
| 2511 |
return; |
| 2512 |
} |
| 2513 |
if (!opts.jtd) |
| 2514 |
checkStrictTypes(it, types); |
| 2515 |
gen.block(() => { |
| 2516 |
for (const group of RULES.rules) |
| 2517 |
groupKeywords(group); |
| 2518 |
groupKeywords(RULES.post); |
| 2519 |
}); |
| 2520 |
function groupKeywords(group) { |
| 2521 |
if (!(0, applicability_1.shouldUseGroup)(schema, group)) |
| 2522 |
return; |
| 2523 |
if (group.type) { |
| 2524 |
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers)); |
| 2525 |
iterateKeywords(it, group); |
| 2526 |
if (types.length === 1 && types[0] === group.type && typeErrors) { |
| 2527 |
gen.else(); |
| 2528 |
(0, dataType_2.reportTypeError)(it); |
| 2529 |
} |
| 2530 |
gen.endIf(); |
| 2531 |
} else { |
| 2532 |
iterateKeywords(it, group); |
| 2533 |
} |
| 2534 |
if (!allErrors) |
| 2535 |
gen.if((0, codegen_1._)`${names_1.default.errors} === ${errsCount || 0}`); |
| 2536 |
} |
| 2537 |
} |
| 2538 |
function iterateKeywords(it, group) { |
| 2539 |
const { gen, schema, opts: { useDefaults } } = it; |
| 2540 |
if (useDefaults) |
| 2541 |
(0, defaults_1.assignDefaults)(it, group.type); |
| 2542 |
gen.block(() => { |
| 2543 |
for (const rule of group.rules) { |
| 2544 |
if ((0, applicability_1.shouldUseRule)(schema, rule)) { |
| 2545 |
keywordCode(it, rule.keyword, rule.definition, group.type); |
| 2546 |
} |
| 2547 |
} |
| 2548 |
}); |
| 2549 |
} |
| 2550 |
function checkStrictTypes(it, types) { |
| 2551 |
if (it.schemaEnv.meta || !it.opts.strictTypes) |
| 2552 |
return; |
| 2553 |
checkContextTypes(it, types); |
| 2554 |
if (!it.opts.allowUnionTypes) |
| 2555 |
checkMultipleTypes(it, types); |
| 2556 |
checkKeywordTypes(it, it.dataTypes); |
| 2557 |
} |
| 2558 |
function checkContextTypes(it, types) { |
| 2559 |
if (!types.length) |
| 2560 |
return; |
| 2561 |
if (!it.dataTypes.length) { |
| 2562 |
it.dataTypes = types; |
| 2563 |
return; |
| 2564 |
} |
| 2565 |
types.forEach((t) => { |
| 2566 |
if (!includesType(it.dataTypes, t)) { |
| 2567 |
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`); |
| 2568 |
} |
| 2569 |
}); |
| 2570 |
narrowSchemaTypes(it, types); |
| 2571 |
} |
| 2572 |
function checkMultipleTypes(it, ts) { |
| 2573 |
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) { |
| 2574 |
strictTypesError(it, "use allowUnionTypes to allow union type keyword"); |
| 2575 |
} |
| 2576 |
} |
| 2577 |
function checkKeywordTypes(it, ts) { |
| 2578 |
const rules = it.self.RULES.all; |
| 2579 |
for (const keyword in rules) { |
| 2580 |
const rule = rules[keyword]; |
| 2581 |
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) { |
| 2582 |
const { type } = rule.definition; |
| 2583 |
if (type.length && !type.some((t) => hasApplicableType(ts, t))) { |
| 2584 |
strictTypesError(it, `missing type "${type.join(",")}" for keyword "${keyword}"`); |
| 2585 |
} |
| 2586 |
} |
| 2587 |
} |
| 2588 |
} |
| 2589 |
function hasApplicableType(schTs, kwdT) { |
| 2590 |
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer"); |
| 2591 |
} |
| 2592 |
function includesType(ts, t) { |
| 2593 |
return ts.includes(t) || t === "integer" && ts.includes("number"); |
| 2594 |
} |
| 2595 |
function narrowSchemaTypes(it, withTypes) { |
| 2596 |
const ts = []; |
| 2597 |
for (const t of it.dataTypes) { |
| 2598 |
if (includesType(withTypes, t)) |
| 2599 |
ts.push(t); |
| 2600 |
else if (withTypes.includes("integer") && t === "number") |
| 2601 |
ts.push("integer"); |
| 2602 |
} |
| 2603 |
it.dataTypes = ts; |
| 2604 |
} |
| 2605 |
function strictTypesError(it, msg) { |
| 2606 |
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath; |
| 2607 |
msg += ` at "${schemaPath}" (strictTypes)`; |
| 2608 |
(0, util_1.checkStrictMode)(it, msg, it.opts.strictTypes); |
| 2609 |
} |
| 2610 |
var KeywordCxt = class { |
| 2611 |
constructor(it, def, keyword) { |
| 2612 |
(0, keyword_1.validateKeywordUsage)(it, def, keyword); |
| 2613 |
this.gen = it.gen; |
| 2614 |
this.allErrors = it.allErrors; |
| 2615 |
this.keyword = keyword; |
| 2616 |
this.data = it.data; |
| 2617 |
this.schema = it.schema[keyword]; |
| 2618 |
this.$data = def.$data && it.opts.$data && this.schema && this.schema.$data; |
| 2619 |
this.schemaValue = (0, util_1.schemaRefOrVal)(it, this.schema, keyword, this.$data); |
| 2620 |
this.schemaType = def.schemaType; |
| 2621 |
this.parentSchema = it.schema; |
| 2622 |
this.params = {}; |
| 2623 |
this.it = it; |
| 2624 |
this.def = def; |
| 2625 |
if (this.$data) { |
| 2626 |
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it)); |
| 2627 |
} else { |
| 2628 |
this.schemaCode = this.schemaValue; |
| 2629 |
if (!(0, keyword_1.validSchemaType)(this.schema, def.schemaType, def.allowUndefined)) { |
| 2630 |
throw new Error(`${keyword} value must be ${JSON.stringify(def.schemaType)}`); |
| 2631 |
} |
| 2632 |
} |
| 2633 |
if ("code" in def ? def.trackErrors : def.errors !== false) { |
| 2634 |
this.errsCount = it.gen.const("_errs", names_1.default.errors); |
| 2635 |
} |
| 2636 |
} |
| 2637 |
result(condition, successAction, failAction) { |
| 2638 |
this.failResult((0, codegen_1.not)(condition), successAction, failAction); |
| 2639 |
} |
| 2640 |
failResult(condition, successAction, failAction) { |
| 2641 |
this.gen.if(condition); |
| 2642 |
if (failAction) |
| 2643 |
failAction(); |
| 2644 |
else |
| 2645 |
this.error(); |
| 2646 |
if (successAction) { |
| 2647 |
this.gen.else(); |
| 2648 |
successAction(); |
| 2649 |
if (this.allErrors) |
| 2650 |
this.gen.endIf(); |
| 2651 |
} else { |
| 2652 |
if (this.allErrors) |
| 2653 |
this.gen.endIf(); |
| 2654 |
else |
| 2655 |
this.gen.else(); |
| 2656 |
} |
| 2657 |
} |
| 2658 |
pass(condition, failAction) { |
| 2659 |
this.failResult((0, codegen_1.not)(condition), void 0, failAction); |
| 2660 |
} |
| 2661 |
fail(condition) { |
| 2662 |
if (condition === void 0) { |
| 2663 |
this.error(); |
| 2664 |
if (!this.allErrors) |
| 2665 |
this.gen.if(false); |
| 2666 |
return; |
| 2667 |
} |
| 2668 |
this.gen.if(condition); |
| 2669 |
this.error(); |
| 2670 |
if (this.allErrors) |
| 2671 |
this.gen.endIf(); |
| 2672 |
else |
| 2673 |
this.gen.else(); |
| 2674 |
} |
| 2675 |
fail$data(condition) { |
| 2676 |
if (!this.$data) |
| 2677 |
return this.fail(condition); |
| 2678 |
const { schemaCode } = this; |
| 2679 |
this.fail((0, codegen_1._)`${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`); |
| 2680 |
} |
| 2681 |
error(append, errorParams, errorPaths) { |
| 2682 |
if (errorParams) { |
| 2683 |
this.setParams(errorParams); |
| 2684 |
this._error(append, errorPaths); |
| 2685 |
this.setParams({}); |
| 2686 |
return; |
| 2687 |
} |
| 2688 |
this._error(append, errorPaths); |
| 2689 |
} |
| 2690 |
_error(append, errorPaths) { |
| 2691 |
; |
| 2692 |
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths); |
| 2693 |
} |
| 2694 |
$dataError() { |
| 2695 |
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError); |
| 2696 |
} |
| 2697 |
reset() { |
| 2698 |
if (this.errsCount === void 0) |
| 2699 |
throw new Error('add "trackErrors" to keyword definition'); |
| 2700 |
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount); |
| 2701 |
} |
| 2702 |
ok(cond) { |
| 2703 |
if (!this.allErrors) |
| 2704 |
this.gen.if(cond); |
| 2705 |
} |
| 2706 |
setParams(obj, assign) { |
| 2707 |
if (assign) |
| 2708 |
Object.assign(this.params, obj); |
| 2709 |
else |
| 2710 |
this.params = obj; |
| 2711 |
} |
| 2712 |
block$data(valid, codeBlock, $dataValid = codegen_1.nil) { |
| 2713 |
this.gen.block(() => { |
| 2714 |
this.check$data(valid, $dataValid); |
| 2715 |
codeBlock(); |
| 2716 |
}); |
| 2717 |
} |
| 2718 |
check$data(valid = codegen_1.nil, $dataValid = codegen_1.nil) { |
| 2719 |
if (!this.$data) |
| 2720 |
return; |
| 2721 |
const { gen, schemaCode, schemaType, def } = this; |
| 2722 |
gen.if((0, codegen_1.or)((0, codegen_1._)`${schemaCode} === undefined`, $dataValid)); |
| 2723 |
if (valid !== codegen_1.nil) |
| 2724 |
gen.assign(valid, true); |
| 2725 |
if (schemaType.length || def.validateSchema) { |
| 2726 |
gen.elseIf(this.invalid$data()); |
| 2727 |
this.$dataError(); |
| 2728 |
if (valid !== codegen_1.nil) |
| 2729 |
gen.assign(valid, false); |
| 2730 |
} |
| 2731 |
gen.else(); |
| 2732 |
} |
| 2733 |
invalid$data() { |
| 2734 |
const { gen, schemaCode, schemaType, def, it } = this; |
| 2735 |
return (0, codegen_1.or)(wrong$DataType(), invalid$DataSchema()); |
| 2736 |
function wrong$DataType() { |
| 2737 |
if (schemaType.length) { |
| 2738 |
if (!(schemaCode instanceof codegen_1.Name)) |
| 2739 |
throw new Error("ajv implementation error"); |
| 2740 |
const st = Array.isArray(schemaType) ? schemaType : [schemaType]; |
| 2741 |
return (0, codegen_1._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`; |
| 2742 |
} |
| 2743 |
return codegen_1.nil; |
| 2744 |
} |
| 2745 |
function invalid$DataSchema() { |
| 2746 |
if (def.validateSchema) { |
| 2747 |
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def.validateSchema }); |
| 2748 |
return (0, codegen_1._)`!${validateSchemaRef}(${schemaCode})`; |
| 2749 |
} |
| 2750 |
return codegen_1.nil; |
| 2751 |
} |
| 2752 |
} |
| 2753 |
subschema(appl, valid) { |
| 2754 |
const subschema = (0, subschema_1.getSubschema)(this.it, appl); |
| 2755 |
(0, subschema_1.extendSubschemaData)(subschema, this.it, appl); |
| 2756 |
(0, subschema_1.extendSubschemaMode)(subschema, appl); |
| 2757 |
const nextContext = { ...this.it, ...subschema, items: void 0, props: void 0 }; |
| 2758 |
subschemaCode(nextContext, valid); |
| 2759 |
return nextContext; |
| 2760 |
} |
| 2761 |
mergeEvaluated(schemaCxt, toName) { |
| 2762 |
const { it, gen } = this; |
| 2763 |
if (!it.opts.unevaluated) |
| 2764 |
return; |
| 2765 |
if (it.props !== true && schemaCxt.props !== void 0) { |
| 2766 |
it.props = util_1.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName); |
| 2767 |
} |
| 2768 |
if (it.items !== true && schemaCxt.items !== void 0) { |
| 2769 |
it.items = util_1.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName); |
| 2770 |
} |
| 2771 |
} |
| 2772 |
mergeValidEvaluated(schemaCxt, valid) { |
| 2773 |
const { it, gen } = this; |
| 2774 |
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) { |
| 2775 |
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1.Name)); |
| 2776 |
return true; |
| 2777 |
} |
| 2778 |
} |
| 2779 |
}; |
| 2780 |
exports.KeywordCxt = KeywordCxt; |
| 2781 |
function keywordCode(it, keyword, def, ruleType) { |
| 2782 |
const cxt = new KeywordCxt(it, def, keyword); |
| 2783 |
if ("code" in def) { |
| 2784 |
def.code(cxt, ruleType); |
| 2785 |
} else if (cxt.$data && def.validate) { |
| 2786 |
(0, keyword_1.funcKeywordCode)(cxt, def); |
| 2787 |
} else if ("macro" in def) { |
| 2788 |
(0, keyword_1.macroKeywordCode)(cxt, def); |
| 2789 |
} else if (def.compile || def.validate) { |
| 2790 |
(0, keyword_1.funcKeywordCode)(cxt, def); |
| 2791 |
} |
| 2792 |
} |
| 2793 |
var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/; |
| 2794 |
var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/; |
| 2795 |
function getData($data, { dataLevel, dataNames, dataPathArr }) { |
| 2796 |
let jsonPointer; |
| 2797 |
let data; |
| 2798 |
if ($data === "") |
| 2799 |
return names_1.default.rootData; |
| 2800 |
if ($data[0] === "/") { |
| 2801 |
if (!JSON_POINTER.test($data)) |
| 2802 |
throw new Error(`Invalid JSON-pointer: ${$data}`); |
| 2803 |
jsonPointer = $data; |
| 2804 |
data = names_1.default.rootData; |
| 2805 |
} else { |
| 2806 |
const matches = RELATIVE_JSON_POINTER.exec($data); |
| 2807 |
if (!matches) |
| 2808 |
throw new Error(`Invalid JSON-pointer: ${$data}`); |
| 2809 |
const up = +matches[1]; |
| 2810 |
jsonPointer = matches[2]; |
| 2811 |
if (jsonPointer === "#") { |
| 2812 |
if (up >= dataLevel) |
| 2813 |
throw new Error(errorMsg("property/index", up)); |
| 2814 |
return dataPathArr[dataLevel - up]; |
| 2815 |
} |
| 2816 |
if (up > dataLevel) |
| 2817 |
throw new Error(errorMsg("data", up)); |
| 2818 |
data = dataNames[dataLevel - up]; |
| 2819 |
if (!jsonPointer) |
| 2820 |
return data; |
| 2821 |
} |
| 2822 |
let expr = data; |
| 2823 |
const segments = jsonPointer.split("/"); |
| 2824 |
for (const segment of segments) { |
| 2825 |
if (segment) { |
| 2826 |
data = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`; |
| 2827 |
expr = (0, codegen_1._)`${expr} && ${data}`; |
| 2828 |
} |
| 2829 |
} |
| 2830 |
return expr; |
| 2831 |
function errorMsg(pointerType, up) { |
| 2832 |
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`; |
| 2833 |
} |
| 2834 |
} |
| 2835 |
exports.getData = getData; |
| 2836 |
} |
| 2837 |
}); |
| 2838 |
|
| 2839 |
// node_modules/ajv/dist/runtime/validation_error.js |
| 2840 |
var require_validation_error = __commonJS({ |
| 2841 |
"node_modules/ajv/dist/runtime/validation_error.js"(exports) { |
| 2842 |
"use strict"; |
| 2843 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 2844 |
var ValidationError = class extends Error { |
| 2845 |
constructor(errors) { |
| 2846 |
super("validation failed"); |
| 2847 |
this.errors = errors; |
| 2848 |
this.ajv = this.validation = true; |
| 2849 |
} |
| 2850 |
}; |
| 2851 |
exports.default = ValidationError; |
| 2852 |
} |
| 2853 |
}); |
| 2854 |
|
| 2855 |
// node_modules/ajv/dist/compile/ref_error.js |
| 2856 |
var require_ref_error = __commonJS({ |
| 2857 |
"node_modules/ajv/dist/compile/ref_error.js"(exports) { |
| 2858 |
"use strict"; |
| 2859 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 2860 |
var resolve_1 = require_resolve(); |
| 2861 |
var MissingRefError = class extends Error { |
| 2862 |
constructor(resolver, baseId, ref, msg) { |
| 2863 |
super(msg || `can't resolve reference ${ref} from id ${baseId}`); |
| 2864 |
this.missingRef = (0, resolve_1.resolveUrl)(resolver, baseId, ref); |
| 2865 |
this.missingSchema = (0, resolve_1.normalizeId)((0, resolve_1.getFullPath)(resolver, this.missingRef)); |
| 2866 |
} |
| 2867 |
}; |
| 2868 |
exports.default = MissingRefError; |
| 2869 |
} |
| 2870 |
}); |
| 2871 |
|
| 2872 |
// node_modules/ajv/dist/compile/index.js |
| 2873 |
var require_compile = __commonJS({ |
| 2874 |
"node_modules/ajv/dist/compile/index.js"(exports) { |
| 2875 |
"use strict"; |
| 2876 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 2877 |
exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0; |
| 2878 |
var codegen_1 = require_codegen(); |
| 2879 |
var validation_error_1 = require_validation_error(); |
| 2880 |
var names_1 = require_names(); |
| 2881 |
var resolve_1 = require_resolve(); |
| 2882 |
var util_1 = require_util(); |
| 2883 |
var validate_1 = require_validate(); |
| 2884 |
var SchemaEnv = class { |
| 2885 |
constructor(env) { |
| 2886 |
var _a; |
| 2887 |
this.refs = {}; |
| 2888 |
this.dynamicAnchors = {}; |
| 2889 |
let schema; |
| 2890 |
if (typeof env.schema == "object") |
| 2891 |
schema = env.schema; |
| 2892 |
this.schema = env.schema; |
| 2893 |
this.schemaId = env.schemaId; |
| 2894 |
this.root = env.root || this; |
| 2895 |
this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]); |
| 2896 |
this.schemaPath = env.schemaPath; |
| 2897 |
this.localRefs = env.localRefs; |
| 2898 |
this.meta = env.meta; |
| 2899 |
this.$async = schema === null || schema === void 0 ? void 0 : schema.$async; |
| 2900 |
this.refs = {}; |
| 2901 |
} |
| 2902 |
}; |
| 2903 |
exports.SchemaEnv = SchemaEnv; |
| 2904 |
function compileSchema(sch) { |
| 2905 |
const _sch = getCompilingSchema.call(this, sch); |
| 2906 |
if (_sch) |
| 2907 |
return _sch; |
| 2908 |
const rootId = (0, resolve_1.getFullPath)(this.opts.uriResolver, sch.root.baseId); |
| 2909 |
const { es5, lines } = this.opts.code; |
| 2910 |
const { ownProperties } = this.opts; |
| 2911 |
const gen = new codegen_1.CodeGen(this.scope, { es5, lines, ownProperties }); |
| 2912 |
let _ValidationError; |
| 2913 |
if (sch.$async) { |
| 2914 |
_ValidationError = gen.scopeValue("Error", { |
| 2915 |
ref: validation_error_1.default, |
| 2916 |
code: (0, codegen_1._)`require("ajv/dist/runtime/validation_error").default` |
| 2917 |
}); |
| 2918 |
} |
| 2919 |
const validateName = gen.scopeName("validate"); |
| 2920 |
sch.validateName = validateName; |
| 2921 |
const schemaCxt = { |
| 2922 |
gen, |
| 2923 |
allErrors: this.opts.allErrors, |
| 2924 |
data: names_1.default.data, |
| 2925 |
parentData: names_1.default.parentData, |
| 2926 |
parentDataProperty: names_1.default.parentDataProperty, |
| 2927 |
dataNames: [names_1.default.data], |
| 2928 |
dataPathArr: [codegen_1.nil], |
| 2929 |
// TODO can its length be used as dataLevel if nil is removed? |
| 2930 |
dataLevel: 0, |
| 2931 |
dataTypes: [], |
| 2932 |
definedProperties: /* @__PURE__ */ new Set(), |
| 2933 |
topSchemaRef: gen.scopeValue("schema", this.opts.code.source === true ? { ref: sch.schema, code: (0, codegen_1.stringify)(sch.schema) } : { ref: sch.schema }), |
| 2934 |
validateName, |
| 2935 |
ValidationError: _ValidationError, |
| 2936 |
schema: sch.schema, |
| 2937 |
schemaEnv: sch, |
| 2938 |
rootId, |
| 2939 |
baseId: sch.baseId || rootId, |
| 2940 |
schemaPath: codegen_1.nil, |
| 2941 |
errSchemaPath: sch.schemaPath || (this.opts.jtd ? "" : "#"), |
| 2942 |
errorPath: (0, codegen_1._)`""`, |
| 2943 |
opts: this.opts, |
| 2944 |
self: this |
| 2945 |
}; |
| 2946 |
let sourceCode; |
| 2947 |
try { |
| 2948 |
this._compilations.add(sch); |
| 2949 |
(0, validate_1.validateFunctionCode)(schemaCxt); |
| 2950 |
gen.optimize(this.opts.code.optimize); |
| 2951 |
const validateCode = gen.toString(); |
| 2952 |
sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${validateCode}`; |
| 2953 |
if (this.opts.code.process) |
| 2954 |
sourceCode = this.opts.code.process(sourceCode, sch); |
| 2955 |
const makeValidate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode); |
| 2956 |
const validate = makeValidate(this, this.scope.get()); |
| 2957 |
this.scope.value(validateName, { ref: validate }); |
| 2958 |
validate.errors = null; |
| 2959 |
validate.schema = sch.schema; |
| 2960 |
validate.schemaEnv = sch; |
| 2961 |
if (sch.$async) |
| 2962 |
validate.$async = true; |
| 2963 |
if (this.opts.code.source === true) { |
| 2964 |
validate.source = { validateName, validateCode, scopeValues: gen._values }; |
| 2965 |
} |
| 2966 |
if (this.opts.unevaluated) { |
| 2967 |
const { props, items } = schemaCxt; |
| 2968 |
validate.evaluated = { |
| 2969 |
props: props instanceof codegen_1.Name ? void 0 : props, |
| 2970 |
items: items instanceof codegen_1.Name ? void 0 : items, |
| 2971 |
dynamicProps: props instanceof codegen_1.Name, |
| 2972 |
dynamicItems: items instanceof codegen_1.Name |
| 2973 |
}; |
| 2974 |
if (validate.source) |
| 2975 |
validate.source.evaluated = (0, codegen_1.stringify)(validate.evaluated); |
| 2976 |
} |
| 2977 |
sch.validate = validate; |
| 2978 |
return sch; |
| 2979 |
} catch (e) { |
| 2980 |
delete sch.validate; |
| 2981 |
delete sch.validateName; |
| 2982 |
if (sourceCode) |
| 2983 |
this.logger.error("Error compiling schema, function code:", sourceCode); |
| 2984 |
throw e; |
| 2985 |
} finally { |
| 2986 |
this._compilations.delete(sch); |
| 2987 |
} |
| 2988 |
} |
| 2989 |
exports.compileSchema = compileSchema; |
| 2990 |
function resolveRef(root, baseId, ref) { |
| 2991 |
var _a; |
| 2992 |
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref); |
| 2993 |
const schOrFunc = root.refs[ref]; |
| 2994 |
if (schOrFunc) |
| 2995 |
return schOrFunc; |
| 2996 |
let _sch = resolve.call(this, root, ref); |
| 2997 |
if (_sch === void 0) { |
| 2998 |
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref]; |
| 2999 |
const { schemaId } = this.opts; |
| 3000 |
if (schema) |
| 3001 |
_sch = new SchemaEnv({ schema, schemaId, root, baseId }); |
| 3002 |
} |
| 3003 |
if (_sch === void 0) |
| 3004 |
return; |
| 3005 |
return root.refs[ref] = inlineOrCompile.call(this, _sch); |
| 3006 |
} |
| 3007 |
exports.resolveRef = resolveRef; |
| 3008 |
function inlineOrCompile(sch) { |
| 3009 |
if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs)) |
| 3010 |
return sch.schema; |
| 3011 |
return sch.validate ? sch : compileSchema.call(this, sch); |
| 3012 |
} |
| 3013 |
function getCompilingSchema(schEnv) { |
| 3014 |
for (const sch of this._compilations) { |
| 3015 |
if (sameSchemaEnv(sch, schEnv)) |
| 3016 |
return sch; |
| 3017 |
} |
| 3018 |
} |
| 3019 |
exports.getCompilingSchema = getCompilingSchema; |
| 3020 |
function sameSchemaEnv(s1, s2) { |
| 3021 |
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId; |
| 3022 |
} |
| 3023 |
function resolve(root, ref) { |
| 3024 |
let sch; |
| 3025 |
while (typeof (sch = this.refs[ref]) == "string") |
| 3026 |
ref = sch; |
| 3027 |
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref); |
| 3028 |
} |
| 3029 |
function resolveSchema(root, ref) { |
| 3030 |
const p = this.opts.uriResolver.parse(ref); |
| 3031 |
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p); |
| 3032 |
let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root.baseId, void 0); |
| 3033 |
if (Object.keys(root.schema).length > 0 && refPath === baseId) { |
| 3034 |
return getJsonPointer.call(this, p, root); |
| 3035 |
} |
| 3036 |
const id = (0, resolve_1.normalizeId)(refPath); |
| 3037 |
const schOrRef = this.refs[id] || this.schemas[id]; |
| 3038 |
if (typeof schOrRef == "string") { |
| 3039 |
const sch = resolveSchema.call(this, root, schOrRef); |
| 3040 |
if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object") |
| 3041 |
return; |
| 3042 |
return getJsonPointer.call(this, p, sch); |
| 3043 |
} |
| 3044 |
if (typeof (schOrRef === null || schOrRef === void 0 ? void 0 : schOrRef.schema) !== "object") |
| 3045 |
return; |
| 3046 |
if (!schOrRef.validate) |
| 3047 |
compileSchema.call(this, schOrRef); |
| 3048 |
if (id === (0, resolve_1.normalizeId)(ref)) { |
| 3049 |
const { schema } = schOrRef; |
| 3050 |
const { schemaId } = this.opts; |
| 3051 |
const schId = schema[schemaId]; |
| 3052 |
if (schId) |
| 3053 |
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId); |
| 3054 |
return new SchemaEnv({ schema, schemaId, root, baseId }); |
| 3055 |
} |
| 3056 |
return getJsonPointer.call(this, p, schOrRef); |
| 3057 |
} |
| 3058 |
exports.resolveSchema = resolveSchema; |
| 3059 |
var PREVENT_SCOPE_CHANGE = /* @__PURE__ */ new Set([ |
| 3060 |
"properties", |
| 3061 |
"patternProperties", |
| 3062 |
"enum", |
| 3063 |
"dependencies", |
| 3064 |
"definitions" |
| 3065 |
]); |
| 3066 |
function getJsonPointer(parsedRef, { baseId, schema, root }) { |
| 3067 |
var _a; |
| 3068 |
if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/") |
| 3069 |
return; |
| 3070 |
for (const part of parsedRef.fragment.slice(1).split("/")) { |
| 3071 |
if (typeof schema === "boolean") |
| 3072 |
return; |
| 3073 |
const partSchema = schema[(0, util_1.unescapeFragment)(part)]; |
| 3074 |
if (partSchema === void 0) |
| 3075 |
return; |
| 3076 |
schema = partSchema; |
| 3077 |
const schId = typeof schema === "object" && schema[this.opts.schemaId]; |
| 3078 |
if (!PREVENT_SCOPE_CHANGE.has(part) && schId) { |
| 3079 |
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId); |
| 3080 |
} |
| 3081 |
} |
| 3082 |
let env; |
| 3083 |
if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) { |
| 3084 |
const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref); |
| 3085 |
env = resolveSchema.call(this, root, $ref); |
| 3086 |
} |
| 3087 |
const { schemaId } = this.opts; |
| 3088 |
env = env || new SchemaEnv({ schema, schemaId, root, baseId }); |
| 3089 |
if (env.schema !== env.root.schema) |
| 3090 |
return env; |
| 3091 |
return void 0; |
| 3092 |
} |
| 3093 |
} |
| 3094 |
}); |
| 3095 |
|
| 3096 |
// node_modules/ajv/dist/refs/data.json |
| 3097 |
var require_data2 = __commonJS({ |
| 3098 |
"node_modules/ajv/dist/refs/data.json"(exports, module) { |
| 3099 |
module.exports = { |
| 3100 |
$id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#", |
| 3101 |
description: "Meta-schema for $data reference (JSON AnySchema extension proposal)", |
| 3102 |
type: "object", |
| 3103 |
required: ["$data"], |
| 3104 |
properties: { |
| 3105 |
$data: { |
| 3106 |
type: "string", |
| 3107 |
anyOf: [{ format: "relative-json-pointer" }, { format: "json-pointer" }] |
| 3108 |
} |
| 3109 |
}, |
| 3110 |
additionalProperties: false |
| 3111 |
}; |
| 3112 |
} |
| 3113 |
}); |
| 3114 |
|
| 3115 |
// node_modules/fast-uri/lib/scopedChars.js |
| 3116 |
var require_scopedChars = __commonJS({ |
| 3117 |
"node_modules/fast-uri/lib/scopedChars.js"(exports, module) { |
| 3118 |
"use strict"; |
| 3119 |
var HEX = { |
| 3120 |
0: 0, |
| 3121 |
1: 1, |
| 3122 |
2: 2, |
| 3123 |
3: 3, |
| 3124 |
4: 4, |
| 3125 |
5: 5, |
| 3126 |
6: 6, |
| 3127 |
7: 7, |
| 3128 |
8: 8, |
| 3129 |
9: 9, |
| 3130 |
a: 10, |
| 3131 |
A: 10, |
| 3132 |
b: 11, |
| 3133 |
B: 11, |
| 3134 |
c: 12, |
| 3135 |
C: 12, |
| 3136 |
d: 13, |
| 3137 |
D: 13, |
| 3138 |
e: 14, |
| 3139 |
E: 14, |
| 3140 |
f: 15, |
| 3141 |
F: 15 |
| 3142 |
}; |
| 3143 |
module.exports = { |
| 3144 |
HEX |
| 3145 |
}; |
| 3146 |
} |
| 3147 |
}); |
| 3148 |
|
| 3149 |
// node_modules/fast-uri/lib/utils.js |
| 3150 |
var require_utils = __commonJS({ |
| 3151 |
"node_modules/fast-uri/lib/utils.js"(exports, module) { |
| 3152 |
"use strict"; |
| 3153 |
var { HEX } = require_scopedChars(); |
| 3154 |
function normalizeIPv4(host) { |
| 3155 |
if (findToken(host, ".") < 3) { |
| 3156 |
return { host, isIPV4: false }; |
| 3157 |
} |
| 3158 |
const matches = host.match(/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/u) || []; |
| 3159 |
const [address] = matches; |
| 3160 |
if (address) { |
| 3161 |
return { host: stripLeadingZeros(address, "."), isIPV4: true }; |
| 3162 |
} else { |
| 3163 |
return { host, isIPV4: false }; |
| 3164 |
} |
| 3165 |
} |
| 3166 |
function stringArrayToHexStripped(input, keepZero = false) { |
| 3167 |
let acc = ""; |
| 3168 |
let strip = true; |
| 3169 |
for (const c of input) { |
| 3170 |
if (HEX[c] === void 0) return void 0; |
| 3171 |
if (c !== "0" && strip === true) strip = false; |
| 3172 |
if (!strip) acc += c; |
| 3173 |
} |
| 3174 |
if (keepZero && acc.length === 0) acc = "0"; |
| 3175 |
return acc; |
| 3176 |
} |
| 3177 |
function getIPV6(input) { |
| 3178 |
let tokenCount = 0; |
| 3179 |
const output = { error: false, address: "", zone: "" }; |
| 3180 |
const address = []; |
| 3181 |
const buffer = []; |
| 3182 |
let isZone = false; |
| 3183 |
let endipv6Encountered = false; |
| 3184 |
let endIpv6 = false; |
| 3185 |
function consume() { |
| 3186 |
if (buffer.length) { |
| 3187 |
if (isZone === false) { |
| 3188 |
const hex = stringArrayToHexStripped(buffer); |
| 3189 |
if (hex !== void 0) { |
| 3190 |
address.push(hex); |
| 3191 |
} else { |
| 3192 |
output.error = true; |
| 3193 |
return false; |
| 3194 |
} |
| 3195 |
} |
| 3196 |
buffer.length = 0; |
| 3197 |
} |
| 3198 |
return true; |
| 3199 |
} |
| 3200 |
for (let i = 0; i < input.length; i++) { |
| 3201 |
const cursor = input[i]; |
| 3202 |
if (cursor === "[" || cursor === "]") { |
| 3203 |
continue; |
| 3204 |
} |
| 3205 |
if (cursor === ":") { |
| 3206 |
if (endipv6Encountered === true) { |
| 3207 |
endIpv6 = true; |
| 3208 |
} |
| 3209 |
if (!consume()) { |
| 3210 |
break; |
| 3211 |
} |
| 3212 |
tokenCount++; |
| 3213 |
address.push(":"); |
| 3214 |
if (tokenCount > 7) { |
| 3215 |
output.error = true; |
| 3216 |
break; |
| 3217 |
} |
| 3218 |
if (i - 1 >= 0 && input[i - 1] === ":") { |
| 3219 |
endipv6Encountered = true; |
| 3220 |
} |
| 3221 |
continue; |
| 3222 |
} else if (cursor === "%") { |
| 3223 |
if (!consume()) { |
| 3224 |
break; |
| 3225 |
} |
| 3226 |
isZone = true; |
| 3227 |
} else { |
| 3228 |
buffer.push(cursor); |
| 3229 |
continue; |
| 3230 |
} |
| 3231 |
} |
| 3232 |
if (buffer.length) { |
| 3233 |
if (isZone) { |
| 3234 |
output.zone = buffer.join(""); |
| 3235 |
} else if (endIpv6) { |
| 3236 |
address.push(buffer.join("")); |
| 3237 |
} else { |
| 3238 |
address.push(stringArrayToHexStripped(buffer)); |
| 3239 |
} |
| 3240 |
} |
| 3241 |
output.address = address.join(""); |
| 3242 |
return output; |
| 3243 |
} |
| 3244 |
function normalizeIPv6(host, opts = {}) { |
| 3245 |
if (findToken(host, ":") < 2) { |
| 3246 |
return { host, isIPV6: false }; |
| 3247 |
} |
| 3248 |
const ipv6 = getIPV6(host); |
| 3249 |
if (!ipv6.error) { |
| 3250 |
let newHost = ipv6.address; |
| 3251 |
let escapedHost = ipv6.address; |
| 3252 |
if (ipv6.zone) { |
| 3253 |
newHost += "%" + ipv6.zone; |
| 3254 |
escapedHost += "%25" + ipv6.zone; |
| 3255 |
} |
| 3256 |
return { host: newHost, escapedHost, isIPV6: true }; |
| 3257 |
} else { |
| 3258 |
return { host, isIPV6: false }; |
| 3259 |
} |
| 3260 |
} |
| 3261 |
function stripLeadingZeros(str, token) { |
| 3262 |
let out = ""; |
| 3263 |
let skip = true; |
| 3264 |
const l = str.length; |
| 3265 |
for (let i = 0; i < l; i++) { |
| 3266 |
const c = str[i]; |
| 3267 |
if (c === "0" && skip) { |
| 3268 |
if (i + 1 <= l && str[i + 1] === token || i + 1 === l) { |
| 3269 |
out += c; |
| 3270 |
skip = false; |
| 3271 |
} |
| 3272 |
} else { |
| 3273 |
if (c === token) { |
| 3274 |
skip = true; |
| 3275 |
} else { |
| 3276 |
skip = false; |
| 3277 |
} |
| 3278 |
out += c; |
| 3279 |
} |
| 3280 |
} |
| 3281 |
return out; |
| 3282 |
} |
| 3283 |
function findToken(str, token) { |
| 3284 |
let ind = 0; |
| 3285 |
for (let i = 0; i < str.length; i++) { |
| 3286 |
if (str[i] === token) ind++; |
| 3287 |
} |
| 3288 |
return ind; |
| 3289 |
} |
| 3290 |
var RDS1 = /^\.\.?\//u; |
| 3291 |
var RDS2 = /^\/\.(?:\/|$)/u; |
| 3292 |
var RDS3 = /^\/\.\.(?:\/|$)/u; |
| 3293 |
var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u; |
| 3294 |
function removeDotSegments(input) { |
| 3295 |
const output = []; |
| 3296 |
while (input.length) { |
| 3297 |
if (input.match(RDS1)) { |
| 3298 |
input = input.replace(RDS1, ""); |
| 3299 |
} else if (input.match(RDS2)) { |
| 3300 |
input = input.replace(RDS2, "/"); |
| 3301 |
} else if (input.match(RDS3)) { |
| 3302 |
input = input.replace(RDS3, "/"); |
| 3303 |
output.pop(); |
| 3304 |
} else if (input === "." || input === "..") { |
| 3305 |
input = ""; |
| 3306 |
} else { |
| 3307 |
const im = input.match(RDS5); |
| 3308 |
if (im) { |
| 3309 |
const s = im[0]; |
| 3310 |
input = input.slice(s.length); |
| 3311 |
output.push(s); |
| 3312 |
} else { |
| 3313 |
throw new Error("Unexpected dot segment condition"); |
| 3314 |
} |
| 3315 |
} |
| 3316 |
} |
| 3317 |
return output.join(""); |
| 3318 |
} |
| 3319 |
function normalizeComponentEncoding(components, esc) { |
| 3320 |
const func = esc !== true ? escape : unescape; |
| 3321 |
if (components.scheme !== void 0) { |
| 3322 |
components.scheme = func(components.scheme); |
| 3323 |
} |
| 3324 |
if (components.userinfo !== void 0) { |
| 3325 |
components.userinfo = func(components.userinfo); |
| 3326 |
} |
| 3327 |
if (components.host !== void 0) { |
| 3328 |
components.host = func(components.host); |
| 3329 |
} |
| 3330 |
if (components.path !== void 0) { |
| 3331 |
components.path = func(components.path); |
| 3332 |
} |
| 3333 |
if (components.query !== void 0) { |
| 3334 |
components.query = func(components.query); |
| 3335 |
} |
| 3336 |
if (components.fragment !== void 0) { |
| 3337 |
components.fragment = func(components.fragment); |
| 3338 |
} |
| 3339 |
return components; |
| 3340 |
} |
| 3341 |
function recomposeAuthority(components, options) { |
| 3342 |
const uriTokens = []; |
| 3343 |
if (components.userinfo !== void 0) { |
| 3344 |
uriTokens.push(components.userinfo); |
| 3345 |
uriTokens.push("@"); |
| 3346 |
} |
| 3347 |
if (components.host !== void 0) { |
| 3348 |
let host = unescape(components.host); |
| 3349 |
const ipV4res = normalizeIPv4(host); |
| 3350 |
if (ipV4res.isIPV4) { |
| 3351 |
host = ipV4res.host; |
| 3352 |
} else { |
| 3353 |
const ipV6res = normalizeIPv6(ipV4res.host, { isIPV4: false }); |
| 3354 |
if (ipV6res.isIPV6 === true) { |
| 3355 |
host = `[${ipV6res.escapedHost}]`; |
| 3356 |
} else { |
| 3357 |
host = components.host; |
| 3358 |
} |
| 3359 |
} |
| 3360 |
uriTokens.push(host); |
| 3361 |
} |
| 3362 |
if (typeof components.port === "number" || typeof components.port === "string") { |
| 3363 |
uriTokens.push(":"); |
| 3364 |
uriTokens.push(String(components.port)); |
| 3365 |
} |
| 3366 |
return uriTokens.length ? uriTokens.join("") : void 0; |
| 3367 |
} |
| 3368 |
module.exports = { |
| 3369 |
recomposeAuthority, |
| 3370 |
normalizeComponentEncoding, |
| 3371 |
removeDotSegments, |
| 3372 |
normalizeIPv4, |
| 3373 |
normalizeIPv6, |
| 3374 |
stringArrayToHexStripped |
| 3375 |
}; |
| 3376 |
} |
| 3377 |
}); |
| 3378 |
|
| 3379 |
// node_modules/fast-uri/lib/schemes.js |
| 3380 |
var require_schemes = __commonJS({ |
| 3381 |
"node_modules/fast-uri/lib/schemes.js"(exports, module) { |
| 3382 |
"use strict"; |
| 3383 |
var UUID_REG = /^[\da-f]{8}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{12}$/iu; |
| 3384 |
var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu; |
| 3385 |
function isSecure(wsComponents) { |
| 3386 |
return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss"; |
| 3387 |
} |
| 3388 |
function httpParse(components) { |
| 3389 |
if (!components.host) { |
| 3390 |
components.error = components.error || "HTTP URIs must have a host."; |
| 3391 |
} |
| 3392 |
return components; |
| 3393 |
} |
| 3394 |
function httpSerialize(components) { |
| 3395 |
const secure = String(components.scheme).toLowerCase() === "https"; |
| 3396 |
if (components.port === (secure ? 443 : 80) || components.port === "") { |
| 3397 |
components.port = void 0; |
| 3398 |
} |
| 3399 |
if (!components.path) { |
| 3400 |
components.path = "/"; |
| 3401 |
} |
| 3402 |
return components; |
| 3403 |
} |
| 3404 |
function wsParse(wsComponents) { |
| 3405 |
wsComponents.secure = isSecure(wsComponents); |
| 3406 |
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : ""); |
| 3407 |
wsComponents.path = void 0; |
| 3408 |
wsComponents.query = void 0; |
| 3409 |
return wsComponents; |
| 3410 |
} |
| 3411 |
function wsSerialize(wsComponents) { |
| 3412 |
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") { |
| 3413 |
wsComponents.port = void 0; |
| 3414 |
} |
| 3415 |
if (typeof wsComponents.secure === "boolean") { |
| 3416 |
wsComponents.scheme = wsComponents.secure ? "wss" : "ws"; |
| 3417 |
wsComponents.secure = void 0; |
| 3418 |
} |
| 3419 |
if (wsComponents.resourceName) { |
| 3420 |
const [path, query] = wsComponents.resourceName.split("?"); |
| 3421 |
wsComponents.path = path && path !== "/" ? path : void 0; |
| 3422 |
wsComponents.query = query; |
| 3423 |
wsComponents.resourceName = void 0; |
| 3424 |
} |
| 3425 |
wsComponents.fragment = void 0; |
| 3426 |
return wsComponents; |
| 3427 |
} |
| 3428 |
function urnParse(urnComponents, options) { |
| 3429 |
if (!urnComponents.path) { |
| 3430 |
urnComponents.error = "URN can not be parsed"; |
| 3431 |
return urnComponents; |
| 3432 |
} |
| 3433 |
const matches = urnComponents.path.match(URN_REG); |
| 3434 |
if (matches) { |
| 3435 |
const scheme = options.scheme || urnComponents.scheme || "urn"; |
| 3436 |
urnComponents.nid = matches[1].toLowerCase(); |
| 3437 |
urnComponents.nss = matches[2]; |
| 3438 |
const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`; |
| 3439 |
const schemeHandler = SCHEMES[urnScheme]; |
| 3440 |
urnComponents.path = void 0; |
| 3441 |
if (schemeHandler) { |
| 3442 |
urnComponents = schemeHandler.parse(urnComponents, options); |
| 3443 |
} |
| 3444 |
} else { |
| 3445 |
urnComponents.error = urnComponents.error || "URN can not be parsed."; |
| 3446 |
} |
| 3447 |
return urnComponents; |
| 3448 |
} |
| 3449 |
function urnSerialize(urnComponents, options) { |
| 3450 |
const scheme = options.scheme || urnComponents.scheme || "urn"; |
| 3451 |
const nid = urnComponents.nid.toLowerCase(); |
| 3452 |
const urnScheme = `${scheme}:${options.nid || nid}`; |
| 3453 |
const schemeHandler = SCHEMES[urnScheme]; |
| 3454 |
if (schemeHandler) { |
| 3455 |
urnComponents = schemeHandler.serialize(urnComponents, options); |
| 3456 |
} |
| 3457 |
const uriComponents = urnComponents; |
| 3458 |
const nss = urnComponents.nss; |
| 3459 |
uriComponents.path = `${nid || options.nid}:${nss}`; |
| 3460 |
options.skipEscape = true; |
| 3461 |
return uriComponents; |
| 3462 |
} |
| 3463 |
function urnuuidParse(urnComponents, options) { |
| 3464 |
const uuidComponents = urnComponents; |
| 3465 |
uuidComponents.uuid = uuidComponents.nss; |
| 3466 |
uuidComponents.nss = void 0; |
| 3467 |
if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) { |
| 3468 |
uuidComponents.error = uuidComponents.error || "UUID is not valid."; |
| 3469 |
} |
| 3470 |
return uuidComponents; |
| 3471 |
} |
| 3472 |
function urnuuidSerialize(uuidComponents) { |
| 3473 |
const urnComponents = uuidComponents; |
| 3474 |
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase(); |
| 3475 |
return urnComponents; |
| 3476 |
} |
| 3477 |
var http = { |
| 3478 |
scheme: "http", |
| 3479 |
domainHost: true, |
| 3480 |
parse: httpParse, |
| 3481 |
serialize: httpSerialize |
| 3482 |
}; |
| 3483 |
var https = { |
| 3484 |
scheme: "https", |
| 3485 |
domainHost: http.domainHost, |
| 3486 |
parse: httpParse, |
| 3487 |
serialize: httpSerialize |
| 3488 |
}; |
| 3489 |
var ws = { |
| 3490 |
scheme: "ws", |
| 3491 |
domainHost: true, |
| 3492 |
parse: wsParse, |
| 3493 |
serialize: wsSerialize |
| 3494 |
}; |
| 3495 |
var wss = { |
| 3496 |
scheme: "wss", |
| 3497 |
domainHost: ws.domainHost, |
| 3498 |
parse: ws.parse, |
| 3499 |
serialize: ws.serialize |
| 3500 |
}; |
| 3501 |
var urn = { |
| 3502 |
scheme: "urn", |
| 3503 |
parse: urnParse, |
| 3504 |
serialize: urnSerialize, |
| 3505 |
skipNormalize: true |
| 3506 |
}; |
| 3507 |
var urnuuid = { |
| 3508 |
scheme: "urn:uuid", |
| 3509 |
parse: urnuuidParse, |
| 3510 |
serialize: urnuuidSerialize, |
| 3511 |
skipNormalize: true |
| 3512 |
}; |
| 3513 |
var SCHEMES = { |
| 3514 |
http, |
| 3515 |
https, |
| 3516 |
ws, |
| 3517 |
wss, |
| 3518 |
urn, |
| 3519 |
"urn:uuid": urnuuid |
| 3520 |
}; |
| 3521 |
module.exports = SCHEMES; |
| 3522 |
} |
| 3523 |
}); |
| 3524 |
|
| 3525 |
// node_modules/fast-uri/index.js |
| 3526 |
var require_fast_uri = __commonJS({ |
| 3527 |
"node_modules/fast-uri/index.js"(exports, module) { |
| 3528 |
"use strict"; |
| 3529 |
var { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = require_utils(); |
| 3530 |
var SCHEMES = require_schemes(); |
| 3531 |
function normalize(uri, options) { |
| 3532 |
if (typeof uri === "string") { |
| 3533 |
uri = serialize(parse(uri, options), options); |
| 3534 |
} else if (typeof uri === "object") { |
| 3535 |
uri = parse(serialize(uri, options), options); |
| 3536 |
} |
| 3537 |
return uri; |
| 3538 |
} |
| 3539 |
function resolve(baseURI, relativeURI, options) { |
| 3540 |
const schemelessOptions = Object.assign({ scheme: "null" }, options); |
| 3541 |
const resolved = resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true); |
| 3542 |
return serialize(resolved, { ...schemelessOptions, skipEscape: true }); |
| 3543 |
} |
| 3544 |
function resolveComponents(base, relative, options, skipNormalization) { |
| 3545 |
const target = {}; |
| 3546 |
if (!skipNormalization) { |
| 3547 |
base = parse(serialize(base, options), options); |
| 3548 |
relative = parse(serialize(relative, options), options); |
| 3549 |
} |
| 3550 |
options = options || {}; |
| 3551 |
if (!options.tolerant && relative.scheme) { |
| 3552 |
target.scheme = relative.scheme; |
| 3553 |
target.userinfo = relative.userinfo; |
| 3554 |
target.host = relative.host; |
| 3555 |
target.port = relative.port; |
| 3556 |
target.path = removeDotSegments(relative.path || ""); |
| 3557 |
target.query = relative.query; |
| 3558 |
} else { |
| 3559 |
if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) { |
| 3560 |
target.userinfo = relative.userinfo; |
| 3561 |
target.host = relative.host; |
| 3562 |
target.port = relative.port; |
| 3563 |
target.path = removeDotSegments(relative.path || ""); |
| 3564 |
target.query = relative.query; |
| 3565 |
} else { |
| 3566 |
if (!relative.path) { |
| 3567 |
target.path = base.path; |
| 3568 |
if (relative.query !== void 0) { |
| 3569 |
target.query = relative.query; |
| 3570 |
} else { |
| 3571 |
target.query = base.query; |
| 3572 |
} |
| 3573 |
} else { |
| 3574 |
if (relative.path.charAt(0) === "/") { |
| 3575 |
target.path = removeDotSegments(relative.path); |
| 3576 |
} else { |
| 3577 |
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) { |
| 3578 |
target.path = "/" + relative.path; |
| 3579 |
} else if (!base.path) { |
| 3580 |
target.path = relative.path; |
| 3581 |
} else { |
| 3582 |
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path; |
| 3583 |
} |
| 3584 |
target.path = removeDotSegments(target.path); |
| 3585 |
} |
| 3586 |
target.query = relative.query; |
| 3587 |
} |
| 3588 |
target.userinfo = base.userinfo; |
| 3589 |
target.host = base.host; |
| 3590 |
target.port = base.port; |
| 3591 |
} |
| 3592 |
target.scheme = base.scheme; |
| 3593 |
} |
| 3594 |
target.fragment = relative.fragment; |
| 3595 |
return target; |
| 3596 |
} |
| 3597 |
function equal(uriA, uriB, options) { |
| 3598 |
if (typeof uriA === "string") { |
| 3599 |
uriA = unescape(uriA); |
| 3600 |
uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), { ...options, skipEscape: true }); |
| 3601 |
} else if (typeof uriA === "object") { |
| 3602 |
uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true }); |
| 3603 |
} |
| 3604 |
if (typeof uriB === "string") { |
| 3605 |
uriB = unescape(uriB); |
| 3606 |
uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), { ...options, skipEscape: true }); |
| 3607 |
} else if (typeof uriB === "object") { |
| 3608 |
uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true }); |
| 3609 |
} |
| 3610 |
return uriA.toLowerCase() === uriB.toLowerCase(); |
| 3611 |
} |
| 3612 |
function serialize(cmpts, opts) { |
| 3613 |
const components = { |
| 3614 |
host: cmpts.host, |
| 3615 |
scheme: cmpts.scheme, |
| 3616 |
userinfo: cmpts.userinfo, |
| 3617 |
port: cmpts.port, |
| 3618 |
path: cmpts.path, |
| 3619 |
query: cmpts.query, |
| 3620 |
nid: cmpts.nid, |
| 3621 |
nss: cmpts.nss, |
| 3622 |
uuid: cmpts.uuid, |
| 3623 |
fragment: cmpts.fragment, |
| 3624 |
reference: cmpts.reference, |
| 3625 |
resourceName: cmpts.resourceName, |
| 3626 |
secure: cmpts.secure, |
| 3627 |
error: "" |
| 3628 |
}; |
| 3629 |
const options = Object.assign({}, opts); |
| 3630 |
const uriTokens = []; |
| 3631 |
const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; |
| 3632 |
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options); |
| 3633 |
if (components.path !== void 0) { |
| 3634 |
if (!options.skipEscape) { |
| 3635 |
components.path = escape(components.path); |
| 3636 |
if (components.scheme !== void 0) { |
| 3637 |
components.path = components.path.split("%3A").join(":"); |
| 3638 |
} |
| 3639 |
} else { |
| 3640 |
components.path = unescape(components.path); |
| 3641 |
} |
| 3642 |
} |
| 3643 |
if (options.reference !== "suffix" && components.scheme) { |
| 3644 |
uriTokens.push(components.scheme); |
| 3645 |
uriTokens.push(":"); |
| 3646 |
} |
| 3647 |
const authority = recomposeAuthority(components, options); |
| 3648 |
if (authority !== void 0) { |
| 3649 |
if (options.reference !== "suffix") { |
| 3650 |
uriTokens.push("//"); |
| 3651 |
} |
| 3652 |
uriTokens.push(authority); |
| 3653 |
if (components.path && components.path.charAt(0) !== "/") { |
| 3654 |
uriTokens.push("/"); |
| 3655 |
} |
| 3656 |
} |
| 3657 |
if (components.path !== void 0) { |
| 3658 |
let s = components.path; |
| 3659 |
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) { |
| 3660 |
s = removeDotSegments(s); |
| 3661 |
} |
| 3662 |
if (authority === void 0) { |
| 3663 |
s = s.replace(/^\/\//u, "/%2F"); |
| 3664 |
} |
| 3665 |
uriTokens.push(s); |
| 3666 |
} |
| 3667 |
if (components.query !== void 0) { |
| 3668 |
uriTokens.push("?"); |
| 3669 |
uriTokens.push(components.query); |
| 3670 |
} |
| 3671 |
if (components.fragment !== void 0) { |
| 3672 |
uriTokens.push("#"); |
| 3673 |
uriTokens.push(components.fragment); |
| 3674 |
} |
| 3675 |
return uriTokens.join(""); |
| 3676 |
} |
| 3677 |
var hexLookUp = Array.from({ length: 127 }, (v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k))); |
| 3678 |
function nonSimpleDomain(value) { |
| 3679 |
let code = 0; |
| 3680 |
for (let i = 0, len = value.length; i < len; ++i) { |
| 3681 |
code = value.charCodeAt(i); |
| 3682 |
if (code > 126 || hexLookUp[code]) { |
| 3683 |
return true; |
| 3684 |
} |
| 3685 |
} |
| 3686 |
return false; |
| 3687 |
} |
| 3688 |
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u; |
| 3689 |
function parse(uri, opts) { |
| 3690 |
const options = Object.assign({}, opts); |
| 3691 |
const parsed = { |
| 3692 |
scheme: void 0, |
| 3693 |
userinfo: void 0, |
| 3694 |
host: "", |
| 3695 |
port: void 0, |
| 3696 |
path: "", |
| 3697 |
query: void 0, |
| 3698 |
fragment: void 0 |
| 3699 |
}; |
| 3700 |
const gotEncoding = uri.indexOf("%") !== -1; |
| 3701 |
let isIP = false; |
| 3702 |
if (options.reference === "suffix") uri = (options.scheme ? options.scheme + ":" : "") + "//" + uri; |
| 3703 |
const matches = uri.match(URI_PARSE); |
| 3704 |
if (matches) { |
| 3705 |
parsed.scheme = matches[1]; |
| 3706 |
parsed.userinfo = matches[3]; |
| 3707 |
parsed.host = matches[4]; |
| 3708 |
parsed.port = parseInt(matches[5], 10); |
| 3709 |
parsed.path = matches[6] || ""; |
| 3710 |
parsed.query = matches[7]; |
| 3711 |
parsed.fragment = matches[8]; |
| 3712 |
if (isNaN(parsed.port)) { |
| 3713 |
parsed.port = matches[5]; |
| 3714 |
} |
| 3715 |
if (parsed.host) { |
| 3716 |
const ipv4result = normalizeIPv4(parsed.host); |
| 3717 |
if (ipv4result.isIPV4 === false) { |
| 3718 |
const ipv6result = normalizeIPv6(ipv4result.host, { isIPV4: false }); |
| 3719 |
parsed.host = ipv6result.host.toLowerCase(); |
| 3720 |
isIP = ipv6result.isIPV6; |
| 3721 |
} else { |
| 3722 |
parsed.host = ipv4result.host; |
| 3723 |
isIP = true; |
| 3724 |
} |
| 3725 |
} |
| 3726 |
if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && !parsed.path && parsed.query === void 0) { |
| 3727 |
parsed.reference = "same-document"; |
| 3728 |
} else if (parsed.scheme === void 0) { |
| 3729 |
parsed.reference = "relative"; |
| 3730 |
} else if (parsed.fragment === void 0) { |
| 3731 |
parsed.reference = "absolute"; |
| 3732 |
} else { |
| 3733 |
parsed.reference = "uri"; |
| 3734 |
} |
| 3735 |
if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) { |
| 3736 |
parsed.error = parsed.error || "URI is not a " + options.reference + " reference."; |
| 3737 |
} |
| 3738 |
const schemeHandler = SCHEMES[(options.scheme || parsed.scheme || "").toLowerCase()]; |
| 3739 |
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) { |
| 3740 |
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) { |
| 3741 |
try { |
| 3742 |
parsed.host = URL.domainToASCII(parsed.host.toLowerCase()); |
| 3743 |
} catch (e) { |
| 3744 |
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e; |
| 3745 |
} |
| 3746 |
} |
| 3747 |
} |
| 3748 |
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) { |
| 3749 |
if (gotEncoding && parsed.scheme !== void 0) { |
| 3750 |
parsed.scheme = unescape(parsed.scheme); |
| 3751 |
} |
| 3752 |
if (gotEncoding && parsed.userinfo !== void 0) { |
| 3753 |
parsed.userinfo = unescape(parsed.userinfo); |
| 3754 |
} |
| 3755 |
if (gotEncoding && parsed.host !== void 0) { |
| 3756 |
parsed.host = unescape(parsed.host); |
| 3757 |
} |
| 3758 |
if (parsed.path !== void 0 && parsed.path.length) { |
| 3759 |
parsed.path = escape(unescape(parsed.path)); |
| 3760 |
} |
| 3761 |
if (parsed.fragment !== void 0 && parsed.fragment.length) { |
| 3762 |
parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment)); |
| 3763 |
} |
| 3764 |
} |
| 3765 |
if (schemeHandler && schemeHandler.parse) { |
| 3766 |
schemeHandler.parse(parsed, options); |
| 3767 |
} |
| 3768 |
} else { |
| 3769 |
parsed.error = parsed.error || "URI can not be parsed."; |
| 3770 |
} |
| 3771 |
return parsed; |
| 3772 |
} |
| 3773 |
var fastUri = { |
| 3774 |
SCHEMES, |
| 3775 |
normalize, |
| 3776 |
resolve, |
| 3777 |
resolveComponents, |
| 3778 |
equal, |
| 3779 |
serialize, |
| 3780 |
parse |
| 3781 |
}; |
| 3782 |
module.exports = fastUri; |
| 3783 |
module.exports.default = fastUri; |
| 3784 |
module.exports.fastUri = fastUri; |
| 3785 |
} |
| 3786 |
}); |
| 3787 |
|
| 3788 |
// node_modules/ajv/dist/runtime/uri.js |
| 3789 |
var require_uri = __commonJS({ |
| 3790 |
"node_modules/ajv/dist/runtime/uri.js"(exports) { |
| 3791 |
"use strict"; |
| 3792 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 3793 |
var uri = require_fast_uri(); |
| 3794 |
uri.code = 'require("ajv/dist/runtime/uri").default'; |
| 3795 |
exports.default = uri; |
| 3796 |
} |
| 3797 |
}); |
| 3798 |
|
| 3799 |
// node_modules/ajv/dist/core.js |
| 3800 |
var require_core = __commonJS({ |
| 3801 |
"node_modules/ajv/dist/core.js"(exports) { |
| 3802 |
"use strict"; |
| 3803 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 3804 |
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0; |
| 3805 |
var validate_1 = require_validate(); |
| 3806 |
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() { |
| 3807 |
return validate_1.KeywordCxt; |
| 3808 |
} }); |
| 3809 |
var codegen_1 = require_codegen(); |
| 3810 |
Object.defineProperty(exports, "_", { enumerable: true, get: function() { |
| 3811 |
return codegen_1._; |
| 3812 |
} }); |
| 3813 |
Object.defineProperty(exports, "str", { enumerable: true, get: function() { |
| 3814 |
return codegen_1.str; |
| 3815 |
} }); |
| 3816 |
Object.defineProperty(exports, "stringify", { enumerable: true, get: function() { |
| 3817 |
return codegen_1.stringify; |
| 3818 |
} }); |
| 3819 |
Object.defineProperty(exports, "nil", { enumerable: true, get: function() { |
| 3820 |
return codegen_1.nil; |
| 3821 |
} }); |
| 3822 |
Object.defineProperty(exports, "Name", { enumerable: true, get: function() { |
| 3823 |
return codegen_1.Name; |
| 3824 |
} }); |
| 3825 |
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() { |
| 3826 |
return codegen_1.CodeGen; |
| 3827 |
} }); |
| 3828 |
var validation_error_1 = require_validation_error(); |
| 3829 |
var ref_error_1 = require_ref_error(); |
| 3830 |
var rules_1 = require_rules(); |
| 3831 |
var compile_1 = require_compile(); |
| 3832 |
var codegen_2 = require_codegen(); |
| 3833 |
var resolve_1 = require_resolve(); |
| 3834 |
var dataType_1 = require_dataType(); |
| 3835 |
var util_1 = require_util(); |
| 3836 |
var $dataRefSchema = require_data2(); |
| 3837 |
var uri_1 = require_uri(); |
| 3838 |
var defaultRegExp = (str, flags) => new RegExp(str, flags); |
| 3839 |
defaultRegExp.code = "new RegExp"; |
| 3840 |
var META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"]; |
| 3841 |
var EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([ |
| 3842 |
"validate", |
| 3843 |
"serialize", |
| 3844 |
"parse", |
| 3845 |
"wrapper", |
| 3846 |
"root", |
| 3847 |
"schema", |
| 3848 |
"keyword", |
| 3849 |
"pattern", |
| 3850 |
"formats", |
| 3851 |
"validate$data", |
| 3852 |
"func", |
| 3853 |
"obj", |
| 3854 |
"Error" |
| 3855 |
]); |
| 3856 |
var removedOptions = { |
| 3857 |
errorDataPath: "", |
| 3858 |
format: "`validateFormats: false` can be used instead.", |
| 3859 |
nullable: '"nullable" keyword is supported by default.', |
| 3860 |
jsonPointers: "Deprecated jsPropertySyntax can be used instead.", |
| 3861 |
extendRefs: "Deprecated ignoreKeywordsWithRef can be used instead.", |
| 3862 |
missingRefs: "Pass empty schema with $id that should be ignored to ajv.addSchema.", |
| 3863 |
processCode: "Use option `code: {process: (code, schemaEnv: object) => string}`", |
| 3864 |
sourceCode: "Use option `code: {source: true}`", |
| 3865 |
strictDefaults: "It is default now, see option `strict`.", |
| 3866 |
strictKeywords: "It is default now, see option `strict`.", |
| 3867 |
uniqueItems: '"uniqueItems" keyword is always validated.', |
| 3868 |
unknownFormats: "Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).", |
| 3869 |
cache: "Map is used as cache, schema object as key.", |
| 3870 |
serialize: "Map is used as cache, schema object as key.", |
| 3871 |
ajvErrors: "It is default now." |
| 3872 |
}; |
| 3873 |
var deprecatedOptions = { |
| 3874 |
ignoreKeywordsWithRef: "", |
| 3875 |
jsPropertySyntax: "", |
| 3876 |
unicode: '"minLength"/"maxLength" account for unicode characters by default.' |
| 3877 |
}; |
| 3878 |
var MAX_EXPRESSION = 200; |
| 3879 |
function requiredOptions(o) { |
| 3880 |
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0; |
| 3881 |
const s = o.strict; |
| 3882 |
const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize; |
| 3883 |
const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0; |
| 3884 |
const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp; |
| 3885 |
const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default; |
| 3886 |
return { |
| 3887 |
strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true, |
| 3888 |
strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true, |
| 3889 |
strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log", |
| 3890 |
strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log", |
| 3891 |
strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false, |
| 3892 |
code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp }, |
| 3893 |
loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION, |
| 3894 |
loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION, |
| 3895 |
meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true, |
| 3896 |
messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true, |
| 3897 |
inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true, |
| 3898 |
schemaId: (_v = o.schemaId) !== null && _v !== void 0 ? _v : "$id", |
| 3899 |
addUsedSchema: (_w = o.addUsedSchema) !== null && _w !== void 0 ? _w : true, |
| 3900 |
validateSchema: (_x = o.validateSchema) !== null && _x !== void 0 ? _x : true, |
| 3901 |
validateFormats: (_y = o.validateFormats) !== null && _y !== void 0 ? _y : true, |
| 3902 |
unicodeRegExp: (_z = o.unicodeRegExp) !== null && _z !== void 0 ? _z : true, |
| 3903 |
int32range: (_0 = o.int32range) !== null && _0 !== void 0 ? _0 : true, |
| 3904 |
uriResolver |
| 3905 |
}; |
| 3906 |
} |
| 3907 |
var Ajv2 = class { |
| 3908 |
constructor(opts = {}) { |
| 3909 |
this.schemas = {}; |
| 3910 |
this.refs = {}; |
| 3911 |
this.formats = {}; |
| 3912 |
this._compilations = /* @__PURE__ */ new Set(); |
| 3913 |
this._loading = {}; |
| 3914 |
this._cache = /* @__PURE__ */ new Map(); |
| 3915 |
opts = this.opts = { ...opts, ...requiredOptions(opts) }; |
| 3916 |
const { es5, lines } = this.opts.code; |
| 3917 |
this.scope = new codegen_2.ValueScope({ scope: {}, prefixes: EXT_SCOPE_NAMES, es5, lines }); |
| 3918 |
this.logger = getLogger(opts.logger); |
| 3919 |
const formatOpt = opts.validateFormats; |
| 3920 |
opts.validateFormats = false; |
| 3921 |
this.RULES = (0, rules_1.getRules)(); |
| 3922 |
checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED"); |
| 3923 |
checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn"); |
| 3924 |
this._metaOpts = getMetaSchemaOptions.call(this); |
| 3925 |
if (opts.formats) |
| 3926 |
addInitialFormats.call(this); |
| 3927 |
this._addVocabularies(); |
| 3928 |
this._addDefaultMetaSchema(); |
| 3929 |
if (opts.keywords) |
| 3930 |
addInitialKeywords.call(this, opts.keywords); |
| 3931 |
if (typeof opts.meta == "object") |
| 3932 |
this.addMetaSchema(opts.meta); |
| 3933 |
addInitialSchemas.call(this); |
| 3934 |
opts.validateFormats = formatOpt; |
| 3935 |
} |
| 3936 |
_addVocabularies() { |
| 3937 |
this.addKeyword("$async"); |
| 3938 |
} |
| 3939 |
_addDefaultMetaSchema() { |
| 3940 |
const { $data, meta, schemaId } = this.opts; |
| 3941 |
let _dataRefSchema = $dataRefSchema; |
| 3942 |
if (schemaId === "id") { |
| 3943 |
_dataRefSchema = { ...$dataRefSchema }; |
| 3944 |
_dataRefSchema.id = _dataRefSchema.$id; |
| 3945 |
delete _dataRefSchema.$id; |
| 3946 |
} |
| 3947 |
if (meta && $data) |
| 3948 |
this.addMetaSchema(_dataRefSchema, _dataRefSchema[schemaId], false); |
| 3949 |
} |
| 3950 |
defaultMeta() { |
| 3951 |
const { meta, schemaId } = this.opts; |
| 3952 |
return this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : void 0; |
| 3953 |
} |
| 3954 |
validate(schemaKeyRef, data) { |
| 3955 |
let v; |
| 3956 |
if (typeof schemaKeyRef == "string") { |
| 3957 |
v = this.getSchema(schemaKeyRef); |
| 3958 |
if (!v) |
| 3959 |
throw new Error(`no schema with key or ref "${schemaKeyRef}"`); |
| 3960 |
} else { |
| 3961 |
v = this.compile(schemaKeyRef); |
| 3962 |
} |
| 3963 |
const valid = v(data); |
| 3964 |
if (!("$async" in v)) |
| 3965 |
this.errors = v.errors; |
| 3966 |
return valid; |
| 3967 |
} |
| 3968 |
compile(schema, _meta) { |
| 3969 |
const sch = this._addSchema(schema, _meta); |
| 3970 |
return sch.validate || this._compileSchemaEnv(sch); |
| 3971 |
} |
| 3972 |
compileAsync(schema, meta) { |
| 3973 |
if (typeof this.opts.loadSchema != "function") { |
| 3974 |
throw new Error("options.loadSchema should be a function"); |
| 3975 |
} |
| 3976 |
const { loadSchema } = this.opts; |
| 3977 |
return runCompileAsync.call(this, schema, meta); |
| 3978 |
async function runCompileAsync(_schema, _meta) { |
| 3979 |
await loadMetaSchema.call(this, _schema.$schema); |
| 3980 |
const sch = this._addSchema(_schema, _meta); |
| 3981 |
return sch.validate || _compileAsync.call(this, sch); |
| 3982 |
} |
| 3983 |
async function loadMetaSchema($ref) { |
| 3984 |
if ($ref && !this.getSchema($ref)) { |
| 3985 |
await runCompileAsync.call(this, { $ref }, true); |
| 3986 |
} |
| 3987 |
} |
| 3988 |
async function _compileAsync(sch) { |
| 3989 |
try { |
| 3990 |
return this._compileSchemaEnv(sch); |
| 3991 |
} catch (e) { |
| 3992 |
if (!(e instanceof ref_error_1.default)) |
| 3993 |
throw e; |
| 3994 |
checkLoaded.call(this, e); |
| 3995 |
await loadMissingSchema.call(this, e.missingSchema); |
| 3996 |
return _compileAsync.call(this, sch); |
| 3997 |
} |
| 3998 |
} |
| 3999 |
function checkLoaded({ missingSchema: ref, missingRef }) { |
| 4000 |
if (this.refs[ref]) { |
| 4001 |
throw new Error(`AnySchema ${ref} is loaded but ${missingRef} cannot be resolved`); |
| 4002 |
} |
| 4003 |
} |
| 4004 |
async function loadMissingSchema(ref) { |
| 4005 |
const _schema = await _loadSchema.call(this, ref); |
| 4006 |
if (!this.refs[ref]) |
| 4007 |
await loadMetaSchema.call(this, _schema.$schema); |
| 4008 |
if (!this.refs[ref]) |
| 4009 |
this.addSchema(_schema, ref, meta); |
| 4010 |
} |
| 4011 |
async function _loadSchema(ref) { |
| 4012 |
const p = this._loading[ref]; |
| 4013 |
if (p) |
| 4014 |
return p; |
| 4015 |
try { |
| 4016 |
return await (this._loading[ref] = loadSchema(ref)); |
| 4017 |
} finally { |
| 4018 |
delete this._loading[ref]; |
| 4019 |
} |
| 4020 |
} |
| 4021 |
} |
| 4022 |
// Adds schema to the instance |
| 4023 |
addSchema(schema, key, _meta, _validateSchema = this.opts.validateSchema) { |
| 4024 |
if (Array.isArray(schema)) { |
| 4025 |
for (const sch of schema) |
| 4026 |
this.addSchema(sch, void 0, _meta, _validateSchema); |
| 4027 |
return this; |
| 4028 |
} |
| 4029 |
let id; |
| 4030 |
if (typeof schema === "object") { |
| 4031 |
const { schemaId } = this.opts; |
| 4032 |
id = schema[schemaId]; |
| 4033 |
if (id !== void 0 && typeof id != "string") { |
| 4034 |
throw new Error(`schema ${schemaId} must be string`); |
| 4035 |
} |
| 4036 |
} |
| 4037 |
key = (0, resolve_1.normalizeId)(key || id); |
| 4038 |
this._checkUnique(key); |
| 4039 |
this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true); |
| 4040 |
return this; |
| 4041 |
} |
| 4042 |
// Add schema that will be used to validate other schemas |
| 4043 |
// options in META_IGNORE_OPTIONS are alway set to false |
| 4044 |
addMetaSchema(schema, key, _validateSchema = this.opts.validateSchema) { |
| 4045 |
this.addSchema(schema, key, true, _validateSchema); |
| 4046 |
return this; |
| 4047 |
} |
| 4048 |
// Validate schema against its meta-schema |
| 4049 |
validateSchema(schema, throwOrLogError) { |
| 4050 |
if (typeof schema == "boolean") |
| 4051 |
return true; |
| 4052 |
let $schema; |
| 4053 |
$schema = schema.$schema; |
| 4054 |
if ($schema !== void 0 && typeof $schema != "string") { |
| 4055 |
throw new Error("$schema must be a string"); |
| 4056 |
} |
| 4057 |
$schema = $schema || this.opts.defaultMeta || this.defaultMeta(); |
| 4058 |
if (!$schema) { |
| 4059 |
this.logger.warn("meta-schema not available"); |
| 4060 |
this.errors = null; |
| 4061 |
return true; |
| 4062 |
} |
| 4063 |
const valid = this.validate($schema, schema); |
| 4064 |
if (!valid && throwOrLogError) { |
| 4065 |
const message = "schema is invalid: " + this.errorsText(); |
| 4066 |
if (this.opts.validateSchema === "log") |
| 4067 |
this.logger.error(message); |
| 4068 |
else |
| 4069 |
throw new Error(message); |
| 4070 |
} |
| 4071 |
return valid; |
| 4072 |
} |
| 4073 |
// Get compiled schema by `key` or `ref`. |
| 4074 |
// (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id) |
| 4075 |
getSchema(keyRef) { |
| 4076 |
let sch; |
| 4077 |
while (typeof (sch = getSchEnv.call(this, keyRef)) == "string") |
| 4078 |
keyRef = sch; |
| 4079 |
if (sch === void 0) { |
| 4080 |
const { schemaId } = this.opts; |
| 4081 |
const root = new compile_1.SchemaEnv({ schema: {}, schemaId }); |
| 4082 |
sch = compile_1.resolveSchema.call(this, root, keyRef); |
| 4083 |
if (!sch) |
| 4084 |
return; |
| 4085 |
this.refs[keyRef] = sch; |
| 4086 |
} |
| 4087 |
return sch.validate || this._compileSchemaEnv(sch); |
| 4088 |
} |
| 4089 |
// Remove cached schema(s). |
| 4090 |
// If no parameter is passed all schemas but meta-schemas are removed. |
| 4091 |
// If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed. |
| 4092 |
// Even if schema is referenced by other schemas it still can be removed as other schemas have local references. |
| 4093 |
removeSchema(schemaKeyRef) { |
| 4094 |
if (schemaKeyRef instanceof RegExp) { |
| 4095 |
this._removeAllSchemas(this.schemas, schemaKeyRef); |
| 4096 |
this._removeAllSchemas(this.refs, schemaKeyRef); |
| 4097 |
return this; |
| 4098 |
} |
| 4099 |
switch (typeof schemaKeyRef) { |
| 4100 |
case "undefined": |
| 4101 |
this._removeAllSchemas(this.schemas); |
| 4102 |
this._removeAllSchemas(this.refs); |
| 4103 |
this._cache.clear(); |
| 4104 |
return this; |
| 4105 |
case "string": { |
| 4106 |
const sch = getSchEnv.call(this, schemaKeyRef); |
| 4107 |
if (typeof sch == "object") |
| 4108 |
this._cache.delete(sch.schema); |
| 4109 |
delete this.schemas[schemaKeyRef]; |
| 4110 |
delete this.refs[schemaKeyRef]; |
| 4111 |
return this; |
| 4112 |
} |
| 4113 |
case "object": { |
| 4114 |
const cacheKey = schemaKeyRef; |
| 4115 |
this._cache.delete(cacheKey); |
| 4116 |
let id = schemaKeyRef[this.opts.schemaId]; |
| 4117 |
if (id) { |
| 4118 |
id = (0, resolve_1.normalizeId)(id); |
| 4119 |
delete this.schemas[id]; |
| 4120 |
delete this.refs[id]; |
| 4121 |
} |
| 4122 |
return this; |
| 4123 |
} |
| 4124 |
default: |
| 4125 |
throw new Error("ajv.removeSchema: invalid parameter"); |
| 4126 |
} |
| 4127 |
} |
| 4128 |
// add "vocabulary" - a collection of keywords |
| 4129 |
addVocabulary(definitions) { |
| 4130 |
for (const def of definitions) |
| 4131 |
this.addKeyword(def); |
| 4132 |
return this; |
| 4133 |
} |
| 4134 |
addKeyword(kwdOrDef, def) { |
| 4135 |
let keyword; |
| 4136 |
if (typeof kwdOrDef == "string") { |
| 4137 |
keyword = kwdOrDef; |
| 4138 |
if (typeof def == "object") { |
| 4139 |
this.logger.warn("these parameters are deprecated, see docs for addKeyword"); |
| 4140 |
def.keyword = keyword; |
| 4141 |
} |
| 4142 |
} else if (typeof kwdOrDef == "object" && def === void 0) { |
| 4143 |
def = kwdOrDef; |
| 4144 |
keyword = def.keyword; |
| 4145 |
if (Array.isArray(keyword) && !keyword.length) { |
| 4146 |
throw new Error("addKeywords: keyword must be string or non-empty array"); |
| 4147 |
} |
| 4148 |
} else { |
| 4149 |
throw new Error("invalid addKeywords parameters"); |
| 4150 |
} |
| 4151 |
checkKeyword.call(this, keyword, def); |
| 4152 |
if (!def) { |
| 4153 |
(0, util_1.eachItem)(keyword, (kwd) => addRule.call(this, kwd)); |
| 4154 |
return this; |
| 4155 |
} |
| 4156 |
keywordMetaschema.call(this, def); |
| 4157 |
const definition = { |
| 4158 |
...def, |
| 4159 |
type: (0, dataType_1.getJSONTypes)(def.type), |
| 4160 |
schemaType: (0, dataType_1.getJSONTypes)(def.schemaType) |
| 4161 |
}; |
| 4162 |
(0, util_1.eachItem)(keyword, definition.type.length === 0 ? (k) => addRule.call(this, k, definition) : (k) => definition.type.forEach((t) => addRule.call(this, k, definition, t))); |
| 4163 |
return this; |
| 4164 |
} |
| 4165 |
getKeyword(keyword) { |
| 4166 |
const rule = this.RULES.all[keyword]; |
| 4167 |
return typeof rule == "object" ? rule.definition : !!rule; |
| 4168 |
} |
| 4169 |
// Remove keyword |
| 4170 |
removeKeyword(keyword) { |
| 4171 |
const { RULES } = this; |
| 4172 |
delete RULES.keywords[keyword]; |
| 4173 |
delete RULES.all[keyword]; |
| 4174 |
for (const group of RULES.rules) { |
| 4175 |
const i = group.rules.findIndex((rule) => rule.keyword === keyword); |
| 4176 |
if (i >= 0) |
| 4177 |
group.rules.splice(i, 1); |
| 4178 |
} |
| 4179 |
return this; |
| 4180 |
} |
| 4181 |
// Add format |
| 4182 |
addFormat(name, format) { |
| 4183 |
if (typeof format == "string") |
| 4184 |
format = new RegExp(format); |
| 4185 |
this.formats[name] = format; |
| 4186 |
return this; |
| 4187 |
} |
| 4188 |
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) { |
| 4189 |
if (!errors || errors.length === 0) |
| 4190 |
return "No errors"; |
| 4191 |
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text, msg) => text + separator + msg); |
| 4192 |
} |
| 4193 |
$dataMetaSchema(metaSchema, keywordsJsonPointers) { |
| 4194 |
const rules = this.RULES.all; |
| 4195 |
metaSchema = JSON.parse(JSON.stringify(metaSchema)); |
| 4196 |
for (const jsonPointer of keywordsJsonPointers) { |
| 4197 |
const segments = jsonPointer.split("/").slice(1); |
| 4198 |
let keywords = metaSchema; |
| 4199 |
for (const seg of segments) |
| 4200 |
keywords = keywords[seg]; |
| 4201 |
for (const key in rules) { |
| 4202 |
const rule = rules[key]; |
| 4203 |
if (typeof rule != "object") |
| 4204 |
continue; |
| 4205 |
const { $data } = rule.definition; |
| 4206 |
const schema = keywords[key]; |
| 4207 |
if ($data && schema) |
| 4208 |
keywords[key] = schemaOrData(schema); |
| 4209 |
} |
| 4210 |
} |
| 4211 |
return metaSchema; |
| 4212 |
} |
| 4213 |
_removeAllSchemas(schemas, regex) { |
| 4214 |
for (const keyRef in schemas) { |
| 4215 |
const sch = schemas[keyRef]; |
| 4216 |
if (!regex || regex.test(keyRef)) { |
| 4217 |
if (typeof sch == "string") { |
| 4218 |
delete schemas[keyRef]; |
| 4219 |
} else if (sch && !sch.meta) { |
| 4220 |
this._cache.delete(sch.schema); |
| 4221 |
delete schemas[keyRef]; |
| 4222 |
} |
| 4223 |
} |
| 4224 |
} |
| 4225 |
} |
| 4226 |
_addSchema(schema, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) { |
| 4227 |
let id; |
| 4228 |
const { schemaId } = this.opts; |
| 4229 |
if (typeof schema == "object") { |
| 4230 |
id = schema[schemaId]; |
| 4231 |
} else { |
| 4232 |
if (this.opts.jtd) |
| 4233 |
throw new Error("schema must be object"); |
| 4234 |
else if (typeof schema != "boolean") |
| 4235 |
throw new Error("schema must be object or boolean"); |
| 4236 |
} |
| 4237 |
let sch = this._cache.get(schema); |
| 4238 |
if (sch !== void 0) |
| 4239 |
return sch; |
| 4240 |
baseId = (0, resolve_1.normalizeId)(id || baseId); |
| 4241 |
const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId); |
| 4242 |
sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs }); |
| 4243 |
this._cache.set(sch.schema, sch); |
| 4244 |
if (addSchema && !baseId.startsWith("#")) { |
| 4245 |
if (baseId) |
| 4246 |
this._checkUnique(baseId); |
| 4247 |
this.refs[baseId] = sch; |
| 4248 |
} |
| 4249 |
if (validateSchema) |
| 4250 |
this.validateSchema(schema, true); |
| 4251 |
return sch; |
| 4252 |
} |
| 4253 |
_checkUnique(id) { |
| 4254 |
if (this.schemas[id] || this.refs[id]) { |
| 4255 |
throw new Error(`schema with key or id "${id}" already exists`); |
| 4256 |
} |
| 4257 |
} |
| 4258 |
_compileSchemaEnv(sch) { |
| 4259 |
if (sch.meta) |
| 4260 |
this._compileMetaSchema(sch); |
| 4261 |
else |
| 4262 |
compile_1.compileSchema.call(this, sch); |
| 4263 |
if (!sch.validate) |
| 4264 |
throw new Error("ajv implementation error"); |
| 4265 |
return sch.validate; |
| 4266 |
} |
| 4267 |
_compileMetaSchema(sch) { |
| 4268 |
const currentOpts = this.opts; |
| 4269 |
this.opts = this._metaOpts; |
| 4270 |
try { |
| 4271 |
compile_1.compileSchema.call(this, sch); |
| 4272 |
} finally { |
| 4273 |
this.opts = currentOpts; |
| 4274 |
} |
| 4275 |
} |
| 4276 |
}; |
| 4277 |
Ajv2.ValidationError = validation_error_1.default; |
| 4278 |
Ajv2.MissingRefError = ref_error_1.default; |
| 4279 |
exports.default = Ajv2; |
| 4280 |
function checkOptions(checkOpts, options, msg, log = "error") { |
| 4281 |
for (const key in checkOpts) { |
| 4282 |
const opt = key; |
| 4283 |
if (opt in options) |
| 4284 |
this.logger[log](`${msg}: option ${key}. ${checkOpts[opt]}`); |
| 4285 |
} |
| 4286 |
} |
| 4287 |
function getSchEnv(keyRef) { |
| 4288 |
keyRef = (0, resolve_1.normalizeId)(keyRef); |
| 4289 |
return this.schemas[keyRef] || this.refs[keyRef]; |
| 4290 |
} |
| 4291 |
function addInitialSchemas() { |
| 4292 |
const optsSchemas = this.opts.schemas; |
| 4293 |
if (!optsSchemas) |
| 4294 |
return; |
| 4295 |
if (Array.isArray(optsSchemas)) |
| 4296 |
this.addSchema(optsSchemas); |
| 4297 |
else |
| 4298 |
for (const key in optsSchemas) |
| 4299 |
this.addSchema(optsSchemas[key], key); |
| 4300 |
} |
| 4301 |
function addInitialFormats() { |
| 4302 |
for (const name in this.opts.formats) { |
| 4303 |
const format = this.opts.formats[name]; |
| 4304 |
if (format) |
| 4305 |
this.addFormat(name, format); |
| 4306 |
} |
| 4307 |
} |
| 4308 |
function addInitialKeywords(defs) { |
| 4309 |
if (Array.isArray(defs)) { |
| 4310 |
this.addVocabulary(defs); |
| 4311 |
return; |
| 4312 |
} |
| 4313 |
this.logger.warn("keywords option as map is deprecated, pass array"); |
| 4314 |
for (const keyword in defs) { |
| 4315 |
const def = defs[keyword]; |
| 4316 |
if (!def.keyword) |
| 4317 |
def.keyword = keyword; |
| 4318 |
this.addKeyword(def); |
| 4319 |
} |
| 4320 |
} |
| 4321 |
function getMetaSchemaOptions() { |
| 4322 |
const metaOpts = { ...this.opts }; |
| 4323 |
for (const opt of META_IGNORE_OPTIONS) |
| 4324 |
delete metaOpts[opt]; |
| 4325 |
return metaOpts; |
| 4326 |
} |
| 4327 |
var noLogs = { log() { |
| 4328 |
}, warn() { |
| 4329 |
}, error() { |
| 4330 |
} }; |
| 4331 |
function getLogger(logger) { |
| 4332 |
if (logger === false) |
| 4333 |
return noLogs; |
| 4334 |
if (logger === void 0) |
| 4335 |
return console; |
| 4336 |
if (logger.log && logger.warn && logger.error) |
| 4337 |
return logger; |
| 4338 |
throw new Error("logger must implement log, warn and error methods"); |
| 4339 |
} |
| 4340 |
var KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i; |
| 4341 |
function checkKeyword(keyword, def) { |
| 4342 |
const { RULES } = this; |
| 4343 |
(0, util_1.eachItem)(keyword, (kwd) => { |
| 4344 |
if (RULES.keywords[kwd]) |
| 4345 |
throw new Error(`Keyword ${kwd} is already defined`); |
| 4346 |
if (!KEYWORD_NAME.test(kwd)) |
| 4347 |
throw new Error(`Keyword ${kwd} has invalid name`); |
| 4348 |
}); |
| 4349 |
if (!def) |
| 4350 |
return; |
| 4351 |
if (def.$data && !("code" in def || "validate" in def)) { |
| 4352 |
throw new Error('$data keyword must have "code" or "validate" function'); |
| 4353 |
} |
| 4354 |
} |
| 4355 |
function addRule(keyword, definition, dataType) { |
| 4356 |
var _a; |
| 4357 |
const post = definition === null || definition === void 0 ? void 0 : definition.post; |
| 4358 |
if (dataType && post) |
| 4359 |
throw new Error('keyword with "post" flag cannot have "type"'); |
| 4360 |
const { RULES } = this; |
| 4361 |
let ruleGroup = post ? RULES.post : RULES.rules.find(({ type: t }) => t === dataType); |
| 4362 |
if (!ruleGroup) { |
| 4363 |
ruleGroup = { type: dataType, rules: [] }; |
| 4364 |
RULES.rules.push(ruleGroup); |
| 4365 |
} |
| 4366 |
RULES.keywords[keyword] = true; |
| 4367 |
if (!definition) |
| 4368 |
return; |
| 4369 |
const rule = { |
| 4370 |
keyword, |
| 4371 |
definition: { |
| 4372 |
...definition, |
| 4373 |
type: (0, dataType_1.getJSONTypes)(definition.type), |
| 4374 |
schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType) |
| 4375 |
} |
| 4376 |
}; |
| 4377 |
if (definition.before) |
| 4378 |
addBeforeRule.call(this, ruleGroup, rule, definition.before); |
| 4379 |
else |
| 4380 |
ruleGroup.rules.push(rule); |
| 4381 |
RULES.all[keyword] = rule; |
| 4382 |
(_a = definition.implements) === null || _a === void 0 ? void 0 : _a.forEach((kwd) => this.addKeyword(kwd)); |
| 4383 |
} |
| 4384 |
function addBeforeRule(ruleGroup, rule, before) { |
| 4385 |
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before); |
| 4386 |
if (i >= 0) { |
| 4387 |
ruleGroup.rules.splice(i, 0, rule); |
| 4388 |
} else { |
| 4389 |
ruleGroup.rules.push(rule); |
| 4390 |
this.logger.warn(`rule ${before} is not defined`); |
| 4391 |
} |
| 4392 |
} |
| 4393 |
function keywordMetaschema(def) { |
| 4394 |
let { metaSchema } = def; |
| 4395 |
if (metaSchema === void 0) |
| 4396 |
return; |
| 4397 |
if (def.$data && this.opts.$data) |
| 4398 |
metaSchema = schemaOrData(metaSchema); |
| 4399 |
def.validateSchema = this.compile(metaSchema, true); |
| 4400 |
} |
| 4401 |
var $dataRef = { |
| 4402 |
$ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#" |
| 4403 |
}; |
| 4404 |
function schemaOrData(schema) { |
| 4405 |
return { anyOf: [schema, $dataRef] }; |
| 4406 |
} |
| 4407 |
} |
| 4408 |
}); |
| 4409 |
|
| 4410 |
// node_modules/ajv/dist/vocabularies/core/ref.js |
| 4411 |
var require_ref = __commonJS({ |
| 4412 |
"node_modules/ajv/dist/vocabularies/core/ref.js"(exports) { |
| 4413 |
"use strict"; |
| 4414 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4415 |
exports.callRef = exports.getValidate = void 0; |
| 4416 |
var ref_error_1 = require_ref_error(); |
| 4417 |
var code_1 = require_code2(); |
| 4418 |
var codegen_1 = require_codegen(); |
| 4419 |
var names_1 = require_names(); |
| 4420 |
var compile_1 = require_compile(); |
| 4421 |
var util_1 = require_util(); |
| 4422 |
var def = { |
| 4423 |
keyword: "$ref", |
| 4424 |
schemaType: "string", |
| 4425 |
code(cxt) { |
| 4426 |
const { gen, schema: $ref, it } = cxt; |
| 4427 |
const { baseId, schemaEnv: env, validateName, opts, self } = it; |
| 4428 |
const { root } = env; |
| 4429 |
if (($ref === "#" || $ref === "#/") && baseId === root.baseId) |
| 4430 |
return callRootRef(); |
| 4431 |
const schOrEnv = compile_1.resolveRef.call(self, root, baseId, $ref); |
| 4432 |
if (schOrEnv === void 0) |
| 4433 |
throw new ref_error_1.default(it.opts.uriResolver, baseId, $ref); |
| 4434 |
if (schOrEnv instanceof compile_1.SchemaEnv) |
| 4435 |
return callValidate(schOrEnv); |
| 4436 |
return inlineRefSchema(schOrEnv); |
| 4437 |
function callRootRef() { |
| 4438 |
if (env === root) |
| 4439 |
return callRef(cxt, validateName, env, env.$async); |
| 4440 |
const rootName = gen.scopeValue("root", { ref: root }); |
| 4441 |
return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root, root.$async); |
| 4442 |
} |
| 4443 |
function callValidate(sch) { |
| 4444 |
const v = getValidate(cxt, sch); |
| 4445 |
callRef(cxt, v, sch, sch.$async); |
| 4446 |
} |
| 4447 |
function inlineRefSchema(sch) { |
| 4448 |
const schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: (0, codegen_1.stringify)(sch) } : { ref: sch }); |
| 4449 |
const valid = gen.name("valid"); |
| 4450 |
const schCxt = cxt.subschema({ |
| 4451 |
schema: sch, |
| 4452 |
dataTypes: [], |
| 4453 |
schemaPath: codegen_1.nil, |
| 4454 |
topSchemaRef: schName, |
| 4455 |
errSchemaPath: $ref |
| 4456 |
}, valid); |
| 4457 |
cxt.mergeEvaluated(schCxt); |
| 4458 |
cxt.ok(valid); |
| 4459 |
} |
| 4460 |
} |
| 4461 |
}; |
| 4462 |
function getValidate(cxt, sch) { |
| 4463 |
const { gen } = cxt; |
| 4464 |
return sch.validate ? gen.scopeValue("validate", { ref: sch.validate }) : (0, codegen_1._)`${gen.scopeValue("wrapper", { ref: sch })}.validate`; |
| 4465 |
} |
| 4466 |
exports.getValidate = getValidate; |
| 4467 |
function callRef(cxt, v, sch, $async) { |
| 4468 |
const { gen, it } = cxt; |
| 4469 |
const { allErrors, schemaEnv: env, opts } = it; |
| 4470 |
const passCxt = opts.passContext ? names_1.default.this : codegen_1.nil; |
| 4471 |
if ($async) |
| 4472 |
callAsyncRef(); |
| 4473 |
else |
| 4474 |
callSyncRef(); |
| 4475 |
function callAsyncRef() { |
| 4476 |
if (!env.$async) |
| 4477 |
throw new Error("async schema referenced by sync schema"); |
| 4478 |
const valid = gen.let("valid"); |
| 4479 |
gen.try(() => { |
| 4480 |
gen.code((0, codegen_1._)`await ${(0, code_1.callValidateCode)(cxt, v, passCxt)}`); |
| 4481 |
addEvaluatedFrom(v); |
| 4482 |
if (!allErrors) |
| 4483 |
gen.assign(valid, true); |
| 4484 |
}, (e) => { |
| 4485 |
gen.if((0, codegen_1._)`!(${e} instanceof ${it.ValidationError})`, () => gen.throw(e)); |
| 4486 |
addErrorsFrom(e); |
| 4487 |
if (!allErrors) |
| 4488 |
gen.assign(valid, false); |
| 4489 |
}); |
| 4490 |
cxt.ok(valid); |
| 4491 |
} |
| 4492 |
function callSyncRef() { |
| 4493 |
cxt.result((0, code_1.callValidateCode)(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v)); |
| 4494 |
} |
| 4495 |
function addErrorsFrom(source) { |
| 4496 |
const errs = (0, codegen_1._)`${source}.errors`; |
| 4497 |
gen.assign(names_1.default.vErrors, (0, codegen_1._)`${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`); |
| 4498 |
gen.assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`); |
| 4499 |
} |
| 4500 |
function addEvaluatedFrom(source) { |
| 4501 |
var _a; |
| 4502 |
if (!it.opts.unevaluated) |
| 4503 |
return; |
| 4504 |
const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated; |
| 4505 |
if (it.props !== true) { |
| 4506 |
if (schEvaluated && !schEvaluated.dynamicProps) { |
| 4507 |
if (schEvaluated.props !== void 0) { |
| 4508 |
it.props = util_1.mergeEvaluated.props(gen, schEvaluated.props, it.props); |
| 4509 |
} |
| 4510 |
} else { |
| 4511 |
const props = gen.var("props", (0, codegen_1._)`${source}.evaluated.props`); |
| 4512 |
it.props = util_1.mergeEvaluated.props(gen, props, it.props, codegen_1.Name); |
| 4513 |
} |
| 4514 |
} |
| 4515 |
if (it.items !== true) { |
| 4516 |
if (schEvaluated && !schEvaluated.dynamicItems) { |
| 4517 |
if (schEvaluated.items !== void 0) { |
| 4518 |
it.items = util_1.mergeEvaluated.items(gen, schEvaluated.items, it.items); |
| 4519 |
} |
| 4520 |
} else { |
| 4521 |
const items = gen.var("items", (0, codegen_1._)`${source}.evaluated.items`); |
| 4522 |
it.items = util_1.mergeEvaluated.items(gen, items, it.items, codegen_1.Name); |
| 4523 |
} |
| 4524 |
} |
| 4525 |
} |
| 4526 |
} |
| 4527 |
exports.callRef = callRef; |
| 4528 |
exports.default = def; |
| 4529 |
} |
| 4530 |
}); |
| 4531 |
|
| 4532 |
// node_modules/ajv-draft-04/dist/vocabulary/core.js |
| 4533 |
var require_core2 = __commonJS({ |
| 4534 |
"node_modules/ajv-draft-04/dist/vocabulary/core.js"(exports) { |
| 4535 |
"use strict"; |
| 4536 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4537 |
var ref_1 = require_ref(); |
| 4538 |
var core = [ |
| 4539 |
"$schema", |
| 4540 |
"id", |
| 4541 |
"$defs", |
| 4542 |
{ keyword: "$comment" }, |
| 4543 |
"definitions", |
| 4544 |
ref_1.default |
| 4545 |
]; |
| 4546 |
exports.default = core; |
| 4547 |
} |
| 4548 |
}); |
| 4549 |
|
| 4550 |
// node_modules/ajv-draft-04/dist/vocabulary/validation/limitNumber.js |
| 4551 |
var require_limitNumber = __commonJS({ |
| 4552 |
"node_modules/ajv-draft-04/dist/vocabulary/validation/limitNumber.js"(exports) { |
| 4553 |
"use strict"; |
| 4554 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4555 |
var core_1 = require_core(); |
| 4556 |
var codegen_1 = require_codegen(); |
| 4557 |
var ops = codegen_1.operators; |
| 4558 |
var KWDs = { |
| 4559 |
maximum: { |
| 4560 |
exclusive: "exclusiveMaximum", |
| 4561 |
ops: [ |
| 4562 |
{ okStr: "<=", ok: ops.LTE, fail: ops.GT }, |
| 4563 |
{ okStr: "<", ok: ops.LT, fail: ops.GTE } |
| 4564 |
] |
| 4565 |
}, |
| 4566 |
minimum: { |
| 4567 |
exclusive: "exclusiveMinimum", |
| 4568 |
ops: [ |
| 4569 |
{ okStr: ">=", ok: ops.GTE, fail: ops.LT }, |
| 4570 |
{ okStr: ">", ok: ops.GT, fail: ops.LTE } |
| 4571 |
] |
| 4572 |
} |
| 4573 |
}; |
| 4574 |
var error = { |
| 4575 |
message: (cxt) => core_1.str`must be ${kwdOp(cxt).okStr} ${cxt.schemaCode}`, |
| 4576 |
params: (cxt) => core_1._`{comparison: ${kwdOp(cxt).okStr}, limit: ${cxt.schemaCode}}` |
| 4577 |
}; |
| 4578 |
var def = { |
| 4579 |
keyword: Object.keys(KWDs), |
| 4580 |
type: "number", |
| 4581 |
schemaType: "number", |
| 4582 |
$data: true, |
| 4583 |
error, |
| 4584 |
code(cxt) { |
| 4585 |
const { data, schemaCode } = cxt; |
| 4586 |
cxt.fail$data(core_1._`${data} ${kwdOp(cxt).fail} ${schemaCode} || isNaN(${data})`); |
| 4587 |
} |
| 4588 |
}; |
| 4589 |
function kwdOp(cxt) { |
| 4590 |
var _a; |
| 4591 |
const keyword = cxt.keyword; |
| 4592 |
const opsIdx = ((_a = cxt.parentSchema) === null || _a === void 0 ? void 0 : _a[KWDs[keyword].exclusive]) ? 1 : 0; |
| 4593 |
return KWDs[keyword].ops[opsIdx]; |
| 4594 |
} |
| 4595 |
exports.default = def; |
| 4596 |
} |
| 4597 |
}); |
| 4598 |
|
| 4599 |
// node_modules/ajv-draft-04/dist/vocabulary/validation/limitNumberExclusive.js |
| 4600 |
var require_limitNumberExclusive = __commonJS({ |
| 4601 |
"node_modules/ajv-draft-04/dist/vocabulary/validation/limitNumberExclusive.js"(exports) { |
| 4602 |
"use strict"; |
| 4603 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4604 |
var KWDs = { |
| 4605 |
exclusiveMaximum: "maximum", |
| 4606 |
exclusiveMinimum: "minimum" |
| 4607 |
}; |
| 4608 |
var def = { |
| 4609 |
keyword: Object.keys(KWDs), |
| 4610 |
type: "number", |
| 4611 |
schemaType: "boolean", |
| 4612 |
code({ keyword, parentSchema }) { |
| 4613 |
const limitKwd = KWDs[keyword]; |
| 4614 |
if (parentSchema[limitKwd] === void 0) { |
| 4615 |
throw new Error(`${keyword} can only be used with ${limitKwd}`); |
| 4616 |
} |
| 4617 |
} |
| 4618 |
}; |
| 4619 |
exports.default = def; |
| 4620 |
} |
| 4621 |
}); |
| 4622 |
|
| 4623 |
// node_modules/ajv/dist/vocabularies/validation/multipleOf.js |
| 4624 |
var require_multipleOf = __commonJS({ |
| 4625 |
"node_modules/ajv/dist/vocabularies/validation/multipleOf.js"(exports) { |
| 4626 |
"use strict"; |
| 4627 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4628 |
var codegen_1 = require_codegen(); |
| 4629 |
var error = { |
| 4630 |
message: ({ schemaCode }) => (0, codegen_1.str)`must be multiple of ${schemaCode}`, |
| 4631 |
params: ({ schemaCode }) => (0, codegen_1._)`{multipleOf: ${schemaCode}}` |
| 4632 |
}; |
| 4633 |
var def = { |
| 4634 |
keyword: "multipleOf", |
| 4635 |
type: "number", |
| 4636 |
schemaType: "number", |
| 4637 |
$data: true, |
| 4638 |
error, |
| 4639 |
code(cxt) { |
| 4640 |
const { gen, data, schemaCode, it } = cxt; |
| 4641 |
const prec = it.opts.multipleOfPrecision; |
| 4642 |
const res = gen.let("res"); |
| 4643 |
const invalid = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`; |
| 4644 |
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`); |
| 4645 |
} |
| 4646 |
}; |
| 4647 |
exports.default = def; |
| 4648 |
} |
| 4649 |
}); |
| 4650 |
|
| 4651 |
// node_modules/ajv/dist/runtime/ucs2length.js |
| 4652 |
var require_ucs2length = __commonJS({ |
| 4653 |
"node_modules/ajv/dist/runtime/ucs2length.js"(exports) { |
| 4654 |
"use strict"; |
| 4655 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4656 |
function ucs2length(str) { |
| 4657 |
const len = str.length; |
| 4658 |
let length = 0; |
| 4659 |
let pos = 0; |
| 4660 |
let value; |
| 4661 |
while (pos < len) { |
| 4662 |
length++; |
| 4663 |
value = str.charCodeAt(pos++); |
| 4664 |
if (value >= 55296 && value <= 56319 && pos < len) { |
| 4665 |
value = str.charCodeAt(pos); |
| 4666 |
if ((value & 64512) === 56320) |
| 4667 |
pos++; |
| 4668 |
} |
| 4669 |
} |
| 4670 |
return length; |
| 4671 |
} |
| 4672 |
exports.default = ucs2length; |
| 4673 |
ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default'; |
| 4674 |
} |
| 4675 |
}); |
| 4676 |
|
| 4677 |
// node_modules/ajv/dist/vocabularies/validation/limitLength.js |
| 4678 |
var require_limitLength = __commonJS({ |
| 4679 |
"node_modules/ajv/dist/vocabularies/validation/limitLength.js"(exports) { |
| 4680 |
"use strict"; |
| 4681 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4682 |
var codegen_1 = require_codegen(); |
| 4683 |
var util_1 = require_util(); |
| 4684 |
var ucs2length_1 = require_ucs2length(); |
| 4685 |
var error = { |
| 4686 |
message({ keyword, schemaCode }) { |
| 4687 |
const comp = keyword === "maxLength" ? "more" : "fewer"; |
| 4688 |
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} characters`; |
| 4689 |
}, |
| 4690 |
params: ({ schemaCode }) => (0, codegen_1._)`{limit: ${schemaCode}}` |
| 4691 |
}; |
| 4692 |
var def = { |
| 4693 |
keyword: ["maxLength", "minLength"], |
| 4694 |
type: "string", |
| 4695 |
schemaType: "number", |
| 4696 |
$data: true, |
| 4697 |
error, |
| 4698 |
code(cxt) { |
| 4699 |
const { keyword, data, schemaCode, it } = cxt; |
| 4700 |
const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT; |
| 4701 |
const len = it.opts.unicode === false ? (0, codegen_1._)`${data}.length` : (0, codegen_1._)`${(0, util_1.useFunc)(cxt.gen, ucs2length_1.default)}(${data})`; |
| 4702 |
cxt.fail$data((0, codegen_1._)`${len} ${op} ${schemaCode}`); |
| 4703 |
} |
| 4704 |
}; |
| 4705 |
exports.default = def; |
| 4706 |
} |
| 4707 |
}); |
| 4708 |
|
| 4709 |
// node_modules/ajv/dist/vocabularies/validation/pattern.js |
| 4710 |
var require_pattern = __commonJS({ |
| 4711 |
"node_modules/ajv/dist/vocabularies/validation/pattern.js"(exports) { |
| 4712 |
"use strict"; |
| 4713 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4714 |
var code_1 = require_code2(); |
| 4715 |
var codegen_1 = require_codegen(); |
| 4716 |
var error = { |
| 4717 |
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`, |
| 4718 |
params: ({ schemaCode }) => (0, codegen_1._)`{pattern: ${schemaCode}}` |
| 4719 |
}; |
| 4720 |
var def = { |
| 4721 |
keyword: "pattern", |
| 4722 |
type: "string", |
| 4723 |
schemaType: "string", |
| 4724 |
$data: true, |
| 4725 |
error, |
| 4726 |
code(cxt) { |
| 4727 |
const { data, $data, schema, schemaCode, it } = cxt; |
| 4728 |
const u = it.opts.unicodeRegExp ? "u" : ""; |
| 4729 |
const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema); |
| 4730 |
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`); |
| 4731 |
} |
| 4732 |
}; |
| 4733 |
exports.default = def; |
| 4734 |
} |
| 4735 |
}); |
| 4736 |
|
| 4737 |
// node_modules/ajv/dist/vocabularies/validation/limitProperties.js |
| 4738 |
var require_limitProperties = __commonJS({ |
| 4739 |
"node_modules/ajv/dist/vocabularies/validation/limitProperties.js"(exports) { |
| 4740 |
"use strict"; |
| 4741 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4742 |
var codegen_1 = require_codegen(); |
| 4743 |
var error = { |
| 4744 |
message({ keyword, schemaCode }) { |
| 4745 |
const comp = keyword === "maxProperties" ? "more" : "fewer"; |
| 4746 |
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} properties`; |
| 4747 |
}, |
| 4748 |
params: ({ schemaCode }) => (0, codegen_1._)`{limit: ${schemaCode}}` |
| 4749 |
}; |
| 4750 |
var def = { |
| 4751 |
keyword: ["maxProperties", "minProperties"], |
| 4752 |
type: "object", |
| 4753 |
schemaType: "number", |
| 4754 |
$data: true, |
| 4755 |
error, |
| 4756 |
code(cxt) { |
| 4757 |
const { keyword, data, schemaCode } = cxt; |
| 4758 |
const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT; |
| 4759 |
cxt.fail$data((0, codegen_1._)`Object.keys(${data}).length ${op} ${schemaCode}`); |
| 4760 |
} |
| 4761 |
}; |
| 4762 |
exports.default = def; |
| 4763 |
} |
| 4764 |
}); |
| 4765 |
|
| 4766 |
// node_modules/ajv/dist/vocabularies/validation/required.js |
| 4767 |
var require_required = __commonJS({ |
| 4768 |
"node_modules/ajv/dist/vocabularies/validation/required.js"(exports) { |
| 4769 |
"use strict"; |
| 4770 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4771 |
var code_1 = require_code2(); |
| 4772 |
var codegen_1 = require_codegen(); |
| 4773 |
var util_1 = require_util(); |
| 4774 |
var error = { |
| 4775 |
message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`, |
| 4776 |
params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}` |
| 4777 |
}; |
| 4778 |
var def = { |
| 4779 |
keyword: "required", |
| 4780 |
type: "object", |
| 4781 |
schemaType: "array", |
| 4782 |
$data: true, |
| 4783 |
error, |
| 4784 |
code(cxt) { |
| 4785 |
const { gen, schema, schemaCode, data, $data, it } = cxt; |
| 4786 |
const { opts } = it; |
| 4787 |
if (!$data && schema.length === 0) |
| 4788 |
return; |
| 4789 |
const useLoop = schema.length >= opts.loopRequired; |
| 4790 |
if (it.allErrors) |
| 4791 |
allErrorsMode(); |
| 4792 |
else |
| 4793 |
exitOnErrorMode(); |
| 4794 |
if (opts.strictRequired) { |
| 4795 |
const props = cxt.parentSchema.properties; |
| 4796 |
const { definedProperties } = cxt.it; |
| 4797 |
for (const requiredKey of schema) { |
| 4798 |
if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === void 0 && !definedProperties.has(requiredKey)) { |
| 4799 |
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath; |
| 4800 |
const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`; |
| 4801 |
(0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired); |
| 4802 |
} |
| 4803 |
} |
| 4804 |
} |
| 4805 |
function allErrorsMode() { |
| 4806 |
if (useLoop || $data) { |
| 4807 |
cxt.block$data(codegen_1.nil, loopAllRequired); |
| 4808 |
} else { |
| 4809 |
for (const prop of schema) { |
| 4810 |
(0, code_1.checkReportMissingProp)(cxt, prop); |
| 4811 |
} |
| 4812 |
} |
| 4813 |
} |
| 4814 |
function exitOnErrorMode() { |
| 4815 |
const missing = gen.let("missing"); |
| 4816 |
if (useLoop || $data) { |
| 4817 |
const valid = gen.let("valid", true); |
| 4818 |
cxt.block$data(valid, () => loopUntilMissing(missing, valid)); |
| 4819 |
cxt.ok(valid); |
| 4820 |
} else { |
| 4821 |
gen.if((0, code_1.checkMissingProp)(cxt, schema, missing)); |
| 4822 |
(0, code_1.reportMissingProp)(cxt, missing); |
| 4823 |
gen.else(); |
| 4824 |
} |
| 4825 |
} |
| 4826 |
function loopAllRequired() { |
| 4827 |
gen.forOf("prop", schemaCode, (prop) => { |
| 4828 |
cxt.setParams({ missingProperty: prop }); |
| 4829 |
gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error()); |
| 4830 |
}); |
| 4831 |
} |
| 4832 |
function loopUntilMissing(missing, valid) { |
| 4833 |
cxt.setParams({ missingProperty: missing }); |
| 4834 |
gen.forOf(missing, schemaCode, () => { |
| 4835 |
gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties)); |
| 4836 |
gen.if((0, codegen_1.not)(valid), () => { |
| 4837 |
cxt.error(); |
| 4838 |
gen.break(); |
| 4839 |
}); |
| 4840 |
}, codegen_1.nil); |
| 4841 |
} |
| 4842 |
} |
| 4843 |
}; |
| 4844 |
exports.default = def; |
| 4845 |
} |
| 4846 |
}); |
| 4847 |
|
| 4848 |
// node_modules/ajv/dist/vocabularies/validation/limitItems.js |
| 4849 |
var require_limitItems = __commonJS({ |
| 4850 |
"node_modules/ajv/dist/vocabularies/validation/limitItems.js"(exports) { |
| 4851 |
"use strict"; |
| 4852 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4853 |
var codegen_1 = require_codegen(); |
| 4854 |
var error = { |
| 4855 |
message({ keyword, schemaCode }) { |
| 4856 |
const comp = keyword === "maxItems" ? "more" : "fewer"; |
| 4857 |
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} items`; |
| 4858 |
}, |
| 4859 |
params: ({ schemaCode }) => (0, codegen_1._)`{limit: ${schemaCode}}` |
| 4860 |
}; |
| 4861 |
var def = { |
| 4862 |
keyword: ["maxItems", "minItems"], |
| 4863 |
type: "array", |
| 4864 |
schemaType: "number", |
| 4865 |
$data: true, |
| 4866 |
error, |
| 4867 |
code(cxt) { |
| 4868 |
const { keyword, data, schemaCode } = cxt; |
| 4869 |
const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT; |
| 4870 |
cxt.fail$data((0, codegen_1._)`${data}.length ${op} ${schemaCode}`); |
| 4871 |
} |
| 4872 |
}; |
| 4873 |
exports.default = def; |
| 4874 |
} |
| 4875 |
}); |
| 4876 |
|
| 4877 |
// node_modules/ajv/dist/runtime/equal.js |
| 4878 |
var require_equal = __commonJS({ |
| 4879 |
"node_modules/ajv/dist/runtime/equal.js"(exports) { |
| 4880 |
"use strict"; |
| 4881 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4882 |
var equal = require_fast_deep_equal(); |
| 4883 |
equal.code = 'require("ajv/dist/runtime/equal").default'; |
| 4884 |
exports.default = equal; |
| 4885 |
} |
| 4886 |
}); |
| 4887 |
|
| 4888 |
// node_modules/ajv/dist/vocabularies/validation/uniqueItems.js |
| 4889 |
var require_uniqueItems = __commonJS({ |
| 4890 |
"node_modules/ajv/dist/vocabularies/validation/uniqueItems.js"(exports) { |
| 4891 |
"use strict"; |
| 4892 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4893 |
var dataType_1 = require_dataType(); |
| 4894 |
var codegen_1 = require_codegen(); |
| 4895 |
var util_1 = require_util(); |
| 4896 |
var equal_1 = require_equal(); |
| 4897 |
var error = { |
| 4898 |
message: ({ params: { i, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j} and ${i} are identical)`, |
| 4899 |
params: ({ params: { i, j } }) => (0, codegen_1._)`{i: ${i}, j: ${j}}` |
| 4900 |
}; |
| 4901 |
var def = { |
| 4902 |
keyword: "uniqueItems", |
| 4903 |
type: "array", |
| 4904 |
schemaType: "boolean", |
| 4905 |
$data: true, |
| 4906 |
error, |
| 4907 |
code(cxt) { |
| 4908 |
const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt; |
| 4909 |
if (!$data && !schema) |
| 4910 |
return; |
| 4911 |
const valid = gen.let("valid"); |
| 4912 |
const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : []; |
| 4913 |
cxt.block$data(valid, validateUniqueItems, (0, codegen_1._)`${schemaCode} === false`); |
| 4914 |
cxt.ok(valid); |
| 4915 |
function validateUniqueItems() { |
| 4916 |
const i = gen.let("i", (0, codegen_1._)`${data}.length`); |
| 4917 |
const j = gen.let("j"); |
| 4918 |
cxt.setParams({ i, j }); |
| 4919 |
gen.assign(valid, true); |
| 4920 |
gen.if((0, codegen_1._)`${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j)); |
| 4921 |
} |
| 4922 |
function canOptimize() { |
| 4923 |
return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array"); |
| 4924 |
} |
| 4925 |
function loopN(i, j) { |
| 4926 |
const item = gen.name("item"); |
| 4927 |
const wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong); |
| 4928 |
const indices = gen.const("indices", (0, codegen_1._)`{}`); |
| 4929 |
gen.for((0, codegen_1._)`;${i}--;`, () => { |
| 4930 |
gen.let(item, (0, codegen_1._)`${data}[${i}]`); |
| 4931 |
gen.if(wrongType, (0, codegen_1._)`continue`); |
| 4932 |
if (itemTypes.length > 1) |
| 4933 |
gen.if((0, codegen_1._)`typeof ${item} == "string"`, (0, codegen_1._)`${item} += "_"`); |
| 4934 |
gen.if((0, codegen_1._)`typeof ${indices}[${item}] == "number"`, () => { |
| 4935 |
gen.assign(j, (0, codegen_1._)`${indices}[${item}]`); |
| 4936 |
cxt.error(); |
| 4937 |
gen.assign(valid, false).break(); |
| 4938 |
}).code((0, codegen_1._)`${indices}[${item}] = ${i}`); |
| 4939 |
}); |
| 4940 |
} |
| 4941 |
function loopN2(i, j) { |
| 4942 |
const eql = (0, util_1.useFunc)(gen, equal_1.default); |
| 4943 |
const outer = gen.name("outer"); |
| 4944 |
gen.label(outer).for((0, codegen_1._)`;${i}--;`, () => gen.for((0, codegen_1._)`${j} = ${i}; ${j}--;`, () => gen.if((0, codegen_1._)`${eql}(${data}[${i}], ${data}[${j}])`, () => { |
| 4945 |
cxt.error(); |
| 4946 |
gen.assign(valid, false).break(outer); |
| 4947 |
}))); |
| 4948 |
} |
| 4949 |
} |
| 4950 |
}; |
| 4951 |
exports.default = def; |
| 4952 |
} |
| 4953 |
}); |
| 4954 |
|
| 4955 |
// node_modules/ajv/dist/vocabularies/validation/const.js |
| 4956 |
var require_const = __commonJS({ |
| 4957 |
"node_modules/ajv/dist/vocabularies/validation/const.js"(exports) { |
| 4958 |
"use strict"; |
| 4959 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4960 |
var codegen_1 = require_codegen(); |
| 4961 |
var util_1 = require_util(); |
| 4962 |
var equal_1 = require_equal(); |
| 4963 |
var error = { |
| 4964 |
message: "must be equal to constant", |
| 4965 |
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValue: ${schemaCode}}` |
| 4966 |
}; |
| 4967 |
var def = { |
| 4968 |
keyword: "const", |
| 4969 |
$data: true, |
| 4970 |
error, |
| 4971 |
code(cxt) { |
| 4972 |
const { gen, data, $data, schemaCode, schema } = cxt; |
| 4973 |
if ($data || schema && typeof schema == "object") { |
| 4974 |
cxt.fail$data((0, codegen_1._)`!${(0, util_1.useFunc)(gen, equal_1.default)}(${data}, ${schemaCode})`); |
| 4975 |
} else { |
| 4976 |
cxt.fail((0, codegen_1._)`${schema} !== ${data}`); |
| 4977 |
} |
| 4978 |
} |
| 4979 |
}; |
| 4980 |
exports.default = def; |
| 4981 |
} |
| 4982 |
}); |
| 4983 |
|
| 4984 |
// node_modules/ajv/dist/vocabularies/validation/enum.js |
| 4985 |
var require_enum = __commonJS({ |
| 4986 |
"node_modules/ajv/dist/vocabularies/validation/enum.js"(exports) { |
| 4987 |
"use strict"; |
| 4988 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 4989 |
var codegen_1 = require_codegen(); |
| 4990 |
var util_1 = require_util(); |
| 4991 |
var equal_1 = require_equal(); |
| 4992 |
var error = { |
| 4993 |
message: "must be equal to one of the allowed values", |
| 4994 |
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: ${schemaCode}}` |
| 4995 |
}; |
| 4996 |
var def = { |
| 4997 |
keyword: "enum", |
| 4998 |
schemaType: "array", |
| 4999 |
$data: true, |
| 5000 |
error, |
| 5001 |
code(cxt) { |
| 5002 |
const { gen, data, $data, schema, schemaCode, it } = cxt; |
| 5003 |
if (!$data && schema.length === 0) |
| 5004 |
throw new Error("enum must have non-empty array"); |
| 5005 |
const useLoop = schema.length >= it.opts.loopEnum; |
| 5006 |
let eql; |
| 5007 |
const getEql = () => eql !== null && eql !== void 0 ? eql : eql = (0, util_1.useFunc)(gen, equal_1.default); |
| 5008 |
let valid; |
| 5009 |
if (useLoop || $data) { |
| 5010 |
valid = gen.let("valid"); |
| 5011 |
cxt.block$data(valid, loopEnum); |
| 5012 |
} else { |
| 5013 |
if (!Array.isArray(schema)) |
| 5014 |
throw new Error("ajv implementation error"); |
| 5015 |
const vSchema = gen.const("vSchema", schemaCode); |
| 5016 |
valid = (0, codegen_1.or)(...schema.map((_x, i) => equalCode(vSchema, i))); |
| 5017 |
} |
| 5018 |
cxt.pass(valid); |
| 5019 |
function loopEnum() { |
| 5020 |
gen.assign(valid, false); |
| 5021 |
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${data}, ${v})`, () => gen.assign(valid, true).break())); |
| 5022 |
} |
| 5023 |
function equalCode(vSchema, i) { |
| 5024 |
const sch = schema[i]; |
| 5025 |
return typeof sch === "object" && sch !== null ? (0, codegen_1._)`${getEql()}(${data}, ${vSchema}[${i}])` : (0, codegen_1._)`${data} === ${sch}`; |
| 5026 |
} |
| 5027 |
} |
| 5028 |
}; |
| 5029 |
exports.default = def; |
| 5030 |
} |
| 5031 |
}); |
| 5032 |
|
| 5033 |
// node_modules/ajv-draft-04/dist/vocabulary/validation/index.js |
| 5034 |
var require_validation = __commonJS({ |
| 5035 |
"node_modules/ajv-draft-04/dist/vocabulary/validation/index.js"(exports) { |
| 5036 |
"use strict"; |
| 5037 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5038 |
var limitNumber_1 = require_limitNumber(); |
| 5039 |
var limitNumberExclusive_1 = require_limitNumberExclusive(); |
| 5040 |
var multipleOf_1 = require_multipleOf(); |
| 5041 |
var limitLength_1 = require_limitLength(); |
| 5042 |
var pattern_1 = require_pattern(); |
| 5043 |
var limitProperties_1 = require_limitProperties(); |
| 5044 |
var required_1 = require_required(); |
| 5045 |
var limitItems_1 = require_limitItems(); |
| 5046 |
var uniqueItems_1 = require_uniqueItems(); |
| 5047 |
var const_1 = require_const(); |
| 5048 |
var enum_1 = require_enum(); |
| 5049 |
var validation = [ |
| 5050 |
// number |
| 5051 |
limitNumber_1.default, |
| 5052 |
limitNumberExclusive_1.default, |
| 5053 |
multipleOf_1.default, |
| 5054 |
// string |
| 5055 |
limitLength_1.default, |
| 5056 |
pattern_1.default, |
| 5057 |
// object |
| 5058 |
limitProperties_1.default, |
| 5059 |
required_1.default, |
| 5060 |
// array |
| 5061 |
limitItems_1.default, |
| 5062 |
uniqueItems_1.default, |
| 5063 |
// any |
| 5064 |
{ keyword: "type", schemaType: ["string", "array"] }, |
| 5065 |
{ keyword: "nullable", schemaType: "boolean" }, |
| 5066 |
const_1.default, |
| 5067 |
enum_1.default |
| 5068 |
]; |
| 5069 |
exports.default = validation; |
| 5070 |
} |
| 5071 |
}); |
| 5072 |
|
| 5073 |
// node_modules/ajv/dist/vocabularies/applicator/additionalItems.js |
| 5074 |
var require_additionalItems = __commonJS({ |
| 5075 |
"node_modules/ajv/dist/vocabularies/applicator/additionalItems.js"(exports) { |
| 5076 |
"use strict"; |
| 5077 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5078 |
exports.validateAdditionalItems = void 0; |
| 5079 |
var codegen_1 = require_codegen(); |
| 5080 |
var util_1 = require_util(); |
| 5081 |
var error = { |
| 5082 |
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`, |
| 5083 |
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}` |
| 5084 |
}; |
| 5085 |
var def = { |
| 5086 |
keyword: "additionalItems", |
| 5087 |
type: "array", |
| 5088 |
schemaType: ["boolean", "object"], |
| 5089 |
before: "uniqueItems", |
| 5090 |
error, |
| 5091 |
code(cxt) { |
| 5092 |
const { parentSchema, it } = cxt; |
| 5093 |
const { items } = parentSchema; |
| 5094 |
if (!Array.isArray(items)) { |
| 5095 |
(0, util_1.checkStrictMode)(it, '"additionalItems" is ignored when "items" is not an array of schemas'); |
| 5096 |
return; |
| 5097 |
} |
| 5098 |
validateAdditionalItems(cxt, items); |
| 5099 |
} |
| 5100 |
}; |
| 5101 |
function validateAdditionalItems(cxt, items) { |
| 5102 |
const { gen, schema, data, keyword, it } = cxt; |
| 5103 |
it.items = true; |
| 5104 |
const len = gen.const("len", (0, codegen_1._)`${data}.length`); |
| 5105 |
if (schema === false) { |
| 5106 |
cxt.setParams({ len: items.length }); |
| 5107 |
cxt.pass((0, codegen_1._)`${len} <= ${items.length}`); |
| 5108 |
} else if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) { |
| 5109 |
const valid = gen.var("valid", (0, codegen_1._)`${len} <= ${items.length}`); |
| 5110 |
gen.if((0, codegen_1.not)(valid), () => validateItems(valid)); |
| 5111 |
cxt.ok(valid); |
| 5112 |
} |
| 5113 |
function validateItems(valid) { |
| 5114 |
gen.forRange("i", items.length, len, (i) => { |
| 5115 |
cxt.subschema({ keyword, dataProp: i, dataPropType: util_1.Type.Num }, valid); |
| 5116 |
if (!it.allErrors) |
| 5117 |
gen.if((0, codegen_1.not)(valid), () => gen.break()); |
| 5118 |
}); |
| 5119 |
} |
| 5120 |
} |
| 5121 |
exports.validateAdditionalItems = validateAdditionalItems; |
| 5122 |
exports.default = def; |
| 5123 |
} |
| 5124 |
}); |
| 5125 |
|
| 5126 |
// node_modules/ajv/dist/vocabularies/applicator/items.js |
| 5127 |
var require_items = __commonJS({ |
| 5128 |
"node_modules/ajv/dist/vocabularies/applicator/items.js"(exports) { |
| 5129 |
"use strict"; |
| 5130 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5131 |
exports.validateTuple = void 0; |
| 5132 |
var codegen_1 = require_codegen(); |
| 5133 |
var util_1 = require_util(); |
| 5134 |
var code_1 = require_code2(); |
| 5135 |
var def = { |
| 5136 |
keyword: "items", |
| 5137 |
type: "array", |
| 5138 |
schemaType: ["object", "array", "boolean"], |
| 5139 |
before: "uniqueItems", |
| 5140 |
code(cxt) { |
| 5141 |
const { schema, it } = cxt; |
| 5142 |
if (Array.isArray(schema)) |
| 5143 |
return validateTuple(cxt, "additionalItems", schema); |
| 5144 |
it.items = true; |
| 5145 |
if ((0, util_1.alwaysValidSchema)(it, schema)) |
| 5146 |
return; |
| 5147 |
cxt.ok((0, code_1.validateArray)(cxt)); |
| 5148 |
} |
| 5149 |
}; |
| 5150 |
function validateTuple(cxt, extraItems, schArr = cxt.schema) { |
| 5151 |
const { gen, parentSchema, data, keyword, it } = cxt; |
| 5152 |
checkStrictTuple(parentSchema); |
| 5153 |
if (it.opts.unevaluated && schArr.length && it.items !== true) { |
| 5154 |
it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items); |
| 5155 |
} |
| 5156 |
const valid = gen.name("valid"); |
| 5157 |
const len = gen.const("len", (0, codegen_1._)`${data}.length`); |
| 5158 |
schArr.forEach((sch, i) => { |
| 5159 |
if ((0, util_1.alwaysValidSchema)(it, sch)) |
| 5160 |
return; |
| 5161 |
gen.if((0, codegen_1._)`${len} > ${i}`, () => cxt.subschema({ |
| 5162 |
keyword, |
| 5163 |
schemaProp: i, |
| 5164 |
dataProp: i |
| 5165 |
}, valid)); |
| 5166 |
cxt.ok(valid); |
| 5167 |
}); |
| 5168 |
function checkStrictTuple(sch) { |
| 5169 |
const { opts, errSchemaPath } = it; |
| 5170 |
const l = schArr.length; |
| 5171 |
const fullTuple = l === sch.minItems && (l === sch.maxItems || sch[extraItems] === false); |
| 5172 |
if (opts.strictTuples && !fullTuple) { |
| 5173 |
const msg = `"${keyword}" is ${l}-tuple, but minItems or maxItems/${extraItems} are not specified or different at path "${errSchemaPath}"`; |
| 5174 |
(0, util_1.checkStrictMode)(it, msg, opts.strictTuples); |
| 5175 |
} |
| 5176 |
} |
| 5177 |
} |
| 5178 |
exports.validateTuple = validateTuple; |
| 5179 |
exports.default = def; |
| 5180 |
} |
| 5181 |
}); |
| 5182 |
|
| 5183 |
// node_modules/ajv/dist/vocabularies/applicator/prefixItems.js |
| 5184 |
var require_prefixItems = __commonJS({ |
| 5185 |
"node_modules/ajv/dist/vocabularies/applicator/prefixItems.js"(exports) { |
| 5186 |
"use strict"; |
| 5187 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5188 |
var items_1 = require_items(); |
| 5189 |
var def = { |
| 5190 |
keyword: "prefixItems", |
| 5191 |
type: "array", |
| 5192 |
schemaType: ["array"], |
| 5193 |
before: "uniqueItems", |
| 5194 |
code: (cxt) => (0, items_1.validateTuple)(cxt, "items") |
| 5195 |
}; |
| 5196 |
exports.default = def; |
| 5197 |
} |
| 5198 |
}); |
| 5199 |
|
| 5200 |
// node_modules/ajv/dist/vocabularies/applicator/items2020.js |
| 5201 |
var require_items2020 = __commonJS({ |
| 5202 |
"node_modules/ajv/dist/vocabularies/applicator/items2020.js"(exports) { |
| 5203 |
"use strict"; |
| 5204 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5205 |
var codegen_1 = require_codegen(); |
| 5206 |
var util_1 = require_util(); |
| 5207 |
var code_1 = require_code2(); |
| 5208 |
var additionalItems_1 = require_additionalItems(); |
| 5209 |
var error = { |
| 5210 |
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`, |
| 5211 |
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}` |
| 5212 |
}; |
| 5213 |
var def = { |
| 5214 |
keyword: "items", |
| 5215 |
type: "array", |
| 5216 |
schemaType: ["object", "boolean"], |
| 5217 |
before: "uniqueItems", |
| 5218 |
error, |
| 5219 |
code(cxt) { |
| 5220 |
const { schema, parentSchema, it } = cxt; |
| 5221 |
const { prefixItems } = parentSchema; |
| 5222 |
it.items = true; |
| 5223 |
if ((0, util_1.alwaysValidSchema)(it, schema)) |
| 5224 |
return; |
| 5225 |
if (prefixItems) |
| 5226 |
(0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems); |
| 5227 |
else |
| 5228 |
cxt.ok((0, code_1.validateArray)(cxt)); |
| 5229 |
} |
| 5230 |
}; |
| 5231 |
exports.default = def; |
| 5232 |
} |
| 5233 |
}); |
| 5234 |
|
| 5235 |
// node_modules/ajv/dist/vocabularies/applicator/contains.js |
| 5236 |
var require_contains = __commonJS({ |
| 5237 |
"node_modules/ajv/dist/vocabularies/applicator/contains.js"(exports) { |
| 5238 |
"use strict"; |
| 5239 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5240 |
var codegen_1 = require_codegen(); |
| 5241 |
var util_1 = require_util(); |
| 5242 |
var error = { |
| 5243 |
message: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`, |
| 5244 |
params: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}` |
| 5245 |
}; |
| 5246 |
var def = { |
| 5247 |
keyword: "contains", |
| 5248 |
type: "array", |
| 5249 |
schemaType: ["object", "boolean"], |
| 5250 |
before: "uniqueItems", |
| 5251 |
trackErrors: true, |
| 5252 |
error, |
| 5253 |
code(cxt) { |
| 5254 |
const { gen, schema, parentSchema, data, it } = cxt; |
| 5255 |
let min; |
| 5256 |
let max; |
| 5257 |
const { minContains, maxContains } = parentSchema; |
| 5258 |
if (it.opts.next) { |
| 5259 |
min = minContains === void 0 ? 1 : minContains; |
| 5260 |
max = maxContains; |
| 5261 |
} else { |
| 5262 |
min = 1; |
| 5263 |
} |
| 5264 |
const len = gen.const("len", (0, codegen_1._)`${data}.length`); |
| 5265 |
cxt.setParams({ min, max }); |
| 5266 |
if (max === void 0 && min === 0) { |
| 5267 |
(0, util_1.checkStrictMode)(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`); |
| 5268 |
return; |
| 5269 |
} |
| 5270 |
if (max !== void 0 && min > max) { |
| 5271 |
(0, util_1.checkStrictMode)(it, `"minContains" > "maxContains" is always invalid`); |
| 5272 |
cxt.fail(); |
| 5273 |
return; |
| 5274 |
} |
| 5275 |
if ((0, util_1.alwaysValidSchema)(it, schema)) { |
| 5276 |
let cond = (0, codegen_1._)`${len} >= ${min}`; |
| 5277 |
if (max !== void 0) |
| 5278 |
cond = (0, codegen_1._)`${cond} && ${len} <= ${max}`; |
| 5279 |
cxt.pass(cond); |
| 5280 |
return; |
| 5281 |
} |
| 5282 |
it.items = true; |
| 5283 |
const valid = gen.name("valid"); |
| 5284 |
if (max === void 0 && min === 1) { |
| 5285 |
validateItems(valid, () => gen.if(valid, () => gen.break())); |
| 5286 |
} else if (min === 0) { |
| 5287 |
gen.let(valid, true); |
| 5288 |
if (max !== void 0) |
| 5289 |
gen.if((0, codegen_1._)`${data}.length > 0`, validateItemsWithCount); |
| 5290 |
} else { |
| 5291 |
gen.let(valid, false); |
| 5292 |
validateItemsWithCount(); |
| 5293 |
} |
| 5294 |
cxt.result(valid, () => cxt.reset()); |
| 5295 |
function validateItemsWithCount() { |
| 5296 |
const schValid = gen.name("_valid"); |
| 5297 |
const count = gen.let("count", 0); |
| 5298 |
validateItems(schValid, () => gen.if(schValid, () => checkLimits(count))); |
| 5299 |
} |
| 5300 |
function validateItems(_valid, block) { |
| 5301 |
gen.forRange("i", 0, len, (i) => { |
| 5302 |
cxt.subschema({ |
| 5303 |
keyword: "contains", |
| 5304 |
dataProp: i, |
| 5305 |
dataPropType: util_1.Type.Num, |
| 5306 |
compositeRule: true |
| 5307 |
}, _valid); |
| 5308 |
block(); |
| 5309 |
}); |
| 5310 |
} |
| 5311 |
function checkLimits(count) { |
| 5312 |
gen.code((0, codegen_1._)`${count}++`); |
| 5313 |
if (max === void 0) { |
| 5314 |
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true).break()); |
| 5315 |
} else { |
| 5316 |
gen.if((0, codegen_1._)`${count} > ${max}`, () => gen.assign(valid, false).break()); |
| 5317 |
if (min === 1) |
| 5318 |
gen.assign(valid, true); |
| 5319 |
else |
| 5320 |
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true)); |
| 5321 |
} |
| 5322 |
} |
| 5323 |
} |
| 5324 |
}; |
| 5325 |
exports.default = def; |
| 5326 |
} |
| 5327 |
}); |
| 5328 |
|
| 5329 |
// node_modules/ajv/dist/vocabularies/applicator/dependencies.js |
| 5330 |
var require_dependencies = __commonJS({ |
| 5331 |
"node_modules/ajv/dist/vocabularies/applicator/dependencies.js"(exports) { |
| 5332 |
"use strict"; |
| 5333 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5334 |
exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0; |
| 5335 |
var codegen_1 = require_codegen(); |
| 5336 |
var util_1 = require_util(); |
| 5337 |
var code_1 = require_code2(); |
| 5338 |
exports.error = { |
| 5339 |
message: ({ params: { property, depsCount, deps } }) => { |
| 5340 |
const property_ies = depsCount === 1 ? "property" : "properties"; |
| 5341 |
return (0, codegen_1.str)`must have ${property_ies} ${deps} when property ${property} is present`; |
| 5342 |
}, |
| 5343 |
params: ({ params: { property, depsCount, deps, missingProperty } }) => (0, codegen_1._)`{property: ${property}, |
| 5344 |
missingProperty: ${missingProperty}, |
| 5345 |
depsCount: ${depsCount}, |
| 5346 |
deps: ${deps}}` |
| 5347 |
// TODO change to reference |
| 5348 |
}; |
| 5349 |
var def = { |
| 5350 |
keyword: "dependencies", |
| 5351 |
type: "object", |
| 5352 |
schemaType: "object", |
| 5353 |
error: exports.error, |
| 5354 |
code(cxt) { |
| 5355 |
const [propDeps, schDeps] = splitDependencies(cxt); |
| 5356 |
validatePropertyDeps(cxt, propDeps); |
| 5357 |
validateSchemaDeps(cxt, schDeps); |
| 5358 |
} |
| 5359 |
}; |
| 5360 |
function splitDependencies({ schema }) { |
| 5361 |
const propertyDeps = {}; |
| 5362 |
const schemaDeps = {}; |
| 5363 |
for (const key in schema) { |
| 5364 |
if (key === "__proto__") |
| 5365 |
continue; |
| 5366 |
const deps = Array.isArray(schema[key]) ? propertyDeps : schemaDeps; |
| 5367 |
deps[key] = schema[key]; |
| 5368 |
} |
| 5369 |
return [propertyDeps, schemaDeps]; |
| 5370 |
} |
| 5371 |
function validatePropertyDeps(cxt, propertyDeps = cxt.schema) { |
| 5372 |
const { gen, data, it } = cxt; |
| 5373 |
if (Object.keys(propertyDeps).length === 0) |
| 5374 |
return; |
| 5375 |
const missing = gen.let("missing"); |
| 5376 |
for (const prop in propertyDeps) { |
| 5377 |
const deps = propertyDeps[prop]; |
| 5378 |
if (deps.length === 0) |
| 5379 |
continue; |
| 5380 |
const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties); |
| 5381 |
cxt.setParams({ |
| 5382 |
property: prop, |
| 5383 |
depsCount: deps.length, |
| 5384 |
deps: deps.join(", ") |
| 5385 |
}); |
| 5386 |
if (it.allErrors) { |
| 5387 |
gen.if(hasProperty, () => { |
| 5388 |
for (const depProp of deps) { |
| 5389 |
(0, code_1.checkReportMissingProp)(cxt, depProp); |
| 5390 |
} |
| 5391 |
}); |
| 5392 |
} else { |
| 5393 |
gen.if((0, codegen_1._)`${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`); |
| 5394 |
(0, code_1.reportMissingProp)(cxt, missing); |
| 5395 |
gen.else(); |
| 5396 |
} |
| 5397 |
} |
| 5398 |
} |
| 5399 |
exports.validatePropertyDeps = validatePropertyDeps; |
| 5400 |
function validateSchemaDeps(cxt, schemaDeps = cxt.schema) { |
| 5401 |
const { gen, data, keyword, it } = cxt; |
| 5402 |
const valid = gen.name("valid"); |
| 5403 |
for (const prop in schemaDeps) { |
| 5404 |
if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop])) |
| 5405 |
continue; |
| 5406 |
gen.if( |
| 5407 |
(0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), |
| 5408 |
() => { |
| 5409 |
const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid); |
| 5410 |
cxt.mergeValidEvaluated(schCxt, valid); |
| 5411 |
}, |
| 5412 |
() => gen.var(valid, true) |
| 5413 |
// TODO var |
| 5414 |
); |
| 5415 |
cxt.ok(valid); |
| 5416 |
} |
| 5417 |
} |
| 5418 |
exports.validateSchemaDeps = validateSchemaDeps; |
| 5419 |
exports.default = def; |
| 5420 |
} |
| 5421 |
}); |
| 5422 |
|
| 5423 |
// node_modules/ajv/dist/vocabularies/applicator/propertyNames.js |
| 5424 |
var require_propertyNames = __commonJS({ |
| 5425 |
"node_modules/ajv/dist/vocabularies/applicator/propertyNames.js"(exports) { |
| 5426 |
"use strict"; |
| 5427 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5428 |
var codegen_1 = require_codegen(); |
| 5429 |
var util_1 = require_util(); |
| 5430 |
var error = { |
| 5431 |
message: "property name must be valid", |
| 5432 |
params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}` |
| 5433 |
}; |
| 5434 |
var def = { |
| 5435 |
keyword: "propertyNames", |
| 5436 |
type: "object", |
| 5437 |
schemaType: ["object", "boolean"], |
| 5438 |
error, |
| 5439 |
code(cxt) { |
| 5440 |
const { gen, schema, data, it } = cxt; |
| 5441 |
if ((0, util_1.alwaysValidSchema)(it, schema)) |
| 5442 |
return; |
| 5443 |
const valid = gen.name("valid"); |
| 5444 |
gen.forIn("key", data, (key) => { |
| 5445 |
cxt.setParams({ propertyName: key }); |
| 5446 |
cxt.subschema({ |
| 5447 |
keyword: "propertyNames", |
| 5448 |
data: key, |
| 5449 |
dataTypes: ["string"], |
| 5450 |
propertyName: key, |
| 5451 |
compositeRule: true |
| 5452 |
}, valid); |
| 5453 |
gen.if((0, codegen_1.not)(valid), () => { |
| 5454 |
cxt.error(true); |
| 5455 |
if (!it.allErrors) |
| 5456 |
gen.break(); |
| 5457 |
}); |
| 5458 |
}); |
| 5459 |
cxt.ok(valid); |
| 5460 |
} |
| 5461 |
}; |
| 5462 |
exports.default = def; |
| 5463 |
} |
| 5464 |
}); |
| 5465 |
|
| 5466 |
// node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js |
| 5467 |
var require_additionalProperties = __commonJS({ |
| 5468 |
"node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js"(exports) { |
| 5469 |
"use strict"; |
| 5470 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5471 |
var code_1 = require_code2(); |
| 5472 |
var codegen_1 = require_codegen(); |
| 5473 |
var names_1 = require_names(); |
| 5474 |
var util_1 = require_util(); |
| 5475 |
var error = { |
| 5476 |
message: "must NOT have additional properties", |
| 5477 |
params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}` |
| 5478 |
}; |
| 5479 |
var def = { |
| 5480 |
keyword: "additionalProperties", |
| 5481 |
type: ["object"], |
| 5482 |
schemaType: ["boolean", "object"], |
| 5483 |
allowUndefined: true, |
| 5484 |
trackErrors: true, |
| 5485 |
error, |
| 5486 |
code(cxt) { |
| 5487 |
const { gen, schema, parentSchema, data, errsCount, it } = cxt; |
| 5488 |
if (!errsCount) |
| 5489 |
throw new Error("ajv implementation error"); |
| 5490 |
const { allErrors, opts } = it; |
| 5491 |
it.props = true; |
| 5492 |
if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema)) |
| 5493 |
return; |
| 5494 |
const props = (0, code_1.allSchemaProperties)(parentSchema.properties); |
| 5495 |
const patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties); |
| 5496 |
checkAdditionalProperties(); |
| 5497 |
cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`); |
| 5498 |
function checkAdditionalProperties() { |
| 5499 |
gen.forIn("key", data, (key) => { |
| 5500 |
if (!props.length && !patProps.length) |
| 5501 |
additionalPropertyCode(key); |
| 5502 |
else |
| 5503 |
gen.if(isAdditional(key), () => additionalPropertyCode(key)); |
| 5504 |
}); |
| 5505 |
} |
| 5506 |
function isAdditional(key) { |
| 5507 |
let definedProp; |
| 5508 |
if (props.length > 8) { |
| 5509 |
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties"); |
| 5510 |
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key); |
| 5511 |
} else if (props.length) { |
| 5512 |
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key} === ${p}`)); |
| 5513 |
} else { |
| 5514 |
definedProp = codegen_1.nil; |
| 5515 |
} |
| 5516 |
if (patProps.length) { |
| 5517 |
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key})`)); |
| 5518 |
} |
| 5519 |
return (0, codegen_1.not)(definedProp); |
| 5520 |
} |
| 5521 |
function deleteAdditional(key) { |
| 5522 |
gen.code((0, codegen_1._)`delete ${data}[${key}]`); |
| 5523 |
} |
| 5524 |
function additionalPropertyCode(key) { |
| 5525 |
if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) { |
| 5526 |
deleteAdditional(key); |
| 5527 |
return; |
| 5528 |
} |
| 5529 |
if (schema === false) { |
| 5530 |
cxt.setParams({ additionalProperty: key }); |
| 5531 |
cxt.error(); |
| 5532 |
if (!allErrors) |
| 5533 |
gen.break(); |
| 5534 |
return; |
| 5535 |
} |
| 5536 |
if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) { |
| 5537 |
const valid = gen.name("valid"); |
| 5538 |
if (opts.removeAdditional === "failing") { |
| 5539 |
applyAdditionalSchema(key, valid, false); |
| 5540 |
gen.if((0, codegen_1.not)(valid), () => { |
| 5541 |
cxt.reset(); |
| 5542 |
deleteAdditional(key); |
| 5543 |
}); |
| 5544 |
} else { |
| 5545 |
applyAdditionalSchema(key, valid); |
| 5546 |
if (!allErrors) |
| 5547 |
gen.if((0, codegen_1.not)(valid), () => gen.break()); |
| 5548 |
} |
| 5549 |
} |
| 5550 |
} |
| 5551 |
function applyAdditionalSchema(key, valid, errors) { |
| 5552 |
const subschema = { |
| 5553 |
keyword: "additionalProperties", |
| 5554 |
dataProp: key, |
| 5555 |
dataPropType: util_1.Type.Str |
| 5556 |
}; |
| 5557 |
if (errors === false) { |
| 5558 |
Object.assign(subschema, { |
| 5559 |
compositeRule: true, |
| 5560 |
createErrors: false, |
| 5561 |
allErrors: false |
| 5562 |
}); |
| 5563 |
} |
| 5564 |
cxt.subschema(subschema, valid); |
| 5565 |
} |
| 5566 |
} |
| 5567 |
}; |
| 5568 |
exports.default = def; |
| 5569 |
} |
| 5570 |
}); |
| 5571 |
|
| 5572 |
// node_modules/ajv/dist/vocabularies/applicator/properties.js |
| 5573 |
var require_properties = __commonJS({ |
| 5574 |
"node_modules/ajv/dist/vocabularies/applicator/properties.js"(exports) { |
| 5575 |
"use strict"; |
| 5576 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5577 |
var validate_1 = require_validate(); |
| 5578 |
var code_1 = require_code2(); |
| 5579 |
var util_1 = require_util(); |
| 5580 |
var additionalProperties_1 = require_additionalProperties(); |
| 5581 |
var def = { |
| 5582 |
keyword: "properties", |
| 5583 |
type: "object", |
| 5584 |
schemaType: "object", |
| 5585 |
code(cxt) { |
| 5586 |
const { gen, schema, parentSchema, data, it } = cxt; |
| 5587 |
if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === void 0) { |
| 5588 |
additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties")); |
| 5589 |
} |
| 5590 |
const allProps = (0, code_1.allSchemaProperties)(schema); |
| 5591 |
for (const prop of allProps) { |
| 5592 |
it.definedProperties.add(prop); |
| 5593 |
} |
| 5594 |
if (it.opts.unevaluated && allProps.length && it.props !== true) { |
| 5595 |
it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props); |
| 5596 |
} |
| 5597 |
const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p])); |
| 5598 |
if (properties.length === 0) |
| 5599 |
return; |
| 5600 |
const valid = gen.name("valid"); |
| 5601 |
for (const prop of properties) { |
| 5602 |
if (hasDefault(prop)) { |
| 5603 |
applyPropertySchema(prop); |
| 5604 |
} else { |
| 5605 |
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties)); |
| 5606 |
applyPropertySchema(prop); |
| 5607 |
if (!it.allErrors) |
| 5608 |
gen.else().var(valid, true); |
| 5609 |
gen.endIf(); |
| 5610 |
} |
| 5611 |
cxt.it.definedProperties.add(prop); |
| 5612 |
cxt.ok(valid); |
| 5613 |
} |
| 5614 |
function hasDefault(prop) { |
| 5615 |
return it.opts.useDefaults && !it.compositeRule && schema[prop].default !== void 0; |
| 5616 |
} |
| 5617 |
function applyPropertySchema(prop) { |
| 5618 |
cxt.subschema({ |
| 5619 |
keyword: "properties", |
| 5620 |
schemaProp: prop, |
| 5621 |
dataProp: prop |
| 5622 |
}, valid); |
| 5623 |
} |
| 5624 |
} |
| 5625 |
}; |
| 5626 |
exports.default = def; |
| 5627 |
} |
| 5628 |
}); |
| 5629 |
|
| 5630 |
// node_modules/ajv/dist/vocabularies/applicator/patternProperties.js |
| 5631 |
var require_patternProperties = __commonJS({ |
| 5632 |
"node_modules/ajv/dist/vocabularies/applicator/patternProperties.js"(exports) { |
| 5633 |
"use strict"; |
| 5634 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5635 |
var code_1 = require_code2(); |
| 5636 |
var codegen_1 = require_codegen(); |
| 5637 |
var util_1 = require_util(); |
| 5638 |
var util_2 = require_util(); |
| 5639 |
var def = { |
| 5640 |
keyword: "patternProperties", |
| 5641 |
type: "object", |
| 5642 |
schemaType: "object", |
| 5643 |
code(cxt) { |
| 5644 |
const { gen, schema, data, parentSchema, it } = cxt; |
| 5645 |
const { opts } = it; |
| 5646 |
const patterns = (0, code_1.allSchemaProperties)(schema); |
| 5647 |
const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p])); |
| 5648 |
if (patterns.length === 0 || alwaysValidPatterns.length === patterns.length && (!it.opts.unevaluated || it.props === true)) { |
| 5649 |
return; |
| 5650 |
} |
| 5651 |
const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties; |
| 5652 |
const valid = gen.name("valid"); |
| 5653 |
if (it.props !== true && !(it.props instanceof codegen_1.Name)) { |
| 5654 |
it.props = (0, util_2.evaluatedPropsToName)(gen, it.props); |
| 5655 |
} |
| 5656 |
const { props } = it; |
| 5657 |
validatePatternProperties(); |
| 5658 |
function validatePatternProperties() { |
| 5659 |
for (const pat of patterns) { |
| 5660 |
if (checkProperties) |
| 5661 |
checkMatchingProperties(pat); |
| 5662 |
if (it.allErrors) { |
| 5663 |
validateProperties(pat); |
| 5664 |
} else { |
| 5665 |
gen.var(valid, true); |
| 5666 |
validateProperties(pat); |
| 5667 |
gen.if(valid); |
| 5668 |
} |
| 5669 |
} |
| 5670 |
} |
| 5671 |
function checkMatchingProperties(pat) { |
| 5672 |
for (const prop in checkProperties) { |
| 5673 |
if (new RegExp(pat).test(prop)) { |
| 5674 |
(0, util_1.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`); |
| 5675 |
} |
| 5676 |
} |
| 5677 |
} |
| 5678 |
function validateProperties(pat) { |
| 5679 |
gen.forIn("key", data, (key) => { |
| 5680 |
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key})`, () => { |
| 5681 |
const alwaysValid = alwaysValidPatterns.includes(pat); |
| 5682 |
if (!alwaysValid) { |
| 5683 |
cxt.subschema({ |
| 5684 |
keyword: "patternProperties", |
| 5685 |
schemaProp: pat, |
| 5686 |
dataProp: key, |
| 5687 |
dataPropType: util_2.Type.Str |
| 5688 |
}, valid); |
| 5689 |
} |
| 5690 |
if (it.opts.unevaluated && props !== true) { |
| 5691 |
gen.assign((0, codegen_1._)`${props}[${key}]`, true); |
| 5692 |
} else if (!alwaysValid && !it.allErrors) { |
| 5693 |
gen.if((0, codegen_1.not)(valid), () => gen.break()); |
| 5694 |
} |
| 5695 |
}); |
| 5696 |
}); |
| 5697 |
} |
| 5698 |
} |
| 5699 |
}; |
| 5700 |
exports.default = def; |
| 5701 |
} |
| 5702 |
}); |
| 5703 |
|
| 5704 |
// node_modules/ajv/dist/vocabularies/applicator/not.js |
| 5705 |
var require_not = __commonJS({ |
| 5706 |
"node_modules/ajv/dist/vocabularies/applicator/not.js"(exports) { |
| 5707 |
"use strict"; |
| 5708 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5709 |
var util_1 = require_util(); |
| 5710 |
var def = { |
| 5711 |
keyword: "not", |
| 5712 |
schemaType: ["object", "boolean"], |
| 5713 |
trackErrors: true, |
| 5714 |
code(cxt) { |
| 5715 |
const { gen, schema, it } = cxt; |
| 5716 |
if ((0, util_1.alwaysValidSchema)(it, schema)) { |
| 5717 |
cxt.fail(); |
| 5718 |
return; |
| 5719 |
} |
| 5720 |
const valid = gen.name("valid"); |
| 5721 |
cxt.subschema({ |
| 5722 |
keyword: "not", |
| 5723 |
compositeRule: true, |
| 5724 |
createErrors: false, |
| 5725 |
allErrors: false |
| 5726 |
}, valid); |
| 5727 |
cxt.failResult(valid, () => cxt.reset(), () => cxt.error()); |
| 5728 |
}, |
| 5729 |
error: { message: "must NOT be valid" } |
| 5730 |
}; |
| 5731 |
exports.default = def; |
| 5732 |
} |
| 5733 |
}); |
| 5734 |
|
| 5735 |
// node_modules/ajv/dist/vocabularies/applicator/anyOf.js |
| 5736 |
var require_anyOf = __commonJS({ |
| 5737 |
"node_modules/ajv/dist/vocabularies/applicator/anyOf.js"(exports) { |
| 5738 |
"use strict"; |
| 5739 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5740 |
var code_1 = require_code2(); |
| 5741 |
var def = { |
| 5742 |
keyword: "anyOf", |
| 5743 |
schemaType: "array", |
| 5744 |
trackErrors: true, |
| 5745 |
code: code_1.validateUnion, |
| 5746 |
error: { message: "must match a schema in anyOf" } |
| 5747 |
}; |
| 5748 |
exports.default = def; |
| 5749 |
} |
| 5750 |
}); |
| 5751 |
|
| 5752 |
// node_modules/ajv/dist/vocabularies/applicator/oneOf.js |
| 5753 |
var require_oneOf = __commonJS({ |
| 5754 |
"node_modules/ajv/dist/vocabularies/applicator/oneOf.js"(exports) { |
| 5755 |
"use strict"; |
| 5756 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5757 |
var codegen_1 = require_codegen(); |
| 5758 |
var util_1 = require_util(); |
| 5759 |
var error = { |
| 5760 |
message: "must match exactly one schema in oneOf", |
| 5761 |
params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}` |
| 5762 |
}; |
| 5763 |
var def = { |
| 5764 |
keyword: "oneOf", |
| 5765 |
schemaType: "array", |
| 5766 |
trackErrors: true, |
| 5767 |
error, |
| 5768 |
code(cxt) { |
| 5769 |
const { gen, schema, parentSchema, it } = cxt; |
| 5770 |
if (!Array.isArray(schema)) |
| 5771 |
throw new Error("ajv implementation error"); |
| 5772 |
if (it.opts.discriminator && parentSchema.discriminator) |
| 5773 |
return; |
| 5774 |
const schArr = schema; |
| 5775 |
const valid = gen.let("valid", false); |
| 5776 |
const passing = gen.let("passing", null); |
| 5777 |
const schValid = gen.name("_valid"); |
| 5778 |
cxt.setParams({ passing }); |
| 5779 |
gen.block(validateOneOf); |
| 5780 |
cxt.result(valid, () => cxt.reset(), () => cxt.error(true)); |
| 5781 |
function validateOneOf() { |
| 5782 |
schArr.forEach((sch, i) => { |
| 5783 |
let schCxt; |
| 5784 |
if ((0, util_1.alwaysValidSchema)(it, sch)) { |
| 5785 |
gen.var(schValid, true); |
| 5786 |
} else { |
| 5787 |
schCxt = cxt.subschema({ |
| 5788 |
keyword: "oneOf", |
| 5789 |
schemaProp: i, |
| 5790 |
compositeRule: true |
| 5791 |
}, schValid); |
| 5792 |
} |
| 5793 |
if (i > 0) { |
| 5794 |
gen.if((0, codegen_1._)`${schValid} && ${valid}`).assign(valid, false).assign(passing, (0, codegen_1._)`[${passing}, ${i}]`).else(); |
| 5795 |
} |
| 5796 |
gen.if(schValid, () => { |
| 5797 |
gen.assign(valid, true); |
| 5798 |
gen.assign(passing, i); |
| 5799 |
if (schCxt) |
| 5800 |
cxt.mergeEvaluated(schCxt, codegen_1.Name); |
| 5801 |
}); |
| 5802 |
}); |
| 5803 |
} |
| 5804 |
} |
| 5805 |
}; |
| 5806 |
exports.default = def; |
| 5807 |
} |
| 5808 |
}); |
| 5809 |
|
| 5810 |
// node_modules/ajv/dist/vocabularies/applicator/allOf.js |
| 5811 |
var require_allOf = __commonJS({ |
| 5812 |
"node_modules/ajv/dist/vocabularies/applicator/allOf.js"(exports) { |
| 5813 |
"use strict"; |
| 5814 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5815 |
var util_1 = require_util(); |
| 5816 |
var def = { |
| 5817 |
keyword: "allOf", |
| 5818 |
schemaType: "array", |
| 5819 |
code(cxt) { |
| 5820 |
const { gen, schema, it } = cxt; |
| 5821 |
if (!Array.isArray(schema)) |
| 5822 |
throw new Error("ajv implementation error"); |
| 5823 |
const valid = gen.name("valid"); |
| 5824 |
schema.forEach((sch, i) => { |
| 5825 |
if ((0, util_1.alwaysValidSchema)(it, sch)) |
| 5826 |
return; |
| 5827 |
const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid); |
| 5828 |
cxt.ok(valid); |
| 5829 |
cxt.mergeEvaluated(schCxt); |
| 5830 |
}); |
| 5831 |
} |
| 5832 |
}; |
| 5833 |
exports.default = def; |
| 5834 |
} |
| 5835 |
}); |
| 5836 |
|
| 5837 |
// node_modules/ajv/dist/vocabularies/applicator/if.js |
| 5838 |
var require_if = __commonJS({ |
| 5839 |
"node_modules/ajv/dist/vocabularies/applicator/if.js"(exports) { |
| 5840 |
"use strict"; |
| 5841 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5842 |
var codegen_1 = require_codegen(); |
| 5843 |
var util_1 = require_util(); |
| 5844 |
var error = { |
| 5845 |
message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`, |
| 5846 |
params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}` |
| 5847 |
}; |
| 5848 |
var def = { |
| 5849 |
keyword: "if", |
| 5850 |
schemaType: ["object", "boolean"], |
| 5851 |
trackErrors: true, |
| 5852 |
error, |
| 5853 |
code(cxt) { |
| 5854 |
const { gen, parentSchema, it } = cxt; |
| 5855 |
if (parentSchema.then === void 0 && parentSchema.else === void 0) { |
| 5856 |
(0, util_1.checkStrictMode)(it, '"if" without "then" and "else" is ignored'); |
| 5857 |
} |
| 5858 |
const hasThen = hasSchema(it, "then"); |
| 5859 |
const hasElse = hasSchema(it, "else"); |
| 5860 |
if (!hasThen && !hasElse) |
| 5861 |
return; |
| 5862 |
const valid = gen.let("valid", true); |
| 5863 |
const schValid = gen.name("_valid"); |
| 5864 |
validateIf(); |
| 5865 |
cxt.reset(); |
| 5866 |
if (hasThen && hasElse) { |
| 5867 |
const ifClause = gen.let("ifClause"); |
| 5868 |
cxt.setParams({ ifClause }); |
| 5869 |
gen.if(schValid, validateClause("then", ifClause), validateClause("else", ifClause)); |
| 5870 |
} else if (hasThen) { |
| 5871 |
gen.if(schValid, validateClause("then")); |
| 5872 |
} else { |
| 5873 |
gen.if((0, codegen_1.not)(schValid), validateClause("else")); |
| 5874 |
} |
| 5875 |
cxt.pass(valid, () => cxt.error(true)); |
| 5876 |
function validateIf() { |
| 5877 |
const schCxt = cxt.subschema({ |
| 5878 |
keyword: "if", |
| 5879 |
compositeRule: true, |
| 5880 |
createErrors: false, |
| 5881 |
allErrors: false |
| 5882 |
}, schValid); |
| 5883 |
cxt.mergeEvaluated(schCxt); |
| 5884 |
} |
| 5885 |
function validateClause(keyword, ifClause) { |
| 5886 |
return () => { |
| 5887 |
const schCxt = cxt.subschema({ keyword }, schValid); |
| 5888 |
gen.assign(valid, schValid); |
| 5889 |
cxt.mergeValidEvaluated(schCxt, valid); |
| 5890 |
if (ifClause) |
| 5891 |
gen.assign(ifClause, (0, codegen_1._)`${keyword}`); |
| 5892 |
else |
| 5893 |
cxt.setParams({ ifClause: keyword }); |
| 5894 |
}; |
| 5895 |
} |
| 5896 |
} |
| 5897 |
}; |
| 5898 |
function hasSchema(it, keyword) { |
| 5899 |
const schema = it.schema[keyword]; |
| 5900 |
return schema !== void 0 && !(0, util_1.alwaysValidSchema)(it, schema); |
| 5901 |
} |
| 5902 |
exports.default = def; |
| 5903 |
} |
| 5904 |
}); |
| 5905 |
|
| 5906 |
// node_modules/ajv/dist/vocabularies/applicator/thenElse.js |
| 5907 |
var require_thenElse = __commonJS({ |
| 5908 |
"node_modules/ajv/dist/vocabularies/applicator/thenElse.js"(exports) { |
| 5909 |
"use strict"; |
| 5910 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5911 |
var util_1 = require_util(); |
| 5912 |
var def = { |
| 5913 |
keyword: ["then", "else"], |
| 5914 |
schemaType: ["object", "boolean"], |
| 5915 |
code({ keyword, parentSchema, it }) { |
| 5916 |
if (parentSchema.if === void 0) |
| 5917 |
(0, util_1.checkStrictMode)(it, `"${keyword}" without "if" is ignored`); |
| 5918 |
} |
| 5919 |
}; |
| 5920 |
exports.default = def; |
| 5921 |
} |
| 5922 |
}); |
| 5923 |
|
| 5924 |
// node_modules/ajv/dist/vocabularies/applicator/index.js |
| 5925 |
var require_applicator = __commonJS({ |
| 5926 |
"node_modules/ajv/dist/vocabularies/applicator/index.js"(exports) { |
| 5927 |
"use strict"; |
| 5928 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5929 |
var additionalItems_1 = require_additionalItems(); |
| 5930 |
var prefixItems_1 = require_prefixItems(); |
| 5931 |
var items_1 = require_items(); |
| 5932 |
var items2020_1 = require_items2020(); |
| 5933 |
var contains_1 = require_contains(); |
| 5934 |
var dependencies_1 = require_dependencies(); |
| 5935 |
var propertyNames_1 = require_propertyNames(); |
| 5936 |
var additionalProperties_1 = require_additionalProperties(); |
| 5937 |
var properties_1 = require_properties(); |
| 5938 |
var patternProperties_1 = require_patternProperties(); |
| 5939 |
var not_1 = require_not(); |
| 5940 |
var anyOf_1 = require_anyOf(); |
| 5941 |
var oneOf_1 = require_oneOf(); |
| 5942 |
var allOf_1 = require_allOf(); |
| 5943 |
var if_1 = require_if(); |
| 5944 |
var thenElse_1 = require_thenElse(); |
| 5945 |
function getApplicator(draft2020 = false) { |
| 5946 |
const applicator = [ |
| 5947 |
// any |
| 5948 |
not_1.default, |
| 5949 |
anyOf_1.default, |
| 5950 |
oneOf_1.default, |
| 5951 |
allOf_1.default, |
| 5952 |
if_1.default, |
| 5953 |
thenElse_1.default, |
| 5954 |
// object |
| 5955 |
propertyNames_1.default, |
| 5956 |
additionalProperties_1.default, |
| 5957 |
dependencies_1.default, |
| 5958 |
properties_1.default, |
| 5959 |
patternProperties_1.default |
| 5960 |
]; |
| 5961 |
if (draft2020) |
| 5962 |
applicator.push(prefixItems_1.default, items2020_1.default); |
| 5963 |
else |
| 5964 |
applicator.push(additionalItems_1.default, items_1.default); |
| 5965 |
applicator.push(contains_1.default); |
| 5966 |
return applicator; |
| 5967 |
} |
| 5968 |
exports.default = getApplicator; |
| 5969 |
} |
| 5970 |
}); |
| 5971 |
|
| 5972 |
// node_modules/ajv/dist/vocabularies/format/format.js |
| 5973 |
var require_format = __commonJS({ |
| 5974 |
"node_modules/ajv/dist/vocabularies/format/format.js"(exports) { |
| 5975 |
"use strict"; |
| 5976 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 5977 |
var codegen_1 = require_codegen(); |
| 5978 |
var error = { |
| 5979 |
message: ({ schemaCode }) => (0, codegen_1.str)`must match format "${schemaCode}"`, |
| 5980 |
params: ({ schemaCode }) => (0, codegen_1._)`{format: ${schemaCode}}` |
| 5981 |
}; |
| 5982 |
var def = { |
| 5983 |
keyword: "format", |
| 5984 |
type: ["number", "string"], |
| 5985 |
schemaType: "string", |
| 5986 |
$data: true, |
| 5987 |
error, |
| 5988 |
code(cxt, ruleType) { |
| 5989 |
const { gen, data, $data, schema, schemaCode, it } = cxt; |
| 5990 |
const { opts, errSchemaPath, schemaEnv, self } = it; |
| 5991 |
if (!opts.validateFormats) |
| 5992 |
return; |
| 5993 |
if ($data) |
| 5994 |
validate$DataFormat(); |
| 5995 |
else |
| 5996 |
validateFormat(); |
| 5997 |
function validate$DataFormat() { |
| 5998 |
const fmts = gen.scopeValue("formats", { |
| 5999 |
ref: self.formats, |
| 6000 |
code: opts.code.formats |
| 6001 |
}); |
| 6002 |
const fDef = gen.const("fDef", (0, codegen_1._)`${fmts}[${schemaCode}]`); |
| 6003 |
const fType = gen.let("fType"); |
| 6004 |
const format = gen.let("format"); |
| 6005 |
gen.if((0, codegen_1._)`typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, (0, codegen_1._)`${fDef}.type || "string"`).assign(format, (0, codegen_1._)`${fDef}.validate`), () => gen.assign(fType, (0, codegen_1._)`"string"`).assign(format, fDef)); |
| 6006 |
cxt.fail$data((0, codegen_1.or)(unknownFmt(), invalidFmt())); |
| 6007 |
function unknownFmt() { |
| 6008 |
if (opts.strictSchema === false) |
| 6009 |
return codegen_1.nil; |
| 6010 |
return (0, codegen_1._)`${schemaCode} && !${format}`; |
| 6011 |
} |
| 6012 |
function invalidFmt() { |
| 6013 |
const callFormat = schemaEnv.$async ? (0, codegen_1._)`(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))` : (0, codegen_1._)`${format}(${data})`; |
| 6014 |
const validData = (0, codegen_1._)`(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))`; |
| 6015 |
return (0, codegen_1._)`${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`; |
| 6016 |
} |
| 6017 |
} |
| 6018 |
function validateFormat() { |
| 6019 |
const formatDef = self.formats[schema]; |
| 6020 |
if (!formatDef) { |
| 6021 |
unknownFormat(); |
| 6022 |
return; |
| 6023 |
} |
| 6024 |
if (formatDef === true) |
| 6025 |
return; |
| 6026 |
const [fmtType, format, fmtRef] = getFormat(formatDef); |
| 6027 |
if (fmtType === ruleType) |
| 6028 |
cxt.pass(validCondition()); |
| 6029 |
function unknownFormat() { |
| 6030 |
if (opts.strictSchema === false) { |
| 6031 |
self.logger.warn(unknownMsg()); |
| 6032 |
return; |
| 6033 |
} |
| 6034 |
throw new Error(unknownMsg()); |
| 6035 |
function unknownMsg() { |
| 6036 |
return `unknown format "${schema}" ignored in schema at path "${errSchemaPath}"`; |
| 6037 |
} |
| 6038 |
} |
| 6039 |
function getFormat(fmtDef) { |
| 6040 |
const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : void 0; |
| 6041 |
const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code }); |
| 6042 |
if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) { |
| 6043 |
return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._)`${fmt}.validate`]; |
| 6044 |
} |
| 6045 |
return ["string", fmtDef, fmt]; |
| 6046 |
} |
| 6047 |
function validCondition() { |
| 6048 |
if (typeof formatDef == "object" && !(formatDef instanceof RegExp) && formatDef.async) { |
| 6049 |
if (!schemaEnv.$async) |
| 6050 |
throw new Error("async format in sync schema"); |
| 6051 |
return (0, codegen_1._)`await ${fmtRef}(${data})`; |
| 6052 |
} |
| 6053 |
return typeof format == "function" ? (0, codegen_1._)`${fmtRef}(${data})` : (0, codegen_1._)`${fmtRef}.test(${data})`; |
| 6054 |
} |
| 6055 |
} |
| 6056 |
} |
| 6057 |
}; |
| 6058 |
exports.default = def; |
| 6059 |
} |
| 6060 |
}); |
| 6061 |
|
| 6062 |
// node_modules/ajv/dist/vocabularies/format/index.js |
| 6063 |
var require_format2 = __commonJS({ |
| 6064 |
"node_modules/ajv/dist/vocabularies/format/index.js"(exports) { |
| 6065 |
"use strict"; |
| 6066 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6067 |
var format_1 = require_format(); |
| 6068 |
var format = [format_1.default]; |
| 6069 |
exports.default = format; |
| 6070 |
} |
| 6071 |
}); |
| 6072 |
|
| 6073 |
// node_modules/ajv-draft-04/dist/vocabulary/draft4.js |
| 6074 |
var require_draft4 = __commonJS({ |
| 6075 |
"node_modules/ajv-draft-04/dist/vocabulary/draft4.js"(exports) { |
| 6076 |
"use strict"; |
| 6077 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6078 |
var core_1 = require_core2(); |
| 6079 |
var validation_1 = require_validation(); |
| 6080 |
var applicator_1 = require_applicator(); |
| 6081 |
var format_1 = require_format2(); |
| 6082 |
var metadataVocabulary = ["title", "description", "default"]; |
| 6083 |
var draft4Vocabularies = [ |
| 6084 |
core_1.default, |
| 6085 |
validation_1.default, |
| 6086 |
applicator_1.default(), |
| 6087 |
format_1.default, |
| 6088 |
metadataVocabulary |
| 6089 |
]; |
| 6090 |
exports.default = draft4Vocabularies; |
| 6091 |
} |
| 6092 |
}); |
| 6093 |
|
| 6094 |
// node_modules/ajv/dist/vocabularies/discriminator/types.js |
| 6095 |
var require_types = __commonJS({ |
| 6096 |
"node_modules/ajv/dist/vocabularies/discriminator/types.js"(exports) { |
| 6097 |
"use strict"; |
| 6098 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6099 |
exports.DiscrError = void 0; |
| 6100 |
var DiscrError; |
| 6101 |
(function(DiscrError2) { |
| 6102 |
DiscrError2["Tag"] = "tag"; |
| 6103 |
DiscrError2["Mapping"] = "mapping"; |
| 6104 |
})(DiscrError || (exports.DiscrError = DiscrError = {})); |
| 6105 |
} |
| 6106 |
}); |
| 6107 |
|
| 6108 |
// node_modules/ajv/dist/vocabularies/discriminator/index.js |
| 6109 |
var require_discriminator = __commonJS({ |
| 6110 |
"node_modules/ajv/dist/vocabularies/discriminator/index.js"(exports) { |
| 6111 |
"use strict"; |
| 6112 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6113 |
var codegen_1 = require_codegen(); |
| 6114 |
var types_1 = require_types(); |
| 6115 |
var compile_1 = require_compile(); |
| 6116 |
var ref_error_1 = require_ref_error(); |
| 6117 |
var util_1 = require_util(); |
| 6118 |
var error = { |
| 6119 |
message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`, |
| 6120 |
params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}` |
| 6121 |
}; |
| 6122 |
var def = { |
| 6123 |
keyword: "discriminator", |
| 6124 |
type: "object", |
| 6125 |
schemaType: "object", |
| 6126 |
error, |
| 6127 |
code(cxt) { |
| 6128 |
const { gen, data, schema, parentSchema, it } = cxt; |
| 6129 |
const { oneOf } = parentSchema; |
| 6130 |
if (!it.opts.discriminator) { |
| 6131 |
throw new Error("discriminator: requires discriminator option"); |
| 6132 |
} |
| 6133 |
const tagName = schema.propertyName; |
| 6134 |
if (typeof tagName != "string") |
| 6135 |
throw new Error("discriminator: requires propertyName"); |
| 6136 |
if (schema.mapping) |
| 6137 |
throw new Error("discriminator: mapping is not supported"); |
| 6138 |
if (!oneOf) |
| 6139 |
throw new Error("discriminator: requires oneOf keyword"); |
| 6140 |
const valid = gen.let("valid", false); |
| 6141 |
const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(tagName)}`); |
| 6142 |
gen.if((0, codegen_1._)`typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName })); |
| 6143 |
cxt.ok(valid); |
| 6144 |
function validateMapping() { |
| 6145 |
const mapping = getMapping(); |
| 6146 |
gen.if(false); |
| 6147 |
for (const tagValue in mapping) { |
| 6148 |
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`); |
| 6149 |
gen.assign(valid, applyTagSchema(mapping[tagValue])); |
| 6150 |
} |
| 6151 |
gen.else(); |
| 6152 |
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName }); |
| 6153 |
gen.endIf(); |
| 6154 |
} |
| 6155 |
function applyTagSchema(schemaProp) { |
| 6156 |
const _valid = gen.name("valid"); |
| 6157 |
const schCxt = cxt.subschema({ keyword: "oneOf", schemaProp }, _valid); |
| 6158 |
cxt.mergeEvaluated(schCxt, codegen_1.Name); |
| 6159 |
return _valid; |
| 6160 |
} |
| 6161 |
function getMapping() { |
| 6162 |
var _a; |
| 6163 |
const oneOfMapping = {}; |
| 6164 |
const topRequired = hasRequired(parentSchema); |
| 6165 |
let tagRequired = true; |
| 6166 |
for (let i = 0; i < oneOf.length; i++) { |
| 6167 |
let sch = oneOf[i]; |
| 6168 |
if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) { |
| 6169 |
const ref = sch.$ref; |
| 6170 |
sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, ref); |
| 6171 |
if (sch instanceof compile_1.SchemaEnv) |
| 6172 |
sch = sch.schema; |
| 6173 |
if (sch === void 0) |
| 6174 |
throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref); |
| 6175 |
} |
| 6176 |
const propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName]; |
| 6177 |
if (typeof propSch != "object") { |
| 6178 |
throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`); |
| 6179 |
} |
| 6180 |
tagRequired = tagRequired && (topRequired || hasRequired(sch)); |
| 6181 |
addMappings(propSch, i); |
| 6182 |
} |
| 6183 |
if (!tagRequired) |
| 6184 |
throw new Error(`discriminator: "${tagName}" must be required`); |
| 6185 |
return oneOfMapping; |
| 6186 |
function hasRequired({ required }) { |
| 6187 |
return Array.isArray(required) && required.includes(tagName); |
| 6188 |
} |
| 6189 |
function addMappings(sch, i) { |
| 6190 |
if (sch.const) { |
| 6191 |
addMapping(sch.const, i); |
| 6192 |
} else if (sch.enum) { |
| 6193 |
for (const tagValue of sch.enum) { |
| 6194 |
addMapping(tagValue, i); |
| 6195 |
} |
| 6196 |
} else { |
| 6197 |
throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`); |
| 6198 |
} |
| 6199 |
} |
| 6200 |
function addMapping(tagValue, i) { |
| 6201 |
if (typeof tagValue != "string" || tagValue in oneOfMapping) { |
| 6202 |
throw new Error(`discriminator: "${tagName}" values must be unique strings`); |
| 6203 |
} |
| 6204 |
oneOfMapping[tagValue] = i; |
| 6205 |
} |
| 6206 |
} |
| 6207 |
} |
| 6208 |
}; |
| 6209 |
exports.default = def; |
| 6210 |
} |
| 6211 |
}); |
| 6212 |
|
| 6213 |
// node_modules/ajv-draft-04/dist/refs/json-schema-draft-04.json |
| 6214 |
var require_json_schema_draft_04 = __commonJS({ |
| 6215 |
"node_modules/ajv-draft-04/dist/refs/json-schema-draft-04.json"(exports, module) { |
| 6216 |
module.exports = { |
| 6217 |
id: "http://json-schema.org/draft-04/schema#", |
| 6218 |
$schema: "http://json-schema.org/draft-04/schema#", |
| 6219 |
description: "Core schema meta-schema", |
| 6220 |
definitions: { |
| 6221 |
schemaArray: { |
| 6222 |
type: "array", |
| 6223 |
minItems: 1, |
| 6224 |
items: { $ref: "#" } |
| 6225 |
}, |
| 6226 |
positiveInteger: { |
| 6227 |
type: "integer", |
| 6228 |
minimum: 0 |
| 6229 |
}, |
| 6230 |
positiveIntegerDefault0: { |
| 6231 |
allOf: [{ $ref: "#/definitions/positiveInteger" }, { default: 0 }] |
| 6232 |
}, |
| 6233 |
simpleTypes: { |
| 6234 |
enum: ["array", "boolean", "integer", "null", "number", "object", "string"] |
| 6235 |
}, |
| 6236 |
stringArray: { |
| 6237 |
type: "array", |
| 6238 |
items: { type: "string" }, |
| 6239 |
minItems: 1, |
| 6240 |
uniqueItems: true |
| 6241 |
} |
| 6242 |
}, |
| 6243 |
type: "object", |
| 6244 |
properties: { |
| 6245 |
id: { |
| 6246 |
type: "string", |
| 6247 |
format: "uri" |
| 6248 |
}, |
| 6249 |
$schema: { |
| 6250 |
type: "string", |
| 6251 |
format: "uri" |
| 6252 |
}, |
| 6253 |
title: { |
| 6254 |
type: "string" |
| 6255 |
}, |
| 6256 |
description: { |
| 6257 |
type: "string" |
| 6258 |
}, |
| 6259 |
default: {}, |
| 6260 |
multipleOf: { |
| 6261 |
type: "number", |
| 6262 |
minimum: 0, |
| 6263 |
exclusiveMinimum: true |
| 6264 |
}, |
| 6265 |
maximum: { |
| 6266 |
type: "number" |
| 6267 |
}, |
| 6268 |
exclusiveMaximum: { |
| 6269 |
type: "boolean", |
| 6270 |
default: false |
| 6271 |
}, |
| 6272 |
minimum: { |
| 6273 |
type: "number" |
| 6274 |
}, |
| 6275 |
exclusiveMinimum: { |
| 6276 |
type: "boolean", |
| 6277 |
default: false |
| 6278 |
}, |
| 6279 |
maxLength: { $ref: "#/definitions/positiveInteger" }, |
| 6280 |
minLength: { $ref: "#/definitions/positiveIntegerDefault0" }, |
| 6281 |
pattern: { |
| 6282 |
type: "string", |
| 6283 |
format: "regex" |
| 6284 |
}, |
| 6285 |
additionalItems: { |
| 6286 |
anyOf: [{ type: "boolean" }, { $ref: "#" }], |
| 6287 |
default: {} |
| 6288 |
}, |
| 6289 |
items: { |
| 6290 |
anyOf: [{ $ref: "#" }, { $ref: "#/definitions/schemaArray" }], |
| 6291 |
default: {} |
| 6292 |
}, |
| 6293 |
maxItems: { $ref: "#/definitions/positiveInteger" }, |
| 6294 |
minItems: { $ref: "#/definitions/positiveIntegerDefault0" }, |
| 6295 |
uniqueItems: { |
| 6296 |
type: "boolean", |
| 6297 |
default: false |
| 6298 |
}, |
| 6299 |
maxProperties: { $ref: "#/definitions/positiveInteger" }, |
| 6300 |
minProperties: { $ref: "#/definitions/positiveIntegerDefault0" }, |
| 6301 |
required: { $ref: "#/definitions/stringArray" }, |
| 6302 |
additionalProperties: { |
| 6303 |
anyOf: [{ type: "boolean" }, { $ref: "#" }], |
| 6304 |
default: {} |
| 6305 |
}, |
| 6306 |
definitions: { |
| 6307 |
type: "object", |
| 6308 |
additionalProperties: { $ref: "#" }, |
| 6309 |
default: {} |
| 6310 |
}, |
| 6311 |
properties: { |
| 6312 |
type: "object", |
| 6313 |
additionalProperties: { $ref: "#" }, |
| 6314 |
default: {} |
| 6315 |
}, |
| 6316 |
patternProperties: { |
| 6317 |
type: "object", |
| 6318 |
additionalProperties: { $ref: "#" }, |
| 6319 |
default: {} |
| 6320 |
}, |
| 6321 |
dependencies: { |
| 6322 |
type: "object", |
| 6323 |
additionalProperties: { |
| 6324 |
anyOf: [{ $ref: "#" }, { $ref: "#/definitions/stringArray" }] |
| 6325 |
} |
| 6326 |
}, |
| 6327 |
enum: { |
| 6328 |
type: "array", |
| 6329 |
minItems: 1, |
| 6330 |
uniqueItems: true |
| 6331 |
}, |
| 6332 |
type: { |
| 6333 |
anyOf: [ |
| 6334 |
{ $ref: "#/definitions/simpleTypes" }, |
| 6335 |
{ |
| 6336 |
type: "array", |
| 6337 |
items: { $ref: "#/definitions/simpleTypes" }, |
| 6338 |
minItems: 1, |
| 6339 |
uniqueItems: true |
| 6340 |
} |
| 6341 |
] |
| 6342 |
}, |
| 6343 |
allOf: { $ref: "#/definitions/schemaArray" }, |
| 6344 |
anyOf: { $ref: "#/definitions/schemaArray" }, |
| 6345 |
oneOf: { $ref: "#/definitions/schemaArray" }, |
| 6346 |
not: { $ref: "#" } |
| 6347 |
}, |
| 6348 |
dependencies: { |
| 6349 |
exclusiveMaximum: ["maximum"], |
| 6350 |
exclusiveMinimum: ["minimum"] |
| 6351 |
}, |
| 6352 |
default: {} |
| 6353 |
}; |
| 6354 |
} |
| 6355 |
}); |
| 6356 |
|
| 6357 |
// node_modules/ajv-draft-04/dist/index.js |
| 6358 |
var require_dist = __commonJS({ |
| 6359 |
"node_modules/ajv-draft-04/dist/index.js"(exports, module) { |
| 6360 |
"use strict"; |
| 6361 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6362 |
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0; |
| 6363 |
var core_1 = require_core(); |
| 6364 |
var draft4_1 = require_draft4(); |
| 6365 |
var discriminator_1 = require_discriminator(); |
| 6366 |
var draft4MetaSchema = require_json_schema_draft_04(); |
| 6367 |
var META_SUPPORT_DATA = ["/properties"]; |
| 6368 |
var META_SCHEMA_ID = "http://json-schema.org/draft-04/schema"; |
| 6369 |
var Ajv2 = class extends core_1.default { |
| 6370 |
constructor(opts = {}) { |
| 6371 |
super({ |
| 6372 |
...opts, |
| 6373 |
schemaId: "id" |
| 6374 |
}); |
| 6375 |
} |
| 6376 |
_addVocabularies() { |
| 6377 |
super._addVocabularies(); |
| 6378 |
draft4_1.default.forEach((v) => this.addVocabulary(v)); |
| 6379 |
if (this.opts.discriminator) |
| 6380 |
this.addKeyword(discriminator_1.default); |
| 6381 |
} |
| 6382 |
_addDefaultMetaSchema() { |
| 6383 |
super._addDefaultMetaSchema(); |
| 6384 |
if (!this.opts.meta) |
| 6385 |
return; |
| 6386 |
const metaSchema = this.opts.$data ? this.$dataMetaSchema(draft4MetaSchema, META_SUPPORT_DATA) : draft4MetaSchema; |
| 6387 |
this.addMetaSchema(metaSchema, META_SCHEMA_ID, false); |
| 6388 |
this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID; |
| 6389 |
} |
| 6390 |
defaultMeta() { |
| 6391 |
return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0); |
| 6392 |
} |
| 6393 |
}; |
| 6394 |
module.exports = exports = Ajv2; |
| 6395 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6396 |
exports.default = Ajv2; |
| 6397 |
var core_2 = require_core(); |
| 6398 |
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() { |
| 6399 |
return core_2.KeywordCxt; |
| 6400 |
} }); |
| 6401 |
var core_3 = require_core(); |
| 6402 |
Object.defineProperty(exports, "_", { enumerable: true, get: function() { |
| 6403 |
return core_3._; |
| 6404 |
} }); |
| 6405 |
Object.defineProperty(exports, "str", { enumerable: true, get: function() { |
| 6406 |
return core_3.str; |
| 6407 |
} }); |
| 6408 |
Object.defineProperty(exports, "stringify", { enumerable: true, get: function() { |
| 6409 |
return core_3.stringify; |
| 6410 |
} }); |
| 6411 |
Object.defineProperty(exports, "nil", { enumerable: true, get: function() { |
| 6412 |
return core_3.nil; |
| 6413 |
} }); |
| 6414 |
Object.defineProperty(exports, "Name", { enumerable: true, get: function() { |
| 6415 |
return core_3.Name; |
| 6416 |
} }); |
| 6417 |
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() { |
| 6418 |
return core_3.CodeGen; |
| 6419 |
} }); |
| 6420 |
} |
| 6421 |
}); |
| 6422 |
|
| 6423 |
// packages/abilities/node_modules/ajv-formats/dist/formats.js |
| 6424 |
var require_formats = __commonJS({ |
| 6425 |
"packages/abilities/node_modules/ajv-formats/dist/formats.js"(exports) { |
| 6426 |
"use strict"; |
| 6427 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6428 |
exports.formatNames = exports.fastFormats = exports.fullFormats = void 0; |
| 6429 |
function fmtDef(validate, compare) { |
| 6430 |
return { validate, compare }; |
| 6431 |
} |
| 6432 |
exports.fullFormats = { |
| 6433 |
// date: http://tools.ietf.org/html/rfc3339#section-5.6 |
| 6434 |
date: fmtDef(date, compareDate), |
| 6435 |
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6 |
| 6436 |
time: fmtDef(getTime(true), compareTime), |
| 6437 |
"date-time": fmtDef(getDateTime(true), compareDateTime), |
| 6438 |
"iso-time": fmtDef(getTime(), compareIsoTime), |
| 6439 |
"iso-date-time": fmtDef(getDateTime(), compareIsoDateTime), |
| 6440 |
// duration: https://tools.ietf.org/html/rfc3339#appendix-A |
| 6441 |
duration: /^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/, |
| 6442 |
uri, |
| 6443 |
"uri-reference": /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i, |
| 6444 |
// uri-template: https://tools.ietf.org/html/rfc6570 |
| 6445 |
"uri-template": /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i, |
| 6446 |
// For the source: https://gist.github.com/dperini/729294 |
| 6447 |
// For test cases: https://mathiasbynens.be/demo/url-regex |
| 6448 |
url: /^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu, |
| 6449 |
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, |
| 6450 |
hostname: /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i, |
| 6451 |
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html |
| 6452 |
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/, |
| 6453 |
ipv6: /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i, |
| 6454 |
regex, |
| 6455 |
// uuid: http://tools.ietf.org/html/rfc4122 |
| 6456 |
uuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i, |
| 6457 |
// JSON-pointer: https://tools.ietf.org/html/rfc6901 |
| 6458 |
// uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A |
| 6459 |
"json-pointer": /^(?:\/(?:[^~/]|~0|~1)*)*$/, |
| 6460 |
"json-pointer-uri-fragment": /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i, |
| 6461 |
// relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00 |
| 6462 |
"relative-json-pointer": /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/, |
| 6463 |
// the following formats are used by the openapi specification: https://spec.openapis.org/oas/v3.0.0#data-types |
| 6464 |
// byte: https://github.com/miguelmota/is-base64 |
| 6465 |
byte, |
| 6466 |
// signed 32 bit integer |
| 6467 |
int32: { type: "number", validate: validateInt32 }, |
| 6468 |
// signed 64 bit integer |
| 6469 |
int64: { type: "number", validate: validateInt64 }, |
| 6470 |
// C-type float |
| 6471 |
float: { type: "number", validate: validateNumber }, |
| 6472 |
// C-type double |
| 6473 |
double: { type: "number", validate: validateNumber }, |
| 6474 |
// hint to the UI to hide input strings |
| 6475 |
password: true, |
| 6476 |
// unchecked string payload |
| 6477 |
binary: true |
| 6478 |
}; |
| 6479 |
exports.fastFormats = { |
| 6480 |
...exports.fullFormats, |
| 6481 |
date: fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d$/, compareDate), |
| 6482 |
time: fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareTime), |
| 6483 |
"date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareDateTime), |
| 6484 |
"iso-time": fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoTime), |
| 6485 |
"iso-date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoDateTime), |
| 6486 |
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js |
| 6487 |
uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i, |
| 6488 |
"uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i, |
| 6489 |
// email (sources from jsen validator): |
| 6490 |
// http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363 |
| 6491 |
// http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'wilful violation') |
| 6492 |
email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i |
| 6493 |
}; |
| 6494 |
exports.formatNames = Object.keys(exports.fullFormats); |
| 6495 |
function isLeapYear(year) { |
| 6496 |
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); |
| 6497 |
} |
| 6498 |
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/; |
| 6499 |
var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; |
| 6500 |
function date(str) { |
| 6501 |
const matches = DATE.exec(str); |
| 6502 |
if (!matches) |
| 6503 |
return false; |
| 6504 |
const year = +matches[1]; |
| 6505 |
const month = +matches[2]; |
| 6506 |
const day = +matches[3]; |
| 6507 |
return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month]); |
| 6508 |
} |
| 6509 |
function compareDate(d1, d2) { |
| 6510 |
if (!(d1 && d2)) |
| 6511 |
return void 0; |
| 6512 |
if (d1 > d2) |
| 6513 |
return 1; |
| 6514 |
if (d1 < d2) |
| 6515 |
return -1; |
| 6516 |
return 0; |
| 6517 |
} |
| 6518 |
var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i; |
| 6519 |
function getTime(strictTimeZone) { |
| 6520 |
return function time(str) { |
| 6521 |
const matches = TIME.exec(str); |
| 6522 |
if (!matches) |
| 6523 |
return false; |
| 6524 |
const hr = +matches[1]; |
| 6525 |
const min = +matches[2]; |
| 6526 |
const sec = +matches[3]; |
| 6527 |
const tz = matches[4]; |
| 6528 |
const tzSign = matches[5] === "-" ? -1 : 1; |
| 6529 |
const tzH = +(matches[6] || 0); |
| 6530 |
const tzM = +(matches[7] || 0); |
| 6531 |
if (tzH > 23 || tzM > 59 || strictTimeZone && !tz) |
| 6532 |
return false; |
| 6533 |
if (hr <= 23 && min <= 59 && sec < 60) |
| 6534 |
return true; |
| 6535 |
const utcMin = min - tzM * tzSign; |
| 6536 |
const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0); |
| 6537 |
return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61; |
| 6538 |
}; |
| 6539 |
} |
| 6540 |
function compareTime(s1, s2) { |
| 6541 |
if (!(s1 && s2)) |
| 6542 |
return void 0; |
| 6543 |
const t1 = (/* @__PURE__ */ new Date("2020-01-01T" + s1)).valueOf(); |
| 6544 |
const t2 = (/* @__PURE__ */ new Date("2020-01-01T" + s2)).valueOf(); |
| 6545 |
if (!(t1 && t2)) |
| 6546 |
return void 0; |
| 6547 |
return t1 - t2; |
| 6548 |
} |
| 6549 |
function compareIsoTime(t1, t2) { |
| 6550 |
if (!(t1 && t2)) |
| 6551 |
return void 0; |
| 6552 |
const a1 = TIME.exec(t1); |
| 6553 |
const a2 = TIME.exec(t2); |
| 6554 |
if (!(a1 && a2)) |
| 6555 |
return void 0; |
| 6556 |
t1 = a1[1] + a1[2] + a1[3]; |
| 6557 |
t2 = a2[1] + a2[2] + a2[3]; |
| 6558 |
if (t1 > t2) |
| 6559 |
return 1; |
| 6560 |
if (t1 < t2) |
| 6561 |
return -1; |
| 6562 |
return 0; |
| 6563 |
} |
| 6564 |
var DATE_TIME_SEPARATOR = /t|\s/i; |
| 6565 |
function getDateTime(strictTimeZone) { |
| 6566 |
const time = getTime(strictTimeZone); |
| 6567 |
return function date_time(str) { |
| 6568 |
const dateTime = str.split(DATE_TIME_SEPARATOR); |
| 6569 |
return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1]); |
| 6570 |
}; |
| 6571 |
} |
| 6572 |
function compareDateTime(dt1, dt2) { |
| 6573 |
if (!(dt1 && dt2)) |
| 6574 |
return void 0; |
| 6575 |
const d1 = new Date(dt1).valueOf(); |
| 6576 |
const d2 = new Date(dt2).valueOf(); |
| 6577 |
if (!(d1 && d2)) |
| 6578 |
return void 0; |
| 6579 |
return d1 - d2; |
| 6580 |
} |
| 6581 |
function compareIsoDateTime(dt1, dt2) { |
| 6582 |
if (!(dt1 && dt2)) |
| 6583 |
return void 0; |
| 6584 |
const [d1, t1] = dt1.split(DATE_TIME_SEPARATOR); |
| 6585 |
const [d2, t2] = dt2.split(DATE_TIME_SEPARATOR); |
| 6586 |
const res = compareDate(d1, d2); |
| 6587 |
if (res === void 0) |
| 6588 |
return void 0; |
| 6589 |
return res || compareTime(t1, t2); |
| 6590 |
} |
| 6591 |
var NOT_URI_FRAGMENT = /\/|:/; |
| 6592 |
var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; |
| 6593 |
function uri(str) { |
| 6594 |
return NOT_URI_FRAGMENT.test(str) && URI.test(str); |
| 6595 |
} |
| 6596 |
var BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm; |
| 6597 |
function byte(str) { |
| 6598 |
BYTE.lastIndex = 0; |
| 6599 |
return BYTE.test(str); |
| 6600 |
} |
| 6601 |
var MIN_INT32 = -(2 ** 31); |
| 6602 |
var MAX_INT32 = 2 ** 31 - 1; |
| 6603 |
function validateInt32(value) { |
| 6604 |
return Number.isInteger(value) && value <= MAX_INT32 && value >= MIN_INT32; |
| 6605 |
} |
| 6606 |
function validateInt64(value) { |
| 6607 |
return Number.isInteger(value); |
| 6608 |
} |
| 6609 |
function validateNumber() { |
| 6610 |
return true; |
| 6611 |
} |
| 6612 |
var Z_ANCHOR = /[^\\]\\Z/; |
| 6613 |
function regex(str) { |
| 6614 |
if (Z_ANCHOR.test(str)) |
| 6615 |
return false; |
| 6616 |
try { |
| 6617 |
new RegExp(str); |
| 6618 |
return true; |
| 6619 |
} catch (e) { |
| 6620 |
return false; |
| 6621 |
} |
| 6622 |
} |
| 6623 |
} |
| 6624 |
}); |
| 6625 |
|
| 6626 |
// node_modules/ajv/dist/vocabularies/core/id.js |
| 6627 |
var require_id = __commonJS({ |
| 6628 |
"node_modules/ajv/dist/vocabularies/core/id.js"(exports) { |
| 6629 |
"use strict"; |
| 6630 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6631 |
var def = { |
| 6632 |
keyword: "id", |
| 6633 |
code() { |
| 6634 |
throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID'); |
| 6635 |
} |
| 6636 |
}; |
| 6637 |
exports.default = def; |
| 6638 |
} |
| 6639 |
}); |
| 6640 |
|
| 6641 |
// node_modules/ajv/dist/vocabularies/core/index.js |
| 6642 |
var require_core3 = __commonJS({ |
| 6643 |
"node_modules/ajv/dist/vocabularies/core/index.js"(exports) { |
| 6644 |
"use strict"; |
| 6645 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6646 |
var id_1 = require_id(); |
| 6647 |
var ref_1 = require_ref(); |
| 6648 |
var core = [ |
| 6649 |
"$schema", |
| 6650 |
"$id", |
| 6651 |
"$defs", |
| 6652 |
"$vocabulary", |
| 6653 |
{ keyword: "$comment" }, |
| 6654 |
"definitions", |
| 6655 |
id_1.default, |
| 6656 |
ref_1.default |
| 6657 |
]; |
| 6658 |
exports.default = core; |
| 6659 |
} |
| 6660 |
}); |
| 6661 |
|
| 6662 |
// node_modules/ajv/dist/vocabularies/validation/limitNumber.js |
| 6663 |
var require_limitNumber2 = __commonJS({ |
| 6664 |
"node_modules/ajv/dist/vocabularies/validation/limitNumber.js"(exports) { |
| 6665 |
"use strict"; |
| 6666 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6667 |
var codegen_1 = require_codegen(); |
| 6668 |
var ops = codegen_1.operators; |
| 6669 |
var KWDs = { |
| 6670 |
maximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT }, |
| 6671 |
minimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT }, |
| 6672 |
exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE }, |
| 6673 |
exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE } |
| 6674 |
}; |
| 6675 |
var error = { |
| 6676 |
message: ({ keyword, schemaCode }) => (0, codegen_1.str)`must be ${KWDs[keyword].okStr} ${schemaCode}`, |
| 6677 |
params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}` |
| 6678 |
}; |
| 6679 |
var def = { |
| 6680 |
keyword: Object.keys(KWDs), |
| 6681 |
type: "number", |
| 6682 |
schemaType: "number", |
| 6683 |
$data: true, |
| 6684 |
error, |
| 6685 |
code(cxt) { |
| 6686 |
const { keyword, data, schemaCode } = cxt; |
| 6687 |
cxt.fail$data((0, codegen_1._)`${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`); |
| 6688 |
} |
| 6689 |
}; |
| 6690 |
exports.default = def; |
| 6691 |
} |
| 6692 |
}); |
| 6693 |
|
| 6694 |
// node_modules/ajv/dist/vocabularies/validation/index.js |
| 6695 |
var require_validation2 = __commonJS({ |
| 6696 |
"node_modules/ajv/dist/vocabularies/validation/index.js"(exports) { |
| 6697 |
"use strict"; |
| 6698 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6699 |
var limitNumber_1 = require_limitNumber2(); |
| 6700 |
var multipleOf_1 = require_multipleOf(); |
| 6701 |
var limitLength_1 = require_limitLength(); |
| 6702 |
var pattern_1 = require_pattern(); |
| 6703 |
var limitProperties_1 = require_limitProperties(); |
| 6704 |
var required_1 = require_required(); |
| 6705 |
var limitItems_1 = require_limitItems(); |
| 6706 |
var uniqueItems_1 = require_uniqueItems(); |
| 6707 |
var const_1 = require_const(); |
| 6708 |
var enum_1 = require_enum(); |
| 6709 |
var validation = [ |
| 6710 |
// number |
| 6711 |
limitNumber_1.default, |
| 6712 |
multipleOf_1.default, |
| 6713 |
// string |
| 6714 |
limitLength_1.default, |
| 6715 |
pattern_1.default, |
| 6716 |
// object |
| 6717 |
limitProperties_1.default, |
| 6718 |
required_1.default, |
| 6719 |
// array |
| 6720 |
limitItems_1.default, |
| 6721 |
uniqueItems_1.default, |
| 6722 |
// any |
| 6723 |
{ keyword: "type", schemaType: ["string", "array"] }, |
| 6724 |
{ keyword: "nullable", schemaType: "boolean" }, |
| 6725 |
const_1.default, |
| 6726 |
enum_1.default |
| 6727 |
]; |
| 6728 |
exports.default = validation; |
| 6729 |
} |
| 6730 |
}); |
| 6731 |
|
| 6732 |
// node_modules/ajv/dist/vocabularies/metadata.js |
| 6733 |
var require_metadata = __commonJS({ |
| 6734 |
"node_modules/ajv/dist/vocabularies/metadata.js"(exports) { |
| 6735 |
"use strict"; |
| 6736 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6737 |
exports.contentVocabulary = exports.metadataVocabulary = void 0; |
| 6738 |
exports.metadataVocabulary = [ |
| 6739 |
"title", |
| 6740 |
"description", |
| 6741 |
"default", |
| 6742 |
"deprecated", |
| 6743 |
"readOnly", |
| 6744 |
"writeOnly", |
| 6745 |
"examples" |
| 6746 |
]; |
| 6747 |
exports.contentVocabulary = [ |
| 6748 |
"contentMediaType", |
| 6749 |
"contentEncoding", |
| 6750 |
"contentSchema" |
| 6751 |
]; |
| 6752 |
} |
| 6753 |
}); |
| 6754 |
|
| 6755 |
// node_modules/ajv/dist/vocabularies/draft7.js |
| 6756 |
var require_draft7 = __commonJS({ |
| 6757 |
"node_modules/ajv/dist/vocabularies/draft7.js"(exports) { |
| 6758 |
"use strict"; |
| 6759 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6760 |
var core_1 = require_core3(); |
| 6761 |
var validation_1 = require_validation2(); |
| 6762 |
var applicator_1 = require_applicator(); |
| 6763 |
var format_1 = require_format2(); |
| 6764 |
var metadata_1 = require_metadata(); |
| 6765 |
var draft7Vocabularies = [ |
| 6766 |
core_1.default, |
| 6767 |
validation_1.default, |
| 6768 |
(0, applicator_1.default)(), |
| 6769 |
format_1.default, |
| 6770 |
metadata_1.metadataVocabulary, |
| 6771 |
metadata_1.contentVocabulary |
| 6772 |
]; |
| 6773 |
exports.default = draft7Vocabularies; |
| 6774 |
} |
| 6775 |
}); |
| 6776 |
|
| 6777 |
// node_modules/ajv/dist/refs/json-schema-draft-07.json |
| 6778 |
var require_json_schema_draft_07 = __commonJS({ |
| 6779 |
"node_modules/ajv/dist/refs/json-schema-draft-07.json"(exports, module) { |
| 6780 |
module.exports = { |
| 6781 |
$schema: "http://json-schema.org/draft-07/schema#", |
| 6782 |
$id: "http://json-schema.org/draft-07/schema#", |
| 6783 |
title: "Core schema meta-schema", |
| 6784 |
definitions: { |
| 6785 |
schemaArray: { |
| 6786 |
type: "array", |
| 6787 |
minItems: 1, |
| 6788 |
items: { $ref: "#" } |
| 6789 |
}, |
| 6790 |
nonNegativeInteger: { |
| 6791 |
type: "integer", |
| 6792 |
minimum: 0 |
| 6793 |
}, |
| 6794 |
nonNegativeIntegerDefault0: { |
| 6795 |
allOf: [{ $ref: "#/definitions/nonNegativeInteger" }, { default: 0 }] |
| 6796 |
}, |
| 6797 |
simpleTypes: { |
| 6798 |
enum: ["array", "boolean", "integer", "null", "number", "object", "string"] |
| 6799 |
}, |
| 6800 |
stringArray: { |
| 6801 |
type: "array", |
| 6802 |
items: { type: "string" }, |
| 6803 |
uniqueItems: true, |
| 6804 |
default: [] |
| 6805 |
} |
| 6806 |
}, |
| 6807 |
type: ["object", "boolean"], |
| 6808 |
properties: { |
| 6809 |
$id: { |
| 6810 |
type: "string", |
| 6811 |
format: "uri-reference" |
| 6812 |
}, |
| 6813 |
$schema: { |
| 6814 |
type: "string", |
| 6815 |
format: "uri" |
| 6816 |
}, |
| 6817 |
$ref: { |
| 6818 |
type: "string", |
| 6819 |
format: "uri-reference" |
| 6820 |
}, |
| 6821 |
$comment: { |
| 6822 |
type: "string" |
| 6823 |
}, |
| 6824 |
title: { |
| 6825 |
type: "string" |
| 6826 |
}, |
| 6827 |
description: { |
| 6828 |
type: "string" |
| 6829 |
}, |
| 6830 |
default: true, |
| 6831 |
readOnly: { |
| 6832 |
type: "boolean", |
| 6833 |
default: false |
| 6834 |
}, |
| 6835 |
examples: { |
| 6836 |
type: "array", |
| 6837 |
items: true |
| 6838 |
}, |
| 6839 |
multipleOf: { |
| 6840 |
type: "number", |
| 6841 |
exclusiveMinimum: 0 |
| 6842 |
}, |
| 6843 |
maximum: { |
| 6844 |
type: "number" |
| 6845 |
}, |
| 6846 |
exclusiveMaximum: { |
| 6847 |
type: "number" |
| 6848 |
}, |
| 6849 |
minimum: { |
| 6850 |
type: "number" |
| 6851 |
}, |
| 6852 |
exclusiveMinimum: { |
| 6853 |
type: "number" |
| 6854 |
}, |
| 6855 |
maxLength: { $ref: "#/definitions/nonNegativeInteger" }, |
| 6856 |
minLength: { $ref: "#/definitions/nonNegativeIntegerDefault0" }, |
| 6857 |
pattern: { |
| 6858 |
type: "string", |
| 6859 |
format: "regex" |
| 6860 |
}, |
| 6861 |
additionalItems: { $ref: "#" }, |
| 6862 |
items: { |
| 6863 |
anyOf: [{ $ref: "#" }, { $ref: "#/definitions/schemaArray" }], |
| 6864 |
default: true |
| 6865 |
}, |
| 6866 |
maxItems: { $ref: "#/definitions/nonNegativeInteger" }, |
| 6867 |
minItems: { $ref: "#/definitions/nonNegativeIntegerDefault0" }, |
| 6868 |
uniqueItems: { |
| 6869 |
type: "boolean", |
| 6870 |
default: false |
| 6871 |
}, |
| 6872 |
contains: { $ref: "#" }, |
| 6873 |
maxProperties: { $ref: "#/definitions/nonNegativeInteger" }, |
| 6874 |
minProperties: { $ref: "#/definitions/nonNegativeIntegerDefault0" }, |
| 6875 |
required: { $ref: "#/definitions/stringArray" }, |
| 6876 |
additionalProperties: { $ref: "#" }, |
| 6877 |
definitions: { |
| 6878 |
type: "object", |
| 6879 |
additionalProperties: { $ref: "#" }, |
| 6880 |
default: {} |
| 6881 |
}, |
| 6882 |
properties: { |
| 6883 |
type: "object", |
| 6884 |
additionalProperties: { $ref: "#" }, |
| 6885 |
default: {} |
| 6886 |
}, |
| 6887 |
patternProperties: { |
| 6888 |
type: "object", |
| 6889 |
additionalProperties: { $ref: "#" }, |
| 6890 |
propertyNames: { format: "regex" }, |
| 6891 |
default: {} |
| 6892 |
}, |
| 6893 |
dependencies: { |
| 6894 |
type: "object", |
| 6895 |
additionalProperties: { |
| 6896 |
anyOf: [{ $ref: "#" }, { $ref: "#/definitions/stringArray" }] |
| 6897 |
} |
| 6898 |
}, |
| 6899 |
propertyNames: { $ref: "#" }, |
| 6900 |
const: true, |
| 6901 |
enum: { |
| 6902 |
type: "array", |
| 6903 |
items: true, |
| 6904 |
minItems: 1, |
| 6905 |
uniqueItems: true |
| 6906 |
}, |
| 6907 |
type: { |
| 6908 |
anyOf: [ |
| 6909 |
{ $ref: "#/definitions/simpleTypes" }, |
| 6910 |
{ |
| 6911 |
type: "array", |
| 6912 |
items: { $ref: "#/definitions/simpleTypes" }, |
| 6913 |
minItems: 1, |
| 6914 |
uniqueItems: true |
| 6915 |
} |
| 6916 |
] |
| 6917 |
}, |
| 6918 |
format: { type: "string" }, |
| 6919 |
contentMediaType: { type: "string" }, |
| 6920 |
contentEncoding: { type: "string" }, |
| 6921 |
if: { $ref: "#" }, |
| 6922 |
then: { $ref: "#" }, |
| 6923 |
else: { $ref: "#" }, |
| 6924 |
allOf: { $ref: "#/definitions/schemaArray" }, |
| 6925 |
anyOf: { $ref: "#/definitions/schemaArray" }, |
| 6926 |
oneOf: { $ref: "#/definitions/schemaArray" }, |
| 6927 |
not: { $ref: "#" } |
| 6928 |
}, |
| 6929 |
default: true |
| 6930 |
}; |
| 6931 |
} |
| 6932 |
}); |
| 6933 |
|
| 6934 |
// node_modules/ajv/dist/ajv.js |
| 6935 |
var require_ajv = __commonJS({ |
| 6936 |
"node_modules/ajv/dist/ajv.js"(exports, module) { |
| 6937 |
"use strict"; |
| 6938 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6939 |
exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0; |
| 6940 |
var core_1 = require_core(); |
| 6941 |
var draft7_1 = require_draft7(); |
| 6942 |
var discriminator_1 = require_discriminator(); |
| 6943 |
var draft7MetaSchema = require_json_schema_draft_07(); |
| 6944 |
var META_SUPPORT_DATA = ["/properties"]; |
| 6945 |
var META_SCHEMA_ID = "http://json-schema.org/draft-07/schema"; |
| 6946 |
var Ajv2 = class extends core_1.default { |
| 6947 |
_addVocabularies() { |
| 6948 |
super._addVocabularies(); |
| 6949 |
draft7_1.default.forEach((v) => this.addVocabulary(v)); |
| 6950 |
if (this.opts.discriminator) |
| 6951 |
this.addKeyword(discriminator_1.default); |
| 6952 |
} |
| 6953 |
_addDefaultMetaSchema() { |
| 6954 |
super._addDefaultMetaSchema(); |
| 6955 |
if (!this.opts.meta) |
| 6956 |
return; |
| 6957 |
const metaSchema = this.opts.$data ? this.$dataMetaSchema(draft7MetaSchema, META_SUPPORT_DATA) : draft7MetaSchema; |
| 6958 |
this.addMetaSchema(metaSchema, META_SCHEMA_ID, false); |
| 6959 |
this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID; |
| 6960 |
} |
| 6961 |
defaultMeta() { |
| 6962 |
return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0); |
| 6963 |
} |
| 6964 |
}; |
| 6965 |
exports.Ajv = Ajv2; |
| 6966 |
module.exports = exports = Ajv2; |
| 6967 |
module.exports.Ajv = Ajv2; |
| 6968 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6969 |
exports.default = Ajv2; |
| 6970 |
var validate_1 = require_validate(); |
| 6971 |
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() { |
| 6972 |
return validate_1.KeywordCxt; |
| 6973 |
} }); |
| 6974 |
var codegen_1 = require_codegen(); |
| 6975 |
Object.defineProperty(exports, "_", { enumerable: true, get: function() { |
| 6976 |
return codegen_1._; |
| 6977 |
} }); |
| 6978 |
Object.defineProperty(exports, "str", { enumerable: true, get: function() { |
| 6979 |
return codegen_1.str; |
| 6980 |
} }); |
| 6981 |
Object.defineProperty(exports, "stringify", { enumerable: true, get: function() { |
| 6982 |
return codegen_1.stringify; |
| 6983 |
} }); |
| 6984 |
Object.defineProperty(exports, "nil", { enumerable: true, get: function() { |
| 6985 |
return codegen_1.nil; |
| 6986 |
} }); |
| 6987 |
Object.defineProperty(exports, "Name", { enumerable: true, get: function() { |
| 6988 |
return codegen_1.Name; |
| 6989 |
} }); |
| 6990 |
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() { |
| 6991 |
return codegen_1.CodeGen; |
| 6992 |
} }); |
| 6993 |
var validation_error_1 = require_validation_error(); |
| 6994 |
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() { |
| 6995 |
return validation_error_1.default; |
| 6996 |
} }); |
| 6997 |
var ref_error_1 = require_ref_error(); |
| 6998 |
Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function() { |
| 6999 |
return ref_error_1.default; |
| 7000 |
} }); |
| 7001 |
} |
| 7002 |
}); |
| 7003 |
|
| 7004 |
// packages/abilities/node_modules/ajv-formats/dist/limit.js |
| 7005 |
var require_limit = __commonJS({ |
| 7006 |
"packages/abilities/node_modules/ajv-formats/dist/limit.js"(exports) { |
| 7007 |
"use strict"; |
| 7008 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 7009 |
exports.formatLimitDefinition = void 0; |
| 7010 |
var ajv_1 = require_ajv(); |
| 7011 |
var codegen_1 = require_codegen(); |
| 7012 |
var ops = codegen_1.operators; |
| 7013 |
var KWDs = { |
| 7014 |
formatMaximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT }, |
| 7015 |
formatMinimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT }, |
| 7016 |
formatExclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE }, |
| 7017 |
formatExclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE } |
| 7018 |
}; |
| 7019 |
var error = { |
| 7020 |
message: ({ keyword, schemaCode }) => (0, codegen_1.str)`should be ${KWDs[keyword].okStr} ${schemaCode}`, |
| 7021 |
params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}` |
| 7022 |
}; |
| 7023 |
exports.formatLimitDefinition = { |
| 7024 |
keyword: Object.keys(KWDs), |
| 7025 |
type: "string", |
| 7026 |
schemaType: "string", |
| 7027 |
$data: true, |
| 7028 |
error, |
| 7029 |
code(cxt) { |
| 7030 |
const { gen, data, schemaCode, keyword, it } = cxt; |
| 7031 |
const { opts, self } = it; |
| 7032 |
if (!opts.validateFormats) |
| 7033 |
return; |
| 7034 |
const fCxt = new ajv_1.KeywordCxt(it, self.RULES.all.format.definition, "format"); |
| 7035 |
if (fCxt.$data) |
| 7036 |
validate$DataFormat(); |
| 7037 |
else |
| 7038 |
validateFormat(); |
| 7039 |
function validate$DataFormat() { |
| 7040 |
const fmts = gen.scopeValue("formats", { |
| 7041 |
ref: self.formats, |
| 7042 |
code: opts.code.formats |
| 7043 |
}); |
| 7044 |
const fmt = gen.const("fmt", (0, codegen_1._)`${fmts}[${fCxt.schemaCode}]`); |
| 7045 |
cxt.fail$data((0, codegen_1.or)((0, codegen_1._)`typeof ${fmt} != "object"`, (0, codegen_1._)`${fmt} instanceof RegExp`, (0, codegen_1._)`typeof ${fmt}.compare != "function"`, compareCode(fmt))); |
| 7046 |
} |
| 7047 |
function validateFormat() { |
| 7048 |
const format = fCxt.schema; |
| 7049 |
const fmtDef = self.formats[format]; |
| 7050 |
if (!fmtDef || fmtDef === true) |
| 7051 |
return; |
| 7052 |
if (typeof fmtDef != "object" || fmtDef instanceof RegExp || typeof fmtDef.compare != "function") { |
| 7053 |
throw new Error(`"${keyword}": format "${format}" does not define "compare" function`); |
| 7054 |
} |
| 7055 |
const fmt = gen.scopeValue("formats", { |
| 7056 |
key: format, |
| 7057 |
ref: fmtDef, |
| 7058 |
code: opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(format)}` : void 0 |
| 7059 |
}); |
| 7060 |
cxt.fail$data(compareCode(fmt)); |
| 7061 |
} |
| 7062 |
function compareCode(fmt) { |
| 7063 |
return (0, codegen_1._)`${fmt}.compare(${data}, ${schemaCode}) ${KWDs[keyword].fail} 0`; |
| 7064 |
} |
| 7065 |
}, |
| 7066 |
dependencies: ["format"] |
| 7067 |
}; |
| 7068 |
var formatLimitPlugin = (ajv2) => { |
| 7069 |
ajv2.addKeyword(exports.formatLimitDefinition); |
| 7070 |
return ajv2; |
| 7071 |
}; |
| 7072 |
exports.default = formatLimitPlugin; |
| 7073 |
} |
| 7074 |
}); |
| 7075 |
|
| 7076 |
// packages/abilities/node_modules/ajv-formats/dist/index.js |
| 7077 |
var require_dist2 = __commonJS({ |
| 7078 |
"packages/abilities/node_modules/ajv-formats/dist/index.js"(exports, module) { |
| 7079 |
"use strict"; |
| 7080 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 7081 |
var formats_1 = require_formats(); |
| 7082 |
var limit_1 = require_limit(); |
| 7083 |
var codegen_1 = require_codegen(); |
| 7084 |
var fullName = new codegen_1.Name("fullFormats"); |
| 7085 |
var fastName = new codegen_1.Name("fastFormats"); |
| 7086 |
var formatsPlugin = (ajv2, opts = { keywords: true }) => { |
| 7087 |
if (Array.isArray(opts)) { |
| 7088 |
addFormats2(ajv2, opts, formats_1.fullFormats, fullName); |
| 7089 |
return ajv2; |
| 7090 |
} |
| 7091 |
const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName]; |
| 7092 |
const list = opts.formats || formats_1.formatNames; |
| 7093 |
addFormats2(ajv2, list, formats, exportName); |
| 7094 |
if (opts.keywords) |
| 7095 |
(0, limit_1.default)(ajv2); |
| 7096 |
return ajv2; |
| 7097 |
}; |
| 7098 |
formatsPlugin.get = (name, mode = "full") => { |
| 7099 |
const formats = mode === "fast" ? formats_1.fastFormats : formats_1.fullFormats; |
| 7100 |
const f = formats[name]; |
| 7101 |
if (!f) |
| 7102 |
throw new Error(`Unknown format "${name}"`); |
| 7103 |
return f; |
| 7104 |
}; |
| 7105 |
function addFormats2(ajv2, list, fs, exportName) { |
| 7106 |
var _a; |
| 7107 |
var _b; |
| 7108 |
(_a = (_b = ajv2.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`; |
| 7109 |
for (const f of list) |
| 7110 |
ajv2.addFormat(f, fs[f]); |
| 7111 |
} |
| 7112 |
module.exports = exports = formatsPlugin; |
| 7113 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 7114 |
exports.default = formatsPlugin; |
| 7115 |
} |
| 7116 |
}); |
| 7117 |
|
| 7118 |
// packages/abilities/build-module/api.mjs |
| 7119 |
var import_data4 = __toESM(require_data(), 1); |
| 7120 |
var import_i18n2 = __toESM(require_i18n(), 1); |
| 7121 |
|
| 7122 |
// packages/abilities/build-module/store/index.mjs |
| 7123 |
var import_data3 = __toESM(require_data(), 1); |
| 7124 |
|
| 7125 |
// packages/abilities/build-module/store/reducer.mjs |
| 7126 |
var import_data = __toESM(require_data(), 1); |
| 7127 |
|
| 7128 |
// packages/abilities/build-module/store/constants.mjs |
| 7129 |
var STORE_NAME = "core/abilities"; |
| 7130 |
var ABILITY_NAME_PATTERN = /^[a-z0-9-]+(?:\/[a-z0-9-]+){1,3}$/; |
| 7131 |
var CATEGORY_SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/; |
| 7132 |
var REGISTER_ABILITY = "REGISTER_ABILITY"; |
| 7133 |
var UNREGISTER_ABILITY = "UNREGISTER_ABILITY"; |
| 7134 |
var REGISTER_ABILITY_CATEGORY = "REGISTER_ABILITY_CATEGORY"; |
| 7135 |
var UNREGISTER_ABILITY_CATEGORY = "UNREGISTER_ABILITY_CATEGORY"; |
| 7136 |
|
| 7137 |
// packages/abilities/build-module/store/reducer.mjs |
| 7138 |
var ABILITY_KEYS = [ |
| 7139 |
"name", |
| 7140 |
"label", |
| 7141 |
"description", |
| 7142 |
"category", |
| 7143 |
"input_schema", |
| 7144 |
"output_schema", |
| 7145 |
"meta", |
| 7146 |
"callback", |
| 7147 |
"permissionCallback" |
| 7148 |
]; |
| 7149 |
var CATEGORY_KEYS = ["slug", "label", "description", "meta"]; |
| 7150 |
function sanitizeAbility(ability) { |
| 7151 |
return Object.keys(ability).filter( |
| 7152 |
(key) => ABILITY_KEYS.includes(key) && ability[key] !== void 0 |
| 7153 |
).reduce( |
| 7154 |
(obj, key) => ({ ...obj, [key]: ability[key] }), |
| 7155 |
{} |
| 7156 |
); |
| 7157 |
} |
| 7158 |
function sanitizeCategory(category) { |
| 7159 |
return Object.keys(category).filter( |
| 7160 |
(key) => CATEGORY_KEYS.includes(key) && category[key] !== void 0 |
| 7161 |
).reduce( |
| 7162 |
(obj, key) => ({ ...obj, [key]: category[key] }), |
| 7163 |
{} |
| 7164 |
); |
| 7165 |
} |
| 7166 |
var DEFAULT_STATE = {}; |
| 7167 |
function abilitiesByName(state = DEFAULT_STATE, action) { |
| 7168 |
switch (action.type) { |
| 7169 |
case REGISTER_ABILITY: { |
| 7170 |
if (!action.ability) { |
| 7171 |
return state; |
| 7172 |
} |
| 7173 |
return { |
| 7174 |
...state, |
| 7175 |
[action.ability.name]: sanitizeAbility(action.ability) |
| 7176 |
}; |
| 7177 |
} |
| 7178 |
case UNREGISTER_ABILITY: { |
| 7179 |
if (!state[action.name]) { |
| 7180 |
return state; |
| 7181 |
} |
| 7182 |
const { [action.name]: _, ...newState } = state; |
| 7183 |
return newState; |
| 7184 |
} |
| 7185 |
default: |
| 7186 |
return state; |
| 7187 |
} |
| 7188 |
} |
| 7189 |
var DEFAULT_CATEGORIES_STATE = {}; |
| 7190 |
function categoriesBySlug(state = DEFAULT_CATEGORIES_STATE, action) { |
| 7191 |
switch (action.type) { |
| 7192 |
case REGISTER_ABILITY_CATEGORY: { |
| 7193 |
if (!action.category) { |
| 7194 |
return state; |
| 7195 |
} |
| 7196 |
return { |
| 7197 |
...state, |
| 7198 |
[action.category.slug]: sanitizeCategory(action.category) |
| 7199 |
}; |
| 7200 |
} |
| 7201 |
case UNREGISTER_ABILITY_CATEGORY: { |
| 7202 |
if (!state[action.slug]) { |
| 7203 |
return state; |
| 7204 |
} |
| 7205 |
const { [action.slug]: _, ...newState } = state; |
| 7206 |
return newState; |
| 7207 |
} |
| 7208 |
default: |
| 7209 |
return state; |
| 7210 |
} |
| 7211 |
} |
| 7212 |
var reducer_default = (0, import_data.combineReducers)({ |
| 7213 |
abilitiesByName, |
| 7214 |
categoriesBySlug |
| 7215 |
}); |
| 7216 |
|
| 7217 |
// packages/abilities/build-module/store/actions.mjs |
| 7218 |
var actions_exports = {}; |
| 7219 |
__export(actions_exports, { |
| 7220 |
registerAbility: () => registerAbility, |
| 7221 |
registerAbilityCategory: () => registerAbilityCategory, |
| 7222 |
unregisterAbility: () => unregisterAbility, |
| 7223 |
unregisterAbilityCategory: () => unregisterAbilityCategory |
| 7224 |
}); |
| 7225 |
var import_i18n = __toESM(require_i18n(), 1); |
| 7226 |
function filterAnnotations(sourceAnnotations, allowedKeys) { |
| 7227 |
const annotations = {}; |
| 7228 |
if (sourceAnnotations) { |
| 7229 |
for (const key of allowedKeys) { |
| 7230 |
if (sourceAnnotations[key] !== void 0) { |
| 7231 |
annotations[key] = sourceAnnotations[key]; |
| 7232 |
} |
| 7233 |
} |
| 7234 |
} |
| 7235 |
return annotations; |
| 7236 |
} |
| 7237 |
function registerAbility(ability) { |
| 7238 |
return ({ select: select2, dispatch: dispatch2 }) => { |
| 7239 |
if (!ability.name) { |
| 7240 |
throw new Error("Ability name is required"); |
| 7241 |
} |
| 7242 |
if (!ABILITY_NAME_PATTERN.test(ability.name)) { |
| 7243 |
throw new Error( |
| 7244 |
'Ability name must be a string containing a namespace prefix with 2-4 segments, e.g. "my-plugin/my-ability" or "core/posts/find". It can only contain lowercase alphanumeric characters, dashes and the forward slash.' |
| 7245 |
); |
| 7246 |
} |
| 7247 |
if (!ability.label) { |
| 7248 |
throw new Error( |
| 7249 |
(0, import_i18n.sprintf)('Ability "%s" must have a label', ability.name) |
| 7250 |
); |
| 7251 |
} |
| 7252 |
if (!ability.description) { |
| 7253 |
throw new Error( |
| 7254 |
(0, import_i18n.sprintf)('Ability "%s" must have a description', ability.name) |
| 7255 |
); |
| 7256 |
} |
| 7257 |
if (!ability.category) { |
| 7258 |
throw new Error( |
| 7259 |
(0, import_i18n.sprintf)('Ability "%s" must have a category', ability.name) |
| 7260 |
); |
| 7261 |
} |
| 7262 |
if (!CATEGORY_SLUG_PATTERN.test(ability.category)) { |
| 7263 |
throw new Error( |
| 7264 |
(0, import_i18n.sprintf)( |
| 7265 |
'Ability "%1$s" has an invalid category. Category must be lowercase alphanumeric with dashes only. Got: "%2$s"', |
| 7266 |
ability.name, |
| 7267 |
ability.category |
| 7268 |
) |
| 7269 |
); |
| 7270 |
} |
| 7271 |
const categories = select2.getAbilityCategories(); |
| 7272 |
const existingCategory = categories.find( |
| 7273 |
(cat) => cat.slug === ability.category |
| 7274 |
); |
| 7275 |
if (!existingCategory) { |
| 7276 |
throw new Error( |
| 7277 |
(0, import_i18n.sprintf)( |
| 7278 |
'Ability "%1$s" references non-existent category "%2$s". Please register the category first.', |
| 7279 |
ability.name, |
| 7280 |
ability.category |
| 7281 |
) |
| 7282 |
); |
| 7283 |
} |
| 7284 |
if (ability.callback && typeof ability.callback !== "function") { |
| 7285 |
throw new Error( |
| 7286 |
(0, import_i18n.sprintf)( |
| 7287 |
'Ability "%s" has an invalid callback. Callback must be a function', |
| 7288 |
ability.name |
| 7289 |
) |
| 7290 |
); |
| 7291 |
} |
| 7292 |
const existingAbility = select2.getAbility(ability.name); |
| 7293 |
if (existingAbility) { |
| 7294 |
throw new Error( |
| 7295 |
(0, import_i18n.sprintf)('Ability "%s" is already registered', ability.name) |
| 7296 |
); |
| 7297 |
} |
| 7298 |
const annotations = filterAnnotations(ability.meta?.annotations, [ |
| 7299 |
"readonly", |
| 7300 |
"destructive", |
| 7301 |
"idempotent", |
| 7302 |
"serverRegistered", |
| 7303 |
"clientRegistered" |
| 7304 |
]); |
| 7305 |
if (!annotations.serverRegistered) { |
| 7306 |
annotations.clientRegistered = true; |
| 7307 |
} |
| 7308 |
const meta = { |
| 7309 |
...ability.meta || {}, |
| 7310 |
annotations |
| 7311 |
}; |
| 7312 |
dispatch2({ |
| 7313 |
type: REGISTER_ABILITY, |
| 7314 |
ability: { |
| 7315 |
...ability, |
| 7316 |
meta |
| 7317 |
} |
| 7318 |
}); |
| 7319 |
}; |
| 7320 |
} |
| 7321 |
function unregisterAbility(name) { |
| 7322 |
return { |
| 7323 |
type: UNREGISTER_ABILITY, |
| 7324 |
name |
| 7325 |
}; |
| 7326 |
} |
| 7327 |
function registerAbilityCategory(slug, args) { |
| 7328 |
return ({ select: select2, dispatch: dispatch2 }) => { |
| 7329 |
if (!slug) { |
| 7330 |
throw new Error("Category slug is required"); |
| 7331 |
} |
| 7332 |
if (!CATEGORY_SLUG_PATTERN.test(slug)) { |
| 7333 |
throw new Error( |
| 7334 |
"Category slug must contain only lowercase alphanumeric characters and dashes." |
| 7335 |
); |
| 7336 |
} |
| 7337 |
const existingCategory = select2.getAbilityCategory(slug); |
| 7338 |
if (existingCategory) { |
| 7339 |
throw new Error( |
| 7340 |
(0, import_i18n.sprintf)('Category "%s" is already registered.', slug) |
| 7341 |
); |
| 7342 |
} |
| 7343 |
if (!args.label || typeof args.label !== "string") { |
| 7344 |
throw new Error( |
| 7345 |
"The category properties must contain a `label` string." |
| 7346 |
); |
| 7347 |
} |
| 7348 |
if (!args.description || typeof args.description !== "string") { |
| 7349 |
throw new Error( |
| 7350 |
"The category properties must contain a `description` string." |
| 7351 |
); |
| 7352 |
} |
| 7353 |
if (args.meta !== void 0 && (typeof args.meta !== "object" || Array.isArray(args.meta))) { |
| 7354 |
throw new Error( |
| 7355 |
"The category properties should provide a valid `meta` object." |
| 7356 |
); |
| 7357 |
} |
| 7358 |
const annotations = filterAnnotations(args.meta?.annotations, [ |
| 7359 |
"serverRegistered", |
| 7360 |
"clientRegistered" |
| 7361 |
]); |
| 7362 |
if (!annotations.serverRegistered) { |
| 7363 |
annotations.clientRegistered = true; |
| 7364 |
} |
| 7365 |
const meta = { |
| 7366 |
...args.meta || {}, |
| 7367 |
annotations |
| 7368 |
}; |
| 7369 |
const category = { |
| 7370 |
slug, |
| 7371 |
label: args.label, |
| 7372 |
description: args.description, |
| 7373 |
meta |
| 7374 |
}; |
| 7375 |
dispatch2({ |
| 7376 |
type: REGISTER_ABILITY_CATEGORY, |
| 7377 |
category |
| 7378 |
}); |
| 7379 |
}; |
| 7380 |
} |
| 7381 |
function unregisterAbilityCategory(slug) { |
| 7382 |
return { |
| 7383 |
type: UNREGISTER_ABILITY_CATEGORY, |
| 7384 |
slug |
| 7385 |
}; |
| 7386 |
} |
| 7387 |
|
| 7388 |
// packages/abilities/build-module/store/selectors.mjs |
| 7389 |
var selectors_exports = {}; |
| 7390 |
__export(selectors_exports, { |
| 7391 |
getAbilities: () => getAbilities, |
| 7392 |
getAbility: () => getAbility, |
| 7393 |
getAbilityCategories: () => getAbilityCategories, |
| 7394 |
getAbilityCategory: () => getAbilityCategory |
| 7395 |
}); |
| 7396 |
var import_data2 = __toESM(require_data(), 1); |
| 7397 |
var getAbilities = (0, import_data2.createSelector)( |
| 7398 |
(state, { category } = {}) => { |
| 7399 |
const abilities = Object.values(state.abilitiesByName); |
| 7400 |
if (category) { |
| 7401 |
return abilities.filter( |
| 7402 |
(ability) => ability.category === category |
| 7403 |
); |
| 7404 |
} |
| 7405 |
return abilities; |
| 7406 |
}, |
| 7407 |
(state, { category } = {}) => [ |
| 7408 |
state.abilitiesByName, |
| 7409 |
category |
| 7410 |
] |
| 7411 |
); |
| 7412 |
function getAbility(state, name) { |
| 7413 |
return state.abilitiesByName[name]; |
| 7414 |
} |
| 7415 |
var getAbilityCategories = (0, import_data2.createSelector)( |
| 7416 |
(state) => { |
| 7417 |
return Object.values(state.categoriesBySlug); |
| 7418 |
}, |
| 7419 |
(state) => [state.categoriesBySlug] |
| 7420 |
); |
| 7421 |
function getAbilityCategory(state, slug) { |
| 7422 |
return state.categoriesBySlug[slug]; |
| 7423 |
} |
| 7424 |
|
| 7425 |
// packages/abilities/build-module/store/index.mjs |
| 7426 |
var store = (0, import_data3.createReduxStore)(STORE_NAME, { |
| 7427 |
reducer: reducer_default, |
| 7428 |
actions: actions_exports, |
| 7429 |
selectors: selectors_exports |
| 7430 |
}); |
| 7431 |
(0, import_data3.register)(store); |
| 7432 |
|
| 7433 |
// packages/abilities/build-module/validation.mjs |
| 7434 |
var import_ajv_draft_04 = __toESM(require_dist(), 1); |
| 7435 |
var import_ajv_formats = __toESM(require_dist2(), 1); |
| 7436 |
var ajv = new import_ajv_draft_04.default({ |
| 7437 |
coerceTypes: false, |
| 7438 |
// No type coercion - AI should send proper JSON |
| 7439 |
useDefaults: true, |
| 7440 |
removeAdditional: false, |
| 7441 |
// Keep additional properties |
| 7442 |
allErrors: true, |
| 7443 |
verbose: true, |
| 7444 |
allowUnionTypes: true |
| 7445 |
// Allow anyOf without explicit type |
| 7446 |
}); |
| 7447 |
(0, import_ajv_formats.default)(ajv, ["date-time", "email", "hostname", "ipv4", "ipv6", "uuid"]); |
| 7448 |
function formatAjvError(ajvError, param) { |
| 7449 |
const instancePath = ajvError.instancePath ? ajvError.instancePath.replace(/\//g, "][").replace(/^\]\[/, "[") + "]" : ""; |
| 7450 |
const fullParam = param + instancePath; |
| 7451 |
switch (ajvError.keyword) { |
| 7452 |
case "type": |
| 7453 |
return `${fullParam} is not of type ${ajvError.params.type}.`; |
| 7454 |
case "required": |
| 7455 |
return `${ajvError.params.missingProperty} is a required property of ${fullParam}.`; |
| 7456 |
case "additionalProperties": |
| 7457 |
return `${ajvError.params.additionalProperty} is not a valid property of Object.`; |
| 7458 |
case "enum": |
| 7459 |
const enumValues = ajvError.params.allowedValues.map( |
| 7460 |
(v) => typeof v === "string" ? v : JSON.stringify(v) |
| 7461 |
).join(", "); |
| 7462 |
return ajvError.params.allowedValues.length === 1 ? `${fullParam} is not ${enumValues}.` : `${fullParam} is not one of ${enumValues}.`; |
| 7463 |
case "pattern": |
| 7464 |
return `${fullParam} does not match pattern ${ajvError.params.pattern}.`; |
| 7465 |
case "format": |
| 7466 |
const format = ajvError.params.format; |
| 7467 |
const formatMessages = { |
| 7468 |
email: "Invalid email address.", |
| 7469 |
"date-time": "Invalid date.", |
| 7470 |
uuid: `${fullParam} is not a valid UUID.`, |
| 7471 |
ipv4: `${fullParam} is not a valid IP address.`, |
| 7472 |
ipv6: `${fullParam} is not a valid IP address.`, |
| 7473 |
hostname: `${fullParam} is not a valid hostname.` |
| 7474 |
}; |
| 7475 |
return formatMessages[format] || `Invalid ${format}.`; |
| 7476 |
case "minimum": |
| 7477 |
case "exclusiveMinimum": |
| 7478 |
return ajvError.keyword === "exclusiveMinimum" ? `${fullParam} must be greater than ${ajvError.params.limit}` : `${fullParam} must be greater than or equal to ${ajvError.params.limit}`; |
| 7479 |
case "maximum": |
| 7480 |
case "exclusiveMaximum": |
| 7481 |
return ajvError.keyword === "exclusiveMaximum" ? `${fullParam} must be less than ${ajvError.params.limit}` : `${fullParam} must be less than or equal to ${ajvError.params.limit}`; |
| 7482 |
case "multipleOf": |
| 7483 |
return `${fullParam} must be a multiple of ${ajvError.params.multipleOf}.`; |
| 7484 |
case "anyOf": |
| 7485 |
case "oneOf": |
| 7486 |
return `${fullParam} is invalid (failed ${ajvError.keyword} validation).`; |
| 7487 |
case "minLength": |
| 7488 |
return `${fullParam} must be at least ${ajvError.params.limit} character${ajvError.params.limit === 1 ? "" : "s"} long.`; |
| 7489 |
case "maxLength": |
| 7490 |
return `${fullParam} must be at most ${ajvError.params.limit} character${ajvError.params.limit === 1 ? "" : "s"} long.`; |
| 7491 |
case "minItems": |
| 7492 |
return `${fullParam} must contain at least ${ajvError.params.limit} item${ajvError.params.limit === 1 ? "" : "s"}.`; |
| 7493 |
case "maxItems": |
| 7494 |
return `${fullParam} must contain at most ${ajvError.params.limit} item${ajvError.params.limit === 1 ? "" : "s"}.`; |
| 7495 |
case "uniqueItems": |
| 7496 |
return `${fullParam} has duplicate items.`; |
| 7497 |
case "minProperties": |
| 7498 |
return `${fullParam} must contain at least ${ajvError.params.limit} propert${ajvError.params.limit === 1 ? "y" : "ies"}.`; |
| 7499 |
case "maxProperties": |
| 7500 |
return `${fullParam} must contain at most ${ajvError.params.limit} propert${ajvError.params.limit === 1 ? "y" : "ies"}.`; |
| 7501 |
default: |
| 7502 |
return ajvError.message || `${fullParam} is invalid (failed ${ajvError.keyword} validation).`; |
| 7503 |
} |
| 7504 |
} |
| 7505 |
function validateValueFromSchema(value, args, param = "") { |
| 7506 |
if (!args || typeof args !== "object") { |
| 7507 |
console.warn(`Schema must be an object. Received ${typeof args}.`); |
| 7508 |
return true; |
| 7509 |
} |
| 7510 |
if (!args.type && !args.anyOf && !args.oneOf) { |
| 7511 |
console.warn( |
| 7512 |
`The "type" schema keyword for ${param || "value"} is required.` |
| 7513 |
); |
| 7514 |
return true; |
| 7515 |
} |
| 7516 |
try { |
| 7517 |
const { default: defaultValue, ...schemaWithoutDefault } = args; |
| 7518 |
const validate = ajv.compile(schemaWithoutDefault); |
| 7519 |
const valid = validate(value === void 0 ? defaultValue : value); |
| 7520 |
if (valid) { |
| 7521 |
return true; |
| 7522 |
} |
| 7523 |
if (validate.errors && validate.errors.length > 0) { |
| 7524 |
const anyOfError = validate.errors.find( |
| 7525 |
(e) => e.keyword === "anyOf" || e.keyword === "oneOf" |
| 7526 |
); |
| 7527 |
if (anyOfError) { |
| 7528 |
return formatAjvError(anyOfError, param); |
| 7529 |
} |
| 7530 |
return formatAjvError(validate.errors[0], param); |
| 7531 |
} |
| 7532 |
return `${param} is invalid.`; |
| 7533 |
} catch (error) { |
| 7534 |
console.error("Schema compilation error:", error); |
| 7535 |
return "Invalid schema provided for validation."; |
| 7536 |
} |
| 7537 |
} |
| 7538 |
|
| 7539 |
// packages/abilities/build-module/api.mjs |
| 7540 |
function getAbilities2(args = {}) { |
| 7541 |
return (0, import_data4.select)(store).getAbilities(args); |
| 7542 |
} |
| 7543 |
function getAbility2(name) { |
| 7544 |
return (0, import_data4.select)(store).getAbility(name); |
| 7545 |
} |
| 7546 |
function getAbilityCategories2() { |
| 7547 |
return (0, import_data4.select)(store).getAbilityCategories(); |
| 7548 |
} |
| 7549 |
function getAbilityCategory2(slug) { |
| 7550 |
return (0, import_data4.select)(store).getAbilityCategory(slug); |
| 7551 |
} |
| 7552 |
function registerAbility2(ability) { |
| 7553 |
(0, import_data4.dispatch)(store).registerAbility(ability); |
| 7554 |
} |
| 7555 |
function unregisterAbility2(name) { |
| 7556 |
(0, import_data4.dispatch)(store).unregisterAbility(name); |
| 7557 |
} |
| 7558 |
function registerAbilityCategory2(slug, args) { |
| 7559 |
(0, import_data4.dispatch)(store).registerAbilityCategory(slug, args); |
| 7560 |
} |
| 7561 |
function unregisterAbilityCategory2(slug) { |
| 7562 |
(0, import_data4.dispatch)(store).unregisterAbilityCategory(slug); |
| 7563 |
} |
| 7564 |
async function executeAbility(name, input) { |
| 7565 |
const ability = getAbility2(name); |
| 7566 |
if (!ability) { |
| 7567 |
throw new Error((0, import_i18n2.sprintf)("Ability not found: %s", name)); |
| 7568 |
} |
| 7569 |
if (!ability.callback) { |
| 7570 |
throw new Error( |
| 7571 |
(0, import_i18n2.sprintf)( |
| 7572 |
'Ability "%s" is missing callback. Please ensure the ability is properly registered.', |
| 7573 |
ability.name |
| 7574 |
) |
| 7575 |
); |
| 7576 |
} |
| 7577 |
if (ability.permissionCallback) { |
| 7578 |
const hasPermission = await ability.permissionCallback(input); |
| 7579 |
if (!hasPermission) { |
| 7580 |
const error = new Error( |
| 7581 |
(0, import_i18n2.sprintf)("Permission denied for ability: %s", ability.name) |
| 7582 |
); |
| 7583 |
error.code = "ability_permission_denied"; |
| 7584 |
throw error; |
| 7585 |
} |
| 7586 |
} |
| 7587 |
if (ability.input_schema) { |
| 7588 |
const inputValidation = validateValueFromSchema( |
| 7589 |
input, |
| 7590 |
ability.input_schema, |
| 7591 |
"input" |
| 7592 |
); |
| 7593 |
if (inputValidation !== true) { |
| 7594 |
const error = new Error( |
| 7595 |
(0, import_i18n2.sprintf)( |
| 7596 |
'Ability "%1$s" has invalid input. Reason: %2$s', |
| 7597 |
ability.name, |
| 7598 |
inputValidation |
| 7599 |
) |
| 7600 |
); |
| 7601 |
error.code = "ability_invalid_input"; |
| 7602 |
throw error; |
| 7603 |
} |
| 7604 |
} |
| 7605 |
let result; |
| 7606 |
try { |
| 7607 |
result = await ability.callback(input); |
| 7608 |
} catch (error) { |
| 7609 |
console.error(`Error executing ability ${ability.name}:`, error); |
| 7610 |
throw error; |
| 7611 |
} |
| 7612 |
if (ability.output_schema) { |
| 7613 |
const outputValidation = validateValueFromSchema( |
| 7614 |
result, |
| 7615 |
ability.output_schema, |
| 7616 |
"output" |
| 7617 |
); |
| 7618 |
if (outputValidation !== true) { |
| 7619 |
const error = new Error( |
| 7620 |
(0, import_i18n2.sprintf)( |
| 7621 |
'Ability "%1$s" has invalid output. Reason: %2$s', |
| 7622 |
ability.name, |
| 7623 |
outputValidation |
| 7624 |
) |
| 7625 |
); |
| 7626 |
error.code = "ability_invalid_output"; |
| 7627 |
throw error; |
| 7628 |
} |
| 7629 |
} |
| 7630 |
return result; |
| 7631 |
} |
| 7632 |
export { |
| 7633 |
executeAbility, |
| 7634 |
getAbilities2 as getAbilities, |
| 7635 |
getAbility2 as getAbility, |
| 7636 |
getAbilityCategories2 as getAbilityCategories, |
| 7637 |
getAbilityCategory2 as getAbilityCategory, |
| 7638 |
registerAbility2 as registerAbility, |
| 7639 |
registerAbilityCategory2 as registerAbilityCategory, |
| 7640 |
store, |
| 7641 |
unregisterAbility2 as unregisterAbility, |
| 7642 |
unregisterAbilityCategory2 as unregisterAbilityCategory, |
| 7643 |
validateValueFromSchema |
| 7644 |
}; |
| 7645 |
//# sourceMappingURL=index.js.map |
| 7646 |
|