import { SetMetadata } from '@nestjs/common';

export const PERMISSION_METADATA_KEY = 'ftb:required-permission';

export interface PermissionScopeOptions {
  productIdParam?: string;
  projectIdParam?: string;
  versionIdParam?: string;
  productIdBody?: string;
  projectIdBody?: string;
  versionIdBody?: string;
}

export interface RequiredPermissionMetadata extends PermissionScopeOptions {
  permission: string;
}

export function RequirePermission(permission: string, scope: PermissionScopeOptions = {}) {
  return SetMetadata(PERMISSION_METADATA_KEY, { permission, ...scope });
}
