import { SetMetadata } from "@nestjs/common";
import type { Permission } from "@customer-portal/domain/auth";

export const REQUIRED_PERMISSIONS_KEY = "requiredPermissions";

/**
 * Decorator to require specific permissions for a route.
 *
 * @example
 * ```typescript
 * @RequirePermissions(PERMISSIONS.ADMIN_USERS)
 * @Get('admin/users')
 * listUsers() { ... }
 * ```
 *
 * @example
 * ```typescript
 * // Require any of the specified permissions
 * @RequirePermissions(PERMISSIONS.BILLING_READ, PERMISSIONS.ADMIN_AUDIT)
 * @Get('billing/summary')
 * getBillingSummary() { ... }
 * ```
 */
export const RequirePermissions = (...permissions: Permission[]) =>
  SetMetadata(REQUIRED_PERMISSIONS_KEY, permissions);
