import type { WorkspaceMemberRole } from "@prisma/client";

/**
 * User types for authentication context
 * These represent the authenticated user from BetterAuth
 */

/**
 * Authenticated user from BetterAuth session
 */
export interface AuthenticatedUser {
  id: string;
  email: string;
  name: string | null;
  workspaceId?: string;
  currentWorkspaceId?: string;
  workspaceRole?: WorkspaceMemberRole;
}

/**
 * Workspace context attached to request by WorkspaceGuard
 */
export interface WorkspaceContext {
  id: string;
}

/**
 * Session context from BetterAuth
 */
export type SessionContext = Record<string, unknown>;

/**
 * Extended request type with user authentication context
 * Used in controllers with @Request() decorator
 */
export interface AuthenticatedRequest {
  user?: AuthenticatedUser;
  session?: SessionContext;
  workspace?: WorkspaceContext;
  ip?: string;
  headers: Record<string, string | string[] | undefined>;
  method: string;
  params: Record<string, string>;
  body: Record<string, unknown>;
}

/**
 * Request with guaranteed user context (after AuthGuard)
 */
export interface RequestWithAuth extends AuthenticatedRequest {
  user: AuthenticatedUser;
  session: SessionContext;
}

/**
 * Request with guaranteed workspace context (after WorkspaceGuard)
 */
export interface RequestWithWorkspace extends RequestWithAuth {
  workspace: WorkspaceContext;
}
