create-ones-app 0.0.9 → 0.0.11

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
@@ -1278,8 +1278,8 @@ var scope = {};
1278
1278
  var util = {};
1279
1279
  Object.defineProperty(util, "__esModule", { value: true });
1280
1280
  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;
1281
- const codegen_1$z = codegen;
1282
- const code_1$a = code$1;
1281
+ const codegen_1$s = codegen;
1282
+ const code_1$9 = code$1;
1283
1283
  function toHash(arr) {
1284
1284
  const hash = {};
1285
1285
  for (const item of arr)
@@ -1332,9 +1332,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
1332
1332
  if (typeof schema == "number" || typeof schema == "boolean")
1333
1333
  return schema;
1334
1334
  if (typeof schema == "string")
1335
- return (0, codegen_1$z._)`${schema}`;
1335
+ return (0, codegen_1$s._)`${schema}`;
1336
1336
  }
1337
- return (0, codegen_1$z._)`${topSchemaRef}${schemaPath}${(0, codegen_1$z.getProperty)(keyword2)}`;
1337
+ return (0, codegen_1$s._)`${topSchemaRef}${schemaPath}${(0, codegen_1$s.getProperty)(keyword2)}`;
1338
1338
  }
1339
1339
  util.schemaRefOrVal = schemaRefOrVal;
1340
1340
  function unescapeFragment(str) {
@@ -1366,20 +1366,20 @@ function eachItem(xs, f) {
1366
1366
  util.eachItem = eachItem;
1367
1367
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
1368
1368
  return (gen, from, to, toName) => {
1369
- const res = to === void 0 ? from : to instanceof codegen_1$z.Name ? (from instanceof codegen_1$z.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$z.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
1370
- return toName === codegen_1$z.Name && !(res instanceof codegen_1$z.Name) ? resultToName(gen, res) : res;
1369
+ const res = to === void 0 ? from : to instanceof codegen_1$s.Name ? (from instanceof codegen_1$s.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$s.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
1370
+ return toName === codegen_1$s.Name && !(res instanceof codegen_1$s.Name) ? resultToName(gen, res) : res;
1371
1371
  };
1372
1372
  }
1373
1373
  util.mergeEvaluated = {
1374
1374
  props: makeMergeEvaluated({
1375
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$z._)`${to} !== true && ${from} !== undefined`, () => {
1376
- gen.if((0, codegen_1$z._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$z._)`${to} || {}`).code((0, codegen_1$z._)`Object.assign(${to}, ${from})`));
1375
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$s._)`${to} !== true && ${from} !== undefined`, () => {
1376
+ gen.if((0, codegen_1$s._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$s._)`${to} || {}`).code((0, codegen_1$s._)`Object.assign(${to}, ${from})`));
1377
1377
  }),
1378
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$z._)`${to} !== true`, () => {
1378
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$s._)`${to} !== true`, () => {
1379
1379
  if (from === true) {
1380
1380
  gen.assign(to, true);
1381
1381
  } else {
1382
- gen.assign(to, (0, codegen_1$z._)`${to} || {}`);
1382
+ gen.assign(to, (0, codegen_1$s._)`${to} || {}`);
1383
1383
  setEvaluated(gen, to, from);
1384
1384
  }
1385
1385
  }),
@@ -1387,8 +1387,8 @@ util.mergeEvaluated = {
1387
1387
  resultToName: evaluatedPropsToName
1388
1388
  }),
1389
1389
  items: makeMergeEvaluated({
1390
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$z._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$z._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
1391
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$z._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$z._)`${to} > ${from} ? ${to} : ${from}`)),
1390
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$s._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$s._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
1391
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$s._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$s._)`${to} > ${from} ? ${to} : ${from}`)),
1392
1392
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
1393
1393
  resultToName: (gen, items2) => gen.var("items", items2)
1394
1394
  })
@@ -1396,21 +1396,21 @@ util.mergeEvaluated = {
1396
1396
  function evaluatedPropsToName(gen, ps) {
1397
1397
  if (ps === true)
1398
1398
  return gen.var("props", true);
1399
- const props = gen.var("props", (0, codegen_1$z._)`{}`);
1399
+ const props = gen.var("props", (0, codegen_1$s._)`{}`);
1400
1400
  if (ps !== void 0)
1401
1401
  setEvaluated(gen, props, ps);
1402
1402
  return props;
1403
1403
  }
1404
1404
  util.evaluatedPropsToName = evaluatedPropsToName;
1405
1405
  function setEvaluated(gen, props, ps) {
1406
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$z._)`${props}${(0, codegen_1$z.getProperty)(p)}`, true));
1406
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$s._)`${props}${(0, codegen_1$s.getProperty)(p)}`, true));
1407
1407
  }
1408
1408
  util.setEvaluated = setEvaluated;
1409
1409
  const snippets = {};
1410
1410
  function useFunc(gen, f) {
1411
1411
  return gen.scopeValue("func", {
1412
1412
  ref: f,
1413
- code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
1413
+ code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
1414
1414
  });
1415
1415
  }
1416
1416
  util.useFunc = useFunc;
@@ -1420,11 +1420,11 @@ var Type;
1420
1420
  Type2[Type2["Str"] = 1] = "Str";
1421
1421
  })(Type || (util.Type = Type = {}));
