@testsmith/api-spector 0.1.5 → 0.1.7

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.
@@ -905,6 +905,7 @@ function checkDCE$1() {
905
905
  reactDom.exports = reactDom_production;
906
906
  }
907
907
  var reactDomExports = reactDom.exports;
908
+ const ReactDOM$2 = /* @__PURE__ */ getDefaultExportFromCjs(reactDomExports);
908
909
  /**
909
910
  * @license React
910
911
  * react-dom-client.production.js
@@ -2075,7 +2076,7 @@ if (canUseDOM)
2075
2076
  passiveBrowserEventsSupported = false;
2076
2077
  }
2077
2078
  var root = null, startText = null, fallbackText = null;
2078
- function getData$1() {
2079
+ function getData() {
2079
2080
  if (fallbackText) return fallbackText;
2080
2081
  var start, startValue = startText, startLength = startValue.length, end, endValue = "value" in root ? root.value : root.textContent, endLength = endValue.length;
2081
2082
  for (start = 0; start < startLength && startValue[start] === endValue[start]; start++) ;
@@ -2330,7 +2331,7 @@ function getNativeBeforeInputChars(domEventName, nativeEvent) {
2330
2331
  }
2331
2332
  function getFallbackBeforeInputChars(domEventName, nativeEvent) {
2332
2333
  if (isComposing)
2333
- 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;
2334
2335
  switch (domEventName) {
2335
2336
  case "paste":
2336
2337
  return null;
@@ -10062,7 +10063,7 @@ function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativ
10062
10063
  }
10063
10064
  else
10064
10065
  isComposing ? isFallbackCompositionEnd(domEventName, nativeEvent) && (eventType = "onCompositionEnd") : "keydown" === domEventName && 229 === nativeEvent.keyCode && (eventType = "onCompositionStart");
10065
- 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(
10066
10067
  eventType,
10067
10068
  domEventName,
10068
10069
  null,
@@ -13394,6 +13395,7 @@ function makeTab(requestId, collectionId) {
13394
13395
  lastResponse: null,
13395
13396
  lastScriptResult: null,
13396
13397
  lastSentRequest: null,
13398
+ lastHookResults: null,
13397
13399
  isSending: false,
13398
13400
  requestTab: "params",
13399
13401
  scriptTab: "pre"
@@ -13413,7 +13415,7 @@ const useStore = create()(
13413
13415
  sessionVars: {},
13414
13416
  showGeneratorPanel: false,
13415
13417
  theme: localStorage.getItem("theme") ?? "dark",
13416
- zoom: Number(localStorage.getItem("zoom") ?? "1"),
13418
+ zoom: Number(localStorage.getItem("zoom") ?? "1.1"),
13417
13419
  history: [],
13418
13420
  sidebarTab: "collections",
13419
13421
  workspaceSettingsOpen: false,
@@ -13508,6 +13510,10 @@ const useStore = create()(
13508
13510
  if (sentRequest !== void 0) tab.lastSentRequest = sentRequest ?? null;
13509
13511
  }
13510
13512
  }),
13513
+ setTabHookResults: (tabId, results) => set2((s) => {
13514
+ const tab = s.tabs.find((t2) => t2.id === tabId);
13515
+ if (tab) tab.lastHookResults = results;
13516
+ }),
13511
13517
  setTabSending: (tabId, sending) => set2((s) => {
13512
13518
  const tab = s.tabs.find((t2) => t2.id === tabId);
13513
13519
  if (tab) tab.isSending = sending;
@@ -13641,6 +13647,12 @@ const useStore = create()(
13641
13647
  s.collections[id2].data.tls = tls;
13642
13648
  s.collections[id2].dirty = true;
13643
13649
  }),
13650
+ updateCollectionAuthAndHeaders: (id2, auth, headers) => set2((s) => {
13651
+ if (!s.collections[id2]) return;
13652
+ s.collections[id2].data.auth = auth;
13653
+ s.collections[id2].data.headers = headers;
13654
+ s.collections[id2].dirty = true;
13655
+ }),
13644
13656
  // ── Folder CRUD ───────────────────────────────────────────────────────────
13645
13657
  addFolder: (collectionId, parentFolderId, name2) => set2((s) => {
13646
13658
  const col = s.collections[collectionId]?.data;
@@ -13760,6 +13772,37 @@ const useStore = create()(
13760
13772
  s.tabs.push(tab);
13761
13773
  s.activeTabId = tab.id;
13762
13774
  }),
13775
+ moveRequest: (srcCollectionId, requestId, destCollectionId, destFolderId, destIndex) => set2((s) => {
13776
+ const srcCol = s.collections[srcCollectionId]?.data;
13777
+ const destCol = s.collections[destCollectionId]?.data;
13778
+ if (!srcCol || !destCol) return;
13779
+ const req = srcCol.requests[requestId];
13780
+ if (!req) return;
13781
+ const srcFolder = findFolderContaining(srcCol.rootFolder, requestId);
13782
+ const srcIdx = srcFolder ? srcFolder.requestIds.indexOf(requestId) : -1;
13783
+ removeFromFolder(srcCol.rootFolder, requestId);
13784
+ s.collections[srcCollectionId].dirty = true;
13785
+ if (srcCollectionId !== destCollectionId) {
13786
+ delete srcCol.requests[requestId];
13787
+ destCol.requests[requestId] = req;
13788
+ const tab = s.tabs.find((t2) => t2.requestId === requestId);
13789
+ if (tab) tab.collectionId = destCollectionId;
13790
+ }
13791
+ const destFolder = findFolder(destCol.rootFolder, destFolderId);
13792
+ if (destFolder) {
13793
+ if (destIndex !== void 0) {
13794
+ let adjusted = destIndex;
13795
+ if (srcCollectionId === destCollectionId && srcFolder?.id === destFolder.id && srcIdx < destIndex) {
13796
+ adjusted--;
13797
+ }
13798
+ adjusted = Math.max(0, Math.min(adjusted, destFolder.requestIds.length));
13799
+ destFolder.requestIds.splice(adjusted, 0, requestId);
13800
+ } else {
13801
+ destFolder.requestIds.push(requestId);
13802
+ }
13803
+ }
13804
+ s.collections[destCollectionId].dirty = true;
13805
+ }),
13763
13806
  // ── Tags ──────────────────────────────────────────────────────────────────
13764
13807
  updateFolderTags: (collectionId, folderId, tags2) => set2((s) => {
13765
13808
  const col = s.collections[collectionId]?.data;
@@ -13804,16 +13847,12 @@ const useStore = create()(
13804
13847
  const state = useStore.getState();
13805
13848
  const colEntry = Object.values(state.collections).find((c) => c.data.requests[requestId]);
13806
13849
  if (!colEntry) return { auth: null, headers: [] };
13850
+ let inheritedAuth = colEntry.data.auth && colEntry.data.auth.type !== "none" ? colEntry.data.auth : null;
13851
+ let inheritedHeaders = colEntry.data.headers?.filter((h) => h.enabled && h.key) ?? [];
13807
13852
  const path = findFolderPath(colEntry.data.rootFolder, requestId);
13808
- let inheritedAuth = null;
13809
- let inheritedHeaders = [];
13810
13853
  for (const folder of path) {
13811
- if (folder.auth && folder.auth.type !== "none") {
13812
- inheritedAuth = folder.auth;
13813
- }
13814
- if (folder.headers && folder.headers.length > 0) {
13815
- inheritedHeaders = [...inheritedHeaders, ...folder.headers];
13816
- }
13854
+ if (folder.auth && folder.auth.type !== "none") inheritedAuth = folder.auth;
13855
+ if (folder.headers?.length) inheritedHeaders = [...inheritedHeaders, ...folder.headers];
13817
13856
  }
13818
13857
  return { auth: inheritedAuth, headers: inheritedHeaders };
13819
13858
  },
@@ -34587,24 +34626,80 @@ function parseVarTokens(str) {
34587
34626
  }
34588
34627
  return found;
34589
34628
  }
34590
- function VarInput({ value, onChange, className, wrapperClassName, ...rest }) {
34629
+ function PortalDropdown({
34630
+ pos,
34631
+ items: items2,
34632
+ activeIndex,
34633
+ mode,
34634
+ onPick
34635
+ }) {
34636
+ return ReactDOM$2.createPortal(
34637
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
34638
+ "ul",
34639
+ {
34640
+ style: { position: "fixed", top: pos.top, left: pos.left, minWidth: pos.minWidth, zIndex: 9999 },
34641
+ className: "max-h-52 overflow-y-auto bg-surface-800 border border-surface-600 rounded shadow-xl text-xs",
34642
+ children: items2.map((s, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
34643
+ "button",
34644
+ {
34645
+ onMouseDown: (e) => {
34646
+ e.preventDefault();
34647
+ onPick(s);
34648
+ },
34649
+ className: `w-full text-left px-3 py-1.5 font-mono transition-colors ${i === activeIndex ? "bg-blue-600 text-white" : "hover:bg-surface-700"}`,
34650
+ children: mode === "var" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
34651
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-500", children: "{{" }),
34652
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: s }),
34653
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-500", children: "}}" })
34654
+ ] }) : s
34655
+ }
34656
+ ) }, s))
34657
+ }
34658
+ ),
34659
+ document.body
34660
+ );
34661
+ }
34662
+ function VarInput({ value, onChange, className, wrapperClassName, staticSuggestions, ...rest }) {
34591
34663
  const varNames = useVarNames();
34592
34664
  const varValues = useVarValues();
34593
34665
  const inputRef = reactExports.useRef(null);
34594
34666
  const [suggestions, setSuggestions] = reactExports.useState([]);
34667
+ const [suggestionMode, setSuggestionMode] = reactExports.useState("var");
34595
34668
  const [activeIndex, setActiveIndex] = reactExports.useState(-1);
34669
+ const [dropPos, setDropPos] = reactExports.useState(null);
34596
34670
  const [showPreview, setShowPreview] = reactExports.useState(false);
34671
+ reactExports.useEffect(() => {
34672
+ if (suggestions.length === 0) {
34673
+ setDropPos(null);
34674
+ return;
34675
+ }
34676
+ const el = inputRef.current;
34677
+ if (!el) return;
34678
+ const r = el.getBoundingClientRect();
34679
+ setDropPos({ top: r.bottom + 2, left: r.left, minWidth: r.width });
34680
+ }, [suggestions.length]);
34597
34681
  function detectQuery(val, cursor2) {
34598
34682
  const before = val.slice(0, cursor2);
34599
- const match = /\{\{(\w*)$/.exec(before);
34600
- if (!match) {
34683
+ const varMatch = /\{\{(\w*)$/.exec(before);
34684
+ if (varMatch) {
34685
+ const q = varMatch[1].toLowerCase();
34686
+ const filtered = varNames.filter((n) => n.toLowerCase().includes(q));
34687
+ setSuggestions(filtered);
34688
+ setSuggestionMode("var");
34689
+ setActiveIndex(-1);
34690
+ } else if (staticSuggestions) {
34691
+ const q = val.toLowerCase();
34692
+ const filtered = q ? staticSuggestions.filter((s) => s.toLowerCase().includes(q)).sort((a, b) => {
34693
+ const aP = a.toLowerCase().startsWith(q) ? 0 : 1;
34694
+ const bP = b.toLowerCase().startsWith(q) ? 0 : 1;
34695
+ return aP - bP;
34696
+ }).slice(0, 20) : staticSuggestions.slice(0, 20);
34697
+ setSuggestions(filtered);
34698
+ setSuggestionMode("static");
34699
+ setActiveIndex(-1);
34700
+ } else {
34601
34701
  setSuggestions([]);
34602
- return;
34603
34702
  }
34604
- const q = match[1].toLowerCase();
34605
- const filtered = varNames.filter((n) => n.toLowerCase().includes(q));
34606
- setSuggestions(filtered);
34607
- setActiveIndex(-1);
34608
34703
  }
34609
34704
  function handleChange(e) {
34610
34705
  const newVal = e.target.value;
@@ -34612,6 +34707,10 @@ function VarInput({ value, onChange, className, wrapperClassName, ...rest }) {
34612
34707
  onChange(newVal);
34613
34708
  detectQuery(newVal, cursor2);
34614
34709
  }
34710
+ function handleFocus(e) {
34711
+ detectQuery(value, e.target.selectionStart ?? value.length);
34712
+ rest.onFocus?.(e);
34713
+ }
34615
34714
  function handleKeyDown(e) {
34616
34715
  if (suggestions.length === 0) return;
34617
34716
  if (e.key === "ArrowDown") {
@@ -34627,21 +34726,28 @@ function VarInput({ value, onChange, className, wrapperClassName, ...rest }) {
34627
34726
  setSuggestions([]);
34628
34727
  }
34629
34728
  }
34630
- const apply = reactExports.useCallback((name2) => {
34729
+ const apply = reactExports.useCallback((suggestion) => {
34730
+ if (suggestionMode === "static") {
34731
+ onChange(suggestion);
34732
+ setSuggestions([]);
34733
+ return;
34734
+ }
34631
34735
  const el = inputRef.current;
34632
34736
  const cursor2 = el?.selectionStart ?? value.length;
34633
34737
  const before = value.slice(0, cursor2);
34634
34738
  const after = value.slice(cursor2);
34635
34739
  const match = /\{\{(\w*)$/.exec(before);
34636
34740
  if (!match) return;
34637
- const newVal = before.slice(0, match.index) + `{{${name2}}}` + after;
34638
- const newCursor = match.index + name2.length + 4;
34741
+ const newVal = before.slice(0, match.index) + `{{${suggestion}}}` + after;
34742
+ const newCursor = match.index + suggestion.length + 4;
34639
34743
  onChange(newVal);
34640
34744
  setSuggestions([]);
34641
34745
  requestAnimationFrame(() => el?.setSelectionRange(newCursor, newCursor));
34642
- }, [value, onChange]);
34643
- function handleBlur() {
34746
+ }, [suggestionMode, value, onChange]);
34747
+ function handleBlur(e) {
34644
34748
  setTimeout(() => setSuggestions([]), 150);
34749
+ setShowPreview(false);
34750
+ rest.onBlur?.(e);
34645
34751
  }
34646
34752
  const tokens = parseVarTokens(value);
34647
34753
  const hasVars = tokens.length > 0;
@@ -34649,6 +34755,7 @@ function VarInput({ value, onChange, className, wrapperClassName, ...rest }) {
34649
34755
  name: name2,
34650
34756
  resolved: varValues[name2] ?? null
34651
34757
  }));
34758
+ const { onFocus: _f, onBlur: _b, ...inputRest } = rest;
34652
34759
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
34653
34760
  "div",
34654
34761
  {
@@ -34663,26 +34770,22 @@ function VarInput({ value, onChange, className, wrapperClassName, ...rest }) {
34663
34770
  value,
34664
34771
  onChange: handleChange,
34665
34772
  onKeyDown: handleKeyDown,
34773
+ onFocus: handleFocus,
34666
34774
  onBlur: handleBlur,
34667
34775
  className: `w-full ${className ?? ""}`,
34668
- ...rest
34776
+ ...inputRest
34669
34777
  }
34670
34778
  ),
34671
- suggestions.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "absolute left-0 top-full mt-0.5 z-50 min-w-[160px] max-h-44 overflow-y-auto bg-surface-800 border border-surface-600 rounded shadow-xl text-xs", children: suggestions.map((name2, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
34672
- "button",
34779
+ suggestions.length > 0 && dropPos && /* @__PURE__ */ jsxRuntimeExports.jsx(
34780
+ PortalDropdown,
34673
34781
  {
34674
- onMouseDown: (e) => {
34675
- e.preventDefault();
34676
- apply(name2);
34677
- },
34678
- className: `w-full text-left px-3 py-1.5 font-mono transition-colors ${i === activeIndex ? "bg-blue-600 text-white" : "hover:bg-surface-700"}`,
34679
- children: [
34680
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-500", children: "{{" }),
34681
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: name2 }),
34682
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-500", children: "}}" })
34683
- ]
34782
+ pos: dropPos,
34783
+ items: suggestions,
34784
+ activeIndex,
34785
+ mode: suggestionMode,
34786
+ onPick: apply
34684
34787
  }
34685
- ) }, name2)) }),
34788
+ ),
34686
34789
  showPreview && suggestions.length === 0 && previewItems.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-0 top-full mt-0.5 z-50 bg-surface-800 border border-surface-600 rounded shadow-xl text-xs min-w-[220px] max-w-[420px]", children: previewItems.map(({ name: name2, resolved }) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-baseline gap-2 px-3 py-1.5 border-b border-surface-700 last:border-0", children: [
34687
34790
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-mono text-blue-400 shrink-0", children: `{{${name2}}}` }),
34688
34791
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-500 mx-0.5", children: "→" }),
@@ -34692,7 +34795,113 @@ function VarInput({ value, onChange, className, wrapperClassName, ...rest }) {
34692
34795
  }
34693
34796
  );
34694
34797
  }
34695
- function KVTable({ rows, onChange, keyPlaceholder = "Key", valuePlaceholder = "Value" }) {
34798
+ const HEADER_NAMES = [
34799
+ "Accept",
34800
+ "Authorization",
34801
+ "Content-Type",
34802
+ "Cache-Control",
34803
+ "Accept-Language",
34804
+ "Accept-Encoding",
34805
+ "Connection",
34806
+ "Content-Encoding",
34807
+ "Content-Length",
34808
+ "Cookie",
34809
+ "Host",
34810
+ "Origin",
34811
+ "Referer",
34812
+ "User-Agent",
34813
+ "X-Api-Key",
34814
+ "X-Auth-Token",
34815
+ "X-Correlation-ID",
34816
+ "X-Request-ID",
34817
+ "X-Forwarded-For",
34818
+ "X-Requested-With",
34819
+ "X-Tenant-ID",
34820
+ "If-Match",
34821
+ "If-None-Match",
34822
+ "If-Modified-Since",
34823
+ "If-Unmodified-Since",
34824
+ "If-Range",
34825
+ "Date",
34826
+ "Expect",
34827
+ "From",
34828
+ "Max-Forwards",
34829
+ "Pragma",
34830
+ "Proxy-Authorization",
34831
+ "Range",
34832
+ "TE",
34833
+ "Upgrade",
34834
+ "Via",
34835
+ "Warning"
34836
+ ];
34837
+ const HEADER_VALUE_SUGGESTIONS = {
34838
+ "accept": [
34839
+ "application/json",
34840
+ "application/xml",
34841
+ "text/html",
34842
+ "text/plain",
34843
+ "application/ld+json",
34844
+ "*/*"
34845
+ ],
34846
+ "content-type": [
34847
+ "application/json",
34848
+ "application/xml",
34849
+ "application/x-www-form-urlencoded",
34850
+ "multipart/form-data",
34851
+ "text/plain",
34852
+ "text/html",
34853
+ "text/xml",
34854
+ "application/octet-stream",
34855
+ "application/graphql",
34856
+ "application/ld+json"
34857
+ ],
34858
+ "cache-control": [
34859
+ "no-cache",
34860
+ "no-store",
34861
+ "max-age=0",
34862
+ "max-age=3600",
34863
+ "must-revalidate",
34864
+ "private",
34865
+ "public"
34866
+ ],
34867
+ "connection": [
34868
+ "keep-alive",
34869
+ "close",
34870
+ "upgrade"
34871
+ ],
34872
+ "accept-encoding": [
34873
+ "gzip",
34874
+ "deflate",
34875
+ "br",
34876
+ "gzip, deflate, br",
34877
+ "identity",
34878
+ "*"
34879
+ ],
34880
+ "accept-language": [
34881
+ "en-US",
34882
+ "en-US,en;q=0.9",
34883
+ "en",
34884
+ "*"
34885
+ ],
34886
+ "pragma": [
34887
+ "no-cache"
34888
+ ],
34889
+ "transfer-encoding": [
34890
+ "chunked",
34891
+ "gzip",
34892
+ "deflate",
34893
+ "compress",
34894
+ "identity"
34895
+ ],
34896
+ "upgrade": [
34897
+ "websocket",
34898
+ "HTTP/2.0"
34899
+ ]
34900
+ };
34901
+ function getValueSuggestions(headerName) {
34902
+ return HEADER_VALUE_SUGGESTIONS[headerName.toLowerCase()];
34903
+ }
34904
+ function KVTable({ rows, onChange, keyPlaceholder = "Key", valuePlaceholder = "Value", headerMode }) {
34696
34905
  const [descVisible, setDescVisible] = reactExports.useState(
34697
34906
  () => new Set(rows.map((r, i) => r.description ? i : -1).filter((i) => i >= 0))
34698
34907
  );
@@ -34746,7 +34955,8 @@ function KVTable({ rows, onChange, keyPlaceholder = "Key", valuePlaceholder = "V
34746
34955
  onChange: (v) => update(idx, { key: v }),
34747
34956
  placeholder: keyPlaceholder,
34748
34957
  wrapperClassName: "flex-1",
34749
- className: "bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500 font-mono"
34958
+ className: "bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500 font-mono",
34959
+ staticSuggestions: headerMode ? HEADER_NAMES : void 0
34750
34960
  }
34751
34961
  ),
34752
34962
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -34756,7 +34966,8 @@ function KVTable({ rows, onChange, keyPlaceholder = "Key", valuePlaceholder = "V
34756
34966
  onChange: (v) => update(idx, { value: v }),
34757
34967
  placeholder: valuePlaceholder,
34758
34968
  wrapperClassName: "flex-1",
34759
- className: "bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500 font-mono"
34969
+ className: "bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500 font-mono",
34970
+ staticSuggestions: headerMode ? getValueSuggestions(row.key) ?? void 0 : void 0
34760
34971
  }
34761
34972
  ),
34762
34973
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -34790,7 +35001,7 @@ function KVTable({ rows, onChange, keyPlaceholder = "Key", valuePlaceholder = "V
34790
35001
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: add2, className: "mt-1 text-surface-400 hover:text-white transition-colors", children: "+ Add" })
34791
35002
  ] });
