@testsmith/api-spector 0.2.1 → 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 = {
@@ -56237,7 +56265,6 @@ const SNIPPET_GROUPS = [
56237
56265
  {
56238
56266
  label: "Check JSON value",
56239
56267
  code: `sp.test("JSON field equals value", function() {
56240
- const json = sp.response.json();
56241
56268
  sp.expect(json.field).to.equal("expected_value");
56242
56269
  });`
56243
56270
  },
@@ -56252,7 +56279,7 @@ const SNIPPET_GROUPS = [
56252
56279
  },
56253
56280
  required: ["id", "name"]
56254
56281
  };
56255
- sp.expect(tv4.validate(sp.response.json(), schema)).to.be.true;
56282
+ sp.expect(tv4.validate(json, schema)).to.be.true;
56256
56283
  });`
56257
56284
  }
56258
56285
  ]
@@ -56284,7 +56311,6 @@ const SNIPPET_GROUPS = [
56284
56311
  {
56285
56312
  label: "Save token from response (use in next requests)",
56286
56313
  code: `// Use collectionVariables so the value persists across requests
56287
- const json = sp.response.json();
56288
56314
  sp.collectionVariables.set("token", json.access_token);`
56289
56315
  },
56290
56316
  {
@@ -56369,22 +56395,20 @@ sp.collectionVariables.set("token", json.access_token);`
56369
56395
  items: [
56370
56396
  {
56371
56397
  label: "Save JSON field to variable",
56372
- code: `const json = sp.response.json();
56373
- sp.variables.set("field_value", json.field);`
56398
+ code: `sp.variables.set("field_value", json.field);`
56374
56399
  },
56375
56400
  {
56376
56401
  label: "Save JSON field to environment",
56377
- code: `const json = sp.response.json();
56378
- sp.environment.set("token", json.token);`
56402
+ code: `sp.environment.set("token", json.token);`
56379
56403
  },
56380
56404
  {
56381
56405
  label: "Extract via JSONPath to variable",
56382
- code: `const matches = sp.jsonPath(sp.response.json(), '$.data[0].id');
56406
+ code: `const matches = sp.jsonPath(json, '$.data[0].id');
56383
56407
  sp.variables.set("extracted_value", String(matches[0] ?? ''));`
56384
56408
  },
56385
56409
  {
56386
56410
  label: "Extract via JSONPath to environment",
56387
- code: `const matches = sp.jsonPath(sp.response.json(), '$.data[0].id');
56411
+ code: `const matches = sp.jsonPath(json, '$.data[0].id');
56388
56412
  sp.environment.set("extracted_value", String(matches[0] ?? ''));`
56389
56413
  },
56390
56414
  {
@@ -56398,6 +56422,26 @@ sp.environment.set("extracted_value", String(matches[0] ?? ''));`
56398
56422
  ]
56399
56423
  }
56400
56424
  ];
56425
+ const JSON_DECL = "const json = sp.response.json();";
56426
+ const JSON_DECL_RX_G = /[ \t]*const\s+json\s*=\s*sp\.response\.json\(\)\s*;?\s*\n?/g;
56427
+ function snippetUsesJson(snippet2) {
56428
+ const withoutDecl = snippet2.replace(JSON_DECL_RX_G, "");
56429
+ return /\bjson\b/.test(withoutDecl);
56430
+ }
56431
+ function appendSnippetToScript(existing, snippet2) {
56432
+ const cleanedSnippet = snippet2.replace(JSON_DECL_RX_G, "").replace(/^\n+/, "");
56433
+ const sep = existing.trim() ? "\n\n" : "";
56434
+ let combined = existing + sep + cleanedSnippet;
56435
+ const needsJson = snippetUsesJson(existing) || snippetUsesJson(cleanedSnippet);
56436
+ const hasTopDecl = /^\s*const\s+json\s*=\s*sp\.response\.json\(\)/m.test(combined);
56437
+ if (needsJson && !hasTopDecl) {
56438
+ combined = combined.replace(JSON_DECL_RX_G, "");
56439
+ combined = `${JSON_DECL}
56440
+
56441
+ ${combined.replace(/^\n+/, "")}`;
56442
+ }
56443
+ return combined;
56444
+ }
56401
56445
  function ScriptsTab({ request, onChange }) {
56402
56446
  const activeTabId = useStore((s) => s.activeTabId);
56403
56447
  const activeAppTab = useStore((s) => s.tabs.find((t2) => t2.id === s.activeTabId));
@@ -56422,9 +56466,12 @@ function ScriptsTab({ request, onChange }) {
56422
56466
  else onChange({ graphqlIntrospectionScript: code2 });
56423
56467
  }
56424
56468
  function insertSnippet2(code2) {
56425
- const current2 = value;
56426
- const separator = current2.trim() ? "\n\n" : "";
56427
- handleChange(current2 + separator + code2);
56469
+ if (scriptType === "post") {
56470
+ handleChange(appendSnippetToScript(value, code2));
56471
+ } else {
56472
+ const separator = value.trim() ? "\n\n" : "";
56473
+ handleChange(value + separator + code2);
56474
+ }
56428
56475
  }
56429
56476
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 h-full min-h-0", children: [
56430
56477
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col flex-1 min-w-0 gap-2", children: [
@@ -57514,8 +57561,8 @@ var scope = {};
57514
57561
  var util = {};
57515
57562
  Object.defineProperty(util, "__esModule", { value: true });
57516
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;
57517
- const codegen_1$v = codegen;
57518
- const code_1$a = code$1;
57564
+ const codegen_1$q = codegen;
57565
+ const code_1$9 = code$1;
57519
57566
  function toHash(arr) {
57520
57567
  const hash = {};
57521
57568
  for (const item of arr)
@@ -57568,9 +57615,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
57568
57615
  if (typeof schema == "number" || typeof schema == "boolean")
57569
57616
  return schema;
57570
57617
  if (typeof schema == "string")
57571
- return (0, codegen_1$v._)`${schema}`;
57618
+ return (0, codegen_1$q._)`${schema}`;
57572
57619
  }
57573
- 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)}`;
57574
57621
  }
57575
57622
  util.schemaRefOrVal = schemaRefOrVal;
57576
57623
  function unescapeFragment(str) {
@@ -57602,20 +57649,20 @@ function eachItem(xs, f) {
57602
57649
  util.eachItem = eachItem;
57603
57650
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
57604
57651
  return (gen, from, to, toName) => {
57605
- 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);
57606
- 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;
57607
57654
  };
57608
57655
  }
57609
57656
  util.mergeEvaluated = {
57610
57657
  props: makeMergeEvaluated({
57611
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
57612
- 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})`));
57613
57660
  }),
57614
- 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`, () => {
57615
57662
  if (from === true) {
57616
57663
  gen.assign(to, true);
57617
57664
  } else {
57618
- gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
57665
+ gen.assign(to, (0, codegen_1$q._)`${to} || {}`);
57619
57666
  setEvaluated(gen, to, from);
57620
57667
  }
57621
57668
  }),
@@ -57623,8 +57670,8 @@ util.mergeEvaluated = {
57623
57670
  resultToName: evaluatedPropsToName
57624
57671
  }),
57625
57672
  items: makeMergeEvaluated({
57626
- 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}`)),
57627
- 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}`)),
57628
57675
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
57629
57676
  resultToName: (gen, items2) => gen.var("items", items2)
57630
57677
  })
@@ -57632,21 +57679,21 @@ util.mergeEvaluated = {
57632
57679
  function evaluatedPropsToName(gen, ps) {
57633
57680
  if (ps === true)
57634
57681
  return gen.var("props", true);
57635
- const props = gen.var("props", (0, codegen_1$v._)`{}`);
57682
+ const props = gen.var("props", (0, codegen_1$q._)`{}`);
57636
57683
  if (ps !== void 0)
57637
57684
  setEvaluated(gen, props, ps);
57638
57685
  return props;
57639
57686
  }
57640
57687
  util.evaluatedPropsToName = evaluatedPropsToName;
57641
57688
  function setEvaluated(gen, props, ps) {
57642
- 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));
57643
57690
  }
