@thatopen/services 0.25.0 → 0.26.1

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/cli.js CHANGED
@@ -25972,8 +25972,8 @@ var scope = {};
25972
25972
  var util = {};
25973
25973
  Object.defineProperty(util, "__esModule", { value: true });
25974
25974
  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;
25975
- const codegen_1$v = codegen;
25976
- const code_1$a = code$1;
25975
+ const codegen_1$q = codegen;
25976
+ const code_1$9 = code$1;
25977
25977
  function toHash(arr) {
25978
25978
  const hash = {};
25979
25979
  for (const item of arr)
@@ -26026,9 +26026,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
26026
26026
  if (typeof schema == "number" || typeof schema == "boolean")
26027
26027
  return schema;
26028
26028
  if (typeof schema == "string")
26029
- return (0, codegen_1$v._)`${schema}`;
26029
+ return (0, codegen_1$q._)`${schema}`;
26030
26030
  }
26031
- return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
26031
+ return (0, codegen_1$q._)`${topSchemaRef}${schemaPath}${(0, codegen_1$q.getProperty)(keyword2)}`;
26032
26032
  }
26033
26033
  util.schemaRefOrVal = schemaRefOrVal;
26034
26034
  function unescapeFragment(str) {
@@ -26060,20 +26060,20 @@ function eachItem(xs, f) {
26060
26060
  util.eachItem = eachItem;
26061
26061
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
26062
26062
  return (gen, from, to, toName) => {
26063
- const res = to === void 0 ? from : to instanceof codegen_1$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
26064
- return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
26063
+ const res = to === void 0 ? from : to instanceof codegen_1$q.Name ? (from instanceof codegen_1$q.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$q.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
26064
+ return toName === codegen_1$q.Name && !(res instanceof codegen_1$q.Name) ? resultToName(gen, res) : res;
26065
26065
  };
26066
26066
  }
26067
26067
  util.mergeEvaluated = {
26068
26068
  props: makeMergeEvaluated({
26069
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
26070
- gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`Object.assign(${to}, ${from})`));
26069
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => {
26070
+ gen.if((0, codegen_1$q._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$q._)`${to} || {}`).code((0, codegen_1$q._)`Object.assign(${to}, ${from})`));
26071
26071
  }),
26072
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
26072
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => {
26073
26073
  if (from === true) {
26074
26074
  gen.assign(to, true);
26075
26075
  } else {
26076
- gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
26076
+ gen.assign(to, (0, codegen_1$q._)`${to} || {}`);
26077
26077
  setEvaluated(gen, to, from);
26078
26078
  }
26079
26079
  }),
@@ -26081,8 +26081,8 @@ util.mergeEvaluated = {
26081
26081
  resultToName: evaluatedPropsToName
26082
26082
  }),
26083
26083
  items: makeMergeEvaluated({
26084
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
26085
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${to} > ${from} ? ${to} : ${from}`)),
26084
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$q._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
26085
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$q._)`${to} > ${from} ? ${to} : ${from}`)),
26086
26086
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
26087
26087
  resultToName: (gen, items2) => gen.var("items", items2)
26088
26088
  })
@@ -26090,21 +26090,21 @@ util.mergeEvaluated = {
26090
26090
  function evaluatedPropsToName(gen, ps) {
26091
26091
  if (ps === true)
26092
26092
  return gen.var("props", true);
26093
- const props = gen.var("props", (0, codegen_1$v._)`{}`);
26093
+ const props = gen.var("props", (0, codegen_1$q._)`{}`);
26094
26094
  if (ps !== void 0)
26095
26095
  setEvaluated(gen, props, ps);
26096
26096
  return props;
26097
26097
  }
26098
26098
  util.evaluatedPropsToName = evaluatedPropsToName;
26099
26099
  function setEvaluated(gen, props, ps) {
26100
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
26100
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$q._)`${props}${(0, codegen_1$q.getProperty)(p)}`, true));
26101
26101
  }
26102
26102
  util.setEvaluated = setEvaluated;
26103
26103
  const snippets = {};
26104
26104
  function useFunc(gen, f) {
26105
26105
  return gen.scopeValue("func", {
26106
26106
  ref: f,
26107
- code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
26107
+ code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
26108
26108
  });
26109
26109
  }
26110
26110
  util.useFunc = useFunc;
@@ -26114,11 +26114,11 @@ var Type;
26114
26114
  Type2[Type2["Str"] = 1] = "Str";
26115
26115
  })(Type || (util.Type = Type = {}));
26116
26116
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
26117
- if (dataProp instanceof codegen_1$v.Name) {
26117
+ if (dataProp instanceof codegen_1$q.Name) {
26118
26118
  const isNumber = dataPropType === Type.Num;
26119
- return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
26119
+ return jsPropertySyntax ? isNumber ? (0, codegen_1$q._)`"[" + ${dataProp} + "]"` : (0, codegen_1$q._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$q._)`"/" + ${dataProp}` : (0, codegen_1$q._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
26120
26120
  }
26121
- return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
26121
+ return jsPropertySyntax ? (0, codegen_1$q.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
26122
26122
  }
26123
26123
  util.getErrorPath = getErrorPath;
26124
26124
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -26132,35 +26132,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
26132
26132
  util.checkStrictMode = checkStrictMode;
26133
26133
  var names$1 = {};
26134
26134
  Object.defineProperty(names$1, "__esModule", { value: true });
26135
- const codegen_1$u = codegen;
26135
+ const codegen_1$p = codegen;
26136
26136
  const names = {
26137
26137
  // validation function arguments
26138
- data: new codegen_1$u.Name("data"),
26138
+ data: new codegen_1$p.Name("data"),
26139
26139
  // data passed to validation function
26140
26140
  // args passed from referencing schema
26141
- valCxt: new codegen_1$u.Name("valCxt"),
26141
+ valCxt: new codegen_1$p.Name("valCxt"),
26142
26142
  // validation/data context - should not be used directly, it is destructured to the names below
26143
- instancePath: new codegen_1$u.Name("instancePath"),
26144
- parentData: new codegen_1$u.Name("parentData"),
26145
- parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
26146
- rootData: new codegen_1$u.Name("rootData"),
26143
+ instancePath: new codegen_1$p.Name("instancePath"),
26144
+ parentData: new codegen_1$p.Name("parentData"),
26145
+ parentDataProperty: new codegen_1$p.Name("parentDataProperty"),
26146
+ rootData: new codegen_1$p.Name("rootData"),
26147
26147
  // root data - same as the data passed to the first/top validation function
26148
- dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
26148
+ dynamicAnchors: new codegen_1$p.Name("dynamicAnchors"),
26149
26149
  // used to support recursiveRef and dynamicRef
26150
26150
  // function scoped variables
26151
- vErrors: new codegen_1$u.Name("vErrors"),
26151
+ vErrors: new codegen_1$p.Name("vErrors"),
26152
26152
  // null or array of validation errors
26153
- errors: new codegen_1$u.Name("errors"),
26153
+ errors: new codegen_1$p.Name("errors"),
26154
26154
  // counter of validation errors
26155
- this: new codegen_1$u.Name("this"),
26155
+ this: new codegen_1$p.Name("this"),
26156
26156
  // "globals"
26157
- self: new codegen_1$u.Name("self"),
26158
- scope: new codegen_1$u.Name("scope"),
26157
+ self: new codegen_1$p.Name("self"),
26158
+ scope: new codegen_1$p.Name("scope"),
26159
26159
  // JTD serialize/parse name for JSON string and position
26160
- json: new codegen_1$u.Name("json"),
26161
- jsonPos: new codegen_1$u.Name("jsonPos"),
26162
- jsonLen: new codegen_1$u.Name("jsonLen"),
26163
- jsonPart: new codegen_1$u.Name("jsonPart")
26160
+ json: new codegen_1$p.Name("json"),
26161
+ jsonPos: new codegen_1$p.Name("jsonPos"),
26162
+ jsonLen: new codegen_1$p.Name("jsonLen"),
26163
+ jsonPart: new codegen_1$p.Name("jsonPart")
26164
26164
  };
26165
26165
  names$1.default = names;
26166
26166
  (function(exports) {
@@ -26280,49 +26280,55 @@ names$1.default = names;
26280
26280
  keyValues.push([E.propertyName, propertyName]);
26281
26281
  }
26282
26282
  })(errors);
26283
- Object.defineProperty(boolSchema, "__esModule", { value: true });
26284
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
26285
- const errors_1$3 = errors;
26286
- const codegen_1$t = codegen;
26287
- const names_1$6 = names$1;
26288
- const boolError = {
26289
- message: "boolean schema is false"
26290
- };
26291
- function topBoolOrEmptySchema(it) {
26292
- const { gen, schema, validateName } = it;
26293
- if (schema === false) {
26294
- falseSchemaError(it, false);
26295
- } else if (typeof schema == "object" && schema.$async === true) {
26296
- gen.return(names_1$6.default.data);
26297
- } else {
26298
- gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
26299
- gen.return(true);
26283
+ var hasRequiredBoolSchema;
26284
+ function requireBoolSchema() {
26285
+ if (hasRequiredBoolSchema) return boolSchema;
26286
+ hasRequiredBoolSchema = 1;
26287
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
26288
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
26289
+ const errors_12 = errors;
26290
+ const codegen_12 = codegen;
26291
+ const names_12 = names$1;
26292
+ const boolError = {
26293
+ message: "boolean schema is false"
26294
+ };
26295
+ function topBoolOrEmptySchema(it) {
26296
+ const { gen, schema, validateName } = it;
26297
+ if (schema === false) {
26298
+ falseSchemaError(it, false);
26299
+ } else if (typeof schema == "object" && schema.$async === true) {
26300
+ gen.return(names_12.default.data);
26301
+ } else {
26302
+ gen.assign((0, codegen_12._)`${validateName}.errors`, null);
26303
+ gen.return(true);
26304
+ }
26300
26305
  }
26301
- }
26302
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
26303
- function boolOrEmptySchema(it, valid) {
26304
- const { gen, schema } = it;
26305
- if (schema === false) {
26306
- gen.var(valid, false);
26307
- falseSchemaError(it);
26308
- } else {
26309
- gen.var(valid, true);
26306
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
26307
+ function boolOrEmptySchema(it, valid) {
26308
+ const { gen, schema } = it;
26309
+ if (schema === false) {
26310
+ gen.var(valid, false);
26311
+ falseSchemaError(it);
26312
+ } else {
26313
+ gen.var(valid, true);
26314
+ }
26310
26315
  }
26311
- }
26312
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
26313
- function falseSchemaError(it, overrideAllErrors) {
26314
- const { gen, data } = it;
26315
- const cxt = {
26316
- gen,
26317
- keyword: "false schema",
26318
- data,
26319
- schema: false,
26320
- schemaCode: false,
26321
- schemaValue: false,
26322
- params: {},
26323
- it
26324
- };
26325
- (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
26316
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
26317
+ function falseSchemaError(it, overrideAllErrors) {
26318
+ const { gen, data } = it;
26319
+ const cxt = {
26320
+ gen,
26321
+ keyword: "false schema",
26322
+ data,
26323
+ schema: false,
26324
+ schemaCode: false,
26325
+ schemaValue: false,
26326
+ params: {},
26327
+ it
26328
+ };
26329
+ (0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
26330
+ }
26331
+ return boolSchema;
26326
26332
  }
26327
26333
  var dataType = {};
26328
26334
  var rules = {};
@@ -26370,10 +26376,10 @@ applicability.shouldUseRule = shouldUseRule;
26370
26376
  Object.defineProperty(dataType, "__esModule", { value: true });
26371
26377
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
26372
26378
  const rules_1 = rules;
26373
- const applicability_1$1 = applicability;
26374
- const errors_1$2 = errors;
26375
- const codegen_1$s = codegen;
26376
- const util_1$r = util;
26379
+ const applicability_1 = applicability;
26380
+ const errors_1 = errors;
26381
+ const codegen_1$o = codegen;
26382
+ const util_1$o = util;
26377
26383
  var DataType;
26378
26384
  (function(DataType2) {
26379
26385
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -26405,7 +26411,7 @@ dataType.getJSONTypes = getJSONTypes;
26405
26411
  function coerceAndCheckDataType(it, types2) {
26406
26412
  const { gen, data, opts } = it;
26407
26413
  const coerceTo = coerceToTypes(types2, opts.coerceTypes);
26408
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
26414
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
26409
26415
  if (checkTypes) {
26410
26416
  const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
26411
26417
  gen.if(wrongType, () => {
@@ -26424,12 +26430,12 @@ function coerceToTypes(types2, coerceTypes) {
26424
26430
  }
26425
26431
  function coerceData(it, types2, coerceTo) {
26426
26432
  const { gen, data, opts } = it;
26427
- const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
26428
- const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
26433
+ const dataType2 = gen.let("dataType", (0, codegen_1$o._)`typeof ${data}`);
26434
+ const coerced = gen.let("coerced", (0, codegen_1$o._)`undefined`);
26429
26435
  if (opts.coerceTypes === "array") {
26430
- gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$s._)`${data}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
26436
+ gen.if((0, codegen_1$o._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$o._)`${data}[0]`).assign(dataType2, (0, codegen_1$o._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
26431
26437
  }
26432
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
26438
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
26433
26439
  for (const t of coerceTo) {
26434
26440
  if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
26435
26441
  coerceSpecificType(t);
@@ -26438,63 +26444,63 @@ function coerceData(it, types2, coerceTo) {
26438
26444
  gen.else();
26439
26445
  reportTypeError(it);
26440
26446
  gen.endIf();
26441
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
26447
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
26442
26448
  gen.assign(data, coerced);
26443
26449
  assignParentData(it, coerced);
26444
26450
  });
26445
26451
  function coerceSpecificType(t) {
26446
26452
  switch (t) {
26447
26453
  case "string":
26448
- gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data}`).elseIf((0, codegen_1$s._)`${data} === null`).assign(coerced, (0, codegen_1$s._)`""`);
26454
+ gen.elseIf((0, codegen_1$o._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$o._)`"" + ${data}`).elseIf((0, codegen_1$o._)`${data} === null`).assign(coerced, (0, codegen_1$o._)`""`);
26449
26455
  return;
26450
26456
  case "number":
26451
- gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
26452
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
26457
+ gen.elseIf((0, codegen_1$o._)`${dataType2} == "boolean" || ${data} === null
26458
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$o._)`+${data}`);
26453
26459
  return;
26454
26460
  case "integer":
26455
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
26456
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
26461
+ gen.elseIf((0, codegen_1$o._)`${dataType2} === "boolean" || ${data} === null
26462
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$o._)`+${data}`);
26457
26463
  return;
26458
26464
  case "boolean":
26459
- gen.elseIf((0, codegen_1$s._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
26465
+ gen.elseIf((0, codegen_1$o._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$o._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
26460
26466
  return;
26461
26467
  case "null":
26462
- gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
26468
+ gen.elseIf((0, codegen_1$o._)`${data} === "" || ${data} === 0 || ${data} === false`);
26463
26469
  gen.assign(coerced, null);
26464
26470
  return;
26465
26471
  case "array":
26466
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
26467
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
26472
+ gen.elseIf((0, codegen_1$o._)`${dataType2} === "string" || ${dataType2} === "number"
26473
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$o._)`[${data}]`);
26468
26474
  }