1422
1422
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
1423
- if (dataProp instanceof codegen_1$z.Name) {
1423
+ if (dataProp instanceof codegen_1$s.Name) {
1424
1424
  const isNumber = dataPropType === Type.Num;
1425
- return jsPropertySyntax ? isNumber ? (0, codegen_1$z._)`"[" + ${dataProp} + "]"` : (0, codegen_1$z._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$z._)`"/" + ${dataProp}` : (0, codegen_1$z._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
1425
+ return jsPropertySyntax ? isNumber ? (0, codegen_1$s._)`"[" + ${dataProp} + "]"` : (0, codegen_1$s._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$s._)`"/" + ${dataProp}` : (0, codegen_1$s._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
1426
1426
  }
1427
- return jsPropertySyntax ? (0, codegen_1$z.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
1427
+ return jsPropertySyntax ? (0, codegen_1$s.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
1428
1428
  }
1429
1429
  util.getErrorPath = getErrorPath;
1430
1430
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -1436,45 +1436,52 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
1436
1436
  it.self.logger.warn(msg);
1437
1437
  }
1438
1438
  util.checkStrictMode = checkStrictMode;
1439
- var names$1 = {};
1440
- Object.defineProperty(names$1, "__esModule", { value: true });
1441
- const codegen_1$y = codegen;
1442
- const names = {
1443
- // validation function arguments
1444
- data: new codegen_1$y.Name("data"),
1445
- // data passed to validation function
1446
- // args passed from referencing schema
1447
- valCxt: new codegen_1$y.Name("valCxt"),
1448
- // validation/data context - should not be used directly, it is destructured to the names below
1449
- instancePath: new codegen_1$y.Name("instancePath"),
1450
- parentData: new codegen_1$y.Name("parentData"),
1451
- parentDataProperty: new codegen_1$y.Name("parentDataProperty"),
1452
- rootData: new codegen_1$y.Name("rootData"),
1453
- // root data - same as the data passed to the first/top validation function
1454
- dynamicAnchors: new codegen_1$y.Name("dynamicAnchors"),
1455
- // used to support recursiveRef and dynamicRef
1456
- // function scoped variables
1457
- vErrors: new codegen_1$y.Name("vErrors"),
1458
- // null or array of validation errors
1459
- errors: new codegen_1$y.Name("errors"),
1460
- // counter of validation errors
1461
- this: new codegen_1$y.Name("this"),
1462
- // "globals"
1463
- self: new codegen_1$y.Name("self"),
1464
- scope: new codegen_1$y.Name("scope"),
1465
- // JTD serialize/parse name for JSON string and position
1466
- json: new codegen_1$y.Name("json"),
1467
- jsonPos: new codegen_1$y.Name("jsonPos"),
1468
- jsonLen: new codegen_1$y.Name("jsonLen"),
1469
- jsonPart: new codegen_1$y.Name("jsonPart")
1470
- };
1471
- names$1.default = names;
1439
+ var names = {};
1440
+ var hasRequiredNames;
1441
+ function requireNames() {
1442
+ if (hasRequiredNames)
1443
+ return names;
1444
+ hasRequiredNames = 1;
1445
+ Object.defineProperty(names, "__esModule", { value: true });
1446
+ const codegen_12 = codegen;
1447
+ const names$1 = {
1448
+ // validation function arguments
1449
+ data: new codegen_12.Name("data"),
1450
+ // data passed to validation function
1451
+ // args passed from referencing schema
1452
+ valCxt: new codegen_12.Name("valCxt"),
1453
+ // validation/data context - should not be used directly, it is destructured to the names below
1454
+ instancePath: new codegen_12.Name("instancePath"),
1455
+ parentData: new codegen_12.Name("parentData"),
1456
+ parentDataProperty: new codegen_12.Name("parentDataProperty"),
1457
+ rootData: new codegen_12.Name("rootData"),
1458
+ // root data - same as the data passed to the first/top validation function
1459
+ dynamicAnchors: new codegen_12.Name("dynamicAnchors"),
1460
+ // used to support recursiveRef and dynamicRef
1461
+ // function scoped variables
1462
+ vErrors: new codegen_12.Name("vErrors"),
1463
+ // null or array of validation errors
1464
+ errors: new codegen_12.Name("errors"),
1465
+ // counter of validation errors
1466
+ this: new codegen_12.Name("this"),
1467
+ // "globals"
1468
+ self: new codegen_12.Name("self"),
1469
+ scope: new codegen_12.Name("scope"),
1470
+ // JTD serialize/parse name for JSON string and position
1471
+ json: new codegen_12.Name("json"),
1472
+ jsonPos: new codegen_12.Name("jsonPos"),
1473
+ jsonLen: new codegen_12.Name("jsonLen"),
1474
+ jsonPart: new codegen_12.Name("jsonPart")
1475
+ };
1476
+ names.default = names$1;
1477
+ return names;
1478
+ }
1472
1479
  (function(exports) {
1473
1480
  Object.defineProperty(exports, "__esModule", { value: true });
1474
1481
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
1475
1482
  const codegen_12 = codegen;
1476
1483
  const util_12 = util;
1477
- const names_12 = names$1;
1484
+ const names_12 = requireNames();
1478
1485
  exports.keywordError = {
1479
1486
  message: ({ keyword: keyword2 }) => (0, codegen_12.str)`must pass "${keyword2}" keyword validation`
1480
1487
  };
@@ -1586,49 +1593,56 @@ names$1.default = names;
1586
1593
  keyValues.push([E.propertyName, propertyName]);
1587
1594
  }
1588
1595
  })(errors);
1589
- Object.defineProperty(boolSchema, "__esModule", { value: true });
1590
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
1591
- const errors_1$3 = errors;
1592
- const codegen_1$x = codegen;
1593
- const names_1$9 = names$1;
1594
- const boolError = {
1595
- message: "boolean schema is false"
1596
- };
1597
- function topBoolOrEmptySchema(it) {
1598
- const { gen, schema, validateName } = it;
1599
- if (schema === false) {
1600
- falseSchemaError(it, false);
1601
- } else if (typeof schema == "object" && schema.$async === true) {
1602
- gen.return(names_1$9.default.data);
1603
- } else {
1604
- gen.assign((0, codegen_1$x._)`${validateName}.errors`, null);
1605
- gen.return(true);
1596
+ var hasRequiredBoolSchema;
1597
+ function requireBoolSchema() {
1598
+ if (hasRequiredBoolSchema)
1599
+ return boolSchema;
1600
+ hasRequiredBoolSchema = 1;
1601
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
1602
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
1603
+ const errors_12 = errors;
1604
+ const codegen_12 = codegen;
1605
+ const names_12 = requireNames();
1606
+ const boolError = {
1607
+ message: "boolean schema is false"
1608
+ };
1609
+ function topBoolOrEmptySchema(it) {
1610
+ const { gen, schema, validateName } = it;
1611
+ if (schema === false) {
1612
+ falseSchemaError(it, false);
1613
+ } else if (typeof schema == "object" && schema.$async === true) {
1614
+ gen.return(names_12.default.data);
1615
+ } else {
1616
+ gen.assign((0, codegen_12._)`${validateName}.errors`, null);
1617
+ gen.return(true);
1618
+ }
1606
1619
  }
1607
- }
1608
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
1609
- function boolOrEmptySchema(it, valid) {
1610
- const { gen, schema } = it;
1611
- if (schema === false) {
1612
- gen.var(valid, false);
1613
- falseSchemaError(it);
1614
- } else {
1615
- gen.var(valid, true);
1620
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
1621
+ function boolOrEmptySchema(it, valid) {
1622
+ const { gen, schema } = it;
1623
+ if (schema === false) {
1624
+ gen.var(valid, false);
1625
+ falseSchemaError(it);
1626
+ } else {
1627
+ gen.var(valid, true);
1628
+ }
1629
+ }
1630
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
1631
+ function falseSchemaError(it, overrideAllErrors) {
1632
+ const { gen, data } = it;
1633
+ const cxt = {
1634
+ gen,
1635
+ keyword: "false schema",
1636
+ data,
1637
+ schema: false,
1638
+ schemaCode: false,
1639
+ schemaValue: false,
1640
+ params: {},
1641
+ it
1642
+ };
1643
+ (0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
1616
1644
  }
1617
- }
1618
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
1619
- function falseSchemaError(it, overrideAllErrors) {
1620
- const { gen, data } = it;
1621
- const cxt = {
1622
- gen,
1623
- keyword: "false schema",
1624
- data,
1625
- schema: false,
1626
- schemaCode: false,
1627
- schemaValue: false,
1628
- params: {},
1629
- it
1630
- };
1631
- (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
1645
+ return boolSchema;
1632
1646
  }
1633
1647
  var dataType = {};
1634
1648
  var rules = {};
@@ -1657,29 +1671,36 @@ function getRules() {
1657
1671
  }
1658
1672
  rules.getRules = getRules;
1659
1673
  var applicability = {};
1660
- Object.defineProperty(applicability, "__esModule", { value: true });
1661
- applicability.shouldUseRule = applicability.shouldUseGroup = applicability.schemaHasRulesForType = void 0;
1662
- function schemaHasRulesForType({ schema, self }, type2) {
1663
- const group = self.RULES.types[type2];
1664
- return group && group !== true && shouldUseGroup(schema, group);
1665
- }
1666
- applicability.schemaHasRulesForType = schemaHasRulesForType;
1667
- function shouldUseGroup(schema, group) {
1668
- return group.rules.some((rule) => shouldUseRule(schema, rule));
1669
- }
1670
- applicability.shouldUseGroup = shouldUseGroup;
1671
- function shouldUseRule(schema, rule) {
1672
- var _a;
1673
- return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
1674
+ var hasRequiredApplicability;
1675
+ function requireApplicability() {
1676
+ if (hasRequiredApplicability)
1677
+ return applicability;
1678
+ hasRequiredApplicability = 1;
1679
+ Object.defineProperty(applicability, "__esModule", { value: true });
1680
+ applicability.shouldUseRule = applicability.shouldUseGroup = applicability.schemaHasRulesForType = void 0;
1681
+ function schemaHasRulesForType({ schema, self }, type2) {
1682
+ const group = self.RULES.types[type2];
1683
+ return group && group !== true && shouldUseGroup(schema, group);
1684
+ }
1685
+ applicability.schemaHasRulesForType = schemaHasRulesForType;
1686
+ function shouldUseGroup(schema, group) {
1687
+ return group.rules.some((rule) => shouldUseRule(schema, rule));
1688
+ }
1689
+ applicability.shouldUseGroup = shouldUseGroup;
1690
+ function shouldUseRule(schema, rule) {
1691
+ var _a;
1692
+ return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
1693
+ }
1694
+ applicability.shouldUseRule = shouldUseRule;
1695
+ return applicability;
1674
1696
  }
1675
- applicability.shouldUseRule = shouldUseRule;
1676
1697
  Object.defineProperty(dataType, "__esModule", { value: true });
1677
1698
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
1678
1699
  const rules_1 = rules;
1679
- const applicability_1$1 = applicability;
1680
- const errors_1$2 = errors;
1681
- const codegen_1$w = codegen;
1682
- const util_1$u = util;
1700
+ const applicability_1 = requireApplicability();
1701
+ const errors_1 = errors;
1702
+ const codegen_1$r = codegen;
1703
+ const util_1$q = util;
1683
1704
  var DataType;
1684
1705
  (function(DataType2) {
1685
1706
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -1711,7 +1732,7 @@ dataType.getJSONTypes = getJSONTypes;
1711
1732
  function coerceAndCheckDataType(it, types2) {
1712
1733
  const { gen, data, opts } = it;
1713
1734
  const coerceTo = coerceToTypes(types2, opts.coerceTypes);
1714
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
1735
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
1715
1736
  if (checkTypes) {
1716
1737
  const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
1717
1738
  gen.if(wrongType, () => {
@@ -1730,12 +1751,12 @@ function coerceToTypes(types2, coerceTypes) {
1730
1751
  }
1731
1752
  function coerceData(it, types2, coerceTo) {
1732
1753
  const { gen, data, opts } = it;
1733
- const dataType2 = gen.let("dataType", (0, codegen_1$w._)`typeof ${data}`);
1734
- const coerced = gen.let("coerced", (0, codegen_1$w._)`undefined`);
1754
+ const dataType2 = gen.let("dataType", (0, codegen_1$r._)`typeof ${data}`);
1755
+ const coerced = gen.let("coerced", (0, codegen_1$r._)`undefined`);
1735
1756
  if (opts.coerceTypes === "array") {
1736
- gen.if((0, codegen_1$w._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$w._)`${data}[0]`).assign(dataType2, (0, codegen_1$w._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
1757
+ gen.if((0, codegen_1$r._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$r._)`${data}[0]`).assign(dataType2, (0, codegen_1$r._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
1737
1758
  }
1738
- gen.if((0, codegen_1$w._)`${coerced} !== undefined`);
1759
+ gen.if((0, codegen_1$r._)`${coerced} !== undefined`);
1739
1760
  for (const t of coerceTo) {
1740
1761
  if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
1741
1762
  coerceSpecificType(t);
@@ -1744,63 +1765,63 @@ function coerceData(it, types2, coerceTo) {
1744
1765
  gen.else();
1745
1766
  reportTypeError(it);
1746
1767
  gen.endIf();
1747
- gen.if((0, codegen_1$w._)`${coerced} !== undefined`, () => {
1768
+ gen.if((0, codegen_1$r._)`${coerced} !== undefined`, () => {
1748
1769
  gen.assign(data, coerced);
1749
1770
  assignParentData(it, coerced);
1750
1771
  });
1751
1772
  function coerceSpecificType(t) {
1752
1773
  switch (t) {
1753
1774
  case "string":
1754
- gen.elseIf((0, codegen_1$w._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$w._)`"" + ${data}`).elseIf((0, codegen_1$w._)`${data} === null`).assign(coerced, (0, codegen_1$w._)`""`);
1775
+ gen.elseIf((0, codegen_1$r._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$r._)`"" + ${data}`).elseIf((0, codegen_1$r._)`${data} === null`).assign(coerced, (0, codegen_1$r._)`""`);
1755
1776
  return;
1756
1777
  case "number":
1757
- gen.elseIf((0, codegen_1$w._)`${dataType2} == "boolean" || ${data} === null
1758
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$w._)`+${data}`);
1778
+ gen.elseIf((0, codegen_1$r._)`${dataType2} == "boolean" || ${data} === null
1779
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$r._)`+${data}`);
1759
1780
  return;
1760
1781
  case "integer":
1761
- gen.elseIf((0, codegen_1$w._)`${dataType2} === "boolean" || ${data} === null
1762
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$w._)`+${data}`);
1782
+ gen.elseIf((0, codegen_1$r._)`${dataType2} === "boolean" || ${data} === null
1783
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$r._)`+${data}`);
1763
1784
  return;
1764
1785
  case "boolean":
1765
- gen.elseIf((0, codegen_1$w._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$w._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
1786
+ gen.elseIf((0, codegen_1$r._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$r._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
1766
1787
  return;
1767
1788
  case "null":
1768
- gen.elseIf((0, codegen_1$w._)`${data} === "" || ${data} === 0 || ${data} === false`);
1789
+ gen.elseIf((0, codegen_1$r._)`${data} === "" || ${data} === 0 || ${data} === false`);
1769
1790
  gen.assign(coerced, null);
1770
1791
  return;
1771
1792
  case "array":
1772
- gen.elseIf((0, codegen_1$w._)`${dataType2} === "string" || ${dataType2} === "number"
1773
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$w._)`[${data}]`);
1793
+ gen.elseIf((0, codegen_1$r._)`${dataType2} === "string" || ${dataType2} === "number"
1794
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$r._)`[${data}]`);
1774
1795
  }
1775
1796
  }
1776
1797
  }
1777
1798
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
1778
- gen.if((0, codegen_1$w._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$w._)`${parentData}[${parentDataProperty}]`, expr));
1799
+ gen.if((0, codegen_1$r._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$r._)`${parentData}[${parentDataProperty}]`, expr));
1779
1800
  }
1780
1801
  function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
1781
- const EQ = correct === DataType.Correct ? codegen_1$w.operators.EQ : codegen_1$w.operators.NEQ;
1802
+ const EQ = correct === DataType.Correct ? codegen_1$r.operators.EQ : codegen_1$r.operators.NEQ;
1782
1803
  let cond;
1783
1804
  switch (dataType2) {
1784
1805
  case "null":
1785
- return (0, codegen_1$w._)`${data} ${EQ} null`;
1806
+ return (0, codegen_1$r._)`${data} ${EQ} null`;
1786
1807
  case "array":
1787
- cond = (0, codegen_1$w._)`Array.isArray(${data})`;
1808
+ cond = (0, codegen_1$r._)`Array.isArray(${data})`;
1788
1809
  break;
1789
1810
  case "object":
1790
- cond = (0, codegen_1$w._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
1811
+ cond = (0, codegen_1$r._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
1791
1812
  break;
1792
1813
  case "integer":
1793
- cond = numCond((0, codegen_1$w._)`!(${data} % 1) && !isNaN(${data})`);
1814
+ cond = numCond((0, codegen_1$r._)`!(${data} % 1) && !isNaN(${data})`);
1794
1815
  break;
1795
1816
  case "number":
1796
1817
  cond = numCond();
1797
1818
  break;
1798
1819
  default:
1799
- return (0, codegen_1$w._)`typeof ${data} ${EQ} ${dataType2}`;
1820
+ return (0, codegen_1$r._)`typeof ${data} ${EQ} ${dataType2}`;
1800
1821
  }
1801
- return correct === DataType.Correct ? cond : (0, codegen_1$w.not)(cond);
1802
- function numCond(_cond = codegen_1$w.nil) {
1803
- return (0, codegen_1$w.and)((0, codegen_1$w._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$w._)`isFinite(${data})` : codegen_1$w.nil);
1822
+ return correct === DataType.Correct ? cond : (0, codegen_1$r.not)(cond);
1823
+ function numCond(_cond = codegen_1$r.nil) {
1824
+ return (0, codegen_1$r.and)((0, codegen_1$r._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$r._)`isFinite(${data})` : codegen_1$r.nil);
1804
1825
  }
1805
1826
  }
1806
1827
  dataType.checkDataType = checkDataType;
@@ -1809,35 +1830,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
1809
1830
  return checkDataType(dataTypes[0], data, strictNums, correct);
1810
1831
  }
1811
1832
  let cond;
1812
- const types2 = (0, util_1$u.toHash)(dataTypes);
1833
+ const types2 = (0, util_1$q.toHash)(dataTypes);
1813
1834
  if (types2.array && types2.object) {
1814
- const notObj = (0, codegen_1$w._)`typeof ${data} != "object"`;
1815
- cond = types2.null ? notObj : (0, codegen_1$w._)`!${data} || ${notObj}`;
1835
+ const notObj = (0, codegen_1$r._)`typeof ${data} != "object"`;
1836
+ cond = types2.null ? notObj : (0, codegen_1$r._)`!${data} || ${notObj}`;
1816
1837
  delete types2.null;
1817
1838
  delete types2.array;
1818
1839
  delete types2.object;
1819
1840
  } else {
1820
- cond = codegen_1$w.nil;
1841
+ cond = codegen_1$r.nil;
1821
1842
  }
1822
1843
  if (types2.number)
1823
1844
  delete types2.integer;
1824
1845
  for (const t in types2)
1825
- cond = (0, codegen_1$w.and)(cond, checkDataType(t, data, strictNums, correct));
1846
+ cond = (0, codegen_1$r.and)(cond, checkDataType(t, data, strictNums, correct));
1826
1847
  return cond;
1827
1848
  }
1828
1849
  dataType.checkDataTypes = checkDataTypes;
1829
1850
  const typeError = {
1830
1851
  message: ({ schema }) => `must be ${schema}`,
1831
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$w._)`{type: ${schema}}` : (0, codegen_1$w._)`{type: ${schemaValue}}`
1852
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$r._)`{type: ${schema}}` : (0, codegen_1$r._)`{type: ${schemaValue}}`
1832
1853
  };
1833
1854
  function reportTypeError(it) {
1834
1855
  const cxt = getTypeErrorContext(it);
1835
- (0, errors_1$2.reportError)(cxt, typeError);
1856
+ (0, errors_1.reportError)(cxt, typeError);
1836
1857
  }
1837
1858
  dataType.reportTypeError = reportTypeError;
1838
1859
  function getTypeErrorContext(it) {
1839
1860
  const { gen, data, schema } = it;
1840
- const schemaCode = (0, util_1$u.schemaRefOrVal)(it, schema, "type");
1861
+ const schemaCode = (0, util_1$q.schemaRefOrVal)(it, schema, "type");
1841
1862
  return {
1842
1863
  gen,
1843
1864
  keyword: "type",
@@ -1851,352 +1872,380 @@ function getTypeErrorContext(it) {
1851
1872
  };
1852
1873
  }
1853
1874
  var defaults = {};
1854
- Object.defineProperty(defaults, "__esModule", { value: true });
1855
- defaults.assignDefaults = void 0;
1856
- const codegen_1$v = codegen;
1857
- const util_1$t = util;
1858
- function assignDefaults(it, ty) {
1859
- const { properties: properties2, items: items2 } = it.schema;
1860
- if (ty === "object" && properties2) {
1861
- for (const key in properties2) {
1862
- assignDefault(it, key, properties2[key].default);
1863
- }
1864
- } else if (ty === "array" && Array.isArray(items2)) {
1865
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
1866
- }
1867
- }
1868
- defaults.assignDefaults = assignDefaults;
1869
- function assignDefault(it, prop, defaultValue) {
1870
- const { gen, compositeRule, data, opts } = it;
1871
- if (defaultValue === void 0)
1872
- return;
1873
- const childData = (0, codegen_1$v._)`${data}${(0, codegen_1$v.getProperty)(prop)}`;
1874
- if (compositeRule) {
1875
- (0, util_1$t.checkStrictMode)(it, `default is ignored for: ${childData}`);
1876
- return;
1875
+ var hasRequiredDefaults;
1876
+ function requireDefaults() {
1877
+ if (hasRequiredDefaults)
1878
+ return defaults;
1879
+ hasRequiredDefaults = 1;
1880
+ Object.defineProperty(defaults, "__esModule", { value: true });
1881
+ defaults.assignDefaults = void 0;
1882
+ const codegen_12 = codegen;
1883
+ const util_12 = util;
1884
+ function assignDefaults(it, ty) {
1885
+ const { properties: properties2, items: items2 } = it.schema;
1886
+ if (ty === "object" && properties2) {
1887
+ for (const key in properties2) {
1888
+ assignDefault(it, key, properties2[key].default);
1889
+ }
1890
+ } else if (ty === "array" && Array.isArray(items2)) {
1891
+ items2.forEach((sch, i) => assignDefault(it, i, sch.default));
1892
+ }
1877
1893
  }
1878
- let condition = (0, codegen_1$v._)`${childData} === undefined`;
1879
- if (opts.useDefaults === "empty") {
1880
- condition = (0, codegen_1$v._)`${condition} || ${childData} === null || ${childData} === ""`;
1894
+ defaults.assignDefaults = assignDefaults;
1895
+ function assignDefault(it, prop, defaultValue) {
1896
+ const { gen, compositeRule, data, opts } = it;
1897
+ if (defaultValue === void 0)
1898
+ return;
1899
+ const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
1900
+ if (compositeRule) {
1901
+ (0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
1902
+ return;
1903
+ }
1904
+ let condition = (0, codegen_12._)`${childData} === undefined`;
1905
+ if (opts.useDefaults === "empty") {
1906
+ condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
1907
+ }
1908
+ gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
1881
1909
  }
1882
- gen.if(condition, (0, codegen_1$v._)`${childData} = ${(0, codegen_1$v.stringify)(defaultValue)}`);
1910
+ return defaults;
1883
1911
  }
1884
1912
  var keyword = {};
1885
1913
  var code = {};
1886
- Object.defineProperty(code, "__esModule", { value: true });
1887
- 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;
1888
- const codegen_1$u = codegen;
1889
- const util_1$s = util;
1890
- const names_1$8 = names$1;
1891
- const util_2$1 = util;
1892
- function checkReportMissingProp(cxt, prop) {
1893
- const { gen, data, it } = cxt;
1894
- gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
1895
- cxt.setParams({ missingProperty: (0, codegen_1$u._)`${prop}` }, true);
1896
- cxt.error();
1897
- });
1898
- }
1899
- code.checkReportMissingProp = checkReportMissingProp;
1900
- function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
1901
- 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}`)));
1902
- }
1903
- code.checkMissingProp = checkMissingProp;
1904
- function reportMissingProp(cxt, missing) {
1905
- cxt.setParams({ missingProperty: missing }, true);
1906
- cxt.error();
1907
- }
1908
- code.reportMissingProp = reportMissingProp;
1909
- function hasPropFunc(gen) {
1910
- return gen.scopeValue("func", {
1911
- // eslint-disable-next-line @typescript-eslint/unbound-method
1912
- ref: Object.prototype.hasOwnProperty,
1913
- code: (0, codegen_1$u._)`Object.prototype.hasOwnProperty`
1914
- });
1915
- }
1916
- code.hasPropFunc = hasPropFunc;
1917
- function isOwnProperty(gen, data, property) {
1918
- return (0, codegen_1$u._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
1919
- }
1920
- code.isOwnProperty = isOwnProperty;
1921
- function propertyInData(gen, data, property, ownProperties) {
1922
- const cond = (0, codegen_1$u._)`${data}${(0, codegen_1$u.getProperty)(property)} !== undefined`;
1923
- return ownProperties ? (0, codegen_1$u._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
1924
- }
1925
- code.propertyInData = propertyInData;
1926
- function noPropertyInData(gen, data, property, ownProperties) {
1927
- const cond = (0, codegen_1$u._)`${data}${(0, codegen_1$u.getProperty)(property)} === undefined`;
1928
- return ownProperties ? (0, codegen_1$u.or)(cond, (0, codegen_1$u.not)(isOwnProperty(gen, data, property))) : cond;
1929
- }
1930
- code.noPropertyInData = noPropertyInData;
1931
- function allSchemaProperties(schemaMap) {
1932
- return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
1933
- }
1934
- code.allSchemaProperties = allSchemaProperties;
1935
- function schemaProperties(it, schemaMap) {
1936
- return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$s.alwaysValidSchema)(it, schemaMap[p]));
1937
- }
1938
- code.schemaProperties = schemaProperties;
1939
- function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context2, passSchema) {
1940
- const dataAndSchema = passSchema ? (0, codegen_1$u._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
1941
- const valCxt = [
1942
- [names_1$8.default.instancePath, (0, codegen_1$u.strConcat)(names_1$8.default.instancePath, errorPath)],
1943
- [names_1$8.default.parentData, it.parentData],
1944
- [names_1$8.default.parentDataProperty, it.parentDataProperty],
1945
- [names_1$8.default.rootData, names_1$8.default.rootData]
1946
- ];
1947
- if (it.opts.dynamicRef)
1948
- valCxt.push([names_1$8.default.dynamicAnchors, names_1$8.default.dynamicAnchors]);
1949
- const args = (0, codegen_1$u._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
1950
- return context2 !== codegen_1$u.nil ? (0, codegen_1$u._)`${func}.call(${context2}, ${args})` : (0, codegen_1$u._)`${func}(${args})`;
1951
- }
1952
- code.callValidateCode = callValidateCode;
1953
- const newRegExp = (0, codegen_1$u._)`new RegExp`;
1954
- function usePattern({ gen, it: { opts } }, pattern2) {
1955
- const u = opts.unicodeRegExp ? "u" : "";
1956
- const { regExp } = opts.code;
1957
- const rx = regExp(pattern2, u);
1958
- return gen.scopeValue("pattern", {
1959
- key: rx.toString(),
1960
- ref: rx,
1961
- code: (0, codegen_1$u._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
1962
- });
1963
- }
1964
- code.usePattern = usePattern;
1965
- function validateArray(cxt) {
1966
- const { gen, data, keyword: keyword2, it } = cxt;
1967
- const valid = gen.name("valid");
1968
- if (it.allErrors) {
1969
- const validArr = gen.let("valid", true);
1970
- validateItems(() => gen.assign(validArr, false));
1971
- return validArr;
1972
- }
1973
- gen.var(valid, true);
1974
- validateItems(() => gen.break());
1975
- return valid;
1976
- function validateItems(notValid) {
1977
- const len = gen.const("len", (0, codegen_1$u._)`${data}.length`);
1978
- gen.forRange("i", 0, len, (i) => {
1979
- cxt.subschema({
1980
- keyword: keyword2,
1981
- dataProp: i,
1982
- dataPropType: util_1$s.Type.Num
1983
- }, valid);
1984
- gen.if((0, codegen_1$u.not)(valid), notValid);
1914
+ var hasRequiredCode;
1915
+ function requireCode() {
1916
+ if (hasRequiredCode)
1917
+ return code;
1918
+ hasRequiredCode = 1;
1919
+ Object.defineProperty(code, "__esModule", { value: true });
1920
+ 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;
1921
+ const codegen_12 = codegen;
1922
+ const util_12 = util;
1923
+ const names_12 = requireNames();
1924
+ const util_22 = util;
1925
+ function checkReportMissingProp(cxt, prop) {
1926
+ const { gen, data, it } = cxt;
1927
+ gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
1928
+ cxt.setParams({ missingProperty: (0, codegen_12._)`${prop}` }, true);
1929
+ cxt.error();
1985
1930
  });
1986
1931
  }
1987
- }
1988
- code.validateArray = validateArray;
1989
- function validateUnion(cxt) {
1990
- const { gen, schema, keyword: keyword2, it } = cxt;
1991
- if (!Array.isArray(schema))
1992
- throw new Error("ajv implementation error");
1993
- const alwaysValid = schema.some((sch) => (0, util_1$s.alwaysValidSchema)(it, sch));
1994
- if (alwaysValid && !it.opts.unevaluated)
1995
- return;
1996
- const valid = gen.let("valid", false);
1997
- const schValid = gen.name("_valid");
1998
- gen.block(() => schema.forEach((_sch, i) => {
1999
- const schCxt = cxt.subschema({
2000
- keyword: keyword2,
2001
- schemaProp: i,
2002
- compositeRule: true
2003
- }, schValid);
2004
- gen.assign(valid, (0, codegen_1$u._)`${valid} || ${schValid}`);
2005
- const merged = cxt.mergeValidEvaluated(schCxt, schValid);
2006
- if (!merged)
2007
- gen.if((0, codegen_1$u.not)(valid));
2008
- }));
2009
- cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
2010
- }
2011
- code.validateUnion = validateUnion;
2012
- Object.defineProperty(keyword, "__esModule", { value: true });
2013
- keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
2014
- const codegen_1$t = codegen;
2015
- const names_1$7 = names$1;
2016
- const code_1$9 = code;
2017
- const errors_1$1 = errors;
2018
- function macroKeywordCode(cxt, def2) {
2019
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
2020
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
2021
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
2022
- if (it.opts.validateSchema !== false)
2023
- it.self.validateSchema(macroSchema, true);
2024
- const valid = gen.name("valid");
2025
- cxt.subschema({
2026
- schema: macroSchema,
2027
- schemaPath: codegen_1$t.nil,
2028
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
2029
- topSchemaRef: schemaRef,
2030
- compositeRule: true
2031
- }, valid);
2032
- cxt.pass(valid, () => cxt.error(true));
2033
- }
2034
- keyword.macroKeywordCode = macroKeywordCode;
2035
- function funcKeywordCode(cxt, def2) {
2036
- var _a;
2037
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
2038
- checkAsyncKeyword(it, def2);
2039
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
2040
- const validateRef = useKeyword(gen, keyword2, validate2);
2041
- const valid = gen.let("valid");
2042
- cxt.block$data(valid, validateKeyword);
2043
- cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
2044
- function validateKeyword() {
2045
- if (def2.errors === false) {
2046
- assignValid();
2047
- if (def2.modifying)
2048
- modifyData(cxt);
2049
- reportErrs(() => cxt.error());
2050
- } else {
2051
- const ruleErrs = def2.async ? validateAsync() : validateSync();
2052
- if (def2.modifying)
2053
- modifyData(cxt);
2054
- reportErrs(() => addErrs(cxt, ruleErrs));
2055
- }
2056
- }
2057
- function validateAsync() {
2058
- const ruleErrs = gen.let("ruleErrs", null);
2059
- gen.try(() => assignValid((0, codegen_1$t._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1$t._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$t._)`${e}.errors`), () => gen.throw(e)));
2060
- return ruleErrs;
1932
+ code.checkReportMissingProp = checkReportMissingProp;
1933
+ function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
1934
+ return (0, codegen_12.or)(...properties2.map((prop) => (0, codegen_12.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_12._)`${missing} = ${prop}`)));
2061
1935
  }
2062
- function validateSync() {
2063
- const validateErrs = (0, codegen_1$t._)`${validateRef}.errors`;
2064
- gen.assign(validateErrs, null);
2065
- assignValid(codegen_1$t.nil);
2066
- return validateErrs;
1936
+ code.checkMissingProp = checkMissingProp;
1937
+ function reportMissingProp(cxt, missing) {
1938
+ cxt.setParams({ missingProperty: missing }, true);
1939
+ cxt.error();
2067
1940
  }
2068
- function assignValid(_await = def2.async ? (0, codegen_1$t._)`await ` : codegen_1$t.nil) {
2069
- const passCxt = it.opts.passContext ? names_1$7.default.this : names_1$7.default.self;
2070
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
2071
- gen.assign(valid, (0, codegen_1$t._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
1941
+ code.reportMissingProp = reportMissingProp;
1942
+ function hasPropFunc(gen) {
1943
+ return gen.scopeValue("func", {
1944
+ // eslint-disable-next-line @typescript-eslint/unbound-method
1945
+ ref: Object.prototype.hasOwnProperty,
1946
+ code: (0, codegen_12._)`Object.prototype.hasOwnProperty`
1947
+ });
2072
1948
  }
2073
- function reportErrs(errors2) {
2074
- var _a2;
2075
- gen.if((0, codegen_1$t.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
1949
+ code.hasPropFunc = hasPropFunc;
1950
+ function isOwnProperty(gen, data, property) {
1951
+ return (0, codegen_12._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
1952
+ }
1953
+ code.isOwnProperty = isOwnProperty;
1954
+ function propertyInData(gen, data, property, ownProperties) {
1955
+ const cond = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(property)} !== undefined`;
1956
+ return ownProperties ? (0, codegen_12._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
1957
+ }
1958
+ code.propertyInData = propertyInData;
1959
+ function noPropertyInData(gen, data, property, ownProperties) {
1960
+ const cond = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(property)} === undefined`;
1961
+ return ownProperties ? (0, codegen_12.or)(cond, (0, codegen_12.not)(isOwnProperty(gen, data, property))) : cond;
1962
+ }
1963
+ code.noPropertyInData = noPropertyInData;
1964
+ function allSchemaProperties(schemaMap) {
1965
+ return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
1966
+ }
1967
+ code.allSchemaProperties = allSchemaProperties;
1968
+ function schemaProperties(it, schemaMap) {
1969
+ return allSchemaProperties(schemaMap).filter((p) => !(0, util_12.alwaysValidSchema)(it, schemaMap[p]));
1970
+ }
1971
+ code.schemaProperties = schemaProperties;
1972
+ function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context2, passSchema) {
1973
+ const dataAndSchema = passSchema ? (0, codegen_12._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
1974
+ const valCxt = [
1975
+ [names_12.default.instancePath, (0, codegen_12.strConcat)(names_12.default.instancePath, errorPath)],
1976
+ [names_12.default.parentData, it.parentData],
1977
+ [names_12.default.parentDataProperty, it.parentDataProperty],
1978
+ [names_12.default.rootData, names_12.default.rootData]
1979
+ ];
1980
+ if (it.opts.dynamicRef)
1981
+ valCxt.push([names_12.default.dynamicAnchors, names_12.default.dynamicAnchors]);
1982
+ const args = (0, codegen_12._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
1983
+ return context2 !== codegen_12.nil ? (0, codegen_12._)`${func}.call(${context2}, ${args})` : (0, codegen_12._)`${func}(${args})`;
1984
+ }
1985
+ code.callValidateCode = callValidateCode;
1986
+ const newRegExp = (0, codegen_12._)`new RegExp`;
1987
+ function usePattern({ gen, it: { opts } }, pattern2) {
1988
+ const u = opts.unicodeRegExp ? "u" : "";
1989
+ const { regExp } = opts.code;
1990
+ const rx = regExp(pattern2, u);
1991
+ return gen.scopeValue("pattern", {
1992
+ key: rx.toString(),
1993
+ ref: rx,
1994
+ code: (0, codegen_12._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_22.useFunc)(gen, regExp)}(${pattern2}, ${u})`
1995
+ });
2076
1996
  }
2077
- }
2078
- keyword.funcKeywordCode = funcKeywordCode;
2079
- function modifyData(cxt) {
2080
- const { gen, data, it } = cxt;
2081
- gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$t._)`${it.parentData}[${it.parentDataProperty}]`));
2082
- }
2083
- function addErrs(cxt, errs) {
2084
- const { gen } = cxt;
2085
- gen.if((0, codegen_1$t._)`Array.isArray(${errs})`, () => {
2086
- 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`);
2087
- (0, errors_1$1.extendErrors)(cxt);
2088
- }, () => cxt.error());
2089
- }
2090
- function checkAsyncKeyword({ schemaEnv }, def2) {
2091
- if (def2.async && !schemaEnv.$async)
2092
- throw new Error("async keyword in sync schema");
2093
- }
2094
- function useKeyword(gen, keyword2, result) {
2095
- if (result === void 0)
2096
- throw new Error(`keyword "${keyword2}" failed to compile`);
2097
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$t.stringify)(result) });
2098
- }
2099
- function validSchemaType(schema, schemaType, allowUndefined = false) {
2100
- 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");
2101
- }
2102
- keyword.validSchemaType = validSchemaType;
2103
- function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
2104
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
2105
- throw new Error("ajv implementation error");
2106
- }
2107
- const deps = def2.dependencies;
2108
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
2109
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
2110
- }
2111
- if (def2.validateSchema) {
2112
- const valid = def2.validateSchema(schema[keyword2]);
2113
- if (!valid) {
2114
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
2115
- if (opts.validateSchema === "log")
2116
- self.logger.error(msg);
2117
- else
2118
- throw new Error(msg);
1997
+ code.usePattern = usePattern;
1998
+ function validateArray(cxt) {
1999
+ const { gen, data, keyword: keyword2, it } = cxt;
2000
+ const valid = gen.name("valid");
2001
+ if (it.allErrors) {
2002
+ const validArr = gen.let("valid", true);
2003
+ validateItems(() => gen.assign(validArr, false));
2004
+ return validArr;
2119
2005
  }
2006
+ gen.var(valid, true);
2007
+ validateItems(() => gen.break());
2008
+ return valid;
2009
+ function validateItems(notValid) {
2010
+ const len = gen.const("len", (0, codegen_12._)`${data}.length`);
2011
+ gen.forRange("i", 0, len, (i) => {
2012
+ cxt.subschema({
2013
+ keyword: keyword2,
2014
+ dataProp: i,
2015
+ dataPropType: util_12.Type.Num
2016
+ }, valid);
2017
+ gen.if((0, codegen_12.not)(valid), notValid);
2018
+ });
2019
+ }
2020
+ }
2021
+ code.validateArray = validateArray;
2022
+ function validateUnion(cxt) {
2023
+ const { gen, schema, keyword: keyword2, it } = cxt;
2024
+ if (!Array.isArray(schema))
2025
+ throw new Error("ajv implementation error");
2026
+ const alwaysValid = schema.some((sch) => (0, util_12.alwaysValidSchema)(it, sch));
2027
+ if (alwaysValid && !it.opts.unevaluated)
2028
+ return;
2029
+ const valid = gen.let("valid", false);
2030
+ const schValid = gen.name("_valid");
2031
+ gen.block(() => schema.forEach((_sch, i) => {
2032
+ const schCxt = cxt.subschema({
2033
+ keyword: keyword2,
2034
+ schemaProp: i,
2035
+ compositeRule: true
2036
+ }, schValid);
2037
+ gen.assign(valid, (0, codegen_12._)`${valid} || ${schValid}`);
2038
+ const merged = cxt.mergeValidEvaluated(schCxt, schValid);
2039
+ if (!merged)
2040
+ gen.if((0, codegen_12.not)(valid));
2041
+ }));
2042
+ cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
2120
2043
  }
2044
+ code.validateUnion = validateUnion;
2045
+ return code;
2121
2046
  }
2122
- keyword.validateKeywordUsage = validateKeywordUsage;
2123
- var subschema = {};
2124
- Object.defineProperty(subschema, "__esModule", { value: true });
2125
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
2126
- const codegen_1$s = codegen;
2127
- const util_1$r = util;
2128
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
2129
- if (keyword2 !== void 0 && schema !== void 0) {
2130
- throw new Error('both "keyword" and "schema" passed, only one allowed');
2131
- }
2132
- if (keyword2 !== void 0) {
2133
- const sch = it.schema[keyword2];
2134
- return schemaProp === void 0 ? {
2135
- schema: sch,
2136
- schemaPath: (0, codegen_1$s._)`${it.schemaPath}${(0, codegen_1$s.getProperty)(keyword2)}`,
2137
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
2138
- } : {
2139
- schema: sch[schemaProp],
2140
- schemaPath: (0, codegen_1$s._)`${it.schemaPath}${(0, codegen_1$s.getProperty)(keyword2)}${(0, codegen_1$s.getProperty)(schemaProp)}`,
2141
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$r.escapeFragment)(schemaProp)}`
2142
- };
2047
+ var hasRequiredKeyword;
2048
+ function requireKeyword() {
2049
+ if (hasRequiredKeyword)
2050
+ return keyword;
2051
+ hasRequiredKeyword = 1;
2052
+ Object.defineProperty(keyword, "__esModule", { value: true });
2053
+ keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
2054
+ const codegen_12 = codegen;
2055
+ const names_12 = requireNames();
2056
+ const code_12 = requireCode();
2057
+ const errors_12 = errors;
2058
+ function macroKeywordCode(cxt, def2) {
2059
+ const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
2060
+ const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
2061
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
2062
+ if (it.opts.validateSchema !== false)
2063
+ it.self.validateSchema(macroSchema, true);
2064
+ const valid = gen.name("valid");
2065
+ cxt.subschema({
2066
+ schema: macroSchema,
2067
+ schemaPath: codegen_12.nil,
2068
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
2069
+ topSchemaRef: schemaRef,
2070
+ compositeRule: true
2071
+ }, valid);
2072
+ cxt.pass(valid, () => cxt.error(true));
2143
2073
  }
2144
- if (schema !== void 0) {
2145
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
2146
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
2074
+ keyword.macroKeywordCode = macroKeywordCode;
2075
+ function funcKeywordCode(cxt, def2) {
2076
+ var _a;
2077
+ const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
2078
+ checkAsyncKeyword(it, def2);
2079
+ const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
2080
+ const validateRef = useKeyword(gen, keyword2, validate2);
2081
+ const valid = gen.let("valid");
2082
+ cxt.block$data(valid, validateKeyword);
2083
+ cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
2084
+ function validateKeyword() {
2085
+ if (def2.errors === false) {
2086
+ assignValid();
2087
+ if (def2.modifying)
2088
+ modifyData(cxt);
2089
+ reportErrs(() => cxt.error());
2090
+ } else {
2091
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
2092
+ if (def2.modifying)
2093
+ modifyData(cxt);
2094
+ reportErrs(() => addErrs(cxt, ruleErrs));
2095
+ }
2096
+ }
2097
+ function validateAsync() {
2098
+ const ruleErrs = gen.let("ruleErrs", null);
2099
+ 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)));
2100
+ return ruleErrs;
2101
+ }
2102
+ function validateSync() {
2103
+ const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
2104
+ gen.assign(validateErrs, null);
2105
+ assignValid(codegen_12.nil);
2106
+ return validateErrs;
2107
+ }
2108
+ function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
2109
+ const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
2110
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
2111
+ gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
2112
+ }
2113
+ function reportErrs(errors2) {
2114
+ var _a2;
2115
+ gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
2147
2116
  }
2148
- return {
2149
- schema,
2150
- schemaPath,
2151
- topSchemaRef,
2152
- errSchemaPath
2153
- };
2154
2117
  }
2155
- throw new Error('either "keyword" or "schema" must be passed');
2156
- }
2157
- subschema.getSubschema = getSubschema;
2158
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
2159
- if (data !== void 0 && dataProp !== void 0) {
2160
- throw new Error('both "data" and "dataProp" passed, only one allowed');
2161
- }
2162
- const { gen } = it;
2163
- if (dataProp !== void 0) {
2164
- const { errorPath, dataPathArr, opts } = it;
2165
- const nextData = gen.let("data", (0, codegen_1$s._)`${it.data}${(0, codegen_1$s.getProperty)(dataProp)}`, true);
2166
- dataContextProps(nextData);
2167
- subschema2.errorPath = (0, codegen_1$s.str)`${errorPath}${(0, util_1$r.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
2168
- subschema2.parentDataProperty = (0, codegen_1$s._)`${dataProp}`;
2169
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
2170
- }
2171
- if (data !== void 0) {
2172
- const nextData = data instanceof codegen_1$s.Name ? data : gen.let("data", data, true);
2173
- dataContextProps(nextData);
2174
- if (propertyName !== void 0)
2175
- subschema2.propertyName = propertyName;
2176
- }
2177
- if (dataTypes)
2178
- subschema2.dataTypes = dataTypes;
2179
- function dataContextProps(_nextData) {
2180
- subschema2.data = _nextData;
2181
- subschema2.dataLevel = it.dataLevel + 1;
2182
- subschema2.dataTypes = [];
2183
- it.definedProperties = /* @__PURE__ */ new Set();
2184
- subschema2.parentData = it.data;
2185
- subschema2.dataNames = [...it.dataNames, _nextData];
2118
+ keyword.funcKeywordCode = funcKeywordCode;
2119
+ function modifyData(cxt) {
2120
+ const { gen, data, it } = cxt;
2121
+ gen.if(it.parentData, () => gen.assign(data, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
2122
+ }
2123
+ function addErrs(cxt, errs) {
2124
+ const { gen } = cxt;
2125
+ gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
2126
+ 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`);
2127
+ (0, errors_12.extendErrors)(cxt);
2128
+ }, () => cxt.error());
2129
+ }
2130
+ function checkAsyncKeyword({ schemaEnv }, def2) {
2131
+ if (def2.async && !schemaEnv.$async)
2132
+ throw new Error("async keyword in sync schema");
2133
+ }
2134
+ function useKeyword(gen, keyword2, result) {
2135
+ if (result === void 0)
2136
+ throw new Error(`keyword "${keyword2}" failed to compile`);
2137
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
2138
+ }
2139
+ function validSchemaType(schema, schemaType, allowUndefined = false) {
2140
+ 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");
2141
+ }
2142
+ keyword.validSchemaType = validSchemaType;
2143
+ function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
2144
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
2145
+ throw new Error("ajv implementation error");
2146
+ }
2147
+ const deps = def2.dependencies;
2148
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
2149
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
2150
+ }
2151
+ if (def2.validateSchema) {
2152
+ const valid = def2.validateSchema(schema[keyword2]);
2153
+ if (!valid) {
2154
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
2155
+ if (opts.validateSchema === "log")
2156
+ self.logger.error(msg);
2157
+ else
2158
+ throw new Error(msg);
2159
+ }
2160
+ }
2186
2161
  }
2162
+ keyword.validateKeywordUsage = validateKeywordUsage;
2163
+ return keyword;
2187
2164
  }
2188
- subschema.extendSubschemaData = extendSubschemaData;
2189
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
2190
- if (compositeRule !== void 0)
2191
- subschema2.compositeRule = compositeRule;
2192
- if (createErrors !== void 0)
2193
- subschema2.createErrors = createErrors;
2194
- if (allErrors !== void 0)
2195
- subschema2.allErrors = allErrors;
2196
- subschema2.jtdDiscriminator = jtdDiscriminator;
2197
- subschema2.jtdMetadata = jtdMetadata;
2165
+ var subschema = {};
2166
+ var hasRequiredSubschema;
2167
+ function requireSubschema() {
2168
+ if (hasRequiredSubschema)
2169
+ return subschema;
2170
+ hasRequiredSubschema = 1;
2171
+ Object.defineProperty(subschema, "__esModule", { value: true });
2172
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
2173
+ const codegen_12 = codegen;
2174
+ const util_12 = util;
2175
+ function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
2176
+ if (keyword2 !== void 0 && schema !== void 0) {
2177
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
2178
+ }
2179
+ if (keyword2 !== void 0) {
2180
+ const sch = it.schema[keyword2];
2181
+ return schemaProp === void 0 ? {
2182
+ schema: sch,
2183
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
2184
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`
2185
+ } : {
2186
+ schema: sch[schemaProp],
2187
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
2188
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
2189
+ };
2190
+ }
2191
+ if (schema !== void 0) {
2192
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
2193
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
2194
+ }
2195
+ return {
2196
+ schema,
2197
+ schemaPath,
2198
+ topSchemaRef,
2199
+ errSchemaPath
2200
+ };
2201
+ }
2202
+ throw new Error('either "keyword" or "schema" must be passed');
2203
+ }
2204
+ subschema.getSubschema = getSubschema;
2205
+ function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
2206
+ if (data !== void 0 && dataProp !== void 0) {
2207
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
2208
+ }
2209
+ const { gen } = it;
2210
+ if (dataProp !== void 0) {
2211
+ const { errorPath, dataPathArr, opts } = it;
2212
+ const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
2213
+ dataContextProps(nextData);
2214
+ subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
2215
+ subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
2216
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
2217
+ }
2218
+ if (data !== void 0) {
2219
+ const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
2220
+ dataContextProps(nextData);
2221
+ if (propertyName !== void 0)
2222
+ subschema2.propertyName = propertyName;
2223
+ }
2224
+ if (dataTypes)
2225
+ subschema2.dataTypes = dataTypes;
2226
+ function dataContextProps(_nextData) {
2227
+ subschema2.data = _nextData;
2228
+ subschema2.dataLevel = it.dataLevel + 1;
2229
+ subschema2.dataTypes = [];
2230
+ it.definedProperties = /* @__PURE__ */ new Set();
2231
+ subschema2.parentData = it.data;
2232
+ subschema2.dataNames = [...it.dataNames, _nextData];
2233
+ }
2234
+ }
2235
+ subschema.extendSubschemaData = extendSubschemaData;
2236
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
2237
+ if (compositeRule !== void 0)
2238
+ subschema2.compositeRule = compositeRule;
2239
+ if (createErrors !== void 0)
2240
+ subschema2.createErrors = createErrors;
2241
+ if (allErrors !== void 0)
2242
+ subschema2.allErrors = allErrors;
2243
+ subschema2.jtdDiscriminator = jtdDiscriminator;
2244
+ subschema2.jtdMetadata = jtdMetadata;
2245
+ }
2246
+ subschema.extendSubschemaMode = extendSubschemaMode;
2247
+ return subschema;
2198
2248
  }
2199
- subschema.extendSubschemaMode = extendSubschemaMode;
2200
2249
  var resolve$2 = {};
2201
2250
  var fastDeepEqual = function equal(a, b) {
2202
2251
  if (a === b)
@@ -2321,7 +2370,7 @@ function escapeJsonPtr(str) {
2321
2370
  var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
2322
2371
  Object.defineProperty(resolve$2, "__esModule", { value: true });
2323
2372
  resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
2324
- const util_1$q = util;
2373
+ const util_1$p = util;
2325
2374
  const equal$3 = fastDeepEqual;
2326
2375
  const traverse = jsonSchemaTraverseExports;
2327
2376
  const SIMPLE_INLINED = /* @__PURE__ */ new Set([
@@ -2380,7 +2429,7 @@ function countKeys(schema) {
2380
2429
  if (SIMPLE_INLINED.has(key))
2381
2430
  continue;
2382
2431
  if (typeof schema[key] == "object") {
2383
- (0, util_1$q.eachItem)(schema[key], (sch) => count += countKeys(sch));
2432
+ (0, util_1$p.eachItem)(schema[key], (sch) => count += countKeys(sch));
2384
2433
  }
2385
2434
  if (count === Infinity)
2386
2435
  return Infinity;
@@ -2468,506 +2517,513 @@ function getSchemaRefs(schema, baseId) {
2468
2517
  }
2469
2518
  }
2470
2519
  resolve$2.getSchemaRefs = getSchemaRefs;
2471
- Object.defineProperty(validate, "__esModule", { value: true });
2472
- validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
2473
- const boolSchema_1 = boolSchema;
2474
- const dataType_1$1 = dataType;
2475
- const applicability_1 = applicability;
2476
- const dataType_2 = dataType;
2477
- const defaults_1 = defaults;
2478
- const keyword_1 = keyword;
2479
- const subschema_1 = subschema;
2480
- const codegen_1$r = codegen;
2481
- const names_1$6 = names$1;
2482
- const resolve_1$2 = resolve$2;
2483
- const util_1$p = util;
2484
- const errors_1 = errors;
2485
- function validateFunctionCode(it) {
2486
- if (isSchemaObj(it)) {
2487
- checkKeywords(it);
2488
- if (schemaCxtHasRules(it)) {
2489
- topSchemaObjCode(it);
2490
- return;
2520
+ var hasRequiredValidate;
2521
+ function requireValidate() {
2522
+ if (hasRequiredValidate)
2523
+ return validate;
2524
+ hasRequiredValidate = 1;
2525
+ Object.defineProperty(validate, "__esModule", { value: true });
2526
+ validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
2527
+ const boolSchema_1 = requireBoolSchema();
2528
+ const dataType_12 = dataType;
2529
+ const applicability_12 = requireApplicability();
2530
+ const dataType_2 = dataType;
2531
+ const defaults_1 = requireDefaults();
2532
+ const keyword_1 = requireKeyword();
2533
+ const subschema_1 = requireSubschema();
2534
+ const codegen_12 = codegen;
2535
+ const names_12 = requireNames();
2536
+ const resolve_12 = resolve$2;
2537
+ const util_12 = util;
2538
+ const errors_12 = errors;
2539
+ function validateFunctionCode(it) {
2540
+ if (isSchemaObj(it)) {
2541
+ checkKeywords(it);
2542
+ if (schemaCxtHasRules(it)) {
2543
+ topSchemaObjCode(it);
2544
+ return;
2545
+ }
2491
2546
  }
2547
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
2492
2548
  }
2493
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
2494
- }
2495
- validate.validateFunctionCode = validateFunctionCode;
2496
- function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
2497
- if (opts.code.es5) {
2498
- gen.func(validateName, (0, codegen_1$r._)`${names_1$6.default.data}, ${names_1$6.default.valCxt}`, schemaEnv.$async, () => {
2499
- gen.code((0, codegen_1$r._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
2500
- destructureValCxtES5(gen, opts);
2501
- gen.code(body);
2549
+ validate.validateFunctionCode = validateFunctionCode;
2550
+ function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
2551
+ if (opts.code.es5) {
2552
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
2553
+ gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
2554
+ destructureValCxtES5(gen, opts);
2555
+ gen.code(body);
2556
+ });
2557
+ } else {
2558
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
2559
+ }
2560
+ }
2561
+ function destructureValCxt(opts) {
2562
+ 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}}={}`;
2563
+ }
2564
+ function destructureValCxtES5(gen, opts) {
2565
+ gen.if(names_12.default.valCxt, () => {
2566
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
2567
+ gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
2568
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
2569
+ gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
2570
+ if (opts.dynamicRef)
2571
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
2572
+ }, () => {
2573
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
2574
+ gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
2575
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
2576
+ gen.var(names_12.default.rootData, names_12.default.data);
2577
+ if (opts.dynamicRef)
2578
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
2502
2579
  });
2503
- } else {
2504
- gen.func(validateName, (0, codegen_1$r._)`${names_1$6.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
2505
2580
  }
2506
- }
2507
- function destructureValCxt(opts) {
2508
- 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}}={}`;
2509
- }
2510
- function destructureValCxtES5(gen, opts) {
2511
- gen.if(names_1$6.default.valCxt, () => {
2512
- gen.var(names_1$6.default.instancePath, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.instancePath}`);
2513
- gen.var(names_1$6.default.parentData, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.parentData}`);
2514
- gen.var(names_1$6.default.parentDataProperty, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.parentDataProperty}`);
2515
- gen.var(names_1$6.default.rootData, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.rootData}`);
2516
- if (opts.dynamicRef)
2517
- gen.var(names_1$6.default.dynamicAnchors, (0, codegen_1$r._)`${names_1$6.default.valCxt}.${names_1$6.default.dynamicAnchors}`);
2518
- }, () => {
2519
- gen.var(names_1$6.default.instancePath, (0, codegen_1$r._)`""`);
2520
- gen.var(names_1$6.default.parentData, (0, codegen_1$r._)`undefined`);
2521
- gen.var(names_1$6.default.parentDataProperty, (0, codegen_1$r._)`undefined`);
2522
- gen.var(names_1$6.default.rootData, names_1$6.default.data);
2523
- if (opts.dynamicRef)
2524
- gen.var(names_1$6.default.dynamicAnchors, (0, codegen_1$r._)`{}`);
2525
- });
2526
- }
2527
- function topSchemaObjCode(it) {
2528
- const { schema, opts, gen } = it;
2529
- validateFunction(it, () => {
2581
+ function topSchemaObjCode(it) {
2582
+ const { schema, opts, gen } = it;
2583
+ validateFunction(it, () => {
2584
+ if (opts.$comment && schema.$comment)
2585
+ commentKeyword(it);
2586
+ checkNoDefault(it);
2587
+ gen.let(names_12.default.vErrors, null);
2588
+ gen.let(names_12.default.errors, 0);
2589
+ if (opts.unevaluated)
2590
+ resetEvaluated(it);
2591
+ typeAndKeywords(it);
2592
+ returnResults(it);
2593
+ });
2594
+ return;
2595
+ }
2596
+ function resetEvaluated(it) {
2597
+ const { gen, validateName } = it;
2598
+ it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
2599
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
2600
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
2601
+ }
2602
+ function funcSourceUrl(schema, opts) {
2603
+ const schId = typeof schema == "object" && schema[opts.schemaId];
2604
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
2605
+ }
2606
+ function subschemaCode(it, valid) {
2607
+ if (isSchemaObj(it)) {
2608
+ checkKeywords(it);
2609
+ if (schemaCxtHasRules(it)) {
2610
+ subSchemaObjCode(it, valid);
2611
+ return;
2612
+ }
2613
+ }
2614
+ (0, boolSchema_1.boolOrEmptySchema)(it, valid);
2615
+ }
2616
+ function schemaCxtHasRules({ schema, self }) {
2617
+ if (typeof schema == "boolean")
2618
+ return !schema;
2619
+ for (const key in schema)
2620
+ if (self.RULES.all[key])
2621
+ return true;
2622
+ return false;
2623
+ }
2624
+ function isSchemaObj(it) {
2625
+ return typeof it.schema != "boolean";
2626
+ }
2627
+ function subSchemaObjCode(it, valid) {
2628
+ const { schema, gen, opts } = it;
2530
2629
  if (opts.$comment && schema.$comment)
2531
2630
  commentKeyword(it);
2532
- checkNoDefault(it);
2533
- gen.let(names_1$6.default.vErrors, null);
2534
- gen.let(names_1$6.default.errors, 0);
2535
- if (opts.unevaluated)
2536
- resetEvaluated(it);
2537
- typeAndKeywords(it);
2538
- returnResults(it);
2539
- });
2540
- return;
2541
- }
2542
- function resetEvaluated(it) {
2543
- const { gen, validateName } = it;
2544
- it.evaluated = gen.const("evaluated", (0, codegen_1$r._)`${validateName}.evaluated`);
2545
- gen.if((0, codegen_1$r._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$r._)`${it.evaluated}.props`, (0, codegen_1$r._)`undefined`));
2546
- gen.if((0, codegen_1$r._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$r._)`${it.evaluated}.items`, (0, codegen_1$r._)`undefined`));
2547
- }
2548
- function funcSourceUrl(schema, opts) {
2549
- const schId = typeof schema == "object" && schema[opts.schemaId];
2550
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$r._)`/*# sourceURL=${schId} */` : codegen_1$r.nil;
2551
- }
2552
- function subschemaCode(it, valid) {
2553
- if (isSchemaObj(it)) {
2554
- checkKeywords(it);
2555
- if (schemaCxtHasRules(it)) {
2556
- subSchemaObjCode(it, valid);
2557
- return;
2558
- }
2631
+ updateContext(it);
2632
+ checkAsyncSchema(it);
2633
+ const errsCount = gen.const("_errs", names_12.default.errors);
2634
+ typeAndKeywords(it, errsCount);
2635
+ gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
2559
2636
  }
2560
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
2561
- }
2562
- function schemaCxtHasRules({ schema, self }) {
2563
- if (typeof schema == "boolean")
2564
- return !schema;
2565
- for (const key in schema)
2566
- if (self.RULES.all[key])
2567
- return true;
2568
- return false;
2569
- }
2570
- function isSchemaObj(it) {
2571
- return typeof it.schema != "boolean";
2572
- }
2573
- function subSchemaObjCode(it, valid) {
2574
- const { schema, gen, opts } = it;
2575
- if (opts.$comment && schema.$comment)
2576
- commentKeyword(it);
2577
- updateContext(it);
2578
- checkAsyncSchema(it);
2579
- const errsCount = gen.const("_errs", names_1$6.default.errors);
2580
- typeAndKeywords(it, errsCount);
2581
- gen.var(valid, (0, codegen_1$r._)`${errsCount} === ${names_1$6.default.errors}`);
2582
- }
2583
- function checkKeywords(it) {
2584
- (0, util_1$p.checkUnknownRules)(it);
2585
- checkRefsAndKeywords(it);
2586
- }
2587
- function typeAndKeywords(it, errsCount) {
2588
- if (it.opts.jtd)
2589
- return schemaKeywords(it, [], false, errsCount);
2590
- const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
2591
- const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
2592
- schemaKeywords(it, types2, !checkedTypes, errsCount);
2593
- }
2594
- function checkRefsAndKeywords(it) {
2595
- const { schema, errSchemaPath, opts, self } = it;
2596
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$p.schemaHasRulesButRef)(schema, self.RULES)) {
2597
- self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
2637
+ function checkKeywords(it) {
2638
+ (0, util_12.checkUnknownRules)(it);
2639
+ checkRefsAndKeywords(it);
2598
2640
  }
2599
- }
2600
- function checkNoDefault(it) {
2601
- const { schema, opts } = it;
2602
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
2603
- (0, util_1$p.checkStrictMode)(it, "default is ignored in the schema root");
2641
+ function typeAndKeywords(it, errsCount) {
2642
+ if (it.opts.jtd)
2643
+ return schemaKeywords(it, [], false, errsCount);
2644
+ const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
2645
+ const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
2646
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
2604
2647
  }
2605
- }
2606
- function updateContext(it) {
2607
- const schId = it.schema[it.opts.schemaId];
2608
- if (schId)
2609
- it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
2610
- }
2611
- function checkAsyncSchema(it) {
2612
- if (it.schema.$async && !it.schemaEnv.$async)
2613
- throw new Error("async schema in sync schema");
2614
- }
2615
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
2616
- const msg = schema.$comment;
2617
- if (opts.$comment === true) {
2618
- gen.code((0, codegen_1$r._)`${names_1$6.default.self}.logger.log(${msg})`);
2619
- } else if (typeof opts.$comment == "function") {
2620
- const schemaPath = (0, codegen_1$r.str)`${errSchemaPath}/$comment`;
2621
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
2622
- gen.code((0, codegen_1$r._)`${names_1$6.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
2648
+ function checkRefsAndKeywords(it) {
2649
+ const { schema, errSchemaPath, opts, self } = it;
2650
+ if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self.RULES)) {
2651
+ self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
2652
+ }
2623
2653
  }
2624
- }
2625
- function returnResults(it) {
2626
- const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
2627
- if (schemaEnv.$async) {
2628
- 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})`));
2629
- } else {
2630
- gen.assign((0, codegen_1$r._)`${validateName}.errors`, names_1$6.default.vErrors);
2631
- if (opts.unevaluated)
2632
- assignEvaluated(it);
2633
- gen.return((0, codegen_1$r._)`${names_1$6.default.errors} === 0`);
2654
+ function checkNoDefault(it) {
2655
+ const { schema, opts } = it;
2656
+ if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
2657
+ (0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
2658
+ }
2634
2659
  }
2635
- }
2636
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
2637
- if (props instanceof codegen_1$r.Name)
2638
- gen.assign((0, codegen_1$r._)`${evaluated}.props`, props);
2639
- if (items2 instanceof codegen_1$r.Name)
2640
- gen.assign((0, codegen_1$r._)`${evaluated}.items`, items2);
2641
- }
2642
- function schemaKeywords(it, types2, typeErrors, errsCount) {
2643
- const { gen, schema, data, allErrors, opts, self } = it;
2644
- const { RULES } = self;
2645
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$p.schemaHasRulesButRef)(schema, RULES))) {
2646
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
2647
- return;
2660
+ function updateContext(it) {
2661
+ const schId = it.schema[it.opts.schemaId];
2662
+ if (schId)
2663
+ it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
2648
2664
  }
2649
- if (!opts.jtd)
2650
- checkStrictTypes(it, types2);
2651
- gen.block(() => {
2652
- for (const group of RULES.rules)
2653
- groupKeywords(group);
2654
- groupKeywords(RULES.post);
2655
- });
2656
- function groupKeywords(group) {
2657
- if (!(0, applicability_1.shouldUseGroup)(schema, group))
2665
+ function checkAsyncSchema(it) {
2666
+ if (it.schema.$async && !it.schemaEnv.$async)
2667
+ throw new Error("async schema in sync schema");
2668
+ }
2669
+ function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
2670
+ const msg = schema.$comment;
2671
+ if (opts.$comment === true) {
2672
+ gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
2673
+ } else if (typeof opts.$comment == "function") {
2674
+ const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
2675
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
2676
+ gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
2677
+ }
2678
+ }
2679
+ function returnResults(it) {
2680
+ const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
2681
+ if (schemaEnv.$async) {
2682
+ gen.if((0, codegen_12._)`${names_12.default.errors} === 0`, () => gen.return(names_12.default.data), () => gen.throw((0, codegen_12._)`new ${ValidationError2}(${names_12.default.vErrors})`));
2683
+ } else {
2684
+ gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
2685
+ if (opts.unevaluated)
2686
+ assignEvaluated(it);
2687
+ gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
2688
+ }
2689
+ }
2690
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
2691
+ if (props instanceof codegen_12.Name)
2692
+ gen.assign((0, codegen_12._)`${evaluated}.props`, props);
2693
+ if (items2 instanceof codegen_12.Name)
2694
+ gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
2695
+ }
2696
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
2697
+ const { gen, schema, data, allErrors, opts, self } = it;
2698
+ const { RULES } = self;
2699
+ if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
2700
+ gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
2658
2701
  return;
