import { apiClient } from '@/infrastructure/api/api-client';
import type { Role } from '@/domain/entities/role';

export interface PermissionMatrix {
  roles: Role[];
  allPermissions: string[];
}

export async function getPermissionMatrix(): Promise<PermissionMatrix> {
  return apiClient<PermissionMatrix>('/api/v1/auth/permissions/matrix');
}

export async function updateRolePermissions(roleId: string, permissions: string[]): Promise<void> {
  await apiClient(`/api/v1/auth/roles/${roleId}/permissions`, {
    method: 'PUT',
    body: { permissions },
  });
}

export async function listRoles(): Promise<Role[]> {
  return apiClient<Role[]>('/api/v1/auth/roles');
}
