| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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/utils.js 3116 var require_utils = __commonJS({ 3117 "node_modules/fast-uri/lib/utils.js"(exports, module) { 3118 "use strict"; 3119 var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu); 3120 var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u); 3121 var isPort = RegExp.prototype.test.bind(/^\d*$/u); 3122 var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu); 3123 var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu); 3124 var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u); 3125 var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u); 3126 var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u); 3127 var BYTE_HEX = new Array(256); 3128 { 3129 const HEX_DIGITS = "0123456789ABCDEF"; 3130 for (let i = 0; i < 256; i++) { 3131 BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15]; 3132 } 3133 } 3134 function percentEncodeNonAscii(cp) { 3135 if (cp < 2048) { 3136 return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63]; 3137 } 3138 if (cp < 65536) { 3139 return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63]; 3140 } 3141 return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63]; 3142 } 3143 function stringArrayToHexStripped(input) { 3144 let acc = ""; 3145 let code = 0; 3146 let i = 0; 3147 for (i = 0; i < input.length; i++) { 3148 code = input[i].charCodeAt(0); 3149 if (code === 48) { 3150 continue; 3151 } 3152 if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) { 3153 return ""; 3154 } 3155 acc += input[i]; 3156 break; 3157 } 3158 for (i += 1; i < input.length; i++) { 3159 code = input[i].charCodeAt(0); 3160 if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) { 3161 return ""; 3162 } 3163 acc += input[i]; 3164 } 3165 return acc; 3166 } 3167 var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/); 3168 var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/); 3169 var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/); 3170 var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u); 3171 function isZoneIdentifier(zone) { 3172 if (zone.length === 0) return false; 3173 for (let i = 0; i < zone.length; i++) { 3174 if (isZoneCharacter(zone[i])) continue; 3175 if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) { 3176 i += 2; 3177 continue; 3178 } 3179 return false; 3180 } 3181 return true; 3182 } 3183 function compressIPv6ZeroRun(hextets) { 3184 let bestStart = -1; 3185 let bestLength = 0; 3186 let runStart = -1; 3187 let runLength = 0; 3188 for (let i = 0; i < hextets.length; i++) { 3189 if (hextets[i] === "0") { 3190 if (runStart === -1) runStart = i; 3191 runLength++; 3192 if (runLength > bestLength) { 3193 bestLength = runLength; 3194 bestStart = runStart; 3195 } 3196 } else { 3197 runStart = -1; 3198 runLength = 0; 3199 } 3200 } 3201 if (bestLength < 2) return hextets.join(":"); 3202 const head = hextets.slice(0, bestStart).join(":"); 3203 const tail = hextets.slice(bestStart + bestLength).join(":"); 3204 return head + "::" + tail; 3205 } 3206 function normalizeIPv6Address(input) { 3207 const compression = input.indexOf("::"); 3208 if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0; 3209 const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":"); 3210 const right = compression === -1 ? [] : input.slice(compression + 2).split(":"); 3211 if (compression !== -1) { 3212 if (left.length === 1 && left[0] === "") left.length = 0; 3213 if (right.length === 1 && right[0] === "") right.length = 0; 3214 } 3215 const parts = left.concat(right); 3216 let hextetCount = 0; 3217 for (let i = 0; i < parts.length; i++) { 3218 const part = parts[i]; 3219 if (part === "") return void 0; 3220 if (part.indexOf(".") !== -1) { 3221 if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0; 3222 hextetCount += 2; 3223 continue; 3224 } 3225 if (!isHextet(part)) return void 0; 3226 parts[i] = parseInt(part, 16).toString(16); 3227 hextetCount++; 3228 } 3229 if (compression === -1) { 3230 if (hextetCount !== 8) return void 0; 3231 return compressIPv6ZeroRun(parts); 3232 } 3233 if (hextetCount >= 8) return void 0; 3234 const expanded = parts.slice(0, left.length); 3235 for (let i = hextetCount; i < 8; i++) expanded.push("0"); 3236 for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]); 3237 return compressIPv6ZeroRun(expanded); 3238 } 3239 function normalizeIPv6(host) { 3240 const bracketed = host[0] === "[" && host[host.length - 1] === "]"; 3241 const hasBracket = host[0] === "[" || host[host.length - 1] === "]"; 3242 if (hasBracket && !bracketed) return { host, isIPV6: false, error: true }; 3243 let input = bracketed ? host.slice(1, -1) : host; 3244 if (bracketed && isIPvFuture(input)) { 3245 input = input.toLowerCase(); 3246 return { host: `[$input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true }; 3247 } 3248 if (findToken(input, ":") < 2) { 3249 return { host, isIPV6: false, error: bracketed }; 3250 } 3251 let zoneIdentifier = ""; 3252 const zoneSeparator = input.indexOf("%"); 3253 if (zoneSeparator !== -1) { 3254 const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1; 3255 zoneIdentifier = input.slice(zoneSeparator + separatorLength); 3256 if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true }; 3257 input = input.slice(0, zoneSeparator); 3258 } 3259 const address = normalizeIPv6Address(input); 3260 if (address === void 0) return { host, isIPV6: false, error: true }; 3261 return { 3262 host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""), 3263 escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""), 3264 isIPV6: true 3265 }; 3266 } 3267 function findToken(str, token) { 3268 let ind = 0; 3269 for (let i = 0; i < str.length; i++) { 3270 if (str[i] === token) ind++; 3271 } 3272 return ind; 3273 } 3274 function removeDotSegments(path) { 3275 let input = path; 3276 const output = []; 3277 let nextSlash = -1; 3278 let len = 0; 3279 while (len = input.length) { 3280 if (len === 1) { 3281 if (input === ".") { 3282 break; 3283 } else if (input === "/") { 3284 output.push("/"); 3285 break; 3286 } else { 3287 output.push(input); 3288 break; 3289 } 3290 } else if (len === 2) { 3291 if (input[0] === ".") { 3292 if (input[1] === ".") { 3293 break; 3294 } else if (input[1] === "/") { 3295 input = input.slice(2); 3296 continue; 3297 } 3298 } else if (input[0] === "/") { 3299 if (input[1] === "." || input[1] === "/") { 3300 output.push("/"); 3301 break; 3302 } 3303 } 3304 } else if (len === 3) { 3305 if (input === "/..") { 3306 if (output.length !== 0) { 3307 output.pop(); 3308 } 3309 output.push("/"); 3310 break; 3311 } 3312 } 3313 if (input[0] === ".") { 3314 if (input[1] === ".") { 3315 if (input[2] === "/") { 3316 input = input.slice(3); 3317 continue; 3318 } 3319 } else if (input[1] === "/") { 3320 input = input.slice(2); 3321 continue; 3322 } 3323 } else if (input[0] === "/") { 3324 if (input[1] === ".") { 3325 if (input[2] === "/") { 3326 input = input.slice(2); 3327 continue; 3328 } else if (input[2] === ".") { 3329 if (input[3] === "/") { 3330 input = input.slice(3); 3331 if (output.length !== 0) { 3332 output.pop(); 3333 } 3334 continue; 3335 } 3336 } 3337 } 3338 } 3339 if ((nextSlash = input.indexOf("/", 1)) === -1) { 3340 output.push(input); 3341 break; 3342 } else { 3343 output.push(input.slice(0, nextSlash)); 3344 input = input.slice(nextSlash); 3345 } 3346 } 3347 return output.join(""); 3348 } 3349 var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" }; 3350 var HOST_DELIM_RE = /[@/?#:]/g; 3351 var HOST_DELIM_NO_COLON_RE = /[@/?#]/g; 3352 function reescapeHostDelimiters(host, isIP) { 3353 const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE; 3354 re.lastIndex = 0; 3355 return host.replace(re, (ch) => HOST_DELIMS[ch]); 3356 } 3357 function normalizePercentEncoding(input, decodeUnreserved = false) { 3358 if (input.indexOf("%") === -1) { 3359 return input; 3360 } 3361 let output = ""; 3362 for (let i = 0; i < input.length; i++) { 3363 if (input[i] === "%" && i + 2 < input.length) { 3364 const hex = input.slice(i + 1, i + 3); 3365 if (isHexPair(hex)) { 3366 const normalizedHex = hex.toUpperCase(); 3367 const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); 3368 if (decodeUnreserved && isUnreserved(decoded)) { 3369 output += decoded; 3370 } else { 3371 output += "%" + normalizedHex; 3372 } 3373 i += 2; 3374 continue; 3375 } 3376 } 3377 output += input[i]; 3378 } 3379 return output; 3380 } 3381 function normalizePathEncoding(input) { 3382 let output = ""; 3383 for (let i = 0; i < input.length; i++) { 3384 const ch = input[i]; 3385 if (ch === "%" && i + 2 < input.length) { 3386 const hex = input.slice(i + 1, i + 3); 3387 if (isHexPair(hex)) { 3388 const normalizedHex = hex.toUpperCase(); 3389 const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); 3390 if (decoded !== "." && isUnreserved(decoded)) { 3391 output += decoded; 3392 } else { 3393 output += "%" + normalizedHex; 3394 } 3395 i += 2; 3396 continue; 3397 } 3398 } 3399 if (isPathCharacter(ch)) { 3400 output += ch; 3401 } else { 3402 const code = input.charCodeAt(i); 3403 if (code < 128) { 3404 output += isEscapeSafe(code) ? ch : BYTE_HEX[code]; 3405 } else if (code < 55296 || code > 57343) { 3406 output += percentEncodeNonAscii(code); 3407 } else if (code <= 56319 && i + 1 < input.length) { 3408 const low = input.charCodeAt(i + 1); 3409 if (low >= 56320 && low <= 57343) { 3410 output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320)); 3411 i++; 3412 } else { 3413 output += percentEncodeNonAscii(65533); 3414 } 3415 } else { 3416 output += percentEncodeNonAscii(65533); 3417 } 3418 } 3419 } 3420 return output; 3421 } 3422 function serializePathEncoding(input, pathNoScheme = false) { 3423 let output = ""; 3424 let firstSegment = pathNoScheme && input[0] !== "/"; 3425 for (let i = 0; i < input.length; i++) { 3426 const ch = input[i]; 3427 if (ch === "%" && i + 2 < input.length) { 3428 const hex = input.slice(i + 1, i + 3); 3429 if (isHexPair(hex)) { 3430 output += "%" + hex.toUpperCase(); 3431 i += 2; 3432 continue; 3433 } 3434 } 3435 if (ch === "/") { 3436 firstSegment = false; 3437 } 3438 if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) { 3439 output += ch; 3440 } else { 3441 const code = input.charCodeAt(i); 3442 if (code < 128) { 3443 output += BYTE_HEX[code]; 3444 } else if (code < 55296 || code > 57343) { 3445 output += percentEncodeNonAscii(code); 3446 } else if (code <= 56319 && i + 1 < input.length) { 3447 const low = input.charCodeAt(i + 1); 3448 if (low >= 56320 && low <= 57343) { 3449 output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320)); 3450 i++; 3451 } else { 3452 output += percentEncodeNonAscii(65533); 3453 } 3454 } else { 3455 output += percentEncodeNonAscii(65533); 3456 } 3457 } 3458 } 3459 return output; 3460 } 3461 function encodeComponent(input, isAllowed) { 3462 let output = ""; 3463 for (let i = 0; i < input.length; i++) { 3464 const ch = input[i]; 3465 if (ch === "%" && i + 2 < input.length) { 3466 const hex = input.slice(i + 1, i + 3); 3467 if (isHexPair(hex)) { 3468 output += "%" + hex.toUpperCase(); 3469 i += 2; 3470 continue; 3471 } 3472 } 3473 if (isAllowed(ch)) { 3474 output += ch; 3475 } else { 3476 const code = input.charCodeAt(i); 3477 if (code < 128) { 3478 output += BYTE_HEX[code]; 3479 } else if (code < 55296 || code > 57343) { 3480 output += percentEncodeNonAscii(code); 3481 } else if (code <= 56319 && i + 1 < input.length) { 3482 const low = input.charCodeAt(i + 1); 3483 if (low >= 56320 && low <= 57343) { 3484 output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320)); 3485 i++; 3486 } else { 3487 output += percentEncodeNonAscii(65533); 3488 } 3489 } else { 3490 output += percentEncodeNonAscii(65533); 3491 } 3492 } 3493 } 3494 return output; 3495 } 3496 function encodeUserinfo(input) { 3497 return encodeComponent(input, isUserinfoCharacter); 3498 } 3499 function encodeQuery(input) { 3500 return encodeComponent(input, isQueryFragmentCharacter); 3501 } 3502 function encodeFragment(input) { 3503 return encodeComponent(input, isQueryFragmentCharacter); 3504 } 3505 function isEscapeSafe(cp) { 3506 return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95; 3507 } 3508 function normalizeQueryFragmentEncoding(input) { 3509 let output = ""; 3510 for (let i = 0; i < input.length; i++) { 3511 const ch = input[i]; 3512 if (ch === "%" && i + 2 < input.length) { 3513 const hex = input.slice(i + 1, i + 3); 3514 if (isHexPair(hex)) { 3515 const normalizedHex = hex.toUpperCase(); 3516 const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); 3517 if (isUnreserved(decoded)) { 3518 output += decoded; 3519 } else { 3520 output += "%" + normalizedHex; 3521 } 3522 i += 2; 3523 continue; 3524 } 3525 } 3526 if (isQueryFragmentCharacter(ch)) { 3527 output += ch; 3528 } else { 3529 const code = input.charCodeAt(i); 3530 if (code < 128) { 3531 output += isEscapeSafe(code) ? ch : BYTE_HEX[code]; 3532 } else if (code < 55296 || code > 57343) { 3533 output += percentEncodeNonAscii(code); 3534 } else if (code <= 56319 && i + 1 < input.length) { 3535 const low = input.charCodeAt(i + 1); 3536 if (low >= 56320 && low <= 57343) { 3537 output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320)); 3538 i++; 3539 } else { 3540 output += percentEncodeNonAscii(65533); 3541 } 3542 } else { 3543 output += percentEncodeNonAscii(65533); 3544 } 3545 } 3546 } 3547 return output; 3548 } 3549 function escapePreservingEscapes(input) { 3550 let output = ""; 3551 for (let i = 0; i < input.length; i++) { 3552 if (input[i] === "%" && i + 2 < input.length) { 3553 const hex = input.slice(i + 1, i + 3); 3554 if (isHexPair(hex)) { 3555 output += "%" + hex.toUpperCase(); 3556 i += 2; 3557 continue; 3558 } 3559 } 3560 output += escape(input[i]); 3561 } 3562 return output; 3563 } 3564 function recomposeAuthority(component) { 3565 const uriTokens = []; 3566 if (component.userinfo !== void 0) { 3567 uriTokens.push(encodeUserinfo(component.userinfo)); 3568 uriTokens.push("@"); 3569 } 3570 if (component.host !== void 0) { 3571 let host = component.host; 3572 if (!isIPv4(host)) { 3573 let ipV6res = normalizeIPv6(host); 3574 if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) { 3575 host = normalizePercentEncoding(host, true); 3576 ipV6res = normalizeIPv6(host); 3577 } 3578 if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) { 3579 host = `[$ipV6res.escapedHost}]`; 3580 } else { 3581 host = reescapeHostDelimiters(host, false); 3582 } 3583 } 3584 uriTokens.push(host); 3585 } 3586 if (typeof component.port === "number" || typeof component.port === "string") { 3587 const port = String(component.port); 3588 if (!isPort(port)) { 3589 throw new TypeError("URI port is malformed."); 3590 } 3591 uriTokens.push(":"); 3592 uriTokens.push(port); 3593 } 3594 return uriTokens.length ? uriTokens.join("") : void 0; 3595 } 3596 module.exports = { 3597 nonSimpleDomain, 3598 recomposeAuthority, 3599 reescapeHostDelimiters, 3600 normalizePercentEncoding, 3601 normalizePathEncoding, 3602 serializePathEncoding, 3603 normalizeQueryFragmentEncoding, 3604 encodeUserinfo, 3605 encodeQuery, 3606 encodeFragment, 3607 escapePreservingEscapes, 3608 removeDotSegments, 3609 isIPv4, 3610 isUUID, 3611 normalizeIPv6, 3612 stringArrayToHexStripped 3613 }; 3614 } 3615 }); 3616 3617 // node_modules/fast-uri/lib/schemes.js 3618 var require_schemes = __commonJS({ 3619 "node_modules/fast-uri/lib/schemes.js"(exports, module) { 3620 "use strict"; 3621 var { isUUID } = require_utils(); 3622 var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu; 3623 var supportedSchemeNames = ( 3624 /** @type {const} */ 3625 [ 3626 "http", 3627 "https", 3628 "ws", 3629 "wss", 3630 "urn", 3631 "urn:uuid" 3632 ] 3633 ); 3634 function isValidSchemeName(name) { 3635 return supportedSchemeNames.indexOf( 3636 /** @type {*} */ 3637 name 3638 ) !== -1; 3639 } 3640 function wsIsSecure(wsComponent) { 3641 if (wsComponent.secure === true) { 3642 return true; 3643 } else if (wsComponent.secure === false) { 3644 return false; 3645 } else if (wsComponent.scheme) { 3646 return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S"); 3647 } else { 3648 return false; 3649 } 3650 } 3651 function httpParse(component) { 3652 if (!component.host) { 3653 component.error = component.error || "HTTP URIs must have a host."; 3654 } 3655 return component; 3656 } 3657 function httpSerialize(component) { 3658 const secure = String(component.scheme).toLowerCase() === "https"; 3659 if (component.port === (secure ? 443 : 80) || component.port === "") { 3660 component.port = void 0; 3661 } 3662 if (!component.path) { 3663 component.path = "/"; 3664 } 3665 return component; 3666 } 3667 function wsParse(wsComponent) { 3668 wsComponent.secure = wsIsSecure(wsComponent); 3669 wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : ""); 3670 wsComponent.path = void 0; 3671 wsComponent.query = void 0; 3672 return wsComponent; 3673 } 3674 function wsSerialize(wsComponent) { 3675 if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") { 3676 wsComponent.port = void 0; 3677 } 3678 if (typeof wsComponent.secure === "boolean") { 3679 wsComponent.scheme = wsComponent.secure ? "wss" : "ws"; 3680 wsComponent.secure = void 0; 3681 } 3682 if (wsComponent.resourceName) { 3683 const queryIndex = wsComponent.resourceName.indexOf("?"); 3684 const path = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex); 3685 wsComponent.path = path && path !== "/" ? path : void 0; 3686 wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1); 3687 wsComponent.resourceName = void 0; 3688 } 3689 wsComponent.fragment = void 0; 3690 return wsComponent; 3691 } 3692 function urnParse(urnComponent, options) { 3693 if (!urnComponent.path) { 3694 urnComponent.error = "URN can not be parsed"; 3695 return urnComponent; 3696 } 3697 const matches = urnComponent.path.match(URN_REG); 3698 if (matches && matches[0] === urnComponent.path) { 3699 const scheme = options.scheme || urnComponent.scheme || "urn"; 3700 urnComponent.nid = matches[1].toLowerCase(); 3701 urnComponent.nss = matches[2]; 3702 const urnScheme = `$scheme}:$options.nid || urnComponent.nid}`; 3703 const schemeHandler = getSchemeHandler(urnScheme); 3704 urnComponent.path = void 0; 3705 if (schemeHandler) { 3706 urnComponent = schemeHandler.parse(urnComponent, options); 3707 } 3708 } else { 3709 urnComponent.error = urnComponent.error || "URN can not be parsed."; 3710 } 3711 return urnComponent; 3712 } 3713 function urnSerialize(urnComponent, options) { 3714 if (urnComponent.nid === void 0) { 3715 throw new Error("URN without nid cannot be serialized"); 3716 } 3717 const scheme = options.scheme || urnComponent.scheme || "urn"; 3718 const nid = urnComponent.nid.toLowerCase(); 3719 const urnScheme = `$scheme}:$options.nid || nid}`; 3720 const schemeHandler = getSchemeHandler(urnScheme); 3721 if (schemeHandler) { 3722 urnComponent = schemeHandler.serialize(urnComponent, options); 3723 } 3724 const uriComponent = urnComponent; 3725 const nss = urnComponent.nss; 3726 uriComponent.path = `$nid || options.nid}:$nss}`; 3727 options.skipEscape = true; 3728 return uriComponent; 3729 } 3730 function urnuuidParse(urnComponent, options) { 3731 const uuidComponent = urnComponent; 3732 uuidComponent.uuid = uuidComponent.nss; 3733 uuidComponent.nss = void 0; 3734 if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) { 3735 uuidComponent.error = uuidComponent.error || "UUID is not valid."; 3736 } 3737 return uuidComponent; 3738 } 3739 function urnuuidSerialize(uuidComponent) { 3740 const urnComponent = uuidComponent; 3741 urnComponent.nss = (uuidComponent.uuid || "").toLowerCase(); 3742 return urnComponent; 3743 } 3744 var http = ( 3745 /** @type {SchemeHandler} */ 3746 { 3747 scheme: "http", 3748 domainHost: true, 3749 parse: httpParse, 3750 serialize: httpSerialize 3751 } 3752 ); 3753 var https = ( 3754 /** @type {SchemeHandler} */ 3755 { 3756 scheme: "https", 3757 domainHost: http.domainHost, 3758 parse: httpParse, 3759 serialize: httpSerialize 3760 } 3761 ); 3762 var ws = ( 3763 /** @type {SchemeHandler} */ 3764 { 3765 scheme: "ws", 3766 domainHost: true, 3767 parse: wsParse, 3768 serialize: wsSerialize 3769 } 3770 ); 3771 var wss = ( 3772 /** @type {SchemeHandler} */ 3773 { 3774 scheme: "wss", 3775 domainHost: ws.domainHost, 3776 parse: ws.parse, 3777 serialize: ws.serialize 3778 } 3779 ); 3780 var urn = ( 3781 /** @type {SchemeHandler} */ 3782 { 3783 scheme: "urn", 3784 parse: urnParse, 3785 serialize: urnSerialize, 3786 skipNormalize: true 3787 } 3788 ); 3789 var urnuuid = ( 3790 /** @type {SchemeHandler} */ 3791 { 3792 scheme: "urn:uuid", 3793 parse: urnuuidParse, 3794 serialize: urnuuidSerialize, 3795 skipNormalize: true 3796 } 3797 ); 3798 var SCHEMES = ( 3799 /** @type {Record<SchemeName, SchemeHandler>} */ 3800 { 3801 http, 3802 https, 3803 ws, 3804 wss, 3805 urn, 3806 "urn:uuid": urnuuid 3807 } 3808 ); 3809 Object.setPrototypeOf(SCHEMES, null); 3810 function getSchemeHandler(scheme) { 3811 return scheme && (SCHEMES[ 3812 /** @type {SchemeName} */ 3813 scheme 3814 ] || SCHEMES[ 3815 /** @type {SchemeName} */ 3816 scheme.toLowerCase() 3817 ]) || void 0; 3818 } 3819 module.exports = { 3820 wsIsSecure, 3821 SCHEMES, 3822 isValidSchemeName, 3823 getSchemeHandler 3824 }; 3825 } 3826 }); 3827 3828 // node_modules/fast-uri/index.js 3829 var require_fast_uri = __commonJS({ 3830 "node_modules/fast-uri/index.js"(exports, module) { 3831 "use strict"; 3832 var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils(); 3833 var { SCHEMES, getSchemeHandler } = require_schemes(); 3834 var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u; 3835 var MALFORMED_SCHEME_ERROR = "URI scheme is malformed."; 3836 function decodeValidScheme(scheme) { 3837 const decodedScheme = unescape(String(scheme)); 3838 if (!VALID_SCHEME.test(decodedScheme)) { 3839 throw new TypeError(MALFORMED_SCHEME_ERROR); 3840 } 3841 return decodedScheme; 3842 } 3843 function normalize(uri, options) { 3844 if (typeof uri === "string") { 3845 uri = /** @type {T} */ 3846 normalizeString(uri, options); 3847 } else if (typeof uri === "object") { 3848 uri = /** @type {T} */ 3849 parse(serialize(uri, options), options); 3850 } 3851 return uri; 3852 } 3853 function resolve(baseURI, relativeURI, options) { 3854 const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" }; 3855 const { 3856 parsed: baseParsed, 3857 malformedAuthorityOrPort: baseMalformed, 3858 malformedPercentEncoding: baseMalformedPercentEncoding, 3859 malformedSchemeSpecific: baseMalformedSchemeSpecific, 3860 malformedHost: baseMalformedHost, 3861 malformedScheme: baseMalformedScheme 3862 } = parseWithStatus(baseURI, schemelessOptions); 3863 const { 3864 parsed: relativeParsed, 3865 malformedAuthorityOrPort: relativeMalformed, 3866 malformedPercentEncoding: relativeMalformedPercentEncoding, 3867 malformedSchemeSpecific: relativeMalformedSchemeSpecific, 3868 malformedHost: relativeMalformedHost, 3869 malformedScheme: relativeMalformedScheme 3870 } = parseWithStatus(relativeURI, schemelessOptions); 3871 if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) { 3872 throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed."); 3873 } 3874 const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true); 3875 const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme); 3876 const resolvedHost = resolved.host; 3877 const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6); 3878 canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP); 3879 const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost); 3880 if (resolved.error && !encodedASCIIHost) { 3881 throw new Error(resolved.error); 3882 } 3883 schemelessOptions.skipEscape = true; 3884 return serialize(resolved, schemelessOptions); 3885 } 3886 function resolveComponent(base, relative, options, skipNormalization) { 3887 const target = {}; 3888 if (!skipNormalization) { 3889 base = parse(serialize(base, options), options); 3890 relative = parse(serialize(relative, options), options); 3891 } 3892 options = options || {}; 3893 if (!options.tolerant && relative.scheme) { 3894 target.scheme = relative.scheme; 3895 target.userinfo = relative.userinfo; 3896 target.host = relative.host; 3897 target.port = relative.port; 3898 target.path = removeDotSegments(relative.path || ""); 3899 target.query = relative.query; 3900 } else { 3901 if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) { 3902 target.userinfo = relative.userinfo; 3903 target.host = relative.host; 3904 target.port = relative.port; 3905 target.path = removeDotSegments(relative.path || ""); 3906 target.query = relative.query; 3907 } else { 3908 if (!relative.path) { 3909 target.path = base.path; 3910 if (relative.query !== void 0) { 3911 target.query = relative.query; 3912 } else { 3913 target.query = base.query; 3914 } 3915 } else { 3916 if (relative.path[0] === "/") { 3917 target.path = removeDotSegments(relative.path); 3918 } else { 3919 if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) { 3920 target.path = "/" + relative.path; 3921 } else if (!base.path) { 3922 target.path = relative.path; 3923 } else { 3924 target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path; 3925 } 3926 target.path = removeDotSegments(target.path); 3927 } 3928 target.query = relative.query; 3929 } 3930 target.userinfo = base.userinfo; 3931 target.host = base.host; 3932 target.port = base.port; 3933 } 3934 target.scheme = base.scheme; 3935 } 3936 target.fragment = relative.fragment; 3937 return target; 3938 } 3939 function equal(uriA, uriB, options) { 3940 const normalizedA = normalizeComparableURI(uriA, options); 3941 const normalizedB = normalizeComparableURI(uriB, options); 3942 return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB; 3943 } 3944 function serialize(cmpts, opts) { 3945 const component = { 3946 host: cmpts.host, 3947 scheme: cmpts.scheme, 3948 userinfo: cmpts.userinfo, 3949 port: cmpts.port, 3950 path: cmpts.path, 3951 query: cmpts.query, 3952 nid: cmpts.nid, 3953 nss: cmpts.nss, 3954 uuid: cmpts.uuid, 3955 fragment: cmpts.fragment, 3956 reference: cmpts.reference, 3957 resourceName: cmpts.resourceName, 3958 secure: cmpts.secure, 3959 error: "" 3960 }; 3961 const options = Object.assign({}, opts); 3962 const uriTokens = []; 3963 if (component.scheme) { 3964 component.scheme = decodeValidScheme(component.scheme); 3965 } 3966 const schemeHandler = getSchemeHandler(options.scheme || component.scheme); 3967 if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options); 3968 const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0; 3969 const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority; 3970 if (component.path !== void 0) { 3971 if (!options.skipEscape) { 3972 component.path = serializePathEncoding(component.path, pathNoScheme); 3973 } else { 3974 component.path = normalizePercentEncoding(component.path); 3975 } 3976 } 3977 if (options.reference !== "suffix" && component.scheme) { 3978 component.scheme = decodeValidScheme(component.scheme); 3979 uriTokens.push(component.scheme, ":"); 3980 } 3981 const authority = recomposeAuthority(component); 3982 if (authority !== void 0) { 3983 if (options.reference !== "suffix") { 3984 uriTokens.push("//"); 3985 } 3986 uriTokens.push(authority); 3987 if (component.path && component.path[0] !== "/") { 3988 uriTokens.push("/"); 3989 } 3990 } 3991 if (component.path !== void 0) { 3992 let s = component.path; 3993 if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) { 3994 s = removeDotSegments(s); 3995 } 3996 if (pathNoScheme) { 3997 s = serializePathEncoding(s, true); 3998 } 3999 if (authority === void 0 && s[0] === "/" && s[1] === "/") { 4000 s = "/%2F" + s.slice(2); 4001 } 4002 uriTokens.push(s); 4003 } 4004 if (component.query !== void 0) { 4005 uriTokens.push("?", encodeQuery(component.query)); 4006 } 4007 if (component.fragment !== void 0) { 4008 uriTokens.push("#", encodeFragment(component.fragment)); 4009 } 4010 return uriTokens.join(""); 4011 } 4012 var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u; 4013 var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/; 4014 var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/; 4015 function getParseError(parsed, matches) { 4016 if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") { 4017 return 'URI path must start with "/" when authority is present.'; 4018 } 4019 if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) { 4020 return "URI port is malformed."; 4021 } 4022 return void 0; 4023 } 4024 function hasMalformedPercentEncoding(component) { 4025 if (component === void 0) return false; 4026 let percent = component.indexOf("%"); 4027 while (percent !== -1) { 4028 if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) { 4029 return true; 4030 } 4031 percent = component.indexOf("%", percent + 3); 4032 } 4033 return false; 4034 } 4035 function isIPLiteral(host) { 4036 return host[0] === "[" && host[host.length - 1] === "]"; 4037 } 4038 function hasMalformedComponentPercentEncoding(matches) { 4039 const host = matches[4]; 4040 return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]); 4041 } 4042 function canonicalizeHost(parsed, options, schemeHandler, isIP) { 4043 if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) { 4044 try { 4045 parsed.host = new URL("http://" + parsed.host).hostname; 4046 } catch (e) { 4047 parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e; 4048 return true; 4049 } 4050 } 4051 return false; 4052 } 4053 function parseWithStatus(uri, opts) { 4054 const options = Object.assign({}, opts); 4055 const parsed = { 4056 scheme: void 0, 4057 userinfo: void 0, 4058 host: "", 4059 port: void 0, 4060 path: "", 4061 query: void 0, 4062 fragment: void 0 4063 }; 4064 let malformedAuthorityOrPort = false; 4065 let malformedPercentEncoding = false; 4066 let malformedSchemeSpecific = false; 4067 let malformedHost = false; 4068 let malformedIPLiteral = false; 4069 let malformedScheme = false; 4070 let isIP = false; 4071 if (options.reference === "suffix") { 4072 if (options.scheme) { 4073 uri = options.scheme + ":" + uri; 4074 } else { 4075 uri = "//" + uri; 4076 } 4077 } 4078 const authorityMatch = uri.match(AUTHORITY_PREFIX); 4079 if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) { 4080 parsed.error = "URI authority must not contain a literal backslash."; 4081 malformedAuthorityOrPort = true; 4082 } 4083 const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION); 4084 if (introducerMatch !== null) { 4085 const region = introducerMatch[1]; 4086 const normalizedRegion = region.replace(/[\t\n\r]/g, ""); 4087 if (normalizedRegion.length >= 2) { 4088 if (normalizedRegion.slice(0, 2) !== "//") { 4089 parsed.error = parsed.error || "URI authority must not contain a literal backslash."; 4090 malformedAuthorityOrPort = true; 4091 } else if (region.length !== normalizedRegion.length) { 4092 parsed.error = parsed.error || "URI authority introducer must not contain whitespace."; 4093 malformedAuthorityOrPort = true; 4094 } 4095 } 4096 } 4097 const matches = uri.match(URI_PARSE); 4098 if (matches) { 4099 parsed.scheme = matches[1]; 4100 parsed.userinfo = matches[3]; 4101 parsed.host = matches[4]; 4102 parsed.port = parseInt(matches[5], 10); 4103 parsed.path = matches[6] || ""; 4104 parsed.query = matches[7]; 4105 parsed.fragment = matches[8]; 4106 if (parsed.scheme !== void 0) { 4107 const decodedScheme = unescape(parsed.scheme); 4108 if (VALID_SCHEME.test(decodedScheme)) { 4109 parsed.scheme = decodedScheme.toLowerCase(); 4110 } else { 4111 parsed.error = parsed.error || MALFORMED_SCHEME_ERROR; 4112 malformedScheme = true; 4113 } 4114 } 4115 malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches); 4116 if (malformedPercentEncoding) { 4117 parsed.error = parsed.error || "URI contains malformed percent-encoding."; 4118 } 4119 if (isNaN(parsed.port)) { 4120 parsed.port = matches[5]; 4121 } 4122 const parseError = getParseError(parsed, matches); 4123 if (parseError !== void 0) { 4124 parsed.error = parsed.error || parseError; 4125 malformedAuthorityOrPort = true; 4126 } 4127 if (parsed.host) { 4128 const ipv4result = isIPv4(parsed.host); 4129 if (ipv4result === false) { 4130 const bracketedIPLiteral = isIPLiteral(parsed.host); 4131 const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1; 4132 const ipv6result = normalizeIPv6(parsed.host); 4133 isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true; 4134 malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true); 4135 parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase(); 4136 if (malformedIPLiteral) { 4137 parsed.error = parsed.error || "URI host is malformed."; 4138 malformedAuthorityOrPort = true; 4139 } 4140 } else { 4141 isIP = true; 4142 } 4143 } 4144 if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) { 4145 parsed.reference = "same-document"; 4146 } else if (parsed.scheme === void 0) { 4147 parsed.reference = "relative"; 4148 } else if (parsed.fragment === void 0) { 4149 parsed.reference = "absolute"; 4150 } else { 4151 parsed.reference = "uri"; 4152 } 4153 if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) { 4154 parsed.error = parsed.error || "URI is not a " + options.reference + " reference."; 4155 } 4156 const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme); 4157 if (!malformedIPLiteral) { 4158 malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP); 4159 } 4160 if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) { 4161 if (uri.indexOf("%") !== -1) { 4162 if (parsed.host !== void 0 && !malformedIPLiteral) { 4163 const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true); 4164 parsed.host = reescapeHostDelimiters(host, isIP); 4165 } 4166 } 4167 if (parsed.path) { 4168 parsed.path = normalizePathEncoding(parsed.path); 4169 } 4170 if (parsed.query) { 4171 parsed.query = normalizeQueryFragmentEncoding(parsed.query); 4172 } 4173 if (parsed.fragment) { 4174 parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment); 4175 } 4176 } 4177 if (schemeHandler && schemeHandler.parse) { 4178 schemeHandler.parse(parsed, options); 4179 if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) { 4180 malformedSchemeSpecific = true; 4181 } 4182 } 4183 } else { 4184 parsed.error = parsed.error || "URI can not be parsed."; 4185 } 4186 return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme }; 4187 } 4188 function parse(uri, opts) { 4189 return parseWithStatus(uri, opts).parsed; 4190 } 4191 function normalizeString(uri, opts) { 4192 return normalizeStringWithStatus(uri, opts).normalized; 4193 } 4194 function normalizeStringWithStatus(uri, opts) { 4195 const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts); 4196 return { 4197 normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts), 4198 malformedAuthorityOrPort, 4199 malformedPercentEncoding, 4200 malformedSchemeSpecific, 4201 malformedHost, 4202 malformedScheme 4203 }; 4204 } 4205 function normalizeComparableURI(uri, opts) { 4206 if (typeof uri !== "string" && typeof uri !== "object") { 4207 return void 0; 4208 } 4209 let value; 4210 try { 4211 value = typeof uri === "string" ? uri : serialize(uri, opts); 4212 } catch { 4213 return void 0; 4214 } 4215 const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts); 4216 return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized; 4217 } 4218 var fastUri = { 4219 SCHEMES, 4220 normalize, 4221 resolve, 4222 resolveComponent, 4223 equal, 4224 serialize, 4225 parse 4226 }; 4227 module.exports = fastUri; 4228 module.exports.default = fastUri; 4229 module.exports.fastUri = fastUri; 4230 } 4231 }); 4232 4233 // node_modules/ajv/dist/runtime/uri.js 4234 var require_uri = __commonJS({ 4235 "node_modules/ajv/dist/runtime/uri.js"(exports) { 4236 "use strict"; 4237 Object.defineProperty(exports, "__esModule", { value: true }); 4238 var uri = require_fast_uri(); 4239 uri.code = 'require("ajv/dist/runtime/uri").default'; 4240 exports.default = uri; 4241 } 4242 }); 4243 4244 // node_modules/ajv/dist/core.js 4245 var require_core = __commonJS({ 4246 "node_modules/ajv/dist/core.js"(exports) { 4247 "use strict"; 4248 Object.defineProperty(exports, "__esModule", { value: true }); 4249 exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0; 4250 var validate_1 = require_validate(); 4251 Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() { 4252 return validate_1.KeywordCxt; 4253 } }); 4254 var codegen_1 = require_codegen(); 4255 Object.defineProperty(exports, "_", { enumerable: true, get: function() { 4256 return codegen_1._; 4257 } }); 4258 Object.defineProperty(exports, "str", { enumerable: true, get: function() { 4259 return codegen_1.str; 4260 } }); 4261 Object.defineProperty(exports, "stringify", { enumerable: true, get: function() { 4262 return codegen_1.stringify; 4263 } }); 4264 Object.defineProperty(exports, "nil", { enumerable: true, get: function() { 4265 return codegen_1.nil; 4266 } }); 4267 Object.defineProperty(exports, "Name", { enumerable: true, get: function() { 4268 return codegen_1.Name; 4269 } }); 4270 Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() { 4271 return codegen_1.CodeGen; 4272 } }); 4273 var validation_error_1 = require_validation_error(); 4274 var ref_error_1 = require_ref_error(); 4275 var rules_1 = require_rules(); 4276 var compile_1 = require_compile(); 4277 var codegen_2 = require_codegen(); 4278 var resolve_1 = require_resolve(); 4279 var dataType_1 = require_dataType(); 4280 var util_1 = require_util(); 4281 var $dataRefSchema = require_data2(); 4282 var uri_1 = require_uri(); 4283 var defaultRegExp = (str, flags) => new RegExp(str, flags); 4284 defaultRegExp.code = "new RegExp"; 4285 var META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"]; 4286 var EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([ 4287 "validate", 4288 "serialize", 4289 "parse", 4290 "wrapper", 4291 "root", 4292 "schema", 4293 "keyword", 4294 "pattern", 4295 "formats", 4296 "validate$data", 4297 "func", 4298 "obj", 4299 "Error" 4300 ]); 4301 var removedOptions = { 4302 errorDataPath: "", 4303 format: "`validateFormats: false` can be used instead.", 4304 nullable: '"nullable" keyword is supported by default.', 4305 jsonPointers: "Deprecated jsPropertySyntax can be used instead.", 4306 extendRefs: "Deprecated ignoreKeywordsWithRef can be used instead.", 4307 missingRefs: "Pass empty schema with $id that should be ignored to ajv.addSchema.", 4308 processCode: "Use option `code: {process: (code, schemaEnv: object) => string}`", 4309 sourceCode: "Use option `code: {source: true}`", 4310 strictDefaults: "It is default now, see option `strict`.", 4311 strictKeywords: "It is default now, see option `strict`.", 4312 uniqueItems: '"uniqueItems" keyword is always validated.', 4313 unknownFormats: "Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).", 4314 cache: "Map is used as cache, schema object as key.", 4315 serialize: "Map is used as cache, schema object as key.", 4316 ajvErrors: "It is default now." 4317 }; 4318 var deprecatedOptions = { 4319 ignoreKeywordsWithRef: "", 4320 jsPropertySyntax: "", 4321 unicode: '"minLength"/"maxLength" account for unicode characters by default.' 4322 }; 4323 var MAX_EXPRESSION = 200; 4324 function requiredOptions(o) { 4325 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; 4326 const s = o.strict; 4327 const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize; 4328 const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0; 4329 const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp; 4330 const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default; 4331 return { 4332 strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true, 4333 strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true, 4334 strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log", 4335 strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log", 4336 strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false, 4337 code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp }, 4338 loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION, 4339 loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION, 4340 meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true, 4341 messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true, 4342 inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true, 4343 schemaId: (_v = o.schemaId) !== null && _v !== void 0 ? _v : "$id", 4344 addUsedSchema: (_w = o.addUsedSchema) !== null && _w !== void 0 ? _w : true, 4345 validateSchema: (_x = o.validateSchema) !== null && _x !== void 0 ? _x : true, 4346 validateFormats: (_y = o.validateFormats) !== null && _y !== void 0 ? _y : true, 4347 unicodeRegExp: (_z = o.unicodeRegExp) !== null && _z !== void 0 ? _z : true, 4348 int32range: (_0 = o.int32range) !== null && _0 !== void 0 ? _0 : true, 4349 uriResolver 4350 }; 4351 } 4352 var Ajv2 = class { 4353 constructor(opts = {}) { 4354 this.schemas = {}; 4355 this.refs = {}; 4356 this.formats = /* @__PURE__ */ Object.create(null); 4357 this._compilations = /* @__PURE__ */ new Set(); 4358 this._loading = {}; 4359 this._cache = /* @__PURE__ */ new Map(); 4360 opts = this.opts = { ...opts, ...requiredOptions(opts) }; 4361 const { es5, lines } = this.opts.code; 4362 this.scope = new codegen_2.ValueScope({ scope: {}, prefixes: EXT_SCOPE_NAMES, es5, lines }); 4363 this.logger = getLogger(opts.logger); 4364 const formatOpt = opts.validateFormats; 4365 opts.validateFormats = false; 4366 this.RULES = (0, rules_1.getRules)(); 4367 checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED"); 4368 checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn"); 4369 this._metaOpts = getMetaSchemaOptions.call(this); 4370 if (opts.formats) 4371 addInitialFormats.call(this); 4372 this._addVocabularies(); 4373 this._addDefaultMetaSchema(); 4374 if (opts.keywords) 4375 addInitialKeywords.call(this, opts.keywords); 4376 if (typeof opts.meta == "object") 4377 this.addMetaSchema(opts.meta); 4378 addInitialSchemas.call(this); 4379 opts.validateFormats = formatOpt; 4380 } 4381 _addVocabularies() { 4382 this.addKeyword("$async"); 4383 } 4384 _addDefaultMetaSchema() { 4385 const { $data, meta, schemaId } = this.opts; 4386 let _dataRefSchema = $dataRefSchema; 4387 if (schemaId === "id") { 4388 _dataRefSchema = { ...$dataRefSchema }; 4389 _dataRefSchema.id = _dataRefSchema.$id; 4390 delete _dataRefSchema.$id; 4391 } 4392 if (meta && $data) 4393 this.addMetaSchema(_dataRefSchema, _dataRefSchema[schemaId], false); 4394 } 4395 defaultMeta() { 4396 const { meta, schemaId } = this.opts; 4397 return this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : void 0; 4398 } 4399 validate(schemaKeyRef, data) { 4400 let v; 4401 if (typeof schemaKeyRef == "string") { 4402 v = this.getSchema(schemaKeyRef); 4403 if (!v) 4404 throw new Error(`no schema with key or ref "$schemaKeyRef}"`); 4405 } else { 4406 v = this.compile(schemaKeyRef); 4407 } 4408 const valid = v(data); 4409 if (!("$async" in v)) 4410 this.errors = v.errors; 4411 return valid; 4412 } 4413 compile(schema, _meta) { 4414 const sch = this._addSchema(schema, _meta); 4415 return sch.validate || this._compileSchemaEnv(sch); 4416 } 4417 compileAsync(schema, meta) { 4418 if (typeof this.opts.loadSchema != "function") { 4419 throw new Error("options.loadSchema should be a function"); 4420 } 4421 const { loadSchema } = this.opts; 4422 return runCompileAsync.call(this, schema, meta); 4423 async function runCompileAsync(_schema, _meta) { 4424 await loadMetaSchema.call(this, _schema.$schema); 4425 const sch = this._addSchema(_schema, _meta); 4426 return sch.validate || _compileAsync.call(this, sch); 4427 } 4428 async function loadMetaSchema($ref) { 4429 if ($ref && !this.getSchema($ref)) { 4430 await runCompileAsync.call(this, { $ref }, true); 4431 } 4432 } 4433 async function _compileAsync(sch) { 4434 try { 4435 return this._compileSchemaEnv(sch); 4436 } catch (e) { 4437 if (!(e instanceof ref_error_1.default)) 4438 throw e; 4439 checkLoaded.call(this, e); 4440 await loadMissingSchema.call(this, e.missingSchema); 4441 return _compileAsync.call(this, sch); 4442 } 4443 } 4444 function checkLoaded({ missingSchema: ref, missingRef }) { 4445 if (this.refs[ref]) { 4446 throw new Error(`AnySchema $ref} is loaded but $missingRef} cannot be resolved`); 4447 } 4448 } 4449 async function loadMissingSchema(ref) { 4450 const _schema = await _loadSchema.call(this, ref); 4451 if (!this.refs[ref]) 4452 await loadMetaSchema.call(this, _schema.$schema); 4453 if (!this.refs[ref]) 4454 this.addSchema(_schema, ref, meta); 4455 } 4456 async function _loadSchema(ref) { 4457 const p = this._loading[ref]; 4458 if (p) 4459 return p; 4460 try { 4461 return await (this._loading[ref] = loadSchema(ref)); 4462 } finally { 4463 delete this._loading[ref]; 4464 } 4465 } 4466 } 4467 // Adds schema to the instance 4468 addSchema(schema, key, _meta, _validateSchema = this.opts.validateSchema) { 4469 if (Array.isArray(schema)) { 4470 for (const sch of schema) 4471 this.addSchema(sch, void 0, _meta, _validateSchema); 4472 return this; 4473 } 4474 let id; 4475 if (typeof schema === "object") { 4476 const { schemaId } = this.opts; 4477 id = schema[schemaId]; 4478 if (id !== void 0 && typeof id != "string") { 4479 throw new Error(`schema $schemaId} must be string`); 4480 } 4481 } 4482 key = (0, resolve_1.normalizeId)(key || id); 4483 this._checkUnique(key); 4484 this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true); 4485 return this; 4486 } 4487 // Add schema that will be used to validate other schemas 4488 // options in META_IGNORE_OPTIONS are alway set to false 4489 addMetaSchema(schema, key, _validateSchema = this.opts.validateSchema) { 4490 this.addSchema(schema, key, true, _validateSchema); 4491 return this; 4492 } 4493 // Validate schema against its meta-schema 4494 validateSchema(schema, throwOrLogError) { 4495 if (typeof schema == "boolean") 4496 return true; 4497 let $schema; 4498 $schema = schema.$schema; 4499 if ($schema !== void 0 && typeof $schema != "string") { 4500 throw new Error("$schema must be a string"); 4501 } 4502 $schema = $schema || this.opts.defaultMeta || this.defaultMeta(); 4503 if (!$schema) { 4504 this.logger.warn("meta-schema not available"); 4505 this.errors = null; 4506 return true; 4507 } 4508 const valid = this.validate($schema, schema); 4509 if (!valid && throwOrLogError) { 4510 const message = "schema is invalid: " + this.errorsText(); 4511 if (this.opts.validateSchema === "log") 4512 this.logger.error(message); 4513 else 4514 throw new Error(message); 4515 } 4516 return valid; 4517 } 4518 // Get compiled schema by `key` or `ref`. 4519 // (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id) 4520 getSchema(keyRef) { 4521 let sch; 4522 while (typeof (sch = getSchEnv.call(this, keyRef)) == "string") 4523 keyRef = sch; 4524 if (sch === void 0) { 4525 const { schemaId } = this.opts; 4526 const root = new compile_1.SchemaEnv({ schema: {}, schemaId }); 4527 sch = compile_1.resolveSchema.call(this, root, keyRef); 4528 if (!sch) 4529 return; 4530 this.refs[keyRef] = sch; 4531 } 4532 return sch.validate || this._compileSchemaEnv(sch); 4533 } 4534 // Remove cached schema(s). 4535 // If no parameter is passed all schemas but meta-schemas are removed. 4536 // If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed. 4537 // Even if schema is referenced by other schemas it still can be removed as other schemas have local references. 4538 removeSchema(schemaKeyRef) { 4539 if (schemaKeyRef instanceof RegExp) { 4540 this._removeAllSchemas(this.schemas, schemaKeyRef); 4541 this._removeAllSchemas(this.refs, schemaKeyRef); 4542 return this; 4543 } 4544 switch (typeof schemaKeyRef) { 4545 case "undefined": 4546 this._removeAllSchemas(this.schemas); 4547 this._removeAllSchemas(this.refs); 4548 this._cache.clear(); 4549 return this; 4550 case "string": { 4551 const sch = getSchEnv.call(this, schemaKeyRef); 4552 if (typeof sch == "object") 4553 this._cache.delete(sch.schema); 4554 delete this.schemas[schemaKeyRef]; 4555 delete this.refs[schemaKeyRef]; 4556 return this; 4557 } 4558 case "object": { 4559 const cacheKey = schemaKeyRef; 4560 this._cache.delete(cacheKey); 4561 let id = schemaKeyRef[this.opts.schemaId]; 4562 if (id) { 4563 id = (0, resolve_1.normalizeId)(id); 4564 delete this.schemas[id]; 4565 delete this.refs[id]; 4566 } 4567 return this; 4568 } 4569 default: 4570 throw new Error("ajv.removeSchema: invalid parameter"); 4571 } 4572 } 4573 // add "vocabulary" - a collection of keywords 4574 addVocabulary(definitions) { 4575 for (const def of definitions) 4576 this.addKeyword(def); 4577 return this; 4578 } 4579 addKeyword(kwdOrDef, def) { 4580 let keyword; 4581 if (typeof kwdOrDef == "string") { 4582 keyword = kwdOrDef; 4583 if (typeof def == "object") { 4584 this.logger.warn("these parameters are deprecated, see docs for addKeyword"); 4585 def.keyword = keyword; 4586 } 4587 } else if (typeof kwdOrDef == "object" && def === void 0) { 4588 def = kwdOrDef; 4589 keyword = def.keyword; 4590 if (Array.isArray(keyword) && !keyword.length) { 4591 throw new Error("addKeywords: keyword must be string or non-empty array"); 4592 } 4593 } else { 4594 throw new Error("invalid addKeywords parameters"); 4595 } 4596 checkKeyword.call(this, keyword, def); 4597 if (!def) { 4598 (0, util_1.eachItem)(keyword, (kwd) => addRule.call(this, kwd)); 4599 return this; 4600 } 4601 keywordMetaschema.call(this, def); 4602 const definition = { 4603 ...def, 4604 type: (0, dataType_1.getJSONTypes)(def.type), 4605 schemaType: (0, dataType_1.getJSONTypes)(def.schemaType) 4606 }; 4607 (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))); 4608 return this; 4609 } 4610 getKeyword(keyword) { 4611 const rule = this.RULES.all[keyword]; 4612 return typeof rule == "object" ? rule.definition : !!rule; 4613 } 4614 // Remove keyword 4615 removeKeyword(keyword) { 4616 const { RULES } = this; 4617 delete RULES.keywords[keyword]; 4618 delete RULES.all[keyword]; 4619 for (const group of RULES.rules) { 4620 const i = group.rules.findIndex((rule) => rule.keyword === keyword); 4621 if (i >= 0) 4622 group.rules.splice(i, 1); 4623 } 4624 return this; 4625 } 4626 // Add format 4627 addFormat(name, format) { 4628 if (typeof format == "string") 4629 format = new RegExp(format); 4630 this.formats[name] = format; 4631 return this; 4632 } 4633 errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) { 4634 if (!errors || errors.length === 0) 4635 return "No errors"; 4636 return errors.map((e) => `$dataVar}$e.instancePath} $e.message}`).reduce((text, msg) => text + separator + msg); 4637 } 4638 $dataMetaSchema(metaSchema, keywordsJsonPointers) { 4639 const rules = this.RULES.all; 4640 metaSchema = JSON.parse(JSON.stringify(metaSchema)); 4641 for (const jsonPointer of keywordsJsonPointers) { 4642 const segments = jsonPointer.split("/").slice(1); 4643 let keywords = metaSchema; 4644 for (const seg of segments) 4645 keywords = keywords[seg]; 4646 for (const key in rules) { 4647 const rule = rules[key]; 4648 if (typeof rule != "object") 4649 continue; 4650 const { $data } = rule.definition; 4651 const schema = keywords[key]; 4652 if ($data && schema) 4653 keywords[key] = schemaOrData(schema); 4654 } 4655 } 4656 return metaSchema; 4657 } 4658 _removeAllSchemas(schemas, regex) { 4659 for (const keyRef in schemas) { 4660 const sch = schemas[keyRef]; 4661 if (!regex || regex.test(keyRef)) { 4662 if (typeof sch == "string") { 4663 delete schemas[keyRef]; 4664 } else if (sch && !sch.meta) { 4665 this._cache.delete(sch.schema); 4666 delete schemas[keyRef]; 4667 } 4668 } 4669 } 4670 } 4671 _addSchema(schema, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) { 4672 let id; 4673 const { schemaId } = this.opts; 4674 if (typeof schema == "object") { 4675 id = schema[schemaId]; 4676 } else { 4677 if (this.opts.jtd) 4678 throw new Error("schema must be object"); 4679 else if (typeof schema != "boolean") 4680 throw new Error("schema must be object or boolean"); 4681 } 4682 let sch = this._cache.get(schema); 4683 if (sch !== void 0) 4684 return sch; 4685 baseId = (0, resolve_1.normalizeId)(id || baseId); 4686 const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId); 4687 sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs }); 4688 this._cache.set(sch.schema, sch); 4689 if (addSchema && !baseId.startsWith("#")) { 4690 if (baseId) 4691 this._checkUnique(baseId); 4692 this.refs[baseId] = sch; 4693 } 4694 if (validateSchema) 4695 this.validateSchema(schema, true); 4696 return sch; 4697 } 4698 _checkUnique(id) { 4699 if (this.schemas[id] || this.refs[id]) { 4700 throw new Error(`schema with key or id "$id}" already exists`); 4701 } 4702 } 4703 _compileSchemaEnv(sch) { 4704 if (sch.meta) 4705 this._compileMetaSchema(sch); 4706 else 4707 compile_1.compileSchema.call(this, sch); 4708 if (!sch.validate) 4709 throw new Error("ajv implementation error"); 4710 return sch.validate; 4711 } 4712 _compileMetaSchema(sch) { 4713 const currentOpts = this.opts; 4714 this.opts = this._metaOpts; 4715 try { 4716 compile_1.compileSchema.call(this, sch); 4717 } finally { 4718 this.opts = currentOpts; 4719 } 4720 } 4721 }; 4722 Ajv2.ValidationError = validation_error_1.default; 4723 Ajv2.MissingRefError = ref_error_1.default; 4724 exports.default = Ajv2; 4725 function checkOptions(checkOpts, options, msg, log = "error") { 4726 for (const key in checkOpts) { 4727 const opt = key; 4728 if (opt in options) 4729 this.logger[log](`$msg}: option $key}. $checkOpts[opt]}`); 4730 } 4731 } 4732 function getSchEnv(keyRef) { 4733 keyRef = (0, resolve_1.normalizeId)(keyRef); 4734 return this.schemas[keyRef] || this.refs[keyRef]; 4735 } 4736 function addInitialSchemas() { 4737 const optsSchemas = this.opts.schemas; 4738 if (!optsSchemas) 4739 return; 4740 if (Array.isArray(optsSchemas)) 4741 this.addSchema(optsSchemas); 4742 else 4743 for (const key in optsSchemas) 4744 this.addSchema(optsSchemas[key], key); 4745 } 4746 function addInitialFormats() { 4747 for (const name in this.opts.formats) { 4748 const format = this.opts.formats[name]; 4749 if (format) 4750 this.addFormat(name, format); 4751 } 4752 } 4753 function addInitialKeywords(defs) { 4754 if (Array.isArray(defs)) { 4755 this.addVocabulary(defs); 4756 return; 4757 } 4758 this.logger.warn("keywords option as map is deprecated, pass array"); 4759 for (const keyword in defs) { 4760 const def = defs[keyword]; 4761 if (!def.keyword) 4762 def.keyword = keyword; 4763 this.addKeyword(def); 4764 } 4765 } 4766 function getMetaSchemaOptions() { 4767 const metaOpts = { ...this.opts }; 4768 for (const opt of META_IGNORE_OPTIONS) 4769 delete metaOpts[opt]; 4770 return metaOpts; 4771 } 4772 var noLogs = { log() { 4773 }, warn() { 4774 }, error() { 4775 } }; 4776 function getLogger(logger) { 4777 if (logger === false) 4778 return noLogs; 4779 if (logger === void 0) 4780 return console; 4781 if (logger.log && logger.warn && logger.error) 4782 return logger; 4783 throw new Error("logger must implement log, warn and error methods"); 4784 } 4785 var KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i; 4786 function checkKeyword(keyword, def) { 4787 const { RULES } = this; 4788 (0, util_1.eachItem)(keyword, (kwd) => { 4789 if (RULES.keywords[kwd]) 4790 throw new Error(`Keyword $kwd} is already defined`); 4791 if (!KEYWORD_NAME.test(kwd)) 4792 throw new Error(`Keyword $kwd} has invalid name`); 4793 }); 4794 if (!def) 4795 return; 4796 if (def.$data && !("code" in def || "validate" in def)) { 4797 throw new Error('$data keyword must have "code" or "validate" function'); 4798 } 4799 } 4800 function addRule(keyword, definition, dataType) { 4801 var _a; 4802 const post = definition === null || definition === void 0 ? void 0 : definition.post; 4803 if (dataType && post) 4804 throw new Error('keyword with "post" flag cannot have "type"'); 4805 const { RULES } = this; 4806 let ruleGroup = post ? RULES.post : RULES.rules.find(({ type: t }) => t === dataType); 4807 if (!ruleGroup) { 4808 ruleGroup = { type: dataType, rules: [] }; 4809 RULES.rules.push(ruleGroup); 4810 } 4811 RULES.keywords[keyword] = true; 4812 if (!definition) 4813 return; 4814 const rule = { 4815 keyword, 4816 definition: { 4817 ...definition, 4818 type: (0, dataType_1.getJSONTypes)(definition.type), 4819 schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType) 4820 } 4821 }; 4822 if (definition.before) 4823 addBeforeRule.call(this, ruleGroup, rule, definition.before); 4824 else 4825 ruleGroup.rules.push(rule); 4826 RULES.all[keyword] = rule; 4827 (_a = definition.implements) === null || _a === void 0 ? void 0 : _a.forEach((kwd) => this.addKeyword(kwd)); 4828 } 4829 function addBeforeRule(ruleGroup, rule, before) { 4830 const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before); 4831 if (i >= 0) { 4832 ruleGroup.rules.splice(i, 0, rule); 4833 } else { 4834 ruleGroup.rules.push(rule); 4835 this.logger.warn(`rule $before} is not defined`); 4836 } 4837 } 4838 function keywordMetaschema(def) { 4839 let { metaSchema } = def; 4840 if (metaSchema === void 0) 4841 return; 4842 if (def.$data && this.opts.$data) 4843 metaSchema = schemaOrData(metaSchema); 4844 def.validateSchema = this.compile(metaSchema, true); 4845 } 4846 var $dataRef = { 4847 $ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#" 4848 }; 4849 function schemaOrData(schema) { 4850 return { anyOf: [schema, $dataRef] }; 4851 } 4852 } 4853 }); 4854 4855 // node_modules/ajv/dist/vocabularies/core/ref.js 4856 var require_ref = __commonJS({ 4857 "node_modules/ajv/dist/vocabularies/core/ref.js"(exports) { 4858 "use strict"; 4859 Object.defineProperty(exports, "__esModule", { value: true }); 4860 exports.callRef = exports.getValidate = void 0; 4861 var ref_error_1 = require_ref_error(); 4862 var code_1 = require_code2(); 4863 var codegen_1 = require_codegen(); 4864 var names_1 = require_names(); 4865 var compile_1 = require_compile(); 4866 var util_1 = require_util(); 4867 var def = { 4868 keyword: "$ref", 4869 schemaType: "string", 4870 code(cxt) { 4871 const { gen, schema: $ref, it } = cxt; 4872 const { baseId, schemaEnv: env, validateName, opts, self } = it; 4873 const { root } = env; 4874 if (($ref === "#" || $ref === "#/") && baseId === root.baseId) 4875 return callRootRef(); 4876 const schOrEnv = compile_1.resolveRef.call(self, root, baseId, $ref); 4877 if (schOrEnv === void 0) 4878 throw new ref_error_1.default(it.opts.uriResolver, baseId, $ref); 4879 if (schOrEnv instanceof compile_1.SchemaEnv) 4880 return callValidate(schOrEnv); 4881 return inlineRefSchema(schOrEnv); 4882 function callRootRef() { 4883 if (env === root) 4884 return callRef(cxt, validateName, env, env.$async); 4885 const rootName = gen.scopeValue("root", { ref: root }); 4886 return callRef(cxt, (0, codegen_1._)`$rootName}.validate`, root, root.$async); 4887 } 4888 function callValidate(sch) { 4889 const v = getValidate(cxt, sch); 4890 callRef(cxt, v, sch, sch.$async); 4891 } 4892 function inlineRefSchema(sch) { 4893 const schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: (0, codegen_1.stringify)(sch) } : { ref: sch }); 4894 const valid = gen.name("valid"); 4895 const schCxt = cxt.subschema({ 4896 schema: sch, 4897 dataTypes: [], 4898 schemaPath: codegen_1.nil, 4899 topSchemaRef: schName, 4900 errSchemaPath: $ref 4901 }, valid); 4902 cxt.mergeEvaluated(schCxt); 4903 cxt.ok(valid); 4904 } 4905 } 4906 }; 4907 function getValidate(cxt, sch) { 4908 const { gen } = cxt; 4909 return sch.validate ? gen.scopeValue("validate", { ref: sch.validate }) : (0, codegen_1._)`$gen.scopeValue("wrapper", { ref: sch })}.validate`; 4910 } 4911 exports.getValidate = getValidate; 4912 function callRef(cxt, v, sch, $async) { 4913 const { gen, it } = cxt; 4914 const { allErrors, schemaEnv: env, opts } = it; 4915 const passCxt = opts.passContext ? names_1.default.this : codegen_1.nil; 4916 if ($async) 4917 callAsyncRef(); 4918 else 4919 callSyncRef(); 4920 function callAsyncRef() { 4921 if (!env.$async) 4922 throw new Error("async schema referenced by sync schema"); 4923 const valid = gen.let("valid"); 4924 gen.try(() => { 4925 gen.code((0, codegen_1._)`await ${(0, code_1.callValidateCode)(cxt, v, passCxt)}`); 4926 addEvaluatedFrom(v); 4927 if (!allErrors) 4928 gen.assign(valid, true); 4929 }, (e) => { 4930 gen.if((0, codegen_1._)`!($e} instanceof $it.ValidationError})`, () => gen.throw(e)); 4931 addErrorsFrom(e); 4932 if (!allErrors) 4933 gen.assign(valid, false); 4934 }); 4935 cxt.ok(valid); 4936 } 4937 function callSyncRef() { 4938 cxt.result((0, code_1.callValidateCode)(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v)); 4939 } 4940 function addErrorsFrom(source) { 4941 const errs = (0, codegen_1._)`$source}.errors`; 4942 gen.assign(names_1.default.vErrors, (0, codegen_1._)`$names_1.default.vErrors} === null ? $errs} : $names_1.default.vErrors}.concat($errs})`); 4943 gen.assign(names_1.default.errors, (0, codegen_1._)`$names_1.default.vErrors}.length`); 4944 } 4945 function addEvaluatedFrom(source) { 4946 var _a; 4947 if (!it.opts.unevaluated) 4948 return; 4949 const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated; 4950 if (it.props !== true) { 4951 if (schEvaluated && !schEvaluated.dynamicProps) { 4952 if (schEvaluated.props !== void 0) { 4953 it.props = util_1.mergeEvaluated.props(gen, schEvaluated.props, it.props); 4954 } 4955 } else { 4956 const props = gen.var("props", (0, codegen_1._)`$source}.evaluated.props`); 4957 it.props = util_1.mergeEvaluated.props(gen, props, it.props, codegen_1.Name); 4958 } 4959 } 4960 if (it.items !== true) { 4961 if (schEvaluated && !schEvaluated.dynamicItems) { 4962 if (schEvaluated.items !== void 0) { 4963 it.items = util_1.mergeEvaluated.items(gen, schEvaluated.items, it.items); 4964 } 4965 } else { 4966 const items = gen.var("items", (0, codegen_1._)`$source}.evaluated.items`); 4967 it.items = util_1.mergeEvaluated.items(gen, items, it.items, codegen_1.Name); 4968 } 4969 } 4970 } 4971 } 4972 exports.callRef = callRef; 4973 exports.default = def; 4974 } 4975 }); 4976 4977 // node_modules/ajv-draft-04/dist/vocabulary/core.js 4978 var require_core2 = __commonJS({ 4979 "node_modules/ajv-draft-04/dist/vocabulary/core.js"(exports) { 4980 "use strict"; 4981 Object.defineProperty(exports, "__esModule", { value: true }); 4982 var ref_1 = require_ref(); 4983 var core = [ 4984 "$schema", 4985 "id", 4986 "$defs", 4987 { keyword: "$comment" }, 4988 "definitions", 4989 ref_1.default 4990 ]; 4991 exports.default = core; 4992 } 4993 }); 4994 4995 // node_modules/ajv-draft-04/dist/vocabulary/validation/limitNumber.js 4996 var require_limitNumber = __commonJS({ 4997 "node_modules/ajv-draft-04/dist/vocabulary/validation/limitNumber.js"(exports) { 4998 "use strict"; 4999 Object.defineProperty(exports, "__esModule", { value: true }); 5000 var core_1 = require_core(); 5001 var codegen_1 = require_codegen(); 5002 var ops = codegen_1.operators; 5003 var KWDs = { 5004 maximum: { 5005 exclusive: "exclusiveMaximum", 5006 ops: [ 5007 { okStr: "<=", ok: ops.LTE, fail: ops.GT }, 5008 { okStr: "<", ok: ops.LT, fail: ops.GTE } 5009 ] 5010 }, 5011 minimum: { 5012 exclusive: "exclusiveMinimum", 5013 ops: [ 5014 { okStr: ">=", ok: ops.GTE, fail: ops.LT }, 5015 { okStr: ">", ok: ops.GT, fail: ops.LTE } 5016 ] 5017 } 5018 }; 5019 var error = { 5020 message: (cxt) => core_1.str`must be $kwdOp(cxt).okStr} $cxt.schemaCode}`, 5021 params: (cxt) => core_1._`{comparison: $kwdOp(cxt).okStr}, limit: $cxt.schemaCode}}` 5022 }; 5023 var def = { 5024 keyword: Object.keys(KWDs), 5025 type: "number", 5026 schemaType: "number", 5027 $data: true, 5028 error, 5029 code(cxt) { 5030 const { data, schemaCode } = cxt; 5031 cxt.fail$data(core_1._`$data} $kwdOp(cxt).fail} $schemaCode} || isNaN($data})`); 5032 } 5033 }; 5034 function kwdOp(cxt) { 5035 var _a; 5036 const keyword = cxt.keyword; 5037 const opsIdx = ((_a = cxt.parentSchema) === null || _a === void 0 ? void 0 : _a[KWDs[keyword].exclusive]) ? 1 : 0; 5038 return KWDs[keyword].ops[opsIdx]; 5039 } 5040 exports.default = def; 5041 } 5042 }); 5043 5044 // node_modules/ajv-draft-04/dist/vocabulary/validation/limitNumberExclusive.js 5045 var require_limitNumberExclusive = __commonJS({ 5046 "node_modules/ajv-draft-04/dist/vocabulary/validation/limitNumberExclusive.js"(exports) { 5047 "use strict"; 5048 Object.defineProperty(exports, "__esModule", { value: true }); 5049 var KWDs = { 5050 exclusiveMaximum: "maximum", 5051 exclusiveMinimum: "minimum" 5052 }; 5053 var def = { 5054 keyword: Object.keys(KWDs), 5055 type: "number", 5056 schemaType: "boolean", 5057 code({ keyword, parentSchema }) { 5058 const limitKwd = KWDs[keyword]; 5059 if (parentSchema[limitKwd] === void 0) { 5060 throw new Error(`$keyword} can only be used with $limitKwd}`); 5061 } 5062 } 5063 }; 5064 exports.default = def; 5065 } 5066 }); 5067 5068 // node_modules/ajv/dist/vocabularies/validation/multipleOf.js 5069 var require_multipleOf = __commonJS({ 5070 "node_modules/ajv/dist/vocabularies/validation/multipleOf.js"(exports) { 5071 "use strict"; 5072 Object.defineProperty(exports, "__esModule", { value: true }); 5073 var codegen_1 = require_codegen(); 5074 var error = { 5075 message: ({ schemaCode }) => (0, codegen_1.str)`must be multiple of $schemaCode}`, 5076 params: ({ schemaCode }) => (0, codegen_1._)`{multipleOf: $schemaCode}}` 5077 }; 5078 var def = { 5079 keyword: "multipleOf", 5080 type: "number", 5081 schemaType: "number", 5082 $data: true, 5083 error, 5084 code(cxt) { 5085 const { gen, data, schemaCode, it } = cxt; 5086 const prec = it.opts.multipleOfPrecision; 5087 const res = gen.let("res"); 5088 const invalid = prec ? (0, codegen_1._)`Math.abs(Math.round($res}) - $res}) > 1e-$prec}` : (0, codegen_1._)`$res} !== parseInt($res})`; 5089 cxt.fail$data((0, codegen_1._)`($schemaCode} === 0 || ($res} = $data}/$schemaCode}, $invalid}))`); 5090 } 5091 }; 5092 exports.default = def; 5093 } 5094 }); 5095 5096 // node_modules/ajv/dist/runtime/ucs2length.js 5097 var require_ucs2length = __commonJS({ 5098 "node_modules/ajv/dist/runtime/ucs2length.js"(exports) { 5099 "use strict"; 5100 Object.defineProperty(exports, "__esModule", { value: true }); 5101 function ucs2length(str) { 5102 const len = str.length; 5103 let length = 0; 5104 let pos = 0; 5105 let value; 5106 while (pos < len) { 5107 length++; 5108 value = str.charCodeAt(pos++); 5109 if (value >= 55296 && value <= 56319 && pos < len) { 5110 value = str.charCodeAt(pos); 5111 if ((value & 64512) === 56320) 5112 pos++; 5113 } 5114 } 5115 return length; 5116 } 5117 exports.default = ucs2length; 5118 ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default'; 5119 } 5120 }); 5121 5122 // node_modules/ajv/dist/vocabularies/validation/limitLength.js 5123 var require_limitLength = __commonJS({ 5124 "node_modules/ajv/dist/vocabularies/validation/limitLength.js"(exports) { 5125 "use strict"; 5126 Object.defineProperty(exports, "__esModule", { value: true }); 5127 var codegen_1 = require_codegen(); 5128 var util_1 = require_util(); 5129 var ucs2length_1 = require_ucs2length(); 5130 var error = { 5131 message({ keyword, schemaCode }) { 5132 const comp = keyword === "maxLength" ? "more" : "fewer"; 5133 return (0, codegen_1.str)`must NOT have $comp} than $schemaCode} characters`; 5134 }, 5135 params: ({ schemaCode }) => (0, codegen_1._)`{limit: $schemaCode}}` 5136 }; 5137 var def = { 5138 keyword: ["maxLength", "minLength"], 5139 type: "string", 5140 schemaType: "number", 5141 $data: true, 5142 error, 5143 code(cxt) { 5144 const { keyword, data, schemaCode, it } = cxt; 5145 const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT; 5146 const len = it.opts.unicode === false ? (0, codegen_1._)`$data}.length` : (0, codegen_1._)`${(0, util_1.useFunc)(cxt.gen, ucs2length_1.default)}($data})`; 5147 cxt.fail$data((0, codegen_1._)`$len} $op} $schemaCode}`); 5148 } 5149 }; 5150 exports.default = def; 5151 } 5152 }); 5153 5154 // node_modules/ajv/dist/vocabularies/validation/pattern.js 5155 var require_pattern = __commonJS({ 5156 "node_modules/ajv/dist/vocabularies/validation/pattern.js"(exports) { 5157 "use strict"; 5158 Object.defineProperty(exports, "__esModule", { value: true }); 5159 var code_1 = require_code2(); 5160 var util_1 = require_util(); 5161 var codegen_1 = require_codegen(); 5162 var error = { 5163 message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "$schemaCode}"`, 5164 params: ({ schemaCode }) => (0, codegen_1._)`{pattern: $schemaCode}}` 5165 }; 5166 var def = { 5167 keyword: "pattern", 5168 type: "string", 5169 schemaType: "string", 5170 $data: true, 5171 error, 5172 code(cxt) { 5173 const { gen, data, $data, schema, schemaCode, it } = cxt; 5174 const u = it.opts.unicodeRegExp ? "u" : ""; 5175 if ($data) { 5176 const { regExp } = it.opts.code; 5177 const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp); 5178 const valid = gen.let("valid"); 5179 gen.try(() => gen.assign(valid, (0, codegen_1._)`$regExpCode}($schemaCode}, $u}).test($data})`), () => gen.assign(valid, false)); 5180 cxt.fail$data((0, codegen_1._)`!$valid}`); 5181 } else { 5182 const regExp = (0, code_1.usePattern)(cxt, schema); 5183 cxt.fail$data((0, codegen_1._)`!$regExp}.test($data})`); 5184 } 5185 } 5186 }; 5187 exports.default = def; 5188 } 5189 }); 5190 5191 // node_modules/ajv/dist/vocabularies/validation/limitProperties.js 5192 var require_limitProperties = __commonJS({ 5193 "node_modules/ajv/dist/vocabularies/validation/limitProperties.js"(exports) { 5194 "use strict"; 5195 Object.defineProperty(exports, "__esModule", { value: true }); 5196 var codegen_1 = require_codegen(); 5197 var error = { 5198 message({ keyword, schemaCode }) { 5199 const comp = keyword === "maxProperties" ? "more" : "fewer"; 5200 return (0, codegen_1.str)`must NOT have $comp} than $schemaCode} properties`; 5201 }, 5202 params: ({ schemaCode }) => (0, codegen_1._)`{limit: $schemaCode}}` 5203 }; 5204 var def = { 5205 keyword: ["maxProperties", "minProperties"], 5206 type: "object", 5207 schemaType: "number", 5208 $data: true, 5209 error, 5210 code(cxt) { 5211 const { keyword, data, schemaCode } = cxt; 5212 const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT; 5213 cxt.fail$data((0, codegen_1._)`Object.keys($data}).length $op} $schemaCode}`); 5214 } 5215 }; 5216 exports.default = def; 5217 } 5218 }); 5219 5220 // node_modules/ajv/dist/vocabularies/validation/required.js 5221 var require_required = __commonJS({ 5222 "node_modules/ajv/dist/vocabularies/validation/required.js"(exports) { 5223 "use strict"; 5224 Object.defineProperty(exports, "__esModule", { value: true }); 5225 var code_1 = require_code2(); 5226 var codegen_1 = require_codegen(); 5227 var util_1 = require_util(); 5228 var error = { 5229 message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '$missingProperty}'`, 5230 params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: $missingProperty}}` 5231 }; 5232 var def = { 5233 keyword: "required", 5234 type: "object", 5235 schemaType: "array", 5236 $data: true, 5237 error, 5238 code(cxt) { 5239 const { gen, schema, schemaCode, data, $data, it } = cxt; 5240 const { opts } = it; 5241 if (!$data && schema.length === 0) 5242 return; 5243 const useLoop = schema.length >= opts.loopRequired; 5244 if (it.allErrors) 5245 allErrorsMode(); 5246 else 5247 exitOnErrorMode(); 5248 if (opts.strictRequired) { 5249 const props = cxt.parentSchema.properties; 5250 const { definedProperties } = cxt.it; 5251 for (const requiredKey of schema) { 5252 if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === void 0 && !definedProperties.has(requiredKey)) { 5253 const schemaPath = it.schemaEnv.baseId + it.errSchemaPath; 5254 const msg = `required property "$requiredKey}" is not defined at "$schemaPath}" (strictRequired)`; 5255 (0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired); 5256 } 5257 } 5258 } 5259 function allErrorsMode() { 5260 if (useLoop || $data) { 5261 cxt.block$data(codegen_1.nil, loopAllRequired); 5262 } else { 5263 for (const prop of schema) { 5264 (0, code_1.checkReportMissingProp)(cxt, prop); 5265 } 5266 } 5267 } 5268 function exitOnErrorMode() { 5269 const missing = gen.let("missing"); 5270 if (useLoop || $data) { 5271 const valid = gen.let("valid", true); 5272 cxt.block$data(valid, () => loopUntilMissing(missing, valid)); 5273 cxt.ok(valid); 5274 } else { 5275 gen.if((0, code_1.checkMissingProp)(cxt, schema, missing)); 5276 (0, code_1.reportMissingProp)(cxt, missing); 5277 gen.else(); 5278 } 5279 } 5280 function loopAllRequired() { 5281 gen.forOf("prop", schemaCode, (prop) => { 5282 cxt.setParams({ missingProperty: prop }); 5283 gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error()); 5284 }); 5285 } 5286 function loopUntilMissing(missing, valid) { 5287 cxt.setParams({ missingProperty: missing }); 5288 gen.forOf(missing, schemaCode, () => { 5289 gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties)); 5290 gen.if((0, codegen_1.not)(valid), () => { 5291 cxt.error(); 5292 gen.break(); 5293 }); 5294 }, codegen_1.nil); 5295 } 5296 } 5297 }; 5298 exports.default = def; 5299 } 5300 }); 5301 5302 // node_modules/ajv/dist/vocabularies/validation/limitItems.js 5303 var require_limitItems = __commonJS({ 5304 "node_modules/ajv/dist/vocabularies/validation/limitItems.js"(exports) { 5305 "use strict"; 5306 Object.defineProperty(exports, "__esModule", { value: true }); 5307 var codegen_1 = require_codegen(); 5308 var error = { 5309 message({ keyword, schemaCode }) { 5310 const comp = keyword === "maxItems" ? "more" : "fewer"; 5311 return (0, codegen_1.str)`must NOT have $comp} than $schemaCode} items`; 5312 }, 5313 params: ({ schemaCode }) => (0, codegen_1._)`{limit: $schemaCode}}` 5314 }; 5315 var def = { 5316 keyword: ["maxItems", "minItems"], 5317 type: "array", 5318 schemaType: "number", 5319 $data: true, 5320 error, 5321 code(cxt) { 5322 const { keyword, data, schemaCode } = cxt; 5323 const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT; 5324 cxt.fail$data((0, codegen_1._)`$data}.length $op} $schemaCode}`); 5325 } 5326 }; 5327 exports.default = def; 5328 } 5329 }); 5330 5331 // node_modules/ajv/dist/runtime/equal.js 5332 var require_equal = __commonJS({ 5333 "node_modules/ajv/dist/runtime/equal.js"(exports) { 5334 "use strict"; 5335 Object.defineProperty(exports, "__esModule", { value: true }); 5336 var equal = require_fast_deep_equal(); 5337 equal.code = 'require("ajv/dist/runtime/equal").default'; 5338 exports.default = equal; 5339 } 5340 }); 5341 5342 // node_modules/ajv/dist/vocabularies/validation/uniqueItems.js 5343 var require_uniqueItems = __commonJS({ 5344 "node_modules/ajv/dist/vocabularies/validation/uniqueItems.js"(exports) { 5345 "use strict"; 5346 Object.defineProperty(exports, "__esModule", { value: true }); 5347 var dataType_1 = require_dataType(); 5348 var codegen_1 = require_codegen(); 5349 var util_1 = require_util(); 5350 var equal_1 = require_equal(); 5351 var error = { 5352 message: ({ params: { i, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## $j} and $i} are identical)`, 5353 params: ({ params: { i, j } }) => (0, codegen_1._)`{i: $i}, j: $j}}` 5354 }; 5355 var def = { 5356 keyword: "uniqueItems", 5357 type: "array", 5358 schemaType: "boolean", 5359 $data: true, 5360 error, 5361 code(cxt) { 5362 const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt; 5363 if (!$data && !schema) 5364 return; 5365 const valid = gen.let("valid"); 5366 const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : []; 5367 cxt.block$data(valid, validateUniqueItems, (0, codegen_1._)`$schemaCode} === false`); 5368 cxt.ok(valid); 5369 function validateUniqueItems() { 5370 const i = gen.let("i", (0, codegen_1._)`$data}.length`); 5371 const j = gen.let("j"); 5372 cxt.setParams({ i, j }); 5373 gen.assign(valid, true); 5374 gen.if((0, codegen_1._)`$i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j)); 5375 } 5376 function canOptimize() { 5377 return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array"); 5378 } 5379 function loopN(i, j) { 5380 const item = gen.name("item"); 5381 const wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong); 5382 const indices = gen.const("indices", (0, codegen_1._)`{}`); 5383 gen.for((0, codegen_1._)`;$i}--;`, () => { 5384 gen.let(item, (0, codegen_1._)`$data}[$i}]`); 5385 gen.if(wrongType, (0, codegen_1._)`continue`); 5386 if (itemTypes.length > 1) 5387 gen.if((0, codegen_1._)`typeof $item} == "string"`, (0, codegen_1._)`$item} += "_"`); 5388 gen.if((0, codegen_1._)`typeof $indices}[$item}] == "number"`, () => { 5389 gen.assign(j, (0, codegen_1._)`$indices}[$item}]`); 5390 cxt.error(); 5391 gen.assign(valid, false).break(); 5392 }).code((0, codegen_1._)`$indices}[$item}] = $i}`); 5393 }); 5394 } 5395 function loopN2(i, j) { 5396 const eql = (0, util_1.useFunc)(gen, equal_1.default); 5397 const outer = gen.name("outer"); 5398 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}])`, () => { 5399 cxt.error(); 5400 gen.assign(valid, false).break(outer); 5401 }))); 5402 } 5403 } 5404 }; 5405 exports.default = def; 5406 } 5407 }); 5408 5409 // node_modules/ajv/dist/vocabularies/validation/const.js 5410 var require_const = __commonJS({ 5411 "node_modules/ajv/dist/vocabularies/validation/const.js"(exports) { 5412 "use strict"; 5413 Object.defineProperty(exports, "__esModule", { value: true }); 5414 var codegen_1 = require_codegen(); 5415 var util_1 = require_util(); 5416 var equal_1 = require_equal(); 5417 var error = { 5418 message: "must be equal to constant", 5419 params: ({ schemaCode }) => (0, codegen_1._)`{allowedValue: $schemaCode}}` 5420 }; 5421 var def = { 5422 keyword: "const", 5423 $data: true, 5424 error, 5425 code(cxt) { 5426 const { gen, data, $data, schemaCode, schema } = cxt; 5427 if ($data || schema && typeof schema == "object") { 5428 cxt.fail$data((0, codegen_1._)`!${(0, util_1.useFunc)(gen, equal_1.default)}($data}, $schemaCode})`); 5429 } else { 5430 cxt.fail((0, codegen_1._)`$schema} !== $data}`); 5431 } 5432 } 5433 }; 5434 exports.default = def; 5435 } 5436 }); 5437 5438 // node_modules/ajv/dist/vocabularies/validation/enum.js 5439 var require_enum = __commonJS({ 5440 "node_modules/ajv/dist/vocabularies/validation/enum.js"(exports) { 5441 "use strict"; 5442 Object.defineProperty(exports, "__esModule", { value: true }); 5443 var codegen_1 = require_codegen(); 5444 var util_1 = require_util(); 5445 var equal_1 = require_equal(); 5446 var error = { 5447 message: "must be equal to one of the allowed values", 5448 params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: $schemaCode}}` 5449 }; 5450 var def = { 5451 keyword: "enum", 5452 schemaType: "array", 5453 $data: true, 5454 error, 5455 code(cxt) { 5456 const { gen, data, $data, schema, schemaCode, it } = cxt; 5457 if (!$data && schema.length === 0) 5458 throw new Error("enum must have non-empty array"); 5459 const useLoop = schema.length >= it.opts.loopEnum; 5460 let eql; 5461 const getEql = () => eql !== null && eql !== void 0 ? eql : eql = (0, util_1.useFunc)(gen, equal_1.default); 5462 let valid; 5463 if (useLoop || $data) { 5464 valid = gen.let("valid"); 5465 cxt.block$data(valid, loopEnum); 5466 } else { 5467 if (!Array.isArray(schema)) 5468 throw new Error("ajv implementation error"); 5469 const vSchema = gen.const("vSchema", schemaCode); 5470 valid = (0, codegen_1.or)(...schema.map((_x, i) => equalCode(vSchema, i))); 5471 } 5472 cxt.pass(valid); 5473 function loopEnum() { 5474 gen.assign(valid, false); 5475 gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`$getEql()}($data}, $v})`, () => gen.assign(valid, true).break())); 5476 } 5477 function equalCode(vSchema, i) { 5478 const sch = schema[i]; 5479 return typeof sch === "object" && sch !== null ? (0, codegen_1._)`$getEql()}($data}, $vSchema}[$i}])` : (0, codegen_1._)`$data} === $sch}`; 5480 } 5481 } 5482 }; 5483 exports.default = def; 5484 } 5485 }); 5486 5487 // node_modules/ajv-draft-04/dist/vocabulary/validation/index.js 5488 var require_validation = __commonJS({ 5489 "node_modules/ajv-draft-04/dist/vocabulary/validation/index.js"(exports) { 5490 "use strict"; 5491 Object.defineProperty(exports, "__esModule", { value: true }); 5492 var limitNumber_1 = require_limitNumber(); 5493 var limitNumberExclusive_1 = require_limitNumberExclusive(); 5494 var multipleOf_1 = require_multipleOf(); 5495 var limitLength_1 = require_limitLength(); 5496 var pattern_1 = require_pattern(); 5497 var limitProperties_1 = require_limitProperties(); 5498 var required_1 = require_required(); 5499 var limitItems_1 = require_limitItems(); 5500 var uniqueItems_1 = require_uniqueItems(); 5501 var const_1 = require_const(); 5502 var enum_1 = require_enum(); 5503 var validation = [ 5504 // number 5505 limitNumber_1.default, 5506 limitNumberExclusive_1.default, 5507 multipleOf_1.default, 5508 // string 5509 limitLength_1.default, 5510 pattern_1.default, 5511 // object 5512 limitProperties_1.default, 5513 required_1.default, 5514 // array 5515 limitItems_1.default, 5516 uniqueItems_1.default, 5517 // any 5518 { keyword: "type", schemaType: ["string", "array"] }, 5519 { keyword: "nullable", schemaType: "boolean" }, 5520 const_1.default, 5521 enum_1.default 5522 ]; 5523 exports.default = validation; 5524 } 5525 }); 5526 5527 // node_modules/ajv/dist/vocabularies/applicator/additionalItems.js 5528 var require_additionalItems = __commonJS({ 5529 "node_modules/ajv/dist/vocabularies/applicator/additionalItems.js"(exports) { 5530 "use strict"; 5531 Object.defineProperty(exports, "__esModule", { value: true }); 5532 exports.validateAdditionalItems = void 0; 5533 var codegen_1 = require_codegen(); 5534 var util_1 = require_util(); 5535 var error = { 5536 message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than $len} items`, 5537 params: ({ params: { len } }) => (0, codegen_1._)`{limit: $len}}` 5538 }; 5539 var def = { 5540 keyword: "additionalItems", 5541 type: "array", 5542 schemaType: ["boolean", "object"], 5543 before: "uniqueItems", 5544 error, 5545 code(cxt) { 5546 const { parentSchema, it } = cxt; 5547 const { items } = parentSchema; 5548 if (!Array.isArray(items)) { 5549 (0, util_1.checkStrictMode)(it, '"additionalItems" is ignored when "items" is not an array of schemas'); 5550 return; 5551 } 5552 validateAdditionalItems(cxt, items); 5553 } 5554 }; 5555 function validateAdditionalItems(cxt, items) { 5556 const { gen, schema, data, keyword, it } = cxt; 5557 it.items = true; 5558 const len = gen.const("len", (0, codegen_1._)`$data}.length`); 5559 if (schema === false) { 5560 cxt.setParams({ len: items.length }); 5561 cxt.pass((0, codegen_1._)`$len} <= $items.length}`); 5562 } else if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) { 5563 const valid = gen.var("valid", (0, codegen_1._)`$len} <= $items.length}`); 5564 gen.if((0, codegen_1.not)(valid), () => validateItems(valid)); 5565 cxt.ok(valid); 5566 } 5567 function validateItems(valid) { 5568 gen.forRange("i", items.length, len, (i) => { 5569 cxt.subschema({ keyword, dataProp: i, dataPropType: util_1.Type.Num }, valid); 5570 if (!it.allErrors) 5571 gen.if((0, codegen_1.not)(valid), () => gen.break()); 5572 }); 5573 } 5574 } 5575 exports.validateAdditionalItems = validateAdditionalItems; 5576 exports.default = def; 5577 } 5578 }); 5579 5580 // node_modules/ajv/dist/vocabularies/applicator/items.js 5581 var require_items = __commonJS({ 5582 "node_modules/ajv/dist/vocabularies/applicator/items.js"(exports) { 5583 "use strict"; 5584 Object.defineProperty(exports, "__esModule", { value: true }); 5585 exports.validateTuple = void 0; 5586 var codegen_1 = require_codegen(); 5587 var util_1 = require_util(); 5588 var code_1 = require_code2(); 5589 var def = { 5590 keyword: "items", 5591 type: "array", 5592 schemaType: ["object", "array", "boolean"], 5593 before: "uniqueItems", 5594 code(cxt) { 5595 const { schema, it } = cxt; 5596 if (Array.isArray(schema)) 5597 return validateTuple(cxt, "additionalItems", schema); 5598 it.items = true; 5599 if ((0, util_1.alwaysValidSchema)(it, schema)) 5600 return; 5601 cxt.ok((0, code_1.validateArray)(cxt)); 5602 } 5603 }; 5604 function validateTuple(cxt, extraItems, schArr = cxt.schema) { 5605 const { gen, parentSchema, data, keyword, it } = cxt; 5606 checkStrictTuple(parentSchema); 5607 if (it.opts.unevaluated && schArr.length && it.items !== true) { 5608 it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items); 5609 } 5610 const valid = gen.name("valid"); 5611 const len = gen.const("len", (0, codegen_1._)`$data}.length`); 5612 schArr.forEach((sch, i) => { 5613 if ((0, util_1.alwaysValidSchema)(it, sch)) 5614 return; 5615 gen.if((0, codegen_1._)`$len} > $i}`, () => cxt.subschema({ 5616 keyword, 5617 schemaProp: i, 5618 dataProp: i 5619 }, valid)); 5620 cxt.ok(valid); 5621 }); 5622 function checkStrictTuple(sch) { 5623 const { opts, errSchemaPath } = it; 5624 const l = schArr.length; 5625 const fullTuple = l === sch.minItems && (l === sch.maxItems || sch[extraItems] === false); 5626 if (opts.strictTuples && !fullTuple) { 5627 const msg = `"$keyword}" is $l}-tuple, but minItems or maxItems/$extraItems} are not specified or different at path "$errSchemaPath}"`; 5628 (0, util_1.checkStrictMode)(it, msg, opts.strictTuples); 5629 } 5630 } 5631 } 5632 exports.validateTuple = validateTuple; 5633 exports.default = def; 5634 } 5635 }); 5636 5637 // node_modules/ajv/dist/vocabularies/applicator/prefixItems.js 5638 var require_prefixItems = __commonJS({ 5639 "node_modules/ajv/dist/vocabularies/applicator/prefixItems.js"(exports) { 5640 "use strict"; 5641 Object.defineProperty(exports, "__esModule", { value: true }); 5642 var items_1 = require_items(); 5643 var def = { 5644 keyword: "prefixItems", 5645 type: "array", 5646 schemaType: ["array"], 5647 before: "uniqueItems", 5648 code: (cxt) => (0, items_1.validateTuple)(cxt, "items") 5649 }; 5650 exports.default = def; 5651 } 5652 }); 5653 5654 // node_modules/ajv/dist/vocabularies/applicator/items2020.js 5655 var require_items2020 = __commonJS({ 5656 "node_modules/ajv/dist/vocabularies/applicator/items2020.js"(exports) { 5657 "use strict"; 5658 Object.defineProperty(exports, "__esModule", { value: true }); 5659 var codegen_1 = require_codegen(); 5660 var util_1 = require_util(); 5661 var code_1 = require_code2(); 5662 var additionalItems_1 = require_additionalItems(); 5663 var error = { 5664 message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than $len} items`, 5665 params: ({ params: { len } }) => (0, codegen_1._)`{limit: $len}}` 5666 }; 5667 var def = { 5668 keyword: "items", 5669 type: "array", 5670 schemaType: ["object", "boolean"], 5671 before: "uniqueItems", 5672 error, 5673 code(cxt) { 5674 const { schema, parentSchema, it } = cxt; 5675 const { prefixItems } = parentSchema; 5676 it.items = true; 5677 if ((0, util_1.alwaysValidSchema)(it, schema)) 5678 return; 5679 if (prefixItems) 5680 (0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems); 5681 else 5682 cxt.ok((0, code_1.validateArray)(cxt)); 5683 } 5684 }; 5685 exports.default = def; 5686 } 5687 }); 5688 5689 // node_modules/ajv/dist/vocabularies/applicator/contains.js 5690 var require_contains = __commonJS({ 5691 "node_modules/ajv/dist/vocabularies/applicator/contains.js"(exports) { 5692 "use strict"; 5693 Object.defineProperty(exports, "__esModule", { value: true }); 5694 var codegen_1 = require_codegen(); 5695 var util_1 = require_util(); 5696 var error = { 5697 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)`, 5698 params: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1._)`{minContains: $min}}` : (0, codegen_1._)`{minContains: $min}, maxContains: $max}}` 5699 }; 5700 var def = { 5701 keyword: "contains", 5702 type: "array", 5703 schemaType: ["object", "boolean"], 5704 before: "uniqueItems", 5705 trackErrors: true, 5706 error, 5707 code(cxt) { 5708 const { gen, schema, parentSchema, data, it } = cxt; 5709 let min; 5710 let max; 5711 const { minContains, maxContains } = parentSchema; 5712 if (it.opts.next) { 5713 min = minContains === void 0 ? 1 : minContains; 5714 max = maxContains; 5715 } else { 5716 min = 1; 5717 } 5718 const len = gen.const("len", (0, codegen_1._)`$data}.length`); 5719 cxt.setParams({ min, max }); 5720 if (max === void 0 && min === 0) { 5721 (0, util_1.checkStrictMode)(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`); 5722 return; 5723 } 5724 if (max !== void 0 && min > max) { 5725 (0, util_1.checkStrictMode)(it, `"minContains" > "maxContains" is always invalid`); 5726 cxt.fail(); 5727 return; 5728 } 5729 if ((0, util_1.alwaysValidSchema)(it, schema)) { 5730 let cond = (0, codegen_1._)`$len} >= $min}`; 5731 if (max !== void 0) 5732 cond = (0, codegen_1._)`$cond} && $len} <= $max}`; 5733 cxt.pass(cond); 5734 return; 5735 } 5736 it.items = true; 5737 const valid = gen.name("valid"); 5738 if (max === void 0 && min === 1) { 5739 validateItems(valid, () => gen.if(valid, () => gen.break())); 5740 } else if (min === 0) { 5741 gen.let(valid, true); 5742 if (max !== void 0) 5743 gen.if((0, codegen_1._)`$data}.length > 0`, validateItemsWithCount); 5744 } else { 5745 gen.let(valid, false); 5746 validateItemsWithCount(); 5747 } 5748 cxt.result(valid, () => cxt.reset()); 5749 function validateItemsWithCount() { 5750 const schValid = gen.name("_valid"); 5751 const count = gen.let("count", 0); 5752 validateItems(schValid, () => gen.if(schValid, () => checkLimits(count))); 5753 } 5754 function validateItems(_valid, block) { 5755 gen.forRange("i", 0, len, (i) => { 5756 cxt.subschema({ 5757 keyword: "contains", 5758 dataProp: i, 5759 dataPropType: util_1.Type.Num, 5760 compositeRule: true 5761 }, _valid); 5762 block(); 5763 }); 5764 } 5765 function checkLimits(count) { 5766 gen.code((0, codegen_1._)`$count}++`); 5767 if (max === void 0) { 5768 gen.if((0, codegen_1._)`$count} >= $min}`, () => gen.assign(valid, true).break()); 5769 } else { 5770 gen.if((0, codegen_1._)`$count} > $max}`, () => gen.assign(valid, false).break()); 5771 if (min === 1) 5772 gen.assign(valid, true); 5773 else 5774 gen.if((0, codegen_1._)`$count} >= $min}`, () => gen.assign(valid, true)); 5775 } 5776 } 5777 } 5778 }; 5779 exports.default = def; 5780 } 5781 }); 5782 5783 // node_modules/ajv/dist/vocabularies/applicator/dependencies.js 5784 var require_dependencies = __commonJS({ 5785 "node_modules/ajv/dist/vocabularies/applicator/dependencies.js"(exports) { 5786 "use strict"; 5787 Object.defineProperty(exports, "__esModule", { value: true }); 5788 exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0; 5789 var codegen_1 = require_codegen(); 5790 var util_1 = require_util(); 5791 var code_1 = require_code2(); 5792 exports.error = { 5793 message: ({ params: { property, depsCount, deps } }) => { 5794 const property_ies = depsCount === 1 ? "property" : "properties"; 5795 return (0, codegen_1.str)`must have $property_ies} $deps} when property $property} is present`; 5796 }, 5797 params: ({ params: { property, depsCount, deps, missingProperty } }) => (0, codegen_1._)`{property: $property}, 5798 missingProperty: $missingProperty}, 5799 depsCount: $depsCount}, 5800 deps: $deps}}` 5801 // TODO change to reference 5802 }; 5803 var def = { 5804 keyword: "dependencies", 5805 type: "object", 5806 schemaType: "object", 5807 error: exports.error, 5808 code(cxt) { 5809 const [propDeps, schDeps] = splitDependencies(cxt); 5810 validatePropertyDeps(cxt, propDeps); 5811 validateSchemaDeps(cxt, schDeps); 5812 } 5813 }; 5814 function splitDependencies({ schema }) { 5815 const propertyDeps = {}; 5816 const schemaDeps = {}; 5817 for (const key in schema) { 5818 if (key === "__proto__") 5819 continue; 5820 const deps = Array.isArray(schema[key]) ? propertyDeps : schemaDeps; 5821 deps[key] = schema[key]; 5822 } 5823 return [propertyDeps, schemaDeps]; 5824 } 5825 function validatePropertyDeps(cxt, propertyDeps = cxt.schema) { 5826 const { gen, data, it } = cxt; 5827 if (Object.keys(propertyDeps).length === 0) 5828 return; 5829 const missing = gen.let("missing"); 5830 for (const prop in propertyDeps) { 5831 const deps = propertyDeps[prop]; 5832 if (deps.length === 0) 5833 continue; 5834 const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties); 5835 cxt.setParams({ 5836 property: prop, 5837 depsCount: deps.length, 5838 deps: deps.join(", ") 5839 }); 5840 if (it.allErrors) { 5841 gen.if(hasProperty, () => { 5842 for (const depProp of deps) { 5843 (0, code_1.checkReportMissingProp)(cxt, depProp); 5844 } 5845 }); 5846 } else { 5847 gen.if((0, codegen_1._)`$hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`); 5848 (0, code_1.reportMissingProp)(cxt, missing); 5849 gen.else(); 5850 } 5851 } 5852 } 5853 exports.validatePropertyDeps = validatePropertyDeps; 5854 function validateSchemaDeps(cxt, schemaDeps = cxt.schema) { 5855 const { gen, data, keyword, it } = cxt; 5856 const valid = gen.name("valid"); 5857 for (const prop in schemaDeps) { 5858 if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop])) 5859 continue; 5860 gen.if( 5861 (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), 5862 () => { 5863 const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid); 5864 cxt.mergeValidEvaluated(schCxt, valid); 5865 }, 5866 () => gen.var(valid, true) 5867 // TODO var 5868 ); 5869 cxt.ok(valid); 5870 } 5871 } 5872 exports.validateSchemaDeps = validateSchemaDeps; 5873 exports.default = def; 5874 } 5875 }); 5876 5877 // node_modules/ajv/dist/vocabularies/applicator/propertyNames.js 5878 var require_propertyNames = __commonJS({ 5879 "node_modules/ajv/dist/vocabularies/applicator/propertyNames.js"(exports) { 5880 "use strict"; 5881 Object.defineProperty(exports, "__esModule", { value: true }); 5882 var codegen_1 = require_codegen(); 5883 var util_1 = require_util(); 5884 var error = { 5885 message: "property name must be valid", 5886 params: ({ params }) => (0, codegen_1._)`{propertyName: $params.propertyName}}` 5887 }; 5888 var def = { 5889 keyword: "propertyNames", 5890 type: "object", 5891 schemaType: ["object", "boolean"], 5892 error, 5893 code(cxt) { 5894 const { gen, schema, data, it } = cxt; 5895 if ((0, util_1.alwaysValidSchema)(it, schema)) 5896 return; 5897 const valid = gen.name("valid"); 5898 gen.forIn("key", data, (key) => { 5899 cxt.setParams({ propertyName: key }); 5900 cxt.subschema({ 5901 keyword: "propertyNames", 5902 data: key, 5903 dataTypes: ["string"], 5904 propertyName: key, 5905 compositeRule: true 5906 }, valid); 5907 gen.if((0, codegen_1.not)(valid), () => { 5908 cxt.error(true); 5909 if (!it.allErrors) 5910 gen.break(); 5911 }); 5912 }); 5913 cxt.ok(valid); 5914 } 5915 }; 5916 exports.default = def; 5917 } 5918 }); 5919 5920 // node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js 5921 var require_additionalProperties = __commonJS({ 5922 "node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js"(exports) { 5923 "use strict"; 5924 Object.defineProperty(exports, "__esModule", { value: true }); 5925 var code_1 = require_code2(); 5926 var codegen_1 = require_codegen(); 5927 var names_1 = require_names(); 5928 var util_1 = require_util(); 5929 var error = { 5930 message: "must NOT have additional properties", 5931 params: ({ params }) => (0, codegen_1._)`{additionalProperty: $params.additionalProperty}}` 5932 }; 5933 var def = { 5934 keyword: "additionalProperties", 5935 type: ["object"], 5936 schemaType: ["boolean", "object"], 5937 allowUndefined: true, 5938 trackErrors: true, 5939 error, 5940 code(cxt) { 5941 const { gen, schema, parentSchema, data, errsCount, it } = cxt; 5942 if (!errsCount) 5943 throw new Error("ajv implementation error"); 5944 const { allErrors, opts } = it; 5945 it.props = true; 5946 if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema)) 5947 return; 5948 const props = (0, code_1.allSchemaProperties)(parentSchema.properties); 5949 const patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties); 5950 checkAdditionalProperties(); 5951 cxt.ok((0, codegen_1._)`$errsCount} === $names_1.default.errors}`); 5952 function checkAdditionalProperties() { 5953 gen.forIn("key", data, (key) => { 5954 if (!props.length && !patProps.length) 5955 additionalPropertyCode(key); 5956 else 5957 gen.if(isAdditional(key), () => additionalPropertyCode(key)); 5958 }); 5959 } 5960 function isAdditional(key) { 5961 let definedProp; 5962 if (props.length > 8) { 5963 const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties"); 5964 definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key); 5965 } else if (props.length) { 5966 definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`$key} === $p}`)); 5967 } else { 5968 definedProp = codegen_1.nil; 5969 } 5970 if (patProps.length) { 5971 definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test($key})`)); 5972 } 5973 return (0, codegen_1.not)(definedProp); 5974 } 5975 function deleteAdditional(key) { 5976 gen.code((0, codegen_1._)`delete $data}[$key}]`); 5977 } 5978 function additionalPropertyCode(key) { 5979 if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) { 5980 deleteAdditional(key); 5981 return; 5982 } 5983 if (schema === false) { 5984 cxt.setParams({ additionalProperty: key }); 5985 cxt.error(); 5986 if (!allErrors) 5987 gen.break(); 5988 return; 5989 } 5990 if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) { 5991 const valid = gen.name("valid"); 5992 if (opts.removeAdditional === "failing") { 5993 applyAdditionalSchema(key, valid, false); 5994 gen.if((0, codegen_1.not)(valid), () => { 5995 cxt.reset(); 5996 deleteAdditional(key); 5997 }); 5998 } else { 5999 applyAdditionalSchema(key, valid); 6000 if (!allErrors) 6001 gen.if((0, codegen_1.not)(valid), () => gen.break()); 6002 } 6003 } 6004 } 6005 function applyAdditionalSchema(key, valid, errors) { 6006 const subschema = { 6007 keyword: "additionalProperties", 6008 dataProp: key, 6009 dataPropType: util_1.Type.Str 6010 }; 6011 if (errors === false) { 6012 Object.assign(subschema, { 6013 compositeRule: true, 6014 createErrors: false, 6015 allErrors: false 6016 }); 6017 } 6018 cxt.subschema(subschema, valid); 6019 } 6020 } 6021 }; 6022 exports.default = def; 6023 } 6024 }); 6025 6026 // node_modules/ajv/dist/vocabularies/applicator/properties.js 6027 var require_properties = __commonJS({ 6028 "node_modules/ajv/dist/vocabularies/applicator/properties.js"(exports) { 6029 "use strict"; 6030 Object.defineProperty(exports, "__esModule", { value: true }); 6031 var validate_1 = require_validate(); 6032 var code_1 = require_code2(); 6033 var util_1 = require_util(); 6034 var additionalProperties_1 = require_additionalProperties(); 6035 var def = { 6036 keyword: "properties", 6037 type: "object", 6038 schemaType: "object", 6039 code(cxt) { 6040 const { gen, schema, parentSchema, data, it } = cxt; 6041 if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === void 0) { 6042 additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties")); 6043 } 6044 const allProps = (0, code_1.allSchemaProperties)(schema); 6045 for (const prop of allProps) { 6046 it.definedProperties.add(prop); 6047 } 6048 if (it.opts.unevaluated && allProps.length && it.props !== true) { 6049 it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props); 6050 } 6051 const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p])); 6052 if (properties.length === 0) 6053 return; 6054 const valid = gen.name("valid"); 6055 for (const prop of properties) { 6056 if (hasDefault(prop)) { 6057 applyPropertySchema(prop); 6058 } else { 6059 gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties)); 6060 applyPropertySchema(prop); 6061 if (!it.allErrors) 6062 gen.else().var(valid, true); 6063 gen.endIf(); 6064 } 6065 cxt.it.definedProperties.add(prop); 6066 cxt.ok(valid); 6067 } 6068 function hasDefault(prop) { 6069 return it.opts.useDefaults && !it.compositeRule && schema[prop].default !== void 0; 6070 } 6071 function applyPropertySchema(prop) { 6072 cxt.subschema({ 6073 keyword: "properties", 6074 schemaProp: prop, 6075 dataProp: prop 6076 }, valid); 6077 } 6078 } 6079 }; 6080 exports.default = def; 6081 } 6082 }); 6083 6084 // node_modules/ajv/dist/vocabularies/applicator/patternProperties.js 6085 var require_patternProperties = __commonJS({ 6086 "node_modules/ajv/dist/vocabularies/applicator/patternProperties.js"(exports) { 6087 "use strict"; 6088 Object.defineProperty(exports, "__esModule", { value: true }); 6089 var code_1 = require_code2(); 6090 var codegen_1 = require_codegen(); 6091 var util_1 = require_util(); 6092 var util_2 = require_util(); 6093 var def = { 6094 keyword: "patternProperties", 6095 type: "object", 6096 schemaType: "object", 6097 code(cxt) { 6098 const { gen, schema, data, parentSchema, it } = cxt; 6099 const { opts } = it; 6100 const patterns = (0, code_1.allSchemaProperties)(schema); 6101 const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p])); 6102 if (patterns.length === 0 || alwaysValidPatterns.length === patterns.length && (!it.opts.unevaluated || it.props === true)) { 6103 return; 6104 } 6105 const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties; 6106 const valid = gen.name("valid"); 6107 if (it.props !== true && !(it.props instanceof codegen_1.Name)) { 6108 it.props = (0, util_2.evaluatedPropsToName)(gen, it.props); 6109 } 6110 const { props } = it; 6111 validatePatternProperties(); 6112 function validatePatternProperties() { 6113 for (const pat of patterns) { 6114 if (checkProperties) 6115 checkMatchingProperties(pat); 6116 if (it.allErrors) { 6117 validateProperties(pat); 6118 } else { 6119 gen.var(valid, true); 6120 validateProperties(pat); 6121 gen.if(valid); 6122 } 6123 } 6124 } 6125 function checkMatchingProperties(pat) { 6126 for (const prop in checkProperties) { 6127 if (new RegExp(pat).test(prop)) { 6128 (0, util_1.checkStrictMode)(it, `property $prop} matches pattern $pat} (use allowMatchingProperties)`); 6129 } 6130 } 6131 } 6132 function validateProperties(pat) { 6133 gen.forIn("key", data, (key) => { 6134 gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test($key})`, () => { 6135 const alwaysValid = alwaysValidPatterns.includes(pat); 6136 if (!alwaysValid) { 6137 cxt.subschema({ 6138 keyword: "patternProperties", 6139 schemaProp: pat, 6140 dataProp: key, 6141 dataPropType: util_2.Type.Str 6142 }, valid); 6143 } 6144 if (it.opts.unevaluated && props !== true) { 6145 gen.assign((0, codegen_1._)`$props}[$key}]`, true); 6146 } else if (!alwaysValid && !it.allErrors) { 6147 gen.if((0, codegen_1.not)(valid), () => gen.break()); 6148 } 6149 }); 6150 }); 6151 } 6152 } 6153 }; 6154 exports.default = def; 6155 } 6156 }); 6157 6158 // node_modules/ajv/dist/vocabularies/applicator/not.js 6159 var require_not = __commonJS({ 6160 "node_modules/ajv/dist/vocabularies/applicator/not.js"(exports) { 6161 "use strict"; 6162 Object.defineProperty(exports, "__esModule", { value: true }); 6163 var util_1 = require_util(); 6164 var def = { 6165 keyword: "not", 6166 schemaType: ["object", "boolean"], 6167 trackErrors: true, 6168 code(cxt) { 6169 const { gen, schema, it } = cxt; 6170 if ((0, util_1.alwaysValidSchema)(it, schema)) { 6171 cxt.fail(); 6172 return; 6173 } 6174 const valid = gen.name("valid"); 6175 cxt.subschema({ 6176 keyword: "not", 6177 compositeRule: true, 6178 createErrors: false, 6179 allErrors: false 6180 }, valid); 6181 cxt.failResult(valid, () => cxt.reset(), () => cxt.error()); 6182 }, 6183 error: { message: "must NOT be valid" } 6184 }; 6185 exports.default = def; 6186 } 6187 }); 6188 6189 // node_modules/ajv/dist/vocabularies/applicator/anyOf.js 6190 var require_anyOf = __commonJS({ 6191 "node_modules/ajv/dist/vocabularies/applicator/anyOf.js"(exports) { 6192 "use strict"; 6193 Object.defineProperty(exports, "__esModule", { value: true }); 6194 var code_1 = require_code2(); 6195 var def = { 6196 keyword: "anyOf", 6197 schemaType: "array", 6198 trackErrors: true, 6199 code: code_1.validateUnion, 6200 error: { message: "must match a schema in anyOf" } 6201 }; 6202 exports.default = def; 6203 } 6204 }); 6205 6206 // node_modules/ajv/dist/vocabularies/applicator/oneOf.js 6207 var require_oneOf = __commonJS({ 6208 "node_modules/ajv/dist/vocabularies/applicator/oneOf.js"(exports) { 6209 "use strict"; 6210 Object.defineProperty(exports, "__esModule", { value: true }); 6211 var codegen_1 = require_codegen(); 6212 var util_1 = require_util(); 6213 var error = { 6214 message: "must match exactly one schema in oneOf", 6215 params: ({ params }) => (0, codegen_1._)`{passingSchemas: $params.passing}}` 6216 }; 6217 var def = { 6218 keyword: "oneOf", 6219 schemaType: "array", 6220 trackErrors: true, 6221 error, 6222 code(cxt) { 6223 const { gen, schema, parentSchema, it } = cxt; 6224 if (!Array.isArray(schema)) 6225 throw new Error("ajv implementation error"); 6226 if (it.opts.discriminator && parentSchema.discriminator) 6227 return; 6228 const schArr = schema; 6229 const valid = gen.let("valid", false); 6230 const passing = gen.let("passing", null); 6231 const schValid = gen.name("_valid"); 6232 cxt.setParams({ passing }); 6233 gen.block(validateOneOf); 6234 cxt.result(valid, () => cxt.reset(), () => cxt.error(true)); 6235 function validateOneOf() { 6236 schArr.forEach((sch, i) => { 6237 let schCxt; 6238 if ((0, util_1.alwaysValidSchema)(it, sch)) { 6239 gen.var(schValid, true); 6240 } else { 6241 schCxt = cxt.subschema({ 6242 keyword: "oneOf", 6243 schemaProp: i, 6244 compositeRule: true 6245 }, schValid); 6246 } 6247 if (i > 0) { 6248 gen.if((0, codegen_1._)`$schValid} && $valid}`).assign(valid, false).assign(passing, (0, codegen_1._)`[$passing}, $i}]`).else(); 6249 } 6250 gen.if(schValid, () => { 6251 gen.assign(valid, true); 6252 gen.assign(passing, i); 6253 if (schCxt) 6254 cxt.mergeEvaluated(schCxt, codegen_1.Name); 6255 }); 6256 }); 6257 } 6258 } 6259 }; 6260 exports.default = def; 6261 } 6262 }); 6263 6264 // node_modules/ajv/dist/vocabularies/applicator/allOf.js 6265 var require_allOf = __commonJS({ 6266 "node_modules/ajv/dist/vocabularies/applicator/allOf.js"(exports) { 6267 "use strict"; 6268 Object.defineProperty(exports, "__esModule", { value: true }); 6269 var util_1 = require_util(); 6270 var def = { 6271 keyword: "allOf", 6272 schemaType: "array", 6273 code(cxt) { 6274 const { gen, schema, it } = cxt; 6275 if (!Array.isArray(schema)) 6276 throw new Error("ajv implementation error"); 6277 const valid = gen.name("valid"); 6278 schema.forEach((sch, i) => { 6279 if ((0, util_1.alwaysValidSchema)(it, sch)) 6280 return; 6281 const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid); 6282 cxt.ok(valid); 6283 cxt.mergeEvaluated(schCxt); 6284 }); 6285 } 6286 }; 6287 exports.default = def; 6288 } 6289 }); 6290 6291 // node_modules/ajv/dist/vocabularies/applicator/if.js 6292 var require_if = __commonJS({ 6293 "node_modules/ajv/dist/vocabularies/applicator/if.js"(exports) { 6294 "use strict"; 6295 Object.defineProperty(exports, "__esModule", { value: true }); 6296 var codegen_1 = require_codegen(); 6297 var util_1 = require_util(); 6298 var error = { 6299 message: ({ params }) => (0, codegen_1.str)`must match "$params.ifClause}" schema`, 6300 params: ({ params }) => (0, codegen_1._)`{failingKeyword: $params.ifClause}}` 6301 }; 6302 var def = { 6303 keyword: "if", 6304 schemaType: ["object", "boolean"], 6305 trackErrors: true, 6306 error, 6307 code(cxt) { 6308 const { gen, parentSchema, it } = cxt; 6309 if (parentSchema.then === void 0 && parentSchema.else === void 0) { 6310 (0, util_1.checkStrictMode)(it, '"if" without "then" and "else" is ignored'); 6311 } 6312 const hasThen = hasSchema(it, "then"); 6313 const hasElse = hasSchema(it, "else"); 6314 if (!hasThen && !hasElse) 6315 return; 6316 const valid = gen.let("valid", true); 6317 const schValid = gen.name("_valid"); 6318 validateIf(); 6319 cxt.reset(); 6320 if (hasThen && hasElse) { 6321 const ifClause = gen.let("ifClause"); 6322 cxt.setParams({ ifClause }); 6323 gen.if(schValid, validateClause("then", ifClause), validateClause("else", ifClause)); 6324 } else if (hasThen) { 6325 gen.if(schValid, validateClause("then")); 6326 } else { 6327 gen.if((0, codegen_1.not)(schValid), validateClause("else")); 6328 } 6329 cxt.pass(valid, () => cxt.error(true)); 6330 function validateIf() { 6331 const schCxt = cxt.subschema({ 6332 keyword: "if", 6333 compositeRule: true, 6334 createErrors: false, 6335 allErrors: false 6336 }, schValid); 6337 cxt.mergeEvaluated(schCxt); 6338 } 6339 function validateClause(keyword, ifClause) { 6340 return () => { 6341 const schCxt = cxt.subschema({ keyword }, schValid); 6342 gen.assign(valid, schValid); 6343 cxt.mergeValidEvaluated(schCxt, valid); 6344 if (ifClause) 6345 gen.assign(ifClause, (0, codegen_1._)`$keyword}`); 6346 else 6347 cxt.setParams({ ifClause: keyword }); 6348 }; 6349 } 6350 } 6351 }; 6352 function hasSchema(it, keyword) { 6353 const schema = it.schema[keyword]; 6354 return schema !== void 0 && !(0, util_1.alwaysValidSchema)(it, schema); 6355 } 6356 exports.default = def; 6357 } 6358 }); 6359 6360 // node_modules/ajv/dist/vocabularies/applicator/thenElse.js 6361 var require_thenElse = __commonJS({ 6362 "node_modules/ajv/dist/vocabularies/applicator/thenElse.js"(exports) { 6363 "use strict"; 6364 Object.defineProperty(exports, "__esModule", { value: true }); 6365 var util_1 = require_util(); 6366 var def = { 6367 keyword: ["then", "else"], 6368 schemaType: ["object", "boolean"], 6369 code({ keyword, parentSchema, it }) { 6370 if (parentSchema.if === void 0) 6371 (0, util_1.checkStrictMode)(it, `"$keyword}" without "if" is ignored`); 6372 } 6373 }; 6374 exports.default = def; 6375 } 6376 }); 6377 6378 // node_modules/ajv/dist/vocabularies/applicator/index.js 6379 var require_applicator = __commonJS({ 6380 "node_modules/ajv/dist/vocabularies/applicator/index.js"(exports) { 6381 "use strict"; 6382 Object.defineProperty(exports, "__esModule", { value: true }); 6383 var additionalItems_1 = require_additionalItems(); 6384 var prefixItems_1 = require_prefixItems(); 6385 var items_1 = require_items(); 6386 var items2020_1 = require_items2020(); 6387 var contains_1 = require_contains(); 6388 var dependencies_1 = require_dependencies(); 6389 var propertyNames_1 = require_propertyNames(); 6390 var additionalProperties_1 = require_additionalProperties(); 6391 var properties_1 = require_properties(); 6392 var patternProperties_1 = require_patternProperties(); 6393 var not_1 = require_not(); 6394 var anyOf_1 = require_anyOf(); 6395 var oneOf_1 = require_oneOf(); 6396 var allOf_1 = require_allOf(); 6397 var if_1 = require_if(); 6398 var thenElse_1 = require_thenElse(); 6399 function getApplicator(draft2020 = false) { 6400 const applicator = [ 6401 // any 6402 not_1.default, 6403 anyOf_1.default, 6404 oneOf_1.default, 6405 allOf_1.default, 6406 if_1.default, 6407 thenElse_1.default, 6408 // object 6409 propertyNames_1.default, 6410 additionalProperties_1.default, 6411 dependencies_1.default, 6412 properties_1.default, 6413 patternProperties_1.default 6414 ]; 6415 if (draft2020) 6416 applicator.push(prefixItems_1.default, items2020_1.default); 6417 else 6418 applicator.push(additionalItems_1.default, items_1.default); 6419 applicator.push(contains_1.default); 6420 return applicator; 6421 } 6422 exports.default = getApplicator; 6423 } 6424 }); 6425 6426 // node_modules/ajv/dist/vocabularies/format/format.js 6427 var require_format = __commonJS({ 6428 "node_modules/ajv/dist/vocabularies/format/format.js"(exports) { 6429 "use strict"; 6430 Object.defineProperty(exports, "__esModule", { value: true }); 6431 var codegen_1 = require_codegen(); 6432 var error = { 6433 message: ({ schemaCode }) => (0, codegen_1.str)`must match format "$schemaCode}"`, 6434 params: ({ schemaCode }) => (0, codegen_1._)`{format: $schemaCode}}` 6435 }; 6436 var def = { 6437 keyword: "format", 6438 type: ["number", "string"], 6439 schemaType: "string", 6440 $data: true, 6441 error, 6442 code(cxt, ruleType) { 6443 const { gen, data, $data, schema, schemaCode, it } = cxt; 6444 const { opts, errSchemaPath, schemaEnv, self } = it; 6445 if (!opts.validateFormats) 6446 return; 6447 if ($data) 6448 validate$DataFormat(); 6449 else 6450 validateFormat(); 6451 function validate$DataFormat() { 6452 const fmts = gen.scopeValue("formats", { 6453 ref: self.formats, 6454 code: opts.code.formats 6455 }); 6456 const fDef = gen.const("fDef", (0, codegen_1._)`$fmts}[$schemaCode}]`); 6457 const fType = gen.let("fType"); 6458 const format = gen.let("format"); 6459 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)); 6460 cxt.fail$data((0, codegen_1.or)(unknownFmt(), invalidFmt())); 6461 function unknownFmt() { 6462 if (opts.strictSchema === false) 6463 return codegen_1.nil; 6464 return (0, codegen_1._)`$schemaCode} && !$format}`; 6465 } 6466 function invalidFmt() { 6467 const callFormat = schemaEnv.$async ? (0, codegen_1._)`($fDef}.async ? await $format}($data}) : $format}($data}))` : (0, codegen_1._)`$format}($data})`; 6468 const validData = (0, codegen_1._)`(typeof $format} == "function" ? $callFormat} : $format}.test($data}))`; 6469 return (0, codegen_1._)`$format} && $format} !== true && $fType} === $ruleType} && !$validData}`; 6470 } 6471 } 6472 function validateFormat() { 6473 const formatDef = self.formats[schema]; 6474 if (!formatDef) { 6475 unknownFormat(); 6476 return; 6477 } 6478 if (formatDef === true) 6479 return; 6480 const [fmtType, format, fmtRef] = getFormat(formatDef); 6481 if (fmtType === ruleType) 6482 cxt.pass(validCondition()); 6483 function unknownFormat() { 6484 if (opts.strictSchema === false) { 6485 self.logger.warn(unknownMsg()); 6486 return; 6487 } 6488 throw new Error(unknownMsg()); 6489 function unknownMsg() { 6490 return `unknown format "$schema}" ignored in schema at path "$errSchemaPath}"`; 6491 } 6492 } 6493 function getFormat(fmtDef) { 6494 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; 6495 const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code }); 6496 if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) { 6497 return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._)`$fmt}.validate`]; 6498 } 6499 return ["string", fmtDef, fmt]; 6500 } 6501 function validCondition() { 6502 if (typeof formatDef == "object" && !(formatDef instanceof RegExp) && formatDef.async) { 6503 if (!schemaEnv.$async) 6504 throw new Error("async format in sync schema"); 6505 return (0, codegen_1._)`await $fmtRef}($data})`; 6506 } 6507 return typeof format == "function" ? (0, codegen_1._)`$fmtRef}($data})` : (0, codegen_1._)`$fmtRef}.test($data})`; 6508 } 6509 } 6510 } 6511 }; 6512 exports.default = def; 6513 } 6514 }); 6515 6516 // node_modules/ajv/dist/vocabularies/format/index.js 6517 var require_format2 = __commonJS({ 6518 "node_modules/ajv/dist/vocabularies/format/index.js"(exports) { 6519 "use strict"; 6520 Object.defineProperty(exports, "__esModule", { value: true }); 6521 var format_1 = require_format(); 6522 var format = [format_1.default]; 6523 exports.default = format; 6524 } 6525 }); 6526 6527 // node_modules/ajv-draft-04/dist/vocabulary/draft4.js 6528 var require_draft4 = __commonJS({ 6529 "node_modules/ajv-draft-04/dist/vocabulary/draft4.js"(exports) { 6530 "use strict"; 6531 Object.defineProperty(exports, "__esModule", { value: true }); 6532 var core_1 = require_core2(); 6533 var validation_1 = require_validation(); 6534 var applicator_1 = require_applicator(); 6535 var format_1 = require_format2(); 6536 var metadataVocabulary = ["title", "description", "default"]; 6537 var draft4Vocabularies = [ 6538 core_1.default, 6539 validation_1.default, 6540 applicator_1.default(), 6541 format_1.default, 6542 metadataVocabulary 6543 ]; 6544 exports.default = draft4Vocabularies; 6545 } 6546 }); 6547 6548 // node_modules/ajv/dist/vocabularies/discriminator/types.js 6549 var require_types = __commonJS({ 6550 "node_modules/ajv/dist/vocabularies/discriminator/types.js"(exports) { 6551 "use strict"; 6552 Object.defineProperty(exports, "__esModule", { value: true }); 6553 exports.DiscrError = void 0; 6554 var DiscrError; 6555 (function(DiscrError2) { 6556 DiscrError2["Tag"] = "tag"; 6557 DiscrError2["Mapping"] = "mapping"; 6558 })(DiscrError || (exports.DiscrError = DiscrError = {})); 6559 } 6560 }); 6561 6562 // node_modules/ajv/dist/vocabularies/discriminator/index.js 6563 var require_discriminator = __commonJS({ 6564 "node_modules/ajv/dist/vocabularies/discriminator/index.js"(exports) { 6565 "use strict"; 6566 Object.defineProperty(exports, "__esModule", { value: true }); 6567 var codegen_1 = require_codegen(); 6568 var types_1 = require_types(); 6569 var compile_1 = require_compile(); 6570 var ref_error_1 = require_ref_error(); 6571 var util_1 = require_util(); 6572 var error = { 6573 message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "$tagName}" must be string` : `value of tag "$tagName}" must be in oneOf`, 6574 params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: $discrError}, tag: $tagName}, tagValue: $tag}}` 6575 }; 6576 var def = { 6577 keyword: "discriminator", 6578 type: "object", 6579 schemaType: "object", 6580 error, 6581 code(cxt) { 6582 const { gen, data, schema, parentSchema, it } = cxt; 6583 const { oneOf } = parentSchema; 6584 if (!it.opts.discriminator) { 6585 throw new Error("discriminator: requires discriminator option"); 6586 } 6587 const tagName = schema.propertyName; 6588 if (typeof tagName != "string") 6589 throw new Error("discriminator: requires propertyName"); 6590 if (schema.mapping) 6591 throw new Error("discriminator: mapping is not supported"); 6592 if (!oneOf) 6593 throw new Error("discriminator: requires oneOf keyword"); 6594 const valid = gen.let("valid", false); 6595 const tag = gen.const("tag", (0, codegen_1._)`$data}${(0, codegen_1.getProperty)(tagName)}`); 6596 gen.if((0, codegen_1._)`typeof $tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName })); 6597 cxt.ok(valid); 6598 function validateMapping() { 6599 const mapping = getMapping(); 6600 gen.if(false); 6601 for (const tagValue in mapping) { 6602 gen.elseIf((0, codegen_1._)`$tag} === $tagValue}`); 6603 gen.assign(valid, applyTagSchema(mapping[tagValue])); 6604 } 6605 gen.else(); 6606 cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName }); 6607 gen.endIf(); 6608 } 6609 function applyTagSchema(schemaProp) { 6610 const _valid = gen.name("valid"); 6611 const schCxt = cxt.subschema({ keyword: "oneOf", schemaProp }, _valid); 6612 cxt.mergeEvaluated(schCxt, codegen_1.Name); 6613 return _valid; 6614 } 6615 function getMapping() { 6616 var _a; 6617 const oneOfMapping = {}; 6618 const topRequired = hasRequired(parentSchema); 6619 let tagRequired = true; 6620 for (let i = 0; i < oneOf.length; i++) { 6621 let sch = oneOf[i]; 6622 if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) { 6623 const ref = sch.$ref; 6624 sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, ref); 6625 if (sch instanceof compile_1.SchemaEnv) 6626 sch = sch.schema; 6627 if (sch === void 0) 6628 throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref); 6629 } 6630 const propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName]; 6631 if (typeof propSch != "object") { 6632 throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/$tagName}"`); 6633 } 6634 tagRequired = tagRequired && (topRequired || hasRequired(sch)); 6635 addMappings(propSch, i); 6636 } 6637 if (!tagRequired) 6638 throw new Error(`discriminator: "$tagName}" must be required`); 6639 return oneOfMapping; 6640 function hasRequired({ required }) { 6641 return Array.isArray(required) && required.includes(tagName); 6642 } 6643 function addMappings(sch, i) { 6644 if (sch.const) { 6645 addMapping(sch.const, i); 6646 } else if (sch.enum) { 6647 for (const tagValue of sch.enum) { 6648 addMapping(tagValue, i); 6649 } 6650 } else { 6651 throw new Error(`discriminator: "properties/$tagName}" must have "const" or "enum"`); 6652 } 6653 } 6654 function addMapping(tagValue, i) { 6655 if (typeof tagValue != "string" || tagValue in oneOfMapping) { 6656 throw new Error(`discriminator: "$tagName}" values must be unique strings`); 6657 } 6658 oneOfMapping[tagValue] = i; 6659 } 6660 } 6661 } 6662 }; 6663 exports.default = def; 6664 } 6665 }); 6666 6667 // node_modules/ajv-draft-04/dist/refs/json-schema-draft-04.json 6668 var require_json_schema_draft_04 = __commonJS({ 6669 "node_modules/ajv-draft-04/dist/refs/json-schema-draft-04.json"(exports, module) { 6670 module.exports = { 6671 id: "http://json-schema.org/draft-04/schema#", 6672 $schema: "http://json-schema.org/draft-04/schema#", 6673 description: "Core schema meta-schema", 6674 definitions: { 6675 schemaArray: { 6676 type: "array", 6677 minItems: 1, 6678 items: { $ref: "#" } 6679 }, 6680 positiveInteger: { 6681 type: "integer", 6682 minimum: 0 6683 }, 6684 positiveIntegerDefault0: { 6685 allOf: [{ $ref: "#/definitions/positiveInteger" }, { default: 0 }] 6686 }, 6687 simpleTypes: { 6688 enum: ["array", "boolean", "integer", "null", "number", "object", "string"] 6689 }, 6690 stringArray: { 6691 type: "array", 6692 items: { type: "string" }, 6693 minItems: 1, 6694 uniqueItems: true 6695 } 6696 }, 6697 type: "object", 6698 properties: { 6699 id: { 6700 type: "string", 6701 format: "uri" 6702 }, 6703 $schema: { 6704 type: "string", 6705 format: "uri" 6706 }, 6707 title: { 6708 type: "string" 6709 }, 6710 description: { 6711 type: "string" 6712 }, 6713 default: {}, 6714 multipleOf: { 6715 type: "number", 6716 minimum: 0, 6717 exclusiveMinimum: true 6718 }, 6719 maximum: { 6720 type: "number" 6721 }, 6722 exclusiveMaximum: { 6723 type: "boolean", 6724 default: false 6725 }, 6726 minimum: { 6727 type: "number" 6728 }, 6729 exclusiveMinimum: { 6730 type: "boolean", 6731 default: false 6732 }, 6733 maxLength: { $ref: "#/definitions/positiveInteger" }, 6734 minLength: { $ref: "#/definitions/positiveIntegerDefault0" }, 6735 pattern: { 6736 type: "string", 6737 format: "regex" 6738 }, 6739 additionalItems: { 6740 anyOf: [{ type: "boolean" }, { $ref: "#" }], 6741 default: {} 6742 }, 6743 items: { 6744 anyOf: [{ $ref: "#" }, { $ref: "#/definitions/schemaArray" }], 6745 default: {} 6746 }, 6747 maxItems: { $ref: "#/definitions/positiveInteger" }, 6748 minItems: { $ref: "#/definitions/positiveIntegerDefault0" }, 6749 uniqueItems: { 6750 type: "boolean", 6751 default: false 6752 }, 6753 maxProperties: { $ref: "#/definitions/positiveInteger" }, 6754 minProperties: { $ref: "#/definitions/positiveIntegerDefault0" }, 6755 required: { $ref: "#/definitions/stringArray" }, 6756 additionalProperties: { 6757 anyOf: [{ type: "boolean" }, { $ref: "#" }], 6758 default: {} 6759 }, 6760 definitions: { 6761 type: "object", 6762 additionalProperties: { $ref: "#" }, 6763 default: {} 6764 }, 6765 properties: { 6766 type: "object", 6767 additionalProperties: { $ref: "#" }, 6768 default: {} 6769 }, 6770 patternProperties: { 6771 type: "object", 6772 additionalProperties: { $ref: "#" }, 6773 default: {} 6774 }, 6775 dependencies: { 6776 type: "object", 6777 additionalProperties: { 6778 anyOf: [{ $ref: "#" }, { $ref: "#/definitions/stringArray" }] 6779 } 6780 }, 6781 enum: { 6782 type: "array", 6783 minItems: 1, 6784 uniqueItems: true 6785 }, 6786 type: { 6787 anyOf: [ 6788 { $ref: "#/definitions/simpleTypes" }, 6789 { 6790 type: "array", 6791 items: { $ref: "#/definitions/simpleTypes" }, 6792 minItems: 1, 6793 uniqueItems: true 6794 } 6795 ] 6796 }, 6797 allOf: { $ref: "#/definitions/schemaArray" }, 6798 anyOf: { $ref: "#/definitions/schemaArray" }, 6799 oneOf: { $ref: "#/definitions/schemaArray" }, 6800 not: { $ref: "#" } 6801 }, 6802 dependencies: { 6803 exclusiveMaximum: ["maximum"], 6804 exclusiveMinimum: ["minimum"] 6805 }, 6806 default: {} 6807 }; 6808 } 6809 }); 6810 6811 // node_modules/ajv-draft-04/dist/index.js 6812 var require_dist = __commonJS({ 6813 "node_modules/ajv-draft-04/dist/index.js"(exports, module) { 6814 "use strict"; 6815 Object.defineProperty(exports, "__esModule", { value: true }); 6816 exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0; 6817 var core_1 = require_core(); 6818 var draft4_1 = require_draft4(); 6819 var discriminator_1 = require_discriminator(); 6820 var draft4MetaSchema = require_json_schema_draft_04(); 6821 var META_SUPPORT_DATA = ["/properties"]; 6822 var META_SCHEMA_ID = "http://json-schema.org/draft-04/schema"; 6823 var Ajv2 = class extends core_1.default { 6824 constructor(opts = {}) { 6825 super({ 6826 ...opts, 6827 schemaId: "id" 6828 }); 6829 } 6830 _addVocabularies() { 6831 super._addVocabularies(); 6832 draft4_1.default.forEach((v) => this.addVocabulary(v)); 6833 if (this.opts.discriminator) 6834 this.addKeyword(discriminator_1.default); 6835 } 6836 _addDefaultMetaSchema() { 6837 super._addDefaultMetaSchema(); 6838 if (!this.opts.meta) 6839 return; 6840 const metaSchema = this.opts.$data ? this.$dataMetaSchema(draft4MetaSchema, META_SUPPORT_DATA) : draft4MetaSchema; 6841 this.addMetaSchema(metaSchema, META_SCHEMA_ID, false); 6842 this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID; 6843 } 6844 defaultMeta() { 6845 return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0); 6846 } 6847 }; 6848 module.exports = exports = Ajv2; 6849 Object.defineProperty(exports, "__esModule", { value: true }); 6850 exports.default = Ajv2; 6851 var core_2 = require_core(); 6852 Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() { 6853 return core_2.KeywordCxt; 6854 } }); 6855 var core_3 = require_core(); 6856 Object.defineProperty(exports, "_", { enumerable: true, get: function() { 6857 return core_3._; 6858 } }); 6859 Object.defineProperty(exports, "str", { enumerable: true, get: function() { 6860 return core_3.str; 6861 } }); 6862 Object.defineProperty(exports, "stringify", { enumerable: true, get: function() { 6863 return core_3.stringify; 6864 } }); 6865 Object.defineProperty(exports, "nil", { enumerable: true, get: function() { 6866 return core_3.nil; 6867 } }); 6868 Object.defineProperty(exports, "Name", { enumerable: true, get: function() { 6869 return core_3.Name; 6870 } }); 6871 Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() { 6872 return core_3.CodeGen; 6873 } }); 6874 } 6875 }); 6876 6877 // node_modules/ajv-formats/dist/formats.js 6878 var require_formats = __commonJS({ 6879 "node_modules/ajv-formats/dist/formats.js"(exports) { 6880 "use strict"; 6881 Object.defineProperty(exports, "__esModule", { value: true }); 6882 exports.formatNames = exports.fastFormats = exports.fullFormats = void 0; 6883 function fmtDef(validate, compare) { 6884 return { validate, compare }; 6885 } 6886 exports.fullFormats = { 6887 // date: http://tools.ietf.org/html/rfc3339#section-5.6 6888 date: fmtDef(date, compareDate), 6889 // date-time: http://tools.ietf.org/html/rfc3339#section-5.6 6890 time: fmtDef(getTime(true), compareTime), 6891 "date-time": fmtDef(getDateTime(true), compareDateTime), 6892 "iso-time": fmtDef(getTime(), compareIsoTime), 6893 "iso-date-time": fmtDef(getDateTime(), compareIsoDateTime), 6894 // duration: https://tools.ietf.org/html/rfc3339#appendix-A 6895 duration: /^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/, 6896 uri, 6897 "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, 6898 // uri-template: https://tools.ietf.org/html/rfc6570 6899 "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, 6900 // For the source: https://gist.github.com/dperini/729294 6901 // For test cases: https://mathiasbynens.be/demo/url-regex 6902 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, 6903 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, 6904 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, 6905 // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html 6906 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)$/, 6907 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, 6908 regex, 6909 // uuid: http://tools.ietf.org/html/rfc4122 6910 uuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i, 6911 // JSON-pointer: https://tools.ietf.org/html/rfc6901 6912 // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A 6913 "json-pointer": /^(?:\/(?:[^~/]|~0|~1)*)*$/, 6914 "json-pointer-uri-fragment": /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i, 6915 // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00 6916 "relative-json-pointer": /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/, 6917 // the following formats are used by the openapi specification: https://spec.openapis.org/oas/v3.0.0#data-types 6918 // byte: https://github.com/miguelmota/is-base64 6919 byte, 6920 // signed 32 bit integer 6921 int32: { type: "number", validate: validateInt32 }, 6922 // signed 64 bit integer 6923 int64: { type: "number", validate: validateInt64 }, 6924 // C-type float 6925 float: { type: "number", validate: validateNumber }, 6926 // C-type double 6927 double: { type: "number", validate: validateNumber }, 6928 // hint to the UI to hide input strings 6929 password: true, 6930 // unchecked string payload 6931 binary: true 6932 }; 6933 exports.fastFormats = { 6934 ...exports.fullFormats, 6935 date: fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d$/, compareDate), 6936 time: fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareTime), 6937 "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), 6938 "iso-time": fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoTime), 6939 "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), 6940 // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js 6941 uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i, 6942 "uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i, 6943 // email (sources from jsen validator): 6944 // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363 6945 // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'wilful violation') 6946 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 6947 }; 6948 exports.formatNames = Object.keys(exports.fullFormats); 6949 function isLeapYear(year) { 6950 return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); 6951 } 6952 var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/; 6953 var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 6954 function date(str) { 6955 const matches = DATE.exec(str); 6956 if (!matches) 6957 return false; 6958 const year = +matches[1]; 6959 const month = +matches[2]; 6960 const day = +matches[3]; 6961 return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month]); 6962 } 6963 function compareDate(d1, d2) { 6964 if (!(d1 && d2)) 6965 return void 0; 6966 if (d1 > d2) 6967 return 1; 6968 if (d1 < d2) 6969 return -1; 6970 return 0; 6971 } 6972 var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i; 6973 function getTime(strictTimeZone) { 6974 return function time(str) { 6975 const matches = TIME.exec(str); 6976 if (!matches) 6977 return false; 6978 const hr = +matches[1]; 6979 const min = +matches[2]; 6980 const sec = +matches[3]; 6981 const tz = matches[4]; 6982 const tzSign = matches[5] === "-" ? -1 : 1; 6983 const tzH = +(matches[6] || 0); 6984 const tzM = +(matches[7] || 0); 6985 if (tzH > 23 || tzM > 59 || strictTimeZone && !tz) 6986 return false; 6987 if (hr <= 23 && min <= 59 && sec < 60) 6988 return true; 6989 const utcMin = min - tzM * tzSign; 6990 const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0); 6991 return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61; 6992 }; 6993 } 6994 function compareTime(s1, s2) { 6995 if (!(s1 && s2)) 6996 return void 0; 6997 const t1 = (/* @__PURE__ */ new Date("2020-01-01T" + s1)).valueOf(); 6998 const t2 = (/* @__PURE__ */ new Date("2020-01-01T" + s2)).valueOf(); 6999 if (!(t1 && t2)) 7000 return void 0; 7001 return t1 - t2; 7002 } 7003 function compareIsoTime(t1, t2) { 7004 if (!(t1 && t2)) 7005 return void 0; 7006 const a1 = TIME.exec(t1); 7007 const a2 = TIME.exec(t2); 7008 if (!(a1 && a2)) 7009 return void 0; 7010 t1 = a1[1] + a1[2] + a1[3]; 7011 t2 = a2[1] + a2[2] + a2[3]; 7012 if (t1 > t2) 7013 return 1; 7014 if (t1 < t2) 7015 return -1; 7016 return 0; 7017 } 7018 var DATE_TIME_SEPARATOR = /t|\s/i; 7019 function getDateTime(strictTimeZone) { 7020 const time = getTime(strictTimeZone); 7021 return function date_time(str) { 7022 const dateTime = str.split(DATE_TIME_SEPARATOR); 7023 return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1]); 7024 }; 7025 } 7026 function compareDateTime(dt1, dt2) { 7027 if (!(dt1 && dt2)) 7028 return void 0; 7029 const d1 = new Date(dt1).valueOf(); 7030 const d2 = new Date(dt2).valueOf(); 7031 if (!(d1 && d2)) 7032 return void 0; 7033 return d1 - d2; 7034 } 7035 function compareIsoDateTime(dt1, dt2) { 7036 if (!(dt1 && dt2)) 7037 return void 0; 7038 const [d1, t1] = dt1.split(DATE_TIME_SEPARATOR); 7039 const [d2, t2] = dt2.split(DATE_TIME_SEPARATOR); 7040 const res = compareDate(d1, d2); 7041 if (res === void 0) 7042 return void 0; 7043 return res || compareTime(t1, t2); 7044 } 7045 var NOT_URI_FRAGMENT = /\/|:/; 7046 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; 7047 function uri(str) { 7048 return NOT_URI_FRAGMENT.test(str) && URI.test(str); 7049 } 7050 var BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm; 7051 function byte(str) { 7052 BYTE.lastIndex = 0; 7053 return BYTE.test(str); 7054 } 7055 var MIN_INT32 = -(2 ** 31); 7056 var MAX_INT32 = 2 ** 31 - 1; 7057 function validateInt32(value) { 7058 return Number.isInteger(value) && value <= MAX_INT32 && value >= MIN_INT32; 7059 } 7060 function validateInt64(value) { 7061 return Number.isInteger(value); 7062 } 7063 function validateNumber() { 7064 return true; 7065 } 7066 var Z_ANCHOR = /[^\\]\\Z/; 7067 function regex(str) { 7068 if (Z_ANCHOR.test(str)) 7069 return false; 7070 try { 7071 new RegExp(str); 7072 return true; 7073 } catch (e) { 7074 return false; 7075 } 7076 } 7077 } 7078 }); 7079 7080 // node_modules/ajv/dist/vocabularies/core/id.js 7081 var require_id = __commonJS({ 7082 "node_modules/ajv/dist/vocabularies/core/id.js"(exports) { 7083 "use strict"; 7084 Object.defineProperty(exports, "__esModule", { value: true }); 7085 var def = { 7086 keyword: "id", 7087 code() { 7088 throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID'); 7089 } 7090 }; 7091 exports.default = def; 7092 } 7093 }); 7094 7095 // node_modules/ajv/dist/vocabularies/core/index.js 7096 var require_core3 = __commonJS({ 7097 "node_modules/ajv/dist/vocabularies/core/index.js"(exports) { 7098 "use strict"; 7099 Object.defineProperty(exports, "__esModule", { value: true }); 7100 var id_1 = require_id(); 7101 var ref_1 = require_ref(); 7102 var core = [ 7103 "$schema", 7104 "$id", 7105 "$defs", 7106 "$vocabulary", 7107 { keyword: "$comment" }, 7108 "definitions", 7109 id_1.default, 7110 ref_1.default 7111 ]; 7112 exports.default = core; 7113 } 7114 }); 7115 7116 // node_modules/ajv/dist/vocabularies/validation/limitNumber.js 7117 var require_limitNumber2 = __commonJS({ 7118 "node_modules/ajv/dist/vocabularies/validation/limitNumber.js"(exports) { 7119 "use strict"; 7120 Object.defineProperty(exports, "__esModule", { value: true }); 7121 var codegen_1 = require_codegen(); 7122 var ops = codegen_1.operators; 7123 var KWDs = { 7124 maximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT }, 7125 minimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT }, 7126 exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE }, 7127 exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE } 7128 }; 7129 var error = { 7130 message: ({ keyword, schemaCode }) => (0, codegen_1.str)`must be $KWDs[keyword].okStr} $schemaCode}`, 7131 params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: $KWDs[keyword].okStr}, limit: $schemaCode}}` 7132 }; 7133 var def = { 7134 keyword: Object.keys(KWDs), 7135 type: "number", 7136 schemaType: "number", 7137 $data: true, 7138 error, 7139 code(cxt) { 7140 const { keyword, data, schemaCode } = cxt; 7141 cxt.fail$data((0, codegen_1._)`$data} $KWDs[keyword].fail} $schemaCode} || isNaN($data})`); 7142 } 7143 }; 7144 exports.default = def; 7145 } 7146 }); 7147 7148 // node_modules/ajv/dist/vocabularies/validation/index.js 7149 var require_validation2 = __commonJS({ 7150 "node_modules/ajv/dist/vocabularies/validation/index.js"(exports) { 7151 "use strict"; 7152 Object.defineProperty(exports, "__esModule", { value: true }); 7153 var limitNumber_1 = require_limitNumber2(); 7154 var multipleOf_1 = require_multipleOf(); 7155 var limitLength_1 = require_limitLength(); 7156 var pattern_1 = require_pattern(); 7157 var limitProperties_1 = require_limitProperties(); 7158 var required_1 = require_required(); 7159 var limitItems_1 = require_limitItems(); 7160 var uniqueItems_1 = require_uniqueItems(); 7161 var const_1 = require_const(); 7162 var enum_1 = require_enum(); 7163 var validation = [ 7164 // number 7165 limitNumber_1.default, 7166 multipleOf_1.default, 7167 // string 7168 limitLength_1.default, 7169 pattern_1.default, 7170 // object 7171 limitProperties_1.default, 7172 required_1.default, 7173 // array 7174 limitItems_1.default, 7175 uniqueItems_1.default, 7176 // any 7177 { keyword: "type", schemaType: ["string", "array"] }, 7178 { keyword: "nullable", schemaType: "boolean" }, 7179 const_1.default, 7180 enum_1.default 7181 ]; 7182 exports.default = validation; 7183 } 7184 }); 7185 7186 // node_modules/ajv/dist/vocabularies/metadata.js 7187 var require_metadata = __commonJS({ 7188 "node_modules/ajv/dist/vocabularies/metadata.js"(exports) { 7189 "use strict"; 7190 Object.defineProperty(exports, "__esModule", { value: true }); 7191 exports.contentVocabulary = exports.metadataVocabulary = void 0; 7192 exports.metadataVocabulary = [ 7193 "title", 7194 "description", 7195 "default", 7196 "deprecated", 7197 "readOnly", 7198 "writeOnly", 7199 "examples" 7200 ]; 7201 exports.contentVocabulary = [ 7202 "contentMediaType", 7203 "contentEncoding", 7204 "contentSchema" 7205 ]; 7206 } 7207 }); 7208 7209 // node_modules/ajv/dist/vocabularies/draft7.js 7210 var require_draft7 = __commonJS({ 7211 "node_modules/ajv/dist/vocabularies/draft7.js"(exports) { 7212 "use strict"; 7213 Object.defineProperty(exports, "__esModule", { value: true }); 7214 var core_1 = require_core3(); 7215 var validation_1 = require_validation2(); 7216 var applicator_1 = require_applicator(); 7217 var format_1 = require_format2(); 7218 var metadata_1 = require_metadata(); 7219 var draft7Vocabularies = [ 7220 core_1.default, 7221 validation_1.default, 7222 (0, applicator_1.default)(), 7223 format_1.default, 7224 metadata_1.metadataVocabulary, 7225 metadata_1.contentVocabulary 7226 ]; 7227 exports.default = draft7Vocabularies; 7228 } 7229 }); 7230 7231 // node_modules/ajv/dist/refs/json-schema-draft-07.json 7232 var require_json_schema_draft_07 = __commonJS({ 7233 "node_modules/ajv/dist/refs/json-schema-draft-07.json"(exports, module) { 7234 module.exports = { 7235 $schema: "http://json-schema.org/draft-07/schema#", 7236 $id: "http://json-schema.org/draft-07/schema#", 7237 title: "Core schema meta-schema", 7238 definitions: { 7239 schemaArray: { 7240 type: "array", 7241 minItems: 1, 7242 items: { $ref: "#" } 7243 }, 7244 nonNegativeInteger: { 7245 type: "integer", 7246 minimum: 0 7247 }, 7248 nonNegativeIntegerDefault0: { 7249 allOf: [{ $ref: "#/definitions/nonNegativeInteger" }, { default: 0 }] 7250 }, 7251 simpleTypes: { 7252 enum: ["array", "boolean", "integer", "null", "number", "object", "string"] 7253 }, 7254 stringArray: { 7255 type: "array", 7256 items: { type: "string" }, 7257 uniqueItems: true, 7258 default: [] 7259 } 7260 }, 7261 type: ["object", "boolean"], 7262 properties: { 7263 $id: { 7264 type: "string", 7265 format: "uri-reference" 7266 }, 7267 $schema: { 7268 type: "string", 7269 format: "uri" 7270 }, 7271 $ref: { 7272 type: "string", 7273 format: "uri-reference" 7274 }, 7275 $comment: { 7276 type: "string" 7277 }, 7278 title: { 7279 type: "string" 7280 }, 7281 description: { 7282 type: "string" 7283 }, 7284 default: true, 7285 readOnly: { 7286 type: "boolean", 7287 default: false 7288 }, 7289 examples: { 7290 type: "array", 7291 items: true 7292 }, 7293 multipleOf: { 7294 type: "number", 7295 exclusiveMinimum: 0 7296 }, 7297 maximum: { 7298 type: "number" 7299 }, 7300 exclusiveMaximum: { 7301 type: "number" 7302 }, 7303 minimum: { 7304 type: "number" 7305 }, 7306 exclusiveMinimum: { 7307 type: "number" 7308 }, 7309 maxLength: { $ref: "#/definitions/nonNegativeInteger" }, 7310 minLength: { $ref: "#/definitions/nonNegativeIntegerDefault0" }, 7311 pattern: { 7312 type: "string", 7313 format: "regex" 7314 }, 7315 additionalItems: { $ref: "#" }, 7316 items: { 7317 anyOf: [{ $ref: "#" }, { $ref: "#/definitions/schemaArray" }], 7318 default: true 7319 }, 7320 maxItems: { $ref: "#/definitions/nonNegativeInteger" }, 7321 minItems: { $ref: "#/definitions/nonNegativeIntegerDefault0" }, 7322 uniqueItems: { 7323 type: "boolean", 7324 default: false 7325 }, 7326 contains: { $ref: "#" }, 7327 maxProperties: { $ref: "#/definitions/nonNegativeInteger" }, 7328 minProperties: { $ref: "#/definitions/nonNegativeIntegerDefault0" }, 7329 required: { $ref: "#/definitions/stringArray" }, 7330 additionalProperties: { $ref: "#" }, 7331 definitions: { 7332 type: "object", 7333 additionalProperties: { $ref: "#" }, 7334 default: {} 7335 }, 7336 properties: { 7337 type: "object", 7338 additionalProperties: { $ref: "#" }, 7339 default: {} 7340 }, 7341 patternProperties: { 7342 type: "object", 7343 additionalProperties: { $ref: "#" }, 7344 propertyNames: { format: "regex" }, 7345 default: {} 7346 }, 7347 dependencies: { 7348 type: "object", 7349 additionalProperties: { 7350 anyOf: [{ $ref: "#" }, { $ref: "#/definitions/stringArray" }] 7351 } 7352 }, 7353 propertyNames: { $ref: "#" }, 7354 const: true, 7355 enum: { 7356 type: "array", 7357 items: true, 7358 minItems: 1, 7359 uniqueItems: true 7360 }, 7361 type: { 7362 anyOf: [ 7363 { $ref: "#/definitions/simpleTypes" }, 7364 { 7365 type: "array", 7366 items: { $ref: "#/definitions/simpleTypes" }, 7367 minItems: 1, 7368 uniqueItems: true 7369 } 7370 ] 7371 }, 7372 format: { type: "string" }, 7373 contentMediaType: { type: "string" }, 7374 contentEncoding: { type: "string" }, 7375 if: { $ref: "#" }, 7376 then: { $ref: "#" }, 7377 else: { $ref: "#" }, 7378 allOf: { $ref: "#/definitions/schemaArray" }, 7379 anyOf: { $ref: "#/definitions/schemaArray" }, 7380 oneOf: { $ref: "#/definitions/schemaArray" }, 7381 not: { $ref: "#" } 7382 }, 7383 default: true 7384 }; 7385 } 7386 }); 7387 7388 // node_modules/ajv/dist/ajv.js 7389 var require_ajv = __commonJS({ 7390 "node_modules/ajv/dist/ajv.js"(exports, module) { 7391 "use strict"; 7392 Object.defineProperty(exports, "__esModule", { value: true }); 7393 exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0; 7394 var core_1 = require_core(); 7395 var draft7_1 = require_draft7(); 7396 var discriminator_1 = require_discriminator(); 7397 var draft7MetaSchema = require_json_schema_draft_07(); 7398 var META_SUPPORT_DATA = ["/properties"]; 7399 var META_SCHEMA_ID = "http://json-schema.org/draft-07/schema"; 7400 var Ajv2 = class extends core_1.default { 7401 _addVocabularies() { 7402 super._addVocabularies(); 7403 draft7_1.default.forEach((v) => this.addVocabulary(v)); 7404 if (this.opts.discriminator) 7405 this.addKeyword(discriminator_1.default); 7406 } 7407 _addDefaultMetaSchema() { 7408 super._addDefaultMetaSchema(); 7409 if (!this.opts.meta) 7410 return; 7411 const metaSchema = this.opts.$data ? this.$dataMetaSchema(draft7MetaSchema, META_SUPPORT_DATA) : draft7MetaSchema; 7412 this.addMetaSchema(metaSchema, META_SCHEMA_ID, false); 7413 this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID; 7414 } 7415 defaultMeta() { 7416 return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0); 7417 } 7418 }; 7419 exports.Ajv = Ajv2; 7420 module.exports = exports = Ajv2; 7421 module.exports.Ajv = Ajv2; 7422 Object.defineProperty(exports, "__esModule", { value: true }); 7423 exports.default = Ajv2; 7424 var validate_1 = require_validate(); 7425 Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() { 7426 return validate_1.KeywordCxt; 7427 } }); 7428 var codegen_1 = require_codegen(); 7429 Object.defineProperty(exports, "_", { enumerable: true, get: function() { 7430 return codegen_1._; 7431 } }); 7432 Object.defineProperty(exports, "str", { enumerable: true, get: function() { 7433 return codegen_1.str; 7434 } }); 7435 Object.defineProperty(exports, "stringify", { enumerable: true, get: function() { 7436 return codegen_1.stringify; 7437 } }); 7438 Object.defineProperty(exports, "nil", { enumerable: true, get: function() { 7439 return codegen_1.nil; 7440 } }); 7441 Object.defineProperty(exports, "Name", { enumerable: true, get: function() { 7442 return codegen_1.Name; 7443 } }); 7444 Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() { 7445 return codegen_1.CodeGen; 7446 } }); 7447 var validation_error_1 = require_validation_error(); 7448 Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() { 7449 return validation_error_1.default; 7450 } }); 7451 var ref_error_1 = require_ref_error(); 7452 Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function() { 7453 return ref_error_1.default; 7454 } }); 7455 } 7456 }); 7457 7458 // node_modules/ajv-formats/dist/limit.js 7459 var require_limit = __commonJS({ 7460 "node_modules/ajv-formats/dist/limit.js"(exports) { 7461 "use strict"; 7462 Object.defineProperty(exports, "__esModule", { value: true }); 7463 exports.formatLimitDefinition = void 0; 7464 var ajv_1 = require_ajv(); 7465 var codegen_1 = require_codegen(); 7466 var ops = codegen_1.operators; 7467 var KWDs = { 7468 formatMaximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT }, 7469 formatMinimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT }, 7470 formatExclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE }, 7471 formatExclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE } 7472 }; 7473 var error = { 7474 message: ({ keyword, schemaCode }) => (0, codegen_1.str)`should be $KWDs[keyword].okStr} $schemaCode}`, 7475 params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: $KWDs[keyword].okStr}, limit: $schemaCode}}` 7476 }; 7477 exports.formatLimitDefinition = { 7478 keyword: Object.keys(KWDs), 7479 type: "string", 7480 schemaType: "string", 7481 $data: true, 7482 error, 7483 code(cxt) { 7484 const { gen, data, schemaCode, keyword, it } = cxt; 7485 const { opts, self } = it; 7486 if (!opts.validateFormats) 7487 return; 7488 const fCxt = new ajv_1.KeywordCxt(it, self.RULES.all.format.definition, "format"); 7489 if (fCxt.$data) 7490 validate$DataFormat(); 7491 else 7492 validateFormat(); 7493 function validate$DataFormat() { 7494 const fmts = gen.scopeValue("formats", { 7495 ref: self.formats, 7496 code: opts.code.formats 7497 }); 7498 const fmt = gen.const("fmt", (0, codegen_1._)`$fmts}[$fCxt.schemaCode}]`); 7499 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))); 7500 } 7501 function validateFormat() { 7502 const format = fCxt.schema; 7503 const fmtDef = self.formats[format]; 7504 if (!fmtDef || fmtDef === true) 7505 return; 7506 if (typeof fmtDef != "object" || fmtDef instanceof RegExp || typeof fmtDef.compare != "function") { 7507 throw new Error(`"$keyword}": format "$format}" does not define "compare" function`); 7508 } 7509 const fmt = gen.scopeValue("formats", { 7510 key: format, 7511 ref: fmtDef, 7512 code: opts.code.formats ? (0, codegen_1._)`$opts.code.formats}${(0, codegen_1.getProperty)(format)}` : void 0 7513 }); 7514 cxt.fail$data(compareCode(fmt)); 7515 } 7516 function compareCode(fmt) { 7517 return (0, codegen_1._)`$fmt}.compare($data}, $schemaCode}) $KWDs[keyword].fail} 0`; 7518 } 7519 }, 7520 dependencies: ["format"] 7521 }; 7522 var formatLimitPlugin = (ajv2) => { 7523 ajv2.addKeyword(exports.formatLimitDefinition); 7524 return ajv2; 7525 }; 7526 exports.default = formatLimitPlugin; 7527 } 7528 }); 7529 7530 // node_modules/ajv-formats/dist/index.js 7531 var require_dist2 = __commonJS({ 7532 "node_modules/ajv-formats/dist/index.js"(exports, module) { 7533 "use strict"; 7534 Object.defineProperty(exports, "__esModule", { value: true }); 7535 var formats_1 = require_formats(); 7536 var limit_1 = require_limit(); 7537 var codegen_1 = require_codegen(); 7538 var fullName = new codegen_1.Name("fullFormats"); 7539 var fastName = new codegen_1.Name("fastFormats"); 7540 var formatsPlugin = (ajv2, opts = { keywords: true }) => { 7541 if (Array.isArray(opts)) { 7542 addFormats2(ajv2, opts, formats_1.fullFormats, fullName); 7543 return ajv2; 7544 } 7545 const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName]; 7546 const list = opts.formats || formats_1.formatNames; 7547 addFormats2(ajv2, list, formats, exportName); 7548 if (opts.keywords) 7549 (0, limit_1.default)(ajv2); 7550 return ajv2; 7551 }; 7552 formatsPlugin.get = (name, mode = "full") => { 7553 const formats = mode === "fast" ? formats_1.fastFormats : formats_1.fullFormats; 7554 const f = formats[name]; 7555 if (!f) 7556 throw new Error(`Unknown format "$name}"`); 7557 return f; 7558 }; 7559 function addFormats2(ajv2, list, fs, exportName) { 7560 var _a; 7561 var _b; 7562 (_a = (_b = ajv2.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").$exportName}`; 7563 for (const f of list) 7564 ajv2.addFormat(f, fs[f]); 7565 } 7566 module.exports = exports = formatsPlugin; 7567 Object.defineProperty(exports, "__esModule", { value: true }); 7568 exports.default = formatsPlugin; 7569 } 7570 }); 7571 7572 // packages/abilities/build-module/api.mjs 7573 var import_data4 = __toESM(require_data(), 1); 7574 var import_i18n2 = __toESM(require_i18n(), 1); 7575 7576 // packages/abilities/build-module/store/index.mjs 7577 var import_data3 = __toESM(require_data(), 1); 7578 7579 // packages/abilities/build-module/store/reducer.mjs 7580 var import_data = __toESM(require_data(), 1); 7581 7582 // packages/abilities/build-module/store/constants.mjs 7583 var STORE_NAME = "core/abilities"; 7584 var ABILITY_NAME_PATTERN = /^[a-z0-9-]+(?:\/[a-z0-9-]+){1,3}$/; 7585 var CATEGORY_SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/; 7586 var REGISTER_ABILITY = "REGISTER_ABILITY"; 7587 var UNREGISTER_ABILITY = "UNREGISTER_ABILITY"; 7588 var REGISTER_ABILITY_CATEGORY = "REGISTER_ABILITY_CATEGORY"; 7589 var UNREGISTER_ABILITY_CATEGORY = "UNREGISTER_ABILITY_CATEGORY"; 7590 7591 // packages/abilities/build-module/store/reducer.mjs 7592 var ABILITY_KEYS = [ 7593 "name", 7594 "label", 7595 "description", 7596 "category", 7597 "input_schema", 7598 "output_schema", 7599 "meta", 7600 "callback", 7601 "permissionCallback" 7602 ]; 7603 var CATEGORY_KEYS = ["slug", "label", "description", "meta"]; 7604 function sanitizeAbility(ability) { 7605 return Object.keys(ability).filter( 7606 (key) => ABILITY_KEYS.includes(key) && ability[key] !== void 0 7607 ).reduce( 7608 (obj, key) => ({ ...obj, [key]: ability[key] }), 7609 {} 7610 ); 7611 } 7612 function sanitizeCategory(category) { 7613 return Object.keys(category).filter( 7614 (key) => CATEGORY_KEYS.includes(key) && category[key] !== void 0 7615 ).reduce( 7616 (obj, key) => ({ ...obj, [key]: category[key] }), 7617 {} 7618 ); 7619 } 7620 var DEFAULT_STATE = {}; 7621 function abilitiesByName(state = DEFAULT_STATE, action) { 7622 switch (action.type) { 7623 case REGISTER_ABILITY: { 7624 if (!action.ability) { 7625 return state; 7626 } 7627 return { 7628 ...state, 7629 [action.ability.name]: sanitizeAbility(action.ability) 7630 }; 7631 } 7632 case UNREGISTER_ABILITY: { 7633 if (!state[action.name]) { 7634 return state; 7635 } 7636 const { [action.name]: _, ...newState } = state; 7637 return newState; 7638 } 7639 default: 7640 return state; 7641 } 7642 } 7643 var DEFAULT_CATEGORIES_STATE = {}; 7644 function categoriesBySlug(state = DEFAULT_CATEGORIES_STATE, action) { 7645 switch (action.type) { 7646 case REGISTER_ABILITY_CATEGORY: { 7647 if (!action.category) { 7648 return state; 7649 } 7650 return { 7651 ...state, 7652 [action.category.slug]: sanitizeCategory(action.category) 7653 }; 7654 } 7655 case UNREGISTER_ABILITY_CATEGORY: { 7656 if (!state[action.slug]) { 7657 return state; 7658 } 7659 const { [action.slug]: _, ...newState } = state; 7660 return newState; 7661 } 7662 default: 7663 return state; 7664 } 7665 } 7666 var reducer_default = (0, import_data.combineReducers)({ 7667 abilitiesByName, 7668 categoriesBySlug 7669 }); 7670 7671 // packages/abilities/build-module/store/actions.mjs 7672 var actions_exports = {}; 7673 __export(actions_exports, { 7674 registerAbility: () => registerAbility, 7675 registerAbilityCategory: () => registerAbilityCategory, 7676 unregisterAbility: () => unregisterAbility, 7677 unregisterAbilityCategory: () => unregisterAbilityCategory 7678 }); 7679 var import_i18n = __toESM(require_i18n(), 1); 7680 function filterAnnotations(sourceAnnotations, allowedKeys) { 7681 const annotations = {}; 7682 if (sourceAnnotations) { 7683 for (const key of allowedKeys) { 7684 if (sourceAnnotations[key] !== void 0) { 7685 annotations[key] = sourceAnnotations[key]; 7686 } 7687 } 7688 } 7689 return annotations; 7690 } 7691 function registerAbility(ability) { 7692 return ({ select: select2, dispatch: dispatch2 }) => { 7693 if (!ability.name) { 7694 throw new Error("Ability name is required"); 7695 } 7696 if (!ABILITY_NAME_PATTERN.test(ability.name)) { 7697 throw new Error( 7698 '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.' 7699 ); 7700 } 7701 if (!ability.label) { 7702 throw new Error( 7703 (0, import_i18n.sprintf)('Ability "%s" must have a label', ability.name) 7704 ); 7705 } 7706 if (!ability.description) { 7707 throw new Error( 7708 (0, import_i18n.sprintf)('Ability "%s" must have a description', ability.name) 7709 ); 7710 } 7711 if (!ability.category) { 7712 throw new Error( 7713 (0, import_i18n.sprintf)('Ability "%s" must have a category', ability.name) 7714 ); 7715 } 7716 if (!CATEGORY_SLUG_PATTERN.test(ability.category)) { 7717 throw new Error( 7718 (0, import_i18n.sprintf)( 7719 'Ability "%1$s" has an invalid category. Category must be lowercase alphanumeric with dashes only. Got: "%2$s"', 7720 ability.name, 7721 ability.category 7722 ) 7723 ); 7724 } 7725 const categories = select2.getAbilityCategories(); 7726 const existingCategory = categories.find( 7727 (cat) => cat.slug === ability.category 7728 ); 7729 if (!existingCategory) { 7730 throw new Error( 7731 (0, import_i18n.sprintf)( 7732 'Ability "%1$s" references non-existent category "%2$s". Please register the category first.', 7733 ability.name, 7734 ability.category 7735 ) 7736 ); 7737 } 7738 if (ability.callback && typeof ability.callback !== "function") { 7739 throw new Error( 7740 (0, import_i18n.sprintf)( 7741 'Ability "%s" has an invalid callback. Callback must be a function', 7742 ability.name 7743 ) 7744 ); 7745 } 7746 const existingAbility = select2.getAbility(ability.name); 7747 if (existingAbility) { 7748 throw new Error( 7749 (0, import_i18n.sprintf)('Ability "%s" is already registered', ability.name) 7750 ); 7751 } 7752 const annotations = filterAnnotations(ability.meta?.annotations, [ 7753 "readonly", 7754 "destructive", 7755 "idempotent", 7756 "serverRegistered", 7757 "clientRegistered" 7758 ]); 7759 if (!annotations.serverRegistered) { 7760 annotations.clientRegistered = true; 7761 } 7762 const meta = { 7763 ...ability.meta || {}, 7764 annotations 7765 }; 7766 dispatch2({ 7767 type: REGISTER_ABILITY, 7768 ability: { 7769 ...ability, 7770 meta 7771 } 7772 }); 7773 }; 7774 } 7775 function unregisterAbility(name) { 7776 return { 7777 type: UNREGISTER_ABILITY, 7778 name 7779 }; 7780 } 7781 function registerAbilityCategory(slug, args) { 7782 return ({ select: select2, dispatch: dispatch2 }) => { 7783 if (!slug) { 7784 throw new Error("Category slug is required"); 7785 } 7786 if (!CATEGORY_SLUG_PATTERN.test(slug)) { 7787 throw new Error( 7788 "Category slug must contain only lowercase alphanumeric characters and dashes." 7789 ); 7790 } 7791 const existingCategory = select2.getAbilityCategory(slug); 7792 if (existingCategory) { 7793 throw new Error( 7794 (0, import_i18n.sprintf)('Category "%s" is already registered.', slug) 7795 ); 7796 } 7797 if (!args.label || typeof args.label !== "string") { 7798 throw new Error( 7799 "The category properties must contain a `label` string." 7800 ); 7801 } 7802 if (!args.description || typeof args.description !== "string") { 7803 throw new Error( 7804 "The category properties must contain a `description` string." 7805 ); 7806 } 7807 if (args.meta !== void 0 && (typeof args.meta !== "object" || Array.isArray(args.meta))) { 7808 throw new Error( 7809 "The category properties should provide a valid `meta` object." 7810 ); 7811 } 7812 const annotations = filterAnnotations(args.meta?.annotations, [ 7813 "serverRegistered", 7814 "clientRegistered" 7815 ]); 7816 if (!annotations.serverRegistered) { 7817 annotations.clientRegistered = true; 7818 } 7819 const meta = { 7820 ...args.meta || {}, 7821 annotations 7822 }; 7823 const category = { 7824 slug, 7825 label: args.label, 7826 description: args.description, 7827 meta 7828 }; 7829 dispatch2({ 7830 type: REGISTER_ABILITY_CATEGORY, 7831 category 7832 }); 7833 }; 7834 } 7835 function unregisterAbilityCategory(slug) { 7836 return { 7837 type: UNREGISTER_ABILITY_CATEGORY, 7838 slug 7839 }; 7840 } 7841 7842 // packages/abilities/build-module/store/selectors.mjs 7843 var selectors_exports = {}; 7844 __export(selectors_exports, { 7845 getAbilities: () => getAbilities, 7846 getAbility: () => getAbility, 7847 getAbilityCategories: () => getAbilityCategories, 7848 getAbilityCategory: () => getAbilityCategory 7849 }); 7850 var import_data2 = __toESM(require_data(), 1); 7851 var getAbilities = (0, import_data2.createSelector)( 7852 (state, { category } = {}) => { 7853 const abilities = Object.values(state.abilitiesByName); 7854 if (category) { 7855 return abilities.filter( 7856 (ability) => ability.category === category 7857 ); 7858 } 7859 return abilities; 7860 }, 7861 (state, { category } = {}) => [ 7862 state.abilitiesByName, 7863 category 7864 ] 7865 ); 7866 function getAbility(state, name) { 7867 return state.abilitiesByName[name]; 7868 } 7869 var getAbilityCategories = (0, import_data2.createSelector)( 7870 (state) => { 7871 return Object.values(state.categoriesBySlug); 7872 }, 7873 (state) => [state.categoriesBySlug] 7874 ); 7875 function getAbilityCategory(state, slug) { 7876 return state.categoriesBySlug[slug]; 7877 } 7878 7879 // packages/abilities/build-module/store/index.mjs 7880 var store = (0, import_data3.createReduxStore)(STORE_NAME, { 7881 reducer: reducer_default, 7882 actions: actions_exports, 7883 selectors: selectors_exports 7884 }); 7885 (0, import_data3.register)(store); 7886 7887 // packages/abilities/build-module/validation.mjs 7888 var import_ajv_draft_04 = __toESM(require_dist(), 1); 7889 var import_ajv_formats = __toESM(require_dist2(), 1); 7890 var ajv = new import_ajv_draft_04.default({ 7891 coerceTypes: false, 7892 // No type coercion - AI should send proper JSON 7893 useDefaults: true, 7894 removeAdditional: false, 7895 // Keep additional properties 7896 allErrors: true, 7897 verbose: true, 7898 allowUnionTypes: true 7899 // Allow anyOf without explicit type 7900 }); 7901 (0, import_ajv_formats.default)(ajv, [ 7902 "date-time", 7903 "email", 7904 "hostname", 7905 "ipv4", 7906 "ipv6", 7907 "uri", 7908 "uuid" 7909 ]); 7910 function formatAjvError(ajvError, param) { 7911 const instancePath = ajvError.instancePath ? ajvError.instancePath.replace(/\//g, "][").replace(/^\]\[/, "[") + "]" : ""; 7912 const fullParam = param + instancePath; 7913 switch (ajvError.keyword) { 7914 case "type": 7915 return `$fullParam} is not of type $ajvError.params.type}.`; 7916 case "required": 7917 return `$ajvError.params.missingProperty} is a required property of $fullParam}.`; 7918 case "additionalProperties": 7919 return `$ajvError.params.additionalProperty} is not a valid property of Object.`; 7920 case "enum": 7921 const enumValues = ajvError.params.allowedValues.map( 7922 (v) => typeof v === "string" ? v : JSON.stringify(v) 7923 ).join(", "); 7924 return ajvError.params.allowedValues.length === 1 ? `$fullParam} is not $enumValues}.` : `$fullParam} is not one of $enumValues}.`; 7925 case "pattern": 7926 return `$fullParam} does not match pattern $ajvError.params.pattern}.`; 7927 case "format": 7928 const format = ajvError.params.format; 7929 const formatMessages = { 7930 email: "Invalid email address.", 7931 "date-time": "Invalid date.", 7932 uuid: `$fullParam} is not a valid UUID.`, 7933 ipv4: `$fullParam} is not a valid IP address.`, 7934 ipv6: `$fullParam} is not a valid IP address.`, 7935 hostname: `$fullParam} is not a valid hostname.`, 7936 uri: `$fullParam} is not a valid URI.` 7937 }; 7938 return formatMessages[format] || `Invalid $format}.`; 7939 case "minimum": 7940 case "exclusiveMinimum": 7941 return ajvError.keyword === "exclusiveMinimum" ? `$fullParam} must be greater than $ajvError.params.limit}` : `$fullParam} must be greater than or equal to $ajvError.params.limit}`; 7942 case "maximum": 7943 case "exclusiveMaximum": 7944 return ajvError.keyword === "exclusiveMaximum" ? `$fullParam} must be less than $ajvError.params.limit}` : `$fullParam} must be less than or equal to $ajvError.params.limit}`; 7945 case "multipleOf": 7946 return `$fullParam} must be a multiple of $ajvError.params.multipleOf}.`; 7947 case "anyOf": 7948 case "oneOf": 7949 return `$fullParam} is invalid (failed $ajvError.keyword} validation).`; 7950 case "minLength": 7951 return `$fullParam} must be at least $ajvError.params.limit} character$ajvError.params.limit === 1 ? "" : "s"} long.`; 7952 case "maxLength": 7953 return `$fullParam} must be at most $ajvError.params.limit} character$ajvError.params.limit === 1 ? "" : "s"} long.`; 7954 case "minItems": 7955 return `$fullParam} must contain at least $ajvError.params.limit} item$ajvError.params.limit === 1 ? "" : "s"}.`; 7956 case "maxItems": 7957 return `$fullParam} must contain at most $ajvError.params.limit} item$ajvError.params.limit === 1 ? "" : "s"}.`; 7958 case "uniqueItems": 7959 return `$fullParam} has duplicate items.`; 7960 case "minProperties": 7961 return `$fullParam} must contain at least $ajvError.params.limit} propert$ajvError.params.limit === 1 ? "y" : "ies"}.`; 7962 case "maxProperties": 7963 return `$fullParam} must contain at most $ajvError.params.limit} propert$ajvError.params.limit === 1 ? "y" : "ies"}.`; 7964 default: 7965 return ajvError.message || `$fullParam} is invalid (failed $ajvError.keyword} validation).`; 7966 } 7967 } 7968 function validateValueFromSchema(value, args, param = "") { 7969 if (!args || typeof args !== "object") { 7970 console.warn(`Schema must be an object. Received $typeof args}.`); 7971 return true; 7972 } 7973 if (!args.type && !args.anyOf && !args.oneOf) { 7974 console.warn( 7975 `The "type" schema keyword for $param || "value"} is required.` 7976 ); 7977 return true; 7978 } 7979 try { 7980 const { default: defaultValue, ...schemaWithoutDefault } = args; 7981 const validate = ajv.compile(schemaWithoutDefault); 7982 const valid = validate(value === void 0 ? defaultValue : value); 7983 if (valid) { 7984 return true; 7985 } 7986 if (validate.errors && validate.errors.length > 0) { 7987 const anyOfError = validate.errors.find( 7988 (e) => e.keyword === "anyOf" || e.keyword === "oneOf" 7989 ); 7990 if (anyOfError) { 7991 return formatAjvError(anyOfError, param); 7992 } 7993 return formatAjvError(validate.errors[0], param); 7994 } 7995 return `$param} is invalid.`; 7996 } catch (error) { 7997 console.error("Schema compilation error:", error); 7998 return "Invalid schema provided for validation."; 7999 } 8000 } 8001 8002 // packages/abilities/build-module/api.mjs 8003 function getAbilities2(args = {}) { 8004 return (0, import_data4.select)(store).getAbilities(args); 8005 } 8006 function getAbility2(name) { 8007 return (0, import_data4.select)(store).getAbility(name); 8008 } 8009 function getAbilityCategories2() { 8010 return (0, import_data4.select)(store).getAbilityCategories(); 8011 } 8012 function getAbilityCategory2(slug) { 8013 return (0, import_data4.select)(store).getAbilityCategory(slug); 8014 } 8015 function registerAbility2(ability) { 8016 (0, import_data4.dispatch)(store).registerAbility(ability); 8017 } 8018 function unregisterAbility2(name) { 8019 (0, import_data4.dispatch)(store).unregisterAbility(name); 8020 } 8021 function registerAbilityCategory2(slug, args) { 8022 (0, import_data4.dispatch)(store).registerAbilityCategory(slug, args); 8023 } 8024 function unregisterAbilityCategory2(slug) { 8025 (0, import_data4.dispatch)(store).unregisterAbilityCategory(slug); 8026 } 8027 async function executeAbility(name, input) { 8028 const ability = getAbility2(name); 8029 if (!ability) { 8030 throw new Error((0, import_i18n2.sprintf)("Ability not found: %s", name)); 8031 } 8032 if (!ability.callback) { 8033 throw new Error( 8034 (0, import_i18n2.sprintf)( 8035 'Ability "%s" is missing callback. Please ensure the ability is properly registered.', 8036 ability.name 8037 ) 8038 ); 8039 } 8040 if (ability.permissionCallback) { 8041 const hasPermission = await ability.permissionCallback(input); 8042 if (!hasPermission) { 8043 const error = new Error( 8044 (0, import_i18n2.sprintf)("Permission denied for ability: %s", ability.name) 8045 ); 8046 error.code = "ability_permission_denied"; 8047 throw error; 8048 } 8049 } 8050 if (ability.input_schema) { 8051 const inputValidation = validateValueFromSchema( 8052 input, 8053 ability.input_schema, 8054 "input" 8055 ); 8056 if (inputValidation !== true) { 8057 const error = new Error( 8058 (0, import_i18n2.sprintf)( 8059 'Ability "%1$s" has invalid input. Reason: %2$s', 8060 ability.name, 8061 inputValidation 8062 ) 8063 ); 8064 error.code = "ability_invalid_input"; 8065 throw error; 8066 } 8067 } 8068 let result; 8069 try { 8070 result = await ability.callback(input); 8071 } catch (error) { 8072 console.error(`Error executing ability $ability.name}:`, error); 8073 throw error; 8074 } 8075 if (ability.output_schema) { 8076 const outputValidation = validateValueFromSchema( 8077 result, 8078 ability.output_schema, 8079 "output" 8080 ); 8081 if (outputValidation !== true) { 8082 const error = new Error( 8083 (0, import_i18n2.sprintf)( 8084 'Ability "%1$s" has invalid output. Reason: %2$s', 8085 ability.name, 8086 outputValidation 8087 ) 8088 ); 8089 error.code = "ability_invalid_output"; 8090 throw error; 8091 } 8092 } 8093 return result; 8094 } 8095 export { 8096 executeAbility, 8097 getAbilities2 as getAbilities, 8098 getAbility2 as getAbility, 8099 getAbilityCategories2 as getAbilityCategories, 8100 getAbilityCategory2 as getAbilityCategory, 8101 registerAbility2 as registerAbility, 8102 registerAbilityCategory2 as registerAbilityCategory, 8103 store, 8104 unregisterAbility2 as unregisterAbility, 8105 unregisterAbilityCategory2 as unregisterAbilityCategory, 8106 validateValueFromSchema 8107 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Oct 14 08:20:33 2026 | Cross-referenced by PHPXref |