@lukoweb/apitogo 0.1.1 → 0.1.3

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.
Files changed (91) hide show
  1. package/dist/cli/cli.js +168 -57
  2. package/dist/declarations/lib/ui/Command.d.ts +1 -1
  3. package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
  4. package/package.json +2 -1
  5. package/src/app/main.tsx +150 -150
  6. package/src/config/loader.ts +245 -245
  7. package/src/index.ts +33 -33
  8. package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
  9. package/src/lib/authentication/components/SignIn.tsx +46 -46
  10. package/src/lib/authentication/components/SignUp.tsx +48 -48
  11. package/src/lib/authentication/providers/clerk.tsx +224 -224
  12. package/src/lib/authentication/ui/AuthCard.tsx +7 -7
  13. package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
  14. package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
  15. package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
  16. package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
  17. package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
  18. package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
  19. package/src/lib/components/Autocomplete.tsx +123 -123
  20. package/src/lib/components/DeveloperHint.tsx +39 -35
  21. package/src/lib/components/Header.tsx +260 -260
  22. package/src/lib/components/Layout.tsx +53 -53
  23. package/src/lib/components/Main.tsx +51 -51
  24. package/src/lib/components/Mermaid.tsx +74 -70
  25. package/src/lib/components/MobileTopNavigation.tsx +276 -276
  26. package/src/lib/components/MultiSelect.tsx +86 -82
  27. package/src/lib/components/TopNavigation.tsx +103 -103
  28. package/src/lib/components/index.ts +26 -26
  29. package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
  30. package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
  31. package/src/lib/components/navigation/NavigationItem.tsx +181 -177
  32. package/src/lib/core/RouteGuard.tsx +193 -193
  33. package/src/lib/errors/ErrorMessage.tsx +50 -46
  34. package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
  35. package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
  36. package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
  37. package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
  38. package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
  39. package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
  40. package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
  41. package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
  42. package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
  43. package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
  44. package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
  45. package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
  46. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
  47. package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
  48. package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
  49. package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
  50. package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
  51. package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
  52. package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
  53. package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
  54. package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
  55. package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
  56. package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
  57. package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
  58. package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
  59. package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
  60. package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
  61. package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
  62. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
  63. package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
  64. package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
  65. package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
  66. package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
  67. package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
  68. package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
  69. package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
  70. package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
  71. package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
  72. package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
  73. package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
  74. package/src/lib/ui/ActionButton.tsx +21 -21
  75. package/src/lib/ui/Command.tsx +191 -191
  76. package/src/lib/util/MdxComponents.tsx +150 -150
  77. package/src/vite/config.ts +234 -231
  78. package/src/vite/dev-server.ts +291 -291
  79. package/src/vite/plugin-api-keys.ts +50 -50
  80. package/src/vite/plugin-api.ts +320 -318
  81. package/src/vite/plugin-auth.ts +38 -38
  82. package/src/vite/plugin-component.ts +45 -39
  83. package/src/vite/plugin-config.ts +75 -75
  84. package/src/vite/plugin-custom-pages.ts +36 -36
  85. package/src/vite/plugin-docs.ts +202 -202
  86. package/src/vite/plugin-markdown-export.ts +214 -214
  87. package/src/vite/plugin-mdx.ts +149 -149
  88. package/src/vite/plugin-navigation.ts +106 -106
  89. package/src/vite/plugin-search.ts +47 -47
  90. package/src/vite/plugin.ts +42 -42
  91. package/src/vite/prerender/prerender.ts +233 -233
