@clarify-labs/renderer 0.10.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/output/{ClarifyShell-UsefuuLS.cjs → ClarifyShell-BAjq876Z.cjs} +85 -82
- package/output/ClarifyShell-BAjq876Z.cjs.map +1 -0
- package/output/{ClarifyShell-Cq5Af46F.js → ClarifyShell-GoSXvgMg.js} +85 -82
- package/output/ClarifyShell-GoSXvgMg.js.map +1 -0
- package/output/{MermaidViewer-Db7qsyVk.cjs → MermaidViewer-BZ8ghcFP.cjs} +2 -2
- package/output/{MermaidViewer-Db7qsyVk.cjs.map → MermaidViewer-BZ8ghcFP.cjs.map} +1 -1
- package/output/{MermaidViewer-Bc9H25yK.js → MermaidViewer-CkIxyqtf.js} +2 -2
- package/output/{MermaidViewer-Bc9H25yK.js.map → MermaidViewer-CkIxyqtf.js.map} +1 -1
- package/output/{OpenApiOperation-BZWeCbvy.js → OpenApiOperation-C2vJztWZ.js} +1536 -211
- package/output/OpenApiOperation-C2vJztWZ.js.map +1 -0
- package/output/{OpenApiOperation-DbZjxIuj.cjs → OpenApiOperation-D-5uE5v7.cjs} +1539 -208
- package/output/OpenApiOperation-D-5uE5v7.cjs.map +1 -0
- package/output/{PageActions-Dg1l9KB1.cjs → PageActions-DJRXlGhz.cjs} +16 -16
- package/output/PageActions-DJRXlGhz.cjs.map +1 -0
- package/output/{PageActions-BQeEmXbT.js → PageActions-bugd7GZh.js} +16 -16
- package/output/PageActions-bugd7GZh.js.map +1 -0
- package/output/{SearchDialog-DjKvqN7p.cjs → SearchDialog-8AdCRp6K.cjs} +3 -3
- package/output/{SearchDialog-DjKvqN7p.cjs.map → SearchDialog-8AdCRp6K.cjs.map} +1 -1
- package/output/{SearchDialog-B67VA0Ut.js → SearchDialog-CBJjDs_9.js} +3 -3
- package/output/{SearchDialog-B67VA0Ut.js.map → SearchDialog-CBJjDs_9.js.map} +1 -1
- package/output/app/PageFooter.d.ts +1 -1
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/components/Tooltip.d.ts +1 -0
- package/output/core/i18n.d.ts +1 -1
- package/output/core/types.d.ts +37 -19
- package/output/{i18n-Bqth9d6Q.js → i18n-BPrC45nD.js} +98 -2
- package/output/i18n-BPrC45nD.js.map +1 -0
- package/output/{i18n-C-fReCj-.cjs → i18n-wXINKKV0.cjs} +98 -2
- package/output/i18n-wXINKKV0.cjs.map +1 -0
- package/output/index.cjs +26 -5
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +3 -3
- package/output/index.js +26 -6
- package/output/index.js.map +1 -1
- package/output/mdx/components.d.ts +2 -1
- package/output/openapi/components/EndpointMethodBadge.d.ts +6 -0
- package/output/openapi/components/EndpointSections.d.ts +2 -2
- package/output/openapi/components/ExamplePanels.d.ts +2 -2
- package/output/openapi/components/InlineListbox.d.ts +13 -0
- package/output/openapi/components/OpenApiAuthPanel.d.ts +12 -0
- package/output/openapi/components/OpenApiOperation.d.ts +1 -9
- package/output/openapi/components/OpenApiOperation.state.d.ts +4 -2
- package/output/openapi/components/OpenApiRequest.d.ts +18 -0
- package/output/openapi/components/OpenApiRequestFields.d.ts +25 -0
- package/output/openapi/components/OpenApiResponseViewer.d.ts +8 -0
- package/output/openapi/components/SendRequestButton.d.ts +9 -0
- package/output/openapi/components/helpers.d.ts +6 -1
- package/output/openapi/components/useOpenApiRequestState.d.ts +41 -0
- package/output/openapi/entry.d.ts +2 -0
- package/output/openapi/index.d.ts +2 -2
- package/output/openapi/lib/api-exchange-code.d.ts +8 -0
- package/output/openapi/lib/api-exchange.d.ts +30 -0
- package/output/openapi/lib/api-request.d.ts +24 -0
- package/output/openapi/lib/request-code.d.ts +2 -2
- package/output/openapi/lib/request-parameters.d.ts +5 -0
- package/output/openapi/store.d.ts +10 -0
- package/output/openapi/types.d.ts +4 -0
- package/output/preview.cjs +37 -27
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +37 -27
- package/output/preview.js.map +1 -1
- package/output/{render-Dc9wxg_r.cjs → render-FICIzeXz.cjs} +2 -2
- package/output/{render-Dc9wxg_r.cjs.map → render-FICIzeXz.cjs.map} +1 -1
- package/output/{render-aS-w4fK4.js → render-XQiw_48i.js} +2 -2
- package/output/{render-aS-w4fK4.js.map → render-XQiw_48i.js.map} +1 -1
- package/output/renderer.css +547 -150
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/output/theme/ThemeEditor.d.ts +8 -4
- package/output/theme/variables.d.ts +8 -4
- package/package.json +1 -1
- package/output/ClarifyShell-Cq5Af46F.js.map +0 -1
- package/output/ClarifyShell-UsefuuLS.cjs.map +0 -1
- package/output/OpenApiOperation-BZWeCbvy.js.map +0 -1
- package/output/OpenApiOperation-DbZjxIuj.cjs.map +0 -1
- package/output/PageActions-BQeEmXbT.js.map +0 -1
- package/output/PageActions-Dg1l9KB1.cjs.map +0 -1
- package/output/i18n-Bqth9d6Q.js.map +0 -1
- package/output/i18n-C-fReCj-.cjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-
|
|
2
|
-
import { C as isExternalHref, E as copyTextToClipboard, c as lucideIconRegistry, h as useTheme, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-
|
|
1
|
+
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-BPrC45nD.js";
|
|
2
|
+
import { C as isExternalHref, E as copyTextToClipboard, c as lucideIconRegistry, h as useTheme, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-bugd7GZh.js";
|
|
3
3
|
import { t as markdownRemarkPlugins } from "./remark-C9iRQM0R.js";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { Children, Suspense, cloneElement, createContext, createElement, forwardRef, isValidElement, lazy, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
6
6
|
import { Link } from "react-router-dom";
|
|
7
|
-
import { Dialog, DialogBackdrop, DialogPanel, Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
|
|
8
|
-
import { AlertTriangle, ArrowRight, ArrowUpRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, File, Folder, FolderOpen, Info, Lightbulb, LinkIcon,
|
|
7
|
+
import { Dialog, DialogBackdrop, DialogPanel, DialogTitle, Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
|
|
8
|
+
import { AlertTriangle, ArrowRight, ArrowUpRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleAlertIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, DownloadIcon, EraserIcon, File, FileX2Icon, Folder, FolderOpen, Info, InfoIcon, Lightbulb, LinkIcon, LoaderCircleIcon, Maximize2, PackageIcon, RotateCcwIcon, SearchIcon, SendIcon, ServerIcon, X, XCircle, XIcon } from "lucide-react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { motion, useInView } from "framer-motion";
|
|
11
11
|
import { create } from "zustand";
|
|
@@ -252,7 +252,7 @@ function Card(arg0) {
|
|
|
252
252
|
}
|
|
253
253
|
//#endregion
|
|
254
254
|
//#region source/components/Mermaid.tsx
|
|
255
|
-
var MermaidViewer = lazy(() => import("./MermaidViewer-
|
|
255
|
+
var MermaidViewer = lazy(() => import("./MermaidViewer-CkIxyqtf.js"));
|
|
256
256
|
var mermaidModulePromise;
|
|
257
257
|
async function loadMermaid() {
|
|
258
258
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
@@ -399,7 +399,7 @@ function getCodePanelTitle(node, fallbackTitle) {
|
|
|
399
399
|
fallbackTitle
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
|
-
function CopyButton(arg0) {
|
|
402
|
+
function CopyButton$1(arg0) {
|
|
403
403
|
const { code } = arg0;
|
|
404
404
|
const t = useBuiltInText();
|
|
405
405
|
const [copyCount, setCopyCount] = useState(0);
|
|
@@ -460,7 +460,7 @@ function CodePanel(arg0) {
|
|
|
460
460
|
children: [/* @__PURE__ */ jsx("pre", {
|
|
461
461
|
className: "clarify-code-pre overflow-x-auto p-4 text-xs text-(--clarify-code-text)",
|
|
462
462
|
children
|
|
463
|
-
}), /* @__PURE__ */ jsx(CopyButton, { code: copyText })]
|
|
463
|
+
}), /* @__PURE__ */ jsx(CopyButton$1, { code: copyText })]
|
|
464
464
|
})]
|
|
465
465
|
});
|
|
466
466
|
}
|
|
@@ -1057,28 +1057,61 @@ function Tabs(arg0) {
|
|
|
1057
1057
|
//#endregion
|
|
1058
1058
|
//#region source/components/Tooltip.tsx
|
|
1059
1059
|
function Tooltip(arg0) {
|
|
1060
|
-
const { content, children, side = "top", className, ...props } = arg0;
|
|
1060
|
+
const { content, children, side = "top", className, triggerClassName, ...props } = arg0;
|
|
1061
1061
|
const contentId = useId();
|
|
1062
1062
|
const [open, setOpen] = useState(false);
|
|
1063
|
+
const triggerRef = useRef(null);
|
|
1064
|
+
const tooltipRef = useRef(null);
|
|
1065
|
+
const [position, setPosition] = useState();
|
|
1066
|
+
useEffect(() => {
|
|
1067
|
+
if (!open) return;
|
|
1068
|
+
function updatePosition() {
|
|
1069
|
+
const bounds = triggerRef.current?.getBoundingClientRect();
|
|
1070
|
+
if (!bounds) return;
|
|
1071
|
+
setPosition({
|
|
1072
|
+
left: bounds.left + bounds.width / 2,
|
|
1073
|
+
top: side === "top" ? bounds.top - 8 : bounds.bottom + 8
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
updatePosition();
|
|
1077
|
+
window.addEventListener("resize", updatePosition);
|
|
1078
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
1079
|
+
return () => {
|
|
1080
|
+
window.removeEventListener("resize", updatePosition);
|
|
1081
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
1082
|
+
};
|
|
1083
|
+
}, [open, side]);
|
|
1084
|
+
useEffect(() => {
|
|
1085
|
+
const tooltip = tooltipRef.current;
|
|
1086
|
+
if (!tooltip || typeof tooltip.showPopover !== "function") return;
|
|
1087
|
+
if (open) tooltip.showPopover();
|
|
1088
|
+
else if (tooltip.matches(":popover-open")) tooltip.hidePopover();
|
|
1089
|
+
}, [open]);
|
|
1063
1090
|
return /* @__PURE__ */ jsxs("span", {
|
|
1064
|
-
className: clsx("clarify-tooltip group
|
|
1091
|
+
className: clsx("clarify-tooltip group inline-flex align-baseline", className),
|
|
1065
1092
|
onMouseEnter: () => setOpen(true),
|
|
1066
1093
|
onMouseLeave: () => setOpen(false),
|
|
1067
1094
|
...props,
|
|
1068
|
-
children: [/* @__PURE__ */ jsx("
|
|
1069
|
-
|
|
1095
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1096
|
+
type: "button",
|
|
1097
|
+
ref: triggerRef,
|
|
1070
1098
|
"aria-describedby": contentId,
|
|
1071
|
-
|
|
1099
|
+
"aria-expanded": open,
|
|
1100
|
+
className: clsx("cursor-help appearance-none rounded-sm border-0 border-b border-dotted border-current bg-transparent p-0 font-inherit text-inherit focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", triggerClassName),
|
|
1072
1101
|
onFocus: () => setOpen(true),
|
|
1073
1102
|
onBlur: () => setOpen(false),
|
|
1103
|
+
onClick: () => setOpen(true),
|
|
1074
1104
|
onKeyDown: (event) => {
|
|
1075
1105
|
if (event.key === "Escape") setOpen(false);
|
|
1076
1106
|
},
|
|
1077
1107
|
children
|
|
1078
1108
|
}), /* @__PURE__ */ jsx("span", {
|
|
1109
|
+
ref: tooltipRef,
|
|
1079
1110
|
id: contentId,
|
|
1080
1111
|
role: "tooltip",
|
|
1081
|
-
|
|
1112
|
+
popover: "manual",
|
|
1113
|
+
style: position,
|
|
1114
|
+
className: clsx("pointer-events-none fixed right-auto bottom-auto z-60 m-0 w-max max-w-64 -translate-x-1/2 rounded-md border-0 bg-(--clarify-theme-tokens-colors-foreground) px-2.5 py-1.5 text-center text-xs/5 font-normal text-(--clarify-theme-tokens-colors-background) shadow-lg transition duration-150", side === "top" && "-translate-y-full", open && position ? "visible opacity-100" : "invisible opacity-0"),
|
|
1082
1115
|
children: content
|
|
1083
1116
|
})]
|
|
1084
1117
|
});
|
|
@@ -1657,6 +1690,23 @@ function listOpenApiOperations(spec) {
|
|
|
1657
1690
|
return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
|
|
1658
1691
|
}
|
|
1659
1692
|
//#endregion
|
|
1693
|
+
//#region source/openapi/components/EndpointMethodBadge.tsx
|
|
1694
|
+
var endpointMethodStyleVars = {
|
|
1695
|
+
GET: "bg-(--clarify-http-method-get-background) text-(--clarify-http-method-get-text)",
|
|
1696
|
+
POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
|
|
1697
|
+
PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
|
|
1698
|
+
PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
|
|
1699
|
+
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
|
|
1700
|
+
WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
|
|
1701
|
+
};
|
|
1702
|
+
function EndpointMethodBadge(arg0) {
|
|
1703
|
+
const { method } = arg0;
|
|
1704
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1705
|
+
className: clsx("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
|
|
1706
|
+
children: method
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
//#endregion
|
|
1660
1710
|
//#region source/components/HighlightedCode.tsx
|
|
1661
1711
|
var cssVariablesTheme = createCssVariablesTheme();
|
|
1662
1712
|
function HighlightedCode(arg0) {
|
|
@@ -1714,6 +1764,15 @@ var snippetControlCharacters = [
|
|
|
1714
1764
|
}
|
|
1715
1765
|
];
|
|
1716
1766
|
var snippetGenerator = snippetz();
|
|
1767
|
+
function getAuthPlaceholder(name) {
|
|
1768
|
+
return `YOUR_${name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^a-zA-Z0-9]+/g, "_").toUpperCase() || "CREDENTIAL"}`;
|
|
1769
|
+
}
|
|
1770
|
+
function redactAuth(auth = []) {
|
|
1771
|
+
return auth.map((input) => ({
|
|
1772
|
+
...input,
|
|
1773
|
+
value: getAuthPlaceholder(input.name)
|
|
1774
|
+
}));
|
|
1775
|
+
}
|
|
1717
1776
|
function protectSnippetControlCharacters(value) {
|
|
1718
1777
|
if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
|
|
1719
1778
|
if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
|
|
@@ -1732,7 +1791,7 @@ function getDefaultServer(spec) {
|
|
|
1732
1791
|
function getDefaultWebhookServer() {
|
|
1733
1792
|
return { url: "https://webhook.example.com" };
|
|
1734
1793
|
}
|
|
1735
|
-
function expandServerUrl(server, serverVariables = {}) {
|
|
1794
|
+
function expandServerUrl$1(server, serverVariables = {}) {
|
|
1736
1795
|
return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
|
|
1737
1796
|
const fallback = server.variables?.[name]?.default ?? name;
|
|
1738
1797
|
return serverVariables[name] ?? fallback;
|
|
@@ -1740,16 +1799,16 @@ function expandServerUrl(server, serverVariables = {}) {
|
|
|
1740
1799
|
}
|
|
1741
1800
|
function buildOperationUrl(input) {
|
|
1742
1801
|
const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
|
|
1743
|
-
return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1802
|
+
return joinPath(expandServerUrl$1(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1744
1803
|
}
|
|
1745
|
-
function getQueryString(parameters, auth) {
|
|
1804
|
+
function getQueryString(parameters, auth = []) {
|
|
1746
1805
|
const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
|
|
1747
1806
|
name: parameter.name,
|
|
1748
1807
|
value: encodeUrlPlaceholders(`{${parameter.name}}`)
|
|
1749
1808
|
}));
|
|
1750
|
-
if (
|
|
1751
|
-
name:
|
|
1752
|
-
value:
|
|
1809
|
+
for (const input of auth) if (input.scheme.type === "apiKey" && input.scheme.in === "query" && input.scheme.name) queryString.push({
|
|
1810
|
+
name: input.scheme.name,
|
|
1811
|
+
value: input.value
|
|
1753
1812
|
});
|
|
1754
1813
|
return queryString;
|
|
1755
1814
|
}
|
|
@@ -1797,15 +1856,14 @@ function getAuthorizationValue(auth) {
|
|
|
1797
1856
|
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "basic") return `Basic ${auth.value}`;
|
|
1798
1857
|
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
1799
1858
|
}
|
|
1800
|
-
function
|
|
1801
|
-
if (!auth) return {};
|
|
1859
|
+
function getAuthHeader(auth) {
|
|
1802
1860
|
if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) return { [auth.scheme.name]: auth.value };
|
|
1803
1861
|
const authorization = getAuthorizationValue(auth);
|
|
1804
1862
|
return authorization ? { Authorization: authorization } : {};
|
|
1805
1863
|
}
|
|
1806
|
-
function getRequestHeaders(requestContent, auth) {
|
|
1864
|
+
function getRequestHeaders(requestContent, auth = []) {
|
|
1807
1865
|
return {
|
|
1808
|
-
...
|
|
1866
|
+
...Object.assign({}, ...auth.map(getAuthHeader)),
|
|
1809
1867
|
Accept: "application/json",
|
|
1810
1868
|
...requestContent ? { "Content-Type": requestContent.mediaType } : {}
|
|
1811
1869
|
};
|
|
@@ -2123,6 +2181,10 @@ var requestSnippetOptions = [
|
|
|
2123
2181
|
}
|
|
2124
2182
|
];
|
|
2125
2183
|
function buildRequestCodeExamples(input) {
|
|
2184
|
+
const redactedInput = {
|
|
2185
|
+
...input,
|
|
2186
|
+
auth: redactAuth(input.auth)
|
|
2187
|
+
};
|
|
2126
2188
|
return requestSnippetOptions.map((option) => ({
|
|
2127
2189
|
key: `${option.languageKey}:${option.client}`,
|
|
2128
2190
|
title: option.title,
|
|
@@ -2130,7 +2192,7 @@ function buildRequestCodeExamples(input) {
|
|
|
2130
2192
|
languageKey: option.languageKey,
|
|
2131
2193
|
clientKey: option.client,
|
|
2132
2194
|
clientTitle: option.clientTitle,
|
|
2133
|
-
code: buildSnippet(
|
|
2195
|
+
code: buildSnippet(redactedInput, option)
|
|
2134
2196
|
}));
|
|
2135
2197
|
}
|
|
2136
2198
|
//#endregion
|
|
@@ -2152,7 +2214,7 @@ function SelectControl(arg0) {
|
|
|
2152
2214
|
className: wrapperClassName,
|
|
2153
2215
|
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
2154
2216
|
"aria-label": label,
|
|
2155
|
-
className: `clarify-openai-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-
|
|
2217
|
+
className: `clarify-openai-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-code-border) bg-(--clarify-code-control-background) px-2.5 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:border-(--clarify-code-border) hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-(--clarify-code-border) data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
|
|
2156
2218
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
2157
2219
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
|
|
2158
2220
|
children: [icon ? /* @__PURE__ */ jsx("span", {
|
|
@@ -2168,10 +2230,10 @@ function SelectControl(arg0) {
|
|
|
2168
2230
|
})]
|
|
2169
2231
|
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
2170
2232
|
anchor: "bottom end",
|
|
2171
|
-
className: "clarify-openai-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-
|
|
2233
|
+
className: "clarify-openai-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) bg-(--clarify-code-surface) p-1 text-xs shadow-lg shadow-black/20 ring-1 ring-(--clarify-code-border) [--anchor-gap:--spacing(1)] focus:outline-none",
|
|
2172
2234
|
children: normalizedOptions.map((option) => /* @__PURE__ */ jsxs(ListboxOption, {
|
|
2173
2235
|
value: option.value,
|
|
2174
|
-
className: "clarify-openai-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-
|
|
2236
|
+
className: "clarify-openai-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-control-text) select-none data-focus:bg-(--clarify-code-control-background-hover) data-focus:text-(--clarify-code-text) data-selected:bg-(--clarify-code-accent-background) data-selected:text-(--clarify-code-accent-text)",
|
|
2175
2237
|
children: [/* @__PURE__ */ jsx("span", { children: option.label }), /* @__PURE__ */ jsx(CheckIcon, {
|
|
2176
2238
|
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
2177
2239
|
"aria-hidden": "true"
|
|
@@ -2285,12 +2347,17 @@ function getSecurityRequirements(spec, operation) {
|
|
|
2285
2347
|
}
|
|
2286
2348
|
function getAuthOptions(spec, operation) {
|
|
2287
2349
|
const schemes = getSecuritySchemes(spec);
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
scheme
|
|
2293
|
-
|
|
2350
|
+
return getSecurityRequirements(spec, operation).map((requirement, index) => {
|
|
2351
|
+
const requirementSchemes = Object.keys(requirement).map((name) => ({
|
|
2352
|
+
name,
|
|
2353
|
+
scheme: schemes[name]
|
|
2354
|
+
})).filter((option) => Boolean(option.scheme));
|
|
2355
|
+
return {
|
|
2356
|
+
key: `requirement:${index}`,
|
|
2357
|
+
label: requirementSchemes.map((option) => option.name).join(" + "),
|
|
2358
|
+
schemes: requirementSchemes
|
|
2359
|
+
};
|
|
2360
|
+
});
|
|
2294
2361
|
}
|
|
2295
2362
|
function authPlaceholder(auth) {
|
|
2296
2363
|
if (!auth) return "";
|
|
@@ -2323,7 +2390,7 @@ function getClientOptions(codeOptions, languageKey) {
|
|
|
2323
2390
|
function ApiExampleCodeGroup(arg0) {
|
|
2324
2391
|
const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, metaInToolbar = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
2325
2392
|
const t = useBuiltInText();
|
|
2326
|
-
const metaClassName = comfortableMeta ? "flex min-h-
|
|
2393
|
+
const metaClassName = comfortableMeta ? "flex min-h-10 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5 py-2" : "flex h-9 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5";
|
|
2327
2394
|
const meta = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2328
2395
|
tag ? /* @__PURE__ */ jsx(ExampleMetaValue, {
|
|
2329
2396
|
label: t("openapi.status"),
|
|
@@ -2342,14 +2409,14 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2342
2409
|
}) : null
|
|
2343
2410
|
] });
|
|
2344
2411
|
return /* @__PURE__ */ jsx("div", {
|
|
2345
|
-
className: "clarify-openai-example my-6 overflow-hidden rounded-
|
|
2412
|
+
className: "clarify-openai-example my-6 overflow-hidden rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-background) shadow-sm",
|
|
2346
2413
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2347
2414
|
className: "not-prose",
|
|
2348
2415
|
children: [
|
|
2349
2416
|
/* @__PURE__ */ jsxs("div", {
|
|
2350
|
-
className: "clarify-openai-example-header flex min-h-
|
|
2417
|
+
className: "clarify-openai-example-header flex min-h-11 items-center gap-3 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-3.5 py-1.5",
|
|
2351
2418
|
children: [/* @__PURE__ */ jsx("h3", {
|
|
2352
|
-
className: "mr-auto min-w-16 truncate py-1 text-
|
|
2419
|
+
className: "mr-auto min-w-16 truncate py-1 text-sm font-semibold text-(--clarify-code-text)",
|
|
2353
2420
|
children: title
|
|
2354
2421
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2355
2422
|
className: "clarify-openai-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
@@ -2786,11 +2853,11 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
2786
2853
|
};
|
|
2787
2854
|
}
|
|
2788
2855
|
function EnumValueNode(arg0) {
|
|
2789
|
-
const { node
|
|
2856
|
+
const { node } = arg0;
|
|
2790
2857
|
return /* @__PURE__ */ jsx("li", {
|
|
2791
|
-
className: "clarify-schema-node m-0
|
|
2858
|
+
className: "clarify-schema-node m-0 p-0",
|
|
2792
2859
|
children: /* @__PURE__ */ jsx("div", {
|
|
2793
|
-
className:
|
|
2860
|
+
className: "flex min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left",
|
|
2794
2861
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2795
2862
|
className: "min-w-0 flex-1",
|
|
2796
2863
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -2824,7 +2891,7 @@ function SchemaNode(arg0) {
|
|
|
2824
2891
|
});
|
|
2825
2892
|
const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
|
|
2826
2893
|
const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
|
|
2827
|
-
const rowClassName =
|
|
2894
|
+
const rowClassName = "flex w-full min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left";
|
|
2828
2895
|
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
|
|
2829
2896
|
className: "min-w-0 flex-1",
|
|
2830
2897
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -2852,7 +2919,7 @@ function SchemaNode(arg0) {
|
|
|
2852
2919
|
children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
2853
2920
|
}) : null] });
|
|
2854
2921
|
return /* @__PURE__ */ jsxs("li", {
|
|
2855
|
-
className: "clarify-schema-node m-0
|
|
2922
|
+
className: "clarify-schema-node m-0 p-0",
|
|
2856
2923
|
children: [hasChildren ? /* @__PURE__ */ jsx("button", {
|
|
2857
2924
|
type: "button",
|
|
2858
2925
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
@@ -2874,7 +2941,7 @@ function SchemaTree(arg0) {
|
|
|
2874
2941
|
if (nodes.length === 0) return null;
|
|
2875
2942
|
return /* @__PURE__ */ jsx("ul", {
|
|
2876
2943
|
role: "list",
|
|
2877
|
-
className: clsx("m-0 list-none divide-y divide-(--clarify-theme-tokens-colors-border)
|
|
2944
|
+
className: clsx("m-0 list-none p-0", depth === 0 ? "divide-y divide-(--clarify-theme-tokens-colors-border)" : "ml-2 border-l border-(--clarify-theme-tokens-colors-border) pl-2"),
|
|
2878
2945
|
children: nodes.map((node) => /* @__PURE__ */ jsx(SchemaNode, {
|
|
2879
2946
|
node,
|
|
2880
2947
|
depth,
|
|
@@ -2887,7 +2954,7 @@ function SchemaProperties(arg0) {
|
|
|
2887
2954
|
const root = getRootSchemaNode(spec, schema, defaultExpanded);
|
|
2888
2955
|
if (!root || root.children.length === 0) return null;
|
|
2889
2956
|
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title }), /* @__PURE__ */ jsx("div", {
|
|
2890
|
-
className: "clarify-schema-properties my-6",
|
|
2957
|
+
className: "clarify-schema-properties not-prose my-6",
|
|
2891
2958
|
children: /* @__PURE__ */ jsx(SchemaTree, { nodes: root.children })
|
|
2892
2959
|
})] });
|
|
2893
2960
|
}
|
|
@@ -2972,7 +3039,8 @@ function ResponseList(arg0) {
|
|
|
2972
3039
|
response
|
|
2973
3040
|
})
|
|
2974
3041
|
})),
|
|
2975
|
-
|
|
3042
|
+
className: "mt-4 mb-6",
|
|
3043
|
+
panelsClassName: "mt-5"
|
|
2976
3044
|
})] });
|
|
2977
3045
|
}
|
|
2978
3046
|
//#endregion
|
|
@@ -2997,7 +3065,7 @@ function EndpointRequest(arg0) {
|
|
|
2997
3065
|
})] });
|
|
2998
3066
|
};
|
|
2999
3067
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [renderDescription(), /* @__PURE__ */ jsxs(Row, {
|
|
3000
|
-
className: "relative mt-6",
|
|
3068
|
+
className: "clarify-openapi-request-workspace relative mt-8 pt-6",
|
|
3001
3069
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsxs("div", {
|
|
3002
3070
|
className: "w-full",
|
|
3003
3071
|
children: [
|
|
@@ -3044,9 +3112,9 @@ function EndpointResponse(arg0) {
|
|
|
3044
3112
|
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
3045
3113
|
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
3046
3114
|
return /* @__PURE__ */ jsx("div", {
|
|
3047
|
-
className: "mt-6",
|
|
3115
|
+
className: "mt-10 pt-6",
|
|
3048
3116
|
children: /* @__PURE__ */ jsxs(Row, {
|
|
3049
|
-
className: "relative",
|
|
3117
|
+
className: "clarify-openapi-response-workspace relative",
|
|
3050
3118
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx("div", {
|
|
3051
3119
|
className: "w-full",
|
|
3052
3120
|
children: /* @__PURE__ */ jsx(ResponseList, {
|
|
@@ -3076,49 +3144,128 @@ function EndpointResponse(arg0) {
|
|
|
3076
3144
|
}
|
|
3077
3145
|
//#endregion
|
|
3078
3146
|
//#region source/openapi/components/InlineListbox.tsx
|
|
3147
|
+
var defaultButtonClassName = "inline-flex min-w-0 items-center justify-between gap-1 border-0 bg-transparent font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary) data-disabled:cursor-not-allowed data-open:bg-(--clarify-ui-active-background)";
|
|
3148
|
+
var optionsClassName = "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 [--anchor-gap:--spacing(1)] focus:outline-none";
|
|
3149
|
+
var optionClassName = "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-focus:text-(--clarify-ui-text-strong) data-selected:bg-(--clarify-ui-active-background) data-selected:text-(--clarify-ui-accent-text)";
|
|
3150
|
+
function OptionContent(arg0) {
|
|
3151
|
+
const { option } = arg0;
|
|
3152
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
|
|
3153
|
+
className: "min-w-0",
|
|
3154
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3155
|
+
className: "block truncate",
|
|
3156
|
+
children: option.label
|
|
3157
|
+
}), option.description ? /* @__PURE__ */ jsx("span", {
|
|
3158
|
+
className: "mt-0.5 block truncate text-2xs text-(--clarify-ui-text-faint)",
|
|
3159
|
+
children: option.description
|
|
3160
|
+
}) : null]
|
|
3161
|
+
}), /* @__PURE__ */ jsx(CheckIcon, {
|
|
3162
|
+
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
3163
|
+
"aria-hidden": "true"
|
|
3164
|
+
})] });
|
|
3165
|
+
}
|
|
3079
3166
|
function InlineListbox(arg0) {
|
|
3080
|
-
const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className } = arg0;
|
|
3081
|
-
const selected = options.find((option) => option.value === value)
|
|
3167
|
+
const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className, invalid, describedBy, disabled = false } = arg0;
|
|
3168
|
+
const selected = options.find((option) => option.value === value);
|
|
3082
3169
|
return /* @__PURE__ */ jsx(Listbox, {
|
|
3083
|
-
value
|
|
3170
|
+
value,
|
|
3084
3171
|
onChange,
|
|
3172
|
+
disabled,
|
|
3085
3173
|
children: /* @__PURE__ */ jsxs("div", {
|
|
3086
|
-
className: clsx("pointer-events-auto relative inline-flex min-w-0", className),
|
|
3174
|
+
className: clsx("pointer-events-auto relative inline-flex min-w-0 w-full", className),
|
|
3087
3175
|
children: [/* @__PURE__ */ jsx(ListboxButton, {
|
|
3088
3176
|
"aria-label": label,
|
|
3089
|
-
|
|
3177
|
+
"aria-invalid": invalid || void 0,
|
|
3178
|
+
"aria-describedby": describedBy,
|
|
3179
|
+
className: clsx(buttonClassName ?? defaultButtonClassName, buttonClassName ? null : compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2 text-xs"),
|
|
3090
3180
|
children: buttonContent ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
3091
3181
|
className: "truncate",
|
|
3092
|
-
children: selected?.label ?? value
|
|
3182
|
+
children: selected?.label ?? (value || label)
|
|
3093
3183
|
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3094
3184
|
className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3095
3185
|
"aria-hidden": "true"
|
|
3096
3186
|
})] })
|
|
3097
3187
|
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
3098
3188
|
anchor: "bottom start",
|
|
3099
|
-
className:
|
|
3100
|
-
children: options.map((option) => /* @__PURE__ */
|
|
3189
|
+
className: optionsClassName,
|
|
3190
|
+
children: options.map((option) => /* @__PURE__ */ jsx(ListboxOption, {
|
|
3101
3191
|
value: option.value,
|
|
3102
|
-
className:
|
|
3103
|
-
children:
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3192
|
+
className: optionClassName,
|
|
3193
|
+
children: /* @__PURE__ */ jsx(OptionContent, { option })
|
|
3194
|
+
}, option.value))
|
|
3195
|
+
})]
|
|
3196
|
+
})
|
|
3197
|
+
});
|
|
3198
|
+
}
|
|
3199
|
+
function MultiInlineListbox(arg0) {
|
|
3200
|
+
const { label, value, options, onChange, disabled = false, invalid, describedBy } = arg0;
|
|
3201
|
+
const selectedLabel = options.filter((option) => value.includes(option.value)).map((option) => option.label).join(", ");
|
|
3202
|
+
return /* @__PURE__ */ jsx(Listbox, {
|
|
3203
|
+
value,
|
|
3204
|
+
onChange,
|
|
3205
|
+
multiple: true,
|
|
3206
|
+
disabled,
|
|
3207
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
3208
|
+
className: "pointer-events-auto relative inline-flex min-w-0 w-full",
|
|
3209
|
+
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
3210
|
+
"aria-label": label,
|
|
3211
|
+
"aria-invalid": invalid || void 0,
|
|
3212
|
+
"aria-describedby": describedBy,
|
|
3213
|
+
className: clsx(defaultButtonClassName, "min-h-8 w-full px-2 text-xs"),
|
|
3214
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3215
|
+
className: "truncate",
|
|
3216
|
+
children: selectedLabel || label
|
|
3217
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3218
|
+
className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3219
|
+
"aria-hidden": "true"
|
|
3220
|
+
})]
|
|
3221
|
+
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
3222
|
+
anchor: "bottom start",
|
|
3223
|
+
className: optionsClassName,
|
|
3224
|
+
children: options.map((option) => /* @__PURE__ */ jsx(ListboxOption, {
|
|
3225
|
+
value: option.value,
|
|
3226
|
+
className: optionClassName,
|
|
3227
|
+
children: /* @__PURE__ */ jsx(OptionContent, { option })
|
|
3116
3228
|
}, option.value))
|
|
3117
3229
|
})]
|
|
3118
3230
|
})
|
|
3119
3231
|
});
|
|
3120
3232
|
}
|
|
3121
3233
|
//#endregion
|
|
3234
|
+
//#region source/openapi/store.ts
|
|
3235
|
+
var credentialScopes = /* @__PURE__ */ new WeakMap();
|
|
3236
|
+
var emptyOpenApiCredentials = Object.freeze({});
|
|
3237
|
+
var nextCredentialScope = 0;
|
|
3238
|
+
function getOpenApiCredentialScope(spec) {
|
|
3239
|
+
const current = credentialScopes.get(spec);
|
|
3240
|
+
if (current) return current;
|
|
3241
|
+
const scope = `openapi-${nextCredentialScope += 1}`;
|
|
3242
|
+
credentialScopes.set(spec, scope);
|
|
3243
|
+
return scope;
|
|
3244
|
+
}
|
|
3245
|
+
var useOpenApiStore = create()((set) => ({
|
|
3246
|
+
credentials: {},
|
|
3247
|
+
setCredential: (scope, name, value) => set((state) => ({ credentials: {
|
|
3248
|
+
...state.credentials,
|
|
3249
|
+
[scope]: {
|
|
3250
|
+
...state.credentials[scope],
|
|
3251
|
+
[name]: value
|
|
3252
|
+
}
|
|
3253
|
+
} })),
|
|
3254
|
+
clearCredential: (scope, name) => set((state) => {
|
|
3255
|
+
const scoped = { ...state.credentials[scope] };
|
|
3256
|
+
delete scoped[name];
|
|
3257
|
+
return { credentials: {
|
|
3258
|
+
...state.credentials,
|
|
3259
|
+
[scope]: scoped
|
|
3260
|
+
} };
|
|
3261
|
+
}),
|
|
3262
|
+
clearCredentials: (scope) => set((state) => {
|
|
3263
|
+
const credentials = { ...state.credentials };
|
|
3264
|
+
delete credentials[scope];
|
|
3265
|
+
return { credentials };
|
|
3266
|
+
})
|
|
3267
|
+
}));
|
|
3268
|
+
//#endregion
|
|
3122
3269
|
//#region source/openapi/components/OpenApiOperation.state.ts
|
|
3123
3270
|
function useOperationRequestState(spec, path, operation, source = "path") {
|
|
3124
3271
|
const parameters = getOperationParameters(spec, path, operation, source);
|
|
@@ -3169,9 +3316,13 @@ function useOperationServerState(spec, operation, path, source = "path") {
|
|
|
3169
3316
|
}
|
|
3170
3317
|
function useOperationAuthState(spec, operation) {
|
|
3171
3318
|
const authOptions = getAuthOptions(spec, operation);
|
|
3172
|
-
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.
|
|
3173
|
-
const selectedAuth = authOptions.find((option) => option.
|
|
3174
|
-
const
|
|
3319
|
+
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.key ?? "");
|
|
3320
|
+
const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
|
|
3321
|
+
const credentialScope = getOpenApiCredentialScope(spec);
|
|
3322
|
+
const authValues = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
|
|
3323
|
+
const setCredential = useOpenApiStore((state) => state.setCredential);
|
|
3324
|
+
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
3325
|
+
const clearCredentials = useOpenApiStore((state) => state.clearCredentials);
|
|
3175
3326
|
const [authOpen, setAuthOpen] = useState(false);
|
|
3176
3327
|
return {
|
|
3177
3328
|
authOptions,
|
|
@@ -3179,37 +3330,1277 @@ function useOperationAuthState(spec, operation) {
|
|
|
3179
3330
|
selectedAuth,
|
|
3180
3331
|
authValues,
|
|
3181
3332
|
authOpen,
|
|
3182
|
-
authInput: selectedAuth ? {
|
|
3183
|
-
name:
|
|
3184
|
-
scheme:
|
|
3185
|
-
value: authValues[
|
|
3186
|
-
} : void 0,
|
|
3333
|
+
authInput: selectedAuth ? selectedAuth.schemes.map((option) => ({
|
|
3334
|
+
name: option.name,
|
|
3335
|
+
scheme: option.scheme,
|
|
3336
|
+
value: authValues[option.name] ?? ""
|
|
3337
|
+
})) : void 0,
|
|
3187
3338
|
onSelectAuth: setSelectedAuthName,
|
|
3188
|
-
onChangeAuthValue: (name, value) =>
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
})),
|
|
3339
|
+
onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
|
|
3340
|
+
onClearAuthValue: (name) => clearCredential(credentialScope, name),
|
|
3341
|
+
onClearAuthValues: () => clearCredentials(credentialScope),
|
|
3192
3342
|
onToggleAuth: () => setAuthOpen((current) => !current),
|
|
3193
3343
|
closeAuth: () => setAuthOpen(false)
|
|
3194
3344
|
};
|
|
3195
3345
|
}
|
|
3196
3346
|
//#endregion
|
|
3197
|
-
//#region source/openapi/
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
}
|
|
3206
|
-
function
|
|
3207
|
-
const
|
|
3347
|
+
//#region source/openapi/lib/api-request.ts
|
|
3348
|
+
function parseBodyObject(body) {
|
|
3349
|
+
try {
|
|
3350
|
+
const parsed = JSON.parse(body);
|
|
3351
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
3352
|
+
} catch {
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
function buildRequestBody(body, mediaType) {
|
|
3357
|
+
const values = parseBodyObject(body);
|
|
3358
|
+
if (mediaType.includes("application/x-www-form-urlencoded") && values) {
|
|
3359
|
+
const params = new URLSearchParams();
|
|
3360
|
+
Object.entries(values).forEach(([name, value]) => params.append(name, typeof value === "string" ? value : JSON.stringify(value)));
|
|
3361
|
+
return params;
|
|
3362
|
+
}
|
|
3363
|
+
if (mediaType.includes("multipart/form-data") && values) {
|
|
3364
|
+
const form = new FormData();
|
|
3365
|
+
Object.entries(values).forEach(([name, value]) => form.append(name, typeof value === "string" ? value : JSON.stringify(value)));
|
|
3366
|
+
return form;
|
|
3367
|
+
}
|
|
3368
|
+
return body;
|
|
3369
|
+
}
|
|
3370
|
+
function expandServerUrl(server, variables) {
|
|
3371
|
+
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
3372
|
+
}
|
|
3373
|
+
function authorizationValue(auth) {
|
|
3374
|
+
const scheme = auth.scheme.scheme?.toLowerCase();
|
|
3375
|
+
if (auth.scheme.type === "http" && scheme === "basic") return `Basic ${auth.value}`;
|
|
3376
|
+
if (auth.scheme.type === "http" && scheme === "bearer") return `Bearer ${auth.value}`;
|
|
3377
|
+
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
3378
|
+
}
|
|
3379
|
+
function parameterKey(parameter) {
|
|
3380
|
+
return `${parameter.in ?? "query"}:${parameter.name ?? ""}`;
|
|
3381
|
+
}
|
|
3382
|
+
function parseParameterValue(value) {
|
|
3383
|
+
const trimmed = value.trim();
|
|
3384
|
+
if (!trimmed || !trimmed.startsWith("[") && !trimmed.startsWith("{")) return value;
|
|
3385
|
+
try {
|
|
3386
|
+
return JSON.parse(trimmed);
|
|
3387
|
+
} catch {
|
|
3388
|
+
return value;
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
function primitiveValue(value) {
|
|
3392
|
+
if (typeof value === "string") return value;
|
|
3393
|
+
if (value === null || typeof value === "undefined") return "";
|
|
3394
|
+
return String(value);
|
|
3395
|
+
}
|
|
3396
|
+
function serializedParameterValues(parameter, rawValue) {
|
|
3397
|
+
const value = parseParameterValue(rawValue);
|
|
3398
|
+
const style = parameter.style ?? (parameter.in === "query" || parameter.in === "cookie" ? "form" : "simple");
|
|
3399
|
+
const explode = parameter.explode ?? style === "form";
|
|
3400
|
+
if (Array.isArray(value)) {
|
|
3401
|
+
if (explode) return value.map((item) => [parameter.name ?? "", primitiveValue(item)]);
|
|
3402
|
+
const delimiter = style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",";
|
|
3403
|
+
return [[parameter.name ?? "", value.map(primitiveValue).join(delimiter)]];
|
|
3404
|
+
}
|
|
3405
|
+
if (typeof value === "object" && value !== null) {
|
|
3406
|
+
const entries = Object.entries(value);
|
|
3407
|
+
if (parameter.style === "deepObject") return entries.map(([key, item]) => [`${parameter.name}[${key}]`, primitiveValue(item)]);
|
|
3408
|
+
if (explode) return entries.map(([key, item]) => [key, primitiveValue(item)]);
|
|
3409
|
+
return [[parameter.name ?? "", entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",")]];
|
|
3410
|
+
}
|
|
3411
|
+
return [[parameter.name ?? "", primitiveValue(value)]];
|
|
3412
|
+
}
|
|
3413
|
+
function pathParameterValue(parameter, rawValue) {
|
|
3414
|
+
const value = parseParameterValue(rawValue);
|
|
3415
|
+
const style = parameter.style ?? "simple";
|
|
3416
|
+
const explode = parameter.explode ?? false;
|
|
3417
|
+
const encode = (item) => encodeURIComponent(primitiveValue(item));
|
|
3418
|
+
if (Array.isArray(value)) {
|
|
3419
|
+
if (style === "label") return `.${value.map(encode).join(explode ? "." : ",")}`;
|
|
3420
|
+
if (style === "matrix") return explode ? value.map((item) => `;${parameter.name}=${encode(item)}`).join("") : `;${parameter.name}=${value.map(encode).join(",")}`;
|
|
3421
|
+
return value.map(encode).join(",");
|
|
3422
|
+
}
|
|
3423
|
+
if (typeof value === "object" && value !== null) {
|
|
3424
|
+
const entries = Object.entries(value);
|
|
3425
|
+
if (style === "label") return explode ? `.${entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(".")}` : `.${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
|
|
3426
|
+
if (style === "matrix") return explode ? entries.map(([key, item]) => `;${encode(key)}=${encode(item)}`).join("") : `;${parameter.name}=${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
|
|
3427
|
+
return explode ? entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(",") : entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",");
|
|
3428
|
+
}
|
|
3429
|
+
const encoded = encode(value);
|
|
3430
|
+
if (style === "label") return `.${encoded}`;
|
|
3431
|
+
if (style === "matrix") return `;${parameter.name}=${encoded}`;
|
|
3432
|
+
return encoded;
|
|
3433
|
+
}
|
|
3434
|
+
function headerParameterValue(parameter, rawValue) {
|
|
3435
|
+
const value = parseParameterValue(rawValue);
|
|
3436
|
+
if (Array.isArray(value)) return value.map(primitiveValue).join(",");
|
|
3437
|
+
if (typeof value === "object" && value !== null) {
|
|
3438
|
+
const entries = Object.entries(value);
|
|
3439
|
+
return parameter.explode ? entries.map(([key, item]) => `${key}=${primitiveValue(item)}`).join(",") : entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",");
|
|
3440
|
+
}
|
|
3441
|
+
return primitiveValue(value);
|
|
3442
|
+
}
|
|
3443
|
+
function buildApiRequest(input) {
|
|
3444
|
+
const headers = new Headers({ Accept: "application/json" });
|
|
3445
|
+
const query = new URLSearchParams();
|
|
3446
|
+
let path = input.path;
|
|
3447
|
+
for (const parameter of input.parameters) {
|
|
3448
|
+
if (!parameter.name) continue;
|
|
3449
|
+
const key = parameterKey(parameter);
|
|
3450
|
+
if (input.parameterEnabled?.[key] === false) continue;
|
|
3451
|
+
const value = input.parameterValues[key] ?? "";
|
|
3452
|
+
if (!value && !parameter.allowEmptyValue) continue;
|
|
3453
|
+
if (parameter.in === "path") path = path.replaceAll(`{${parameter.name}}`, pathParameterValue(parameter, value));
|
|
3454
|
+
if (parameter.in === "query") serializedParameterValues(parameter, value).forEach(([name, item]) => query.append(name, item));
|
|
3455
|
+
if (parameter.in === "header") headers.set(parameter.name, headerParameterValue(parameter, value));
|
|
3456
|
+
}
|
|
3457
|
+
for (const auth of input.auth ?? []) {
|
|
3458
|
+
if (!auth.value) continue;
|
|
3459
|
+
if (auth.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) query.set(auth.scheme.name, auth.value);
|
|
3460
|
+
else if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) headers.set(auth.scheme.name, auth.value);
|
|
3461
|
+
else {
|
|
3462
|
+
const authorization = authorizationValue(auth);
|
|
3463
|
+
if (authorization) headers.set("Authorization", authorization);
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
const url = new URL(joinPath(expandServerUrl(input.server, input.serverVariables ?? {}), path), input.baseUrl);
|
|
3467
|
+
query.forEach((value, key) => url.searchParams.append(key, value));
|
|
3468
|
+
const body = input.body?.trim();
|
|
3469
|
+
const mediaType = input.mediaType || "application/json";
|
|
3470
|
+
const requestBody = body && input.method.toUpperCase() !== "GET" && input.method.toUpperCase() !== "HEAD" ? buildRequestBody(body, mediaType) : void 0;
|
|
3471
|
+
if (requestBody && !(requestBody instanceof FormData)) headers.set("Content-Type", mediaType);
|
|
3472
|
+
return {
|
|
3473
|
+
url: url.toString(),
|
|
3474
|
+
init: {
|
|
3475
|
+
method: input.method.toUpperCase(),
|
|
3476
|
+
headers,
|
|
3477
|
+
credentials: "include",
|
|
3478
|
+
...requestBody ? { body: requestBody } : {}
|
|
3479
|
+
}
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
//#endregion
|
|
3483
|
+
//#region source/openapi/components/OpenApiAuthPanel.tsx
|
|
3484
|
+
function OpenApiAuthPanel(arg0) {
|
|
3485
|
+
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue, onClearAuthValue } = arg0;
|
|
3486
|
+
const t = useBuiltInText();
|
|
3487
|
+
if (authOptions.length === 0) return null;
|
|
3488
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3489
|
+
className: "grid divide-y divide-(--clarify-theme-tokens-colors-border)",
|
|
3490
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
3491
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
3492
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3493
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
3494
|
+
children: "Auth"
|
|
3495
|
+
}), /* @__PURE__ */ jsx(InlineListbox, {
|
|
3496
|
+
label: "Auth",
|
|
3497
|
+
value: selectedAuthName,
|
|
3498
|
+
options: authOptions.map((option) => ({
|
|
3499
|
+
value: option.key,
|
|
3500
|
+
label: option.label || t("openapi.none")
|
|
3501
|
+
})),
|
|
3502
|
+
onChange: onSelectAuth
|
|
3503
|
+
})]
|
|
3504
|
+
}), selectedAuth?.schemes.map((option) => /* @__PURE__ */ jsxs("label", {
|
|
3505
|
+
className: "group grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
3506
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3507
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
3508
|
+
children: authLabel(option.name, option.scheme)
|
|
3509
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3510
|
+
className: "flex min-w-0 items-center focus-within:bg-(--clarify-ui-hover-background)",
|
|
3511
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
3512
|
+
type: "password",
|
|
3513
|
+
value: authValues[option.name] ?? "",
|
|
3514
|
+
placeholder: authPlaceholder(option),
|
|
3515
|
+
onChange: (event) => onChangeAuthValue(option.name, event.target.value),
|
|
3516
|
+
autoComplete: "off",
|
|
3517
|
+
className: "h-8 min-w-0 flex-1 border-0 bg-transparent px-2 text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
|
|
3518
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
3519
|
+
type: "button",
|
|
3520
|
+
onClick: () => onClearAuthValue(option.name),
|
|
3521
|
+
className: "mr-1 h-6 shrink-0 rounded-(--clarify-theme-tokens-radius-md) px-1 text-2xs font-medium text-(--clarify-ui-text-faint) opacity-0 transition-opacity hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary) group-hover:opacity-100",
|
|
3522
|
+
children: t("openapi.clear")
|
|
3523
|
+
})]
|
|
3524
|
+
})]
|
|
3525
|
+
}, option.name))]
|
|
3526
|
+
});
|
|
3527
|
+
}
|
|
3528
|
+
//#endregion
|
|
3529
|
+
//#region source/openapi/components/OpenApiRequestFields.tsx
|
|
3530
|
+
function RequestField(arg0) {
|
|
3531
|
+
const { spec, parameter, value, enabled, onChange, onEnabledChange, issue } = arg0;
|
|
3532
|
+
const t = useBuiltInText();
|
|
3533
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
3534
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
3535
|
+
const itemSchema = isRecord$1(schemaRecord?.items) ? schemaRecord.items : void 0;
|
|
3536
|
+
const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
|
|
3537
|
+
const itemOptions = Array.isArray(itemSchema?.enum) ? itemSchema.enum.map(String) : [];
|
|
3538
|
+
const type = schemaToType(schema) ?? "string";
|
|
3539
|
+
const description = parameter.description ?? (typeof schemaRecord?.description === "string" ? schemaRecord.description : void 0);
|
|
3540
|
+
const structured = type.includes("[]") || type.includes("object");
|
|
3541
|
+
const boolean = type.includes("boolean");
|
|
3542
|
+
const numeric = type.includes("integer") || type.includes("number");
|
|
3543
|
+
const fieldId = `openapi-parameter-${parameter.in ?? "query"}-${parameter.name ?? ""}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
3544
|
+
const issueText = issue === "required" ? t("openapi.required") : issue ? t(`openapi.parameter${issue[0].toUpperCase()}${issue.slice(1)}`) : void 0;
|
|
3545
|
+
const controlProps = {
|
|
3546
|
+
"aria-label": parameter.name,
|
|
3547
|
+
"aria-invalid": issue ? true : void 0,
|
|
3548
|
+
"aria-describedby": issue ? `${fieldId}-issue` : void 0,
|
|
3549
|
+
disabled: !enabled
|
|
3550
|
+
};
|
|
3551
|
+
const arrayValue = (() => {
|
|
3552
|
+
try {
|
|
3553
|
+
const parsed = JSON.parse(value);
|
|
3554
|
+
return Array.isArray(parsed) ? parsed.map(String) : [];
|
|
3555
|
+
} catch {
|
|
3556
|
+
return [];
|
|
3557
|
+
}
|
|
3558
|
+
})();
|
|
3559
|
+
const descriptionTip = description ? /* @__PURE__ */ jsxs(Tooltip, {
|
|
3560
|
+
content: /* @__PURE__ */ jsx(Markdown, {
|
|
3561
|
+
className: "max-w-80 text-left *:first:mt-0 *:last:mb-0",
|
|
3562
|
+
children: description
|
|
3563
|
+
}),
|
|
3564
|
+
side: "bottom",
|
|
3565
|
+
className: "mr-1 shrink-0 [&>[role=tooltip]]:w-80 [&>[role=tooltip]]:max-w-[min(20rem,calc(100vw-2rem))] [&>[role=tooltip]]:border [&>[role=tooltip]]:border-(--clarify-theme-tokens-colors-border) [&>[role=tooltip]]:bg-(--clarify-theme-tokens-colors-surface) [&>[role=tooltip]]:p-3 [&>[role=tooltip]]:text-(--clarify-ui-text) [&>[role=tooltip]]:shadow-xl",
|
|
3566
|
+
triggerClassName: "clarify-field-description-trigger clarify-ui-control inline-flex size-7 items-center justify-center rounded-md !border-b-0 text-(--clarify-ui-text-faint) transition-colors",
|
|
3567
|
+
children: [/* @__PURE__ */ jsx(InfoIcon, {
|
|
3568
|
+
className: "size-4",
|
|
3569
|
+
"aria-hidden": "true"
|
|
3570
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
3571
|
+
className: "sr-only",
|
|
3572
|
+
children: t("openapi.fieldDescription")
|
|
3573
|
+
})]
|
|
3574
|
+
}) : null;
|
|
3575
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3576
|
+
className: "group grid min-w-0 grid-cols-[2rem_minmax(0,1fr)] sm:grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)] sm:items-stretch",
|
|
3577
|
+
children: [
|
|
3578
|
+
/* @__PURE__ */ jsx("div", {
|
|
3579
|
+
className: "flex min-h-8 items-center justify-center border-r border-(--clarify-theme-tokens-colors-border)",
|
|
3580
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
3581
|
+
type: "checkbox",
|
|
3582
|
+
checked: enabled,
|
|
3583
|
+
disabled: parameter.required,
|
|
3584
|
+
onChange: (event) => onEnabledChange(event.target.checked),
|
|
3585
|
+
"aria-label": `${t("openapi.includeParameter")}: ${parameter.name ?? ""}`,
|
|
3586
|
+
className: "size-3.5 shrink-0 accent-(--clarify-theme-tokens-colors-primary) disabled:cursor-not-allowed"
|
|
3587
|
+
})
|
|
3588
|
+
}),
|
|
3589
|
+
/* @__PURE__ */ jsx("div", {
|
|
3590
|
+
className: "flex min-h-8 min-w-0 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2",
|
|
3591
|
+
children: /* @__PURE__ */ jsxs("label", {
|
|
3592
|
+
htmlFor: fieldId,
|
|
3593
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-(--clarify-ui-text-strong)",
|
|
3594
|
+
children: [
|
|
3595
|
+
/* @__PURE__ */ jsx("span", {
|
|
3596
|
+
className: "truncate font-mono",
|
|
3597
|
+
children: parameter.name
|
|
3598
|
+
}),
|
|
3599
|
+
/* @__PURE__ */ jsx("span", {
|
|
3600
|
+
className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
|
|
3601
|
+
children: type
|
|
3602
|
+
}),
|
|
3603
|
+
parameter.required ? /* @__PURE__ */ jsx("span", {
|
|
3604
|
+
className: "text-(--clarify-error-accent-text)",
|
|
3605
|
+
children: "*"
|
|
3606
|
+
}) : null
|
|
3607
|
+
]
|
|
3608
|
+
})
|
|
3609
|
+
}),
|
|
3610
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3611
|
+
className: clsx("col-start-2 flex min-w-0 items-center border-t border-(--clarify-theme-tokens-colors-border) sm:col-start-3 sm:row-start-1 sm:border-t-0", !enabled && "opacity-45"),
|
|
3612
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3613
|
+
className: "min-w-0 flex-1",
|
|
3614
|
+
children: itemOptions.length > 0 ? /* @__PURE__ */ jsx(MultiInlineListbox, {
|
|
3615
|
+
label: parameter.name ?? "",
|
|
3616
|
+
value: arrayValue,
|
|
3617
|
+
options: itemOptions.map((option) => ({
|
|
3618
|
+
value: option,
|
|
3619
|
+
label: option
|
|
3620
|
+
})),
|
|
3621
|
+
onChange: (next) => onChange(JSON.stringify(next)),
|
|
3622
|
+
invalid: Boolean(issue),
|
|
3623
|
+
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
3624
|
+
disabled: !enabled
|
|
3625
|
+
}) : options.length > 0 ? /* @__PURE__ */ jsx(InlineListbox, {
|
|
3626
|
+
label: parameter.name ?? "",
|
|
3627
|
+
value,
|
|
3628
|
+
options: [...parameter.required ? [] : [{
|
|
3629
|
+
value: "",
|
|
3630
|
+
label: t("openapi.none")
|
|
3631
|
+
}], ...options.map((option) => ({
|
|
3632
|
+
value: option,
|
|
3633
|
+
label: option
|
|
3634
|
+
}))],
|
|
3635
|
+
onChange,
|
|
3636
|
+
invalid: Boolean(issue),
|
|
3637
|
+
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
3638
|
+
disabled: !enabled
|
|
3639
|
+
}) : boolean ? /* @__PURE__ */ jsx("input", {
|
|
3640
|
+
...controlProps,
|
|
3641
|
+
id: fieldId,
|
|
3642
|
+
type: "checkbox",
|
|
3643
|
+
checked: value === "true",
|
|
3644
|
+
onChange: (event) => onChange(String(event.target.checked)),
|
|
3645
|
+
className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
|
|
3646
|
+
}) : structured ? /* @__PURE__ */ jsx("textarea", {
|
|
3647
|
+
...controlProps,
|
|
3648
|
+
id: fieldId,
|
|
3649
|
+
value,
|
|
3650
|
+
required: parameter.required,
|
|
3651
|
+
onChange: (event) => onChange(event.target.value),
|
|
3652
|
+
rows: 3,
|
|
3653
|
+
spellCheck: false,
|
|
3654
|
+
placeholder: type.includes("[]") ? "[]" : "{}",
|
|
3655
|
+
className: "w-full resize-y border-0 bg-transparent p-2 font-mono text-xs/5 text-(--clarify-theme-tokens-colors-foreground) outline-hidden aria-invalid:text-(--clarify-error-accent-text) focus:bg-(--clarify-ui-hover-background)"
|
|
3656
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
3657
|
+
...controlProps,
|
|
3658
|
+
id: fieldId,
|
|
3659
|
+
value,
|
|
3660
|
+
type: numeric ? "number" : schemaRecord?.format === "date" ? "date" : schemaRecord?.format === "date-time" ? "datetime-local" : "text",
|
|
3661
|
+
required: parameter.required,
|
|
3662
|
+
onChange: (event) => onChange(event.target.value),
|
|
3663
|
+
className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden transition placeholder:text-(--clarify-ui-text-faint) focus:bg-(--clarify-ui-hover-background) aria-invalid:text-(--clarify-error-accent-text)"
|
|
3664
|
+
})
|
|
3665
|
+
}), descriptionTip]
|
|
3666
|
+
}),
|
|
3667
|
+
issueText ? /* @__PURE__ */ jsx("span", {
|
|
3668
|
+
id: `${fieldId}-issue`,
|
|
3669
|
+
className: "col-start-2 border-t border-(--clarify-theme-tokens-colors-border) px-2 py-1 text-xs/5 font-medium text-(--clarify-error-accent-text) sm:col-start-3",
|
|
3670
|
+
children: issueText
|
|
3671
|
+
}) : null
|
|
3672
|
+
]
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
function RequestSection(arg0) {
|
|
3676
|
+
const { title, count, defaultOpen, actions, className, contentClassName, children } = arg0;
|
|
3677
|
+
return /* @__PURE__ */ jsxs("details", {
|
|
3678
|
+
open: defaultOpen,
|
|
3679
|
+
className: clsx("group shrink-0 border-b border-(--clarify-theme-tokens-colors-border)", className),
|
|
3680
|
+
children: [/* @__PURE__ */ jsxs("summary", {
|
|
3681
|
+
className: "flex min-h-11 cursor-pointer list-none items-center gap-2 bg-(--clarify-ui-subtle-background) px-2.5 text-sm font-medium text-(--clarify-ui-text-strong) hover:bg-(--clarify-ui-hover-background) group-open:border-b group-open:border-(--clarify-theme-tokens-colors-border)",
|
|
3682
|
+
children: [
|
|
3683
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3684
|
+
className: "size-4 shrink-0 -rotate-90 transition group-open:rotate-0",
|
|
3685
|
+
"aria-hidden": "true"
|
|
3686
|
+
}),
|
|
3687
|
+
/* @__PURE__ */ jsx("span", {
|
|
3688
|
+
className: "flex-1",
|
|
3689
|
+
children: title
|
|
3690
|
+
}),
|
|
3691
|
+
typeof count === "number" ? /* @__PURE__ */ jsx("span", {
|
|
3692
|
+
className: "font-mono text-xs text-(--clarify-ui-text-faint)",
|
|
3693
|
+
children: count
|
|
3694
|
+
}) : null,
|
|
3695
|
+
actions ? /* @__PURE__ */ jsx("span", {
|
|
3696
|
+
className: "flex items-center gap-1",
|
|
3697
|
+
onClick: (event) => {
|
|
3698
|
+
event.preventDefault();
|
|
3699
|
+
event.stopPropagation();
|
|
3700
|
+
},
|
|
3701
|
+
children: actions
|
|
3702
|
+
}) : null
|
|
3703
|
+
]
|
|
3704
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3705
|
+
className: clsx("divide-y divide-(--clarify-theme-tokens-colors-border)", contentClassName),
|
|
3706
|
+
children
|
|
3707
|
+
})]
|
|
3708
|
+
});
|
|
3709
|
+
}
|
|
3710
|
+
//#endregion
|
|
3711
|
+
//#region source/openapi/components/OpenApiResponseViewer.tsx
|
|
3712
|
+
function formatBytes(size) {
|
|
3713
|
+
if (size < 1024) return `${size} B`;
|
|
3714
|
+
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
|
|
3715
|
+
return `${(size / (1024 * 1024)).toFixed(1)} MB`;
|
|
3716
|
+
}
|
|
3717
|
+
function parseJson(value) {
|
|
3718
|
+
try {
|
|
3719
|
+
return JSON.parse(value);
|
|
3720
|
+
} catch {
|
|
3721
|
+
return;
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
function ResponseState(arg0) {
|
|
3725
|
+
const { icon: Icon, title, description, tone = "default" } = arg0;
|
|
3726
|
+
const error = tone === "error";
|
|
3727
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3728
|
+
className: "grid min-h-56 flex-1 place-items-center px-6 py-10 text-center",
|
|
3729
|
+
role: error ? "alert" : "status",
|
|
3730
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
3731
|
+
className: "max-w-sm",
|
|
3732
|
+
children: [
|
|
3733
|
+
/* @__PURE__ */ jsx("span", {
|
|
3734
|
+
className: clsx("mx-auto mb-3 grid size-10 place-items-center rounded-full border", error ? "border-(--clarify-code-danger-border) bg-(--clarify-code-danger-background) text-(--clarify-code-danger)" : "border-(--clarify-code-border) bg-(--clarify-code-control-background) text-(--clarify-code-muted)"),
|
|
3735
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3736
|
+
className: "size-4.5",
|
|
3737
|
+
"aria-hidden": "true"
|
|
3738
|
+
})
|
|
3739
|
+
}),
|
|
3740
|
+
/* @__PURE__ */ jsx("p", {
|
|
3741
|
+
className: clsx("text-sm font-semibold", error ? "text-(--clarify-code-danger)" : "text-(--clarify-code-text)"),
|
|
3742
|
+
children: title
|
|
3743
|
+
}),
|
|
3744
|
+
/* @__PURE__ */ jsx("p", {
|
|
3745
|
+
className: "mt-1 text-xs/5 text-(--clarify-code-faint)",
|
|
3746
|
+
children: description
|
|
3747
|
+
})
|
|
3748
|
+
]
|
|
3749
|
+
})
|
|
3750
|
+
});
|
|
3751
|
+
}
|
|
3752
|
+
function JsonPreview(arg0) {
|
|
3753
|
+
const { value } = arg0;
|
|
3754
|
+
if (Array.isArray(value)) return /* @__PURE__ */ jsx("div", {
|
|
3755
|
+
className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
|
|
3756
|
+
children: value.map((item, index) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
3757
|
+
className: "mr-2 text-(--clarify-code-faint)",
|
|
3758
|
+
children: index
|
|
3759
|
+
}), /* @__PURE__ */ jsx(JsonPreview, { value: item })] }, index))
|
|
3760
|
+
});
|
|
3761
|
+
if (isRecord$1(value)) return /* @__PURE__ */ jsx("div", {
|
|
3762
|
+
className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
|
|
3763
|
+
children: Object.entries(value).map(([key, item]) => /* @__PURE__ */ jsxs("div", {
|
|
3764
|
+
className: "grid grid-cols-[minmax(5rem,auto)_1fr] gap-3",
|
|
3765
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3766
|
+
className: "text-(--clarify-code-property)",
|
|
3767
|
+
children: key
|
|
3768
|
+
}), /* @__PURE__ */ jsx(JsonPreview, { value: item })]
|
|
3769
|
+
}, key))
|
|
3770
|
+
});
|
|
3771
|
+
if (value === null) return /* @__PURE__ */ jsx("span", {
|
|
3772
|
+
className: "text-(--clarify-code-faint)",
|
|
3773
|
+
children: "null"
|
|
3774
|
+
});
|
|
3775
|
+
if (typeof value === "string") return /* @__PURE__ */ jsx("span", {
|
|
3776
|
+
className: "wrap-break-word text-(--clarify-code-string)",
|
|
3777
|
+
children: value
|
|
3778
|
+
});
|
|
3208
3779
|
return /* @__PURE__ */ jsx("span", {
|
|
3209
|
-
className:
|
|
3210
|
-
children:
|
|
3780
|
+
className: "text-(--clarify-code-number)",
|
|
3781
|
+
children: String(value)
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
function CopyButton(arg0) {
|
|
3785
|
+
const { value } = arg0;
|
|
3786
|
+
const t = useBuiltInText();
|
|
3787
|
+
const [copied, setCopied] = useState(false);
|
|
3788
|
+
async function copy() {
|
|
3789
|
+
const success = await copyTextToClipboard(value);
|
|
3790
|
+
setCopied(success);
|
|
3791
|
+
if (success) window.setTimeout(() => setCopied(false), 1600);
|
|
3792
|
+
}
|
|
3793
|
+
return /* @__PURE__ */ jsx("button", {
|
|
3794
|
+
type: "button",
|
|
3795
|
+
onClick: copy,
|
|
3796
|
+
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
3797
|
+
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
3798
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
3799
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
3800
|
+
className: "size-4 text-(--clarify-code-success)",
|
|
3801
|
+
"aria-hidden": "true"
|
|
3802
|
+
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
3803
|
+
className: "size-4",
|
|
3804
|
+
"aria-hidden": "true"
|
|
3805
|
+
})
|
|
3806
|
+
});
|
|
3807
|
+
}
|
|
3808
|
+
function ResponseMedia(arg0) {
|
|
3809
|
+
const { blob, type } = arg0;
|
|
3810
|
+
const elementRef = useRef(null);
|
|
3811
|
+
useEffect(() => {
|
|
3812
|
+
const element = elementRef.current;
|
|
3813
|
+
if (!element) return;
|
|
3814
|
+
const url = URL.createObjectURL(blob);
|
|
3815
|
+
element.src = url;
|
|
3816
|
+
return () => {
|
|
3817
|
+
element.removeAttribute("src");
|
|
3818
|
+
URL.revokeObjectURL(url);
|
|
3819
|
+
};
|
|
3820
|
+
}, [blob]);
|
|
3821
|
+
if (type === "image") return /* @__PURE__ */ jsx("img", {
|
|
3822
|
+
ref: elementRef,
|
|
3823
|
+
alt: "",
|
|
3824
|
+
className: "max-h-128 max-w-full object-contain"
|
|
3825
|
+
});
|
|
3826
|
+
if (type === "audio") return /* @__PURE__ */ jsx("audio", {
|
|
3827
|
+
ref: elementRef,
|
|
3828
|
+
controls: true,
|
|
3829
|
+
className: "w-full"
|
|
3830
|
+
});
|
|
3831
|
+
return /* @__PURE__ */ jsx("video", {
|
|
3832
|
+
ref: elementRef,
|
|
3833
|
+
controls: true,
|
|
3834
|
+
className: "max-h-128 max-w-full"
|
|
3211
3835
|
});
|
|
3212
3836
|
}
|
|
3837
|
+
function ResponsePreview(arg0) {
|
|
3838
|
+
const { exchange } = arg0;
|
|
3839
|
+
const t = useBuiltInText();
|
|
3840
|
+
const contentType = exchange.contentType.toLowerCase();
|
|
3841
|
+
if (!exchange.size) return /* @__PURE__ */ jsx(ResponseState, {
|
|
3842
|
+
icon: FileX2Icon,
|
|
3843
|
+
title: t("openapi.responseBodyEmptyTitle"),
|
|
3844
|
+
description: t("openapi.responseBodyEmpty")
|
|
3845
|
+
});
|
|
3846
|
+
if (contentType.includes("json")) {
|
|
3847
|
+
const parsed = parseJson(exchange.body);
|
|
3848
|
+
return typeof parsed === "undefined" ? /* @__PURE__ */ jsx("pre", {
|
|
3849
|
+
className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
3850
|
+
children: exchange.body
|
|
3851
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
3852
|
+
className: "overflow-auto font-mono text-xs/5",
|
|
3853
|
+
children: /* @__PURE__ */ jsx(JsonPreview, { value: parsed })
|
|
3854
|
+
});
|
|
3855
|
+
}
|
|
3856
|
+
if (contentType.startsWith("image/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
3857
|
+
blob: exchange.blob,
|
|
3858
|
+
type: "image"
|
|
3859
|
+
});
|
|
3860
|
+
if (contentType.startsWith("audio/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
3861
|
+
blob: exchange.blob,
|
|
3862
|
+
type: "audio"
|
|
3863
|
+
});
|
|
3864
|
+
if (contentType.startsWith("video/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
3865
|
+
blob: exchange.blob,
|
|
3866
|
+
type: "video"
|
|
3867
|
+
});
|
|
3868
|
+
if (contentType.includes("html")) return /* @__PURE__ */ jsx("iframe", {
|
|
3869
|
+
srcDoc: exchange.body,
|
|
3870
|
+
sandbox: "",
|
|
3871
|
+
title: "Response preview",
|
|
3872
|
+
className: "h-96 w-full border-0 bg-white"
|
|
3873
|
+
});
|
|
3874
|
+
if (contentType.startsWith("text/") || contentType.includes("xml") || contentType.includes("yaml")) return /* @__PURE__ */ jsx("pre", {
|
|
3875
|
+
className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
3876
|
+
children: exchange.body
|
|
3877
|
+
});
|
|
3878
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3879
|
+
className: "grid min-h-56 place-items-center text-xs text-(--clarify-code-faint)",
|
|
3880
|
+
children: t("openapi.binaryPreview")
|
|
3881
|
+
});
|
|
3882
|
+
}
|
|
3883
|
+
function ResponseHeaders(arg0) {
|
|
3884
|
+
const { headers: sourceHeaders } = arg0;
|
|
3885
|
+
const t = useBuiltInText();
|
|
3886
|
+
const [query, setQuery] = useState("");
|
|
3887
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
3888
|
+
const headers = normalizedQuery ? sourceHeaders.filter(([name, value]) => `${name} ${value}`.toLowerCase().includes(normalizedQuery)) : sourceHeaders;
|
|
3889
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
3890
|
+
/* @__PURE__ */ jsxs("label", {
|
|
3891
|
+
className: "flex h-9 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-control-background) px-3",
|
|
3892
|
+
children: [
|
|
3893
|
+
/* @__PURE__ */ jsx(SearchIcon, {
|
|
3894
|
+
className: "size-4 shrink-0 text-(--clarify-code-muted)",
|
|
3895
|
+
"aria-hidden": "true"
|
|
3896
|
+
}),
|
|
3897
|
+
/* @__PURE__ */ jsx("span", {
|
|
3898
|
+
className: "sr-only",
|
|
3899
|
+
children: t("openapi.searchHeaders")
|
|
3900
|
+
}),
|
|
3901
|
+
/* @__PURE__ */ jsx("input", {
|
|
3902
|
+
value: query,
|
|
3903
|
+
onChange: (event) => setQuery(event.target.value),
|
|
3904
|
+
placeholder: t("openapi.searchHeaders"),
|
|
3905
|
+
className: "min-w-0 flex-1 bg-transparent text-xs text-(--clarify-code-text) outline-none placeholder:text-(--clarify-code-faint)"
|
|
3906
|
+
})
|
|
3907
|
+
]
|
|
3908
|
+
}),
|
|
3909
|
+
/* @__PURE__ */ jsx("div", {
|
|
3910
|
+
className: "overflow-x-auto",
|
|
3911
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
3912
|
+
className: "w-full min-w-96 table-fixed border-collapse text-left font-mono text-xs/5",
|
|
3913
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
3914
|
+
className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
|
|
3915
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
3916
|
+
/* @__PURE__ */ jsx("th", {
|
|
3917
|
+
className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
|
|
3918
|
+
children: t("openapi.headerName")
|
|
3919
|
+
}),
|
|
3920
|
+
/* @__PURE__ */ jsx("th", {
|
|
3921
|
+
className: "px-3 py-2 font-semibold",
|
|
3922
|
+
children: t("openapi.headerValue")
|
|
3923
|
+
}),
|
|
3924
|
+
/* @__PURE__ */ jsx("th", {
|
|
3925
|
+
className: "w-10",
|
|
3926
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
3927
|
+
className: "sr-only",
|
|
3928
|
+
children: t("actions.copy")
|
|
3929
|
+
})
|
|
3930
|
+
})
|
|
3931
|
+
] })
|
|
3932
|
+
}), /* @__PURE__ */ jsx("tbody", { children: headers.map(([name, value], index) => /* @__PURE__ */ jsxs("tr", {
|
|
3933
|
+
className: "border-t border-(--clarify-code-border) hover:bg-(--clarify-code-control-background)",
|
|
3934
|
+
children: [
|
|
3935
|
+
/* @__PURE__ */ jsx("td", {
|
|
3936
|
+
className: "break-all border-r border-(--clarify-code-border) px-3 py-2 align-top text-(--clarify-code-property)",
|
|
3937
|
+
children: name
|
|
3938
|
+
}),
|
|
3939
|
+
/* @__PURE__ */ jsx("td", {
|
|
3940
|
+
className: "break-all px-3 py-2 align-top text-(--clarify-code-text)",
|
|
3941
|
+
children: value
|
|
3942
|
+
}),
|
|
3943
|
+
/* @__PURE__ */ jsx("td", {
|
|
3944
|
+
className: "pr-1",
|
|
3945
|
+
children: /* @__PURE__ */ jsx(CopyButton, { value: `${name}: ${value}` })
|
|
3946
|
+
})
|
|
3947
|
+
]
|
|
3948
|
+
}, `${name}:${index}`)) })]
|
|
3949
|
+
})
|
|
3950
|
+
}),
|
|
3951
|
+
headers.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
3952
|
+
className: "border-t border-(--clarify-code-border) py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
3953
|
+
children: t("openapi.noHeaders")
|
|
3954
|
+
}) : null
|
|
3955
|
+
] });
|
|
3956
|
+
}
|
|
3957
|
+
function HiddenCookies() {
|
|
3958
|
+
const t = useBuiltInText();
|
|
3959
|
+
return /* @__PURE__ */ jsxs("table", {
|
|
3960
|
+
className: "w-full table-fixed border-collapse text-left text-xs/5",
|
|
3961
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
3962
|
+
className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
|
|
3963
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
3964
|
+
className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
|
|
3965
|
+
children: t("openapi.headerName")
|
|
3966
|
+
}), /* @__PURE__ */ jsx("th", {
|
|
3967
|
+
className: "px-3 py-2 font-semibold",
|
|
3968
|
+
children: t("openapi.headerValue")
|
|
3969
|
+
})] })
|
|
3970
|
+
}), /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx("tr", {
|
|
3971
|
+
className: "border-t border-(--clarify-code-border)",
|
|
3972
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
3973
|
+
colSpan: 2,
|
|
3974
|
+
className: "px-3 py-5 text-center text-(--clarify-code-faint)",
|
|
3975
|
+
children: t("openapi.cookiesBrowserHidden")
|
|
3976
|
+
})
|
|
3977
|
+
}) })]
|
|
3978
|
+
});
|
|
3979
|
+
}
|
|
3980
|
+
function OpenApiResponseViewer(arg0) {
|
|
3981
|
+
const { exchange, error } = arg0;
|
|
3982
|
+
const t = useBuiltInText();
|
|
3983
|
+
const [bodyMode, setBodyMode] = useState("preview");
|
|
3984
|
+
function downloadBody() {
|
|
3985
|
+
if (!exchange) return;
|
|
3986
|
+
const url = URL.createObjectURL(exchange.blob);
|
|
3987
|
+
const anchor = document.createElement("a");
|
|
3988
|
+
anchor.href = url;
|
|
3989
|
+
anchor.download = `response.${exchange.contentType.includes("json") ? "json" : "bin"}`;
|
|
3990
|
+
anchor.click();
|
|
3991
|
+
URL.revokeObjectURL(url);
|
|
3992
|
+
}
|
|
3993
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
3994
|
+
className: "clarify-api-response flex h-full min-h-96 min-w-0 flex-col bg-(--clarify-code-background) text-(--clarify-code-text)",
|
|
3995
|
+
"aria-label": t("openapi.response"),
|
|
3996
|
+
children: [
|
|
3997
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3998
|
+
className: "sticky top-0 z-10 flex min-h-11 flex-wrap items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-2.5 text-sm font-medium",
|
|
3999
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4000
|
+
className: "mr-auto text-(--clarify-code-text)",
|
|
4001
|
+
children: t("openapi.response")
|
|
4002
|
+
}), exchange ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
4003
|
+
/* @__PURE__ */ jsxs("span", {
|
|
4004
|
+
className: "text-xs font-semibold text-(--clarify-code-muted)",
|
|
4005
|
+
children: [exchange.duration, " ms"]
|
|
4006
|
+
}),
|
|
4007
|
+
/* @__PURE__ */ jsx("span", {
|
|
4008
|
+
className: "text-xs text-(--clarify-code-faint)",
|
|
4009
|
+
children: formatBytes(exchange.size)
|
|
4010
|
+
}),
|
|
4011
|
+
/* @__PURE__ */ jsx("span", { className: clsx("size-2 rounded-full", exchange.status < 400 ? "bg-(--clarify-code-success)" : "bg-(--clarify-code-danger)") }),
|
|
4012
|
+
/* @__PURE__ */ jsxs("span", {
|
|
4013
|
+
className: clsx("text-xs font-semibold", exchange.status < 400 ? "text-(--clarify-code-success)" : "text-(--clarify-code-danger)"),
|
|
4014
|
+
children: [
|
|
4015
|
+
exchange.status,
|
|
4016
|
+
" ",
|
|
4017
|
+
exchange.statusText
|
|
4018
|
+
]
|
|
4019
|
+
})
|
|
4020
|
+
] }) : null]
|
|
4021
|
+
}),
|
|
4022
|
+
error ? /* @__PURE__ */ jsx(ResponseState, {
|
|
4023
|
+
icon: CircleAlertIcon,
|
|
4024
|
+
title: t("openapi.responseErrorTitle"),
|
|
4025
|
+
description: error,
|
|
4026
|
+
tone: "error"
|
|
4027
|
+
}) : null,
|
|
4028
|
+
!error && !exchange ? /* @__PURE__ */ jsx(ResponseState, {
|
|
4029
|
+
icon: SendIcon,
|
|
4030
|
+
title: t("openapi.responseEmptyTitle"),
|
|
4031
|
+
description: t("openapi.responseEmpty")
|
|
4032
|
+
}) : null,
|
|
4033
|
+
exchange ? /* @__PURE__ */ jsxs("div", {
|
|
4034
|
+
className: "min-h-0 flex-1 overflow-auto",
|
|
4035
|
+
children: [
|
|
4036
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4037
|
+
title: t("openapi.cookies"),
|
|
4038
|
+
count: 0,
|
|
4039
|
+
children: /* @__PURE__ */ jsx(HiddenCookies, {})
|
|
4040
|
+
}),
|
|
4041
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4042
|
+
title: t("openapi.requestHeaders"),
|
|
4043
|
+
count: exchange.request.headers.length,
|
|
4044
|
+
children: /* @__PURE__ */ jsx(ResponseHeaders, { headers: exchange.request.headers })
|
|
4045
|
+
}),
|
|
4046
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4047
|
+
title: t("openapi.responseHeaders"),
|
|
4048
|
+
count: exchange.headers.length,
|
|
4049
|
+
children: /* @__PURE__ */ jsx(ResponseHeaders, { headers: exchange.headers })
|
|
4050
|
+
}),
|
|
4051
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4052
|
+
title: t("openapi.body"),
|
|
4053
|
+
defaultOpen: true,
|
|
4054
|
+
actions: /* @__PURE__ */ jsx("span", {
|
|
4055
|
+
className: "font-mono text-2xs font-normal text-(--clarify-code-faint)",
|
|
4056
|
+
children: exchange.contentType || t("openapi.unknownContentType")
|
|
4057
|
+
}),
|
|
4058
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
4059
|
+
className: "min-h-72",
|
|
4060
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4061
|
+
className: "flex h-10 items-center justify-between border-b border-(--clarify-code-border) px-3",
|
|
4062
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
4063
|
+
role: "tablist",
|
|
4064
|
+
className: "flex",
|
|
4065
|
+
children: ["preview", "raw"].map((mode) => /* @__PURE__ */ jsx("button", {
|
|
4066
|
+
type: "button",
|
|
4067
|
+
role: "tab",
|
|
4068
|
+
"aria-selected": bodyMode === mode,
|
|
4069
|
+
onClick: () => setBodyMode(mode),
|
|
4070
|
+
className: clsx("border-b-2 px-2.5 py-1 text-2xs font-semibold", bodyMode === mode ? "border-(--clarify-theme-tokens-colors-primary) text-(--clarify-code-text)" : "border-transparent text-(--clarify-code-muted)"),
|
|
4071
|
+
children: mode === "preview" ? t("openapi.preview") : t("openapi.raw")
|
|
4072
|
+
}, mode))
|
|
4073
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
4074
|
+
className: "flex",
|
|
4075
|
+
children: [/* @__PURE__ */ jsx(CopyButton, { value: exchange.body }), /* @__PURE__ */ jsx("button", {
|
|
4076
|
+
type: "button",
|
|
4077
|
+
onClick: downloadBody,
|
|
4078
|
+
"aria-label": t("openapi.downloadBody"),
|
|
4079
|
+
title: t("openapi.downloadBody"),
|
|
4080
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4081
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, {
|
|
4082
|
+
className: "size-4",
|
|
4083
|
+
"aria-hidden": "true"
|
|
4084
|
+
})
|
|
4085
|
+
})]
|
|
4086
|
+
})]
|
|
4087
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4088
|
+
className: "p-4",
|
|
4089
|
+
children: bodyMode === "preview" ? /* @__PURE__ */ jsx(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ jsx("pre", {
|
|
4090
|
+
className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
4091
|
+
children: exchange.body
|
|
4092
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
4093
|
+
className: "py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
4094
|
+
children: t("openapi.responseBodyEmpty")
|
|
4095
|
+
})
|
|
4096
|
+
})]
|
|
4097
|
+
})
|
|
4098
|
+
})
|
|
4099
|
+
]
|
|
4100
|
+
}) : null
|
|
4101
|
+
]
|
|
4102
|
+
});
|
|
4103
|
+
}
|
|
4104
|
+
//#endregion
|
|
4105
|
+
//#region source/openapi/components/SendRequestButton.tsx
|
|
4106
|
+
function SendRequestButton(arg0) {
|
|
4107
|
+
const { label, busy = false, text, onClick } = arg0;
|
|
4108
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
4109
|
+
type: "button",
|
|
4110
|
+
disabled: busy,
|
|
4111
|
+
"aria-label": label,
|
|
4112
|
+
title: label,
|
|
4113
|
+
onClick,
|
|
4114
|
+
className: Boolean(text) ? "flex h-8 shrink-0 items-center gap-1.5 rounded bg-(--clarify-theme-tokens-colors-foreground) px-3 text-xs font-semibold text-(--clarify-theme-tokens-colors-background) transition hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60" : "grid size-7 shrink-0 place-items-center rounded bg-(--clarify-ui-accent-background) text-(--clarify-ui-accent-text) ring-1 ring-inset ring-(--clarify-ui-accent-border) transition-colors hover:bg-(--clarify-theme-tokens-colors-foreground) hover:text-(--clarify-theme-tokens-colors-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60",
|
|
4115
|
+
children: [busy ? /* @__PURE__ */ jsx(LoaderCircleIcon, {
|
|
4116
|
+
className: "size-4 animate-spin",
|
|
4117
|
+
"aria-hidden": "true"
|
|
4118
|
+
}) : /* @__PURE__ */ jsx(SendIcon, {
|
|
4119
|
+
className: "size-4",
|
|
4120
|
+
"aria-hidden": "true"
|
|
4121
|
+
}), text]
|
|
4122
|
+
});
|
|
4123
|
+
}
|
|
4124
|
+
//#endregion
|
|
4125
|
+
//#region source/openapi/lib/api-exchange.ts
|
|
4126
|
+
var ApiRequestError = class extends Error {
|
|
4127
|
+
category;
|
|
4128
|
+
constructor(message, options) {
|
|
4129
|
+
super(message, options);
|
|
4130
|
+
this.name = "ApiRequestError";
|
|
4131
|
+
this.category = "network";
|
|
4132
|
+
}
|
|
4133
|
+
};
|
|
4134
|
+
function requestBodySnapshot(body) {
|
|
4135
|
+
if (typeof body === "string") return body;
|
|
4136
|
+
if (body instanceof URLSearchParams) return body.toString();
|
|
4137
|
+
}
|
|
4138
|
+
function requestSnapshot(request) {
|
|
4139
|
+
return {
|
|
4140
|
+
url: request.url,
|
|
4141
|
+
method: request.init.method ?? "GET",
|
|
4142
|
+
headers: Array.from(new Headers(request.init.headers).entries()),
|
|
4143
|
+
body: requestBodySnapshot(request.init.body)
|
|
4144
|
+
};
|
|
4145
|
+
}
|
|
4146
|
+
async function executeApiRequest(request, options = {}) {
|
|
4147
|
+
const fetchRequest = options.fetch ?? fetch;
|
|
4148
|
+
const now = options.now ?? (() => performance.now());
|
|
4149
|
+
const startedAt = now();
|
|
4150
|
+
let response;
|
|
4151
|
+
try {
|
|
4152
|
+
response = await fetchRequest(request.url, {
|
|
4153
|
+
...request.init,
|
|
4154
|
+
signal: options.signal
|
|
4155
|
+
});
|
|
4156
|
+
} catch (cause) {
|
|
4157
|
+
if (cause instanceof DOMException && cause.name === "AbortError") throw cause;
|
|
4158
|
+
throw new ApiRequestError(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
4159
|
+
}
|
|
4160
|
+
const blob = await response.blob();
|
|
4161
|
+
return {
|
|
4162
|
+
request: requestSnapshot(request),
|
|
4163
|
+
status: response.status,
|
|
4164
|
+
statusText: response.statusText,
|
|
4165
|
+
url: response.url || request.url,
|
|
4166
|
+
redirected: response.redirected,
|
|
4167
|
+
duration: Math.round(now() - startedAt),
|
|
4168
|
+
size: blob.size,
|
|
4169
|
+
headers: Array.from(response.headers.entries()),
|
|
4170
|
+
contentType: response.headers.get("content-type") ?? blob.type,
|
|
4171
|
+
body: await blob.text(),
|
|
4172
|
+
blob
|
|
4173
|
+
};
|
|
4174
|
+
}
|
|
4175
|
+
//#endregion
|
|
4176
|
+
//#region source/openapi/lib/request-parameters.ts
|
|
4177
|
+
function structuredIssue(value, type) {
|
|
4178
|
+
if (!type.includes("[]") && !type.includes("object")) return void 0;
|
|
4179
|
+
try {
|
|
4180
|
+
const parsed = JSON.parse(value);
|
|
4181
|
+
if (type.includes("[]") && !Array.isArray(parsed)) return "invalidArray";
|
|
4182
|
+
if (type.includes("object") && !isRecord$1(parsed)) return "invalidObject";
|
|
4183
|
+
} catch {
|
|
4184
|
+
return type.includes("[]") ? "invalidArray" : "invalidObject";
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
function scalarIssue(value, type, format) {
|
|
4188
|
+
if (type.includes("integer") && !Number.isInteger(Number(value))) return "invalidInteger";
|
|
4189
|
+
if (type.includes("number") && !Number.isFinite(Number(value))) return "invalidNumber";
|
|
4190
|
+
if (format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return "invalidDate";
|
|
4191
|
+
if (format === "date-time" && Number.isNaN(Date.parse(value))) return "invalidDateTime";
|
|
4192
|
+
}
|
|
4193
|
+
function validateRequestParameter(spec, parameter, value) {
|
|
4194
|
+
if (!value) return parameter.required ? "required" : void 0;
|
|
4195
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
4196
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
4197
|
+
const type = schemaToType(schema) ?? "string";
|
|
4198
|
+
const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
|
|
4199
|
+
if (options.length > 0 && !options.includes(value)) return "invalidEnum";
|
|
4200
|
+
return structuredIssue(value, type) ?? scalarIssue(value, type, schemaRecord?.format);
|
|
4201
|
+
}
|
|
4202
|
+
function validateRequestParameters(spec, parameters, values) {
|
|
4203
|
+
return Object.fromEntries(parameters.filter((parameter) => parameter.in !== "cookie").flatMap((parameter) => {
|
|
4204
|
+
const key = parameterKey(parameter);
|
|
4205
|
+
const issue = validateRequestParameter(spec, parameter, values[key] ?? "");
|
|
4206
|
+
return issue ? [[key, issue]] : [];
|
|
4207
|
+
}));
|
|
4208
|
+
}
|
|
4209
|
+
//#endregion
|
|
4210
|
+
//#region source/openapi/components/useOpenApiRequestState.ts
|
|
4211
|
+
function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
4212
|
+
const servers = getServers(spec, operation, path, operationSource);
|
|
4213
|
+
const [selectedServerKey, setSelectedServerKey] = useState(getServerKey(servers[0], 0));
|
|
4214
|
+
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
4215
|
+
const [serverVariables, setServerVariables] = useState(defaultServerVariables(selectedServer));
|
|
4216
|
+
const authOptions = getAuthOptions(spec, operation);
|
|
4217
|
+
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.key ?? "");
|
|
4218
|
+
const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
|
|
4219
|
+
const credentialScope = getOpenApiCredentialScope(spec);
|
|
4220
|
+
const credentials = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
|
|
4221
|
+
const setCredential = useOpenApiStore((state) => state.setCredential);
|
|
4222
|
+
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
4223
|
+
const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
|
|
4224
|
+
const [mediaType, setMediaType] = useState(requestContents[0]?.mediaType ?? "");
|
|
4225
|
+
const [body, setBody] = useState(stringifyExample(getExampleEntries((requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0])?.value, spec)[0]?.value));
|
|
4226
|
+
function selectServer(value) {
|
|
4227
|
+
const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
|
|
4228
|
+
setSelectedServerKey(value);
|
|
4229
|
+
setServerVariables(defaultServerVariables(nextServer));
|
|
4230
|
+
}
|
|
4231
|
+
function selectMediaType(value) {
|
|
4232
|
+
const content = requestContents.find((entry) => entry.mediaType === value)?.value;
|
|
4233
|
+
setMediaType(value);
|
|
4234
|
+
setBody(stringifyExample(getExampleEntries(content, spec)[0]?.value));
|
|
4235
|
+
}
|
|
4236
|
+
return {
|
|
4237
|
+
servers,
|
|
4238
|
+
selectedServer,
|
|
4239
|
+
selectedServerKey,
|
|
4240
|
+
serverVariables,
|
|
4241
|
+
setServerVariables,
|
|
4242
|
+
serverVariableEntries: Object.entries(selectedServer.variables ?? {}),
|
|
4243
|
+
selectServer,
|
|
4244
|
+
authOptions,
|
|
4245
|
+
selectedAuthName,
|
|
4246
|
+
setSelectedAuthName,
|
|
4247
|
+
selectedAuth,
|
|
4248
|
+
credentialScope,
|
|
4249
|
+
credentials,
|
|
4250
|
+
setCredential,
|
|
4251
|
+
clearCredential,
|
|
4252
|
+
requestContents,
|
|
4253
|
+
mediaType,
|
|
4254
|
+
body,
|
|
4255
|
+
setBody,
|
|
4256
|
+
selectMediaType
|
|
4257
|
+
};
|
|
4258
|
+
}
|
|
4259
|
+
function useOpenApiParameterState(spec, parameters, initialParameterValue) {
|
|
4260
|
+
const [parameterValues, setParameterValues] = useState(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), initialParameterValue(parameter)])));
|
|
4261
|
+
const [parameterEnabled, setParameterEnabled] = useState(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), true])));
|
|
4262
|
+
const [parameterIssues, setParameterIssues] = useState({});
|
|
4263
|
+
function setParameterGroupValues(grouped, mode) {
|
|
4264
|
+
const keys = new Set(grouped.map(parameterKey));
|
|
4265
|
+
setParameterValues((current) => ({
|
|
4266
|
+
...current,
|
|
4267
|
+
...Object.fromEntries(grouped.map((parameter) => [parameterKey(parameter), mode === "reset" ? initialParameterValue(parameter) : ""]))
|
|
4268
|
+
}));
|
|
4269
|
+
setParameterIssues((current) => Object.fromEntries(Object.entries(current).filter(([key]) => !keys.has(key))));
|
|
4270
|
+
}
|
|
4271
|
+
function setParameterIncluded(parameter, enabled) {
|
|
4272
|
+
const key = parameterKey(parameter);
|
|
4273
|
+
setParameterEnabled((current) => ({
|
|
4274
|
+
...current,
|
|
4275
|
+
[key]: enabled
|
|
4276
|
+
}));
|
|
4277
|
+
if (!enabled) setParameterIssues((current) => {
|
|
4278
|
+
const next = { ...current };
|
|
4279
|
+
delete next[key];
|
|
4280
|
+
return next;
|
|
4281
|
+
});
|
|
4282
|
+
}
|
|
4283
|
+
function updateParameterValue(parameter, value) {
|
|
4284
|
+
const key = parameterKey(parameter);
|
|
4285
|
+
setParameterValues((current) => ({
|
|
4286
|
+
...current,
|
|
4287
|
+
[key]: value
|
|
4288
|
+
}));
|
|
4289
|
+
setParameterIssues((current) => {
|
|
4290
|
+
const next = { ...current };
|
|
4291
|
+
delete next[key];
|
|
4292
|
+
return next;
|
|
4293
|
+
});
|
|
4294
|
+
}
|
|
4295
|
+
function validate(parametersToValidate) {
|
|
4296
|
+
const issues = validateRequestParameters(spec, parametersToValidate, parameterValues);
|
|
4297
|
+
setParameterIssues(issues);
|
|
4298
|
+
return issues;
|
|
4299
|
+
}
|
|
4300
|
+
return {
|
|
4301
|
+
parameterValues,
|
|
4302
|
+
parameterEnabled,
|
|
4303
|
+
parameterIssues,
|
|
4304
|
+
setParameterGroupValues,
|
|
4305
|
+
setParameterIncluded,
|
|
4306
|
+
updateParameterValue,
|
|
4307
|
+
validate
|
|
4308
|
+
};
|
|
4309
|
+
}
|
|
4310
|
+
function useOpenApiRequestExecution() {
|
|
4311
|
+
const [exchange, setExchange] = useState();
|
|
4312
|
+
const [error, setError] = useState("");
|
|
4313
|
+
const [sending, setSending] = useState(false);
|
|
4314
|
+
const requestController = useRef(null);
|
|
4315
|
+
useEffect(() => () => requestController.current?.abort(), []);
|
|
4316
|
+
async function execute(request, corsHint) {
|
|
4317
|
+
requestController.current?.abort();
|
|
4318
|
+
const controller = new AbortController();
|
|
4319
|
+
requestController.current = controller;
|
|
4320
|
+
setSending(true);
|
|
4321
|
+
setError("");
|
|
4322
|
+
setExchange(void 0);
|
|
4323
|
+
try {
|
|
4324
|
+
setExchange(await executeApiRequest(request, { signal: controller.signal }));
|
|
4325
|
+
} catch (cause) {
|
|
4326
|
+
if (cause instanceof DOMException && cause.name === "AbortError") return;
|
|
4327
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
4328
|
+
setError(`${message}. ${corsHint}`);
|
|
4329
|
+
} finally {
|
|
4330
|
+
if (requestController.current === controller) {
|
|
4331
|
+
requestController.current = null;
|
|
4332
|
+
setSending(false);
|
|
4333
|
+
}
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
return {
|
|
4337
|
+
exchange,
|
|
4338
|
+
error,
|
|
4339
|
+
sending,
|
|
4340
|
+
execute
|
|
4341
|
+
};
|
|
4342
|
+
}
|
|
4343
|
+
//#endregion
|
|
4344
|
+
//#region source/openapi/components/OpenApiRequest.tsx
|
|
4345
|
+
function initialParameterValue(spec, parameter) {
|
|
4346
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
4347
|
+
if (!isRecord$1(schema)) return "";
|
|
4348
|
+
return stringifyExample(schema.example ?? schema.default ?? (Array.isArray(schema.enum) ? schema.enum[0] : void 0));
|
|
4349
|
+
}
|
|
4350
|
+
function parameterGroupLabel(location, t) {
|
|
4351
|
+
if (location === "path") return t("openapi.pathParameters");
|
|
4352
|
+
if (location === "header") return t("openapi.headers");
|
|
4353
|
+
if (location === "cookie") return t("openapi.cookies");
|
|
4354
|
+
return t("openapi.queryParameters");
|
|
4355
|
+
}
|
|
4356
|
+
function OpenApiRequestWorkbench(arg0) {
|
|
4357
|
+
const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
|
|
4358
|
+
const t = useBuiltInText();
|
|
4359
|
+
const parameters = getOperationParameters(spec, path, operation, operationSource);
|
|
4360
|
+
const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, body, setBody, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource);
|
|
4361
|
+
const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter));
|
|
4362
|
+
const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue } = parameterState;
|
|
4363
|
+
const { exchange, error, sending, execute } = useOpenApiRequestExecution();
|
|
4364
|
+
const parameterGroups = [
|
|
4365
|
+
"cookie",
|
|
4366
|
+
"header",
|
|
4367
|
+
"query"
|
|
4368
|
+
].map((location) => ({
|
|
4369
|
+
location,
|
|
4370
|
+
parameters: parameters.filter((parameter) => parameter.in === location)
|
|
4371
|
+
})).filter((group) => group.parameters.length > 0);
|
|
4372
|
+
const pathParameters = parameters.filter((parameter) => parameter.in === "path");
|
|
4373
|
+
const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
|
|
4374
|
+
async function sendRequest() {
|
|
4375
|
+
const enabledParameters = parameters.filter((parameter) => parameterEnabled[parameterKey(parameter)] !== false);
|
|
4376
|
+
const issues = parameterState.validate(enabledParameters);
|
|
4377
|
+
if (Object.keys(issues).length > 0) return;
|
|
4378
|
+
await execute(buildApiRequest({
|
|
4379
|
+
method,
|
|
4380
|
+
path,
|
|
4381
|
+
server: selectedServer,
|
|
4382
|
+
serverVariables,
|
|
4383
|
+
parameters,
|
|
4384
|
+
parameterValues,
|
|
4385
|
+
parameterEnabled,
|
|
4386
|
+
auth: selectedAuth?.schemes.map((option) => ({
|
|
4387
|
+
scheme: option.scheme,
|
|
4388
|
+
value: credentials[option.name] ?? ""
|
|
4389
|
+
})),
|
|
4390
|
+
mediaType,
|
|
4391
|
+
body,
|
|
4392
|
+
baseUrl: window.location.href
|
|
4393
|
+
}), t("openapi.requestCorsHint"));
|
|
4394
|
+
}
|
|
4395
|
+
function renderParameterField(parameter) {
|
|
4396
|
+
const key = parameterKey(parameter);
|
|
4397
|
+
return /* @__PURE__ */ jsx(RequestField, {
|
|
4398
|
+
spec,
|
|
4399
|
+
parameter,
|
|
4400
|
+
value: parameterValues[key] ?? "",
|
|
4401
|
+
enabled: parameterEnabled[key] !== false,
|
|
4402
|
+
issue: parameterIssues[key],
|
|
4403
|
+
onEnabledChange: (enabled) => setParameterIncluded(parameter, enabled),
|
|
4404
|
+
onChange: (value) => updateParameterValue(parameter, value)
|
|
4405
|
+
}, key);
|
|
4406
|
+
}
|
|
4407
|
+
function renderParameterGroup(group) {
|
|
4408
|
+
const { location, parameters: grouped } = group;
|
|
4409
|
+
const actions = location === "cookie" ? void 0 : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
4410
|
+
type: "button",
|
|
4411
|
+
title: t("openapi.resetToExample"),
|
|
4412
|
+
"aria-label": t("openapi.resetToExample"),
|
|
4413
|
+
onClick: () => setParameterGroupValues(grouped, "reset"),
|
|
4414
|
+
className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4415
|
+
children: /* @__PURE__ */ jsx(RotateCcwIcon, {
|
|
4416
|
+
className: "size-3.5",
|
|
4417
|
+
"aria-hidden": "true"
|
|
4418
|
+
})
|
|
4419
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
4420
|
+
type: "button",
|
|
4421
|
+
title: t("openapi.clear"),
|
|
4422
|
+
"aria-label": t("openapi.clear"),
|
|
4423
|
+
onClick: () => setParameterGroupValues(grouped, "clear"),
|
|
4424
|
+
className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4425
|
+
children: /* @__PURE__ */ jsx(EraserIcon, {
|
|
4426
|
+
className: "size-3.5",
|
|
4427
|
+
"aria-hidden": "true"
|
|
4428
|
+
})
|
|
4429
|
+
})] });
|
|
4430
|
+
return /* @__PURE__ */ jsx(RequestSection, {
|
|
4431
|
+
title: parameterGroupLabel(location, t),
|
|
4432
|
+
count: grouped.length,
|
|
4433
|
+
defaultOpen: true,
|
|
4434
|
+
actions,
|
|
4435
|
+
children: location === "cookie" ? /* @__PURE__ */ jsx("p", {
|
|
4436
|
+
className: "px-3 py-4 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
4437
|
+
children: t("openapi.cookieParametersBrowserManaged")
|
|
4438
|
+
}) : grouped.map(renderParameterField)
|
|
4439
|
+
}, location);
|
|
4440
|
+
}
|
|
4441
|
+
function renderHeader() {
|
|
4442
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4443
|
+
className: "flex min-w-0 items-center gap-1.5 border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-2",
|
|
4444
|
+
children: [
|
|
4445
|
+
/* @__PURE__ */ jsx(EndpointMethodBadge, { method: method.toUpperCase() }),
|
|
4446
|
+
servers.length > 0 ? /* @__PURE__ */ jsx(InlineListbox, {
|
|
4447
|
+
label: t("openapi.server"),
|
|
4448
|
+
value: selectedServerKey,
|
|
4449
|
+
options: servers.map((server, index) => ({
|
|
4450
|
+
value: getServerKey(server, index),
|
|
4451
|
+
label: server.url ?? `Server ${index + 1}`,
|
|
4452
|
+
description: server.description
|
|
4453
|
+
})),
|
|
4454
|
+
onChange: selectServer,
|
|
4455
|
+
className: "min-w-0 max-w-48 shrink sm:max-w-48",
|
|
4456
|
+
buttonClassName: "flex h-8 min-w-0 max-w-full items-center gap-1 rounded-(--clarify-theme-tokens-radius-md) px-2 text-xs font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)"
|
|
4457
|
+
}) : null,
|
|
4458
|
+
/* @__PURE__ */ jsx("span", {
|
|
4459
|
+
className: "min-w-0 flex-1 overflow-x-auto border-l border-(--clarify-theme-tokens-colors-border) pl-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground)",
|
|
4460
|
+
children: path || "/"
|
|
4461
|
+
}),
|
|
4462
|
+
/* @__PURE__ */ jsx(SendRequestButton, {
|
|
4463
|
+
label: sending ? t("openapi.sendingRequest") : t("openapi.sendRequest"),
|
|
4464
|
+
busy: sending,
|
|
4465
|
+
text: t("openapi.sendRequest"),
|
|
4466
|
+
onClick: sendRequest
|
|
4467
|
+
}),
|
|
4468
|
+
onClose ? /* @__PURE__ */ jsx("button", {
|
|
4469
|
+
type: "button",
|
|
4470
|
+
onClick: onClose,
|
|
4471
|
+
"aria-label": t("openapi.closeRequest"),
|
|
4472
|
+
title: t("openapi.closeRequest"),
|
|
4473
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4474
|
+
children: /* @__PURE__ */ jsx(XIcon, {
|
|
4475
|
+
className: "size-4",
|
|
4476
|
+
"aria-hidden": "true"
|
|
4477
|
+
})
|
|
4478
|
+
}) : null
|
|
4479
|
+
]
|
|
4480
|
+
});
|
|
4481
|
+
}
|
|
4482
|
+
function renderVariables() {
|
|
4483
|
+
if (serverVariableEntries.length === 0) return null;
|
|
4484
|
+
return /* @__PURE__ */ jsx(RequestSection, {
|
|
4485
|
+
title: t("openapi.variables"),
|
|
4486
|
+
count: serverVariableEntries.length,
|
|
4487
|
+
defaultOpen: true,
|
|
4488
|
+
children: serverVariableEntries.map(([name, variable]) => /* @__PURE__ */ jsxs("label", {
|
|
4489
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
4490
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4491
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
4492
|
+
children: name
|
|
4493
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
4494
|
+
value: serverVariables[name] ?? variable.default ?? "",
|
|
4495
|
+
onChange: (event) => setServerVariables((current) => ({
|
|
4496
|
+
...current,
|
|
4497
|
+
[name]: event.target.value
|
|
4498
|
+
})),
|
|
4499
|
+
className: "h-8 min-w-0 border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background) focus:ring-0"
|
|
4500
|
+
})]
|
|
4501
|
+
}, name))
|
|
4502
|
+
});
|
|
4503
|
+
}
|
|
4504
|
+
function renderRequestBody() {
|
|
4505
|
+
if (requestContents.length === 0) return null;
|
|
4506
|
+
return /* @__PURE__ */ jsxs(RequestSection, {
|
|
4507
|
+
title: t("openapi.requestBody"),
|
|
4508
|
+
count: 1,
|
|
4509
|
+
defaultOpen: true,
|
|
4510
|
+
className: "open:grid open:min-h-55 open:grow open:shrink open:basis-55 open:grid-rows-[auto_minmax(11rem,1fr)]",
|
|
4511
|
+
contentClassName: clsx("grid h-full min-h-0", requestContents.length > 1 ? "grid-rows-[auto_minmax(11rem,1fr)]" : "grid-rows-[minmax(11rem,1fr)]"),
|
|
4512
|
+
children: [requestContents.length > 1 ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(InlineListbox, {
|
|
4513
|
+
label: t("openapi.mediaType"),
|
|
4514
|
+
value: mediaType,
|
|
4515
|
+
options: requestContents.map((entry) => ({
|
|
4516
|
+
value: entry.mediaType,
|
|
4517
|
+
label: entry.mediaType
|
|
4518
|
+
})),
|
|
4519
|
+
onChange: selectMediaType
|
|
4520
|
+
}) }) : null, /* @__PURE__ */ jsx("textarea", {
|
|
4521
|
+
"aria-label": t("openapi.requestBody"),
|
|
4522
|
+
value: body,
|
|
4523
|
+
onChange: (event) => setBody(event.target.value),
|
|
4524
|
+
spellCheck: false,
|
|
4525
|
+
className: "block h-full min-h-44 w-full resize-none border-0 bg-(--clarify-code-background) p-3 font-mono text-xs/5 text-(--clarify-code-text) outline-hidden focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary)"
|
|
4526
|
+
})]
|
|
4527
|
+
});
|
|
4528
|
+
}
|
|
4529
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4530
|
+
className: clsx("clarify-api-request flex min-h-0 min-w-0 flex-col not-prose bg-(--clarify-theme-tokens-colors-surface) [--clarify-theme-tokens-radius-lg:6px] [--clarify-theme-tokens-radius-md:4px] [--clarify-theme-tokens-radius-sm:2px] [--clarify-theme-tokens-radius-xl:8px] [--clarify-ui-accent-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_10%,transparent)] [--clarify-ui-accent-border:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_22%,transparent)] [--clarify-ui-accent-text:var(--clarify-theme-tokens-colors-foreground)] [--clarify-ui-active-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_12%,transparent)] [--clarify-ui-subtle-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_5%,transparent)]", compact ? "h-full" : "my-6"),
|
|
4531
|
+
children: [renderHeader(), /* @__PURE__ */ jsxs("div", {
|
|
4532
|
+
className: "grid min-h-0 flex-1 gap-0 px-0 lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]",
|
|
4533
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4534
|
+
className: "flex min-h-0 min-w-0 flex-col overflow-y-auto",
|
|
4535
|
+
children: [
|
|
4536
|
+
authOptions.length > 0 ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4537
|
+
title: t("openapi.authentication"),
|
|
4538
|
+
count: selectedAuth?.schemes.length ?? 0,
|
|
4539
|
+
defaultOpen: true,
|
|
4540
|
+
children: /* @__PURE__ */ jsx(OpenApiAuthPanel, {
|
|
4541
|
+
authOptions,
|
|
4542
|
+
selectedAuthName,
|
|
4543
|
+
selectedAuth,
|
|
4544
|
+
authValues: credentials,
|
|
4545
|
+
onSelectAuth: setSelectedAuthName,
|
|
4546
|
+
onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
|
|
4547
|
+
onClearAuthValue: (name) => clearCredential(credentialScope, name)
|
|
4548
|
+
})
|
|
4549
|
+
}) : null,
|
|
4550
|
+
renderVariables(),
|
|
4551
|
+
pathParameters.length > 0 ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4552
|
+
title: t("openapi.pathParameters"),
|
|
4553
|
+
count: pathParameters.length,
|
|
4554
|
+
defaultOpen: true,
|
|
4555
|
+
children: pathParameters.map(renderParameterField)
|
|
4556
|
+
}) : null,
|
|
4557
|
+
parameterGroups.map(renderParameterGroup),
|
|
4558
|
+
renderRequestBody(),
|
|
4559
|
+
!hasRequestConfiguration ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4560
|
+
title: t("openapi.requestConfiguration"),
|
|
4561
|
+
count: 0,
|
|
4562
|
+
defaultOpen: true,
|
|
4563
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
4564
|
+
className: "px-3 py-5 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
4565
|
+
children: t("openapi.noRequestConfiguration")
|
|
4566
|
+
})
|
|
4567
|
+
}) : null
|
|
4568
|
+
]
|
|
4569
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4570
|
+
className: "h-full min-h-0 min-w-0 overflow-hidden border-t border-(--clarify-theme-tokens-colors-border) lg:border-t-0 lg:border-l",
|
|
4571
|
+
children: /* @__PURE__ */ jsx(OpenApiResponseViewer, {
|
|
4572
|
+
exchange,
|
|
4573
|
+
error
|
|
4574
|
+
})
|
|
4575
|
+
})]
|
|
4576
|
+
})]
|
|
4577
|
+
});
|
|
4578
|
+
}
|
|
4579
|
+
function OpenApiRequestDialog(arg0) {
|
|
4580
|
+
const { open, onClose, ...workbenchProps } = arg0;
|
|
4581
|
+
const t = useBuiltInText();
|
|
4582
|
+
return /* @__PURE__ */ jsxs(Dialog, {
|
|
4583
|
+
open,
|
|
4584
|
+
onClose: () => {},
|
|
4585
|
+
className: "relative z-50",
|
|
4586
|
+
children: [/* @__PURE__ */ jsx(DialogBackdrop, { className: "fixed inset-0 bg-(--clarify-ui-overlay-background) backdrop-blur-sm" }), /* @__PURE__ */ jsx("div", {
|
|
4587
|
+
className: "fixed inset-0 grid place-items-center overflow-y-auto p-3 sm:p-6",
|
|
4588
|
+
children: /* @__PURE__ */ jsxs(DialogPanel, {
|
|
4589
|
+
className: "relative flex h-[min(46rem,calc(100dvh-1.5rem))] w-full max-w-7xl flex-col overflow-hidden rounded-lg border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) shadow-2xl sm:h-[min(46rem,calc(100dvh-3rem))]",
|
|
4590
|
+
children: [/* @__PURE__ */ jsx(DialogTitle, {
|
|
4591
|
+
className: "sr-only",
|
|
4592
|
+
children: t("openapi.tryRequest")
|
|
4593
|
+
}), /* @__PURE__ */ jsx(OpenApiRequestWorkbench, {
|
|
4594
|
+
...workbenchProps,
|
|
4595
|
+
compact: true,
|
|
4596
|
+
onClose
|
|
4597
|
+
})]
|
|
4598
|
+
})
|
|
4599
|
+
})]
|
|
4600
|
+
});
|
|
4601
|
+
}
|
|
4602
|
+
//#endregion
|
|
4603
|
+
//#region source/openapi/components/OpenApiOperation.tsx
|
|
3213
4604
|
function EndpointPath(arg0) {
|
|
3214
4605
|
const { path, copied = false, onCopy } = arg0;
|
|
3215
4606
|
const t = useBuiltInText();
|
|
@@ -3409,51 +4800,9 @@ function ServerPanel(arg0) {
|
|
|
3409
4800
|
})
|
|
3410
4801
|
});
|
|
3411
4802
|
}
|
|
3412
|
-
function AuthPanel(arg0) {
|
|
3413
|
-
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3414
|
-
if (authOptions.length === 0) return null;
|
|
3415
|
-
return /* @__PURE__ */ jsx("div", {
|
|
3416
|
-
className: "border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background) p-3",
|
|
3417
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
3418
|
-
className: "grid gap-3 sm:grid-cols-(--clarify-openapi-control-grid)",
|
|
3419
|
-
children: [/* @__PURE__ */ jsxs("label", {
|
|
3420
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
3421
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3422
|
-
className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3423
|
-
children: "Auth"
|
|
3424
|
-
}), /* @__PURE__ */ jsx(InlineListbox, {
|
|
3425
|
-
label: "Auth",
|
|
3426
|
-
value: selectedAuthName,
|
|
3427
|
-
options: authOptions.map(({ name, scheme }) => ({
|
|
3428
|
-
value: name,
|
|
3429
|
-
label: name,
|
|
3430
|
-
description: authLabel(name, scheme)
|
|
3431
|
-
})),
|
|
3432
|
-
onChange: onSelectAuth
|
|
3433
|
-
})]
|
|
3434
|
-
}), selectedAuth ? /* @__PURE__ */ jsxs("label", {
|
|
3435
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
3436
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3437
|
-
className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3438
|
-
children: "Credential"
|
|
3439
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
3440
|
-
className: "flex min-w-0 items-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-1.5 shadow-xs",
|
|
3441
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3442
|
-
className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3443
|
-
children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
|
|
3444
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
3445
|
-
value: authValues[selectedAuth.name] ?? "",
|
|
3446
|
-
placeholder: authPlaceholder(selectedAuth),
|
|
3447
|
-
onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
|
|
3448
|
-
className: "min-w-0 flex-1 border-0 bg-transparent px-0 py-0 text-xs font-semibold text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
|
|
3449
|
-
})]
|
|
3450
|
-
})]
|
|
3451
|
-
}) : null]
|
|
3452
|
-
})
|
|
3453
|
-
});
|
|
3454
|
-
}
|
|
3455
4803
|
function EndpointIdentity(arg0) {
|
|
3456
|
-
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen,
|
|
4804
|
+
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, onSelectServer, onChangeServerVariable, onToggleServer, onTryRequest } = arg0;
|
|
4805
|
+
const t = useBuiltInText();
|
|
3457
4806
|
const directServerSelect = servers.length > 1 && servers.every((server) => Object.keys(server.variables ?? {}).length === 0);
|
|
3458
4807
|
const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
|
|
3459
4808
|
const [copiedUrl, setCopiedUrl] = useState(false);
|
|
@@ -3468,61 +4817,40 @@ function EndpointIdentity(arg0) {
|
|
|
3468
4817
|
}
|
|
3469
4818
|
return /* @__PURE__ */ jsxs("div", {
|
|
3470
4819
|
className: "clarify-openai-endpoint-identity not-prose flex w-full flex-col overflow-hidden rounded-xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-xs",
|
|
3471
|
-
children: [
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
})
|
|
3506
|
-
}) : null
|
|
3507
|
-
]
|
|
3508
|
-
}),
|
|
3509
|
-
serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ jsx(ServerPanel, {
|
|
3510
|
-
servers,
|
|
3511
|
-
selectedKey: selectedServerKey,
|
|
3512
|
-
selectedServer,
|
|
3513
|
-
variables: serverVariables,
|
|
3514
|
-
onSelectServer,
|
|
3515
|
-
onChangeVariable: onChangeServerVariable
|
|
3516
|
-
}) : null,
|
|
3517
|
-
authOpen ? /* @__PURE__ */ jsx(AuthPanel, {
|
|
3518
|
-
authOptions,
|
|
3519
|
-
selectedAuthName,
|
|
3520
|
-
selectedAuth,
|
|
3521
|
-
authValues,
|
|
3522
|
-
onSelectAuth,
|
|
3523
|
-
onChangeAuthValue
|
|
3524
|
-
}) : null
|
|
3525
|
-
]
|
|
4820
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4821
|
+
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
4822
|
+
children: [
|
|
4823
|
+
/* @__PURE__ */ jsx(EndpointMethodBadge, { method }),
|
|
4824
|
+
operationSource === "webhook" ? /* @__PURE__ */ jsx(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
|
|
4825
|
+
/* @__PURE__ */ jsx(ServerUrlValue, {
|
|
4826
|
+
servers,
|
|
4827
|
+
selectedKey: selectedServerKey,
|
|
4828
|
+
server: selectedServer,
|
|
4829
|
+
variables: serverVariables,
|
|
4830
|
+
open: serverOpen,
|
|
4831
|
+
interactive: serverInteractive,
|
|
4832
|
+
directSelect: directServerSelect,
|
|
4833
|
+
onSelect: onSelectServer,
|
|
4834
|
+
onToggle: onToggleServer
|
|
4835
|
+
}),
|
|
4836
|
+
/* @__PURE__ */ jsx(EndpointPath, {
|
|
4837
|
+
path,
|
|
4838
|
+
copied: copiedUrl,
|
|
4839
|
+
onCopy: handleCopyUrl
|
|
4840
|
+
}),
|
|
4841
|
+
onTryRequest ? /* @__PURE__ */ jsx(SendRequestButton, {
|
|
4842
|
+
label: t("openapi.tryRequest"),
|
|
4843
|
+
onClick: onTryRequest
|
|
4844
|
+
}) : null
|
|
4845
|
+
]
|
|
4846
|
+
}), serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ jsx(ServerPanel, {
|
|
4847
|
+
servers,
|
|
4848
|
+
selectedKey: selectedServerKey,
|
|
4849
|
+
selectedServer,
|
|
4850
|
+
variables: serverVariables,
|
|
4851
|
+
onSelectServer,
|
|
4852
|
+
onChangeVariable: onChangeServerVariable
|
|
4853
|
+
}) : null]
|
|
3526
4854
|
});
|
|
3527
4855
|
}
|
|
3528
4856
|
function OpenApiOperation(arg0) {
|
|
@@ -3535,6 +4863,7 @@ function OpenApiOperation(arg0) {
|
|
|
3535
4863
|
const authState = useOperationAuthState(spec, operation);
|
|
3536
4864
|
const [linkedExampleKey, setLinkedExampleKey] = useState("");
|
|
3537
4865
|
const [selectedResponseStatus, setSelectedResponseStatus] = useState(() => getDefaultResponseStatus(operation, spec));
|
|
4866
|
+
const [requestOpen, setRequestOpen] = useState(false);
|
|
3538
4867
|
return /* @__PURE__ */ jsxs("section", {
|
|
3539
4868
|
className: "clarify-openai-endpoint scroll-mt-24 pb-16 first:pt-0 last:pb-0",
|
|
3540
4869
|
"aria-labelledby": id,
|
|
@@ -3552,23 +4881,19 @@ function OpenApiOperation(arg0) {
|
|
|
3552
4881
|
selectedServer: serverState.selectedServer,
|
|
3553
4882
|
serverVariables: serverState.serverVariables,
|
|
3554
4883
|
serverOpen: serverState.serverOpen,
|
|
3555
|
-
authOptions: authState.authOptions,
|
|
3556
|
-
selectedAuthName: authState.selectedAuthName,
|
|
3557
|
-
selectedAuth: authState.selectedAuth,
|
|
3558
|
-
authValues: authState.authValues,
|
|
3559
|
-
authOpen: authState.authOpen,
|
|
3560
4884
|
onSelectServer: serverState.onSelectServer,
|
|
3561
4885
|
onChangeServerVariable: serverState.onChangeServerVariable,
|
|
3562
|
-
onToggleServer:
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
4886
|
+
onToggleServer: serverState.onToggleServer,
|
|
4887
|
+
onTryRequest: () => setRequestOpen(true)
|
|
4888
|
+
}),
|
|
4889
|
+
/* @__PURE__ */ jsx(OpenApiRequestDialog, {
|
|
4890
|
+
open: requestOpen,
|
|
4891
|
+
onClose: () => setRequestOpen(false),
|
|
4892
|
+
spec,
|
|
4893
|
+
path,
|
|
4894
|
+
method,
|
|
4895
|
+
operation,
|
|
4896
|
+
operationSource
|
|
3572
4897
|
}),
|
|
3573
4898
|
/* @__PURE__ */ jsx(EndpointRequest, {
|
|
3574
4899
|
spec,
|
|
@@ -3602,6 +4927,6 @@ function OpenApiOperation(arg0) {
|
|
|
3602
4927
|
});
|
|
3603
4928
|
}
|
|
3604
4929
|
//#endregion
|
|
3605
|
-
export {
|
|
4930
|
+
export { Code as A, GridPattern as C, Tag as D, Heading as E, CardGroup as F, Callout as I, Button as L, Pre as M, Mermaid as N, Feedback as O, Card as P, Prose as S, Logo as T, WebFrame as _, ResponseExamplesPanel as a, Step as b, getAuthOptions as c, getOpenApiOperationEntry as d, listOpenApiOperations as f, primitives_exports as g, Markdown as h, RequestExamplesPanel as i, CodeGroup as j, Collapse as k, getServerKey as l, getRequestBody$1 as m, OpenApiOperation as n, authPlaceholder as o, getMediaTypeEntries as p, OpenApiRequestWorkbench as r, defaultServerVariables as s, EndpointIdentity as t, getServers as u, TabItem as v, HeroPattern as w, Steps as x, Tabs as y };
|
|
3606
4931
|
|
|
3607
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
4932
|
+
//# sourceMappingURL=OpenApiOperation-C2vJztWZ.js.map
|