34792
35003
  }
34793
- const AUTH_TYPES$1 = ["none", "bearer", "basic", "digest", "ntlm", "apikey"];
35004
+ const AUTH_TYPES$2 = ["none", "bearer", "basic", "digest", "ntlm", "apikey"];
34794
35005
  function FolderSettingsModal({ collectionId, folder, onClose }) {
34795
35006
  const updateFolder = useStore((s) => s.updateFolder);
34796
35007
  const [activeTab, setActiveTab] = reactExports.useState("auth");
@@ -34841,7 +35052,8 @@ function FolderSettingsModal({ collectionId, folder, onClose }) {
34841
35052
  rows: headers,
34842
35053
  onChange: setHeaders,
34843
35054
  keyPlaceholder: "Header-Name",
34844
- valuePlaceholder: "value"
35055
+ valuePlaceholder: "value",
35056
+ headerMode: true
34845
35057
  }
34846
35058
  )
34847
35059
  ] }),
@@ -34874,7 +35086,7 @@ function FolderAuthPanel({ auth, onChange }) {
34874
35086
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-surface-600", children: "Auth configured here is inherited by all requests in this folder unless the request overrides it with its own non-none auth type." }),
34875
35087
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
34876
35088
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-400", children: "Type:" }),
34877
- AUTH_TYPES$1.map((t2) => /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-1 cursor-pointer", children: [
35089
+ AUTH_TYPES$2.map((t2) => /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-1 cursor-pointer", children: [
34878
35090
  /* @__PURE__ */ jsxRuntimeExports.jsx(
34879
35091
  "input",
34880
35092
  {
@@ -35020,14 +35232,23 @@ function FolderAuthPanel({ auth, onChange }) {
35020
35232
  ] }) })
35021
35233
  ] });
35022
35234
  }
35235
+ const AUTH_TYPES$1 = ["none", "bearer", "basic", "digest", "ntlm", "apikey"];
35023
35236
  function CollectionSettingsModal({ collection, onClose }) {
35024
35237
  const updateCollectionTls = useStore((s) => s.updateCollectionTls);
35238
+ const updateCollectionAuthAndHeaders = useStore((s) => s.updateCollectionAuthAndHeaders);
35239
+ const [activeTab, setActiveTab] = reactExports.useState("auth");
35240
+ const [auth, setAuth] = reactExports.useState(collection.auth ?? { type: "none" });
35241
+ const [headers, setHeaders] = reactExports.useState(collection.headers ?? []);
35025
35242
  const existing = collection.tls;
35026
35243
  const [caCertPath, setCaCertPath] = reactExports.useState(existing?.caCertPath ?? "");
35027
35244
  const [clientCertPath, setClientCertPath] = reactExports.useState(existing?.clientCertPath ?? "");
35028
35245
  const [clientKeyPath, setClientKeyPath] = reactExports.useState(existing?.clientKeyPath ?? "");
35029
35246
  const [rejectUnauthorized, setRejectUnauthorized] = reactExports.useState(existing?.rejectUnauthorized !== false);
35247
+ function patchAuth(patch) {
35248
+ setAuth((prev) => ({ ...prev, ...patch }));
35249
+ }
35030
35250
  function save() {
35251
+ updateCollectionAuthAndHeaders(collection.id, auth, headers);
35031
35252
  const hasAny = caCertPath.trim() || clientCertPath.trim() || clientKeyPath.trim();
35032
35253
  updateCollectionTls(collection.id, hasAny ? {
35033
35254
  caCertPath: caCertPath.trim() || void 0,
@@ -35045,65 +35266,90 @@ function CollectionSettingsModal({ collection, onClose }) {
35045
35266
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
35046
35267
  "div",
35047
35268
  {
35048
- className: "w-[560px] bg-surface-900 border border-surface-800 rounded-lg shadow-2xl flex flex-col max-h-[80vh]",
35269
+ className: "w-[600px] bg-surface-900 border border-surface-800 rounded-lg shadow-2xl flex flex-col max-h-[80vh]",
35049
35270
  onClick: (e) => e.stopPropagation(),
35050
35271
  children: [
35051
35272
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between px-4 py-2.5 border-b border-surface-800 shrink-0", children: [
35052
35273
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
35053
35274
  /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-sm font-semibold", children: "Collection settings" }),
35054
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-surface-600 mt-0.5", children: collection.name })
35275
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-[10px] text-surface-600 mt-0.5", children: [
35276
+ collection.name,
35277
+ " — auth and headers inherited by all requests in this collection"
35278
+ ] })
35055
35279
  ] }),
35056
35280
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: onClose, className: "text-surface-400 hover:text-white text-lg leading-none", children: "×" })
35057
35281
  ] }),
35058
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-3 flex-1 overflow-y-auto text-xs flex flex-col gap-3", children: [
35059
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-surface-500", children: "TLS settings override the workspace-level configuration for every request in this collection. Leave all paths empty to inherit from the workspace." }),
35060
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
35061
- /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] uppercase tracking-wider text-surface-600 font-medium", children: "CA Certificate path" }),
35062
- /* @__PURE__ */ jsxRuntimeExports.jsx(
35063
- "input",
35064
- {
35065
- value: caCertPath,
35066
- onChange: (e) => setCaCertPath(e.target.value),
35067
- placeholder: "/path/to/ca.crt (leave empty to inherit)",
35068
- className: "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"
35069
- }
35070
- )
35071
- ] }),
35072
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
35073
- /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] uppercase tracking-wider text-surface-600 font-medium", children: "Client certificate path" }),
35074
- /* @__PURE__ */ jsxRuntimeExports.jsx(
35075
- "input",
35076
- {
35077
- value: clientCertPath,
35078
- onChange: (e) => setClientCertPath(e.target.value),
35079
- placeholder: "/path/to/client.crt (leave empty to inherit)",
35080
- className: "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"
35081
- }
35082
- )
35083
- ] }),
35084
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
35085
- /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] uppercase tracking-wider text-surface-600 font-medium", children: "Client key path" }),
35086
- /* @__PURE__ */ jsxRuntimeExports.jsx(
35087
- "input",
35088
- {
35089
- value: clientKeyPath,
35090
- onChange: (e) => setClientKeyPath(e.target.value),
35091
- placeholder: "/path/to/client.key (leave empty to inherit)",
35092
- className: "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"
35093
- }
35094
- )
35095
- ] }),
35096
- /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 cursor-pointer", children: [
35097
- /* @__PURE__ */ jsxRuntimeExports.jsx(
35098
- "input",
35099
- {
35100
- type: "checkbox",
35101
- checked: rejectUnauthorized,
35102
- onChange: (e) => setRejectUnauthorized(e.target.checked),
35103
- className: "accent-blue-500"
35104
- }
35105
- ),
35106
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Reject unauthorized / self-signed certificates" })
35282
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex border-b border-surface-800 px-4 shrink-0", children: ["auth", "headers", "tls"].map((t2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
35283
+ "button",
35284
+ {
35285
+ onClick: () => setActiveTab(t2),
35286
+ className: `px-3 py-1.5 text-xs transition-colors border-b-2 -mb-px capitalize ${activeTab === t2 ? "border-blue-500 text-white" : "border-transparent text-surface-400 hover:text-white"}`,
35287
+ children: t2 === "tls" ? "TLS" : t2
35288
+ },
35289
+ t2
35290
+ )) }),
35291
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-3 flex-1 overflow-y-auto text-xs", children: [
35292
+ activeTab === "auth" && /* @__PURE__ */ jsxRuntimeExports.jsx(CollectionAuthPanel, { auth, onChange: patchAuth }),
35293
+ activeTab === "headers" && /* @__PURE__ */ jsxRuntimeExports.jsx(
35294
+ KVTable,
35295
+ {
35296
+ rows: headers,
35297
+ onChange: setHeaders,
35298
+ keyPlaceholder: "Header-Name",
35299
+ valuePlaceholder: "value",
35300
+ headerMode: true
35301
+ }
35302
+ ),
35303
+ activeTab === "tls" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3", children: [
35304
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-surface-500", children: "TLS settings override the workspace-level configuration for every request in this collection. Leave all paths empty to inherit from the workspace." }),
35305
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
35306
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] uppercase tracking-wider text-surface-600 font-medium", children: "CA Certificate path" }),
35307
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35308
+ "input",
35309
+ {
35310
+ value: caCertPath,
35311
+ onChange: (e) => setCaCertPath(e.target.value),
35312
+ placeholder: "/path/to/ca.crt (leave empty to inherit)",
35313
+ className: "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"
35314
+ }
35315
+ )
35316
+ ] }),
35317
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
35318
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] uppercase tracking-wider text-surface-600 font-medium", children: "Client certificate path" }),
35319
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35320
+ "input",
35321
+ {
35322
+ value: clientCertPath,
35323
+ onChange: (e) => setClientCertPath(e.target.value),
35324
+ placeholder: "/path/to/client.crt (leave empty to inherit)",
35325
+ className: "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"
35326
+ }
35327
+ )
35328
+ ] }),
35329
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
35330
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-[10px] uppercase tracking-wider text-surface-600 font-medium", children: "Client key path" }),
35331
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35332
+ "input",
35333
+ {
35334
+ value: clientKeyPath,
35335
+ onChange: (e) => setClientKeyPath(e.target.value),
35336
+ placeholder: "/path/to/client.key (leave empty to inherit)",
35337
+ className: "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"
35338
+ }
35339
+ )
35340
+ ] }),
35341
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 cursor-pointer", children: [
35342
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35343
+ "input",
35344
+ {
35345
+ type: "checkbox",
35346
+ checked: rejectUnauthorized,
35347
+ onChange: (e) => setRejectUnauthorized(e.target.checked),
35348
+ className: "accent-blue-500"
35349
+ }
35350
+ ),
35351
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Reject unauthorized / self-signed certificates" })
35352
+ ] })
35107
35353
  ] })
35108
35354
  ] }),
35109
35355
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 px-4 py-3 border-t border-surface-800 shrink-0", children: [
@@ -35130,6 +35376,160 @@ function CollectionSettingsModal({ collection, onClose }) {
35130
35376
  }
35131
35377
  );
35132
35378
  }
35379
+ function CollectionAuthPanel({ auth, onChange }) {
35380
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3", children: [
35381
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-surface-600", children: "Auth configured here is inherited by all requests in this collection unless a folder or request overrides it with its own non-none auth type." }),
35382
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
35383
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-400", children: "Type:" }),
35384
+ AUTH_TYPES$1.map((t2) => /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-1 cursor-pointer", children: [
35385
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35386
+ "input",
35387
+ {
35388
+ type: "radio",
35389
+ value: t2,
35390
+ checked: auth.type === t2,
35391
+ onChange: () => onChange({ type: t2 }),
35392
+ className: "accent-blue-500"
35393
+ }
35394
+ ),
35395
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: auth.type === t2 ? "text-white" : "text-surface-400", children: t2 })
35396
+ ] }, t2))
35397
+ ] }),
35398
+ auth.type === "bearer" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
35399
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Token" }),
35400
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35401
+ "input",
35402
+ {
35403
+ value: auth.token ?? "",
35404
+ onChange: (e) => onChange({ token: e.target.value }),
35405
+ placeholder: "Bearer token",
35406
+ className: "bg-surface-800 border border-surface-700 rounded px-2 py-1 font-mono focus:outline-none focus:border-blue-500"
35407
+ }
35408
+ )
35409
+ ] }),
35410
+ (auth.type === "basic" || auth.type === "digest") && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
35411
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
35412
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Username" }),
35413
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35414
+ "input",
35415
+ {
35416
+ value: auth.username ?? "",
35417
+ onChange: (e) => onChange({ username: e.target.value }),
35418
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500"
35419
+ }
35420
+ )
35421
+ ] }),
35422
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
35423
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Password" }),
35424
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35425
+ "input",
35426
+ {
35427
+ type: "password",
35428
+ value: auth.password ?? "",
35429
+ onChange: (e) => onChange({ password: e.target.value }),
35430
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 font-mono focus:outline-none focus:border-blue-500"
35431
+ }
35432
+ )
35433
+ ] })
35434
+ ] }),
35435
+ auth.type === "ntlm" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [
35436
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
35437
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
35438
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Username" }),
35439
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35440
+ "input",
35441
+ {
35442
+ value: auth.username ?? "",
35443
+ onChange: (e) => onChange({ username: e.target.value }),
35444
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500"
35445
+ }
35446
+ )
35447
+ ] }),
35448
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
35449
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Password" }),
35450
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35451
+ "input",
35452
+ {
35453
+ type: "password",
35454
+ value: auth.password ?? "",
35455
+ onChange: (e) => onChange({ password: e.target.value }),
35456
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 font-mono focus:outline-none focus:border-blue-500"
35457
+ }
35458
+ )
35459
+ ] })
35460
+ ] }),
35461
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
35462
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
35463
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Domain" }),
35464
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35465
+ "input",
35466
+ {
35467
+ value: auth.ntlmDomain ?? "",
35468
+ onChange: (e) => onChange({ ntlmDomain: e.target.value }),
35469
+ placeholder: "WORKGROUP",
35470
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500"
35471
+ }
35472
+ )
35473
+ ] }),
35474
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
35475
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Workstation" }),
35476
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35477
+ "input",
35478
+ {
35479
+ value: auth.ntlmWorkstation ?? "",
35480
+ onChange: (e) => onChange({ ntlmWorkstation: e.target.value }),
35481
+ placeholder: "MACHINE",
35482
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500"
35483
+ }
35484
+ )
35485
+ ] })
35486
+ ] })
35487
+ ] }),
35488
+ auth.type === "apikey" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1.5", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
35489
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
35490
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Key name" }),
35491
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35492
+ "input",
35493
+ {
35494
+ value: auth.apiKeyName ?? "X-API-Key",
35495
+ onChange: (e) => onChange({ apiKeyName: e.target.value }),
35496
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500"
35497
+ }
35498
+ )
35499
+ ] }),
35500
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
35501
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "In" }),
35502
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
35503
+ "select",
35504
+ {
35505
+ value: auth.apiKeyIn ?? "header",
35506
+ onChange: (e) => onChange({ apiKeyIn: e.target.value }),
35507
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 focus:outline-none focus:border-blue-500",
35508
+ children: [
35509
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "header", children: "Header" }),
35510
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "query", children: "Query" })
35511
+ ]
35512
+ }
35513
+ )
35514
+ ] }),
35515
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
35516
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-surface-400", children: "Value" }),
35517
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
35518
+ "input",
35519
+ {
35520
+ value: auth.apiKeyValue ?? "",
35521
+ onChange: (e) => onChange({ apiKeyValue: e.target.value }),
35522
+ placeholder: "API key value",
35523
+ className: "mt-1 w-full bg-surface-800 border border-surface-700 rounded px-2 py-1 font-mono focus:outline-none focus:border-blue-500"
35524
+ }
35525
+ )
35526
+ ] })
35527
+ ] }) })
35528
+ ] });
35529
+ }
35530
+ const DragCtx = reactExports.createContext({ dragging: null, setDragging: () => {
35531
+ }, onDrop: () => {
35532
+ } });
35133
35533
  function InlineEdit({
35134
35534
  value,
35135
35535
  onCommit,
@@ -35377,16 +35777,23 @@ function CollectionTree() {
35377
35777
  const updateRequestTags = useStore((s) => s.updateRequestTags);
35378
35778
  const updateRequest = useStore((s) => s.updateRequest);
35379
35779
  const openRunner = useStore((s) => s.openRunner);
35780
+ const moveRequest = useStore((s) => s.moveRequest);
35380
35781
  const colList = Object.values(collections);
35381
35782
  const [pendingConfirm, setPendingConfirm] = reactExports.useState(null);
35382
35783
  const [newRequestId, setNewRequestId] = reactExports.useState(null);
35784
+ const [dragging, setDragging] = reactExports.useState(null);
35383
35785
  function confirmThen(message, action) {
35384
35786
  setPendingConfirm({ message, onConfirm: () => {
35385
35787
  action();
35386
35788
  setPendingConfirm(null);
35387
35789
  } });
35388
35790
  }
35389
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col flex-1 min-h-0 select-none", children: [
35791
+ function onDrop(destCollectionId, destFolderId, destIndex) {
35792
+ if (!dragging) return;
35793
+ moveRequest(dragging.collectionId, dragging.requestId, destCollectionId, destFolderId, destIndex);
35794
+ setDragging(null);
35795
+ }
35796
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(DragCtx.Provider, { value: { dragging, setDragging, onDrop }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col flex-1 min-h-0 select-none", children: [
35390
35797
  pendingConfirm && /* @__PURE__ */ jsxRuntimeExports.jsx(
35391
35798
  ConfirmDialog,
35392
35799
  {
@@ -35431,7 +35838,7 @@ function CollectionTree() {
35431
35838
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "pt-1", children: "or import from Postman / OpenAPI above." })
35432
35839
  ] })
35433
35840
  ] })
35434
- ] });
35841
+ ] }) });
35435
35842
  }
