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