@dbs-portal/module-tenant-management
v1.0.0
Published
Tenant management and multi-tenancy support module
Maintainers
Readme
@dbs-portal/module-tenant-management
A comprehensive multi-tenancy management module for DBS Portal, providing tenant CRUD operations, context switching, analytics, feature management, and backup/restore capabilities.
Features
🏢 Tenant Management
- Complete CRUD operations for tenant entities
- Tenant activation/deactivation with status tracking
- Bulk operations for multiple tenants
- Tenant cloning with configurable options
- Connection string management and testing
🔄 Multi-Tenant Context
- Seamless tenant switching with context preservation
- Tenant-aware React context provider
- Automatic tenant detection and validation
- Tenant isolation and security boundaries
📊 Analytics & Monitoring
- Comprehensive tenant analytics dashboard
- Usage metrics and growth tracking
- Performance monitoring and uptime statistics
- Revenue analytics and user engagement metrics
⚙️ Feature Management
- Dynamic feature flag management per tenant
- Feature expiration and lifecycle management
- Granular feature configuration with typed values
- Feature dependency and requirement tracking
💾 Backup & Restore
- Automated and manual backup creation
- Multiple backup types (full, incremental, differential)
- Backup scheduling and retention policies
- One-click restore with data validation
🎨 Advanced UI Components
- TenantDetail: Comprehensive tenant information display
- TenantSwitcher: Multi-tenant context switcher with search
- TenantAnalytics: Real-time analytics dashboard
- TenantFeatureManager: Feature flag management interface
- TenantBackupManager: Backup and restore operations
- Tenant CRUD Operations: Create, read, update, and delete tenants
- Feature Management: Configure tenant-specific features and limitations
- Connection Management: Manage tenant database connections
- Analytics Dashboard: Tenant usage statistics and analytics
- Tenant Switching: Easy tenant context switching for administrators
Installation
yarn add @dbs-portal/module-tenant-managementUsage
import {
TenantList,
TenantForm,
TenantDetail,
useTenants,
TenantProvider
} from '@dbs-portal/module-tenant-management'
// Wrap your app with TenantProvider
function App() {
return (
<TenantProvider>
<TenantList />
</TenantProvider>
)
}
// Use tenant hooks
function TenantComponent() {
const { data: tenants, isLoading } = useTenants()
return (
<div>
{tenants?.map(tenant => (
<div key={tenant.id}>{tenant.name}</div>
))}
</div>
)
}Components
Core Components
TenantList- List all tenants with filtering and paginationTenantForm- Create/edit tenant form with validationTenantDetail- Detailed tenant information and statisticsTenantSwitcher- Tenant context switching component
Advanced Components
TenantFeatureManager- Manage tenant-specific featuresTenantAnalytics- Tenant usage analytics dashboardTenantConnectionManager- Database connection managementTenantBackupRestore- Backup and restore functionality
Hooks
Data Hooks
useTenants()- Fetch tenants with paginationuseTenant(id)- Fetch single tenantuseCreateTenant()- Create new tenantuseUpdateTenant()- Update existing tenantuseDeleteTenant()- Delete tenant
Feature Hooks
useTenantFeatures(id)- Manage tenant featuresuseTenantAnalytics(id)- Get tenant analyticsuseTenantConnections(id)- Manage connectionsuseCurrentTenant()- Get current tenant context
Services
TenantService- Core tenant CRUD operationsTenantFeatureService- Feature managementTenantAnalyticsService- Analytics and reportingTenantConnectionService- Connection management
Types
interface Tenant {
id: string
name: string
displayName: string
connectionString?: string
isActive: boolean
features: TenantFeature[]
createdAt: Date
updatedAt: Date
}
interface TenantFeature {
name: string
isEnabled: boolean
value?: any
expiresAt?: Date
}Multi-tenancy Support
This module provides complete multi-tenancy support including:
- Tenant Isolation: Complete data separation between tenants
- Feature Flags: Per-tenant feature configuration
- Resource Limits: Configurable limits per tenant
- Analytics: Usage tracking and reporting
- Backup/Restore: Tenant-specific data management
Dependencies
@dbs-portal/core-shared- Shared types and utilities@dbs-portal/core-api- API client functionality@dbs-portal/core-ui- UI components and themes@dbs-portal/core-store- State management@dbs-portal/core-auth- Authentication integration@dbs-portal/module-identity- User and role management
License
MIT
