@spooky-sync/cli 0.0.1-canary.260 → 0.0.1-canary.261

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/devtools-mcp/index.js +844 -814
  2. package/package.json +6 -6
@@ -16367,8 +16367,8 @@ var scope = {};
16367
16367
  var util = {};
16368
16368
  Object.defineProperty(util, "__esModule", { value: true });
16369
16369
  util.checkStrictMode = util.getErrorPath = util.Type = util.useFunc = util.setEvaluated = util.evaluatedPropsToName = util.mergeEvaluated = util.eachItem = util.unescapeJsonPointer = util.escapeJsonPointer = util.escapeFragment = util.unescapeFragment = util.schemaRefOrVal = util.schemaHasRulesButRef = util.schemaHasRules = util.checkUnknownRules = util.alwaysValidSchema = util.toHash = void 0;
16370
- const codegen_1$v = codegen;
16371
- const code_1$a = code$1;
16370
+ const codegen_1$q = codegen;
16371
+ const code_1$9 = code$1;
16372
16372
  function toHash(arr) {
16373
16373
  const hash = {};
16374
16374
  for (const item of arr)
@@ -16421,9 +16421,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
16421
16421
  if (typeof schema == "number" || typeof schema == "boolean")
16422
16422
  return schema;
16423
16423
  if (typeof schema == "string")
16424
- return (0, codegen_1$v._)`${schema}`;
16424
+ return (0, codegen_1$q._)`${schema}`;
16425
16425
  }
16426
- return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
16426
+ return (0, codegen_1$q._)`${topSchemaRef}${schemaPath}${(0, codegen_1$q.getProperty)(keyword2)}`;
16427
16427
  }
16428
16428
  util.schemaRefOrVal = schemaRefOrVal;
16429
16429
  function unescapeFragment(str) {
@@ -16455,20 +16455,20 @@ function eachItem(xs, f) {
16455
16455
  util.eachItem = eachItem;
16456
16456
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
16457
16457
  return (gen, from, to, toName) => {
16458
- const res = to === void 0 ? from : to instanceof codegen_1$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
16459
- return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
16458
+ const res = to === void 0 ? from : to instanceof codegen_1$q.Name ? (from instanceof codegen_1$q.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$q.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
16459
+ return toName === codegen_1$q.Name && !(res instanceof codegen_1$q.Name) ? resultToName(gen, res) : res;
16460
16460
  };
16461
16461
  }
16462
16462
  util.mergeEvaluated = {
16463
16463
  props: makeMergeEvaluated({
16464
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
16465
- gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`Object.assign(${to}, ${from})`));
16464
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => {
16465
+ gen.if((0, codegen_1$q._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$q._)`${to} || {}`).code((0, codegen_1$q._)`Object.assign(${to}, ${from})`));
16466
16466
  }),
16467
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
16467
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => {
16468
16468
  if (from === true) {
16469
16469
  gen.assign(to, true);
16470
16470
  } else {
16471
- gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
16471
+ gen.assign(to, (0, codegen_1$q._)`${to} || {}`);
16472
16472
  setEvaluated(gen, to, from);
16473
16473
  }
16474
16474
  }),
@@ -16476,8 +16476,8 @@ util.mergeEvaluated = {
16476
16476
  resultToName: evaluatedPropsToName
16477
16477
  }),
16478
16478
  items: makeMergeEvaluated({
16479
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
16480
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${to} > ${from} ? ${to} : ${from}`)),
16479
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$q._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
16480
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$q._)`${to} > ${from} ? ${to} : ${from}`)),
16481
16481
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
16482
16482
  resultToName: (gen, items2) => gen.var("items", items2)
16483
16483
  })
@@ -16485,21 +16485,21 @@ util.mergeEvaluated = {
16485
16485
  function evaluatedPropsToName(gen, ps) {
16486
16486
  if (ps === true)
16487
16487
  return gen.var("props", true);
16488
- const props = gen.var("props", (0, codegen_1$v._)`{}`);
16488
+ const props = gen.var("props", (0, codegen_1$q._)`{}`);
16489
16489
  if (ps !== void 0)
16490
16490
  setEvaluated(gen, props, ps);
16491
16491
  return props;
16492
16492
  }
16493
16493
  util.evaluatedPropsToName = evaluatedPropsToName;
16494
16494
  function setEvaluated(gen, props, ps) {
16495
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
16495
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$q._)`${props}${(0, codegen_1$q.getProperty)(p)}`, true));
16496
16496
  }
16497
16497
  util.setEvaluated = setEvaluated;
16498
16498
  const snippets = {};
16499
16499
  function useFunc(gen, f) {
16500
16500
  return gen.scopeValue("func", {
16501
16501
  ref: f,
16502
- code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
16502
+ code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
16503
16503
  });
16504
16504
  }
16505
16505
  util.useFunc = useFunc;
@@ -16509,11 +16509,11 @@ var Type;
16509
16509
  Type2[Type2["Str"] = 1] = "Str";
16510
16510
  })(Type || (util.Type = Type = {}));
16511
16511
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
16512
- if (dataProp instanceof codegen_1$v.Name) {
16512
+ if (dataProp instanceof codegen_1$q.Name) {
16513
16513
  const isNumber = dataPropType === Type.Num;
16514
- return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
16514
+ return jsPropertySyntax ? isNumber ? (0, codegen_1$q._)`"[" + ${dataProp} + "]"` : (0, codegen_1$q._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$q._)`"/" + ${dataProp}` : (0, codegen_1$q._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
16515
16515
  }
16516
- return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
16516
+ return jsPropertySyntax ? (0, codegen_1$q.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
16517
16517
  }
16518
16518
  util.getErrorPath = getErrorPath;
16519
16519
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -16527,35 +16527,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
16527
16527
  util.checkStrictMode = checkStrictMode;
16528
16528
  var names$1 = {};
16529
16529
  Object.defineProperty(names$1, "__esModule", { value: true });
16530
- const codegen_1$u = codegen;
16530
+ const codegen_1$p = codegen;
16531
16531
  const names = {
16532
16532
  // validation function arguments
16533
- data: new codegen_1$u.Name("data"),
16533
+ data: new codegen_1$p.Name("data"),
16534
16534
  // data passed to validation function
16535
16535
  // args passed from referencing schema
16536
- valCxt: new codegen_1$u.Name("valCxt"),
16536
+ valCxt: new codegen_1$p.Name("valCxt"),
16537
16537
  // validation/data context - should not be used directly, it is destructured to the names below
16538
- instancePath: new codegen_1$u.Name("instancePath"),
16539
- parentData: new codegen_1$u.Name("parentData"),
16540
- parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
16541
- rootData: new codegen_1$u.Name("rootData"),
16538
+ instancePath: new codegen_1$p.Name("instancePath"),
16539
+ parentData: new codegen_1$p.Name("parentData"),
16540
+ parentDataProperty: new codegen_1$p.Name("parentDataProperty"),
16541
+ rootData: new codegen_1$p.Name("rootData"),
16542
16542
  // root data - same as the data passed to the first/top validation function
16543
- dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
16543
+ dynamicAnchors: new codegen_1$p.Name("dynamicAnchors"),
16544
16544
  // used to support recursiveRef and dynamicRef
16545
16545
  // function scoped variables
16546
- vErrors: new codegen_1$u.Name("vErrors"),
16546
+ vErrors: new codegen_1$p.Name("vErrors"),
16547
16547
  // null or array of validation errors
16548
- errors: new codegen_1$u.Name("errors"),
16548
+ errors: new codegen_1$p.Name("errors"),
16549
16549
  // counter of validation errors
16550
- this: new codegen_1$u.Name("this"),
16550
+ this: new codegen_1$p.Name("this"),
16551
16551
  // "globals"
16552
- self: new codegen_1$u.Name("self"),
16553
- scope: new codegen_1$u.Name("scope"),
16552
+ self: new codegen_1$p.Name("self"),
16553
+ scope: new codegen_1$p.Name("scope"),
16554
16554
  // JTD serialize/parse name for JSON string and position
16555
- json: new codegen_1$u.Name("json"),
16556
- jsonPos: new codegen_1$u.Name("jsonPos"),
16557
- jsonLen: new codegen_1$u.Name("jsonLen"),
16558
- jsonPart: new codegen_1$u.Name("jsonPart")
16555
+ json: new codegen_1$p.Name("json"),
16556
+ jsonPos: new codegen_1$p.Name("jsonPos"),
16557
+ jsonLen: new codegen_1$p.Name("jsonLen"),
16558
+ jsonPart: new codegen_1$p.Name("jsonPart")
16559
16559
  };
16560
16560
  names$1.default = names;
16561
16561
  (function(exports) {
@@ -16675,49 +16675,55 @@ names$1.default = names;
16675
16675
  keyValues.push([E.propertyName, propertyName]);
16676
16676
  }
16677
16677
  })(errors);
16678
- Object.defineProperty(boolSchema, "__esModule", { value: true });
16679
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
16680
- const errors_1$3 = errors;
16681
- const codegen_1$t = codegen;
16682
- const names_1$6 = names$1;
16683
- const boolError = {
16684
- message: "boolean schema is false"
16685
- };
16686
- function topBoolOrEmptySchema(it) {
16687
- const { gen, schema, validateName } = it;
16688
- if (schema === false) {
16689
- falseSchemaError(it, false);
16690
- } else if (typeof schema == "object" && schema.$async === true) {
16691
- gen.return(names_1$6.default.data);
16692
- } else {
16693
- gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
16694
- gen.return(true);
16678
+ var hasRequiredBoolSchema;
16679
+ function requireBoolSchema() {
16680
+ if (hasRequiredBoolSchema) return boolSchema;
16681
+ hasRequiredBoolSchema = 1;
16682
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
16683
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
16684
+ const errors_12 = errors;
16685
+ const codegen_12 = codegen;
16686
+ const names_12 = names$1;
16687
+ const boolError = {
16688
+ message: "boolean schema is false"
16689
+ };
16690
+ function topBoolOrEmptySchema(it) {
16691
+ const { gen, schema, validateName } = it;
16692
+ if (schema === false) {
16693
+ falseSchemaError(it, false);
16694
+ } else if (typeof schema == "object" && schema.$async === true) {
16695
+ gen.return(names_12.default.data);
16696
+ } else {
16697
+ gen.assign((0, codegen_12._)`${validateName}.errors`, null);
16698
+ gen.return(true);
16699
+ }
16695
16700
  }
16696
- }
16697
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
16698
- function boolOrEmptySchema(it, valid) {
16699
- const { gen, schema } = it;
16700
- if (schema === false) {
16701
- gen.var(valid, false);
16702
- falseSchemaError(it);
16703
- } else {
16704
- gen.var(valid, true);
16701
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
16702
+ function boolOrEmptySchema(it, valid) {
16703
+ const { gen, schema } = it;
16704
+ if (schema === false) {
16705
+ gen.var(valid, false);
16706
+ falseSchemaError(it);
16707
+ } else {
16708
+ gen.var(valid, true);
16709
+ }
16705
16710
  }
16706
- }
16707
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
16708
- function falseSchemaError(it, overrideAllErrors) {
16709
- const { gen, data } = it;
16710
- const cxt = {
16711
- gen,
16712
- keyword: "false schema",
16713
- data,
16714
- schema: false,
16715
- schemaCode: false,
16716
- schemaValue: false,
16717
- params: {},
16718
- it
16719
- };
16720
- (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
16711
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
16712
+ function falseSchemaError(it, overrideAllErrors) {
16713
+ const { gen, data } = it;
16714
+ const cxt = {
16715
+ gen,
16716
+ keyword: "false schema",
16717
+ data,
16718
+ schema: false,
16719
+ schemaCode: false,
16720
+ schemaValue: false,
16721
+ params: {},
16722
+ it
16723
+ };
16724
+ (0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
16725
+ }
16726
+ return boolSchema;
16721
16727
  }
16722
16728
  var dataType = {};
16723
16729
  var rules = {};
@@ -16765,10 +16771,10 @@ applicability.shouldUseRule = shouldUseRule;
16765
16771
  Object.defineProperty(dataType, "__esModule", { value: true });
16766
16772
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
16767
16773
  const rules_1 = rules;
16768
- const applicability_1$1 = applicability;
16769
- const errors_1$2 = errors;
16770
- const codegen_1$s = codegen;
16771
- const util_1$r = util;
16774
+ const applicability_1 = applicability;
16775
+ const errors_1 = errors;
16776
+ const codegen_1$o = codegen;
16777
+ const util_1$o = util;
16772
16778
  var DataType;
16773
16779
  (function(DataType2) {
16774
16780
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -16800,7 +16806,7 @@ dataType.getJSONTypes = getJSONTypes;
16800
16806
  function coerceAndCheckDataType(it, types2) {
16801
16807
  const { gen, data, opts } = it;
16802
16808
  const coerceTo = coerceToTypes(types2, opts.coerceTypes);
16803
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
16809
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
16804
16810
  if (checkTypes) {
16805
16811
  const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
16806
16812
  gen.if(wrongType, () => {
@@ -16819,12 +16825,12 @@ function coerceToTypes(types2, coerceTypes) {
16819
16825
  }
16820
16826
  function coerceData(it, types2, coerceTo) {
16821
16827
  const { gen, data, opts } = it;
16822
- const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
16823
- const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
16828
+ const dataType2 = gen.let("dataType", (0, codegen_1$o._)`typeof ${data}`);
16829
+ const coerced = gen.let("coerced", (0, codegen_1$o._)`undefined`);
16824
16830
  if (opts.coerceTypes === "array") {
16825
- gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$s._)`${data}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
16831
+ gen.if((0, codegen_1$o._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$o._)`${data}[0]`).assign(dataType2, (0, codegen_1$o._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
16826
16832
  }
16827
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
16833
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
16828
16834
  for (const t of coerceTo) {
16829
16835
  if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
16830
16836
  coerceSpecificType(t);
@@ -16833,63 +16839,63 @@ function coerceData(it, types2, coerceTo) {
16833
16839
  gen.else();
16834
16840
  reportTypeError(it);
16835
16841
  gen.endIf();
16836
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
16842
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
16837
16843
  gen.assign(data, coerced);
16838
16844
  assignParentData(it, coerced);
16839
16845
  });
16840
16846
  function coerceSpecificType(t) {
16841
16847
  switch (t) {
16842
16848
  case "string":
16843
- gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data}`).elseIf((0, codegen_1$s._)`${data} === null`).assign(coerced, (0, codegen_1$s._)`""`);
16849
+ gen.elseIf((0, codegen_1$o._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$o._)`"" + ${data}`).elseIf((0, codegen_1$o._)`${data} === null`).assign(coerced, (0, codegen_1$o._)`""`);
16844
16850
  return;
16845
16851
  case "number":
16846
- gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
16847
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
16852
+ gen.elseIf((0, codegen_1$o._)`${dataType2} == "boolean" || ${data} === null
16853
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$o._)`+${data}`);
16848
16854
  return;
16849
16855
  case "integer":
16850
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
16851
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
16856
+ gen.elseIf((0, codegen_1$o._)`${dataType2} === "boolean" || ${data} === null
16857
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$o._)`+${data}`);
16852
16858
  return;
16853
16859
  case "boolean":
16854
- gen.elseIf((0, codegen_1$s._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
16860
+ gen.elseIf((0, codegen_1$o._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$o._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
16855
16861
  return;
16856
16862
  case "null":
16857
- gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
16863
+ gen.elseIf((0, codegen_1$o._)`${data} === "" || ${data} === 0 || ${data} === false`);
16858
16864
  gen.assign(coerced, null);
16859
16865
  return;
16860
16866
  case "array":
16861
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
16862
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
16867
+ gen.elseIf((0, codegen_1$o._)`${dataType2} === "string" || ${dataType2} === "number"
16868
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$o._)`[${data}]`);
16863
16869
  }
