@qodalis/cli-server-plugin-admin 1.0.0-beta.1 → 1.0.0-beta.12

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 (60) hide show
  1. package/README.md +177 -0
  2. package/dashboard/assets/index-CThBrI8x.js +248 -0
  3. package/dashboard/assets/index-SAFC7f6i.css +32 -0
  4. package/dashboard/assets/wasm/qodalis_cli_wasm_bg.wasm +0 -0
  5. package/dashboard/index.html +14 -0
  6. package/dist/auth/auth-controller.d.ts +5 -1
  7. package/dist/auth/auth-controller.d.ts.map +1 -1
  8. package/dist/auth/auth-controller.js +35 -5
  9. package/dist/auth/auth-controller.js.map +1 -1
  10. package/dist/auth/auth-middleware.d.ts +2 -1
  11. package/dist/auth/auth-middleware.d.ts.map +1 -1
  12. package/dist/auth/auth-middleware.js +35 -1
  13. package/dist/auth/auth-middleware.js.map +1 -1
  14. package/dist/auth/auth-provider.d.ts +33 -0
  15. package/dist/auth/auth-provider.d.ts.map +1 -0
  16. package/dist/auth/auth-provider.js +16 -0
  17. package/dist/auth/auth-provider.js.map +1 -0
  18. package/dist/auth/jwt-service.d.ts +12 -2
  19. package/dist/auth/jwt-service.d.ts.map +1 -1
  20. package/dist/auth/jwt-service.js +11 -2
  21. package/dist/auth/jwt-service.js.map +1 -1
  22. package/dist/cli-admin-builder.d.ts +42 -9
  23. package/dist/cli-admin-builder.d.ts.map +1 -1
  24. package/dist/cli-admin-builder.js +71 -49
  25. package/dist/cli-admin-builder.js.map +1 -1
  26. package/dist/controllers/plugins-controller.d.ts.map +1 -1
  27. package/dist/controllers/plugins-controller.js +1 -2
  28. package/dist/controllers/plugins-controller.js.map +1 -1
  29. package/dist/controllers/status-controller.d.ts +1 -0
  30. package/dist/controllers/status-controller.d.ts.map +1 -1
  31. package/dist/controllers/status-controller.js.map +1 -1
  32. package/dist/controllers/ws-clients-controller.d.ts +1 -0
  33. package/dist/controllers/ws-clients-controller.d.ts.map +1 -1
  34. package/dist/controllers/ws-clients-controller.js.map +1 -1
  35. package/dist/index.d.ts +3 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +7 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/services/admin-config.d.ts +15 -3
  40. package/dist/services/admin-config.d.ts.map +1 -1
  41. package/dist/services/admin-config.js +15 -3
  42. package/dist/services/admin-config.js.map +1 -1
  43. package/dist/services/admin-theme.d.ts +31 -0
  44. package/dist/services/admin-theme.d.ts.map +1 -0
  45. package/dist/services/admin-theme.js +94 -0
  46. package/dist/services/admin-theme.js.map +1 -0
  47. package/dist/services/dashboard-dir.d.ts +10 -0
  48. package/dist/services/dashboard-dir.d.ts.map +1 -0
  49. package/dist/services/dashboard-dir.js +51 -0
  50. package/dist/services/dashboard-dir.js.map +1 -0
  51. package/dist/services/log-ring-buffer.d.ts +6 -0
  52. package/dist/services/log-ring-buffer.d.ts.map +1 -1
  53. package/dist/services/log-ring-buffer.js +13 -0
  54. package/dist/services/log-ring-buffer.js.map +1 -1
  55. package/dist/services/module-registry.d.ts +12 -7
  56. package/dist/services/module-registry.d.ts.map +1 -1
  57. package/dist/services/module-registry.js +22 -10
  58. package/dist/services/module-registry.js.map +1 -1
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +6 -2
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # @qodalis/cli-server-plugin-admin
2
+
3
+ Admin dashboard plugin for [Qodalis CLI Server (Node.js)](https://github.com/qodalis-solutions/cli-server-node). Provides JWT authentication, server status, plugin management, configuration, log viewing, and WebSocket client monitoring via a REST API and bundled SPA dashboard.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @qodalis/cli-server-plugin-admin
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { createCliServer } from '@qodalis/cli-server-node';
15
+ import { CliAdminBuilder } from '@qodalis/cli-server-plugin-admin';
16
+
17
+ const { app, registry, builder, eventSocketManager } = createCliServer({
18
+ configure: (builder) => {
19
+ // register your modules...
20
+ },
21
+ });
22
+
23
+ const adminPlugin = new CliAdminBuilder()
24
+ .setCredentials('admin', 'my-secret-password')
25
+ .setJwtSecret('my-jwt-secret')
26
+ .build({ registry, eventSocketManager, builder });
27
+
28
+ // Using createCliServer:
29
+ mountPlugin(adminPlugin);
30
+
31
+ // Or on an existing Express app:
32
+ app.use(adminPlugin.prefix, adminPlugin.router);
33
+ app.use(adminPlugin.dashboardPrefix, adminPlugin.dashboardRouter);
34
+ ```
35
+
36
+ ## Configuration
37
+
38
+ When the users plugin is installed, pass `setAuthProvider(usersPlugin.serverAuth)`: the dashboard then logs in with users credentials, its token is a users session token, and every admin route requires `admin:access`. The static credentials below are only used when the users plugin is absent.
39
+
40
+ Credentials and JWT secret can be set via the builder or environment variables:
41
+
42
+ | Environment Variable | Default | Description |
43
+ |---|---|---|
44
+ | `QCLI_ADMIN_USERNAME` | `admin` | Admin login username |
45
+ | `QCLI_ADMIN_PASSWORD` | `admin` | Admin login password |
46
+ | `QCLI_ADMIN_JWT_SECRET` | Random | JWT signing secret |
47
+
48
+ ## Builder Options
49
+
50
+ | Method | Description |
51
+ |---|---|
52
+ | `setCredentials(username, password)` | Set admin login credentials (only used without the users plugin) |
53
+ | `setAuthProvider(usersPlugin.serverAuth)` | Log in through the users plugin; requires the `admin:access` permission (`admin` has it via `*`) |
54
+ | `setJwtSecret(secret)` | Set JWT signing secret |
55
+ | `setRegisteredJobs(count)` | Report job count in the status endpoint |
56
+ | `setEnabledFeatures(features)` | Add custom feature flags to the status endpoint |
57
+ | `setDashboardDir(dir)` | Override the path to the dashboard SPA dist directory |
58
+ | `setTheme(theme)` | Dashboard color scheme: mode and per-scheme colors (see [Color scheme](#color-scheme)) |
59
+
60
+ ## REST API
61
+
62
+ All endpoints are mounted at the plugin's built-in prefix (`/api/v1/qcli`). Routes below `/auth/login` require a valid JWT in the `Authorization: Bearer <token>` header.
63
+
64
+ ### Authentication
65
+
66
+ | Method | Endpoint | Description |
67
+ |---|---|---|
68
+ | POST | `/auth/login` | Authenticate with username/password, receive JWT |
69
+ | GET | `/auth/me` | Get current user info from token |
70
+
71
+ ### Status
72
+
73
+ | Method | Endpoint | Description |
74
+ |---|---|---|
75
+ | GET | `/status` | Server uptime, memory, platform, connections, registered commands, enabled features |
76
+
77
+ ### Plugins
78
+
79
+ | Method | Endpoint | Description |
80
+ |---|---|---|
81
+ | GET | `/plugins` | List all registered modules |
82
+ | POST | `/plugins/:id/toggle` | Enable or disable a module |
83
+
84
+ ### Configuration
85
+
86
+ When the users plugin is installed, pass `setAuthProvider(usersPlugin.serverAuth)`: the dashboard then logs in with users credentials, its token is a users session token, and every admin route requires `admin:access`. The static credentials below are only used when the users plugin is absent.
87
+
88
+ | Method | Endpoint | Description |
89
+ |---|---|---|
90
+ | GET | `/config` | Return structured config sections (server, auth, custom) |
91
+ | PUT | `/config` | Update mutable (custom) settings |
92
+
93
+ ### Logs
94
+
95
+ | Method | Endpoint | Description |
96
+ |---|---|---|
97
+ | GET | `/logs` | Query log entries with optional `level`, `search`, `limit`, `offset` params |
98
+
99
+ The log buffer captures `console.log`/`warn`/`error` output. As a safety net, a value written after a `password`, `passwd`, `secret` or `token` label (`password: x`, `token=x`, `password for user "root": x`) is replaced with `[REDACTED]` before the entry is stored or broadcast.
100
+
101
+ ### WebSocket Clients
102
+
103
+ | Method | Endpoint | Description |
104
+ |---|---|---|
105
+ | GET | `/ws/clients` | List connected WebSocket clients |
106
+
107
+ ## Dashboard
108
+
109
+ The plugin includes a bundled SPA dashboard served at the built-in prefix (`/qcli/admin`). The dashboard is found in this order: the directory given to `setDashboardDir()`, a sibling `cli-server-dashboard/dist` build (development), the package's bundled `dashboard/` directory, and the `@qodalis/cli-server-dashboard` package if installed separately. The same order applies whether the plugin runs compiled or from source (`tsx`).
110
+
111
+ ## Color scheme
112
+
113
+ Match the dashboard to your own design with `setTheme()`:
114
+
115
+ ```typescript
116
+ const adminPlugin = new CliAdminBuilder()
117
+ .setCredentials('admin', 'my-secret-password')
118
+ .setTheme({
119
+ mode: 'system',
120
+ light: {
121
+ primary: '#2a6bba', primaryHover: '#1f5596', accent: '#2a6bba',
122
+ background: '#f1f6fa', backgroundAccent: '#f1f6fa', surface: '#ffffff',
123
+ border: '#d9e3ec', heading: '#142231', text: '#142231', muted: '#5d6f82',
124
+ },
125
+ dark: {
126
+ primary: '#4f9be0', primaryHover: '#3f8ad3', onPrimary: '#0d1823', accent: '#4f9be0',
127
+ background: '#0d1823', backgroundAccent: '#0d1823', surface: '#13212f', popover: '#13212f',
128
+ border: '#22364a', text: '#e6eef6', muted: '#93a6b9',
129
+ },
130
+ })
131
+ .build({ registry, eventSocketManager, builder, executor });
132
+ ```
133
+
134
+ `setTheme()` throws on an invalid theme. The types (`AdminTheme`, `AdminThemeColors`, `AdminThemeMode`) and
135
+ `validateAdminTheme()` are exported.
136
+
137
+ `mode` is `dark` (default), `light`, or `system` to follow the browser's `prefers-color-scheme`. Each scheme takes any
138
+ subset of the tokens below; the ones you leave out keep their defaults.
139
+
140
+ Values must be plain CSS colors: hex (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`), a color function with numeric arguments
141
+ (`rgb()`, `rgba()`, `hsl()`, `hsla()`, `hwb()`, `lab()`, `lch()`, `oklab()`, `oklch()`) or a named color. Anything else
142
+ (an unknown mode or token, `var()`, `url()`, `;` ...) is rejected at startup with an error naming the token, so a theme
143
+ cannot inject CSS.
144
+
145
+ The plugin serves the validated scheme at `GET /qcli/admin/theme.json` (public, like the dashboard files, since the
146
+ sign-in page uses it), e.g. `{"mode":"system","dark":{"primary":"#4f9be0"},"light":{"primary":"#2a6bba"}}`. The
147
+ dashboard applies it before its first render.
148
+
149
+ The defaults match the Qodalis CLI panel: its grays, indigo accent with the violet glow, and status colors in dark; the same palette for light backgrounds in light.
150
+
151
+ | Token | CSS variable | Used for | Dark default | Light default |
152
+ | --- | --- | --- | --- | --- |
153
+ | `primary` | `--qcli-primary` | Primary buttons, active navigation, toggles, focus rings | `#818cf8` | `#4f46e5` |
154
+ | `primaryHover` | `--qcli-primary-hover` | Primary buttons on hover | `#a5b4fc` | `#4338ca` |
155
+ | `onPrimary` | `--qcli-on-primary` | Text and icons on `primary` | `#111827` | `#ffffff` |
156
+ | `accent` | `--qcli-accent` | Highlighted text: links, command names, active items | `#a78bfa` | `#7c3aed` |
157
+ | `background` | `--qcli-background` | Page background | `#111827` | `#f9fafb` |
158
+ | `backgroundAccent` | `--qcli-background-accent` | Start of the page background gradient (set it to `background` for a flat page) | `#1f2937` | `#eef2ff` |
159
+ | `sidebar` | `--qcli-sidebar` | Sidebar background | `#1f2937` | `#ffffff` |
160
+ | `surface` | `--qcli-surface` | Cards, panels and tables | `rgba(255, 255, 255, 0.04)` | `#ffffff` |
161
+ | `popover` | `--qcli-popover` | Dialogs and dropdown menus (opaque) | `#1f2937` | `#ffffff` |
162
+ | `control` | `--qcli-control` | Inputs, secondary buttons, chips | `rgba(255, 255, 255, 0.06)` | `rgba(17, 24, 39, 0.05)` |
163
+ | `controlHover` | `--qcli-control-hover` | Inputs and secondary buttons on hover | `rgba(255, 255, 255, 0.1)` | `rgba(17, 24, 39, 0.1)` |
164
+ | `border` | `--qcli-border` | Borders and dividers | `#374151` | `#e5e7eb` |
165
+ | `overlay` | `--qcli-overlay` | Backdrop behind dialogs | `rgba(0, 0, 0, 0.6)` | `rgba(17, 24, 39, 0.45)` |
166
+ | `heading` | `--qcli-heading` | Headings and values | `#ffffff` | `#111827` |
167
+ | `text` | `--qcli-text` | Body text | `rgba(255, 255, 255, 0.87)` | `#1f2937` |
168
+ | `muted` | `--qcli-muted` | Secondary text and labels | `rgba(255, 255, 255, 0.6)` | `#4b5563` |
169
+ | `subtle` | `--qcli-subtle` | Hints, placeholders, timestamps | `rgba(255, 255, 255, 0.4)` | `#6b7280` |
170
+ | `success` | `--qcli-success` | Success states | `#3fb950` | `#1a7f37` |
171
+ | `warning` | `--qcli-warning` | Warning states | `#f0883e` | `#bc4c00` |
172
+ | `error` | `--qcli-error` | Errors and destructive actions | `#f85149` | `#cf222e` |
173
+ | `info` | `--qcli-info` | Informational states | `#58a6ff` | `#0969da` |
174
+
175
+ ## License
176
+
177
+ MIT