import type { AdminRole, Permission } from './roles'

export type AuthUser = {
  id: string
  name: string
  email?: string
  role: AdminRole
}

export type AuthState = {
  user: AuthUser | null
  mode: 'demo' | 'real'
}

export type LoginResult = {
  user: AuthUser
  token?: string
}

export type AuthAdapter = {
  loginWithPassword(username: string, password: string): Promise<LoginResult>
  loginDemo(role?: AdminRole): Promise<LoginResult>
  logout(): Promise<void>
  switchRole(role: AdminRole): Promise<AuthUser>
  getCurrentUser(): Promise<AuthUser | null>
  hasPermission(role: AdminRole, permission: Permission): boolean
}
