@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,125 +1,129 @@
1
- import { useMutation } from "@tanstack/react-query";
2
- import { useEffect, useRef, useState } from "react";
3
- import { useNavigate, useSearchParams } from "react-router";
4
- import { Spinner } from "@lukoweb/apitogo/components";
5
- import { ActionButton } from "@lukoweb/apitogo/ui/ActionButton.js";
6
- import { Alert, AlertDescription, AlertTitle } from "@lukoweb/apitogo/ui/Alert.js";
7
- import {
8
- CardContent,
9
- CardDescription,
10
- CardHeader,
11
- CardTitle,
12
- } from "@lukoweb/apitogo/ui/Card.js";
13
- import { Input } from "@lukoweb/apitogo/ui/Input.js";
14
- import { EMAIL_LINK_STORAGE_KEY } from "../constants.js";
15
- import { getRelativeRedirectUrl } from "../utils/relativeRedirectUrl.js";
16
- import { AuthCard } from "./AuthCard.js";
17
-
18
- export const EmailLinkCallbackUi = ({
19
- onCompleteSignIn,
20
- isEmailLinkUrl,
21
- }: {
22
- onCompleteSignIn: (email: string) => Promise<void>;
23
- isEmailLinkUrl: (url: string) => boolean;
24
- }) => {
25
- const navigate = useNavigate();
26
- const [searchParams] = useSearchParams();
27
- const redirectTo = searchParams.get("redirectTo");
28
- const relativeRedirectTo = getRelativeRedirectUrl(redirectTo);
29
-
30
- const [emailInput, setEmailInput] = useState("");
31
-
32
- const signInMutation = useMutation({
33
- mutationFn: (email: string) => onCompleteSignIn(email),
34
- onSuccess: () => {
35
- localStorage.removeItem(EMAIL_LINK_STORAGE_KEY);
36
- void navigate(relativeRedirectTo, { replace: true });
37
- },
38
- });
39
-
40
- const [storedEmail] = useState(() =>
41
- localStorage.getItem(EMAIL_LINK_STORAGE_KEY),
42
- );
43
-
44
- const isValidLink = isEmailLinkUrl(window.location.href);
45
-
46
- const hasTriggered = useRef(false);
47
- useEffect(() => {
48
- if (isValidLink && storedEmail && !hasTriggered.current) {
49
- hasTriggered.current = true;
50
- signInMutation.mutate(storedEmail);
51
- }
52
- }, [isValidLink, storedEmail, signInMutation.mutate]);
53
-
54
- if (!isValidLink) {
55
- return (
56
- <AuthCard>
57
- <CardHeader className="text-center">
58
- <CardTitle>Invalid sign-in link</CardTitle>
59
- <CardDescription>
60
- This sign-in link is invalid or has expired. Please request a new
61
- one.
62
- </CardDescription>
63
- </CardHeader>
64
- <CardContent className="flex justify-center">
65
- <a href="/signin/email-link" className="text-sm text-primary">
66
- Request a new sign-in link
67
- </a>
68
- </CardContent>
69
- </AuthCard>
70
- );
71
- }
72
-
73
- if (signInMutation.isPending || (storedEmail && signInMutation.isIdle)) {
74
- return (
75
- <AuthCard>
76
- <CardHeader className="text-center">
77
- <CardTitle>Signing you in...</CardTitle>
78
- <CardDescription>
79
- Please wait while we complete your sign-in.
80
- </CardDescription>
81
- </CardHeader>
82
- <CardContent className="flex items-center justify-center">
83
- <Spinner />
84
- </CardContent>
85
- </AuthCard>
86
- );
87
- }
88
-
89
- return (
90
- <AuthCard>
91
- <CardHeader>
92
- <CardTitle>Confirm your email</CardTitle>
93
- <CardDescription>
94
- Please enter the email address you used to request the sign-in link.
95
- </CardDescription>
96
- </CardHeader>
97
- <CardContent className="flex flex-col gap-4">
98
- {signInMutation.error && (
99
- <Alert variant="destructive">
100
- <AlertTitle>Error</AlertTitle>
101
- <AlertDescription>{signInMutation.error.message}</AlertDescription>
102
- </Alert>
103
- )}
104
- <form
105
- onSubmit={(e) => {
106
- e.preventDefault();
107
- signInMutation.mutate(emailInput);
108
- }}
109
- className="flex flex-col gap-2"
110
- >
111
- <Input
112
- placeholder="you@example.com"
113
- type="email"
114
- value={emailInput}
115
- onChange={(e) => setEmailInput(e.target.value)}
116
- required
117
- />
118
- <ActionButton type="submit" isPending={signInMutation.isPending}>
119
- Complete sign-in
120
- </ActionButton>
121
- </form>
122
- </CardContent>
123
- </AuthCard>
124
- );
125
- };
1
+ import { Spinner } from "@lukoweb/apitogo/components";
2
+ import { ActionButton } from "@lukoweb/apitogo/ui/ActionButton.js";
3
+ import {
4
+ Alert,
5
+ AlertDescription,
6
+ AlertTitle,
7
+ } from "@lukoweb/apitogo/ui/Alert.js";
8
+ import {
9
+ CardContent,
10
+ CardDescription,
11
+ CardHeader,
12
+ CardTitle,
13
+ } from "@lukoweb/apitogo/ui/Card.js";
14
+ import { Input } from "@lukoweb/apitogo/ui/Input.js";
15
+ import { useMutation } from "@tanstack/react-query";
16
+ import { useEffect, useRef, useState } from "react";
17
+ import { useNavigate, useSearchParams } from "react-router";
18
+ import { EMAIL_LINK_STORAGE_KEY } from "../constants.js";
19
+ import { getRelativeRedirectUrl } from "../utils/relativeRedirectUrl.js";
20
+ import { AuthCard } from "./AuthCard.js";
21
+
22
+ export const EmailLinkCallbackUi = ({
23
+ onCompleteSignIn,
24
+ isEmailLinkUrl,
25
+ }: {
26
+ onCompleteSignIn: (email: string) => Promise<void>;
27
+ isEmailLinkUrl: (url: string) => boolean;
28
+ }) => {
29
+ const navigate = useNavigate();
30
+ const [searchParams] = useSearchParams();
31
+ const redirectTo = searchParams.get("redirectTo");
32
+ const relativeRedirectTo = getRelativeRedirectUrl(redirectTo);
33
+
34
+ const [emailInput, setEmailInput] = useState("");
35
+
36
+ const signInMutation = useMutation({
37
+ mutationFn: (email: string) => onCompleteSignIn(email),
38
+ onSuccess: () => {
39
+ localStorage.removeItem(EMAIL_LINK_STORAGE_KEY);
40
+ void navigate(relativeRedirectTo, { replace: true });
41
+ },
42
+ });
43
+
44
+ const [storedEmail] = useState(() =>
45
+ localStorage.getItem(EMAIL_LINK_STORAGE_KEY),
46
+ );
47
+
48
+ const isValidLink = isEmailLinkUrl(window.location.href);
49
+
50
+ const hasTriggered = useRef(false);
51
+ useEffect(() => {
52
+ if (isValidLink && storedEmail && !hasTriggered.current) {
53
+ hasTriggered.current = true;
54
+ signInMutation.mutate(storedEmail);
55
+ }
56
+ }, [isValidLink, storedEmail, signInMutation.mutate]);
57
+
58
+ if (!isValidLink) {
59
+ return (
60
+ <AuthCard>
61
+ <CardHeader className="text-center">
62
+ <CardTitle>Invalid sign-in link</CardTitle>
63
+ <CardDescription>
64
+ This sign-in link is invalid or has expired. Please request a new
65
+ one.
66
+ </CardDescription>
67
+ </CardHeader>
68
+ <CardContent className="flex justify-center">
69
+ <a href="/signin/email-link" className="text-sm text-primary">
70
+ Request a new sign-in link
71
+ </a>
72
+ </CardContent>
73
+ </AuthCard>
74
+ );
75
+ }
76
+
77
+ if (signInMutation.isPending || (storedEmail && signInMutation.isIdle)) {
78
+ return (
79
+ <AuthCard>
80
+ <CardHeader className="text-center">
81
+ <CardTitle>Signing you in...</CardTitle>
82
+ <CardDescription>
83
+ Please wait while we complete your sign-in.
84
+ </CardDescription>
85
+ </CardHeader>
86
+ <CardContent className="flex items-center justify-center">
87
+ <Spinner />
88
+ </CardContent>
89
+ </AuthCard>
90
+ );
91
+ }
92
+
93
+ return (
94
+ <AuthCard>
95
+ <CardHeader>
96
+ <CardTitle>Confirm your email</CardTitle>
97
+ <CardDescription>
98
+ Please enter the email address you used to request the sign-in link.
99
+ </CardDescription>
100
+ </CardHeader>
101
+ <CardContent className="flex flex-col gap-4">
102
+ {signInMutation.error && (
103
+ <Alert variant="destructive">
104
+ <AlertTitle>Error</AlertTitle>
105
+ <AlertDescription>{signInMutation.error.message}</AlertDescription>
106
+ </Alert>
107
+ )}
108
+ <form
109
+ onSubmit={(e) => {
110
+ e.preventDefault();
111
+ signInMutation.mutate(emailInput);
112
+ }}
113
+ className="flex flex-col gap-2"
114
+ >
115
+ <Input
116
+ placeholder="you@example.com"
117
+ type="email"
118
+ value={emailInput}
119
+ onChange={(e) => setEmailInput(e.target.value)}
120
+ required
121
+ />
122
+ <ActionButton type="submit" isPending={signInMutation.isPending}>
123
+ Complete sign-in
124
+ </ActionButton>
125
+ </form>
126
+ </CardContent>
127
+ </AuthCard>
128
+ );
129
+ };
@@ -1,101 +1,105 @@
1
- import { useMutation } from "@tanstack/react-query";
2
- import { Mail, RefreshCw } from "lucide-react";
3
- import { useState } from "react";
4
- import { Link, Navigate } from "react-router";
5
- import { Alert, AlertDescription, AlertTitle } from "@lukoweb/apitogo/ui/Alert.js";
6
- import { Button } from "@lukoweb/apitogo/ui/Button.js";
7
- import {
8
- CardContent,
9
- CardDescription,
10
- CardHeader,
11
- CardTitle,
12
- } from "@lukoweb/apitogo/ui/Card.js";
13
- import { cn } from "../../util/cn.js";
14
- import { EMAIL_LINK_STORAGE_KEY } from "../constants.js";
15
- import { AuthCard } from "./AuthCard.js";
16
-
17
- export const EmailLinkSentUi = ({
18
- onResendEmailLink,
19
- }: {
20
- onResendEmailLink: () => Promise<void>;
21
- }) => {
22
- const [email] = useState(() => localStorage.getItem(EMAIL_LINK_STORAGE_KEY));
23
-
24
- const resendMutation = useMutation({
25
- mutationFn: () => onResendEmailLink(),
26
- });
27
-
28
- if (!email) {
29
- return <Navigate to="/signin/email-link" replace />;
30
- }
31
-
32
- return (
33
- <AuthCard>
34
- <CardHeader className="text-center">
35
- <div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10">
36
- <Mail className="h-8 w-8 text-primary" />
37
- </div>
38
- <CardTitle>Check your email</CardTitle>
39
- <CardDescription>
40
- We've sent a sign-in link to <strong>{email}</strong>.
41
- </CardDescription>
42
- </CardHeader>
43
- <CardContent className="flex flex-col gap-4">
44
- {resendMutation.error && (
45
- <Alert variant="destructive">
46
- <AlertTitle>Error</AlertTitle>
47
- <AlertDescription>{resendMutation.error.message}</AlertDescription>
48
- </Alert>
49
- )}
50
-
51
- {resendMutation.isSuccess && (
52
- <Alert>
53
- <AlertTitle>Email sent</AlertTitle>
54
- <AlertDescription>
55
- A new sign-in link has been sent. Please check your inbox.
56
- </AlertDescription>
57
- </Alert>
58
- )}
59
-
60
- <div className="space-y-4">
61
- <div className="relative">
62
- <div className="absolute inset-0 flex items-center">
63
- <span className="w-full border-t" />
64
- </div>
65
- <div className="relative flex justify-center text-sm">
66
- <span className="bg-card px-2 text-muted-foreground">
67
- Didn't receive the email?
68
- </span>
69
- </div>
70
- </div>
71
-
72
- <Button
73
- variant="outline"
74
- onClick={() => void resendMutation.mutate()}
75
- disabled={resendMutation.isPending}
76
- className="w-full gap-2"
77
- >
78
- <RefreshCw
79
- className={cn(
80
- "h-4 w-4",
81
- resendMutation.isPending && "animate-spin",
82
- )}
83
- />
84
- Resend sign-in link
85
- </Button>
86
- </div>
87
-
88
- <p className="text-center text-xs text-muted-foreground">
89
- Make sure to check your spam folder if you don't see the email.
90
- </p>
91
-
92
- <Link
93
- to="/signin"
94
- className="text-sm text-muted-foreground text-center"
95
- >
96
- Back to sign in
97
- </Link>
98
- </CardContent>
99
- </AuthCard>
100
- );
101
- };
1
+ import {
2
+ Alert,
3
+ AlertDescription,
4
+ AlertTitle,
5
+ } from "@lukoweb/apitogo/ui/Alert.js";
6
+ import { Button } from "@lukoweb/apitogo/ui/Button.js";
7
+ import {
8
+ CardContent,
9
+ CardDescription,
10
+ CardHeader,
11
+ CardTitle,
12
+ } from "@lukoweb/apitogo/ui/Card.js";
13
+ import { useMutation } from "@tanstack/react-query";
14
+ import { Mail, RefreshCw } from "lucide-react";
15
+ import { useState } from "react";
16
+ import { Link, Navigate } from "react-router";
17
+ import { cn } from "../../util/cn.js";
18
+ import { EMAIL_LINK_STORAGE_KEY } from "../constants.js";
19
+ import { AuthCard } from "./AuthCard.js";
20
+
21
+ export const EmailLinkSentUi = ({
22
+ onResendEmailLink,
23
+ }: {
24
+ onResendEmailLink: () => Promise<void>;
25
+ }) => {
26
+ const [email] = useState(() => localStorage.getItem(EMAIL_LINK_STORAGE_KEY));
27
+
28
+ const resendMutation = useMutation({
29
+ mutationFn: () => onResendEmailLink(),
30
+ });
31
+
32
+ if (!email) {
33
+ return <Navigate to="/signin/email-link" replace />;
34
+ }
35
+
36
+ return (
37
+ <AuthCard>
38
+ <CardHeader className="text-center">
39
+ <div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10">
40
+ <Mail className="h-8 w-8 text-primary" />
41
+ </div>
42
+ <CardTitle>Check your email</CardTitle>
43
+ <CardDescription>
44
+ We've sent a sign-in link to <strong>{email}</strong>.
45
+ </CardDescription>
46
+ </CardHeader>
47
+ <CardContent className="flex flex-col gap-4">
48
+ {resendMutation.error && (
49
+ <Alert variant="destructive">
50
+ <AlertTitle>Error</AlertTitle>
51
+ <AlertDescription>{resendMutation.error.message}</AlertDescription>
52
+ </Alert>
53
+ )}
54
+
55
+ {resendMutation.isSuccess && (
56
+ <Alert>
57
+ <AlertTitle>Email sent</AlertTitle>
58
+ <AlertDescription>
59
+ A new sign-in link has been sent. Please check your inbox.
60
+ </AlertDescription>
61
+ </Alert>
62
+ )}
63
+
64
+ <div className="space-y-4">
65
+ <div className="relative">
66
+ <div className="absolute inset-0 flex items-center">
67
+ <span className="w-full border-t" />
68
+ </div>
69
+ <div className="relative flex justify-center text-sm">
70
+ <span className="bg-card px-2 text-muted-foreground">
71
+ Didn't receive the email?
72
+ </span>
73
+ </div>
74
+ </div>
75
+
76
+ <Button
77
+ variant="outline"
78
+ onClick={() => void resendMutation.mutate()}
79
+ disabled={resendMutation.isPending}
80
+ className="w-full gap-2"
81
+ >
82
+ <RefreshCw
83
+ className={cn(
84
+ "h-4 w-4",
85
+ resendMutation.isPending && "animate-spin",
86
+ )}
87
+ />
88
+ Resend sign-in link
89
+ </Button>
90
+ </div>
91
+
92
+ <p className="text-center text-xs text-muted-foreground">
93
+ Make sure to check your spam folder if you don't see the email.
94
+ </p>
95
+
96
+ <Link
97
+ to="/signin"
98
+ className="text-sm text-muted-foreground text-center"
99
+ >
100
+ Back to sign in
101
+ </Link>
102
+ </CardContent>
103
+ </AuthCard>
104
+ );
105
+ };