template-saas/apps/backend/dist/modules/rbac/services/rbac.service.d.ts
rckrdmrd 26f0e52ca7 feat: Initial commit - template-saas
Template base para proyectos SaaS multi-tenant.

Estructura inicial:
- apps/backend (NestJS API)
- apps/frontend (React/Vite)
- apps/database (PostgreSQL DDL)
- docs/ (Documentación)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:41:24 -06:00

32 lines
2.0 KiB
TypeScript

import { Repository } from 'typeorm';
import { Role, Permission, UserRole, RolePermission } from '../entities';
import { CreateRoleDto, UpdateRoleDto, AssignRoleDto } from '../dto';
export declare class RbacService {
private readonly roleRepository;
private readonly permissionRepository;
private readonly userRoleRepository;
private readonly rolePermissionRepository;
constructor(roleRepository: Repository<Role>, permissionRepository: Repository<Permission>, userRoleRepository: Repository<UserRole>, rolePermissionRepository: Repository<RolePermission>);
createRole(dto: CreateRoleDto, tenantId: string): Promise<Role>;
updateRole(roleId: string, dto: UpdateRoleDto, tenantId: string): Promise<Role>;
deleteRole(roleId: string, tenantId: string): Promise<void>;
findAllRoles(tenantId: string): Promise<Role[]>;
findRoleById(roleId: string, tenantId: string): Promise<Role>;
getRoleWithPermissions(roleId: string, tenantId: string): Promise<{
role: Role;
permissions: Permission[];
}>;
findAllPermissions(): Promise<Permission[]>;
findPermissionsByCategory(category: string): Promise<Permission[]>;
getRolePermissions(roleId: string): Promise<Permission[]>;
setRolePermissions(roleId: string, permissionCodes: string[], tenantId: string): Promise<void>;
assignRoleToUser(dto: AssignRoleDto, tenantId: string, assignedBy: string): Promise<UserRole>;
removeRoleFromUser(userId: string, roleId: string, tenantId: string): Promise<void>;
getUserRoles(userId: string, tenantId: string): Promise<Role[]>;
getUserPermissions(userId: string, tenantId: string): Promise<Permission[]>;
userHasPermission(userId: string, tenantId: string, permissionCode: string): Promise<boolean>;
userHasAnyPermission(userId: string, tenantId: string, permissionCodes: string[]): Promise<boolean>;
userHasAllPermissions(userId: string, tenantId: string, permissionCodes: string[]): Promise<boolean>;
userHasRole(userId: string, tenantId: string, roleCode: string): Promise<boolean>;
}