zudoku 0.1.1-dev.30 → 0.1.1-dev.32
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/App.js +7 -2
- package/dist/app/App.js.map +1 -1
- package/dist/config/config.d.ts +5 -0
- package/dist/lib/components/Header.js +1 -1
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/Layout.js +1 -1
- package/dist/lib/components/Layout.js.map +1 -1
- package/dist/lib/components/SyntaxHighlight.d.ts +1 -0
- package/dist/lib/components/SyntaxHighlight.js +1 -1
- package/dist/lib/components/SyntaxHighlight.js.map +1 -1
- package/dist/lib/components/context/DevPortalProvider.js +1 -1
- package/dist/lib/components/context/DevPortalProvider.js.map +1 -1
- package/dist/lib/components/navigation/SideNavigation.js +1 -1
- package/dist/lib/components/navigation/SideNavigation.js.map +1 -1
- package/dist/lib/components/navigation/SideNavigationCategory.js +1 -1
- package/dist/lib/components/navigation/SideNavigationCategory.js.map +1 -1
- package/dist/lib/components/navigation/SideNavigationItem.d.ts +1 -0
- package/dist/lib/components/navigation/SideNavigationItem.js +8 -1
- package/dist/lib/components/navigation/SideNavigationItem.js.map +1 -1
- package/dist/lib/components/navigation/SideNavigationWrapper.d.ts +3 -0
- package/dist/lib/components/navigation/SideNavigationWrapper.js +2 -3
- package/dist/lib/components/navigation/SideNavigationWrapper.js.map +1 -1
- package/dist/lib/core/DevPortalContext.d.ts +1 -0
- package/dist/lib/core/DevPortalContext.js +2 -2
- package/dist/lib/core/DevPortalContext.js.map +1 -1
- package/dist/lib/core/plugins.d.ts +1 -1
- package/dist/lib/core/plugins.js +1 -1
- package/dist/lib/core/plugins.js.map +1 -1
- package/dist/lib/plugins/api-key/CreateApiKeys.d.ts +5 -0
- package/dist/lib/plugins/api-key/CreateApiKeys.js +37 -0
- package/dist/lib/plugins/api-key/CreateApiKeys.js.map +1 -0
- package/dist/lib/plugins/api-key/SettingsApiKeys.d.ts +3 -2
- package/dist/lib/plugins/api-key/SettingsApiKeys.js +30 -4
- package/dist/lib/plugins/api-key/SettingsApiKeys.js.map +1 -1
- package/dist/lib/plugins/api-key/index.d.ts +18 -21
- package/dist/lib/plugins/api-key/index.js +49 -24
- package/dist/lib/plugins/api-key/index.js.map +1 -1
- package/dist/lib/plugins/markdown/MdxPage.js +1 -1
- package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
- package/dist/lib/plugins/openapi/MakeRequest.js +22 -12
- package/dist/lib/plugins/openapi/MakeRequest.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js +24 -1
- package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +1 -1
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +2 -2
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +13 -13
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.d.ts +2 -2
- package/dist/lib/plugins/openapi/graphql/gql.js +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +1 -0
- package/dist/lib/plugins/openapi/graphql/graphql.js +4 -0
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.js +2 -0
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/Headers.js +5 -16
- package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/InlineInput.js +1 -1
- package/dist/lib/plugins/openapi/playground/{UrlParts.d.ts → PathParams.d.ts} +2 -2
- package/dist/lib/plugins/openapi/playground/{UrlParts.js → PathParams.js} +4 -4
- package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/Playground.d.ts +7 -4
- package/dist/lib/plugins/openapi/playground/Playground.js +48 -46
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/QueryParams.d.ts +4 -6
- package/dist/lib/plugins/openapi/playground/QueryParams.js +27 -22
- package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/UrlDisplay.d.ts +4 -0
- package/dist/lib/plugins/openapi/playground/UrlDisplay.js +22 -0
- package/dist/lib/plugins/openapi/playground/UrlDisplay.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/createUrl.d.ts +2 -0
- package/dist/lib/plugins/openapi/playground/createUrl.js +15 -0
- package/dist/lib/plugins/openapi/playground/createUrl.js.map +1 -0
- package/dist/lib/plugins/openapi/util/generateSchemaExample.d.ts +1 -1
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js +19 -9
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
- package/dist/lib/util/MdxComponents.js +1 -1
- package/dist/lib/util/MdxComponents.js.map +1 -1
- package/dist/vite/plugin-api-keys.d.ts +4 -0
- package/dist/vite/plugin-api-keys.js +33 -0
- package/dist/vite/plugin-api-keys.js.map +1 -0
- package/dist/vite/plugin-component.js +8 -20
- package/dist/vite/plugin-component.js.map +1 -1
- package/dist/vite/plugin-mdx.js +1 -1
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/dist/vite/plugin.js +2 -0
- package/dist/vite/plugin.js.map +1 -1
- package/lib/{urql-B7mLfVog.js → urql-DMlBWUKL.js} +301 -321
- package/lib/{DevPortal-COMmOqxP.js → util-CJko6Ria.js} +3661 -4915
- package/lib/zudoku.components.js +1313 -4
- package/lib/zudoku.openapi-worker.js +1 -1
- package/lib/zudoku.plugins.js +16287 -15966
- package/package.json +1 -1
- package/src/app/App.tsx +7 -2
- package/src/lib/components/Header.tsx +3 -3
- package/src/lib/components/Layout.tsx +6 -1
- package/src/lib/components/SyntaxHighlight.tsx +6 -3
- package/src/lib/components/context/DevPortalProvider.ts +1 -1
- package/src/lib/components/navigation/SideNavigation.tsx +4 -1
- package/src/lib/components/navigation/SideNavigationCategory.tsx +3 -1
- package/src/lib/components/navigation/SideNavigationItem.tsx +8 -1
- package/src/lib/components/navigation/SideNavigationWrapper.tsx +14 -11
- package/src/lib/core/DevPortalContext.ts +3 -2
- package/src/lib/core/plugins.ts +1 -1
- package/src/lib/plugins/api-key/CreateApiKeys.tsx +84 -0
- package/src/lib/plugins/api-key/SettingsApiKeys.tsx +105 -11
- package/src/lib/plugins/api-key/index.tsx +71 -66
- package/src/lib/plugins/markdown/MdxPage.tsx +2 -2
- package/src/lib/plugins/openapi/MakeRequest.tsx +25 -23
- package/src/lib/plugins/openapi/OperationListItem.tsx +137 -1
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +1 -1
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +1 -2
- package/src/lib/plugins/openapi/Sidecar.tsx +20 -20
- package/src/lib/plugins/openapi/graphql/gql.ts +3 -3
- package/src/lib/plugins/openapi/graphql/graphql.ts +5 -0
- package/src/lib/plugins/openapi/index.tsx +2 -0
- package/src/lib/plugins/openapi/playground/Headers.tsx +14 -20
- package/src/lib/plugins/openapi/playground/InlineInput.tsx +1 -1
- package/src/lib/plugins/openapi/playground/{UrlParts.tsx → PathParams.tsx} +22 -26
- package/src/lib/plugins/openapi/playground/Playground.tsx +205 -155
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +84 -57
- package/src/lib/plugins/openapi/playground/UrlDisplay.tsx +32 -0
- package/src/lib/plugins/openapi/playground/createUrl.ts +22 -0
- package/src/lib/plugins/openapi/util/generateSchemaExample.ts +24 -9
- package/src/lib/util/MdxComponents.tsx +1 -0
- package/dist/lib/plugins/openapi/playground/UrlParts.js.map +0 -1
- package/src/lib/plugins/openapi/queries.graphql +0 -6
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
import { useApiIdentities } from "../../components/context/DevPortalProvider.js";
|
|
2
1
|
import type { OperationListItemResult } from "./OperationList.js";
|
|
3
2
|
import { Playground } from "./playground/Playground.js";
|
|
4
3
|
import { useOasConfig } from "./index.js";
|
|
5
|
-
import {
|
|
4
|
+
import { graphql } from "./graphql/index.js";
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
import { useQuery } from "urql";
|
|
7
|
+
|
|
8
|
+
const GetServerQuery = graphql(/* GraphQL */ `
|
|
8
9
|
query getServerQuery($input: JSON!, $type: SchemaType!) {
|
|
9
10
|
schema(input: $input, type: $type) {
|
|
10
11
|
url
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
`);
|
|
14
15
|
|
|
15
16
|
export const MakeRequest = ({
|
|
16
17
|
operation,
|
|
17
18
|
}: {
|
|
18
19
|
operation: OperationListItemResult;
|
|
19
20
|
}) => {
|
|
20
|
-
const identities = useApiIdentities();
|
|
21
21
|
const variables = useOasConfig();
|
|
22
|
-
const [server] = useQuery({ query:
|
|
22
|
+
const [server] = useQuery({ query: GetServerQuery, variables });
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<div>
|
|
26
26
|
<Playground
|
|
27
|
-
host={server.data?.schema.url}
|
|
27
|
+
host={server.data?.schema.url ?? ""}
|
|
28
28
|
method={operation.method}
|
|
29
29
|
url={operation.path}
|
|
30
|
-
|
|
30
|
+
headers={operation.parameters
|
|
31
|
+
?.filter((p) => p.in === "header")
|
|
32
|
+
.map((param) => ({
|
|
33
|
+
name: param.name,
|
|
34
|
+
value: "",
|
|
35
|
+
}))}
|
|
36
|
+
queryParams={operation.parameters
|
|
37
|
+
?.filter((p) => p.in === "query")
|
|
38
|
+
.map((param) => ({
|
|
39
|
+
name: param.name,
|
|
40
|
+
value: "",
|
|
41
|
+
}))}
|
|
42
|
+
pathParams={operation.parameters
|
|
43
|
+
?.filter((p) => p.in === "path")
|
|
44
|
+
.map((param) => ({
|
|
45
|
+
name: param.name,
|
|
46
|
+
value: "",
|
|
47
|
+
}))}
|
|
31
48
|
/>
|
|
32
|
-
{identities.data.map((identity) => (
|
|
33
|
-
<button
|
|
34
|
-
key={identity.id}
|
|
35
|
-
onClick={() => {
|
|
36
|
-
const test = new Request(
|
|
37
|
-
"https://zudoku-customer-main-b36fa2f.d2.zuplo.dev" +
|
|
38
|
-
operation.path,
|
|
39
|
-
);
|
|
40
|
-
void fetch(identity.authorizeRequest(test));
|
|
41
|
-
}}
|
|
42
|
-
className="p-2 border border-border rounded hover:bg-accent"
|
|
43
|
-
>
|
|
44
|
-
Test Request {operation.path} ({identity.name})
|
|
45
|
-
</button>
|
|
46
|
-
))}
|
|
47
49
|
</div>
|
|
48
50
|
);
|
|
49
51
|
};
|
|
@@ -5,6 +5,10 @@ import { OperationsFragment } from "./OperationList.js";
|
|
|
5
5
|
import { ParameterList } from "./ParameterList.js";
|
|
6
6
|
import { Sidecar } from "./Sidecar.js";
|
|
7
7
|
import { FragmentType, useFragment } from "./graphql/index.js";
|
|
8
|
+
import { SchemaObject } from "../../oas/parser/index.js";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { cn } from "../../util/cn.js";
|
|
11
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../ui/Tabs.js";
|
|
8
12
|
|
|
9
13
|
export const PARAM_GROUPS = ["path", "query", "header", "cookie"] as const;
|
|
10
14
|
export type ParameterGroup = (typeof PARAM_GROUPS)[number];
|
|
@@ -16,7 +20,7 @@ export const OperationListItem = ({
|
|
|
16
20
|
}) => {
|
|
17
21
|
const operation = useFragment(OperationsFragment, operationFragment);
|
|
18
22
|
const groupedParameters = groupBy(operation?.parameters ?? [], "in");
|
|
19
|
-
|
|
23
|
+
const first = operation.responses.find((re) => re.statusCode === "200");
|
|
20
24
|
return (
|
|
21
25
|
<div
|
|
22
26
|
key={operation.operationId}
|
|
@@ -48,8 +52,140 @@ export const OperationListItem = ({
|
|
|
48
52
|
)}
|
|
49
53
|
</div>
|
|
50
54
|
)}
|
|
55
|
+
<Heading level={3} className="capitalize">
|
|
56
|
+
Repsonses
|
|
57
|
+
</Heading>
|
|
58
|
+
<Tabs defaultValue={`${first?.statusCode}${first?.description}`}>
|
|
59
|
+
<TabsList>
|
|
60
|
+
{operation.responses.map((response) => (
|
|
61
|
+
<TabsTrigger value={response.statusCode + response.description}>
|
|
62
|
+
{response.description} ({response.statusCode})
|
|
63
|
+
</TabsTrigger>
|
|
64
|
+
))}
|
|
65
|
+
</TabsList>
|
|
66
|
+
<ul className="list-none m-0 px-0 overflow-hidden">
|
|
67
|
+
{operation.responses.map((response) => (
|
|
68
|
+
<TabsContent value={response.statusCode + response.description}>
|
|
69
|
+
<ViewSchema schema={response.content?.at(0)?.schema} name="" />
|
|
70
|
+
</TabsContent>
|
|
71
|
+
))}
|
|
72
|
+
</ul>
|
|
73
|
+
</Tabs>
|
|
51
74
|
</div>
|
|
75
|
+
|
|
52
76
|
<Sidecar operation={operation} />
|
|
53
77
|
</div>
|
|
54
78
|
);
|
|
55
79
|
};
|
|
80
|
+
|
|
81
|
+
const ViewSchema = ({
|
|
82
|
+
name,
|
|
83
|
+
schema,
|
|
84
|
+
level = 0,
|
|
85
|
+
collapsible = false,
|
|
86
|
+
}: {
|
|
87
|
+
level?: number;
|
|
88
|
+
collapsible?: boolean;
|
|
89
|
+
name?: string;
|
|
90
|
+
schema: SchemaObject;
|
|
91
|
+
}) => {
|
|
92
|
+
const [open, setOpen] = useState(!collapsible);
|
|
93
|
+
|
|
94
|
+
const properties = Object.entries(schema.properties ?? {});
|
|
95
|
+
const additionalProperties =
|
|
96
|
+
typeof schema.additionalProperties === "object"
|
|
97
|
+
? Object.entries(schema.additionalProperties)
|
|
98
|
+
: [];
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div
|
|
102
|
+
className={cn(
|
|
103
|
+
"not-prose",
|
|
104
|
+
level > 0 && "border border-border rounded text-sm",
|
|
105
|
+
)}
|
|
106
|
+
onClick={
|
|
107
|
+
collapsible
|
|
108
|
+
? () => {
|
|
109
|
+
setOpen((open) => !open);
|
|
110
|
+
}
|
|
111
|
+
: undefined
|
|
112
|
+
}
|
|
113
|
+
>
|
|
114
|
+
{(schema.title ?? name) && (
|
|
115
|
+
<div className="ml-2 my-1 font-bold">{schema.title ?? name}</div>
|
|
116
|
+
)}
|
|
117
|
+
{level === 0 && <p>schema.description</p>}
|
|
118
|
+
<ul>
|
|
119
|
+
{open &&
|
|
120
|
+
properties
|
|
121
|
+
.concat(additionalProperties)
|
|
122
|
+
.map(([propertyName, property]) => (
|
|
123
|
+
<div
|
|
124
|
+
className={cn(
|
|
125
|
+
level > 0 ? "py-2" : "py-4",
|
|
126
|
+
"px-2 border-t border-border bg-border/20 hover:bg-border/30 flex gap-1 flex-col",
|
|
127
|
+
property.deprecated && "opacity-50",
|
|
128
|
+
)}
|
|
129
|
+
>
|
|
130
|
+
<div className="flex items-center gap-2 relative">
|
|
131
|
+
<code>
|
|
132
|
+
{propertyName} {property.title}
|
|
133
|
+
</code>
|
|
134
|
+
|
|
135
|
+
{property.type && (
|
|
136
|
+
<span className="text-sm text-muted-foreground">
|
|
137
|
+
{property.type}
|
|
138
|
+
</span>
|
|
139
|
+
)}
|
|
140
|
+
{property.deprecated && (
|
|
141
|
+
<span className="text-sm text-muted-foreground">
|
|
142
|
+
Deprecated
|
|
143
|
+
</span>
|
|
144
|
+
)}
|
|
145
|
+
|
|
146
|
+
{!schema.required?.includes(propertyName) &&
|
|
147
|
+
!property.required && (
|
|
148
|
+
<span className="py-px px-1.5 font-medium text-xs border border-border rounded-lg">
|
|
149
|
+
optional
|
|
150
|
+
</span>
|
|
151
|
+
)}
|
|
152
|
+
{/*{property.type === "object" && (*/}
|
|
153
|
+
{/* <div className="absolute right-3">+</div>*/}
|
|
154
|
+
{/*)}*/}
|
|
155
|
+
</div>
|
|
156
|
+
{property.description && (
|
|
157
|
+
<Markdown
|
|
158
|
+
content={property.description}
|
|
159
|
+
className="prose text-sm prose-p:my-1 leading-normal line-clamp-4"
|
|
160
|
+
/>
|
|
161
|
+
)}
|
|
162
|
+
|
|
163
|
+
{property.enum && (
|
|
164
|
+
<span className="text-sm text-muted-foreground flex gap-1 flex-wrap items-center">
|
|
165
|
+
<span>Possible values</span>
|
|
166
|
+
{property.enum
|
|
167
|
+
.filter((value) => value)
|
|
168
|
+
.map((value) => (
|
|
169
|
+
<span className="font-mono text-xs border-border border bg-muted rounded px-1">
|
|
170
|
+
{value}
|
|
171
|
+
</span>
|
|
172
|
+
))}
|
|
173
|
+
</span>
|
|
174
|
+
)}
|
|
175
|
+
{property.type === "object" && (
|
|
176
|
+
<div className="mt-2.5">
|
|
177
|
+
<ViewSchema schema={property} level={level + 1} />
|
|
178
|
+
</div>
|
|
179
|
+
)}
|
|
180
|
+
{property.type === "array" &&
|
|
181
|
+
property.items.type === "object" && (
|
|
182
|
+
<div className="mt-2.5">
|
|
183
|
+
<ViewSchema schema={property.items} level={level + 1} />
|
|
184
|
+
</div>
|
|
185
|
+
)}
|
|
186
|
+
</div>
|
|
187
|
+
))}
|
|
188
|
+
</ul>
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
};
|
|
@@ -20,7 +20,7 @@ export const ResponsesSidecarBox = ({
|
|
|
20
20
|
return (
|
|
21
21
|
<SidecarBox.Root>
|
|
22
22
|
<SidecarBox.Head className="text-xs grid grid-rows-2 pb-0">
|
|
23
|
-
<span className="font-mono">Responses</span>
|
|
23
|
+
<span className="font-mono">Example Responses</span>
|
|
24
24
|
<div className="flex gap-2">
|
|
25
25
|
{responses.map((response, index) => (
|
|
26
26
|
<div
|
|
@@ -43,7 +43,6 @@ export const ResponsesSidecarBox = ({
|
|
|
43
43
|
<SyntaxHighlight
|
|
44
44
|
language="json"
|
|
45
45
|
noBackground
|
|
46
|
-
copyable={false}
|
|
47
46
|
className="text-xs"
|
|
48
47
|
code={JSON.stringify(generateSchemaExample(schema), null, 2)}
|
|
49
48
|
/>
|
|
@@ -111,7 +111,6 @@ export const Sidecar = ({
|
|
|
111
111
|
return (
|
|
112
112
|
<aside className="flex flex-col overflow-hidden sticky top-[--scroll-padding] gap-4">
|
|
113
113
|
<SidecarBox.Root>
|
|
114
|
-
<MakeRequest operation={operation} />
|
|
115
114
|
<SidecarBox.Head className="flex justify-between items-center flex-nowrap p-2 gap-2 text-xs">
|
|
116
115
|
<span className="font-mono break-words">
|
|
117
116
|
<span className={cn("font-semibold", methodTextColor)}>
|
|
@@ -120,35 +119,36 @@ export const Sidecar = ({
|
|
|
120
119
|
|
|
121
120
|
{path}
|
|
122
121
|
</span>
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
122
|
+
<div className="flex gap-2 items-center">
|
|
123
|
+
<Select
|
|
124
|
+
className="self-start"
|
|
125
|
+
onChange={(e) => setOption(e.target.value)}
|
|
126
|
+
options={[
|
|
127
|
+
{ value: "shell", label: "cURL" },
|
|
128
|
+
{ value: "js", label: "Javascript" },
|
|
129
|
+
{ value: "python", label: "Python" },
|
|
130
|
+
{ value: "java", label: "Java" },
|
|
131
|
+
{ value: "go", label: "Go" },
|
|
132
|
+
{ value: "csharp", label: "C#" },
|
|
133
|
+
{ value: "kotlin", label: "Kotlin" },
|
|
134
|
+
{ value: "objc", label: "Objective C" },
|
|
135
|
+
{ value: "php", label: "PHP" },
|
|
136
|
+
{ value: "ruby", label: "Ruby" },
|
|
137
|
+
{ value: "swift", label: "Swift" },
|
|
138
|
+
]}
|
|
139
|
+
/>
|
|
140
|
+
<MakeRequest operation={operation} />
|
|
141
|
+
</div>
|
|
140
142
|
</SidecarBox.Head>
|
|
141
143
|
<SidecarBox.Body>
|
|
142
144
|
<SyntaxHighlight
|
|
143
145
|
language={option}
|
|
144
|
-
copyable={false}
|
|
145
146
|
noBackground
|
|
146
147
|
className="text-xs"
|
|
147
148
|
code={code}
|
|
148
149
|
/>
|
|
149
150
|
</SidecarBox.Body>
|
|
150
151
|
</SidecarBox.Root>
|
|
151
|
-
{/*<MakeRequest />*/}
|
|
152
152
|
{requestBodyContent && (
|
|
153
153
|
<RequestBodySidecarBox content={requestBodyContent} />
|
|
154
154
|
)}
|
|
@@ -19,7 +19,7 @@ const documents = {
|
|
|
19
19
|
types.OperationsFragmentFragmentDoc,
|
|
20
20
|
"\n query AllOperations($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n description\n title\n url\n version\n tags {\n name\n description\n operations {\n slug\n ...OperationsFragment\n }\n }\n }\n }\n":
|
|
21
21
|
types.AllOperationsDocument,
|
|
22
|
-
"\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n method\n summary\n operationId\n path\n }\n }\n }\n }\n":
|
|
22
|
+
"\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n deprecated\n method\n summary\n operationId\n path\n }\n }\n }\n }\n":
|
|
23
23
|
types.GetCategoriesDocument,
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -59,8 +59,8 @@ export function graphql(
|
|
|
59
59
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
60
60
|
*/
|
|
61
61
|
export function graphql(
|
|
62
|
-
source: "\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n method\n summary\n operationId\n path\n }\n }\n }\n }\n",
|
|
63
|
-
): (typeof documents)["\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n method\n summary\n operationId\n path\n }\n }\n }\n }\n"];
|
|
62
|
+
source: "\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n deprecated\n method\n summary\n operationId\n path\n }\n }\n }\n }\n",
|
|
63
|
+
): (typeof documents)["\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n deprecated\n method\n summary\n operationId\n path\n }\n }\n }\n }\n"];
|
|
64
64
|
|
|
65
65
|
export function graphql(source: string) {
|
|
66
66
|
return (documents as any)[source] ?? {};
|
|
@@ -259,6 +259,7 @@ export type GetCategoriesQuery = {
|
|
|
259
259
|
operations: Array<{
|
|
260
260
|
__typename: "OperationItem";
|
|
261
261
|
slug: string;
|
|
262
|
+
deprecated?: boolean | null;
|
|
262
263
|
method: string;
|
|
263
264
|
summary?: string | null;
|
|
264
265
|
operationId?: string | null;
|
|
@@ -763,6 +764,10 @@ export const GetCategoriesDocument = {
|
|
|
763
764
|
kind: "Field",
|
|
764
765
|
name: { kind: "Name", value: "slug" },
|
|
765
766
|
},
|
|
767
|
+
{
|
|
768
|
+
kind: "Field",
|
|
769
|
+
name: { kind: "Name", value: "deprecated" },
|
|
770
|
+
},
|
|
766
771
|
{
|
|
767
772
|
kind: "Field",
|
|
768
773
|
name: { kind: "Name", value: "method" },
|
|
@@ -66,6 +66,7 @@ const GetCategoriesQuery = graphql(`
|
|
|
66
66
|
operations {
|
|
67
67
|
__typename
|
|
68
68
|
slug
|
|
69
|
+
deprecated
|
|
69
70
|
method
|
|
70
71
|
summary
|
|
71
72
|
operationId
|
|
@@ -109,6 +110,7 @@ export const openApiPlugin = (config: OasPluginConfig): DevPortalPlugin => {
|
|
|
109
110
|
collapsible: false,
|
|
110
111
|
children: tag.operations.map((operation) => ({
|
|
111
112
|
path: `#${operation.slug}`,
|
|
113
|
+
muted: !!operation.deprecated,
|
|
112
114
|
title: operation.summary ?? operation.path,
|
|
113
115
|
label: (
|
|
114
116
|
<div className="flex flex-1 min-w-0 justify-between gap-2">
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Control, useFieldArray, UseFormRegister } from "react-hook-form";
|
|
2
|
-
import {
|
|
2
|
+
import { XIcon } from "lucide-react";
|
|
3
3
|
import { InlineInput } from "./InlineInput.js";
|
|
4
4
|
import type { PlaygroundForm, Header } from "./Playground.js";
|
|
5
|
-
import {
|
|
5
|
+
import { Button } from "../../../ui/Button.js";
|
|
6
6
|
|
|
7
7
|
export const Headers = ({
|
|
8
8
|
control,
|
|
@@ -17,20 +17,6 @@ export const Headers = ({
|
|
|
17
17
|
control,
|
|
18
18
|
name: "headers",
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
const headersCount = headers.length;
|
|
22
|
-
const headersLastName = headers.at(-1)?.name;
|
|
23
|
-
const headersValue = headers.at(-1)?.value;
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (headersCount === 0) {
|
|
27
|
-
append({ name: "", value: "" });
|
|
28
|
-
}
|
|
29
|
-
if (headersLastName !== "" || headersValue !== "") {
|
|
30
|
-
append({ name: "", value: "" });
|
|
31
|
-
}
|
|
32
|
-
}, [append, headersCount, headersLastName, headersValue]);
|
|
33
|
-
|
|
34
20
|
return (
|
|
35
21
|
<div className="grid grid-cols-[1fr_1fr_auto]">
|
|
36
22
|
{fields.map((header, i) => (
|
|
@@ -38,29 +24,37 @@ export const Headers = ({
|
|
|
38
24
|
key={header.id}
|
|
39
25
|
className="grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-muted rounded overflow-hidden group"
|
|
40
26
|
>
|
|
41
|
-
{/*<input type="checkbox" />*/}
|
|
42
27
|
<InlineInput
|
|
43
28
|
{...register(`headers.${i}.name`)}
|
|
44
29
|
placeholder="Name"
|
|
45
30
|
className="peer"
|
|
31
|
+
autoComplete="off"
|
|
46
32
|
/>
|
|
47
33
|
<InlineInput
|
|
48
34
|
placeholder={"Value"}
|
|
49
35
|
className="peer"
|
|
50
36
|
{...register(`headers.${i}.value`)}
|
|
37
|
+
autoComplete="off"
|
|
51
38
|
/>
|
|
52
39
|
<button
|
|
53
40
|
className="hover:bg-black/5 p-1 rounded mr-2 text-muted-foreground invisible group-hover:visible peer-focus:visible"
|
|
54
41
|
onClick={() => {
|
|
55
42
|
remove(i);
|
|
56
43
|
}}
|
|
57
|
-
|
|
44
|
+
type="button"
|
|
58
45
|
>
|
|
59
|
-
<
|
|
46
|
+
<XIcon size={16} />
|
|
60
47
|
</button>
|
|
61
|
-
<div className="col-span-full border-b
|
|
48
|
+
<div className="col-span-full border-b border-border"></div>
|
|
62
49
|
</div>
|
|
63
50
|
))}
|
|
51
|
+
<Button
|
|
52
|
+
className="col-span-full mt-4"
|
|
53
|
+
onClick={() => append({ name: "", value: "" })}
|
|
54
|
+
type="button"
|
|
55
|
+
>
|
|
56
|
+
Add header
|
|
57
|
+
</Button>
|
|
64
58
|
</div>
|
|
65
59
|
);
|
|
66
60
|
};
|
|
@@ -26,7 +26,7 @@ const ParameterValue = forwardRef<HTMLInputElement, ParameterValueProps>(
|
|
|
26
26
|
},
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
export const
|
|
29
|
+
export const PathParams = ({
|
|
30
30
|
control,
|
|
31
31
|
register,
|
|
32
32
|
}: {
|
|
@@ -35,33 +35,29 @@ export const UrlParts = ({
|
|
|
35
35
|
}) => {
|
|
36
36
|
const { fields } = useFieldArray<PlaygroundForm>({
|
|
37
37
|
control,
|
|
38
|
-
name: "
|
|
38
|
+
name: "pathParams",
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
return (
|
|
42
|
-
<div
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
className="peer"
|
|
60
|
-
/>
|
|
41
|
+
return fields.map((part, i) => (
|
|
42
|
+
<div
|
|
43
|
+
key={part.id}
|
|
44
|
+
className="grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-muted rounded overflow-hidden group"
|
|
45
|
+
>
|
|
46
|
+
<InlineInput
|
|
47
|
+
{...register(`pathParams.${i}.name`)}
|
|
48
|
+
disabled
|
|
49
|
+
placeholder="Name"
|
|
50
|
+
className="peer"
|
|
51
|
+
/>
|
|
52
|
+
<ParameterValue
|
|
53
|
+
{...register(`pathParams.${i}.value`)}
|
|
54
|
+
part={part.name}
|
|
55
|
+
{...{ [DATA_ATTR]: part.name }}
|
|
56
|
+
placeholder="Value"
|
|
57
|
+
className="peer"
|
|
58
|
+
/>
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
</div>
|
|
64
|
-
))}
|
|
60
|
+
<div className="col-span-full border-b border-border"></div>
|
|
65
61
|
</div>
|
|
66
|
-
);
|
|
62
|
+
));
|
|
67
63
|
};
|