@testsmith/api-spector 0.2.2 → 0.2.3

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.
@@ -2076,7 +2076,7 @@ if (canUseDOM)
2076
2076
  passiveBrowserEventsSupported = false;
2077
2077
  }
2078
2078
  var root = null, startText = null, fallbackText = null;
2079
- function getData$1() {
2079
+ function getData() {
2080
2080
  if (fallbackText) return fallbackText;
2081
2081
  var start, startValue = startText, startLength = startValue.length, end, endValue = "value" in root ? root.value : root.textContent, endLength = endValue.length;
2082
2082
  for (start = 0; start < startLength && startValue[start] === endValue[start]; start++) ;
@@ -2331,7 +2331,7 @@ function getNativeBeforeInputChars(domEventName, nativeEvent) {
2331
2331
  }
2332
2332
  function getFallbackBeforeInputChars(domEventName, nativeEvent) {
2333
2333
  if (isComposing)
2334
- return "compositionend" === domEventName || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent) ? (domEventName = getData$1(), fallbackText = startText = root = null, isComposing = false, domEventName) : null;
2334
+ return "compositionend" === domEventName || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent) ? (domEventName = getData(), fallbackText = startText = root = null, isComposing = false, domEventName) : null;
2335
2335
  switch (domEventName) {
2336
2336
  case "paste":
2337
2337
  return null;
@@ -10063,7 +10063,7 @@ function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativ
10063
10063
  }
10064
10064
  else
10065
10065
  isComposing ? isFallbackCompositionEnd(domEventName, nativeEvent) && (eventType = "onCompositionEnd") : "keydown" === domEventName && 229 === nativeEvent.keyCode && (eventType = "onCompositionStart");
10066
- eventType && (useFallbackCompositionData && "ko" !== nativeEvent.locale && (isComposing || "onCompositionStart" !== eventType ? "onCompositionEnd" === eventType && isComposing && (fallbackData = getData$1()) : (root = nativeEventTarget, startText = "value" in root ? root.value : root.textContent, isComposing = true)), handleEventFunc = accumulateTwoPhaseListeners(targetInst, eventType), 0 < handleEventFunc.length && (eventType = new SyntheticCompositionEvent(
10066
+ eventType && (useFallbackCompositionData && "ko" !== nativeEvent.locale && (isComposing || "onCompositionStart" !== eventType ? "onCompositionEnd" === eventType && isComposing && (fallbackData = getData()) : (root = nativeEventTarget, startText = "value" in root ? root.value : root.textContent, isComposing = true)), handleEventFunc = accumulateTwoPhaseListeners(targetInst, eventType), 0 < handleEventFunc.length && (eventType = new SyntheticCompositionEvent(
10067
10067
  eventType,
10068
10068
  domEventName,
10069
10069
  null,
@@ -13433,6 +13433,8 @@ const useStore = create()(
13433
13433
  commandPaletteOpen: false,
13434
13434
  pinnedResponse: null,
13435
13435
  lastContractReport: null,
13436
+ contractSnapshots: {},
13437
+ activeContractSnapshotRelPath: null,
13436
13438
  wsConnections: {},
13437
13439
  // ── Workspace ─────────────────────────────────────────────────────────────
13438
13440
  setWorkspace: (ws2, path) => set2((s) => {
@@ -13458,6 +13460,8 @@ const useStore = create()(
13458
13460
  s.wsConnections = {};
13459
13461
  s.pinnedResponse = null;
13460
13462
  s.lastContractReport = null;
13463
+ s.contractSnapshots = {};
13464
+ s.activeContractSnapshotRelPath = null;
13461
13465
  }),
13462
13466
  updateWorkspaceSettings: (settings) => set2((s) => {
13463
13467
  if (s.workspace) s.workspace.settings = settings;
@@ -13922,6 +13926,24 @@ const useStore = create()(
13922
13926
  setLastContractReport: (r) => set2((s) => {
13923
13927
  s.lastContractReport = r;
13924
13928
  }),
13929
+ // ── Contract snapshots ────────────────────────────────────────────────────
13930
+ loadContractSnapshot: (relPath, snapshot) => set2((s) => {
13931
+ s.contractSnapshots[relPath] = snapshot;
13932
+ if (s.workspace) {
13933
+ if (!s.workspace.contracts) s.workspace.contracts = [];
13934
+ if (!s.workspace.contracts.includes(relPath)) s.workspace.contracts.push(relPath);
13935
+ }
13936
+ }),
13937
+ removeContractSnapshot: (relPath) => set2((s) => {
13938
+ delete s.contractSnapshots[relPath];
13939
+ if (s.activeContractSnapshotRelPath === relPath) s.activeContractSnapshotRelPath = null;
13940
+ if (s.workspace?.contracts) {
13941
+ s.workspace.contracts = s.workspace.contracts.filter((p2) => p2 !== relPath);
13942
+ }
13943
+ }),
13944
+ setActiveContractSnapshot: (relPath) => set2((s) => {
13945
+ s.activeContractSnapshotRelPath = relPath;
13946
+ }),
13925
13947
  // ── Inherited auth/headers ────────────────────────────────────────────────
13926
13948
  getInheritedAuthAndHeaders: (requestId) => {
13927
13949
  const state = useStore.getState();
@@ -14182,6 +14204,7 @@ function useWorkspaceLoader() {
14182
14204
  const loadEnvironment = useStore((s) => s.loadEnvironment);
14183
14205
  const loadMock = useStore((s) => s.loadMock);
14184
14206
  const setActiveCollection = useStore((s) => s.setActiveCollection);
14207
+ const loadContractSnapshot = useStore((s) => s.loadContractSnapshot);
14185
14208
  const setTheme = useStore((s) => s.setTheme);
14186
14209
  const setZoom = useStore((s) => s.setZoom);
14187
14210
  const applyWorkspace = reactExports.useCallback(async (ws2, path) => {
@@ -14218,6 +14241,11 @@ function useWorkspaceLoader() {
14218
14241
  } catch {
14219
14242
  }
14220
14243
  }
14244
+ try {
14245
+ const snapshots = await electron$o.listContractSnapshots(ws2.contracts ?? []);
14246
+ for (const { relPath, snapshot } of snapshots) loadContractSnapshot(relPath, snapshot);
14247
+ } catch {
14248
+ }
14221
14249
  if (ws2.collections.length > 0) {
14222
14250
  try {
14223
14251
  const firstCol = await electron$o.loadCollection(ws2.collections[0]);
@@ -14225,7 +14253,7 @@ function useWorkspaceLoader() {
14225
14253
  } catch {
14226
14254
  }
14227
14255
  }
14228
- }, [loadCollection, loadEnvironment, loadMock, setActiveCollection, setTheme, setZoom]);
14256
+ }, [loadCollection, loadEnvironment, loadMock, loadContractSnapshot, setActiveCollection, setTheme, setZoom]);
14229
14257
  return { applyWorkspace };
14230
14258
  }
14231
14259
  const METHOD_COLORS$1 = {
@@ -57533,8 +57561,8 @@ var scope = {};
57533
57561
  var util = {};
57534
57562
  Object.defineProperty(util, "__esModule", { value: true });
57535
57563
  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;
57536
- const codegen_1$v = codegen;
57537
- const code_1$a = code$1;
57564
+ const codegen_1$q = codegen;
57565
+ const code_1$9 = code$1;
57538
57566
  function toHash(arr) {
57539
57567
  const hash = {};
57540
57568
  for (const item of arr)
@@ -57587,9 +57615,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
57587
57615
  if (typeof schema == "number" || typeof schema == "boolean")
57588
57616
  return schema;
57589
57617
  if (typeof schema == "string")
57590
- return (0, codegen_1$v._)`${schema}`;
57618
+ return (0, codegen_1$q._)`${schema}`;
57591
57619
  }
57592
- return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
57620
+ return (0, codegen_1$q._)`${topSchemaRef}${schemaPath}${(0, codegen_1$q.getProperty)(keyword2)}`;
57593
57621
  }
57594
57622
  util.schemaRefOrVal = schemaRefOrVal;
57595
57623
  function unescapeFragment(str) {
@@ -57621,20 +57649,20 @@ function eachItem(xs, f) {
57621
57649
  util.eachItem = eachItem;
57622
57650
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
57623
57651
  return (gen, from, to, toName) => {
57624
- 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) : mergeValues(from, to);
57625
- return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
57652
+ 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) : mergeValues(from, to);
57653
+ return toName === codegen_1$q.Name && !(res instanceof codegen_1$q.Name) ? resultToName(gen, res) : res;
57626
57654
  };
57627
57655
  }
57628
57656
  util.mergeEvaluated = {
57629
57657
  props: makeMergeEvaluated({
57630
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
57631
- 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})`));
57658
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => {
57659
+ 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})`));
57632
57660
  }),
57633
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
57661
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => {
57634
57662
  if (from === true) {
57635
57663
  gen.assign(to, true);
57636
57664
  } else {
57637
- gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
57665
+ gen.assign(to, (0, codegen_1$q._)`${to} || {}`);
57638
57666
  setEvaluated(gen, to, from);
57639
57667
  }
57640
57668
  }),
@@ -57642,8 +57670,8 @@ util.mergeEvaluated = {
57642
57670
  resultToName: evaluatedPropsToName
57643
57671
  }),
57644
57672
  items: makeMergeEvaluated({
57645
- 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}`)),
57646
- 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}`)),
57673
+ 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}`)),
57674
+ 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}`)),
57647
57675
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
57648
57676
  resultToName: (gen, items2) => gen.var("items", items2)
57649
57677
  })
@@ -57651,21 +57679,21 @@ util.mergeEvaluated = {
57651
57679
  function evaluatedPropsToName(gen, ps) {
57652
57680
  if (ps === true)
57653
57681
  return gen.var("props", true);
57654
- const props = gen.var("props", (0, codegen_1$v._)`{}`);
57682
+ const props = gen.var("props", (0, codegen_1$q._)`{}`);
57655
57683
  if (ps !== void 0)
57656
57684
  setEvaluated(gen, props, ps);
57657
57685
  return props;
57658
57686
  }
57659
57687
  util.evaluatedPropsToName = evaluatedPropsToName;
57660
57688
  function setEvaluated(gen, props, ps) {
57661
- Object.keys(ps).forEach((p2) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p2)}`, true));
57689
+ Object.keys(ps).forEach((p2) => gen.assign((0, codegen_1$q._)`${props}${(0, codegen_1$q.getProperty)(p2)}`, true));
57662
57690
  }
57663
57691
  util.setEvaluated = setEvaluated;
57664
57692
  const snippets = {};
57665
57693
  function useFunc(gen, f) {
57666
57694
  return gen.scopeValue("func", {
57667
57695
  ref: f,
57668
- code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
57696
+ code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
57669
57697
  });
57670
57698
  }
57671
57699
  util.useFunc = useFunc;
@@ -57675,11 +57703,11 @@ var Type;
57675
57703
  Type2[Type2["Str"] = 1] = "Str";
57676
57704
  })(Type || (util.Type = Type = {}));
57677
57705
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
57678
- if (dataProp instanceof codegen_1$v.Name) {
57706
+ if (dataProp instanceof codegen_1$q.Name) {
57679
57707
  const isNumber = dataPropType === Type.Num;
57680
- 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")`;
57708
+ 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")`;
57681
57709
  }
57682
- return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
57710
+ return jsPropertySyntax ? (0, codegen_1$q.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
57683
57711
  }
57684
57712
  util.getErrorPath = getErrorPath;
57685
57713
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -57693,35 +57721,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
57693
57721
  util.checkStrictMode = checkStrictMode;
57694
57722
  var names$1 = {};
57695
57723
  Object.defineProperty(names$1, "__esModule", { value: true });
