create-disposabl-app 0.3.3 → 0.3.4
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/index.js +31 -6
- package/dist/templates/default/apps/web/src/routeTree.gen.ts +49 -5
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +154 -0
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.tsx +23 -5
- package/dist/templates/default/bun.lock +237 -39
- package/dist/templates/default/disposabl.json +3 -1
- package/dist/templates/default/package.json +4 -2
- package/dist/templates/default/packages/backend/generate.ts +9 -0
- package/dist/templates/default/packages/cli/README.md +17 -0
- package/dist/templates/default/packages/cli/auth.ts +301 -0
- package/dist/templates/default/packages/cli/build.ts +9 -0
- package/dist/templates/default/packages/cli/index.ts +146 -0
- package/dist/templates/default/packages/cli/package.json +35 -0
- package/dist/templates/default/packages/cli/tsconfig.json +15 -0
- package/dist/templates/default/packages/disposabl-kit/platforms.ts +4 -4
- package/dist/templates/default/packages/disposabl-kit/server/http.ts +24 -5
- package/dist/templates/default/packages/sdk/README.md +20 -0
- package/dist/templates/default/packages/sdk/openapi-ts.config.ts +10 -0
- package/dist/templates/default/packages/sdk/package.json +31 -0
- package/dist/templates/default/packages/sdk/src/config.ts +11 -0
- package/dist/templates/default/packages/sdk/src/generated/client/client.gen.ts +300 -0
- package/dist/templates/default/packages/sdk/src/generated/client/index.ts +27 -0
- package/dist/templates/default/packages/sdk/src/generated/client/types.gen.ts +238 -0
- package/dist/templates/default/packages/sdk/src/generated/client/utils.gen.ts +337 -0
- package/dist/templates/default/packages/sdk/src/generated/client.gen.ts +28 -0
- package/dist/templates/default/packages/sdk/src/generated/core/auth.gen.ts +49 -0
- package/dist/templates/default/packages/sdk/src/generated/core/bodySerializer.gen.ts +96 -0
- package/dist/templates/default/packages/sdk/src/generated/core/params.gen.ts +188 -0
- package/dist/templates/default/packages/sdk/src/generated/core/pathSerializer.gen.ts +186 -0
- package/dist/templates/default/packages/sdk/src/generated/core/queryKeySerializer.gen.ts +134 -0
- package/dist/templates/default/packages/sdk/src/generated/core/serverSentEvents.gen.ts +265 -0
- package/dist/templates/default/packages/sdk/src/generated/core/types.gen.ts +126 -0
- package/dist/templates/default/packages/sdk/src/generated/core/utils.gen.ts +146 -0
- package/dist/templates/default/packages/sdk/src/generated/index.ts +18 -0
- package/dist/templates/default/packages/sdk/src/generated/sdk.gen.ts +82 -0
- package/dist/templates/default/packages/sdk/src/generated/types.gen.ts +134 -0
- package/dist/templates/default/packages/sdk/src/index.ts +3 -0
- package/dist/templates/default/packages/sdk/tsconfig.build.json +10 -0
- package/dist/templates/default/packages/sdk/tsconfig.json +12 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { fileURLToPath } from "node:url";
|
|
|
8
8
|
import { Command, CommanderError } from "commander";
|
|
9
9
|
import * as p2 from "@clack/prompts";
|
|
10
10
|
// package.json
|
|
11
|
-
var version = "0.3.
|
|
11
|
+
var version = "0.3.4";
|
|
12
12
|
|
|
13
13
|
// ../disposabl-kit/platforms.ts
|
|
14
14
|
var platforms = [
|
|
@@ -39,8 +39,8 @@ var platforms = [
|
|
|
39
39
|
group: "MCP & plugins",
|
|
40
40
|
status: "available"
|
|
41
41
|
},
|
|
42
|
-
{ id: "api", label: "API", group: "
|
|
43
|
-
{ id: "cli", label: "CLI", group: "
|
|
42
|
+
{ id: "api", label: "API", group: "Developer tools", status: "available" },
|
|
43
|
+
{ id: "cli", label: "CLI", group: "Developer tools", status: "available" },
|
|
44
44
|
{
|
|
45
45
|
id: "python-sdk",
|
|
46
46
|
label: "Python SDK",
|
|
@@ -50,8 +50,8 @@ var platforms = [
|
|
|
50
50
|
{
|
|
51
51
|
id: "typescript-sdk",
|
|
52
52
|
label: "TypeScript SDK",
|
|
53
|
-
group: "
|
|
54
|
-
status: "
|
|
53
|
+
group: "Developer tools",
|
|
54
|
+
status: "available"
|
|
55
55
|
}
|
|
56
56
|
];
|
|
57
57
|
var platformIds = platforms.map(({ id }) => id);
|
|
@@ -115,6 +115,10 @@ function selectFeatures(input = "none") {
|
|
|
115
115
|
}
|
|
116
116
|
function selectedFolders(config) {
|
|
117
117
|
const result = ["apps/web"];
|
|
118
|
+
if (config.platforms.includes("cli"))
|
|
119
|
+
result.push("packages/cli");
|
|
120
|
+
if (config.platforms.includes("typescript-sdk"))
|
|
121
|
+
result.push("packages/sdk");
|
|
118
122
|
if (config.platforms.some((platform) => platform === "android" || platform === "ios"))
|
|
119
123
|
result.push("apps/mobile");
|
|
120
124
|
if (config.platforms.some((platform) => ["windows", "linux", "macos"].includes(platform)))
|
|
@@ -351,6 +355,25 @@ async function createApp(template, destination, name, config, overwrite = false)
|
|
|
351
355
|
force: true
|
|
352
356
|
});
|
|
353
357
|
}
|
|
358
|
+
for (const kind of ["cli", "sdk"]) {
|
|
359
|
+
const folder = join(destination, "packages", kind);
|
|
360
|
+
if (!folders.includes(`packages/${kind}`)) {
|
|
361
|
+
await rm(folder, { recursive: true, force: true });
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
const packagePath = join(folder, "package.json");
|
|
365
|
+
const client = JSON.parse(await readFile(packagePath, "utf8"));
|
|
366
|
+
client.name = `${name}-${kind}`;
|
|
367
|
+
if (client.name.length > 214)
|
|
368
|
+
throw new Error("Project name is too long for generated package names.");
|
|
369
|
+
if (kind === "cli")
|
|
370
|
+
client.bin = { [name]: "dist/index.js" };
|
|
371
|
+
await writeFile(packagePath, JSON.stringify(client, null, 2) + `
|
|
372
|
+
`);
|
|
373
|
+
const readme = join(folder, "README.md");
|
|
374
|
+
if (existsSync(readme))
|
|
375
|
+
await writeFile(readme, (await readFile(readme, "utf8")).replaceAll(`@disposabl/${kind}`, client.name));
|
|
376
|
+
}
|
|
354
377
|
if (existsSync(join(destination, "gitignore"))) {
|
|
355
378
|
await rename(join(destination, "gitignore"), join(destination, ".gitignore"));
|
|
356
379
|
}
|
|
@@ -419,6 +442,8 @@ function showOptions(json) {
|
|
|
419
442
|
defaults: { platforms: ["web"], features: selectFeatures() },
|
|
420
443
|
folders: {
|
|
421
444
|
web: "apps/web",
|
|
445
|
+
cli: "packages/cli",
|
|
446
|
+
"typescript-sdk": "packages/sdk",
|
|
422
447
|
android: "apps/mobile",
|
|
423
448
|
ios: "apps/mobile",
|
|
424
449
|
windows: "apps/desktop",
|
|
@@ -428,7 +453,7 @@ function showOptions(json) {
|
|
|
428
453
|
blog: "apps/blog",
|
|
429
454
|
changelog: "apps/changelog"
|
|
430
455
|
},
|
|
431
|
-
configOnly: ["mcp", "openai-plugin", "claude-code-plugin"]
|
|
456
|
+
configOnly: ["api", "mcp", "openai-plugin", "claude-code-plugin"]
|
|
432
457
|
}, null, 2));
|
|
433
458
|
return;
|
|
434
459
|
}
|
|
@@ -16,6 +16,7 @@ import { Route as DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesConsen
|
|
|
16
16
|
import { Route as DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthPagesLoginRouteImport } from './../../../packages/disposabl-kit/client/routes/_auth-pages/login'
|
|
17
17
|
import { Route as DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthPagesSignUpRouteImport } from './../../../packages/disposabl-kit/client/routes/_auth-pages/signUp'
|
|
18
18
|
import { Route as AuthenticatedDashboardRouteImport } from './router/_authenticated/dashboard'
|
|
19
|
+
import { Route as AuthenticatedDashboardDotapiKeysRouteImport } from './router/_authenticated/dashboard.api-keys'
|
|
19
20
|
import { Route as AuthenticatedTodosIndexRouteImport } from './router/_authenticated/todos/index'
|
|
20
21
|
import { Route as AuthenticatedTodosIdRouteImport } from './router/_authenticated/todos/$id'
|
|
21
22
|
|
|
@@ -73,6 +74,12 @@ const AuthenticatedDashboardRoute = AuthenticatedDashboardRouteImport.update({
|
|
|
73
74
|
getParentRoute: () =>
|
|
74
75
|
DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthenticatedRouteRoute,
|
|
75
76
|
} as any)
|
|
77
|
+
const AuthenticatedDashboardDotapiKeysRoute =
|
|
78
|
+
AuthenticatedDashboardDotapiKeysRouteImport.update({
|
|
79
|
+
id: '/api-keys',
|
|
80
|
+
path: '/api-keys',
|
|
81
|
+
getParentRoute: () => AuthenticatedDashboardRoute,
|
|
82
|
+
} as any)
|
|
76
83
|
const AuthenticatedTodosIndexRoute = AuthenticatedTodosIndexRouteImport.update({
|
|
77
84
|
id: '/todos/',
|
|
78
85
|
path: '/todos/',
|
|
@@ -91,7 +98,8 @@ export interface FileRoutesByFullPath {
|
|
|
91
98
|
'/consent': typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesConsentRoute
|
|
92
99
|
'/login': typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthPagesLoginRoute
|
|
93
100
|
'/signup': typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthPagesSignUpRoute
|
|
94
|
-
'/dashboard': typeof
|
|
101
|
+
'/dashboard': typeof AuthenticatedDashboardRouteWithChildren
|
|
102
|
+
'/dashboard/api-keys': typeof AuthenticatedDashboardDotapiKeysRoute
|
|
95
103
|
'/todos/$id': typeof AuthenticatedTodosIdRoute
|
|
96
104
|
'/todos/': typeof AuthenticatedTodosIndexRoute
|
|
97
105
|
}
|
|
@@ -100,7 +108,8 @@ export interface FileRoutesByTo {
|
|
|
100
108
|
'/consent': typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesConsentRoute
|
|
101
109
|
'/login': typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthPagesLoginRoute
|
|
102
110
|
'/signup': typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthPagesSignUpRoute
|
|
103
|
-
'/dashboard': typeof
|
|
111
|
+
'/dashboard': typeof AuthenticatedDashboardRouteWithChildren
|
|
112
|
+
'/dashboard/api-keys': typeof AuthenticatedDashboardDotapiKeysRoute
|
|
104
113
|
'/todos/$id': typeof AuthenticatedTodosIdRoute
|
|
105
114
|
'/todos': typeof AuthenticatedTodosIndexRoute
|
|
106
115
|
}
|
|
@@ -112,7 +121,8 @@ export interface FileRoutesById {
|
|
|
112
121
|
'/_providers/login': typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthPagesLoginRoute
|
|
113
122
|
'/_providers/signup': typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthPagesSignUpRoute
|
|
114
123
|
'/_providers/': typeof IndexRoute
|
|
115
|
-
'/_providers/_authenticated/dashboard': typeof
|
|
124
|
+
'/_providers/_authenticated/dashboard': typeof AuthenticatedDashboardRouteWithChildren
|
|
125
|
+
'/_providers/_authenticated/dashboard/api-keys': typeof AuthenticatedDashboardDotapiKeysRoute
|
|
116
126
|
'/_providers/_authenticated/todos/$id': typeof AuthenticatedTodosIdRoute
|
|
117
127
|
'/_providers/_authenticated/todos/': typeof AuthenticatedTodosIndexRoute
|
|
118
128
|
}
|
|
@@ -124,6 +134,7 @@ export interface FileRouteTypes {
|
|
|
124
134
|
| '/login'
|
|
125
135
|
| '/signup'
|
|
126
136
|
| '/dashboard'
|
|
137
|
+
| '/dashboard/api-keys'
|
|
127
138
|
| '/todos/$id'
|
|
128
139
|
| '/todos/'
|
|
129
140
|
fileRoutesByTo: FileRoutesByTo
|
|
@@ -133,6 +144,7 @@ export interface FileRouteTypes {
|
|
|
133
144
|
| '/login'
|
|
134
145
|
| '/signup'
|
|
135
146
|
| '/dashboard'
|
|
147
|
+
| '/dashboard/api-keys'
|
|
136
148
|
| '/todos/$id'
|
|
137
149
|
| '/todos'
|
|
138
150
|
id:
|
|
@@ -144,6 +156,7 @@ export interface FileRouteTypes {
|
|
|
144
156
|
| '/_providers/signup'
|
|
145
157
|
| '/_providers/'
|
|
146
158
|
| '/_providers/_authenticated/dashboard'
|
|
159
|
+
| '/_providers/_authenticated/dashboard/api-keys'
|
|
147
160
|
| '/_providers/_authenticated/todos/$id'
|
|
148
161
|
| '/_providers/_authenticated/todos/'
|
|
149
162
|
fileRoutesById: FileRoutesById
|
|
@@ -203,6 +216,13 @@ declare module '@tanstack/react-router' {
|
|
|
203
216
|
preLoaderRoute: typeof AuthenticatedDashboardRouteImport
|
|
204
217
|
parentRoute: typeof DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthenticatedRouteRoute
|
|
205
218
|
}
|
|
219
|
+
'/_providers/_authenticated/dashboard/api-keys': {
|
|
220
|
+
id: '/_providers/_authenticated/dashboard/api-keys'
|
|
221
|
+
path: '/api-keys'
|
|
222
|
+
fullPath: '/dashboard/api-keys'
|
|
223
|
+
preLoaderRoute: typeof AuthenticatedDashboardDotapiKeysRouteImport
|
|
224
|
+
parentRoute: typeof AuthenticatedDashboardRoute
|
|
225
|
+
}
|
|
206
226
|
'/_providers/_authenticated/todos/': {
|
|
207
227
|
id: '/_providers/_authenticated/todos/'
|
|
208
228
|
path: '/todos'
|
|
@@ -220,15 +240,30 @@ declare module '@tanstack/react-router' {
|
|
|
220
240
|
}
|
|
221
241
|
}
|
|
222
242
|
|
|
243
|
+
interface AuthenticatedDashboardRouteChildren {
|
|
244
|
+
AuthenticatedDashboardDotapiKeysRoute: typeof AuthenticatedDashboardDotapiKeysRoute
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const AuthenticatedDashboardRouteChildren: AuthenticatedDashboardRouteChildren =
|
|
248
|
+
{
|
|
249
|
+
AuthenticatedDashboardDotapiKeysRoute:
|
|
250
|
+
AuthenticatedDashboardDotapiKeysRoute,
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const AuthenticatedDashboardRouteWithChildren =
|
|
254
|
+
AuthenticatedDashboardRoute._addFileChildren(
|
|
255
|
+
AuthenticatedDashboardRouteChildren,
|
|
256
|
+
)
|
|
257
|
+
|
|
223
258
|
interface DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthenticatedRouteRouteChildren {
|
|
224
|
-
AuthenticatedDashboardRoute: typeof
|
|
259
|
+
AuthenticatedDashboardRoute: typeof AuthenticatedDashboardRouteWithChildren
|
|
225
260
|
AuthenticatedTodosIdRoute: typeof AuthenticatedTodosIdRoute
|
|
226
261
|
AuthenticatedTodosIndexRoute: typeof AuthenticatedTodosIndexRoute
|
|
227
262
|
}
|
|
228
263
|
|
|
229
264
|
const DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthenticatedRouteRouteChildren: DotDotDotDotDotDotDotDotPackagesDisposablKitClientRoutesAuthenticatedRouteRouteChildren =
|
|
230
265
|
{
|
|
231
|
-
AuthenticatedDashboardRoute:
|
|
266
|
+
AuthenticatedDashboardRoute: AuthenticatedDashboardRouteWithChildren,
|
|
232
267
|
AuthenticatedTodosIdRoute: AuthenticatedTodosIdRoute,
|
|
233
268
|
AuthenticatedTodosIndexRoute: AuthenticatedTodosIndexRoute,
|
|
234
269
|
}
|
|
@@ -271,3 +306,12 @@ const rootRouteChildren: RootRouteChildren = {
|
|
|
271
306
|
export const routeTree = rootRouteImport
|
|
272
307
|
._addFileChildren(rootRouteChildren)
|
|
273
308
|
._addFileTypes<FileRouteTypes>()
|
|
309
|
+
|
|
310
|
+
import type { getRouter } from './router.tsx'
|
|
311
|
+
import type { createStart } from '@tanstack/react-start'
|
|
312
|
+
declare module '@tanstack/react-start' {
|
|
313
|
+
interface Register {
|
|
314
|
+
ssr: true
|
|
315
|
+
router: Awaited<ReturnType<typeof getRouter>>
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
3
|
+
import { useAction, useMutation, useQuery } from "convex/react";
|
|
4
|
+
import { api } from "../../../../../packages/backend/convex/_generated/api";
|
|
5
|
+
import { Button } from "@disposabl/disposabl-kit/client/components/ui/button";
|
|
6
|
+
import { Input } from "@disposabl/disposabl-kit/client/components/ui/input";
|
|
7
|
+
import config from "../../../../../disposabl.json";
|
|
8
|
+
|
|
9
|
+
export const Route = createFileRoute(
|
|
10
|
+
"/_providers/_authenticated/dashboard/api-keys",
|
|
11
|
+
)({ component: ApiKeys });
|
|
12
|
+
function ApiKeys() {
|
|
13
|
+
const enabled = config.platforms.includes("api");
|
|
14
|
+
const connections = useQuery(api.mcp.listConnections, enabled ? {} : "skip");
|
|
15
|
+
const create = useAction(api.mcp.createApiKey);
|
|
16
|
+
const revoke = useMutation(api.mcp.revokeConnection);
|
|
17
|
+
const [name, setName] = useState("");
|
|
18
|
+
const [key, setKey] = useState<string>();
|
|
19
|
+
const [pending, setPending] = useState(false);
|
|
20
|
+
const [error, setError] = useState<string>();
|
|
21
|
+
const [copied, setCopied] = useState(false);
|
|
22
|
+
if (!enabled)
|
|
23
|
+
return (
|
|
24
|
+
<main className="mx-auto max-w-xl p-6">
|
|
25
|
+
<h1 className="text-2xl font-semibold">API access is not enabled</h1>
|
|
26
|
+
</main>
|
|
27
|
+
);
|
|
28
|
+
const keys = connections?.filter(
|
|
29
|
+
(connection) => connection.kind === "apiKey",
|
|
30
|
+
);
|
|
31
|
+
return (
|
|
32
|
+
<main className="mx-auto max-w-xl space-y-6 p-6">
|
|
33
|
+
<h1 className="text-2xl font-semibold">API keys</h1>
|
|
34
|
+
<p>
|
|
35
|
+
Use a key with the API or TypeScript SDK. Each key can access your data
|
|
36
|
+
through all enabled operations.
|
|
37
|
+
</p>
|
|
38
|
+
<form
|
|
39
|
+
className="flex gap-2"
|
|
40
|
+
onSubmit={async (event) => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
if (pending) return;
|
|
43
|
+
setPending(true);
|
|
44
|
+
setError(undefined);
|
|
45
|
+
try {
|
|
46
|
+
const result = await create({ name: name.trim(), scopes: [] });
|
|
47
|
+
setKey(result.apiKey);
|
|
48
|
+
setName("");
|
|
49
|
+
setCopied(false);
|
|
50
|
+
} catch {
|
|
51
|
+
setError("Could not create the key. Please try again.");
|
|
52
|
+
} finally {
|
|
53
|
+
setPending(false);
|
|
54
|
+
}
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<label className="flex-1">
|
|
58
|
+
Key name
|
|
59
|
+
<Input
|
|
60
|
+
value={name}
|
|
61
|
+
maxLength={100}
|
|
62
|
+
required
|
|
63
|
+
onChange={(event) => setName(event.target.value)}
|
|
64
|
+
placeholder="My integration"
|
|
65
|
+
/>
|
|
66
|
+
</label>
|
|
67
|
+
<Button
|
|
68
|
+
type="submit"
|
|
69
|
+
className="self-end"
|
|
70
|
+
disabled={pending || !name.trim() || !!key}
|
|
71
|
+
>
|
|
72
|
+
Create key
|
|
73
|
+
</Button>
|
|
74
|
+
</form>
|
|
75
|
+
{key && (
|
|
76
|
+
<section
|
|
77
|
+
className="space-y-3 rounded border p-4"
|
|
78
|
+
aria-label="New API key"
|
|
79
|
+
>
|
|
80
|
+
<p>Copy this key now. It will not be shown again.</p>
|
|
81
|
+
<label className="block">
|
|
82
|
+
API key
|
|
83
|
+
<textarea
|
|
84
|
+
className="mt-2 w-full rounded border p-2 font-mono text-sm"
|
|
85
|
+
readOnly
|
|
86
|
+
value={key}
|
|
87
|
+
spellCheck={false}
|
|
88
|
+
/>
|
|
89
|
+
</label>
|
|
90
|
+
<div className="flex gap-2">
|
|
91
|
+
<Button
|
|
92
|
+
onClick={async () => {
|
|
93
|
+
try {
|
|
94
|
+
await navigator.clipboard.writeText(key);
|
|
95
|
+
setCopied(true);
|
|
96
|
+
} catch {
|
|
97
|
+
setError("Copy failed. Select and copy the key manually.");
|
|
98
|
+
}
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
{copied ? "Copied" : "Copy key"}
|
|
102
|
+
</Button>
|
|
103
|
+
<Button variant="outline" onClick={() => setKey(undefined)}>
|
|
104
|
+
Done
|
|
105
|
+
</Button>
|
|
106
|
+
</div>
|
|
107
|
+
</section>
|
|
108
|
+
)}
|
|
109
|
+
{error && (
|
|
110
|
+
<p role="alert" className="text-destructive">
|
|
111
|
+
{error}
|
|
112
|
+
</p>
|
|
113
|
+
)}
|
|
114
|
+
{keys === undefined ? (
|
|
115
|
+
<p role="status">Loading keys…</p>
|
|
116
|
+
) : (
|
|
117
|
+
<ul className="space-y-3">
|
|
118
|
+
{keys.map((connection) => (
|
|
119
|
+
<li
|
|
120
|
+
key={connection.id}
|
|
121
|
+
className="flex items-center justify-between gap-4 rounded border p-4"
|
|
122
|
+
>
|
|
123
|
+
<div>
|
|
124
|
+
<p className="font-medium">{connection.name}</p>
|
|
125
|
+
<p className="text-sm text-muted-foreground">
|
|
126
|
+
Created {new Date(connection.createdAt).toLocaleDateString()}
|
|
127
|
+
</p>
|
|
128
|
+
</div>
|
|
129
|
+
<Button
|
|
130
|
+
variant="outline"
|
|
131
|
+
disabled={pending}
|
|
132
|
+
onClick={async () => {
|
|
133
|
+
setPending(true);
|
|
134
|
+
setError(undefined);
|
|
135
|
+
try {
|
|
136
|
+
await revoke({ id: connection.id });
|
|
137
|
+
setKey(undefined);
|
|
138
|
+
} catch {
|
|
139
|
+
setError("Could not revoke the key. Please try again.");
|
|
140
|
+
} finally {
|
|
141
|
+
setPending(false);
|
|
142
|
+
}
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
Revoke
|
|
146
|
+
</Button>
|
|
147
|
+
</li>
|
|
148
|
+
))}
|
|
149
|
+
</ul>
|
|
150
|
+
)}
|
|
151
|
+
{keys?.length === 0 && <p>No API keys yet.</p>}
|
|
152
|
+
</main>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createFileRoute,
|
|
3
|
+
Link,
|
|
4
|
+
Outlet,
|
|
5
|
+
useLocation,
|
|
6
|
+
} from "@tanstack/react-router";
|
|
7
|
+
import config from "../../../../../disposabl.json";
|
|
2
8
|
|
|
3
9
|
export const Route = createFileRoute("/_providers/_authenticated/dashboard")({
|
|
4
|
-
component:
|
|
10
|
+
component: Dashboard,
|
|
5
11
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
function Dashboard() {
|
|
13
|
+
const pathname = useLocation({ select: (location) => location.pathname });
|
|
14
|
+
if (pathname !== "/dashboard" && pathname !== "/dashboard/")
|
|
15
|
+
return <Outlet />;
|
|
16
|
+
return (
|
|
17
|
+
<main className="mx-auto max-w-xl space-y-4 p-6">
|
|
18
|
+
<h1 className="text-2xl font-semibold">Dashboard</h1>
|
|
19
|
+
<nav className="flex gap-4">
|
|
20
|
+
<Link to="/todos">Todos</Link>
|
|
21
|
+
{config.platforms.includes("api") && (
|
|
22
|
+
<Link to="/dashboard/api-keys">API keys</Link>
|
|
23
|
+
)}
|
|
24
|
+
</nav>
|
|
25
|
+
</main>
|
|
26
|
+
);
|
|
9
27
|
}
|