35436
35843
  function CollectionNode({
35437
35844
  col,
@@ -35462,6 +35869,8 @@ function CollectionNode({
35462
35869
  const [renaming, setRenaming] = reactExports.useState(false);
35463
35870
  const [showSettings, setShowSettings] = reactExports.useState(false);
35464
35871
  const [expandCtrl, setExpandCtrl] = reactExports.useState({ value: true, seq: 0 });
35872
+ const [dropOver, setDropOver] = reactExports.useState(false);
35873
+ const dragCtx = reactExports.useContext(DragCtx);
35465
35874
  function expandAll() {
35466
35875
  setExpandCtrl((c) => ({ value: true, seq: c.seq + 1 }));
35467
35876
  }
@@ -35472,11 +35881,21 @@ function CollectionNode({
35472
35881
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
35473
35882
  "div",
35474
35883
  {
35475
- className: `group flex items-start gap-1 px-2 py-1.5 cursor-pointer hover:bg-surface-800 transition-colors ${isActive ? "text-[var(--text-primary)]" : "text-surface-400"}`,
35884
+ className: `group flex items-start gap-1 px-2 py-1.5 cursor-pointer hover:bg-surface-800 transition-colors ${isActive ? "text-[var(--text-primary)]" : "text-surface-400"} ${dropOver ? "outline outline-1 outline-blue-500 rounded" : ""}`,
35476
35885
  onClick: () => {
35477
35886
  onSelectCollection();
35478
35887
  setExpanded((e) => !e);
35479
35888
  },
35889
+ onDragOver: dragCtx.dragging ? (e) => {
35890
+ e.preventDefault();
35891
+ setDropOver(true);
35892
+ } : void 0,
35893
+ onDragLeave: () => setDropOver(false),
35894
+ onDrop: (e) => {
35895
+ e.preventDefault();
35896
+ setDropOver(false);
35897
+ dragCtx.onDrop(col.id, col.rootFolder.id);
35898
+ },
35480
35899
  children: [
35481
35900
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] w-3 text-center shrink-0 mt-0.5", children: expanded ? "▾" : "▸" }),
35482
35901
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 min-w-0", children: renaming ? /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -35502,7 +35921,7 @@ function CollectionNode({
35502
35921
  { type: "item", label: "Collapse all", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CollapseAllIcon, {}), onClick: collapseAll },
35503
35922
  { type: "separator" },
35504
35923
  { type: "item", label: "Collection data", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(TableIcon, {}), onClick: onSelectCollection },
35505
- { type: "item", label: "Settings (TLS)", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(GearIcon, {}), onClick: () => setShowSettings(true) },
35924
+ { type: "item", label: "Settings", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(GearIcon, {}), onClick: () => setShowSettings(true) },
35506
35925
  { type: "item", label: "Rename", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(PencilIcon, {}), onClick: () => setRenaming(true) },
35507
35926
  { type: "item", label: "Duplicate", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, {}), onClick: onDuplicateCollection },
35508
35927
  { type: "separator" },
@@ -35560,6 +35979,8 @@ function FolderRow({
35560
35979
  const [renaming, setRenaming] = reactExports.useState(false);
35561
35980
  const [showSettings, setShowSettings] = reactExports.useState(false);
35562
35981
  const [addingTag, setAddingTag] = reactExports.useState(false);
35982
+ const [dropOver, setDropOver] = reactExports.useState(false);
35983
+ const dragCtx = reactExports.useContext(DragCtx);
35563
35984
  const tags2 = folder.tags ?? [];
35564
35985
  const indent = depth * 12 + 8;
35565
35986
  const hasInheritedConfig = folder.auth && folder.auth.type !== "none" || folder.headers && folder.headers.length > 0;
@@ -35567,9 +35988,19 @@ function FolderRow({
35567
35988
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
35568
35989
  "div",
35569
35990
  {
35570
- className: "group flex items-start gap-1 py-1 hover:bg-surface-800 transition-colors cursor-pointer text-surface-400",
35991
+ className: `group flex items-start gap-1 py-1 hover:bg-surface-800 transition-colors cursor-pointer text-surface-400 ${dropOver ? "outline outline-1 outline-blue-500 rounded" : ""}`,
35571
35992
  style: { paddingLeft: indent },
35572
35993
  onClick: () => setExpanded((e) => !e),
35994
+ onDragOver: dragCtx.dragging ? (e) => {
35995
+ e.preventDefault();
35996
+ setDropOver(true);
35997
+ } : void 0,
35998
+ onDragLeave: () => setDropOver(false),
35999
+ onDrop: (e) => {
36000
+ e.preventDefault();
36001
+ setDropOver(false);
36002
+ dragCtx.onDrop(collectionId, folder.id);
36003
+ },
35573
36004
  children: [
35574
36005
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] w-3 text-center shrink-0 mt-0.5", children: expanded ? "▾" : "▸" }),
35575
36006
  /* @__PURE__ */ jsxRuntimeExports.jsx(FolderIcon, { className: `shrink-0 mt-0.5 ${hasInheritedConfig ? "text-blue-500" : "text-amber-600"}` }),
@@ -35603,7 +36034,7 @@ function FolderRow({
35603
36034
  { type: "item", label: "Add request", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {}), onClick: onAddRequest },
35604
36035
  { type: "item", label: "Add sub-folder", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FolderIcon, {}), onClick: onAddFolder },
35605
36036
  { type: "separator" },
35606
- { type: "item", label: "Auth & headers", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(KeyIcon, {}), onClick: () => setShowSettings(true) },
36037
+ { type: "item", label: "Settings", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(KeyIcon, {}), onClick: () => setShowSettings(true) },
35607
36038
  { type: "item", label: "Add tag", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(TagIcon, {}), onClick: () => setAddingTag(true) },
35608
36039
  { type: "item", label: "Rename", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(PencilIcon, {}), onClick: () => setRenaming(true) },
35609
36040
  { type: "item", label: "Duplicate", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, {}), onClick: onDuplicate },
@@ -35689,13 +36120,16 @@ function FolderContents({
35689
36120
  },
35690
36121
  sub.id
35691
36122
  )),
35692
- folder.requestIds.map((reqId) => {
36123
+ folder.requestIds.map((reqId, reqIndex) => {
35693
36124
  const req = requests[reqId];
35694
36125
  if (!req) return null;
35695
36126
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
35696
36127
  RequestRow,
35697
36128
  {
35698
36129
  reqId: req.id,
36130
+ collectionId,
36131
+ folderId: folder.id,
36132
+ reqIndex,
35699
36133
  name: req.name,
35700
36134
  method: req.method,
35701
36135
  hookType: req.hookType,
@@ -35728,7 +36162,10 @@ const HOOK_COLORS = {
35728
36162
  afterAll: "bg-cyan-800 text-white"
35729
36163
  };
35730
36164
  function RequestRow({
35731
- reqId: _reqId,
36165
+ reqId,
36166
+ collectionId,
36167
+ folderId,
36168
+ reqIndex,
35732
36169
  name: name2,
35733
36170
  method,
35734
36171
  hookType,
@@ -35745,6 +36182,8 @@ function RequestRow({
35745
36182
  }) {
35746
36183
  const [renaming, setRenaming] = reactExports.useState(autoRename);
35747
36184
  const [addingTag, setAddingTag] = reactExports.useState(false);
36185
+ const [dropPos, setDropPos] = reactExports.useState(null);
36186
+ const dragCtx = reactExports.useContext(DragCtx);
35748
36187
  const hookMenuItems = [
35749
36188
  ...["beforeAll", "before", "after", "afterAll"].map((ht) => ({
35750
36189
  type: "item",
@@ -35752,55 +36191,84 @@ function RequestRow({
35752
36191
  onClick: () => onSetHookType(hookType === ht ? void 0 : ht)
35753
36192
  }))
35754
36193
  ];
35755
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
35756
- "div",
35757
- {
35758
- className: `group flex items-start gap-1.5 py-1 pr-1 rounded-sm cursor-pointer transition-colors ${isActive ? "bg-surface-800 text-[var(--text-primary)]" : "text-surface-300 hover:bg-surface-800"}`,
35759
- style: { paddingLeft: indent },
35760
- onClick: onSelect,
35761
- onDoubleClick: () => setRenaming(true),
35762
- children: [
35763
- /* @__PURE__ */ jsxRuntimeExports.jsx(MethodBadge, { method, size: "xs" }),
35764
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
35765
- renaming ? /* @__PURE__ */ jsxRuntimeExports.jsx(
35766
- InlineEdit,
35767
- {
35768
- value: name2,
35769
- onCommit: (v) => {
35770
- onRename(v);
35771
- setRenaming(false);
35772
- },
35773
- onCancel: () => setRenaming(false),
35774
- className: "w-full text-xs"
35775
- }
35776
- ) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 min-w-0", children: [
35777
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs truncate", children: name2 }),
35778
- hookType && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `shrink-0 text-[9px] font-bold px-1 py-px rounded ${HOOK_COLORS[hookType]}`, children: HOOK_LABELS[hookType].toUpperCase() })
36194
+ function handleDragOver(e) {
36195
+ if (!dragCtx.dragging || dragCtx.dragging.requestId === reqId) return;
36196
+ e.preventDefault();
36197
+ const rect = e.currentTarget.getBoundingClientRect();
36198
+ setDropPos(e.clientY < rect.top + rect.height / 2 ? "before" : "after");
36199
+ }
36200
+ function handleDrop(e) {
36201
+ e.preventDefault();
36202
+ e.stopPropagation();
36203
+ const insertIndex = dropPos === "before" ? reqIndex : reqIndex + 1;
36204
+ dragCtx.onDrop(collectionId, folderId, insertIndex);
36205
+ setDropPos(null);
36206
+ }
36207
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [
36208
+ dropPos === "before" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute top-0 inset-x-0 h-0.5 bg-blue-500 z-10 pointer-events-none" }),
36209
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
36210
+ "div",
36211
+ {
36212
+ draggable: true,
36213
+ className: `group flex items-start gap-1.5 py-1 pr-1 rounded-sm cursor-pointer transition-colors ${isActive ? "bg-surface-800 text-[var(--text-primary)]" : "text-surface-300 hover:bg-surface-800"}`,
36214
+ style: { paddingLeft: indent },
36215
+ onClick: onSelect,
36216
+ onDoubleClick: () => setRenaming(true),
36217
+ onDragStart: (e) => {
36218
+ e.dataTransfer.effectAllowed = "move";
36219
+ dragCtx.setDragging({ requestId: reqId, collectionId });
36220
+ },
36221
+ onDragEnd: () => {
36222
+ dragCtx.setDragging(null);
36223
+ setDropPos(null);
36224
+ },
36225
+ onDragOver: handleDragOver,
36226
+ onDragLeave: () => setDropPos(null),
36227
+ onDrop: handleDrop,
36228
+ children: [
36229
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MethodBadge, { method, size: "xs" }),
36230
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
36231
+ renaming ? /* @__PURE__ */ jsxRuntimeExports.jsx(
36232
+ InlineEdit,
36233
+ {
36234
+ value: name2,
36235
+ onCommit: (v) => {
36236
+ onRename(v);
36237
+ setRenaming(false);
36238
+ },
36239
+ onCancel: () => setRenaming(false),
36240
+ className: "w-full text-xs"
36241
+ }
36242
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 min-w-0", children: [
36243
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs truncate", children: name2 }),
36244
+ hookType && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `shrink-0 text-[9px] font-bold px-1 py-px rounded ${HOOK_COLORS[hookType]}`, children: HOOK_LABELS[hookType].toUpperCase() })
36245
+ ] }),
36246
+ (tags2.length > 0 || addingTag) && /* @__PURE__ */ jsxRuntimeExports.jsx(
36247
+ TagChips,
36248
+ {
36249
+ tags: tags2,
36250
+ onRemove: (tag) => onUpdateTags(tags2.filter((t2) => t2 !== tag)),
36251
+ onAdd: (tag) => onUpdateTags([...tags2, tag]),
36252
+ forceAdding: addingTag,
36253
+ onDoneAdding: () => setAddingTag(false)
36254
+ }
36255
+ )
35779
36256
  ] }),
35780
- (tags2.length > 0 || addingTag) && /* @__PURE__ */ jsxRuntimeExports.jsx(
35781
- TagChips,
35782
- {
35783
- tags: tags2,
35784
- onRemove: (tag) => onUpdateTags(tags2.filter((t2) => t2 !== tag)),
35785
- onAdd: (tag) => onUpdateTags([...tags2, tag]),
35786
- forceAdding: addingTag,
35787
- onDoneAdding: () => setAddingTag(false)
35788
- }
35789
- )
35790
- ] }),
35791
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DotsBtn, { items: [
35792
- { type: "item", label: "Rename", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(PencilIcon, {}), onClick: () => setRenaming(true) },
35793
- { type: "item", label: "Duplicate", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, {}), onClick: onDuplicate },
35794
- { type: "item", label: "Add tag", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(TagIcon, {}), onClick: () => setAddingTag(true) },
35795
- { type: "separator" },
35796
- { type: "header", label: "Hook type" },
35797
- ...hookMenuItems,
35798
- { type: "separator" },
35799
- { type: "item", label: "Delete", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(TrashIcon, {}), danger: true, onClick: onDelete }
35800
- ] }) })
35801
- ]
35802
- }
35803
- );
36257
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DotsBtn, { items: [
36258
+ { type: "item", label: "Rename", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(PencilIcon, {}), onClick: () => setRenaming(true) },
36259
+ { type: "item", label: "Duplicate", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, {}), onClick: onDuplicate },
36260
+ { type: "item", label: "Add tag", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(TagIcon, {}), onClick: () => setAddingTag(true) },
36261
+ { type: "separator" },
36262
+ { type: "header", label: "Hook type" },
36263
+ ...hookMenuItems,
36264
+ { type: "separator" },
36265
+ { type: "item", label: "Delete", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(TrashIcon, {}), danger: true, onClick: onDelete }
36266
+ ] }) }),
36267
+ dropPos === "after" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-0 inset-x-0 h-0.5 bg-blue-500 z-10 pointer-events-none" })
36268
+ ]
36269
+ }
36270
+ )
36271
+ ] });
35804
36272
  }
35805
36273
  function DotsHorizontalIcon() {
35806
36274
  return /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { className: "w-3.5 h-3.5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M6 10a2 2 0 11-4 0 2 2 0 014 0zm6 0a2 2 0 11-4 0 2 2 0 014 0zm6 0a2 2 0 11-4 0 2 2 0 014 0z" }) });
@@ -35844,6 +36312,115 @@ function GearIcon() {
35844
36312
  /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" })
35845
36313
  ] });
35846
36314
  }
36315
+ function findFolderById(root2, id2) {
36316
+ if (root2.id === id2) return root2;
36317
+ for (const sub of root2.folders) {
36318
+ const found = findFolderById(sub, id2);
36319
+ if (found) return found;
36320
+ }
36321
+ return null;
36322
+ }
36323
+ function makeHook(req, collectionVars, hookType, scopeId, scopeAncestors, mainRequestId) {
36324
+ return { request: req, collectionVars, isHook: true, hookType, scopeId, scopeAncestors, mainRequestId };
36325
+ }
36326
+ function buildFolderPlan(folder, requests, collectionVars, filterTags, scopeId, ancestorIds, wrappers) {
36327
+ const result = [];
36328
+ const folderReqs = folder.requestIds.map((id2) => requests[id2]).filter(Boolean);
36329
+ const beforeAllHooks = folderReqs.filter((r) => r.hookType === "beforeAll");
36330
+ const beforeHooks = folderReqs.filter((r) => r.hookType === "before");
36331
+ const afterHooks = folderReqs.filter((r) => r.hookType === "after");
36332
+ const afterAllHooks = folderReqs.filter((r) => r.hookType === "afterAll");
36333
+ const regularReqs = folderReqs.filter((r) => !r.hookType);
36334
+ const myWrapper = { scopeId, ancestors: ancestorIds, before: beforeHooks, after: afterHooks };
36335
+ const allWrappers = [...wrappers, myWrapper];
36336
+ for (const req of beforeAllHooks) {
36337
+ result.push(makeHook(req, collectionVars, "beforeAll", scopeId, ancestorIds));
36338
+ }
36339
+ for (const req of regularReqs) {
36340
+ const tags2 = req.meta?.tags ?? [];
36341
+ if (filterTags.length > 0 && !filterTags.some((t2) => tags2.includes(t2))) continue;
36342
+ for (const w of allWrappers) {
36343
+ for (const hookReq of w.before) {
36344
+ result.push(makeHook(hookReq, collectionVars, "before", w.scopeId, w.ancestors, req.id));
36345
+ }
36346
+ }
36347
+ result.push({ request: req, collectionVars, scopeId, scopeAncestors: ancestorIds });
36348
+ for (const w of [...allWrappers].reverse()) {
36349
+ for (const hookReq of w.after) {
36350
+ result.push(makeHook(hookReq, collectionVars, "after", w.scopeId, w.ancestors, req.id));
36351
+ }
36352
+ }
36353
+ }
36354
+ for (const sub of folder.folders) {
36355
+ const folderTags = sub.tags ?? [];
36356
+ const effectiveFilter = filterTags.length === 0 ? filterTags : folderTags.some((t2) => filterTags.includes(t2)) ? [] : filterTags;
36357
+ result.push(...buildFolderPlan(
36358
+ sub,
36359
+ requests,
36360
+ collectionVars,
36361
+ effectiveFilter,
36362
+ sub.id,
36363
+ [...ancestorIds, scopeId],
36364
+ allWrappers
36365
+ ));
36366
+ }
36367
+ for (const req of afterAllHooks) {
36368
+ result.push(makeHook(req, collectionVars, "afterAll", scopeId, ancestorIds));
36369
+ }
36370
+ return result;
36371
+ }
36372
+ function collectAllTags(folder, requests) {
36373
+ const tags2 = /* @__PURE__ */ new Set();
36374
+ function walk(f) {
36375
+ (f.tags ?? []).forEach((t2) => tags2.add(t2));
36376
+ for (const reqId of f.requestIds) {
36377
+ (requests[reqId]?.meta?.tags ?? []).forEach((t2) => tags2.add(t2));
36378
+ }
36379
+ f.folders.forEach(walk);
36380
+ }
36381
+ walk(folder);
36382
+ return Array.from(tags2).sort();
36383
+ }
36384
+ function folderPathTo(root2, requestId) {
36385
+ if (root2.requestIds.includes(requestId)) return [root2];
36386
+ for (const sub of root2.folders) {
36387
+ const path = folderPathTo(sub, requestId);
36388
+ if (path.length > 0) return [root2, ...path];
36389
+ }
36390
+ return [];
36391
+ }
36392
+ function getHooksForRequest(requestId, collection) {
36393
+ const path = folderPathTo(collection.rootFolder, requestId);
36394
+ const before = [];
36395
+ const afterReversed = [];
36396
+ for (const folder of path) {
36397
+ const reqs = folder.requestIds.map((id2) => collection.requests[id2]).filter(Boolean);
36398
+ const bAll = reqs.filter((r) => r.hookType === "beforeAll");
36399
+ const bEach = reqs.filter((r) => r.hookType === "before");
36400
+ const aEach = reqs.filter((r) => r.hookType === "after");
36401
+ const aAll = reqs.filter((r) => r.hookType === "afterAll");
36402
+ before.push(...bAll, ...bEach);
36403
+ afterReversed.push(...aEach, ...aAll);
36404
+ }
36405
+ return { before, after: afterReversed.reverse() };
36406
+ }
36407
+ function buildRunPlan(collection, folderId, filterTags) {
36408
+ const collectionVars = collection.collectionVariables ?? {};
36409
+ if (folderId) {
36410
+ const folder = findFolderById(collection.rootFolder, folderId);
36411
+ if (!folder) return [];
36412
+ return buildFolderPlan(folder, collection.requests, collectionVars, filterTags, folder.id, [], []);
36413
+ }
36414
+ return buildFolderPlan(
36415
+ collection.rootFolder,
36416
+ collection.requests,
36417
+ collectionVars,
36418
+ filterTags,
36419
+ collection.rootFolder.id,
36420
+ [],
36421
+ []
36422
+ );
36423
+ }
35847
36424
  function ParamsTab({ request, onChange }) {
35848
36425
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
35849
36426
  KVTable,
@@ -35862,7 +36439,8 @@ function HeadersTab({ request, onChange }) {
35862
36439
  rows: request.headers,
35863
36440
  onChange: (rows) => onChange({ headers: rows }),
35864
36441
  keyPlaceholder: "Header-Name",
35865
- valuePlaceholder: "value"
36442
+ valuePlaceholder: "value",
36443
+ headerMode: true
35866
36444
  }
35867
36445
  );
35868
36446
  }
@@ -44317,8 +44895,8 @@ var scope = {};
44317
44895
  var util = {};
44318
44896
  Object.defineProperty(util, "__esModule", { value: true });
44319
44897
  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;
44320
- const codegen_1$v = codegen;
44321
- const code_1$a = code$1;
44898
+ const codegen_1$q = codegen;
44899
+ const code_1$9 = code$1;
44322
44900
  function toHash(arr) {
44323
44901
  const hash = {};
44324
44902
  for (const item of arr)
@@ -44371,9 +44949,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
44371
44949
  if (typeof schema == "number" || typeof schema == "boolean")
44372
44950
  return schema;
44373
44951
  if (typeof schema == "string")
44374
- return (0, codegen_1$v._)`${schema}`;
44952
+ return (0, codegen_1$q._)`${schema}`;
44375
44953
  }
44376
- return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
44954
+ return (0, codegen_1$q._)`${topSchemaRef}${schemaPath}${(0, codegen_1$q.getProperty)(keyword2)}`;
44377
44955
  }
44378
44956
  util.schemaRefOrVal = schemaRefOrVal;
44379
44957
  function unescapeFragment(str) {
@@ -44405,20 +44983,20 @@ function eachItem(xs, f) {
44405
44983
  util.eachItem = eachItem;
44406
44984
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
44407
44985
  return (gen, from, to, toName) => {
44408
- 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);
44409
- return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
44986
+ 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);
44987
+ return toName === codegen_1$q.Name && !(res instanceof codegen_1$q.Name) ? resultToName(gen, res) : res;
44410
44988
  };
