@qwickapps/server 1.7.0 → 1.7.2
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/CHANGELOG.md +66 -0
- package/README.md +13 -116
- package/dist/src/core/control-panel.d.ts.map +1 -1
- package/dist/src/core/control-panel.js +6 -4
- package/dist/src/core/control-panel.js.map +1 -1
- package/dist/src/core/gateway.d.ts.map +1 -1
- package/dist/src/core/gateway.js +24 -2
- package/dist/src/core/gateway.js.map +1 -1
- package/dist/src/core/plugin-registry.d.ts +15 -2
- package/dist/src/core/plugin-registry.d.ts.map +1 -1
- package/dist/src/core/plugin-registry.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/plugins/api-keys/api-keys-plugin.d.ts +5 -2
- package/dist/src/plugins/api-keys/api-keys-plugin.d.ts.map +1 -1
- package/dist/src/plugins/api-keys/api-keys-plugin.js +61 -19
- package/dist/src/plugins/api-keys/api-keys-plugin.js.map +1 -1
- package/dist/src/plugins/api-keys/index.d.ts +0 -4
- package/dist/src/plugins/api-keys/index.d.ts.map +1 -1
- package/dist/src/plugins/api-keys/index.js +2 -3
- package/dist/src/plugins/api-keys/index.js.map +1 -1
- package/dist/src/plugins/api-keys/stores/postgres-store.d.ts.map +1 -1
- package/dist/src/plugins/api-keys/stores/postgres-store.js +29 -0
- package/dist/src/plugins/api-keys/stores/postgres-store.js.map +1 -1
- package/dist/src/plugins/api-keys/types.d.ts +9 -3
- package/dist/src/plugins/api-keys/types.d.ts.map +1 -1
- package/dist/src/plugins/api-keys/types.js.map +1 -1
- package/dist/src/plugins/auth/auth-plugin.d.ts.map +1 -1
- package/dist/src/plugins/auth/auth-plugin.js +4 -2
- package/dist/src/plugins/auth/auth-plugin.js.map +1 -1
- package/dist/src/plugins/auth/env-config.d.ts.map +1 -1
- package/dist/src/plugins/auth/env-config.js +1 -0
- package/dist/src/plugins/auth/env-config.js.map +1 -1
- package/dist/src/plugins/auth/index.d.ts +0 -4
- package/dist/src/plugins/auth/index.d.ts.map +1 -1
- package/dist/src/plugins/auth/index.js +2 -3
- package/dist/src/plugins/auth/index.js.map +1 -1
- package/dist/src/plugins/bans/bans-plugin.d.ts +5 -2
- package/dist/src/plugins/bans/bans-plugin.d.ts.map +1 -1
- package/dist/src/plugins/bans/bans-plugin.js +71 -25
- package/dist/src/plugins/bans/bans-plugin.js.map +1 -1
- package/dist/src/plugins/bans/index.d.ts +1 -5
- package/dist/src/plugins/bans/index.d.ts.map +1 -1
- package/dist/src/plugins/bans/index.js +3 -4
- package/dist/src/plugins/bans/index.js.map +1 -1
- package/dist/src/plugins/bans/stores/in-memory-store.d.ts +34 -0
- package/dist/src/plugins/bans/stores/in-memory-store.d.ts.map +1 -0
- package/dist/src/plugins/bans/stores/in-memory-store.js +97 -0
- package/dist/src/plugins/bans/stores/in-memory-store.js.map +1 -0
- package/dist/src/plugins/bans/stores/index.d.ts +1 -0
- package/dist/src/plugins/bans/stores/index.d.ts.map +1 -1
- package/dist/src/plugins/bans/stores/index.js +1 -0
- package/dist/src/plugins/bans/stores/index.js.map +1 -1
- package/dist/src/plugins/bans/types.d.ts +13 -6
- package/dist/src/plugins/bans/types.d.ts.map +1 -1
- package/dist/src/plugins/cache-plugin.d.ts +35 -16
- package/dist/src/plugins/cache-plugin.d.ts.map +1 -1
- package/dist/src/plugins/cache-plugin.js +299 -20
- package/dist/src/plugins/cache-plugin.js.map +1 -1
- package/dist/src/plugins/cms/cms-plugin.d.ts.map +1 -1
- package/dist/src/plugins/cms/cms-plugin.js +3 -1
- package/dist/src/plugins/cms/cms-plugin.js.map +1 -1
- package/dist/src/plugins/devices/devices-plugin.d.ts +5 -2
- package/dist/src/plugins/devices/devices-plugin.d.ts.map +1 -1
- package/dist/src/plugins/devices/devices-plugin.js +62 -26
- package/dist/src/plugins/devices/devices-plugin.js.map +1 -1
- package/dist/src/plugins/devices/index.d.ts +0 -4
- package/dist/src/plugins/devices/index.d.ts.map +1 -1
- package/dist/src/plugins/devices/index.js +2 -3
- package/dist/src/plugins/devices/index.js.map +1 -1
- package/dist/src/plugins/entitlements/entitlements-plugin.d.ts +5 -2
- package/dist/src/plugins/entitlements/entitlements-plugin.d.ts.map +1 -1
- package/dist/src/plugins/entitlements/entitlements-plugin.js +78 -41
- package/dist/src/plugins/entitlements/entitlements-plugin.js.map +1 -1
- package/dist/src/plugins/entitlements/index.d.ts +1 -5
- package/dist/src/plugins/entitlements/index.d.ts.map +1 -1
- package/dist/src/plugins/entitlements/index.js +3 -4
- package/dist/src/plugins/entitlements/index.js.map +1 -1
- package/dist/src/plugins/entitlements/sources/in-memory-source.d.ts +9 -0
- package/dist/src/plugins/entitlements/sources/in-memory-source.d.ts.map +1 -0
- package/dist/src/plugins/entitlements/sources/in-memory-source.js +65 -0
- package/dist/src/plugins/entitlements/sources/in-memory-source.js.map +1 -0
- package/dist/src/plugins/entitlements/sources/index.d.ts +1 -0
- package/dist/src/plugins/entitlements/sources/index.d.ts.map +1 -1
- package/dist/src/plugins/entitlements/sources/index.js +1 -0
- package/dist/src/plugins/entitlements/sources/index.js.map +1 -1
- package/dist/src/plugins/entitlements/types.d.ts +9 -2
- package/dist/src/plugins/entitlements/types.d.ts.map +1 -1
- package/dist/src/plugins/health-plugin.d.ts.map +1 -1
- package/dist/src/plugins/health-plugin.js +1 -0
- package/dist/src/plugins/health-plugin.js.map +1 -1
- package/dist/src/plugins/index.d.ts +4 -4
- package/dist/src/plugins/index.d.ts.map +1 -1
- package/dist/src/plugins/index.js +4 -4
- package/dist/src/plugins/index.js.map +1 -1
- package/dist/src/plugins/logs-plugin.d.ts.map +1 -1
- package/dist/src/plugins/logs-plugin.js +49 -1
- package/dist/src/plugins/logs-plugin.js.map +1 -1
- package/dist/src/plugins/maintenance-plugin.d.ts.map +1 -1
- package/dist/src/plugins/maintenance-plugin.js +39 -0
- package/dist/src/plugins/maintenance-plugin.js.map +1 -1
- package/dist/src/plugins/notifications/index.d.ts +0 -4
- package/dist/src/plugins/notifications/index.d.ts.map +1 -1
- package/dist/src/plugins/notifications/index.js +2 -3
- package/dist/src/plugins/notifications/index.js.map +1 -1
- package/dist/src/plugins/notifications/notifications-plugin.d.ts +5 -2
- package/dist/src/plugins/notifications/notifications-plugin.d.ts.map +1 -1
- package/dist/src/plugins/notifications/notifications-plugin.js +46 -13
- package/dist/src/plugins/notifications/notifications-plugin.js.map +1 -1
- package/dist/src/plugins/parental/index.d.ts +0 -4
- package/dist/src/plugins/parental/index.d.ts.map +1 -1
- package/dist/src/plugins/parental/index.js +2 -3
- package/dist/src/plugins/parental/index.js.map +1 -1
- package/dist/src/plugins/parental/parental-plugin.d.ts +5 -2
- package/dist/src/plugins/parental/parental-plugin.d.ts.map +1 -1
- package/dist/src/plugins/parental/parental-plugin.js +60 -24
- package/dist/src/plugins/parental/parental-plugin.js.map +1 -1
- package/dist/src/plugins/postgres-plugin.d.ts +3 -1
- package/dist/src/plugins/postgres-plugin.d.ts.map +1 -1
- package/dist/src/plugins/postgres-plugin.js +18 -8
- package/dist/src/plugins/postgres-plugin.js.map +1 -1
- package/dist/src/plugins/preferences/index.d.ts +0 -4
- package/dist/src/plugins/preferences/index.d.ts.map +1 -1
- package/dist/src/plugins/preferences/index.js +2 -3
- package/dist/src/plugins/preferences/index.js.map +1 -1
- package/dist/src/plugins/preferences/preferences-plugin.d.ts +5 -2
- package/dist/src/plugins/preferences/preferences-plugin.d.ts.map +1 -1
- package/dist/src/plugins/preferences/preferences-plugin.js +63 -19
- package/dist/src/plugins/preferences/preferences-plugin.js.map +1 -1
- package/dist/src/plugins/profiles/index.d.ts +0 -4
- package/dist/src/plugins/profiles/index.d.ts.map +1 -1
- package/dist/src/plugins/profiles/index.js +2 -3
- package/dist/src/plugins/profiles/index.js.map +1 -1
- package/dist/src/plugins/profiles/profiles-plugin.d.ts +5 -2
- package/dist/src/plugins/profiles/profiles-plugin.d.ts.map +1 -1
- package/dist/src/plugins/profiles/profiles-plugin.js +60 -26
- package/dist/src/plugins/profiles/profiles-plugin.js.map +1 -1
- package/dist/src/plugins/profiles/types.d.ts +9 -2
- package/dist/src/plugins/profiles/types.d.ts.map +1 -1
- package/dist/src/plugins/qwickbrain/index.d.ts +0 -4
- package/dist/src/plugins/qwickbrain/index.d.ts.map +1 -1
- package/dist/src/plugins/qwickbrain/index.js +2 -3
- package/dist/src/plugins/qwickbrain/index.js.map +1 -1
- package/dist/src/plugins/qwickbrain/qwickbrain-plugin.d.ts.map +1 -1
- package/dist/src/plugins/qwickbrain/qwickbrain-plugin.js +117 -0
- package/dist/src/plugins/qwickbrain/qwickbrain-plugin.js.map +1 -1
- package/dist/src/plugins/rate-limit/index.d.ts +0 -4
- package/dist/src/plugins/rate-limit/index.d.ts.map +1 -1
- package/dist/src/plugins/rate-limit/index.js +2 -3
- package/dist/src/plugins/rate-limit/index.js.map +1 -1
- package/dist/src/plugins/subscriptions/index.d.ts +0 -4
- package/dist/src/plugins/subscriptions/index.d.ts.map +1 -1
- package/dist/src/plugins/subscriptions/index.js +2 -3
- package/dist/src/plugins/subscriptions/index.js.map +1 -1
- package/dist/src/plugins/subscriptions/subscriptions-plugin.d.ts +5 -2
- package/dist/src/plugins/subscriptions/subscriptions-plugin.d.ts.map +1 -1
- package/dist/src/plugins/subscriptions/subscriptions-plugin.js +63 -29
- package/dist/src/plugins/subscriptions/subscriptions-plugin.js.map +1 -1
- package/dist/src/plugins/subscriptions/types.d.ts +8 -2
- package/dist/src/plugins/subscriptions/types.d.ts.map +1 -1
- package/dist/src/plugins/tenants/index.d.ts +1 -1
- package/dist/src/plugins/tenants/index.d.ts.map +1 -1
- package/dist/src/plugins/tenants/index.js +1 -1
- package/dist/src/plugins/tenants/index.js.map +1 -1
- package/dist/src/plugins/tenants/stores/in-memory-store.d.ts +59 -0
- package/dist/src/plugins/tenants/stores/in-memory-store.d.ts.map +1 -0
- package/dist/src/plugins/tenants/stores/in-memory-store.js +257 -0
- package/dist/src/plugins/tenants/stores/in-memory-store.js.map +1 -0
- package/dist/src/plugins/tenants/stores/index.d.ts +8 -0
- package/dist/src/plugins/tenants/stores/index.d.ts.map +1 -0
- package/dist/src/plugins/tenants/stores/index.js +8 -0
- package/dist/src/plugins/tenants/stores/index.js.map +1 -0
- package/dist/src/plugins/tenants/tenants-plugin.d.ts +5 -2
- package/dist/src/plugins/tenants/tenants-plugin.d.ts.map +1 -1
- package/dist/src/plugins/tenants/tenants-plugin.js +93 -60
- package/dist/src/plugins/tenants/tenants-plugin.js.map +1 -1
- package/dist/src/plugins/tenants/types.d.ts +8 -2
- package/dist/src/plugins/tenants/types.d.ts.map +1 -1
- package/dist/src/plugins/usage/index.d.ts +0 -4
- package/dist/src/plugins/usage/index.d.ts.map +1 -1
- package/dist/src/plugins/usage/index.js +2 -3
- package/dist/src/plugins/usage/index.js.map +1 -1
- package/dist/src/plugins/usage/usage-plugin.d.ts +5 -2
- package/dist/src/plugins/usage/usage-plugin.d.ts.map +1 -1
- package/dist/src/plugins/usage/usage-plugin.js +57 -23
- package/dist/src/plugins/usage/usage-plugin.js.map +1 -1
- package/dist/src/plugins/users/index.d.ts +1 -1
- package/dist/src/plugins/users/index.d.ts.map +1 -1
- package/dist/src/plugins/users/index.js +1 -1
- package/dist/src/plugins/users/index.js.map +1 -1
- package/dist/src/plugins/users/stores/in-memory-store.d.ts +36 -0
- package/dist/src/plugins/users/stores/in-memory-store.d.ts.map +1 -0
- package/dist/src/plugins/users/stores/in-memory-store.js +122 -0
- package/dist/src/plugins/users/stores/in-memory-store.js.map +1 -0
- package/dist/src/plugins/users/stores/index.d.ts +1 -0
- package/dist/src/plugins/users/stores/index.d.ts.map +1 -1
- package/dist/src/plugins/users/stores/index.js +1 -0
- package/dist/src/plugins/users/stores/index.js.map +1 -1
- package/dist/src/plugins/users/types.d.ts +7 -2
- package/dist/src/plugins/users/types.d.ts.map +1 -1
- package/dist/src/plugins/users/users-plugin.d.ts +5 -2
- package/dist/src/plugins/users/users-plugin.d.ts.map +1 -1
- package/dist/src/plugins/users/users-plugin.js +56 -23
- package/dist/src/plugins/users/users-plugin.js.map +1 -1
- package/dist/ui/src/api/controlPanelApi.d.ts +10 -1
- package/dist/ui/src/api/controlPanelApi.d.ts.map +1 -1
- package/dist/ui/src/api/controlPanelApi.js.map +1 -1
- package/dist/ui/src/dashboard/PluginWidgetRenderer.d.ts +3 -1
- package/dist/ui/src/dashboard/PluginWidgetRenderer.d.ts.map +1 -1
- package/dist/ui/src/dashboard/PluginWidgetRenderer.js +5 -1
- package/dist/ui/src/dashboard/PluginWidgetRenderer.js.map +1 -1
- package/dist/ui/src/dashboard/builtInWidgets.d.ts.map +1 -1
- package/dist/ui/src/dashboard/builtInWidgets.js +13 -1
- package/dist/ui/src/dashboard/builtInWidgets.js.map +1 -1
- package/dist/ui/src/dashboard/widgets/CacheMaintenanceWidget.d.ts +11 -0
- package/dist/ui/src/dashboard/widgets/CacheMaintenanceWidget.d.ts.map +1 -0
- package/dist/ui/src/dashboard/widgets/CacheMaintenanceWidget.js +77 -0
- package/dist/ui/src/dashboard/widgets/CacheMaintenanceWidget.js.map +1 -0
- package/dist/ui/src/dashboard/widgets/DatabaseOpsWidget.d.ts +10 -0
- package/dist/ui/src/dashboard/widgets/DatabaseOpsWidget.d.ts.map +1 -0
- package/dist/ui/src/dashboard/widgets/DatabaseOpsWidget.js +14 -0
- package/dist/ui/src/dashboard/widgets/DatabaseOpsWidget.js.map +1 -0
- package/dist/ui/src/dashboard/widgets/EnvironmentConfigWidget.d.ts +10 -0
- package/dist/ui/src/dashboard/widgets/EnvironmentConfigWidget.d.ts.map +1 -0
- package/dist/ui/src/dashboard/widgets/EnvironmentConfigWidget.js +14 -0
- package/dist/ui/src/dashboard/widgets/EnvironmentConfigWidget.js.map +1 -0
- package/dist/ui/src/dashboard/widgets/LogsMaintenanceWidget.d.ts +11 -0
- package/dist/ui/src/dashboard/widgets/LogsMaintenanceWidget.d.ts.map +1 -0
- package/dist/ui/src/dashboard/widgets/LogsMaintenanceWidget.js +96 -0
- package/dist/ui/src/dashboard/widgets/LogsMaintenanceWidget.js.map +1 -0
- package/dist/ui/src/dashboard/widgets/SeedManagementWidget.d.ts +10 -0
- package/dist/ui/src/dashboard/widgets/SeedManagementWidget.d.ts.map +1 -0
- package/dist/ui/src/dashboard/widgets/SeedManagementWidget.js +55 -0
- package/dist/ui/src/dashboard/widgets/SeedManagementWidget.js.map +1 -0
- package/dist/ui/src/dashboard/widgets/ServiceControlWidget.d.ts +10 -0
- package/dist/ui/src/dashboard/widgets/ServiceControlWidget.d.ts.map +1 -0
- package/dist/ui/src/dashboard/widgets/ServiceControlWidget.js +14 -0
- package/dist/ui/src/dashboard/widgets/ServiceControlWidget.js.map +1 -0
- package/dist/ui/src/dashboard/widgets/index.d.ts +6 -0
- package/dist/ui/src/dashboard/widgets/index.d.ts.map +1 -1
- package/dist/ui/src/dashboard/widgets/index.js +6 -0
- package/dist/ui/src/dashboard/widgets/index.js.map +1 -1
- package/dist/ui/src/pages/DashboardPage.js +1 -1
- package/dist/ui/src/pages/DashboardPage.js.map +1 -1
- package/dist-ui/assets/index-0gzisPdy.js +528 -0
- package/dist-ui/assets/{index-lm1yX6UD.js.map → index-0gzisPdy.js.map} +1 -1
- package/dist-ui/index.html +1 -1
- package/dist-ui-lib/index.js +3109 -2774
- package/dist-ui-lib/index.js.map +1 -1
- package/dist-ui-lib/src/api/controlPanelApi.d.ts +10 -1
- package/dist-ui-lib/src/dashboard/PluginWidgetRenderer.d.ts +3 -1
- package/dist-ui-lib/src/dashboard/widgets/CacheMaintenanceWidget.d.ts +10 -0
- package/dist-ui-lib/src/dashboard/widgets/DatabaseOpsWidget.d.ts +9 -0
- package/dist-ui-lib/src/dashboard/widgets/EnvironmentConfigWidget.d.ts +9 -0
- package/dist-ui-lib/src/dashboard/widgets/LogsMaintenanceWidget.d.ts +10 -0
- package/dist-ui-lib/src/dashboard/widgets/SeedManagementWidget.d.ts +9 -0
- package/dist-ui-lib/src/dashboard/widgets/ServiceControlWidget.d.ts +9 -0
- package/dist-ui-lib/src/dashboard/widgets/index.d.ts +6 -0
- package/package.json +12 -6
- package/src/core/control-panel.ts +6 -4
- package/src/core/gateway.ts +25 -2
- package/src/core/plugin-registry.ts +15 -2
- package/src/index.ts +53 -0
- package/src/plugins/api-keys/api-keys-plugin.ts +64 -20
- package/src/plugins/api-keys/index.ts +2 -5
- package/src/plugins/api-keys/stores/postgres-store.ts +30 -0
- package/src/plugins/api-keys/types.ts +9 -3
- package/src/plugins/auth/auth-plugin.ts +4 -2
- package/src/plugins/auth/env-config.ts +1 -0
- package/src/plugins/auth/index.ts +3 -5
- package/src/plugins/bans/bans-plugin.ts +71 -26
- package/src/plugins/bans/index.ts +4 -6
- package/src/plugins/bans/stores/in-memory-store.ts +106 -0
- package/src/plugins/bans/stores/index.ts +1 -0
- package/src/plugins/bans/types.ts +13 -6
- package/src/plugins/cache-plugin.test.ts +2 -2
- package/src/plugins/cache-plugin.ts +331 -30
- package/src/plugins/cms/cms-plugin.ts +3 -1
- package/src/plugins/devices/devices-plugin.ts +62 -27
- package/src/plugins/devices/index.ts +3 -5
- package/src/plugins/entitlements/entitlements-plugin.ts +81 -43
- package/src/plugins/entitlements/index.ts +4 -6
- package/src/plugins/entitlements/sources/in-memory-source.ts +76 -0
- package/src/plugins/entitlements/sources/index.ts +1 -0
- package/src/plugins/entitlements/types.ts +9 -2
- package/src/plugins/health-plugin.ts +1 -0
- package/src/plugins/index.ts +4 -1
- package/src/plugins/logs-plugin.ts +55 -1
- package/src/plugins/maintenance-plugin.ts +43 -0
- package/src/plugins/notifications/index.ts +3 -5
- package/src/plugins/notifications/notifications-plugin.ts +49 -19
- package/src/plugins/parental/index.ts +3 -5
- package/src/plugins/parental/parental-plugin.ts +63 -25
- package/src/plugins/postgres-plugin.test.ts +2 -2
- package/src/plugins/postgres-plugin.ts +20 -9
- package/src/plugins/preferences/index.ts +3 -5
- package/src/plugins/preferences/preferences-plugin.ts +66 -20
- package/src/plugins/profiles/index.ts +3 -5
- package/src/plugins/profiles/profiles-plugin.ts +60 -27
- package/src/plugins/profiles/types.ts +9 -2
- package/src/plugins/qwickbrain/index.ts +3 -5
- package/src/plugins/qwickbrain/qwickbrain-plugin.ts +135 -0
- package/src/plugins/rate-limit/index.ts +3 -5
- package/src/plugins/subscriptions/index.ts +3 -5
- package/src/plugins/subscriptions/subscriptions-plugin.ts +63 -30
- package/src/plugins/subscriptions/types.ts +8 -2
- package/src/plugins/tenants/index.ts +1 -1
- package/src/plugins/tenants/stores/in-memory-store.ts +335 -0
- package/src/plugins/tenants/stores/index.ts +13 -0
- package/src/plugins/tenants/tenants-plugin.ts +97 -62
- package/src/plugins/tenants/types.ts +8 -2
- package/src/plugins/usage/index.ts +3 -5
- package/src/plugins/usage/usage-plugin.ts +60 -26
- package/src/plugins/users/index.ts +1 -1
- package/src/plugins/users/stores/in-memory-store.ts +140 -0
- package/src/plugins/users/stores/index.ts +1 -0
- package/src/plugins/users/types.ts +7 -2
- package/src/plugins/users/users-plugin.ts +56 -24
- package/src/testing/index.ts +1 -0
- package/src/testing/pg-mem-pool.ts +33 -0
- package/ui/src/api/controlPanelApi.ts +10 -1
- package/ui/src/dashboard/PluginWidgetRenderer.tsx +8 -0
- package/ui/src/dashboard/builtInWidgets.tsx +19 -1
- package/ui/src/dashboard/widgets/CacheMaintenanceWidget.tsx +195 -0
- package/ui/src/dashboard/widgets/DatabaseOpsWidget.tsx +29 -0
- package/ui/src/dashboard/widgets/EnvironmentConfigWidget.tsx +29 -0
- package/ui/src/dashboard/widgets/LogsMaintenanceWidget.tsx +247 -0
- package/ui/src/dashboard/widgets/SeedManagementWidget.tsx +128 -0
- package/ui/src/dashboard/widgets/ServiceControlWidget.tsx +29 -0
- package/ui/src/dashboard/widgets/index.ts +6 -0
- package/ui/src/pages/DashboardPage.tsx +2 -2
- package/ui/src/pages/MaintenancePage.tsx +1 -1
- package/dist-ui/assets/index-lm1yX6UD.js +0 -528
|
@@ -22,6 +22,8 @@ import type {
|
|
|
22
22
|
} from './types.js';
|
|
23
23
|
import type { AuthenticatedRequest } from '../auth/types.js';
|
|
24
24
|
import { getUserByEmail, getUserById, getUsersByIds } from '../users/users-plugin.js';
|
|
25
|
+
import { hasPostgres, getPostgres } from '../postgres-plugin.js';
|
|
26
|
+
import { postgresBanStore } from './stores/index.js';
|
|
25
27
|
|
|
26
28
|
// Store instance for helper access
|
|
27
29
|
let currentStore: BanStore | null = null;
|
|
@@ -29,17 +31,18 @@ let banCleanupInterval: NodeJS.Timeout | null = null;
|
|
|
29
31
|
let pluginConfig: BansPluginConfig | null = null;
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
|
-
* Create the Bans plugin
|
|
34
|
+
* Create the Bans plugin with smart defaults
|
|
35
|
+
*
|
|
36
|
+
* Config is optional - plugin will use defaults and get dependencies from registry.
|
|
37
|
+
* Gracefully handles missing dependencies with clear log messages.
|
|
33
38
|
*/
|
|
34
|
-
export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (debug) {
|
|
42
|
-
console.log(`[BansPlugin] ${message}`, data || '');
|
|
39
|
+
export function createBansPlugin(config: Partial<BansPluginConfig> = {}): Plugin {
|
|
40
|
+
function log(message: string, data?: Record<string, unknown>, isError = false) {
|
|
41
|
+
const prefix = '[BansPlugin]';
|
|
42
|
+
if (isError) {
|
|
43
|
+
console.error(`${prefix} ${message}`, data || '');
|
|
44
|
+
} else if (config.debug) {
|
|
45
|
+
console.log(`${prefix} ${message}`, data || '');
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -49,26 +52,68 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
49
52
|
version: '1.0.0',
|
|
50
53
|
|
|
51
54
|
async onStart(_pluginConfig: PluginConfig, registry: PluginRegistry): Promise<void> {
|
|
52
|
-
|
|
55
|
+
const logger = registry.getLogger('bans');
|
|
53
56
|
|
|
54
57
|
// Check for users plugin dependency
|
|
55
58
|
if (!registry.hasPlugin('users')) {
|
|
56
|
-
|
|
59
|
+
logger.warn('Users plugin not loaded! Bans plugin disabled.');
|
|
60
|
+
registry.registerHealthCheck({
|
|
61
|
+
name: 'bans-store',
|
|
62
|
+
type: 'custom',
|
|
63
|
+
check: async () => ({
|
|
64
|
+
healthy: false,
|
|
65
|
+
details: {
|
|
66
|
+
error: 'Users plugin not available',
|
|
67
|
+
state: 'disabled',
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check for postgres in registry
|
|
75
|
+
if (!hasPostgres()) {
|
|
76
|
+
logger.warn('No Database! Bans plugin disabled.');
|
|
77
|
+
registry.registerHealthCheck({
|
|
78
|
+
name: 'bans-store',
|
|
79
|
+
type: 'custom',
|
|
80
|
+
check: async () => ({
|
|
81
|
+
healthy: false,
|
|
82
|
+
details: {
|
|
83
|
+
error: 'PostgreSQL not available',
|
|
84
|
+
state: 'disabled',
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
57
89
|
}
|
|
58
90
|
|
|
91
|
+
// Smart defaults - get dependencies from registry
|
|
92
|
+
const store = config.store ?? postgresBanStore({
|
|
93
|
+
pool: () => getPostgres().getPool(),
|
|
94
|
+
autoCreateTables: true,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const debug = config.debug ?? false;
|
|
98
|
+
const apiPrefix = config.api?.prefix ?? '/bans';
|
|
99
|
+
const apiEnabled = config.api?.enabled ?? true;
|
|
100
|
+
const supportTemporary = config.supportTemporary ?? true;
|
|
101
|
+
|
|
102
|
+
log('Starting bans plugin');
|
|
103
|
+
|
|
59
104
|
// Initialize the store (creates tables if needed)
|
|
60
|
-
await
|
|
105
|
+
await store.initialize();
|
|
61
106
|
log('Bans plugin migrations complete');
|
|
62
107
|
|
|
63
108
|
// Store references for helper access
|
|
64
|
-
currentStore =
|
|
65
|
-
pluginConfig = config;
|
|
109
|
+
currentStore = store;
|
|
110
|
+
pluginConfig = { ...config, store, debug, supportTemporary };
|
|
66
111
|
|
|
67
112
|
// Start ban cleanup interval if temporary bans are supported
|
|
68
|
-
if (
|
|
113
|
+
if (supportTemporary) {
|
|
69
114
|
banCleanupInterval = setInterval(async () => {
|
|
70
115
|
try {
|
|
71
|
-
const cleaned = await
|
|
116
|
+
const cleaned = await store.cleanupExpiredBans();
|
|
72
117
|
if (cleaned > 0) {
|
|
73
118
|
log('Cleaned up expired bans', { count: cleaned });
|
|
74
119
|
}
|
|
@@ -85,7 +130,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
85
130
|
check: async () => {
|
|
86
131
|
try {
|
|
87
132
|
// Simple health check - list with limit 0
|
|
88
|
-
await
|
|
133
|
+
await store.listActiveBans({ limit: 0 });
|
|
89
134
|
return { healthy: true };
|
|
90
135
|
} catch {
|
|
91
136
|
return { healthy: false };
|
|
@@ -105,7 +150,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
105
150
|
const limit = Math.min(parseInt(req.query.limit as string) || 50, 100);
|
|
106
151
|
const offset = parseInt(req.query.offset as string) || 0;
|
|
107
152
|
|
|
108
|
-
const result = await
|
|
153
|
+
const result = await store.listActiveBans({ limit, offset });
|
|
109
154
|
|
|
110
155
|
// Batch fetch users for all bans (single query instead of N queries)
|
|
111
156
|
const userIds = [...new Set(result.bans.map((ban) => ban.user_id))];
|
|
@@ -133,7 +178,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
133
178
|
pluginId: 'bans',
|
|
134
179
|
handler: async (req: Request, res: Response) => {
|
|
135
180
|
try {
|
|
136
|
-
const ban = await
|
|
181
|
+
const ban = await store.getActiveBan(req.params.userId);
|
|
137
182
|
res.json({
|
|
138
183
|
isBanned: ban !== null,
|
|
139
184
|
ban,
|
|
@@ -152,7 +197,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
152
197
|
pluginId: 'bans',
|
|
153
198
|
handler: async (req: Request, res: Response) => {
|
|
154
199
|
try {
|
|
155
|
-
const bans = await
|
|
200
|
+
const bans = await store.listBans(req.params.userId);
|
|
156
201
|
res.json({ bans });
|
|
157
202
|
} catch (error) {
|
|
158
203
|
console.error('[BansPlugin] Get ban history error:', error);
|
|
@@ -185,7 +230,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
185
230
|
return res.status(404).json({ error: 'User not found' });
|
|
186
231
|
}
|
|
187
232
|
|
|
188
|
-
const ban = await
|
|
233
|
+
const ban = await store.createBan(input);
|
|
189
234
|
|
|
190
235
|
// Call onBan callback if provided
|
|
191
236
|
if (config.callbacks?.onBan) {
|
|
@@ -227,7 +272,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
227
272
|
note: req.body?.note,
|
|
228
273
|
};
|
|
229
274
|
|
|
230
|
-
const removed = await
|
|
275
|
+
const removed = await store.removeBan(input);
|
|
231
276
|
if (!removed) {
|
|
232
277
|
return res.status(404).json({ error: 'No active ban found' });
|
|
233
278
|
}
|
|
@@ -292,7 +337,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
292
337
|
metadata: req.body.metadata,
|
|
293
338
|
};
|
|
294
339
|
|
|
295
|
-
const ban = await
|
|
340
|
+
const ban = await store.createBan(input);
|
|
296
341
|
|
|
297
342
|
// Call onBan callback if provided
|
|
298
343
|
if (config.callbacks?.onBan) {
|
|
@@ -335,7 +380,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
335
380
|
note: req.body?.note,
|
|
336
381
|
};
|
|
337
382
|
|
|
338
|
-
const removed = await
|
|
383
|
+
const removed = await store.removeBan(input);
|
|
339
384
|
if (!removed) {
|
|
340
385
|
return res.status(404).json({ error: 'No active ban found' });
|
|
341
386
|
}
|
|
@@ -370,7 +415,7 @@ export function createBansPlugin(config: BansPluginConfig): Plugin {
|
|
|
370
415
|
banCleanupInterval = null;
|
|
371
416
|
}
|
|
372
417
|
|
|
373
|
-
await
|
|
418
|
+
if (currentStore) { await currentStore.shutdown(); };
|
|
374
419
|
currentStore = null;
|
|
375
420
|
pluginConfig = null;
|
|
376
421
|
|
|
@@ -28,10 +28,8 @@ export type {
|
|
|
28
28
|
} from './types.js';
|
|
29
29
|
|
|
30
30
|
// Stores
|
|
31
|
-
export { postgresBanStore } from './stores/index.js';
|
|
31
|
+
export { postgresBanStore, inMemoryBanStore } from './stores/index.js';
|
|
32
|
+
|
|
33
|
+
// UI Components are exported from main package index (@qwickapps/server)
|
|
34
|
+
// Do NOT export here to avoid loading UI dependencies when importing plugins
|
|
32
35
|
|
|
33
|
-
// UI Components
|
|
34
|
-
export { BansStatusWidget } from './BansStatusWidget.js';
|
|
35
|
-
export type { BansStatusWidgetProps } from './BansStatusWidget.js';
|
|
36
|
-
export { BansManagementPage } from './BansManagementPage.js';
|
|
37
|
-
export type { BansManagementPageProps } from './BansManagementPage.js';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory Ban Store for Demo/Testing
|
|
3
|
+
*
|
|
4
|
+
* Implements the BanStore interface with in-memory storage.
|
|
5
|
+
* Supports temporary and permanent bans with expiration.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function createInMemoryBanStore() {
|
|
9
|
+
const bans = new Map<string, any>();
|
|
10
|
+
let idCounter = 1;
|
|
11
|
+
|
|
12
|
+
function isActiveBan(ban: any): boolean {
|
|
13
|
+
if (!ban.is_active) return false;
|
|
14
|
+
if (ban.expires_at && new Date(ban.expires_at) <= new Date()) return false;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
name: 'in-memory',
|
|
20
|
+
|
|
21
|
+
async initialize() {
|
|
22
|
+
console.log('[InMemoryBanStore] Initialized');
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
async isBanned(userId: string) {
|
|
26
|
+
for (const ban of bans.values()) {
|
|
27
|
+
if (ban.user_id === userId && isActiveBan(ban)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
async getActiveBan(userId: string) {
|
|
35
|
+
for (const ban of bans.values()) {
|
|
36
|
+
if (ban.user_id === userId && isActiveBan(ban)) {
|
|
37
|
+
return ban;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
async createBan(input: any) {
|
|
44
|
+
const id = String(idCounter++);
|
|
45
|
+
const now = new Date();
|
|
46
|
+
const ban = {
|
|
47
|
+
id,
|
|
48
|
+
user_id: input.user_id,
|
|
49
|
+
reason: input.reason,
|
|
50
|
+
banned_by: input.banned_by || 'system',
|
|
51
|
+
banned_at: now,
|
|
52
|
+
expires_at: input.duration ? new Date(now.getTime() + input.duration * 1000) : null,
|
|
53
|
+
is_active: true,
|
|
54
|
+
metadata: input.metadata || {},
|
|
55
|
+
};
|
|
56
|
+
bans.set(id, ban);
|
|
57
|
+
return ban;
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
async removeBan(input: any) {
|
|
61
|
+
for (const ban of bans.values()) {
|
|
62
|
+
if (ban.user_id === input.user_id && isActiveBan(ban)) {
|
|
63
|
+
ban.is_active = false;
|
|
64
|
+
ban.removed_at = new Date();
|
|
65
|
+
ban.removed_by = input.removed_by;
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
async listBans(userId: string) {
|
|
73
|
+
const userBans: any[] = [];
|
|
74
|
+
for (const ban of bans.values()) {
|
|
75
|
+
if (ban.user_id === userId) {
|
|
76
|
+
userBans.push(ban);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return userBans;
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
async listActiveBans(options: { limit?: number; offset?: number } = {}) {
|
|
83
|
+
const activeBans = Array.from(bans.values()).filter(isActiveBan);
|
|
84
|
+
const total = activeBans.length;
|
|
85
|
+
const offset = options.offset || 0;
|
|
86
|
+
const limit = options.limit || 50;
|
|
87
|
+
const result = activeBans.slice(offset, offset + limit);
|
|
88
|
+
return { bans: result, total };
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
async cleanupExpiredBans() {
|
|
92
|
+
let cleaned = 0;
|
|
93
|
+
for (const ban of bans.values()) {
|
|
94
|
+
if (ban.is_active && ban.expires_at && new Date(ban.expires_at) <= new Date()) {
|
|
95
|
+
ban.is_active = false;
|
|
96
|
+
cleaned++;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return cleaned;
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
async shutdown() {
|
|
103
|
+
console.log('[InMemoryBanStore] Shutdown');
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -107,22 +107,29 @@ export interface BanCallbacks {
|
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Bans plugin configuration
|
|
110
|
+
*
|
|
111
|
+
* All properties are optional - plugin will use smart defaults:
|
|
112
|
+
* - store: Postgres ban store using registry's postgres instance
|
|
113
|
+
* - supportTemporary: true
|
|
114
|
+
* - api.prefix: '/bans'
|
|
115
|
+
* - api.enabled: true
|
|
116
|
+
* - debug: false
|
|
110
117
|
*/
|
|
111
118
|
export interface BansPluginConfig {
|
|
112
|
-
/** Ban storage backend */
|
|
113
|
-
store
|
|
114
|
-
/** Support temporary bans (with expiration) */
|
|
119
|
+
/** Ban storage backend (default: postgres ban store from registry) */
|
|
120
|
+
store?: BanStore;
|
|
121
|
+
/** Support temporary bans (with expiration) (default: true) */
|
|
115
122
|
supportTemporary?: boolean;
|
|
116
123
|
/** Callbacks */
|
|
117
124
|
callbacks?: BanCallbacks;
|
|
118
125
|
/** API configuration */
|
|
119
126
|
api?: {
|
|
120
|
-
/** API route prefix (default: '/
|
|
127
|
+
/** API route prefix (default: '/bans') */
|
|
121
128
|
prefix?: string;
|
|
122
|
-
/** Enable API endpoints */
|
|
129
|
+
/** Enable API endpoints (default: true) */
|
|
123
130
|
enabled?: boolean;
|
|
124
131
|
};
|
|
125
|
-
/** Enable debug logging */
|
|
132
|
+
/** Enable debug logging (default: false) */
|
|
126
133
|
debug?: boolean;
|
|
127
134
|
}
|
|
128
135
|
|
|
@@ -141,12 +141,12 @@ describe('Cache Plugin', () => {
|
|
|
141
141
|
expect(hasCache('test')).toBe(true);
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
it('should log
|
|
144
|
+
it('should log info message on successful connection', async () => {
|
|
145
145
|
const plugin = createCachePlugin(mockConfig, 'test');
|
|
146
146
|
await plugin.onStart({}, mockRegistry);
|
|
147
147
|
|
|
148
148
|
const logger = mockRegistry.getLogger('cache:test');
|
|
149
|
-
expect(logger.
|
|
149
|
+
expect(logger.info).toHaveBeenCalledWith(
|
|
150
150
|
expect.stringContaining('connected')
|
|
151
151
|
);
|
|
152
152
|
});
|