zudoku 0.0.0-f3786a4 → 0.0.0-f3f6db5
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/dist/app/main.js +1 -2
- package/dist/app/main.js.map +1 -1
- package/dist/config/validators/InputSidebarSchema.d.ts +2 -2
- package/dist/lib/components/PathRenderer.d.ts +11 -0
- package/dist/lib/components/PathRenderer.js +25 -0
- package/dist/lib/components/PathRenderer.js.map +1 -0
- package/dist/lib/components/ThemeSwitch.js +4 -4
- package/dist/lib/components/ThemeSwitch.js.map +1 -1
- package/dist/lib/components/index.d.ts +1 -0
- package/dist/lib/components/index.js +4 -2
- package/dist/lib/components/index.js.map +1 -1
- package/dist/lib/components/navigation/SidebarCategory.js +17 -15
- package/dist/lib/components/navigation/SidebarCategory.js.map +1 -1
- package/dist/lib/oas/graphql/circular.js +17 -6
- package/dist/lib/oas/graphql/circular.js.map +1 -1
- package/dist/lib/oas/graphql/index.d.ts +1 -0
- package/dist/lib/oas/graphql/index.js +41 -23
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/plugins/openapi/ColorizedParam.js +3 -1
- package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
- package/dist/lib/plugins/openapi/Endpoint.js +2 -2
- package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
- package/dist/lib/plugins/openapi/{Route.d.ts → OpenApiRoute.d.ts} +2 -1
- package/dist/lib/plugins/openapi/{Route.js → OpenApiRoute.js} +3 -4
- package/dist/lib/plugins/openapi/OpenApiRoute.js.map +1 -0
- package/dist/lib/plugins/openapi/OperationList.d.ts +4 -1
- package/dist/lib/plugins/openapi/OperationList.js +20 -14
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js +2 -2
- package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.d.ts +1 -1
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +2 -0
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +6 -11
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/SidecarExamples.js +17 -14
- package/dist/lib/plugins/openapi/SidecarExamples.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.d.ts +6 -2
- package/dist/lib/plugins/openapi/graphql/gql.js +3 -2
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +47 -26
- package/dist/lib/plugins/openapi/graphql/graphql.js +20 -16
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.js +97 -54
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +1 -0
- package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js +5 -5
- package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/Headers.js +17 -16
- package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/ParamsGrid.d.ts +5 -0
- package/dist/lib/plugins/openapi/playground/ParamsGrid.js +4 -0
- package/dist/lib/plugins/openapi/playground/ParamsGrid.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/PathParams.js +4 -12
- package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/Playground.d.ts +13 -0
- package/dist/lib/plugins/openapi/playground/Playground.js +25 -45
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/QueryParams.js +4 -3
- package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/SubmitButton.d.ts +7 -0
- package/dist/lib/plugins/openapi/playground/SubmitButton.js +22 -0
- package/dist/lib/plugins/openapi/playground/SubmitButton.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/result-panel/RequestTab.d.ts +7 -0
- package/dist/lib/plugins/openapi/playground/result-panel/RequestTab.js +11 -0
- package/dist/lib/plugins/openapi/playground/result-panel/RequestTab.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.d.ts +8 -0
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +95 -0
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.d.ts +7 -0
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js +16 -0
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.d.ts +10 -0
- package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.js +32 -0
- package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.test.d.ts +1 -0
- package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.test.js +56 -0
- package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.test.js.map +1 -0
- package/dist/lib/plugins/openapi/schema/{SchemaComponents.js → SchemaPropertyItem.js} +10 -8
- package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js.map +1 -0
- package/dist/lib/plugins/openapi/schema/SchemaView.js +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/utils.d.ts +1 -0
- package/dist/lib/plugins/openapi/schema/utils.js +2 -0
- package/dist/lib/plugins/openapi/schema/utils.js.map +1 -1
- package/dist/lib/ui/Command.js +1 -1
- package/dist/lib/ui/Command.js.map +1 -1
- package/dist/lib/ui/Select.js +2 -2
- package/dist/lib/ui/Select.js.map +1 -1
- package/dist/lib/util/joinUrl.js +1 -1
- package/dist/lib/util/joinUrl.js.map +1 -1
- package/dist/lib/util/joinUrl.test.d.ts +1 -0
- package/dist/lib/util/joinUrl.test.js +43 -0
- package/dist/lib/util/joinUrl.test.js.map +1 -0
- package/dist/vite/plugin-api.js +9 -1
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/prerender.js +0 -1
- package/dist/vite/prerender.js.map +1 -1
- package/lib/{AuthenticationPlugin-CvwlQWjV.js → AuthenticationPlugin-Du8cLBSr.js} +2 -2
- package/lib/{AuthenticationPlugin-CvwlQWjV.js.map → AuthenticationPlugin-Du8cLBSr.js.map} +1 -1
- package/lib/{Markdown-B8o9Qz4q.js → Markdown-Cyrx_JrO.js} +8 -9
- package/lib/{Markdown-B8o9Qz4q.js.map → Markdown-Cyrx_JrO.js.map} +1 -1
- package/lib/{MdxPage-DiWukCrZ.js → MdxPage-BuG8Tuwc.js} +5 -5
- package/lib/{MdxPage-DiWukCrZ.js.map → MdxPage-BuG8Tuwc.js.map} +1 -1
- package/lib/OpenApiRoute-UrC_t0e5.js +36 -0
- package/lib/OpenApiRoute-UrC_t0e5.js.map +1 -0
- package/lib/{OperationList-CyNwMHMV.js → OperationList-CDt1xdc4.js} +1925 -1902
- package/lib/OperationList-CDt1xdc4.js.map +1 -0
- package/lib/{Select-4kIgJ1bc.js → Select-CnCZ4WhS.js} +61 -61
- package/lib/Select-CnCZ4WhS.js.map +1 -0
- package/lib/{SlotletProvider-CtIp8rP3.js → SlotletProvider-mQiPDQIH.js} +2 -2
- package/lib/{SlotletProvider-CtIp8rP3.js.map → SlotletProvider-mQiPDQIH.js.map} +1 -1
- package/lib/{SyntaxHighlight-C1w1QPdY.js → SyntaxHighlight-B0L4SC_N.js} +11 -5
- package/lib/SyntaxHighlight-B0L4SC_N.js.map +1 -0
- package/lib/{ZudokuContext-Bp2uQx1d.js → ZudokuContext-BTUJPpQl.js} +36 -35
- package/lib/{ZudokuContext-Bp2uQx1d.js.map → ZudokuContext-BTUJPpQl.js.map} +1 -1
- package/lib/{circular-Dgpd6AN-.js → circular-DxaIIlWD.js} +251 -239
- package/lib/{circular-Dgpd6AN-.js.map → circular-DxaIIlWD.js.map} +1 -1
- package/lib/{createServer-BV0tHzLK.js → createServer-CjNktZzL.js} +821 -808
- package/lib/{createServer-BV0tHzLK.js.map → createServer-CjNktZzL.js.map} +1 -1
- package/lib/{hook-BDmay56y.js → hook-FT3SJLe_.js} +2 -2
- package/lib/{hook-BDmay56y.js.map → hook-FT3SJLe_.js.map} +1 -1
- package/lib/{index-LNp6rxyU.js → index-CjJS0l4l.js} +2 -2
- package/lib/{index-LNp6rxyU.js.map → index-CjJS0l4l.js.map} +1 -1
- package/lib/index-Eb1oiHbM.js +1997 -0
- package/lib/index-Eb1oiHbM.js.map +1 -0
- package/lib/{joinUrl-BTy9bvoK.js → joinUrl-nLx9pD-Z.js} +2 -2
- package/lib/joinUrl-nLx9pD-Z.js.map +1 -0
- package/lib/ui/Command.js +27 -27
- package/lib/ui/Command.js.map +1 -1
- package/lib/ui/Select.js +2 -2
- package/lib/ui/Select.js.map +1 -1
- package/lib/{useScrollToAnchor-S-NbG5Za.js → useScrollToAnchor-BZsGmBng.js} +86 -90
- package/lib/useScrollToAnchor-BZsGmBng.js.map +1 -0
- package/lib/zudoku.auth-clerk.js +1 -1
- package/lib/zudoku.auth-openid.js +3 -3
- package/lib/zudoku.components.js +364 -348
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.plugin-api-catalog.js +3 -3
- package/lib/zudoku.plugin-api-keys.js +4 -4
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +6 -5
- package/lib/zudoku.plugin-openapi.js.map +1 -1
- package/package.json +1 -1
- package/src/app/main.tsx +1 -2
- package/src/lib/components/PathRenderer.tsx +59 -0
- package/src/lib/components/ThemeSwitch.tsx +15 -14
- package/src/lib/components/index.ts +7 -5
- package/src/lib/components/navigation/SidebarCategory.tsx +44 -41
- package/src/lib/oas/graphql/circular.ts +27 -6
- package/src/lib/oas/graphql/index.ts +63 -35
- package/src/lib/plugins/openapi/ColorizedParam.tsx +3 -3
- package/src/lib/plugins/openapi/Endpoint.tsx +2 -2
- package/src/lib/plugins/openapi/{Route.tsx → OpenApiRoute.tsx} +3 -3
- package/src/lib/plugins/openapi/OperationList.tsx +34 -12
- package/src/lib/plugins/openapi/OperationListItem.tsx +6 -1
- package/src/lib/plugins/openapi/ParameterListItem.tsx +2 -1
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +2 -0
- package/src/lib/plugins/openapi/Sidecar.tsx +18 -27
- package/src/lib/plugins/openapi/SidecarExamples.tsx +24 -24
- package/src/lib/plugins/openapi/graphql/gql.ts +12 -4
- package/src/lib/plugins/openapi/graphql/graphql.ts +66 -43
- package/src/lib/plugins/openapi/index.tsx +125 -67
- package/src/lib/plugins/openapi/interfaces.ts +1 -0
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +30 -27
- package/src/lib/plugins/openapi/playground/Headers.tsx +65 -65
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +8 -0
- package/src/lib/plugins/openapi/playground/PathParams.tsx +34 -74
- package/src/lib/plugins/openapi/playground/Playground.tsx +86 -148
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +1 -1
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +46 -45
- package/src/lib/plugins/openapi/playground/SubmitButton.tsx +75 -0
- package/src/lib/plugins/openapi/playground/result-panel/RequestTab.tsx +73 -0
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +210 -0
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +101 -0
- package/src/lib/plugins/openapi/playground/result-panel/convertToTypes.test.ts +64 -0
- package/src/lib/plugins/openapi/playground/result-panel/convertToTypes.ts +36 -0
- package/src/lib/plugins/openapi/schema/{SchemaComponents.tsx → SchemaPropertyItem.tsx} +10 -6
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +4 -1
- package/src/lib/plugins/openapi/schema/utils.ts +4 -0
- package/src/lib/ui/Command.tsx +1 -1
- package/src/lib/ui/Select.tsx +1 -1
- package/src/lib/util/joinUrl.test.ts +62 -0
- package/src/lib/util/joinUrl.ts +1 -1
- package/dist/lib/plugins/openapi/Route.js.map +0 -1
- package/dist/lib/plugins/openapi/playground/ResponseTab.d.ts +0 -4
- package/dist/lib/plugins/openapi/playground/ResponseTab.js +0 -42
- package/dist/lib/plugins/openapi/playground/ResponseTab.js.map +0 -1
- package/dist/lib/plugins/openapi/schema/SchemaComponents.js.map +0 -1
- package/lib/OperationList-CyNwMHMV.js.map +0 -1
- package/lib/Route-DH64hIrR.js +0 -35
- package/lib/Route-DH64hIrR.js.map +0 -1
- package/lib/Select-4kIgJ1bc.js.map +0 -1
- package/lib/StaggeredRender-DgsamH_G.js +0 -17
- package/lib/StaggeredRender-DgsamH_G.js.map +0 -1
- package/lib/SyntaxHighlight-C1w1QPdY.js.map +0 -1
- package/lib/index-Bn6Lc9tq.js +0 -9
- package/lib/index-Bn6Lc9tq.js.map +0 -1
- package/lib/index-BtNudmKQ.js +0 -1744
- package/lib/index-BtNudmKQ.js.map +0 -1
- package/lib/joinUrl-BTy9bvoK.js.map +0 -1
- package/lib/useScrollToAnchor-S-NbG5Za.js.map +0 -1
- package/src/lib/plugins/openapi/playground/ResponseTab.tsx +0 -76
- /package/dist/lib/plugins/openapi/schema/{SchemaComponents.d.ts → SchemaPropertyItem.d.ts} +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { ChevronRightIcon } from "lucide-react";
|
|
3
|
+
import { Fragment, useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
Collapsible,
|
|
6
|
+
CollapsibleContent,
|
|
7
|
+
CollapsibleTrigger,
|
|
8
|
+
} from "zudoku/ui/Collapsible.js";
|
|
9
|
+
import {
|
|
10
|
+
Select,
|
|
11
|
+
SelectContent,
|
|
12
|
+
SelectItem,
|
|
13
|
+
SelectTrigger,
|
|
14
|
+
SelectValue,
|
|
15
|
+
} from "zudoku/ui/Select.js";
|
|
16
|
+
import { SyntaxHighlight } from "../../../../components/SyntaxHighlight.js";
|
|
17
|
+
import { Card } from "../../../../ui/Card.js";
|
|
18
|
+
import { convertToTypes } from "./convertToTypes.js";
|
|
19
|
+
|
|
20
|
+
const statusCodeMap: Record<number, string> = {
|
|
21
|
+
200: "OK",
|
|
22
|
+
201: "Created",
|
|
23
|
+
202: "Accepted",
|
|
24
|
+
204: "No Content",
|
|
25
|
+
400: "Bad Request",
|
|
26
|
+
401: "Unauthorized",
|
|
27
|
+
403: "Forbidden",
|
|
28
|
+
404: "Not Found",
|
|
29
|
+
405: "Method Not Allowed",
|
|
30
|
+
500: "Internal Server Error",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const mimeTypeToLanguage = (mimeType: string) => {
|
|
34
|
+
const mimeTypeMapping = {
|
|
35
|
+
"application/json": "json",
|
|
36
|
+
"text/json": "json",
|
|
37
|
+
"text/html": "html",
|
|
38
|
+
"text/css": "css",
|
|
39
|
+
"text/javascript": "javascript",
|
|
40
|
+
"application/xml": "xml",
|
|
41
|
+
"application/xhtml+xml": "xhtml",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return Object.entries(mimeTypeMapping).find(([mime]) =>
|
|
45
|
+
mimeType.includes(mime),
|
|
46
|
+
)?.[1];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const detectLanguage = (headers: Array<[string, string]>) => {
|
|
50
|
+
const contentType =
|
|
51
|
+
headers.find(([key, value]) => key === "Content-Type")?.[1] || "";
|
|
52
|
+
return mimeTypeToLanguage(contentType);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const tryParseJson = (body: string) => {
|
|
56
|
+
try {
|
|
57
|
+
return JSON.stringify(JSON.parse(body), null, 2);
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const sortHeadersByRelevance = (
|
|
64
|
+
headers: Array<[string, string]>,
|
|
65
|
+
): Array<[string, string]> => {
|
|
66
|
+
const priorityOrder = [
|
|
67
|
+
"Content-Type",
|
|
68
|
+
"Content-Length",
|
|
69
|
+
"Authorization",
|
|
70
|
+
"X-RateLimit-Remaining",
|
|
71
|
+
"X-RateLimit-Limit",
|
|
72
|
+
"Cache-Control",
|
|
73
|
+
"ETag",
|
|
74
|
+
].map((key) => key.toLowerCase());
|
|
75
|
+
|
|
76
|
+
return [...headers].sort(([keyA], [keyB]) => {
|
|
77
|
+
const indexA = priorityOrder.indexOf(keyA.toLowerCase());
|
|
78
|
+
const indexB = priorityOrder.indexOf(keyB.toLowerCase());
|
|
79
|
+
if (indexA === indexB) return 0;
|
|
80
|
+
if (indexA === -1) return 1;
|
|
81
|
+
if (indexB === -1) return -1;
|
|
82
|
+
return indexA - indexB;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const ResponseTab = ({
|
|
87
|
+
body = "",
|
|
88
|
+
headers,
|
|
89
|
+
status,
|
|
90
|
+
time,
|
|
91
|
+
size,
|
|
92
|
+
url,
|
|
93
|
+
}: {
|
|
94
|
+
body?: string;
|
|
95
|
+
headers: Array<[string, string]>;
|
|
96
|
+
status: number;
|
|
97
|
+
time: number;
|
|
98
|
+
size: number;
|
|
99
|
+
url: string;
|
|
100
|
+
}) => {
|
|
101
|
+
const detectedLanguage = detectLanguage(headers);
|
|
102
|
+
const jsonContent = tryParseJson(body);
|
|
103
|
+
const beautifiedBody = jsonContent || body;
|
|
104
|
+
const [view, setView] = useState<"formatted" | "raw" | "types">(
|
|
105
|
+
jsonContent ? "formatted" : "raw",
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const types = useQuery({
|
|
109
|
+
queryKey: ["types", beautifiedBody],
|
|
110
|
+
queryFn: async () => {
|
|
111
|
+
return convertToTypes(JSON.parse(beautifiedBody));
|
|
112
|
+
},
|
|
113
|
+
enabled: view === "types",
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const sortedHeaders = sortHeadersByRelevance([...headers]);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className="flex flex-col gap-2 h-full overflow-y-scroll max-h-[calc(100vh-220px)] py-4">
|
|
120
|
+
<Collapsible defaultOpen>
|
|
121
|
+
<CollapsibleTrigger className="flex items-center gap-2 hover:text-primary group">
|
|
122
|
+
<ChevronRightIcon className="h-4 w-4 transition-transform duration-200 group-data-[state=open]:rotate-[90deg]" />
|
|
123
|
+
<span className="font-semibold">Headers</span>
|
|
124
|
+
</CollapsibleTrigger>
|
|
125
|
+
<CollapsibleContent>
|
|
126
|
+
<div className="grid grid-cols-[auto,1fr] gap-x-8 gap-y-1 pl-1.5 pt-2 font-mono text-xs">
|
|
127
|
+
{sortedHeaders.slice(0, 5).map(([key, value]) => (
|
|
128
|
+
<Fragment key={key}>
|
|
129
|
+
<div className="text-primary whitespace-pre">{key}</div>
|
|
130
|
+
<div className="break-all">{value}</div>
|
|
131
|
+
</Fragment>
|
|
132
|
+
))}
|
|
133
|
+
{sortedHeaders.length > 5 && (
|
|
134
|
+
<Collapsible className="col-span-full grid-cols-subgrid grid">
|
|
135
|
+
<CollapsibleTrigger className="col-span-2 text-xs text-muted-foreground hover:text-primary flex items-center gap-1 py-1">
|
|
136
|
+
<ChevronRightIcon className="h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-[90deg]" />
|
|
137
|
+
Show {sortedHeaders.length - 5} more headers
|
|
138
|
+
</CollapsibleTrigger>
|
|
139
|
+
<CollapsibleContent className="col-span-full grid grid-cols-subgrid gap-x-8 gap-y-1 ">
|
|
140
|
+
{sortedHeaders.slice(5).map(([key, value]) => (
|
|
141
|
+
<Fragment key={key}>
|
|
142
|
+
<div className="text-primary whitespace-pre">{key}</div>
|
|
143
|
+
<div className="break-all">{value}</div>
|
|
144
|
+
</Fragment>
|
|
145
|
+
))}
|
|
146
|
+
</CollapsibleContent>
|
|
147
|
+
</Collapsible>
|
|
148
|
+
)}
|
|
149
|
+
</div>
|
|
150
|
+
</CollapsibleContent>
|
|
151
|
+
</Collapsible>
|
|
152
|
+
|
|
153
|
+
<Card className="shadow-none">
|
|
154
|
+
<SyntaxHighlight
|
|
155
|
+
language={
|
|
156
|
+
view === "types"
|
|
157
|
+
? "typescript"
|
|
158
|
+
: view === "raw"
|
|
159
|
+
? jsonContent
|
|
160
|
+
? "plain"
|
|
161
|
+
: detectedLanguage
|
|
162
|
+
: "json"
|
|
163
|
+
}
|
|
164
|
+
noBackground
|
|
165
|
+
// playground dialog has h-5/6 ≈ 83.333vh
|
|
166
|
+
className="overflow-x-auto p-4 text-xs max-h-[calc(83.333vh-180px)]"
|
|
167
|
+
code={
|
|
168
|
+
(view === "raw"
|
|
169
|
+
? body
|
|
170
|
+
: view === "types"
|
|
171
|
+
? types.data?.lines.join("\n")
|
|
172
|
+
: beautifiedBody) ?? ""
|
|
173
|
+
}
|
|
174
|
+
/>
|
|
175
|
+
</Card>
|
|
176
|
+
<div className="flex gap-2 justify-between">
|
|
177
|
+
<div className="flex text-xs gap-2 border bg-muted rounded-md p-2 items-center h-8 font-mono divide-x">
|
|
178
|
+
<div>
|
|
179
|
+
<span className="text-muted-foreground">Status</span> {status}{" "}
|
|
180
|
+
{statusCodeMap[status] ?? ""}
|
|
181
|
+
</div>
|
|
182
|
+
<div>
|
|
183
|
+
<span className="text-muted-foreground">Time</span>{" "}
|
|
184
|
+
{time.toFixed(0)}ms
|
|
185
|
+
</div>
|
|
186
|
+
<div>
|
|
187
|
+
<span className="text-muted-foreground">Size</span> {size}B
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
{jsonContent && (
|
|
191
|
+
<div>
|
|
192
|
+
<Select
|
|
193
|
+
value={view}
|
|
194
|
+
onValueChange={(value) => setView(value as "formatted" | "raw")}
|
|
195
|
+
>
|
|
196
|
+
<SelectTrigger className="min-w-32">
|
|
197
|
+
<SelectValue placeholder="View" />
|
|
198
|
+
</SelectTrigger>
|
|
199
|
+
<SelectContent>
|
|
200
|
+
<SelectItem value="formatted">Formatted</SelectItem>
|
|
201
|
+
<SelectItem value="raw">Raw</SelectItem>
|
|
202
|
+
<SelectItem value="types">Types</SelectItem>
|
|
203
|
+
</SelectContent>
|
|
204
|
+
</Select>
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
);
|
|
210
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import { Spinner } from "../../../../components/Spinner.js";
|
|
3
|
+
import { Callout } from "../../../../ui/Callout.js";
|
|
4
|
+
import {
|
|
5
|
+
Card,
|
|
6
|
+
CardContent,
|
|
7
|
+
CardHeader,
|
|
8
|
+
CardTitle,
|
|
9
|
+
} from "../../../../ui/Card.js";
|
|
10
|
+
import {
|
|
11
|
+
Tabs,
|
|
12
|
+
TabsContent,
|
|
13
|
+
TabsList,
|
|
14
|
+
TabsTrigger,
|
|
15
|
+
} from "../../../../ui/Tabs.js";
|
|
16
|
+
import { cn } from "../../../../util/cn.js";
|
|
17
|
+
import { PlaygroundResult } from "../Playground.js";
|
|
18
|
+
import { RequestTab } from "./RequestTab.js";
|
|
19
|
+
import { ResponseTab } from "./ResponseTab.js";
|
|
20
|
+
|
|
21
|
+
export const ResultPanel = ({
|
|
22
|
+
queryMutation,
|
|
23
|
+
showPathParamsWarning,
|
|
24
|
+
}: {
|
|
25
|
+
queryMutation: UseMutationResult<PlaygroundResult, Error, any, unknown>;
|
|
26
|
+
showPathParamsWarning: boolean;
|
|
27
|
+
}) => {
|
|
28
|
+
const status = ((queryMutation.data?.status ?? 0) / 100).toFixed(0);
|
|
29
|
+
return (
|
|
30
|
+
<div className="min-w-0 p-8 bg-muted/70 overflow-y-auto">
|
|
31
|
+
{queryMutation.error ? (
|
|
32
|
+
<div className="flex flex-col gap-2">
|
|
33
|
+
{showPathParamsWarning && (
|
|
34
|
+
<Callout type="caution">
|
|
35
|
+
Some path parameters are missing values. Please fill them in to
|
|
36
|
+
ensure the request is sent correctly.
|
|
37
|
+
</Callout>
|
|
38
|
+
)}
|
|
39
|
+
<Card>
|
|
40
|
+
<CardHeader>
|
|
41
|
+
<CardTitle>Request failed</CardTitle>
|
|
42
|
+
</CardHeader>
|
|
43
|
+
<CardContent>
|
|
44
|
+
Error:{" "}
|
|
45
|
+
{queryMutation.error.message ||
|
|
46
|
+
String(queryMutation.error) ||
|
|
47
|
+
"Unexpected error"}
|
|
48
|
+
</CardContent>
|
|
49
|
+
</Card>
|
|
50
|
+
</div>
|
|
51
|
+
) : queryMutation.data ? (
|
|
52
|
+
<div className="flex flex-col gap-2">
|
|
53
|
+
<Tabs defaultValue="response">
|
|
54
|
+
<TabsList>
|
|
55
|
+
<TabsTrigger value="request">Request</TabsTrigger>
|
|
56
|
+
<TabsTrigger value="response">
|
|
57
|
+
Response
|
|
58
|
+
<span
|
|
59
|
+
className={cn(
|
|
60
|
+
"text-xs font-mono ml-1",
|
|
61
|
+
status === "2" && "text-green-500",
|
|
62
|
+
status === "3" && "text-blue-500",
|
|
63
|
+
status === "4" && "text-yellow-500",
|
|
64
|
+
status === "5" && "text-red-500",
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
({queryMutation.data.status})
|
|
68
|
+
</span>
|
|
69
|
+
</TabsTrigger>
|
|
70
|
+
</TabsList>
|
|
71
|
+
<TabsContent value="request">
|
|
72
|
+
<RequestTab {...queryMutation.data.request} />
|
|
73
|
+
</TabsContent>
|
|
74
|
+
<TabsContent value="response">
|
|
75
|
+
<ResponseTab
|
|
76
|
+
status={queryMutation.data.status}
|
|
77
|
+
time={queryMutation.data.time}
|
|
78
|
+
size={queryMutation.data.size}
|
|
79
|
+
headers={queryMutation.data.headers}
|
|
80
|
+
body={queryMutation.data.body}
|
|
81
|
+
url={queryMutation.data.request.url}
|
|
82
|
+
/>
|
|
83
|
+
</TabsContent>
|
|
84
|
+
</Tabs>
|
|
85
|
+
</div>
|
|
86
|
+
) : (
|
|
87
|
+
<div className="grid place-items-center h-full">
|
|
88
|
+
<span className="text-[16px] font-semibold text-muted-foreground">
|
|
89
|
+
{queryMutation.isPending ? (
|
|
90
|
+
<Spinner />
|
|
91
|
+
) : (
|
|
92
|
+
"Send a request first to see the response here"
|
|
93
|
+
)}
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default ResultPanel;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { generateInterface } from "./convertToTypes.js";
|
|
3
|
+
|
|
4
|
+
describe("generateInterface", () => {
|
|
5
|
+
it("should handle primitive types", () => {
|
|
6
|
+
const input = {
|
|
7
|
+
string: "hello",
|
|
8
|
+
number: 42,
|
|
9
|
+
boolean: true,
|
|
10
|
+
null: null,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const expected = [
|
|
14
|
+
"{",
|
|
15
|
+
" string: string;",
|
|
16
|
+
" number: number;",
|
|
17
|
+
" boolean: boolean;",
|
|
18
|
+
" null: null;",
|
|
19
|
+
"}",
|
|
20
|
+
].join("\n");
|
|
21
|
+
|
|
22
|
+
expect(generateInterface(input)).toBe(expected);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should handle nested objects", () => {
|
|
26
|
+
const input = {
|
|
27
|
+
user: {
|
|
28
|
+
name: "John",
|
|
29
|
+
age: 30,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const expected = [
|
|
34
|
+
"{",
|
|
35
|
+
" user: {",
|
|
36
|
+
" name: string;",
|
|
37
|
+
" age: number;",
|
|
38
|
+
"};",
|
|
39
|
+
"}",
|
|
40
|
+
].join("\n");
|
|
41
|
+
|
|
42
|
+
expect(generateInterface(input)).toBe(expected);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should handle arrays", () => {
|
|
46
|
+
const input = {
|
|
47
|
+
numbers: [1, 2, 3],
|
|
48
|
+
empty: [],
|
|
49
|
+
objects: [{ id: 1 }],
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const expected = [
|
|
53
|
+
"{",
|
|
54
|
+
" numbers: number[];",
|
|
55
|
+
" empty: any[];",
|
|
56
|
+
" objects: {",
|
|
57
|
+
" id: number;",
|
|
58
|
+
"}[];",
|
|
59
|
+
"}",
|
|
60
|
+
].join("\n");
|
|
61
|
+
|
|
62
|
+
expect(generateInterface(input)).toBe(expected);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
2
|
+
type JsonObject = { [key: string]: JsonValue };
|
|
3
|
+
type JsonArray = JsonValue[];
|
|
4
|
+
|
|
5
|
+
function inferType(value: JsonValue): string {
|
|
6
|
+
if (value === null) return "null";
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
if (value.length === 0) return "any[]";
|
|
9
|
+
const firstValue = value[0];
|
|
10
|
+
if (firstValue === undefined) return "any[]";
|
|
11
|
+
const elementType = inferType(firstValue);
|
|
12
|
+
return `${elementType}[]`;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === "object") {
|
|
15
|
+
return generateInterface(value);
|
|
16
|
+
}
|
|
17
|
+
return typeof value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function generateInterface(obj: JsonObject, indentation = ""): string {
|
|
21
|
+
const lines: string[] = ["{"];
|
|
22
|
+
|
|
23
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
24
|
+
const propertyType = inferType(value);
|
|
25
|
+
lines.push(` ${key}: ${propertyType};`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
lines.push("}");
|
|
29
|
+
return lines.join("\n");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function convertToTypes(json: JsonValue): { lines: string[] } {
|
|
33
|
+
const typeDefinition = inferType(json);
|
|
34
|
+
const lines = [`type GeneratedType = ${typeDefinition};`];
|
|
35
|
+
return { lines };
|
|
36
|
+
}
|
|
@@ -3,7 +3,6 @@ import { ListPlusIcon, RefreshCcwDotIcon } from "lucide-react";
|
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { Badge } from "zudoku/ui/Badge.js";
|
|
5
5
|
import { Markdown, ProseClasses } from "../../../components/Markdown.js";
|
|
6
|
-
import { CIRCULAR_REF } from "../../../oas/graphql/circular.js";
|
|
7
6
|
import type { SchemaObject } from "../../../oas/parser/index.js";
|
|
8
7
|
import { Button } from "../../../ui/Button.js";
|
|
9
8
|
import { cn } from "../../../util/cn.js";
|
|
@@ -12,6 +11,7 @@ import { LogicalGroup } from "./LogicalGroup/LogicalGroup.js";
|
|
|
12
11
|
import { SchemaView } from "./SchemaView.js";
|
|
13
12
|
import {
|
|
14
13
|
hasLogicalGroupings,
|
|
14
|
+
isCircularRef,
|
|
15
15
|
isComplexType,
|
|
16
16
|
LogicalSchemaTypeMap,
|
|
17
17
|
} from "./utils.js";
|
|
@@ -41,13 +41,10 @@ export const SchemaLogicalGroup = ({
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const isCircularRef = (schema: unknown): schema is string =>
|
|
45
|
-
schema === CIRCULAR_REF;
|
|
46
|
-
|
|
47
44
|
const RecursiveIndicator = () => (
|
|
48
45
|
<div className="flex items-center gap-2 italic text-sm text-muted-foreground font-mono bg-muted px-2 py-0.5 rounded-md">
|
|
49
46
|
<RefreshCcwDotIcon size={16} />
|
|
50
|
-
<span>
|
|
47
|
+
<span>circular</span>
|
|
51
48
|
</div>
|
|
52
49
|
);
|
|
53
50
|
|
|
@@ -74,6 +71,8 @@ export const SchemaPropertyItem = ({
|
|
|
74
71
|
<div className="flex flex-col gap-1 justify-between text-sm">
|
|
75
72
|
<div className="flex gap-2 items-center">
|
|
76
73
|
<code>{name}</code>
|
|
74
|
+
<Badge variant="muted">object</Badge>
|
|
75
|
+
{group === "optional" && <Badge variant="outline">optional</Badge>}
|
|
77
76
|
<RecursiveIndicator />
|
|
78
77
|
</div>
|
|
79
78
|
</div>
|
|
@@ -96,6 +95,9 @@ export const SchemaPropertyItem = ({
|
|
|
96
95
|
)}
|
|
97
96
|
</Badge>
|
|
98
97
|
{group === "optional" && <Badge variant="outline">optional</Badge>}
|
|
98
|
+
{schema.type === "array" &&
|
|
99
|
+
"items" in schema &&
|
|
100
|
+
isCircularRef(schema.items) && <RecursiveIndicator />}
|
|
99
101
|
</div>
|
|
100
102
|
|
|
101
103
|
{schema.description && (
|
|
@@ -133,7 +135,9 @@ export const SchemaPropertyItem = ({
|
|
|
133
135
|
<SchemaView schema={schema} level={level + 1} />
|
|
134
136
|
) : (
|
|
135
137
|
schema.type === "array" &&
|
|
136
|
-
|
|
138
|
+
"items" in schema &&
|
|
139
|
+
typeof schema.items === "object" &&
|
|
140
|
+
!isCircularRef(schema.items) && (
|
|
137
141
|
<SchemaView schema={schema.items} level={level + 1} />
|
|
138
142
|
)
|
|
139
143
|
)}
|
|
@@ -3,7 +3,10 @@ import type { SchemaObject } from "../../../oas/parser/index.js";
|
|
|
3
3
|
import { Card, CardContent, CardHeader, CardTitle } from "../../../ui/Card.js";
|
|
4
4
|
import { cn } from "../../../util/cn.js";
|
|
5
5
|
import { groupBy } from "../../../util/groupBy.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
SchemaLogicalGroup,
|
|
8
|
+
SchemaPropertyItem,
|
|
9
|
+
} from "./SchemaPropertyItem.js";
|
|
7
10
|
import { hasLogicalGroupings } from "./utils.js";
|
|
8
11
|
|
|
9
12
|
export const SchemaView = ({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CIRCULAR_REF } from "../../../oas/graphql/circular.js";
|
|
1
2
|
import type { SchemaObject } from "../../../oas/parser/index.js";
|
|
2
3
|
|
|
3
4
|
export const isComplexType = (value: SchemaObject) =>
|
|
@@ -16,3 +17,6 @@ export const LogicalSchemaTypeMap = {
|
|
|
16
17
|
} as const;
|
|
17
18
|
|
|
18
19
|
export type LogicalGroupType = "AND" | "OR" | "ONE";
|
|
20
|
+
|
|
21
|
+
export const isCircularRef = (schema: unknown): schema is string =>
|
|
22
|
+
schema === CIRCULAR_REF;
|
package/src/lib/ui/Command.tsx
CHANGED
|
@@ -61,7 +61,7 @@ const CommandInlineInput = React.forwardRef<
|
|
|
61
61
|
<CommandPrimitive.Input
|
|
62
62
|
ref={ref}
|
|
63
63
|
className={cn(
|
|
64
|
-
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none
|
|
64
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
65
65
|
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
66
66
|
className,
|
|
67
67
|
)}
|
package/src/lib/ui/Select.tsx
CHANGED
|
@@ -83,9 +83,9 @@ const SelectContent = React.forwardRef<
|
|
|
83
83
|
<SelectScrollUpButton />
|
|
84
84
|
<SelectPrimitive.Viewport
|
|
85
85
|
className={cn(
|
|
86
|
-
"p-1",
|
|
87
86
|
position === "popper" &&
|
|
88
87
|
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
|
|
88
|
+
"divide-y",
|
|
89
89
|
)}
|
|
90
90
|
>
|
|
91
91
|
{children}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { joinUrl } from "./joinUrl.js";
|
|
3
|
+
|
|
4
|
+
describe("joinUrl", () => {
|
|
5
|
+
test("handles basic URL joining", () => {
|
|
6
|
+
expect(joinUrl("https://example.com", "path")).toBe(
|
|
7
|
+
"https://example.com/path",
|
|
8
|
+
);
|
|
9
|
+
expect(joinUrl("https://example.com/", "path")).toBe(
|
|
10
|
+
"https://example.com/path",
|
|
11
|
+
);
|
|
12
|
+
expect(joinUrl("https://example.com/", "/path")).toBe(
|
|
13
|
+
"https://example.com/path",
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("handles multiple path segments", () => {
|
|
18
|
+
expect(joinUrl("https://example.com", "api", "v1", "users")).toBe(
|
|
19
|
+
"https://example.com/api/v1/users",
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// test("handles query parameters", () => {
|
|
24
|
+
// expect(joinUrl("https://example.com", "path?query=1")).toBe(
|
|
25
|
+
// "https://example.com/path?query=1",
|
|
26
|
+
// );
|
|
27
|
+
// expect(joinUrl("https://example.com?base=1", "path?query=1")).toBe(
|
|
28
|
+
// "https://example.com/path?query=1",
|
|
29
|
+
// );
|
|
30
|
+
// });
|
|
31
|
+
|
|
32
|
+
// test("handles repeated dots and question marks", () => {
|
|
33
|
+
// expect(joinUrl("https://example.com", "path/../../../test")).toBe(
|
|
34
|
+
// "https://example.com/path/../../../test",
|
|
35
|
+
// );
|
|
36
|
+
// expect(joinUrl("https://example.com", "test????a=1")).toBe(
|
|
37
|
+
// "https://example.com/test????a=1",
|
|
38
|
+
// );
|
|
39
|
+
// });
|
|
40
|
+
|
|
41
|
+
test("handles falsy values", () => {
|
|
42
|
+
expect(joinUrl("https://example.com", null, undefined, false, "path")).toBe(
|
|
43
|
+
"https://example.com/path",
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("handles numeric values", () => {
|
|
48
|
+
expect(joinUrl("https://example.com", "api", 123, "test")).toBe(
|
|
49
|
+
"https://example.com/api/123/test",
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("handles relative paths", () => {
|
|
54
|
+
expect(joinUrl("/api", "v1", "users")).toBe("/api/v1/users");
|
|
55
|
+
expect(joinUrl("api", "v1", "users")).toBe("/api/v1/users");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("handles empty input", () => {
|
|
59
|
+
expect(joinUrl()).toBe("/");
|
|
60
|
+
expect(joinUrl("")).toBe("/");
|
|
61
|
+
});
|
|
62
|
+
});
|
package/src/lib/util/joinUrl.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Mostly adapted from https://github.com/moxystudio/js-proper-url-join
|
|
2
|
-
const defaultUrlRegExp = /^(\w+:\/\/[^/?]+)?(
|
|
2
|
+
const defaultUrlRegExp = /^(\w+:\/\/[^/?]+)?([^?]*)(\?.*)?$/;
|
|
3
3
|
|
|
4
4
|
const normalizeParts = (
|
|
5
5
|
parts: (string | number | null | undefined | false)[],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../../src/lib/plugins/openapi/Route.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,GAMP,EAAE,EAAE;IACH,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,EAAa,CAAC;IAE3C,MAAM,KAAK,GACT,MAAM,CAAC,IAAI,KAAK,MAAM;QACpB,CAAC,CAAC;YACE,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,OAAO;gBACZ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAE;gBACxB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE;SACvC;QACH,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IAEjD,MAAM,cAAc,GAAG,OAAO,IAAI,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEjD,OAAO,CACL,KAAC,iBAAiB,IAChB,KAAK,EAAE;YACL,MAAM,EAAE;gBACN,GAAG,MAAM;gBACT,OAAO,EAAE,cAAc;gBACvB,QAAQ,EAAE,MAAM,CAAC,WAAW,CAC1B,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAClE;gBACD,GAAG,KAAK;aACT;SACF,YAED,KAAC,eAAe,IAAC,MAAM,EAAE,MAAM,YAC7B,KAAC,MAAM,KAAG,GACM,GACA,CACrB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { SyntaxHighlight } from "../../../components/SyntaxHighlight.js";
|
|
4
|
-
import { Card } from "../../../ui/Card.js";
|
|
5
|
-
import { SimpleSelect } from "../SimpleSelect.js";
|
|
6
|
-
const mimeTypeToLanguage = (mimeType) => {
|
|
7
|
-
const mimeTypeMapping = {
|
|
8
|
-
"application/json": "json",
|
|
9
|
-
"text/json": "json",
|
|
10
|
-
"text/html": "html",
|
|
11
|
-
"text/css": "css",
|
|
12
|
-
"text/javascript": "javascript",
|
|
13
|
-
"application/xml": "xml",
|
|
14
|
-
"application/xhtml+xml": "xhtml",
|
|
15
|
-
};
|
|
16
|
-
return Object.entries(mimeTypeMapping).find(([mime]) => mimeType.includes(mime))?.[1];
|
|
17
|
-
};
|
|
18
|
-
const detectLanguage = (headers) => {
|
|
19
|
-
const contentType = headers.get("Content-Type") || "";
|
|
20
|
-
return mimeTypeToLanguage(contentType);
|
|
21
|
-
};
|
|
22
|
-
const tryParseJson = (body) => {
|
|
23
|
-
try {
|
|
24
|
-
return JSON.stringify(JSON.parse(body), null, 2);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export const ResponseTab = ({ body = "", headers, }) => {
|
|
31
|
-
const detectedLanguage = detectLanguage(headers);
|
|
32
|
-
const jsonContent = tryParseJson(body);
|
|
33
|
-
const beautifiedBody = jsonContent || body;
|
|
34
|
-
const [view, setView] = useState(jsonContent ? "formatted" : "raw");
|
|
35
|
-
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Card, { className: "shadow-none", children: _jsx(SyntaxHighlight, { language: view === "raw" ? (jsonContent ? "plain" : detectedLanguage) : "json", noBackground: true,
|
|
36
|
-
// playground dialog has h-5/6 ≈ 83.333vh
|
|
37
|
-
className: "overflow-x-auto p-4 text-xs max-h-[calc(83.333vh-180px)]", code: view === "raw" ? body : beautifiedBody }) }), jsonContent && (_jsx("div", { className: "flex justify-end", children: _jsx(SimpleSelect, { value: view, onChange: (e) => setView(e.target.value), options: [
|
|
38
|
-
{ value: "formatted", label: "Formatted" },
|
|
39
|
-
{ value: "raw", label: "Raw" },
|
|
40
|
-
] }) }))] }));
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=ResponseTab.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseTab.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/playground/ResponseTab.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC9C,MAAM,eAAe,GAAG;QACtB,kBAAkB,EAAE,MAAM;QAC1B,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,MAAM;QACnB,UAAU,EAAE,KAAK;QACjB,iBAAiB,EAAE,YAAY;QAC/B,iBAAiB,EAAE,KAAK;QACxB,uBAAuB,EAAE,OAAO;KACjC,CAAC;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CACrD,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CACxB,EAAE,CAAC,CAAC,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IACtD,OAAO,kBAAkB,CAAC,WAAW,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;IACpC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd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