44411
44989
  }
44412
44990
  util.mergeEvaluated = {
44413
44991
  props: makeMergeEvaluated({
44414
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
44415
- 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})`));
44992
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => {
44993
+ 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})`));
44416
44994
  }),
44417
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
44995
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => {
44418
44996
  if (from === true) {
44419
44997
  gen.assign(to, true);
44420
44998
  } else {
44421
- gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
44999
+ gen.assign(to, (0, codegen_1$q._)`${to} || {}`);
44422
45000
  setEvaluated(gen, to, from);
44423
45001
  }
44424
45002
  }),
@@ -44426,8 +45004,8 @@ util.mergeEvaluated = {
44426
45004
  resultToName: evaluatedPropsToName
44427
45005
  }),
44428
45006
  items: makeMergeEvaluated({
44429
- 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}`)),
44430
- 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}`)),
45007
+ 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}`)),
45008
+ 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}`)),
44431
45009
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
44432
45010
  resultToName: (gen, items2) => gen.var("items", items2)
44433
45011
  })
@@ -44435,21 +45013,21 @@ util.mergeEvaluated = {
44435
45013
  function evaluatedPropsToName(gen, ps) {
44436
45014
  if (ps === true)
44437
45015
  return gen.var("props", true);
44438
- const props = gen.var("props", (0, codegen_1$v._)`{}`);
45016
+ const props = gen.var("props", (0, codegen_1$q._)`{}`);
44439
45017
  if (ps !== void 0)
44440
45018
  setEvaluated(gen, props, ps);
44441
45019
  return props;
44442
45020
  }
44443
45021
  util.evaluatedPropsToName = evaluatedPropsToName;
44444
45022
  function setEvaluated(gen, props, ps) {
44445
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
45023
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$q._)`${props}${(0, codegen_1$q.getProperty)(p)}`, true));
44446
45024
  }
44447
45025
  util.setEvaluated = setEvaluated;
44448
45026
  const snippets = {};
44449
45027
  function useFunc(gen, f) {
44450
45028
  return gen.scopeValue("func", {
44451
45029
  ref: f,
44452
- code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
45030
+ code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
44453
45031
  });
44454
45032
  }
44455
45033
  util.useFunc = useFunc;
@@ -44459,11 +45037,11 @@ var Type;
44459
45037
  Type2[Type2["Str"] = 1] = "Str";
44460
45038
  })(Type || (util.Type = Type = {}));
44461
45039
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
44462
- if (dataProp instanceof codegen_1$v.Name) {
45040
+ if (dataProp instanceof codegen_1$q.Name) {
44463
45041
  const isNumber = dataPropType === Type.Num;
44464
- 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")`;
45042
+ 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")`;
44465
45043
  }
44466
- return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
45044
+ return jsPropertySyntax ? (0, codegen_1$q.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
44467
45045
  }
44468
45046
  util.getErrorPath = getErrorPath;
44469
45047
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -44477,35 +45055,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
44477
45055
  util.checkStrictMode = checkStrictMode;
44478
45056
  var names$1 = {};
44479
45057
  Object.defineProperty(names$1, "__esModule", { value: true });
44480
- const codegen_1$u = codegen;
45058
+ const codegen_1$p = codegen;
44481
45059
  const names = {
44482
45060
  // validation function arguments
44483
- data: new codegen_1$u.Name("data"),
45061
+ data: new codegen_1$p.Name("data"),
44484
45062
  // data passed to validation function
44485
45063
  // args passed from referencing schema
44486
- valCxt: new codegen_1$u.Name("valCxt"),
45064
+ valCxt: new codegen_1$p.Name("valCxt"),
44487
45065
  // validation/data context - should not be used directly, it is destructured to the names below
44488
- instancePath: new codegen_1$u.Name("instancePath"),
44489
- parentData: new codegen_1$u.Name("parentData"),
44490
- parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
44491
- rootData: new codegen_1$u.Name("rootData"),
45066
+ instancePath: new codegen_1$p.Name("instancePath"),
45067
+ parentData: new codegen_1$p.Name("parentData"),
45068
+ parentDataProperty: new codegen_1$p.Name("parentDataProperty"),
45069
+ rootData: new codegen_1$p.Name("rootData"),
44492
45070
  // root data - same as the data passed to the first/top validation function
44493
- dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
45071
+ dynamicAnchors: new codegen_1$p.Name("dynamicAnchors"),
44494
45072
  // used to support recursiveRef and dynamicRef
44495
45073
  // function scoped variables
44496
- vErrors: new codegen_1$u.Name("vErrors"),
45074
+ vErrors: new codegen_1$p.Name("vErrors"),
44497
45075
  // null or array of validation errors
44498
- errors: new codegen_1$u.Name("errors"),
45076
+ errors: new codegen_1$p.Name("errors"),
44499
45077
  // counter of validation errors
44500
- this: new codegen_1$u.Name("this"),
45078
+ this: new codegen_1$p.Name("this"),
44501
45079
  // "globals"
44502
- self: new codegen_1$u.Name("self"),
44503
- scope: new codegen_1$u.Name("scope"),
45080
+ self: new codegen_1$p.Name("self"),
45081
+ scope: new codegen_1$p.Name("scope"),
44504
45082
  // JTD serialize/parse name for JSON string and position
44505
- json: new codegen_1$u.Name("json"),
44506
- jsonPos: new codegen_1$u.Name("jsonPos"),
44507
- jsonLen: new codegen_1$u.Name("jsonLen"),
44508
- jsonPart: new codegen_1$u.Name("jsonPart")
45083
+ json: new codegen_1$p.Name("json"),
45084
+ jsonPos: new codegen_1$p.Name("jsonPos"),
45085
+ jsonLen: new codegen_1$p.Name("jsonLen"),
45086
+ jsonPart: new codegen_1$p.Name("jsonPart")
44509
45087
  };
44510
45088
  names$1.default = names;
44511
45089
  (function(exports$1) {
@@ -44625,49 +45203,55 @@ names$1.default = names;
44625
45203
  keyValues.push([E.propertyName, propertyName2]);
44626
45204
  }
44627
45205
  })(errors);
44628
- Object.defineProperty(boolSchema, "__esModule", { value: true });
44629
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
44630
- const errors_1$3 = errors;
44631
- const codegen_1$t = codegen;
44632
- const names_1$6 = names$1;
44633
- const boolError = {
44634
- message: "boolean schema is false"
44635
- };
44636
- function topBoolOrEmptySchema(it) {
44637
- const { gen, schema, validateName } = it;
44638
- if (schema === false) {
44639
- falseSchemaError(it, false);
44640
- } else if (typeof schema == "object" && schema.$async === true) {
44641
- gen.return(names_1$6.default.data);
44642
- } else {
44643
- gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
44644
- gen.return(true);
45206
+ var hasRequiredBoolSchema;
45207
+ function requireBoolSchema() {
45208
+ if (hasRequiredBoolSchema) return boolSchema;
45209
+ hasRequiredBoolSchema = 1;
45210
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
45211
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
45212
+ const errors_12 = errors;
45213
+ const codegen_12 = codegen;
45214
+ const names_12 = names$1;
45215
+ const boolError = {
45216
+ message: "boolean schema is false"
45217
+ };
45218
+ function topBoolOrEmptySchema(it) {
45219
+ const { gen, schema, validateName } = it;
45220
+ if (schema === false) {
45221
+ falseSchemaError(it, false);
45222
+ } else if (typeof schema == "object" && schema.$async === true) {
45223
+ gen.return(names_12.default.data);
45224
+ } else {
45225
+ gen.assign((0, codegen_12._)`${validateName}.errors`, null);
45226
+ gen.return(true);
45227
+ }
44645
45228
  }
44646
- }
44647
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
44648
- function boolOrEmptySchema(it, valid) {
44649
- const { gen, schema } = it;
44650
- if (schema === false) {
44651
- gen.var(valid, false);
44652
- falseSchemaError(it);
44653
- } else {
44654
- gen.var(valid, true);
45229
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
45230
+ function boolOrEmptySchema(it, valid) {
45231
+ const { gen, schema } = it;
45232
+ if (schema === false) {
45233
+ gen.var(valid, false);
45234
+ falseSchemaError(it);
45235
+ } else {
45236
+ gen.var(valid, true);
45237
+ }
45238
+ }
45239
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
45240
+ function falseSchemaError(it, overrideAllErrors) {
45241
+ const { gen, data } = it;
45242
+ const cxt = {
45243
+ gen,
45244
+ keyword: "false schema",
45245
+ data,
45246
+ schema: false,
45247
+ schemaCode: false,
45248
+ schemaValue: false,
45249
+ params: {},
45250
+ it
45251
+ };
45252
+ (0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
44655
45253
  }
44656
- }
44657
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
44658
- function falseSchemaError(it, overrideAllErrors) {
44659
- const { gen, data } = it;
44660
- const cxt = {
44661
- gen,
44662
- keyword: "false schema",
44663
- data,
44664
- schema: false,
44665
- schemaCode: false,
44666
- schemaValue: false,
44667
- params: {},
44668
- it
44669
- };
44670
- (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
45254
+ return boolSchema;
44671
45255
  }
44672
45256
  var dataType = {};
44673
45257
  var rules = {};
@@ -44715,10 +45299,10 @@ applicability.shouldUseRule = shouldUseRule;
44715
45299
  Object.defineProperty(dataType, "__esModule", { value: true });
44716
45300
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
44717
45301
  const rules_1 = rules;
44718
- const applicability_1$1 = applicability;
44719
- const errors_1$2 = errors;
44720
- const codegen_1$s = codegen;
44721
- const util_1$r = util;
45302
+ const applicability_1 = applicability;
45303
+ const errors_1 = errors;
45304
+ const codegen_1$o = codegen;
45305
+ const util_1$o = util;
44722
45306
  var DataType;
44723
45307
  (function(DataType2) {
44724
45308
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -44750,7 +45334,7 @@ dataType.getJSONTypes = getJSONTypes;
44750
45334
  function coerceAndCheckDataType(it, types2) {
44751
45335
  const { gen, data, opts } = it;
44752
45336
  const coerceTo = coerceToTypes(types2, opts.coerceTypes);
44753
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
45337
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
44754
45338
  if (checkTypes) {
44755
45339
  const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
44756
45340
  gen.if(wrongType, () => {
@@ -44769,12 +45353,12 @@ function coerceToTypes(types2, coerceTypes) {
44769
45353
  }
44770
45354
  function coerceData(it, types2, coerceTo) {
44771
45355
  const { gen, data, opts } = it;
44772
- const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
44773
- const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
45356
+ const dataType2 = gen.let("dataType", (0, codegen_1$o._)`typeof ${data}`);
45357
+ const coerced = gen.let("coerced", (0, codegen_1$o._)`undefined`);
44774
45358
  if (opts.coerceTypes === "array") {
44775
- 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)));
45359
+ 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)));
44776
45360
  }
44777
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
45361
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
44778
45362
  for (const t2 of coerceTo) {
44779
45363
  if (COERCIBLE.has(t2) || t2 === "array" && opts.coerceTypes === "array") {
44780
45364
  coerceSpecificType(t2);
@@ -44783,63 +45367,63 @@ function coerceData(it, types2, coerceTo) {
44783
45367
  gen.else();
44784
45368
  reportTypeError(it);
44785
45369
  gen.endIf();
44786
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
45370
+ gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
44787
45371
  gen.assign(data, coerced);
44788
45372
  assignParentData(it, coerced);
44789
45373
  });
44790
45374
  function coerceSpecificType(t2) {
44791
45375
  switch (t2) {
44792
45376
  case "string":
44793
- 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._)`""`);
45377
+ 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._)`""`);
44794
45378
  return;
44795
45379
  case "number":
44796
- gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
44797
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
45380
+ gen.elseIf((0, codegen_1$o._)`${dataType2} == "boolean" || ${data} === null
45381
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$o._)`+${data}`);
44798
45382
  return;
44799
45383
  case "integer":
44800
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
44801
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
45384
+ gen.elseIf((0, codegen_1$o._)`${dataType2} === "boolean" || ${data} === null
45385
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$o._)`+${data}`);
44802
45386
  return;
44803
45387
  case "boolean":
44804
- 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);
45388
+ 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);
44805
45389
  return;
44806
45390
  case "null":
44807
- gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
45391
+ gen.elseIf((0, codegen_1$o._)`${data} === "" || ${data} === 0 || ${data} === false`);
44808
45392
  gen.assign(coerced, null);
44809
45393
  return;
44810
45394
  case "array":
44811
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
44812
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
45395
+ gen.elseIf((0, codegen_1$o._)`${dataType2} === "string" || ${dataType2} === "number"
45396
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$o._)`[${data}]`);
44813
45397
  }
44814
45398
  }
44815
45399
  }
44816
45400
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
44817
- gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
45401
+ gen.if((0, codegen_1$o._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$o._)`${parentData}[${parentDataProperty}]`, expr));
44818
45402
  }
44819
45403
  function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
44820
- const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
45404
+ const EQ = correct === DataType.Correct ? codegen_1$o.operators.EQ : codegen_1$o.operators.NEQ;
44821
45405
  let cond;
44822
45406
  switch (dataType2) {
44823
45407
  case "null":
44824
- return (0, codegen_1$s._)`${data} ${EQ} null`;
45408
+ return (0, codegen_1$o._)`${data} ${EQ} null`;
44825
45409
  case "array":
44826
- cond = (0, codegen_1$s._)`Array.isArray(${data})`;
45410
+ cond = (0, codegen_1$o._)`Array.isArray(${data})`;
44827
45411
  break;
44828
45412
  case "object":
44829
- cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
45413
+ cond = (0, codegen_1$o._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
44830
45414
  break;
44831
45415
  case "integer":
44832
- cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
45416
+ cond = numCond((0, codegen_1$o._)`!(${data} % 1) && !isNaN(${data})`);
44833
45417
  break;
44834
45418
  case "number":
44835
45419
  cond = numCond();
44836
45420
  break;
44837
45421
  default:
44838
- return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
45422
+ return (0, codegen_1$o._)`typeof ${data} ${EQ} ${dataType2}`;
44839
45423
  }
44840
- return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
44841
- function numCond(_cond = codegen_1$s.nil) {
44842
- 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);
45424
+ return correct === DataType.Correct ? cond : (0, codegen_1$o.not)(cond);
45425
+ function numCond(_cond = codegen_1$o.nil) {
45426
+ 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);
44843
45427
  }
44844
45428
  }
44845
45429
  dataType.checkDataType = checkDataType;
@@ -44848,35 +45432,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
44848
45432
  return checkDataType(dataTypes[0], data, strictNums, correct);
44849
45433
  }
44850
45434
  let cond;
44851
- const types2 = (0, util_1$r.toHash)(dataTypes);
45435
+ const types2 = (0, util_1$o.toHash)(dataTypes);
44852
45436
  if (types2.array && types2.object) {
44853
- const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
44854
- cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
45437
+ const notObj = (0, codegen_1$o._)`typeof ${data} != "object"`;
45438
+ cond = types2.null ? notObj : (0, codegen_1$o._)`!${data} || ${notObj}`;
44855
45439
  delete types2.null;
44856
45440
  delete types2.array;
44857
45441
  delete types2.object;
44858
45442
  } else {
44859
- cond = codegen_1$s.nil;
45443
+ cond = codegen_1$o.nil;
44860
45444
  }
44861
45445
  if (types2.number)
44862
45446
  delete types2.integer;
44863
45447
  for (const t2 in types2)
44864
- cond = (0, codegen_1$s.and)(cond, checkDataType(t2, data, strictNums, correct));
45448
+ cond = (0, codegen_1$o.and)(cond, checkDataType(t2, data, strictNums, correct));
44865
45449
  return cond;
44866
45450
  }
44867
45451
  dataType.checkDataTypes = checkDataTypes;
44868
45452
  const typeError = {
44869
45453
  message: ({ schema }) => `must be ${schema}`,
44870
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
45454
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$o._)`{type: ${schema}}` : (0, codegen_1$o._)`{type: ${schemaValue}}`
44871
45455
  };
44872
45456
  function reportTypeError(it) {
44873
45457
  const cxt = getTypeErrorContext(it);
44874
- (0, errors_1$2.reportError)(cxt, typeError);
45458
+ (0, errors_1.reportError)(cxt, typeError);
44875
45459
  }
44876
45460
  dataType.reportTypeError = reportTypeError;
44877
45461
  function getTypeErrorContext(it) {
44878
45462
  const { gen, data, schema } = it;
44879
- const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
45463
+ const schemaCode = (0, util_1$o.schemaRefOrVal)(it, schema, "type");
44880
45464
  return {
44881
45465
  gen,
44882
45466
  keyword: "type",
@@ -44890,54 +45474,60 @@ function getTypeErrorContext(it) {
44890
45474
  };
44891
45475
  }
44892
45476
  var defaults = {};
44893
- Object.defineProperty(defaults, "__esModule", { value: true });
44894
- defaults.assignDefaults = void 0;
44895
- const codegen_1$r = codegen;
44896
- const util_1$q = util;
44897
- function assignDefaults(it, ty) {
44898
- const { properties: properties2, items: items2 } = it.schema;
44899
- if (ty === "object" && properties2) {
44900
- for (const key in properties2) {
44901
- assignDefault(it, key, properties2[key].default);
44902
- }
44903
- } else if (ty === "array" && Array.isArray(items2)) {
44904
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
44905
- }
44906
- }
44907
- defaults.assignDefaults = assignDefaults;
44908
- function assignDefault(it, prop, defaultValue) {
44909
- const { gen, compositeRule, data, opts } = it;
44910
- if (defaultValue === void 0)
44911
- return;
44912
- const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
44913
- if (compositeRule) {
44914
- (0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
44915
- return;
45477
+ var hasRequiredDefaults;
45478
+ function requireDefaults() {
45479
+ if (hasRequiredDefaults) return defaults;
45480
+ hasRequiredDefaults = 1;
45481
+ Object.defineProperty(defaults, "__esModule", { value: true });
45482
+ defaults.assignDefaults = void 0;
45483
+ const codegen_12 = codegen;
45484
+ const util_12 = util;
45485
+ function assignDefaults(it, ty) {
45486
+ const { properties: properties2, items: items2 } = it.schema;
45487
+ if (ty === "object" && properties2) {
45488
+ for (const key in properties2) {
45489
+ assignDefault(it, key, properties2[key].default);
45490
+ }
45491
+ } else if (ty === "array" && Array.isArray(items2)) {
45492
+ items2.forEach((sch, i) => assignDefault(it, i, sch.default));
45493
+ }
44916
45494
  }
44917
- let condition = (0, codegen_1$r._)`${childData} === undefined`;
44918
- if (opts.useDefaults === "empty") {
44919
- condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
45495
+ defaults.assignDefaults = assignDefaults;
45496
+ function assignDefault(it, prop, defaultValue) {
45497
+ const { gen, compositeRule, data, opts } = it;
45498
+ if (defaultValue === void 0)
45499
+ return;
45500
+ const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
45501
+ if (compositeRule) {
45502
+ (0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
45503
+ return;
45504
+ }
45505
+ let condition = (0, codegen_12._)`${childData} === undefined`;
45506
+ if (opts.useDefaults === "empty") {
45507
+ condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
45508
+ }
45509
+ gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
44920
45510
  }
44921
- gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
45511
+ return defaults;
44922
45512
  }
44923
45513
  var keyword = {};
44924
45514
  var code = {};
44925
45515
  Object.defineProperty(code, "__esModule", { value: true });
44926
45516
  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;
44927
- const codegen_1$q = codegen;
44928
- const util_1$p = util;
44929
- const names_1$5 = names$1;
45517
+ const codegen_1$n = codegen;
45518
+ const util_1$n = util;
45519
+ const names_1$3 = names$1;
44930
45520
  const util_2$1 = util;
44931
45521
  function checkReportMissingProp(cxt, prop) {
44932
45522
  const { gen, data, it } = cxt;
44933
45523
  gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
44934
- cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
45524
+ cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
44935
45525
  cxt.error();
44936
45526
  });
44937
45527
  }
44938
45528
  code.checkReportMissingProp = checkReportMissingProp;
44939
45529
  function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
44940
- 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}`)));
45530
+ 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}`)));
44941
45531
  }
44942
45532
  code.checkMissingProp = checkMissingProp;
44943
45533
  function reportMissingProp(cxt, missing) {
@@ -44949,22 +45539,22 @@ function hasPropFunc(gen) {
44949
45539
  return gen.scopeValue("func", {
44950
45540
  // eslint-disable-next-line @typescript-eslint/unbound-method
44951
45541
  ref: Object.prototype.hasOwnProperty,
44952
- code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
45542
+ code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
44953
45543
  });
44954
45544
  }
44955
45545
  code.hasPropFunc = hasPropFunc;
44956
45546
  function isOwnProperty(gen, data, property) {
44957
- return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
45547
+ return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
44958
45548
  }
44959
45549
  code.isOwnProperty = isOwnProperty;
44960
45550
  function propertyInData(gen, data, property, ownProperties) {
44961
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
44962
- return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
45551
+ const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} !== undefined`;
45552
+ return ownProperties ? (0, codegen_1$n._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
44963
45553
  }
