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