57696
- const codegen_1$u = codegen;
57724
+ const codegen_1$p = codegen;
57697
57725
  const names = {
57698
57726
  // validation function arguments
57699
- data: new codegen_1$u.Name("data"),
57727
+ data: new codegen_1$p.Name("data"),
57700
57728
  // data passed to validation function
57701
57729
  // args passed from referencing schema
57702
- valCxt: new codegen_1$u.Name("valCxt"),
57730
+ valCxt: new codegen_1$p.Name("valCxt"),
57703
57731
  // validation/data context - should not be used directly, it is destructured to the names below
57704
- instancePath: new codegen_1$u.Name("instancePath"),
57705
- parentData: new codegen_1$u.Name("parentData"),
57706
- parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
57707
- rootData: new codegen_1$u.Name("rootData"),
57732
+ instancePath: new codegen_1$p.Name("instancePath"),
57733
+ parentData: new codegen_1$p.Name("parentData"),
57734
+ parentDataProperty: new codegen_1$p.Name("parentDataProperty"),
57735
+ rootData: new codegen_1$p.Name("rootData"),
57708
57736
  // root data - same as the data passed to the first/top validation function
57709
- dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
57737
+ dynamicAnchors: new codegen_1$p.Name("dynamicAnchors"),
57710
57738
  // used to support recursiveRef and dynamicRef
57711
57739
  // function scoped variables
57712
- vErrors: new codegen_1$u.Name("vErrors"),
57740
+ vErrors: new codegen_1$p.Name("vErrors"),
57713
57741
  // null or array of validation errors
57714
- errors: new codegen_1$u.Name("errors"),
57742
+ errors: new codegen_1$p.Name("errors"),
57715
57743
  // counter of validation errors
57716
- this: new codegen_1$u.Name("this"),
57744
+ this: new codegen_1$p.Name("this"),
57717
57745
  // "globals"
57718
- self: new codegen_1$u.Name("self"),
57719
- scope: new codegen_1$u.Name("scope"),
57746
+ self: new codegen_1$p.Name("self"),
57747
+ scope: new codegen_1$p.Name("scope"),
57720
57748
  // JTD serialize/parse name for JSON string and position
57721
- json: new codegen_1$u.Name("json"),
57722
- jsonPos: new codegen_1$u.Name("jsonPos"),
57723
- jsonLen: new codegen_1$u.Name("jsonLen"),
57724
- jsonPart: new codegen_1$u.Name("jsonPart")
57749
+ json: new codegen_1$p.Name("json"),
57750
+ jsonPos: new codegen_1$p.Name("jsonPos"),
57751
+ jsonLen: new codegen_1$p.Name("jsonLen"),
57752
+ jsonPart: new codegen_1$p.Name("jsonPart")
57725
57753
  };
57726
57754
  names$1.default = names;
57727
57755
  (function(exports$1) {
@@ -57841,49 +57869,55 @@ names$1.default = names;
57841
57869
  keyValues.push([E.propertyName, propertyName2]);
57842
57870
  }
57843
57871
  })(errors);
57844
- Object.defineProperty(boolSchema, "__esModule", { value: true });
57845
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
57846
- const errors_1$3 = errors;
57847
- const codegen_1$t = codegen;
57848
- const names_1$6 = names$1;
57849
- const boolError = {
57850
- message: "boolean schema is false"
57851
- };
57852
- function topBoolOrEmptySchema(it) {
57853
- const { gen, schema, validateName: validateName2 } = it;
57854
- if (schema === false) {
57855
- falseSchemaError(it, false);
57856
- } else if (typeof schema == "object" && schema.$async === true) {
57857
- gen.return(names_1$6.default.data);
57858
- } else {
57859
- gen.assign((0, codegen_1$t._)`${validateName2}.errors`, null);
57860
- gen.return(true);
57872
+ var hasRequiredBoolSchema;
57873
+ function requireBoolSchema() {
57874
+ if (hasRequiredBoolSchema) return boolSchema;
57875
+ hasRequiredBoolSchema = 1;
57876
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
57877
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
57878
+ const errors_12 = errors;
57879
+ const codegen_12 = codegen;
57880
+ const names_12 = names$1;
57881
+ const boolError = {
57882
+ message: "boolean schema is false"
57883
+ };
57884
+ function topBoolOrEmptySchema(it) {
57885
+ const { gen, schema, validateName: validateName2 } = it;
57886
+ if (schema === false) {
57887
+ falseSchemaError(it, false);
57888
+ } else if (typeof schema == "object" && schema.$async === true) {
57889
+ gen.return(names_12.default.data);
57890
+ } else {
57891
+ gen.assign((0, codegen_12._)`${validateName2}.errors`, null);
57892
+ gen.return(true);
57893
+ }
57861
57894
  }
57862
- }
57863
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
57864
- function boolOrEmptySchema(it, valid) {
57865
- const { gen, schema } = it;
57866
- if (schema === false) {
57867
- gen.var(valid, false);
57868
- falseSchemaError(it);
57869
- } else {
57870
- gen.var(valid, true);
57895
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
57896
+ function boolOrEmptySchema(it, valid) {
57897
+ const { gen, schema } = it;
57898
+ if (schema === false) {
57899
+ gen.var(valid, false);
57900
+ falseSchemaError(it);
57901
+ } else {
57902
+ gen.var(valid, true);
57903
+ }
57904
+ }
57905
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
57906
+ function falseSchemaError(it, overrideAllErrors) {
57907
+ const { gen, data } = it;
57908
+ const cxt = {
57909
+ gen,
57910
+ keyword: "false schema",
57911
+ data,
57912
+ schema: false,
57913
+ schemaCode: false,
57914
+ schemaValue: false,
57915
+ params: {},
57916
+ it
57917
+ };
57918
+ (0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
57871
57919
  }
57872
- }
57873
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
57874
- function falseSchemaError(it, overrideAllErrors) {
57875
- const { gen, data } = it;
57876
- const cxt = {
57877
- gen,
57878
- keyword: "false schema",
57879
- data,
57880
- schema: false,
57881
- schemaCode: false,
57882
- schemaValue: false,
57883
- params: {},
57884
- it
57885
- };
57886
- (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
57920
+ return boolSchema;
57887
57921
  }
57888
57922
  var dataType = {};
57889
57923
  var rules = {};
@@ -57931,10 +57965,10 @@ applicability.shouldUseRule = shouldUseRule;
57931
57965
  Object.defineProperty(dataType, "__esModule", { value: true });
57932
57966
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
57933
57967
  const rules_1 = rules;
57934
- const applicability_1$1 = applicability;
57935
- const errors_1$2 = errors;
57936
- const codegen_1$s = codegen;
57937
- const util_1$r = util;
57968
+ const applicability_1 = applicability;
57969
+ const errors_1 = errors;
57970
+ const codegen_1$o = codegen;
57971
+ const util_1$o = util;
57938
57972
  var DataType;
57939
57973
  (function(DataType2) {
57940
57974
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -57966,7 +58000,7 @@ dataType.getJSONTypes = getJSONTypes;
57966
58000
  function coerceAndCheckDataType(it, types2) {
57967
58001
  const { gen, data, opts } = it;
57968
58002
  const coerceTo = coerceToTypes(types2, opts.coerceTypes);
57969
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
58003
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
57970
58004
  if (checkTypes) {
57971
58005
  const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
57972
58006
  gen.if(wrongType, () => {
@@ -57985,12 +58019,12 @@ function coerceToTypes(types2, coerceTypes) {
57985
58019
  }
57986
58020
  function coerceData(it, types2, coerceTo) {
57987
58021
  const { gen, data, opts } = it;
57988
- const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
57989
- const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
58022
+ const dataType2 = gen.let("dataType", (0, codegen_1$o._)`typeof ${data}`);
58023
+ const coerced = gen.let("coerced", (0, codegen_1$o._)`undefined`);
57990
58024
  if (opts.coerceTypes === "array") {
57991
- 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)));
58025
+ 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)));
57992
58026
  }
57993
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
58027
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
57994
58028
  for (const t2 of coerceTo) {
57995
58029
  if (COERCIBLE.has(t2) || t2 === "array" && opts.coerceTypes === "array") {
57996
58030
  coerceSpecificType(t2);
@@ -57999,63 +58033,63 @@ function coerceData(it, types2, coerceTo) {
57999
58033
  gen.else();
58000
58034
  reportTypeError(it);
58001
58035
  gen.endIf();
58002
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
58036
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
58003
58037
  gen.assign(data, coerced);
58004
58038
  assignParentData(it, coerced);
58005
58039
  });
58006
58040
  function coerceSpecificType(t2) {
58007
58041
  switch (t2) {
58008
58042
  case "string":
58009
- 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._)`""`);
58043
+ 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._)`""`);
58010
58044
  return;
58011
58045
  case "number":
58012
- gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
58013
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
58046
+ gen.elseIf((0, codegen_1$o._)`${dataType2} == "boolean" || ${data} === null
58047
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$o._)`+${data}`);
58014
58048
  return;
58015
58049
  case "integer":
58016
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
58017
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
58050
+ gen.elseIf((0, codegen_1$o._)`${dataType2} === "boolean" || ${data} === null
58051
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$o._)`+${data}`);
58018
58052
  return;
58019
58053
  case "boolean":
58020
- 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);
58054
+ 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);
58021
58055
  return;
58022
58056
  case "null":
58023
- gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
58057
+ gen.elseIf((0, codegen_1$o._)`${data} === "" || ${data} === 0 || ${data} === false`);
58024
58058
  gen.assign(coerced, null);
58025
58059
  return;
58026
58060
  case "array":
58027
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
58028
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
58061
+ gen.elseIf((0, codegen_1$o._)`${dataType2} === "string" || ${dataType2} === "number"
58062
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$o._)`[${data}]`);
58029
58063
  }
58030
58064
  }
58031
58065
  }
58032
58066
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
58033
- gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
58067
+ gen.if((0, codegen_1$o._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$o._)`${parentData}[${parentDataProperty}]`, expr));
58034
58068
  }
58035
58069
  function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
58036
- const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
58070
+ const EQ = correct === DataType.Correct ? codegen_1$o.operators.EQ : codegen_1$o.operators.NEQ;
58037
58071
  let cond;
58038
58072
  switch (dataType2) {
58039
58073
  case "null":
58040
- return (0, codegen_1$s._)`${data} ${EQ} null`;
58074
+ return (0, codegen_1$o._)`${data} ${EQ} null`;
58041
58075
  case "array":
58042
- cond = (0, codegen_1$s._)`Array.isArray(${data})`;
58076
+ cond = (0, codegen_1$o._)`Array.isArray(${data})`;
58043
58077
  break;
58044
58078
  case "object":
58045
- cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
58079
+ cond = (0, codegen_1$o._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
58046
58080
  break;
58047
58081
  case "integer":
58048
- cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
58082
+ cond = numCond((0, codegen_1$o._)`!(${data} % 1) && !isNaN(${data})`);
58049
58083
  break;
58050
58084
  case "number":
58051
58085
  cond = numCond();
58052
58086
  break;
58053
58087
  default:
58054
- return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
58088
+ return (0, codegen_1$o._)`typeof ${data} ${EQ} ${dataType2}`;
58055
58089
  }
58056
- return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
58057
- function numCond(_cond = codegen_1$s.nil) {
58058
- 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);
58090
+ return correct === DataType.Correct ? cond : (0, codegen_1$o.not)(cond);
58091
+ function numCond(_cond = codegen_1$o.nil) {
58092
+ 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);
58059
58093
  }
58060
58094
  }
58061
58095
  dataType.checkDataType = checkDataType;
@@ -58064,35 +58098,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
58064
58098
  return checkDataType(dataTypes[0], data, strictNums, correct);
58065
58099
  }
58066
58100
  let cond;
58067
- const types2 = (0, util_1$r.toHash)(dataTypes);
58101
+ const types2 = (0, util_1$o.toHash)(dataTypes);
58068
58102
  if (types2.array && types2.object) {
58069
- const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
58070
- cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
58103
+ const notObj = (0, codegen_1$o._)`typeof ${data} != "object"`;
58104
+ cond = types2.null ? notObj : (0, codegen_1$o._)`!${data} || ${notObj}`;
58071
58105
  delete types2.null;
58072
58106
  delete types2.array;
58073
58107
  delete types2.object;
58074
58108
  } else {
58075
- cond = codegen_1$s.nil;
58109
+ cond = codegen_1$o.nil;
58076
58110
  }
58077
58111
  if (types2.number)
58078
58112
  delete types2.integer;
58079
58113
  for (const t2 in types2)
58080
- cond = (0, codegen_1$s.and)(cond, checkDataType(t2, data, strictNums, correct));
58114
+ cond = (0, codegen_1$o.and)(cond, checkDataType(t2, data, strictNums, correct));
58081
58115
  return cond;
58082
58116
  }
58083
58117
  dataType.checkDataTypes = checkDataTypes;
58084
58118
  const typeError = {
58085
58119
  message: ({ schema }) => `must be ${schema}`,
58086
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
58120
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$o._)`{type: ${schema}}` : (0, codegen_1$o._)`{type: ${schemaValue}}`
58087
58121
  };
58088
58122
  function reportTypeError(it) {
58089
58123
  const cxt = getTypeErrorContext(it);
58090
- (0, errors_1$2.reportError)(cxt, typeError);
58124
+ (0, errors_1.reportError)(cxt, typeError);
58091
58125
  }
58092
58126
  dataType.reportTypeError = reportTypeError;
58093
58127
  function getTypeErrorContext(it) {
58094
58128
  const { gen, data, schema } = it;
58095
- const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
58129
+ const schemaCode = (0, util_1$o.schemaRefOrVal)(it, schema, "type");
58096
58130
  return {
58097
58131
  gen,
58098
58132
  keyword: "type",
@@ -58106,54 +58140,60 @@ function getTypeErrorContext(it) {
58106
58140
  };
58107
58141
  }
58108
58142
  var defaults = {};
58109
- Object.defineProperty(defaults, "__esModule", { value: true });
58110
- defaults.assignDefaults = void 0;
58111
- const codegen_1$r = codegen;
58112
- const util_1$q = util;
58113
- function assignDefaults(it, ty) {
58114
- const { properties: properties2, items: items2 } = it.schema;
58115
- if (ty === "object" && properties2) {
58116
- for (const key in properties2) {
58117
- assignDefault(it, key, properties2[key].default);
58118
- }
58119
- } else if (ty === "array" && Array.isArray(items2)) {
58120
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
58121
- }
58122
- }
58123
- defaults.assignDefaults = assignDefaults;
58124
- function assignDefault(it, prop, defaultValue) {
58125
- const { gen, compositeRule, data, opts } = it;
58126
- if (defaultValue === void 0)
58127
- return;
58128
- const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
58129
- if (compositeRule) {
58130
- (0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
58131
- return;
58143
+ var hasRequiredDefaults;
58144
+ function requireDefaults() {
58145
+ if (hasRequiredDefaults) return defaults;
58146
+ hasRequiredDefaults = 1;
58147
+ Object.defineProperty(defaults, "__esModule", { value: true });
58148
+ defaults.assignDefaults = void 0;
58149
+ const codegen_12 = codegen;
58150
+ const util_12 = util;
58151
+ function assignDefaults(it, ty) {
58152
+ const { properties: properties2, items: items2 } = it.schema;
58153
+ if (ty === "object" && properties2) {
58154
+ for (const key in properties2) {
58155
+ assignDefault(it, key, properties2[key].default);
58156
+ }
58157
+ } else if (ty === "array" && Array.isArray(items2)) {
58158
+ items2.forEach((sch, i) => assignDefault(it, i, sch.default));
58159
+ }
58132
58160
  }
58133
- let condition = (0, codegen_1$r._)`${childData} === undefined`;
58134
- if (opts.useDefaults === "empty") {
58135
- condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
58161
+ defaults.assignDefaults = assignDefaults;
58162
+ function assignDefault(it, prop, defaultValue) {
58163
+ const { gen, compositeRule, data, opts } = it;
58164
+ if (defaultValue === void 0)
58165
+ return;
58166
+ const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
58167
+ if (compositeRule) {
58168
+ (0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
58169
+ return;
58170
+ }
58171
+ let condition = (0, codegen_12._)`${childData} === undefined`;
58172
+ if (opts.useDefaults === "empty") {
58173
+ condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
58174
+ }
58175
+ gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
58136
58176
  }
58137
- gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
58177
+ return defaults;
58138
58178
  }
58139
58179
  var keyword = {};
58140
58180
  var code = {};
58141
58181
  Object.defineProperty(code, "__esModule", { value: true });
58142
58182
  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;
58143
- const codegen_1$q = codegen;
58144
- const util_1$p = util;
58145
- const names_1$5 = names$1;
58183
+ const codegen_1$n = codegen;
58184
+ const util_1$n = util;
58185
+ const names_1$3 = names$1;
58146
58186
  const util_2$1 = util;
58147
58187
  function checkReportMissingProp(cxt, prop) {
58148
58188
  const { gen, data, it } = cxt;
58149
58189
  gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
58150
- cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
58190
+ cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
58151
58191
  cxt.error();
58152
58192
  });
58153
58193
  }
58154
58194
  code.checkReportMissingProp = checkReportMissingProp;
58155
58195
  function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
58156
- 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}`)));
58196
+ 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}`)));
58157
58197
  }
58158
58198
  code.checkMissingProp = checkMissingProp;
58159
58199
  function reportMissingProp(cxt, missing) {
@@ -58165,22 +58205,22 @@ function hasPropFunc(gen) {
58165
58205
  return gen.scopeValue("func", {
58166
58206
  // eslint-disable-next-line @typescript-eslint/unbound-method
58167
58207
  ref: Object.prototype.hasOwnProperty,
58168
- code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
58208
+ code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
58169
58209
  });
58170
58210
  }
58171
58211
  code.hasPropFunc = hasPropFunc;
58172
58212
  function isOwnProperty(gen, data, property) {
58173
- return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
58213
+ return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
58174
58214
  }
58175
58215
  code.isOwnProperty = isOwnProperty;
58176
58216
  function propertyInData(gen, data, property, ownProperties) {
58177
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
58178
- return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
58217
+ const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} !== undefined`;
58218
+ return ownProperties ? (0, codegen_1$n._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
58179
58219
  }