2659
- if (group.type) {
2660
- gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
2661
- iterateKeywords(it, group);
2662
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
2663
- gen.else();
2664
- (0, dataType_2.reportTypeError)(it);
2702
+ }
2703
+ if (!opts.jtd)
2704
+ checkStrictTypes(it, types2);
2705
+ gen.block(() => {
2706
+ for (const group of RULES.rules)
2707
+ groupKeywords(group);
2708
+ groupKeywords(RULES.post);
2709
+ });
2710
+ function groupKeywords(group) {
2711
+ if (!(0, applicability_12.shouldUseGroup)(schema, group))
2712
+ return;
2713
+ if (group.type) {
2714
+ gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
2715
+ iterateKeywords(it, group);
2716
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
2717
+ gen.else();
2718
+ (0, dataType_2.reportTypeError)(it);
2719
+ }
2720
+ gen.endIf();
2721
+ } else {
2722
+ iterateKeywords(it, group);
2665
2723
  }
2666
- gen.endIf();
2667
- } else {
2668
- iterateKeywords(it, group);
2724
+ if (!allErrors)
2725
+ gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
2669
2726
  }
2670
- if (!allErrors)
2671
- gen.if((0, codegen_1$r._)`${names_1$6.default.errors} === ${errsCount || 0}`);
2672
2727
  }
