@lukoweb/apitogo 0.1.0 → 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.
- package/dist/cli/cli.js +37 -147
- package/dist/declarations/lib/ui/Command.d.ts +1 -1
- package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
- package/package.json +1 -1
- package/src/app/main.tsx +150 -150
- package/src/config/loader.ts +245 -245
- package/src/index.ts +33 -33
- package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
- package/src/lib/authentication/components/SignIn.tsx +46 -46
- package/src/lib/authentication/components/SignUp.tsx +48 -48
- package/src/lib/authentication/providers/clerk.tsx +224 -224
- package/src/lib/authentication/ui/AuthCard.tsx +7 -7
- package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
- package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
- package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
- package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
- package/src/lib/components/Autocomplete.tsx +123 -123
- package/src/lib/components/DeveloperHint.tsx +39 -35
- package/src/lib/components/Header.tsx +260 -260
- package/src/lib/components/Layout.tsx +53 -53
- package/src/lib/components/Main.tsx +51 -51
- package/src/lib/components/Mermaid.tsx +74 -70
- package/src/lib/components/MobileTopNavigation.tsx +276 -276
- package/src/lib/components/MultiSelect.tsx +86 -82
- package/src/lib/components/TopNavigation.tsx +103 -103
- package/src/lib/components/index.ts +26 -26
- package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
- package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
- package/src/lib/components/navigation/NavigationItem.tsx +181 -177
- package/src/lib/core/RouteGuard.tsx +193 -193
- package/src/lib/errors/ErrorMessage.tsx +50 -46
- package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
- package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
- package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
- package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
- package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
- package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
- package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
- package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
- package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
- package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
- package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
- package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
- package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
- package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
- package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
- package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
- package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
- package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
- package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
- package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
- package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
- package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
- package/src/lib/ui/ActionButton.tsx +21 -21
- package/src/lib/ui/Command.tsx +191 -191
- package/src/lib/util/MdxComponents.tsx +150 -150
- package/src/vite/config.ts +234 -231
- package/src/vite/dev-server.ts +291 -291
- package/src/vite/plugin-api-keys.ts +50 -50
- package/src/vite/plugin-api.ts +320 -318
- package/src/vite/plugin-auth.ts +38 -38
- package/src/vite/plugin-component.ts +45 -39
- package/src/vite/plugin-config.ts +75 -75
- package/src/vite/plugin-custom-pages.ts +36 -36
- package/src/vite/plugin-docs.ts +202 -202
- package/src/vite/plugin-markdown-export.ts +214 -214
- package/src/vite/plugin-mdx.ts +149 -149
- package/src/vite/plugin-navigation.ts +106 -106
- package/src/vite/plugin-search.ts +47 -47
- package/src/vite/plugin.ts +42 -42
- package/src/vite/prerender/prerender.ts +233 -233
|
@@ -1,124 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
import { ActionButton } from "@lukoweb/apitogo/ui/ActionButton.js";
|
|
2
|
+
import {
|
|
3
|
+
Alert,
|
|
4
|
+
AlertDescription,
|
|
5
|
+
AlertTitle,
|
|
6
|
+
} from "@lukoweb/apitogo/ui/Alert.js";
|
|
7
|
+
import { DialogClose, DialogFooter } from "@lukoweb/apitogo/ui/Dialog.js";
|
|
8
|
+
import {
|
|
9
|
+
Select,
|
|
10
|
+
SelectContent,
|
|
11
|
+
SelectGroup,
|
|
12
|
+
SelectItem,
|
|
13
|
+
SelectTrigger,
|
|
14
|
+
SelectValue,
|
|
15
|
+
} from "@lukoweb/apitogo/ui/Select.js";
|
|
16
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
17
|
+
import { useForm } from "react-hook-form";
|
|
18
|
+
import { useNavigate } from "react-router";
|
|
19
|
+
import { useZudoku } from "../../components/context/ZudokuContext.js";
|
|
20
|
+
import { useAuth } from "../../hooks/index.js";
|
|
21
|
+
import { Button } from "../../ui/Button.js";
|
|
22
|
+
import { Input } from "../../ui/Input.js";
|
|
23
|
+
import type { ApiKeyService } from "./index.js";
|
|
24
|
+
|
|
25
|
+
type CreateApiKey = { description?: string; expiresOn?: string };
|
|
26
|
+
|
|
27
|
+
export const CreateApiKey = ({
|
|
28
|
+
service,
|
|
29
|
+
onOpenChange,
|
|
30
|
+
}: {
|
|
31
|
+
service: ApiKeyService;
|
|
32
|
+
onOpenChange: (open: boolean) => void;
|
|
33
|
+
}) => {
|
|
34
|
+
const context = useZudoku();
|
|
35
|
+
const queryClient = useQueryClient();
|
|
36
|
+
const navigate = useNavigate();
|
|
37
|
+
const form = useForm<CreateApiKey>({
|
|
38
|
+
defaultValues: {
|
|
39
|
+
expiresOn: "30",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const auth = useAuth();
|
|
43
|
+
|
|
44
|
+
const createKeyMutation = useMutation({
|
|
45
|
+
mutationFn: ({ description, expiresOn }: CreateApiKey) => {
|
|
46
|
+
if (!service.createKey) {
|
|
47
|
+
throw new Error("createKey not implemented");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const expiresOnDate =
|
|
51
|
+
expiresOn !== "never" ? addDaysToDate(Number(expiresOn)) : undefined;
|
|
52
|
+
|
|
53
|
+
return service.createKey({
|
|
54
|
+
apiKey: {
|
|
55
|
+
description: description || "Secret Key",
|
|
56
|
+
expiresOn: expiresOnDate,
|
|
57
|
+
},
|
|
58
|
+
context,
|
|
59
|
+
auth,
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
onSuccess: async () => {
|
|
63
|
+
await queryClient.invalidateQueries({ queryKey: ["api-keys"] });
|
|
64
|
+
await navigate("/settings/api-keys/");
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (!service.createKey) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<form
|
|
74
|
+
onSubmit={form.handleSubmit((data) =>
|
|
75
|
+
createKeyMutation.mutate(
|
|
76
|
+
{ ...data },
|
|
77
|
+
{
|
|
78
|
+
onSuccess: () => onOpenChange(false),
|
|
79
|
+
},
|
|
80
|
+
),
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
{createKeyMutation.error && (
|
|
84
|
+
<Alert variant="destructive" className="mb-4">
|
|
85
|
+
<AlertTitle>Error</AlertTitle>
|
|
86
|
+
<AlertDescription>{createKeyMutation.error.message}</AlertDescription>
|
|
87
|
+
</Alert>
|
|
88
|
+
)}
|
|
89
|
+
<div className="flex gap-2 flex-col text-sm font-medium">
|
|
90
|
+
Name
|
|
91
|
+
<Input {...form.register("description")} />
|
|
92
|
+
Expiration
|
|
93
|
+
<Select
|
|
94
|
+
onValueChange={(value) => form.setValue("expiresOn", value)}
|
|
95
|
+
defaultValue={form.getValues("expiresOn")}
|
|
96
|
+
>
|
|
97
|
+
<SelectTrigger>
|
|
98
|
+
<SelectValue />
|
|
99
|
+
</SelectTrigger>
|
|
100
|
+
<SelectContent>
|
|
101
|
+
<SelectGroup>
|
|
102
|
+
{[7, 30, 60, 90].map((option) => (
|
|
103
|
+
<SelectItem value={String(option)} key={option}>
|
|
104
|
+
{option} days
|
|
105
|
+
</SelectItem>
|
|
106
|
+
))}
|
|
107
|
+
<SelectItem value="never">Never</SelectItem>
|
|
108
|
+
</SelectGroup>
|
|
109
|
+
</SelectContent>
|
|
110
|
+
</Select>
|
|
111
|
+
<DialogFooter>
|
|
112
|
+
<DialogClose asChild>
|
|
113
|
+
<Button variant="outline">Cancel</Button>
|
|
114
|
+
</DialogClose>
|
|
115
|
+
<ActionButton type="submit" isPending={createKeyMutation.isPending}>
|
|
116
|
+
Generate Key
|
|
117
|
+
</ActionButton>
|
|
118
|
+
</DialogFooter>
|
|
119
|
+
</div>
|
|
120
|
+
</form>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const addDaysToDate = (days: number): string => {
|
|
125
|
+
const date = new Date();
|
|
126
|
+
date.setDate(date.getDate() + days);
|
|
127
|
+
return date.toISOString();
|
|
128
|
+
};
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "
|
|
9
|
-
import { Button } from "../../ui/Button.js";
|
|
10
|
-
import { CreateApiKey } from "./CreateApiKey.js";
|
|
11
|
-
import type { ApiKeyService } from "./index.js";
|
|
12
|
-
|
|
13
|
-
interface CreateApiKeyDialogProps {
|
|
14
|
-
service: ApiKeyService;
|
|
15
|
-
isOpen: boolean;
|
|
16
|
-
onOpenChange: (open: boolean) => void;
|
|
17
|
-
trigger?: ReactNode;
|
|
18
|
-
buttonVariant?:
|
|
19
|
-
| "default"
|
|
20
|
-
| "destructive"
|
|
21
|
-
| "outline"
|
|
22
|
-
| "secondary"
|
|
23
|
-
| "ghost"
|
|
24
|
-
| "link";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const CreateApiKeyDialog = ({
|
|
28
|
-
service,
|
|
29
|
-
isOpen,
|
|
30
|
-
onOpenChange,
|
|
31
|
-
trigger,
|
|
32
|
-
buttonVariant = "outline",
|
|
33
|
-
}: CreateApiKeyDialogProps) => {
|
|
34
|
-
const defaultTrigger = (
|
|
35
|
-
<Button variant={buttonVariant}>Create API Key</Button>
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
|
40
|
-
<DialogTrigger asChild>{trigger ?? defaultTrigger}</DialogTrigger>
|
|
41
|
-
<DialogContent>
|
|
42
|
-
<DialogHeader>
|
|
43
|
-
<DialogTitle>Create API Key</DialogTitle>
|
|
44
|
-
</DialogHeader>
|
|
45
|
-
<CreateApiKey service={service} onOpenChange={onOpenChange} />
|
|
46
|
-
</DialogContent>
|
|
47
|
-
</Dialog>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
Dialog,
|
|
3
|
+
DialogContent,
|
|
4
|
+
DialogHeader,
|
|
5
|
+
DialogTitle,
|
|
6
|
+
DialogTrigger,
|
|
7
|
+
} from "@lukoweb/apitogo/ui/Dialog.js";
|
|
8
|
+
import type { ReactNode } from "react";
|
|
9
|
+
import { Button } from "../../ui/Button.js";
|
|
10
|
+
import { CreateApiKey } from "./CreateApiKey.js";
|
|
11
|
+
import type { ApiKeyService } from "./index.js";
|
|
12
|
+
|
|
13
|
+
interface CreateApiKeyDialogProps {
|
|
14
|
+
service: ApiKeyService;
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
onOpenChange: (open: boolean) => void;
|
|
17
|
+
trigger?: ReactNode;
|
|
18
|
+
buttonVariant?:
|
|
19
|
+
| "default"
|
|
20
|
+
| "destructive"
|
|
21
|
+
| "outline"
|
|
22
|
+
| "secondary"
|
|
23
|
+
| "ghost"
|
|
24
|
+
| "link";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const CreateApiKeyDialog = ({
|
|
28
|
+
service,
|
|
29
|
+
isOpen,
|
|
30
|
+
onOpenChange,
|
|
31
|
+
trigger,
|
|
32
|
+
buttonVariant = "outline",
|
|
33
|
+
}: CreateApiKeyDialogProps) => {
|
|
34
|
+
const defaultTrigger = (
|
|
35
|
+
<Button variant={buttonVariant}>Create API Key</Button>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
|
40
|
+
<DialogTrigger asChild>{trigger ?? defaultTrigger}</DialogTrigger>
|
|
41
|
+
<DialogContent>
|
|
42
|
+
<DialogHeader>
|
|
43
|
+
<DialogTitle>Create API Key</DialogTitle>
|
|
44
|
+
</DialogHeader>
|
|
45
|
+
<CreateApiKey service={service} onOpenChange={onOpenChange} />
|
|
46
|
+
</DialogContent>
|
|
47
|
+
</Dialog>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "
|
|
12
|
-
import { useVerifiedEmail } from "../../authentication/hook.js";
|
|
13
|
-
import { Slot } from "../../components/Slot.js";
|
|
14
|
-
import { ErrorMessage } from "../../errors/ErrorMessage.js";
|
|
15
|
-
import { CreateApiKeyDialog } from "./CreateApiKeyDialog.js";
|
|
16
|
-
import type { ApiKeyService } from "./index.js";
|
|
17
|
-
import { ApiKeyList } from "./settings/ApiKeyList.js";
|
|
18
|
-
|
|
19
|
-
export const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {
|
|
20
|
-
const [isCreateApiKeyOpen, setIsCreateApiKeyOpen] = useState(false);
|
|
21
|
-
const auth = useAuth();
|
|
22
|
-
const { supportsEmailVerification, requestEmailVerification, refresh } =
|
|
23
|
-
useVerifiedEmail();
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div className="max-w-3xl h-full pt-(--padding-content-top) pb-(--padding-content-bottom)">
|
|
27
|
-
<Slot.Target name="api-keys-list-page" />
|
|
28
|
-
|
|
29
|
-
<div className="flex justify-between pb-3">
|
|
30
|
-
<h1 className="font-medium text-2xl">API Keys</h1>
|
|
31
|
-
|
|
32
|
-
{service.createKey && (
|
|
33
|
-
<CreateApiKeyDialog
|
|
34
|
-
service={service}
|
|
35
|
-
isOpen={isCreateApiKeyOpen}
|
|
36
|
-
onOpenChange={setIsCreateApiKeyOpen}
|
|
37
|
-
/>
|
|
38
|
-
)}
|
|
39
|
-
</div>
|
|
40
|
-
<p>Create, manage, and monitor your API keys</p>
|
|
41
|
-
|
|
42
|
-
<Slot.Target name="api-keys-list-page-before-keys" />
|
|
43
|
-
{auth.profile?.emailVerified === false ? (
|
|
44
|
-
<Item variant="outline" className="mt-4">
|
|
45
|
-
<ItemContent>
|
|
46
|
-
<ItemTitle>Verified email required</ItemTitle>
|
|
47
|
-
<ItemDescription>
|
|
48
|
-
You need to verify your email to access API keys.
|
|
49
|
-
</ItemDescription>
|
|
50
|
-
</ItemContent>
|
|
51
|
-
<ItemActions>
|
|
52
|
-
<Button onClick={refresh}>Refresh</Button>
|
|
53
|
-
</ItemActions>
|
|
54
|
-
|
|
55
|
-
{supportsEmailVerification && (
|
|
56
|
-
<ItemActions>
|
|
57
|
-
<Button onClick={() => requestEmailVerification()}>
|
|
58
|
-
Request verification
|
|
59
|
-
</Button>
|
|
60
|
-
</ItemActions>
|
|
61
|
-
)}
|
|
62
|
-
</Item>
|
|
63
|
-
) : (
|
|
64
|
-
<ErrorBoundary
|
|
65
|
-
fallbackRender={({ error }) => <ErrorMessage error={error} />}
|
|
66
|
-
>
|
|
67
|
-
<ApiKeyList service={service} />
|
|
68
|
-
</ErrorBoundary>
|
|
69
|
-
)}
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
1
|
+
import { Button } from "@lukoweb/apitogo/components";
|
|
2
|
+
import { useAuth } from "@lukoweb/apitogo/hooks";
|
|
3
|
+
import {
|
|
4
|
+
Item,
|
|
5
|
+
ItemActions,
|
|
6
|
+
ItemContent,
|
|
7
|
+
ItemDescription,
|
|
8
|
+
ItemTitle,
|
|
9
|
+
} from "@lukoweb/apitogo/ui/Item.js";
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
12
|
+
import { useVerifiedEmail } from "../../authentication/hook.js";
|
|
13
|
+
import { Slot } from "../../components/Slot.js";
|
|
14
|
+
import { ErrorMessage } from "../../errors/ErrorMessage.js";
|
|
15
|
+
import { CreateApiKeyDialog } from "./CreateApiKeyDialog.js";
|
|
16
|
+
import type { ApiKeyService } from "./index.js";
|
|
17
|
+
import { ApiKeyList } from "./settings/ApiKeyList.js";
|
|
18
|
+
|
|
19
|
+
export const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {
|
|
20
|
+
const [isCreateApiKeyOpen, setIsCreateApiKeyOpen] = useState(false);
|
|
21
|
+
const auth = useAuth();
|
|
22
|
+
const { supportsEmailVerification, requestEmailVerification, refresh } =
|
|
23
|
+
useVerifiedEmail();
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="max-w-3xl h-full pt-(--padding-content-top) pb-(--padding-content-bottom)">
|
|
27
|
+
<Slot.Target name="api-keys-list-page" />
|
|
28
|
+
|
|
29
|
+
<div className="flex justify-between pb-3">
|
|
30
|
+
<h1 className="font-medium text-2xl">API Keys</h1>
|
|
31
|
+
|
|
32
|
+
{service.createKey && (
|
|
33
|
+
<CreateApiKeyDialog
|
|
34
|
+
service={service}
|
|
35
|
+
isOpen={isCreateApiKeyOpen}
|
|
36
|
+
onOpenChange={setIsCreateApiKeyOpen}
|
|
37
|
+
/>
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
<p>Create, manage, and monitor your API keys</p>
|
|
41
|
+
|
|
42
|
+
<Slot.Target name="api-keys-list-page-before-keys" />
|
|
43
|
+
{auth.profile?.emailVerified === false ? (
|
|
44
|
+
<Item variant="outline" className="mt-4">
|
|
45
|
+
<ItemContent>
|
|
46
|
+
<ItemTitle>Verified email required</ItemTitle>
|
|
47
|
+
<ItemDescription>
|
|
48
|
+
You need to verify your email to access API keys.
|
|
49
|
+
</ItemDescription>
|
|
50
|
+
</ItemContent>
|
|
51
|
+
<ItemActions>
|
|
52
|
+
<Button onClick={refresh}>Refresh</Button>
|
|
53
|
+
</ItemActions>
|
|
54
|
+
|
|
55
|
+
{supportsEmailVerification && (
|
|
56
|
+
<ItemActions>
|
|
57
|
+
<Button onClick={() => requestEmailVerification()}>
|
|
58
|
+
Request verification
|
|
59
|
+
</Button>
|
|
60
|
+
</ItemActions>
|
|
61
|
+
)}
|
|
62
|
+
</Item>
|
|
63
|
+
) : (
|
|
64
|
+
<ErrorBoundary
|
|
65
|
+
fallbackRender={({ error }) => <ErrorMessage error={error} />}
|
|
66
|
+
>
|
|
67
|
+
<ApiKeyList service={service} />
|
|
68
|
+
</ErrorBoundary>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
};
|