57644
57691
  util.setEvaluated = setEvaluated;
57645
57692
  const snippets = {};
57646
57693
  function useFunc(gen, f) {
57647
57694
  return gen.scopeValue("func", {
57648
57695
  ref: f,
57649
- 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))
57650
57697
  });
57651
57698
  }
57652
57699
  util.useFunc = useFunc;
@@ -57656,11 +57703,11 @@ var Type;
57656
57703
  Type2[Type2["Str"] = 1] = "Str";
57657
57704
  })(Type || (util.Type = Type = {}));
57658
57705
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
57659
- if (dataProp instanceof codegen_1$v.Name) {
57706
+ if (dataProp instanceof codegen_1$q.Name) {
57660
57707
  const isNumber = dataPropType === Type.Num;
57661
- 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")`;
57662
57709
  }
57663
- return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
57710
+ return jsPropertySyntax ? (0, codegen_1$q.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
57664
57711
  }
57665
57712
  util.getErrorPath = getErrorPath;
57666
57713
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -57674,35 +57721,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
57674
57721
  util.checkStrictMode = checkStrictMode;
57675
57722
  var names$1 = {};
57676
57723
  Object.defineProperty(names$1, "__esModule", { value: true });
57677
- const codegen_1$u = codegen;
57724
+ const codegen_1$p = codegen;
57678
57725
  const names = {
57679
57726
  // validation function arguments
57680
- data: new codegen_1$u.Name("data"),
57727
+ data: new codegen_1$p.Name("data"),
57681
57728
  // data passed to validation function
57682
57729
  // args passed from referencing schema
57683
- valCxt: new codegen_1$u.Name("valCxt"),
57730
+ valCxt: new codegen_1$p.Name("valCxt"),
57684
57731
  // validation/data context - should not be used directly, it is destructured to the names below
57685
- instancePath: new codegen_1$u.Name("instancePath"),
57686
- parentData: new codegen_1$u.Name("parentData"),
57687
- parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
57688
- 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"),
57689
57736
  // root data - same as the data passed to the first/top validation function
57690
- dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
57737
+ dynamicAnchors: new codegen_1$p.Name("dynamicAnchors"),
57691
57738
  // used to support recursiveRef and dynamicRef
57692
57739
  // function scoped variables
57693
- vErrors: new codegen_1$u.Name("vErrors"),
57740
+ vErrors: new codegen_1$p.Name("vErrors"),
57694
57741
  // null or array of validation errors
57695
- errors: new codegen_1$u.Name("errors"),
57742
+ errors: new codegen_1$p.Name("errors"),
57696
57743
  // counter of validation errors
57697
- this: new codegen_1$u.Name("this"),
57744
+ this: new codegen_1$p.Name("this"),
57698
57745
  // "globals"
57699
- self: new codegen_1$u.Name("self"),
57700
- scope: new codegen_1$u.Name("scope"),
57746
+ self: new codegen_1$p.Name("self"),
57747
+ scope: new codegen_1$p.Name("scope"),
57701
57748
  // JTD serialize/parse name for JSON string and position
57702
- json: new codegen_1$u.Name("json"),
57703
- jsonPos: new codegen_1$u.Name("jsonPos"),
57704
- jsonLen: new codegen_1$u.Name("jsonLen"),
57705
- 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")
57706
57753
  };
57707
57754
  names$1.default = names;
57708
57755
  (function(exports$1) {
@@ -57822,49 +57869,55 @@ names$1.default = names;
57822
57869
  keyValues.push([E.propertyName, propertyName2]);
57823
57870
  }
57824
57871
  })(errors);
57825
- Object.defineProperty(boolSchema, "__esModule", { value: true });
57826
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
57827
- const errors_1$3 = errors;
57828
- const codegen_1$t = codegen;
57829
- const names_1$6 = names$1;
57830
- const boolError = {
57831
- message: "boolean schema is false"
57832
- };
57833
- function topBoolOrEmptySchema(it) {
57834
- const { gen, schema, validateName: validateName2 } = it;
57835
- if (schema === false) {
57836
- falseSchemaError(it, false);
57837
- } else if (typeof schema == "object" && schema.$async === true) {
57838
- gen.return(names_1$6.default.data);
57839
- } else {
57840
- gen.assign((0, codegen_1$t._)`${validateName2}.errors`, null);
57841
- 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
+ }
57842
57894
  }
57843
- }
57844
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
57845
- function boolOrEmptySchema(it, valid) {
57846
- const { gen, schema } = it;
57847
- if (schema === false) {
57848
- gen.var(valid, false);
57849
- falseSchemaError(it);
57850
- } else {
57851
- 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);
57852
57919
  }
57853
- }
57854
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
57855
- function falseSchemaError(it, overrideAllErrors) {
57856
- const { gen, data } = it;
57857
- const cxt = {
57858
- gen,
57859
- keyword: "false schema",
57860
- data,
57861
- schema: false,
57862
- schemaCode: false,
57863
- schemaValue: false,
57864
- params: {},
57865
- it
57866
- };
57867
- (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
57920
+ return boolSchema;
57868
57921
  }
57869
57922
  var dataType = {};
57870
57923
  var rules = {};
@@ -57912,10 +57965,10 @@ applicability.shouldUseRule = shouldUseRule;
57912
57965
  Object.defineProperty(dataType, "__esModule", { value: true });
57913
57966
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
57914
57967
  const rules_1 = rules;
57915
- const applicability_1$1 = applicability;
57916
- const errors_1$2 = errors;
57917
- const codegen_1$s = codegen;
57918
- 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;
57919
57972
  var DataType;
57920
57973
  (function(DataType2) {
57921
57974
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -57947,7 +58000,7 @@ dataType.getJSONTypes = getJSONTypes;
57947
58000
  function coerceAndCheckDataType(it, types2) {
57948
58001
  const { gen, data, opts } = it;
57949
58002
  const coerceTo = coerceToTypes(types2, opts.coerceTypes);
57950
- 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]));
57951
58004
  if (checkTypes) {
57952
58005
  const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
57953
58006
  gen.if(wrongType, () => {
@@ -57966,12 +58019,12 @@ function coerceToTypes(types2, coerceTypes) {
57966
58019
  }
57967
58020
  function coerceData(it, types2, coerceTo) {
57968
58021
  const { gen, data, opts } = it;
57969
- const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
57970
- 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`);
57971
58024
  if (opts.coerceTypes === "array") {
57972
- 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)));
57973
58026
  }
57974
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
58027
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
57975
58028
  for (const t2 of coerceTo) {
57976
58029
  if (COERCIBLE.has(t2) || t2 === "array" && opts.coerceTypes === "array") {
57977
58030
  coerceSpecificType(t2);
@@ -57980,63 +58033,63 @@ function coerceData(it, types2, coerceTo) {
57980
58033
  gen.else();
57981
58034
  reportTypeError(it);
57982
58035
  gen.endIf();
57983
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
58036
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
57984
58037
  gen.assign(data, coerced);
57985
58038
  assignParentData(it, coerced);
57986
58039
  });
57987
58040
  function coerceSpecificType(t2) {
57988
58041
  switch (t2) {
57989
58042
  case "string":
57990
- 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._)`""`);
57991
58044
  return;
57992
58045
  case "number":
57993
- gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
57994
- || (${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}`);
57995
58048
  return;
57996
58049
  case "integer":
57997
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
57998
- || (${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}`);
57999
58052
  return;
58000
58053
  case "boolean":
58001
- 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);
58002
58055
  return;
58003
58056
  case "null":
58004
- gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
58057
+ gen.elseIf((0, codegen_1$o._)`${data} === "" || ${data} === 0 || ${data} === false`);
58005
58058
  gen.assign(coerced, null);
58006
58059
  return;
58007
58060
  case "array":
58008
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
58009
- || ${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}]`);
58010
58063
  }
58011
58064
  }
58012
58065
  }
58013
58066
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
58014
- 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));
58015
58068
  }
