@rebilly/instruments 9.32.1 → 9.33.0

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.
package/dist/index.js CHANGED
@@ -5690,7 +5690,7 @@ function Jt(e2, t2) {
5690
5690
  return s;
5691
5691
  }
5692
5692
  var Gt = P$1;
5693
- const Yt = /* @__PURE__ */ wt(Gt), Qt = "56.15.0";
5693
+ const Yt = /* @__PURE__ */ wt(Gt), Qt = "56.15.1";
5694
5694
  let Xt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Zt = (e2 = 21) => {
5695
5695
  let t2 = "", s = e2;
5696
5696
  for (; s--; )
@@ -11172,7 +11172,7 @@ async function U() {
11172
11172
  requestId: l.requestId
11173
11173
  };
11174
11174
  } catch (r2) {
11175
- return console.log(r2), {};
11175
+ return console.error(r2), {};
11176
11176
  }
11177
11177
  }
11178
11178
  async function De() {
@@ -15481,6 +15481,7 @@ async function fetchData({
15481
15481
  availableInstruments
15482
15482
  });
15483
15483
  } catch (error2) {
15484
+ console.error(error2);
15484
15485
  }
15485
15486
  return new DataInstance({});
15486
15487
  }
@@ -17405,29 +17406,29 @@ var util = {};
17405
17406
  })(util);
17406
17407
  var names$1 = {};
17407
17408
  Object.defineProperty(names$1, "__esModule", { value: true });
17408
- const codegen_1$s = codegen;
17409
+ const codegen_1$x = codegen;
17409
17410
  const names = {
17410
17411
  // validation function arguments
17411
- data: new codegen_1$s.Name("data"),
17412
+ data: new codegen_1$x.Name("data"),
17412
17413
  // args passed from referencing schema
17413
- valCxt: new codegen_1$s.Name("valCxt"),
17414
- instancePath: new codegen_1$s.Name("instancePath"),
17415
- parentData: new codegen_1$s.Name("parentData"),
17416
- parentDataProperty: new codegen_1$s.Name("parentDataProperty"),
17417
- rootData: new codegen_1$s.Name("rootData"),
17418
- dynamicAnchors: new codegen_1$s.Name("dynamicAnchors"),
17414
+ valCxt: new codegen_1$x.Name("valCxt"),
17415
+ instancePath: new codegen_1$x.Name("instancePath"),
17416
+ parentData: new codegen_1$x.Name("parentData"),
17417
+ parentDataProperty: new codegen_1$x.Name("parentDataProperty"),
17418
+ rootData: new codegen_1$x.Name("rootData"),
17419
+ dynamicAnchors: new codegen_1$x.Name("dynamicAnchors"),
17419
17420
  // function scoped variables
17420
- vErrors: new codegen_1$s.Name("vErrors"),
17421
- errors: new codegen_1$s.Name("errors"),
17422
- this: new codegen_1$s.Name("this"),
17421
+ vErrors: new codegen_1$x.Name("vErrors"),
17422
+ errors: new codegen_1$x.Name("errors"),
17423
+ this: new codegen_1$x.Name("this"),
17423
17424
  // "globals"
17424
- self: new codegen_1$s.Name("self"),
17425
- scope: new codegen_1$s.Name("scope"),
17425
+ self: new codegen_1$x.Name("self"),
17426
+ scope: new codegen_1$x.Name("scope"),
17426
17427
  // JTD serialize/parse name for JSON string and position
17427
- json: new codegen_1$s.Name("json"),
17428
- jsonPos: new codegen_1$s.Name("jsonPos"),
17429
- jsonLen: new codegen_1$s.Name("jsonLen"),
17430
- jsonPart: new codegen_1$s.Name("jsonPart")
17428
+ json: new codegen_1$x.Name("json"),
17429
+ jsonPos: new codegen_1$x.Name("jsonPos"),
17430
+ jsonLen: new codegen_1$x.Name("jsonLen"),
17431
+ jsonPart: new codegen_1$x.Name("jsonPart")
17431
17432
  };
17432
17433
  names$1.default = names;
17433
17434
  (function(exports) {
@@ -17546,56 +17547,49 @@ names$1.default = names;
17546
17547
  keyValues.push([E.propertyName, propertyName]);
17547
17548
  }
17548
17549
  })(errors);
17549
- var hasRequiredBoolSchema;
17550
- function requireBoolSchema() {
17551
- if (hasRequiredBoolSchema)
17552
- return boolSchema;
17553
- hasRequiredBoolSchema = 1;
17554
- Object.defineProperty(boolSchema, "__esModule", { value: true });
17555
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
17556
- const errors_1 = errors;
17557
- const codegen_12 = codegen;
17558
- const names_12 = names$1;
17559
- const boolError = {
17560
- message: "boolean schema is false"
17561
- };
17562
- function topBoolOrEmptySchema(it2) {
17563
- const { gen, schema: schema2, validateName } = it2;
17564
- if (schema2 === false) {
17565
- falseSchemaError(it2, false);
17566
- } else if (typeof schema2 == "object" && schema2.$async === true) {
17567
- gen.return(names_12.default.data);
17568
- } else {
17569
- gen.assign((0, codegen_12._)`${validateName}.errors`, null);
17570
- gen.return(true);
17571
- }
17572
- }
17573
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
17574
- function boolOrEmptySchema(it2, valid) {
17575
- const { gen, schema: schema2 } = it2;
17576
- if (schema2 === false) {
17577
- gen.var(valid, false);
17578
- falseSchemaError(it2);
17579
- } else {
17580
- gen.var(valid, true);
17581
- }
17550
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
17551
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
17552
+ const errors_1$2 = errors;
17553
+ const codegen_1$w = codegen;
17554
+ const names_1$9 = names$1;
17555
+ const boolError = {
17556
+ message: "boolean schema is false"
17557
+ };
17558
+ function topBoolOrEmptySchema(it2) {
17559
+ const { gen, schema: schema2, validateName } = it2;
17560
+ if (schema2 === false) {
17561
+ falseSchemaError(it2, false);
17562
+ } else if (typeof schema2 == "object" && schema2.$async === true) {
17563
+ gen.return(names_1$9.default.data);
17564
+ } else {
17565
+ gen.assign((0, codegen_1$w._)`${validateName}.errors`, null);
17566
+ gen.return(true);
17582
17567
  }
17583
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
17584
- function falseSchemaError(it2, overrideAllErrors) {
17585
- const { gen, data } = it2;
17586
- const cxt = {
17587
- gen,
17588
- keyword: "false schema",
17589
- data,
17590
- schema: false,
17591
- schemaCode: false,
17592
- schemaValue: false,
17593
- params: {},
17594
- it: it2
17595
- };
17596
- (0, errors_1.reportError)(cxt, boolError, void 0, overrideAllErrors);
17568
+ }
17569
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
17570
+ function boolOrEmptySchema(it2, valid) {
17571
+ const { gen, schema: schema2 } = it2;
17572
+ if (schema2 === false) {
17573
+ gen.var(valid, false);
17574
+ falseSchemaError(it2);
17575
+ } else {
17576
+ gen.var(valid, true);
17597
17577
  }
17598
- return boolSchema;
17578
+ }
17579
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
17580
+ function falseSchemaError(it2, overrideAllErrors) {
17581
+ const { gen, data } = it2;
17582
+ const cxt = {
17583
+ gen,
17584
+ keyword: "false schema",
17585
+ data,
17586
+ schema: false,
17587
+ schemaCode: false,
17588
+ schemaValue: false,
17589
+ params: {},
17590
+ it: it2
17591
+ };
17592
+ (0, errors_1$2.reportError)(cxt, boolError, void 0, overrideAllErrors);
17599
17593
  }
17600
17594
  var dataType = {};
17601
17595
  var rules = {};
@@ -17644,8 +17638,8 @@ applicability.shouldUseRule = shouldUseRule;
17644
17638
  Object.defineProperty(exports, "__esModule", { value: true });
17645
17639
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
17646
17640
  const rules_1 = rules;
17647
- const applicability_1 = applicability;
17648
- const errors_1 = errors;
17641
+ const applicability_12 = applicability;
17642
+ const errors_12 = errors;
17649
17643
  const codegen_12 = codegen;
17650
17644
  const util_12 = util;
17651
17645
  var DataType;
@@ -17679,7 +17673,7 @@ applicability.shouldUseRule = shouldUseRule;
17679
17673
  function coerceAndCheckDataType(it2, types2) {
17680
17674
  const { gen, data, opts } = it2;
17681
17675
  const coerceTo = coerceToTypes(types2, opts.coerceTypes);
17682
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it2, types2[0]));
17676
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_12.schemaHasRulesForType)(it2, types2[0]));
17683
17677
  if (checkTypes) {
17684
17678
  const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
17685
17679
  gen.if(wrongType, () => {
@@ -17800,7 +17794,7 @@ applicability.shouldUseRule = shouldUseRule;
17800
17794
  };
17801
17795
  function reportTypeError(it2) {
17802
17796
  const cxt = getTypeErrorContext(it2);
17803
- (0, errors_1.reportError)(cxt, typeError);
17797
+ (0, errors_12.reportError)(cxt, typeError);
17804
17798
  }
17805
17799
  exports.reportTypeError = reportTypeError;
17806
17800
  function getTypeErrorContext(it2) {
@@ -17820,61 +17814,54 @@ applicability.shouldUseRule = shouldUseRule;
17820
17814
  }
17821
17815
  })(dataType);
17822
17816
  var defaults = {};
