"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.AdminRbacController = void 0;
const common_1 = require("@nestjs/common");
const admin_rbac_service_1 = require("./admin-rbac.service");
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
const permissions_guard_1 = require("../auth/guards/permissions.guard");
const permissions_decorator_1 = require("../auth/decorators/permissions.decorator");
let AdminRbacController = class AdminRbacController {
    constructor(service) {
        this.service = service;
    }
    getRoles() { return this.service.getRoles(); }
    createRole(dto) { return this.service.createRole(dto); }
    deleteRole(id) { return this.service.deleteRole(id); }
    getPermissions() { return this.service.getPermissions(); }
    createPermission(dto) { return this.service.createPermission(dto); }
    deletePermission(id) { return this.service.deletePermission(id); }
    getRolePermissions(roleId) { return this.service.getRolePermissions(roleId); }
    assignPermission(roleId, permId) {
        return this.service.assignPermission(roleId, permId);
    }
    revokePermission(id) { return this.service.revokePermission(id); }
    seed() { return this.service.seedDefaultPermissions(); }
};
exports.AdminRbacController = AdminRbacController;
__decorate([
    (0, common_1.Get)("roles"),
    (0, permissions_decorator_1.RequirePermission)("rbac.read"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "getRoles", null);
__decorate([
    (0, common_1.Post)("roles"),
    (0, permissions_decorator_1.RequirePermission)("rbac.write"),
    (0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "createRole", null);
__decorate([
    (0, common_1.Delete)("roles/:id"),
    (0, permissions_decorator_1.RequirePermission)("rbac.write"),
    __param(0, (0, common_1.Param)("id")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "deleteRole", null);
__decorate([
    (0, common_1.Get)("permissions"),
    (0, permissions_decorator_1.RequirePermission)("rbac.read"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "getPermissions", null);
__decorate([
    (0, common_1.Post)("permissions"),
    (0, permissions_decorator_1.RequirePermission)("rbac.write"),
    (0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "createPermission", null);
__decorate([
    (0, common_1.Delete)("permissions/:id"),
    (0, permissions_decorator_1.RequirePermission)("rbac.write"),
    __param(0, (0, common_1.Param)("id")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "deletePermission", null);
__decorate([
    (0, common_1.Get)("roles/:roleId/permissions"),
    (0, permissions_decorator_1.RequirePermission)("rbac.read"),
    __param(0, (0, common_1.Param)("roleId")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "getRolePermissions", null);
__decorate([
    (0, common_1.Post)("roles/:roleId/permissions"),
    (0, permissions_decorator_1.RequirePermission)("rbac.write"),
    (0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
    __param(0, (0, common_1.Param)("roleId")),
    __param(1, (0, common_1.Body)("permission_id")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "assignPermission", null);
__decorate([
    (0, common_1.Delete)("permissions/:id/revoke"),
    (0, permissions_decorator_1.RequirePermission)("rbac.write"),
    __param(0, (0, common_1.Param)("id")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "revokePermission", null);
__decorate([
    (0, common_1.Post)("seed"),
    (0, permissions_decorator_1.RequirePermission)("rbac.write"),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AdminRbacController.prototype, "seed", null);
exports.AdminRbacController = AdminRbacController = __decorate([
    (0, common_1.Controller)("admin/rbac"),
    (0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, permissions_guard_1.PermissionsGuard),
    __metadata("design:paramtypes", [admin_rbac_service_1.AdminRbacService])
], AdminRbacController);
//# sourceMappingURL=admin-rbac.controller.js.map