58016
58069
  function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
58017
- 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;
58018
58071
  let cond;
58019
58072
  switch (dataType2) {
58020
58073
  case "null":
58021
- return (0, codegen_1$s._)`${data} ${EQ} null`;
58074
+ return (0, codegen_1$o._)`${data} ${EQ} null`;
58022
58075
  case "array":
58023
- cond = (0, codegen_1$s._)`Array.isArray(${data})`;
58076
+ cond = (0, codegen_1$o._)`Array.isArray(${data})`;
58024
58077
  break;
58025
58078
  case "object":
58026
- 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})`;
58027
58080
  break;
58028
58081
  case "integer":
58029
- cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
58082
+ cond = numCond((0, codegen_1$o._)`!(${data} % 1) && !isNaN(${data})`);
58030
58083
  break;
58031
58084
  case "number":
58032
58085
  cond = numCond();
58033
58086
  break;
58034
58087
  default:
58035
- return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
58088
+ return (0, codegen_1$o._)`typeof ${data} ${EQ} ${dataType2}`;
58036
58089
  }
58037
- return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
58038
- function numCond(_cond = codegen_1$s.nil) {
58039
- 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);
58040
58093
  }
58041
58094
  }
58042
58095
  dataType.checkDataType = checkDataType;
@@ -58045,35 +58098,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
58045
58098
  return checkDataType(dataTypes[0], data, strictNums, correct);
58046
58099
  }
58047
58100
  let cond;
58048
- const types2 = (0, util_1$r.toHash)(dataTypes);
58101
+ const types2 = (0, util_1$o.toHash)(dataTypes);
58049
58102
  if (types2.array && types2.object) {
58050
- const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
58051
- 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}`;
58052
58105
  delete types2.null;
58053
58106
  delete types2.array;
58054
58107
  delete types2.object;
58055
58108
  } else {
58056
- cond = codegen_1$s.nil;
58109
+ cond = codegen_1$o.nil;
58057
58110
  }
58058
58111
  if (types2.number)
58059
58112
  delete types2.integer;
58060
58113
  for (const t2 in types2)
58061
- 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));
58062
58115
  return cond;
58063
58116
  }
58064
58117
  dataType.checkDataTypes = checkDataTypes;
58065
58118
  const typeError = {
58066
58119
  message: ({ schema }) => `must be ${schema}`,
58067
- 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}}`
58068
58121
  };
58069
58122
  function reportTypeError(it) {
58070
58123
  const cxt = getTypeErrorContext(it);
58071
- (0, errors_1$2.reportError)(cxt, typeError);
58124
+ (0, errors_1.reportError)(cxt, typeError);
58072
58125
  }
58073
58126
  dataType.reportTypeError = reportTypeError;
58074
58127
  function getTypeErrorContext(it) {
58075
58128
  const { gen, data, schema } = it;
58076
- const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
58129
+ const schemaCode = (0, util_1$o.schemaRefOrVal)(it, schema, "type");
58077
58130
  return {
58078
58131
  gen,
58079
58132
  keyword: "type",
@@ -58087,54 +58140,60 @@ function getTypeErrorContext(it) {
58087
58140
  };
58088
58141
  }
58089
58142
  var defaults = {};
58090
- Object.defineProperty(defaults, "__esModule", { value: true });
58091
- defaults.assignDefaults = void 0;
58092
- const codegen_1$r = codegen;
58093
- const util_1$q = util;
58094
- function assignDefaults(it, ty) {
58095
- const { properties: properties2, items: items2 } = it.schema;
58096
- if (ty === "object" && properties2) {
58097
- for (const key in properties2) {
58098
- assignDefault(it, key, properties2[key].default);
58099
- }
58100
- } else if (ty === "array" && Array.isArray(items2)) {
58101
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
58102
- }
58103
- }
58104
- defaults.assignDefaults = assignDefaults;
58105
- function assignDefault(it, prop, defaultValue) {
58106
- const { gen, compositeRule, data, opts } = it;
58107
- if (defaultValue === void 0)
58108
- return;
58109
- const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
58110
- if (compositeRule) {
58111
- (0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
58112
- 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
+ }
58113
58160
  }
58114
- let condition = (0, codegen_1$r._)`${childData} === undefined`;
58115
- if (opts.useDefaults === "empty") {
58116
- 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)}`);
58117
58176
  }
58118
- gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
58177
+ return defaults;
58119
58178
  }
58120
58179
  var keyword = {};
58121
58180
  var code = {};
58122
58181
  Object.defineProperty(code, "__esModule", { value: true });
58123
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;
58124
- const codegen_1$q = codegen;
58125
- const util_1$p = util;
58126
- 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;
58127
58186
  const util_2$1 = util;
58128
58187
  function checkReportMissingProp(cxt, prop) {
58129
58188
  const { gen, data, it } = cxt;
58130
58189
  gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
58131
- cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
58190
+ cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
58132
58191
  cxt.error();
58133
58192
  });
58134
58193
  }
58135
58194
  code.checkReportMissingProp = checkReportMissingProp;
58136
58195
  function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
58137
- 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}`)));
58138
58197
  }
58139
58198
  code.checkMissingProp = checkMissingProp;
58140
58199
  function reportMissingProp(cxt, missing) {
@@ -58146,22 +58205,22 @@ function hasPropFunc(gen) {
58146
58205
  return gen.scopeValue("func", {
58147
58206
  // eslint-disable-next-line @typescript-eslint/unbound-method
58148
58207
  ref: Object.prototype.hasOwnProperty,
58149
- code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
58208
+ code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
58150
58209
  });
58151
58210
  }
58152
58211
  code.hasPropFunc = hasPropFunc;
58153
58212
  function isOwnProperty(gen, data, property) {
58154
- return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
58213
+ return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
58155
58214
  }
58156
58215
  code.isOwnProperty = isOwnProperty;
58157
58216
  function propertyInData(gen, data, property, ownProperties) {
58158
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
58159
- 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;
58160
58219
  }
58161
58220
  code.propertyInData = propertyInData;
58162
58221
  function noPropertyInData(gen, data, property, ownProperties) {
58163
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
58164
- 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;
58165
58224
  }
58166
58225
  code.noPropertyInData = noPropertyInData;
58167
58226
  function allSchemaProperties(schemaMap) {
@@ -58169,24 +58228,24 @@ function allSchemaProperties(schemaMap) {
58169
58228
  }
58170
58229
  code.allSchemaProperties = allSchemaProperties;
58171
58230
  function schemaProperties(it, schemaMap) {
58172
- 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]));
58173
58232
  }
58174
58233
  code.schemaProperties = schemaProperties;
58175
58234
  function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
58176
- 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;
58177
58236
  const valCxt = [
58178
- [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
58179
- [names_1$5.default.parentData, it.parentData],
58180
- [names_1$5.default.parentDataProperty, it.parentDataProperty],
58181
- [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]
58182
58241
  ];
58183
58242
  if (it.opts.dynamicRef)
58184
- valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
58185
- const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
58186
- 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})`;
58187
58246
  }
58188
58247
  code.callValidateCode = callValidateCode;