58180
58220
  code.propertyInData = propertyInData;
58181
58221
  function noPropertyInData(gen, data, property, ownProperties) {
58182
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
58183
- return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond;
58222
+ const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} === undefined`;
58223
+ return ownProperties ? (0, codegen_1$n.or)(cond, (0, codegen_1$n.not)(isOwnProperty(gen, data, property))) : cond;
58184
58224
  }
58185
58225
  code.noPropertyInData = noPropertyInData;
58186
58226
  function allSchemaProperties(schemaMap) {
@@ -58188,24 +58228,24 @@ function allSchemaProperties(schemaMap) {
58188
58228
  }
58189
58229
  code.allSchemaProperties = allSchemaProperties;
58190
58230
  function schemaProperties(it, schemaMap) {
58191
- return allSchemaProperties(schemaMap).filter((p2) => !(0, util_1$p.alwaysValidSchema)(it, schemaMap[p2]));
58231
+ return allSchemaProperties(schemaMap).filter((p2) => !(0, util_1$n.alwaysValidSchema)(it, schemaMap[p2]));
58192
58232
  }
58193
58233
  code.schemaProperties = schemaProperties;
58194
58234
  function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
58195
- const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
58235
+ const dataAndSchema = passSchema ? (0, codegen_1$n._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
58196
58236
  const valCxt = [
58197
- [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
58198
- [names_1$5.default.parentData, it.parentData],
58199
- [names_1$5.default.parentDataProperty, it.parentDataProperty],
58200
- [names_1$5.default.rootData, names_1$5.default.rootData]
58237
+ [names_1$3.default.instancePath, (0, codegen_1$n.strConcat)(names_1$3.default.instancePath, errorPath)],
58238
+ [names_1$3.default.parentData, it.parentData],
58239
+ [names_1$3.default.parentDataProperty, it.parentDataProperty],
58240
+ [names_1$3.default.rootData, names_1$3.default.rootData]
58201
58241
  ];
58202
58242
  if (it.opts.dynamicRef)
58203
- valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
58204
- const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
58205
- return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
58243
+ valCxt.push([names_1$3.default.dynamicAnchors, names_1$3.default.dynamicAnchors]);
58244
+ const args = (0, codegen_1$n._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
58245
+ return context !== codegen_1$n.nil ? (0, codegen_1$n._)`${func}.call(${context}, ${args})` : (0, codegen_1$n._)`${func}(${args})`;
58206
58246
  }
58207
58247
  code.callValidateCode = callValidateCode;
58208
- const newRegExp = (0, codegen_1$q._)`new RegExp`;
58248
+ const newRegExp = (0, codegen_1$n._)`new RegExp`;
58209
58249
  function usePattern({ gen, it: { opts } }, pattern2) {
58210
58250
  const u = opts.unicodeRegExp ? "u" : "";
58211
58251
  const { regExp } = opts.code;
@@ -58213,7 +58253,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
58213
58253
  return gen.scopeValue("pattern", {
58214
58254
  key: rx.toString(),
58215
58255
  ref: rx,
58216
- code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
58256
+ code: (0, codegen_1$n._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
58217
58257
  });
58218
58258
  }
58219
58259
  code.usePattern = usePattern;
@@ -58229,14 +58269,14 @@ function validateArray(cxt) {
58229
58269
  validateItems(() => gen.break());
58230
58270
  return valid;
58231
58271
  function validateItems(notValid) {
58232
- const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
58272
+ const len = gen.const("len", (0, codegen_1$n._)`${data}.length`);
58233
58273
  gen.forRange("i", 0, len, (i) => {
58234
58274
  cxt.subschema({
58235
58275
  keyword: keyword2,
58236
58276
  dataProp: i,
58237
- dataPropType: util_1$p.Type.Num
58277
+ dataPropType: util_1$n.Type.Num
58238
58278
  }, valid);
58239
- gen.if((0, codegen_1$q.not)(valid), notValid);
58279
+ gen.if((0, codegen_1$n.not)(valid), notValid);
58240
58280
  });
58241
58281
  }
58242
58282
  }
@@ -58245,7 +58285,7 @@ function validateUnion(cxt) {
58245
58285
  const { gen, schema, keyword: keyword2, it } = cxt;
58246
58286
  if (!Array.isArray(schema))
58247
58287
  throw new Error("ajv implementation error");
58248
- const alwaysValid = schema.some((sch) => (0, util_1$p.alwaysValidSchema)(it, sch));
58288
+ const alwaysValid = schema.some((sch) => (0, util_1$n.alwaysValidSchema)(it, sch));
58249
58289
  if (alwaysValid && !it.opts.unevaluated)
58250
58290
  return;
58251
58291
  const valid = gen.let("valid", false);
@@ -58256,202 +58296,214 @@ function validateUnion(cxt) {
58256
58296
  schemaProp: i,
58257
58297
  compositeRule: true
58258
58298
  }, schValid);
58259
- gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
58299
+ gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
58260
58300
  const merged = cxt.mergeValidEvaluated(schCxt, schValid);
58261
58301
  if (!merged)
58262
- gen.if((0, codegen_1$q.not)(valid));
58302
+ gen.if((0, codegen_1$n.not)(valid));
58263
58303
  }));
58264
58304
  cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
58265
58305
  }
58266
58306
  code.validateUnion = validateUnion;
58267
- Object.defineProperty(keyword, "__esModule", { value: true });
58268
- keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
58269
- const codegen_1$p = codegen;
58270
- const names_1$4 = names$1;
58271
- const code_1$9 = code;
58272
- const errors_1$1 = errors;
58273
- function macroKeywordCode(cxt, def2) {
58274
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
58275
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
58276
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
58277
- if (it.opts.validateSchema !== false)
58278
- it.self.validateSchema(macroSchema, true);
58279
- const valid = gen.name("valid");
58280
- cxt.subschema({
58281
- schema: macroSchema,
58282
- schemaPath: codegen_1$p.nil,
58283
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
58284
- topSchemaRef: schemaRef,
58285
- compositeRule: true
58286
- }, valid);
58287
- cxt.pass(valid, () => cxt.error(true));
58288
- }
58289
- keyword.macroKeywordCode = macroKeywordCode;
58290
- function funcKeywordCode(cxt, def2) {
58291
- var _a2;
58292
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
58293
- checkAsyncKeyword(it, def2);
58294
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
58295
- const validateRef = useKeyword(gen, keyword2, validate2);
58296
- const valid = gen.let("valid");
58297
- cxt.block$data(valid, validateKeyword);
58298
- cxt.ok((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid);
58299
- function validateKeyword() {
58300
- if (def2.errors === false) {
58301
- assignValid();
58302
- if (def2.modifying)
58303
- modifyData(cxt);
58304
- reportErrs(() => cxt.error());
58305
- } else {
58306
- const ruleErrs = def2.async ? validateAsync() : validateSync();
58307
- if (def2.modifying)
58308
- modifyData(cxt);
58309
- reportErrs(() => addErrs(cxt, ruleErrs));
58310
- }
58311
- }
58312
- function validateAsync() {
58313
- const ruleErrs = gen.let("ruleErrs", null);
58314
- 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)));
58315
- return ruleErrs;
58316
- }
58317
- function validateSync() {
58318
- const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
58319
- gen.assign(validateErrs, null);
58320
- assignValid(codegen_1$p.nil);
58321
- return validateErrs;
58322
- }
58323
- function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
58324
- const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
58325
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
58326
- gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
58327
- }
58328
- function reportErrs(errors2) {
58329
- var _a3;
58330
- gen.if((0, codegen_1$p.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
58331
- }
58332
- }
58333
- keyword.funcKeywordCode = funcKeywordCode;
58334
- function modifyData(cxt) {
58335
- const { gen, data, it } = cxt;
58336
- gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
58337
- }
58338
- function addErrs(cxt, errs) {
58339
- const { gen } = cxt;
58340
- gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
58341
- 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`);
58342
- (0, errors_1$1.extendErrors)(cxt);
58343
- }, () => cxt.error());
58344
- }
58345
- function checkAsyncKeyword({ schemaEnv }, def2) {
58346
- if (def2.async && !schemaEnv.$async)
58347
- throw new Error("async keyword in sync schema");
58348
- }
58349
- function useKeyword(gen, keyword2, result) {
58350
- if (result === void 0)
58351
- throw new Error(`keyword "${keyword2}" failed to compile`);
58352
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
58353
- }
58354
- function validSchemaType(schema, schemaType, allowUndefined = false) {
58355
- 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");
58356
- }
58357
- keyword.validSchemaType = validSchemaType;
58358
- function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
58359
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
58360
- throw new Error("ajv implementation error");
58307
+ var hasRequiredKeyword;
58308
+ function requireKeyword() {
58309
+ if (hasRequiredKeyword) return keyword;
58310
+ hasRequiredKeyword = 1;
58311
+ Object.defineProperty(keyword, "__esModule", { value: true });
58312
+ keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
58313
+ const codegen_12 = codegen;
58314
+ const names_12 = names$1;
58315
+ const code_12 = code;
58316
+ const errors_12 = errors;
58317
+ function macroKeywordCode(cxt, def2) {
58318
+ const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
58319
+ const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
58320
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
58321
+ if (it.opts.validateSchema !== false)
58322
+ it.self.validateSchema(macroSchema, true);
58323
+ const valid = gen.name("valid");
58324
+ cxt.subschema({
58325
+ schema: macroSchema,
58326
+ schemaPath: codegen_12.nil,
58327
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
58328
+ topSchemaRef: schemaRef,
58329
+ compositeRule: true
58330
+ }, valid);
58331
+ cxt.pass(valid, () => cxt.error(true));
58361
58332
  }
58362
- const deps = def2.dependencies;
58363
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
58364
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
58333
+ keyword.macroKeywordCode = macroKeywordCode;
58334
+ function funcKeywordCode(cxt, def2) {
58335
+ var _a2;
58336
+ const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
58337
+ checkAsyncKeyword(it, def2);
58338
+ const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
58339
+ const validateRef = useKeyword(gen, keyword2, validate2);
58340
+ const valid = gen.let("valid");
58341
+ cxt.block$data(valid, validateKeyword);
58342
+ cxt.ok((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid);
58343
+ function validateKeyword() {
58344
+ if (def2.errors === false) {
58345
+ assignValid();
58346
+ if (def2.modifying)
58347
+ modifyData(cxt);
58348
+ reportErrs(() => cxt.error());
58349
+ } else {
58350
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
58351
+ if (def2.modifying)
58352
+ modifyData(cxt);
58353
+ reportErrs(() => addErrs(cxt, ruleErrs));
58354
+ }
58355
+ }
58356
+ function validateAsync() {
58357
+ const ruleErrs = gen.let("ruleErrs", null);
58358
+ 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)));
58359
+ return ruleErrs;
58360
+ }
58361
+ function validateSync() {
58362
+ const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
58363
+ gen.assign(validateErrs, null);
58364
+ assignValid(codegen_12.nil);
58365
+ return validateErrs;
58366
+ }
58367
+ function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
58368
+ const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
58369
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
58370
+ gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
58371
+ }
58372
+ function reportErrs(errors2) {
58373
+ var _a3;
58374
+ gen.if((0, codegen_12.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
58375
+ }
58365
58376
  }
58366
- if (def2.validateSchema) {
58367
- const valid = def2.validateSchema(schema[keyword2]);
58368
- if (!valid) {
58369
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
58370
- if (opts.validateSchema === "log")
58371
- self.logger.error(msg);
58372
- else
58373
- throw new Error(msg);
58377
+ keyword.funcKeywordCode = funcKeywordCode;
58378
+ function modifyData(cxt) {
58379
+ const { gen, data, it } = cxt;
58380
+ gen.if(it.parentData, () => gen.assign(data, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
58381
+ }
58382
+ function addErrs(cxt, errs) {
58383
+ const { gen } = cxt;
58384
+ gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
58385
+ 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`);
58386
+ (0, errors_12.extendErrors)(cxt);
58387
+ }, () => cxt.error());
58388
+ }
58389
+ function checkAsyncKeyword({ schemaEnv }, def2) {
58390
+ if (def2.async && !schemaEnv.$async)
58391
+ throw new Error("async keyword in sync schema");
58392
+ }
58393
+ function useKeyword(gen, keyword2, result) {
58394
+ if (result === void 0)
58395
+ throw new Error(`keyword "${keyword2}" failed to compile`);
58396
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
58397
+ }
58398
+ function validSchemaType(schema, schemaType, allowUndefined = false) {
58399
+ 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");
58400
+ }
58401
+ keyword.validSchemaType = validSchemaType;
58402
+ function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
58403
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
58404
+ throw new Error("ajv implementation error");
58405
+ }
58406
+ const deps = def2.dependencies;
58407
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
58408
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
58409
+ }
58410
+ if (def2.validateSchema) {
58411
+ const valid = def2.validateSchema(schema[keyword2]);
58412
+ if (!valid) {
58413
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
58414
+ if (opts.validateSchema === "log")
58415
+ self.logger.error(msg);
58416
+ else
58417
+ throw new Error(msg);
58418
+ }
58374
58419
  }
58375
58420
  }
58421
+ keyword.validateKeywordUsage = validateKeywordUsage;
58422
+ return keyword;
58376
58423
  }
58377
- keyword.validateKeywordUsage = validateKeywordUsage;
58378
58424
  var subschema = {};
58379
- Object.defineProperty(subschema, "__esModule", { value: true });
58380
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
58381
- const codegen_1$o = codegen;
58382
- const util_1$o = util;
58383
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
58384
- if (keyword2 !== void 0 && schema !== void 0) {
58385
- throw new Error('both "keyword" and "schema" passed, only one allowed');
58386
- }
58387
- if (keyword2 !== void 0) {
58388
- const sch = it.schema[keyword2];
58389
- return schemaProp === void 0 ? {
58390
- schema: sch,
58391
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
58392
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
58393
- } : {
58394
- schema: sch[schemaProp],
58395
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
58396
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
58397
- };
58398
- }
58399
- if (schema !== void 0) {
58400
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
58401
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
58425
+ var hasRequiredSubschema;
58426
+ function requireSubschema() {
58427
+ if (hasRequiredSubschema) return subschema;
58428
+ hasRequiredSubschema = 1;
58429
+ Object.defineProperty(subschema, "__esModule", { value: true });
58430
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
58431
+ const codegen_12 = codegen;
58432
+ const util_12 = util;
58433
+ function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
58434
+ if (keyword2 !== void 0 && schema !== void 0) {
58435
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
58402
58436
  }
58403
- return {
58404
- schema,
58405
- schemaPath,
58406
- topSchemaRef,
58407
- errSchemaPath
58408
- };
58409
- }
58410
- throw new Error('either "keyword" or "schema" must be passed');
58411
- }
58412
- subschema.getSubschema = getSubschema;
58413
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName: propertyName2 }) {
58414
- if (data !== void 0 && dataProp !== void 0) {
58415
- throw new Error('both "data" and "dataProp" passed, only one allowed');
58416
- }
58417
- const { gen } = it;
58418
- if (dataProp !== void 0) {
58419
- const { errorPath, dataPathArr, opts } = it;
58420
- const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
58421
- dataContextProps(nextData);
58422
- subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
58423
- subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
58424
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
58425
- }
58426
- if (data !== void 0) {
58427
- const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
58428
- dataContextProps(nextData);
58429
- if (propertyName2 !== void 0)
58430
- subschema2.propertyName = propertyName2;
58431
- }
58432
- if (dataTypes)
58433
- subschema2.dataTypes = dataTypes;
58434
- function dataContextProps(_nextData) {
58435
- subschema2.data = _nextData;
58436
- subschema2.dataLevel = it.dataLevel + 1;
58437
- subschema2.dataTypes = [];
58438
- it.definedProperties = /* @__PURE__ */ new Set();
58439
- subschema2.parentData = it.data;
58440
- subschema2.dataNames = [...it.dataNames, _nextData];
58441
- }
58442
- }
58443
- subschema.extendSubschemaData = extendSubschemaData;
58444
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
58445
- if (compositeRule !== void 0)
58446
- subschema2.compositeRule = compositeRule;
58447
- if (createErrors !== void 0)
58448
- subschema2.createErrors = createErrors;
58449
- if (allErrors !== void 0)
58450
- subschema2.allErrors = allErrors;
58451
- subschema2.jtdDiscriminator = jtdDiscriminator;
58452
- subschema2.jtdMetadata = jtdMetadata;
58453
- }
58454
- subschema.extendSubschemaMode = extendSubschemaMode;
58437
+ if (keyword2 !== void 0) {
58438
+ const sch = it.schema[keyword2];
58439
+ return schemaProp === void 0 ? {
58440
+ schema: sch,
58441
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
58442
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`
58443
+ } : {
58444
+ schema: sch[schemaProp],
58445
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
58446
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
58447
+ };
58448
+ }
58449
+ if (schema !== void 0) {
58450
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
58451
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
58452
+ }
58453
+ return {
58454
+ schema,
58455
+ schemaPath,
58456
+ topSchemaRef,
58457
+ errSchemaPath
58458
+ };
58459
+ }
58460
+ throw new Error('either "keyword" or "schema" must be passed');
58461
+ }
58462
+ subschema.getSubschema = getSubschema;
58463
+ function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName: propertyName2 }) {
58464
+ if (data !== void 0 && dataProp !== void 0) {
58465
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
58466
+ }
58467
+ const { gen } = it;
58468
+ if (dataProp !== void 0) {
58469
+ const { errorPath, dataPathArr, opts } = it;
58470
+ const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
58471
+ dataContextProps(nextData);
58472
+ subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
58473
+ subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
58474
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
58475
+ }
58476
+ if (data !== void 0) {
58477
+ const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
58478
+ dataContextProps(nextData);
58479
+ if (propertyName2 !== void 0)
58480
+ subschema2.propertyName = propertyName2;
58481
+ }
58482
+ if (dataTypes)
58483
+ subschema2.dataTypes = dataTypes;
58484
+ function dataContextProps(_nextData) {
58485
+ subschema2.data = _nextData;
58486
+ subschema2.dataLevel = it.dataLevel + 1;
58487
+ subschema2.dataTypes = [];
58488
+ it.definedProperties = /* @__PURE__ */ new Set();
58489
+ subschema2.parentData = it.data;
58490
+ subschema2.dataNames = [...it.dataNames, _nextData];
58491
+ }
58492
+ }
58493
+ subschema.extendSubschemaData = extendSubschemaData;
58494
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
58495
+ if (compositeRule !== void 0)
58496
+ subschema2.compositeRule = compositeRule;
58497
+ if (createErrors !== void 0)
58498
+ subschema2.createErrors = createErrors;
58499
+ if (allErrors !== void 0)
58500
+ subschema2.allErrors = allErrors;
58501
+ subschema2.jtdDiscriminator = jtdDiscriminator;
58502
+ subschema2.jtdMetadata = jtdMetadata;
58503
+ }
58504
+ subschema.extendSubschemaMode = extendSubschemaMode;
58505
+ return subschema;
58506
+ }
58455
58507
  var resolve$2 = {};
