export type UserStatus = 0 | 1 | 2 | 3

export interface SessionUser {
  id: number
  username: string
  email: string
  phone: string
  nickname: string
  avatar: string
  status: UserStatus
}

export interface TokenBundle {
  access_token: string
  refresh_token?: string
  expires_in: number
  user: SessionUser
}

export interface OAuthProviderInfo {
  provider: string
  name: string
  enabled?: boolean
  auth_url?: string
}

export interface OAuthAuthorizationResponse {
  auth_url: string
  state: string
}

export interface AuthCapabilities {
  password: boolean
  email_activation: boolean
  email_code: boolean
  sms_code: boolean
  password_reset: boolean
  admin_bootstrap_required: boolean
  oauth_providers: OAuthProviderInfo[]
}

export interface Role {
  id: number
  name: string
  code: string
  description: string
  is_system: boolean
  is_default: boolean
  status: 0 | 1
}

export interface LoginByPasswordRequest {
  username: string
  password: string
  device_id?: string
  device_name?: string
  device_browser?: string
  device_os?: string
}

export interface LoginByEmailCodeRequest {
  email: string
  code: string
}

export interface LoginBySmsCodeRequest {
  phone: string
  code: string
}

export interface RegisterRequest {
  username: string
  password: string
  email?: string
  phone?: string
  phone_code?: string
  nickname?: string
}

export interface BootstrapAdminRequest {
  username: string
  password: string
  email?: string
  nickname?: string
}

export interface RegisterResponse {
  user: SessionUser
  message: string
}

export interface ActionMessageResponse {
  message: string
}

export interface SendEmailCodeRequest {
  email: string
  scene?: string
}

export interface SendSmsCodeRequest {
  phone: string
  purpose?: string
}

export interface ResendActivationEmailRequest {
  email: string
}

export interface ForgotPasswordRequest {
  email: string
}

export interface ResetPasswordRequest {
  token: string
  new_password: string
  confirm_password: string
}

export interface ValidateResetTokenResponse {
  valid: boolean
  email?: string
  expires_at?: string
}
