export interface ApiClientConfig {
  baseUrl: string;
  getToken?: () => string | null;
  defaultHeaders?: Record<string, string>;
  /** Request timeout in milliseconds. Default: 10000 (10s). Set 0 to disable. */
  timeoutMs?: number;
  /** Max retries for idempotent requests (GET/HEAD/OPTIONS). Default: 2. */
  retries?: number;
  /** Base delay in ms for exponential backoff between retries. Default: 500. */
  retryDelayMs?: number;
}

export interface ApiResult<T> {
  data: T | null;
  error: string | null;
}

export interface ApiClient {
  /**
   * Fetch that throws on error — use when caller handles errors.
   */
  fetch<T>(path: string, options?: RequestInit): Promise<T>;

  /**
   * Safe fetch that never throws — returns { data, error } tuple.
   */
  safeFetch<T>(path: string, options?: RequestInit): Promise<ApiResult<T>>;
}