58189
- const newRegExp = (0, codegen_1$q._)`new RegExp`;
58248
+ const newRegExp = (0, codegen_1$n._)`new RegExp`;
58190
58249
  function usePattern({ gen, it: { opts } }, pattern2) {
58191
58250
  const u = opts.unicodeRegExp ? "u" : "";
58192
58251
  const { regExp } = opts.code;
@@ -58194,7 +58253,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
58194
58253
  return gen.scopeValue("pattern", {
58195
58254
  key: rx.toString(),
58196
58255
  ref: rx,
58197
- 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})`
58198
58257
  });
58199
58258
  }
58200
58259
  code.usePattern = usePattern;
@@ -58210,14 +58269,14 @@ function validateArray(cxt) {
58210
58269
  validateItems(() => gen.break());
58211
58270
  return valid;
58212
58271
  function validateItems(notValid) {
58213
- const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
58272
+ const len = gen.const("len", (0, codegen_1$n._)`${data}.length`);
58214
58273
  gen.forRange("i", 0, len, (i) => {
58215
58274
  cxt.subschema({
58216
58275
  keyword: keyword2,
58217
58276
  dataProp: i,
58218
- dataPropType: util_1$p.Type.Num
58277
+ dataPropType: util_1$n.Type.Num
58219
58278
  }, valid);
58220
- gen.if((0, codegen_1$q.not)(valid), notValid);
58279
+ gen.if((0, codegen_1$n.not)(valid), notValid);
58221
58280
  });
58222
58281
  }
58223
58282
  }
@@ -58226,7 +58285,7 @@ function validateUnion(cxt) {
58226
58285
  const { gen, schema, keyword: keyword2, it } = cxt;
58227
58286
  if (!Array.isArray(schema))
58228
58287
  throw new Error("ajv implementation error");
58229
- 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));
58230
58289
  if (alwaysValid && !it.opts.unevaluated)
58231
58290
  return;
58232
58291
  const valid = gen.let("valid", false);
@@ -58237,202 +58296,214 @@ function validateUnion(cxt) {
58237
58296
  schemaProp: i,
58238
58297
  compositeRule: true
58239
58298
  }, schValid);
58240
- gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
58299
+ gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
58241
58300
  const merged = cxt.mergeValidEvaluated(schCxt, schValid);
58242
58301
  if (!merged)
58243
- gen.if((0, codegen_1$q.not)(valid));
58302
+ gen.if((0, codegen_1$n.not)(valid));
58244
58303
  }));
58245
58304
  cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
58246
58305
  }
58247
58306
  code.validateUnion = validateUnion;
58248
- Object.defineProperty(keyword, "__esModule", { value: true });
58249
- keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
58250
- const codegen_1$p = codegen;
58251
- const names_1$4 = names$1;
58252
- const code_1$9 = code;
58253
- const errors_1$1 = errors;
58254
- function macroKeywordCode(cxt, def2) {
58255
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
58256
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
58257
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
58258
- if (it.opts.validateSchema !== false)
58259
- it.self.validateSchema(macroSchema, true);
58260
- const valid = gen.name("valid");
58261
- cxt.subschema({
58262
- schema: macroSchema,
58263
- schemaPath: codegen_1$p.nil,
58264
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
58265
- topSchemaRef: schemaRef,
58266
- compositeRule: true
58267
- }, valid);
58268
- cxt.pass(valid, () => cxt.error(true));
58269
- }
58270
- keyword.macroKeywordCode = macroKeywordCode;
58271
- function funcKeywordCode(cxt, def2) {
58272
- var _a2;
58273
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
58274
- checkAsyncKeyword(it, def2);
58275
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
58276
- const validateRef = useKeyword(gen, keyword2, validate2);
58277
- const valid = gen.let("valid");
58278
- cxt.block$data(valid, validateKeyword);
58279
- cxt.ok((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid);
58280
- function validateKeyword() {
58281
- if (def2.errors === false) {
58282
- assignValid();
58283
- if (def2.modifying)
58284
- modifyData(cxt);
58285
- reportErrs(() => cxt.error());
58286
- } else {
58287
- const ruleErrs = def2.async ? validateAsync() : validateSync();
58288
- if (def2.modifying)
58289
- modifyData(cxt);
58290
- reportErrs(() => addErrs(cxt, ruleErrs));
58291
- }
58292
- }
58293
- function validateAsync() {
58294
- const ruleErrs = gen.let("ruleErrs", null);
58295
- 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)));
58296
- return ruleErrs;
58297
- }
58298
- function validateSync() {
58299
- const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
58300
- gen.assign(validateErrs, null);
58301
- assignValid(codegen_1$p.nil);
58302
- return validateErrs;
58303
- }
58304
- function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
58305
- const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
58306
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
58307
- gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
58308
- }
58309
- function reportErrs(errors2) {
58310
- var _a3;
58311
- gen.if((0, codegen_1$p.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
58312
- }
58313
- }
58314
- keyword.funcKeywordCode = funcKeywordCode;
58315
- function modifyData(cxt) {
58316
- const { gen, data, it } = cxt;
58317
- gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
58318
- }
58319
- function addErrs(cxt, errs) {
58320
- const { gen } = cxt;
58321
- gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
58322
- 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`);
58323
- (0, errors_1$1.extendErrors)(cxt);
58324
- }, () => cxt.error());
58325
- }
58326
- function checkAsyncKeyword({ schemaEnv }, def2) {
58327
- if (def2.async && !schemaEnv.$async)
58328
- throw new Error("async keyword in sync schema");
58329
- }
58330
- function useKeyword(gen, keyword2, result) {
58331
- if (result === void 0)
58332
- throw new Error(`keyword "${keyword2}" failed to compile`);
58333
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
58334
- }
58335
- function validSchemaType(schema, schemaType, allowUndefined = false) {
58336
- 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");
58337
- }
58338
- keyword.validSchemaType = validSchemaType;
58339
- function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
58340
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
58341
- 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));
58342
58332
  }
58343
- const deps = def2.dependencies;
58344
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
58345
- 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
+ }
58346
58376
  }
58347
- if (def2.validateSchema) {
58348
- const valid = def2.validateSchema(schema[keyword2]);
58349
- if (!valid) {
58350
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
58351
- if (opts.validateSchema === "log")
58352
- self.logger.error(msg);
58353
- else
58354
- 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
+ }
58355
58419
  }
58356
58420
  }
58421
+ keyword.validateKeywordUsage = validateKeywordUsage;
58422
+ return keyword;
58357
58423
  }
58358
- keyword.validateKeywordUsage = validateKeywordUsage;
58359
58424
  var subschema = {};
58360
- Object.defineProperty(subschema, "__esModule", { value: true });
58361
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
58362
- const codegen_1$o = codegen;
58363
- const util_1$o = util;
58364
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
58365
- if (keyword2 !== void 0 && schema !== void 0) {
58366
- throw new Error('both "keyword" and "schema" passed, only one allowed');
58367
- }
58368
- if (keyword2 !== void 0) {
58369
- const sch = it.schema[keyword2];
58370
- return schemaProp === void 0 ? {
58371
- schema: sch,
58372
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
58373
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
58374
- } : {
58375
- schema: sch[schemaProp],
58376
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
58377
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
58378
- };
58379
- }
58380
- if (schema !== void 0) {
58381
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
58382
- 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');
58383
58436
  }