17823
- var hasRequiredDefaults;
17824
- function requireDefaults() {
17825
- if (hasRequiredDefaults)
17826
- return defaults;
17827
- hasRequiredDefaults = 1;
17828
- Object.defineProperty(defaults, "__esModule", { value: true });
17829
- defaults.assignDefaults = void 0;
17830
- const codegen_12 = codegen;
17831
- const util_12 = util;
17832
- function assignDefaults(it2, ty) {
17833
- const { properties: properties2, items: items2 } = it2.schema;
17834
- if (ty === "object" && properties2) {
17835
- for (const key in properties2) {
17836
- assignDefault(it2, key, properties2[key].default);
17837
- }
17838
- } else if (ty === "array" && Array.isArray(items2)) {
17839
- items2.forEach((sch, i) => assignDefault(it2, i, sch.default));
17840
- }
17817
+ Object.defineProperty(defaults, "__esModule", { value: true });
17818
+ defaults.assignDefaults = void 0;
17819
+ const codegen_1$v = codegen;
17820
+ const util_1$t = util;
17821
+ function assignDefaults(it2, ty) {
17822
+ const { properties: properties2, items: items2 } = it2.schema;
17823
+ if (ty === "object" && properties2) {
17824
+ for (const key in properties2) {
17825
+ assignDefault(it2, key, properties2[key].default);
17826
+ }
17827
+ } else if (ty === "array" && Array.isArray(items2)) {
17828
+ items2.forEach((sch, i) => assignDefault(it2, i, sch.default));
17829
+ }
17830
+ }
17831
+ defaults.assignDefaults = assignDefaults;
17832
+ function assignDefault(it2, prop, defaultValue) {
17833
+ const { gen, compositeRule, data, opts } = it2;
17834
+ if (defaultValue === void 0)
17835
+ return;
17836
+ const childData = (0, codegen_1$v._)`${data}${(0, codegen_1$v.getProperty)(prop)}`;
17837
+ if (compositeRule) {
17838
+ (0, util_1$t.checkStrictMode)(it2, `default is ignored for: ${childData}`);
17839
+ return;
17841
17840
  }
17842
- defaults.assignDefaults = assignDefaults;
17843
- function assignDefault(it2, prop, defaultValue) {
17844
- const { gen, compositeRule, data, opts } = it2;
17845
- if (defaultValue === void 0)
17846
- return;
17847
- const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
17848
- if (compositeRule) {
17849
- (0, util_12.checkStrictMode)(it2, `default is ignored for: ${childData}`);
17850
- return;
17851
- }
17852
- let condition = (0, codegen_12._)`${childData} === undefined`;
17853
- if (opts.useDefaults === "empty") {
17854
- condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
17855
- }
17856
- gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
17841
+ let condition = (0, codegen_1$v._)`${childData} === undefined`;
17842
+ if (opts.useDefaults === "empty") {
17843
+ condition = (0, codegen_1$v._)`${condition} || ${childData} === null || ${childData} === ""`;
17857
17844
  }
17858
- return defaults;
17845
+ gen.if(condition, (0, codegen_1$v._)`${childData} = ${(0, codegen_1$v.stringify)(defaultValue)}`);
17859
17846
  }
17860
17847
  var keyword = {};
17861
17848
  var code = {};
17862
17849
  Object.defineProperty(code, "__esModule", { value: true });
17863
17850
  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;
17864
- const codegen_1$r = codegen;
17865
- const util_1$q = util;
17866
- const names_1$6 = names$1;
17851
+ const codegen_1$u = codegen;
17852
+ const util_1$s = util;
17853
+ const names_1$8 = names$1;
17867
17854
  const util_2$1 = util;
17868
17855
  function checkReportMissingProp(cxt, prop) {
17869
17856
  const { gen, data, it: it2 } = cxt;
17870
17857
  gen.if(noPropertyInData(gen, data, prop, it2.opts.ownProperties), () => {
17871
- cxt.setParams({ missingProperty: (0, codegen_1$r._)`${prop}` }, true);
17858
+ cxt.setParams({ missingProperty: (0, codegen_1$u._)`${prop}` }, true);
17872
17859
  cxt.error();
17873
17860
  });
17874
17861
  }
17875
17862
  code.checkReportMissingProp = checkReportMissingProp;
17876
17863
  function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
17877
- return (0, codegen_1$r.or)(...properties2.map((prop) => (0, codegen_1$r.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$r._)`${missing} = ${prop}`)));
17864
+ return (0, codegen_1$u.or)(...properties2.map((prop) => (0, codegen_1$u.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$u._)`${missing} = ${prop}`)));
17878
17865
  }
17879
17866
  code.checkMissingProp = checkMissingProp;
