@bhooai/nexus-cli 2.0.7 → 2.0.9
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/package.json +1 -1
- package/templates/base/apps/admin/package.json.ejs +3 -3
- package/templates/base/apps/admin/postcss.config.js +1 -1
- package/templates/base/apps/admin/tailwind.config.js +1 -0
- package/templates/base/apps/admin/src/App.tsx +0 -38
- package/templates/base/apps/admin/src/alertCenter.tsx +0 -151
- package/templates/base/apps/admin/src/api.ts +0 -474
- package/templates/base/apps/admin/src/assets/bhooai-nexus-logo.svg +0 -25
- package/templates/base/apps/admin/src/components/ThemeCentre.tsx +0 -201
- package/templates/base/apps/admin/src/components/shell/AppearancePanel.tsx +0 -37
- package/templates/base/apps/admin/src/components/shell/Dashboard.tsx +0 -441
- package/templates/base/apps/admin/src/components/shell/Login.tsx +0 -69
- package/templates/base/apps/admin/src/components/shell/NotifyPanel.tsx +0 -102
- package/templates/base/apps/admin/src/components/shell/RailPanel.tsx +0 -133
- package/templates/base/apps/admin/src/components/shell/SettingsDialog.tsx +0 -217
- package/templates/base/apps/admin/src/components/ui/ConfirmDialog.tsx +0 -38
- package/templates/base/apps/admin/src/components/ui/LintChecks.tsx +0 -54
- package/templates/base/apps/admin/src/components/ui/PageHead.tsx +0 -13
- package/templates/base/apps/admin/src/components/ui/PageHero.tsx +0 -15
- package/templates/base/apps/admin/src/icons.tsx +0 -104
- package/templates/base/apps/admin/src/index.css +0 -3539
- package/templates/base/apps/admin/src/lib/constants.ts +0 -94
- package/templates/base/apps/admin/src/lib/theme.ts +0 -80
- package/templates/base/apps/admin/src/lib/types.ts +0 -39
- package/templates/base/apps/admin/src/lib/utils.ts +0 -147
- package/templates/base/apps/admin/src/pages/Config.tsx +0 -108
- package/templates/base/apps/admin/src/pages/Databases.tsx +0 -122
- package/templates/base/apps/admin/src/pages/Environment.tsx +0 -69
- package/templates/base/apps/admin/src/pages/Logs.tsx +0 -270
- package/templates/base/apps/admin/src/pages/Monitoring.tsx +0 -88
- package/templates/base/apps/admin/src/pages/Overview.tsx +0 -108
- package/templates/base/apps/admin/src/pages/Payments.tsx +0 -68
- package/templates/base/apps/admin/src/pages/Plugins.tsx +0 -36
- package/templates/base/apps/admin/src/pages/Processes.tsx +0 -67
- package/templates/base/apps/admin/src/pages/Schema.tsx +0 -130
- package/templates/base/apps/admin/src/pages/Users.tsx +0 -144
- package/templates/base/apps/admin/src/pages/ai/AddProviderDialog.tsx +0 -150
- package/templates/base/apps/admin/src/pages/ai/AiAgents.tsx +0 -31
- package/templates/base/apps/admin/src/pages/ai/AiChatPlayground.tsx +0 -208
- package/templates/base/apps/admin/src/pages/ai/AiProviders.tsx +0 -276
- package/templates/base/apps/admin/src/pages/ai/AiSettings.tsx +0 -84
- package/templates/base/apps/admin/src/pages/ai/ProviderCard.tsx +0 -145
- package/templates/base/apps/admin/src/pages/ai/ProviderGroup.tsx +0 -50
- package/templates/base/apps/admin/src/pages/ai/ProviderKeyDialog.tsx +0 -66
- package/templates/base/apps/admin/src/pages/monitoring/RequestSeriesChart.tsx +0 -70
- package/templates/base/apps/admin/src/pages/overview/TrafficChart.tsx +0 -32
- package/templates/base/apps/admin/src/pages/payments/OrdersTable.tsx +0 -27
- package/templates/base/apps/admin/src/pages/payments/PaymentKeysDialog.tsx +0 -74
- package/templates/base/apps/admin/src/pages/payments/TestConsole.tsx +0 -173
- package/templates/base/apps/admin/src/pages/payments/TransactionsTable.tsx +0 -26
- package/templates/base/apps/admin/src/style.css +0 -6517
package/package.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"build": "vite build"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@bhooai/nexus-admin": "
|
|
12
|
-
"@bhooai/nexus-safe-goto": "
|
|
11
|
+
"@bhooai/nexus-admin": "^2.0.6",
|
|
12
|
+
"@bhooai/nexus-safe-goto": "^2.0.1",
|
|
13
13
|
"react": "^18.3.1",
|
|
14
14
|
"react-dom": "^18.3.1"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@bhooai/nexus-postcss": "^2.0.
|
|
17
|
+
"@bhooai/nexus-postcss": "^2.0.6",
|
|
18
18
|
"tailwindcss": "^3.4.14",
|
|
19
19
|
"vite": "^5.4.10"
|
|
20
20
|
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { AlertProvider } from './alertCenter.js';
|
|
3
|
-
import { getAccessToken, refresh, setAccessToken } from './api.js';
|
|
4
|
-
import type { AdminUser } from './lib/types.js';
|
|
5
|
-
import { USER_KEY } from './lib/constants.js';
|
|
6
|
-
import { readUser } from './lib/utils.js';
|
|
7
|
-
import { Dashboard } from './components/shell/Dashboard.js';
|
|
8
|
-
import { Login } from './components/shell/Login.js';
|
|
9
|
-
|
|
10
|
-
export function App() {
|
|
11
|
-
const [boot, setBoot] = useState<'loading' | 'ready'>('loading');
|
|
12
|
-
const [authed, setAuthed] = useState(() => !!getAccessToken());
|
|
13
|
-
const [user, setUser] = useState<AdminUser | null>(readUser);
|
|
14
|
-
|
|
15
|
-
// Restore the session from the HttpOnly refresh cookie on boot, so a page
|
|
16
|
-
// reload stays logged in instead of bouncing back to the login screen.
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (getAccessToken()) {
|
|
19
|
-
setBoot('ready');
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
void refresh().then((ok) => {
|
|
23
|
-
if (ok) {
|
|
24
|
-
setAuthed(true);
|
|
25
|
-
// Reuse any stored user; refresh() only restores the token + identity.
|
|
26
|
-
setUser(readUser());
|
|
27
|
-
}
|
|
28
|
-
setBoot('ready');
|
|
29
|
-
});
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
if (boot === 'loading') {
|
|
33
|
-
return <div className="admin-boot bg-mesh"><span className="admin-overline">Loading…</span></div>;
|
|
34
|
-
}
|
|
35
|
-
if (!authed) return <Login onAuthed={(u) => { setUser(u); window.localStorage.setItem(USER_KEY, JSON.stringify(u)); setAuthed(true); }} />;
|
|
36
|
-
const onUserChange = (u: AdminUser) => { setUser(u); try { window.localStorage.setItem(USER_KEY, JSON.stringify(u)); } catch { /* ignore */ } };
|
|
37
|
-
return <AlertProvider><Dashboard user={user} onUserChange={onUserChange} onLogout={() => { setAccessToken(''); setUser(null); window.localStorage.removeItem(USER_KEY); setAuthed(false); }} /></AlertProvider>;
|
|
38
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { createContext, useCallback, useContext, useEffect, useRef, useState, type ReactNode } from 'react';
|
|
2
|
-
import { Icon, type IconName } from './icons.js';
|
|
3
|
-
|
|
4
|
-
export type AlertKind = 'ok' | 'err' | 'warn';
|
|
5
|
-
|
|
6
|
-
export interface AdminAlert {
|
|
7
|
-
id: string;
|
|
8
|
-
kind: AlertKind;
|
|
9
|
-
message: string;
|
|
10
|
-
source: string;
|
|
11
|
-
at: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface AlertContextValue {
|
|
15
|
-
alerts: AdminAlert[];
|
|
16
|
-
toasts: AdminAlert[];
|
|
17
|
-
push: (kind: AlertKind, message: string, source: string) => void;
|
|
18
|
-
clear: () => void;
|
|
19
|
-
dismiss: (id: string) => void;
|
|
20
|
-
dismissToast: (id: string) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const TOAST_TTL = 4500;
|
|
24
|
-
|
|
25
|
-
const ALERTS_KEY = 'nexus-admin-alerts';
|
|
26
|
-
const MAX_ALERTS = 50;
|
|
27
|
-
|
|
28
|
-
const AlertContext = createContext<AlertContextValue | null>(null);
|
|
29
|
-
|
|
30
|
-
function loadAlerts(): AdminAlert[] {
|
|
31
|
-
if (typeof window === 'undefined') return [];
|
|
32
|
-
try {
|
|
33
|
-
const raw = window.localStorage.getItem(ALERTS_KEY);
|
|
34
|
-
if (!raw) return [];
|
|
35
|
-
const parsed = JSON.parse(raw) as AdminAlert[];
|
|
36
|
-
if (!Array.isArray(parsed)) return [];
|
|
37
|
-
return parsed
|
|
38
|
-
.filter((a) => a && typeof a.message === 'string' && typeof a.source === 'string')
|
|
39
|
-
.slice(0, MAX_ALERTS);
|
|
40
|
-
} catch { /* ignore corrupt value */ }
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function AlertProvider({ children }: { children: ReactNode }) {
|
|
45
|
-
const [alerts, setAlerts] = useState<AdminAlert[]>(() => loadAlerts());
|
|
46
|
-
const [toasts, setToasts] = useState<AdminAlert[]>([]);
|
|
47
|
-
const idRef = useRef(0);
|
|
48
|
-
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
try { window.localStorage.setItem(ALERTS_KEY, JSON.stringify(alerts)); } catch { /* storage unavailable */ }
|
|
51
|
-
}, [alerts]);
|
|
52
|
-
|
|
53
|
-
const push = useCallback((kind: AlertKind, message: string, source: string) => {
|
|
54
|
-
const text = String(message ?? '').trim();
|
|
55
|
-
if (!text) return;
|
|
56
|
-
idRef.current += 1;
|
|
57
|
-
const alert: AdminAlert = {
|
|
58
|
-
id: `${Date.now()}-${idRef.current}`,
|
|
59
|
-
kind,
|
|
60
|
-
message: text,
|
|
61
|
-
source: source || 'admin',
|
|
62
|
-
at: new Date().toLocaleString(),
|
|
63
|
-
};
|
|
64
|
-
setAlerts((prev) => [alert, ...prev].slice(0, MAX_ALERTS));
|
|
65
|
-
setToasts((prev) => [...prev.slice(-3), alert]);
|
|
66
|
-
window.setTimeout(() => {
|
|
67
|
-
setToasts((prev) => prev.filter((t) => t.id !== alert.id));
|
|
68
|
-
}, TOAST_TTL);
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
const clear = useCallback(() => setAlerts([]), []);
|
|
72
|
-
|
|
73
|
-
const dismiss = useCallback((id: string) => {
|
|
74
|
-
setAlerts((prev) => prev.filter((a) => a.id !== id));
|
|
75
|
-
}, []);
|
|
76
|
-
|
|
77
|
-
const dismissToast = useCallback((id: string) => {
|
|
78
|
-
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
79
|
-
}, []);
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<AlertContext.Provider value={{ alerts, toasts, push, clear, dismiss, dismissToast }}>
|
|
83
|
-
{children}
|
|
84
|
-
</AlertContext.Provider>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function useAlerts(): AlertContextValue {
|
|
89
|
-
const ctx = useContext(AlertContext);
|
|
90
|
-
if (!ctx) throw new Error('useAlerts must be used within <AlertProvider>');
|
|
91
|
-
return ctx;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** Pages that default their action messages to "warn" unless they look like errors. */
|
|
95
|
-
const WARN_SOURCES = new Set<string>();
|
|
96
|
-
|
|
97
|
-
function kindFor(source: string, value: string): AlertKind {
|
|
98
|
-
if (WARN_SOURCES.has(source)) return 'warn';
|
|
99
|
-
return /fail|error|could not|no .* (found|available)|unavailable|invalid|missing|rejected|failed|did not|unreachable/i.test(value) ? 'err' : 'ok';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function useAdminAlert(source: string): [
|
|
103
|
-
string | null,
|
|
104
|
-
(value: string | { kind: AlertKind; text: string } | null) => void,
|
|
105
|
-
] {
|
|
106
|
-
const { push } = useAlerts();
|
|
107
|
-
const [msg, setMsg] = useState<string | null>(null);
|
|
108
|
-
const currentRef = useRef<string | null>(null);
|
|
109
|
-
|
|
110
|
-
const set = useCallback((value: string | { kind: AlertKind; text: string } | null) => {
|
|
111
|
-
if (!value) { currentRef.current = null; setMsg(null); return; }
|
|
112
|
-
if (typeof value === 'object') {
|
|
113
|
-
const text = String(value.text ?? '').trim();
|
|
114
|
-
if (!text) return;
|
|
115
|
-
if (text === currentRef.current) { setMsg(text); return; }
|
|
116
|
-
currentRef.current = text;
|
|
117
|
-
setMsg(text);
|
|
118
|
-
push(value.kind, text, source);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const text = String(value).trim();
|
|
122
|
-
const current = currentRef.current;
|
|
123
|
-
currentRef.current = text || null;
|
|
124
|
-
setMsg(text || null);
|
|
125
|
-
if (text && text !== current) push(kindFor(source, text), text, source);
|
|
126
|
-
}, [push, source]);
|
|
127
|
-
|
|
128
|
-
return [msg, set];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const TOAST_ICONS: Record<AlertKind, IconName> = { ok: 'check', err: 'x', warn: 'alertCircle' };
|
|
132
|
-
|
|
133
|
-
/** Floating alert popups, top-right, themed via the surrounding admin shell. */
|
|
134
|
-
export function ToastStack() {
|
|
135
|
-
const { toasts, dismissToast } = useAlerts();
|
|
136
|
-
if (!toasts.length) return null;
|
|
137
|
-
return (
|
|
138
|
-
<div className="admin-toasts" role="region" aria-label="Notifications">
|
|
139
|
-
{toasts.map((t) => (
|
|
140
|
-
<div key={t.id} className={`admin-toast is-${t.kind}`} role="status">
|
|
141
|
-
<span className="admin-toast-icon"><Icon name={TOAST_ICONS[t.kind]} size={14} /></span>
|
|
142
|
-
<span className="admin-toast-body">
|
|
143
|
-
<b>{t.message}</b>
|
|
144
|
-
<small>{t.source} · {t.at}</small>
|
|
145
|
-
</span>
|
|
146
|
-
<button type="button" className="admin-toast-x" aria-label="Dismiss notification" onClick={() => dismissToast(t.id)}>×</button>
|
|
147
|
-
</div>
|
|
148
|
-
))}
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
}
|