@lukoweb/apitogo 0.1.1 → 0.1.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.
Files changed (91) hide show
  1. package/dist/cli/cli.js +17 -6
  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 +1 -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,174 +1,177 @@
1
- import { ExternalLinkIcon } from "lucide-react";
2
- import { Badge } from "@lukoweb/apitogo/ui/Badge.js";
3
- import { NativeSelect, NativeSelectOption } from "@lukoweb/apitogo/ui/NativeSelect.js";
4
- import { SyntaxHighlight } from "../../ui/SyntaxHighlight.js";
5
- import { NonHighlightedCode } from "./components/NonHighlightedCode.js";
6
- import type { MediaTypeObject } from "./graphql/graphql.js";
7
- import * as SidecarBox from "./SidecarBox.js";
8
-
9
- const formatForDisplay = (value: unknown): string | undefined => {
10
- if (value == null) return;
11
- if (typeof value === "string") return value.trim();
12
- return JSON.stringify(value, null, 2);
13
- };
14
-
15
- const getLanguage = (mediaType?: string): string => {
16
- if (!mediaType) return "text";
17
- if (mediaType.endsWith("+json")) return "json";
18
- if (mediaType.endsWith("+xml")) return "xml";
19
- if (mediaType.endsWith("+yaml")) return "yaml";
20
-
21
- const languages: Record<string, string> = {
22
- "text/html": "html",
23
- "application/x-ndjson": "json",
24
- "application/json": "json",
25
- "application/xml": "xml",
26
- "application/x-yaml": "yaml",
27
- "text/csv": "csv",
28
- "application/javascript": "javascript",
29
- "application/graphql": "graphql",
30
- };
31
- return languages[mediaType] ?? "text";
32
- };
33
-
34
- export type SidecarExamplesProps = {
35
- content: MediaTypeObject[];
36
- description?: string;
37
- selectedContentIndex: number;
38
- selectedExampleIndex: number;
39
- onExampleChange?: ({
40
- contentTypeIndex,
41
- exampleIndex,
42
- }: {
43
- contentTypeIndex: number;
44
- exampleIndex: number;
45
- }) => void;
46
- isOnScreen: boolean;
47
- shouldLazyHighlight?: boolean;
48
- };
49
-
50
- export const SidecarExamples = ({
51
- content,
52
- description,
53
- onExampleChange,
54
- selectedContentIndex,
55
- selectedExampleIndex,
56
- isOnScreen,
57
- shouldLazyHighlight,
58
- }: SidecarExamplesProps) => {
59
- // Get example value, with fallback to schema-generated example
60
- const selectedContent = content[selectedContentIndex];
61
- const examples = selectedContent?.examples ?? [];
62
- const selectedExample = examples?.[selectedExampleIndex];
63
-
64
- const formattedExample = formatForDisplay(selectedExample?.value);
65
- const language = getLanguage(selectedContent?.mediaType);
66
-
67
- return (
68
- <>
69
- <SidecarBox.Body className="p-0">
70
- {selectedExample?.externalValue ? (
71
- <div className="p-4">
72
- <a
73
- href={selectedExample.externalValue}
74
- target="_blank"
75
- rel="noopener noreferrer"
76
- className="text-xs text-primary hover:underline"
77
- >
78
- View External Example
79
- <ExternalLinkIcon className="size-3 inline-block ms-1 align-[-0.125em]" />
80
- </a>
81
- </div>
82
- ) : shouldLazyHighlight && !isOnScreen && formattedExample ? (
83
- <NonHighlightedCode code={formattedExample} />
84
- ) : formattedExample ? (
85
- <SyntaxHighlight
86
- embedded
87
- language={language}
88
- className="[--scrollbar-color:gray] rounded-none max-h-[200px] text-xs overflow-auto"
89
- code={formattedExample}
90
- />
91
- ) : (
92
- <div className="grid place-items-center text-xs text-muted-foreground min-h-18">
93
- No example specified for this content type
94
- </div>
95
- )}
96
- {selectedExample?.description && (
97
- <div className="border-t text-xs px-3 py-1.5 text-muted-foreground">
98
- {selectedExample.description}
99
- </div>
100
- )}
101
- </SidecarBox.Body>
102
- <SidecarBox.Footer className="text-xs">
103
- {description && (
104
- <div className="text-muted-foreground text-xs px-1 py-2">
105
- {description}
106
- </div>
107
- )}
108
- {(examples.length !== 0 || content.length !== 0) && (
109
- <div className="flex items-center gap-2 justify-between min-w-0">
110
- <div className="flex items-center gap-2 flex-wrap">
111
- {content.length > 1 ? (
112
- <NativeSelect
113
- className="text-xs h-fit py-1 truncate bg-background"
114
- value={selectedContentIndex.toString()}
115
- onChange={(e) =>
116
- onExampleChange?.({
117
- contentTypeIndex: Number(e.target.value),
118
- exampleIndex: 0,
119
- })
120
- }
121
- >
122
- {content.map((c, index) => (
123
- <NativeSelectOption
124
- key={c.mediaType}
125
- value={index.toString()}
126
- >
127
- {c.mediaType}
128
- </NativeSelectOption>
129
- ))}
130
- </NativeSelect>
131
- ) : (
132
- <Badge
133
- className="text-[11px] font-mono font-normal"
134
- variant="outline"
135
- >
136
- {content[0]?.mediaType}
137
- </Badge>
138
- )}
139
- </div>
140
- {examples.length > 1 && (
141
- <NativeSelect
142
- className="text-xs h-fit py-1 truncate bg-background"
143
- value={selectedExampleIndex.toString()}
144
- onChange={(e) =>
145
- onExampleChange?.({
146
- contentTypeIndex: selectedContentIndex,
147
- exampleIndex: Number(e.target.value),
148
- })
149
- }
150
- >
151
- {examples.map((example, index) => (
152
- <NativeSelectOption
153
- key={
154
- example.summary ||
155
- example.name ||
156
- example.description ||
157
- `Example ${index + 1}`
158
- }
159
- value={index.toString()}
160
- >
161
- {example.summary ||
162
- example.name ||
163
- example.description ||
164
- `Example ${index + 1}`}
165
- </NativeSelectOption>
166
- ))}
167
- </NativeSelect>
168
- )}
169
- </div>
170
- )}
171
- </SidecarBox.Footer>
172
- </>
173
- );
174
- };
1
+ import { Badge } from "@lukoweb/apitogo/ui/Badge.js";
2
+ import {
3
+ NativeSelect,
4
+ NativeSelectOption,
5
+ } from "@lukoweb/apitogo/ui/NativeSelect.js";
6
+ import { ExternalLinkIcon } from "lucide-react";
7
+ import { SyntaxHighlight } from "../../ui/SyntaxHighlight.js";
8
+ import { NonHighlightedCode } from "./components/NonHighlightedCode.js";
9
+ import type { MediaTypeObject } from "./graphql/graphql.js";
10
+ import * as SidecarBox from "./SidecarBox.js";
11
+
12
+ const formatForDisplay = (value: unknown): string | undefined => {
13
+ if (value == null) return;
14
+ if (typeof value === "string") return value.trim();
15
+ return JSON.stringify(value, null, 2);
16
+ };
17
+
18
+ const getLanguage = (mediaType?: string): string => {
19
+ if (!mediaType) return "text";
20
+ if (mediaType.endsWith("+json")) return "json";
21
+ if (mediaType.endsWith("+xml")) return "xml";
22
+ if (mediaType.endsWith("+yaml")) return "yaml";
23
+
24
+ const languages: Record<string, string> = {
25
+ "text/html": "html",
26
+ "application/x-ndjson": "json",
27
+ "application/json": "json",
28
+ "application/xml": "xml",
29
+ "application/x-yaml": "yaml",
30
+ "text/csv": "csv",
31
+ "application/javascript": "javascript",
32
+ "application/graphql": "graphql",
33
+ };
34
+ return languages[mediaType] ?? "text";
35
+ };
36
+
37
+ export type SidecarExamplesProps = {
38
+ content: MediaTypeObject[];
39
+ description?: string;
40
+ selectedContentIndex: number;
41
+ selectedExampleIndex: number;
42
+ onExampleChange?: ({
43
+ contentTypeIndex,
44
+ exampleIndex,
45
+ }: {
46
+ contentTypeIndex: number;
47
+ exampleIndex: number;
48
+ }) => void;
49
+ isOnScreen: boolean;
50
+ shouldLazyHighlight?: boolean;
51
+ };
52
+
53
+ export const SidecarExamples = ({
54
+ content,
55
+ description,
56
+ onExampleChange,
57
+ selectedContentIndex,
58
+ selectedExampleIndex,
59
+ isOnScreen,
60
+ shouldLazyHighlight,
61
+ }: SidecarExamplesProps) => {
62
+ // Get example value, with fallback to schema-generated example
63
+ const selectedContent = content[selectedContentIndex];
64
+ const examples = selectedContent?.examples ?? [];
65
+ const selectedExample = examples?.[selectedExampleIndex];
66
+
67
+ const formattedExample = formatForDisplay(selectedExample?.value);
68
+ const language = getLanguage(selectedContent?.mediaType);
69
+
70
+ return (
71
+ <>
72
+ <SidecarBox.Body className="p-0">
73
+ {selectedExample?.externalValue ? (
74
+ <div className="p-4">
75
+ <a
76
+ href={selectedExample.externalValue}
77
+ target="_blank"
78
+ rel="noopener noreferrer"
79
+ className="text-xs text-primary hover:underline"
80
+ >
81
+ View External Example
82
+ <ExternalLinkIcon className="size-3 inline-block ms-1 align-[-0.125em]" />
83
+ </a>
84
+ </div>
85
+ ) : shouldLazyHighlight && !isOnScreen && formattedExample ? (
86
+ <NonHighlightedCode code={formattedExample} />
87
+ ) : formattedExample ? (
88
+ <SyntaxHighlight
89
+ embedded
90
+ language={language}
91
+ className="[--scrollbar-color:gray] rounded-none max-h-[200px] text-xs overflow-auto"
92
+ code={formattedExample}
93
+ />
94
+ ) : (
95
+ <div className="grid place-items-center text-xs text-muted-foreground min-h-18">
96
+ No example specified for this content type
97
+ </div>
98
+ )}
99
+ {selectedExample?.description && (
100
+ <div className="border-t text-xs px-3 py-1.5 text-muted-foreground">
101
+ {selectedExample.description}
102
+ </div>
103
+ )}
104
+ </SidecarBox.Body>
105
+ <SidecarBox.Footer className="text-xs">
106
+ {description && (
107
+ <div className="text-muted-foreground text-xs px-1 py-2">
108
+ {description}
109
+ </div>
110
+ )}
111
+ {(examples.length !== 0 || content.length !== 0) && (
112
+ <div className="flex items-center gap-2 justify-between min-w-0">
113
+ <div className="flex items-center gap-2 flex-wrap">
114
+ {content.length > 1 ? (
115
+ <NativeSelect
116
+ className="text-xs h-fit py-1 truncate bg-background"
117
+ value={selectedContentIndex.toString()}
118
+ onChange={(e) =>
119
+ onExampleChange?.({
120
+ contentTypeIndex: Number(e.target.value),
121
+ exampleIndex: 0,
122
+ })
123
+ }
124
+ >
125
+ {content.map((c, index) => (
126
+ <NativeSelectOption
127
+ key={c.mediaType}
128
+ value={index.toString()}
129
+ >
130
+ {c.mediaType}
131
+ </NativeSelectOption>
132
+ ))}
133
+ </NativeSelect>
134
+ ) : (
135
+ <Badge
136
+ className="text-[11px] font-mono font-normal"
137
+ variant="outline"
138
+ >
139
+ {content[0]?.mediaType}
140
+ </Badge>
141
+ )}
142
+ </div>
143
+ {examples.length > 1 && (
144
+ <NativeSelect
145
+ className="text-xs h-fit py-1 truncate bg-background"
146
+ value={selectedExampleIndex.toString()}
147
+ onChange={(e) =>
148
+ onExampleChange?.({
149
+ contentTypeIndex: selectedContentIndex,
150
+ exampleIndex: Number(e.target.value),
151
+ })
152
+ }
153
+ >
154
+ {examples.map((example, index) => (
155
+ <NativeSelectOption
156
+ key={
157
+ example.summary ||
158
+ example.name ||
159
+ example.description ||
160
+ `Example ${index + 1}`
161
+ }
162
+ value={index.toString()}
163
+ >
164
+ {example.summary ||
165
+ example.name ||
166
+ example.description ||
167
+ `Example ${index + 1}`}
168
+ </NativeSelectOption>
169
+ ))}
170
+ </NativeSelect>
171
+ )}
172
+ </div>
173
+ )}
174
+ </SidecarBox.Footer>
175
+ </>
176
+ );
177
+ };
@@ -1,58 +1,58 @@
1
- import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";
2
- import { useState } from "react";
3
- import { Button } from "@lukoweb/apitogo/ui/Button.js";
4
- import { cn } from "../../../util/cn.js";
5
- import { SelectOnClick } from "./SelectOnClick.js";
6
-
7
- export const EnumValues = ({
8
- values,
9
- className,
10
- maxVisibleValues = 8,
11
- }: {
12
- values: Array<string | number>;
13
- className?: string;
14
- maxVisibleValues?: number;
15
- }) => {
16
- const [isOpen, setIsOpen] = useState(false);
17
-
18
- if (!values.length) return null;
19
-
20
- const shouldCollapse = values.length > maxVisibleValues;
21
- const visibleValues =
22
- shouldCollapse && !isOpen ? values.slice(0, maxVisibleValues) : values;
23
-
24
- return (
25
- <div className={cn("flex flex-wrap gap-1.5", className)}>
26
- <span className="text-muted-foreground">Enum values:</span>
27
- {visibleValues.map((value) => (
28
- <div key={value}>
29
- <SelectOnClick className="border rounded-sm px-1 font-mono">
30
- {value}
31
- </SelectOnClick>
32
- </div>
33
- ))}
34
- {shouldCollapse && (
35
- <Button
36
- variant="ghost"
37
- size="sm"
38
- className="h-fit px-0"
39
- onClick={() => setIsOpen(!isOpen)}
40
- >
41
- {isOpen ? (
42
- <div className="flex items-center gap-1">
43
- <ChevronUpIcon size={12} />
44
- <span className="text-muted-foreground">show less</span>
45
- </div>
46
- ) : (
47
- <div className="flex items-center gap-1">
48
- <ChevronDownIcon size={12} />
49
- <span className="text-muted-foreground">
50
- show {values.length - maxVisibleValues} more
51
- </span>
52
- </div>
53
- )}
54
- </Button>
55
- )}
56
- </div>
57
- );
58
- };
1
+ import { Button } from "@lukoweb/apitogo/ui/Button.js";
2
+ import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";
3
+ import { useState } from "react";
4
+ import { cn } from "../../../util/cn.js";
5
+ import { SelectOnClick } from "./SelectOnClick.js";
6
+
7
+ export const EnumValues = ({
8
+ values,
9
+ className,
10
+ maxVisibleValues = 8,
11
+ }: {
12
+ values: Array<string | number>;
13
+ className?: string;
14
+ maxVisibleValues?: number;
15
+ }) => {
16
+ const [isOpen, setIsOpen] = useState(false);
17
+
18
+ if (!values.length) return null;
19
+
20
+ const shouldCollapse = values.length > maxVisibleValues;
21
+ const visibleValues =
22
+ shouldCollapse && !isOpen ? values.slice(0, maxVisibleValues) : values;
23
+
24
+ return (
25
+ <div className={cn("flex flex-wrap gap-1.5", className)}>
26
+ <span className="text-muted-foreground">Enum values:</span>
27
+ {visibleValues.map((value) => (
28
+ <div key={value}>
29
+ <SelectOnClick className="border rounded-sm px-1 font-mono">
30
+ {value}
31
+ </SelectOnClick>
32
+ </div>
33
+ ))}
34
+ {shouldCollapse && (
35
+ <Button
36
+ variant="ghost"
37
+ size="sm"
38
+ className="h-fit px-0"
39
+ onClick={() => setIsOpen(!isOpen)}
40
+ >
41
+ {isOpen ? (
42
+ <div className="flex items-center gap-1">
43
+ <ChevronUpIcon size={12} />
44
+ <span className="text-muted-foreground">show less</span>
45
+ </div>
46
+ ) : (
47
+ <div className="flex items-center gap-1">
48
+ <ChevronDownIcon size={12} />
49
+ <span className="text-muted-foreground">
50
+ show {values.length - maxVisibleValues} more
51
+ </span>
52
+ </div>
53
+ )}
54
+ </Button>
55
+ )}
56
+ </div>
57
+ );
58
+ };