58384
- return {
58385
- schema,
58386
- schemaPath,
58387
- topSchemaRef,
58388
- errSchemaPath
58389
- };
58390
- }
58391
- throw new Error('either "keyword" or "schema" must be passed');
58392
- }
58393
- subschema.getSubschema = getSubschema;
58394
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName: propertyName2 }) {
58395
- if (data !== void 0 && dataProp !== void 0) {
58396
- throw new Error('both "data" and "dataProp" passed, only one allowed');
58397
- }
58398
- const { gen } = it;
58399
- if (dataProp !== void 0) {
58400
- const { errorPath, dataPathArr, opts } = it;
58401
- const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
58402
- dataContextProps(nextData);
58403
- subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
58404
- subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
58405
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
58406
- }
58407
- if (data !== void 0) {
58408
- const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
58409
- dataContextProps(nextData);
58410
- if (propertyName2 !== void 0)
58411
- subschema2.propertyName = propertyName2;
58412
- }
58413
- if (dataTypes)
58414
- subschema2.dataTypes = dataTypes;
58415
- function dataContextProps(_nextData) {
58416
- subschema2.data = _nextData;
58417
- subschema2.dataLevel = it.dataLevel + 1;
58418
- subschema2.dataTypes = [];
58419
- it.definedProperties = /* @__PURE__ */ new Set();
58420
- subschema2.parentData = it.data;
58421
- subschema2.dataNames = [...it.dataNames, _nextData];
58422
- }
58423
- }
58424
- subschema.extendSubschemaData = extendSubschemaData;
58425
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
58426
- if (compositeRule !== void 0)
58427
- subschema2.compositeRule = compositeRule;
58428
- if (createErrors !== void 0)
58429
- subschema2.createErrors = createErrors;
58430
- if (allErrors !== void 0)
58431
- subschema2.allErrors = allErrors;
58432
- subschema2.jtdDiscriminator = jtdDiscriminator;
58433
- subschema2.jtdMetadata = jtdMetadata;
58434
- }
58435
- 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
+ }
58436
58507
  var resolve$2 = {};
58437
58508
  var fastDeepEqual = function equal(a, b) {
58438
58509
  if (a === b) return true;
@@ -58547,7 +58618,7 @@ function escapeJsonPtr(str) {
58547
58618
  var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
58548
58619
  Object.defineProperty(resolve$2, "__esModule", { value: true });
58549
58620
  resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
58550
- const util_1$n = util;
58621
+ const util_1$m = util;
58551
58622
  const equal$3 = fastDeepEqual;
58552
58623
  const traverse = jsonSchemaTraverseExports;
58553
58624
  const SIMPLE_INLINED = /* @__PURE__ */ new Set([
@@ -58606,7 +58677,7 @@ function countKeys(schema) {
58606
58677
  if (SIMPLE_INLINED.has(key))
58607
58678
  continue;
58608
58679
  if (typeof schema[key] == "object") {
58609
- (0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
58680
+ (0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys(sch));
58610
58681
  }
58611
58682
  if (count === Infinity)
58612
58683
  return Infinity;
@@ -58694,516 +58765,528 @@ function getSchemaRefs(schema, baseId) {
58694
58765
  }
58695
58766
  }
58696
58767
  resolve$2.getSchemaRefs = getSchemaRefs;
58697
- Object.defineProperty(validate, "__esModule", { value: true });
58698
- validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
58699
- const boolSchema_1 = boolSchema;
58700
- const dataType_1$1 = dataType;
58701
- const applicability_1 = applicability;
58702
- const dataType_2 = dataType;
58703
- const defaults_1 = defaults;
58704
- const keyword_1 = keyword;
58705
- const subschema_1 = subschema;
58706
- const codegen_1$n = codegen;
58707
- const names_1$3 = names$1;
58708
- const resolve_1$2 = resolve$2;
58709
- const util_1$m = util;
58710
- const errors_1 = errors;
58711
- function validateFunctionCode(it) {
58712
- if (isSchemaObj(it)) {
58713
- checkKeywords(it);
58714
- if (schemaCxtHasRules(it)) {
58715
- topSchemaObjCode(it);
58716
- 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
+ }
58717
58793
  }
58794
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
58718
58795
  }
58719
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
58720
- }
58721
- validate.validateFunctionCode = validateFunctionCode;
58722
- function validateFunction({ gen, validateName: validateName2, schema, schemaEnv, opts }, body) {
58723
- if (opts.code.es5) {
58724
- gen.func(validateName2, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
58725
- gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
58726
- destructureValCxtES5(gen, opts);
58727
- 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._)`{}`);
58728
58826
  });
58729
- } else {
58730
- gen.func(validateName2, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
58731
- }
58732
- }
58733
- function destructureValCxt(opts) {
58734
- 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}}={}`;
58735
- }
58736
- function destructureValCxtES5(gen, opts) {
58737
- gen.if(names_1$3.default.valCxt, () => {
58738
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
58739
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
58740
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
58741
- gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
58742
- if (opts.dynamicRef)
58743
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
58744
- }, () => {
58745
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
58746
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
58747
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
58748
- gen.var(names_1$3.default.rootData, names_1$3.default.data);
58749
- if (opts.dynamicRef)
58750
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
58751
- });
58752
- }
58753
- function topSchemaObjCode(it) {
58754
- const { schema, opts, gen } = it;
58755
- 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;
58756
58876
  if (opts.$comment && schema.$comment)
58757
58877
  commentKeyword(it);
58758
- checkNoDefault(it);
58759
- gen.let(names_1$3.default.vErrors, null);
58760
- gen.let(names_1$3.default.errors, 0);
58761
- if (opts.unevaluated)
58762
- resetEvaluated(it);
58763
- typeAndKeywords(it);
58764
- returnResults(it);
58765
- });
58766
- return;
58767
- }
58768
- function resetEvaluated(it) {
58769
- const { gen, validateName: validateName2 } = it;
58770
- it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName2}.evaluated`);
58771
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
58772
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
58773
- }
58774
- function funcSourceUrl(schema, opts) {
58775
- const schId = typeof schema == "object" && schema[opts.schemaId];
58776
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
58777
- }
58778
- function subschemaCode(it, valid) {
58779
- if (isSchemaObj(it)) {
58780
- checkKeywords(it);
58781
- if (schemaCxtHasRules(it)) {
58782
- subSchemaObjCode(it, valid);
58783
- 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}"`);
58784
58899
  }
58785
58900
  }