@@ -1,51 +1,51 @@
1
- import { ChevronsDownUpIcon, ChevronsUpDownIcon } from "lucide-react";
2
- import { CollapsibleTrigger } from "@lukoweb/apitogo/ui/Collapsible.js";
3
- import { cn } from "../../../util/cn.js";
4
-
5
- export const CollapsibleHeaderTrigger = ({
6
- children,
7
- className,
8
- }: {
9
- children: React.ReactNode;
10
- className?: string;
11
- }) => {
12
- return (
13
- <div
14
- className={cn(
15
- "grid grid-cols-[max-content_1fr_max-content] items-center gap-2 group bg-muted w-full h-10 ps-4 pe-2 border-b",
16
- className,
17
- )}
18
- >
19
- {children}
20
- <CollapsibleTrigger
21
- className={cn(
22
- "flex items-center gap-4 group bg-muted w-full p-2 hover:bg-accent hover:brightness-95 opacity-75 rounded-md",
23
- className,
24
- )}
25
- >
26
- <ChevronsDownUpIcon
27
- className="group-data-[state=closed]:hidden shrink-0"
28
- size={14}
29
- />
30
- <ChevronsUpDownIcon
31
- className="group-data-[state=open]:hidden shrink-0"
32
- size={14}
33
- />
34
- </CollapsibleTrigger>
35
- </div>
36
- );
37
- };
38
-
39
- export const CollapsibleHeader = ({
40
- children,
41
- className,
42
- }: {
43
- children: React.ReactNode;
44
- className?: string;
45
- }) => {
46
- return (
47
- <span className={cn("font-semibold w-full text-start", className)}>
48
- {children}
49
- </span>
50
- );
51
- };
1
+ import { CollapsibleTrigger } from "@lukoweb/apitogo/ui/Collapsible.js";
2
+ import { ChevronsDownUpIcon, ChevronsUpDownIcon } from "lucide-react";
3
+ import { cn } from "../../../util/cn.js";
4
+
5
+ export const CollapsibleHeaderTrigger = ({
6
+ children,
7
+ className,
8
+ }: {
9
+ children: React.ReactNode;
10
+ className?: string;
11
+ }) => {
12
+ return (
13
+ <div
14
+ className={cn(
15
+ "grid grid-cols-[max-content_1fr_max-content] items-center gap-2 group bg-muted w-full h-10 ps-4 pe-2 border-b",
16
+ className,
17
+ )}
18
+ >
19
+ {children}
20
+ <CollapsibleTrigger
21
+ className={cn(
22
+ "flex items-center gap-4 group bg-muted w-full p-2 hover:bg-accent hover:brightness-95 opacity-75 rounded-md",
23
+ className,
24
+ )}
25
+ >
26
+ <ChevronsDownUpIcon
27
+ className="group-data-[state=closed]:hidden shrink-0"
28
+ size={14}
29
+ />
30
+ <ChevronsUpDownIcon
31
+ className="group-data-[state=open]:hidden shrink-0"
32
+ size={14}
33
+ />
34
+ </CollapsibleTrigger>
35
+ </div>
36
+ );
37
+ };
38
+
39
+ export const CollapsibleHeader = ({
40
+ children,
41
+ className,
42
+ }: {
43
+ children: React.ReactNode;
44
+ className?: string;
45
+ }) => {
46
+ return (
47
+ <span className={cn("font-semibold w-full text-start", className)}>
48
+ {children}
49
+ </span>
50
+ );
51
+ };
@@ -1,60 +1,60 @@
1
- import { PlusCircleIcon } from "lucide-react";
2
- import { Button } from "@lukoweb/apitogo/ui/Button.js";
3
- import {
4
- DropdownMenu,
5
- DropdownMenuContent,
6
- DropdownMenuGroup,
7
- DropdownMenuItem,
8
- DropdownMenuLabel,
9
- DropdownMenuSeparator,
10
- DropdownMenuTrigger,
11
- } from "@lukoweb/apitogo/ui/DropdownMenu.js";
12
- import type { ExampleItem, MediaTypeObject } from "../graphql/graphql.js";
13
-
14
- const ExamplesDropdown = ({
15
- examples,
16
- onSelect,
17
- }: {
18
- examples: MediaTypeObject[];
19
- onSelect: (example: ExampleItem, mediaType: string) => void;
20
- }) => {
21
- return (
22
- <DropdownMenu>
23
- <DropdownMenuTrigger asChild>
24
- <Button
25
- variant="ghost"
26
- size="sm"
27
- className="hover:bg-accent hover:brightness-95 gap-2"
28
- >
29
- Use Example
30
- <PlusCircleIcon size={14} />
31
- </Button>
32
- </DropdownMenuTrigger>
33
- <DropdownMenuContent className="max-w-72">
34
- {examples.map((mediaTypeObject) => (
35
- <div key={mediaTypeObject.mediaType}>
36
- <DropdownMenuLabel>{mediaTypeObject.mediaType}</DropdownMenuLabel>
37
- <DropdownMenuSeparator />
38
- <DropdownMenuGroup>
39
- {mediaTypeObject.examples?.map((example) => (
40
- <DropdownMenuItem
41
- key={example.name}
42
- onSelect={() => onSelect(example, mediaTypeObject.mediaType)}
43
- >
44
- <span
45
- className="line-clamp-1"
46
- title={example.summary ?? example.name}
47
- >
48
- {example.summary ?? example.name}
49
- </span>
50
- </DropdownMenuItem>
51
- ))}
52
- </DropdownMenuGroup>
53
- </div>
54
- ))}
55
- </DropdownMenuContent>
56
- </DropdownMenu>
57
- );
58
- };
59
-
60
- export default ExamplesDropdown;
1
+ import { Button } from "@lukoweb/apitogo/ui/Button.js";
2
+ import {
3
+ DropdownMenu,
4
+ DropdownMenuContent,
5
+ DropdownMenuGroup,
6
+ DropdownMenuItem,
7
+ DropdownMenuLabel,
8
+ DropdownMenuSeparator,
9
+ DropdownMenuTrigger,
10
+ } from "@lukoweb/apitogo/ui/DropdownMenu.js";
11
+ import { PlusCircleIcon } from "lucide-react";
12
+ import type { ExampleItem, MediaTypeObject } from "../graphql/graphql.js";
13
+
14
+ const ExamplesDropdown = ({
15
+ examples,
16
+ onSelect,
17
+ }: {
18
+ examples: MediaTypeObject[];
19
+ onSelect: (example: ExampleItem, mediaType: string) => void;
20
+ }) => {
21
+ return (
22
+ <DropdownMenu>
23
+ <DropdownMenuTrigger asChild>
24
+ <Button
25
+ variant="ghost"
26
+ size="sm"
27
+ className="hover:bg-accent hover:brightness-95 gap-2"
28
+ >
29
+ Use Example
30
+ <PlusCircleIcon size={14} />
31
+ </Button>
32
+ </DropdownMenuTrigger>
33
+ <DropdownMenuContent className="max-w-72">
34
+ {examples.map((mediaTypeObject) => (
35
+ <div key={mediaTypeObject.mediaType}>
36
+ <DropdownMenuLabel>{mediaTypeObject.mediaType}</DropdownMenuLabel>
37
+ <DropdownMenuSeparator />
38
+ <DropdownMenuGroup>
39
+ {mediaTypeObject.examples?.map((example) => (
40
+ <DropdownMenuItem
41
+ key={example.name}
42
+ onSelect={() => onSelect(example, mediaTypeObject.mediaType)}
43
+ >
44
+ <span
45
+ className="line-clamp-1"
46
+ title={example.summary ?? example.name}
47
+ >
48
+ {example.summary ?? example.name}
49
+ </span>
50
+ </DropdownMenuItem>
51
+ ))}
52
+ </DropdownMenuGroup>
53
+ </div>
54
+ ))}
55
+ </DropdownMenuContent>
56
+ </DropdownMenu>
57
+ );
58
+ };
59
+
60
+ export default ExamplesDropdown;
@@ -1,187 +1,194 @@
1
- import { CircleAlertIcon, LockIcon, TableOfContentsIcon } from "lucide-react";
2
- import { type Control, useFormContext } from "react-hook-form";
3
- import { Checkbox } from "@lukoweb/apitogo/ui/Checkbox.js";
4
- import { Collapsible, CollapsibleContent } from "@lukoweb/apitogo/ui/Collapsible.js";
5
- import { Tooltip, TooltipContent, TooltipTrigger } from "@lukoweb/apitogo/ui/Tooltip.js";
6
- import { Autocomplete } from "../../../components/Autocomplete.js";
7
- import { cn } from "../../../util/cn.js";
8
- import {
9
- CollapsibleHeader,
10
- CollapsibleHeaderTrigger,
11
- } from "./CollapsibleHeader.js";
12
- import ParamsGrid, {
13
- ParamsGridInput,
14
- ParamsGridItem,
15
- ParamsGridRemoveButton,
16
- } from "./ParamsGrid.js";
17
- import type { Header, PlaygroundForm } from "./Playground.js";
18
- import { useKeyValueFieldManager } from "./request-panel/useKeyValueFieldManager.js";
19
-
20
- // prettier-ignore
1
+ import { Checkbox } from "@lukoweb/apitogo/ui/Checkbox.js";
2
+ import {
3
+ Collapsible,
4
+ CollapsibleContent,
5
+ } from "@lukoweb/apitogo/ui/Collapsible.js";
6
+ import {
7
+ Tooltip,
8
+ TooltipContent,
9
+ TooltipTrigger,
10
+ } from "@lukoweb/apitogo/ui/Tooltip.js";
11
+ import { CircleAlertIcon, LockIcon, TableOfContentsIcon } from "lucide-react";
12
+ import { type Control, useFormContext } from "react-hook-form";
13
+ import { Autocomplete } from "../../../components/Autocomplete.js";
14
+ import { cn } from "../../../util/cn.js";
15
+ import {
16
+ CollapsibleHeader,
17
+ CollapsibleHeaderTrigger,
18
+ } from "./CollapsibleHeader.js";
19
+ import ParamsGrid, {
20
+ ParamsGridInput,
21
+ ParamsGridItem,
22
+ ParamsGridRemoveButton,
23
+ } from "./ParamsGrid.js";
24
+ import type { Header, PlaygroundForm } from "./Playground.js";
25
+ import { useKeyValueFieldManager } from "./request-panel/useKeyValueFieldManager.js";
26
+
27
+ // prettier-ignore
21
28
  const headerOptions = Object.freeze([
22
29
  "Accept", "Accept-Encoding", "Accept-Language", "Authorization", "Cache-Control", "Connection",
23
30
  "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Range",
24
31
  "Content-Security-Policy", "Content-Type", "Cookie", "Date", "ETag", "Expires", "Host",
25
32
  "If-Modified-Since", "Location", "Origin", "Pragma", "Referer", "Set-Cookie", "User-Agent",
26
33
  "X-Requested-With",
27
- ]);
28
-
29
- export const Headers = ({
30
- control,
31
- schemaHeaders,
32
- lockedHeaders,
33
- }: {
34
- control: Control<PlaygroundForm>;
35
- schemaHeaders: Header[];
36
- lockedHeaders?: string[];
37
- }) => {
38
- const { watch, formState } = useFormContext<PlaygroundForm>();
39
- const watchedHeaders = watch("headers");
40
-
41
- const manager = useKeyValueFieldManager<PlaygroundForm, "headers">({
42
- control,
43
- name: "headers",
44
- defaultValue: { name: "", value: "", active: false },
45
- });
46
-
47
- const missingHeaders = schemaHeaders
48
- .filter((h) => !watchedHeaders.some((f) => f.name === h.name))
49
- .map(({ name }) => name);
50
-
51
- const hiddenHeadersIndex = manager.fields.flatMap((f, index) => {
52
- const keep = !lockedHeaders
53
- ?.map((h) => h.toLowerCase())
54
- .includes(f.name.toLowerCase());
55
-
56
- return keep ? [] : [index];
57
- });
58
-
59
- const lockedHeaderFields =
60
- lockedHeaders?.map((h) => ({
61
- name: h,
62
- id: `locked-${h}`,
63
- value: "••••••••••",
64
- active: true,
65
- locked: true,
66
- })) ?? [];
67
-
68
- return (
69
- <Collapsible defaultOpen>
70
- <CollapsibleHeaderTrigger>
71
- <TableOfContentsIcon size={14} />
72
- <CollapsibleHeader>Headers</CollapsibleHeader>
73
- </CollapsibleHeaderTrigger>
74
- <CollapsibleContent className="CollapsibleContent">
75
- <div className="flex flex-col gap-2">
76
- <div className="overflow-hidden">
77
- <ParamsGrid>
78
- {lockedHeaderFields.map((field) => (
79
- <Tooltip key={field.id}>
80
- <TooltipTrigger asChild>
81
- <ParamsGridItem
82
- key={field.id}
83
- className="opacity-50 cursor-not-allowed font-mono text-xs min-h-10"
84
- >
85
- <LockIcon size={16} />
86
- <ParamsGridInput value={field.name} disabled />
87
- <div>{field.value}</div>
88
- </ParamsGridItem>
89
- </TooltipTrigger>
90
- <TooltipContent alignOffset={10} side="bottom" align="start">
91
- <p>This header is set by the selected authentication.</p>
92
- </TooltipContent>
93
- </Tooltip>
94
- ))}
95
- {manager.fields.map((field, i) => {
96
- const currentSchemaHeader = schemaHeaders.find(
97
- (h) => h.name === watchedHeaders.at(i)?.name,
98
- );
99
- const hasEnum =
100
- currentSchemaHeader?.enum &&
101
- currentSchemaHeader.enum.length > 0;
102
- const isHidden = hiddenHeadersIndex.includes(i);
103
- const nameInputProps = manager.getNameInputProps(i);
104
- const valueInputProps = manager.getValueInputProps(i);
105
-
106
- return (
107
- <ParamsGridItem
108
- key={field.id}
109
- className={cn(
110
- isHidden && "text-amber-600",
111
- isHidden &&
112
- !formState.dirtyFields.headers?.[i]?.value &&
113
- "hidden",
114
- )}
115
- >
116
- <Checkbox
117
- className={cn(isHidden && "hidden")}
118
- {...manager.getCheckboxProps(i)}
119
- />
120
- <Tooltip>
121
- <TooltipTrigger asChild>
122
- <CircleAlertIcon
123
- className={cn(
124
- "text-amber-600",
125
- !isHidden && "hidden",
126
- )}
127
- size={16}
128
- />
129
- </TooltipTrigger>
130
- <TooltipContent
131
- alignOffset={10}
132
- side="bottom"
133
- align="start"
134
- >
135
- <p>
136
- This header will be overwritten by the selected
137
- authentication.
138
- </p>
139
- </TooltipContent>
140
- </Tooltip>
141
- <ParamsGridInput asChild>
142
- <Autocomplete
143
- {...nameInputProps}
144
- value={String(manager.getValue(i, "name"))}
145
- placeholder="Name"
146
- options={[...missingHeaders, ...headerOptions]}
147
- onChange={(v) => manager.setValue(i, "name", v)}
148
- onSelect={(v) =>
149
- manager.setValue(i, "name", v, { focus: "next" })
150
- }
151
- />
152
- </ParamsGridInput>
153
- <div className="flex items-center gap-2">
154
- {!hasEnum ? (
155
- <ParamsGridInput
156
- placeholder="Value"
157
- autoComplete="off"
158
- {...valueInputProps}
159
- />
160
- ) : (
161
- <ParamsGridInput asChild>
162
- <Autocomplete
163
- {...valueInputProps}
164
- value={String(manager.getValue(i, "value"))}
165
- shouldFilter={false}
166
- options={currentSchemaHeader.enum ?? []}
167
- onChange={(v) => manager.setValue(i, "value", v)}
168
- onSelect={(v) =>
169
- manager.setValue(i, "value", v, { focus: "next" })
170
- }
171
- />
172
- </ParamsGridInput>
173
- )}
174
- <ParamsGridRemoveButton
175
- {...manager.getRemoveButtonProps(i)}
176
- />
177
- </div>
178
- </ParamsGridItem>
179
- );
180
- })}
181
- </ParamsGrid>
182
- </div>
183
- </div>
184
- </CollapsibleContent>
185
- </Collapsible>
186
- );
187
- };
34
+ ]);
35
+
36
+ export const Headers = ({
37
+ control,
38
+ schemaHeaders,
39
+ lockedHeaders,
40
+ }: {
41
+ control: Control<PlaygroundForm>;
42
+ schemaHeaders: Header[];
43
+ lockedHeaders?: string[];
44
+ }) => {
45
+ const { watch, formState } = useFormContext<PlaygroundForm>();
46
+ const watchedHeaders = watch("headers");
47
+
48
+ const manager = useKeyValueFieldManager<PlaygroundForm, "headers">({
49
+ control,
50
+ name: "headers",
51
+ defaultValue: { name: "", value: "", active: false },
52
+ });
53
+
54
+ const missingHeaders = schemaHeaders
55
+ .filter((h) => !watchedHeaders.some((f) => f.name === h.name))
56
+ .map(({ name }) => name);
57
+
58
+ const hiddenHeadersIndex = manager.fields.flatMap((f, index) => {
59
+ const keep = !lockedHeaders
60
+ ?.map((h) => h.toLowerCase())
61
+ .includes(f.name.toLowerCase());
62
+
63
+ return keep ? [] : [index];
64
+ });
65
+
66
+ const lockedHeaderFields =
67
+ lockedHeaders?.map((h) => ({
68
+ name: h,
69
+ id: `locked-${h}`,
70
+ value: "••••••••••",
71
+ active: true,
72
+ locked: true,
73
+ })) ?? [];
74
+
75
+ return (
76
+ <Collapsible defaultOpen>
77
+ <CollapsibleHeaderTrigger>
78
+ <TableOfContentsIcon size={14} />
79
+ <CollapsibleHeader>Headers</CollapsibleHeader>
80
+ </CollapsibleHeaderTrigger>
81
+ <CollapsibleContent className="CollapsibleContent">
82
+ <div className="flex flex-col gap-2">
83
+ <div className="overflow-hidden">
84
+ <ParamsGrid>
85
+ {lockedHeaderFields.map((field) => (
86
+ <Tooltip key={field.id}>
87
+ <TooltipTrigger asChild>
88
+ <ParamsGridItem
89
+ key={field.id}
90
+ className="opacity-50 cursor-not-allowed font-mono text-xs min-h-10"
91
+ >
92
+ <LockIcon size={16} />
93
+ <ParamsGridInput value={field.name} disabled />
94
+ <div>{field.value}</div>
95
+ </ParamsGridItem>
96
+ </TooltipTrigger>
97
+ <TooltipContent alignOffset={10} side="bottom" align="start">
98
+ <p>This header is set by the selected authentication.</p>
99
+ </TooltipContent>
100
+ </Tooltip>
101
+ ))}
102
+ {manager.fields.map((field, i) => {
103
+ const currentSchemaHeader = schemaHeaders.find(
104
+ (h) => h.name === watchedHeaders.at(i)?.name,
105
+ );
106
+ const hasEnum =
107
+ currentSchemaHeader?.enum &&
108
+ currentSchemaHeader.enum.length > 0;
109
+ const isHidden = hiddenHeadersIndex.includes(i);
110
+ const nameInputProps = manager.getNameInputProps(i);
111
+ const valueInputProps = manager.getValueInputProps(i);
112
+
113
+ return (
114
+ <ParamsGridItem
115
+ key={field.id}
116
+ className={cn(
117
+ isHidden && "text-amber-600",
118
+ isHidden &&
119
+ !formState.dirtyFields.headers?.[i]?.value &&
120
+ "hidden",
121
+ )}
122
+ >
123
+ <Checkbox
124
+ className={cn(isHidden && "hidden")}
125
+ {...manager.getCheckboxProps(i)}
126
+ />
127
+ <Tooltip>
128
+ <TooltipTrigger asChild>
129
+ <CircleAlertIcon
130
+ className={cn(
131
+ "text-amber-600",
132
+ !isHidden && "hidden",
133
+ )}
134
+ size={16}
135
+ />
136
+ </TooltipTrigger>
137
+ <TooltipContent
138
+ alignOffset={10}
139
+ side="bottom"
140
+ align="start"
141
+ >
142
+ <p>
143
+ This header will be overwritten by the selected
144
+ authentication.
145
+ </p>
146
+ </TooltipContent>
147
+ </Tooltip>
148
+ <ParamsGridInput asChild>
149
+ <Autocomplete
150
+ {...nameInputProps}
151
+ value={String(manager.getValue(i, "name"))}
152
+ placeholder="Name"
153
+ options={[...missingHeaders, ...headerOptions]}
154
+ onChange={(v) => manager.setValue(i, "name", v)}
155
+ onSelect={(v) =>
156
+ manager.setValue(i, "name", v, { focus: "next" })
157
+ }
158
+ />
159
+ </ParamsGridInput>
160
+ <div className="flex items-center gap-2">
161
+ {!hasEnum ? (
162
+ <ParamsGridInput
163
+ placeholder="Value"
164
+ autoComplete="off"
165
+ {...valueInputProps}
166
+ />
167
+ ) : (
168
+ <ParamsGridInput asChild>
169
+ <Autocomplete
170
+ {...valueInputProps}
171
+ value={String(manager.getValue(i, "value"))}
172
+ shouldFilter={false}
173
+ options={currentSchemaHeader.enum ?? []}
174
+ onChange={(v) => manager.setValue(i, "value", v)}
175
+ onSelect={(v) =>
176
+ manager.setValue(i, "value", v, { focus: "next" })
177
+ }
178
+ />
179
+ </ParamsGridInput>
180
+ )}
181
+ <ParamsGridRemoveButton
182
+ {...manager.getRemoveButtonProps(i)}
183
+ />
184
+ </div>
185
+ </ParamsGridItem>
186
+ );
187
+ })}
188
+ </ParamsGrid>
189
+ </div>
190
+ </div>
191
+ </CollapsibleContent>
192
+ </Collapsible>
193
+ );
194
+ };