2673
- }
2674
- function iterateKeywords(it, group) {
2675
- const { gen, schema, opts: { useDefaults } } = it;
2676
- if (useDefaults)
2677
- (0, defaults_1.assignDefaults)(it, group.type);
2678
- gen.block(() => {
2679
- for (const rule of group.rules) {
2680
- if ((0, applicability_1.shouldUseRule)(schema, rule)) {
2681
- keywordCode(it, rule.keyword, rule.definition, group.type);
2728
+ function iterateKeywords(it, group) {
2729
+ const { gen, schema, opts: { useDefaults } } = it;
2730
+ if (useDefaults)
2731
+ (0, defaults_1.assignDefaults)(it, group.type);
2732
+ gen.block(() => {
2733
+ for (const rule of group.rules) {
2734
+ if ((0, applicability_12.shouldUseRule)(schema, rule)) {
2735
+ keywordCode(it, rule.keyword, rule.definition, group.type);
2736
+ }
2682
2737
  }
2738
+ });
2739
+ }
2740
+ function checkStrictTypes(it, types2) {
2741
+ if (it.schemaEnv.meta || !it.opts.strictTypes)
2742
+ return;
2743
+ checkContextTypes(it, types2);
2744
+ if (!it.opts.allowUnionTypes)
2745
+ checkMultipleTypes(it, types2);
2746
+ checkKeywordTypes(it, it.dataTypes);
2747
+ }
2748
+ function checkContextTypes(it, types2) {
2749
+ if (!types2.length)
2750
+ return;
2751
+ if (!it.dataTypes.length) {
2752
+ it.dataTypes = types2;
2753
+ return;
2683
2754
  }
2684
- });
2685
- }
2686
- function checkStrictTypes(it, types2) {
2687
- if (it.schemaEnv.meta || !it.opts.strictTypes)
2688
- return;
2689
- checkContextTypes(it, types2);
2690
- if (!it.opts.allowUnionTypes)
2691
- checkMultipleTypes(it, types2);
2692
- checkKeywordTypes(it, it.dataTypes);
2693
- }
2694
- function checkContextTypes(it, types2) {
2695
- if (!types2.length)
2696
- return;
2697
- if (!it.dataTypes.length) {
2698
- it.dataTypes = types2;
2699
- return;
2755
+ types2.forEach((t) => {
2756
+ if (!includesType(it.dataTypes, t)) {
2757
+ strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
2758
+ }
2759
+ });
2760
+ narrowSchemaTypes(it, types2);
2700
2761
  }
2701
- types2.forEach((t) => {
2702
- if (!includesType(it.dataTypes, t)) {
2703
- strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
2762
+ function checkMultipleTypes(it, ts) {
2763
+ if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
2764
+ strictTypesError(it, "use allowUnionTypes to allow union type keyword");
2704
2765
  }
2705
- });
2706
- narrowSchemaTypes(it, types2);
2707
- }
2708
- function checkMultipleTypes(it, ts) {
2709
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
2710
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
2711
2766
  }
2712
- }
2713
- function checkKeywordTypes(it, ts) {
2714
- const rules2 = it.self.RULES.all;
2715
- for (const keyword2 in rules2) {
2716
- const rule = rules2[keyword2];
2717
- if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
2718
- const { type: type2 } = rule.definition;
2719
- if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
2720
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
2767
+ function checkKeywordTypes(it, ts) {
2768
+ const rules2 = it.self.RULES.all;
2769
+ for (const keyword2 in rules2) {
2770
+ const rule = rules2[keyword2];
2771
+ if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
2772
+ const { type: type2 } = rule.definition;
2773
+ if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
2774
+ strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
2775
+ }
2721
2776
  }
2722
2777
  }
2723
2778
  }
2724
- }
2725
- function hasApplicableType(schTs, kwdT) {
2726
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
2727
- }
2728
- function includesType(ts, t) {
2729
- return ts.includes(t) || t === "integer" && ts.includes("number");
2730
- }
2731
- function narrowSchemaTypes(it, withTypes) {
2732
- const ts = [];
2733
- for (const t of it.dataTypes) {
2734
- if (includesType(withTypes, t))
2735
- ts.push(t);
2736
- else if (withTypes.includes("integer") && t === "number")
2737
- ts.push("integer");
2738
- }
2739
- it.dataTypes = ts;
2740
- }
2741
- function strictTypesError(it, msg) {
2742
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
2743
- msg += ` at "${schemaPath}" (strictTypes)`;
2744
- (0, util_1$p.checkStrictMode)(it, msg, it.opts.strictTypes);
2745
- }
2746
- class KeywordCxt {
2747
- constructor(it, def2, keyword2) {
2748
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
2749
- this.gen = it.gen;
2750
- this.allErrors = it.allErrors;
2751
- this.keyword = keyword2;
2752
- this.data = it.data;
2753
- this.schema = it.schema[keyword2];
2754
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
2755
- this.schemaValue = (0, util_1$p.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
2756
- this.schemaType = def2.schemaType;
2757
- this.parentSchema = it.schema;
2758
- this.params = {};
2759
- this.it = it;
2760
- this.def = def2;
2761
- if (this.$data) {
2762
- this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
2763
- } else {
2764
- this.schemaCode = this.schemaValue;
2765
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
2766
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
2779
+ function hasApplicableType(schTs, kwdT) {
2780
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
2781
+ }
2782
+ function includesType(ts, t) {
2783
+ return ts.includes(t) || t === "integer" && ts.includes("number");
2784
+ }
2785
+ function narrowSchemaTypes(it, withTypes) {
2786
+ const ts = [];
2787
+ for (const t of it.dataTypes) {
2788
+ if (includesType(withTypes, t))
2789
+ ts.push(t);
2790
+ else if (withTypes.includes("integer") && t === "number")
2791
+ ts.push("integer");
2792
+ }
2793
+ it.dataTypes = ts;
2794
+ }
2795
+ function strictTypesError(it, msg) {
2796
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
2797
+ msg += ` at "${schemaPath}" (strictTypes)`;
2798
+ (0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
2799
+ }
2800
+ class KeywordCxt {
2801
+ constructor(it, def2, keyword2) {
2802
+ (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
2803
+ this.gen = it.gen;
2804
+ this.allErrors = it.allErrors;
2805
+ this.keyword = keyword2;
2806
+ this.data = it.data;
2807
+ this.schema = it.schema[keyword2];
2808
+ this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
2809
+ this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
2810
+ this.schemaType = def2.schemaType;
2811
+ this.parentSchema = it.schema;
2812
+ this.params = {};
2813
+ this.it = it;
2814
+ this.def = def2;
2815
+ if (this.$data) {
2816
+ this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
2817
+ } else {
2818
+ this.schemaCode = this.schemaValue;
2819
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
2820
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
2821
+ }
2822
+ }
2823
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
2824
+ this.errsCount = it.gen.const("_errs", names_12.default.errors);
2767
2825
  }
2768
2826
  }
2769
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
2770
- this.errsCount = it.gen.const("_errs", names_1$6.default.errors);
2827
+ result(condition, successAction, failAction) {
2828
+ this.failResult((0, codegen_12.not)(condition), successAction, failAction);
2771
2829
  }
2772
- }
2773
- result(condition, successAction, failAction) {
2774
- this.failResult((0, codegen_1$r.not)(condition), successAction, failAction);
2775
- }
2776
- failResult(condition, successAction, failAction) {
2777
- this.gen.if(condition);
2778
- if (failAction)
2779
- failAction();
2780
- else
2830
+ failResult(condition, successAction, failAction) {
2831
+ this.gen.if(condition);
2832
+ if (failAction)
2833
+ failAction();
2834
+ else
2835
+ this.error();
2836
+ if (successAction) {
2837
+ this.gen.else();
2838
+ successAction();
2839
+ if (this.allErrors)
2840
+ this.gen.endIf();
2841
+ } else {
2842
+ if (this.allErrors)
2843
+ this.gen.endIf();
2844
+ else
2845
+ this.gen.else();
2846
+ }
2847
+ }
2848
+ pass(condition, failAction) {
2849
+ this.failResult((0, codegen_12.not)(condition), void 0, failAction);
2850
+ }
2851
+ fail(condition) {
2852
+ if (condition === void 0) {
2853
+ this.error();
2854
+ if (!this.allErrors)
2855
+ this.gen.if(false);
2856
+ return;
2857
+ }
2858
+ this.gen.if(condition);
2781
2859
  this.error();
2782
- if (successAction) {
2783
- this.gen.else();
2784
- successAction();
2785
- if (this.allErrors)
2786
- this.gen.endIf();
2787
- } else {
2788
2860
  if (this.allErrors)
2789
2861
  this.gen.endIf();
2790
2862
  else
2791
2863
  this.gen.else();
2792
2864
  }
2793
- }
2794
- pass(condition, failAction) {
2795
- this.failResult((0, codegen_1$r.not)(condition), void 0, failAction);
2796
- }
2797
- fail(condition) {
2798
- if (condition === void 0) {
2799
- this.error();
2865
+ fail$data(condition) {
2866
+ if (!this.$data)
2867
+ return this.fail(condition);
2868
+ const { schemaCode } = this;
2869
+ this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
2870
+ }
2871
+ error(append, errorParams, errorPaths) {
2872
+ if (errorParams) {
2873
+ this.setParams(errorParams);
2874
+ this._error(append, errorPaths);
2875
+ this.setParams({});
2876
+ return;
2877
+ }
2878
+ this._error(append, errorPaths);
2879
+ }
2880
+ _error(append, errorPaths) {
2881
+ (append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
2882
+ }
2883
+ $dataError() {
2884
+ (0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
2885
+ }
2886
+ reset() {
2887
+ if (this.errsCount === void 0)
2888
+ throw new Error('add "trackErrors" to keyword definition');
2889
+ (0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
2890
+ }
2891
+ ok(cond) {
2800
2892
  if (!this.allErrors)
2801
- this.gen.if(false);
2802
- return;
2893
+ this.gen.if(cond);
2803
2894
  }
2804
- this.gen.if(condition);
2805
- this.error();
2806
- if (this.allErrors)
2807
- this.gen.endIf();
2808
- else
2809
- this.gen.else();
2810
- }
2811
- fail$data(condition) {
2812
- if (!this.$data)
2813
- return this.fail(condition);
2814
- const { schemaCode } = this;
2815
- this.fail((0, codegen_1$r._)`${schemaCode} !== undefined && (${(0, codegen_1$r.or)(this.invalid$data(), condition)})`);
2816
- }
2817
- error(append, errorParams, errorPaths) {
2818
- if (errorParams) {
2819
- this.setParams(errorParams);
2820
- this._error(append, errorPaths);
2821
- this.setParams({});
2822
- return;
2895
+ setParams(obj, assign) {
2896
+ if (assign)
2897
+ Object.assign(this.params, obj);
2898
+ else
2899
+ this.params = obj;
2823
2900
  }
2824
- this._error(append, errorPaths);
2825
- }
2826
- _error(append, errorPaths) {
2827
- (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
2828
- }
2829
- $dataError() {
2830
- (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
2831
- }
2832
- reset() {
2833
- if (this.errsCount === void 0)
2834
- throw new Error('add "trackErrors" to keyword definition');
2835
- (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
2836
- }
2837
- ok(cond) {
2838
- if (!this.allErrors)
2839
- this.gen.if(cond);
2840
- }
2841
- setParams(obj, assign) {
2842
- if (assign)
2843
- Object.assign(this.params, obj);
2844
- else
2845
- this.params = obj;
2846
- }
2847
- block$data(valid, codeBlock, $dataValid = codegen_1$r.nil) {
2848
- this.gen.block(() => {
2849
- this.check$data(valid, $dataValid);
2850
- codeBlock();
2851
- });
2852
- }
2853
- check$data(valid = codegen_1$r.nil, $dataValid = codegen_1$r.nil) {
2854
- if (!this.$data)
2855
- return;
2856
- const { gen, schemaCode, schemaType, def: def2 } = this;
2857
- gen.if((0, codegen_1$r.or)((0, codegen_1$r._)`${schemaCode} === undefined`, $dataValid));
2858
- if (valid !== codegen_1$r.nil)
2859
- gen.assign(valid, true);
2860
- if (schemaType.length || def2.validateSchema) {
2861
- gen.elseIf(this.invalid$data());
2862
- this.$dataError();
2863
- if (valid !== codegen_1$r.nil)
2864
- gen.assign(valid, false);
2901
+ block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
2902
+ this.gen.block(() => {
2903
+ this.check$data(valid, $dataValid);
2904
+ codeBlock();
2905
+ });
2865
2906
  }
2866
- gen.else();
2867
- }
2868
- invalid$data() {
2869
- const { gen, schemaCode, schemaType, def: def2, it } = this;
2870
- return (0, codegen_1$r.or)(wrong$DataType(), invalid$DataSchema());
2871
- function wrong$DataType() {
2872
- if (schemaType.length) {
2873
- if (!(schemaCode instanceof codegen_1$r.Name))
2874
- throw new Error("ajv implementation error");
2875
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
2876
- return (0, codegen_1$r._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
2907
+ check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
2908
+ if (!this.$data)
2909
+ return;
2910
+ const { gen, schemaCode, schemaType, def: def2 } = this;
2911
+ gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
2912
+ if (valid !== codegen_12.nil)
2913
+ gen.assign(valid, true);
2914
+ if (schemaType.length || def2.validateSchema) {
2915
+ gen.elseIf(this.invalid$data());
2916
+ this.$dataError();
2917
+ if (valid !== codegen_12.nil)
2918
+ gen.assign(valid, false);
2877
2919
  }
2878
- return codegen_1$r.nil;
2920
+ gen.else();
2879
2921
  }
2880
- function invalid$DataSchema() {
2881
- if (def2.validateSchema) {
2882
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
2883
- return (0, codegen_1$r._)`!${validateSchemaRef}(${schemaCode})`;
2922
+ invalid$data() {
2923
+ const { gen, schemaCode, schemaType, def: def2, it } = this;
2924
+ return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
2925
+ function wrong$DataType() {
2926
+ if (schemaType.length) {
2927
+ if (!(schemaCode instanceof codegen_12.Name))
2928
+ throw new Error("ajv implementation error");
2929
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
2930
+ return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
2931
+ }
2932
+ return codegen_12.nil;
2933
+ }
2934
+ function invalid$DataSchema() {
2935
+ if (def2.validateSchema) {
2936
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
2937
+ return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
2938
+ }
2939
+ return codegen_12.nil;
2884
2940
  }
2885
- return codegen_1$r.nil;
2886
2941
  }
2887
- }
2888
- subschema(appl, valid) {
2889
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
2890
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
2891
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
2892
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
2893
- subschemaCode(nextContext, valid);
2894
- return nextContext;
2895
- }
2896
- mergeEvaluated(schemaCxt, toName) {
2897
- const { it, gen } = this;
2898
- if (!it.opts.unevaluated)
2899
- return;
2900
- if (it.props !== true && schemaCxt.props !== void 0) {
2901
- it.props = util_1$p.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
2942
+ subschema(appl, valid) {
2943
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
2944
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
2945
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
2946
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
2947
+ subschemaCode(nextContext, valid);
2948
+ return nextContext;
2949
+ }
2950
+ mergeEvaluated(schemaCxt, toName) {
2951
+ const { it, gen } = this;
2952
+ if (!it.opts.unevaluated)
2953
+ return;
2954
+ if (it.props !== true && schemaCxt.props !== void 0) {
2955
+ it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
2956
+ }
2957
+ if (it.items !== true && schemaCxt.items !== void 0) {
2958
+ it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
2959
+ }
2902
2960
  }
2903
- if (it.items !== true && schemaCxt.items !== void 0) {
2904
- it.items = util_1$p.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
2961
+ mergeValidEvaluated(schemaCxt, valid) {
2962
+ const { it, gen } = this;
2963
+ if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
2964
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
2965
+ return true;
2966
+ }
2905
2967
  }
2906
2968
  }
2907
- mergeValidEvaluated(schemaCxt, valid) {
2908
- const { it, gen } = this;
2909
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
2910
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$r.Name));
2911
- return true;
2969
+ validate.KeywordCxt = KeywordCxt;
2970
+ function keywordCode(it, keyword2, def2, ruleType) {
2971
+ const cxt = new KeywordCxt(it, def2, keyword2);
2972
+ if ("code" in def2) {
2973
+ def2.code(cxt, ruleType);
2974
+ } else if (cxt.$data && def2.validate) {
2975
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
2976
+ } else if ("macro" in def2) {
2977
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
2978
+ } else if (def2.compile || def2.validate) {
2979
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
2980
+ }
2981
+ }
2982
+ const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
2983
+ const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
2984
+ function getData($data, { dataLevel, dataNames, dataPathArr }) {
2985
+ let jsonPointer;
2986
+ let data;
2987
+ if ($data === "")
2988
+ return names_12.default.rootData;
2989
+ if ($data[0] === "/") {
2990
+ if (!JSON_POINTER.test($data))
2991
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
2992
+ jsonPointer = $data;
2993
+ data = names_12.default.rootData;
2994
+ } else {
2995
+ const matches = RELATIVE_JSON_POINTER.exec($data);
2996
+ if (!matches)
2997
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
2998
+ const up = +matches[1];
2999
+ jsonPointer = matches[2];
3000
+ if (jsonPointer === "#") {
3001
+ if (up >= dataLevel)
3002
+ throw new Error(errorMsg("property/index", up));
3003
+ return dataPathArr[dataLevel - up];
3004
+ }
3005
+ if (up > dataLevel)
3006
+ throw new Error(errorMsg("data", up));
3007
+ data = dataNames[dataLevel - up];
3008
+ if (!jsonPointer)
3009
+ return data;
3010
+ }
3011
+ let expr = data;
3012
+ const segments = jsonPointer.split("/");
3013
+ for (const segment of segments) {
3014
+ if (segment) {
3015
+ data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
3016
+ expr = (0, codegen_12._)`${expr} && ${data}`;
3017
+ }
3018
+ }
3019
+ return expr;
3020
+ function errorMsg(pointerType, up) {
3021
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
2912
3022
  }
2913
3023
  }
3024
+ validate.getData = getData;
3025
+ return validate;
2914
3026
  }
2915
- validate.KeywordCxt = KeywordCxt;
2916
- function keywordCode(it, keyword2, def2, ruleType) {
2917
- const cxt = new KeywordCxt(it, def2, keyword2);
2918
- if ("code" in def2) {
2919
- def2.code(cxt, ruleType);
2920
- } else if (cxt.$data && def2.validate) {
2921
- (0, keyword_1.funcKeywordCode)(cxt, def2);
2922
- } else if ("macro" in def2) {
2923
- (0, keyword_1.macroKeywordCode)(cxt, def2);
2924
- } else if (def2.compile || def2.validate) {
2925
- (0, keyword_1.funcKeywordCode)(cxt, def2);
2926
- }
2927
- }
2928
- const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
2929
- const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
2930
- function getData($data, { dataLevel, dataNames, dataPathArr }) {
2931
- let jsonPointer;
2932
- let data;
2933
- if ($data === "")
2934
- return names_1$6.default.rootData;
2935
- if ($data[0] === "/") {
2936
- if (!JSON_POINTER.test($data))
2937
- throw new Error(`Invalid JSON-pointer: ${$data}`);
2938
- jsonPointer = $data;
2939
- data = names_1$6.default.rootData;
2940
- } else {
2941
- const matches = RELATIVE_JSON_POINTER.exec($data);
2942
- if (!matches)
2943
- throw new Error(`Invalid JSON-pointer: ${$data}`);
2944
- const up = +matches[1];
2945
- jsonPointer = matches[2];
2946
- if (jsonPointer === "#") {
2947
- if (up >= dataLevel)
2948
- throw new Error(errorMsg("property/index", up));
2949
- return dataPathArr[dataLevel - up];
2950
- }
2951
- if (up > dataLevel)
2952
- throw new Error(errorMsg("data", up));
2953
- data = dataNames[dataLevel - up];
2954
- if (!jsonPointer)
2955
- return data;
2956
- }
2957
- let expr = data;
2958
- const segments = jsonPointer.split("/");
2959
- for (const segment of segments) {
2960
- if (segment) {
2961
- data = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)((0, util_1$p.unescapeJsonPointer)(segment))}`;
2962
- expr = (0, codegen_1$r._)`${expr} && ${data}`;
2963
- }
2964
- }
2965
- return expr;
2966
- function errorMsg(pointerType, up) {
2967
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
2968
- }
2969
- }
2970
- validate.getData = getData;
2971
3027
  var validation_error = {};
2972
3028
  Object.defineProperty(validation_error, "__esModule", { value: true });
2973
3029
  class ValidationError extends Error {
@@ -2994,10 +3050,10 @@ Object.defineProperty(compile, "__esModule", { value: true });
2994
3050
  compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
2995
3051
  const codegen_1$q = codegen;
2996
3052
  const validation_error_1 = validation_error;
2997
- const names_1$5 = names$1;
3053
+ const names_1$5 = requireNames();
2998
3054
  const resolve_1 = resolve$2;
2999
3055
  const util_1$o = util;
3000
- const validate_1$1 = validate;
3056
+ const validate_1$1 = requireValidate();
3001
3057
  class SchemaEnv {
3002
3058
  constructor(env) {
3003
3059
  var _a;
@@ -3948,7 +4004,7 @@ uri$1.default = uri;
3948
4004
  (function(exports) {
3949
4005
  Object.defineProperty(exports, "__esModule", { value: true });
3950
4006
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
3951
- var validate_12 = validate;
4007
+ var validate_12 = requireValidate();
3952
4008
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
3953
4009
  return validate_12.KeywordCxt;
3954
4010
  } });
@@ -4566,9 +4622,9 @@ var ref = {};
4566
4622
  Object.defineProperty(ref, "__esModule", { value: true });
4567
4623
  ref.callRef = ref.getValidate = void 0;
4568
4624
  const ref_error_1$1 = ref_error;
4569
- const code_1$8 = code;
4625
+ const code_1$8 = requireCode();
4570
4626
  const codegen_1$p = codegen;
4571
- const names_1$4 = names$1;
4627
+ const names_1$4 = requireNames();
4572
4628
  const compile_1$2 = compile;
4573
4629
  const util_1$n = util;
4574
4630
  const def$A = {
@@ -4789,7 +4845,7 @@ const def$x = {
4789
4845
  limitLength.default = def$x;
4790
4846
  var pattern = {};
4791
4847
  Object.defineProperty(pattern, "__esModule", { value: true });
4792
- const code_1$7 = code;
4848
+ const code_1$7 = requireCode();
4793
4849
  const codegen_1$l = codegen;
4794
4850
  const error$h = {
4795
4851
  message: ({ schemaCode }) => (0, codegen_1$l.str)`must match pattern "${schemaCode}"`,
@@ -4834,7 +4890,7 @@ const def$v = {
4834
4890
  limitProperties.default = def$v;
4835
4891
  var required = {};
4836
4892
  Object.defineProperty(required, "__esModule", { value: true });
4837
- const code_1$6 = code;
4893
+ const code_1$6 = requireCode();
4838
4894
  const codegen_1$j = codegen;
4839
4895
  const util_1$l = util;
4840
4896
  const error$f = {
@@ -5148,7 +5204,7 @@ Object.defineProperty(items, "__esModule", { value: true });
5148
5204
  items.validateTuple = void 0;
5149
5205
  const codegen_1$d = codegen;
5150
5206
  const util_1$g = util;
5151
- const code_1$5 = code;
5207
+ const code_1$5 = requireCode();
5152
5208
  const def$o = {
5153
5209
  keyword: "items",
5154
5210
  type: "array",
@@ -5208,7 +5264,7 @@ var items2020 = {};
5208
5264
  Object.defineProperty(items2020, "__esModule", { value: true });
5209
5265
  const codegen_1$c = codegen;
5210
5266
  const util_1$f = util;
5211
- const code_1$4 = code;
5267
+ const code_1$4 = requireCode();
5212
5268
  const additionalItems_1$1 = additionalItems;
5213
5269
  const error$9 = {
5214
5270
  message: ({ params: { len } }) => (0, codegen_1$c.str)`must NOT have more than ${len} items`,
@@ -5327,7 +5383,7 @@ var dependencies = {};
5327
5383
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
5328
5384
  const codegen_12 = codegen;
5329
5385
  const util_12 = util;
5330
- const code_12 = code;
5386
+ const code_12 = requireCode();
5331
5387
  exports.error = {
5332
5388
  message: ({ params: { property, depsCount, deps } }) => {
5333
5389
  const property_ies = depsCount === 1 ? "property" : "properties";
@@ -5450,9 +5506,9 @@ const def$k = {
5450
5506
  propertyNames.default = def$k;
5451
5507
  var additionalProperties = {};
5452
5508
  Object.defineProperty(additionalProperties, "__esModule", { value: true });
5453
- const code_1$3 = code;
5509
+ const code_1$3 = requireCode();
5454
5510
  const codegen_1$9 = codegen;
5455
- const names_1$3 = names$1;
5511
+ const names_1$3 = requireNames();
5456
5512
  const util_1$c = util;
5457
5513
  const error$6 = {
5458
5514
  message: "must NOT have additional properties",
@@ -5550,8 +5606,8 @@ const def$j = {
5550
5606
  additionalProperties.default = def$j;
5551
5607
  var properties$8 = {};
5552
5608
  Object.defineProperty(properties$8, "__esModule", { value: true });
5553
- const validate_1 = validate;
5554
- const code_1$2 = code;
5609
+ const validate_1 = requireValidate();
5610
+ const code_1$2 = requireCode();
5555
5611
  const util_1$b = util;
5556
5612
  const additionalProperties_1$1 = additionalProperties;
5557
5613
  const def$i = {
@@ -5602,7 +5658,7 @@ const def$i = {
5602
5658
  properties$8.default = def$i;
5603
5659
  var patternProperties = {};
5604
5660
  Object.defineProperty(patternProperties, "__esModule", { value: true });
5605
- const code_1$1 = code;
5661
+ const code_1$1 = requireCode();
5606
5662
  const codegen_1$8 = codegen;
5607
5663
  const util_1$a = util;
5608
5664
  const util_2 = util;
@@ -5695,7 +5751,7 @@ const def$g = {
5695
5751
  not.default = def$g;
5696
5752
  var anyOf = {};
5697
5753
  Object.defineProperty(anyOf, "__esModule", { value: true });
5698
- const code_1 = code;
5754
+ const code_1 = requireCode();
5699
5755
  const def$f = {
5700
5756
  keyword: "anyOf",
5701
5757
  schemaType: "array",
@@ -5898,7 +5954,7 @@ var dynamicAnchor$1 = {};
5898
5954
  Object.defineProperty(dynamicAnchor$1, "__esModule", { value: true });
5899
5955
  dynamicAnchor$1.dynamicAnchor = void 0;
5900
5956
  const codegen_1$5 = codegen;
5901
- const names_1$2 = names$1;
5957
+ const names_1$2 = requireNames();
5902
5958
  const compile_1$1 = compile;
5903
5959
  const ref_1$1 = ref;
5904
5960
  const def$a = {
@@ -5927,7 +5983,7 @@ var dynamicRef$1 = {};
5927
5983
  Object.defineProperty(dynamicRef$1, "__esModule", { value: true });
5928
5984
  dynamicRef$1.dynamicRef = void 0;
5929
5985
  const codegen_1$4 = codegen;
5930
- const names_1$1 = names$1;
5986
+ const names_1$1 = requireNames();
5931
5987
  const ref_1 = ref;
5932
5988
  const def$9 = {
5933
5989
  keyword: "$dynamicRef",
@@ -6041,7 +6097,7 @@ var unevaluatedProperties = {};
6041
6097
  Object.defineProperty(unevaluatedProperties, "__esModule", { value: true });
6042
6098
  const codegen_1$3 = codegen;
6043
6099
  const util_1$2 = util;
6044
- const names_1 = names$1;
6100
+ const names_1 = requireNames();
6045
6101
  const error$3 = {
6046
6102
  message: "must NOT have unevaluated properties",
6047
6103
  params: ({ params }) => (0, codegen_1$3._)`{unevaluatedProperty: ${params.unevaluatedProperty}}`
@@ -6957,7 +7013,7 @@ jsonSchema202012.default = addMetaSchema2020;
6957
7013
  module.exports.Ajv2020 = Ajv20202;
6958
7014
  Object.defineProperty(exports, "__esModule", { value: true });
6959
7015
  exports.default = Ajv20202;
6960
- var validate_12 = validate;
7016
+ var validate_12 = requireValidate();
6961
7017
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
6962
7018
  return validate_12.KeywordCxt;
6963
7019
  } });