26469
26475
  }
26470
26476
  }
26471
26477
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
26472
- gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
26478
+ gen.if((0, codegen_1$o._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$o._)`${parentData}[${parentDataProperty}]`, expr));
26473
26479
  }
26474
26480
  function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
26475
- const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
26481
+ const EQ = correct === DataType.Correct ? codegen_1$o.operators.EQ : codegen_1$o.operators.NEQ;
26476
26482
  let cond;
26477
26483
  switch (dataType2) {
26478
26484
  case "null":
26479
- return (0, codegen_1$s._)`${data} ${EQ} null`;
26485
+ return (0, codegen_1$o._)`${data} ${EQ} null`;
26480
26486
  case "array":
26481
- cond = (0, codegen_1$s._)`Array.isArray(${data})`;
26487
+ cond = (0, codegen_1$o._)`Array.isArray(${data})`;
26482
26488
  break;
26483
26489
  case "object":
26484
- cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
26490
+ cond = (0, codegen_1$o._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
26485
26491
  break;
26486
26492
  case "integer":
26487
- cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
26493
+ cond = numCond((0, codegen_1$o._)`!(${data} % 1) && !isNaN(${data})`);
26488
26494
  break;
26489
26495
  case "number":
26490
26496
  cond = numCond();
26491
26497
  break;
26492
26498
  default:
26493
- return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
26499
+ return (0, codegen_1$o._)`typeof ${data} ${EQ} ${dataType2}`;
26494
26500
  }
26495
- return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
26496
- function numCond(_cond = codegen_1$s.nil) {
26497
- return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data})` : codegen_1$s.nil);
26501
+ return correct === DataType.Correct ? cond : (0, codegen_1$o.not)(cond);
26502
+ function numCond(_cond = codegen_1$o.nil) {
26503
+ return (0, codegen_1$o.and)((0, codegen_1$o._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$o._)`isFinite(${data})` : codegen_1$o.nil);
26498
26504
  }
26499
26505
  }
26500
26506
  dataType.checkDataType = checkDataType;
@@ -26503,35 +26509,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
26503
26509
  return checkDataType(dataTypes[0], data, strictNums, correct);
26504
26510
  }
26505
26511
  let cond;
26506
- const types2 = (0, util_1$r.toHash)(dataTypes);
26512
+ const types2 = (0, util_1$o.toHash)(dataTypes);
26507
26513
  if (types2.array && types2.object) {
26508
- const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
26509
- cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
26514
+ const notObj = (0, codegen_1$o._)`typeof ${data} != "object"`;
26515
+ cond = types2.null ? notObj : (0, codegen_1$o._)`!${data} || ${notObj}`;
26510
26516
  delete types2.null;
26511
26517
  delete types2.array;
26512
26518
  delete types2.object;
26513
26519
  } else {
26514
- cond = codegen_1$s.nil;
26520
+ cond = codegen_1$o.nil;
26515
26521
  }
26516
26522
  if (types2.number)
26517
26523
  delete types2.integer;
26518
26524
  for (const t in types2)
26519
- cond = (0, codegen_1$s.and)(cond, checkDataType(t, data, strictNums, correct));
26525
+ cond = (0, codegen_1$o.and)(cond, checkDataType(t, data, strictNums, correct));
26520
26526
  return cond;
26521
26527
  }
26522
26528
  dataType.checkDataTypes = checkDataTypes;
26523
26529
  const typeError = {
26524
26530
  message: ({ schema }) => `must be ${schema}`,
26525
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
26531
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$o._)`{type: ${schema}}` : (0, codegen_1$o._)`{type: ${schemaValue}}`
26526
26532
  };
26527
26533
  function reportTypeError(it) {
26528
26534
  const cxt = getTypeErrorContext(it);
26529
- (0, errors_1$2.reportError)(cxt, typeError);
26535
+ (0, errors_1.reportError)(cxt, typeError);
26530
26536
  }
26531
26537
  dataType.reportTypeError = reportTypeError;
26532
26538
  function getTypeErrorContext(it) {
26533
26539
  const { gen, data, schema } = it;
26534
- const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
26540
+ const schemaCode = (0, util_1$o.schemaRefOrVal)(it, schema, "type");
26535
26541
  return {
26536
26542
  gen,
26537
26543
  keyword: "type",
@@ -26545,54 +26551,60 @@ function getTypeErrorContext(it) {
26545
26551
  };
26546
26552
  }
26547
26553
  var defaults = {};
26548
- Object.defineProperty(defaults, "__esModule", { value: true });
26549
- defaults.assignDefaults = void 0;
26550
- const codegen_1$r = codegen;
26551
- const util_1$q = util;
26552
- function assignDefaults(it, ty) {
26553
- const { properties: properties2, items: items2 } = it.schema;
26554
- if (ty === "object" && properties2) {
26555
- for (const key in properties2) {
26556
- assignDefault(it, key, properties2[key].default);
26557
- }
26558
- } else if (ty === "array" && Array.isArray(items2)) {
26559
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
26560
- }
26561
- }
26562
- defaults.assignDefaults = assignDefaults;
26563
- function assignDefault(it, prop, defaultValue) {
26564
- const { gen, compositeRule, data, opts } = it;
26565
- if (defaultValue === void 0)
26566
- return;
26567
- const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
26568
- if (compositeRule) {
26569
- (0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
26570
- return;
26554
+ var hasRequiredDefaults;
26555
+ function requireDefaults() {
26556
+ if (hasRequiredDefaults) return defaults;
26557
+ hasRequiredDefaults = 1;
26558
+ Object.defineProperty(defaults, "__esModule", { value: true });
26559
+ defaults.assignDefaults = void 0;
26560
+ const codegen_12 = codegen;
26561
+ const util_12 = util;
26562
+ function assignDefaults(it, ty) {
26563
+ const { properties: properties2, items: items2 } = it.schema;
26564
+ if (ty === "object" && properties2) {
26565
+ for (const key in properties2) {
26566
+ assignDefault(it, key, properties2[key].default);
26567
+ }
26568
+ } else if (ty === "array" && Array.isArray(items2)) {
26569
+ items2.forEach((sch, i) => assignDefault(it, i, sch.default));
26570
+ }
26571
26571
  }
26572
- let condition = (0, codegen_1$r._)`${childData} === undefined`;
26573
- if (opts.useDefaults === "empty") {
26574
- condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
26572
+ defaults.assignDefaults = assignDefaults;
26573
+ function assignDefault(it, prop, defaultValue) {
26574
+ const { gen, compositeRule, data, opts } = it;
26575
+ if (defaultValue === void 0)
26576
+ return;
26577
+ const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
26578
+ if (compositeRule) {
26579
+ (0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
26580
+ return;
26581
+ }
26582
+ let condition = (0, codegen_12._)`${childData} === undefined`;
26583
+ if (opts.useDefaults === "empty") {
26584
+ condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
26585
+ }
26586
+ gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
26575
26587
  }
26576
- gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
26588
+ return defaults;
26577
26589
  }
26578
26590
  var keyword = {};
26579
26591
  var code = {};
26580
26592
  Object.defineProperty(code, "__esModule", { value: true });
26581
26593
  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;
26582
- const codegen_1$q = codegen;
26583
- const util_1$p = util;
26584
- const names_1$5 = names$1;
26594
+ const codegen_1$n = codegen;
26595
+ const util_1$n = util;
26596
+ const names_1$3 = names$1;
26585
26597
  const util_2$1 = util;
26586
26598
  function checkReportMissingProp(cxt, prop) {
26587
26599
  const { gen, data, it } = cxt;
26588
26600
  gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
26589
- cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
26601
+ cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
26590
26602
  cxt.error();
26591
26603
  });
26592
26604
  }
26593
26605
  code.checkReportMissingProp = checkReportMissingProp;
26594
26606
  function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
26595
- return (0, codegen_1$q.or)(...properties2.map((prop) => (0, codegen_1$q.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$q._)`${missing} = ${prop}`)));
26607
+ return (0, codegen_1$n.or)(...properties2.map((prop) => (0, codegen_1$n.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$n._)`${missing} = ${prop}`)));
26596
26608
  }
26597
26609
  code.checkMissingProp = checkMissingProp;
26598
26610
  function reportMissingProp(cxt, missing) {
@@ -26604,22 +26616,22 @@ function hasPropFunc(gen) {
26604
26616
  return gen.scopeValue("func", {
26605
26617
  // eslint-disable-next-line @typescript-eslint/unbound-method
26606
26618
  ref: Object.prototype.hasOwnProperty,
26607
- code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
26619
+ code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
26608
26620
  });
26609
26621
  }
26610
26622
  code.hasPropFunc = hasPropFunc;
26611
26623
  function isOwnProperty(gen, data, property) {
26612
- return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
26624
+ return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
26613
26625
  }
26614
26626
  code.isOwnProperty = isOwnProperty;
26615
26627
  function propertyInData(gen, data, property, ownProperties) {
26616
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
26617
- return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
26628
+ const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} !== undefined`;
26629
+ return ownProperties ? (0, codegen_1$n._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
26618
26630
  }