58786
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
58787
- }
58788
- function schemaCxtHasRules({ schema, self }) {
58789
- if (typeof schema == "boolean")
58790
- return !schema;
58791
- for (const key in schema)
58792
- if (self.RULES.all[key])
58793
- return true;
58794
- return false;
58795
- }
58796
- function isSchemaObj(it) {
58797
- return typeof it.schema != "boolean";
58798
- }
58799
- function subSchemaObjCode(it, valid) {
58800
- const { schema, gen, opts } = it;
58801
- if (opts.$comment && schema.$comment)
58802
- commentKeyword(it);
58803
- updateContext(it);
58804
- checkAsyncSchema(it);
58805
- const errsCount = gen.const("_errs", names_1$3.default.errors);
58806
- typeAndKeywords(it, errsCount);
58807
- gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
58808
- }
58809
- function checkKeywords(it) {
58810
- (0, util_1$m.checkUnknownRules)(it);
58811
- checkRefsAndKeywords(it);
58812
- }
58813
- function typeAndKeywords(it, errsCount) {
58814
- if (it.opts.jtd)
58815
- return schemaKeywords(it, [], false, errsCount);
58816
- const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
58817
- const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
58818
- schemaKeywords(it, types2, !checkedTypes, errsCount);
58819
- }
58820
- function checkRefsAndKeywords(it) {
58821
- const { schema, errSchemaPath, opts, self } = it;
58822
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self.RULES)) {
58823
- self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
58824
- }
58825
- }
58826
- function checkNoDefault(it) {
58827
- const { schema, opts } = it;
58828
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
58829
- (0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
58830
- }
58831
- }
58832
- function updateContext(it) {
58833
- const schId = it.schema[it.opts.schemaId];
58834
- if (schId)
58835
- it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
58836
- }
58837
- function checkAsyncSchema(it) {
58838
- if (it.schema.$async && !it.schemaEnv.$async)
58839
- throw new Error("async schema in sync schema");
58840
- }
58841
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
58842
- const msg = schema.$comment;
58843
- if (opts.$comment === true) {
58844
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
58845
- } else if (typeof opts.$comment == "function") {
58846
- const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
58847
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
58848
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
58849
- }
58850
- }
58851
- function returnResults(it) {
58852
- const { gen, schemaEnv, validateName: validateName2, ValidationError: ValidationError2, opts } = it;
58853
- if (schemaEnv.$async) {
58854
- 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})`));
58855
- } else {
58856
- gen.assign((0, codegen_1$n._)`${validateName2}.errors`, names_1$3.default.vErrors);
58857
- if (opts.unevaluated)
58858
- assignEvaluated(it);
58859
- gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
58860
- }
58861
- }
58862
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
58863
- if (props instanceof codegen_1$n.Name)
58864
- gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
58865
- if (items2 instanceof codegen_1$n.Name)
58866
- gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
58867
- }
58868
- function schemaKeywords(it, types2, typeErrors, errsCount) {
58869
- const { gen, schema, data, allErrors, opts, self } = it;
58870
- const { RULES } = self;
58871
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
58872
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
58873
- 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
+ }
58874
58906
  }
58875
- if (!opts.jtd)
58876
- checkStrictTypes(it, types2);
58877
- gen.block(() => {
58878
- for (const group of RULES.rules)
58879
- groupKeywords(group);
58880
- groupKeywords(RULES.post);
58881
- });
58882
- function groupKeywords(group) {
58883
- 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));
58884
58948
  return;
58885
- if (group.type) {
58886
- gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
58887
- iterateKeywords(it, group);
58888
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
58889
- gen.else();
58890
- (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);
58891
58970
  }
58892
- gen.endIf();
58893
- } else {
58894
- iterateKeywords(it, group);
58971
+ if (!allErrors)
58972
+ gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
58895
58973
  }
58896
- if (!allErrors)
58897
- gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
58898
58974
  }
58899
- }
58900
- function iterateKeywords(it, group) {
58901
- const { gen, schema, opts: { useDefaults } } = it;
58902
- if (useDefaults)
58903
- (0, defaults_1.assignDefaults)(it, group.type);
58904
- gen.block(() => {
58905
- for (const rule of group.rules) {
58906
- if ((0, applicability_1.shouldUseRule)(schema, rule)) {
58907
- 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
+ }
58908
58984
  }
58909
- }
58910
- });
58911
- }
58912
- function checkStrictTypes(it, types2) {
58913
- if (it.schemaEnv.meta || !it.opts.strictTypes)
58914
- return;
58915
- checkContextTypes(it, types2);
58916
- if (!it.opts.allowUnionTypes)
58917
- checkMultipleTypes(it, types2);
58918
- checkKeywordTypes(it, it.dataTypes);
58919
- }
58920
- function checkContextTypes(it, types2) {
58921
- if (!types2.length)
58922
- return;
58923
- if (!it.dataTypes.length) {
58924
- it.dataTypes = types2;
58925
- 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);
58926
58994
  }
58927
- types2.forEach((t2) => {
58928
- if (!includesType(it.dataTypes, t2)) {
58929
- 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;
58930
59001
  }
58931
- });
58932
- narrowSchemaTypes(it, types2);
58933
- }
58934
- function checkMultipleTypes(it, ts) {
58935
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
58936
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
58937
- }
58938
- }
58939
- function checkKeywordTypes(it, ts) {
58940
- const rules2 = it.self.RULES.all;
58941
- for (const keyword2 in rules2) {
58942
- const rule = rules2[keyword2];
58943
- if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
58944
- const { type: type2 } = rule.definition;
58945
- if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
58946
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
58947
- }
58948
- }
58949
- }
58950
- }
58951
- function hasApplicableType(schTs, kwdT) {
58952
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
58953
- }
58954
- function includesType(ts, t2) {
58955
- return ts.includes(t2) || t2 === "integer" && ts.includes("number");
58956
- }
58957
- function narrowSchemaTypes(it, withTypes) {
58958
- const ts = [];
58959
- for (const t2 of it.dataTypes) {
58960
- if (includesType(withTypes, t2))
58961
- ts.push(t2);
58962
- else if (withTypes.includes("integer") && t2 === "number")
58963
- ts.push("integer");
58964
- }
58965
- it.dataTypes = ts;
58966
- }
58967
- function strictTypesError(it, msg) {
58968
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
58969
- msg += ` at "${schemaPath}" (strictTypes)`;
58970
- (0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
58971
- }
58972
- class KeywordCxt {
58973
- constructor(it, def2, keyword2) {
58974
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
58975
- this.gen = it.gen;
58976
- this.allErrors = it.allErrors;
58977
- this.keyword = keyword2;
58978
- this.data = it.data;
58979
- this.schema = it.schema[keyword2];
58980
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
58981
- this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
58982
- this.schemaType = def2.schemaType;
58983
- this.parentSchema = it.schema;
58984
- this.params = {};
58985
- this.it = it;
58986
- this.def = def2;
58987
- if (this.$data) {
58988
- this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
58989
- } else {
58990
- this.schemaCode = this.schemaValue;
58991
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
58992
- 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);
58993
59072
  }
58994
59073
  }
58995
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
58996
- 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);
58997
59076
  }
58998
- }
58999
- result(condition, successAction, failAction) {
59000
- this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
59001
- }
59002
- failResult(condition, successAction, failAction) {
59003
- this.gen.if(condition);
59004
- if (failAction)
59005
- failAction();
59006
- 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);
59007
59106
  this.error();
59008
- if (successAction) {
59009
- this.gen.else();
59010
- successAction();
59011
- if (this.allErrors)
59012
- this.gen.endIf();
59013
- } else {
59014
59107
  if (this.allErrors)
59015
59108
  this.gen.endIf();
59016
59109
  else
59017
59110
  this.gen.else();
59018
59111
  }
59019
- }
59020
- pass(condition, failAction) {
59021
- this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
59022
- }
59023
- fail(condition) {
59024
- if (condition === void 0) {
59025
- 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) {
59026
59139
  if (!this.allErrors)
59027
- this.gen.if(false);
59028
- return;
59140
+ this.gen.if(cond);
59029
59141
  }
59030
- this.gen.if(condition);
59031
- this.error();
59032
- if (this.allErrors)
59033
- this.gen.endIf();
59034
- else
59035
- this.gen.else();
59036
- }
59037
- fail$data(condition) {
59038
- if (!this.$data)
59039
- return this.fail(condition);
59040
- const { schemaCode } = this;
59041
- this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
59042
- }
59043
- error(append, errorParams, errorPaths) {
59044
- if (errorParams) {
59045
- this.setParams(errorParams);
59046
- this._error(append, errorPaths);
59047
- this.setParams({});
59048
- return;
59142
+ setParams(obj, assign2) {
59143
+ if (assign2)
59144
+ Object.assign(this.params, obj);
59145
+ else
59146
+ this.params = obj;
59049
59147
  }
59050
- this._error(append, errorPaths);
59051
- }
59052
- _error(append, errorPaths) {
59053
- (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
59054
- }
59055
- $dataError() {
59056
- (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
59057
- }
59058
- reset() {
59059
- if (this.errsCount === void 0)
59060
- throw new Error('add "trackErrors" to keyword definition');
59061
- (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
59062
- }
59063
- ok(cond) {
59064
- if (!this.allErrors)
59065
- this.gen.if(cond);
59066
- }
59067
- setParams(obj, assign2) {
59068
- if (assign2)
59069
- Object.assign(this.params, obj);
59070
- else
59071
- this.params = obj;
59072
- }
59073
- block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
59074
- this.gen.block(() => {
59075
- this.check$data(valid, $dataValid);
59076
- codeBlock();
59077
- });
59078
- }
59079
- check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
59080
- if (!this.$data)
59081
- return;
59082
- const { gen, schemaCode, schemaType, def: def2 } = this;
59083
- gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
59084
- if (valid !== codegen_1$n.nil)
59085
- gen.assign(valid, true);
59086
- if (schemaType.length || def2.validateSchema) {
59087
- gen.elseIf(this.invalid$data());
59088
- this.$dataError();
59089
- if (valid !== codegen_1$n.nil)
59090
- 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
+ });
59091
59153
  }
59092
- gen.else();
59093
- }
59094
- invalid$data() {
59095
- const { gen, schemaCode, schemaType, def: def2, it } = this;
59096
- return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
59097
- function wrong$DataType() {
59098
- if (schemaType.length) {
59099
- if (!(schemaCode instanceof codegen_1$n.Name))
59100
- throw new Error("ajv implementation error");
59101
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
59102
- 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);
59103
59166
  }
59104
- return codegen_1$n.nil;
59167
+ gen.else();
59105
59168
  }
59106
- function invalid$DataSchema() {
59107
- if (def2.validateSchema) {
59108
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
59109
- 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);
59110
59206
  }
59111
- return codegen_1$n.nil;
59112
- }
59113
- }
59114
- subschema(appl, valid) {
59115
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
59116
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
59117
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
59118
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
59119
- subschemaCode(nextContext, valid);
59120
- return nextContext;
59121
- }
59122
- mergeEvaluated(schemaCxt, toName) {
59123
- const { it, gen } = this;
59124
- if (!it.opts.unevaluated)
59125
- return;
59126
- if (it.props !== true && schemaCxt.props !== void 0) {
59127
- it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
59128
59207
  }
59129
- if (it.items !== true && schemaCxt.items !== void 0) {
59130
- 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
+ }
59131
59214
  }
59132
59215
  }
59133
- mergeValidEvaluated(schemaCxt, valid) {
59134
- const { it, gen } = this;
59135
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
59136
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
59137
- 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);
59138
59227
  }
59139
59228
  }
59140
- }
59141
- validate.KeywordCxt = KeywordCxt;
59142
- function keywordCode(it, keyword2, def2, ruleType) {
59143
- const cxt = new KeywordCxt(it, def2, keyword2);
59144
- if ("code" in def2) {
59145
- def2.code(cxt, ruleType);
59146
- } else if (cxt.$data && def2.validate) {
59147
- (0, keyword_1.funcKeywordCode)(cxt, def2);
59148
- } else if ("macro" in def2) {
59149
- (0, keyword_1.macroKeywordCode)(cxt, def2);
59150
- } else if (def2.compile || def2.validate) {
59151
- (0, keyword_1.funcKeywordCode)(cxt, def2);
59152
- }
59153
- }
59154
- const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
59155
- const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
59156
- function getData($data, { dataLevel, dataNames, dataPathArr }) {
59157
- let jsonPointer;
59158
- let data;
59159
- if ($data === "")
59160
- return names_1$3.default.rootData;
59161
- if ($data[0] === "/") {
59162
- if (!JSON_POINTER.test($data))
59163
- throw new Error(`Invalid JSON-pointer: ${$data}`);
59164
- jsonPointer = $data;
59165
- data = names_1$3.default.rootData;
59166
- } else {
59167
- const matches = RELATIVE_JSON_POINTER.exec($data);
59168
- if (!matches)
59169
- throw new Error(`Invalid JSON-pointer: ${$data}`);
59170
- const up = +matches[1];
59171
- jsonPointer = matches[2];
59172
- if (jsonPointer === "#") {
59173
- if (up >= dataLevel)
59174
- throw new Error(errorMsg("property/index", up));
59175
- return dataPathArr[dataLevel - up];
59176
- }
59177
- if (up > dataLevel)
59178
- throw new Error(errorMsg("data", up));
59179
- data = dataNames[dataLevel - up];
59180
- if (!jsonPointer)
59181
- return data;
59182
- }
59183
- let expr = data;
59184
- const segments = jsonPointer.split("/");
59185
- for (const segment of segments) {
59186
- if (segment) {
59187
- data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
59188
- 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}`;
59189
59269
  }