44964
45554
  code.propertyInData = propertyInData;
44965
45555
  function noPropertyInData(gen, data, property, ownProperties) {
44966
- const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
44967
- return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond;
45556
+ const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} === undefined`;
45557
+ return ownProperties ? (0, codegen_1$n.or)(cond, (0, codegen_1$n.not)(isOwnProperty(gen, data, property))) : cond;
44968
45558
  }
44969
45559
  code.noPropertyInData = noPropertyInData;
44970
45560
  function allSchemaProperties(schemaMap) {
@@ -44972,24 +45562,24 @@ function allSchemaProperties(schemaMap) {
44972
45562
  }
44973
45563
  code.allSchemaProperties = allSchemaProperties;
44974
45564
  function schemaProperties(it, schemaMap) {
44975
- return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$p.alwaysValidSchema)(it, schemaMap[p]));
45565
+ return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$n.alwaysValidSchema)(it, schemaMap[p]));
44976
45566
  }
44977
45567
  code.schemaProperties = schemaProperties;
44978
45568
  function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
44979
- const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
45569
+ const dataAndSchema = passSchema ? (0, codegen_1$n._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
44980
45570
  const valCxt = [
44981
- [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
44982
- [names_1$5.default.parentData, it.parentData],
44983
- [names_1$5.default.parentDataProperty, it.parentDataProperty],
44984
- [names_1$5.default.rootData, names_1$5.default.rootData]
45571
+ [names_1$3.default.instancePath, (0, codegen_1$n.strConcat)(names_1$3.default.instancePath, errorPath)],
45572
+ [names_1$3.default.parentData, it.parentData],
45573
+ [names_1$3.default.parentDataProperty, it.parentDataProperty],
45574
+ [names_1$3.default.rootData, names_1$3.default.rootData]
44985
45575
  ];
44986
45576
  if (it.opts.dynamicRef)
44987
- valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
44988
- const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
44989
- return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
45577
+ valCxt.push([names_1$3.default.dynamicAnchors, names_1$3.default.dynamicAnchors]);
45578
+ const args = (0, codegen_1$n._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
45579
+ return context !== codegen_1$n.nil ? (0, codegen_1$n._)`${func}.call(${context}, ${args})` : (0, codegen_1$n._)`${func}(${args})`;
44990
45580
  }
44991
45581
  code.callValidateCode = callValidateCode;
44992
- const newRegExp = (0, codegen_1$q._)`new RegExp`;
45582
+ const newRegExp = (0, codegen_1$n._)`new RegExp`;
44993
45583
  function usePattern({ gen, it: { opts } }, pattern2) {
44994
45584
  const u = opts.unicodeRegExp ? "u" : "";
44995
45585
  const { regExp } = opts.code;
@@ -44997,7 +45587,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
44997
45587
  return gen.scopeValue("pattern", {
44998
45588
  key: rx.toString(),
44999
45589
  ref: rx,
45000
- code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
45590
+ code: (0, codegen_1$n._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
45001
45591
  });
45002
45592
  }
45003
45593
  code.usePattern = usePattern;
@@ -45013,14 +45603,14 @@ function validateArray(cxt) {
45013
45603
  validateItems(() => gen.break());
45014
45604
  return valid;
45015
45605
  function validateItems(notValid) {
45016
- const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
45606
+ const len = gen.const("len", (0, codegen_1$n._)`${data}.length`);
45017
45607
  gen.forRange("i", 0, len, (i) => {
45018
45608
  cxt.subschema({
45019
45609
  keyword: keyword2,
45020
45610
  dataProp: i,
45021
- dataPropType: util_1$p.Type.Num
45611
+ dataPropType: util_1$n.Type.Num
45022
45612
  }, valid);
45023
- gen.if((0, codegen_1$q.not)(valid), notValid);
45613
+ gen.if((0, codegen_1$n.not)(valid), notValid);
45024
45614
  });
45025
45615
  }
45026
45616
  }
@@ -45029,7 +45619,7 @@ function validateUnion(cxt) {
45029
45619
  const { gen, schema, keyword: keyword2, it } = cxt;
45030
45620
  if (!Array.isArray(schema))
45031
45621
  throw new Error("ajv implementation error");
45032
- const alwaysValid = schema.some((sch) => (0, util_1$p.alwaysValidSchema)(it, sch));
45622
+ const alwaysValid = schema.some((sch) => (0, util_1$n.alwaysValidSchema)(it, sch));
45033
45623
  if (alwaysValid && !it.opts.unevaluated)
45034
45624
  return;
45035
45625
  const valid = gen.let("valid", false);
@@ -45040,202 +45630,214 @@ function validateUnion(cxt) {
45040
45630
  schemaProp: i,
45041
45631
  compositeRule: true
45042
45632
  }, schValid);
45043
- gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
45633
+ gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
45044
45634
  const merged = cxt.mergeValidEvaluated(schCxt, schValid);
45045
45635
  if (!merged)
45046
- gen.if((0, codegen_1$q.not)(valid));
45636
+ gen.if((0, codegen_1$n.not)(valid));
45047
45637
  }));
45048
45638
  cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
45049
45639
  }
45050
45640
  code.validateUnion = validateUnion;
45051
- Object.defineProperty(keyword, "__esModule", { value: true });
45052
- keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
45053
- const codegen_1$p = codegen;
45054
- const names_1$4 = names$1;
45055
- const code_1$9 = code;
45056
- const errors_1$1 = errors;
45057
- function macroKeywordCode(cxt, def2) {
45058
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
45059
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
45060
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
45061
- if (it.opts.validateSchema !== false)
45062
- it.self.validateSchema(macroSchema, true);
45063
- const valid = gen.name("valid");
45064
- cxt.subschema({
45065
- schema: macroSchema,
45066
- schemaPath: codegen_1$p.nil,
45067
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
45068
- topSchemaRef: schemaRef,
45069
- compositeRule: true
45070
- }, valid);
45071
- cxt.pass(valid, () => cxt.error(true));
45072
- }
45073
- keyword.macroKeywordCode = macroKeywordCode;
45074
- function funcKeywordCode(cxt, def2) {
45075
- var _a2;
45076
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
45077
- checkAsyncKeyword(it, def2);
45078
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
45079
- const validateRef = useKeyword(gen, keyword2, validate2);
45080
- const valid = gen.let("valid");
45081
- cxt.block$data(valid, validateKeyword);
45082
- cxt.ok((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid);
45083
- function validateKeyword() {
45084
- if (def2.errors === false) {
45085
- assignValid();
45086
- if (def2.modifying)
45087
- modifyData(cxt);
45088
- reportErrs(() => cxt.error());
45089
- } else {
45090
- const ruleErrs = def2.async ? validateAsync() : validateSync();
45091
- if (def2.modifying)
45092
- modifyData(cxt);
45093
- reportErrs(() => addErrs(cxt, ruleErrs));
45094
- }
45095
- }
45096
- function validateAsync() {
45097
- const ruleErrs = gen.let("ruleErrs", null);
45098
- 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)));
45099
- return ruleErrs;
45100
- }
45101
- function validateSync() {
45102
- const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
45103
- gen.assign(validateErrs, null);
45104
- assignValid(codegen_1$p.nil);
45105
- return validateErrs;
45106
- }
45107
- function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
45108
- const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
45109
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
45110
- gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
45111
- }
45112
- function reportErrs(errors2) {
45113
- var _a3;
45114
- gen.if((0, codegen_1$p.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
45115
- }
45116
- }
45117
- keyword.funcKeywordCode = funcKeywordCode;
45118
- function modifyData(cxt) {
45119
- const { gen, data, it } = cxt;
45120
- gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
45121
- }
45122
- function addErrs(cxt, errs) {
45123
- const { gen } = cxt;
45124
- gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
45125
- 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`);
45126
- (0, errors_1$1.extendErrors)(cxt);
45127
- }, () => cxt.error());
45128
- }
45129
- function checkAsyncKeyword({ schemaEnv }, def2) {
45130
- if (def2.async && !schemaEnv.$async)
45131
- throw new Error("async keyword in sync schema");
45132
- }
45133
- function useKeyword(gen, keyword2, result) {
45134
- if (result === void 0)
45135
- throw new Error(`keyword "${keyword2}" failed to compile`);
45136
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
45137
- }
45138
- function validSchemaType(schema, schemaType, allowUndefined = false) {
45139
- 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");
45140
- }
45141
- keyword.validSchemaType = validSchemaType;
45142
- function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
45143
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
45144
- throw new Error("ajv implementation error");
45641
+ var hasRequiredKeyword;
45642
+ function requireKeyword() {
45643
+ if (hasRequiredKeyword) return keyword;
45644
+ hasRequiredKeyword = 1;
45645
+ Object.defineProperty(keyword, "__esModule", { value: true });
45646
+ keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
45647
+ const codegen_12 = codegen;
45648
+ const names_12 = names$1;
45649
+ const code_12 = code;
45650
+ const errors_12 = errors;
45651
+ function macroKeywordCode(cxt, def2) {
45652
+ const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
45653
+ const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
45654
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
45655
+ if (it.opts.validateSchema !== false)
45656
+ it.self.validateSchema(macroSchema, true);
45657
+ const valid = gen.name("valid");
45658
+ cxt.subschema({
45659
+ schema: macroSchema,
45660
+ schemaPath: codegen_12.nil,
45661
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
45662
+ topSchemaRef: schemaRef,
45663
+ compositeRule: true
45664
+ }, valid);
45665
+ cxt.pass(valid, () => cxt.error(true));
45145
45666
  }
45146
- const deps = def2.dependencies;
45147
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
45148
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
45667
+ keyword.macroKeywordCode = macroKeywordCode;
45668
+ function funcKeywordCode(cxt, def2) {
45669
+ var _a2;
45670
+ const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
45671
+ checkAsyncKeyword(it, def2);
45672
+ const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
45673
+ const validateRef = useKeyword(gen, keyword2, validate2);
45674
+ const valid = gen.let("valid");
45675
+ cxt.block$data(valid, validateKeyword);
45676
+ cxt.ok((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid);
45677
+ function validateKeyword() {
45678
+ if (def2.errors === false) {
45679
+ assignValid();
45680
+ if (def2.modifying)
45681
+ modifyData(cxt);
45682
+ reportErrs(() => cxt.error());
45683
+ } else {
45684
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
45685
+ if (def2.modifying)
45686
+ modifyData(cxt);
45687
+ reportErrs(() => addErrs(cxt, ruleErrs));
45688
+ }
45689
+ }
45690
+ function validateAsync() {
45691
+ const ruleErrs = gen.let("ruleErrs", null);
45692
+ 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)));
45693
+ return ruleErrs;
45694
+ }
45695
+ function validateSync() {
45696
+ const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
45697
+ gen.assign(validateErrs, null);
45698
+ assignValid(codegen_12.nil);
45699
+ return validateErrs;
45700
+ }
45701
+ function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
45702
+ const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
45703
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
45704
+ gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
45705
+ }
45706
+ function reportErrs(errors2) {
45707
+ var _a3;
45708
+ gen.if((0, codegen_12.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
45709
+ }
45149
45710
  }
45150
- if (def2.validateSchema) {
45151
- const valid = def2.validateSchema(schema[keyword2]);
45152
- if (!valid) {
45153
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
45154
- if (opts.validateSchema === "log")
45155
- self.logger.error(msg);
45156
- else
45157
- throw new Error(msg);
45711
+ keyword.funcKeywordCode = funcKeywordCode;
45712
+ function modifyData(cxt) {
45713
+ const { gen, data, it } = cxt;
45714
+ gen.if(it.parentData, () => gen.assign(data, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
45715
+ }
45716
+ function addErrs(cxt, errs) {
45717
+ const { gen } = cxt;
45718
+ gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
45719
+ 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`);
45720
+ (0, errors_12.extendErrors)(cxt);
45721
+ }, () => cxt.error());
45722
+ }
45723
+ function checkAsyncKeyword({ schemaEnv }, def2) {
45724
+ if (def2.async && !schemaEnv.$async)
45725
+ throw new Error("async keyword in sync schema");
45726
+ }
45727
+ function useKeyword(gen, keyword2, result) {
45728
+ if (result === void 0)
45729
+ throw new Error(`keyword "${keyword2}" failed to compile`);
45730
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
45731
+ }
45732
+ function validSchemaType(schema, schemaType, allowUndefined = false) {
45733
+ 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");
45734
+ }
45735
+ keyword.validSchemaType = validSchemaType;
45736
+ function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
45737
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
45738
+ throw new Error("ajv implementation error");
45739
+ }
45740
+ const deps = def2.dependencies;
45741
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
45742
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
45743
+ }
45744
+ if (def2.validateSchema) {
45745
+ const valid = def2.validateSchema(schema[keyword2]);
45746
+ if (!valid) {
45747
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
45748
+ if (opts.validateSchema === "log")
45749
+ self.logger.error(msg);
45750
+ else
45751
+ throw new Error(msg);
45752
+ }
45158
45753
  }
45159
45754
  }
45755
+ keyword.validateKeywordUsage = validateKeywordUsage;
45756
+ return keyword;
45160
45757
  }
45161
- keyword.validateKeywordUsage = validateKeywordUsage;
45162
45758
  var subschema = {};
45163
- Object.defineProperty(subschema, "__esModule", { value: true });
45164
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
45165
- const codegen_1$o = codegen;
45166
- const util_1$o = util;
45167
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
45168
- if (keyword2 !== void 0 && schema !== void 0) {
45169
- throw new Error('both "keyword" and "schema" passed, only one allowed');
45170
- }
45171
- if (keyword2 !== void 0) {
45172
- const sch = it.schema[keyword2];
45173
- return schemaProp === void 0 ? {
45174
- schema: sch,
45175
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
45176
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
45177
- } : {
45178
- schema: sch[schemaProp],
45179
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
45180
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
45181
- };
45182
- }
45183
- if (schema !== void 0) {
45184
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
45185
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
45759
+ var hasRequiredSubschema;
45760
+ function requireSubschema() {
45761
+ if (hasRequiredSubschema) return subschema;
45762
+ hasRequiredSubschema = 1;
45763
+ Object.defineProperty(subschema, "__esModule", { value: true });
45764
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
45765
+ const codegen_12 = codegen;
45766
+ const util_12 = util;
45767
+ function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
45768
+ if (keyword2 !== void 0 && schema !== void 0) {
45769
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
45186
45770
  }
45187
- return {
45188
- schema,
45189
- schemaPath,
45190
- topSchemaRef,
45191
- errSchemaPath
45192
- };
45193
- }
45194
- throw new Error('either "keyword" or "schema" must be passed');
45195
- }
45196
- subschema.getSubschema = getSubschema;
45197
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName: propertyName2 }) {
45198
- if (data !== void 0 && dataProp !== void 0) {
45199
- throw new Error('both "data" and "dataProp" passed, only one allowed');
45200
- }
45201
- const { gen } = it;
45202
- if (dataProp !== void 0) {
45203
- const { errorPath, dataPathArr, opts } = it;
45204
- const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
45205
- dataContextProps(nextData);
45206
- subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
45207
- subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
45208
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
45209
- }
45210
- if (data !== void 0) {
45211
- const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
45212
- dataContextProps(nextData);
45213
- if (propertyName2 !== void 0)
45214
- subschema2.propertyName = propertyName2;
45215
- }
45216
- if (dataTypes)
45217
- subschema2.dataTypes = dataTypes;
45218
- function dataContextProps(_nextData) {
45219
- subschema2.data = _nextData;
45220
- subschema2.dataLevel = it.dataLevel + 1;
45221
- subschema2.dataTypes = [];
45222
- it.definedProperties = /* @__PURE__ */ new Set();
45223
- subschema2.parentData = it.data;
45224
- subschema2.dataNames = [...it.dataNames, _nextData];
45225
- }
45226
- }
45227
- subschema.extendSubschemaData = extendSubschemaData;
45228
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
45229
- if (compositeRule !== void 0)
45230
- subschema2.compositeRule = compositeRule;
45231
- if (createErrors !== void 0)
45232
- subschema2.createErrors = createErrors;
45233
- if (allErrors !== void 0)
45234
- subschema2.allErrors = allErrors;
45235
- subschema2.jtdDiscriminator = jtdDiscriminator;
45236
- subschema2.jtdMetadata = jtdMetadata;
45237
- }
45238
- subschema.extendSubschemaMode = extendSubschemaMode;
45771
+ if (keyword2 !== void 0) {
45772
+ const sch = it.schema[keyword2];
45773
+ return schemaProp === void 0 ? {
45774
+ schema: sch,
45775
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
45776
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`
45777
+ } : {
45778
+ schema: sch[schemaProp],
45779
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
45780
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
45781
+ };
45782
+ }
45783
+ if (schema !== void 0) {
45784
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
45785
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
45786
+ }
45787
+ return {
45788
+ schema,
45789
+ schemaPath,
45790
+ topSchemaRef,
45791
+ errSchemaPath
45792
+ };
45793
+ }
45794
+ throw new Error('either "keyword" or "schema" must be passed');
45795
+ }
45796
+ subschema.getSubschema = getSubschema;
45797
+ function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName: propertyName2 }) {
45798
+ if (data !== void 0 && dataProp !== void 0) {
45799
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
45800
+ }
45801
+ const { gen } = it;
45802
+ if (dataProp !== void 0) {
45803
+ const { errorPath, dataPathArr, opts } = it;
45804
+ const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
45805
+ dataContextProps(nextData);
45806
+ subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
45807
+ subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
45808
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
45809
+ }
45810
+ if (data !== void 0) {
45811
+ const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
45812
+ dataContextProps(nextData);
45813
+ if (propertyName2 !== void 0)
45814
+ subschema2.propertyName = propertyName2;
45815
+ }
45816
+ if (dataTypes)
45817
+ subschema2.dataTypes = dataTypes;
45818
+ function dataContextProps(_nextData) {
45819
+ subschema2.data = _nextData;
45820
+ subschema2.dataLevel = it.dataLevel + 1;
45821
+ subschema2.dataTypes = [];
45822
+ it.definedProperties = /* @__PURE__ */ new Set();
45823
+ subschema2.parentData = it.data;
45824
+ subschema2.dataNames = [...it.dataNames, _nextData];
45825
+ }
45826
+ }
45827
+ subschema.extendSubschemaData = extendSubschemaData;
45828
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
45829
+ if (compositeRule !== void 0)
45830
+ subschema2.compositeRule = compositeRule;
45831
+ if (createErrors !== void 0)
45832
+ subschema2.createErrors = createErrors;
45833
+ if (allErrors !== void 0)
45834
+ subschema2.allErrors = allErrors;
45835
+ subschema2.jtdDiscriminator = jtdDiscriminator;
45836
+ subschema2.jtdMetadata = jtdMetadata;
45837
+ }
45838
+ subschema.extendSubschemaMode = extendSubschemaMode;
45839
+ return subschema;
45840
+ }
45239
45841
  var resolve$2 = {};