16864
16870
  }
16865
16871
  }
16866
16872
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
16867
- gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
16873
+ gen.if((0, codegen_1$o._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$o._)`${parentData}[${parentDataProperty}]`, expr));
16868
16874
  }
16869
16875
  function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
16870
- const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
16876
+ const EQ = correct === DataType.Correct ? codegen_1$o.operators.EQ : codegen_1$o.operators.NEQ;
16871
16877
  let cond;
16872
16878
  switch (dataType2) {
16873
16879
  case "null":
16874
- return (0, codegen_1$s._)`${data} ${EQ} null`;
16880
+ return (0, codegen_1$o._)`${data} ${EQ} null`;
16875
16881
  case "array":
16876
- cond = (0, codegen_1$s._)`Array.isArray(${data})`;
16882
+ cond = (0, codegen_1$o._)`Array.isArray(${data})`;
16877
16883
  break;
16878
16884
  case "object":
16879
- cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
16885
+ cond = (0, codegen_1$o._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
16880
16886
  break;
16881
16887
  case "integer":
16882
- cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
16888
+ cond = numCond((0, codegen_1$o._)`!(${data} % 1) && !isNaN(${data})`);
16883
16889
  break;
16884
16890
  case "number":
16885
16891
  cond = numCond();
16886
16892
  break;
16887
16893
  default:
16888
- return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
16894
+ return (0, codegen_1$o._)`typeof ${data} ${EQ} ${dataType2}`;
16889
16895
  }
16890
- return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
16891
- function numCond(_cond = codegen_1$s.nil) {
16892
- return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data})` : codegen_1$s.nil);
16896
+ return correct === DataType.Correct ? cond : (0, codegen_1$o.not)(cond);
16897
+ function numCond(_cond = codegen_1$o.nil) {
16898
+ return (0, codegen_1$o.and)((0, codegen_1$o._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$o._)`isFinite(${data})` : codegen_1$o.nil);
16893
16899
  }
16894
16900
  }
16895
16901
  dataType.checkDataType = checkDataType;
@@ -16898,35 +16904,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
16898
16904
  return checkDataType(dataTypes[0], data, strictNums, correct);
16899
16905
  }
16900
16906
  let cond;
16901
- const types2 = (0, util_1$r.toHash)(dataTypes);
16907
+ const types2 = (0, util_1$o.toHash)(dataTypes);
16902
16908
  if (types2.array && types2.object) {
16903
- const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
16904
- cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
16909
+ const notObj = (0, codegen_1$o._)`typeof ${data} != "object"`;
16910
+ cond = types2.null ? notObj : (0, codegen_1$o._)`!${data} || ${notObj}`;
16905
16911
  delete types2.null;
16906
16912
  delete types2.array;
16907
16913
  delete types2.object;
16908
16914
  } else {
16909
- cond = codegen_1$s.nil;
16915
+ cond = codegen_1$o.nil;
16910
16916
  }
16911
16917
  if (types2.number)
16912
16918
  delete types2.integer;
16913
16919
  for (const t in types2)
16914
- cond = (0, codegen_1$s.and)(cond, checkDataType(t, data, strictNums, correct));
16920
+ cond = (0, codegen_1$o.and)(cond, checkDataType(t, data, strictNums, correct));
16915
16921
  return cond;
16916
16922
  }
16917
16923
  dataType.checkDataTypes = checkDataTypes;
16918
16924
  const typeError = {
16919
16925
  message: ({ schema }) => `must be ${schema}`,
16920
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
16926
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$o._)`{type: ${schema}}` : (0, codegen_1$o._)`{type: ${schemaValue}}`
16921
16927
  };
16922
16928
  function reportTypeError(it) {
16923
16929
  const cxt = getTypeErrorContext(it);
16924
- (0, errors_1$2.reportError)(cxt, typeError);
16930
+ (0, errors_1.reportError)(cxt, typeError);
16925
16931
  }
16926
16932
  dataType.reportTypeError = reportTypeError;
16927
16933
  function getTypeErrorContext(it) {
16928
16934
  const { gen, data, schema } = it;
16929
- const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
16935
+ const schemaCode = (0, util_1$o.schemaRefOrVal)(it, schema, "type");
16930
16936
  return {
16931
16937
  gen,
16932
16938
  keyword: "type",
@@ -16940,54 +16946,60 @@ function getTypeErrorContext(it) {
16940
16946
  };
16941
16947
  }
16942
16948
  var defaults = {};
16943
- Object.defineProperty(defaults, "__esModule", { value: true });
16944
- defaults.assignDefaults = void 0;
16945
- const codegen_1$r = codegen;
16946
- const util_1$q = util;
16947
- function assignDefaults(it, ty) {
16948
- const { properties: properties2, items: items2 } = it.schema;
16949
- if (ty === "object" && properties2) {
16950
- for (const key in properties2) {
16951
- assignDefault(it, key, properties2[key].default);
16952
- }
16953
- } else if (ty === "array" && Array.isArray(items2)) {
16954
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
16955
- }
16956
- }
16957
- defaults.assignDefaults = assignDefaults;
16958
- function assignDefault(it, prop, defaultValue) {
16959
- const { gen, compositeRule, data, opts } = it;
16960
- if (defaultValue === void 0)
16961
- return;
16962
- const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
16963
- if (compositeRule) {
16964
- (0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
16965
- return;
16949
+ var hasRequiredDefaults;
16950
+ function requireDefaults() {
16951
+ if (hasRequiredDefaults) return defaults;
16952
+ hasRequiredDefaults = 1;
16953
+ Object.defineProperty(defaults, "__esModule", { value: true });
16954
+ defaults.assignDefaults = void 0;
16955
+ const codegen_12 = codegen;
16956
+ const util_12 = util;
16957
+ function assignDefaults(it, ty) {
16958
+ const { properties: properties2, items: items2 } = it.schema;
16959
+ if (ty === "object" && properties2) {
16960
+ for (const key in properties2) {
16961
+ assignDefault(it, key, properties2[key].default);
16962
+ }
16963
+ } else if (ty === "array" && Array.isArray(items2)) {
16964
+ items2.forEach((sch, i) => assignDefault(it, i, sch.default));
16965
+ }
16966
16966
  }
16967
- let condition = (0, codegen_1$r._)`${childData} === undefined`;
16968
- if (opts.useDefaults === "empty") {
16969
- condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
16967
+ defaults.assignDefaults = assignDefaults;
16968
+ function assignDefault(it, prop, defaultValue) {
16969
+ const { gen, compositeRule, data, opts } = it;
16970
+ if (defaultValue === void 0)
16971
+ return;
16972
+ const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
16973
+ if (compositeRule) {
16974
+ (0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
16975
+ return;
16976
+ }
16977
+ let condition = (0, codegen_12._)`${childData} === undefined`;
16978
+ if (opts.useDefaults === "empty") {
16979
+ condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
16980
+ }
16981
+ gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
16970
16982
  }
16971
- gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
16983
+ return defaults;
16972
16984
  }
16973
16985
  var keyword = {};
16974
16986
  var code = {};
16975
16987
  Object.defineProperty(code, "__esModule", { value: true });
16976
16988
  code.validateUnion = code.validateArray = code.usePattern = code.callValidateCode = code.schemaProperties = code.allSchemaProperties = code.noPropertyInData = code.propertyInData = code.isOwnProperty = code.hasPropFunc = code.reportMissingProp = code.checkMissingProp = code.checkReportMissingProp = void 0;
16977
- const codegen_1$q = codegen;
16978
- const util_1$p = util;
16979
- const names_1$5 = names$1;
16989
+ const codegen_1$n = codegen;
16990
+ const util_1$n = util;
16991
+ const names_1$3 = names$1;
16980
16992
  const util_2$1 = util;
16981
16993
  function checkReportMissingProp(cxt, prop) {
16982
16994
  const { gen, data, it } = cxt;
16983
16995
  gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
16984
- cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
16996
+ cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
16985
16997
  cxt.error();
16986
16998
  });
16987
16999
  }
16988
17000
  code.checkReportMissingProp = checkReportMissingProp;
16989
17001
  function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
16990
- return (0, codegen_1$q.or)(...properties2.map((prop) => (0, codegen_1$q.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$q._)`${missing} = ${prop}`)));
17002
+ return (0, codegen_1$n.or)(...properties2.map((prop) => (0, codegen_1$n.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$n._)`${missing} = ${prop}`)));
16991
17003
  }
16992
17004
  code.checkMissingProp = checkMissingProp;
16993
17005
  function reportMissingProp(cxt, missing) {
@@ -16999,22 +17011,22 @@ function hasPropFunc(gen) {
16999
17011
  return gen.scopeValue("func", {
17000
17012
  // eslint-disable-next-line @typescript-eslint/unbound-method
17001
17013
  ref: Object.prototype.hasOwnProperty,
17002
- code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
17014
+ code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
17003
17015
  });
17004
17016
  }
17005
17017
  code.hasPropFunc = hasPropFunc;
17006
17018
  function isOwnProperty(gen, data, property) {
17007
- return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
17019
+ return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
17008
17020
  }
17009
17021
  code.isOwnProperty = isOwnProperty;
17010
17022
  function propertyInData(gen, data, property, ownProperties) {
17011
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
17012
- return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
17023
+ const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} !== undefined`;
17024
+ return ownProperties ? (0, codegen_1$n._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
17013
17025
  }