58456
58508
  var fastDeepEqual = function equal(a, b) {
58457
58509
  if (a === b) return true;
@@ -58566,7 +58618,7 @@ function escapeJsonPtr(str) {
58566
58618
  var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
58567
58619
  Object.defineProperty(resolve$2, "__esModule", { value: true });
58568
58620
  resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
58569
- const util_1$n = util;
58621
+ const util_1$m = util;
58570
58622
  const equal$3 = fastDeepEqual;
58571
58623
  const traverse = jsonSchemaTraverseExports;
58572
58624
  const SIMPLE_INLINED = /* @__PURE__ */ new Set([
@@ -58625,7 +58677,7 @@ function countKeys(schema) {
58625
58677
  if (SIMPLE_INLINED.has(key))
58626
58678
  continue;
58627
58679
  if (typeof schema[key] == "object") {
58628
- (0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
58680
+ (0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys(sch));
58629
58681
  }
58630
58682
  if (count === Infinity)
58631
58683
  return Infinity;
@@ -58713,516 +58765,528 @@ function getSchemaRefs(schema, baseId) {
58713
58765
  }
58714
58766
  }
58715
58767
  resolve$2.getSchemaRefs = getSchemaRefs;
58716
- Object.defineProperty(validate, "__esModule", { value: true });
58717
- validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
58718
- const boolSchema_1 = boolSchema;
58719
- const dataType_1$1 = dataType;
58720
- const applicability_1 = applicability;
58721
- const dataType_2 = dataType;
58722
- const defaults_1 = defaults;
58723
- const keyword_1 = keyword;
58724
- const subschema_1 = subschema;
58725
- const codegen_1$n = codegen;
58726
- const names_1$3 = names$1;
58727
- const resolve_1$2 = resolve$2;
58728
- const util_1$m = util;
58729
- const errors_1 = errors;
58730
- function validateFunctionCode(it) {
58731
- if (isSchemaObj(it)) {
58732
- checkKeywords(it);
58733
- if (schemaCxtHasRules(it)) {
58734
- topSchemaObjCode(it);
58735
- return;
58768
+ var hasRequiredValidate;
58769
+ function requireValidate() {
58770
+ if (hasRequiredValidate) return validate;
58771
+ hasRequiredValidate = 1;
58772
+ Object.defineProperty(validate, "__esModule", { value: true });
58773
+ validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
58774
+ const boolSchema_1 = requireBoolSchema();
58775
+ const dataType_12 = dataType;
58776
+ const applicability_12 = applicability;
58777
+ const dataType_2 = dataType;
58778
+ const defaults_1 = requireDefaults();
58779
+ const keyword_1 = requireKeyword();
58780
+ const subschema_1 = requireSubschema();
58781
+ const codegen_12 = codegen;
58782
+ const names_12 = names$1;
58783
+ const resolve_12 = resolve$2;
58784
+ const util_12 = util;
58785
+ const errors_12 = errors;
58786
+ function validateFunctionCode(it) {
58787
+ if (isSchemaObj(it)) {
58788
+ checkKeywords(it);
58789
+ if (schemaCxtHasRules(it)) {
58790
+ topSchemaObjCode(it);
58791
+ return;
58792
+ }
58736
58793
  }
58794
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
58737
58795
  }
58738
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
58739
- }
58740
- validate.validateFunctionCode = validateFunctionCode;
58741
- function validateFunction({ gen, validateName: validateName2, schema, schemaEnv, opts }, body) {
58742
- if (opts.code.es5) {
58743
- gen.func(validateName2, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
58744
- gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
58745
- destructureValCxtES5(gen, opts);
58746
- gen.code(body);
58796
+ validate.validateFunctionCode = validateFunctionCode;
58797
+ function validateFunction({ gen, validateName: validateName2, schema, schemaEnv, opts }, body) {
58798
+ if (opts.code.es5) {
58799
+ gen.func(validateName2, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
58800
+ gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
58801
+ destructureValCxtES5(gen, opts);
58802
+ gen.code(body);
58803
+ });
58804
+ } else {
58805
+ gen.func(validateName2, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
58806
+ }
58807
+ }
58808
+ function destructureValCxt(opts) {
58809
+ 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}}={}`;
58810
+ }
58811
+ function destructureValCxtES5(gen, opts) {
58812
+ gen.if(names_12.default.valCxt, () => {
58813
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
58814
+ gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
58815
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
58816
+ gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
58817
+ if (opts.dynamicRef)
58818
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
58819
+ }, () => {
58820
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
58821
+ gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
58822
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
58823
+ gen.var(names_12.default.rootData, names_12.default.data);
58824
+ if (opts.dynamicRef)
58825
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
58747
58826
  });
58748
- } else {
58749
- gen.func(validateName2, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
58750
- }
58751
- }
58752
- function destructureValCxt(opts) {
58753
- 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}}={}`;
58754
- }
58755
- function destructureValCxtES5(gen, opts) {
58756
- gen.if(names_1$3.default.valCxt, () => {
58757
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
58758
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
58759
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
58760
- gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
58761
- if (opts.dynamicRef)
58762
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
58763
- }, () => {
58764
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
58765
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
58766
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
58767
- gen.var(names_1$3.default.rootData, names_1$3.default.data);
58768
- if (opts.dynamicRef)
58769
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
58770
- });
58771
- }
58772
- function topSchemaObjCode(it) {
58773
- const { schema, opts, gen } = it;
58774
- validateFunction(it, () => {
58827
+ }
58828
+ function topSchemaObjCode(it) {
58829
+ const { schema, opts, gen } = it;
58830
+ validateFunction(it, () => {
58831
+ if (opts.$comment && schema.$comment)
58832
+ commentKeyword(it);
58833
+ checkNoDefault(it);
58834
+ gen.let(names_12.default.vErrors, null);
58835
+ gen.let(names_12.default.errors, 0);
58836
+ if (opts.unevaluated)
58837
+ resetEvaluated(it);
58838
+ typeAndKeywords(it);
58839
+ returnResults(it);
58840
+ });
58841
+ return;
58842
+ }
58843
+ function resetEvaluated(it) {
58844
+ const { gen, validateName: validateName2 } = it;
58845
+ it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName2}.evaluated`);
58846
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
58847
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
58848
+ }
58849
+ function funcSourceUrl(schema, opts) {
58850
+ const schId = typeof schema == "object" && schema[opts.schemaId];
58851
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
58852
+ }
58853
+ function subschemaCode(it, valid) {
58854
+ if (isSchemaObj(it)) {
58855
+ checkKeywords(it);
58856
+ if (schemaCxtHasRules(it)) {
58857
+ subSchemaObjCode(it, valid);
58858
+ return;
58859
+ }
58860
+ }
58861
+ (0, boolSchema_1.boolOrEmptySchema)(it, valid);
58862
+ }
58863
+ function schemaCxtHasRules({ schema, self }) {
58864
+ if (typeof schema == "boolean")
58865
+ return !schema;
58866
+ for (const key in schema)
58867
+ if (self.RULES.all[key])
58868
+ return true;
58869
+ return false;
58870
+ }
58871
+ function isSchemaObj(it) {
58872
+ return typeof it.schema != "boolean";
58873
+ }
58874
+ function subSchemaObjCode(it, valid) {
58875
+ const { schema, gen, opts } = it;
58775
58876
  if (opts.$comment && schema.$comment)
58776
58877
  commentKeyword(it);
58777
- checkNoDefault(it);
58778
- gen.let(names_1$3.default.vErrors, null);
58779
- gen.let(names_1$3.default.errors, 0);
58780
- if (opts.unevaluated)
58781
- resetEvaluated(it);
58782
- typeAndKeywords(it);
58783
- returnResults(it);
58784
- });
58785
- return;
58786
- }
58787
- function resetEvaluated(it) {
58788
- const { gen, validateName: validateName2 } = it;
58789
- it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName2}.evaluated`);
58790
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
58791
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
58792
- }
58793
- function funcSourceUrl(schema, opts) {
58794
- const schId = typeof schema == "object" && schema[opts.schemaId];
58795
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
58796
- }
58797
- function subschemaCode(it, valid) {
58798
- if (isSchemaObj(it)) {
58799
- checkKeywords(it);
58800
- if (schemaCxtHasRules(it)) {
58801
- subSchemaObjCode(it, valid);
58802
- return;
58878
+ updateContext(it);
58879
+ checkAsyncSchema(it);
58880
+ const errsCount = gen.const("_errs", names_12.default.errors);
58881
+ typeAndKeywords(it, errsCount);
58882
+ gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
58883
+ }
58884
+ function checkKeywords(it) {
58885
+ (0, util_12.checkUnknownRules)(it);
58886
+ checkRefsAndKeywords(it);
58887
+ }
58888
+ function typeAndKeywords(it, errsCount) {
58889
+ if (it.opts.jtd)
58890
+ return schemaKeywords(it, [], false, errsCount);
58891
+ const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
58892
+ const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
58893
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
58894
+ }
58895
+ function checkRefsAndKeywords(it) {
58896
+ const { schema, errSchemaPath, opts, self } = it;
58897
+ if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self.RULES)) {
58898
+ self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
58803
58899
  }
58804
58900
  }
58805
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
58806
- }
58807
- function schemaCxtHasRules({ schema, self }) {
58808
- if (typeof schema == "boolean")
58809
- return !schema;
58810
- for (const key in schema)
58811
- if (self.RULES.all[key])
58812
- return true;
58813
- return false;
58814
- }
58815
- function isSchemaObj(it) {
58816
- return typeof it.schema != "boolean";
58817
- }
58818
- function subSchemaObjCode(it, valid) {
58819
- const { schema, gen, opts } = it;
58820
- if (opts.$comment && schema.$comment)
58821
- commentKeyword(it);
58822
- updateContext(it);
58823
- checkAsyncSchema(it);
58824
- const errsCount = gen.const("_errs", names_1$3.default.errors);
58825
- typeAndKeywords(it, errsCount);
58826
- gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
58827
- }
58828
- function checkKeywords(it) {
58829
- (0, util_1$m.checkUnknownRules)(it);
58830
- checkRefsAndKeywords(it);
58831
- }
58832
- function typeAndKeywords(it, errsCount) {
58833
- if (it.opts.jtd)
58834
- return schemaKeywords(it, [], false, errsCount);
58835
- const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
58836
- const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
58837
- schemaKeywords(it, types2, !checkedTypes, errsCount);
58838
- }
58839
- function checkRefsAndKeywords(it) {
58840
- const { schema, errSchemaPath, opts, self } = it;
58841
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self.RULES)) {
58842
- self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
58843
- }
58844
- }
58845
- function checkNoDefault(it) {
58846
- const { schema, opts } = it;
58847
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
58848
- (0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
58849
- }
58850
- }
58851
- function updateContext(it) {
58852
- const schId = it.schema[it.opts.schemaId];
58853
- if (schId)
58854
- it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
58855
- }
58856
- function checkAsyncSchema(it) {
58857
- if (it.schema.$async && !it.schemaEnv.$async)
58858
- throw new Error("async schema in sync schema");
58859
- }
58860
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
58861
- const msg = schema.$comment;
58862
- if (opts.$comment === true) {
58863
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
58864
- } else if (typeof opts.$comment == "function") {
58865
- const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
58866
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
58867
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
58868
- }
58869
- }
58870
- function returnResults(it) {
58871
- const { gen, schemaEnv, validateName: validateName2, ValidationError: ValidationError2, opts } = it;
58872
- if (schemaEnv.$async) {
58873
- 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})`));
58874
- } else {
58875
- gen.assign((0, codegen_1$n._)`${validateName2}.errors`, names_1$3.default.vErrors);
58876
- if (opts.unevaluated)
58877
- assignEvaluated(it);
58878
- gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
58879
- }
58880
- }
58881
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
58882
- if (props instanceof codegen_1$n.Name)
58883
- gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
58884
- if (items2 instanceof codegen_1$n.Name)
58885
- gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
58886
- }
58887
- function schemaKeywords(it, types2, typeErrors, errsCount) {
58888
- const { gen, schema, data, allErrors, opts, self } = it;
58889
- const { RULES } = self;
58890
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
58891
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
58892
- return;
58901
+ function checkNoDefault(it) {
58902
+ const { schema, opts } = it;
58903
+ if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
58904
+ (0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
58905
+ }
58893
58906
  }
58894
- if (!opts.jtd)
58895
- checkStrictTypes(it, types2);
58896
- gen.block(() => {
58897
- for (const group of RULES.rules)
58898
- groupKeywords(group);
58899
- groupKeywords(RULES.post);
58900
- });
58901
- function groupKeywords(group) {
58902
- if (!(0, applicability_1.shouldUseGroup)(schema, group))
58907
+ function updateContext(it) {
58908
+ const schId = it.schema[it.opts.schemaId];
58909
+ if (schId)
58910
+ it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
58911
+ }
58912
+ function checkAsyncSchema(it) {
58913
+ if (it.schema.$async && !it.schemaEnv.$async)
58914
+ throw new Error("async schema in sync schema");
58915
+ }
58916
+ function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
58917
+ const msg = schema.$comment;
58918
+ if (opts.$comment === true) {
58919
+ gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
58920
+ } else if (typeof opts.$comment == "function") {
58921
+ const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
58922
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
58923
+ gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
58924
+ }
58925
+ }
58926
+ function returnResults(it) {
58927
+ const { gen, schemaEnv, validateName: validateName2, ValidationError, opts } = it;
58928
+ if (schemaEnv.$async) {
58929
+ 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})`));
58930
+ } else {
58931
+ gen.assign((0, codegen_12._)`${validateName2}.errors`, names_12.default.vErrors);
58932
+ if (opts.unevaluated)
58933
+ assignEvaluated(it);
58934
+ gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
58935
+ }
58936
+ }
58937
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
58938
+ if (props instanceof codegen_12.Name)
58939
+ gen.assign((0, codegen_12._)`${evaluated}.props`, props);
58940
+ if (items2 instanceof codegen_12.Name)
58941
+ gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
58942
+ }
58943
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
58944
+ const { gen, schema, data, allErrors, opts, self } = it;
58945
+ const { RULES } = self;
58946
+ if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
58947
+ gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
58903
58948
  return;
