@qwickapps/server 1.2.0 → 1.3.1
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 +392 -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 +120 -54
- 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 +679 -319
- 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 +307 -0
- package/dist/core/plugin-registry.d.ts.map +1 -0
- package/dist/core/plugin-registry.js +352 -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 +10 -0
- package/dist/plugins/auth/adapters/index.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/index.js +10 -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/adapters/supertokens-adapter.d.ts +18 -0
- package/dist/plugins/auth/adapters/supertokens-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/supertokens-adapter.js +267 -0
- package/dist/plugins/auth/adapters/supertokens-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/env-config.d.ts +88 -0
- package/dist/plugins/auth/env-config.d.ts.map +1 -0
- package/dist/plugins/auth/env-config.js +489 -0
- package/dist/plugins/auth/env-config.js.map +1 -0
- package/dist/plugins/auth/index.d.ts +14 -0
- package/dist/plugins/auth/index.d.ts.map +1 -0
- package/dist/plugins/auth/index.js +16 -0
- package/dist/plugins/auth/index.js.map +1 -0
- package/dist/plugins/auth/supertokens-adapter.test.d.ts +10 -0
- package/dist/plugins/auth/supertokens-adapter.test.d.ts.map +1 -0
- package/dist/plugins/auth/supertokens-adapter.test.js +486 -0
- package/dist/plugins/auth/supertokens-adapter.test.js.map +1 -0
- package/dist/plugins/auth/types.d.ts +218 -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 +99 -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 +10 -2
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +10 -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 +50 -29
- package/dist/plugins/postgres-plugin.test.js.map +1 -1
- package/dist/plugins/preferences/__tests__/deep-merge.test.d.ts +7 -0
- package/dist/plugins/preferences/__tests__/deep-merge.test.d.ts.map +1 -0
- package/dist/plugins/preferences/__tests__/deep-merge.test.js +215 -0
- package/dist/plugins/preferences/__tests__/deep-merge.test.js.map +1 -0
- package/dist/plugins/preferences/__tests__/preferences-plugin.test.d.ts +7 -0
- package/dist/plugins/preferences/__tests__/preferences-plugin.test.d.ts.map +1 -0
- package/dist/plugins/preferences/__tests__/preferences-plugin.test.js +265 -0
- package/dist/plugins/preferences/__tests__/preferences-plugin.test.js.map +1 -0
- package/dist/plugins/preferences/index.d.ts +12 -0
- package/dist/plugins/preferences/index.d.ts.map +1 -0
- package/dist/plugins/preferences/index.js +13 -0
- package/dist/plugins/preferences/index.js.map +1 -0
- package/dist/plugins/preferences/preferences-plugin.d.ts +39 -0
- package/dist/plugins/preferences/preferences-plugin.d.ts.map +1 -0
- package/dist/plugins/preferences/preferences-plugin.js +226 -0
- package/dist/plugins/preferences/preferences-plugin.js.map +1 -0
- package/dist/plugins/preferences/stores/index.d.ts +9 -0
- package/dist/plugins/preferences/stores/index.d.ts.map +1 -0
- package/dist/plugins/preferences/stores/index.js +9 -0
- package/dist/plugins/preferences/stores/index.js.map +1 -0
- package/dist/plugins/preferences/stores/postgres-store.d.ts +41 -0
- package/dist/plugins/preferences/stores/postgres-store.d.ts.map +1 -0
- package/dist/plugins/preferences/stores/postgres-store.js +181 -0
- package/dist/plugins/preferences/stores/postgres-store.js.map +1 -0
- package/dist/plugins/preferences/types.d.ts +91 -0
- package/dist/plugins/preferences/types.d.ts.map +1 -0
- package/dist/plugins/preferences/types.js +10 -0
- package/dist/plugins/preferences/types.js.map +1 -0
- package/dist/plugins/users/__tests__/users-plugin.test.d.ts +9 -0
- package/dist/plugins/users/__tests__/users-plugin.test.d.ts.map +1 -0
- package/dist/plugins/users/__tests__/users-plugin.test.js +546 -0
- package/dist/plugins/users/__tests__/users-plugin.test.js.map +1 -0
- 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 +225 -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 +45 -0
- package/dist/plugins/users/users-plugin.d.ts.map +1 -0
- package/dist/plugins/users/users-plugin.js +359 -0
- package/dist/plugins/users/users-plugin.js.map +1 -0
- package/dist-ui/assets/index-BY8OxNgO.js +465 -0
- package/dist-ui/assets/index-BY8OxNgO.js.map +1 -0
- package/dist-ui/index.html +1 -1
- package/dist-ui-lib/api/controlPanelApi.d.ts +278 -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 +48 -0
- package/dist-ui-lib/dashboard/builtInWidgets.d.ts +25 -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 +5172 -0
- package/dist-ui-lib/index.js.map +1 -0
- package/dist-ui-lib/pages/AuthPage.d.ts +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/PluginsPage.d.ts +1 -0
- package/dist-ui-lib/pages/SystemPage.d.ts +1 -0
- package/dist-ui-lib/pages/UsersPage.d.ts +22 -0
- package/package.json +24 -7
- package/src/core/control-panel.ts +145 -61
- package/src/core/gateway.ts +863 -403
- package/src/core/index.ts +21 -2
- package/src/core/plugin-registry.ts +716 -0
- package/src/core/types.ts +31 -37
- package/src/index.ts +125 -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 +10 -0
- package/src/plugins/auth/adapters/supabase-adapter.ts +149 -0
- package/src/plugins/auth/adapters/supertokens-adapter.ts +326 -0
- package/src/plugins/auth/auth-plugin.test.ts +176 -0
- package/src/plugins/auth/auth-plugin.ts +303 -0
- package/src/plugins/auth/env-config.ts +572 -0
- package/src/plugins/auth/index.ts +42 -0
- package/src/plugins/auth/supertokens-adapter.test.ts +621 -0
- package/src/plugins/auth/types.ts +245 -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 +108 -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 +132 -4
- package/src/plugins/logs-plugin.ts +28 -14
- package/src/plugins/postgres-plugin.test.ts +52 -29
- package/src/plugins/postgres-plugin.ts +11 -9
- package/src/plugins/preferences/__tests__/deep-merge.test.ts +242 -0
- package/src/plugins/preferences/__tests__/preferences-plugin.test.ts +350 -0
- package/src/plugins/preferences/index.ts +30 -0
- package/src/plugins/preferences/preferences-plugin.ts +270 -0
- package/src/plugins/preferences/stores/index.ts +9 -0
- package/src/plugins/preferences/stores/postgres-store.ts +252 -0
- package/src/plugins/preferences/types.ts +100 -0
- package/src/plugins/users/__tests__/users-plugin.test.ts +690 -0
- package/src/plugins/users/index.ts +38 -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 +247 -0
- package/src/plugins/users/users-plugin.ts +418 -0
- package/ui/src/App.tsx +188 -31
- package/ui/src/api/controlPanelApi.ts +453 -1
- package/ui/src/components/ControlPanelApp.tsx +212 -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 +118 -0
- package/ui/src/dashboard/WidgetComponentRegistry.tsx +120 -0
- package/ui/src/dashboard/builtInWidgets.tsx +35 -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/AuthPage.tsx +259 -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/PluginsPage.tsx +394 -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 +56 -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
|
@@ -6,30 +6,50 @@
|
|
|
6
6
|
* Copyright (c) 2025 QwickApps.com. All rights reserved.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { Plugin, PluginConfig, PluginRegistry } from '../core/plugin-registry.js';
|
|
10
|
+
import type { HealthCheck } from '../core/types.js';
|
|
10
11
|
|
|
11
12
|
export interface HealthPluginConfig {
|
|
12
13
|
checks: HealthCheck[];
|
|
13
14
|
aggregateEndpoint?: string;
|
|
15
|
+
/** Whether to show the ServiceHealthWidget on the dashboard (default: true) */
|
|
16
|
+
showWidget?: boolean;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* Create a health check plugin
|
|
18
21
|
*/
|
|
19
|
-
export function createHealthPlugin(config: HealthPluginConfig):
|
|
22
|
+
export function createHealthPlugin(config: HealthPluginConfig): Plugin {
|
|
20
23
|
return {
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
id: 'health',
|
|
25
|
+
name: 'Health Plugin',
|
|
26
|
+
version: '1.0.0',
|
|
23
27
|
|
|
24
|
-
async
|
|
25
|
-
const
|
|
28
|
+
async onStart(_pluginConfig: PluginConfig, registry: PluginRegistry): Promise<void> {
|
|
29
|
+
const logger = registry.getLogger('health');
|
|
26
30
|
|
|
27
31
|
// Register all health checks
|
|
28
32
|
for (const check of config.checks) {
|
|
29
|
-
registerHealthCheck(check);
|
|
33
|
+
registry.registerHealthCheck(check);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Register the ServiceHealthWidget (shown by default unless disabled)
|
|
37
|
+
if (config.showWidget !== false) {
|
|
38
|
+
registry.addWidget({
|
|
39
|
+
id: 'service-health',
|
|
40
|
+
title: 'Service Health',
|
|
41
|
+
component: 'ServiceHealthWidget',
|
|
42
|
+
priority: 10,
|
|
43
|
+
showByDefault: true,
|
|
44
|
+
pluginId: 'health',
|
|
45
|
+
});
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
logger.debug(`Registered ${config.checks.length} health checks`);
|
|
33
49
|
},
|
|
50
|
+
|
|
51
|
+
async onStop(): Promise<void> {
|
|
52
|
+
// Nothing to cleanup
|
|
53
|
+
},
|
|
34
54
|
};
|
|
35
55
|
}
|
package/src/plugins/index.ts
CHANGED
|
@@ -22,9 +22,137 @@ export type { FrontendAppPluginConfig } from './frontend-app-plugin.js';
|
|
|
22
22
|
export { createPostgresPlugin, getPostgres, hasPostgres } from './postgres-plugin.js';
|
|
23
23
|
export type { PostgresPluginConfig, PostgresInstance, TransactionCallback } from './postgres-plugin.js';
|
|
24
24
|
|
|
25
|
-
// Backward compatibility aliases (deprecated)
|
|
26
|
-
export { createPostgresPlugin as createDatabasePlugin, getPostgres as getDatabase, hasPostgres as hasDatabase } from './postgres-plugin.js';
|
|
27
|
-
export type { PostgresPluginConfig as DatabasePluginConfig, PostgresInstance as DatabaseInstance } from './postgres-plugin.js';
|
|
28
|
-
|
|
29
25
|
export { createCachePlugin, getCache, hasCache } from './cache-plugin.js';
|
|
30
26
|
export type { CachePluginConfig, CacheInstance } from './cache-plugin.js';
|
|
27
|
+
|
|
28
|
+
// Auth plugin
|
|
29
|
+
export {
|
|
30
|
+
createAuthPlugin,
|
|
31
|
+
createAuthPluginFromEnv,
|
|
32
|
+
getAuthStatus,
|
|
33
|
+
isAuthenticated,
|
|
34
|
+
getAuthenticatedUser,
|
|
35
|
+
getAccessToken,
|
|
36
|
+
requireAuth,
|
|
37
|
+
requireRoles,
|
|
38
|
+
requireAnyRole,
|
|
39
|
+
auth0Adapter,
|
|
40
|
+
basicAdapter,
|
|
41
|
+
supabaseAdapter,
|
|
42
|
+
supertokensAdapter,
|
|
43
|
+
isAuthenticatedRequest,
|
|
44
|
+
} from './auth/index.js';
|
|
45
|
+
export type {
|
|
46
|
+
AuthPluginConfig,
|
|
47
|
+
AuthAdapter,
|
|
48
|
+
AuthenticatedUser,
|
|
49
|
+
AuthenticatedRequest,
|
|
50
|
+
Auth0AdapterConfig,
|
|
51
|
+
SupabaseAdapterConfig,
|
|
52
|
+
BasicAdapterConfig,
|
|
53
|
+
SupertokensAdapterConfig,
|
|
54
|
+
AuthPluginState,
|
|
55
|
+
AuthEnvPluginOptions,
|
|
56
|
+
AuthConfigStatus,
|
|
57
|
+
} from './auth/index.js';
|
|
58
|
+
|
|
59
|
+
// Users plugin
|
|
60
|
+
export {
|
|
61
|
+
createUsersPlugin,
|
|
62
|
+
getUserStore,
|
|
63
|
+
getUserById,
|
|
64
|
+
getUserByEmail,
|
|
65
|
+
findOrCreateUser,
|
|
66
|
+
postgresUserStore,
|
|
67
|
+
} from './users/index.js';
|
|
68
|
+
export type {
|
|
69
|
+
UsersPluginConfig,
|
|
70
|
+
UserStore,
|
|
71
|
+
User,
|
|
72
|
+
CreateUserInput,
|
|
73
|
+
UpdateUserInput,
|
|
74
|
+
UserSearchParams,
|
|
75
|
+
UserListResponse,
|
|
76
|
+
PostgresUserStoreConfig,
|
|
77
|
+
UserSyncConfig,
|
|
78
|
+
UsersApiConfig,
|
|
79
|
+
UsersUiConfig,
|
|
80
|
+
} from './users/index.js';
|
|
81
|
+
|
|
82
|
+
// Bans plugin (separate from Users, depends on Users)
|
|
83
|
+
export {
|
|
84
|
+
createBansPlugin,
|
|
85
|
+
getBanStore,
|
|
86
|
+
isUserBanned,
|
|
87
|
+
isEmailBanned,
|
|
88
|
+
getActiveBan,
|
|
89
|
+
banUser,
|
|
90
|
+
unbanUser,
|
|
91
|
+
listActiveBans,
|
|
92
|
+
postgresBanStore,
|
|
93
|
+
} from './bans/index.js';
|
|
94
|
+
export type {
|
|
95
|
+
BansPluginConfig,
|
|
96
|
+
BanStore,
|
|
97
|
+
Ban,
|
|
98
|
+
CreateBanInput,
|
|
99
|
+
RemoveBanInput,
|
|
100
|
+
BanCallbacks,
|
|
101
|
+
PostgresBanStoreConfig,
|
|
102
|
+
} from './bans/index.js';
|
|
103
|
+
|
|
104
|
+
// Entitlements plugin
|
|
105
|
+
export {
|
|
106
|
+
createEntitlementsPlugin,
|
|
107
|
+
getEntitlementSource,
|
|
108
|
+
isSourceReadonly,
|
|
109
|
+
getEntitlements,
|
|
110
|
+
refreshEntitlements,
|
|
111
|
+
hasEntitlement,
|
|
112
|
+
hasAnyEntitlement,
|
|
113
|
+
hasAllEntitlements,
|
|
114
|
+
grantEntitlement,
|
|
115
|
+
revokeEntitlement,
|
|
116
|
+
setEntitlements,
|
|
117
|
+
getAvailableEntitlements,
|
|
118
|
+
getEntitlementStats,
|
|
119
|
+
invalidateEntitlementCache,
|
|
120
|
+
storeExternalIdMapping,
|
|
121
|
+
invalidateByExternalId,
|
|
122
|
+
requireEntitlement,
|
|
123
|
+
requireAnyEntitlement,
|
|
124
|
+
requireAllEntitlements,
|
|
125
|
+
postgresEntitlementSource,
|
|
126
|
+
} from './entitlements/index.js';
|
|
127
|
+
export type {
|
|
128
|
+
EntitlementsPluginConfig,
|
|
129
|
+
EntitlementSource,
|
|
130
|
+
EntitlementResult,
|
|
131
|
+
EntitlementDefinition,
|
|
132
|
+
EntitlementCallbacks,
|
|
133
|
+
EntitlementsCacheConfig,
|
|
134
|
+
EntitlementsApiConfig,
|
|
135
|
+
PostgresEntitlementSourceConfig,
|
|
136
|
+
UserEntitlement,
|
|
137
|
+
CachedEntitlements,
|
|
138
|
+
EntitlementStats,
|
|
139
|
+
} from './entitlements/index.js';
|
|
140
|
+
|
|
141
|
+
// Preferences plugin (depends on Users)
|
|
142
|
+
export {
|
|
143
|
+
createPreferencesPlugin,
|
|
144
|
+
getPreferencesStore,
|
|
145
|
+
getPreferences,
|
|
146
|
+
updatePreferences,
|
|
147
|
+
deletePreferences,
|
|
148
|
+
getDefaultPreferences,
|
|
149
|
+
postgresPreferencesStore,
|
|
150
|
+
deepMerge,
|
|
151
|
+
} from './preferences/index.js';
|
|
152
|
+
export type {
|
|
153
|
+
PreferencesPluginConfig,
|
|
154
|
+
PreferencesStore,
|
|
155
|
+
UserPreferences,
|
|
156
|
+
PostgresPreferencesStoreConfig,
|
|
157
|
+
PreferencesApiConfig,
|
|
158
|
+
} from './preferences/index.js';
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
import { existsSync, readFileSync, statSync } from 'fs';
|
|
11
11
|
import { resolve } from 'path';
|
|
12
12
|
import type { Request, Response } from 'express';
|
|
13
|
-
import type {
|
|
13
|
+
import type { Plugin, PluginConfig, PluginRegistry } from '../core/plugin-registry.js';
|
|
14
|
+
import type { LogSource } from '../core/types.js';
|
|
14
15
|
import { getLoggingSubsystem } from '../core/logging.js';
|
|
15
16
|
|
|
16
17
|
export interface LogsPluginConfig {
|
|
@@ -61,7 +62,7 @@ function getDefaultSources(): LogSource[] {
|
|
|
61
62
|
/**
|
|
62
63
|
* Create a logs plugin
|
|
63
64
|
*/
|
|
64
|
-
export function createLogsPlugin(config: LogsPluginConfig = {}):
|
|
65
|
+
export function createLogsPlugin(config: LogsPluginConfig = {}): Plugin {
|
|
65
66
|
const maxLines = config.retention?.maxLines || 10000;
|
|
66
67
|
|
|
67
68
|
// Use provided sources or default to logging subsystem paths
|
|
@@ -73,13 +74,18 @@ export function createLogsPlugin(config: LogsPluginConfig = {}): ControlPanelPlu
|
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
id: 'logs',
|
|
78
|
+
name: 'Logs Plugin',
|
|
79
|
+
version: '1.0.0',
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
async onStart(_pluginConfig: PluginConfig, registry: PluginRegistry): Promise<void> {
|
|
82
|
+
const logger = registry.getLogger('logs');
|
|
83
|
+
|
|
84
|
+
// Register /logs/sources route
|
|
85
|
+
registry.addRoute({
|
|
81
86
|
method: 'get',
|
|
82
87
|
path: '/logs/sources',
|
|
88
|
+
pluginId: 'logs',
|
|
83
89
|
handler: (_req: Request, res: Response) => {
|
|
84
90
|
const sources = getSources();
|
|
85
91
|
res.json({
|
|
@@ -89,10 +95,13 @@ export function createLogsPlugin(config: LogsPluginConfig = {}): ControlPanelPlu
|
|
|
89
95
|
})),
|
|
90
96
|
});
|
|
91
97
|
},
|
|
92
|
-
}
|
|
93
|
-
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Register /logs route
|
|
101
|
+
registry.addRoute({
|
|
94
102
|
method: 'get',
|
|
95
103
|
path: '/logs',
|
|
104
|
+
pluginId: 'logs',
|
|
96
105
|
handler: (req: Request, res: Response) => {
|
|
97
106
|
try {
|
|
98
107
|
const sources = getSources();
|
|
@@ -124,10 +133,13 @@ export function createLogsPlugin(config: LogsPluginConfig = {}): ControlPanelPlu
|
|
|
124
133
|
});
|
|
125
134
|
}
|
|
126
135
|
},
|
|
127
|
-
}
|
|
128
|
-
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Register /logs/stats route
|
|
139
|
+
registry.addRoute({
|
|
129
140
|
method: 'get',
|
|
130
141
|
path: '/logs/stats',
|
|
142
|
+
pluginId: 'logs',
|
|
131
143
|
handler: (req: Request, res: Response) => {
|
|
132
144
|
try {
|
|
133
145
|
const sources = getSources();
|
|
@@ -151,12 +163,14 @@ export function createLogsPlugin(config: LogsPluginConfig = {}): ControlPanelPlu
|
|
|
151
163
|
});
|
|
152
164
|
}
|
|
153
165
|
},
|
|
154
|
-
}
|
|
155
|
-
],
|
|
166
|
+
});
|
|
156
167
|
|
|
157
|
-
async onInit(context: PluginContext): Promise<void> {
|
|
158
168
|
const sources = getSources();
|
|
159
|
-
|
|
169
|
+
logger.debug(`Logs plugin initialized with ${sources.length} sources`);
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
async onStop(): Promise<void> {
|
|
173
|
+
// Nothing to cleanup
|
|
160
174
|
},
|
|
161
175
|
};
|
|
162
176
|
}
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
hasPostgres,
|
|
39
39
|
type PostgresPluginConfig,
|
|
40
40
|
} from './postgres-plugin.js';
|
|
41
|
+
import type { PluginRegistry } from '../core/plugin-registry.js';
|
|
41
42
|
|
|
42
43
|
describe('PostgreSQL Plugin', () => {
|
|
43
44
|
const mockConfig: PostgresPluginConfig = {
|
|
@@ -46,21 +47,42 @@ describe('PostgreSQL Plugin', () => {
|
|
|
46
47
|
healthCheck: false, // Disable for unit tests
|
|
47
48
|
};
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
// Create a mock registry that matches the new Plugin interface
|
|
51
|
+
const createMockRegistry = (): PluginRegistry => ({
|
|
52
|
+
hasPlugin: vi.fn().mockReturnValue(false),
|
|
53
|
+
getPlugin: vi.fn().mockReturnValue(null),
|
|
54
|
+
listPlugins: vi.fn().mockReturnValue([]),
|
|
55
|
+
addRoute: vi.fn(),
|
|
56
|
+
addMenuItem: vi.fn(),
|
|
57
|
+
addPage: vi.fn(),
|
|
58
|
+
addWidget: vi.fn(),
|
|
59
|
+
addConfigComponent: vi.fn(),
|
|
60
|
+
getRoutes: vi.fn().mockReturnValue([]),
|
|
61
|
+
getMenuItems: vi.fn().mockReturnValue([]),
|
|
62
|
+
getPages: vi.fn().mockReturnValue([]),
|
|
63
|
+
getWidgets: vi.fn().mockReturnValue([]),
|
|
64
|
+
getConfigComponents: vi.fn().mockReturnValue([]),
|
|
65
|
+
getPluginContributions: vi.fn().mockReturnValue({ routes: [], menuItems: [], pages: [], widgets: [], config: undefined }),
|
|
66
|
+
getConfig: vi.fn().mockReturnValue({}),
|
|
67
|
+
setConfig: vi.fn().mockResolvedValue(undefined),
|
|
68
|
+
subscribe: vi.fn().mockReturnValue(() => {}),
|
|
69
|
+
emit: vi.fn(),
|
|
70
|
+
registerHealthCheck: vi.fn(),
|
|
71
|
+
getApp: vi.fn().mockReturnValue({} as any),
|
|
72
|
+
getRouter: vi.fn().mockReturnValue({} as any),
|
|
73
|
+
getLogger: vi.fn().mockReturnValue({
|
|
54
74
|
debug: vi.fn(),
|
|
55
75
|
info: vi.fn(),
|
|
56
76
|
warn: vi.fn(),
|
|
57
77
|
error: vi.fn(),
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
let mockRegistry: PluginRegistry;
|
|
61
82
|
|
|
62
83
|
beforeEach(() => {
|
|
63
84
|
vi.clearAllMocks();
|
|
85
|
+
mockRegistry = createMockRegistry();
|
|
64
86
|
});
|
|
65
87
|
|
|
66
88
|
afterEach(async () => {
|
|
@@ -74,33 +96,34 @@ describe('PostgreSQL Plugin', () => {
|
|
|
74
96
|
describe('createPostgresPlugin', () => {
|
|
75
97
|
it('should create a plugin with correct name', () => {
|
|
76
98
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
77
|
-
expect(plugin.name).toBe('
|
|
99
|
+
expect(plugin.name).toBe('PostgreSQL (test)');
|
|
78
100
|
});
|
|
79
101
|
|
|
80
102
|
it('should use "default" as instance name when not specified', () => {
|
|
81
103
|
const plugin = createPostgresPlugin(mockConfig);
|
|
82
|
-
expect(plugin.name).toBe('
|
|
104
|
+
expect(plugin.name).toBe('PostgreSQL (default)');
|
|
83
105
|
});
|
|
84
106
|
|
|
85
|
-
it('should have
|
|
86
|
-
const plugin = createPostgresPlugin(mockConfig);
|
|
87
|
-
expect(plugin.
|
|
107
|
+
it('should have correct plugin id', () => {
|
|
108
|
+
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
109
|
+
expect(plugin.id).toBe('postgres:test');
|
|
88
110
|
});
|
|
89
111
|
});
|
|
90
112
|
|
|
91
|
-
describe('
|
|
113
|
+
describe('onStart', () => {
|
|
92
114
|
it('should register the postgres instance', async () => {
|
|
93
115
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
94
|
-
await plugin.
|
|
116
|
+
await plugin.onStart({}, mockRegistry);
|
|
95
117
|
|
|
96
118
|
expect(hasPostgres('test')).toBe(true);
|
|
97
119
|
});
|
|
98
120
|
|
|
99
121
|
it('should log debug message on successful connection', async () => {
|
|
100
122
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
101
|
-
await plugin.
|
|
123
|
+
await plugin.onStart({}, mockRegistry);
|
|
102
124
|
|
|
103
|
-
|
|
125
|
+
const logger = mockRegistry.getLogger('postgres:test');
|
|
126
|
+
expect(logger.debug).toHaveBeenCalledWith(
|
|
104
127
|
expect.stringContaining('connected')
|
|
105
128
|
);
|
|
106
129
|
});
|
|
@@ -108,9 +131,9 @@ describe('PostgreSQL Plugin', () => {
|
|
|
108
131
|
it('should register health check when enabled', async () => {
|
|
109
132
|
const configWithHealth = { ...mockConfig, healthCheck: true };
|
|
110
133
|
const plugin = createPostgresPlugin(configWithHealth, 'test');
|
|
111
|
-
await plugin.
|
|
134
|
+
await plugin.onStart({}, mockRegistry);
|
|
112
135
|
|
|
113
|
-
expect(
|
|
136
|
+
expect(mockRegistry.registerHealthCheck).toHaveBeenCalledWith(
|
|
114
137
|
expect.objectContaining({
|
|
115
138
|
name: 'postgres',
|
|
116
139
|
type: 'custom',
|
|
@@ -125,9 +148,9 @@ describe('PostgreSQL Plugin', () => {
|
|
|
125
148
|
healthCheckName: 'custom-db',
|
|
126
149
|
};
|
|
127
150
|
const plugin = createPostgresPlugin(configWithCustomName, 'test');
|
|
128
|
-
await plugin.
|
|
151
|
+
await plugin.onStart({}, mockRegistry);
|
|
129
152
|
|
|
130
|
-
expect(
|
|
153
|
+
expect(mockRegistry.registerHealthCheck).toHaveBeenCalledWith(
|
|
131
154
|
expect.objectContaining({
|
|
132
155
|
name: 'custom-db',
|
|
133
156
|
})
|
|
@@ -138,7 +161,7 @@ describe('PostgreSQL Plugin', () => {
|
|
|
138
161
|
describe('getPostgres', () => {
|
|
139
162
|
it('should return registered instance', async () => {
|
|
140
163
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
141
|
-
await plugin.
|
|
164
|
+
await plugin.onStart({}, mockRegistry);
|
|
142
165
|
|
|
143
166
|
const db = getPostgres('test');
|
|
144
167
|
expect(db).toBeDefined();
|
|
@@ -161,7 +184,7 @@ describe('PostgreSQL Plugin', () => {
|
|
|
161
184
|
|
|
162
185
|
it('should return true for registered instance', async () => {
|
|
163
186
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
164
|
-
await plugin.
|
|
187
|
+
await plugin.onStart({}, mockRegistry);
|
|
165
188
|
|
|
166
189
|
expect(hasPostgres('test')).toBe(true);
|
|
167
190
|
});
|
|
@@ -170,7 +193,7 @@ describe('PostgreSQL Plugin', () => {
|
|
|
170
193
|
describe('PostgresInstance', () => {
|
|
171
194
|
it('should execute query and return rows', async () => {
|
|
172
195
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
173
|
-
await plugin.
|
|
196
|
+
await plugin.onStart({}, mockRegistry);
|
|
174
197
|
|
|
175
198
|
const db = getPostgres('test');
|
|
176
199
|
const result = await db.query('SELECT 1');
|
|
@@ -179,7 +202,7 @@ describe('PostgreSQL Plugin', () => {
|
|
|
179
202
|
|
|
180
203
|
it('should return null from queryOne when no rows', async () => {
|
|
181
204
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
182
|
-
await plugin.
|
|
205
|
+
await plugin.onStart({}, mockRegistry);
|
|
183
206
|
|
|
184
207
|
const db = getPostgres('test');
|
|
185
208
|
const result = await db.queryOne('SELECT 1');
|
|
@@ -188,7 +211,7 @@ describe('PostgreSQL Plugin', () => {
|
|
|
188
211
|
|
|
189
212
|
it('should return pool stats', async () => {
|
|
190
213
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
191
|
-
await plugin.
|
|
214
|
+
await plugin.onStart({}, mockRegistry);
|
|
192
215
|
|
|
193
216
|
const db = getPostgres('test');
|
|
194
217
|
const stats = db.getStats();
|
|
@@ -198,14 +221,14 @@ describe('PostgreSQL Plugin', () => {
|
|
|
198
221
|
});
|
|
199
222
|
});
|
|
200
223
|
|
|
201
|
-
describe('
|
|
224
|
+
describe('onStop', () => {
|
|
202
225
|
it('should close pool and unregister instance', async () => {
|
|
203
226
|
const plugin = createPostgresPlugin(mockConfig, 'test');
|
|
204
|
-
await plugin.
|
|
227
|
+
await plugin.onStart({}, mockRegistry);
|
|
205
228
|
|
|
206
229
|
expect(hasPostgres('test')).toBe(true);
|
|
207
230
|
|
|
208
|
-
await plugin.
|
|
231
|
+
await plugin.onStop();
|
|
209
232
|
|
|
210
233
|
expect(hasPostgres('test')).toBe(false);
|
|
211
234
|
});
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
49
|
import pg from 'pg';
|
|
50
|
-
import type {
|
|
50
|
+
import type { Plugin, PluginConfig, PluginRegistry } from '../core/plugin-registry.js';
|
|
51
51
|
|
|
52
52
|
const { Pool } = pg;
|
|
53
53
|
|
|
@@ -173,7 +173,7 @@ export function hasPostgres(name = 'default'): boolean {
|
|
|
173
173
|
*
|
|
174
174
|
* @param config - PostgreSQL configuration
|
|
175
175
|
* @param instanceName - Name for this PostgreSQL instance (default: 'default')
|
|
176
|
-
* @returns A
|
|
176
|
+
* @returns A plugin
|
|
177
177
|
*
|
|
178
178
|
* @example
|
|
179
179
|
* ```typescript
|
|
@@ -187,8 +187,9 @@ export function hasPostgres(name = 'default'): boolean {
|
|
|
187
187
|
export function createPostgresPlugin(
|
|
188
188
|
config: PostgresPluginConfig,
|
|
189
189
|
instanceName = 'default'
|
|
190
|
-
):
|
|
190
|
+
): Plugin {
|
|
191
191
|
let pool: pg.Pool | null = null;
|
|
192
|
+
const pluginId = `postgres:${instanceName}`;
|
|
192
193
|
|
|
193
194
|
const createInstance = (): PostgresInstance => {
|
|
194
195
|
if (!pool) {
|
|
@@ -282,11 +283,12 @@ export function createPostgresPlugin(
|
|
|
282
283
|
};
|
|
283
284
|
|
|
284
285
|
return {
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
id: pluginId,
|
|
287
|
+
name: `PostgreSQL (${instanceName})`,
|
|
288
|
+
version: '1.0.0',
|
|
287
289
|
|
|
288
|
-
async
|
|
289
|
-
const
|
|
290
|
+
async onStart(_pluginConfig: PluginConfig, registry: PluginRegistry): Promise<void> {
|
|
291
|
+
const logger = registry.getLogger(pluginId);
|
|
290
292
|
|
|
291
293
|
// Create and register the instance
|
|
292
294
|
const instance = createInstance();
|
|
@@ -303,7 +305,7 @@ export function createPostgresPlugin(
|
|
|
303
305
|
|
|
304
306
|
// Register health check if enabled
|
|
305
307
|
if (config.healthCheck !== false) {
|
|
306
|
-
registerHealthCheck({
|
|
308
|
+
registry.registerHealthCheck({
|
|
307
309
|
name: config.healthCheckName ?? 'postgres',
|
|
308
310
|
type: 'custom',
|
|
309
311
|
interval: config.healthCheckInterval ?? 30000,
|
|
@@ -334,7 +336,7 @@ export function createPostgresPlugin(
|
|
|
334
336
|
}
|
|
335
337
|
},
|
|
336
338
|
|
|
337
|
-
async
|
|
339
|
+
async onStop(): Promise<void> {
|
|
338
340
|
const instance = instances.get(instanceName);
|
|
339
341
|
if (instance) {
|
|
340
342
|
await instance.close();
|