// ─────────────────────────────────────────────────────────────────────────────
// email-settings.types.ts
// Types + DTOs for the Email Settings (per-user SMTP) module.
// Mirrors the backend EmailSettingsEntity / DTOs.
// ─────────────────────────────────────────────────────────────────────────────

/** Encryption modes supported by the backend transporter. */
export type SmtpEncryption = "tls" | "ssl" | "none" | string;

/**
 * A single SMTP config row, as returned by the API.
 * NOTE: smtp_password comes back MASKED ("••••••••") from list/detail —
 * never the real secret.
 */
export interface EmailSetting {
  id: number;
  smtp_host: string;
  smtp_port: number;
  smtp_username: string;
  smtp_password: string; // masked in responses
  smtp_encryption: SmtpEncryption;
  from_email: string;
  from_name: string | null;
  user_id: number | null;
  created_at: string;
  updated_at: string;
}

/** Row shape used by the table (1:1 with EmailSetting + a display sno). */
export interface EmailSettingRow extends EmailSetting {
  sno: number;
}

/** Create / update payload. Password optional on update (blank = keep existing). */
export interface UpsertEmailSettingDto {
  smtp_host: string;
  smtp_port: number;
  smtp_username: string;
  smtp_password?: string;
  smtp_encryption: SmtpEncryption;
  from_email: string;
  from_name?: string | null;
  user_id?: number | null;
}

/** Body for the "send test email" action. */
export interface SendTestDto {
  to: string;
}

/** Standard paginated envelope used across modules (kept for parity). */
export interface PaginationMeta {
  total: number;
  page: number;
  limit: number;
  totalPages: number;
}