58904
- if (group.type) {
58905
- gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
58906
- iterateKeywords(it, group);
58907
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
58908
- gen.else();
58909
- (0, dataType_2.reportTypeError)(it);
58949
+ }
58950
+ if (!opts.jtd)
58951
+ checkStrictTypes(it, types2);
58952
+ gen.block(() => {
58953
+ for (const group of RULES.rules)
58954
+ groupKeywords(group);
58955
+ groupKeywords(RULES.post);
58956
+ });
58957
+ function groupKeywords(group) {
58958
+ if (!(0, applicability_12.shouldUseGroup)(schema, group))
58959
+ return;
58960
+ if (group.type) {
58961
+ gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
58962
+ iterateKeywords(it, group);
58963
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
58964
+ gen.else();
58965
+ (0, dataType_2.reportTypeError)(it);
58966
+ }
58967
+ gen.endIf();
58968
+ } else {
58969
+ iterateKeywords(it, group);
58910
58970
  }
58911
- gen.endIf();
58912
- } else {
58913
- iterateKeywords(it, group);
58971
+ if (!allErrors)
58972
+ gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
58914
58973
  }
58915
- if (!allErrors)
58916
- gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
58917
58974
  }
58918
- }
58919
- function iterateKeywords(it, group) {
58920
- const { gen, schema, opts: { useDefaults } } = it;
58921
- if (useDefaults)
58922
- (0, defaults_1.assignDefaults)(it, group.type);
58923
- gen.block(() => {
58924
- for (const rule of group.rules) {
58925
- if ((0, applicability_1.shouldUseRule)(schema, rule)) {
58926
- keywordCode(it, rule.keyword, rule.definition, group.type);
58975
+ function iterateKeywords(it, group) {
58976
+ const { gen, schema, opts: { useDefaults } } = it;
58977
+ if (useDefaults)
58978
+ (0, defaults_1.assignDefaults)(it, group.type);
58979
+ gen.block(() => {
58980
+ for (const rule of group.rules) {
58981
+ if ((0, applicability_12.shouldUseRule)(schema, rule)) {
58982
+ keywordCode(it, rule.keyword, rule.definition, group.type);
58983
+ }
58927
58984
  }
58928
- }
58929
- });
58930
- }
58931
- function checkStrictTypes(it, types2) {
58932
- if (it.schemaEnv.meta || !it.opts.strictTypes)
58933
- return;
58934
- checkContextTypes(it, types2);
58935
- if (!it.opts.allowUnionTypes)
58936
- checkMultipleTypes(it, types2);
58937
- checkKeywordTypes(it, it.dataTypes);
58938
- }
58939
- function checkContextTypes(it, types2) {
58940
- if (!types2.length)
58941
- return;
58942
- if (!it.dataTypes.length) {
58943
- it.dataTypes = types2;
58944
- return;
58985
+ });
58986
+ }
58987
+ function checkStrictTypes(it, types2) {
58988
+ if (it.schemaEnv.meta || !it.opts.strictTypes)
58989
+ return;
58990
+ checkContextTypes(it, types2);
58991
+ if (!it.opts.allowUnionTypes)
58992
+ checkMultipleTypes(it, types2);
58993
+ checkKeywordTypes(it, it.dataTypes);
58945
58994
  }
58946
- types2.forEach((t2) => {
58947
- if (!includesType(it.dataTypes, t2)) {
58948
- strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
58995
+ function checkContextTypes(it, types2) {
58996
+ if (!types2.length)
58997
+ return;
58998
+ if (!it.dataTypes.length) {
58999
+ it.dataTypes = types2;
59000
+ return;
58949
59001
  }
58950
- });
58951
- narrowSchemaTypes(it, types2);
58952
- }
58953
- function checkMultipleTypes(it, ts) {
58954
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
58955
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
58956
- }
58957
- }
58958
- function checkKeywordTypes(it, ts) {
58959
- const rules2 = it.self.RULES.all;
58960
- for (const keyword2 in rules2) {
58961
- const rule = rules2[keyword2];
58962
- if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
58963
- const { type: type2 } = rule.definition;
58964
- if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
58965
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
58966
- }
58967
- }
58968
- }
58969
- }
58970
- function hasApplicableType(schTs, kwdT) {
58971
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
58972
- }
58973
- function includesType(ts, t2) {
58974
- return ts.includes(t2) || t2 === "integer" && ts.includes("number");
58975
- }
58976
- function narrowSchemaTypes(it, withTypes) {
58977
- const ts = [];
58978
- for (const t2 of it.dataTypes) {
58979
- if (includesType(withTypes, t2))
58980
- ts.push(t2);
58981
- else if (withTypes.includes("integer") && t2 === "number")
58982
- ts.push("integer");
58983
- }
58984
- it.dataTypes = ts;
58985
- }
58986
- function strictTypesError(it, msg) {
58987
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
58988
- msg += ` at "${schemaPath}" (strictTypes)`;
58989
- (0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
58990
- }
58991
- class KeywordCxt {
58992
- constructor(it, def2, keyword2) {
58993
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
58994
- this.gen = it.gen;
58995
- this.allErrors = it.allErrors;
58996
- this.keyword = keyword2;
58997
- this.data = it.data;
58998
- this.schema = it.schema[keyword2];
58999
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
59000
- this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
59001
- this.schemaType = def2.schemaType;
59002
- this.parentSchema = it.schema;
59003
- this.params = {};
59004
- this.it = it;
59005
- this.def = def2;
59006
- if (this.$data) {
59007
- this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
59008
- } else {
59009
- this.schemaCode = this.schemaValue;
59010
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
59011
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
59002
+ types2.forEach((t2) => {
59003
+ if (!includesType(it.dataTypes, t2)) {
59004
+ strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
59005
+ }
59006
+ });
59007
+ narrowSchemaTypes(it, types2);
59008
+ }
59009
+ function checkMultipleTypes(it, ts) {
59010
+ if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
59011
+ strictTypesError(it, "use allowUnionTypes to allow union type keyword");
59012
+ }
59013
+ }
59014
+ function checkKeywordTypes(it, ts) {
59015
+ const rules2 = it.self.RULES.all;
59016
+ for (const keyword2 in rules2) {
59017
+ const rule = rules2[keyword2];
59018
+ if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
59019
+ const { type: type2 } = rule.definition;
59020
+ if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
59021
+ strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
59022
+ }
59023
+ }
59024
+ }
59025
+ }
59026
+ function hasApplicableType(schTs, kwdT) {
59027
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
59028
+ }
59029
+ function includesType(ts, t2) {
59030
+ return ts.includes(t2) || t2 === "integer" && ts.includes("number");
59031
+ }
59032
+ function narrowSchemaTypes(it, withTypes) {
59033
+ const ts = [];
59034
+ for (const t2 of it.dataTypes) {
59035
+ if (includesType(withTypes, t2))
59036
+ ts.push(t2);
59037
+ else if (withTypes.includes("integer") && t2 === "number")
59038
+ ts.push("integer");
59039
+ }
59040
+ it.dataTypes = ts;
59041
+ }
59042
+ function strictTypesError(it, msg) {
59043
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
59044
+ msg += ` at "${schemaPath}" (strictTypes)`;
59045
+ (0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
59046
+ }
59047
+ class KeywordCxt {
59048
+ constructor(it, def2, keyword2) {
59049
+ (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
59050
+ this.gen = it.gen;
59051
+ this.allErrors = it.allErrors;
59052
+ this.keyword = keyword2;
59053
+ this.data = it.data;
59054
+ this.schema = it.schema[keyword2];
59055
+ this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
59056
+ this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
59057
+ this.schemaType = def2.schemaType;
59058
+ this.parentSchema = it.schema;
59059
+ this.params = {};
59060
+ this.it = it;
59061
+ this.def = def2;
59062
+ if (this.$data) {
59063
+ this.schemaCode = it.gen.const("vSchema", getData2(this.$data, it));
59064
+ } else {
59065
+ this.schemaCode = this.schemaValue;
59066
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
59067
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
59068
+ }
59069
+ }
59070
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
59071
+ this.errsCount = it.gen.const("_errs", names_12.default.errors);
59012
59072
  }
59013
59073
  }
59014
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
59015
- this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
59074
+ result(condition, successAction, failAction) {
59075
+ this.failResult((0, codegen_12.not)(condition), successAction, failAction);
59016
59076
  }
59017
- }
59018
- result(condition, successAction, failAction) {
59019
- this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
59020
- }
59021
- failResult(condition, successAction, failAction) {
59022
- this.gen.if(condition);
59023
- if (failAction)
59024
- failAction();
59025
- else
59077
+ failResult(condition, successAction, failAction) {
59078
+ this.gen.if(condition);
59079
+ if (failAction)
59080
+ failAction();
59081
+ else
59082
+ this.error();
59083
+ if (successAction) {
59084
+ this.gen.else();
59085
+ successAction();
59086
+ if (this.allErrors)
59087
+ this.gen.endIf();
59088
+ } else {
59089
+ if (this.allErrors)
59090
+ this.gen.endIf();
59091
+ else
59092
+ this.gen.else();
59093
+ }
59094
+ }
59095
+ pass(condition, failAction) {
59096
+ this.failResult((0, codegen_12.not)(condition), void 0, failAction);
59097
+ }
59098
+ fail(condition) {
59099
+ if (condition === void 0) {
59100
+ this.error();
59101
+ if (!this.allErrors)
59102
+ this.gen.if(false);
59103
+ return;
59104
+ }
59105
+ this.gen.if(condition);
59026
59106
  this.error();
59027
- if (successAction) {
59028
- this.gen.else();
59029
- successAction();
59030
- if (this.allErrors)
59031
- this.gen.endIf();
59032
- } else {
59033
59107
  if (this.allErrors)
59034
59108
  this.gen.endIf();
59035
59109
  else
59036
59110
  this.gen.else();
59037
59111
  }
59038
- }
59039
- pass(condition, failAction) {
59040
- this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
59041
- }
59042
- fail(condition) {
59043
- if (condition === void 0) {
59044
- this.error();
59112
+ fail$data(condition) {
59113
+ if (!this.$data)
59114
+ return this.fail(condition);
59115
+ const { schemaCode } = this;
59116
+ this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
59117
+ }
59118
+ error(append, errorParams, errorPaths) {
59119
+ if (errorParams) {
59120
+ this.setParams(errorParams);
59121
+ this._error(append, errorPaths);
59122
+ this.setParams({});
59123
+ return;
59124
+ }
59125
+ this._error(append, errorPaths);
59126
+ }
59127
+ _error(append, errorPaths) {
59128
+ (append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
59129
+ }
59130
+ $dataError() {
59131
+ (0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
59132
+ }
59133
+ reset() {
59134
+ if (this.errsCount === void 0)
59135
+ throw new Error('add "trackErrors" to keyword definition');
59136
+ (0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
59137
+ }
59138
+ ok(cond) {
59045
59139
  if (!this.allErrors)
59046
- this.gen.if(false);
59047
- return;
59140
+ this.gen.if(cond);
59048
59141
  }
59049
- this.gen.if(condition);
59050
- this.error();
59051
- if (this.allErrors)
59052
- this.gen.endIf();
59053
- else
59054
- this.gen.else();
59055
- }
59056
- fail$data(condition) {
59057
- if (!this.$data)
59058
- return this.fail(condition);
59059
- const { schemaCode } = this;
59060
- this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
59061
- }
59062
- error(append, errorParams, errorPaths) {
59063
- if (errorParams) {
59064
- this.setParams(errorParams);
59065
- this._error(append, errorPaths);
59066
- this.setParams({});
59067
- return;
59142
+ setParams(obj, assign2) {
59143
+ if (assign2)
59144
+ Object.assign(this.params, obj);
59145
+ else
59146
+ this.params = obj;
59068
59147
  }
59069
- this._error(append, errorPaths);
59070
- }
59071
- _error(append, errorPaths) {
59072
- (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
59073
- }
59074
- $dataError() {
59075
- (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
59076
- }
59077
- reset() {
59078
- if (this.errsCount === void 0)
59079
- throw new Error('add "trackErrors" to keyword definition');
59080
- (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
59081
- }
59082
- ok(cond) {
59083
- if (!this.allErrors)
59084
- this.gen.if(cond);
59085
- }
59086
- setParams(obj, assign2) {
59087
- if (assign2)
59088
- Object.assign(this.params, obj);
59089
- else
59090
- this.params = obj;
59091
- }
59092
- block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
59093
- this.gen.block(() => {
59094
- this.check$data(valid, $dataValid);
59095
- codeBlock();
59096
- });
59097
- }
59098
- check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
59099
- if (!this.$data)
59100
- return;
59101
- const { gen, schemaCode, schemaType, def: def2 } = this;
59102
- gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
59103
- if (valid !== codegen_1$n.nil)
59104
- gen.assign(valid, true);
59105
- if (schemaType.length || def2.validateSchema) {
59106
- gen.elseIf(this.invalid$data());
59107
- this.$dataError();
59108
- if (valid !== codegen_1$n.nil)
59109
- gen.assign(valid, false);
59148
+ block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
59149
+ this.gen.block(() => {
59150
+ this.check$data(valid, $dataValid);
59151
+ codeBlock();
59152
+ });
59110
59153
  }
59111
- gen.else();
59112
- }
59113
- invalid$data() {
59114
- const { gen, schemaCode, schemaType, def: def2, it } = this;
59115
- return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
59116
- function wrong$DataType() {
59117
- if (schemaType.length) {
59118
- if (!(schemaCode instanceof codegen_1$n.Name))
59119
- throw new Error("ajv implementation error");
59120
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
59121
- return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
59154
+ check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
59155
+ if (!this.$data)
59156
+ return;
59157
+ const { gen, schemaCode, schemaType, def: def2 } = this;
59158
+ gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
59159
+ if (valid !== codegen_12.nil)
59160
+ gen.assign(valid, true);
59161
+ if (schemaType.length || def2.validateSchema) {
59162
+ gen.elseIf(this.invalid$data());
59163
+ this.$dataError();
59164
+ if (valid !== codegen_12.nil)
59165
+ gen.assign(valid, false);
59122
59166
  }
59123
- return codegen_1$n.nil;
59167
+ gen.else();
59124
59168
  }
59125
- function invalid$DataSchema() {
59126
- if (def2.validateSchema) {
59127
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
59128
- return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
59169
+ invalid$data() {
59170
+ const { gen, schemaCode, schemaType, def: def2, it } = this;
59171
+ return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
59172
+ function wrong$DataType() {
59173
+ if (schemaType.length) {
59174
+ if (!(schemaCode instanceof codegen_12.Name))
59175
+ throw new Error("ajv implementation error");
59176
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
59177
+ return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
59178
+ }
59179
+ return codegen_12.nil;
59180
+ }
59181
+ function invalid$DataSchema() {
59182
+ if (def2.validateSchema) {
59183
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
59184
+ return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
59185
+ }
59186
+ return codegen_12.nil;
59187
+ }
59188
+ }
59189
+ subschema(appl, valid) {
59190
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
59191
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
59192
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
59193
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
59194
+ subschemaCode(nextContext, valid);
59195
+ return nextContext;
59196
+ }
59197
+ mergeEvaluated(schemaCxt, toName) {
59198
+ const { it, gen } = this;
59199
+ if (!it.opts.unevaluated)
59200
+ return;
59201
+ if (it.props !== true && schemaCxt.props !== void 0) {
59202
+ it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
59203
+ }
59204
+ if (it.items !== true && schemaCxt.items !== void 0) {
59205
+ it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
59129
59206
  }
59130
- return codegen_1$n.nil;
59131
- }
59132
- }
59133
- subschema(appl, valid) {
59134
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
59135
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
59136
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
59137
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
59138
- subschemaCode(nextContext, valid);
59139
- return nextContext;
59140
- }
59141
- mergeEvaluated(schemaCxt, toName) {
59142
- const { it, gen } = this;
59143
- if (!it.opts.unevaluated)
59144
- return;
59145
- if (it.props !== true && schemaCxt.props !== void 0) {
59146
- it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
59147
59207
  }
59148
- if (it.items !== true && schemaCxt.items !== void 0) {
59149
- it.items = util_1$m.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
59208
+ mergeValidEvaluated(schemaCxt, valid) {
59209
+ const { it, gen } = this;
59210
+ if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
59211
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
59212
+ return true;
59213
+ }
59150
59214
  }
59151
59215
  }
59152
- mergeValidEvaluated(schemaCxt, valid) {
59153
- const { it, gen } = this;
59154
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
59155
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
59156
- return true;
59216
+ validate.KeywordCxt = KeywordCxt;
59217
+ function keywordCode(it, keyword2, def2, ruleType) {
59218
+ const cxt = new KeywordCxt(it, def2, keyword2);
59219
+ if ("code" in def2) {
59220
+ def2.code(cxt, ruleType);
59221
+ } else if (cxt.$data && def2.validate) {
59222
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
59223
+ } else if ("macro" in def2) {
59224
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
59225
+ } else if (def2.compile || def2.validate) {
59226
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
59157
59227
  }
59158
59228
  }
59159
- }
59160
- validate.KeywordCxt = KeywordCxt;
59161
- function keywordCode(it, keyword2, def2, ruleType) {
59162
- const cxt = new KeywordCxt(it, def2, keyword2);
59163
- if ("code" in def2) {
59164
- def2.code(cxt, ruleType);
59165
- } else if (cxt.$data && def2.validate) {
59166
- (0, keyword_1.funcKeywordCode)(cxt, def2);
59167
- } else if ("macro" in def2) {
59168
- (0, keyword_1.macroKeywordCode)(cxt, def2);
59169
- } else if (def2.compile || def2.validate) {
59170
- (0, keyword_1.funcKeywordCode)(cxt, def2);
59171
- }
59172
- }
59173
- const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
59174
- const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
59175
- function getData($data, { dataLevel, dataNames, dataPathArr }) {
59176
- let jsonPointer;
59177
- let data;
59178
- if ($data === "")
59179
- return names_1$3.default.rootData;
59180
- if ($data[0] === "/") {
59181
- if (!JSON_POINTER.test($data))
59182
- throw new Error(`Invalid JSON-pointer: ${$data}`);
59183
- jsonPointer = $data;
59184
- data = names_1$3.default.rootData;
59185
- } else {
59186
- const matches = RELATIVE_JSON_POINTER.exec($data);
59187
- if (!matches)
59188
- throw new Error(`Invalid JSON-pointer: ${$data}`);
59189
- const up = +matches[1];
59190
- jsonPointer = matches[2];
59191
- if (jsonPointer === "#") {
59192
- if (up >= dataLevel)
59193
- throw new Error(errorMsg("property/index", up));
59194
- return dataPathArr[dataLevel - up];
59195
- }
59196
- if (up > dataLevel)
59197
- throw new Error(errorMsg("data", up));
59198
- data = dataNames[dataLevel - up];
59199
- if (!jsonPointer)
59200
- return data;
59201
- }
59202
- let expr = data;
59203
- const segments = jsonPointer.split("/");
59204
- for (const segment of segments) {
59205
- if (segment) {
59206
- data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
59207
- expr = (0, codegen_1$n._)`${expr} && ${data}`;
59229
+ const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
59230
+ const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
59231
+ function getData2($data, { dataLevel, dataNames, dataPathArr }) {
59232
+ let jsonPointer;
59233
+ let data;
59234
+ if ($data === "")
59235
+ return names_12.default.rootData;
59236
+ if ($data[0] === "/") {
59237
+ if (!JSON_POINTER.test($data))
59238
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
59239
+ jsonPointer = $data;
59240
+ data = names_12.default.rootData;
59241
+ } else {
59242
+ const matches = RELATIVE_JSON_POINTER.exec($data);
59243
+ if (!matches)
59244
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
59245
+ const up = +matches[1];
59246
+ jsonPointer = matches[2];
59247
+ if (jsonPointer === "#") {
59248
+ if (up >= dataLevel)
59249
+ throw new Error(errorMsg("property/index", up));
59250
+ return dataPathArr[dataLevel - up];
59251
+ }
59252
+ if (up > dataLevel)
59253
+ throw new Error(errorMsg("data", up));
59254
+ data = dataNames[dataLevel - up];
59255
+ if (!jsonPointer)
59256
+ return data;
59257
+ }
59258
+ let expr = data;
59259
+ const segments = jsonPointer.split("/");
59260
+ for (const segment of segments) {
59261
+ if (segment) {
59262
+ data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
59263
+ expr = (0, codegen_12._)`${expr} && ${data}`;
59264
+ }
59265
+ }
59266
+ return expr;
59267
+ function errorMsg(pointerType, up) {
59268
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
59208
59269
  }
59209
59270
  }
59210
- return expr;
59211
- function errorMsg(pointerType, up) {
59212
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
59213
- }
59271
+ validate.getData = getData2;
59272
+ return validate;
59214
59273
  }
59215
- validate.getData = getData;
59216
59274
  var validation_error = {};
59217
- Object.defineProperty(validation_error, "__esModule", { value: true });
59218
- class ValidationError extends Error {
59219
- constructor(errors2) {
59220
- super("validation failed");
59221
- this.errors = errors2;
59222
- this.ajv = this.validation = true;
59275
+ var hasRequiredValidation_error;
59276
+ function requireValidation_error() {
59277
+ if (hasRequiredValidation_error) return validation_error;
59278
+ hasRequiredValidation_error = 1;
59279
+ Object.defineProperty(validation_error, "__esModule", { value: true });
59280
+ class ValidationError extends Error {
59281
+ constructor(errors2) {
59282
+ super("validation failed");
59283
+ this.errors = errors2;
59284
+ this.ajv = this.validation = true;
59285
+ }
59223
59286
  }
59287
+ validation_error.default = ValidationError;
59288
+ return validation_error;
59224
59289
  }
59225
- validation_error.default = ValidationError;
59226
59290
  var ref_error = {};
59227
59291
  Object.defineProperty(ref_error, "__esModule", { value: true });
59228
59292
  const resolve_1$1 = resolve$2;
@@ -59238,11 +59302,11 @@ var compile = {};
59238
59302
  Object.defineProperty(compile, "__esModule", { value: true });
59239
59303
  compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
59240
59304
  const codegen_1$m = codegen;
59241
- const validation_error_1 = validation_error;
59305
+ const validation_error_1 = requireValidation_error();
59242
59306
  const names_1$2 = names$1;
59243
59307
  const resolve_1 = resolve$2;
59244
59308
  const util_1$l = util;
59245
- const validate_1$1 = validate;
59309
+ const validate_1$1 = requireValidate();
59246
59310
  class SchemaEnv {
59247
59311
  constructor(env) {
59248
59312
  var _a2;
@@ -60171,7 +60235,7 @@ uri$1.default = uri;
60171
60235
  (function(exports$1) {
60172
60236
  Object.defineProperty(exports$1, "__esModule", { value: true });
60173
60237
  exports$1.CodeGen = exports$1.Name = exports$1.nil = exports$1.stringify = exports$1.str = exports$1._ = exports$1.KeywordCxt = void 0;
60174
- var validate_12 = validate;
60238
+ var validate_12 = requireValidate();
60175
60239
  Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
60176
60240
  return validate_12.KeywordCxt;
60177
60241
  } });
@@ -60194,7 +60258,7 @@ uri$1.default = uri;
60194
60258
  Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
60195
60259
  return codegen_12.CodeGen;
60196
60260
  } });
60197
- const validation_error_12 = validation_error;
60261
+ const validation_error_12 = requireValidation_error();
60198
60262
  const ref_error_12 = ref_error;
60199
60263
  const rules_12 = rules;
60200
60264
  const compile_12 = compile;
@@ -61782,7 +61846,7 @@ const def$a = {
61782
61846
  additionalProperties.default = def$a;
61783
61847
  var properties$1 = {};
61784
61848
  Object.defineProperty(properties$1, "__esModule", { value: true });
61785
- const validate_1 = validate;
61849
+ const validate_1 = requireValidate();
61786
61850
  const code_1$2 = code;
61787
61851
  const util_1$7 = util;
61788
61852
  const additionalProperties_1$1 = additionalProperties;
@@ -62633,7 +62697,7 @@ const require$$3 = {
62633
62697
  module.exports.Ajv = Ajv2;
62634
62698
  Object.defineProperty(exports$1, "__esModule", { value: true });
62635
62699
  exports$1.default = Ajv2;
62636
- var validate_12 = validate;
62700
+ var validate_12 = requireValidate();
62637
62701
  Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
62638
62702
  return validate_12.KeywordCxt;
62639
62703
  } });
@@ -62656,7 +62720,7 @@ const require$$3 = {
62656
62720
  Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
62657
62721
  return codegen_12.CodeGen;
62658
62722
  } });
62659
- var validation_error_12 = validation_error;
62723
+ var validation_error_12 = requireValidation_error();
62660
62724
  Object.defineProperty(exports$1, "ValidationError", { enumerable: true, get: function() {
62661
62725
  return validation_error_12.default;
62662
62726
  } });
@@ -68781,11 +68845,20 @@ function ContractPanel() {
68781
68845
  const activeCollId = useStore((s) => s.activeCollectionId);
68782
68846
  const report = useStore((s) => s.lastContractReport);
68783
68847
  const setReport = useStore((s) => s.setLastContractReport);
68848
+ const snapshots = useStore((s) => s.contractSnapshots);
68849
+ const activeSnapshotRelPath = useStore((s) => s.activeContractSnapshotRelPath);
68850
+ const setActiveSnapshot = useStore((s) => s.setActiveContractSnapshot);
68851
+ const loadContractSnapshot = useStore((s) => s.loadContractSnapshot);
68852
+ const removeContractSnapshot = useStore((s) => s.removeContractSnapshot);
68853
+ const workspace = useStore((s) => s.workspace);
68784
68854
  const [mode, setMode] = reactExports.useState("consumer");
68785
68855
  const [specUrl, setSpecUrl] = reactExports.useState("");
68786
68856
  const [requestBaseUrl, setRequestBaseUrl] = reactExports.useState("");
68787
68857
  const [running, setRunning] = reactExports.useState(false);
68858
+ const [capturing, setCapturing] = reactExports.useState(false);
68788
68859
  const [error2, setError] = reactExports.useState(null);
68860
+ const snapshotList = Object.entries(snapshots).map(([relPath, snapshot]) => ({ relPath, snapshot })).sort((a, b) => b.snapshot.capturedAt.localeCompare(a.snapshot.capturedAt));
68861
+ const activeSnapshot = activeSnapshotRelPath ? snapshots[activeSnapshotRelPath] ?? null : null;
68789
68862
  const allRequests = Object.values(collections).flatMap((c) => Object.values(c.data.requests));
68790
68863
  const contractRequests = allRequests.filter(
68791
68864
  (r) => r.contract && (r.contract.statusCode !== void 0 || r.contract.bodySchema || r.contract.headers?.length)
@@ -68795,8 +68868,8 @@ function ContractPanel() {
68795
68868
  (environments[activeEnvId]?.data.variables ?? []).filter((v) => v.enabled).map((v) => [v.key, v.value])
68796
68869
  ) : {};
68797
68870
  async function runContracts() {
68798
- if (mode !== "consumer" && !specUrl.trim()) {
68799
- setError("Provide an OpenAPI spec URL for provider / bi-directional mode.");
68871
+ if (mode !== "consumer" && !specUrl.trim() && !activeSnapshotRelPath) {
68872
+ setError("Provide an OpenAPI spec URL or pick a pinned snapshot for provider / bi-directional mode.");
68800
68873
  return;
68801
68874
  }
68802
68875
  setRunning(true);
@@ -68810,6 +68883,7 @@ function ContractPanel() {
68810
68883
  envVars,
68811
68884
  collectionVars,
68812
68885
  specUrl: specUrl.trim() || void 0,
68886
+ specSnapshotRelPath: activeSnapshotRelPath ?? void 0,
68813
68887
  requestBaseUrl: requestBaseUrl.trim() || void 0
68814
68888
  });
68815
68889
  setReport(result);
@@ -68819,6 +68893,37 @@ function ContractPanel() {
68819
68893
  setRunning(false);
68820
68894
  }
68821
68895
  }
68896
+ async function captureSnapshot() {
68897
+ if (!specUrl.trim()) {
68898
+ setError("Enter a spec URL before pinning a snapshot.");
68899
+ return;
68900
+ }
68901
+ setCapturing(true);
68902
+ setError(null);
68903
+ try {
68904
+ const { relPath, snapshot } = await electron$2.captureContractSnapshot({ specUrl: specUrl.trim() });
68905
+ loadContractSnapshot(relPath, snapshot);
68906
+ setActiveSnapshot(relPath);
68907
+ const ws2 = useStore.getState().workspace;
68908
+ if (ws2) await electron$2.saveWorkspace(ws2);
68909
+ } catch (e) {
68910
+ setError(e instanceof Error ? e.message : String(e));
68911
+ } finally {
68912
+ setCapturing(false);
68913
+ }
68914
+ }
68915
+ async function deleteActiveSnapshot() {
68916
+ if (!activeSnapshotRelPath) return;
68917
+ const relPath = activeSnapshotRelPath;
68918
+ try {
68919
+ await electron$2.deleteContractSnapshot(relPath);
68920
+ removeContractSnapshot(relPath);
68921
+ const ws2 = useStore.getState().workspace;
68922
+ if (ws2) await electron$2.saveWorkspace(ws2);
68923
+ } catch (e) {
68924
+ setError(e instanceof Error ? e.message : String(e));
68925
+ }
68926
+ }
68822
68927
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col flex-1 min-h-0 overflow-hidden", children: [
68823
68928
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 px-3 py-3 border-b border-surface-800 flex-shrink-0", children: [
68824
68929
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex gap-1 bg-surface-800 rounded-lg p-0.5", children: ["consumer", "provider", "bidirectional"].map((m) => /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -68836,16 +68941,65 @@ function ContractPanel() {
68836
68941
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-surface-500 leading-relaxed", children: mode === "consumer" ? "Sends requests to the real provider and validates each response against the contract defined in the Contract tab." : mode === "provider" ? "Static analysis — validates that your requests conform to the provider's published OpenAPI spec (no HTTP calls)." : "Checks static schema compatibility between consumer contracts and provider spec, then verifies live responses." }),
68837
68942
  mode !== "consumer" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [
68838
68943
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
68944
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] text-surface-500 uppercase tracking-wider font-medium block mb-1", children: "Spec version" }),
68945
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-1", children: [
68946
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
68947
+ "select",
68948
+ {
68949
+ value: activeSnapshotRelPath ?? "",
68950
+ onChange: (e) => setActiveSnapshot(e.target.value || null),
68951
+ disabled: !workspace,
68952
+ className: "flex-1 text-xs bg-surface-800 border border-surface-700 rounded px-2 py-1.5 focus:outline-none focus:border-blue-500 disabled:opacity-50",
68953
+ children: [
68954
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Live URL (latest from provider)" }),
68955
+ snapshotList.map(({ relPath, snapshot }) => /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: relPath, children: [
68956
+ snapshot.name,
68957
+ snapshot.specVersion ? "" : ` — ${snapshot.capturedAt.slice(0, 10)}`
68958
+ ] }, relPath))
68959
+ ]
68960
+ }
68961
+ ),
68962
+ activeSnapshotRelPath && /* @__PURE__ */ jsxRuntimeExports.jsx(
68963
+ "button",
68964
+ {
68965
+ onClick: deleteActiveSnapshot,
68966
+ title: "Delete this snapshot",
68967
+ className: "px-2 text-xs text-surface-500 hover:text-red-400 bg-surface-800 hover:bg-surface-700 rounded transition-colors",
68968
+ children: "✕"
68969
+ }
68970
+ )
68971
+ ] }),
68972
+ activeSnapshot && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-[10px] text-surface-600 mt-1 font-mono truncate", children: [
68973
+ "Captured ",
68974
+ activeSnapshot.capturedAt.slice(0, 19).replace("T", " "),
68975
+ " — sha ",
68976
+ activeSnapshot.sha256.slice(0, 8)
68977
+ ] })
68978
+ ] }),
68979
+ !activeSnapshotRelPath && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
68839
68980
  /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] text-surface-500 uppercase tracking-wider font-medium block mb-1", children: "OpenAPI Spec URL" }),