59190
59270
  }
59191
- return expr;
59192
- function errorMsg(pointerType, up) {
59193
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
59194
- }
59271
+ validate.getData = getData2;
59272
+ return validate;
59195
59273
  }
59196
- validate.getData = getData;
59197
59274
  var validation_error = {};
59198
- Object.defineProperty(validation_error, "__esModule", { value: true });
59199
- class ValidationError extends Error {
59200
- constructor(errors2) {
59201
- super("validation failed");
59202
- this.errors = errors2;
59203
- 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
+ }
59204
59286
  }
59287
+ validation_error.default = ValidationError;
59288
+ return validation_error;
59205
59289
  }
59206
- validation_error.default = ValidationError;
59207
59290
  var ref_error = {};
59208
59291
  Object.defineProperty(ref_error, "__esModule", { value: true });
59209
59292
  const resolve_1$1 = resolve$2;
@@ -59219,11 +59302,11 @@ var compile = {};
59219
59302
  Object.defineProperty(compile, "__esModule", { value: true });
59220
59303
  compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
59221
59304
  const codegen_1$m = codegen;
59222
- const validation_error_1 = validation_error;
59305
+ const validation_error_1 = requireValidation_error();
59223
59306
  const names_1$2 = names$1;
59224
59307
  const resolve_1 = resolve$2;
59225
59308
  const util_1$l = util;
59226
- const validate_1$1 = validate;
59309
+ const validate_1$1 = requireValidate();
59227
59310
  class SchemaEnv {
59228
59311
  constructor(env) {
59229
59312
  var _a2;
@@ -60152,7 +60235,7 @@ uri$1.default = uri;
60152
60235
  (function(exports$1) {
60153
60236
  Object.defineProperty(exports$1, "__esModule", { value: true });
60154
60237
  exports$1.CodeGen = exports$1.Name = exports$1.nil = exports$1.stringify = exports$1.str = exports$1._ = exports$1.KeywordCxt = void 0;
60155
- var validate_12 = validate;
60238
+ var validate_12 = requireValidate();
60156
60239
  Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
60157
60240
  return validate_12.KeywordCxt;
60158
60241
  } });
@@ -60175,7 +60258,7 @@ uri$1.default = uri;
60175
60258
  Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
60176
60259
  return codegen_12.CodeGen;
60177
60260
  } });
60178
- const validation_error_12 = validation_error;
60261
+ const validation_error_12 = requireValidation_error();
60179
60262
  const ref_error_12 = ref_error;
60180
60263
  const rules_12 = rules;
60181
60264
  const compile_12 = compile;
@@ -61763,7 +61846,7 @@ const def$a = {
61763
61846
  additionalProperties.default = def$a;
61764
61847
  var properties$1 = {};
61765
61848
  Object.defineProperty(properties$1, "__esModule", { value: true });
61766
- const validate_1 = validate;
61849
+ const validate_1 = requireValidate();
61767
61850
  const code_1$2 = code;
61768
61851
  const util_1$7 = util;
61769
61852
  const additionalProperties_1$1 = additionalProperties;
@@ -62614,7 +62697,7 @@ const require$$3 = {
62614
62697
  module.exports.Ajv = Ajv2;
62615
62698
  Object.defineProperty(exports$1, "__esModule", { value: true });
62616
62699
  exports$1.default = Ajv2;
62617
- var validate_12 = validate;
62700
+ var validate_12 = requireValidate();
62618
62701
  Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
62619
62702
  return validate_12.KeywordCxt;
62620
62703
  } });
@@ -62637,7 +62720,7 @@ const require$$3 = {
62637
62720
  Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
62638
62721
  return codegen_12.CodeGen;
62639
62722
  } });
62640
- var validation_error_12 = validation_error;
62723
+ var validation_error_12 = requireValidation_error();
62641
62724
  Object.defineProperty(exports$1, "ValidationError", { enumerable: true, get: function() {
62642
62725
  return validation_error_12.default;
62643
62726
  } });
