/**
 * User Impersonation module — types and schemas.
 * Admin-only: temporarily act as another user for debugging.
 * All impersonation sessions are audit-logged.
 */

import { z } from 'zod';

export interface ImpersonationSessionDoc {
  id: string;
  productId: string;
  adminUserId: string; // the admin performing impersonation
  targetUserId: string; // the user being impersonated
  reason: string;
  active: boolean;
  startedAt: string;
  endedAt: string | null;
  createdAt: string;
}

// ── Schemas ────────────────────────────────────────────────────

export const StartImpersonationSchema = z.object({
  targetUserId: z.string().min(1),
  reason: z.string().min(1).max(500),
});

export const StopImpersonationSchema = z.object({
  sessionId: z.string().min(1),
});

export type StartImpersonationInput = z.infer<typeof StartImpersonationSchema>;
