@spooky-sync/cli 0.0.1-canary.380 → 0.0.1-canary.381

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