17014
17026
  code.propertyInData = propertyInData;
17015
17027
  function noPropertyInData(gen, data, property, ownProperties) {
17016
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
17017
- return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond;
17028
+ const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} === undefined`;
17029
+ return ownProperties ? (0, codegen_1$n.or)(cond, (0, codegen_1$n.not)(isOwnProperty(gen, data, property))) : cond;
17018
17030
  }
17019
17031
  code.noPropertyInData = noPropertyInData;
17020
17032
  function allSchemaProperties(schemaMap) {
@@ -17022,24 +17034,24 @@ function allSchemaProperties(schemaMap) {
17022
17034
  }
17023
17035
  code.allSchemaProperties = allSchemaProperties;
17024
17036
  function schemaProperties(it, schemaMap) {
17025
- return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$p.alwaysValidSchema)(it, schemaMap[p]));
17037
+ return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$n.alwaysValidSchema)(it, schemaMap[p]));
17026
17038
  }
17027
17039
  code.schemaProperties = schemaProperties;
17028
17040
  function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
17029
- const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
17041
+ const dataAndSchema = passSchema ? (0, codegen_1$n._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
17030
17042
  const valCxt = [
17031
- [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
17032
- [names_1$5.default.parentData, it.parentData],
17033
- [names_1$5.default.parentDataProperty, it.parentDataProperty],
17034
- [names_1$5.default.rootData, names_1$5.default.rootData]
17043
+ [names_1$3.default.instancePath, (0, codegen_1$n.strConcat)(names_1$3.default.instancePath, errorPath)],
17044
+ [names_1$3.default.parentData, it.parentData],
17045
+ [names_1$3.default.parentDataProperty, it.parentDataProperty],
17046
+ [names_1$3.default.rootData, names_1$3.default.rootData]
17035
17047
  ];
17036
17048
  if (it.opts.dynamicRef)
17037
- valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
17038
- const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
17039
- return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
17049
+ valCxt.push([names_1$3.default.dynamicAnchors, names_1$3.default.dynamicAnchors]);
17050
+ const args = (0, codegen_1$n._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
17051
+ return context !== codegen_1$n.nil ? (0, codegen_1$n._)`${func}.call(${context}, ${args})` : (0, codegen_1$n._)`${func}(${args})`;
17040
17052
  }
17041
17053
  code.callValidateCode = callValidateCode;
17042
- const newRegExp = (0, codegen_1$q._)`new RegExp`;
17054
+ const newRegExp = (0, codegen_1$n._)`new RegExp`;
17043
17055
  function usePattern({ gen, it: { opts } }, pattern2) {
17044
17056
  const u = opts.unicodeRegExp ? "u" : "";
17045
17057
  const { regExp } = opts.code;
@@ -17047,7 +17059,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
17047
17059
  return gen.scopeValue("pattern", {
17048
17060
  key: rx.toString(),
17049
17061
  ref: rx,
17050
- code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
17062
+ code: (0, codegen_1$n._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
17051
17063
  });
17052
17064
  }
17053
17065
  code.usePattern = usePattern;
@@ -17063,14 +17075,14 @@ function validateArray(cxt) {
17063
17075
  validateItems(() => gen.break());
17064
17076
  return valid;
17065
17077
  function validateItems(notValid) {
17066
- const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
17078
+ const len = gen.const("len", (0, codegen_1$n._)`${data}.length`);
17067
17079
  gen.forRange("i", 0, len, (i) => {
17068
17080
  cxt.subschema({
17069
17081
  keyword: keyword2,
17070
17082
  dataProp: i,
17071
- dataPropType: util_1$p.Type.Num
17083
+ dataPropType: util_1$n.Type.Num
17072
17084
  }, valid);
17073
- gen.if((0, codegen_1$q.not)(valid), notValid);
17085
+ gen.if((0, codegen_1$n.not)(valid), notValid);
17074
17086
  });
17075
17087
  }
17076
17088
  }
@@ -17079,7 +17091,7 @@ function validateUnion(cxt) {
17079
17091
  const { gen, schema, keyword: keyword2, it } = cxt;
17080
17092
  if (!Array.isArray(schema))
17081
17093
  throw new Error("ajv implementation error");
17082
- const alwaysValid = schema.some((sch) => (0, util_1$p.alwaysValidSchema)(it, sch));
17094
+ const alwaysValid = schema.some((sch) => (0, util_1$n.alwaysValidSchema)(it, sch));
17083
17095
  if (alwaysValid && !it.opts.unevaluated)
17084
17096
  return;
17085
17097
  const valid = gen.let("valid", false);
@@ -17090,202 +17102,214 @@ function validateUnion(cxt) {
17090
17102
  schemaProp: i,
17091
17103
  compositeRule: true
17092
17104
  }, schValid);
17093
- gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
17105
+ gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
17094
17106
  const merged = cxt.mergeValidEvaluated(schCxt, schValid);
17095
17107
  if (!merged)
17096
- gen.if((0, codegen_1$q.not)(valid));
17108
+ gen.if((0, codegen_1$n.not)(valid));
17097
17109
  }));
17098
17110
  cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
17099
17111
  }
17100
17112
  code.validateUnion = validateUnion;
17101
- Object.defineProperty(keyword, "__esModule", { value: true });
17102
- keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
17103
- const codegen_1$p = codegen;
17104
- const names_1$4 = names$1;
17105
- const code_1$9 = code;
17106
- const errors_1$1 = errors;
17107
- function macroKeywordCode(cxt, def2) {
17108
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
17109
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
17110
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
17111
- if (it.opts.validateSchema !== false)
17112
- it.self.validateSchema(macroSchema, true);
17113
- const valid = gen.name("valid");
17114
- cxt.subschema({
17115
- schema: macroSchema,
17116
- schemaPath: codegen_1$p.nil,
17117
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
17118
- topSchemaRef: schemaRef,
17119
- compositeRule: true
17120
- }, valid);
17121
- cxt.pass(valid, () => cxt.error(true));
17122
- }
17123
- keyword.macroKeywordCode = macroKeywordCode;
17124
- function funcKeywordCode(cxt, def2) {
17125
- var _a;
17126
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
17127
- checkAsyncKeyword(it, def2);
17128
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
17129
- const validateRef = useKeyword(gen, keyword2, validate2);
17130
- const valid = gen.let("valid");
17131
- cxt.block$data(valid, validateKeyword);
17132
- cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
17133
- function validateKeyword() {
17134
- if (def2.errors === false) {
17135
- assignValid();
17136
- if (def2.modifying)
17137
- modifyData(cxt);
17138
- reportErrs(() => cxt.error());
17139
- } else {
17140
- const ruleErrs = def2.async ? validateAsync() : validateSync();
17141
- if (def2.modifying)
17142
- modifyData(cxt);
17143
- reportErrs(() => addErrs(cxt, ruleErrs));
17144
- }
17145
- }
17146
- function validateAsync() {
17147
- const ruleErrs = gen.let("ruleErrs", null);
17148
- gen.try(() => assignValid((0, codegen_1$p._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1$p._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$p._)`${e}.errors`), () => gen.throw(e)));
17149
- return ruleErrs;
17150
- }
17151
- function validateSync() {
17152
- const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
17153
- gen.assign(validateErrs, null);
17154
- assignValid(codegen_1$p.nil);
17155
- return validateErrs;
17156
- }
17157
- function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
17158
- const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
17159
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
17160
- gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
17161
- }
17162
- function reportErrs(errors2) {
17163
- var _a2;
17164
- gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
17165
- }
17166
- }
17167
- keyword.funcKeywordCode = funcKeywordCode;
17168
- function modifyData(cxt) {
17169
- const { gen, data, it } = cxt;
17170
- gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
17171
- }
17172
- function addErrs(cxt, errs) {
17173
- const { gen } = cxt;
17174
- gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
17175
- gen.assign(names_1$4.default.vErrors, (0, codegen_1$p._)`${names_1$4.default.vErrors} === null ? ${errs} : ${names_1$4.default.vErrors}.concat(${errs})`).assign(names_1$4.default.errors, (0, codegen_1$p._)`${names_1$4.default.vErrors}.length`);
17176
- (0, errors_1$1.extendErrors)(cxt);
17177
- }, () => cxt.error());
17178
- }
17179
- function checkAsyncKeyword({ schemaEnv }, def2) {
17180
- if (def2.async && !schemaEnv.$async)
17181
- throw new Error("async keyword in sync schema");
17182
- }
17183
- function useKeyword(gen, keyword2, result) {
17184
- if (result === void 0)
17185
- throw new Error(`keyword "${keyword2}" failed to compile`);
17186
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
17187
- }
17188
- function validSchemaType(schema, schemaType, allowUndefined = false) {
17189
- 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");
17190
- }
17191
- keyword.validSchemaType = validSchemaType;
17192
- function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
17193
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
17194
- throw new Error("ajv implementation error");
17113
+ var hasRequiredKeyword;
17114
+ function requireKeyword() {
17115
+ if (hasRequiredKeyword) return keyword;
17116
+ hasRequiredKeyword = 1;
17117
+ Object.defineProperty(keyword, "__esModule", { value: true });
17118
+ keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
17119
+ const codegen_12 = codegen;
17120
+ const names_12 = names$1;
17121
+ const code_12 = code;
17122
+ const errors_12 = errors;
17123
+ function macroKeywordCode(cxt, def2) {
17124
+ const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
17125
+ const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
17126
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
17127
+ if (it.opts.validateSchema !== false)
17128
+ it.self.validateSchema(macroSchema, true);
17129
+ const valid = gen.name("valid");
17130
+ cxt.subschema({
17131
+ schema: macroSchema,
17132
+ schemaPath: codegen_12.nil,
17133
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
17134
+ topSchemaRef: schemaRef,
17135
+ compositeRule: true
17136
+ }, valid);
17137
+ cxt.pass(valid, () => cxt.error(true));
17195
17138
  }
17196
- const deps = def2.dependencies;
17197
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
17198
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
17139
+ keyword.macroKeywordCode = macroKeywordCode;
17140
+ function funcKeywordCode(cxt, def2) {
17141
+ var _a;
17142
+ const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
17143
+ checkAsyncKeyword(it, def2);
17144
+ const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
17145
+ const validateRef = useKeyword(gen, keyword2, validate2);
17146
+ const valid = gen.let("valid");
17147
+ cxt.block$data(valid, validateKeyword);
17148
+ cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
17149
+ function validateKeyword() {
17150
+ if (def2.errors === false) {
17151
+ assignValid();
17152
+ if (def2.modifying)
17153
+ modifyData(cxt);
17154
+ reportErrs(() => cxt.error());
17155
+ } else {
17156
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
17157
+ if (def2.modifying)
17158
+ modifyData(cxt);
17159
+ reportErrs(() => addErrs(cxt, ruleErrs));
17160
+ }
17161
+ }
17162
+ function validateAsync() {
17163
+ const ruleErrs = gen.let("ruleErrs", null);
17164
+ gen.try(() => assignValid((0, codegen_12._)`await `), (e) => gen.assign(valid, false).if((0, codegen_12._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_12._)`${e}.errors`), () => gen.throw(e)));
17165
+ return ruleErrs;
17166
+ }
17167
+ function validateSync() {
17168
+ const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
17169
+ gen.assign(validateErrs, null);
17170
+ assignValid(codegen_12.nil);
17171
+ return validateErrs;
17172
+ }
17173
+ function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
17174
+ const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
17175
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
17176
+ gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
17177
+ }
17178
+ function reportErrs(errors2) {
17179
+ var _a2;
17180
+ gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
17181
+ }
17199
17182
  }
17200
- if (def2.validateSchema) {
17201
- const valid = def2.validateSchema(schema[keyword2]);
17202
- if (!valid) {
17203
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
17204
- if (opts.validateSchema === "log")
17205
- self.logger.error(msg);
17206
- else
17207
- throw new Error(msg);
17183
+ keyword.funcKeywordCode = funcKeywordCode;
17184
+ function modifyData(cxt) {
17185
+ const { gen, data, it } = cxt;
17186
+ gen.if(it.parentData, () => gen.assign(data, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
17187
+ }
17188
+ function addErrs(cxt, errs) {
17189
+ const { gen } = cxt;
17190
+ gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
17191
+ gen.assign(names_12.default.vErrors, (0, codegen_12._)`${names_12.default.vErrors} === null ? ${errs} : ${names_12.default.vErrors}.concat(${errs})`).assign(names_12.default.errors, (0, codegen_12._)`${names_12.default.vErrors}.length`);
17192
+ (0, errors_12.extendErrors)(cxt);
17193
+ }, () => cxt.error());
17194
+ }
17195
+ function checkAsyncKeyword({ schemaEnv }, def2) {
17196
+ if (def2.async && !schemaEnv.$async)
17197
+ throw new Error("async keyword in sync schema");
17198
+ }
17199
+ function useKeyword(gen, keyword2, result) {
17200
+ if (result === void 0)
17201
+ throw new Error(`keyword "${keyword2}" failed to compile`);
17202
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
17203
+ }
17204
+ function validSchemaType(schema, schemaType, allowUndefined = false) {
17205
+ 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");
17206
+ }
17207
+ keyword.validSchemaType = validSchemaType;
17208
+ function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
17209
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
17210
+ throw new Error("ajv implementation error");
17211
+ }
17212
+ const deps = def2.dependencies;
17213
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
17214
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
17215
+ }
17216
+ if (def2.validateSchema) {
17217
+ const valid = def2.validateSchema(schema[keyword2]);
17218
+ if (!valid) {
17219
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
17220
+ if (opts.validateSchema === "log")
17221
+ self.logger.error(msg);
17222
+ else
17223
+ throw new Error(msg);
17224
+ }
17208
17225
  }
17209
17226
  }
17227
+ keyword.validateKeywordUsage = validateKeywordUsage;
17228
+ return keyword;
17210
17229
  }
17211
- keyword.validateKeywordUsage = validateKeywordUsage;
17212
17230
  var subschema = {};
17213
- Object.defineProperty(subschema, "__esModule", { value: true });
17214
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
17215
- const codegen_1$o = codegen;
17216
- const util_1$o = util;
17217
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
17218
- if (keyword2 !== void 0 && schema !== void 0) {
17219
- throw new Error('both "keyword" and "schema" passed, only one allowed');
17220
- }
17221
- if (keyword2 !== void 0) {
17222
- const sch = it.schema[keyword2];
17223
- return schemaProp === void 0 ? {
17224
- schema: sch,
17225
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
17226
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
17227
- } : {
17228
- schema: sch[schemaProp],
17229
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
17230
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
17231
- };
17232
- }
17233
- if (schema !== void 0) {
17234
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
17235
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
17231
+ var hasRequiredSubschema;
17232
+ function requireSubschema() {
17233
+ if (hasRequiredSubschema) return subschema;
17234
+ hasRequiredSubschema = 1;
17235
+ Object.defineProperty(subschema, "__esModule", { value: true });
17236
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
17237
+ const codegen_12 = codegen;
17238
+ const util_12 = util;
17239
+ function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
17240
+ if (keyword2 !== void 0 && schema !== void 0) {
17241
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
17236
17242
  }
17237
- return {
17238
- schema,
17239
- schemaPath,
17240
- topSchemaRef,
17241
- errSchemaPath
17242
- };
17243
- }
17244
- throw new Error('either "keyword" or "schema" must be passed');
17245
- }
17246
- subschema.getSubschema = getSubschema;
17247
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
17248
- if (data !== void 0 && dataProp !== void 0) {
17249
- throw new Error('both "data" and "dataProp" passed, only one allowed');
17250
- }
17251
- const { gen } = it;
17252
- if (dataProp !== void 0) {
17253
- const { errorPath, dataPathArr, opts } = it;
17254
- const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
17255
- dataContextProps(nextData);
17256
- subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
17257
- subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
17258
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
17259
- }
17260
- if (data !== void 0) {
17261
- const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
17262
- dataContextProps(nextData);
17263
- if (propertyName !== void 0)
17264
- subschema2.propertyName = propertyName;
17265
- }
17266
- if (dataTypes)
17267
- subschema2.dataTypes = dataTypes;
17268
- function dataContextProps(_nextData) {
17269
- subschema2.data = _nextData;
17270
- subschema2.dataLevel = it.dataLevel + 1;
17271
- subschema2.dataTypes = [];
17272
- it.definedProperties = /* @__PURE__ */ new Set();
17273
- subschema2.parentData = it.data;
17274
- subschema2.dataNames = [...it.dataNames, _nextData];
17275
- }
17276
- }
17277
- subschema.extendSubschemaData = extendSubschemaData;
17278
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
17279
- if (compositeRule !== void 0)
17280
- subschema2.compositeRule = compositeRule;
17281
- if (createErrors !== void 0)
17282
- subschema2.createErrors = createErrors;
17283
- if (allErrors !== void 0)
17284
- subschema2.allErrors = allErrors;
17285
- subschema2.jtdDiscriminator = jtdDiscriminator;
17286
- subschema2.jtdMetadata = jtdMetadata;
17287
- }
17288
- subschema.extendSubschemaMode = extendSubschemaMode;
17243
+ if (keyword2 !== void 0) {
17244
+ const sch = it.schema[keyword2];
17245
+ return schemaProp === void 0 ? {
17246
+ schema: sch,
17247
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
17248
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`
17249
+ } : {
17250
+ schema: sch[schemaProp],
17251
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
17252
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
17253
+ };
17254
+ }
17255
+ if (schema !== void 0) {
17256
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
17257
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
17258
+ }
17259
+ return {
17260
+ schema,
17261
+ schemaPath,
17262
+ topSchemaRef,
17263
+ errSchemaPath
17264
+ };
17265
+ }
17266
+ throw new Error('either "keyword" or "schema" must be passed');
17267
+ }
17268
+ subschema.getSubschema = getSubschema;
17269
+ function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
17270
+ if (data !== void 0 && dataProp !== void 0) {
17271
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
17272
+ }
17273
+ const { gen } = it;
17274
+ if (dataProp !== void 0) {
17275
+ const { errorPath, dataPathArr, opts } = it;
17276
+ const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
17277
+ dataContextProps(nextData);
17278
+ subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
17279
+ subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
17280
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
17281
+ }
17282
+ if (data !== void 0) {
17283
+ const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
17284
+ dataContextProps(nextData);
17285
+ if (propertyName !== void 0)
17286
+ subschema2.propertyName = propertyName;
17287
+ }
17288
+ if (dataTypes)
17289
+ subschema2.dataTypes = dataTypes;
17290
+ function dataContextProps(_nextData) {
17291
+ subschema2.data = _nextData;
17292
+ subschema2.dataLevel = it.dataLevel + 1;
17293
+ subschema2.dataTypes = [];
17294
+ it.definedProperties = /* @__PURE__ */ new Set();
17295
+ subschema2.parentData = it.data;
17296
+ subschema2.dataNames = [...it.dataNames, _nextData];
17297
+ }
17298
+ }
17299
+ subschema.extendSubschemaData = extendSubschemaData;
17300
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
17301
+ if (compositeRule !== void 0)
17302
+ subschema2.compositeRule = compositeRule;
17303
+ if (createErrors !== void 0)
17304
+ subschema2.createErrors = createErrors;
17305
+ if (allErrors !== void 0)
17306
+ subschema2.allErrors = allErrors;
17307
+ subschema2.jtdDiscriminator = jtdDiscriminator;
17308
+ subschema2.jtdMetadata = jtdMetadata;
17309
+ }
17310
+ subschema.extendSubschemaMode = extendSubschemaMode;
17311
+ return subschema;
17312
+ }
17289
17313
  var resolve$2 = {};
