/**
 * Unified request types for authentication context.
 *
 * Replaces the previously scattered interfaces:
 * - RequestWithSession (auth.controller.ts)
 * - AuthRequest (auth.guard.ts)
 * - BetterAuthRequest (this file, removed)
 * - RequestWithUser (current-user.decorator.ts)
 */

import type { Request } from "express";
import type { AuthUser } from "@mosaic/shared";

// Re-export AuthUser for use in other modules
export type { AuthUser };

/**
 * Session data stored in request after authentication
 */
export interface RequestSession {
  id: string;
  token: string;
  expiresAt: Date;
  [key: string]: unknown;
}

/**
 * Request that may or may not have auth data (before guard runs).
 * Used by AuthGuard and other middleware that processes requests
 * before authentication is confirmed.
 */
export interface MaybeAuthenticatedRequest extends Request {
  user?: AuthUser;
  session?: Record<string, unknown>;
}

/**
 * Request with authenticated user attached by AuthGuard.
 * After AuthGuard runs, user and session are guaranteed present.
 * Use this type in controllers/decorators that sit behind AuthGuard.
 */
export interface AuthenticatedRequest extends Request {
  user: AuthUser;
  session: RequestSession;
}