17880
17867
  function reportMissingProp(cxt, missing) {
@@ -17886,22 +17873,22 @@ function hasPropFunc(gen) {
17886
17873
  return gen.scopeValue("func", {
17887
17874
  // eslint-disable-next-line @typescript-eslint/unbound-method
17888
17875
  ref: Object.prototype.hasOwnProperty,
17889
- code: (0, codegen_1$r._)`Object.prototype.hasOwnProperty`
17876
+ code: (0, codegen_1$u._)`Object.prototype.hasOwnProperty`
17890
17877
  });
17891
17878
  }
17892
17879
  code.hasPropFunc = hasPropFunc;
17893
17880
  function isOwnProperty(gen, data, property) {
17894
- return (0, codegen_1$r._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
17881
+ return (0, codegen_1$u._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
17895
17882
  }
17896
17883
  code.isOwnProperty = isOwnProperty;
17897
17884
  function propertyInData(gen, data, property, ownProperties) {
17898
- const cond = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(property)} !== undefined`;
17899
- return ownProperties ? (0, codegen_1$r._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
17885
+ const cond = (0, codegen_1$u._)`${data}${(0, codegen_1$u.getProperty)(property)} !== undefined`;
17886
+ return ownProperties ? (0, codegen_1$u._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
17900
17887
  }
17901
17888
  code.propertyInData = propertyInData;
17902
17889
  function noPropertyInData(gen, data, property, ownProperties) {
17903
- const cond = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(property)} === undefined`;
17904
- return ownProperties ? (0, codegen_1$r.or)(cond, (0, codegen_1$r.not)(isOwnProperty(gen, data, property))) : cond;
17890
+ const cond = (0, codegen_1$u._)`${data}${(0, codegen_1$u.getProperty)(property)} === undefined`;
17891
+ return ownProperties ? (0, codegen_1$u.or)(cond, (0, codegen_1$u.not)(isOwnProperty(gen, data, property))) : cond;
17905
17892
  }
17906
17893
  code.noPropertyInData = noPropertyInData;
17907
17894
  function allSchemaProperties(schemaMap) {
@@ -17909,24 +17896,24 @@ function allSchemaProperties(schemaMap) {
17909
17896
  }
17910
17897
  code.allSchemaProperties = allSchemaProperties;
17911
17898
  function schemaProperties(it2, schemaMap) {
17912
- return allSchemaProperties(schemaMap).filter((p2) => !(0, util_1$q.alwaysValidSchema)(it2, schemaMap[p2]));
17899
+ return allSchemaProperties(schemaMap).filter((p2) => !(0, util_1$s.alwaysValidSchema)(it2, schemaMap[p2]));
17913
17900
  }
17914
17901
  code.schemaProperties = schemaProperties;
17915
17902
  function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it: it2 }, func, context, passSchema) {
17916
- const dataAndSchema = passSchema ? (0, codegen_1$r._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
17903
+ const dataAndSchema = passSchema ? (0, codegen_1$u._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
17917
17904
  const valCxt = [
17918
- [names_1$6.default.instancePath, (0, codegen_1$r.strConcat)(names_1$6.default.instancePath, errorPath)],
17919
- [names_1$6.default.parentData, it2.parentData],
17920
- [names_1$6.default.parentDataProperty, it2.parentDataProperty],
17921
- [names_1$6.default.rootData, names_1$6.default.rootData]
17905
+ [names_1$8.default.instancePath, (0, codegen_1$u.strConcat)(names_1$8.default.instancePath, errorPath)],
17906
+ [names_1$8.default.parentData, it2.parentData],
17907
+ [names_1$8.default.parentDataProperty, it2.parentDataProperty],
17908
+ [names_1$8.default.rootData, names_1$8.default.rootData]
17922
17909
  ];
17923
17910
  if (it2.opts.dynamicRef)
17924
- valCxt.push([names_1$6.default.dynamicAnchors, names_1$6.default.dynamicAnchors]);
17925
- const args = (0, codegen_1$r._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
17926
- return context !== codegen_1$r.nil ? (0, codegen_1$r._)`${func}.call(${context}, ${args})` : (0, codegen_1$r._)`${func}(${args})`;
17911
+ valCxt.push([names_1$8.default.dynamicAnchors, names_1$8.default.dynamicAnchors]);
17912
+ const args = (0, codegen_1$u._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
17913
+ return context !== codegen_1$u.nil ? (0, codegen_1$u._)`${func}.call(${context}, ${args})` : (0, codegen_1$u._)`${func}(${args})`;
17927
17914
  }
17928
17915
  code.callValidateCode = callValidateCode;
17929
- const newRegExp = (0, codegen_1$r._)`new RegExp`;
17916
+ const newRegExp = (0, codegen_1$u._)`new RegExp`;
17930
17917
  function usePattern({ gen, it: { opts } }, pattern2) {
17931
17918
  const u = opts.unicodeRegExp ? "u" : "";
17932
17919
  const { regExp } = opts.code;
@@ -17934,7 +17921,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
17934
17921
  return gen.scopeValue("pattern", {
17935
17922
  key: rx.toString(),
17936
17923
  ref: rx,
17937
- code: (0, codegen_1$r._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
17924
+ code: (0, codegen_1$u._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
17938
17925
  });
17939
17926
  }
17940
17927
  code.usePattern = usePattern;
@@ -17950,14 +17937,14 @@ function validateArray(cxt) {
17950
17937
  validateItems(() => gen.break());
17951
17938
  return valid;
17952
17939
  function validateItems(notValid) {
17953
- const len = gen.const("len", (0, codegen_1$r._)`${data}.length`);
17940
+ const len = gen.const("len", (0, codegen_1$u._)`${data}.length`);
17954
17941
  gen.forRange("i", 0, len, (i) => {
17955
17942
  cxt.subschema({
17956
17943
  keyword: keyword2,
17957
17944
  dataProp: i,
17958
- dataPropType: util_1$q.Type.Num
17945
+ dataPropType: util_1$s.Type.Num
17959
17946
  }, valid);
17960
- gen.if((0, codegen_1$r.not)(valid), notValid);
17947
+ gen.if((0, codegen_1$u.not)(valid), notValid);
17961
17948
  });
17962
17949
  }
17963
17950
  }
@@ -17966,7 +17953,7 @@ function validateUnion(cxt) {
17966
17953
  const { gen, schema: schema2, keyword: keyword2, it: it2 } = cxt;
17967
17954
  if (!Array.isArray(schema2))
17968
17955
  throw new Error("ajv implementation error");
17969
- const alwaysValid = schema2.some((sch) => (0, util_1$q.alwaysValidSchema)(it2, sch));
17956
+ const alwaysValid = schema2.some((sch) => (0, util_1$s.alwaysValidSchema)(it2, sch));
17970
17957
  if (alwaysValid && !it2.opts.unevaluated)
17971
17958
  return;
17972
17959
  const valid = gen.let("valid", false);
@@ -17977,216 +17964,202 @@ function validateUnion(cxt) {
17977
17964
  schemaProp: i,
17978
17965
  compositeRule: true
17979
17966
  }, schValid);
17980
- gen.assign(valid, (0, codegen_1$r._)`${valid} || ${schValid}`);
17967
+ gen.assign(valid, (0, codegen_1$u._)`${valid} || ${schValid}`);
17981
17968
  const merged = cxt.mergeValidEvaluated(schCxt, schValid);
17982
17969
  if (!merged)
17983
- gen.if((0, codegen_1$r.not)(valid));
17970
+ gen.if((0, codegen_1$u.not)(valid));
17984
17971
  }));
17985
17972
  cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
17986
17973
  }
17987
17974
  code.validateUnion = validateUnion;
17988
- var hasRequiredKeyword;
17989
- function requireKeyword() {
17990
- if (hasRequiredKeyword)
17991
- return keyword;
17992
- hasRequiredKeyword = 1;
17993
- Object.defineProperty(keyword, "__esModule", { value: true });
17994
- keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
17995
- const codegen_12 = codegen;
17996
- const names_12 = names$1;
17997
- const code_12 = code;
17998
- const errors_1 = errors;
17999
- function macroKeywordCode(cxt, def2) {
18000
- const { gen, keyword: keyword2, schema: schema2, parentSchema, it: it2 } = cxt;
18001
- const macroSchema = def2.macro.call(it2.self, schema2, parentSchema, it2);
18002
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
18003
- if (it2.opts.validateSchema !== false)
18004
- it2.self.validateSchema(macroSchema, true);
18005
- const valid = gen.name("valid");
18006
- cxt.subschema({
18007
- schema: macroSchema,
18008
- schemaPath: codegen_12.nil,
18009
- errSchemaPath: `${it2.errSchemaPath}/${keyword2}`,
18010
- topSchemaRef: schemaRef,
18011
- compositeRule: true
18012
- }, valid);
18013
- cxt.pass(valid, () => cxt.error(true));
18014
- }
18015
- keyword.macroKeywordCode = macroKeywordCode;
18016
- function funcKeywordCode(cxt, def2) {
18017
- var _a;
18018
- const { gen, keyword: keyword2, schema: schema2, parentSchema, $data, it: it2 } = cxt;
18019
- checkAsyncKeyword(it2, def2);
18020
- const validate2 = !$data && def2.compile ? def2.compile.call(it2.self, schema2, parentSchema, it2) : def2.validate;
18021
- const validateRef = useKeyword(gen, keyword2, validate2);
18022
- const valid = gen.let("valid");
18023
- cxt.block$data(valid, validateKeyword);
18024
- cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
18025
- function validateKeyword() {
18026
- if (def2.errors === false) {
18027
- assignValid();
18028
- if (def2.modifying)
18029
- modifyData(cxt);
18030
- reportErrs(() => cxt.error());
18031
- } else {
18032
- const ruleErrs = def2.async ? validateAsync() : validateSync();
18033
- if (def2.modifying)
18034
- modifyData(cxt);
18035
- reportErrs(() => addErrs(cxt, ruleErrs));
18036
- }
18037
- }
18038
- function validateAsync() {
18039
- const ruleErrs = gen.let("ruleErrs", null);
18040
- gen.try(() => assignValid((0, codegen_12._)`await `), (e2) => gen.assign(valid, false).if((0, codegen_12._)`${e2} instanceof ${it2.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_12._)`${e2}.errors`), () => gen.throw(e2)));
18041
- return ruleErrs;
18042
- }
18043
- function validateSync() {
18044
- const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
18045
- gen.assign(validateErrs, null);
18046
- assignValid(codegen_12.nil);
18047
- return validateErrs;
18048
- }
18049
- function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
18050
- const passCxt = it2.opts.passContext ? names_12.default.this : names_12.default.self;
18051
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
18052
- gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
18053
- }
18054
- function reportErrs(errors2) {
18055
- var _a2;
18056
- gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
17975
+ Object.defineProperty(keyword, "__esModule", { value: true });
17976
+ keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
17977
+ const codegen_1$t = codegen;
17978
+ const names_1$7 = names$1;
17979
+ const code_1$9 = code;
17980
+ const errors_1$1 = errors;
17981
+ function macroKeywordCode(cxt, def2) {
17982
+ const { gen, keyword: keyword2, schema: schema2, parentSchema, it: it2 } = cxt;
17983
+ const macroSchema = def2.macro.call(it2.self, schema2, parentSchema, it2);
17984
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
17985
+ if (it2.opts.validateSchema !== false)
17986
+ it2.self.validateSchema(macroSchema, true);
17987
+ const valid = gen.name("valid");
17988
+ cxt.subschema({
17989
+ schema: macroSchema,
17990
+ schemaPath: codegen_1$t.nil,
17991
+ errSchemaPath: `${it2.errSchemaPath}/${keyword2}`,
17992
+ topSchemaRef: schemaRef,
17993
+ compositeRule: true
17994
+ }, valid);
17995
+ cxt.pass(valid, () => cxt.error(true));
17996
+ }
17997
+ keyword.macroKeywordCode = macroKeywordCode;
17998
+ function funcKeywordCode(cxt, def2) {
17999
+ var _a;
18000
+ const { gen, keyword: keyword2, schema: schema2, parentSchema, $data, it: it2 } = cxt;
18001
+ checkAsyncKeyword(it2, def2);
18002
+ const validate2 = !$data && def2.compile ? def2.compile.call(it2.self, schema2, parentSchema, it2) : def2.validate;
18003
+ const validateRef = useKeyword(gen, keyword2, validate2);
18004
+ const valid = gen.let("valid");
18005
+ cxt.block$data(valid, validateKeyword);
18006
+ cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
18007
+ function validateKeyword() {
18008
+ if (def2.errors === false) {
18009
+ assignValid();
18010
+ if (def2.modifying)
18011
+ modifyData(cxt);
18012
+ reportErrs(() => cxt.error());
18013
+ } else {
18014
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
18015
+ if (def2.modifying)
18016
+ modifyData(cxt);
18017
+ reportErrs(() => addErrs(cxt, ruleErrs));
18057
18018
  }
18058
18019
  }
18059
- keyword.funcKeywordCode = funcKeywordCode;
18060
- function modifyData(cxt) {
18061
- const { gen, data, it: it2 } = cxt;
18062
- gen.if(it2.parentData, () => gen.assign(data, (0, codegen_12._)`${it2.parentData}[${it2.parentDataProperty}]`));
18063
- }
18064
- function addErrs(cxt, errs) {
18065
- const { gen } = cxt;
18066
- gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
18067
- 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`);
18068
- (0, errors_1.extendErrors)(cxt);
18069
- }, () => cxt.error());
18070
- }
18071
- function checkAsyncKeyword({ schemaEnv }, def2) {
18072
- if (def2.async && !schemaEnv.$async)
18073
- throw new Error("async keyword in sync schema");
18074
- }
18075
- function useKeyword(gen, keyword2, result) {
18076
- if (result === void 0)
18077
- throw new Error(`keyword "${keyword2}" failed to compile`);
18078
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
18079
- }
18080
- function validSchemaType(schema2, schemaType, allowUndefined = false) {
18081
- return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema2) : st === "object" ? schema2 && typeof schema2 == "object" && !Array.isArray(schema2) : typeof schema2 == st || allowUndefined && typeof schema2 == "undefined");
18082
- }
18083
- keyword.validSchemaType = validSchemaType;
18084
- function validateKeywordUsage({ schema: schema2, opts, self: self2, errSchemaPath }, def2, keyword2) {
18085
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
18086
- throw new Error("ajv implementation error");
18087
- }
18088
- const deps = def2.dependencies;
18089
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema2, kwd))) {
18090
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
18091
- }
18092
- if (def2.validateSchema) {
18093
- const valid = def2.validateSchema(schema2[keyword2]);
18094
- if (!valid) {
18095
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
18096
- if (opts.validateSchema === "log")
18097
- self2.logger.error(msg);
18098
- else
18099
- throw new Error(msg);
18100
- }
18020
+ function validateAsync() {
18021
+ const ruleErrs = gen.let("ruleErrs", null);
18022
+ gen.try(() => assignValid((0, codegen_1$t._)`await `), (e2) => gen.assign(valid, false).if((0, codegen_1$t._)`${e2} instanceof ${it2.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$t._)`${e2}.errors`), () => gen.throw(e2)));
18023
+ return ruleErrs;
18024
+ }
18025
+ function validateSync() {
18026
+ const validateErrs = (0, codegen_1$t._)`${validateRef}.errors`;
18027
+ gen.assign(validateErrs, null);
18028
+ assignValid(codegen_1$t.nil);
18029
+ return validateErrs;
18030
+ }
18031
+ function assignValid(_await = def2.async ? (0, codegen_1$t._)`await ` : codegen_1$t.nil) {
18032
+ const passCxt = it2.opts.passContext ? names_1$7.default.this : names_1$7.default.self;
18033
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
18034
+ gen.assign(valid, (0, codegen_1$t._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
18035
+ }
18036
+ function reportErrs(errors2) {
18037
+ var _a2;
18038
+ gen.if((0, codegen_1$t.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
18039
+ }
18040
+ }
18041
+ keyword.funcKeywordCode = funcKeywordCode;
18042
+ function modifyData(cxt) {
18043
+ const { gen, data, it: it2 } = cxt;
18044
+ gen.if(it2.parentData, () => gen.assign(data, (0, codegen_1$t._)`${it2.parentData}[${it2.parentDataProperty}]`));
18045
+ }
18046
+ function addErrs(cxt, errs) {
18047
+ const { gen } = cxt;
18048
+ gen.if((0, codegen_1$t._)`Array.isArray(${errs})`, () => {
18049
+ gen.assign(names_1$7.default.vErrors, (0, codegen_1$t._)`${names_1$7.default.vErrors} === null ? ${errs} : ${names_1$7.default.vErrors}.concat(${errs})`).assign(names_1$7.default.errors, (0, codegen_1$t._)`${names_1$7.default.vErrors}.length`);
18050
+ (0, errors_1$1.extendErrors)(cxt);
18051
+ }, () => cxt.error());
18052
+ }
18053
+ function checkAsyncKeyword({ schemaEnv }, def2) {
18054
+ if (def2.async && !schemaEnv.$async)
18055
+ throw new Error("async keyword in sync schema");
18056
+ }
18057
+ function useKeyword(gen, keyword2, result) {
18058
+ if (result === void 0)
18059
+ throw new Error(`keyword "${keyword2}" failed to compile`);
18060
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$t.stringify)(result) });
18061
+ }
18062
+ function validSchemaType(schema2, schemaType, allowUndefined = false) {
18063
+ return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema2) : st === "object" ? schema2 && typeof schema2 == "object" && !Array.isArray(schema2) : typeof schema2 == st || allowUndefined && typeof schema2 == "undefined");
18064
+ }
18065
+ keyword.validSchemaType = validSchemaType;
18066
+ function validateKeywordUsage({ schema: schema2, opts, self: self2, errSchemaPath }, def2, keyword2) {
18067
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
18068
+ throw new Error("ajv implementation error");
18069
+ }
18070
+ const deps = def2.dependencies;
18071
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema2, kwd))) {
18072
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
18073
+ }
18074
+ if (def2.validateSchema) {
18075
+ const valid = def2.validateSchema(schema2[keyword2]);
18076
+ if (!valid) {
18077
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
18078
+ if (opts.validateSchema === "log")
18079
+ self2.logger.error(msg);
18080
+ else
18081
+ throw new Error(msg);
18101
18082
  }
18102
18083
  }
18103
- keyword.validateKeywordUsage = validateKeywordUsage;
18104
- return keyword;
18105
18084
  }
18085
+ keyword.validateKeywordUsage = validateKeywordUsage;
18106
18086
  var subschema = {};
18107
- var hasRequiredSubschema;
18108
- function requireSubschema() {
18109
- if (hasRequiredSubschema)
18110
- return subschema;
18111
- hasRequiredSubschema = 1;
18112
- Object.defineProperty(subschema, "__esModule", { value: true });
18113
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
18114
- const codegen_12 = codegen;
18115
- const util_12 = util;
18116
- function getSubschema(it2, { keyword: keyword2, schemaProp, schema: schema2, schemaPath, errSchemaPath, topSchemaRef }) {
18117
- if (keyword2 !== void 0 && schema2 !== void 0) {
18118
- throw new Error('both "keyword" and "schema" passed, only one allowed');
18119
- }
18120
- if (keyword2 !== void 0) {
18121
- const sch = it2.schema[keyword2];
18122
- return schemaProp === void 0 ? {
18123
- schema: sch,
18124
- schemaPath: (0, codegen_12._)`${it2.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
18125
- errSchemaPath: `${it2.errSchemaPath}/${keyword2}`
18126
- } : {
18127
- schema: sch[schemaProp],
18128
- schemaPath: (0, codegen_12._)`${it2.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
18129
- errSchemaPath: `${it2.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
18130
- };
18131
- }
18132
- if (schema2 !== void 0) {
18133
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
18134
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
18135
- }
18136
- return {
18137
- schema: schema2,
18138
- schemaPath,
18139
- topSchemaRef,
18140
- errSchemaPath
18141
- };
18087
+ Object.defineProperty(subschema, "__esModule", { value: true });
18088
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
18089
+ const codegen_1$s = codegen;
18090
+ const util_1$r = util;
18091
+ function getSubschema(it2, { keyword: keyword2, schemaProp, schema: schema2, schemaPath, errSchemaPath, topSchemaRef }) {
18092
+ if (keyword2 !== void 0 && schema2 !== void 0) {
18093
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
18094
+ }
18095
+ if (keyword2 !== void 0) {
18096
+ const sch = it2.schema[keyword2];
18097
+ return schemaProp === void 0 ? {
18098
+ schema: sch,
18099
+ schemaPath: (0, codegen_1$s._)`${it2.schemaPath}${(0, codegen_1$s.getProperty)(keyword2)}`,
18100
+ errSchemaPath: `${it2.errSchemaPath}/${keyword2}`
18101
+ } : {
18102
+ schema: sch[schemaProp],
18103
+ schemaPath: (0, codegen_1$s._)`${it2.schemaPath}${(0, codegen_1$s.getProperty)(keyword2)}${(0, codegen_1$s.getProperty)(schemaProp)}`,
18104
+ errSchemaPath: `${it2.errSchemaPath}/${keyword2}/${(0, util_1$r.escapeFragment)(schemaProp)}`
18105
+ };
18106
+ }
18107
+ if (schema2 !== void 0) {
18108
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
18109
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
18142
18110
  }
18143
- throw new Error('either "keyword" or "schema" must be passed');
18144
- }
18145
- subschema.getSubschema = getSubschema;
18146
- function extendSubschemaData(subschema2, it2, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
18147
- if (data !== void 0 && dataProp !== void 0) {
18148
- throw new Error('both "data" and "dataProp" passed, only one allowed');
18149
- }
18150
- const { gen } = it2;
18151
- if (dataProp !== void 0) {
18152
- const { errorPath, dataPathArr, opts } = it2;
18153
- const nextData = gen.let("data", (0, codegen_12._)`${it2.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
18154
- dataContextProps(nextData);
18155
- subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
18156
- subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
18157
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
18158
- }
18159
- if (data !== void 0) {
18160
- const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
18161
- dataContextProps(nextData);
18162
- if (propertyName !== void 0)
18163
- subschema2.propertyName = propertyName;
18164
- }
18165
- if (dataTypes)
18166
- subschema2.dataTypes = dataTypes;
18167
- function dataContextProps(_nextData) {
18168
- subschema2.data = _nextData;
18169
- subschema2.dataLevel = it2.dataLevel + 1;
18170
- subschema2.dataTypes = [];
18171
- it2.definedProperties = /* @__PURE__ */ new Set();
18172
- subschema2.parentData = it2.data;
18173
- subschema2.dataNames = [...it2.dataNames, _nextData];
18174
- }
18175
- }
18176
- subschema.extendSubschemaData = extendSubschemaData;
18177
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
18178
- if (compositeRule !== void 0)
18179
- subschema2.compositeRule = compositeRule;
18180
- if (createErrors !== void 0)
18181
- subschema2.createErrors = createErrors;
18182
- if (allErrors !== void 0)
18183
- subschema2.allErrors = allErrors;
18184
- subschema2.jtdDiscriminator = jtdDiscriminator;
18185
- subschema2.jtdMetadata = jtdMetadata;
18186
- }
18187
- subschema.extendSubschemaMode = extendSubschemaMode;
18188
- return subschema;
18189
- }
18111
+ return {
18112
+ schema: schema2,
18113
+ schemaPath,
18114
+ topSchemaRef,
18115
+ errSchemaPath
18116
+ };
18117
+ }
18118
+ throw new Error('either "keyword" or "schema" must be passed');
18119
+ }
18120
+ subschema.getSubschema = getSubschema;
18121
+ function extendSubschemaData(subschema2, it2, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
18122
+ if (data !== void 0 && dataProp !== void 0) {
18123
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
18124
+ }
18125
+ const { gen } = it2;
18126
+ if (dataProp !== void 0) {
18127
+ const { errorPath, dataPathArr, opts } = it2;
18128
+ const nextData = gen.let("data", (0, codegen_1$s._)`${it2.data}${(0, codegen_1$s.getProperty)(dataProp)}`, true);
18129
+ dataContextProps(nextData);
18130
+ subschema2.errorPath = (0, codegen_1$s.str)`${errorPath}${(0, util_1$r.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
18131
+ subschema2.parentDataProperty = (0, codegen_1$s._)`${dataProp}`;
18132
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
18133
+ }
18134
+ if (data !== void 0) {
18135
+ const nextData = data instanceof codegen_1$s.Name ? data : gen.let("data", data, true);
18136
+ dataContextProps(nextData);
18137
+ if (propertyName !== void 0)
18138
+ subschema2.propertyName = propertyName;
18139
+ }
18140
+ if (dataTypes)
18141
+ subschema2.dataTypes = dataTypes;
18142
+ function dataContextProps(_nextData) {
18143
+ subschema2.data = _nextData;
18144
+ subschema2.dataLevel = it2.dataLevel + 1;
18145
+ subschema2.dataTypes = [];
18146
+ it2.definedProperties = /* @__PURE__ */ new Set();
18147
+ subschema2.parentData = it2.data;
18148
+ subschema2.dataNames = [...it2.dataNames, _nextData];
18149
+ }
18150
+ }
18151
+ subschema.extendSubschemaData = extendSubschemaData;
18152
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
18153
+ if (compositeRule !== void 0)
18154
+ subschema2.compositeRule = compositeRule;
18155
+ if (createErrors !== void 0)
18156
+ subschema2.createErrors = createErrors;
18157
+ if (allErrors !== void 0)
18158
+ subschema2.allErrors = allErrors;
18159
+ subschema2.jtdDiscriminator = jtdDiscriminator;
18160
+ subschema2.jtdMetadata = jtdMetadata;
18161
+ }
18162
+ subschema.extendSubschemaMode = extendSubschemaMode;
18190
18163
  var resolve$1 = {};
18191
18164
  var fastDeepEqual = function equal(a, b2) {
18192
18165
  if (a === b2)
@@ -18311,7 +18284,7 @@ function escapeJsonPtr(str) {
18311
18284
  var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
18312
18285
  Object.defineProperty(resolve$1, "__esModule", { value: true });
18313
18286
  resolve$1.getSchemaRefs = resolve$1.resolveUrl = resolve$1.normalizeId = resolve$1._getFullPath = resolve$1.getFullPath = resolve$1.inlineRef = void 0;
18314
- const util_1$p = util;
18287
+ const util_1$q = util;
18315
18288
  const equal$2 = fastDeepEqual;
18316
18289
  const traverse = jsonSchemaTraverseExports;
18317
18290
  const SIMPLE_INLINED = /* @__PURE__ */ new Set([
@@ -18370,7 +18343,7 @@ function countKeys(schema2) {
18370
18343
  if (SIMPLE_INLINED.has(key))
18371
18344
  continue;
18372
18345
  if (typeof schema2[key] == "object") {
18373
- (0, util_1$p.eachItem)(schema2[key], (sch) => count += countKeys(sch));
18346
+ (0, util_1$q.eachItem)(schema2[key], (sch) => count += countKeys(sch));
18374
18347
  }
18375
18348
  if (count === Infinity)
18376
18349
  return Infinity;
@@ -18458,557 +18431,536 @@ function getSchemaRefs(schema2, baseId) {
18458
18431
  }
18459
18432
  }
18460
18433
  resolve$1.getSchemaRefs = getSchemaRefs;
18461
- var hasRequiredValidate;
18462
- function requireValidate() {
18463
- if (hasRequiredValidate)
18464
- return validate$1;
18465
- hasRequiredValidate = 1;
18466
- Object.defineProperty(validate$1, "__esModule", { value: true });
18467
- validate$1.getData = validate$1.KeywordCxt = validate$1.validateFunctionCode = void 0;
18468
- const boolSchema_1 = requireBoolSchema();
18469
- const dataType_12 = dataType;
18470
- const applicability_1 = applicability;
18471
- const dataType_2 = dataType;
18472
- const defaults_1 = requireDefaults();
18473
- const keyword_1 = requireKeyword();
18474
- const subschema_1 = requireSubschema();
18475
- const codegen_12 = codegen;
18476
- const names_12 = names$1;
18477
- const resolve_12 = resolve$1;
18478
- const util_12 = util;
18479
- const errors_1 = errors;
18480
- function validateFunctionCode(it2) {
18481
- if (isSchemaObj(it2)) {
18482
- checkKeywords(it2);
18483
- if (schemaCxtHasRules(it2)) {
18484
- topSchemaObjCode(it2);
18485
- return;
18486
- }
18434
+ Object.defineProperty(validate$1, "__esModule", { value: true });
18435
+ validate$1.getData = validate$1.KeywordCxt = validate$1.validateFunctionCode = void 0;
18436
+ const boolSchema_1 = boolSchema;
18437
+ const dataType_1$1 = dataType;
18438
+ const applicability_1 = applicability;
18439
+ const dataType_2 = dataType;
18440
+ const defaults_1 = defaults;
18441
+ const keyword_1 = keyword;
18442
+ const subschema_1 = subschema;
18443
+ const codegen_1$r = codegen;
18444
+ const names_1$6 = names$1;
18445
+ const resolve_1$2 = resolve$1;
18446
+ const util_1$p = util;
18447
+ const errors_1 = errors;
18448
+ function validateFunctionCode(it2) {
18449
+ if (isSchemaObj(it2)) {
18450
+ checkKeywords(it2);
18451
+ if (schemaCxtHasRules(it2)) {
18452
+ topSchemaObjCode(it2);
18453
+ return;
18487
18454
  }
18488
- validateFunction(it2, () => (0, boolSchema_1.topBoolOrEmptySchema)(it2));
18489
- }
18490
- validate$1.validateFunctionCode = validateFunctionCode;
18491
- function validateFunction({ gen, validateName, schema: schema2, schemaEnv, opts }, body) {
18492
- if (opts.code.es5) {
18493
- gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
18494
- gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema2, opts)}`);
18495
- destructureValCxtES5(gen, opts);
18496
- gen.code(body);
18497
- });
18498
- } else {
18499
- gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema2, opts)).code(body));
18500
- }
18501
- }
18502
- function destructureValCxt(opts) {
18503
- 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}}={}`;
18504
- }
18505
- function destructureValCxtES5(gen, opts) {
18506
- gen.if(names_12.default.valCxt, () => {
18507
- gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
18508
- gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
18509
- gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
18510
- gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
18511
- if (opts.dynamicRef)
18512
- gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
18513
- }, () => {
18514
- gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
18515
- gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
18516
- gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
18517
- gen.var(names_12.default.rootData, names_12.default.data);
18518
- if (opts.dynamicRef)
18519
- gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
18520
- });
18521
18455
  }
18522
- function topSchemaObjCode(it2) {
18523
- const { schema: schema2, opts, gen } = it2;
18524
- validateFunction(it2, () => {
18525
- if (opts.$comment && schema2.$comment)
18526
- commentKeyword(it2);
18527
- checkNoDefault(it2);
18528
- gen.let(names_12.default.vErrors, null);
18529
- gen.let(names_12.default.errors, 0);
18530
- if (opts.unevaluated)
18531
- resetEvaluated(it2);
18532
- typeAndKeywords(it2);
18533
- returnResults(it2);
18456
+ validateFunction(it2, () => (0, boolSchema_1.topBoolOrEmptySchema)(it2));
18457
+ }
18458
+ validate$1.validateFunctionCode = validateFunctionCode;
18459
+ function validateFunction({ gen, validateName, schema: schema2, schemaEnv, opts }, body) {
18460
+ if (opts.code.es5) {
18461
+ gen.func(validateName, (0, codegen_1$r._)`${names_1$6.default.data}, ${names_1$6.default.valCxt}`, schemaEnv.$async, () => {
18462
+ gen.code((0, codegen_1$r._)`"use strict"; ${funcSourceUrl(schema2, opts)}`);
18463
+ destructureValCxtES5(gen, opts);
18464
+ gen.code(body);
18534
18465
  });
18535
- return;
18536
- }
18537
- function resetEvaluated(it2) {
18538
- const { gen, validateName } = it2;
18539
- it2.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
18540
- gen.if((0, codegen_12._)`${it2.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it2.evaluated}.props`, (0, codegen_12._)`undefined`));
18541
- gen.if((0, codegen_12._)`${it2.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it2.evaluated}.items`, (0, codegen_12._)`undefined`));
18542
- }
18543
- function funcSourceUrl(schema2, opts) {
18544
- const schId = typeof schema2 == "object" && schema2[opts.schemaId];
18545
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
18546
- }
18547
- function subschemaCode(it2, valid) {
18548
- if (isSchemaObj(it2)) {
18549
- checkKeywords(it2);
18550
- if (schemaCxtHasRules(it2)) {
18551
- subSchemaObjCode(it2, valid);
18552
- return;
18553
- }
18554
- }
18555
- (0, boolSchema_1.boolOrEmptySchema)(it2, valid);
18556
- }
18557
- function schemaCxtHasRules({ schema: schema2, self: self2 }) {
18558
- if (typeof schema2 == "boolean")
18559
- return !schema2;
18560
- for (const key in schema2)
18561
- if (self2.RULES.all[key])
18562
- return true;
18563
- return false;
18564
- }
18565
- function isSchemaObj(it2) {
18566
- return typeof it2.schema != "boolean";
18567
- }
18568
- function subSchemaObjCode(it2, valid) {
18569
- const { schema: schema2, gen, opts } = it2;
18466
+ } else {
18467
+ gen.func(validateName, (0, codegen_1$r._)`${names_1$6.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema2, opts)).code(body));
18468
+ }
18469
+ }
18470
+ function destructureValCxt(opts) {
18471
+ return (0, codegen_1$r._)`{${names_1$6.default.instancePath}="", ${names_1$6.default.parentData}, ${names_1$6.default.parentDataProperty}, ${names_1$6.default.rootData}=${names_1$6.default.data}${opts.dynamicRef ? (0, codegen_1$r._)`, ${names_1$6.default.dynamicAnchors}={}` : codegen_1$r.nil}}={}`;
18472
+ }
18473
+ function destructureValCxtES5(gen, opts) {
18474
+ gen.if(names_1$6.default.valCxt, () => {
18475
+ gen.var(names_1$6.default.instancePath, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.instancePath}`);
18476
+ gen.var(names_1$6.default.parentData, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.parentData}`);
18477
+ gen.var(names_1$6.default.parentDataProperty, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.parentDataProperty}`);
18478
+ gen.var(names_1$6.default.rootData, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.rootData}`);
18479
+ if (opts.dynamicRef)
18480
+ gen.var(names_1$6.default.dynamicAnchors, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.dynamicAnchors}`);
18481
+ }, () => {
18482
+ gen.var(names_1$6.default.instancePath, (0, codegen_1$r._)`""`);
18483
+ gen.var(names_1$6.default.parentData, (0, codegen_1$r._)`undefined`);
18484
+ gen.var(names_1$6.default.parentDataProperty, (0, codegen_1$r._)`undefined`);
18485
+ gen.var(names_1$6.default.rootData, names_1$6.default.data);
18486
+ if (opts.dynamicRef)
18487
+ gen.var(names_1$6.default.dynamicAnchors, (0, codegen_1$r._)`{}`);
18488
+ });
18489
+ }
18490
+ function topSchemaObjCode(it2) {
18491
+ const { schema: schema2, opts, gen } = it2;
18492
+ validateFunction(it2, () => {
18570
18493
  if (opts.$comment && schema2.$comment)
18571
18494
  commentKeyword(it2);
18572
- updateContext(it2);
18573
- checkAsyncSchema(it2);
18574
- const errsCount = gen.const("_errs", names_12.default.errors);
18575
- typeAndKeywords(it2, errsCount);
18576
- gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
18577
- }
18578
- function checkKeywords(it2) {
18579
- (0, util_12.checkUnknownRules)(it2);
18580
- checkRefsAndKeywords(it2);
18581
- }
18582
- function typeAndKeywords(it2, errsCount) {
18583
- if (it2.opts.jtd)
18584
- return schemaKeywords(it2, [], false, errsCount);
18585
- const types2 = (0, dataType_12.getSchemaTypes)(it2.schema);
18586
- const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it2, types2);
18587
- schemaKeywords(it2, types2, !checkedTypes, errsCount);
18588
- }
18589
- function checkRefsAndKeywords(it2) {
18590
- const { schema: schema2, errSchemaPath, opts, self: self2 } = it2;
18591
- if (schema2.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema2, self2.RULES)) {
18592
- self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
18593
- }
18594
- }
18595
- function checkNoDefault(it2) {
18596
- const { schema: schema2, opts } = it2;
18597
- if (schema2.default !== void 0 && opts.useDefaults && opts.strictSchema) {
18598
- (0, util_12.checkStrictMode)(it2, "default is ignored in the schema root");
18599
- }
18600
- }
18601
- function updateContext(it2) {
18602
- const schId = it2.schema[it2.opts.schemaId];
18603
- if (schId)
18604
- it2.baseId = (0, resolve_12.resolveUrl)(it2.opts.uriResolver, it2.baseId, schId);
18605
- }
18606
- function checkAsyncSchema(it2) {
18607
- if (it2.schema.$async && !it2.schemaEnv.$async)
18608
- throw new Error("async schema in sync schema");
18609
- }
18610
- function commentKeyword({ gen, schemaEnv, schema: schema2, errSchemaPath, opts }) {
18611
- const msg = schema2.$comment;
18612
- if (opts.$comment === true) {
18613
- gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
18614
- } else if (typeof opts.$comment == "function") {
18615
- const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
18616
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
18617
- gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
18618
- }
18619
- }
18620
- function returnResults(it2) {
18621
- const { gen, schemaEnv, validateName, ValidationError, opts } = it2;
18622
- if (schemaEnv.$async) {
18623
- 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})`));
18624
- } else {
18625
- gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
18626
- if (opts.unevaluated)
18627
- assignEvaluated(it2);
18628
- gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
18629
- }
18630
- }
18631
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
18632
- if (props instanceof codegen_12.Name)
18633
- gen.assign((0, codegen_12._)`${evaluated}.props`, props);
18634
- if (items2 instanceof codegen_12.Name)
18635
- gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
18636
- }
18637
- function schemaKeywords(it2, types2, typeErrors, errsCount) {
18638
- const { gen, schema: schema2, data, allErrors, opts, self: self2 } = it2;
18639
- const { RULES } = self2;
18640
- if (schema2.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema2, RULES))) {
18641
- gen.block(() => keywordCode(it2, "$ref", RULES.all.$ref.definition));
18495
+ checkNoDefault(it2);
18496
+ gen.let(names_1$6.default.vErrors, null);
18497
+ gen.let(names_1$6.default.errors, 0);
18498
+ if (opts.unevaluated)
18499
+ resetEvaluated(it2);
18500
+ typeAndKeywords(it2);
18501
+ returnResults(it2);
18502
+ });
18503
+ return;
18504
+ }
18505
+ function resetEvaluated(it2) {
18506
+ const { gen, validateName } = it2;
18507
+ it2.evaluated = gen.const("evaluated", (0, codegen_1$r._)`${validateName}.evaluated`);
18508
+ gen.if((0, codegen_1$r._)`${it2.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$r._)`${it2.evaluated}.props`, (0, codegen_1$r._)`undefined`));
18509
+ gen.if((0, codegen_1$r._)`${it2.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$r._)`${it2.evaluated}.items`, (0, codegen_1$r._)`undefined`));
18510
+ }
18511
+ function funcSourceUrl(schema2, opts) {
18512
+ const schId = typeof schema2 == "object" && schema2[opts.schemaId];
18513
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$r._)`/*# sourceURL=${schId} */` : codegen_1$r.nil;
18514
+ }
18515
+ function subschemaCode(it2, valid) {
18516
+ if (isSchemaObj(it2)) {
18517
+ checkKeywords(it2);
18518
+ if (schemaCxtHasRules(it2)) {
18519
+ subSchemaObjCode(it2, valid);
18642
18520
  return;
18643
18521
  }
18644
- if (!opts.jtd)
18645
- checkStrictTypes(it2, types2);
18646
- gen.block(() => {
18647
- for (const group of RULES.rules)
18648
- groupKeywords(group);
18649
- groupKeywords(RULES.post);
18650
- });
18651
- function groupKeywords(group) {
18652
- if (!(0, applicability_1.shouldUseGroup)(schema2, group))
18653
- return;
18654
- if (group.type) {
18655
- gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
18656
- iterateKeywords(it2, group);
18657
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
18658
- gen.else();
18659
- (0, dataType_2.reportTypeError)(it2);
18660
- }
18661
- gen.endIf();
18662
- } else {
18663
- iterateKeywords(it2, group);
18664
- }
18665
- if (!allErrors)
18666
- gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
18667
- }
18668
- }
18669
- function iterateKeywords(it2, group) {
18670
- const { gen, schema: schema2, opts: { useDefaults } } = it2;
18671
- if (useDefaults)
18672
- (0, defaults_1.assignDefaults)(it2, group.type);
18673
- gen.block(() => {
18674
- for (const rule of group.rules) {
18675
- if ((0, applicability_1.shouldUseRule)(schema2, rule)) {
18676
- keywordCode(it2, rule.keyword, rule.definition, group.type);
18677
- }
18678
- }
18679
- });
18680
18522
  }
18681
- function checkStrictTypes(it2, types2) {
18682
- if (it2.schemaEnv.meta || !it2.opts.strictTypes)
18683
- return;
18684
- checkContextTypes(it2, types2);
18685
- if (!it2.opts.allowUnionTypes)
18686
- checkMultipleTypes(it2, types2);
18687
- checkKeywordTypes(it2, it2.dataTypes);
18523
+ (0, boolSchema_1.boolOrEmptySchema)(it2, valid);
18524
+ }
18525
+ function schemaCxtHasRules({ schema: schema2, self: self2 }) {
18526
+ if (typeof schema2 == "boolean")
18527
+ return !schema2;
18528
+ for (const key in schema2)
18529
+ if (self2.RULES.all[key])
18530
+ return true;
18531
+ return false;
18532
+ }
18533
+ function isSchemaObj(it2) {
18534
+ return typeof it2.schema != "boolean";
18535
+ }
18536
+ function subSchemaObjCode(it2, valid) {
18537
+ const { schema: schema2, gen, opts } = it2;
18538
+ if (opts.$comment && schema2.$comment)
18539
+ commentKeyword(it2);
18540
+ updateContext(it2);
18541
+ checkAsyncSchema(it2);
18542
+ const errsCount = gen.const("_errs", names_1$6.default.errors);
18543
+ typeAndKeywords(it2, errsCount);
18544
+ gen.var(valid, (0, codegen_1$r._)`${errsCount} === ${names_1$6.default.errors}`);
18545
+ }
18546
+ function checkKeywords(it2) {
18547
+ (0, util_1$p.checkUnknownRules)(it2);
18548
+ checkRefsAndKeywords(it2);
18549
+ }
18550
+ function typeAndKeywords(it2, errsCount) {
18551
+ if (it2.opts.jtd)
18552
+ return schemaKeywords(it2, [], false, errsCount);
18553
+ const types2 = (0, dataType_1$1.getSchemaTypes)(it2.schema);
18554
+ const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it2, types2);
18555
+ schemaKeywords(it2, types2, !checkedTypes, errsCount);
18556
+ }
18557
+ function checkRefsAndKeywords(it2) {
18558
+ const { schema: schema2, errSchemaPath, opts, self: self2 } = it2;
18559
+ if (schema2.$ref && opts.ignoreKeywordsWithRef && (0, util_1$p.schemaHasRulesButRef)(schema2, self2.RULES)) {
18560
+ self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
18561
+ }
18562
+ }
18563
+ function checkNoDefault(it2) {
18564
+ const { schema: schema2, opts } = it2;
18565
+ if (schema2.default !== void 0 && opts.useDefaults && opts.strictSchema) {
18566
+ (0, util_1$p.checkStrictMode)(it2, "default is ignored in the schema root");
18567
+ }
18568
+ }
18569
+ function updateContext(it2) {
18570
+ const schId = it2.schema[it2.opts.schemaId];
18571
+ if (schId)
18572
+ it2.baseId = (0, resolve_1$2.resolveUrl)(it2.opts.uriResolver, it2.baseId, schId);
18573
+ }
18574
+ function checkAsyncSchema(it2) {
18575
+ if (it2.schema.$async && !it2.schemaEnv.$async)
18576
+ throw new Error("async schema in sync schema");
18577
+ }
18578
+ function commentKeyword({ gen, schemaEnv, schema: schema2, errSchemaPath, opts }) {
18579
+ const msg = schema2.$comment;
18580
+ if (opts.$comment === true) {
18581
+ gen.code((0, codegen_1$r._)`${names_1$6.default.self}.logger.log(${msg})`);
18582
+ } else if (typeof opts.$comment == "function") {
18583
+ const schemaPath = (0, codegen_1$r.str)`${errSchemaPath}/$comment`;
18584
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
18585
+ gen.code((0, codegen_1$r._)`${names_1$6.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
18586
+ }
18587
+ }
18588
+ function returnResults(it2) {
18589
+ const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it2;
18590
+ if (schemaEnv.$async) {
18591
+ gen.if((0, codegen_1$r._)`${names_1$6.default.errors} === 0`, () => gen.return(names_1$6.default.data), () => gen.throw((0, codegen_1$r._)`new ${ValidationError2}(${names_1$6.default.vErrors})`));
18592
+ } else {
18593
+ gen.assign((0, codegen_1$r._)`${validateName}.errors`, names_1$6.default.vErrors);
18594
+ if (opts.unevaluated)
18595
+ assignEvaluated(it2);
18596
+ gen.return((0, codegen_1$r._)`${names_1$6.default.errors} === 0`);
18597
+ }
18598
+ }
18599
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
18600
+ if (props instanceof codegen_1$r.Name)
18601
+ gen.assign((0, codegen_1$r._)`${evaluated}.props`, props);
18602
+ if (items2 instanceof codegen_1$r.Name)
18603
+ gen.assign((0, codegen_1$r._)`${evaluated}.items`, items2);
18604
+ }
18605
+ function schemaKeywords(it2, types2, typeErrors, errsCount) {
18606
+ const { gen, schema: schema2, data, allErrors, opts, self: self2 } = it2;
18607
+ const { RULES } = self2;
18608
+ if (schema2.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$p.schemaHasRulesButRef)(schema2, RULES))) {
18609
+ gen.block(() => keywordCode(it2, "$ref", RULES.all.$ref.definition));
18610
+ return;
18688
18611
  }
18689
- function checkContextTypes(it2, types2) {
18690
- if (!types2.length)
18691
- return;
18692
- if (!it2.dataTypes.length) {
18693
- it2.dataTypes = types2;
18612
+ if (!opts.jtd)
18613
+ checkStrictTypes(it2, types2);
18614
+ gen.block(() => {
18615
+ for (const group of RULES.rules)
18616
+ groupKeywords(group);
18617
+ groupKeywords(RULES.post);
18618
+ });
18619
+ function groupKeywords(group) {
18620
+ if (!(0, applicability_1.shouldUseGroup)(schema2, group))
18694
18621
  return;
18695
- }
18696
- types2.forEach((t2) => {
18697
- if (!includesType(it2.dataTypes, t2)) {
18698
- strictTypesError(it2, `type "${t2}" not allowed by context "${it2.dataTypes.join(",")}"`);
18622
+ if (group.type) {
18623
+ gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
18624
+ iterateKeywords(it2, group);
18625
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
18626
+ gen.else();
18627
+ (0, dataType_2.reportTypeError)(it2);
18699
18628
  }
18700
- });
18701
- narrowSchemaTypes(it2, types2);
18702
- }
18703
- function checkMultipleTypes(it2, ts2) {
18704
- if (ts2.length > 1 && !(ts2.length === 2 && ts2.includes("null"))) {
18705
- strictTypesError(it2, "use allowUnionTypes to allow union type keyword");
18629
+ gen.endIf();
18630
+ } else {
18631
+ iterateKeywords(it2, group);
18706
18632
  }
18633
+ if (!allErrors)
18634
+ gen.if((0, codegen_1$r._)`${names_1$6.default.errors} === ${errsCount || 0}`);
18707
18635
  }
18708
- function checkKeywordTypes(it2, ts2) {
18709
- const rules2 = it2.self.RULES.all;
18710
- for (const keyword2 in rules2) {
18711
- const rule = rules2[keyword2];
18712
- if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it2.schema, rule)) {
18713
- const { type: type2 } = rule.definition;
18714
- if (type2.length && !type2.some((t2) => hasApplicableType(ts2, t2))) {
18715
- strictTypesError(it2, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
18716
- }
18636
+ }
18637
+ function iterateKeywords(it2, group) {
18638
+ const { gen, schema: schema2, opts: { useDefaults } } = it2;
18639
+ if (useDefaults)
18640
+ (0, defaults_1.assignDefaults)(it2, group.type);
18641
+ gen.block(() => {
18642
+ for (const rule of group.rules) {
18643
+ if ((0, applicability_1.shouldUseRule)(schema2, rule)) {
18644
+ keywordCode(it2, rule.keyword, rule.definition, group.type);
18717
18645
  }
18718
18646
  }
18647
+ });
18648
+ }
18649
+ function checkStrictTypes(it2, types2) {
18650
+ if (it2.schemaEnv.meta || !it2.opts.strictTypes)
18651
+ return;
18652
+ checkContextTypes(it2, types2);
18653
+ if (!it2.opts.allowUnionTypes)
18654
+ checkMultipleTypes(it2, types2);
18655
+ checkKeywordTypes(it2, it2.dataTypes);
18656
+ }
18657
+ function checkContextTypes(it2, types2) {
18658
+ if (!types2.length)
18659
+ return;
18660
+ if (!it2.dataTypes.length) {
18661
+ it2.dataTypes = types2;
18662
+ return;
18719
18663
  }
18720
- function hasApplicableType(schTs, kwdT) {
18721
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
18722
- }
18723
- function includesType(ts2, t2) {
18724
- return ts2.includes(t2) || t2 === "integer" && ts2.includes("number");
18725
- }
18726
- function narrowSchemaTypes(it2, withTypes) {
18727
- const ts2 = [];
18728
- for (const t2 of it2.dataTypes) {
18729
- if (includesType(withTypes, t2))
18730
- ts2.push(t2);
18731
- else if (withTypes.includes("integer") && t2 === "number")
18732
- ts2.push("integer");
18733
- }
18734
- it2.dataTypes = ts2;
18735
- }
18736
- function strictTypesError(it2, msg) {
18737
- const schemaPath = it2.schemaEnv.baseId + it2.errSchemaPath;
18738
- msg += ` at "${schemaPath}" (strictTypes)`;
18739
- (0, util_12.checkStrictMode)(it2, msg, it2.opts.strictTypes);
18740
- }
18741
- class KeywordCxt {
18742
- constructor(it2, def2, keyword2) {
18743
- (0, keyword_1.validateKeywordUsage)(it2, def2, keyword2);
18744
- this.gen = it2.gen;
18745
- this.allErrors = it2.allErrors;
18746
- this.keyword = keyword2;
18747
- this.data = it2.data;
18748
- this.schema = it2.schema[keyword2];
18749
- this.$data = def2.$data && it2.opts.$data && this.schema && this.schema.$data;
18750
- this.schemaValue = (0, util_12.schemaRefOrVal)(it2, this.schema, keyword2, this.$data);
18751
- this.schemaType = def2.schemaType;
18752
- this.parentSchema = it2.schema;
18753
- this.params = {};
18754
- this.it = it2;
18755
- this.def = def2;
18756
- if (this.$data) {
18757
- this.schemaCode = it2.gen.const("vSchema", getData(this.$data, it2));
18758
- } else {
18759
- this.schemaCode = this.schemaValue;
18760
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
18761
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
18762
- }
18763
- }
18764
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
18765
- this.errsCount = it2.gen.const("_errs", names_12.default.errors);
18766
- }
18664
+ types2.forEach((t2) => {
18665
+ if (!includesType(it2.dataTypes, t2)) {
18666
+ strictTypesError(it2, `type "${t2}" not allowed by context "${it2.dataTypes.join(",")}"`);
18767
18667
  }
18768
- result(condition, successAction, failAction) {
18769
- this.failResult((0, codegen_12.not)(condition), successAction, failAction);
18770
- }
18771
- failResult(condition, successAction, failAction) {
18772
- this.gen.if(condition);
18773
- if (failAction)
18774
- failAction();
18775
- else
18776
- this.error();
18777
- if (successAction) {
18778
- this.gen.else();
18779
- successAction();
18780
- if (this.allErrors)
18781
- this.gen.endIf();
18782
- } else {
18783
- if (this.allErrors)
18784
- this.gen.endIf();
18785
- else
18786
- this.gen.else();
18668
+ });
18669
+ narrowSchemaTypes(it2, types2);
18670
+ }
18671
+ function checkMultipleTypes(it2, ts2) {
18672
+ if (ts2.length > 1 && !(ts2.length === 2 && ts2.includes("null"))) {
18673
+ strictTypesError(it2, "use allowUnionTypes to allow union type keyword");
18674
+ }
18675
+ }
18676
+ function checkKeywordTypes(it2, ts2) {
18677
+ const rules2 = it2.self.RULES.all;
18678
+ for (const keyword2 in rules2) {
18679
+ const rule = rules2[keyword2];
18680
+ if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it2.schema, rule)) {
18681
+ const { type: type2 } = rule.definition;
18682
+ if (type2.length && !type2.some((t2) => hasApplicableType(ts2, t2))) {
18683
+ strictTypesError(it2, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
18684
+ }
18685
+ }
18686
+ }
18687
+ }
18688
+ function hasApplicableType(schTs, kwdT) {
18689
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
18690
+ }
18691
+ function includesType(ts2, t2) {
18692
+ return ts2.includes(t2) || t2 === "integer" && ts2.includes("number");
18693
+ }
18694
+ function narrowSchemaTypes(it2, withTypes) {
18695
+ const ts2 = [];
18696
+ for (const t2 of it2.dataTypes) {
18697
+ if (includesType(withTypes, t2))
18698
+ ts2.push(t2);
18699
+ else if (withTypes.includes("integer") && t2 === "number")
18700
+ ts2.push("integer");
18701
+ }
18702
+ it2.dataTypes = ts2;
18703
+ }
18704
+ function strictTypesError(it2, msg) {
18705
+ const schemaPath = it2.schemaEnv.baseId + it2.errSchemaPath;
18706
+ msg += ` at "${schemaPath}" (strictTypes)`;
18707
+ (0, util_1$p.checkStrictMode)(it2, msg, it2.opts.strictTypes);
18708
+ }
18709
+ class KeywordCxt {
18710
+ constructor(it2, def2, keyword2) {
18711
+ (0, keyword_1.validateKeywordUsage)(it2, def2, keyword2);
18712
+ this.gen = it2.gen;
18713
+ this.allErrors = it2.allErrors;
18714
+ this.keyword = keyword2;
18715
+ this.data = it2.data;
18716
+ this.schema = it2.schema[keyword2];
18717
+ this.$data = def2.$data && it2.opts.$data && this.schema && this.schema.$data;
18718
+ this.schemaValue = (0, util_1$p.schemaRefOrVal)(it2, this.schema, keyword2, this.$data);
18719
+ this.schemaType = def2.schemaType;
18720
+ this.parentSchema = it2.schema;
18721
+ this.params = {};
18722
+ this.it = it2;
18723
+ this.def = def2;
18724
+ if (this.$data) {
18725
+ this.schemaCode = it2.gen.const("vSchema", getData(this.$data, it2));
18726
+ } else {
18727
+ this.schemaCode = this.schemaValue;
18728
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
18729
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
18787
18730
  }
18788
18731
  }
18789
- pass(condition, failAction) {
18790
- this.failResult((0, codegen_12.not)(condition), void 0, failAction);
18732
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
18733
+ this.errsCount = it2.gen.const("_errs", names_1$6.default.errors);
18791
18734
  }
18792
- fail(condition) {
18793
- if (condition === void 0) {
18794
- this.error();
18795
- if (!this.allErrors)
18796
- this.gen.if(false);
18797
- return;
18798
- }
18799
- this.gen.if(condition);
18735
+ }
18736
+ result(condition, successAction, failAction) {
18737
+ this.failResult((0, codegen_1$r.not)(condition), successAction, failAction);
18738
+ }
18739
+ failResult(condition, successAction, failAction) {
18740
+ this.gen.if(condition);
18741
+ if (failAction)
18742
+ failAction();
18743
+ else
18800
18744
  this.error();
18745
+ if (successAction) {
18746
+ this.gen.else();
18747
+ successAction();
18748
+ if (this.allErrors)
18749
+ this.gen.endIf();
18750
+ } else {
18801
18751
  if (this.allErrors)
18802
18752
  this.gen.endIf();
18803
18753
  else
18804
18754
  this.gen.else();
18805
18755
  }
18806
- fail$data(condition) {
18807
- if (!this.$data)
18808
- return this.fail(condition);
18809
- const { schemaCode } = this;
18810
- this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
18811
- }
18812
- error(append2, errorParams, errorPaths) {
18813
- if (errorParams) {
18814
- this.setParams(errorParams);
18815
- this._error(append2, errorPaths);
18816
- this.setParams({});
18817
- return;
18818
- }
18819
- this._error(append2, errorPaths);
18820
- }
18821
- _error(append2, errorPaths) {
18822
- (append2 ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
18823
- }
18824
- $dataError() {
18825
- (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
18826
- }
18827
- reset() {
18828
- if (this.errsCount === void 0)
18829
- throw new Error('add "trackErrors" to keyword definition');
18830
- (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
18831
- }
18832
- ok(cond) {
18756
+ }
18757
+ pass(condition, failAction) {
18758
+ this.failResult((0, codegen_1$r.not)(condition), void 0, failAction);
18759
+ }
18760
+ fail(condition) {
18761
+ if (condition === void 0) {
18762
+ this.error();
18833
18763
  if (!this.allErrors)
18834
- this.gen.if(cond);
18764
+ this.gen.if(false);
18765
+ return;
18835
18766
  }
18836
- setParams(obj, assign) {
18837
- if (assign)
18838
- Object.assign(this.params, obj);
18839
- else
18840
- this.params = obj;
18767
+ this.gen.if(condition);
18768
+ this.error();
18769
+ if (this.allErrors)
18770
+ this.gen.endIf();
18771
+ else
18772
+ this.gen.else();
18773
+ }
18774
+ fail$data(condition) {
18775
+ if (!this.$data)
18776
+ return this.fail(condition);
18777
+ const { schemaCode } = this;
18778
+ this.fail((0, codegen_1$r._)`${schemaCode} !== undefined && (${(0, codegen_1$r.or)(this.invalid$data(), condition)})`);
18779
+ }
18780
+ error(append2, errorParams, errorPaths) {
18781
+ if (errorParams) {
18782
+ this.setParams(errorParams);
18783
+ this._error(append2, errorPaths);
18784
+ this.setParams({});
18785
+ return;
18841
18786
  }
18842
- block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
18843
- this.gen.block(() => {
18844
- this.check$data(valid, $dataValid);
18845
- codeBlock();
18846
- });
18787
+ this._error(append2, errorPaths);
18788
+ }
18789
+ _error(append2, errorPaths) {
18790
+ (append2 ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
18791
+ }
18792
+ $dataError() {
18793
+ (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
18794
+ }
18795
+ reset() {
18796
+ if (this.errsCount === void 0)
18797
+ throw new Error('add "trackErrors" to keyword definition');
18798
+ (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
18799
+ }
18800
+ ok(cond) {
18801
+ if (!this.allErrors)
18802
+ this.gen.if(cond);
18803
+ }
18804
+ setParams(obj, assign) {
18805
+ if (assign)
18806
+ Object.assign(this.params, obj);
18807
+ else
18808
+ this.params = obj;
18809
+ }
18810
+ block$data(valid, codeBlock, $dataValid = codegen_1$r.nil) {
18811
+ this.gen.block(() => {
18812
+ this.check$data(valid, $dataValid);
18813
+ codeBlock();
18814
+ });
18815
+ }
18816
+ check$data(valid = codegen_1$r.nil, $dataValid = codegen_1$r.nil) {
18817
+ if (!this.$data)
18818
+ return;
18819
+ const { gen, schemaCode, schemaType, def: def2 } = this;
18820
+ gen.if((0, codegen_1$r.or)((0, codegen_1$r._)`${schemaCode} === undefined`, $dataValid));
18821
+ if (valid !== codegen_1$r.nil)
18822
+ gen.assign(valid, true);
18823
+ if (schemaType.length || def2.validateSchema) {
18824
+ gen.elseIf(this.invalid$data());
18825
+ this.$dataError();
18826
+ if (valid !== codegen_1$r.nil)
18827
+ gen.assign(valid, false);
18847
18828
  }
18848
- check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
18849
- if (!this.$data)
18850
- return;
18851
- const { gen, schemaCode, schemaType, def: def2 } = this;
18852
- gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
18853
- if (valid !== codegen_12.nil)
18854
- gen.assign(valid, true);
18855
- if (schemaType.length || def2.validateSchema) {
18856
- gen.elseIf(this.invalid$data());
18857
- this.$dataError();
18858
- if (valid !== codegen_12.nil)
18859
- gen.assign(valid, false);
18829
+ gen.else();
18830
+ }
18831
+ invalid$data() {
18832
+ const { gen, schemaCode, schemaType, def: def2, it: it2 } = this;
18833
+ return (0, codegen_1$r.or)(wrong$DataType(), invalid$DataSchema());
18834
+ function wrong$DataType() {
18835
+ if (schemaType.length) {
18836
+ if (!(schemaCode instanceof codegen_1$r.Name))
18837
+ throw new Error("ajv implementation error");
18838
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
18839
+ return (0, codegen_1$r._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it2.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
18860
18840
  }
18861
- gen.else();
18841
+ return codegen_1$r.nil;
18862
18842
  }
18863
- invalid$data() {
18864
- const { gen, schemaCode, schemaType, def: def2, it: it2 } = this;
18865
- return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
18866
- function wrong$DataType() {
18867
- if (schemaType.length) {
18868
- if (!(schemaCode instanceof codegen_12.Name))
18869
- throw new Error("ajv implementation error");
18870
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
18871
- return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it2.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
18872
- }
18873
- return codegen_12.nil;
18874
- }
18875
- function invalid$DataSchema() {
18876
- if (def2.validateSchema) {
18877
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
18878
- return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
18879
- }
18880
- return codegen_12.nil;
18843
+ function invalid$DataSchema() {
18844
+ if (def2.validateSchema) {
18845
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
18846
+ return (0, codegen_1$r._)`!${validateSchemaRef}(${schemaCode})`;
18881
18847
  }
18848
+ return codegen_1$r.nil;
18882
18849
  }
18883
- subschema(appl, valid) {
18884
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
18885
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
18886
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
18887
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
18888
- subschemaCode(nextContext, valid);
18889
- return nextContext;
18850
+ }
18851
+ subschema(appl, valid) {
18852
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
18853
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
18854
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
18855
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
18856
+ subschemaCode(nextContext, valid);
18857
+ return nextContext;
18858
+ }
18859
+ mergeEvaluated(schemaCxt, toName) {
18860
+ const { it: it2, gen } = this;
18861
+ if (!it2.opts.unevaluated)
18862
+ return;
18863
+ if (it2.props !== true && schemaCxt.props !== void 0) {
18864
+ it2.props = util_1$p.mergeEvaluated.props(gen, schemaCxt.props, it2.props, toName);
18890
18865
  }
18891
- mergeEvaluated(schemaCxt, toName) {
18892
- const { it: it2, gen } = this;
18893
- if (!it2.opts.unevaluated)
18894
- return;
18895
- if (it2.props !== true && schemaCxt.props !== void 0) {
18896
- it2.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it2.props, toName);
18897
- }
18898
- if (it2.items !== true && schemaCxt.items !== void 0) {
18899
- it2.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it2.items, toName);
18900
- }
18866
+ if (it2.items !== true && schemaCxt.items !== void 0) {
18867
+ it2.items = util_1$p.mergeEvaluated.items(gen, schemaCxt.items, it2.items, toName);
18901
18868
  }
18902
- mergeValidEvaluated(schemaCxt, valid) {
18903
- const { it: it2, gen } = this;
18904
- if (it2.opts.unevaluated && (it2.props !== true || it2.items !== true)) {
18905
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
18906
- return true;
18907
- }
18869
+ }
18870
+ mergeValidEvaluated(schemaCxt, valid) {
18871
+ const { it: it2, gen } = this;
18872
+ if (it2.opts.unevaluated && (it2.props !== true || it2.items !== true)) {
18873
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$r.Name));
18874
+ return true;
18908
18875
  }
18909
18876
  }
18910
- validate$1.KeywordCxt = KeywordCxt;
18911
- function keywordCode(it2, keyword2, def2, ruleType) {
18912
- const cxt = new KeywordCxt(it2, def2, keyword2);
18913
- if ("code" in def2) {
18914
- def2.code(cxt, ruleType);
18915
- } else if (cxt.$data && def2.validate) {
18916
- (0, keyword_1.funcKeywordCode)(cxt, def2);
18917
- } else if ("macro" in def2) {
18918
- (0, keyword_1.macroKeywordCode)(cxt, def2);
18919
- } else if (def2.compile || def2.validate) {
18920
- (0, keyword_1.funcKeywordCode)(cxt, def2);
18921
- }
18922
- }
18923
- const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
18924
- const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
18925
- function getData($data, { dataLevel, dataNames, dataPathArr }) {
18926
- let jsonPointer;
18927
- let data;
18928
- if ($data === "")
18929
- return names_12.default.rootData;
18930
- if ($data[0] === "/") {
18931
- if (!JSON_POINTER.test($data))
18932
- throw new Error(`Invalid JSON-pointer: ${$data}`);
18933
- jsonPointer = $data;
18934
- data = names_12.default.rootData;
18935
- } else {
18936
- const matches = RELATIVE_JSON_POINTER.exec($data);
18937
- if (!matches)
18938
- throw new Error(`Invalid JSON-pointer: ${$data}`);
18939
- const up = +matches[1];
18940
- jsonPointer = matches[2];
18941
- if (jsonPointer === "#") {
18942
- if (up >= dataLevel)
18943
- throw new Error(errorMsg("property/index", up));
18944
- return dataPathArr[dataLevel - up];
18945
- }
18946
- if (up > dataLevel)
18947
- throw new Error(errorMsg("data", up));
18948
- data = dataNames[dataLevel - up];
18949
- if (!jsonPointer)
18950
- return data;
18951
- }
18952
- let expr = data;
18953
- const segments = jsonPointer.split("/");
18954
- for (const segment of segments) {
18955
- if (segment) {
18956
- data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
18957
- expr = (0, codegen_12._)`${expr} && ${data}`;
18958
- }
18959
- }
18960
- return expr;
18961
- function errorMsg(pointerType, up) {
18962
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
18963
- }
18964
- }
18965
- validate$1.getData = getData;
18966
- return validate$1;
18967
18877
  }
18878
+ validate$1.KeywordCxt = KeywordCxt;
18879
+ function keywordCode(it2, keyword2, def2, ruleType) {
18880
+ const cxt = new KeywordCxt(it2, def2, keyword2);
18881
+ if ("code" in def2) {
18882
+ def2.code(cxt, ruleType);
18883
+ } else if (cxt.$data && def2.validate) {
18884
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
18885
+ } else if ("macro" in def2) {
18886
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
18887
+ } else if (def2.compile || def2.validate) {
18888
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
18889
+ }
18890
+ }
18891
+ const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
18892
+ const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
18893
+ function getData($data, { dataLevel, dataNames, dataPathArr }) {
18894
+ let jsonPointer;
18895
+ let data;
18896
+ if ($data === "")
18897
+ return names_1$6.default.rootData;
18898
+ if ($data[0] === "/") {
18899
+ if (!JSON_POINTER.test($data))
18900
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
18901
+ jsonPointer = $data;
18902
+ data = names_1$6.default.rootData;
18903
+ } else {
18904
+ const matches = RELATIVE_JSON_POINTER.exec($data);
18905
+ if (!matches)
18906
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
18907
+ const up = +matches[1];
18908
+ jsonPointer = matches[2];
18909
+ if (jsonPointer === "#") {
18910
+ if (up >= dataLevel)
18911
+ throw new Error(errorMsg("property/index", up));
18912
+ return dataPathArr[dataLevel - up];
18913
+ }
18914
+ if (up > dataLevel)
18915
+ throw new Error(errorMsg("data", up));
18916
+ data = dataNames[dataLevel - up];
18917
+ if (!jsonPointer)
18918
+ return data;
18919
+ }
18920
+ let expr = data;
18921
+ const segments = jsonPointer.split("/");
18922
+ for (const segment of segments) {
18923
+ if (segment) {
18924
+ data = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)((0, util_1$p.unescapeJsonPointer)(segment))}`;
18925
+ expr = (0, codegen_1$r._)`${expr} && ${data}`;
18926
+ }
18927
+ }
18928
+ return expr;
18929
+ function errorMsg(pointerType, up) {
18930
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
18931
+ }
18932
+ }
18933
+ validate$1.getData = getData;
18968
18934
  var validation_error = {};
18969
- var hasRequiredValidation_error;
18970
- function requireValidation_error() {
18971
- if (hasRequiredValidation_error)
18972
- return validation_error;
18973
- hasRequiredValidation_error = 1;
18974
- Object.defineProperty(validation_error, "__esModule", { value: true });
18975
- class ValidationError extends Error {
18976
- constructor(errors2) {
18977
- super("validation failed");
18978
- this.errors = errors2;
18979
- this.ajv = this.validation = true;
18980
- }
18981
- }
18982
- validation_error.default = ValidationError;
18983
- return validation_error;
18935
+ Object.defineProperty(validation_error, "__esModule", { value: true });
18936
+ class ValidationError extends Error {
18937
+ constructor(errors2) {
18938
+ super("validation failed");
18939
+ this.errors = errors2;
18940
+ this.ajv = this.validation = true;
18941
+ }
18984
18942
  }
18943
+ validation_error.default = ValidationError;
18985
18944
  var ref_error = {};
18986
- var hasRequiredRef_error;
18987
- function requireRef_error() {
18988
- if (hasRequiredRef_error)
18989
- return ref_error;
18990
- hasRequiredRef_error = 1;
18991
- Object.defineProperty(ref_error, "__esModule", { value: true });
18992
- const resolve_12 = resolve$1;
18993
- class MissingRefError extends Error {
18994
- constructor(resolver, baseId, ref2, msg) {
18995
- super(msg || `can't resolve reference ${ref2} from id ${baseId}`);
18996
- this.missingRef = (0, resolve_12.resolveUrl)(resolver, baseId, ref2);
18997
- this.missingSchema = (0, resolve_12.normalizeId)((0, resolve_12.getFullPath)(resolver, this.missingRef));
18998
- }
18945
+ Object.defineProperty(ref_error, "__esModule", { value: true });
18946
+ const resolve_1$1 = resolve$1;
18947
+ class MissingRefError extends Error {
18948
+ constructor(resolver, baseId, ref2, msg) {
18949
+ super(msg || `can't resolve reference ${ref2} from id ${baseId}`);
18950
+ this.missingRef = (0, resolve_1$1.resolveUrl)(resolver, baseId, ref2);
18951
+ this.missingSchema = (0, resolve_1$1.normalizeId)((0, resolve_1$1.getFullPath)(resolver, this.missingRef));
18999
18952
  }
19000
- ref_error.default = MissingRefError;
19001
- return ref_error;
19002
18953
  }
18954
+ ref_error.default = MissingRefError;
19003
18955
  var compile = {};
19004
18956
  Object.defineProperty(compile, "__esModule", { value: true });
19005
18957
  compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
19006
18958
  const codegen_1$q = codegen;
19007
- const validation_error_1 = requireValidation_error();
18959
+ const validation_error_1 = validation_error;
19008
18960
  const names_1$5 = names$1;
19009
18961
  const resolve_1 = resolve$1;
19010
18962
  const util_1$o = util;
19011
- const validate_1$1 = requireValidate();
18963
+ const validate_1$1 = validate$1;
19012
18964
  class SchemaEnv {
19013
18965
  constructor(env) {
19014
18966
  var _a;
@@ -20295,7 +20247,7 @@ uri$1.default = uri;
20295
20247
  (function(exports) {
20296
20248
  Object.defineProperty(exports, "__esModule", { value: true });
20297
20249
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
20298
- var validate_12 = requireValidate();
20250
+ var validate_12 = validate$1;
20299
20251
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
20300
20252
  return validate_12.KeywordCxt;
20301
20253
  } });
@@ -20318,8 +20270,8 @@ uri$1.default = uri;
20318
20270
  Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
20319
20271
  return codegen_12.CodeGen;
20320
20272
  } });
20321
- const validation_error_12 = requireValidation_error();
20322
- const ref_error_12 = requireRef_error();
20273
+ const validation_error_12 = validation_error;
20274
+ const ref_error_12 = ref_error;
20323
20275
  const rules_1 = rules;
20324
20276
  const compile_12 = compile;
20325
20277
  const codegen_2 = codegen;
@@ -20912,7 +20864,7 @@ id.default = def$B;
20912
20864
  var ref = {};
20913
20865
  Object.defineProperty(ref, "__esModule", { value: true });
20914
20866
  ref.callRef = ref.getValidate = void 0;
20915
- const ref_error_1 = requireRef_error();
20867
+ const ref_error_1 = ref_error;
20916
20868
  const code_1$8 = code;
20917
20869
  const codegen_1$p = codegen;
20918
20870
  const names_1$4 = names$1;
@@ -21897,7 +21849,7 @@ const def$j = {
21897
21849
  additionalProperties.default = def$j;
21898
21850
  var properties$8 = {};
21899
21851
  Object.defineProperty(properties$8, "__esModule", { value: true });
21900
- const validate_1 = requireValidate();
21852
+ const validate_1 = validate$1;
21901
21853
  const code_1$2 = code;
21902
21854
  const util_1$b = util;
21903
21855
  const additionalProperties_1$1 = additionalProperties;
@@ -23255,7 +23207,7 @@ jsonSchema201909.default = addMetaSchema2019;
23255
23207
  module.exports = exports = Ajv2019;
23256
23208
  Object.defineProperty(exports, "__esModule", { value: true });
23257
23209
  exports.default = Ajv2019;
23258
- var validate_12 = requireValidate();
23210
+ var validate_12 = validate$1;
23259
23211
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
23260
23212
  return validate_12.KeywordCxt;
23261
23213
  } });
@@ -23278,11 +23230,11 @@ jsonSchema201909.default = addMetaSchema2019;
23278
23230
  Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
23279
23231
  return codegen_12.CodeGen;
23280
23232
  } });
23281
- var validation_error_12 = requireValidation_error();
23233
+ var validation_error_12 = validation_error;
23282
23234
  Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() {
23283
23235
  return validation_error_12.default;
23284
23236
  } });
23285
- var ref_error_12 = requireRef_error();
23237
+ var ref_error_12 = ref_error;
23286
23238
  Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function() {
23287
23239
  return ref_error_12.default;
23288
23240
  } });
@@ -24270,7 +24222,7 @@ function handleComputedProperty(options) {
24270
24222
  var _a;
24271
24223
  return Object.assign({}, options, {
24272
24224
  _computed: {
24273
- version: "9.32.0",
24225
+ version: "9.32.2",
24274
24226
  paymentMethodsUrl: ((_a = options._dev) == null ? void 0 : _a.paymentMethodsUrl) ?? "https://forms.secure-payments.app"
24275
24227
  }
24276
24228
  });
@@ -27612,7 +27564,7 @@ class RebillyInstrumentsInstance {
27612
27564
  await show({ componentName, payload });
27613
27565
  }
27614
27566
  get version() {
27615
- return `RebillyInstruments Ver.${"9.32.0"}`;
27567
+ return `RebillyInstruments Ver.${"9.32.2"}`;
27616
27568
  }
27617
27569
  on(eventName, callback) {
27618
27570
  on({ eventName, callback });