26619
26631
  code.propertyInData = propertyInData;
26620
26632
  function noPropertyInData(gen, data, property, ownProperties) {
26621
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
26622
- return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond;
26633
+ const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} === undefined`;
26634
+ return ownProperties ? (0, codegen_1$n.or)(cond, (0, codegen_1$n.not)(isOwnProperty(gen, data, property))) : cond;
26623
26635
  }
26624
26636
  code.noPropertyInData = noPropertyInData;
26625
26637
  function allSchemaProperties(schemaMap) {
@@ -26627,24 +26639,24 @@ function allSchemaProperties(schemaMap) {
26627
26639
  }
26628
26640
  code.allSchemaProperties = allSchemaProperties;
26629
26641
  function schemaProperties(it, schemaMap) {
26630
- return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$p.alwaysValidSchema)(it, schemaMap[p]));
26642
+ return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$n.alwaysValidSchema)(it, schemaMap[p]));
26631
26643
  }
26632
26644
  code.schemaProperties = schemaProperties;
26633
26645
  function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
26634
- const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
26646
+ const dataAndSchema = passSchema ? (0, codegen_1$n._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
26635
26647
  const valCxt = [
26636
- [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
26637
- [names_1$5.default.parentData, it.parentData],
26638
- [names_1$5.default.parentDataProperty, it.parentDataProperty],
26639
- [names_1$5.default.rootData, names_1$5.default.rootData]
26648
+ [names_1$3.default.instancePath, (0, codegen_1$n.strConcat)(names_1$3.default.instancePath, errorPath)],
26649
+ [names_1$3.default.parentData, it.parentData],
26650
+ [names_1$3.default.parentDataProperty, it.parentDataProperty],
26651
+ [names_1$3.default.rootData, names_1$3.default.rootData]
26640
26652
  ];
26641
26653
  if (it.opts.dynamicRef)
26642
- valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
26643
- const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
26644
- return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
26654
+ valCxt.push([names_1$3.default.dynamicAnchors, names_1$3.default.dynamicAnchors]);
26655
+ const args = (0, codegen_1$n._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
26656
+ return context !== codegen_1$n.nil ? (0, codegen_1$n._)`${func}.call(${context}, ${args})` : (0, codegen_1$n._)`${func}(${args})`;
26645
26657
  }
26646
26658
  code.callValidateCode = callValidateCode;
26647
- const newRegExp = (0, codegen_1$q._)`new RegExp`;
26659
+ const newRegExp = (0, codegen_1$n._)`new RegExp`;
26648
26660
  function usePattern({ gen, it: { opts } }, pattern2) {
26649
26661
  const u = opts.unicodeRegExp ? "u" : "";
26650
26662
  const { regExp } = opts.code;
@@ -26652,7 +26664,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
26652
26664
  return gen.scopeValue("pattern", {
26653
26665
  key: rx.toString(),
26654
26666
  ref: rx,
26655
- code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
26667
+ code: (0, codegen_1$n._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
26656
26668
  });
26657
26669
  }
26658
26670
  code.usePattern = usePattern;
@@ -26668,14 +26680,14 @@ function validateArray(cxt) {
26668
26680
  validateItems(() => gen.break());
26669
26681
  return valid;
26670
26682
  function validateItems(notValid) {
26671
- const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
26683
+ const len = gen.const("len", (0, codegen_1$n._)`${data}.length`);
26672
26684
  gen.forRange("i", 0, len, (i) => {
26673
26685
  cxt.subschema({
26674
26686
  keyword: keyword2,
26675
26687
  dataProp: i,
26676
- dataPropType: util_1$p.Type.Num
26688
+ dataPropType: util_1$n.Type.Num
26677
26689
  }, valid);
26678
- gen.if((0, codegen_1$q.not)(valid), notValid);
26690
+ gen.if((0, codegen_1$n.not)(valid), notValid);
26679
26691
  });
26680
26692
  }
26681
26693
  }
@@ -26684,7 +26696,7 @@ function validateUnion(cxt) {
26684
26696
  const { gen, schema, keyword: keyword2, it } = cxt;
26685
26697
  if (!Array.isArray(schema))
26686
26698
  throw new Error("ajv implementation error");
26687
- const alwaysValid = schema.some((sch) => (0, util_1$p.alwaysValidSchema)(it, sch));
26699
+ const alwaysValid = schema.some((sch) => (0, util_1$n.alwaysValidSchema)(it, sch));
26688
26700
  if (alwaysValid && !it.opts.unevaluated)
26689
26701
  return;
26690
26702
  const valid = gen.let("valid", false);
@@ -26695,202 +26707,214 @@ function validateUnion(cxt) {
26695
26707
  schemaProp: i,
26696
26708
  compositeRule: true
26697
26709
  }, schValid);
26698
- gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
26710
+ gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
26699
26711
  const merged = cxt.mergeValidEvaluated(schCxt, schValid);
26700
26712
  if (!merged)
26701
- gen.if((0, codegen_1$q.not)(valid));
26713
+ gen.if((0, codegen_1$n.not)(valid));
26702
26714
  }));
26703
26715
  cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
26704
26716
  }
26705
26717
  code.validateUnion = validateUnion;
26706
- Object.defineProperty(keyword, "__esModule", { value: true });
26707
- keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
26708
- const codegen_1$p = codegen;
26709
- const names_1$4 = names$1;
26710
- const code_1$9 = code;
26711
- const errors_1$1 = errors;
26712
- function macroKeywordCode(cxt, def2) {
26713
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
26714
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
26715
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
26716
- if (it.opts.validateSchema !== false)
26717
- it.self.validateSchema(macroSchema, true);
26718
- const valid = gen.name("valid");
26719
- cxt.subschema({
26720
- schema: macroSchema,
26721
- schemaPath: codegen_1$p.nil,
26722
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
26723
- topSchemaRef: schemaRef,
26724
- compositeRule: true
26725
- }, valid);
26726
- cxt.pass(valid, () => cxt.error(true));
26727
- }
26728
- keyword.macroKeywordCode = macroKeywordCode;
26729
- function funcKeywordCode(cxt, def2) {
26730
- var _a;
26731
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
26732
- checkAsyncKeyword(it, def2);
26733
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
26734
- const validateRef = useKeyword(gen, keyword2, validate2);
26735
- const valid = gen.let("valid");
26736
- cxt.block$data(valid, validateKeyword);
26737
- cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
26738
- function validateKeyword() {
26739
- if (def2.errors === false) {
26740
- assignValid();
26741
- if (def2.modifying)
26742
- modifyData(cxt);
26743
- reportErrs(() => cxt.error());
26744
- } else {
26745
- const ruleErrs = def2.async ? validateAsync() : validateSync();
26746
- if (def2.modifying)
26747
- modifyData(cxt);
26748
- reportErrs(() => addErrs(cxt, ruleErrs));
26749
- }
26750
- }
26751
- function validateAsync() {
26752
- const ruleErrs = gen.let("ruleErrs", null);
26753
- gen.try(() => assignValid((0, codegen_1$p._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1$p._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$p._)`${e}.errors`), () => gen.throw(e)));
26754
- return ruleErrs;
26755
- }
26756
- function validateSync() {
26757
- const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
26758
- gen.assign(validateErrs, null);
26759
- assignValid(codegen_1$p.nil);
26760
- return validateErrs;
26761
- }
26762
- function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
26763
- const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
26764
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
26765
- gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
26766
- }
26767
- function reportErrs(errors2) {
26768
- var _a2;
26769
- gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
26770
- }
26771
- }
26772
- keyword.funcKeywordCode = funcKeywordCode;
26773
- function modifyData(cxt) {
26774
- const { gen, data, it } = cxt;
26775
- gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
26776
- }
26777
- function addErrs(cxt, errs) {
26778
- const { gen } = cxt;
26779
- gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
26780
- gen.assign(names_1$4.default.vErrors, (0, codegen_1$p._)`${names_1$4.default.vErrors} === null ? ${errs} : ${names_1$4.default.vErrors}.concat(${errs})`).assign(names_1$4.default.errors, (0, codegen_1$p._)`${names_1$4.default.vErrors}.length`);
26781
- (0, errors_1$1.extendErrors)(cxt);
26782
- }, () => cxt.error());
26783
- }
26784
- function checkAsyncKeyword({ schemaEnv }, def2) {
26785
- if (def2.async && !schemaEnv.$async)
26786
- throw new Error("async keyword in sync schema");
26787
- }
26788
- function useKeyword(gen, keyword2, result) {
26789
- if (result === void 0)
26790
- throw new Error(`keyword "${keyword2}" failed to compile`);
26791
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
26792
- }
26793
- function validSchemaType(schema, schemaType, allowUndefined = false) {
26794
- 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");
26795
- }
26796
- keyword.validSchemaType = validSchemaType;
26797
- function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
26798
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
26799
- throw new Error("ajv implementation error");
26718
+ var hasRequiredKeyword;
26719
+ function requireKeyword() {
26720
+ if (hasRequiredKeyword) return keyword;
26721
+ hasRequiredKeyword = 1;
26722
+ Object.defineProperty(keyword, "__esModule", { value: true });
26723
+ keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
26724
+ const codegen_12 = codegen;
26725
+ const names_12 = names$1;
26726
+ const code_12 = code;
26727
+ const errors_12 = errors;
26728
+ function macroKeywordCode(cxt, def2) {
26729
+ const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
26730
+ const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
26731
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
26732
+ if (it.opts.validateSchema !== false)
26733
+ it.self.validateSchema(macroSchema, true);
26734
+ const valid = gen.name("valid");
26735
+ cxt.subschema({
26736
+ schema: macroSchema,
26737
+ schemaPath: codegen_12.nil,
26738
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
26739
+ topSchemaRef: schemaRef,
26740
+ compositeRule: true
26741
+ }, valid);
26742
+ cxt.pass(valid, () => cxt.error(true));
26800
26743
  }
26801
- const deps = def2.dependencies;
26802
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
26803
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
26744
+ keyword.macroKeywordCode = macroKeywordCode;
26745
+ function funcKeywordCode(cxt, def2) {
26746
+ var _a;
26747
+ const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
26748
+ checkAsyncKeyword(it, def2);
26749
+ const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
26750
+ const validateRef = useKeyword(gen, keyword2, validate2);
26751
+ const valid = gen.let("valid");
26752
+ cxt.block$data(valid, validateKeyword);
26753
+ cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
26754
+ function validateKeyword() {
26755
+ if (def2.errors === false) {
26756
+ assignValid();
26757
+ if (def2.modifying)
26758
+ modifyData(cxt);
26759
+ reportErrs(() => cxt.error());
26760
+ } else {
26761
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
26762
+ if (def2.modifying)
26763
+ modifyData(cxt);
26764
+ reportErrs(() => addErrs(cxt, ruleErrs));
26765
+ }
26766
+ }
26767
+ function validateAsync() {
26768
+ const ruleErrs = gen.let("ruleErrs", null);
26769
+ 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)));
26770
+ return ruleErrs;
26771
+ }
26772
+ function validateSync() {
26773
+ const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
26774
+ gen.assign(validateErrs, null);
26775
+ assignValid(codegen_12.nil);
26776
+ return validateErrs;
26777
+ }
26778
+ function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
26779
+ const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
26780
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
26781
+ gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
26782
+ }
26783
+ function reportErrs(errors2) {
26784
+ var _a2;
26785
+ gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
26786
+ }
26804
26787
  }
26805
- if (def2.validateSchema) {
26806
- const valid = def2.validateSchema(schema[keyword2]);
26807
- if (!valid) {
26808
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
26809
- if (opts.validateSchema === "log")
26810
- self2.logger.error(msg);
26811
- else
26812
- throw new Error(msg);
26788
+ keyword.funcKeywordCode = funcKeywordCode;
26789
+ function modifyData(cxt) {
26790
+ const { gen, data, it } = cxt;
26791
+ gen.if(it.parentData, () => gen.assign(data, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
26792
+ }
26793
+ function addErrs(cxt, errs) {
26794
+ const { gen } = cxt;
26795
+ gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
26796
+ 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`);
26797
+ (0, errors_12.extendErrors)(cxt);
26798
+ }, () => cxt.error());
26799
+ }
26800
+ function checkAsyncKeyword({ schemaEnv }, def2) {
26801
+ if (def2.async && !schemaEnv.$async)
26802
+ throw new Error("async keyword in sync schema");
26803
+ }
26804
+ function useKeyword(gen, keyword2, result) {
26805
+ if (result === void 0)
26806
+ throw new Error(`keyword "${keyword2}" failed to compile`);
26807
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
26808
+ }
26809
+ function validSchemaType(schema, schemaType, allowUndefined = false) {
26810
+ 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");
26811
+ }
26812
+ keyword.validSchemaType = validSchemaType;
26813
+ function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
26814
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
26815
+ throw new Error("ajv implementation error");
26816
+ }
26817
+ const deps = def2.dependencies;
26818
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
26819
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
26820
+ }
26821
+ if (def2.validateSchema) {
26822
+ const valid = def2.validateSchema(schema[keyword2]);
26823
+ if (!valid) {
26824
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
26825
+ if (opts.validateSchema === "log")
26826
+ self2.logger.error(msg);
26827
+ else
26828
+ throw new Error(msg);
26829
+ }
26813
26830
  }
