@clarify-labs/renderer 0.10.0 → 0.10.2
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-CxhXBtsR.js → ClarifyShell-1LuBliwt.js} +124 -40
- package/output/ClarifyShell-1LuBliwt.js.map +1 -0
- package/output/{ClarifyShell-DjLRRW8T.cjs → ClarifyShell-C6li72Ce.cjs} +136 -52
- package/output/ClarifyShell-C6li72Ce.cjs.map +1 -0
- package/output/MermaidViewer-B6-BMCJG.cjs +101 -0
- package/output/MermaidViewer-B6-BMCJG.cjs.map +1 -0
- package/output/MermaidViewer-dXsomvM7.js +98 -0
- package/output/MermaidViewer-dXsomvM7.js.map +1 -0
- package/output/{OpenApiOperation-qp5tFaWP.cjs → OpenApiOperation-B52IWlKb.cjs} +405 -243
- package/output/OpenApiOperation-B52IWlKb.cjs.map +1 -0
- package/output/{OpenApiOperation-CyBkzvob.js → OpenApiOperation-DgrqzeiS.js} +377 -228
- package/output/OpenApiOperation-DgrqzeiS.js.map +1 -0
- package/output/{PageActions-GS_cxeJN.cjs → PageActions-BjB6PYmL.cjs} +73 -734
- package/output/PageActions-BjB6PYmL.cjs.map +1 -0
- package/output/{PageActions-Dn8IGWoL.js → PageActions-D7K9LDGf.js} +67 -680
- package/output/PageActions-D7K9LDGf.js.map +1 -0
- package/output/SearchDialog-CIPvXMT3.cjs +414 -0
- package/output/SearchDialog-CIPvXMT3.cjs.map +1 -0
- package/output/SearchDialog-CxYLjRi5.js +411 -0
- package/output/SearchDialog-CxYLjRi5.js.map +1 -0
- package/output/app/AppShell.d.ts +2 -2
- package/output/app/SectionHashSync.d.ts +6 -0
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/components/HighlightedCode.d.ts +7 -0
- package/output/components/MermaidViewer.d.ts +7 -0
- package/output/context.d.ts +1 -1
- package/output/core/context.d.ts +3 -4
- package/output/core/i18n.d.ts +1 -1
- package/output/core/index.d.ts +1 -1
- package/output/core/types.d.ts +36 -19
- package/output/i18n-DnqZHFT7.js +247 -0
- package/output/i18n-DnqZHFT7.js.map +1 -0
- package/output/i18n-b4iTLeia.cjs +294 -0
- package/output/i18n-b4iTLeia.cjs.map +1 -0
- package/output/index.cjs +91 -94
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +7 -7
- package/output/index.js +83 -87
- package/output/index.js.map +1 -1
- package/output/markdown.cjs +2 -1
- package/output/markdown.d.ts +1 -1
- package/output/markdown.js +2 -2
- package/output/mdx/remark.d.ts +1 -0
- package/output/openapi/components/EndpointSections.d.ts +3 -1
- package/output/openapi/components/ExamplePanels.d.ts +5 -2
- package/output/openapi/components/OpenApiOperation.d.ts +3 -1
- package/output/openapi/components/OpenApiOperation.state.d.ts +3 -3
- package/output/openapi/components/SchemaProperties.d.ts +1 -0
- package/output/openapi/components/helpers.d.ts +2 -2
- package/output/openapi/entry.d.ts +0 -1
- package/output/openapi/lib/helpers.d.ts +5 -3
- package/output/openapi/lib/request-code.d.ts +2 -1
- package/output/openapi/lib/spec-path.d.ts +6 -1
- package/output/openapi/lib/utils.d.ts +10 -4
- package/output/preview.cjs +7 -5
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +5 -3
- package/output/preview.js.map +1 -1
- package/output/{remark-Dd2WU50s.js → remark-C9iRQM0R.js} +4 -3
- package/output/remark-C9iRQM0R.js.map +1 -0
- package/output/{remark-zSQT0MBv.cjs → remark-DTLbG8PK.cjs} +9 -2
- package/output/remark-DTLbG8PK.cjs.map +1 -0
- package/output/{render-CV0a-qtD.js → render-DKj24Jqw.js} +15 -8
- package/output/render-DKj24Jqw.js.map +1 -0
- package/output/{render-CCCoUWDP.cjs → render-Di5B6Zc0.cjs} +15 -8
- package/output/render-Di5B6Zc0.cjs.map +1 -0
- package/output/renderer.css +234 -20
- package/output/runtime/ClarifyShell.d.ts +5 -6
- package/output/server.cjs +4 -4
- package/output/server.cjs.map +1 -1
- package/output/server.js +4 -4
- package/output/server.js.map +1 -1
- package/output/shell/Navigation.d.ts +1 -0
- package/output/shell/search/SearchDialog.d.ts +1 -1
- package/output/slots/RuntimeSlot.d.ts +7 -7
- package/output/slots/context.d.ts +5 -5
- package/output/slots/index.d.ts +2 -2
- package/output/slots/types.d.ts +1 -1
- package/output/utils/path.d.ts +1 -1
- package/package.json +3 -1
- package/output/ClarifyShell-CxhXBtsR.js.map +0 -1
- package/output/ClarifyShell-DjLRRW8T.cjs.map +0 -1
- package/output/OpenApiOperation-CyBkzvob.js.map +0 -1
- package/output/OpenApiOperation-qp5tFaWP.cjs.map +0 -1
- package/output/PageActions-Dn8IGWoL.js.map +0 -1
- package/output/PageActions-GS_cxeJN.cjs.map +0 -1
- package/output/remark-Dd2WU50s.js.map +0 -1
- package/output/remark-zSQT0MBv.cjs.map +0 -1
- package/output/render-CCCoUWDP.cjs.map +0 -1
- package/output/render-CV0a-qtD.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_i18n = require("./i18n-b4iTLeia.cjs");
|
|
3
|
+
const require_PageActions = require("./PageActions-BjB6PYmL.cjs");
|
|
4
|
+
const require_remark = require("./remark-DTLbG8PK.cjs");
|
|
4
5
|
let clsx = require("clsx");
|
|
5
6
|
clsx = require_rolldown_runtime.__toESM(clsx, 1);
|
|
6
7
|
let react = require("react");
|
|
@@ -10,14 +11,16 @@ let lucide_react = require("lucide-react");
|
|
|
10
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
12
|
let framer_motion = require("framer-motion");
|
|
12
13
|
let zustand = require("zustand");
|
|
13
|
-
let react_zoom_pan_pinch = require("react-zoom-pan-pinch");
|
|
14
14
|
let react_markdown = require("react-markdown");
|
|
15
15
|
react_markdown = require_rolldown_runtime.__toESM(react_markdown, 1);
|
|
16
|
+
let rehype_raw = require("rehype-raw");
|
|
17
|
+
rehype_raw = require_rolldown_runtime.__toESM(rehype_raw, 1);
|
|
16
18
|
let github_slugger = require("github-slugger");
|
|
19
|
+
let shiki = require("shiki");
|
|
17
20
|
let _scalar_snippetz = require("@scalar/snippetz");
|
|
18
21
|
//#region source/components/LocalizedLink.tsx
|
|
19
22
|
function useLocalizedHref(href) {
|
|
20
|
-
return require_PageActions.localizeHref(href,
|
|
23
|
+
return require_PageActions.localizeHref(href, require_i18n.useConfig(), require_i18n.useLocale());
|
|
21
24
|
}
|
|
22
25
|
function LocalizedLink(arg0) {
|
|
23
26
|
const { href, ...props } = arg0;
|
|
@@ -116,7 +119,7 @@ var defaultTitleKeys = {
|
|
|
116
119
|
};
|
|
117
120
|
function Callout(arg0) {
|
|
118
121
|
const { children, type = "info", title, icon = true, className, ...props } = arg0;
|
|
119
|
-
const t =
|
|
122
|
+
const t = require_i18n.useBuiltInText();
|
|
120
123
|
const style = calloutStyles[type];
|
|
121
124
|
const Icon = style.Icon;
|
|
122
125
|
const resolvedTitle = title === void 0 ? t(defaultTitleKeys[type]) : title;
|
|
@@ -200,63 +203,19 @@ function Card(arg0) {
|
|
|
200
203
|
}
|
|
201
204
|
//#endregion
|
|
202
205
|
//#region source/components/Mermaid.tsx
|
|
206
|
+
var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-B6-BMCJG.cjs")));
|
|
203
207
|
var mermaidModulePromise;
|
|
204
208
|
async function loadMermaid() {
|
|
205
209
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
206
210
|
return mermaidModulePromise;
|
|
207
211
|
}
|
|
208
|
-
function ZoomControls() {
|
|
209
|
-
const { zoomIn, zoomOut, resetTransform } = (0, react_zoom_pan_pinch.useControls)();
|
|
210
|
-
const t = require_PageActions.useBuiltInText();
|
|
211
|
-
const buttonClassName = "flex h-7 w-7 items-center justify-center rounded-md bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) shadow-xs ring-1 ring-(--clarify-theme-tokens-colors-border) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)";
|
|
212
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
213
|
-
className: "clarify-mermaid-controls absolute top-2 right-2 z-10 flex gap-1 opacity-0 transition group-hover:opacity-100 focus-within:opacity-100",
|
|
214
|
-
children: [
|
|
215
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
216
|
-
type: "button",
|
|
217
|
-
"aria-label": t("mermaid.zoomIn"),
|
|
218
|
-
title: t("mermaid.zoomIn"),
|
|
219
|
-
onClick: () => zoomIn(),
|
|
220
|
-
className: buttonClassName,
|
|
221
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ZoomIn, {
|
|
222
|
-
className: "h-4 w-4",
|
|
223
|
-
"aria-hidden": "true"
|
|
224
|
-
})
|
|
225
|
-
}),
|
|
226
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
227
|
-
type: "button",
|
|
228
|
-
"aria-label": t("mermaid.zoomOut"),
|
|
229
|
-
title: t("mermaid.zoomOut"),
|
|
230
|
-
onClick: () => zoomOut(),
|
|
231
|
-
className: buttonClassName,
|
|
232
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ZoomOut, {
|
|
233
|
-
className: "h-4 w-4",
|
|
234
|
-
"aria-hidden": "true"
|
|
235
|
-
})
|
|
236
|
-
}),
|
|
237
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
238
|
-
type: "button",
|
|
239
|
-
"aria-label": t("mermaid.resetZoom"),
|
|
240
|
-
title: t("mermaid.resetZoom"),
|
|
241
|
-
onClick: () => resetTransform(),
|
|
242
|
-
className: buttonClassName,
|
|
243
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Maximize2, {
|
|
244
|
-
className: "h-4 w-4",
|
|
245
|
-
"aria-hidden": "true"
|
|
246
|
-
})
|
|
247
|
-
})
|
|
248
|
-
]
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
212
|
function Mermaid(arg0) {
|
|
252
213
|
const { chart, className } = arg0;
|
|
253
|
-
const t =
|
|
214
|
+
const t = require_i18n.useBuiltInText();
|
|
254
215
|
const { resolvedTheme } = require_PageActions.useTheme();
|
|
255
216
|
const renderId = `clarify-mermaid-${(0, react.useId)().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
256
|
-
const containerRef = (0, react.useRef)(null);
|
|
257
217
|
const [svg, setSvg] = (0, react.useState)("");
|
|
258
218
|
const [error, setError] = (0, react.useState)(void 0);
|
|
259
|
-
const [focused, setFocused] = (0, react.useState)(false);
|
|
260
219
|
(0, react.useEffect)(() => {
|
|
261
220
|
let cancelled = false;
|
|
262
221
|
async function renderChart() {
|
|
@@ -319,42 +278,24 @@ function Mermaid(arg0) {
|
|
|
319
278
|
children: chart.trim()
|
|
320
279
|
})
|
|
321
280
|
});
|
|
281
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, {
|
|
282
|
+
fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MermaidStaticSvg, {
|
|
283
|
+
svg,
|
|
284
|
+
className
|
|
285
|
+
}),
|
|
286
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MermaidViewer, {
|
|
287
|
+
svg,
|
|
288
|
+
className
|
|
289
|
+
})
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function MermaidStaticSvg(arg0) {
|
|
293
|
+
const { svg, className } = arg0;
|
|
322
294
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
onFocus: () => setFocused(true),
|
|
328
|
-
onBlur: () => setFocused(false),
|
|
329
|
-
className: (0, clsx.default)("clarify-mermaid group not-prose relative my-6 overflow-hidden rounded-2xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", className),
|
|
330
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_zoom_pan_pinch.TransformWrapper, {
|
|
331
|
-
minScale: .5,
|
|
332
|
-
maxScale: 8,
|
|
333
|
-
initialScale: 1,
|
|
334
|
-
centerOnInit: true,
|
|
335
|
-
smooth: true,
|
|
336
|
-
wheel: {
|
|
337
|
-
step: .05,
|
|
338
|
-
wheelDisabled: !focused,
|
|
339
|
-
touchPadDisabled: !focused
|
|
340
|
-
},
|
|
341
|
-
doubleClick: { mode: "reset" },
|
|
342
|
-
children: [
|
|
343
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ZoomControls, {}),
|
|
344
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_zoom_pan_pinch.TransformComponent, {
|
|
345
|
-
wrapperClass: "!w-full !cursor-grab active:!cursor-grabbing",
|
|
346
|
-
contentClass: "!w-full justify-center [&_svg]:h-auto [&_svg]:max-w-full",
|
|
347
|
-
wrapperStyle: { height: "min(70vh, 32rem)" },
|
|
348
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
349
|
-
className: "flex h-full w-full items-center justify-center p-4",
|
|
350
|
-
dangerouslySetInnerHTML: { __html: svg }
|
|
351
|
-
})
|
|
352
|
-
}),
|
|
353
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
354
|
-
className: (0, clsx.default)("clarify-mermaid-hint pointer-events-none absolute bottom-2 left-1/2 z-10 -translate-x-1/2 rounded-full bg-(--clarify-theme-tokens-colors-surface)/90 px-2.5 py-1 text-2xs text-(--clarify-ui-text-soft) shadow-xs ring-1 ring-(--clarify-theme-tokens-colors-border) backdrop-blur-sm transition", focused ? "opacity-0" : "opacity-0 group-hover:opacity-100"),
|
|
355
|
-
children: t("mermaid.scrollHint")
|
|
356
|
-
})
|
|
357
|
-
]
|
|
295
|
+
className: (0, clsx.default)("clarify-mermaid not-prose my-6 overflow-x-auto rounded-2xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-4", className),
|
|
296
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
297
|
+
className: "flex w-full justify-center [&_svg]:h-auto [&_svg]:max-w-full",
|
|
298
|
+
dangerouslySetInnerHTML: { __html: svg }
|
|
358
299
|
})
|
|
359
300
|
});
|
|
360
301
|
}
|
|
@@ -388,15 +329,23 @@ function getNodeText(node) {
|
|
|
388
329
|
if ((0, react.isValidElement)(node)) return getNodeText(node.props.children);
|
|
389
330
|
return "";
|
|
390
331
|
}
|
|
332
|
+
function getCodeLanguage(node) {
|
|
333
|
+
if (!(0, react.isValidElement)(node)) return void 0;
|
|
334
|
+
const { className, language, children } = node.props;
|
|
335
|
+
if (language) return language;
|
|
336
|
+
const languageClass = className?.split(/\s+/).find((value) => value.startsWith("language-"));
|
|
337
|
+
if (languageClass) return languageClass.slice(9);
|
|
338
|
+
return react.Children.toArray(children).map(getCodeLanguage).find(Boolean);
|
|
339
|
+
}
|
|
391
340
|
function CopyButton(arg0) {
|
|
392
341
|
const { code } = arg0;
|
|
393
|
-
const t =
|
|
342
|
+
const t = require_i18n.useBuiltInText();
|
|
394
343
|
const [copyCount, setCopyCount] = (0, react.useState)(0);
|
|
395
344
|
const copied = copyCount > 0;
|
|
396
345
|
(0, react.useEffect)(() => {
|
|
397
346
|
if (copyCount === 0) return void 0;
|
|
398
|
-
const timeout =
|
|
399
|
-
return () =>
|
|
347
|
+
const timeout = setTimeout(() => setCopyCount(0), 1e3);
|
|
348
|
+
return () => clearTimeout(timeout);
|
|
400
349
|
}, [copyCount]);
|
|
401
350
|
if (!code) return null;
|
|
402
351
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
@@ -455,8 +404,9 @@ function CodePanel(arg0) {
|
|
|
455
404
|
}
|
|
456
405
|
function CodeGroupHeader(arg0) {
|
|
457
406
|
const { title, children, selectedIndex } = arg0;
|
|
458
|
-
const t =
|
|
407
|
+
const t = require_i18n.useBuiltInText();
|
|
459
408
|
const hasTabs = react.Children.count(children) > 1;
|
|
409
|
+
const indicatorLayoutId = (0, react.useId)();
|
|
460
410
|
if (!title && !hasTabs) return null;
|
|
461
411
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
462
412
|
className: "clarify-code-group-header flex min-h-(--clarify-code-header-min-height) flex-wrap items-start gap-x-4 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-4",
|
|
@@ -464,13 +414,22 @@ function CodeGroupHeader(arg0) {
|
|
|
464
414
|
className: "mr-auto pt-3 text-xs font-semibold text-(--clarify-code-text)",
|
|
465
415
|
children: title
|
|
466
416
|
}) : null, hasTabs ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabList, {
|
|
467
|
-
className: "clarify-code-tabs -mb-px flex gap-
|
|
468
|
-
children: react.Children.map(children, (child, childIndex) => /* @__PURE__ */ (0, react_jsx_runtime.
|
|
469
|
-
className: (0, clsx.default)("clarify-code-tab border-b py-3 transition data-selected:not-data-focus:outline-hidden", childIndex === selectedIndex ? "
|
|
470
|
-
children: getPanelTitle({
|
|
417
|
+
className: "clarify-code-tabs -mr-2 -mb-px flex gap-0 text-xs font-medium",
|
|
418
|
+
children: react.Children.map(children, (child, childIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.Tab, {
|
|
419
|
+
className: (0, clsx.default)("clarify-code-tab relative border-b border-transparent px-2 py-3 transition-colors hover:bg-(--clarify-code-control-background-hover) data-selected:not-data-focus:outline-hidden", childIndex === selectedIndex ? "text-(--clarify-code-accent-text)" : "text-(--clarify-code-control-text) hover:text-(--clarify-code-text)"),
|
|
420
|
+
children: [getPanelTitle({
|
|
471
421
|
...(0, react.isValidElement)(child) ? child.props : {},
|
|
472
422
|
fallbackTitle: t("actions.code")
|
|
473
|
-
})
|
|
423
|
+
}), childIndex === selectedIndex ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.span, {
|
|
424
|
+
layoutId: indicatorLayoutId,
|
|
425
|
+
className: "absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-(--clarify-code-accent-text)",
|
|
426
|
+
transition: {
|
|
427
|
+
type: "spring",
|
|
428
|
+
stiffness: 460,
|
|
429
|
+
damping: 34,
|
|
430
|
+
mass: .7
|
|
431
|
+
}
|
|
432
|
+
}) : null]
|
|
474
433
|
}))
|
|
475
434
|
}) : null]
|
|
476
435
|
});
|
|
@@ -534,7 +493,7 @@ function useTabGroupProps(availableLanguages) {
|
|
|
534
493
|
var CodeGroupContext = (0, react.createContext)(false);
|
|
535
494
|
function CodeGroup(arg0) {
|
|
536
495
|
const { children, title, ...props } = arg0;
|
|
537
|
-
const t =
|
|
496
|
+
const t = require_i18n.useBuiltInText();
|
|
538
497
|
const tabGroupProps = useTabGroupProps(react.Children.map(children, (child) => getPanelTitle({
|
|
539
498
|
...(0, react.isValidElement)(child) ? child.props : {},
|
|
540
499
|
fallbackTitle: t("actions.code")
|
|
@@ -582,7 +541,9 @@ function Code(arg0) {
|
|
|
582
541
|
function Pre(arg0) {
|
|
583
542
|
const { children, language, code, ...props } = arg0;
|
|
584
543
|
const isGrouped = (0, react.useContext)(CodeGroupContext);
|
|
585
|
-
|
|
544
|
+
const resolvedLanguage = language ?? getCodeLanguage(children);
|
|
545
|
+
const resolvedCode = code ?? getNodeText(children);
|
|
546
|
+
if (resolvedLanguage === "mermaid") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Mermaid, { chart: resolvedCode });
|
|
586
547
|
if (isGrouped) return children;
|
|
587
548
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeGroup, {
|
|
588
549
|
...props,
|
|
@@ -641,7 +602,7 @@ function FeedbackButton(props) {
|
|
|
641
602
|
}
|
|
642
603
|
var FeedbackForm = (0, react.forwardRef)(function FeedbackForm(arg0, ref) {
|
|
643
604
|
const { onSubmit, className, ...props } = arg0;
|
|
644
|
-
const t =
|
|
605
|
+
const t = require_i18n.useBuiltInText();
|
|
645
606
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
646
607
|
...props,
|
|
647
608
|
ref,
|
|
@@ -668,7 +629,7 @@ var FeedbackForm = (0, react.forwardRef)(function FeedbackForm(arg0, ref) {
|
|
|
668
629
|
});
|
|
669
630
|
var FeedbackThanks = (0, react.forwardRef)(function FeedbackThanks(arg0, ref) {
|
|
670
631
|
const { className, ...props } = arg0;
|
|
671
|
-
const t =
|
|
632
|
+
const t = require_i18n.useBuiltInText();
|
|
672
633
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
673
634
|
...props,
|
|
674
635
|
ref,
|
|
@@ -921,16 +882,17 @@ function Tabs(arg0) {
|
|
|
921
882
|
onChange: handleChange,
|
|
922
883
|
className,
|
|
923
884
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabList, {
|
|
924
|
-
className: (0, clsx.default)("flex flex-wrap items-center gap-
|
|
885
|
+
className: (0, clsx.default)("-mx-2 flex flex-wrap items-center gap-2 border-b border-(--clarify-theme-tokens-colors-border) px-2 pb-0", listClassName),
|
|
925
886
|
children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Tab, {
|
|
926
|
-
className: ({ selected }) => (0, clsx.default)("clarify-ui-tab relative inline-flex h-10 shrink-0 items-center px-
|
|
887
|
+
className: ({ selected }) => (0, clsx.default)("clarify-content-tab clarify-ui-tab relative inline-flex h-10 shrink-0 items-center rounded-t-md px-2 py-0 text-sm font-medium transition-colors focus:outline-none", selected && "clarify-ui-tab-active"),
|
|
927
888
|
children: ({ selected }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.label }), selected ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.span, {
|
|
928
889
|
layoutId: indicatorLayoutId,
|
|
929
|
-
className: "absolute inset-x-
|
|
890
|
+
className: "absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-(--clarify-ui-tab-indicator) shadow-[0_0_0.5rem_var(--clarify-ui-accent-glow)]",
|
|
930
891
|
transition: {
|
|
931
|
-
type: "
|
|
932
|
-
|
|
933
|
-
|
|
892
|
+
type: "spring",
|
|
893
|
+
stiffness: 460,
|
|
894
|
+
damping: 34,
|
|
895
|
+
mass: .7
|
|
934
896
|
}
|
|
935
897
|
}) : null] })
|
|
936
898
|
}, item.id))
|
|
@@ -1185,44 +1147,55 @@ function Markdown(arg0) {
|
|
|
1185
1147
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_markdown.default, {
|
|
1186
1148
|
components: markdownComponents,
|
|
1187
1149
|
remarkPlugins: require_remark.markdownRemarkPlugins,
|
|
1150
|
+
rehypePlugins: [rehype_raw.default],
|
|
1188
1151
|
children
|
|
1189
1152
|
})
|
|
1190
1153
|
});
|
|
1191
1154
|
}
|
|
1192
1155
|
//#endregion
|
|
1193
1156
|
//#region source/openapi/lib/helpers.ts
|
|
1194
|
-
function isRecord(value) {
|
|
1157
|
+
function isRecord$1(value) {
|
|
1195
1158
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1196
1159
|
}
|
|
1197
1160
|
function isReference(value) {
|
|
1198
|
-
return isRecord(value) && typeof value.$ref === "string";
|
|
1161
|
+
return isRecord$1(value) && typeof value.$ref === "string";
|
|
1199
1162
|
}
|
|
1200
1163
|
function resolveReferenceName(ref) {
|
|
1201
1164
|
return ref.split("/").filter(Boolean).at(-1) ?? ref;
|
|
1202
1165
|
}
|
|
1203
|
-
function resolveOpenApiRef(spec, ref) {
|
|
1166
|
+
function resolveOpenApiRef$1(spec, ref) {
|
|
1204
1167
|
if (!ref.startsWith("#/")) return void 0;
|
|
1205
|
-
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
|
|
1168
|
+
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord$1(current) ? current[part] : void 0, spec);
|
|
1206
1169
|
}
|
|
1207
1170
|
function resolveSchema(spec, schema, seen = /* @__PURE__ */ new Set()) {
|
|
1208
1171
|
if (!isReference(schema)) return schema;
|
|
1209
1172
|
if (seen.has(schema.$ref)) return schema;
|
|
1210
1173
|
seen.add(schema.$ref);
|
|
1211
|
-
return resolveSchema(spec, resolveOpenApiRef(spec, schema.$ref), seen) ?? schema;
|
|
1174
|
+
return resolveSchema(spec, resolveOpenApiRef$1(spec, schema.$ref), seen) ?? schema;
|
|
1212
1175
|
}
|
|
1213
|
-
function getPathItem(spec, path) {
|
|
1176
|
+
function getPathItem$1(spec, path) {
|
|
1214
1177
|
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
1215
1178
|
}
|
|
1179
|
+
function getOperationPathItem(spec, path, source = "path") {
|
|
1180
|
+
if (source === "path") return getPathItem$1(spec, path);
|
|
1181
|
+
const webhooks = spec.webhooks;
|
|
1182
|
+
return resolveObjectRef(spec, isRecord$1(webhooks) ? webhooks[path] : void 0);
|
|
1183
|
+
}
|
|
1184
|
+
function joinPath(base, path) {
|
|
1185
|
+
if (!base) return path || "/";
|
|
1186
|
+
if (!path) return base;
|
|
1187
|
+
return `${base.endsWith("/") ? base.slice(0, -1) : base}${path.startsWith("/") ? path : `/${path}`}`;
|
|
1188
|
+
}
|
|
1216
1189
|
function resolveObjectRef(spec, value) {
|
|
1217
|
-
const resolved = spec && isReference(value) ? resolveOpenApiRef(spec, value.$ref) : value;
|
|
1218
|
-
return isRecord(resolved) && !isReference(resolved) ? resolved : void 0;
|
|
1190
|
+
const resolved = spec && isReference(value) ? resolveOpenApiRef$1(spec, value.$ref) : value;
|
|
1191
|
+
return isRecord$1(resolved) && !isReference(resolved) ? resolved : void 0;
|
|
1219
1192
|
}
|
|
1220
1193
|
function schemaHasType(schema, type) {
|
|
1221
|
-
if (!isRecord(schema)) return false;
|
|
1194
|
+
if (!isRecord$1(schema)) return false;
|
|
1222
1195
|
return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
|
|
1223
1196
|
}
|
|
1224
|
-
function getOperationParameters(spec, path, operation) {
|
|
1225
|
-
const pathParameters =
|
|
1197
|
+
function getOperationParameters(spec, path, operation, source = "path") {
|
|
1198
|
+
const pathParameters = getOperationPathItem(spec, path, source)?.parameters;
|
|
1226
1199
|
const operationParameters = operation.parameters;
|
|
1227
1200
|
const parameters = [...Array.isArray(pathParameters) ? pathParameters : [], ...Array.isArray(operationParameters) ? operationParameters : []].map((parameter) => resolveObjectRef(spec, parameter)).filter((parameter) => Boolean(parameter));
|
|
1228
1201
|
const deduped = /* @__PURE__ */ new Map();
|
|
@@ -1240,7 +1213,7 @@ function getRequestBody$1(spec, operation) {
|
|
|
1240
1213
|
return resolveObjectRef(spec, requestBody);
|
|
1241
1214
|
}
|
|
1242
1215
|
function getMediaTypeEntries(content, spec) {
|
|
1243
|
-
if (!isRecord(content)) return [];
|
|
1216
|
+
if (!isRecord$1(content)) return [];
|
|
1244
1217
|
return Object.entries(content).map(([mediaType, value]) => ({
|
|
1245
1218
|
mediaType,
|
|
1246
1219
|
value: resolveObjectRef(spec, value)
|
|
@@ -1252,12 +1225,12 @@ function getJsonLikeContent(content, spec) {
|
|
|
1252
1225
|
return getMediaTypeEntries(content, spec)[0];
|
|
1253
1226
|
}
|
|
1254
1227
|
function getExampleValue(example) {
|
|
1255
|
-
if (isRecord(example) && "value" in example) return example.value;
|
|
1256
|
-
if (isRecord(example) && "externalValue" in example) return void 0;
|
|
1228
|
+
if (isRecord$1(example) && "value" in example) return example.value;
|
|
1229
|
+
if (isRecord$1(example) && "externalValue" in example) return void 0;
|
|
1257
1230
|
return example;
|
|
1258
1231
|
}
|
|
1259
1232
|
function getExampleTitle(key, example) {
|
|
1260
|
-
if (isRecord(example)) {
|
|
1233
|
+
if (isRecord$1(example)) {
|
|
1261
1234
|
const summary = typeof example.summary === "string" ? example.summary : void 0;
|
|
1262
1235
|
return {
|
|
1263
1236
|
title: summary ?? key,
|
|
@@ -1266,9 +1239,9 @@ function getExampleTitle(key, example) {
|
|
|
1266
1239
|
}
|
|
1267
1240
|
return { title: key };
|
|
1268
1241
|
}
|
|
1269
|
-
function getExampleEntries(mediaType) {
|
|
1242
|
+
function getExampleEntries(mediaType, spec) {
|
|
1270
1243
|
if (!mediaType) return [];
|
|
1271
|
-
if (isRecord(mediaType.examples)) {
|
|
1244
|
+
if (isRecord$1(mediaType.examples)) {
|
|
1272
1245
|
const examples = [];
|
|
1273
1246
|
for (const [key, example] of Object.entries(mediaType.examples)) {
|
|
1274
1247
|
const value = getExampleValue(example);
|
|
@@ -1288,7 +1261,7 @@ function getExampleEntries(mediaType) {
|
|
|
1288
1261
|
title: "Example",
|
|
1289
1262
|
value: mediaType.example
|
|
1290
1263
|
}];
|
|
1291
|
-
const generated = schemaToExample(mediaType.schema);
|
|
1264
|
+
const generated = schemaToExample(spec ? resolveSchema(spec, mediaType.schema) : mediaType.schema);
|
|
1292
1265
|
return typeof generated === "undefined" ? [] : [{
|
|
1293
1266
|
key: "schema",
|
|
1294
1267
|
title: "schema",
|
|
@@ -1300,7 +1273,7 @@ function getContentExample(mediaType) {
|
|
|
1300
1273
|
return getExampleEntries(mediaType)[0]?.value;
|
|
1301
1274
|
}
|
|
1302
1275
|
function schemaToType(schema) {
|
|
1303
|
-
if (!isRecord(schema)) return void 0;
|
|
1276
|
+
if (!isRecord$1(schema)) return void 0;
|
|
1304
1277
|
if (isReference(schema)) return resolveReferenceName(schema.$ref);
|
|
1305
1278
|
if (typeof schema.const !== "undefined") return JSON.stringify(schema.const);
|
|
1306
1279
|
if (Array.isArray(schema.enum)) return "enum";
|
|
@@ -1312,14 +1285,14 @@ function schemaToType(schema) {
|
|
|
1312
1285
|
return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
|
|
1313
1286
|
}
|
|
1314
1287
|
function schemaToExample(schema, depth = 0) {
|
|
1315
|
-
if (!isRecord(schema) || depth > 3) return void 0;
|
|
1288
|
+
if (!isRecord$1(schema) || depth > 3) return void 0;
|
|
1316
1289
|
if (typeof schema.example !== "undefined") return schema.example;
|
|
1317
1290
|
if (typeof schema.default !== "undefined") return schema.default;
|
|
1318
1291
|
if (Array.isArray(schema.enum)) return schema.enum[0];
|
|
1319
1292
|
if (isReference(schema)) return { id: resolveReferenceName(schema.$ref) };
|
|
1320
1293
|
if (schemaHasType(schema, "array")) return [schemaToExample(schema.items, depth + 1) ?? "string"];
|
|
1321
|
-
if (schemaHasType(schema, "object") || isRecord(schema.properties)) {
|
|
1322
|
-
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
1294
|
+
if (schemaHasType(schema, "object") || isRecord$1(schema.properties)) {
|
|
1295
|
+
const properties = isRecord$1(schema.properties) ? schema.properties : {};
|
|
1323
1296
|
return Object.fromEntries(Object.entries(properties).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
|
|
1324
1297
|
}
|
|
1325
1298
|
return exampleForType(schemaToType(schema));
|
|
@@ -1339,7 +1312,7 @@ function stringifyExample(value) {
|
|
|
1339
1312
|
}
|
|
1340
1313
|
function getResponseEntries(operation, spec) {
|
|
1341
1314
|
const responses = operation.responses;
|
|
1342
|
-
if (!isRecord(responses)) return [];
|
|
1315
|
+
if (!isRecord$1(responses)) return [];
|
|
1343
1316
|
return Object.entries(responses).map(([status, response]) => ({
|
|
1344
1317
|
status,
|
|
1345
1318
|
response: resolveObjectRef(spec, response)
|
|
@@ -1354,14 +1327,163 @@ function codeLanguageForMediaType(mediaType) {
|
|
|
1354
1327
|
return "text";
|
|
1355
1328
|
}
|
|
1356
1329
|
//#endregion
|
|
1330
|
+
//#region source/openapi/lib/utils.ts
|
|
1331
|
+
var OPENAPI_HTTP_METHODS = [
|
|
1332
|
+
"get",
|
|
1333
|
+
"put",
|
|
1334
|
+
"post",
|
|
1335
|
+
"delete",
|
|
1336
|
+
"options",
|
|
1337
|
+
"head",
|
|
1338
|
+
"patch",
|
|
1339
|
+
"trace"
|
|
1340
|
+
];
|
|
1341
|
+
var CLARIFY_OPENAPI_SECTION_ID_EXTENSION = "x-clarify-section-id";
|
|
1342
|
+
function getOpenApiOperationSectionId(operation) {
|
|
1343
|
+
const sectionId = operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION];
|
|
1344
|
+
return typeof sectionId === "string" ? sectionId : "";
|
|
1345
|
+
}
|
|
1346
|
+
function createOpenApiOperationSectionId(operation, method, path, source) {
|
|
1347
|
+
return (typeof operation.operationId === "string" ? operation.operationId.trim() : "") || (0, github_slugger.slug)(`${source === "webhook" ? "webhook " : ""}${method.toLowerCase()} ${path}`);
|
|
1348
|
+
}
|
|
1349
|
+
function normalizeOpenApiOperationSectionId(operation, method, path, source) {
|
|
1350
|
+
const sectionId = operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION];
|
|
1351
|
+
if (typeof sectionId !== "string" || !sectionId) operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION] = createOpenApiOperationSectionId(operation, method, path, source);
|
|
1352
|
+
return operation;
|
|
1353
|
+
}
|
|
1354
|
+
function isOpenAPIHttpMethod(method) {
|
|
1355
|
+
return OPENAPI_HTTP_METHODS.includes(method.toLowerCase());
|
|
1356
|
+
}
|
|
1357
|
+
function isRecord(value) {
|
|
1358
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1359
|
+
}
|
|
1360
|
+
function resolveOpenApiRef(spec, ref) {
|
|
1361
|
+
if (!ref.startsWith("#/")) return void 0;
|
|
1362
|
+
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
|
|
1363
|
+
}
|
|
1364
|
+
function getPathItem(spec, path) {
|
|
1365
|
+
const pathItem = spec.paths?.[path];
|
|
1366
|
+
const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
|
|
1367
|
+
return isRecord(resolved) ? resolved : void 0;
|
|
1368
|
+
}
|
|
1369
|
+
function getWebhookItem(spec, path) {
|
|
1370
|
+
const webhooks = spec.webhooks;
|
|
1371
|
+
const pathItem = isRecord(webhooks) ? webhooks[path] : void 0;
|
|
1372
|
+
const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
|
|
1373
|
+
return isRecord(resolved) ? resolved : void 0;
|
|
1374
|
+
}
|
|
1375
|
+
function listOperationsFromPathItems(items, source, spec) {
|
|
1376
|
+
const operations = [];
|
|
1377
|
+
for (const path of Object.keys(items)) {
|
|
1378
|
+
const pathItem = source === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path);
|
|
1379
|
+
if (!pathItem) continue;
|
|
1380
|
+
for (const method of OPENAPI_HTTP_METHODS) {
|
|
1381
|
+
const operation = pathItem[method];
|
|
1382
|
+
if (isRecord(operation)) operations.push({
|
|
1383
|
+
path,
|
|
1384
|
+
method,
|
|
1385
|
+
operation: normalizeOpenApiOperationSectionId(operation, method, path, source),
|
|
1386
|
+
source
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
return operations;
|
|
1391
|
+
}
|
|
1392
|
+
function getOpenApiOperationEntry(spec, path, method, source) {
|
|
1393
|
+
if (!isOpenAPIHttpMethod(method)) return void 0;
|
|
1394
|
+
const normalizedMethod = method.toLowerCase();
|
|
1395
|
+
const sources = source ? [source] : ["path", "webhook"];
|
|
1396
|
+
for (const currentSource of sources) {
|
|
1397
|
+
const operation = (currentSource === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path))?.[normalizedMethod];
|
|
1398
|
+
if (isRecord(operation)) return {
|
|
1399
|
+
path,
|
|
1400
|
+
method: normalizedMethod,
|
|
1401
|
+
operation: normalizeOpenApiOperationSectionId(operation, normalizedMethod, path, currentSource),
|
|
1402
|
+
source: currentSource
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
function listOpenApiOperations(spec) {
|
|
1407
|
+
const paths = spec.paths ?? {};
|
|
1408
|
+
const webhooks = spec.webhooks;
|
|
1409
|
+
return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
|
|
1410
|
+
}
|
|
1411
|
+
//#endregion
|
|
1412
|
+
//#region source/components/HighlightedCode.tsx
|
|
1413
|
+
var cssVariablesTheme = (0, shiki.createCssVariablesTheme)();
|
|
1414
|
+
function HighlightedCode(arg0) {
|
|
1415
|
+
const { code, language } = arg0;
|
|
1416
|
+
const [lines, setLines] = (0, react.useState)();
|
|
1417
|
+
(0, react.useEffect)(() => {
|
|
1418
|
+
let active = true;
|
|
1419
|
+
(0, shiki.codeToTokens)(code, {
|
|
1420
|
+
lang: language,
|
|
1421
|
+
theme: cssVariablesTheme
|
|
1422
|
+
}).then((result) => {
|
|
1423
|
+
if (active) setLines(result.tokens);
|
|
1424
|
+
}).catch(() => {
|
|
1425
|
+
if (active) setLines(void 0);
|
|
1426
|
+
});
|
|
1427
|
+
return () => {
|
|
1428
|
+
active = false;
|
|
1429
|
+
};
|
|
1430
|
+
}, [code, language]);
|
|
1431
|
+
if (!lines) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1432
|
+
className: `language-${language}`,
|
|
1433
|
+
children: code
|
|
1434
|
+
});
|
|
1435
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1436
|
+
className: `language-${language}`,
|
|
1437
|
+
children: lines.map((line, lineIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1438
|
+
className: "line",
|
|
1439
|
+
children: [line.map((token, tokenIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1440
|
+
style: {
|
|
1441
|
+
color: token.color,
|
|
1442
|
+
...token.htmlStyle
|
|
1443
|
+
},
|
|
1444
|
+
children: token.content
|
|
1445
|
+
}, tokenIndex)), lineIndex < lines.length - 1 ? "\n" : null]
|
|
1446
|
+
}, lineIndex))
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
//#endregion
|
|
1357
1450
|
//#region source/openapi/lib/request-code.ts
|
|
1451
|
+
var snippetControlCharacters = [
|
|
1452
|
+
{
|
|
1453
|
+
character: "\n",
|
|
1454
|
+
placeholder: "",
|
|
1455
|
+
escape: "\\n"
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
character: "\r",
|
|
1459
|
+
placeholder: "",
|
|
1460
|
+
escape: "\\r"
|
|
1461
|
+
},
|
|
1462
|
+
{
|
|
1463
|
+
character: " ",
|
|
1464
|
+
placeholder: "",
|
|
1465
|
+
escape: "\\t"
|
|
1466
|
+
}
|
|
1467
|
+
];
|
|
1358
1468
|
var snippetGenerator = (0, _scalar_snippetz.snippetz)();
|
|
1469
|
+
function protectSnippetControlCharacters(value) {
|
|
1470
|
+
if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
|
|
1471
|
+
if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
|
|
1472
|
+
if (!isRecord$1(value)) return value;
|
|
1473
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, protectSnippetControlCharacters(item)]));
|
|
1474
|
+
}
|
|
1475
|
+
function restoreSnippetControlCharacters(code) {
|
|
1476
|
+
return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.placeholder, item.escape), code);
|
|
1477
|
+
}
|
|
1359
1478
|
function getDefaultServer(spec) {
|
|
1360
1479
|
const servers = spec.servers;
|
|
1361
1480
|
if (!Array.isArray(servers)) return { url: "https://api.example.com" };
|
|
1362
|
-
const firstServer = servers.find(isRecord);
|
|
1481
|
+
const firstServer = servers.find(isRecord$1);
|
|
1363
1482
|
return firstServer && typeof firstServer.url === "string" ? firstServer : { url: "https://api.example.com" };
|
|
1364
1483
|
}
|
|
1484
|
+
function getDefaultWebhookServer() {
|
|
1485
|
+
return { url: "https://webhook.example.com" };
|
|
1486
|
+
}
|
|
1365
1487
|
function expandServerUrl(server, serverVariables = {}) {
|
|
1366
1488
|
return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
|
|
1367
1489
|
const fallback = server.variables?.[name]?.default ?? name;
|
|
@@ -1369,7 +1491,8 @@ function expandServerUrl(server, serverVariables = {}) {
|
|
|
1369
1491
|
});
|
|
1370
1492
|
}
|
|
1371
1493
|
function buildOperationUrl(input) {
|
|
1372
|
-
|
|
1494
|
+
const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
|
|
1495
|
+
return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1373
1496
|
}
|
|
1374
1497
|
function getQueryString(parameters, auth) {
|
|
1375
1498
|
const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
|
|
@@ -1386,18 +1509,18 @@ function isFormMediaType(mediaType) {
|
|
|
1386
1509
|
return mediaType.includes("multipart/form-data") || mediaType.includes("application/x-www-form-urlencoded");
|
|
1387
1510
|
}
|
|
1388
1511
|
function isBinarySchema(schema) {
|
|
1389
|
-
return isRecord(schema) && schema.type === "string" && schema.format === "binary";
|
|
1512
|
+
return isRecord$1(schema) && schema.type === "string" && schema.format === "binary";
|
|
1390
1513
|
}
|
|
1391
1514
|
function getSchemaProperties(schema) {
|
|
1392
|
-
return isRecord(schema) && isRecord(schema.properties) ? schema.properties : {};
|
|
1515
|
+
return isRecord$1(schema) && isRecord$1(schema.properties) ? schema.properties : {};
|
|
1393
1516
|
}
|
|
1394
1517
|
function getFieldValue(name, value, schema) {
|
|
1395
|
-
if (isRecord(value) && typeof value[name] !== "undefined") return value[name];
|
|
1518
|
+
if (isRecord$1(value) && typeof value[name] !== "undefined") return value[name];
|
|
1396
1519
|
if (isBinarySchema(schema)) return `@${name}`;
|
|
1397
1520
|
}
|
|
1398
1521
|
function getFormParams(value, requestContent) {
|
|
1399
1522
|
const properties = getSchemaProperties(requestContent.value.schema);
|
|
1400
|
-
return Array.from(/* @__PURE__ */ new Set([...Object.keys(properties), ...isRecord(value) ? Object.keys(value) : []])).flatMap((name) => {
|
|
1523
|
+
return Array.from(/* @__PURE__ */ new Set([...Object.keys(properties), ...isRecord$1(value) ? Object.keys(value) : []])).flatMap((name) => {
|
|
1401
1524
|
const fieldValue = getFieldValue(name, value, properties[name]);
|
|
1402
1525
|
if (typeof fieldValue === "undefined") return [];
|
|
1403
1526
|
const contentType = requestContent.value.encoding?.[name]?.contentType;
|
|
@@ -1419,7 +1542,7 @@ function getRequestBody(requestContent) {
|
|
|
1419
1542
|
const params = getFormParams(value, requestContent);
|
|
1420
1543
|
return params.length > 0 ? { params } : void 0;
|
|
1421
1544
|
}
|
|
1422
|
-
return { serialized: stringifyExample(value) };
|
|
1545
|
+
return { serialized: stringifyExample(protectSnippetControlCharacters(value)) };
|
|
1423
1546
|
}
|
|
1424
1547
|
function getAuthorizationValue(auth) {
|
|
1425
1548
|
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "bearer") return `Bearer ${auth.value}`;
|
|
@@ -1472,7 +1595,7 @@ function buildSnippetErrorMessage(error) {
|
|
|
1472
1595
|
}
|
|
1473
1596
|
function buildSnippet(input, target) {
|
|
1474
1597
|
try {
|
|
1475
|
-
return decodeUrlPlaceholders(snippetGenerator.print(target.target, target.client, buildHarRequest(input)) || "");
|
|
1598
|
+
return restoreSnippetControlCharacters(decodeUrlPlaceholders(snippetGenerator.print(target.target, target.client, buildHarRequest(input)) || ""));
|
|
1476
1599
|
} catch (error) {
|
|
1477
1600
|
return buildSnippetErrorMessage(error);
|
|
1478
1601
|
}
|
|
@@ -1781,7 +1904,7 @@ function SelectControl(arg0) {
|
|
|
1781
1904
|
className: wrapperClassName,
|
|
1782
1905
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
|
|
1783
1906
|
"aria-label": label,
|
|
1784
|
-
className: `clarify-api-select-button flex ${buttonSizeClassName} items-center justify-between gap-2 rounded-lg bg-(--clarify-code-control-background) px-2 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:bg-(--clarify-code-control-background-
|
|
1907
|
+
className: `clarify-api-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-lg 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-white/20 hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-white/20 data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
|
|
1785
1908
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1786
1909
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
|
|
1787
1910
|
children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1800,7 +1923,7 @@ function SelectControl(arg0) {
|
|
|
1800
1923
|
className: "clarify-api-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-xl 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",
|
|
1801
1924
|
children: normalizedOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
|
|
1802
1925
|
value: option.value,
|
|
1803
|
-
className: "clarify-api-select-option group flex cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-
|
|
1926
|
+
className: "clarify-api-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-lg 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)",
|
|
1804
1927
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
1805
1928
|
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
1806
1929
|
"aria-hidden": "true"
|
|
@@ -1814,7 +1937,7 @@ function SelectControl(arg0) {
|
|
|
1814
1937
|
//#region source/openapi/components/CodeDisplay.tsx
|
|
1815
1938
|
function CopyCodeButton(arg0) {
|
|
1816
1939
|
const { code } = arg0;
|
|
1817
|
-
const t =
|
|
1940
|
+
const t = require_i18n.useBuiltInText();
|
|
1818
1941
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
1819
1942
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1820
1943
|
type: "button",
|
|
@@ -1822,10 +1945,10 @@ function CopyCodeButton(arg0) {
|
|
|
1822
1945
|
require_PageActions.copyTextToClipboard(code).then((ok) => {
|
|
1823
1946
|
if (!ok) return;
|
|
1824
1947
|
setCopied(true);
|
|
1825
|
-
|
|
1948
|
+
setTimeout(() => setCopied(false), 1e3);
|
|
1826
1949
|
});
|
|
1827
1950
|
},
|
|
1828
|
-
className: "flex items-center gap-1.5 rounded-full bg-(--clarify-code-control-background) px-2.5 py-1.5 text-2xs font-medium text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus:bg-(--clarify-code-control-background-hover) focus:text-(--clarify-code-text)",
|
|
1951
|
+
className: "ml-auto flex shrink-0 items-center gap-1.5 rounded-full bg-(--clarify-code-control-background) px-2.5 py-1.5 text-2xs font-medium whitespace-nowrap text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus:bg-(--clarify-code-control-background-hover) focus:text-(--clarify-code-text)",
|
|
1829
1952
|
children: [copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
1830
1953
|
className: "h-3.5 w-3.5 text-(--clarify-theme-tokens-colors-primary)",
|
|
1831
1954
|
"aria-hidden": "true"
|
|
@@ -1850,11 +1973,11 @@ function ExampleMetaValue(arg0) {
|
|
|
1850
1973
|
}
|
|
1851
1974
|
function CodeToolbar(arg0) {
|
|
1852
1975
|
const { code, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
1853
|
-
const t =
|
|
1976
|
+
const t = require_i18n.useBuiltInText();
|
|
1854
1977
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1855
|
-
className: "
|
|
1978
|
+
className: "clarify-api-code-toolbar flex items-center gap-2 px-4 pt-3",
|
|
1856
1979
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1857
|
-
className: "flex min-w-0 items-center gap-2",
|
|
1980
|
+
className: "clarify-api-code-toolbar-controls flex min-w-0 flex-1 flex-wrap items-center gap-2",
|
|
1858
1981
|
children: [languageOptions && languageOptions.length > 1 && selectedLanguageKey && onSelectLanguage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
1859
1982
|
label: t("openapi.language"),
|
|
1860
1983
|
value: selectedLanguageKey,
|
|
@@ -1879,12 +2002,12 @@ function CodeToolbar(arg0) {
|
|
|
1879
2002
|
}
|
|
1880
2003
|
//#endregion
|
|
1881
2004
|
//#region source/openapi/components/helpers.ts
|
|
1882
|
-
function getServers(spec, operation, path) {
|
|
2005
|
+
function getServers(spec, operation, path, source = "path") {
|
|
1883
2006
|
const operationServers = operation.servers;
|
|
1884
|
-
const pathServers = path ?
|
|
1885
|
-
const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : spec.servers;
|
|
2007
|
+
const pathServers = path ? getOperationPathItem(spec, path, source)?.servers : void 0;
|
|
2008
|
+
const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : source === "webhook" ? [{ url: "https://webhook.example.com" }] : spec.servers;
|
|
1886
2009
|
if (!Array.isArray(servers)) return [{ url: "https://api.example.com" }];
|
|
1887
|
-
const validServers = servers.filter((server) => isRecord(server) && typeof server.url === "string");
|
|
2010
|
+
const validServers = servers.filter((server) => isRecord$1(server) && typeof server.url === "string");
|
|
1888
2011
|
return validServers.length > 0 ? validServers : [{ url: "https://api.example.com" }];
|
|
1889
2012
|
}
|
|
1890
2013
|
function getServerKey(server, index) {
|
|
@@ -1898,14 +2021,14 @@ function defaultServerVariables(server) {
|
|
|
1898
2021
|
}
|
|
1899
2022
|
function getSecuritySchemes(spec) {
|
|
1900
2023
|
const schemes = spec.components;
|
|
1901
|
-
if (!isRecord(schemes) || !isRecord(schemes.securitySchemes)) return {};
|
|
1902
|
-
return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord(entry[1])));
|
|
2024
|
+
if (!isRecord$1(schemes) || !isRecord$1(schemes.securitySchemes)) return {};
|
|
2025
|
+
return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord$1(entry[1])));
|
|
1903
2026
|
}
|
|
1904
2027
|
function getSecurityRequirements(spec, operation) {
|
|
1905
2028
|
const operationSecurity = operation.security;
|
|
1906
|
-
if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord);
|
|
2029
|
+
if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord$1);
|
|
1907
2030
|
const specSecurity = spec.security;
|
|
1908
|
-
return Array.isArray(specSecurity) ? specSecurity.filter(isRecord) : [];
|
|
2031
|
+
return Array.isArray(specSecurity) ? specSecurity.filter(isRecord$1) : [];
|
|
1909
2032
|
}
|
|
1910
2033
|
function getAuthOptions(spec, operation) {
|
|
1911
2034
|
const schemes = getSecuritySchemes(spec);
|
|
@@ -1946,7 +2069,7 @@ function getClientOptions(codeOptions, languageKey) {
|
|
|
1946
2069
|
//#region source/openapi/components/ExamplePanels.tsx
|
|
1947
2070
|
function ApiExampleCodeGroup(arg0) {
|
|
1948
2071
|
const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
1949
|
-
const t =
|
|
2072
|
+
const t = require_i18n.useBuiltInText();
|
|
1950
2073
|
const metaClassName = comfortableMeta ? "flex min-h-11 min-w-0 items-center gap-2 border-y border-(--clarify-code-border) border-t-transparent bg-(--clarify-code-background) px-4 py-2" : "flex h-9 min-w-0 items-center gap-2 border-y border-(--clarify-code-border) border-t-transparent bg-(--clarify-code-background) px-4";
|
|
1951
2074
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1952
2075
|
className: "clarify-api-example my-6 overflow-hidden rounded-2xl bg-(--clarify-code-background) shadow-md ring-1 ring-(--clarify-code-border)",
|
|
@@ -1959,7 +2082,7 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
1959
2082
|
className: "mr-auto min-w-16 truncate py-1 text-xs font-semibold text-(--clarify-code-text)",
|
|
1960
2083
|
children: title
|
|
1961
2084
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1962
|
-
className: "ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
2085
|
+
className: "clarify-api-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
1963
2086
|
children: [mediaTypes && mediaTypes.length > 1 && selectedMediaType && onSelectMediaType ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
1964
2087
|
label: t("openapi.mediaType"),
|
|
1965
2088
|
value: selectedMediaType,
|
|
@@ -1999,7 +2122,7 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
1999
2122
|
]
|
|
2000
2123
|
}) : null,
|
|
2001
2124
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2002
|
-
className: "clarify-api-example-code group
|
|
2125
|
+
className: "clarify-api-example-code group bg-(--clarify-code-background)",
|
|
2003
2126
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeToolbar, {
|
|
2004
2127
|
code,
|
|
2005
2128
|
languageOptions,
|
|
@@ -2009,10 +2132,10 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2009
2132
|
selectedClientKey,
|
|
2010
2133
|
onSelectClient
|
|
2011
2134
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
2012
|
-
className:
|
|
2013
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2014
|
-
|
|
2015
|
-
|
|
2135
|
+
className: "max-h-128 overflow-auto overscroll-contain px-4 pt-3 pb-4 text-xs text-(--clarify-code-text)",
|
|
2136
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HighlightedCode, {
|
|
2137
|
+
code,
|
|
2138
|
+
language
|
|
2016
2139
|
})
|
|
2017
2140
|
})]
|
|
2018
2141
|
})
|
|
@@ -2020,13 +2143,13 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2020
2143
|
})
|
|
2021
2144
|
});
|
|
2022
2145
|
}
|
|
2023
|
-
function firstExampleKeyForMediaType(requestContents, mediaType) {
|
|
2024
|
-
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value)[0]?.key ?? "";
|
|
2146
|
+
function firstExampleKeyForMediaType(requestContents, mediaType, spec) {
|
|
2147
|
+
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value, spec)[0]?.key ?? "";
|
|
2025
2148
|
}
|
|
2026
2149
|
function useRequestExamplesState(arg0) {
|
|
2027
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2150
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2028
2151
|
const selectedContent = requestContents.find((content) => content.mediaType === selectedMediaType) ?? requestContents[0];
|
|
2029
|
-
const examples = getExampleEntries(selectedContent?.value);
|
|
2152
|
+
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2030
2153
|
const [selectedExampleKey, setSelectedExampleKey] = (0, react.useState)(examples[0]?.key ?? "");
|
|
2031
2154
|
const [selectedLanguageKey, setSelectedLanguageKey] = (0, react.useState)("shell");
|
|
2032
2155
|
const [selectedClientKey, setSelectedClientKey] = (0, react.useState)("curl");
|
|
@@ -2047,7 +2170,8 @@ function useRequestExamplesState(arg0) {
|
|
|
2047
2170
|
} : void 0,
|
|
2048
2171
|
server: selectedServer,
|
|
2049
2172
|
serverVariables,
|
|
2050
|
-
auth
|
|
2173
|
+
auth,
|
|
2174
|
+
operationSource
|
|
2051
2175
|
});
|
|
2052
2176
|
const selectedLanguage = codeOptions.find((option) => option.languageKey === selectedLanguageKey) ?? codeOptions[0];
|
|
2053
2177
|
const selectedCode = codeOptions.find((option) => option.languageKey === selectedLanguage.languageKey && option.clientKey === selectedClientKey) ?? selectedLanguage;
|
|
@@ -2060,7 +2184,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2060
2184
|
examples,
|
|
2061
2185
|
onSelectMediaType: (value) => {
|
|
2062
2186
|
onSelectMediaType(value);
|
|
2063
|
-
setSelectedExampleKey(firstExampleKeyForMediaType(requestContents, value));
|
|
2187
|
+
setSelectedExampleKey(firstExampleKeyForMediaType(requestContents, value, spec));
|
|
2064
2188
|
},
|
|
2065
2189
|
onSelectExample: (value) => {
|
|
2066
2190
|
setSelectedExampleKey(value);
|
|
@@ -2075,8 +2199,8 @@ function useRequestExamplesState(arg0) {
|
|
|
2075
2199
|
};
|
|
2076
2200
|
}
|
|
2077
2201
|
function RequestExamplesPanel(arg0) {
|
|
2078
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2079
|
-
const t =
|
|
2202
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2203
|
+
const t = require_i18n.useBuiltInText();
|
|
2080
2204
|
const state = useRequestExamplesState({
|
|
2081
2205
|
spec,
|
|
2082
2206
|
path,
|
|
@@ -2088,6 +2212,7 @@ function RequestExamplesPanel(arg0) {
|
|
|
2088
2212
|
selectedServer,
|
|
2089
2213
|
serverVariables,
|
|
2090
2214
|
auth,
|
|
2215
|
+
operationSource,
|
|
2091
2216
|
sharedExampleKey,
|
|
2092
2217
|
onSelectExampleKey
|
|
2093
2218
|
});
|
|
@@ -2111,12 +2236,15 @@ function RequestExamplesPanel(arg0) {
|
|
|
2111
2236
|
onSelectClient: state.onSelectClient
|
|
2112
2237
|
});
|
|
2113
2238
|
}
|
|
2114
|
-
function firstExampleKeyForResponseContent(content) {
|
|
2115
|
-
return getExampleEntries(content?.value)[0]?.key ?? "";
|
|
2239
|
+
function firstExampleKeyForResponseContent(content, spec) {
|
|
2240
|
+
return getExampleEntries(content?.value, spec)[0]?.key ?? "";
|
|
2241
|
+
}
|
|
2242
|
+
function getResponseExampleBody(content, example) {
|
|
2243
|
+
return content ? stringifyExample(example?.value) : "";
|
|
2116
2244
|
}
|
|
2117
2245
|
function useResponseExamplesState(arg0) {
|
|
2118
2246
|
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2119
|
-
const orderedResponses = [...getResponseEntries(operation, spec)
|
|
2247
|
+
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2120
2248
|
if (left.status === "default") return -1;
|
|
2121
2249
|
if (right.status === "default") return 1;
|
|
2122
2250
|
const leftCode = Number(left.status);
|
|
@@ -2131,15 +2259,15 @@ function useResponseExamplesState(arg0) {
|
|
|
2131
2259
|
const [selection, setSelection] = (0, react.useState)(() => ({
|
|
2132
2260
|
status: activeStatus,
|
|
2133
2261
|
mediaType: responseContents[0]?.mediaType ?? "",
|
|
2134
|
-
exampleKey: firstExampleKeyForResponseContent(responseContents[0])
|
|
2262
|
+
exampleKey: firstExampleKeyForResponseContent(responseContents[0], spec)
|
|
2135
2263
|
}));
|
|
2136
2264
|
const resolvedSelection = selection.status === activeStatus ? selection : {
|
|
2137
2265
|
status: activeStatus,
|
|
2138
2266
|
mediaType: responseContents[0]?.mediaType ?? "",
|
|
2139
|
-
exampleKey: firstExampleKeyForResponseContent(responseContents[0])
|
|
2267
|
+
exampleKey: firstExampleKeyForResponseContent(responseContents[0], spec)
|
|
2140
2268
|
};
|
|
2141
2269
|
const selectedContent = responseContents.find((content) => content.mediaType === resolvedSelection.mediaType) ?? responseContents[0];
|
|
2142
|
-
const examples = getExampleEntries(selectedContent?.value);
|
|
2270
|
+
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2143
2271
|
const selectedExampleKey = examples.some((example) => example.key === resolvedSelection.exampleKey) ? resolvedSelection.exampleKey : examples[0]?.key ?? "";
|
|
2144
2272
|
const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
|
|
2145
2273
|
const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
|
|
@@ -2150,7 +2278,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2150
2278
|
selectedContent,
|
|
2151
2279
|
examples,
|
|
2152
2280
|
selectedExample,
|
|
2153
|
-
|
|
2281
|
+
responseBody: getResponseExampleBody(selectedContent, selectedExample),
|
|
2154
2282
|
onSelectStatus: (value) => {
|
|
2155
2283
|
const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
|
|
2156
2284
|
if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
|
|
@@ -2158,7 +2286,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2158
2286
|
setSelection({
|
|
2159
2287
|
status: value,
|
|
2160
2288
|
mediaType: nextContents[0]?.mediaType ?? "",
|
|
2161
|
-
exampleKey: firstExampleKeyForResponseContent(nextContents[0])
|
|
2289
|
+
exampleKey: firstExampleKeyForResponseContent(nextContents[0], spec)
|
|
2162
2290
|
});
|
|
2163
2291
|
},
|
|
2164
2292
|
onSelectMediaType: (value) => {
|
|
@@ -2166,7 +2294,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2166
2294
|
setSelection((current) => ({
|
|
2167
2295
|
...current,
|
|
2168
2296
|
mediaType: value,
|
|
2169
|
-
exampleKey: firstExampleKeyForResponseContent(nextContent)
|
|
2297
|
+
exampleKey: firstExampleKeyForResponseContent(nextContent, spec)
|
|
2170
2298
|
}));
|
|
2171
2299
|
},
|
|
2172
2300
|
onSelectExample: (value) => {
|
|
@@ -2179,8 +2307,8 @@ function useResponseExamplesState(arg0) {
|
|
|
2179
2307
|
};
|
|
2180
2308
|
}
|
|
2181
2309
|
function ResponseExamplesPanel(arg0) {
|
|
2182
|
-
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2183
|
-
const t =
|
|
2310
|
+
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2311
|
+
const t = require_i18n.useBuiltInText();
|
|
2184
2312
|
const state = useResponseExamplesState({
|
|
2185
2313
|
operation,
|
|
2186
2314
|
spec,
|
|
@@ -2189,17 +2317,13 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2189
2317
|
selectedStatus,
|
|
2190
2318
|
onSelectStatus
|
|
2191
2319
|
});
|
|
2192
|
-
if (!state.
|
|
2320
|
+
if (!state.selectedContent || !state.responseBody) return null;
|
|
2193
2321
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
2194
|
-
title: t("openapi.response"),
|
|
2195
|
-
|
|
2196
|
-
tagOptions: state.responses.map(({ status }) => status),
|
|
2197
|
-
onSelectTag: state.onSelectStatus,
|
|
2198
|
-
label: state.selectedContent.mediaType,
|
|
2322
|
+
title: title ?? t("openapi.response"),
|
|
2323
|
+
label: state.selectedContent?.mediaType,
|
|
2199
2324
|
labelOptions: state.responseContents.map((content) => content.mediaType),
|
|
2200
|
-
onSelectLabel: state.onSelectMediaType,
|
|
2201
|
-
|
|
2202
|
-
code: state.responseCode,
|
|
2325
|
+
onSelectLabel: state.responseContents.length > 0 ? state.onSelectMediaType : void 0,
|
|
2326
|
+
code: state.responseBody,
|
|
2203
2327
|
language: codeLanguageForMediaType(state.selectedContent.mediaType),
|
|
2204
2328
|
examples: state.examples,
|
|
2205
2329
|
selectedExampleKey: state.selectedExample?.key,
|
|
@@ -2211,7 +2335,7 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2211
2335
|
function getEnumDescriptions(schema) {
|
|
2212
2336
|
const descriptions = schema["x-enumDescriptions"];
|
|
2213
2337
|
if (Array.isArray(descriptions)) return descriptions.map((value) => typeof value === "string" ? value : void 0);
|
|
2214
|
-
if (isRecord(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
|
|
2338
|
+
if (isRecord$1(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
|
|
2215
2339
|
const description = descriptions[String(value)];
|
|
2216
2340
|
return typeof description === "string" ? description : void 0;
|
|
2217
2341
|
}) : [];
|
|
@@ -2277,7 +2401,7 @@ function getSchemaChildren(arg0) {
|
|
|
2277
2401
|
defaultExpanded
|
|
2278
2402
|
});
|
|
2279
2403
|
}
|
|
2280
|
-
if (!isRecord(schema)) return [];
|
|
2404
|
+
if (!isRecord$1(schema)) return [];
|
|
2281
2405
|
const arrayChildren = schemaHasType(schema, "array") ? getSchemaChildren({
|
|
2282
2406
|
spec,
|
|
2283
2407
|
schema: schema.items,
|
|
@@ -2288,10 +2412,10 @@ function getSchemaChildren(arg0) {
|
|
|
2288
2412
|
}) : [];
|
|
2289
2413
|
const objectRequired = Array.isArray(schema.required) ? schema.required.map(String) : required;
|
|
2290
2414
|
const enumChildren = getEnumChildren(schema, path);
|
|
2291
|
-
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
2415
|
+
const properties = isRecord$1(schema.properties) ? schema.properties : {};
|
|
2292
2416
|
const propertyChildren = Object.entries(properties).map(([name, propertySchema]) => {
|
|
2293
2417
|
const resolvedProperty = resolveSchema(spec, propertySchema);
|
|
2294
|
-
const property = isRecord(resolvedProperty) ? resolvedProperty : isRecord(propertySchema) ? propertySchema : {};
|
|
2418
|
+
const property = isRecord$1(resolvedProperty) ? resolvedProperty : isRecord$1(propertySchema) ? propertySchema : {};
|
|
2295
2419
|
const isArray = schemaHasType(property, "array");
|
|
2296
2420
|
const childPath = path ? `${path}.${name}` : name;
|
|
2297
2421
|
const children = getSchemaChildren({
|
|
@@ -2315,7 +2439,7 @@ function getSchemaChildren(arg0) {
|
|
|
2315
2439
|
children
|
|
2316
2440
|
};
|
|
2317
2441
|
});
|
|
2318
|
-
const additionalPropertyChildren = isRecord(schema.additionalProperties) ? [{
|
|
2442
|
+
const additionalPropertyChildren = isRecord$1(schema.additionalProperties) ? [{
|
|
2319
2443
|
key: `${path || "root"}.*`,
|
|
2320
2444
|
name: "*",
|
|
2321
2445
|
kind: "property",
|
|
@@ -2335,7 +2459,7 @@ function getSchemaChildren(arg0) {
|
|
|
2335
2459
|
}] : [];
|
|
2336
2460
|
const composedChildren = getComposedBranches(schema).map(({ label, schema: branchSchema }) => {
|
|
2337
2461
|
const resolvedBranch = resolveSchema(spec, branchSchema);
|
|
2338
|
-
const branch = isRecord(resolvedBranch) ? resolvedBranch : void 0;
|
|
2462
|
+
const branch = isRecord$1(resolvedBranch) ? resolvedBranch : void 0;
|
|
2339
2463
|
return {
|
|
2340
2464
|
key: `${path || "root"}.${label}`,
|
|
2341
2465
|
name: label,
|
|
@@ -2367,7 +2491,7 @@ function getSchemaChildren(arg0) {
|
|
|
2367
2491
|
function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
2368
2492
|
if (isReference(schema)) {
|
|
2369
2493
|
const resolvedSchema = resolveSchema(spec, schema);
|
|
2370
|
-
const resolved = isRecord(resolvedSchema) ? resolvedSchema : {};
|
|
2494
|
+
const resolved = isRecord$1(resolvedSchema) ? resolvedSchema : {};
|
|
2371
2495
|
return {
|
|
2372
2496
|
key: schema.$ref,
|
|
2373
2497
|
name: resolveReferenceName(schema.$ref),
|
|
@@ -2385,7 +2509,7 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
2385
2509
|
})
|
|
2386
2510
|
};
|
|
2387
2511
|
}
|
|
2388
|
-
if (!isRecord(schema)) return void 0;
|
|
2512
|
+
if (!isRecord$1(schema)) return void 0;
|
|
2389
2513
|
return {
|
|
2390
2514
|
key: "root",
|
|
2391
2515
|
name: "body",
|
|
@@ -2432,7 +2556,7 @@ function EnumValueNode(arg0) {
|
|
|
2432
2556
|
}
|
|
2433
2557
|
function SchemaNode(arg0) {
|
|
2434
2558
|
const { node, depth = 0, defaultExpanded } = arg0;
|
|
2435
|
-
const t =
|
|
2559
|
+
const t = require_i18n.useBuiltInText();
|
|
2436
2560
|
const [expanded, setExpanded] = (0, react.useState)(defaultExpanded ?? depth < 1);
|
|
2437
2561
|
const hasChildren = node.children.length > 0;
|
|
2438
2562
|
if (node.kind === "enum") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EnumValueNode, {
|
|
@@ -2459,7 +2583,7 @@ function SchemaNode(arg0) {
|
|
|
2459
2583
|
className: "*:first:mt-0 *:last:mb-0",
|
|
2460
2584
|
children: node.description
|
|
2461
2585
|
}) : fallbackDescription, node.details ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2462
|
-
className: "text-xs text-(--clarify-ui-text-
|
|
2586
|
+
className: "text-xs text-(--clarify-ui-text-soft)",
|
|
2463
2587
|
children: node.details
|
|
2464
2588
|
}) : null]
|
|
2465
2589
|
})]
|
|
@@ -2475,7 +2599,7 @@ function SchemaNode(arg0) {
|
|
|
2475
2599
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
2476
2600
|
"aria-expanded": expanded,
|
|
2477
2601
|
onClick: () => setExpanded((value) => !value),
|
|
2478
|
-
className: (0, clsx.default)(rowClassName, "cursor-pointer transition"),
|
|
2602
|
+
className: (0, clsx.default)(rowClassName, "cursor-pointer transition hover:bg-(--clarify-ui-hover-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)"),
|
|
2479
2603
|
children: content
|
|
2480
2604
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2481
2605
|
className: rowClassName,
|
|
@@ -2509,7 +2633,7 @@ function SchemaProperties(arg0) {
|
|
|
2509
2633
|
})] });
|
|
2510
2634
|
}
|
|
2511
2635
|
function ParameterList(arg0) {
|
|
2512
|
-
const t =
|
|
2636
|
+
const t = require_i18n.useBuiltInText();
|
|
2513
2637
|
const { title, parameters } = arg0;
|
|
2514
2638
|
if (parameters.length === 0) return null;
|
|
2515
2639
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Properties, { children: parameters.map((parameter) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
|
|
@@ -2522,8 +2646,8 @@ function ParameterList(arg0) {
|
|
|
2522
2646
|
}, `${parameter.in}-${parameter.name}`)) })] });
|
|
2523
2647
|
}
|
|
2524
2648
|
function ResponseList(arg0) {
|
|
2525
|
-
const { operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
2526
|
-
const t =
|
|
2649
|
+
const { title, operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
2650
|
+
const t = require_i18n.useBuiltInText();
|
|
2527
2651
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2528
2652
|
if (left.status === "default") return -1;
|
|
2529
2653
|
if (right.status === "default") return 1;
|
|
@@ -2543,10 +2667,10 @@ function ResponseList(arg0) {
|
|
|
2543
2667
|
children: [
|
|
2544
2668
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2545
2669
|
className: "flex flex-wrap items-center gap-2",
|
|
2546
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2670
|
+
children: [orderedResponses.length === 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2547
2671
|
className: "text-sm/5 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
2548
2672
|
children: status
|
|
2549
|
-
}), type ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2673
|
+
}) : null, type ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2550
2674
|
className: "text-xs text-(--clarify-theme-tokens-colors-muted)",
|
|
2551
2675
|
children: type
|
|
2552
2676
|
}) : null]
|
|
@@ -2571,12 +2695,12 @@ function ResponseList(arg0) {
|
|
|
2571
2695
|
};
|
|
2572
2696
|
if (orderedResponses.length === 1) {
|
|
2573
2697
|
const [{ status, response }] = orderedResponses;
|
|
2574
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.responses") }), renderResponsePanel({
|
|
2698
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title ?? t("openapi.responses") }), renderResponsePanel({
|
|
2575
2699
|
status,
|
|
2576
2700
|
response
|
|
2577
2701
|
})] });
|
|
2578
2702
|
}
|
|
2579
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.responses") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
2703
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title ?? t("openapi.responses") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
2580
2704
|
selectedIndex,
|
|
2581
2705
|
onChange: (index) => {
|
|
2582
2706
|
onSelectStatus?.(orderedResponses[index]?.status ?? "");
|
|
@@ -2595,8 +2719,8 @@ function ResponseList(arg0) {
|
|
|
2595
2719
|
//#endregion
|
|
2596
2720
|
//#region source/openapi/components/EndpointSections.tsx
|
|
2597
2721
|
function EndpointRequest(arg0) {
|
|
2598
|
-
const { spec, path, method, description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2599
|
-
const t =
|
|
2722
|
+
const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2723
|
+
const t = require_i18n.useBuiltInText();
|
|
2600
2724
|
const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
|
|
2601
2725
|
const renderDescription = () => {
|
|
2602
2726
|
if (!description) return null;
|
|
@@ -2647,6 +2771,7 @@ function EndpointRequest(arg0) {
|
|
|
2647
2771
|
selectedServer,
|
|
2648
2772
|
serverVariables,
|
|
2649
2773
|
auth,
|
|
2774
|
+
operationSource,
|
|
2650
2775
|
sharedExampleKey,
|
|
2651
2776
|
onSelectExampleKey
|
|
2652
2777
|
})
|
|
@@ -2655,7 +2780,10 @@ function EndpointRequest(arg0) {
|
|
|
2655
2780
|
})] });
|
|
2656
2781
|
}
|
|
2657
2782
|
function EndpointResponse(arg0) {
|
|
2658
|
-
const { spec, operation, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2783
|
+
const { spec, operation, operationSource = "path", sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2784
|
+
const t = require_i18n.useBuiltInText();
|
|
2785
|
+
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
2786
|
+
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
2659
2787
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2660
2788
|
className: "mt-6",
|
|
2661
2789
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
|
|
@@ -2663,6 +2791,7 @@ function EndpointResponse(arg0) {
|
|
|
2663
2791
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2664
2792
|
className: "w-full",
|
|
2665
2793
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
|
|
2794
|
+
title: responseTitle,
|
|
2666
2795
|
operation,
|
|
2667
2796
|
spec,
|
|
2668
2797
|
selectedStatus,
|
|
@@ -2675,6 +2804,7 @@ function EndpointResponse(arg0) {
|
|
|
2675
2804
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseExamplesPanel, {
|
|
2676
2805
|
operation,
|
|
2677
2806
|
spec,
|
|
2807
|
+
title: responseExampleTitle,
|
|
2678
2808
|
sharedExampleKey,
|
|
2679
2809
|
onSelectExampleKey,
|
|
2680
2810
|
selectedStatus,
|
|
@@ -2687,8 +2817,8 @@ function EndpointResponse(arg0) {
|
|
|
2687
2817
|
}
|
|
2688
2818
|
//#endregion
|
|
2689
2819
|
//#region source/openapi/components/OpenApiOperation.state.ts
|
|
2690
|
-
function useOperationRequestState(spec, path, operation) {
|
|
2691
|
-
const parameters = getOperationParameters(spec, path, operation);
|
|
2820
|
+
function useOperationRequestState(spec, path, operation, source = "path") {
|
|
2821
|
+
const parameters = getOperationParameters(spec, path, operation, source);
|
|
2692
2822
|
const requestBody = getRequestBody$1(spec, operation);
|
|
2693
2823
|
const requestContents = getMediaTypeEntries(requestBody?.content, spec);
|
|
2694
2824
|
const [selectedRequestMediaType, setSelectedRequestMediaType] = (0, react.useState)(requestContents[0]?.mediaType ?? "");
|
|
@@ -2709,8 +2839,8 @@ function useOperationRequestState(spec, path, operation) {
|
|
|
2709
2839
|
groupedParameters
|
|
2710
2840
|
};
|
|
2711
2841
|
}
|
|
2712
|
-
function useOperationServerState(spec, operation, path) {
|
|
2713
|
-
const servers = getServers(spec, operation, path);
|
|
2842
|
+
function useOperationServerState(spec, operation, path, source = "path") {
|
|
2843
|
+
const servers = getServers(spec, operation, path, source);
|
|
2714
2844
|
const [selectedServerKey, setSelectedServerKey] = (0, react.useState)(getServerKey(servers[0], 0));
|
|
2715
2845
|
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
2716
2846
|
const [serverVariables, setServerVariables] = (0, react.useState)(defaultServerVariables(selectedServer));
|
|
@@ -2767,7 +2897,8 @@ var endpointMethodStyleVars = {
|
|
|
2767
2897
|
POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
|
|
2768
2898
|
PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
|
|
2769
2899
|
PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
|
|
2770
|
-
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)"
|
|
2900
|
+
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
|
|
2901
|
+
WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
|
|
2771
2902
|
};
|
|
2772
2903
|
function EndpointMethodBadge(arg0) {
|
|
2773
2904
|
const { method } = arg0;
|
|
@@ -2778,7 +2909,7 @@ function EndpointMethodBadge(arg0) {
|
|
|
2778
2909
|
}
|
|
2779
2910
|
function EndpointPath(arg0) {
|
|
2780
2911
|
const { path, copied = false, onCopy } = arg0;
|
|
2781
|
-
const t =
|
|
2912
|
+
const t = require_i18n.useBuiltInText();
|
|
2782
2913
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2783
2914
|
className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
|
|
2784
2915
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -2792,7 +2923,7 @@ function EndpointPath(arg0) {
|
|
|
2792
2923
|
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
2793
2924
|
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
2794
2925
|
onClick: onCopy,
|
|
2795
|
-
className: (0, clsx.default)("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)", copied && "border-emerald-400/70 bg-emerald-50 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-200"),
|
|
2926
|
+
className: (0, clsx.default)("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) transition hover:border-(--clarify-ui-text-faint) 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)", copied && "border-emerald-400/70 bg-emerald-50 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-200"),
|
|
2796
2927
|
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
2797
2928
|
className: "h-3.5 w-3.5",
|
|
2798
2929
|
"aria-hidden": "true"
|
|
@@ -2813,7 +2944,7 @@ function InlineListbox(arg0) {
|
|
|
2813
2944
|
className: "pointer-events-auto relative inline-flex min-w-0",
|
|
2814
2945
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
|
|
2815
2946
|
"aria-label": label,
|
|
2816
|
-
className: (0, clsx.default)("inline-flex min-w-0 items-center gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) font-semibold text-(--clarify-
|
|
2947
|
+
className: (0, clsx.default)("inline-flex min-w-0 items-center gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) font-semibold text-(--clarify-ui-text-strong) shadow-xs outline-hidden transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) data-open:border-(--clarify-ui-accent-border) data-open:bg-(--clarify-ui-active-background) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)", compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2.5 py-1.5 text-xs"),
|
|
2817
2948
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2818
2949
|
className: "truncate",
|
|
2819
2950
|
children: selected?.label ?? value
|
|
@@ -2826,7 +2957,7 @@ function InlineListbox(arg0) {
|
|
|
2826
2957
|
className: "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-xl bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 ring-1 ring-(--clarify-theme-tokens-colors-border) [--anchor-gap:--spacing(1)] focus:outline-none",
|
|
2827
2958
|
children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
|
|
2828
2959
|
value: option.value,
|
|
2829
|
-
className: "group flex cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-
|
|
2960
|
+
className: "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-lg 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)",
|
|
2830
2961
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2831
2962
|
className: "min-w-0",
|
|
2832
2963
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -2849,9 +2980,12 @@ function getServerPreviewUrl(server, variables) {
|
|
|
2849
2980
|
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
2850
2981
|
}
|
|
2851
2982
|
function getFullEndpointUrl(server, variables, path) {
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2983
|
+
return joinPath(getServerPreviewUrl(server, variables), path);
|
|
2984
|
+
}
|
|
2985
|
+
function getServerProtocolLabel(server, variables) {
|
|
2986
|
+
const url = getServerPreviewUrl(server, variables);
|
|
2987
|
+
const protocol = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toUpperCase();
|
|
2988
|
+
return protocol === "WS" || protocol === "WSS" ? protocol : void 0;
|
|
2855
2989
|
}
|
|
2856
2990
|
function getDefaultResponseStatus(operation, spec) {
|
|
2857
2991
|
const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
|
|
@@ -2867,21 +3001,25 @@ function getDefaultResponseStatus(operation, spec) {
|
|
|
2867
3001
|
function ServerUrlValue(arg0) {
|
|
2868
3002
|
const { server, variables, open, interactive, onToggle } = arg0;
|
|
2869
3003
|
const url = getServerPreviewUrl(server, variables);
|
|
3004
|
+
const protocolLabel = getServerProtocolLabel(server, variables);
|
|
2870
3005
|
if (!interactive) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2871
3006
|
"aria-label": "Server",
|
|
2872
|
-
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text
|
|
3007
|
+
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5",
|
|
2873
3008
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2874
3009
|
className: "sm:hidden",
|
|
2875
3010
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
|
|
2876
3011
|
className: "h-4 w-4",
|
|
2877
3012
|
"aria-hidden": "true"
|
|
2878
3013
|
})
|
|
2879
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
2880
|
-
className: "hidden min-w-0 items-center overflow-hidden sm:flex",
|
|
2881
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3014
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3015
|
+
className: "hidden min-w-0 items-center gap-1.5 overflow-hidden sm:flex",
|
|
3016
|
+
children: [protocolLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3017
|
+
className: "shrink-0 rounded bg-sky-100 px-1.5 py-0.5 text-2xs font-black text-sky-700 dark:bg-sky-400/15 dark:text-sky-200",
|
|
3018
|
+
children: protocolLabel
|
|
3019
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2882
3020
|
className: "truncate font-semibold text-xs",
|
|
2883
3021
|
children: url
|
|
2884
|
-
})
|
|
3022
|
+
})]
|
|
2885
3023
|
})]
|
|
2886
3024
|
});
|
|
2887
3025
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
@@ -2889,7 +3027,7 @@ function ServerUrlValue(arg0) {
|
|
|
2889
3027
|
"aria-expanded": open,
|
|
2890
3028
|
"aria-label": "Server",
|
|
2891
3029
|
onClick: onToggle,
|
|
2892
|
-
className: (0, clsx.default)("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text
|
|
3030
|
+
className: (0, clsx.default)("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) 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) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5", open ? "bg-(--clarify-ui-active-background) text-(--clarify-theme-tokens-colors-foreground)" : null),
|
|
2893
3031
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2894
3032
|
className: "sm:hidden",
|
|
2895
3033
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
|
|
@@ -2898,13 +3036,20 @@ function ServerUrlValue(arg0) {
|
|
|
2898
3036
|
})
|
|
2899
3037
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2900
3038
|
className: "hidden min-w-0 items-center gap-1 overflow-hidden sm:flex",
|
|
2901
|
-
children: [
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
"
|
|
2907
|
-
|
|
3039
|
+
children: [
|
|
3040
|
+
protocolLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3041
|
+
className: "shrink-0 rounded bg-sky-100 px-1.5 py-0.5 text-2xs font-black text-sky-700 dark:bg-sky-400/15 dark:text-sky-200",
|
|
3042
|
+
children: protocolLabel
|
|
3043
|
+
}) : null,
|
|
3044
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3045
|
+
className: "truncate font-semibold text-xs",
|
|
3046
|
+
children: url
|
|
3047
|
+
}),
|
|
3048
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
3049
|
+
className: "h-3.5 w-3.5 shrink-0 text-zinc-400",
|
|
3050
|
+
"aria-hidden": "true"
|
|
3051
|
+
})
|
|
3052
|
+
]
|
|
2908
3053
|
})]
|
|
2909
3054
|
});
|
|
2910
3055
|
}
|
|
@@ -3001,7 +3146,8 @@ function AuthPanel(arg0) {
|
|
|
3001
3146
|
className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3002
3147
|
children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
|
|
3003
3148
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3004
|
-
value: authValues[selectedAuth.name] ??
|
|
3149
|
+
value: authValues[selectedAuth.name] ?? "",
|
|
3150
|
+
placeholder: authPlaceholder(selectedAuth),
|
|
3005
3151
|
onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
|
|
3006
3152
|
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)"
|
|
3007
3153
|
})]
|
|
@@ -3011,14 +3157,14 @@ function AuthPanel(arg0) {
|
|
|
3011
3157
|
});
|
|
3012
3158
|
}
|
|
3013
3159
|
function EndpointIdentity(arg0) {
|
|
3014
|
-
const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3160
|
+
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3015
3161
|
const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
|
|
3016
3162
|
const [copiedUrl, setCopiedUrl] = (0, react.useState)(false);
|
|
3017
3163
|
const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
|
|
3018
3164
|
(0, react.useEffect)(() => {
|
|
3019
3165
|
if (!copiedUrl) return void 0;
|
|
3020
|
-
const timeout =
|
|
3021
|
-
return () =>
|
|
3166
|
+
const timeout = setTimeout(() => setCopiedUrl(false), 1200);
|
|
3167
|
+
return () => clearTimeout(timeout);
|
|
3022
3168
|
}, [copiedUrl]);
|
|
3023
3169
|
async function handleCopyUrl() {
|
|
3024
3170
|
if (await require_PageActions.copyTextToClipboard(fullUrl)) setCopiedUrl(true);
|
|
@@ -3030,6 +3176,7 @@ function EndpointIdentity(arg0) {
|
|
|
3030
3176
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
3031
3177
|
children: [
|
|
3032
3178
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method }),
|
|
3179
|
+
operationSource === "webhook" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
|
|
3033
3180
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerUrlValue, {
|
|
3034
3181
|
server: selectedServer,
|
|
3035
3182
|
variables: serverVariables,
|
|
@@ -3047,7 +3194,7 @@ function EndpointIdentity(arg0) {
|
|
|
3047
3194
|
"aria-expanded": authOpen,
|
|
3048
3195
|
"aria-label": "Auth",
|
|
3049
3196
|
onClick: onToggleAuth,
|
|
3050
|
-
className: (0, clsx.default)("ml-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-emerald-700 dark:hover:text-emerald-200", authOpen ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-400/15 dark:text-emerald-100" : "bg-(--clarify-ui-subtle-background)"),
|
|
3197
|
+
className: (0, clsx.default)("ml-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-emerald-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) dark:hover:text-emerald-200", authOpen ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-400/15 dark:text-emerald-100" : "bg-(--clarify-ui-subtle-background)"),
|
|
3051
3198
|
children: authOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.UnlockKeyholeIcon, {
|
|
3052
3199
|
className: "h-4 w-4",
|
|
3053
3200
|
"aria-hidden": "true"
|
|
@@ -3078,12 +3225,12 @@ function EndpointIdentity(arg0) {
|
|
|
3078
3225
|
});
|
|
3079
3226
|
}
|
|
3080
3227
|
function OpenApiOperation(arg0) {
|
|
3081
|
-
const { spec, path, method, operation } = arg0;
|
|
3082
|
-
const id = (
|
|
3228
|
+
const { spec, path, method, operation, operationSource = "path" } = arg0;
|
|
3229
|
+
const id = getOpenApiOperationSectionId(operation);
|
|
3083
3230
|
const summary = operation.summary ?? `${method} ${path}`;
|
|
3084
3231
|
const description = operation.description;
|
|
3085
|
-
const requestState = useOperationRequestState(spec, path, operation);
|
|
3086
|
-
const serverState = useOperationServerState(spec, operation, path);
|
|
3232
|
+
const requestState = useOperationRequestState(spec, path, operation, operationSource);
|
|
3233
|
+
const serverState = useOperationServerState(spec, operation, path, operationSource);
|
|
3087
3234
|
const authState = useOperationAuthState(spec, operation);
|
|
3088
3235
|
const [linkedExampleKey, setLinkedExampleKey] = (0, react.useState)("");
|
|
3089
3236
|
const [selectedResponseStatus, setSelectedResponseStatus] = (0, react.useState)(() => getDefaultResponseStatus(operation, spec));
|
|
@@ -3097,6 +3244,7 @@ function OpenApiOperation(arg0) {
|
|
|
3097
3244
|
}),
|
|
3098
3245
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointIdentity, {
|
|
3099
3246
|
method,
|
|
3247
|
+
operationSource,
|
|
3100
3248
|
path,
|
|
3101
3249
|
servers: serverState.servers,
|
|
3102
3250
|
selectedServerKey: serverState.selectedServerKey,
|
|
@@ -3125,6 +3273,7 @@ function OpenApiOperation(arg0) {
|
|
|
3125
3273
|
spec,
|
|
3126
3274
|
path,
|
|
3127
3275
|
method,
|
|
3276
|
+
operationSource,
|
|
3128
3277
|
description,
|
|
3129
3278
|
groupedParameters: requestState.groupedParameters,
|
|
3130
3279
|
parameters: requestState.parameters,
|
|
@@ -3142,6 +3291,7 @@ function OpenApiOperation(arg0) {
|
|
|
3142
3291
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointResponse, {
|
|
3143
3292
|
spec,
|
|
3144
3293
|
operation,
|
|
3294
|
+
operationSource,
|
|
3145
3295
|
sharedExampleKey: linkedExampleKey,
|
|
3146
3296
|
onSelectExampleKey: setLinkedExampleKey,
|
|
3147
3297
|
selectedStatus: selectedResponseStatus,
|
|
@@ -3307,6 +3457,12 @@ Object.defineProperty(exports, "getMediaTypeEntries", {
|
|
|
3307
3457
|
return getMediaTypeEntries;
|
|
3308
3458
|
}
|
|
3309
3459
|
});
|
|
3460
|
+
Object.defineProperty(exports, "getOpenApiOperationEntry", {
|
|
3461
|
+
enumerable: true,
|
|
3462
|
+
get: function() {
|
|
3463
|
+
return getOpenApiOperationEntry;
|
|
3464
|
+
}
|
|
3465
|
+
});
|
|
3310
3466
|
Object.defineProperty(exports, "getRequestBody", {
|
|
3311
3467
|
enumerable: true,
|
|
3312
3468
|
get: function() {
|
|
@@ -3325,6 +3481,12 @@ Object.defineProperty(exports, "getServers", {
|
|
|
3325
3481
|
return getServers;
|
|
3326
3482
|
}
|
|
3327
3483
|
});
|
|
3484
|
+
Object.defineProperty(exports, "listOpenApiOperations", {
|
|
3485
|
+
enumerable: true,
|
|
3486
|
+
get: function() {
|
|
3487
|
+
return listOpenApiOperations;
|
|
3488
|
+
}
|
|
3489
|
+
});
|
|
3328
3490
|
Object.defineProperty(exports, "primitives_exports", {
|
|
3329
3491
|
enumerable: true,
|
|
3330
3492
|
get: function() {
|
|
@@ -3332,4 +3494,4 @@ Object.defineProperty(exports, "primitives_exports", {
|
|
|
3332
3494
|
}
|
|
3333
3495
|
});
|
|
3334
3496
|
|
|
3335
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
3497
|
+
//# sourceMappingURL=OpenApiOperation-B52IWlKb.cjs.map
|