/**
 * API Types
 * Type definitions for API layer
 */

/**
 * Generic API Result
 */
export interface ApiResult<T = unknown> {
  readonly url: string;
  readonly ok: boolean;
  readonly status: number;
  readonly statusText: string;
  readonly body: T;
}

/**
 * API Request Options
 */
export interface ApiRequestOptions {
  readonly method:
    | 'GET'
    | 'PUT'
    | 'POST'
    | 'DELETE'
    | 'OPTIONS'
    | 'HEAD'
    | 'PATCH';
  readonly url: string;
  readonly path?: Record<string, unknown>;
  readonly cookies?: Record<string, unknown>;
  readonly headers?: Record<string, string>;
  readonly query?: Record<string, string | number | boolean | string[]>;
  readonly formData?: Record<string, string | Blob | File>;
  readonly body?: unknown;
  readonly mediaType?: string;
  readonly responseHeader?: string;
  readonly errors?: Record<number, string>;
}

/**
 * API Error
 */
export interface ApiErrorData {
  readonly url: string;
  readonly status: number;
  readonly statusText: string;
  readonly body: unknown;
}

/**
 * Base Response from API
 * 统一使用 snake_case 字段命名，code 为 string 类型
 */
export interface BaseApiResponse<T = unknown> {
  code?: string;
  message?: string;
  data?: T;
  meta?: {
    request_id?: string;
    timestamp?: string;
    api_version?: string;
    page?: number;
    page_size?: number;
    total?: number;
    total_pages?: number;
  };
}