26814
26831
  }
26832
+ keyword.validateKeywordUsage = validateKeywordUsage;
26833
+ return keyword;
26815
26834
  }
26816
- keyword.validateKeywordUsage = validateKeywordUsage;
26817
26835
  var subschema = {};
26818
- Object.defineProperty(subschema, "__esModule", { value: true });
26819
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
26820
- const codegen_1$o = codegen;
26821
- const util_1$o = util;
26822
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
26823
- if (keyword2 !== void 0 && schema !== void 0) {
26824
- throw new Error('both "keyword" and "schema" passed, only one allowed');
26825
- }
26826
- if (keyword2 !== void 0) {
26827
- const sch = it.schema[keyword2];
26828
- return schemaProp === void 0 ? {
26829
- schema: sch,
26830
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
26831
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
26832
- } : {
26833
- schema: sch[schemaProp],
26834
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
26835
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
26836
- };
26837
- }
26838
- if (schema !== void 0) {
26839
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
26840
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
26836
+ var hasRequiredSubschema;
26837
+ function requireSubschema() {
26838
+ if (hasRequiredSubschema) return subschema;
26839
+ hasRequiredSubschema = 1;
26840
+ Object.defineProperty(subschema, "__esModule", { value: true });
26841
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
26842
+ const codegen_12 = codegen;
26843
+ const util_12 = util;
26844
+ function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
26845
+ if (keyword2 !== void 0 && schema !== void 0) {
26846
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
26841
26847
  }
26842
- return {
26843
- schema,
26844
- schemaPath,
26845
- topSchemaRef,
26846
- errSchemaPath
26847
- };
26848
- }
26849
- throw new Error('either "keyword" or "schema" must be passed');
26850
- }
26851
- subschema.getSubschema = getSubschema;
26852
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
26853
- if (data !== void 0 && dataProp !== void 0) {
26854
- throw new Error('both "data" and "dataProp" passed, only one allowed');
26855
- }
26856
- const { gen } = it;
26857
- if (dataProp !== void 0) {
26858
- const { errorPath, dataPathArr, opts } = it;
26859
- const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
26860
- dataContextProps(nextData);
26861
- subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
26862
- subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
26863
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
26864
- }
26865
- if (data !== void 0) {
26866
- const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
26867
- dataContextProps(nextData);
26868
- if (propertyName !== void 0)
26869
- subschema2.propertyName = propertyName;
26870
- }
26871
- if (dataTypes)
26872
- subschema2.dataTypes = dataTypes;
26873
- function dataContextProps(_nextData) {
26874
- subschema2.data = _nextData;
26875
- subschema2.dataLevel = it.dataLevel + 1;
26876
- subschema2.dataTypes = [];
26877
- it.definedProperties = /* @__PURE__ */ new Set();
26878
- subschema2.parentData = it.data;
26879
- subschema2.dataNames = [...it.dataNames, _nextData];
26880
- }
26881
- }
26882
- subschema.extendSubschemaData = extendSubschemaData;
26883
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
26884
- if (compositeRule !== void 0)
26885
- subschema2.compositeRule = compositeRule;
26886
- if (createErrors !== void 0)
26887
- subschema2.createErrors = createErrors;
26888
- if (allErrors !== void 0)
26889
- subschema2.allErrors = allErrors;
26890
- subschema2.jtdDiscriminator = jtdDiscriminator;
26891
- subschema2.jtdMetadata = jtdMetadata;
26892
- }
26893
- subschema.extendSubschemaMode = extendSubschemaMode;
26848
+ if (keyword2 !== void 0) {
26849
+ const sch = it.schema[keyword2];
26850
+ return schemaProp === void 0 ? {
26851
+ schema: sch,
26852
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
26853
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`
26854
+ } : {
26855
+ schema: sch[schemaProp],
26856
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
26857
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
26858
+ };
26859
+ }
26860
+ if (schema !== void 0) {
26861
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
26862
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
26863
+ }
26864
+ return {
26865
+ schema,
26866
+ schemaPath,
26867
+ topSchemaRef,
26868
+ errSchemaPath
26869
+ };
26870
+ }
26871
+ throw new Error('either "keyword" or "schema" must be passed');
26872
+ }
26873
+ subschema.getSubschema = getSubschema;
26874
+ function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
26875
+ if (data !== void 0 && dataProp !== void 0) {
26876
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
26877
+ }
26878
+ const { gen } = it;
26879
+ if (dataProp !== void 0) {
26880
+ const { errorPath, dataPathArr, opts } = it;
26881
+ const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
26882
+ dataContextProps(nextData);
26883
+ subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
26884
+ subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
26885
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
26886
+ }
26887
+ if (data !== void 0) {
26888
+ const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
26889
+ dataContextProps(nextData);
26890
+ if (propertyName !== void 0)
26891
+ subschema2.propertyName = propertyName;
26892
+ }
26893
+ if (dataTypes)
26894
+ subschema2.dataTypes = dataTypes;
26895
+ function dataContextProps(_nextData) {
26896
+ subschema2.data = _nextData;
26897
+ subschema2.dataLevel = it.dataLevel + 1;
26898
+ subschema2.dataTypes = [];
26899
+ it.definedProperties = /* @__PURE__ */ new Set();
26900
+ subschema2.parentData = it.data;
26901
+ subschema2.dataNames = [...it.dataNames, _nextData];
26902
+ }
26903
+ }
26904
+ subschema.extendSubschemaData = extendSubschemaData;
26905
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
26906
+ if (compositeRule !== void 0)
26907
+ subschema2.compositeRule = compositeRule;
26908
+ if (createErrors !== void 0)
26909
+ subschema2.createErrors = createErrors;
26910
+ if (allErrors !== void 0)
26911
+ subschema2.allErrors = allErrors;
26912
+ subschema2.jtdDiscriminator = jtdDiscriminator;
26913
+ subschema2.jtdMetadata = jtdMetadata;
26914
+ }
26915
+ subschema.extendSubschemaMode = extendSubschemaMode;
26916
+ return subschema;
26917
+ }
26894
26918
  var resolve$2 = {};
26895
26919
  var fastDeepEqual = function equal(a, b) {
26896
26920
  if (a === b) return true;
@@ -27005,7 +27029,7 @@ function escapeJsonPtr(str) {
27005
27029
  var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
27006
27030
  Object.defineProperty(resolve$2, "__esModule", { value: true });
27007
27031
  resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
27008
- const util_1$n = util;
27032
+ const util_1$m = util;
27009
27033
  const equal$3 = fastDeepEqual;
27010
27034
  const traverse = jsonSchemaTraverseExports;
27011
27035
  const SIMPLE_INLINED = /* @__PURE__ */ new Set([
@@ -27064,7 +27088,7 @@ function countKeys(schema) {
27064
27088
  if (SIMPLE_INLINED.has(key))
27065
27089
  continue;
27066
27090
  if (typeof schema[key] == "object") {
27067
- (0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
27091
+ (0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys(sch));
27068
27092
  }
27069
27093
  if (count === Infinity)
27070
27094
  return Infinity;
@@ -27152,516 +27176,528 @@ function getSchemaRefs(schema, baseId) {
27152
27176
  }
27153
27177
  }
27154
27178
  resolve$2.getSchemaRefs = getSchemaRefs;
27155
- Object.defineProperty(validate, "__esModule", { value: true });
27156
- validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
27157
- const boolSchema_1 = boolSchema;
27158
- const dataType_1$1 = dataType;
27159
- const applicability_1 = applicability;
27160
- const dataType_2 = dataType;
27161
- const defaults_1 = defaults;
27162
- const keyword_1 = keyword;
27163
- const subschema_1 = subschema;
27164
- const codegen_1$n = codegen;
27165
- const names_1$3 = names$1;
27166
- const resolve_1$2 = resolve$2;
27167
- const util_1$m = util;
27168
- const errors_1 = errors;
27169
- function validateFunctionCode(it) {
27170
- if (isSchemaObj(it)) {
27171
- checkKeywords(it);
27172
- if (schemaCxtHasRules(it)) {
27173
- topSchemaObjCode(it);
27174
- return;
27179
+ var hasRequiredValidate;
27180
+ function requireValidate() {
27181
+ if (hasRequiredValidate) return validate;
27182
+ hasRequiredValidate = 1;
27183
+ Object.defineProperty(validate, "__esModule", { value: true });
27184
+ validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
27185
+ const boolSchema_1 = requireBoolSchema();
27186
+ const dataType_12 = dataType;
27187
+ const applicability_12 = applicability;
27188
+ const dataType_2 = dataType;
27189
+ const defaults_1 = requireDefaults();
27190
+ const keyword_1 = requireKeyword();
27191
+ const subschema_1 = requireSubschema();
27192
+ const codegen_12 = codegen;
27193
+ const names_12 = names$1;
27194
+ const resolve_12 = resolve$2;
27195
+ const util_12 = util;
27196
+ const errors_12 = errors;
27197
+ function validateFunctionCode(it) {
27198
+ if (isSchemaObj(it)) {
27199
+ checkKeywords(it);
27200
+ if (schemaCxtHasRules(it)) {
27201
+ topSchemaObjCode(it);
27202
+ return;
27203
+ }
27175
27204
  }
27205
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
27176
27206
  }
27177
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
27178
- }
27179
- validate.validateFunctionCode = validateFunctionCode;
27180
- function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
27181
- if (opts.code.es5) {
27182
- gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
27183
- gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
27184
- destructureValCxtES5(gen, opts);
27185
- gen.code(body);
27207
+ validate.validateFunctionCode = validateFunctionCode;
27208
+ function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
27209
+ if (opts.code.es5) {
27210
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
27211
+ gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
27212
+ destructureValCxtES5(gen, opts);
27213
+ gen.code(body);
27214
+ });
27215
+ } else {
27216
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
27217
+ }
27218
+ }
27219
+ function destructureValCxt(opts) {
27220
+ 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}}={}`;
27221
+ }
27222
+ function destructureValCxtES5(gen, opts) {
27223
+ gen.if(names_12.default.valCxt, () => {
27224
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
27225
+ gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
27226
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
27227
+ gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
27228
+ if (opts.dynamicRef)
27229
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
27230
+ }, () => {
27231
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
27232
+ gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
27233
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
27234
+ gen.var(names_12.default.rootData, names_12.default.data);
27235
+ if (opts.dynamicRef)
27236
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
27186
27237
  });
27187
- } else {
27188
- gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
27189
- }
27190
- }
27191
- function destructureValCxt(opts) {
27192
- return (0, codegen_1$n._)`{${names_1$3.default.instancePath}="", ${names_1$3.default.parentData}, ${names_1$3.default.parentDataProperty}, ${names_1$3.default.rootData}=${names_1$3.default.data}${opts.dynamicRef ? (0, codegen_1$n._)`, ${names_1$3.default.dynamicAnchors}={}` : codegen_1$n.nil}}={}`;
27193
- }
27194
- function destructureValCxtES5(gen, opts) {
27195
- gen.if(names_1$3.default.valCxt, () => {
27196
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
27197
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
27198
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
27199
- gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
27200
- if (opts.dynamicRef)
27201
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
27202
- }, () => {
27203
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
27204
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
27205
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
27206
- gen.var(names_1$3.default.rootData, names_1$3.default.data);
27207
- if (opts.dynamicRef)
27208
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
27209
- });
27210
- }
27211
- function topSchemaObjCode(it) {
27212
- const { schema, opts, gen } = it;
27213
- validateFunction(it, () => {
27238
+ }
27239
+ function topSchemaObjCode(it) {
27240
+ const { schema, opts, gen } = it;
27241
+ validateFunction(it, () => {
27242
+ if (opts.$comment && schema.$comment)
27243
+ commentKeyword(it);
27244
+ checkNoDefault(it);
27245
+ gen.let(names_12.default.vErrors, null);
27246
+ gen.let(names_12.default.errors, 0);
27247
+ if (opts.unevaluated)
27248
+ resetEvaluated(it);
27249
+ typeAndKeywords(it);
27250
+ returnResults(it);
27251
+ });
27252
+ return;
27253
+ }
27254
+ function resetEvaluated(it) {
27255
+ const { gen, validateName } = it;
27256
+ it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
27257
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
27258
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
27259
+ }
27260
+ function funcSourceUrl(schema, opts) {
27261
+ const schId = typeof schema == "object" && schema[opts.schemaId];
27262
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
27263
+ }
27264
+ function subschemaCode(it, valid) {
27265
+ if (isSchemaObj(it)) {
27266
+ checkKeywords(it);
27267
+ if (schemaCxtHasRules(it)) {
27268
+ subSchemaObjCode(it, valid);
27269
+ return;
27270
+ }
27271
+ }
27272
+ (0, boolSchema_1.boolOrEmptySchema)(it, valid);
27273
+ }
27274
+ function schemaCxtHasRules({ schema, self: self2 }) {
27275
+ if (typeof schema == "boolean")
27276
+ return !schema;
27277
+ for (const key in schema)
27278
+ if (self2.RULES.all[key])
27279
+ return true;
27280
+ return false;
27281
+ }
27282
+ function isSchemaObj(it) {
27283
+ return typeof it.schema != "boolean";
27284
+ }
27285
+ function subSchemaObjCode(it, valid) {
27286
+ const { schema, gen, opts } = it;
27214
27287
  if (opts.$comment && schema.$comment)
27215
27288
  commentKeyword(it);
27216
- checkNoDefault(it);
27217
- gen.let(names_1$3.default.vErrors, null);
27218
- gen.let(names_1$3.default.errors, 0);
27219
- if (opts.unevaluated)
27220
- resetEvaluated(it);
27221
- typeAndKeywords(it);
27222
- returnResults(it);
27223
- });
27224
- return;
27225
- }
27226
- function resetEvaluated(it) {
27227
- const { gen, validateName } = it;
27228
- it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
27229
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
27230
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
27231
- }
27232
- function funcSourceUrl(schema, opts) {
27233
- const schId = typeof schema == "object" && schema[opts.schemaId];
27234
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
27235
- }
27236
- function subschemaCode(it, valid) {
27237
- if (isSchemaObj(it)) {
27238
- checkKeywords(it);
27239
- if (schemaCxtHasRules(it)) {
27240
- subSchemaObjCode(it, valid);
27241
- return;
27289
+ updateContext(it);
27290
+ checkAsyncSchema(it);
27291
+ const errsCount = gen.const("_errs", names_12.default.errors);
27292
+ typeAndKeywords(it, errsCount);
27293
+ gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
27294
+ }
27295
+ function checkKeywords(it) {
27296
+ (0, util_12.checkUnknownRules)(it);
27297
+ checkRefsAndKeywords(it);
27298
+ }
27299
+ function typeAndKeywords(it, errsCount) {
27300
+ if (it.opts.jtd)
27301
+ return schemaKeywords(it, [], false, errsCount);
27302
+ const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
27303
+ const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
27304
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
27305
+ }
27306
+ function checkRefsAndKeywords(it) {
27307
+ const { schema, errSchemaPath, opts, self: self2 } = it;
27308
+ if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self2.RULES)) {
27309
+ self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
27242
27310
  }
27243
27311
  }