45240
45842
  var fastDeepEqual = function equal(a, b) {
45241
45843
  if (a === b) return true;
@@ -45350,7 +45952,7 @@ function escapeJsonPtr(str) {
45350
45952
  var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
45351
45953
  Object.defineProperty(resolve$2, "__esModule", { value: true });
45352
45954
  resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
45353
- const util_1$n = util;
45955
+ const util_1$m = util;
45354
45956
  const equal$3 = fastDeepEqual;
45355
45957
  const traverse = jsonSchemaTraverseExports;
45356
45958
  const SIMPLE_INLINED = /* @__PURE__ */ new Set([
@@ -45409,7 +46011,7 @@ function countKeys(schema) {
45409
46011
  if (SIMPLE_INLINED.has(key))
45410
46012
  continue;
45411
46013
  if (typeof schema[key] == "object") {
45412
- (0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
46014
+ (0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys(sch));
45413
46015
  }
45414
46016
  if (count === Infinity)
45415
46017
  return Infinity;
@@ -45497,516 +46099,528 @@ function getSchemaRefs(schema, baseId) {
45497
46099
  }
45498
46100
  }
45499
46101
  resolve$2.getSchemaRefs = getSchemaRefs;
45500
- Object.defineProperty(validate, "__esModule", { value: true });
45501
- validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
45502
- const boolSchema_1 = boolSchema;
45503
- const dataType_1$1 = dataType;
45504
- const applicability_1 = applicability;
45505
- const dataType_2 = dataType;
45506
- const defaults_1 = defaults;
45507
- const keyword_1 = keyword;
45508
- const subschema_1 = subschema;
45509
- const codegen_1$n = codegen;
45510
- const names_1$3 = names$1;
45511
- const resolve_1$2 = resolve$2;
45512
- const util_1$m = util;
45513
- const errors_1 = errors;
45514
- function validateFunctionCode(it) {
45515
- if (isSchemaObj(it)) {
45516
- checkKeywords(it);
45517
- if (schemaCxtHasRules(it)) {
45518
- topSchemaObjCode(it);
45519
- return;
46102
+ var hasRequiredValidate;
46103
+ function requireValidate() {
46104
+ if (hasRequiredValidate) return validate;
46105
+ hasRequiredValidate = 1;
46106
+ Object.defineProperty(validate, "__esModule", { value: true });
46107
+ validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
46108
+ const boolSchema_1 = requireBoolSchema();
46109
+ const dataType_12 = dataType;
46110
+ const applicability_12 = applicability;
46111
+ const dataType_2 = dataType;
46112
+ const defaults_1 = requireDefaults();
46113
+ const keyword_1 = requireKeyword();
46114
+ const subschema_1 = requireSubschema();
46115
+ const codegen_12 = codegen;
46116
+ const names_12 = names$1;
46117
+ const resolve_12 = resolve$2;
46118
+ const util_12 = util;
46119
+ const errors_12 = errors;
46120
+ function validateFunctionCode(it) {
46121
+ if (isSchemaObj(it)) {
46122
+ checkKeywords(it);
46123
+ if (schemaCxtHasRules(it)) {
46124
+ topSchemaObjCode(it);
46125
+ return;
46126
+ }
45520
46127
  }
46128
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
45521
46129
  }
45522
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
45523
- }
45524
- validate.validateFunctionCode = validateFunctionCode;
45525
- function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
45526
- if (opts.code.es5) {
45527
- gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
45528
- gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
45529
- destructureValCxtES5(gen, opts);
45530
- gen.code(body);
46130
+ validate.validateFunctionCode = validateFunctionCode;
46131
+ function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
46132
+ if (opts.code.es5) {
46133
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
46134
+ gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
46135
+ destructureValCxtES5(gen, opts);
46136
+ gen.code(body);
46137
+ });
46138
+ } else {
46139
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
46140
+ }
46141
+ }
46142
+ function destructureValCxt(opts) {
46143
+ 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}}={}`;
46144
+ }
46145
+ function destructureValCxtES5(gen, opts) {
46146
+ gen.if(names_12.default.valCxt, () => {
46147
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
46148
+ gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
46149
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
46150
+ gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
46151
+ if (opts.dynamicRef)
46152
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
46153
+ }, () => {
46154
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
46155
+ gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
46156
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
46157
+ gen.var(names_12.default.rootData, names_12.default.data);
46158
+ if (opts.dynamicRef)
46159
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
45531
46160
  });
45532
- } else {
45533
- gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
45534
- }
45535
- }
45536
- function destructureValCxt(opts) {
45537
- 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}}={}`;
45538
- }
45539
- function destructureValCxtES5(gen, opts) {
45540
- gen.if(names_1$3.default.valCxt, () => {
45541
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
45542
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
45543
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
45544
- gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
45545
- if (opts.dynamicRef)
45546
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
45547
- }, () => {
45548
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
45549
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
45550
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
45551
- gen.var(names_1$3.default.rootData, names_1$3.default.data);
45552
- if (opts.dynamicRef)
45553
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
45554
- });
45555
- }
45556
- function topSchemaObjCode(it) {
45557
- const { schema, opts, gen } = it;
45558
- validateFunction(it, () => {
46161
+ }
46162
+ function topSchemaObjCode(it) {
46163
+ const { schema, opts, gen } = it;
46164
+ validateFunction(it, () => {
46165
+ if (opts.$comment && schema.$comment)
46166
+ commentKeyword(it);
46167
+ checkNoDefault(it);
46168
+ gen.let(names_12.default.vErrors, null);
46169
+ gen.let(names_12.default.errors, 0);
46170
+ if (opts.unevaluated)
46171
+ resetEvaluated(it);
46172
+ typeAndKeywords(it);
46173
+ returnResults(it);
46174
+ });
46175
+ return;
46176
+ }
46177
+ function resetEvaluated(it) {
46178
+ const { gen, validateName } = it;
46179
+ it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
46180
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
46181
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
46182
+ }
46183
+ function funcSourceUrl(schema, opts) {
46184
+ const schId = typeof schema == "object" && schema[opts.schemaId];
46185
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
46186
+ }
46187
+ function subschemaCode(it, valid) {
46188
+ if (isSchemaObj(it)) {
46189
+ checkKeywords(it);
46190
+ if (schemaCxtHasRules(it)) {
46191
+ subSchemaObjCode(it, valid);
46192
+ return;
46193
+ }
46194
+ }
46195
+ (0, boolSchema_1.boolOrEmptySchema)(it, valid);
46196
+ }
46197
+ function schemaCxtHasRules({ schema, self }) {
46198
+ if (typeof schema == "boolean")
46199
+ return !schema;
46200
+ for (const key in schema)
46201
+ if (self.RULES.all[key])
46202
+ return true;
46203
+ return false;
46204
+ }
46205
+ function isSchemaObj(it) {
46206
+ return typeof it.schema != "boolean";
46207
+ }
46208
+ function subSchemaObjCode(it, valid) {
46209
+ const { schema, gen, opts } = it;
45559
46210
  if (opts.$comment && schema.$comment)
45560
46211
  commentKeyword(it);
45561
- checkNoDefault(it);
45562
- gen.let(names_1$3.default.vErrors, null);
45563
- gen.let(names_1$3.default.errors, 0);
45564
- if (opts.unevaluated)
45565
- resetEvaluated(it);
45566
- typeAndKeywords(it);
45567
- returnResults(it);
45568
- });
45569
- return;
45570
- }
45571
- function resetEvaluated(it) {
45572
- const { gen, validateName } = it;
45573
- it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
45574
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
45575
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
45576
- }
45577
- function funcSourceUrl(schema, opts) {
45578
- const schId = typeof schema == "object" && schema[opts.schemaId];
45579
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
45580
- }
45581
- function subschemaCode(it, valid) {
45582
- if (isSchemaObj(it)) {
45583
- checkKeywords(it);
45584
- if (schemaCxtHasRules(it)) {
45585
- subSchemaObjCode(it, valid);
45586
- return;
46212
+ updateContext(it);
46213
+ checkAsyncSchema(it);
46214
+ const errsCount = gen.const("_errs", names_12.default.errors);
46215
+ typeAndKeywords(it, errsCount);
46216
+ gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
46217
+ }
46218
+ function checkKeywords(it) {
46219
+ (0, util_12.checkUnknownRules)(it);
46220
+ checkRefsAndKeywords(it);
46221
+ }
46222
+ function typeAndKeywords(it, errsCount) {
46223
+ if (it.opts.jtd)
46224
+ return schemaKeywords(it, [], false, errsCount);
46225
+ const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
46226
+ const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
46227
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
46228
+ }
46229
+ function checkRefsAndKeywords(it) {
46230
+ const { schema, errSchemaPath, opts, self } = it;
46231
+ if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self.RULES)) {
46232
+ self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
45587
46233
  }
45588
46234
  }
45589
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
45590
- }
45591
- function schemaCxtHasRules({ schema, self }) {
45592
- if (typeof schema == "boolean")
45593
- return !schema;
45594
- for (const key in schema)
45595
- if (self.RULES.all[key])
45596
- return true;
45597
- return false;
45598
- }
45599
- function isSchemaObj(it) {
45600
- return typeof it.schema != "boolean";
45601
- }
45602
- function subSchemaObjCode(it, valid) {
45603
- const { schema, gen, opts } = it;
45604
- if (opts.$comment && schema.$comment)
45605
- commentKeyword(it);
45606
- updateContext(it);
45607
- checkAsyncSchema(it);
45608
- const errsCount = gen.const("_errs", names_1$3.default.errors);
45609
- typeAndKeywords(it, errsCount);
45610
- gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
45611
- }
45612
- function checkKeywords(it) {
45613
- (0, util_1$m.checkUnknownRules)(it);
45614
- checkRefsAndKeywords(it);
45615
- }
45616
- function typeAndKeywords(it, errsCount) {
45617
- if (it.opts.jtd)
45618
- return schemaKeywords(it, [], false, errsCount);
45619
- const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
45620
- const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
45621
- schemaKeywords(it, types2, !checkedTypes, errsCount);
45622
- }
45623
- function checkRefsAndKeywords(it) {
45624
- const { schema, errSchemaPath, opts, self } = it;
45625
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self.RULES)) {
45626
- self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
45627
- }
45628
- }
45629
- function checkNoDefault(it) {
45630
- const { schema, opts } = it;
45631
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
45632
- (0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
45633
- }
45634
- }
45635
- function updateContext(it) {
45636
- const schId = it.schema[it.opts.schemaId];
45637
- if (schId)
45638
- it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
45639
- }
45640
- function checkAsyncSchema(it) {
45641
- if (it.schema.$async && !it.schemaEnv.$async)
45642
- throw new Error("async schema in sync schema");
45643
- }
45644
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
45645
- const msg = schema.$comment;
45646
- if (opts.$comment === true) {
45647
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
45648
- } else if (typeof opts.$comment == "function") {
45649
- const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
45650
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
45651
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
45652
- }
45653
- }
45654
- function returnResults(it) {
45655
- const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
45656
- if (schemaEnv.$async) {
45657
- 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})`));
45658
- } else {
45659
- gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
45660
- if (opts.unevaluated)
45661
- assignEvaluated(it);
45662
- gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
45663
- }
45664
- }
45665
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
45666
- if (props instanceof codegen_1$n.Name)
45667
- gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
45668
- if (items2 instanceof codegen_1$n.Name)
45669
- gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
45670
- }
45671
- function schemaKeywords(it, types2, typeErrors, errsCount) {
45672
- const { gen, schema, data, allErrors, opts, self } = it;
45673
- const { RULES } = self;
45674
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
45675
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
45676
- return;
46235
+ function checkNoDefault(it) {
46236
+ const { schema, opts } = it;
46237
+ if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
46238
+ (0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
46239
+ }
45677
46240
  }
45678
- if (!opts.jtd)
45679
- checkStrictTypes(it, types2);
45680
- gen.block(() => {
45681
- for (const group of RULES.rules)
45682
- groupKeywords(group);
45683
- groupKeywords(RULES.post);
45684
- });
45685
- function groupKeywords(group) {
45686
- if (!(0, applicability_1.shouldUseGroup)(schema, group))
46241
+ function updateContext(it) {
46242
+ const schId = it.schema[it.opts.schemaId];
46243
+ if (schId)
46244
+ it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
46245
+ }
46246
+ function checkAsyncSchema(it) {
46247
+ if (it.schema.$async && !it.schemaEnv.$async)
46248
+ throw new Error("async schema in sync schema");
46249
+ }
46250
+ function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
46251
+ const msg = schema.$comment;
46252
+ if (opts.$comment === true) {
46253
+ gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
46254
+ } else if (typeof opts.$comment == "function") {
46255
+ const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
46256
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
46257
+ gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
46258
+ }
46259
+ }
46260
+ function returnResults(it) {
46261
+ const { gen, schemaEnv, validateName, ValidationError, opts } = it;
46262
+ if (schemaEnv.$async) {
46263
+ 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})`));
46264
+ } else {
46265
+ gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
46266
+ if (opts.unevaluated)
46267
+ assignEvaluated(it);
46268
+ gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
46269
+ }
46270
+ }
46271
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
46272
+ if (props instanceof codegen_12.Name)
46273
+ gen.assign((0, codegen_12._)`${evaluated}.props`, props);
46274
+ if (items2 instanceof codegen_12.Name)
46275
+ gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
46276
+ }
46277
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
46278
+ const { gen, schema, data, allErrors, opts, self } = it;
46279
+ const { RULES } = self;
46280
+ if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
46281
+ gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
45687
46282
  return;
45688
- if (group.type) {
45689
- gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
45690
- iterateKeywords(it, group);
45691
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
45692
- gen.else();
45693
- (0, dataType_2.reportTypeError)(it);
46283
+ }
46284
+ if (!opts.jtd)
46285
+ checkStrictTypes(it, types2);
46286
+ gen.block(() => {
46287
+ for (const group of RULES.rules)
46288
+ groupKeywords(group);
46289
+ groupKeywords(RULES.post);
46290
+ });
46291
+ function groupKeywords(group) {
46292
+ if (!(0, applicability_12.shouldUseGroup)(schema, group))
46293
+ return;
46294
+ if (group.type) {
46295
+ gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
46296
+ iterateKeywords(it, group);
46297
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
46298
+ gen.else();
46299
+ (0, dataType_2.reportTypeError)(it);
46300
+ }
46301
+ gen.endIf();
46302
+ } else {
46303
+ iterateKeywords(it, group);
45694
46304
  }
45695
- gen.endIf();
45696
- } else {
45697
- iterateKeywords(it, group);
46305
+ if (!allErrors)
46306
+ gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
45698
46307
  }
45699
- if (!allErrors)
45700
- gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
45701
46308
  }