17290
17314
  var fastDeepEqual = function equal(a, b) {
17291
17315
  if (a === b) return true;
@@ -17400,7 +17424,7 @@ function escapeJsonPtr(str) {
17400
17424
  var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
17401
17425
  Object.defineProperty(resolve$2, "__esModule", { value: true });
17402
17426
  resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
17403
- const util_1$n = util;
17427
+ const util_1$m = util;
17404
17428
  const equal$3 = fastDeepEqual;
17405
17429
  const traverse = jsonSchemaTraverseExports;
17406
17430
  const SIMPLE_INLINED = /* @__PURE__ */ new Set([
@@ -17459,7 +17483,7 @@ function countKeys(schema) {
17459
17483
  if (SIMPLE_INLINED.has(key))
17460
17484
  continue;
17461
17485
  if (typeof schema[key] == "object") {
17462
- (0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
17486
+ (0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys(sch));
17463
17487
  }
17464
17488
  if (count === Infinity)
17465
17489
  return Infinity;
@@ -17547,506 +17571,512 @@ function getSchemaRefs(schema, baseId) {
17547
17571
  }
17548
17572
  }
17549
17573
  resolve$2.getSchemaRefs = getSchemaRefs;
17550
- Object.defineProperty(validate, "__esModule", { value: true });
17551
- validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
17552
- const boolSchema_1 = boolSchema;
17553
- const dataType_1$1 = dataType;
17554
- const applicability_1 = applicability;
17555
- const dataType_2 = dataType;
17556
- const defaults_1 = defaults;
17557
- const keyword_1 = keyword;
17558
- const subschema_1 = subschema;
17559
- const codegen_1$n = codegen;
17560
- const names_1$3 = names$1;
17561
- const resolve_1$2 = resolve$2;
17562
- const util_1$m = util;
17563
- const errors_1 = errors;
17564
- function validateFunctionCode(it) {
17565
- if (isSchemaObj(it)) {
17566
- checkKeywords(it);
17567
- if (schemaCxtHasRules(it)) {
17568
- topSchemaObjCode(it);
17569
- return;
17574
+ var hasRequiredValidate;
17575
+ function requireValidate() {
17576
+ if (hasRequiredValidate) return validate;
17577
+ hasRequiredValidate = 1;
17578
+ Object.defineProperty(validate, "__esModule", { value: true });
17579
+ validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
17580
+ const boolSchema_1 = requireBoolSchema();
17581
+ const dataType_12 = dataType;
17582
+ const applicability_12 = applicability;
17583
+ const dataType_2 = dataType;
17584
+ const defaults_1 = requireDefaults();
17585
+ const keyword_1 = requireKeyword();
17586
+ const subschema_1 = requireSubschema();
17587
+ const codegen_12 = codegen;
17588
+ const names_12 = names$1;
17589
+ const resolve_12 = resolve$2;
17590
+ const util_12 = util;
17591
+ const errors_12 = errors;
17592
+ function validateFunctionCode(it) {
17593
+ if (isSchemaObj(it)) {
17594
+ checkKeywords(it);
17595
+ if (schemaCxtHasRules(it)) {
17596
+ topSchemaObjCode(it);
17597
+ return;
17598
+ }
17570
17599
  }
17600
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
17571
17601
  }
17572
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
17573
- }
17574
- validate.validateFunctionCode = validateFunctionCode;
17575
- function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
17576
- if (opts.code.es5) {
17577
- gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
17578
- gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
17579
- destructureValCxtES5(gen, opts);
17580
- gen.code(body);
17602
+ validate.validateFunctionCode = validateFunctionCode;
17603
+ function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
17604
+ if (opts.code.es5) {
17605
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
17606
+ gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
17607
+ destructureValCxtES5(gen, opts);
17608
+ gen.code(body);
17609
+ });
17610
+ } else {
17611
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
17612
+ }
17613
+ }
17614
+ function destructureValCxt(opts) {
17615
+ return (0, codegen_12._)`{${names_12.default.instancePath}="", ${names_12.default.parentData}, ${names_12.default.parentDataProperty}, ${names_12.default.rootData}=${names_12.default.data}${opts.dynamicRef ? (0, codegen_12._)`, ${names_12.default.dynamicAnchors}={}` : codegen_12.nil}}={}`;
17616
+ }
17617
+ function destructureValCxtES5(gen, opts) {
17618
+ gen.if(names_12.default.valCxt, () => {
17619
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
17620
+ gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
17621
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
17622
+ gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
17623
+ if (opts.dynamicRef)
17624
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
17625
+ }, () => {
17626
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
17627
+ gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
17628
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
17629
+ gen.var(names_12.default.rootData, names_12.default.data);
17630
+ if (opts.dynamicRef)
17631
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
17581
17632
  });
17582
- } else {
17583
- gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
17584
- }
17585
- }
17586
- function destructureValCxt(opts) {
17587
- return (0, codegen_1$n._)`{${names_1$3.default.instancePath}="", ${names_1$3.default.parentData}, ${names_1$3.default.parentDataProperty}, ${names_1$3.default.rootData}=${names_1$3.default.data}${opts.dynamicRef ? (0, codegen_1$n._)`, ${names_1$3.default.dynamicAnchors}={}` : codegen_1$n.nil}}={}`;
17588
- }
17589
- function destructureValCxtES5(gen, opts) {
17590
- gen.if(names_1$3.default.valCxt, () => {
17591
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
17592
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
17593
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
17594
- gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
17595
- if (opts.dynamicRef)
17596
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
17597
- }, () => {
17598
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
17599
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
17600
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
17601
- gen.var(names_1$3.default.rootData, names_1$3.default.data);
17602
- if (opts.dynamicRef)
17603
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
17604
- });
17605
- }
17606
- function topSchemaObjCode(it) {
17607
- const { schema, opts, gen } = it;
17608
- validateFunction(it, () => {
17633
+ }
17634
+ function topSchemaObjCode(it) {
17635
+ const { schema, opts, gen } = it;
17636
+ validateFunction(it, () => {
17637
+ if (opts.$comment && schema.$comment)
17638
+ commentKeyword(it);
17639
+ checkNoDefault(it);
17640
+ gen.let(names_12.default.vErrors, null);
17641
+ gen.let(names_12.default.errors, 0);
17642
+ if (opts.unevaluated)
17643
+ resetEvaluated(it);
17644
+ typeAndKeywords(it);
17645
+ returnResults(it);
17646
+ });
17647
+ return;
17648
+ }
17649
+ function resetEvaluated(it) {
17650
+ const { gen, validateName } = it;
17651
+ it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
17652
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
17653
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
17654
+ }
17655
+ function funcSourceUrl(schema, opts) {
17656
+ const schId = typeof schema == "object" && schema[opts.schemaId];
17657
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
17658
+ }
17659
+ function subschemaCode(it, valid) {
17660
+ if (isSchemaObj(it)) {
17661
+ checkKeywords(it);
17662
+ if (schemaCxtHasRules(it)) {
17663
+ subSchemaObjCode(it, valid);
17664
+ return;
17665
+ }
17666
+ }
17667
+ (0, boolSchema_1.boolOrEmptySchema)(it, valid);
17668
+ }
17669
+ function schemaCxtHasRules({ schema, self }) {
17670
+ if (typeof schema == "boolean")
17671
+ return !schema;
17672
+ for (const key in schema)
17673
+ if (self.RULES.all[key])
17674
+ return true;
17675
+ return false;
17676
+ }
17677
+ function isSchemaObj(it) {
17678
+ return typeof it.schema != "boolean";
17679
+ }
17680
+ function subSchemaObjCode(it, valid) {
17681
+ const { schema, gen, opts } = it;
17609
17682
  if (opts.$comment && schema.$comment)
17610
17683
  commentKeyword(it);
17611
- checkNoDefault(it);
17612
- gen.let(names_1$3.default.vErrors, null);
17613
- gen.let(names_1$3.default.errors, 0);
17614
- if (opts.unevaluated)
17615
- resetEvaluated(it);
17616
- typeAndKeywords(it);
17617
- returnResults(it);
17618
- });
17619
- return;
17620
- }
17621
- function resetEvaluated(it) {
17622
- const { gen, validateName } = it;
17623
- it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
17624
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
17625
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
17626
- }
17627
- function funcSourceUrl(schema, opts) {
17628
- const schId = typeof schema == "object" && schema[opts.schemaId];
17629
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
17630
- }
17631
- function subschemaCode(it, valid) {
17632
- if (isSchemaObj(it)) {
17633
- checkKeywords(it);
17634
- if (schemaCxtHasRules(it)) {
17635
- subSchemaObjCode(it, valid);
17684
+ updateContext(it);
17685
+ checkAsyncSchema(it);
17686
+ const errsCount = gen.const("_errs", names_12.default.errors);
17687
+ typeAndKeywords(it, errsCount);
17688
+ gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
17689
+ }
17690
+ function checkKeywords(it) {
17691
+ (0, util_12.checkUnknownRules)(it);
17692
+ checkRefsAndKeywords(it);
17693
+ }
17694
+ function typeAndKeywords(it, errsCount) {
17695
+ if (it.opts.jtd)
17696
+ return schemaKeywords(it, [], false, errsCount);
17697
+ const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
17698
+ const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
17699
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
17700
+ }
17701
+ function checkRefsAndKeywords(it) {
17702
+ const { schema, errSchemaPath, opts, self } = it;
17703
+ if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self.RULES)) {
17704
+ self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
17705
+ }
17706
+ }
17707
+ function checkNoDefault(it) {
17708
+ const { schema, opts } = it;
17709
+ if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
17710
+ (0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
17711
+ }
17712
+ }
17713
+ function updateContext(it) {
17714
+ const schId = it.schema[it.opts.schemaId];
17715
+ if (schId)
17716
+ it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
17717
+ }
17718
+ function checkAsyncSchema(it) {
17719
+ if (it.schema.$async && !it.schemaEnv.$async)
17720
+ throw new Error("async schema in sync schema");
17721
+ }
17722
+ function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
17723
+ const msg = schema.$comment;
17724
+ if (opts.$comment === true) {
17725
+ gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
17726
+ } else if (typeof opts.$comment == "function") {
17727
+ const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
17728
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
17729
+ gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
17730
+ }
17731
+ }
17732
+ function returnResults(it) {
17733
+ const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
17734
+ if (schemaEnv.$async) {
17735
+ gen.if((0, codegen_12._)`${names_12.default.errors} === 0`, () => gen.return(names_12.default.data), () => gen.throw((0, codegen_12._)`new ${ValidationError2}(${names_12.default.vErrors})`));
17736
+ } else {
17737
+ gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
17738
+ if (opts.unevaluated)
17739
+ assignEvaluated(it);
17740
+ gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
17741
+ }
17742
+ }
17743
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
17744
+ if (props instanceof codegen_12.Name)
17745
+ gen.assign((0, codegen_12._)`${evaluated}.props`, props);
17746
+ if (items2 instanceof codegen_12.Name)
17747
+ gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
17748
+ }
17749
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
17750
+ const { gen, schema, data, allErrors, opts, self } = it;
17751
+ const { RULES } = self;
17752
+ if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
17753
+ gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
17636
17754
  return;
17637
17755
  }
17756
+ if (!opts.jtd)
17757
+ checkStrictTypes(it, types2);
17758
+ gen.block(() => {
17759
+ for (const group of RULES.rules)
17760
+ groupKeywords(group);
17761
+ groupKeywords(RULES.post);
17762
+ });
17763
+ function groupKeywords(group) {
17764
+ if (!(0, applicability_12.shouldUseGroup)(schema, group))
17765
+ return;
17766
+ if (group.type) {
17767
+ gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
17768
+ iterateKeywords(it, group);
17769
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
17770
+ gen.else();
17771
+ (0, dataType_2.reportTypeError)(it);
17772
+ }
17773
+ gen.endIf();
17774
+ } else {
17775
+ iterateKeywords(it, group);
17776
+ }
17777
+ if (!allErrors)
17778
+ gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
17779
+ }
17638
17780
  }