68840
- /* @__PURE__ */ jsxRuntimeExports.jsx(
68841
- "input",
68842
- {
68843
- value: specUrl,
68844
- onChange: (e) => setSpecUrl(e.target.value),
68845
- placeholder: "https://api.example.com/openapi.json",
68846
- className: "w-full text-xs bg-surface-800 border border-surface-700 rounded px-2.5 py-1.5 focus:outline-none focus:border-blue-500 font-mono placeholder-surface-600"
68847
- }
68848
- )
68981
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-1", children: [
68982
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
68983
+ "input",
68984
+ {
68985
+ value: specUrl,
68986
+ onChange: (e) => setSpecUrl(e.target.value),
68987
+ placeholder: "https://api.example.com/openapi.json",
68988
+ className: "flex-1 text-xs bg-surface-800 border border-surface-700 rounded px-2.5 py-1.5 focus:outline-none focus:border-blue-500 font-mono placeholder-surface-600"
68989
+ }
68990
+ ),
68991
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
68992
+ "button",
68993
+ {
68994
+ onClick: captureSnapshot,
68995
+ disabled: capturing || !specUrl.trim() || !workspace,
68996
+ title: "Fetch and pin this spec as a versioned snapshot",
68997
+ className: "px-2.5 text-xs bg-surface-800 hover:bg-surface-700 disabled:opacity-50 disabled:hover:bg-surface-800 rounded transition-colors",
68998
+ children: capturing ? "…" : "Pin"
68999
+ }
69000
+ )
69001
+ ] }),
69002
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-surface-600 mt-1 leading-relaxed", children: "Pin a snapshot to run against a specific spec version later, even after the provider ships an update." })
68849
69003
  ] }),
68850
69004
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
68851
69005
  /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "text-[10px] text-surface-500 uppercase tracking-wider font-medium block mb-1", children: [
@@ -68870,7 +69024,7 @@ function ContractPanel() {
68870
69024
  "button",
68871
69025
  {
68872
69026
  onClick: runContracts,
68873
- disabled: running || mode !== "consumer" && !specUrl.trim(),
69027
+ disabled: running || mode !== "consumer" && !specUrl.trim() && !activeSnapshotRelPath,
68874
69028
  className: "px-3 py-1 text-xs bg-blue-700 hover:bg-blue-600 disabled:bg-surface-800 disabled:text-surface-600 rounded transition-colors font-medium",
68875
69029
  children: running ? "Running…" : "Run"
68876
69030
  }
@@ -70241,7 +70395,7 @@ function App() {
70241
70395
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "#6aa3c8" }, children: "Spector" }),
70242
70396
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-2 text-[10px] font-normal opacity-50", children: [
70243
70397
  "v",
70244
- "0.2.2"
70398
+ "0.2.3"
70245
70399
  ] }),
70246
70400
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mx-2 opacity-30", children: "·" }),
70247
70401
  /* @__PURE__ */ jsxRuntimeExports.jsx(