@ampless/admin 0.2.0-alpha.18 → 0.2.0-alpha.19
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/api/index.d.ts +2 -48
- package/dist/api/index.js +0 -562
- package/dist/chunk-4QYY7CO7.js +358 -0
- package/dist/{chunk-T3ONEJ6K.js → chunk-5JKOPRCO.js} +2 -2
- package/dist/{chunk-KAMD3SDE.js → chunk-5Q6KVRZ2.js} +2 -2
- package/dist/{chunk-WJTZ5BNQ.js → chunk-A3SWBQA6.js} +1 -1
- package/dist/{chunk-I5S7J7UZ.js → chunk-BC4B6DLO.js} +2 -2
- package/dist/{chunk-5VDMBDFB.js → chunk-CQY55RDG.js} +1 -1
- package/dist/{chunk-3EDGG6ST.js → chunk-CVJCMTYB.js} +2 -2
- package/dist/{chunk-LIGSQETK.js → chunk-IM5MVZOH.js} +2 -2
- package/dist/{chunk-YECVXCET.js → chunk-OSUTPPAU.js} +79 -63
- package/dist/{chunk-G7B3R6WQ.js → chunk-QXJIIBUQ.js} +2 -2
- package/dist/{chunk-IJKYZNII.js → chunk-S66L5CDS.js} +1 -1
- package/dist/{chunk-XFJXMCXX.js → chunk-SRNH2IVA.js} +1 -1
- package/dist/{chunk-OYKHRBCF.js → chunk-W6BXESPW.js} +1 -1
- package/dist/{chunk-K4GZPMPL.js → chunk-XY4JWSMS.js} +1 -1
- package/dist/components/admin-dashboard.js +3 -3
- package/dist/components/edit-post-view.js +5 -5
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +6 -6
- package/dist/components/login-view.js +3 -3
- package/dist/components/mcp-tokens-view.d.ts +19 -2
- package/dist/components/mcp-tokens-view.js +3 -3
- package/dist/components/media-view.js +5 -5
- package/dist/components/new-post-view.js +5 -5
- package/dist/components/posts-list-view.js +3 -3
- package/dist/components/users-list-view.js +3 -3
- package/dist/{i18n-B1gZ90FD.d.ts → i18n-MWvAMHzn.d.ts} +118 -94
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/pages/index.d.ts +15 -3
- package/dist/pages/index.js +29 -15
- package/package.json +3 -3
- package/dist/chunk-Q7WU724A.js +0 -205
package/dist/chunk-Q7WU724A.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import {
|
|
3
|
-
useT
|
|
4
|
-
} from "./chunk-K4GZPMPL.js";
|
|
5
|
-
|
|
6
|
-
// src/components/mcp-tokens-view.tsx
|
|
7
|
-
import { useEffect, useState } from "react";
|
|
8
|
-
import {
|
|
9
|
-
Button,
|
|
10
|
-
Input,
|
|
11
|
-
Label,
|
|
12
|
-
Table,
|
|
13
|
-
TableBody,
|
|
14
|
-
TableCell,
|
|
15
|
-
TableHead,
|
|
16
|
-
TableHeader,
|
|
17
|
-
TableRow
|
|
18
|
-
} from "@ampless/runtime/ui";
|
|
19
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
-
var TOKENS_URL = "/api/admin/mcp-tokens";
|
|
21
|
-
function McpTokensView() {
|
|
22
|
-
const t = useT();
|
|
23
|
-
const [tokens, setTokens] = useState(null);
|
|
24
|
-
const [loading, setLoading] = useState(true);
|
|
25
|
-
const [loadError, setLoadError] = useState(null);
|
|
26
|
-
const [label, setLabel] = useState("");
|
|
27
|
-
const [role, setRole] = useState("admin");
|
|
28
|
-
const [creating, setCreating] = useState(false);
|
|
29
|
-
const [createError, setCreateError] = useState(null);
|
|
30
|
-
const [createdPlaintext, setCreatedPlaintext] = useState(null);
|
|
31
|
-
const [copied, setCopied] = useState(false);
|
|
32
|
-
async function loadTokens() {
|
|
33
|
-
setLoading(true);
|
|
34
|
-
setLoadError(null);
|
|
35
|
-
try {
|
|
36
|
-
const res = await fetch(TOKENS_URL);
|
|
37
|
-
if (!res.ok) {
|
|
38
|
-
const body2 = await res.json().catch(() => ({}));
|
|
39
|
-
throw new Error(body2.error ?? `HTTP ${res.status}`);
|
|
40
|
-
}
|
|
41
|
-
const body = await res.json();
|
|
42
|
-
setTokens(body.tokens);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
console.error("[mcp-tokens] load failed", err);
|
|
45
|
-
setLoadError(err instanceof Error ? err.message : String(err));
|
|
46
|
-
} finally {
|
|
47
|
-
setLoading(false);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
void loadTokens();
|
|
52
|
-
}, []);
|
|
53
|
-
async function createToken(e) {
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
if (!label.trim()) return;
|
|
56
|
-
setCreating(true);
|
|
57
|
-
setCreateError(null);
|
|
58
|
-
try {
|
|
59
|
-
const res = await fetch(TOKENS_URL, {
|
|
60
|
-
method: "POST",
|
|
61
|
-
headers: { "Content-Type": "application/json" },
|
|
62
|
-
body: JSON.stringify({ label: label.trim(), role })
|
|
63
|
-
});
|
|
64
|
-
if (!res.ok) {
|
|
65
|
-
const body2 = await res.json().catch(() => ({}));
|
|
66
|
-
throw new Error(body2.error ?? `HTTP ${res.status}`);
|
|
67
|
-
}
|
|
68
|
-
const body = await res.json();
|
|
69
|
-
setCreatedPlaintext(body.token);
|
|
70
|
-
setLabel("");
|
|
71
|
-
void loadTokens();
|
|
72
|
-
} catch (err) {
|
|
73
|
-
console.error("[mcp-tokens] create failed", err);
|
|
74
|
-
setCreateError(err instanceof Error ? err.message : String(err));
|
|
75
|
-
} finally {
|
|
76
|
-
setCreating(false);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async function revoke(hash) {
|
|
80
|
-
if (!confirm(t("mcpTokens.revokeConfirm"))) return;
|
|
81
|
-
try {
|
|
82
|
-
const res = await fetch(TOKENS_URL, {
|
|
83
|
-
method: "DELETE",
|
|
84
|
-
headers: { "Content-Type": "application/json" },
|
|
85
|
-
body: JSON.stringify({ hash })
|
|
86
|
-
});
|
|
87
|
-
if (!res.ok) {
|
|
88
|
-
const body = await res.json().catch(() => ({}));
|
|
89
|
-
throw new Error(body.error ?? `HTTP ${res.status}`);
|
|
90
|
-
}
|
|
91
|
-
void loadTokens();
|
|
92
|
-
} catch (err) {
|
|
93
|
-
console.error("[mcp-tokens] revoke failed", err);
|
|
94
|
-
alert(err instanceof Error ? err.message : String(err));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async function copyToClipboard() {
|
|
98
|
-
if (!createdPlaintext) return;
|
|
99
|
-
try {
|
|
100
|
-
await navigator.clipboard.writeText(createdPlaintext);
|
|
101
|
-
setCopied(true);
|
|
102
|
-
setTimeout(() => setCopied(false), 1500);
|
|
103
|
-
} catch (err) {
|
|
104
|
-
console.warn("[mcp-tokens] clipboard write failed", err);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-4xl space-y-8 p-4 md:p-8", children: [
|
|
108
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
109
|
-
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold md:text-3xl", children: t("mcpTokens.title") }),
|
|
110
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: t("mcpTokens.description") })
|
|
111
|
-
] }),
|
|
112
|
-
/* @__PURE__ */ jsxs("section", { className: "rounded-md border bg-card p-4 md:p-6", children: [
|
|
113
|
-
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: t("mcpTokens.createTitle") }),
|
|
114
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: t("mcpTokens.createHint") }),
|
|
115
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: createToken, className: "mt-4 space-y-3", children: [
|
|
116
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
117
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: "mcp-label", children: t("mcpTokens.labelLabel") }),
|
|
118
|
-
/* @__PURE__ */ jsx(
|
|
119
|
-
Input,
|
|
120
|
-
{
|
|
121
|
-
id: "mcp-label",
|
|
122
|
-
value: label,
|
|
123
|
-
placeholder: t("mcpTokens.labelPlaceholder"),
|
|
124
|
-
onChange: (e) => setLabel(e.target.value),
|
|
125
|
-
maxLength: 80
|
|
126
|
-
}
|
|
127
|
-
)
|
|
128
|
-
] }),
|
|
129
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
130
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: "mcp-role", children: t("mcpTokens.roleLabel") }),
|
|
131
|
-
/* @__PURE__ */ jsxs(
|
|
132
|
-
"select",
|
|
133
|
-
{
|
|
134
|
-
id: "mcp-role",
|
|
135
|
-
className: "w-full rounded-md border bg-background px-2 py-1.5 text-sm",
|
|
136
|
-
value: role,
|
|
137
|
-
onChange: (e) => setRole(e.target.value === "editor" ? "editor" : "admin"),
|
|
138
|
-
children: [
|
|
139
|
-
/* @__PURE__ */ jsx("option", { value: "admin", children: t("mcpTokens.roleAdmin") }),
|
|
140
|
-
/* @__PURE__ */ jsx("option", { value: "editor", children: t("mcpTokens.roleEditor") })
|
|
141
|
-
]
|
|
142
|
-
}
|
|
143
|
-
)
|
|
144
|
-
] }),
|
|
145
|
-
createError && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: createError }),
|
|
146
|
-
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: creating || !label.trim(), children: creating ? t("mcpTokens.creating") : t("mcpTokens.createButton") })
|
|
147
|
-
] })
|
|
148
|
-
] }),
|
|
149
|
-
/* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
|
|
150
|
-
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: t("mcpTokens.listTitle") }),
|
|
151
|
-
loading ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("mcpTokens.loading") }) : loadError ? /* @__PURE__ */ jsxs("p", { className: "text-sm text-destructive", children: [
|
|
152
|
-
t("mcpTokens.error"),
|
|
153
|
-
": ",
|
|
154
|
-
loadError
|
|
155
|
-
] }) : !tokens || tokens.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("mcpTokens.listEmpty") }) : /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs(Table, { children: [
|
|
156
|
-
/* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
157
|
-
/* @__PURE__ */ jsx(TableHead, { children: t("mcpTokens.columnLabel") }),
|
|
158
|
-
/* @__PURE__ */ jsx(TableHead, { children: t("mcpTokens.columnRole") }),
|
|
159
|
-
/* @__PURE__ */ jsx(TableHead, { children: t("mcpTokens.columnCreated") }),
|
|
160
|
-
/* @__PURE__ */ jsx(TableHead, { children: t("mcpTokens.columnLastUsed") }),
|
|
161
|
-
/* @__PURE__ */ jsx(TableHead, { children: t("mcpTokens.columnActions") })
|
|
162
|
-
] }) }),
|
|
163
|
-
/* @__PURE__ */ jsx(TableBody, { children: tokens.map((tok) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
164
|
-
/* @__PURE__ */ jsx(TableCell, { className: "font-medium", children: tok.label }),
|
|
165
|
-
/* @__PURE__ */ jsx(TableCell, { children: tok.role === "admin" ? t("mcpTokens.roleAdmin") : t("mcpTokens.roleEditor") }),
|
|
166
|
-
/* @__PURE__ */ jsx(TableCell, { className: "text-xs text-muted-foreground", children: new Date(tok.createdAt).toLocaleString() }),
|
|
167
|
-
/* @__PURE__ */ jsx(TableCell, { className: "text-xs text-muted-foreground", children: tok.lastUsedAt ? new Date(tok.lastUsedAt).toLocaleString() : t("mcpTokens.lastUsedNever") }),
|
|
168
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
|
|
169
|
-
Button,
|
|
170
|
-
{
|
|
171
|
-
type: "button",
|
|
172
|
-
variant: "outline",
|
|
173
|
-
size: "sm",
|
|
174
|
-
onClick: () => revoke(tok.hash),
|
|
175
|
-
children: t("mcpTokens.revoke")
|
|
176
|
-
}
|
|
177
|
-
) })
|
|
178
|
-
] }, tok.hash)) })
|
|
179
|
-
] }) })
|
|
180
|
-
] }),
|
|
181
|
-
createdPlaintext && /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-2xl rounded-md border bg-card p-6 shadow-lg", children: [
|
|
182
|
-
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold", children: t("mcpTokens.createdTitle") }),
|
|
183
|
-
/* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: t("mcpTokens.createdHint") }),
|
|
184
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 rounded-md border bg-muted/50 p-3", children: /* @__PURE__ */ jsx("code", { className: "block break-all font-mono text-xs", children: createdPlaintext }) }),
|
|
185
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-4 flex justify-end gap-2", children: [
|
|
186
|
-
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => void copyToClipboard(), children: copied ? t("mcpTokens.copied") : t("mcpTokens.copy") }),
|
|
187
|
-
/* @__PURE__ */ jsx(
|
|
188
|
-
Button,
|
|
189
|
-
{
|
|
190
|
-
type: "button",
|
|
191
|
-
onClick: () => {
|
|
192
|
-
setCreatedPlaintext(null);
|
|
193
|
-
setCopied(false);
|
|
194
|
-
},
|
|
195
|
-
children: t("mcpTokens.close")
|
|
196
|
-
}
|
|
197
|
-
)
|
|
198
|
-
] })
|
|
199
|
-
] }) })
|
|
200
|
-
] });
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export {
|
|
204
|
-
McpTokensView
|
|
205
|
-
};
|