45702
- }
45703
- function iterateKeywords(it, group) {
45704
- const { gen, schema, opts: { useDefaults } } = it;
45705
- if (useDefaults)
45706
- (0, defaults_1.assignDefaults)(it, group.type);
45707
- gen.block(() => {
45708
- for (const rule of group.rules) {
45709
- if ((0, applicability_1.shouldUseRule)(schema, rule)) {
45710
- keywordCode(it, rule.keyword, rule.definition, group.type);
46309
+ function iterateKeywords(it, group) {
46310
+ const { gen, schema, opts: { useDefaults } } = it;
46311
+ if (useDefaults)
46312
+ (0, defaults_1.assignDefaults)(it, group.type);
46313
+ gen.block(() => {
46314
+ for (const rule of group.rules) {
46315
+ if ((0, applicability_12.shouldUseRule)(schema, rule)) {
46316
+ keywordCode(it, rule.keyword, rule.definition, group.type);
46317
+ }
45711
46318
  }
45712
- }
45713
- });
45714
- }
45715
- function checkStrictTypes(it, types2) {
45716
- if (it.schemaEnv.meta || !it.opts.strictTypes)
45717
- return;
45718
- checkContextTypes(it, types2);
45719
- if (!it.opts.allowUnionTypes)
45720
- checkMultipleTypes(it, types2);
45721
- checkKeywordTypes(it, it.dataTypes);
45722
- }
45723
- function checkContextTypes(it, types2) {
45724
- if (!types2.length)
45725
- return;
45726
- if (!it.dataTypes.length) {
45727
- it.dataTypes = types2;
45728
- return;
46319
+ });
46320
+ }
46321
+ function checkStrictTypes(it, types2) {
46322
+ if (it.schemaEnv.meta || !it.opts.strictTypes)
46323
+ return;
46324
+ checkContextTypes(it, types2);
46325
+ if (!it.opts.allowUnionTypes)
46326
+ checkMultipleTypes(it, types2);
46327
+ checkKeywordTypes(it, it.dataTypes);
45729
46328
  }
45730
- types2.forEach((t2) => {
45731
- if (!includesType(it.dataTypes, t2)) {
45732
- strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
46329
+ function checkContextTypes(it, types2) {
46330
+ if (!types2.length)
46331
+ return;
46332
+ if (!it.dataTypes.length) {
46333
+ it.dataTypes = types2;
46334
+ return;
45733
46335
  }
45734
- });
45735
- narrowSchemaTypes(it, types2);
45736
- }
45737
- function checkMultipleTypes(it, ts) {
45738
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
45739
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
45740
- }
45741
- }
45742
- function checkKeywordTypes(it, ts) {
45743
- const rules2 = it.self.RULES.all;
45744
- for (const keyword2 in rules2) {
45745
- const rule = rules2[keyword2];
45746
- if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
45747
- const { type: type2 } = rule.definition;
45748
- if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
45749
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
45750
- }
45751
- }
45752
- }
45753
- }
45754
- function hasApplicableType(schTs, kwdT) {
45755
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
45756
- }
45757
- function includesType(ts, t2) {
45758
- return ts.includes(t2) || t2 === "integer" && ts.includes("number");
45759
- }
45760
- function narrowSchemaTypes(it, withTypes) {
45761
- const ts = [];
45762
- for (const t2 of it.dataTypes) {
45763
- if (includesType(withTypes, t2))
45764
- ts.push(t2);
45765
- else if (withTypes.includes("integer") && t2 === "number")
45766
- ts.push("integer");
45767
- }
45768
- it.dataTypes = ts;
45769
- }
45770
- function strictTypesError(it, msg) {
45771
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
45772
- msg += ` at "${schemaPath}" (strictTypes)`;
45773
- (0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
45774
- }
45775
- class KeywordCxt {
45776
- constructor(it, def2, keyword2) {
45777
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
45778
- this.gen = it.gen;
45779
- this.allErrors = it.allErrors;
45780
- this.keyword = keyword2;
45781
- this.data = it.data;
45782
- this.schema = it.schema[keyword2];
45783
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
45784
- this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
45785
- this.schemaType = def2.schemaType;
45786
- this.parentSchema = it.schema;
45787
- this.params = {};
45788
- this.it = it;
45789
- this.def = def2;
45790
- if (this.$data) {
45791
- this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
45792
- } else {
45793
- this.schemaCode = this.schemaValue;
45794
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
45795
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
46336
+ types2.forEach((t2) => {
46337
+ if (!includesType(it.dataTypes, t2)) {
46338
+ strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
46339
+ }
46340
+ });
46341
+ narrowSchemaTypes(it, types2);
46342
+ }
46343
+ function checkMultipleTypes(it, ts) {
46344
+ if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
46345
+ strictTypesError(it, "use allowUnionTypes to allow union type keyword");
46346
+ }
46347
+ }
46348
+ function checkKeywordTypes(it, ts) {
46349
+ const rules2 = it.self.RULES.all;
46350
+ for (const keyword2 in rules2) {
46351
+ const rule = rules2[keyword2];
46352
+ if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
46353
+ const { type: type2 } = rule.definition;
46354
+ if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
46355
+ strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
46356
+ }
46357
+ }
46358
+ }
46359
+ }
46360
+ function hasApplicableType(schTs, kwdT) {
46361
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
46362
+ }
46363
+ function includesType(ts, t2) {
46364
+ return ts.includes(t2) || t2 === "integer" && ts.includes("number");
46365
+ }
46366
+ function narrowSchemaTypes(it, withTypes) {
46367
+ const ts = [];
46368
+ for (const t2 of it.dataTypes) {
46369
+ if (includesType(withTypes, t2))
46370
+ ts.push(t2);
46371
+ else if (withTypes.includes("integer") && t2 === "number")
46372
+ ts.push("integer");
46373
+ }
46374
+ it.dataTypes = ts;
46375
+ }
46376
+ function strictTypesError(it, msg) {
46377
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
46378
+ msg += ` at "${schemaPath}" (strictTypes)`;
46379
+ (0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
46380
+ }
46381
+ class KeywordCxt {
46382
+ constructor(it, def2, keyword2) {
46383
+ (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
46384
+ this.gen = it.gen;
46385
+ this.allErrors = it.allErrors;
46386
+ this.keyword = keyword2;
46387
+ this.data = it.data;
46388
+ this.schema = it.schema[keyword2];
46389
+ this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
46390
+ this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
46391
+ this.schemaType = def2.schemaType;
46392
+ this.parentSchema = it.schema;
46393
+ this.params = {};
46394
+ this.it = it;
46395
+ this.def = def2;
46396
+ if (this.$data) {
46397
+ this.schemaCode = it.gen.const("vSchema", getData2(this.$data, it));
46398
+ } else {
46399
+ this.schemaCode = this.schemaValue;
46400
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
46401
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
46402
+ }
46403
+ }
46404
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
46405
+ this.errsCount = it.gen.const("_errs", names_12.default.errors);
45796
46406
  }
45797
46407
  }
45798
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
45799
- this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
46408
+ result(condition, successAction, failAction) {
46409
+ this.failResult((0, codegen_12.not)(condition), successAction, failAction);
45800
46410
  }
45801
- }
45802
- result(condition, successAction, failAction) {
45803
- this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
45804
- }
45805
- failResult(condition, successAction, failAction) {
45806
- this.gen.if(condition);
45807
- if (failAction)
45808
- failAction();
45809
- else
46411
+ failResult(condition, successAction, failAction) {
46412
+ this.gen.if(condition);
46413
+ if (failAction)
46414
+ failAction();
46415
+ else
46416
+ this.error();
46417
+ if (successAction) {
46418
+ this.gen.else();
46419
+ successAction();
46420
+ if (this.allErrors)
46421
+ this.gen.endIf();
46422
+ } else {
46423
+ if (this.allErrors)
46424
+ this.gen.endIf();
46425
+ else
46426
+ this.gen.else();
46427
+ }
46428
+ }
46429
+ pass(condition, failAction) {
46430
+ this.failResult((0, codegen_12.not)(condition), void 0, failAction);
46431
+ }
46432
+ fail(condition) {
46433
+ if (condition === void 0) {
46434
+ this.error();
46435
+ if (!this.allErrors)
46436
+ this.gen.if(false);
46437
+ return;
46438
+ }
46439
+ this.gen.if(condition);
45810
46440
  this.error();
45811
- if (successAction) {
45812
- this.gen.else();
45813
- successAction();
45814
- if (this.allErrors)
45815
- this.gen.endIf();
45816
- } else {
45817
46441
  if (this.allErrors)
45818
46442
  this.gen.endIf();
45819
46443
  else
45820
46444
  this.gen.else();
45821
46445
  }
45822
- }
45823
- pass(condition, failAction) {
45824
- this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
45825
- }
45826
- fail(condition) {
45827
- if (condition === void 0) {
45828
- this.error();
46446
+ fail$data(condition) {
46447
+ if (!this.$data)
46448
+ return this.fail(condition);
46449
+ const { schemaCode } = this;
46450
+ this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
46451
+ }
46452
+ error(append, errorParams, errorPaths) {
46453
+ if (errorParams) {
46454
+ this.setParams(errorParams);
46455
+ this._error(append, errorPaths);
46456
+ this.setParams({});
46457
+ return;
46458
+ }
46459
+ this._error(append, errorPaths);
46460
+ }
46461
+ _error(append, errorPaths) {
46462
+ (append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
46463
+ }
46464
+ $dataError() {
46465
+ (0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
46466
+ }
46467
+ reset() {
46468
+ if (this.errsCount === void 0)
46469
+ throw new Error('add "trackErrors" to keyword definition');
46470
+ (0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
46471
+ }
46472
+ ok(cond) {
45829
46473
  if (!this.allErrors)
45830
- this.gen.if(false);
45831
- return;
46474
+ this.gen.if(cond);
45832
46475
  }
45833
- this.gen.if(condition);
45834
- this.error();
45835
- if (this.allErrors)
45836
- this.gen.endIf();
45837
- else
45838
- this.gen.else();
45839
- }
45840
- fail$data(condition) {
45841
- if (!this.$data)
45842
- return this.fail(condition);
45843
- const { schemaCode } = this;
45844
- this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
45845
- }
45846
- error(append, errorParams, errorPaths) {
45847
- if (errorParams) {
45848
- this.setParams(errorParams);
45849
- this._error(append, errorPaths);
45850
- this.setParams({});
45851
- return;
46476
+ setParams(obj, assign2) {
46477
+ if (assign2)
46478
+ Object.assign(this.params, obj);
46479
+ else
46480
+ this.params = obj;
45852
46481
  }
45853
- this._error(append, errorPaths);
45854
- }
45855
- _error(append, errorPaths) {
45856
- (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
45857
- }
45858
- $dataError() {
45859
- (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
45860
- }
45861
- reset() {
45862
- if (this.errsCount === void 0)
45863
- throw new Error('add "trackErrors" to keyword definition');
45864
- (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
45865
- }
45866
- ok(cond) {
45867
- if (!this.allErrors)
45868
- this.gen.if(cond);
45869
- }
45870
- setParams(obj, assign2) {
45871
- if (assign2)
45872
- Object.assign(this.params, obj);
45873
- else
45874
- this.params = obj;
45875
- }
45876
- block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
45877
- this.gen.block(() => {
45878
- this.check$data(valid, $dataValid);
45879
- codeBlock();
45880
- });
45881
- }
45882
- check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
45883
- if (!this.$data)
45884
- return;
45885
- const { gen, schemaCode, schemaType, def: def2 } = this;
45886
- gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
45887
- if (valid !== codegen_1$n.nil)
45888
- gen.assign(valid, true);
45889
- if (schemaType.length || def2.validateSchema) {
45890
- gen.elseIf(this.invalid$data());
45891
- this.$dataError();
45892
- if (valid !== codegen_1$n.nil)
45893
- gen.assign(valid, false);
46482
+ block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
46483
+ this.gen.block(() => {
46484
+ this.check$data(valid, $dataValid);
46485
+ codeBlock();
46486
+ });
45894
46487
  }
45895
- gen.else();
45896
- }
45897
- invalid$data() {
45898
- const { gen, schemaCode, schemaType, def: def2, it } = this;
45899
- return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
45900
- function wrong$DataType() {
45901
- if (schemaType.length) {
45902
- if (!(schemaCode instanceof codegen_1$n.Name))
45903
- throw new Error("ajv implementation error");
45904
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
45905
- return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
46488
+ check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
46489
+ if (!this.$data)
46490
+ return;
46491
+ const { gen, schemaCode, schemaType, def: def2 } = this;
46492
+ gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
46493
+ if (valid !== codegen_12.nil)
46494
+ gen.assign(valid, true);
46495
+ if (schemaType.length || def2.validateSchema) {
46496
+ gen.elseIf(this.invalid$data());
46497
+ this.$dataError();
46498
+ if (valid !== codegen_12.nil)
46499
+ gen.assign(valid, false);
45906
46500
  }
45907
- return codegen_1$n.nil;
46501
+ gen.else();
45908
46502
  }
45909
- function invalid$DataSchema() {
45910
- if (def2.validateSchema) {
45911
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
45912
- return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
46503
+ invalid$data() {
46504
+ const { gen, schemaCode, schemaType, def: def2, it } = this;
46505
+ return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
46506
+ function wrong$DataType() {
46507
+ if (schemaType.length) {
46508
+ if (!(schemaCode instanceof codegen_12.Name))
46509
+ throw new Error("ajv implementation error");
46510
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
46511
+ return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
46512
+ }
46513
+ return codegen_12.nil;
46514
+ }
46515
+ function invalid$DataSchema() {
46516
+ if (def2.validateSchema) {
46517
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
46518
+ return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
46519
+ }
46520
+ return codegen_12.nil;
46521
+ }
46522
+ }
46523
+ subschema(appl, valid) {
46524
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
46525
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
46526
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
46527
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
46528
+ subschemaCode(nextContext, valid);
46529
+ return nextContext;
46530
+ }
46531
+ mergeEvaluated(schemaCxt, toName) {
46532
+ const { it, gen } = this;
46533
+ if (!it.opts.unevaluated)
46534
+ return;
46535
+ if (it.props !== true && schemaCxt.props !== void 0) {
46536
+ it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
46537
+ }
46538
+ if (it.items !== true && schemaCxt.items !== void 0) {
46539
+ it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
45913
46540
  }
45914
- return codegen_1$n.nil;
45915
- }
45916
- }
45917
- subschema(appl, valid) {
45918
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
45919
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
45920
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
45921
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
45922
- subschemaCode(nextContext, valid);
45923
- return nextContext;
45924
- }
45925
- mergeEvaluated(schemaCxt, toName) {
45926
- const { it, gen } = this;
45927
- if (!it.opts.unevaluated)
45928
- return;
45929
- if (it.props !== true && schemaCxt.props !== void 0) {
45930
- it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
45931
46541
  }
45932
- if (it.items !== true && schemaCxt.items !== void 0) {
45933
- it.items = util_1$m.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
46542
+ mergeValidEvaluated(schemaCxt, valid) {
46543
+ const { it, gen } = this;
46544
+ if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
46545
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
46546
+ return true;
46547
+ }
45934
46548
  }
45935
46549
  }
45936
- mergeValidEvaluated(schemaCxt, valid) {
45937
- const { it, gen } = this;
45938
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
45939
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
45940
- return true;
46550
+ validate.KeywordCxt = KeywordCxt;
46551
+ function keywordCode(it, keyword2, def2, ruleType) {
46552
+ const cxt = new KeywordCxt(it, def2, keyword2);
46553
+ if ("code" in def2) {
46554
+ def2.code(cxt, ruleType);
46555
+ } else if (cxt.$data && def2.validate) {
46556
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
46557
+ } else if ("macro" in def2) {
46558
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
46559
+ } else if (def2.compile || def2.validate) {
46560
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
45941
46561
  }
45942
46562
  }
45943
- }
45944
- validate.KeywordCxt = KeywordCxt;
45945
- function keywordCode(it, keyword2, def2, ruleType) {
45946
- const cxt = new KeywordCxt(it, def2, keyword2);
45947
- if ("code" in def2) {
45948
- def2.code(cxt, ruleType);
45949
- } else if (cxt.$data && def2.validate) {
45950
- (0, keyword_1.funcKeywordCode)(cxt, def2);
45951
- } else if ("macro" in def2) {
45952
- (0, keyword_1.macroKeywordCode)(cxt, def2);
45953
- } else if (def2.compile || def2.validate) {
45954
- (0, keyword_1.funcKeywordCode)(cxt, def2);
45955
- }
45956
- }
45957
- const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
45958
- const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
45959
- function getData($data, { dataLevel, dataNames, dataPathArr }) {
45960
- let jsonPointer;
45961
- let data;
45962
- if ($data === "")
45963
- return names_1$3.default.rootData;
45964
- if ($data[0] === "/") {
45965
- if (!JSON_POINTER.test($data))
45966
- throw new Error(`Invalid JSON-pointer: ${$data}`);
45967
- jsonPointer = $data;
45968
- data = names_1$3.default.rootData;
45969
- } else {
45970
- const matches = RELATIVE_JSON_POINTER.exec($data);
45971
- if (!matches)
45972
- throw new Error(`Invalid JSON-pointer: ${$data}`);
45973
- const up = +matches[1];
45974
- jsonPointer = matches[2];
45975
- if (jsonPointer === "#") {
45976
- if (up >= dataLevel)
45977
- throw new Error(errorMsg("property/index", up));
45978
- return dataPathArr[dataLevel - up];
45979
- }
45980
- if (up > dataLevel)
45981
- throw new Error(errorMsg("data", up));
45982
- data = dataNames[dataLevel - up];
45983
- if (!jsonPointer)
45984
- return data;
45985
- }
45986
- let expr = data;
45987
- const segments = jsonPointer.split("/");
45988
- for (const segment of segments) {
45989
- if (segment) {
45990
- data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
45991
- expr = (0, codegen_1$n._)`${expr} && ${data}`;
46563
+ const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
46564
+ const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
46565
+ function getData2($data, { dataLevel, dataNames, dataPathArr }) {
46566
+ let jsonPointer;
46567
+ let data;
46568
+ if ($data === "")
46569
+ return names_12.default.rootData;
46570
+ if ($data[0] === "/") {
46571
+ if (!JSON_POINTER.test($data))
46572
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
46573
+ jsonPointer = $data;
46574
+ data = names_12.default.rootData;
46575
+ } else {
46576
+ const matches = RELATIVE_JSON_POINTER.exec($data);
46577
+ if (!matches)
46578
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
46579
+ const up = +matches[1];
46580
+ jsonPointer = matches[2];
46581
+ if (jsonPointer === "#") {
46582
+ if (up >= dataLevel)
46583
+ throw new Error(errorMsg("property/index", up));
46584
+ return dataPathArr[dataLevel - up];
46585
+ }
46586
+ if (up > dataLevel)
46587
+ throw new Error(errorMsg("data", up));
46588
+ data = dataNames[dataLevel - up];
46589
+ if (!jsonPointer)
46590
+ return data;
46591
+ }
46592
+ let expr = data;
46593
+ const segments = jsonPointer.split("/");
46594
+ for (const segment of segments) {
46595
+ if (segment) {
46596
+ data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
46597
+ expr = (0, codegen_12._)`${expr} && ${data}`;
46598
+ }
46599
+ }
46600
+ return expr;
46601
+ function errorMsg(pointerType, up) {
46602
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
45992
46603
  }
45993
46604
  }
45994
- return expr;
45995
- function errorMsg(pointerType, up) {
45996
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
45997
- }
46605
+ validate.getData = getData2;
46606
+ return validate;
45998
46607
  }
45999
- validate.getData = getData;
46000
46608
  var validation_error = {};
46001
- Object.defineProperty(validation_error, "__esModule", { value: true });
46002
- class ValidationError extends Error {
46003
- constructor(errors2) {
46004
- super("validation failed");
46005
- this.errors = errors2;
46006
- this.ajv = this.validation = true;
46609
+ var hasRequiredValidation_error;
46610
+ function requireValidation_error() {
46611
+ if (hasRequiredValidation_error) return validation_error;
46612
+ hasRequiredValidation_error = 1;
46613
+ Object.defineProperty(validation_error, "__esModule", { value: true });
46614
+ class ValidationError extends Error {
46615
+ constructor(errors2) {
46616
+ super("validation failed");
46617
+ this.errors = errors2;
46618
+ this.ajv = this.validation = true;
46619
+ }
46007
46620
  }
46621
+ validation_error.default = ValidationError;
46622
+ return validation_error;
46008
46623
  }
46009
- validation_error.default = ValidationError;
46010
46624
  var ref_error = {};
46011
46625
  Object.defineProperty(ref_error, "__esModule", { value: true });
46012
46626
  const resolve_1$1 = resolve$2;
@@ -46022,11 +46636,11 @@ var compile = {};
46022
46636
  Object.defineProperty(compile, "__esModule", { value: true });
46023
46637
  compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
46024
46638
  const codegen_1$m = codegen;
46025
- const validation_error_1 = validation_error;
46639
+ const validation_error_1 = requireValidation_error();
46026
46640
  const names_1$2 = names$1;
46027
46641
  const resolve_1 = resolve$2;
46028
46642
  const util_1$l = util;
46029
- const validate_1$1 = validate;
46643
+ const validate_1$1 = requireValidate();
46030
46644
  class SchemaEnv {
46031
46645
  constructor(env) {
46032
46646
  var _a2;
@@ -46955,7 +47569,7 @@ uri$1.default = uri;
46955
47569
  (function(exports$1) {
46956
47570
  Object.defineProperty(exports$1, "__esModule", { value: true });
46957
47571
  exports$1.CodeGen = exports$1.Name = exports$1.nil = exports$1.stringify = exports$1.str = exports$1._ = exports$1.KeywordCxt = void 0;
46958
- var validate_12 = validate;
47572
+ var validate_12 = requireValidate();
46959
47573
  Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
46960
47574
  return validate_12.KeywordCxt;
46961
47575
  } });
@@ -46978,7 +47592,7 @@ uri$1.default = uri;
46978
47592
  Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
46979
47593
  return codegen_12.CodeGen;
46980
47594
  } });
46981
- const validation_error_12 = validation_error;
47595
+ const validation_error_12 = requireValidation_error();
46982
47596
  const ref_error_12 = ref_error;
46983
47597
  const rules_12 = rules;
46984
47598
  const compile_12 = compile;
@@ -48566,7 +49180,7 @@ const def$a = {
48566
49180
  additionalProperties.default = def$a;
48567
49181
  var properties$1 = {};
48568
49182
  Object.defineProperty(properties$1, "__esModule", { value: true });
48569
- const validate_1 = validate;
49183
+ const validate_1 = requireValidate();
48570
49184
  const code_1$2 = code;
48571
49185
  const util_1$7 = util;
48572
49186
  const additionalProperties_1$1 = additionalProperties;
@@ -49417,7 +50031,7 @@ const require$$3 = {
49417
50031
  module.exports.Ajv = Ajv2;
49418
50032
  Object.defineProperty(exports$1, "__esModule", { value: true });
49419
50033
  exports$1.default = Ajv2;
49420
- var validate_12 = validate;
50034
+ var validate_12 = requireValidate();
49421
50035
  Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
49422
50036
  return validate_12.KeywordCxt;
49423
50037
  } });
@@ -49440,7 +50054,7 @@ const require$$3 = {
49440
50054
  Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
49441
50055
  return codegen_12.CodeGen;
49442
50056
  } });
49443
- var validation_error_12 = validation_error;
50057
+ var validation_error_12 = requireValidation_error();
49444
50058
  Object.defineProperty(exports$1, "ValidationError", { enumerable: true, get: function() {
49445
50059
  return validation_error_12.default;
49446
50060
  } });
@@ -49832,6 +50446,7 @@ function RequestBuilder({ request }) {
49832
50446
  const globals = useStore((s) => s.globals);
49833
50447
  const activeTabId = useStore((s) => s.activeTabId);
49834
50448
  const setTabResponse = useStore((s) => s.setTabResponse);
50449
+ const setTabHookResults = useStore((s) => s.setTabHookResults);
49835
50450
  const setTabSending = useStore((s) => s.setTabSending);
49836
50451
  const setTabRequestTab = useStore((s) => s.setTabRequestTab);
49837
50452
  const addHistoryEntry = useStore((s) => s.addHistoryEntry);
@@ -49845,6 +50460,14 @@ function RequestBuilder({ request }) {
49845
50460
  if (activeTabId) setTabRequestTab(activeTabId, t2);
49846
50461
  }
49847
50462
  const [editingName, setEditingName] = reactExports.useState(false);
50463
+ const [runHooks, setRunHooks] = reactExports.useState(() => localStorage.getItem("runHooks") !== "false");
50464
+ function toggleRunHooks() {
50465
+ setRunHooks((prev) => {
50466
+ const next = !prev;
50467
+ localStorage.setItem("runHooks", String(next));
50468
+ return next;
50469
+ });
50470
+ }
49848
50471
  function update(patch) {
49849
50472
  updateRequest(request.id, patch);
49850
50473
  }
@@ -49852,35 +50475,79 @@ function RequestBuilder({ request }) {
49852
50475
  if (!activeTabId) return;
49853
50476
  setTabSending(activeTabId, true);
49854
50477
  setTabResponse(activeTabId, null, null);
50478
+ setTabHookResults(activeTabId, null);
50479
+ const collectedHookResults = [];
49855
50480
  try {
49856
50481
  const activeEnv = activeEnvironmentId ? environments[activeEnvironmentId]?.data ?? null : null;
49857
50482
  const sessionVars = useStore.getState().sessionVars;
49858
- const collectionVars = {
50483
+ const tls = collectionTls ? { ...workspaceSettings?.tls, ...collectionTls } : workspaceSettings?.tls;
50484
+ const basePayload = {
50485
+ environment: activeEnv,
50486
+ proxy: workspaceSettings?.proxy,
50487
+ tls,
50488
+ piiMaskPatterns: workspaceSettings?.piiMaskPatterns
50489
+ };
50490
+ let collectionVars = {
49859
50491
  ...activeCollectionId ? collections[activeCollectionId]?.data.collectionVariables ?? {} : {},
49860
50492
  ...sessionVars
49861
50493
  };
50494
+ let liveGlobals = { ...globals };
49862
50495
  const inherited = useStore.getState().getInheritedAuthAndHeaders(request.id);
49863
50496
  const mergedAuth = request.auth.type !== "none" ? request.auth : inherited.auth ?? request.auth;
49864
50497
  const mergedHeaders = [
49865
50498
  ...inherited.headers.filter((h) => h.enabled),
49866
50499
  ...request.headers
49867
50500
  ];
49868
- const mergedRequest = {
49869
- ...request,
49870
- auth: mergedAuth,
49871
- headers: mergedHeaders
49872
- };
50501
+ const mergedRequest = { ...request, auth: mergedAuth, headers: mergedHeaders };
50502
+ const collection = activeCollectionId ? collections[activeCollectionId]?.data : null;
50503
+ const hooks = runHooks && collection ? getHooksForRequest(request.id, collection) : { before: [], after: [] };
50504
+ for (const hook of hooks.before) {
50505
+ const start = Date.now();
50506
+ try {
50507
+ const r = await electron$h.sendRequest({ ...basePayload, request: hook, collectionVars, globals: liveGlobals });
50508
+ applyScriptUpdates(r.scriptResult);
50509
+ collectionVars = { ...collectionVars, ...r.scriptResult.updatedCollectionVars };
50510
+ liveGlobals = { ...liveGlobals, ...r.scriptResult.updatedGlobals };
50511
+ const allPassed = r.scriptResult.testResults.every((t2) => t2.passed);
50512
+ collectedHookResults.push({
50513
+ requestId: hook.id,
50514
+ name: hook.name,
50515
+ method: hook.method,
50516
+ resolvedUrl: r.scriptResult.resolvedUrl,
50517
+ status: r.scriptResult.postScriptError ? "error" : r.scriptResult.testResults.length > 0 ? allPassed ? "passed" : "failed" : "passed",
50518
+ httpStatus: r.response.status,
50519
+ durationMs: Date.now() - start,
50520
+ isHook: true,
50521
+ hookType: hook.hookType,
50522
+ testResults: r.scriptResult.testResults,
50523
+ consoleOutput: r.scriptResult.consoleOutput,
50524
+ preScriptError: r.scriptResult.preScriptError,
50525
+ postScriptError: r.scriptResult.postScriptError
50526
+ });
50527
+ } catch (err) {
50528
+ collectedHookResults.push({
50529
+ requestId: hook.id,
50530
+ name: hook.name,
50531
+ method: hook.method,
50532
+ resolvedUrl: hook.url,
50533
+ status: "error",
50534
+ durationMs: Date.now() - start,
50535
+ isHook: true,
50536
+ hookType: hook.hookType,
50537
+ error: err instanceof Error ? err.message : String(err)
50538
+ });
50539
+ }
50540
+ }
49873
50541
  const result = await electron$h.sendRequest({
50542
+ ...basePayload,
49874
50543
  request: mergedRequest,
49875
- environment: activeEnv,
49876
50544
  collectionVars,
49877
- globals,
49878
- proxy: workspaceSettings?.proxy,
49879
- tls: collectionTls ? { ...workspaceSettings?.tls, ...collectionTls } : workspaceSettings?.tls,
49880
- piiMaskPatterns: workspaceSettings?.piiMaskPatterns
50545
+ globals: liveGlobals
49881
50546
  });
49882
50547
  setTabResponse(activeTabId, result.response, result.scriptResult, result.sentRequest);
49883
50548
  applyScriptUpdates(result.scriptResult);
50549
+ collectionVars = { ...collectionVars, ...result.scriptResult.updatedCollectionVars };
50550
+ liveGlobals = { ...liveGlobals, ...result.scriptResult.updatedGlobals };
49884
50551
  addHistoryEntry({
49885
50552
  id: crypto.randomUUID(),
49886
50553
  timestamp: Date.now(),
@@ -49890,6 +50557,46 @@ function RequestBuilder({ request }) {
49890
50557
  environmentName: activeEnv?.name ?? null,
49891
50558
  scriptResult: result.scriptResult
49892
50559
  });
50560
+ for (const hook of hooks.after) {
50561
+ const start = Date.now();
50562
+ try {
50563
+ const r = await electron$h.sendRequest({ ...basePayload, request: hook, collectionVars, globals: liveGlobals });
50564
+ applyScriptUpdates(r.scriptResult);
50565
+ collectionVars = { ...collectionVars, ...r.scriptResult.updatedCollectionVars };
50566
+ liveGlobals = { ...liveGlobals, ...r.scriptResult.updatedGlobals };
50567
+ const allPassed = r.scriptResult.testResults.every((t2) => t2.passed);
50568
+ collectedHookResults.push({
50569
+ requestId: hook.id,
50570
+ name: hook.name,
50571
+ method: hook.method,
50572
+ resolvedUrl: r.scriptResult.resolvedUrl,
50573
+ status: r.scriptResult.postScriptError ? "error" : r.scriptResult.testResults.length > 0 ? allPassed ? "passed" : "failed" : "passed",
50574
+ httpStatus: r.response.status,
50575
+ durationMs: Date.now() - start,
50576
+ isHook: true,
50577
+ hookType: hook.hookType,
50578
+ testResults: r.scriptResult.testResults,
50579
+ consoleOutput: r.scriptResult.consoleOutput,
50580
+ preScriptError: r.scriptResult.preScriptError,
50581
+ postScriptError: r.scriptResult.postScriptError
50582
+ });
50583
+ } catch (err) {
50584
+ collectedHookResults.push({
50585
+ requestId: hook.id,
50586
+ name: hook.name,
50587
+ method: hook.method,
50588
+ resolvedUrl: hook.url,
50589
+ status: "error",
50590
+ durationMs: Date.now() - start,
50591
+ isHook: true,
50592
+ hookType: hook.hookType,
50593
+ error: err instanceof Error ? err.message : String(err)
50594
+ });
50595
+ }
50596
+ }
50597
+ if (collectedHookResults.length > 0) {
50598
+ setTabHookResults(activeTabId, collectedHookResults);
50599
+ }
49893
50600
  } finally {
49894
50601
  setTabSending(activeTabId, false);
49895
50602
  }
@@ -49967,15 +50674,26 @@ function RequestBuilder({ request }) {
49967
50674
  className: "bg-surface-800 border border-surface-700 rounded px-3 py-1.5 text-sm focus:outline-none focus:border-blue-500 font-mono placeholder-surface-700"
49968
50675
  }
49969
50676
  ),
49970
- !isWs && /* @__PURE__ */ jsxRuntimeExports.jsx(
49971
- "button",
49972
- {
49973
- onClick: sendRequest,
49974
- disabled: isSending || !request.url,
49975
- className: "px-4 py-1.5 bg-blue-600 hover:bg-blue-500 disabled:bg-surface-800 disabled:text-surface-400 rounded text-sm font-medium transition-colors min-w-[72px]",
49976
- children: isSending ? "..." : "Send"
49977
- }
49978
- )
50677
+ !isWs && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
50678
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
50679
+ "button",
50680
+ {
50681
+ onClick: toggleRunHooks,
50682
+ title: runHooks ? "Hooks enabled — click to disable" : "Hooks disabled — click to enable",
50683
+ className: `px-2 py-1.5 rounded text-xs font-medium transition-colors border ${runHooks ? "border-violet-500 text-violet-400 hover:bg-violet-500/10" : "border-surface-700 text-surface-500 hover:text-surface-300"}`,
50684
+ children: "hooks"
50685
+ }
50686
+ ),
50687
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
50688
+ "button",
50689
+ {
50690
+ onClick: sendRequest,
50691
+ disabled: isSending || !request.url,
50692
+ className: "px-4 py-1.5 bg-blue-600 hover:bg-blue-500 disabled:bg-surface-800 disabled:text-surface-400 rounded text-sm font-medium transition-colors min-w-[72px]",
50693
+ children: isSending ? "..." : "Send"
50694
+ }
50695
+ )
50696
+ ] })
49979
50697
  ] }),
49980
50698
  isWs ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(WebSocketPanel, { request }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
49981
50699
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex border-b border-surface-800 px-4 gap-0 flex-shrink-0", children: tabs.map((tab) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -50553,6 +51271,87 @@ function prettyXml(raw) {
50553
51271
  return raw;
50554
51272
  }
50555
51273
  }
51274
+ const HOOK_BADGE$1 = {
51275
+ beforeAll: { label: "BEFORE ALL", cls: "bg-violet-700 text-white" },
51276
+ before: { label: "BEFORE", cls: "bg-violet-600 text-white" },
51277
+ after: { label: "AFTER", cls: "bg-cyan-700 text-white" },
51278
+ afterAll: { label: "AFTER ALL", cls: "bg-cyan-800 text-white" }
51279
+ };
51280
+ function HookResultsPanel({ results }) {
51281
+ const [open, setOpen] = reactExports.useState(true);
51282
+ const [expanded, setExpanded] = reactExports.useState(/* @__PURE__ */ new Set());
51283
+ const failed = results.filter((r) => r.status === "failed" || r.status === "error").length;
51284
+ function toggle(id2) {
51285
+ setExpanded((prev) => {
51286
+ const next = new Set(prev);
51287
+ if (next.has(id2)) {
51288
+ next.delete(id2);
51289
+ } else {
51290
+ next.add(id2);
51291
+ }
51292
+ return next;
51293
+ });
51294
+ }
51295
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-b border-surface-800 flex-shrink-0", children: [
51296
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
51297
+ "button",
51298
+ {
51299
+ onClick: () => setOpen((o) => !o),
51300
+ className: "w-full flex items-center gap-2 px-4 py-1.5 text-xs hover:bg-surface-800/30 transition-colors",
51301
+ children: [
51302
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-400", children: open ? "▾" : "▸" }),
51303
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-surface-400", children: "Hooks" }),
51304
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-surface-500", children: [
51305
+ results.length,
51306
+ " ran"
51307
+ ] }),
51308
+ failed > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-1 px-1.5 py-0.5 rounded text-[10px] bg-red-800/60 text-red-300", children: [
51309
+ failed,
51310
+ " failed"
51311
+ ] })
51312
+ ]
51313
+ }
51314
+ ),
51315
+ open && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 pb-2 flex flex-col gap-0.5", children: results.map((r, i) => {
51316
+ const badge = HOOK_BADGE$1[r.hookType ?? ""];
51317
+ const hasDetail = (r.consoleOutput?.length ?? 0) > 0 || (r.testResults?.length ?? 0) > 0 || r.error || r.preScriptError || r.postScriptError;
51318
+ const isExpanded = expanded.has(r.requestId + i);
51319
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs", children: [
51320
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
51321
+ "div",
51322
+ {
51323
+ className: `flex items-center gap-2 py-0.5 ${hasDetail ? "cursor-pointer hover:bg-surface-800/20 rounded px-1 -mx-1" : ""}`,
51324
+ onClick: () => hasDetail && toggle(r.requestId + i),
51325
+ children: [
51326
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `w-1.5 h-1.5 rounded-full shrink-0 ${r.status === "passed" ? "bg-emerald-500" : r.status === "failed" ? "bg-red-500" : "bg-orange-500"}` }),
51327
+ badge && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[9px] font-bold px-1 py-0.5 rounded uppercase tracking-wide shrink-0 ${badge.cls}`, children: badge.label }),
51328
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-300 truncate", children: r.name }),
51329
+ r.httpStatus !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `ml-auto shrink-0 font-mono ${r.httpStatus < 400 ? "text-emerald-400" : "text-red-400"}`, children: r.httpStatus }),
51330
+ r.durationMs !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-surface-500 shrink-0", children: [
51331
+ r.durationMs,
51332
+ "ms"
51333
+ ] }),
51334
+ hasDetail && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-surface-500 shrink-0", children: isExpanded ? "▾" : "▸" })
51335
+ ]
51336
+ }
51337
+ ),
51338
+ isExpanded && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ml-5 mt-0.5 mb-1 flex flex-col gap-1", children: [
51339
+ r.error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-red-400 font-mono text-[10px] whitespace-pre-wrap", children: r.error }),
51340
+ (r.preScriptError || r.postScriptError) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-orange-400 font-mono text-[10px] whitespace-pre-wrap", children: r.preScriptError ?? r.postScriptError }),
51341
+ r.testResults?.map((t2, ti) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `flex items-center gap-1.5 ${t2.passed ? "text-emerald-400" : "text-red-400"}`, children: [
51342
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t2.passed ? "✓" : "✗" }),
51343
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t2.name }),
51344
+ t2.error && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-surface-500 text-[10px]", children: [
51345
+ "— ",
51346
+ t2.error
51347
+ ] })
51348
+ ] }, ti)),
51349
+ r.consoleOutput?.map((line, li) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-mono text-[10px] text-surface-400", children: line }, li))
51350
+ ] })
51351
+ ] }, r.requestId + i);
51352
+ }) })
51353
+ ] });
51354
+ }
50556
51355
  function SaveAsMockModal({ onClose }) {
50557
51356
  const mocks = useStore((s) => s.mocks);
50558
51357
  const addMock = useStore((s) => s.addMock);
@@ -50834,6 +51633,7 @@ function ResponseViewer() {
50834
51633
  const response = activeTab?.lastResponse ?? null;
50835
51634
  const scriptResult = activeTab?.lastScriptResult ?? null;
50836
51635
  const sentRequest = activeTab?.lastSentRequest ?? null;
51636
+ const hookResults = activeTab?.lastHookResults ?? null;
50837
51637
  const requestId = activeTab?.requestId ?? null;
50838
51638
  const [tab, setTab] = reactExports.useState("body");
50839
51639
  reactExports.useEffect(() => {
@@ -50906,6 +51706,7 @@ function ResponseViewer() {
50906
51706
  { id: "console", label: "Console", badge: hasScriptError ? "!" : consoleCount > 0 ? consoleCount : void 0, error: hasScriptError }
50907
51707
  ];
50908
51708
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "h-full flex flex-col", children: [
51709
+ hookResults && hookResults.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(HookResultsPanel, { results: hookResults }),
50909
51710
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 px-4 py-1.5 border-b border-surface-800 flex-shrink-0 overflow-x-auto", children: [
50910
51711
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `text-sm font-bold shrink-0 ${getStatusColor(response.status)}`, children: [
50911
51712
  response.status,
@@ -53114,92 +53915,6 @@ ${failures.join("\n")}
53114
53915
  ];
53115
53916
  return lines.join("\n") + "\n";
53116
53917
  }
53117
- function findFolderById(root2, id2) {
53118
- if (root2.id === id2) return root2;
53119
- for (const sub of root2.folders) {
53120
- const found = findFolderById(sub, id2);
53121
- if (found) return found;
53122
- }
53123
- return null;
53124
- }
53125
- function makeHook(req, collectionVars, hookType, scopeId, scopeAncestors, mainRequestId) {
53126
- return { request: req, collectionVars, isHook: true, hookType, scopeId, scopeAncestors, mainRequestId };
53127
- }
53128
- function buildFolderPlan(folder, requests, collectionVars, filterTags, scopeId, ancestorIds, wrappers) {
53129
- const result = [];
53130
- const folderReqs = folder.requestIds.map((id2) => requests[id2]).filter(Boolean);
53131
- const beforeAllHooks = folderReqs.filter((r) => r.hookType === "beforeAll");
53132
- const beforeHooks = folderReqs.filter((r) => r.hookType === "before");
53133
- const afterHooks = folderReqs.filter((r) => r.hookType === "after");
53134
- const afterAllHooks = folderReqs.filter((r) => r.hookType === "afterAll");
53135
- const regularReqs = folderReqs.filter((r) => !r.hookType);
53136
- const myWrapper = { scopeId, ancestors: ancestorIds, before: beforeHooks, after: afterHooks };
53137
- const allWrappers = [...wrappers, myWrapper];
53138
- for (const req of beforeAllHooks) {
53139
- result.push(makeHook(req, collectionVars, "beforeAll", scopeId, ancestorIds));
53140
- }
53141
- for (const req of regularReqs) {
53142
- const tags2 = req.meta?.tags ?? [];
53143
- if (filterTags.length > 0 && !filterTags.some((t2) => tags2.includes(t2))) continue;
53144
- for (const w of allWrappers) {
53145
- for (const hookReq of w.before) {
53146
- result.push(makeHook(hookReq, collectionVars, "before", w.scopeId, w.ancestors, req.id));
53147
- }
53148
- }
53149
- result.push({ request: req, collectionVars, scopeId, scopeAncestors: ancestorIds });
53150
- for (const w of [...allWrappers].reverse()) {
53151
- for (const hookReq of w.after) {
53152
- result.push(makeHook(hookReq, collectionVars, "after", w.scopeId, w.ancestors, req.id));
53153
- }
53154
- }
53155
- }
53156
- for (const sub of folder.folders) {
53157
- const folderTags = sub.tags ?? [];
53158
- const effectiveFilter = filterTags.length === 0 ? filterTags : folderTags.some((t2) => filterTags.includes(t2)) ? [] : filterTags;
53159
- result.push(...buildFolderPlan(
53160
- sub,
53161
- requests,
53162
- collectionVars,
53163
- effectiveFilter,
53164
- sub.id,
53165
- [...ancestorIds, scopeId],
53166
- allWrappers
53167
- ));
53168
- }
53169
- for (const req of afterAllHooks) {
53170
- result.push(makeHook(req, collectionVars, "afterAll", scopeId, ancestorIds));
53171
- }
53172
- return result;
53173
- }
53174
- function collectAllTags(folder, requests) {
53175
- const tags2 = /* @__PURE__ */ new Set();
53176
- function walk(f) {
53177
- (f.tags ?? []).forEach((t2) => tags2.add(t2));
53178
- for (const reqId of f.requestIds) {
53179
- (requests[reqId]?.meta?.tags ?? []).forEach((t2) => tags2.add(t2));
53180
- }
53181
- f.folders.forEach(walk);
53182
- }
53183
- walk(folder);
53184
- return Array.from(tags2).sort();
53185
- }
53186
- function buildRunPlan(collection, folderId, filterTags) {
53187
- const collectionVars = collection.collectionVariables ?? {};
53188
- if (folderId) {
53189
- const folder = findFolderById(collection.rootFolder, folderId);
53190
- if (!folder) return [];
53191
- return buildFolderPlan(folder, collection.requests, collectionVars, filterTags, folder.id, [], []);
53192
- }
53193
- return buildFolderPlan(
53194
- collection.rootFolder,
53195
- collection.requests,
53196
- collectionVars,
53197
- filterTags,
53198
- collection.rootFolder.id,
53199
- [],
53200
- []
53201
- );
53202
- }
53203
53918
  function buildCliArgs(wsPath, envName, tags2) {
53204
53919
  const parts = [`node out/main/runner.js --workspace ${wsPath}`];
53205
53920
  if (envName) parts.push(`--env "${envName}"`);
@@ -53464,7 +54179,7 @@ function RunnerModal() {
53464
54179
  {
53465
54180
  onClick: run,
53466
54181
  disabled: runnerRunning,
53467
- className: "px-4 py-1.5 text-xs bg-emerald-700 hover:bg-emerald-600 disabled:bg-surface-800 disabled:text-surface-400 rounded font-medium transition-colors flex items-center gap-1.5 whitespace-nowrap",
54182
+ className: "px-4 py-1.5 text-xs text-white bg-emerald-700 hover:bg-emerald-600 disabled:bg-surface-800 disabled:text-surface-400 rounded font-medium transition-colors flex items-center gap-1.5 whitespace-nowrap",
53468
54183
  children: [
53469
54184
  /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z", clipRule: "evenodd" }) }),
53470
54185
  runnerRunning ? "Running…" : "Run"
@@ -53572,7 +54287,7 @@ function RunnerModal() {
53572
54287
  },
53573
54288
  idx
53574
54289
  )) }) }) }),
53575
- summary && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 px-4 py-2 border-t border-surface-800 bg-surface-950/50 flex-shrink-0 text-xs", children: [
54290
+ summary && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 px-4 py-2 border-t border-surface-800 bg-surface-800/30 flex-shrink-0 text-xs", children: [
53576
54291
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-emerald-400 font-medium", children: [
53577
54292
  summary.passed,
53578
54293
  " passed"
@@ -56278,7 +56993,7 @@ function App() {
56278
56993
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "#6aa3c8" }, children: "Spector" }),
56279
56994
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-2 text-[10px] font-normal opacity-50", children: [
56280
56995
  "v",
56281
- "0.1.5"
56996
+ "0.1.7"
56282
56997
  ] }),
56283
56998
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mx-2 opacity-30", children: "·" }),
56284
56999
  /* @__PURE__ */ jsxRuntimeExports.jsx(