- HERENCIA-SIMCO.md actualizado con directivas v3.7 y v3.8 - Actualizaciones de configuracion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
212 lines
10 KiB
JavaScript
212 lines
10 KiB
JavaScript
"use strict";
|
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.SuperadminController = void 0;
|
|
const common_1 = require("@nestjs/common");
|
|
const swagger_1 = require("@nestjs/swagger");
|
|
const superadmin_service_1 = require("./superadmin.service");
|
|
const dto_1 = require("./dto");
|
|
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
|
|
const permissions_guard_1 = require("../rbac/guards/permissions.guard");
|
|
let SuperadminController = class SuperadminController {
|
|
constructor(superadminService) {
|
|
this.superadminService = superadminService;
|
|
}
|
|
async getDashboardStats() {
|
|
return this.superadminService.getDashboardStats();
|
|
}
|
|
async listTenants(query) {
|
|
return this.superadminService.listTenants(query);
|
|
}
|
|
async getTenant(id) {
|
|
return this.superadminService.getTenant(id);
|
|
}
|
|
async createTenant(dto) {
|
|
return this.superadminService.createTenant(dto);
|
|
}
|
|
async updateTenant(id, dto) {
|
|
return this.superadminService.updateTenant(id, dto);
|
|
}
|
|
async updateTenantStatus(id, dto) {
|
|
return this.superadminService.updateTenantStatus(id, dto);
|
|
}
|
|
async deleteTenant(id) {
|
|
return this.superadminService.deleteTenant(id);
|
|
}
|
|
async getTenantUsers(id, page = 1, limit = 10) {
|
|
return this.superadminService.getTenantUsers(id, page, limit);
|
|
}
|
|
async getMetricsSummary() {
|
|
return this.superadminService.getMetricsSummary();
|
|
}
|
|
async getTenantGrowth(months = 12) {
|
|
return this.superadminService.getTenantGrowth(months);
|
|
}
|
|
async getUserGrowth(months = 12) {
|
|
return this.superadminService.getUserGrowth(months);
|
|
}
|
|
async getPlanDistribution() {
|
|
return this.superadminService.getPlanDistribution();
|
|
}
|
|
async getStatusDistribution() {
|
|
return this.superadminService.getStatusDistribution();
|
|
}
|
|
async getTopTenants(limit = 10) {
|
|
return this.superadminService.getTopTenants(limit);
|
|
}
|
|
};
|
|
exports.SuperadminController = SuperadminController;
|
|
__decorate([
|
|
(0, common_1.Get)('dashboard/stats'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get dashboard statistics' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Dashboard statistics' }),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", []),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getDashboardStats", null);
|
|
__decorate([
|
|
(0, common_1.Get)('tenants'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'List all tenants with pagination' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Paginated list of tenants' }),
|
|
__param(0, (0, common_1.Query)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [dto_1.ListTenantsQueryDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "listTenants", null);
|
|
__decorate([
|
|
(0, common_1.Get)('tenants/:id'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get tenant by ID' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Tenant details with stats' }),
|
|
(0, swagger_1.ApiResponse)({ status: 404, description: 'Tenant not found' }),
|
|
__param(0, (0, common_1.Param)('id')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getTenant", null);
|
|
__decorate([
|
|
(0, common_1.Post)('tenants'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Create a new tenant' }),
|
|
(0, swagger_1.ApiResponse)({ status: 201, description: 'Tenant created' }),
|
|
(0, swagger_1.ApiResponse)({ status: 409, description: 'Slug already exists' }),
|
|
__param(0, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [dto_1.CreateTenantDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "createTenant", null);
|
|
__decorate([
|
|
(0, common_1.Patch)('tenants/:id'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Update tenant details' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Tenant updated' }),
|
|
(0, swagger_1.ApiResponse)({ status: 404, description: 'Tenant not found' }),
|
|
__param(0, (0, common_1.Param)('id')),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, dto_1.UpdateTenantDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "updateTenant", null);
|
|
__decorate([
|
|
(0, common_1.Patch)('tenants/:id/status'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Update tenant status (suspend/activate)' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Status updated' }),
|
|
(0, swagger_1.ApiResponse)({ status: 404, description: 'Tenant not found' }),
|
|
__param(0, (0, common_1.Param)('id')),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, dto_1.UpdateTenantStatusDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "updateTenantStatus", null);
|
|
__decorate([
|
|
(0, common_1.Delete)('tenants/:id'),
|
|
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Delete a tenant' }),
|
|
(0, swagger_1.ApiResponse)({ status: 204, description: 'Tenant deleted' }),
|
|
(0, swagger_1.ApiResponse)({ status: 400, description: 'Cannot delete tenant with users' }),
|
|
(0, swagger_1.ApiResponse)({ status: 404, description: 'Tenant not found' }),
|
|
__param(0, (0, common_1.Param)('id')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "deleteTenant", null);
|
|
__decorate([
|
|
(0, common_1.Get)('tenants/:id/users'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get users for a specific tenant' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Paginated list of tenant users' }),
|
|
(0, swagger_1.ApiResponse)({ status: 404, description: 'Tenant not found' }),
|
|
__param(0, (0, common_1.Param)('id')),
|
|
__param(1, (0, common_1.Query)('page')),
|
|
__param(2, (0, common_1.Query)('limit')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, Object, Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getTenantUsers", null);
|
|
__decorate([
|
|
(0, common_1.Get)('metrics'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get all metrics summary' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Complete metrics summary' }),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", []),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getMetricsSummary", null);
|
|
__decorate([
|
|
(0, common_1.Get)('metrics/tenant-growth'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get tenant growth over time' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Tenant growth by month' }),
|
|
__param(0, (0, common_1.Query)('months')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getTenantGrowth", null);
|
|
__decorate([
|
|
(0, common_1.Get)('metrics/user-growth'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get user growth over time' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'User growth by month' }),
|
|
__param(0, (0, common_1.Query)('months')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getUserGrowth", null);
|
|
__decorate([
|
|
(0, common_1.Get)('metrics/plan-distribution'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get plan distribution' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Distribution of plans' }),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", []),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getPlanDistribution", null);
|
|
__decorate([
|
|
(0, common_1.Get)('metrics/status-distribution'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get tenant status distribution' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Distribution of tenant statuses' }),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", []),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getStatusDistribution", null);
|
|
__decorate([
|
|
(0, common_1.Get)('metrics/top-tenants'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Get top tenants by user count' }),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Top tenants list' }),
|
|
__param(0, (0, common_1.Query)('limit')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], SuperadminController.prototype, "getTopTenants", null);
|
|
exports.SuperadminController = SuperadminController = __decorate([
|
|
(0, swagger_1.ApiTags)('superadmin'),
|
|
(0, common_1.Controller)('superadmin'),
|
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, permissions_guard_1.PermissionsGuard),
|
|
(0, permissions_guard_1.RequireRoles)('superadmin'),
|
|
(0, swagger_1.ApiBearerAuth)(),
|
|
__metadata("design:paramtypes", [superadmin_service_1.SuperadminService])
|
|
], SuperadminController);
|
|
//# sourceMappingURL=superadmin.controller.js.map
|