import { hc } from 'hono/client';
import type { AppType } from '@d8d/auth-module-mt';

/**
 * 认证API客户端
 * 基于Hono Client的RPC调用，提供类型安全的API调用
 */
export const authClient = hc<AppType>('/');

/**
 * 认证API端点配置
 */
export const authEndpoints = {
  login: '/auth/login',
  logout: '/auth/logout',
  me: '/auth/me',
  register: '/auth/register'
} as const;

/**
 * 认证错误类型
 */
export type AuthError = {
  message: string;
  code?: string;
  status?: number;
};

/**
 * 登录请求参数
 */
export interface LoginRequest {
  username: string;
  password: string;
}

/**
 * 登录响应
 */
export interface LoginResponse {
  token: string;
  user: {
    id: number;
    username: string;
    email: string;
    role: {
      id: number;
      name: string;
    };
  };
}

/**
 * 用户信息
 */
export interface UserInfo {
  id: number;
  username: string;
  email: string;
  role: {
    id: number;
    name: string;
  };
  createdAt: string;
  updatedAt: string;
}