@qwickapps/server 1.1.9 → 1.3.0
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/README.md +318 -0
- package/dist/core/control-panel.d.ts +7 -2
- package/dist/core/control-panel.d.ts.map +1 -1
- package/dist/core/control-panel.js +99 -60
- package/dist/core/control-panel.js.map +1 -1
- package/dist/core/gateway.d.ts +159 -79
- package/dist/core/gateway.d.ts.map +1 -1
- package/dist/core/gateway.js +683 -315
- package/dist/core/gateway.js.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/plugin-registry.d.ts +271 -0
- package/dist/core/plugin-registry.d.ts.map +1 -0
- package/dist/core/plugin-registry.js +326 -0
- package/dist/core/plugin-registry.js.map +1 -0
- package/dist/core/types.d.ts +16 -33
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -7
- package/dist/index.js.map +1 -1
- package/dist/plugins/auth/adapters/auth0-adapter.d.ts +14 -0
- package/dist/plugins/auth/adapters/auth0-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/auth0-adapter.js +179 -0
- package/dist/plugins/auth/adapters/auth0-adapter.js.map +1 -0
- package/dist/plugins/auth/adapters/basic-adapter.d.ts +13 -0
- package/dist/plugins/auth/adapters/basic-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/basic-adapter.js +51 -0
- package/dist/plugins/auth/adapters/basic-adapter.js.map +1 -0
- package/dist/plugins/auth/adapters/index.d.ts +9 -0
- package/dist/plugins/auth/adapters/index.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/index.js +9 -0
- package/dist/plugins/auth/adapters/index.js.map +1 -0
- package/dist/plugins/auth/adapters/supabase-adapter.d.ts +13 -0
- package/dist/plugins/auth/adapters/supabase-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/supabase-adapter.js +109 -0
- package/dist/plugins/auth/adapters/supabase-adapter.js.map +1 -0
- package/dist/plugins/auth/auth-plugin.d.ts +40 -0
- package/dist/plugins/auth/auth-plugin.d.ts.map +1 -0
- package/dist/plugins/auth/auth-plugin.js +255 -0
- package/dist/plugins/auth/auth-plugin.js.map +1 -0
- package/dist/plugins/auth/auth-plugin.test.d.ts +9 -0
- package/dist/plugins/auth/auth-plugin.test.d.ts.map +1 -0
- package/dist/plugins/auth/auth-plugin.test.js +147 -0
- package/dist/plugins/auth/auth-plugin.test.js.map +1 -0
- package/dist/plugins/auth/index.d.ts +12 -0
- package/dist/plugins/auth/index.d.ts.map +1 -0
- package/dist/plugins/auth/index.js +13 -0
- package/dist/plugins/auth/index.js.map +1 -0
- package/dist/plugins/auth/types.d.ts +148 -0
- package/dist/plugins/auth/types.d.ts.map +1 -0
- package/dist/plugins/auth/types.js +14 -0
- package/dist/plugins/auth/types.js.map +1 -0
- package/dist/plugins/bans/bans-plugin.d.ts +59 -0
- package/dist/plugins/bans/bans-plugin.d.ts.map +1 -0
- package/dist/plugins/bans/bans-plugin.js +428 -0
- package/dist/plugins/bans/bans-plugin.js.map +1 -0
- package/dist/plugins/bans/index.d.ts +9 -0
- package/dist/plugins/bans/index.d.ts.map +1 -0
- package/dist/plugins/bans/index.js +10 -0
- package/dist/plugins/bans/index.js.map +1 -0
- package/dist/plugins/bans/stores/index.d.ts +7 -0
- package/dist/plugins/bans/stores/index.d.ts.map +1 -0
- package/dist/plugins/bans/stores/index.js +7 -0
- package/dist/plugins/bans/stores/index.js.map +1 -0
- package/dist/plugins/bans/stores/postgres-store.d.ts +29 -0
- package/dist/plugins/bans/stores/postgres-store.d.ts.map +1 -0
- package/dist/plugins/bans/stores/postgres-store.js +132 -0
- package/dist/plugins/bans/stores/postgres-store.js.map +1 -0
- package/dist/plugins/bans/types.d.ts +128 -0
- package/dist/plugins/bans/types.d.ts.map +1 -0
- package/dist/plugins/bans/types.js +11 -0
- package/dist/plugins/bans/types.js.map +1 -0
- package/dist/plugins/cache-plugin.d.ts +14 -3
- package/dist/plugins/cache-plugin.d.ts.map +1 -1
- package/dist/plugins/cache-plugin.js +27 -7
- package/dist/plugins/cache-plugin.js.map +1 -1
- package/dist/plugins/cache-plugin.test.js +96 -32
- package/dist/plugins/cache-plugin.test.js.map +1 -1
- package/dist/plugins/config-plugin.d.ts +3 -2
- package/dist/plugins/config-plugin.d.ts.map +1 -1
- package/dist/plugins/config-plugin.js +17 -10
- package/dist/plugins/config-plugin.js.map +1 -1
- package/dist/plugins/diagnostics-plugin.d.ts +2 -2
- package/dist/plugins/diagnostics-plugin.d.ts.map +1 -1
- package/dist/plugins/diagnostics-plugin.js +17 -10
- package/dist/plugins/diagnostics-plugin.js.map +1 -1
- package/dist/plugins/entitlements/entitlements-plugin.d.ts +95 -0
- package/dist/plugins/entitlements/entitlements-plugin.d.ts.map +1 -0
- package/dist/plugins/entitlements/entitlements-plugin.js +707 -0
- package/dist/plugins/entitlements/entitlements-plugin.js.map +1 -0
- package/dist/plugins/entitlements/index.d.ts +12 -0
- package/dist/plugins/entitlements/index.d.ts.map +1 -0
- package/dist/plugins/entitlements/index.js +16 -0
- package/dist/plugins/entitlements/index.js.map +1 -0
- package/dist/plugins/entitlements/sources/index.d.ts +9 -0
- package/dist/plugins/entitlements/sources/index.d.ts.map +1 -0
- package/dist/plugins/entitlements/sources/index.js +9 -0
- package/dist/plugins/entitlements/sources/index.js.map +1 -0
- package/dist/plugins/entitlements/sources/postgres-source.d.ts +29 -0
- package/dist/plugins/entitlements/sources/postgres-source.d.ts.map +1 -0
- package/dist/plugins/entitlements/sources/postgres-source.js +169 -0
- package/dist/plugins/entitlements/sources/postgres-source.js.map +1 -0
- package/dist/plugins/entitlements/types.d.ts +232 -0
- package/dist/plugins/entitlements/types.d.ts.map +1 -0
- package/dist/plugins/entitlements/types.js +11 -0
- package/dist/plugins/entitlements/types.js.map +1 -0
- package/dist/plugins/frontend-app-plugin.d.ts +9 -3
- package/dist/plugins/frontend-app-plugin.d.ts.map +1 -1
- package/dist/plugins/frontend-app-plugin.js +14 -9
- package/dist/plugins/frontend-app-plugin.js.map +1 -1
- package/dist/plugins/health-plugin.d.ts +5 -2
- package/dist/plugins/health-plugin.d.ts.map +1 -1
- package/dist/plugins/health-plugin.js +20 -5
- package/dist/plugins/health-plugin.js.map +1 -1
- package/dist/plugins/index.d.ts +8 -2
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +8 -2
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/logs-plugin.d.ts +3 -2
- package/dist/plugins/logs-plugin.d.ts.map +1 -1
- package/dist/plugins/logs-plugin.js +21 -12
- package/dist/plugins/logs-plugin.js.map +1 -1
- package/dist/plugins/postgres-plugin.d.ts +3 -3
- package/dist/plugins/postgres-plugin.d.ts.map +1 -1
- package/dist/plugins/postgres-plugin.js +9 -7
- package/dist/plugins/postgres-plugin.js.map +1 -1
- package/dist/plugins/postgres-plugin.test.js +47 -29
- package/dist/plugins/postgres-plugin.test.js.map +1 -1
- package/dist/plugins/users/index.d.ts +12 -0
- package/dist/plugins/users/index.d.ts.map +1 -0
- package/dist/plugins/users/index.js +13 -0
- package/dist/plugins/users/index.js.map +1 -0
- package/dist/plugins/users/stores/index.d.ts +7 -0
- package/dist/plugins/users/stores/index.d.ts.map +1 -0
- package/dist/plugins/users/stores/index.js +7 -0
- package/dist/plugins/users/stores/index.js.map +1 -0
- package/dist/plugins/users/stores/postgres-store.d.ts +28 -0
- package/dist/plugins/users/stores/postgres-store.d.ts.map +1 -0
- package/dist/plugins/users/stores/postgres-store.js +157 -0
- package/dist/plugins/users/stores/postgres-store.js.map +1 -0
- package/dist/plugins/users/types.d.ts +189 -0
- package/dist/plugins/users/types.d.ts.map +1 -0
- package/dist/plugins/users/types.js +12 -0
- package/dist/plugins/users/types.js.map +1 -0
- package/dist/plugins/users/users-plugin.d.ts +39 -0
- package/dist/plugins/users/users-plugin.d.ts.map +1 -0
- package/dist/plugins/users/users-plugin.js +242 -0
- package/dist/plugins/users/users-plugin.js.map +1 -0
- package/dist-ui/assets/index-Bsp2ntcw.js +465 -0
- package/dist-ui/assets/index-Bsp2ntcw.js.map +1 -0
- package/dist-ui/index.html +1 -1
- package/dist-ui-lib/api/controlPanelApi.d.ts +232 -0
- package/dist-ui-lib/components/ControlPanelApp.d.ts +61 -0
- package/dist-ui-lib/components/index.d.ts +18 -0
- package/dist-ui-lib/config/AppConfig.d.ts +7 -0
- package/dist-ui-lib/dashboard/DashboardWidgetRegistry.d.ts +62 -0
- package/dist-ui-lib/dashboard/DashboardWidgetRenderer.d.ts +8 -0
- package/dist-ui-lib/dashboard/PluginWidgetRenderer.d.ts +19 -0
- package/dist-ui-lib/dashboard/WidgetComponentRegistry.d.ts +44 -0
- package/dist-ui-lib/dashboard/builtInWidgets.d.ts +19 -0
- package/dist-ui-lib/dashboard/index.d.ts +13 -0
- package/dist-ui-lib/dashboard/widgets/ServiceHealthWidget.d.ts +12 -0
- package/dist-ui-lib/dashboard/widgets/index.d.ts +6 -0
- package/dist-ui-lib/index.js +6441 -0
- package/dist-ui-lib/index.js.map +1 -0
- package/dist-ui-lib/pages/ConfigPage.d.ts +1 -0
- package/dist-ui-lib/pages/DashboardPage.d.ts +1 -0
- package/dist-ui-lib/pages/DiagnosticsPage.d.ts +1 -0
- package/dist-ui-lib/pages/EntitlementsPage.d.ts +17 -0
- package/dist-ui-lib/pages/LogsPage.d.ts +1 -0
- package/dist-ui-lib/pages/NotFoundPage.d.ts +1 -0
- package/dist-ui-lib/pages/PluginPage.d.ts +15 -0
- package/dist-ui-lib/pages/SystemPage.d.ts +1 -0
- package/dist-ui-lib/pages/UsersPage.d.ts +22 -0
- package/package.json +18 -6
- package/src/core/control-panel.ts +122 -68
- package/src/core/gateway.ts +870 -399
- package/src/core/index.ts +21 -2
- package/src/core/plugin-registry.ts +653 -0
- package/src/core/types.ts +31 -37
- package/src/index.ts +118 -19
- package/src/plugins/auth/adapters/auth0-adapter.ts +214 -0
- package/src/plugins/auth/adapters/basic-adapter.ts +61 -0
- package/src/plugins/auth/adapters/index.ts +9 -0
- package/src/plugins/auth/adapters/supabase-adapter.ts +141 -0
- package/src/plugins/auth/auth-plugin.test.ts +176 -0
- package/src/plugins/auth/auth-plugin.ts +303 -0
- package/src/plugins/auth/index.ts +33 -0
- package/src/plugins/auth/types.ts +165 -0
- package/src/plugins/bans/bans-plugin.ts +485 -0
- package/src/plugins/bans/index.ts +31 -0
- package/src/plugins/bans/stores/index.ts +7 -0
- package/src/plugins/bans/stores/postgres-store.ts +195 -0
- package/src/plugins/bans/types.ts +141 -0
- package/src/plugins/cache-plugin.test.ts +105 -32
- package/src/plugins/cache-plugin.ts +40 -9
- package/src/plugins/config-plugin.ts +23 -12
- package/src/plugins/diagnostics-plugin.ts +22 -12
- package/src/plugins/entitlements/entitlements-plugin.ts +820 -0
- package/src/plugins/entitlements/index.ts +51 -0
- package/src/plugins/entitlements/sources/index.ts +9 -0
- package/src/plugins/entitlements/sources/postgres-source.ts +253 -0
- package/src/plugins/entitlements/types.ts +256 -0
- package/src/plugins/frontend-app-plugin.ts +24 -12
- package/src/plugins/health-plugin.ts +27 -7
- package/src/plugins/index.ts +106 -4
- package/src/plugins/logs-plugin.ts +28 -14
- package/src/plugins/postgres-plugin.test.ts +49 -29
- package/src/plugins/postgres-plugin.ts +11 -9
- package/src/plugins/users/index.ts +35 -0
- package/src/plugins/users/stores/index.ts +7 -0
- package/src/plugins/users/stores/postgres-store.ts +225 -0
- package/src/plugins/users/types.ts +209 -0
- package/src/plugins/users/users-plugin.ts +281 -0
- package/ui/src/App.tsx +185 -31
- package/ui/src/api/controlPanelApi.ts +354 -1
- package/ui/src/components/ControlPanelApp.tsx +209 -0
- package/ui/src/components/index.ts +62 -0
- package/ui/src/dashboard/DashboardWidgetRegistry.tsx +129 -0
- package/ui/src/dashboard/DashboardWidgetRenderer.tsx +34 -0
- package/ui/src/dashboard/PluginWidgetRenderer.tsx +115 -0
- package/ui/src/dashboard/WidgetComponentRegistry.tsx +116 -0
- package/ui/src/dashboard/builtInWidgets.tsx +29 -0
- package/ui/src/dashboard/index.ts +35 -0
- package/ui/src/dashboard/widgets/ServiceHealthWidget.tsx +140 -0
- package/ui/src/dashboard/widgets/index.ts +7 -0
- package/ui/src/pages/DashboardPage.tsx +28 -149
- package/ui/src/pages/EntitlementsPage.tsx +557 -0
- package/ui/src/pages/LogsPage.tsx +174 -8
- package/ui/src/pages/PluginPage.tsx +148 -0
- package/ui/src/pages/SystemPage.tsx +445 -0
- package/ui/src/pages/UsersPage.tsx +837 -0
- package/ui/tsconfig.lib.json +11 -0
- package/ui/vite.lib.config.ts +51 -0
- package/dist-ui/assets/index-CW1BviRn.js +0 -465
- package/dist-ui/assets/index-CW1BviRn.js.map +0 -1
- package/ui/src/pages/HealthPage.tsx +0 -204
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* Copyright (c) 2025 QwickApps.com. All rights reserved.
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
|
-
import type {
|
|
51
|
+
import type { Plugin, PluginConfig, PluginRegistry } from '../core/plugin-registry.js';
|
|
52
52
|
|
|
53
53
|
// Dynamic import for ioredis (optional peer dependency)
|
|
54
54
|
type Redis = import('ioredis').default;
|
|
@@ -180,9 +180,19 @@ export interface CacheInstance {
|
|
|
180
180
|
* Get all keys matching a pattern
|
|
181
181
|
* @param pattern - Pattern to match (prefix is applied automatically)
|
|
182
182
|
* @returns Array of matching keys (without prefix)
|
|
183
|
+
* @deprecated Use scanKeys() for production - keys() blocks Redis on large datasets
|
|
183
184
|
*/
|
|
184
185
|
keys(pattern: string): Promise<string[]>;
|
|
185
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Scan keys matching a pattern using cursor-based iteration (non-blocking)
|
|
189
|
+
* @param pattern - Pattern to match (prefix is applied automatically)
|
|
190
|
+
* @param options - Optional scan configuration
|
|
191
|
+
* @param options.count - Hint for how many keys to return per iteration (default: 100)
|
|
192
|
+
* @returns Array of matching keys (without prefix)
|
|
193
|
+
*/
|
|
194
|
+
scanKeys(pattern: string, options?: { count?: number }): Promise<string[]>;
|
|
195
|
+
|
|
186
196
|
/**
|
|
187
197
|
* Flush all keys with the configured prefix
|
|
188
198
|
* @returns Number of keys deleted
|
|
@@ -248,7 +258,7 @@ export function hasCache(name = 'default'): boolean {
|
|
|
248
258
|
*
|
|
249
259
|
* @param config - Cache configuration
|
|
250
260
|
* @param instanceName - Name for this cache instance (default: 'default')
|
|
251
|
-
* @returns A
|
|
261
|
+
* @returns A plugin
|
|
252
262
|
*
|
|
253
263
|
* @example
|
|
254
264
|
* ```typescript
|
|
@@ -263,10 +273,11 @@ export function hasCache(name = 'default'): boolean {
|
|
|
263
273
|
export function createCachePlugin(
|
|
264
274
|
config: CachePluginConfig,
|
|
265
275
|
instanceName = 'default'
|
|
266
|
-
):
|
|
276
|
+
): Plugin {
|
|
267
277
|
let client: Redis | null = null;
|
|
268
278
|
const prefix = config.keyPrefix ?? '';
|
|
269
279
|
const defaultTtl = config.defaultTtl ?? 3600;
|
|
280
|
+
const pluginId = `cache:${instanceName}`;
|
|
270
281
|
|
|
271
282
|
const prefixKey = (key: string): string => `${prefix}${key}`;
|
|
272
283
|
const unprefixKey = (key: string): string =>
|
|
@@ -382,6 +393,25 @@ export function createCachePlugin(
|
|
|
382
393
|
return keys.map(unprefixKey);
|
|
383
394
|
},
|
|
384
395
|
|
|
396
|
+
async scanKeys(pattern: string, options?: { count?: number }): Promise<string[]> {
|
|
397
|
+
if (!client) throw new Error('Cache client not initialized');
|
|
398
|
+
const results: string[] = [];
|
|
399
|
+
const stream = client.scanStream({
|
|
400
|
+
match: prefixKey(pattern),
|
|
401
|
+
count: options?.count ?? 100,
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
return new Promise((resolve, reject) => {
|
|
405
|
+
stream.on('data', (keys: string[]) => {
|
|
406
|
+
for (const key of keys) {
|
|
407
|
+
results.push(unprefixKey(key));
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
stream.on('end', () => resolve(results));
|
|
411
|
+
stream.on('error', (err) => reject(err));
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
|
|
385
415
|
async flush(): Promise<number> {
|
|
386
416
|
if (!client) throw new Error('Cache client not initialized');
|
|
387
417
|
if (!prefix) {
|
|
@@ -437,11 +467,12 @@ export function createCachePlugin(
|
|
|
437
467
|
};
|
|
438
468
|
|
|
439
469
|
return {
|
|
440
|
-
|
|
441
|
-
|
|
470
|
+
id: pluginId,
|
|
471
|
+
name: `Redis Cache (${instanceName})`,
|
|
472
|
+
version: '1.0.0',
|
|
442
473
|
|
|
443
|
-
async
|
|
444
|
-
const
|
|
474
|
+
async onStart(_pluginConfig: PluginConfig, registry: PluginRegistry): Promise<void> {
|
|
475
|
+
const logger = registry.getLogger(pluginId);
|
|
445
476
|
|
|
446
477
|
// Create and register the instance
|
|
447
478
|
const instance = await createInstance();
|
|
@@ -459,7 +490,7 @@ export function createCachePlugin(
|
|
|
459
490
|
|
|
460
491
|
// Register health check if enabled
|
|
461
492
|
if (config.healthCheck !== false) {
|
|
462
|
-
registerHealthCheck({
|
|
493
|
+
registry.registerHealthCheck({
|
|
463
494
|
name: config.healthCheckName ?? 'redis',
|
|
464
495
|
type: 'custom',
|
|
465
496
|
interval: config.healthCheckInterval ?? 30000,
|
|
@@ -492,7 +523,7 @@ export function createCachePlugin(
|
|
|
492
523
|
}
|
|
493
524
|
},
|
|
494
525
|
|
|
495
|
-
async
|
|
526
|
+
async onStop(): Promise<void> {
|
|
496
527
|
const instance = instances.get(instanceName);
|
|
497
528
|
if (instance) {
|
|
498
529
|
await instance.close();
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Request, Response } from 'express';
|
|
10
|
-
import type {
|
|
10
|
+
import type { Plugin, PluginConfig, PluginRegistry } from '../core/plugin-registry.js';
|
|
11
|
+
import type { ConfigDisplayOptions } from '../core/types.js';
|
|
11
12
|
|
|
12
13
|
export interface ConfigPluginConfig extends ConfigDisplayOptions {}
|
|
13
14
|
|
|
@@ -20,15 +21,20 @@ interface ConfigValidationResult {
|
|
|
20
21
|
/**
|
|
21
22
|
* Create a config display plugin
|
|
22
23
|
*/
|
|
23
|
-
export function createConfigPlugin(config: ConfigPluginConfig):
|
|
24
|
+
export function createConfigPlugin(config: ConfigPluginConfig): Plugin {
|
|
24
25
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
id: 'config',
|
|
27
|
+
name: 'Config Plugin',
|
|
28
|
+
version: '1.0.0',
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
async onStart(_pluginConfig: PluginConfig, registry: PluginRegistry): Promise<void> {
|
|
31
|
+
const logger = registry.getLogger('config');
|
|
32
|
+
|
|
33
|
+
// Register /config route
|
|
34
|
+
registry.addRoute({
|
|
30
35
|
method: 'get',
|
|
31
36
|
path: '/config',
|
|
37
|
+
pluginId: 'config',
|
|
32
38
|
handler: (_req: Request, res: Response) => {
|
|
33
39
|
const envVars: Record<string, string> = {};
|
|
34
40
|
|
|
@@ -52,10 +58,13 @@ export function createConfigPlugin(config: ConfigPluginConfig): ControlPanelPlug
|
|
|
52
58
|
config: envVars,
|
|
53
59
|
});
|
|
54
60
|
},
|
|
55
|
-
}
|
|
56
|
-
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Register /config/validate route
|
|
64
|
+
registry.addRoute({
|
|
57
65
|
method: 'get',
|
|
58
66
|
path: '/config/validate',
|
|
67
|
+
pluginId: 'config',
|
|
59
68
|
handler: (_req: Request, res: Response) => {
|
|
60
69
|
const results: ConfigValidationResult[] = [];
|
|
61
70
|
let allValid = true;
|
|
@@ -97,11 +106,13 @@ export function createConfigPlugin(config: ConfigPluginConfig): ControlPanelPlug
|
|
|
97
106
|
results,
|
|
98
107
|
});
|
|
99
108
|
},
|
|
100
|
-
}
|
|
101
|
-
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
logger.debug(`Config plugin initialized with ${config.show.length} vars`);
|
|
112
|
+
},
|
|
102
113
|
|
|
103
|
-
async
|
|
104
|
-
|
|
114
|
+
async onStop(): Promise<void> {
|
|
115
|
+
// Nothing to cleanup
|
|
105
116
|
},
|
|
106
117
|
};
|
|
107
118
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { existsSync, readFileSync } from 'fs';
|
|
10
10
|
import { resolve } from 'path';
|
|
11
11
|
import type { Request, Response } from 'express';
|
|
12
|
-
import type {
|
|
12
|
+
import type { Plugin, PluginConfig, PluginRegistry } from '../core/plugin-registry.js';
|
|
13
13
|
|
|
14
14
|
export interface DiagnosticsPluginConfig {
|
|
15
15
|
include?: {
|
|
@@ -31,7 +31,7 @@ export interface DiagnosticsPluginConfig {
|
|
|
31
31
|
/**
|
|
32
32
|
* Create a diagnostics plugin for AI agents
|
|
33
33
|
*/
|
|
34
|
-
export function createDiagnosticsPlugin(config: DiagnosticsPluginConfig = {}):
|
|
34
|
+
export function createDiagnosticsPlugin(config: DiagnosticsPluginConfig = {}): Plugin {
|
|
35
35
|
const {
|
|
36
36
|
include = { logs: { startup: 100, app: 200 }, health: true, config: true, system: true },
|
|
37
37
|
logPaths = { startup: './logs/startup.log', app: './logs/app.log' },
|
|
@@ -39,13 +39,18 @@ export function createDiagnosticsPlugin(config: DiagnosticsPluginConfig = {}): C
|
|
|
39
39
|
} = config;
|
|
40
40
|
|
|
41
41
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
id: 'diagnostics',
|
|
43
|
+
name: 'Diagnostics Plugin',
|
|
44
|
+
version: '1.0.0',
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
async onStart(_pluginConfig: PluginConfig, registry: PluginRegistry): Promise<void> {
|
|
47
|
+
const logger = registry.getLogger('diagnostics');
|
|
48
|
+
|
|
49
|
+
// Register full diagnostics endpoint
|
|
50
|
+
registry.addRoute({
|
|
47
51
|
method: 'get',
|
|
48
52
|
path: endpoint,
|
|
53
|
+
pluginId: 'diagnostics',
|
|
49
54
|
handler: (_req: Request, res: Response) => {
|
|
50
55
|
try {
|
|
51
56
|
const report: Record<string, unknown> = {
|
|
@@ -113,10 +118,13 @@ export function createDiagnosticsPlugin(config: DiagnosticsPluginConfig = {}): C
|
|
|
113
118
|
});
|
|
114
119
|
}
|
|
115
120
|
},
|
|
116
|
-
}
|
|
117
|
-
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Register summary diagnostics endpoint
|
|
124
|
+
registry.addRoute({
|
|
118
125
|
method: 'get',
|
|
119
126
|
path: '/diagnostics/summary',
|
|
127
|
+
pluginId: 'diagnostics',
|
|
120
128
|
handler: (_req: Request, res: Response) => {
|
|
121
129
|
try {
|
|
122
130
|
const memUsage = process.memoryUsage();
|
|
@@ -138,11 +146,13 @@ export function createDiagnosticsPlugin(config: DiagnosticsPluginConfig = {}): C
|
|
|
138
146
|
});
|
|
139
147
|
}
|
|
140
148
|
},
|
|
141
|
-
}
|
|
142
|
-
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
logger.debug('Diagnostics plugin initialized');
|
|
152
|
+
},
|
|
143
153
|
|
|
144
|
-
async
|
|
145
|
-
|
|
154
|
+
async onStop(): Promise<void> {
|
|
155
|
+
// Nothing to cleanup
|
|
146
156
|
},
|
|
147
157
|
};
|
|
148
158
|
}
|