27244
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
27245
- }
27246
- function schemaCxtHasRules({ schema, self: self2 }) {
27247
- if (typeof schema == "boolean")
27248
- return !schema;
27249
- for (const key in schema)
27250
- if (self2.RULES.all[key])
27251
- return true;
27252
- return false;
27253
- }
27254
- function isSchemaObj(it) {
27255
- return typeof it.schema != "boolean";
27256
- }
27257
- function subSchemaObjCode(it, valid) {
27258
- const { schema, gen, opts } = it;
27259
- if (opts.$comment && schema.$comment)
27260
- commentKeyword(it);
27261
- updateContext(it);
27262
- checkAsyncSchema(it);
27263
- const errsCount = gen.const("_errs", names_1$3.default.errors);
27264
- typeAndKeywords(it, errsCount);
27265
- gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
27266
- }
27267
- function checkKeywords(it) {
27268
- (0, util_1$m.checkUnknownRules)(it);
27269
- checkRefsAndKeywords(it);
27270
- }
27271
- function typeAndKeywords(it, errsCount) {
27272
- if (it.opts.jtd)
27273
- return schemaKeywords(it, [], false, errsCount);
27274
- const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
27275
- const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
27276
- schemaKeywords(it, types2, !checkedTypes, errsCount);
27277
- }
27278
- function checkRefsAndKeywords(it) {
27279
- const { schema, errSchemaPath, opts, self: self2 } = it;
27280
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self2.RULES)) {
27281
- self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
27282
- }
27283
- }
27284
- function checkNoDefault(it) {
27285
- const { schema, opts } = it;
27286
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
27287
- (0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
27288
- }
27289
- }
27290
- function updateContext(it) {
27291
- const schId = it.schema[it.opts.schemaId];
27292
- if (schId)
27293
- it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
27294
- }
27295
- function checkAsyncSchema(it) {
27296
- if (it.schema.$async && !it.schemaEnv.$async)
27297
- throw new Error("async schema in sync schema");
27298
- }
27299
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
27300
- const msg = schema.$comment;
27301
- if (opts.$comment === true) {
27302
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
27303
- } else if (typeof opts.$comment == "function") {
27304
- const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
27305
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
27306
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
27307
- }
27308
- }
27309
- function returnResults(it) {
27310
- const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
27311
- if (schemaEnv.$async) {
27312
- gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === 0`, () => gen.return(names_1$3.default.data), () => gen.throw((0, codegen_1$n._)`new ${ValidationError2}(${names_1$3.default.vErrors})`));
27313
- } else {
27314
- gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
27315
- if (opts.unevaluated)
27316
- assignEvaluated(it);
27317
- gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
27318
- }
27319
- }
27320
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
27321
- if (props instanceof codegen_1$n.Name)
27322
- gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
27323
- if (items2 instanceof codegen_1$n.Name)
27324
- gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
27325
- }
27326
- function schemaKeywords(it, types2, typeErrors, errsCount) {
27327
- const { gen, schema, data, allErrors, opts, self: self2 } = it;
27328
- const { RULES } = self2;
27329
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
27330
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
27331
- return;
27312
+ function checkNoDefault(it) {
27313
+ const { schema, opts } = it;
27314
+ if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
27315
+ (0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
27316
+ }
27332
27317
  }
27333
- if (!opts.jtd)
27334
- checkStrictTypes(it, types2);
27335
- gen.block(() => {
27336
- for (const group of RULES.rules)
27337
- groupKeywords(group);
27338
- groupKeywords(RULES.post);
27339
- });
27340
- function groupKeywords(group) {
27341
- if (!(0, applicability_1.shouldUseGroup)(schema, group))
27318
+ function updateContext(it) {
27319
+ const schId = it.schema[it.opts.schemaId];
27320
+ if (schId)
27321
+ it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
27322
+ }
27323
+ function checkAsyncSchema(it) {
27324
+ if (it.schema.$async && !it.schemaEnv.$async)
27325
+ throw new Error("async schema in sync schema");
27326
+ }
27327
+ function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
27328
+ const msg = schema.$comment;
27329
+ if (opts.$comment === true) {
27330
+ gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
27331
+ } else if (typeof opts.$comment == "function") {
27332
+ const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
27333
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
27334
+ gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
27335
+ }
27336
+ }
27337
+ function returnResults(it) {
27338
+ const { gen, schemaEnv, validateName, ValidationError, opts } = it;
27339
+ if (schemaEnv.$async) {
27340
+ gen.if((0, codegen_12._)`${names_12.default.errors} === 0`, () => gen.return(names_12.default.data), () => gen.throw((0, codegen_12._)`new ${ValidationError}(${names_12.default.vErrors})`));
27341
+ } else {
27342
+ gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
27343
+ if (opts.unevaluated)
27344
+ assignEvaluated(it);
27345
+ gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
27346
+ }
27347
+ }
27348
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
27349
+ if (props instanceof codegen_12.Name)
27350
+ gen.assign((0, codegen_12._)`${evaluated}.props`, props);
27351
+ if (items2 instanceof codegen_12.Name)
27352
+ gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
27353
+ }
27354
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
27355
+ const { gen, schema, data, allErrors, opts, self: self2 } = it;
27356
+ const { RULES } = self2;
27357
+ if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
27358
+ gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
27342
27359
  return;
27343
- if (group.type) {
27344
- gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
27345
- iterateKeywords(it, group);
27346
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
27347
- gen.else();
27348
- (0, dataType_2.reportTypeError)(it);
27360
+ }
27361
+ if (!opts.jtd)
27362
+ checkStrictTypes(it, types2);
27363
+ gen.block(() => {
27364
+ for (const group of RULES.rules)
27365
+ groupKeywords(group);
27366
+ groupKeywords(RULES.post);
27367
+ });
27368
+ function groupKeywords(group) {
27369
+ if (!(0, applicability_12.shouldUseGroup)(schema, group))
27370
+ return;
27371
+ if (group.type) {
27372
+ gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
27373
+ iterateKeywords(it, group);
27374
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
27375
+ gen.else();
27376
+ (0, dataType_2.reportTypeError)(it);
27377
+ }
27378
+ gen.endIf();
27379
+ } else {
27380
+ iterateKeywords(it, group);
27349
27381
  }
27350
- gen.endIf();
27351
- } else {
27352
- iterateKeywords(it, group);
27382
+ if (!allErrors)
27383
+ gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
27353
27384
  }
27354
- if (!allErrors)
27355
- gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
27356
27385
  }
27357
- }
27358
- function iterateKeywords(it, group) {
27359
- const { gen, schema, opts: { useDefaults } } = it;
27360
- if (useDefaults)
27361
- (0, defaults_1.assignDefaults)(it, group.type);
27362
- gen.block(() => {
27363
- for (const rule of group.rules) {
27364
- if ((0, applicability_1.shouldUseRule)(schema, rule)) {
27365
- keywordCode(it, rule.keyword, rule.definition, group.type);
27386
+ function iterateKeywords(it, group) {
27387
+ const { gen, schema, opts: { useDefaults } } = it;
27388
+ if (useDefaults)
27389
+ (0, defaults_1.assignDefaults)(it, group.type);
27390
+ gen.block(() => {
27391
+ for (const rule of group.rules) {
27392
+ if ((0, applicability_12.shouldUseRule)(schema, rule)) {
27393
+ keywordCode(it, rule.keyword, rule.definition, group.type);
27394
+ }
27366
27395
  }
27367
- }
27368
- });
27369
- }
27370
- function checkStrictTypes(it, types2) {
27371
- if (it.schemaEnv.meta || !it.opts.strictTypes)
27372
- return;
27373
- checkContextTypes(it, types2);
27374
- if (!it.opts.allowUnionTypes)
27375
- checkMultipleTypes(it, types2);
27376
- checkKeywordTypes(it, it.dataTypes);
27377
- }
27378
- function checkContextTypes(it, types2) {
27379
- if (!types2.length)
27380
- return;
27381
- if (!it.dataTypes.length) {
27382
- it.dataTypes = types2;
27383
- return;
27396
+ });
27397
+ }
27398
+ function checkStrictTypes(it, types2) {
27399
+ if (it.schemaEnv.meta || !it.opts.strictTypes)
27400
+ return;
27401
+ checkContextTypes(it, types2);
27402
+ if (!it.opts.allowUnionTypes)
27403
+ checkMultipleTypes(it, types2);
27404
+ checkKeywordTypes(it, it.dataTypes);
27384
27405
  }
27385
- types2.forEach((t) => {
27386
- if (!includesType(it.dataTypes, t)) {
27387
- strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
27406
+ function checkContextTypes(it, types2) {
27407
+ if (!types2.length)
27408
+ return;
27409
+ if (!it.dataTypes.length) {
27410
+ it.dataTypes = types2;
27411
+ return;
27388
27412
  }
27389
- });
27390
- narrowSchemaTypes(it, types2);
27391
- }
27392
- function checkMultipleTypes(it, ts) {
27393
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
27394
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
27395
- }
27396
- }
27397
- function checkKeywordTypes(it, ts) {
27398
- const rules2 = it.self.RULES.all;
27399
- for (const keyword2 in rules2) {
27400
- const rule = rules2[keyword2];
27401
- if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
27402
- const { type: type2 } = rule.definition;
27403
- if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
27404
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
27405
- }
27406
- }
27407
- }
27408
- }
27409
- function hasApplicableType(schTs, kwdT) {
27410
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
27411
- }
27412
- function includesType(ts, t) {
27413
- return ts.includes(t) || t === "integer" && ts.includes("number");
27414
- }
27415
- function narrowSchemaTypes(it, withTypes) {
27416
- const ts = [];
27417
- for (const t of it.dataTypes) {
27418
- if (includesType(withTypes, t))
27419
- ts.push(t);
27420
- else if (withTypes.includes("integer") && t === "number")
27421
- ts.push("integer");
27422
- }
27423
- it.dataTypes = ts;
27424
- }
27425
- function strictTypesError(it, msg) {
27426
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
27427
- msg += ` at "${schemaPath}" (strictTypes)`;
27428
- (0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
27429
- }
27430
- class KeywordCxt {
27431
- constructor(it, def2, keyword2) {
27432
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
27433
- this.gen = it.gen;
27434
- this.allErrors = it.allErrors;
27435
- this.keyword = keyword2;
27436
- this.data = it.data;
27437
- this.schema = it.schema[keyword2];
27438
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
27439
- this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
27440
- this.schemaType = def2.schemaType;
27441
- this.parentSchema = it.schema;
27442
- this.params = {};
27443
- this.it = it;
27444
- this.def = def2;
27445
- if (this.$data) {
27446
- this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
27447
- } else {
27448
- this.schemaCode = this.schemaValue;
27449
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
27450
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
27413
+ types2.forEach((t) => {
27414
+ if (!includesType(it.dataTypes, t)) {
27415
+ strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
27416
+ }
27417
+ });
27418
+ narrowSchemaTypes(it, types2);
27419
+ }
27420
+ function checkMultipleTypes(it, ts) {
27421
+ if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
27422
+ strictTypesError(it, "use allowUnionTypes to allow union type keyword");
27423
+ }
27424
+ }
27425
+ function checkKeywordTypes(it, ts) {
27426
+ const rules2 = it.self.RULES.all;
27427
+ for (const keyword2 in rules2) {
27428
+ const rule = rules2[keyword2];
27429
+ if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
27430
+ const { type: type2 } = rule.definition;
27431
+ if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
27432
+ strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
27433
+ }
27434
+ }
27435
+ }
27436
+ }
27437
+ function hasApplicableType(schTs, kwdT) {
27438
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
27439
+ }
27440
+ function includesType(ts, t) {
27441
+ return ts.includes(t) || t === "integer" && ts.includes("number");
27442
+ }
27443
+ function narrowSchemaTypes(it, withTypes) {
27444
+ const ts = [];
27445
+ for (const t of it.dataTypes) {
27446
+ if (includesType(withTypes, t))
27447
+ ts.push(t);
27448
+ else if (withTypes.includes("integer") && t === "number")
27449
+ ts.push("integer");
27450
+ }
27451
+ it.dataTypes = ts;
27452
+ }
27453
+ function strictTypesError(it, msg) {
27454
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
27455
+ msg += ` at "${schemaPath}" (strictTypes)`;
27456
+ (0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
27457
+ }
27458
+ class KeywordCxt {
27459
+ constructor(it, def2, keyword2) {
27460
+ (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
27461
+ this.gen = it.gen;
27462
+ this.allErrors = it.allErrors;
27463
+ this.keyword = keyword2;
27464
+ this.data = it.data;
27465
+ this.schema = it.schema[keyword2];
27466
+ this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
27467
+ this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
27468
+ this.schemaType = def2.schemaType;
27469
+ this.parentSchema = it.schema;
27470
+ this.params = {};
27471
+ this.it = it;
27472
+ this.def = def2;
27473
+ if (this.$data) {
27474
+ this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
27475
+ } else {
27476
+ this.schemaCode = this.schemaValue;
27477
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
27478
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
27479
+ }
27480
+ }
27481
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
27482
+ this.errsCount = it.gen.const("_errs", names_12.default.errors);
27451
27483
  }
27452
27484
  }
27453
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
27454
- this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
27485
+ result(condition, successAction, failAction) {
27486
+ this.failResult((0, codegen_12.not)(condition), successAction, failAction);
27455
27487
  }
27456
- }
27457
- result(condition, successAction, failAction) {
27458
- this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
27459
- }
27460
- failResult(condition, successAction, failAction) {
27461
- this.gen.if(condition);
27462
- if (failAction)
27463
- failAction();
27464
- else
27488
+ failResult(condition, successAction, failAction) {
27489
+ this.gen.if(condition);
27490
+ if (failAction)
27491
+ failAction();
27492
+ else
27493
+ this.error();
27494
+ if (successAction) {
27495
+ this.gen.else();
27496
+ successAction();
27497
+ if (this.allErrors)
27498
+ this.gen.endIf();
27499
+ } else {
27500
+ if (this.allErrors)
27501
+ this.gen.endIf();
27502
+ else
27503
+ this.gen.else();
27504
+ }
27505
+ }
27506
+ pass(condition, failAction) {
27507
+ this.failResult((0, codegen_12.not)(condition), void 0, failAction);
27508
+ }
27509
+ fail(condition) {
27510
+ if (condition === void 0) {
27511
+ this.error();
27512
+ if (!this.allErrors)
27513
+ this.gen.if(false);
27514
+ return;
27515
+ }
27516
+ this.gen.if(condition);
27465
27517
  this.error();
27466
- if (successAction) {
27467
- this.gen.else();
27468
- successAction();
27469
- if (this.allErrors)
27470
- this.gen.endIf();
27471
- } else {
27472
27518
  if (this.allErrors)
27473
27519
  this.gen.endIf();
27474
27520
  else
27475
27521
  this.gen.else();
27476
27522
  }
27477
- }
27478
- pass(condition, failAction) {
27479
- this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
27480
- }
27481
- fail(condition) {
27482
- if (condition === void 0) {
27483
- this.error();
27523
+ fail$data(condition) {
27524
+ if (!this.$data)
27525
+ return this.fail(condition);
27526
+ const { schemaCode } = this;
27527
+ this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
27528
+ }
27529
+ error(append, errorParams, errorPaths) {
27530
+ if (errorParams) {
27531
+ this.setParams(errorParams);
27532
+ this._error(append, errorPaths);
27533
+ this.setParams({});
27534
+ return;
27535
+ }
27536
+ this._error(append, errorPaths);
27537
+ }
27538
+ _error(append, errorPaths) {
27539
+ (append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
27540
+ }
27541
+ $dataError() {
27542
+ (0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
27543
+ }
27544
+ reset() {
27545
+ if (this.errsCount === void 0)
27546
+ throw new Error('add "trackErrors" to keyword definition');
27547
+ (0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
27548
+ }
27549
+ ok(cond) {
27484
27550
  if (!this.allErrors)
27485
- this.gen.if(false);
27486
- return;
27551
+ this.gen.if(cond);
27487
27552
  }
27488
- this.gen.if(condition);
27489
- this.error();
27490
- if (this.allErrors)
27491
- this.gen.endIf();
27492
- else
27493
- this.gen.else();
27494
- }
27495
- fail$data(condition) {
27496
- if (!this.$data)
27497
- return this.fail(condition);
27498
- const { schemaCode } = this;
27499
- this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
27500
- }
27501
- error(append, errorParams, errorPaths) {
27502
- if (errorParams) {
27503
- this.setParams(errorParams);
27504
- this._error(append, errorPaths);
27505
- this.setParams({});
27506
- return;
27553
+ setParams(obj, assign) {
27554
+ if (assign)
27555
+ Object.assign(this.params, obj);
27556
+ else
27557
+ this.params = obj;
27507
27558
  }
27508
- this._error(append, errorPaths);
27509
- }
27510
- _error(append, errorPaths) {
27511
- (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
27512
- }
27513
- $dataError() {
27514
- (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
27515
- }
27516
- reset() {
27517
- if (this.errsCount === void 0)
27518
- throw new Error('add "trackErrors" to keyword definition');
27519
- (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
27520
- }
27521
- ok(cond) {
27522
- if (!this.allErrors)
27523
- this.gen.if(cond);
27524
- }
27525
- setParams(obj, assign) {
27526
- if (assign)
27527
- Object.assign(this.params, obj);
27528
- else
27529
- this.params = obj;
27530
- }
27531
- block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
27532
- this.gen.block(() => {
27533
- this.check$data(valid, $dataValid);
27534
- codeBlock();
27535
- });
27536
- }
27537
- check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
27538
- if (!this.$data)
27539
- return;
27540
- const { gen, schemaCode, schemaType, def: def2 } = this;
27541
- gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
27542
- if (valid !== codegen_1$n.nil)
27543
- gen.assign(valid, true);
27544
- if (schemaType.length || def2.validateSchema) {
27545
- gen.elseIf(this.invalid$data());
27546
- this.$dataError();
27547
- if (valid !== codegen_1$n.nil)
27548
- gen.assign(valid, false);
27559
+ block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
27560
+ this.gen.block(() => {
27561
+ this.check$data(valid, $dataValid);
27562
+ codeBlock();
27563
+ });
27549
27564
  }
27550
- gen.else();
27551
- }
27552
- invalid$data() {
27553
- const { gen, schemaCode, schemaType, def: def2, it } = this;
27554
- return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
27555
- function wrong$DataType() {
27556
- if (schemaType.length) {
27557
- if (!(schemaCode instanceof codegen_1$n.Name))
27558
- throw new Error("ajv implementation error");
27559
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
27560
- return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
27565
+ check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
27566
+ if (!this.$data)
27567
+ return;
27568
+ const { gen, schemaCode, schemaType, def: def2 } = this;
27569
+ gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
27570
+ if (valid !== codegen_12.nil)
27571
+ gen.assign(valid, true);
27572
+ if (schemaType.length || def2.validateSchema) {
27573
+ gen.elseIf(this.invalid$data());
27574
+ this.$dataError();
27575
+ if (valid !== codegen_12.nil)
27576
+ gen.assign(valid, false);
27561
27577
  }
27562
- return codegen_1$n.nil;
27578
+ gen.else();
27563
27579
  }
27564
- function invalid$DataSchema() {
27565
- if (def2.validateSchema) {
27566
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
27567
- return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
27580
+ invalid$data() {
27581
+ const { gen, schemaCode, schemaType, def: def2, it } = this;
27582
+ return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
27583
+ function wrong$DataType() {
27584
+ if (schemaType.length) {
27585
+ if (!(schemaCode instanceof codegen_12.Name))
27586
+ throw new Error("ajv implementation error");
27587
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
27588
+ return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
27589
+ }
27590
+ return codegen_12.nil;
27591
+ }
27592
+ function invalid$DataSchema() {
27593
+ if (def2.validateSchema) {
27594
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
27595
+ return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
27596
+ }
27597
+ return codegen_12.nil;
27598
+ }
27599
+ }
27600
+ subschema(appl, valid) {
27601
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
27602
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
27603
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
27604
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
27605
+ subschemaCode(nextContext, valid);
27606
+ return nextContext;
27607
+ }
27608
+ mergeEvaluated(schemaCxt, toName) {
27609
+ const { it, gen } = this;
27610
+ if (!it.opts.unevaluated)
27611
+ return;
27612
+ if (it.props !== true && schemaCxt.props !== void 0) {
27613
+ it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
27614
+ }
27615
+ if (it.items !== true && schemaCxt.items !== void 0) {
27616
+ it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
27568
27617
  }
27569
- return codegen_1$n.nil;
27570
- }
27571
- }
27572
- subschema(appl, valid) {
27573
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
27574
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
27575
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
27576
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
27577
- subschemaCode(nextContext, valid);
27578
- return nextContext;
27579
- }
27580
- mergeEvaluated(schemaCxt, toName) {
27581
- const { it, gen } = this;
27582
- if (!it.opts.unevaluated)
27583
- return;
27584
- if (it.props !== true && schemaCxt.props !== void 0) {
27585
- it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
27586
27618
  }
27587
- if (it.items !== true && schemaCxt.items !== void 0) {
27588
- it.items = util_1$m.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
27619
+ mergeValidEvaluated(schemaCxt, valid) {
27620
+ const { it, gen } = this;
27621
+ if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
27622
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
27623
+ return true;
27624
+ }
27589
27625
  }
27590
27626
  }
27591
- mergeValidEvaluated(schemaCxt, valid) {
27592
- const { it, gen } = this;
27593
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
27594
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
27595
- return true;
27627
+ validate.KeywordCxt = KeywordCxt;
27628
+ function keywordCode(it, keyword2, def2, ruleType) {
27629
+ const cxt = new KeywordCxt(it, def2, keyword2);
27630
+ if ("code" in def2) {
27631
+ def2.code(cxt, ruleType);
27632
+ } else if (cxt.$data && def2.validate) {
27633
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
27634
+ } else if ("macro" in def2) {
27635
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
27636
+ } else if (def2.compile || def2.validate) {
27637
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
27638
+ }
27639
+ }
27640
+ const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
27641
+ const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
27642
+ function getData($data, { dataLevel, dataNames, dataPathArr }) {
27643
+ let jsonPointer;
27644
+ let data;
27645
+ if ($data === "")
27646
+ return names_12.default.rootData;
27647
+ if ($data[0] === "/") {
27648
+ if (!JSON_POINTER.test($data))
27649
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
27650
+ jsonPointer = $data;
27651
+ data = names_12.default.rootData;
27652
+ } else {
27653
+ const matches = RELATIVE_JSON_POINTER.exec($data);
27654
+ if (!matches)
27655
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
27656
+ const up = +matches[1];
27657
+ jsonPointer = matches[2];
27658
+ if (jsonPointer === "#") {
27659
+ if (up >= dataLevel)
27660
+ throw new Error(errorMsg("property/index", up));
27661
+ return dataPathArr[dataLevel - up];
27662
+ }
27663
+ if (up > dataLevel)
27664
+ throw new Error(errorMsg("data", up));
27665
+ data = dataNames[dataLevel - up];
27666
+ if (!jsonPointer)
27667
+ return data;
27596
27668
  }
27597
- }
27598
- }
27599
- validate.KeywordCxt = KeywordCxt;
27600
- function keywordCode(it, keyword2, def2, ruleType) {
27601
- const cxt = new KeywordCxt(it, def2, keyword2);
27602
- if ("code" in def2) {
27603
- def2.code(cxt, ruleType);
27604
- } else if (cxt.$data && def2.validate) {
27605
- (0, keyword_1.funcKeywordCode)(cxt, def2);
27606
- } else if ("macro" in def2) {
27607
- (0, keyword_1.macroKeywordCode)(cxt, def2);
27608
- } else if (def2.compile || def2.validate) {
27609
- (0, keyword_1.funcKeywordCode)(cxt, def2);
27610
- }
27611
- }
27612
- const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
27613
- const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
27614
- function getData($data, { dataLevel, dataNames, dataPathArr }) {
27615
- let jsonPointer;
27616
- let data;
27617
- if ($data === "")
27618
- return names_1$3.default.rootData;
27619
- if ($data[0] === "/") {
27620
- if (!JSON_POINTER.test($data))
27621
- throw new Error(`Invalid JSON-pointer: ${$data}`);
27622
- jsonPointer = $data;
27623
- data = names_1$3.default.rootData;
27624
- } else {
27625
- const matches = RELATIVE_JSON_POINTER.exec($data);
27626
- if (!matches)
27627
- throw new Error(`Invalid JSON-pointer: ${$data}`);
27628
- const up = +matches[1];
27629
- jsonPointer = matches[2];
27630
- if (jsonPointer === "#") {
27631
- if (up >= dataLevel)
27632
- throw new Error(errorMsg("property/index", up));
27633
- return dataPathArr[dataLevel - up];
27634
- }
27635
- if (up > dataLevel)
27636
- throw new Error(errorMsg("data", up));
27637
- data = dataNames[dataLevel - up];
27638
- if (!jsonPointer)
27639
- return data;
27640
- }
27641
- let expr = data;
27642
- const segments = jsonPointer.split("/");
27643
- for (const segment of segments) {
27644
- if (segment) {
27645
- data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
27646
- expr = (0, codegen_1$n._)`${expr} && ${data}`;
27669
+ let expr = data;
27670
+ const segments = jsonPointer.split("/");
27671
+ for (const segment of segments) {
27672
+ if (segment) {
27673
+ data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
27674
+ expr = (0, codegen_12._)`${expr} && ${data}`;
27675
+ }
27676
+ }
27677
+ return expr;
27678
+ function errorMsg(pointerType, up) {
27679
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
27647
27680
  }
27648
27681
  }
27649
- return expr;
27650
- function errorMsg(pointerType, up) {
27651
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
27652
- }
27682
+ validate.getData = getData;
27683
+ return validate;
27653
27684
  }
27654
- validate.getData = getData;
27655
27685
  var validation_error = {};
27656
- Object.defineProperty(validation_error, "__esModule", { value: true });
27657
- class ValidationError extends Error {
27658
- constructor(errors2) {
27659
- super("validation failed");
27660
- this.errors = errors2;
27661
- this.ajv = this.validation = true;
27686
+ var hasRequiredValidation_error;
27687
+ function requireValidation_error() {
27688
+ if (hasRequiredValidation_error) return validation_error;
27689
+ hasRequiredValidation_error = 1;
27690
+ Object.defineProperty(validation_error, "__esModule", { value: true });
27691
+ class ValidationError extends Error {
27692
+ constructor(errors2) {
27693
+ super("validation failed");
27694
+ this.errors = errors2;
27695
+ this.ajv = this.validation = true;
27696
+ }
27662
27697
  }
27698
+ validation_error.default = ValidationError;
27699
+ return validation_error;
27663
27700
  }
27664
- validation_error.default = ValidationError;
27665
27701
  var ref_error = {};
27666
27702
  Object.defineProperty(ref_error, "__esModule", { value: true });
27667
27703
  const resolve_1$1 = resolve$2;
@@ -27677,11 +27713,11 @@ var compile = {};
27677
27713
  Object.defineProperty(compile, "__esModule", { value: true });
27678
27714
  compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
27679
27715
  const codegen_1$m = codegen;
27680
- const validation_error_1 = validation_error;
27716
+ const validation_error_1 = requireValidation_error();
27681
27717
  const names_1$2 = names$1;
27682
27718
  const resolve_1 = resolve$2;
27683
27719
  const util_1$l = util;
27684
- const validate_1$1 = validate;
27720
+ const validate_1$1 = requireValidate();
27685
27721
  class SchemaEnv {
27686
27722
  constructor(env) {
27687
27723
  var _a;
@@ -28966,7 +29002,7 @@ uri$1.default = uri;
28966
29002
  (function(exports) {
28967
29003
  Object.defineProperty(exports, "__esModule", { value: true });
28968
29004
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
28969
- var validate_12 = validate;
29005
+ var validate_12 = requireValidate();
28970
29006
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
28971
29007
  return validate_12.KeywordCxt;
28972
29008
  } });
@@ -28989,7 +29025,7 @@ uri$1.default = uri;
28989
29025
  Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
28990
29026
  return codegen_12.CodeGen;
28991
29027
  } });
28992
- const validation_error_12 = validation_error;
29028
+ const validation_error_12 = requireValidation_error();
28993
29029
  const ref_error_12 = ref_error;
28994
29030
  const rules_12 = rules;
28995
29031
  const compile_12 = compile;
@@ -30577,7 +30613,7 @@ const def$a = {
30577
30613
  additionalProperties.default = def$a;
30578
30614
  var properties$1 = {};
30579
30615
  Object.defineProperty(properties$1, "__esModule", { value: true });
30580
- const validate_1 = validate;
30616
+ const validate_1 = requireValidate();
30581
30617
  const code_1$2 = code;
30582
30618
  const util_1$7 = util;
30583
30619
  const additionalProperties_1$1 = additionalProperties;
@@ -31428,7 +31464,7 @@ const require$$3 = {
31428
31464
  module2.exports.Ajv = Ajv2;
31429
31465
  Object.defineProperty(exports, "__esModule", { value: true });
31430
31466
  exports.default = Ajv2;
31431
- var validate_12 = validate;
31467
+ var validate_12 = requireValidate();
31432
31468
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
31433
31469
  return validate_12.KeywordCxt;
31434
31470
  } });
@@ -31451,7 +31487,7 @@ const require$$3 = {
31451
31487
  Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
31452
31488
  return codegen_12.CodeGen;
31453
31489
  } });
31454
- var validation_error_12 = validation_error;
31490
+ var validation_error_12 = requireValidation_error();
31455
31491
  Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() {
31456
31492
  return validation_error_12.default;
31457
31493
  } });