17639
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
17640
- }
17641
- function schemaCxtHasRules({ schema, self }) {
17642
- if (typeof schema == "boolean")
17643
- return !schema;
17644
- for (const key in schema)
17645
- if (self.RULES.all[key])
17646
- return true;
17647
- return false;
17648
- }
17649
- function isSchemaObj(it) {
17650
- return typeof it.schema != "boolean";
17651
- }
17652
- function subSchemaObjCode(it, valid) {
17653
- const { schema, gen, opts } = it;
17654
- if (opts.$comment && schema.$comment)
17655
- commentKeyword(it);
17656
- updateContext(it);
17657
- checkAsyncSchema(it);
17658
- const errsCount = gen.const("_errs", names_1$3.default.errors);
17659
- typeAndKeywords(it, errsCount);
17660
- gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
17661
- }
17662
- function checkKeywords(it) {
17663
- (0, util_1$m.checkUnknownRules)(it);
17664
- checkRefsAndKeywords(it);
17665
- }
17666
- function typeAndKeywords(it, errsCount) {
17667
- if (it.opts.jtd)
17668
- return schemaKeywords(it, [], false, errsCount);
17669
- const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
17670
- const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
17671
- schemaKeywords(it, types2, !checkedTypes, errsCount);
17672
- }
17673
- function checkRefsAndKeywords(it) {
17674
- const { schema, errSchemaPath, opts, self } = it;
17675
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self.RULES)) {
17676
- self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
17677
- }
17678
- }
17679
- function checkNoDefault(it) {
17680
- const { schema, opts } = it;
17681
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
17682
- (0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
17683
- }
17684
- }
17685
- function updateContext(it) {
17686
- const schId = it.schema[it.opts.schemaId];
17687
- if (schId)
17688
- it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
17689
- }
17690
- function checkAsyncSchema(it) {
17691
- if (it.schema.$async && !it.schemaEnv.$async)
17692
- throw new Error("async schema in sync schema");
17693
- }
17694
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
17695
- const msg = schema.$comment;
17696
- if (opts.$comment === true) {
17697
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
17698
- } else if (typeof opts.$comment == "function") {
17699
- const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
17700
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
17701
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
17702
- }
17703
- }
17704
- function returnResults(it) {
17705
- const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
17706
- if (schemaEnv.$async) {
17707
- gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === 0`, () => gen.return(names_1$3.default.data), () => gen.throw((0, codegen_1$n._)`new ${ValidationError2}(${names_1$3.default.vErrors})`));
17708
- } else {
17709
- gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
17710
- if (opts.unevaluated)
17711
- assignEvaluated(it);
17712
- gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
17713
- }
17714
- }
17715
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
17716
- if (props instanceof codegen_1$n.Name)
17717
- gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
17718
- if (items2 instanceof codegen_1$n.Name)
17719
- gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
17720
- }
17721
- function schemaKeywords(it, types2, typeErrors, errsCount) {
17722
- const { gen, schema, data, allErrors, opts, self } = it;
17723
- const { RULES } = self;
17724
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
17725
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
17726
- return;
17781
+ function iterateKeywords(it, group) {
17782
+ const { gen, schema, opts: { useDefaults } } = it;
17783
+ if (useDefaults)
17784
+ (0, defaults_1.assignDefaults)(it, group.type);
17785
+ gen.block(() => {
17786
+ for (const rule of group.rules) {
17787
+ if ((0, applicability_12.shouldUseRule)(schema, rule)) {
17788
+ keywordCode(it, rule.keyword, rule.definition, group.type);
17789
+ }
17790
+ }
17791
+ });
17727
17792
  }
17728
- if (!opts.jtd)
17729
- checkStrictTypes(it, types2);
17730
- gen.block(() => {
17731
- for (const group of RULES.rules)
17732
- groupKeywords(group);
17733
- groupKeywords(RULES.post);
17734
- });
17735
- function groupKeywords(group) {
17736
- if (!(0, applicability_1.shouldUseGroup)(schema, group))
17793
+ function checkStrictTypes(it, types2) {
17794
+ if (it.schemaEnv.meta || !it.opts.strictTypes)
17737
17795
  return;
17738
- if (group.type) {
17739
- gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
17740
- iterateKeywords(it, group);
17741
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
17742
- gen.else();
17743
- (0, dataType_2.reportTypeError)(it);
17796
+ checkContextTypes(it, types2);
17797
+ if (!it.opts.allowUnionTypes)
17798
+ checkMultipleTypes(it, types2);
17799
+ checkKeywordTypes(it, it.dataTypes);
17800
+ }
17801
+ function checkContextTypes(it, types2) {
17802
+ if (!types2.length)
17803
+ return;
17804
+ if (!it.dataTypes.length) {
17805
+ it.dataTypes = types2;
17806
+ return;
17807
+ }
17808
+ types2.forEach((t) => {
17809
+ if (!includesType(it.dataTypes, t)) {
17810
+ strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
17744
17811
  }
17745
- gen.endIf();
17746
- } else {
17747
- iterateKeywords(it, group);
17812
+ });
17813
+ narrowSchemaTypes(it, types2);
17814
+ }
17815
+ function checkMultipleTypes(it, ts) {
17816
+ if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
17817
+ strictTypesError(it, "use allowUnionTypes to allow union type keyword");
17748
17818
  }
17749
- if (!allErrors)
17750
- gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
17751
17819
  }
17752
- }
17753
- function iterateKeywords(it, group) {
17754
- const { gen, schema, opts: { useDefaults } } = it;
17755
- if (useDefaults)
17756
- (0, defaults_1.assignDefaults)(it, group.type);
17757
- gen.block(() => {
17758
- for (const rule of group.rules) {
17759
- if ((0, applicability_1.shouldUseRule)(schema, rule)) {
17760
- keywordCode(it, rule.keyword, rule.definition, group.type);
17820
+ function checkKeywordTypes(it, ts) {
17821
+ const rules2 = it.self.RULES.all;
17822
+ for (const keyword2 in rules2) {
17823
+ const rule = rules2[keyword2];
17824
+ if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
17825
+ const { type: type2 } = rule.definition;
17826
+ if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
17827
+ strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
17828
+ }
17761
17829
  }
17762
17830
  }
17763
- });
17764
- }
17765
- function checkStrictTypes(it, types2) {
17766
- if (it.schemaEnv.meta || !it.opts.strictTypes)
17767
- return;
17768
- checkContextTypes(it, types2);
17769
- if (!it.opts.allowUnionTypes)
17770
- checkMultipleTypes(it, types2);
17771
- checkKeywordTypes(it, it.dataTypes);
17772
- }
17773
- function checkContextTypes(it, types2) {
17774
- if (!types2.length)
17775
- return;
17776
- if (!it.dataTypes.length) {
17777
- it.dataTypes = types2;
17778
- return;
17779
17831
  }
17780
- types2.forEach((t) => {
17781
- if (!includesType(it.dataTypes, t)) {
17782
- strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
17832
+ function hasApplicableType(schTs, kwdT) {
17833
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
17834
+ }
17835
+ function includesType(ts, t) {
17836
+ return ts.includes(t) || t === "integer" && ts.includes("number");
17837
+ }
17838
+ function narrowSchemaTypes(it, withTypes) {
17839
+ const ts = [];
17840
+ for (const t of it.dataTypes) {
17841
+ if (includesType(withTypes, t))
17842
+ ts.push(t);
17843
+ else if (withTypes.includes("integer") && t === "number")
17844
+ ts.push("integer");
17845
+ }
17846
+ it.dataTypes = ts;
17847
+ }
17848
+ function strictTypesError(it, msg) {
17849
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
17850
+ msg += ` at "${schemaPath}" (strictTypes)`;
17851
+ (0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
17852
+ }
17853
+ class KeywordCxt {
17854
+ constructor(it, def2, keyword2) {
17855
+ (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
17856
+ this.gen = it.gen;
17857
+ this.allErrors = it.allErrors;
17858
+ this.keyword = keyword2;
17859
+ this.data = it.data;
17860
+ this.schema = it.schema[keyword2];
17861
+ this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
17862
+ this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
17863
+ this.schemaType = def2.schemaType;
17864
+ this.parentSchema = it.schema;
17865
+ this.params = {};
17866
+ this.it = it;
17867
+ this.def = def2;
17868
+ if (this.$data) {
17869
+ this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
17870
+ } else {
17871
+ this.schemaCode = this.schemaValue;
17872
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
17873
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
17874
+ }
17875
+ }
17876
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
17877
+ this.errsCount = it.gen.const("_errs", names_12.default.errors);
17878
+ }
17783
17879
  }
17784
- });
17785
- narrowSchemaTypes(it, types2);
17786
- }
17787
- function checkMultipleTypes(it, ts) {
17788
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
17789
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
17790
- }
17791
- }
17792
- function checkKeywordTypes(it, ts) {
17793
- const rules2 = it.self.RULES.all;
17794
- for (const keyword2 in rules2) {
17795
- const rule = rules2[keyword2];
17796
- if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
17797
- const { type: type2 } = rule.definition;
17798
- if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
17799
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
17800
- }
17801
- }
17802
- }
17803
- }
17804
- function hasApplicableType(schTs, kwdT) {
17805
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
17806
- }
17807
- function includesType(ts, t) {
17808
- return ts.includes(t) || t === "integer" && ts.includes("number");
17809
- }
17810
- function narrowSchemaTypes(it, withTypes) {
17811
- const ts = [];
17812
- for (const t of it.dataTypes) {
17813
- if (includesType(withTypes, t))
17814
- ts.push(t);
17815
- else if (withTypes.includes("integer") && t === "number")
17816
- ts.push("integer");
17817
- }
17818
- it.dataTypes = ts;
17819
- }
17820
- function strictTypesError(it, msg) {
17821
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
17822
- msg += ` at "${schemaPath}" (strictTypes)`;
17823
- (0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
17824
- }
17825
- class KeywordCxt {
17826
- constructor(it, def2, keyword2) {
17827
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
17828
- this.gen = it.gen;
17829
- this.allErrors = it.allErrors;
17830
- this.keyword = keyword2;
17831
- this.data = it.data;
17832
- this.schema = it.schema[keyword2];
17833
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
17834
- this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
17835
- this.schemaType = def2.schemaType;
17836
- this.parentSchema = it.schema;
17837
- this.params = {};
17838
- this.it = it;
17839
- this.def = def2;
17840
- if (this.$data) {
17841
- this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
17842
- } else {
17843
- this.schemaCode = this.schemaValue;
17844
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
17845
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
17880
+ result(condition, successAction, failAction) {
17881
+ this.failResult((0, codegen_12.not)(condition), successAction, failAction);
17882
+ }
17883
+ failResult(condition, successAction, failAction) {
17884
+ this.gen.if(condition);
17885
+ if (failAction)
17886
+ failAction();
17887
+ else
17888
+ this.error();
17889
+ if (successAction) {
17890
+ this.gen.else();
17891
+ successAction();
17892
+ if (this.allErrors)
17893
+ this.gen.endIf();
17894
+ } else {
17895
+ if (this.allErrors)
17896
+ this.gen.endIf();
17897
+ else
17898
+ this.gen.else();
17846
17899
  }
17847
17900
  }
17848
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
17849
- this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
17901
+ pass(condition, failAction) {
17902
+ this.failResult((0, codegen_12.not)(condition), void 0, failAction);
17850
17903
  }
17851
- }
17852
- result(condition, successAction, failAction) {
17853
- this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
17854
- }
17855
- failResult(condition, successAction, failAction) {
17856
- this.gen.if(condition);
17857
- if (failAction)
17858
- failAction();
17859
- else
17904
+ fail(condition) {
17905
+ if (condition === void 0) {
17906
+ this.error();
17907
+ if (!this.allErrors)
17908
+ this.gen.if(false);
17909
+ return;
17910
+ }
17911
+ this.gen.if(condition);
17860
17912
  this.error();
17861
- if (successAction) {
17862
- this.gen.else();
17863
- successAction();
17864
- if (this.allErrors)
17865
- this.gen.endIf();
17866
- } else {
17867
17913
  if (this.allErrors)
17868
17914
  this.gen.endIf();
17869
17915
  else
17870
17916
  this.gen.else();
17871
17917
  }
17872
- }
17873
- pass(condition, failAction) {
17874
- this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
17875
- }
17876
- fail(condition) {
17877
- if (condition === void 0) {
17878
- this.error();
17918
+ fail$data(condition) {
17919
+ if (!this.$data)
17920
+ return this.fail(condition);
17921
+ const { schemaCode } = this;
17922
+ this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
17923
+ }
17924
+ error(append, errorParams, errorPaths) {
17925
+ if (errorParams) {
17926
+ this.setParams(errorParams);
17927
+ this._error(append, errorPaths);
17928
+ this.setParams({});
17929
+ return;
17930
+ }
17931
+ this._error(append, errorPaths);
17932
+ }
17933
+ _error(append, errorPaths) {
17934
+ (append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
17935
+ }
17936
+ $dataError() {
17937
+ (0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
17938
+ }
17939
+ reset() {
17940
+ if (this.errsCount === void 0)
17941
+ throw new Error('add "trackErrors" to keyword definition');
17942
+ (0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
17943
+ }
17944
+ ok(cond) {
17879
17945
  if (!this.allErrors)
17880
- this.gen.if(false);
17881
- return;
17946
+ this.gen.if(cond);
17882
17947
  }
17883
- this.gen.if(condition);
17884
- this.error();
17885
- if (this.allErrors)
17886
- this.gen.endIf();
17887
- else
17888
- this.gen.else();
17889
- }
17890
- fail$data(condition) {
17891
- if (!this.$data)
17892
- return this.fail(condition);
17893
- const { schemaCode } = this;
17894
- this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
17895
- }
17896
- error(append, errorParams, errorPaths) {
17897
- if (errorParams) {
17898
- this.setParams(errorParams);
17899
- this._error(append, errorPaths);
17900
- this.setParams({});
17901
- return;
17948
+ setParams(obj, assign) {
17949
+ if (assign)
17950
+ Object.assign(this.params, obj);
17951
+ else
17952
+ this.params = obj;
17902
17953
  }
17903
- this._error(append, errorPaths);
17904
- }
17905
- _error(append, errorPaths) {
17906
- (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
17907
- }
17908
- $dataError() {
17909
- (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
17910
- }
17911
- reset() {
17912
- if (this.errsCount === void 0)
17913
- throw new Error('add "trackErrors" to keyword definition');
17914
- (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
17915
- }
17916
- ok(cond) {
17917
- if (!this.allErrors)
17918
- this.gen.if(cond);
17919
- }
17920
- setParams(obj, assign) {
17921
- if (assign)
17922
- Object.assign(this.params, obj);
17923
- else
17924
- this.params = obj;
17925
- }
17926
- block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
17927
- this.gen.block(() => {
17928
- this.check$data(valid, $dataValid);
17929
- codeBlock();
17930
- });
17931
- }
17932
- check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
17933
- if (!this.$data)
17934
- return;
17935
- const { gen, schemaCode, schemaType, def: def2 } = this;
17936
- gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
17937
- if (valid !== codegen_1$n.nil)
17938
- gen.assign(valid, true);
17939
- if (schemaType.length || def2.validateSchema) {
17940
- gen.elseIf(this.invalid$data());
17941
- this.$dataError();
17942
- if (valid !== codegen_1$n.nil)
17943
- gen.assign(valid, false);
17954
+ block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
17955
+ this.gen.block(() => {
17956
+ this.check$data(valid, $dataValid);
17957
+ codeBlock();
17958
+ });
17944
17959
  }
17945
- gen.else();
17946
- }
17947
- invalid$data() {
17948
- const { gen, schemaCode, schemaType, def: def2, it } = this;
17949
- return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
17950
- function wrong$DataType() {
17951
- if (schemaType.length) {
17952
- if (!(schemaCode instanceof codegen_1$n.Name))
17953
- throw new Error("ajv implementation error");
17954
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
17955
- return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
17960
+ check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
17961
+ if (!this.$data)
17962
+ return;
17963
+ const { gen, schemaCode, schemaType, def: def2 } = this;
17964
+ gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
17965
+ if (valid !== codegen_12.nil)
17966
+ gen.assign(valid, true);
17967
+ if (schemaType.length || def2.validateSchema) {
17968
+ gen.elseIf(this.invalid$data());
17969
+ this.$dataError();
17970
+ if (valid !== codegen_12.nil)
17971
+ gen.assign(valid, false);
17956
17972
  }
17957
- return codegen_1$n.nil;
17973
+ gen.else();
17958
17974
  }
17959
- function invalid$DataSchema() {
17960
- if (def2.validateSchema) {
17961
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
17962
- return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
17975
+ invalid$data() {
17976
+ const { gen, schemaCode, schemaType, def: def2, it } = this;
17977
+ return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
17978
+ function wrong$DataType() {
17979
+ if (schemaType.length) {
17980
+ if (!(schemaCode instanceof codegen_12.Name))
17981
+ throw new Error("ajv implementation error");
17982
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
17983
+ return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
17984
+ }
17985
+ return codegen_12.nil;
17986
+ }
17987
+ function invalid$DataSchema() {
17988
+ if (def2.validateSchema) {
17989
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
17990
+ return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
17991
+ }
17992
+ return codegen_12.nil;
17963
17993
  }
17964
- return codegen_1$n.nil;
17965
17994
  }
17966
- }
17967
- subschema(appl, valid) {
17968
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
17969
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
17970
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
17971
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
17972
- subschemaCode(nextContext, valid);
17973
- return nextContext;
17974
- }
17975
- mergeEvaluated(schemaCxt, toName) {
17976
- const { it, gen } = this;
17977
- if (!it.opts.unevaluated)
17978
- return;
17979
- if (it.props !== true && schemaCxt.props !== void 0) {
17980
- it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
17995
+ subschema(appl, valid) {
17996
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
17997
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
17998
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
17999
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
18000
+ subschemaCode(nextContext, valid);
18001
+ return nextContext;
17981
18002
  }
17982
- if (it.items !== true && schemaCxt.items !== void 0) {
17983
- it.items = util_1$m.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
18003
+ mergeEvaluated(schemaCxt, toName) {
18004
+ const { it, gen } = this;
18005
+ if (!it.opts.unevaluated)
18006
+ return;
18007
+ if (it.props !== true && schemaCxt.props !== void 0) {
18008
+ it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
18009
+ }
18010
+ if (it.items !== true && schemaCxt.items !== void 0) {
18011
+ it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
18012
+ }
17984
18013
  }
17985
- }
17986
- mergeValidEvaluated(schemaCxt, valid) {
17987
- const { it, gen } = this;
17988
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
17989
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
17990
- return true;
18014
+ mergeValidEvaluated(schemaCxt, valid) {
18015
+ const { it, gen } = this;
18016
+ if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
18017
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
18018
+ return true;
18019
+ }
17991
18020
  }
17992
18021
  }
17993
- }
17994
- validate.KeywordCxt = KeywordCxt;
17995
- function keywordCode(it, keyword2, def2, ruleType) {
17996
- const cxt = new KeywordCxt(it, def2, keyword2);
17997
- if ("code" in def2) {
17998
- def2.code(cxt, ruleType);
17999
- } else if (cxt.$data && def2.validate) {
18000
- (0, keyword_1.funcKeywordCode)(cxt, def2);
18001
- } else if ("macro" in def2) {
18002
- (0, keyword_1.macroKeywordCode)(cxt, def2);
18003
- } else if (def2.compile || def2.validate) {
18004
- (0, keyword_1.funcKeywordCode)(cxt, def2);
18005
- }
18006
- }
18007
- const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
18008
- const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
18009
- function getData($data, { dataLevel, dataNames, dataPathArr }) {
18010
- let jsonPointer;
18011
- let data;
18012
- if ($data === "")
18013
- return names_1$3.default.rootData;
18014
- if ($data[0] === "/") {
18015
- if (!JSON_POINTER.test($data))
18016
- throw new Error(`Invalid JSON-pointer: ${$data}`);
18017
- jsonPointer = $data;
18018
- data = names_1$3.default.rootData;
18019
- } else {
18020
- const matches = RELATIVE_JSON_POINTER.exec($data);
18021
- if (!matches)
18022
- throw new Error(`Invalid JSON-pointer: ${$data}`);
18023
- const up = +matches[1];
18024
- jsonPointer = matches[2];
18025
- if (jsonPointer === "#") {
18026
- if (up >= dataLevel)
18027
- throw new Error(errorMsg("property/index", up));
18028
- return dataPathArr[dataLevel - up];
18029
- }
18030
- if (up > dataLevel)
18031
- throw new Error(errorMsg("data", up));
18032
- data = dataNames[dataLevel - up];
18033
- if (!jsonPointer)
18034
- return data;
18035
- }
18036
- let expr = data;
18037
- const segments = jsonPointer.split("/");
18038
- for (const segment of segments) {
18039
- if (segment) {
18040
- data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
18041
- expr = (0, codegen_1$n._)`${expr} && ${data}`;
18022
+ validate.KeywordCxt = KeywordCxt;
18023
+ function keywordCode(it, keyword2, def2, ruleType) {
18024
+ const cxt = new KeywordCxt(it, def2, keyword2);
18025
+ if ("code" in def2) {
18026
+ def2.code(cxt, ruleType);
18027
+ } else if (cxt.$data && def2.validate) {
18028
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
18029
+ } else if ("macro" in def2) {
18030
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
18031
+ } else if (def2.compile || def2.validate) {
18032
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
18033
+ }
18034
+ }
18035
+ const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
18036
+ const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
18037
+ function getData($data, { dataLevel, dataNames, dataPathArr }) {
18038
+ let jsonPointer;
18039
+ let data;
18040
+ if ($data === "")
18041
+ return names_12.default.rootData;
18042
+ if ($data[0] === "/") {
18043
+ if (!JSON_POINTER.test($data))
18044
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
18045
+ jsonPointer = $data;
18046
+ data = names_12.default.rootData;
18047
+ } else {
18048
+ const matches = RELATIVE_JSON_POINTER.exec($data);
18049
+ if (!matches)
18050
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
18051
+ const up = +matches[1];
18052
+ jsonPointer = matches[2];
18053
+ if (jsonPointer === "#") {
18054
+ if (up >= dataLevel)
18055
+ throw new Error(errorMsg("property/index", up));
18056
+ return dataPathArr[dataLevel - up];
18057
+ }
18058
+ if (up > dataLevel)
18059
+ throw new Error(errorMsg("data", up));
18060
+ data = dataNames[dataLevel - up];
18061
+ if (!jsonPointer)
18062
+ return data;
18063
+ }
18064
+ let expr = data;
18065
+ const segments = jsonPointer.split("/");
18066
+ for (const segment of segments) {
18067
+ if (segment) {
18068
+ data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
18069
+ expr = (0, codegen_12._)`${expr} && ${data}`;
18070
+ }
18071
+ }
18072
+ return expr;
18073
+ function errorMsg(pointerType, up) {
18074
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
18042
18075
  }
18043
18076
  }
18044
- return expr;
18045
- function errorMsg(pointerType, up) {
18046
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
18047
- }
18077
+ validate.getData = getData;
18078
+ return validate;
18048
18079
  }
18049
- validate.getData = getData;
18050
18080
  var validation_error = {};
18051
18081
  Object.defineProperty(validation_error, "__esModule", { value: true });
18052
18082
  class ValidationError extends Error {
@@ -18076,7 +18106,7 @@ const validation_error_1 = validation_error;
18076
18106
  const names_1$2 = names$1;
18077
18107
  const resolve_1 = resolve$2;
18078
18108
  const util_1$l = util;
18079
- const validate_1$1 = validate;
18109
+ const validate_1$1 = requireValidate();
18080
18110
  class SchemaEnv {
18081
18111
  constructor(env) {
18082
18112
  var _a;
@@ -19005,7 +19035,7 @@ uri$1.default = uri;
19005
19035
  (function(exports) {
19006
19036
  Object.defineProperty(exports, "__esModule", { value: true });
19007
19037
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
19008
- var validate_12 = validate;
19038
+ var validate_12 = requireValidate();
19009
19039
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
19010
19040
  return validate_12.KeywordCxt;
19011
19041
  } });
@@ -20616,7 +20646,7 @@ const def$a = {
20616
20646
  additionalProperties.default = def$a;
20617
20647
  var properties$1 = {};
20618
20648
  Object.defineProperty(properties$1, "__esModule", { value: true });
20619
- const validate_1 = validate;
20649
+ const validate_1 = requireValidate();
20620
20650
  const code_1$2 = code;
20621
20651
  const util_1$7 = util;
20622
20652
  const additionalProperties_1$1 = additionalProperties;
@@ -21467,7 +21497,7 @@ const require$$3 = {
21467
21497
  module.exports.Ajv = Ajv2;
21468
21498
  Object.defineProperty(exports, "__esModule", { value: true });
21469
21499
  exports.default = Ajv2;
21470
- var validate_12 = validate;
21500
+ var validate_12 = requireValidate();
21471
21501
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
21472
21502
  return validate_12.KeywordCxt;
21473
21503
  } });