@@ -63544,28 +63627,23 @@ function makeJsonSnippet(path, value, mode) {
63544
63627
  const acc = jsonAccessor(path);
63545
63628
  const label = jsonPathLabel(path);
63546
63629
  const lit = toLit(value);
63547
- const decl = "const json = sp.response.json();";
63548
63630
  switch (mode) {
63549
63631
  case "equals":
63550
63632
  return `sp.test('${label} equals ${lit}', function() {
63551
- ${decl}
63552
63633
  sp.expect(${acc}).to.equal(${lit});
63553
63634
  });`;
63554
63635
  case "exists":
63555
63636
  return `sp.test('${label} exists', function() {
63556
- ${decl}
63557
63637
  sp.expect(${acc}).to.not.be.oneOf([null, undefined]);
63558
63638
  });`;
63559
63639
  case "type": {
63560
63640
  const t2 = value === null ? "null" : typeof value;
63561
63641
  return `sp.test('${label} is ${t2}', function() {
63562
- ${decl}
63563
63642
  sp.expect(${acc}).to.be.a("${t2}");
63564
63643
  });`;
63565
63644
  }
63566
63645
  case "contains":
63567
63646
  return `sp.test('${label} contains ${lit}', function() {
63568
- ${decl}
63569
63647
  sp.expect(${acc}).to.include(${lit});
63570
63648
  });`;
63571
63649
  }
@@ -63574,7 +63652,7 @@ function makeJsonPathSnippet(path, value, filterKey, filterValue) {
63574
63652
  const expr = toJsonPathExpr(path, filterKey, filterValue);
63575
63653
  const lit = toLit(value);
63576
63654
  return `sp.test('${expr} equals ${lit}', function() {
63577
- const matches = sp.jsonPath(sp.response.json(), '${expr}');
63655
+ const matches = sp.jsonPath(json, '${expr}');
63578
63656
  sp.expect(matches.length).to.be.above(0);
63579
63657
  sp.expect(matches[0]).to.equal(${lit});
63580
63658
  });`;
@@ -63599,13 +63677,12 @@ function makeXmlSnippet(selector, value, mode) {
63599
63677
  function makeJsonExtractSnippet(path, target) {
63600
63678
  const acc = jsonAccessor(path);
63601
63679
  const varName = varNameFromPath(path);
63602
- return `const json = sp.response.json();
63603
- sp.${target}.set("${varName}", String(${acc}));`;
63680
+ return `sp.${target}.set("${varName}", String(${acc}));`;
63604
63681
  }
63605
63682
  function makeJsonPathExtractSnippet(path, filterKey, filterValue, target) {
63606
63683
  const expr = toJsonPathExpr(path, filterKey, filterValue);
63607
63684
  const varName = varNameFromPath(path);
63608
- return `const matches = sp.jsonPath(sp.response.json(), '${expr}');
63685
+ return `const matches = sp.jsonPath(json, '${expr}');
63609
63686
  sp.${target}.set("${varName}", String(matches[0] ?? ''));`;
63610
63687
  }
63611
63688
  function makeXmlExtractSnippet(selector, target) {
@@ -64402,12 +64479,7 @@ function ResponseViewer() {
64402
64479
  const req = Object.values(state.collections).find((c) => c.data.requests[requestId])?.data.requests[requestId];
64403
64480
  if (!req) return;
64404
64481
  const existing = req.postRequestScript ?? "";
64405
- let cleaned = snippet2;
64406
- if (existing.includes("const json = sp.response.json()")) {
64407
- cleaned = cleaned.replace(/^\s*const json = sp\.response\.json\(\);?\s*\n?/m, "").replace(/\n\s*const json = sp\.response\.json\(\);?\s*\n/g, "\n");
64408
- }
64409
- const sep = existing.trim() ? "\n\n" : "";
64410
- updateRequest(requestId, { postRequestScript: existing + sep + cleaned });
64482
+ updateRequest(requestId, { postRequestScript: appendSnippetToScript(existing, snippet2) });
64411
64483
  if (activeTabId) {
64412
64484
  setTabRequestTab(activeTabId, "scripts");
64413
64485
  setTabScriptTab(activeTabId, "post");
@@ -68773,11 +68845,20 @@ function ContractPanel() {
68773
68845
  const activeCollId = useStore((s) => s.activeCollectionId);
68774
68846
  const report = useStore((s) => s.lastContractReport);
68775
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);
68776
68854
  const [mode, setMode] = reactExports.useState("consumer");
68777
68855
  const [specUrl, setSpecUrl] = reactExports.useState("");
68778
68856
  const [requestBaseUrl, setRequestBaseUrl] = reactExports.useState("");
68779
68857
  const [running, setRunning] = reactExports.useState(false);
68858
+ const [capturing, setCapturing] = reactExports.useState(false);
68780
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;
68781
68862
  const allRequests = Object.values(collections).flatMap((c) => Object.values(c.data.requests));
68782
68863
  const contractRequests = allRequests.filter(
68783
68864
  (r) => r.contract && (r.contract.statusCode !== void 0 || r.contract.bodySchema || r.contract.headers?.length)
@@ -68787,8 +68868,8 @@ function ContractPanel() {
68787
68868
  (environments[activeEnvId]?.data.variables ?? []).filter((v) => v.enabled).map((v) => [v.key, v.value])
68788
68869
  ) : {};
68789
68870
  async function runContracts() {
68790
- if (mode !== "consumer" && !specUrl.trim()) {
68791
- 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.");
68792
68873
  return;
68793
68874
  }
68794
68875
  setRunning(true);
@@ -68802,6 +68883,7 @@ function ContractPanel() {
68802
68883
  envVars,
68803
68884
  collectionVars,
68804
68885
  specUrl: specUrl.trim() || void 0,
68886
+ specSnapshotRelPath: activeSnapshotRelPath ?? void 0,
68805
68887
  requestBaseUrl: requestBaseUrl.trim() || void 0
68806
68888
  });
68807
68889
  setReport(result);
@@ -68811,6 +68893,37 @@ function ContractPanel() {
68811
68893
  setRunning(false);
68812
68894
  }
68813
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
+ }
68814
68927
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col flex-1 min-h-0 overflow-hidden", children: [
68815
68928
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 px-3 py-3 border-b border-surface-800 flex-shrink-0", children: [
68816
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(
@@ -68828,16 +68941,65 @@ function ContractPanel() {
68828
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." }),
68829
68942
  mode !== "consumer" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [
68830
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: [
68831
68980
  /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] text-surface-500 uppercase tracking-wider font-medium block mb-1", children: "OpenAPI Spec URL" }),
68832
- /* @__PURE__ */ jsxRuntimeExports.jsx(
68833
- "input",
68834
- {
68835
- value: specUrl,
68836
- onChange: (e) => setSpecUrl(e.target.value),
68837
- placeholder: "https://api.example.com/openapi.json",
68838
- 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"
68839
- }
68840
- )
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." })
68841
69003
  ] }),
68842
69004
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
68843
69005
  /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "text-[10px] text-surface-500 uppercase tracking-wider font-medium block mb-1", children: [
@@ -68862,7 +69024,7 @@ function ContractPanel() {
68862
69024
  "button",
68863
69025
  {
68864
69026
  onClick: runContracts,
68865
- disabled: running || mode !== "consumer" && !specUrl.trim(),
69027
+ disabled: running || mode !== "consumer" && !specUrl.trim() && !activeSnapshotRelPath,
68866
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",
68867
69029
  children: running ? "Running…" : "Run"
68868
69030
  }
@@ -70233,7 +70395,7 @@ function App() {
70233
70395
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "#6aa3c8" }, children: "Spector" }),
70234
70396
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-2 text-[10px] font-normal opacity-50", children: [
70235
70397
  "v",
70236
- "0.2.1"
70398
+ "0.2.3"
70237
70399
  ] }),
70238
70400
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mx-2 opacity-30", children: "·" }),
70239
70401
  /* @__PURE__ */ jsxRuntimeExports.jsx(