// ═══════════════════════════════════════════════════════════
// Error Constants — from CONTRACTS.md §1.3, §7.1
// ═══════════════════════════════════════════════════════════

import type { ErrorCode } from "../types/api.js";

/** Error code to HTTP status mapping */
export const ERROR_STATUS_MAP: Record<ErrorCode, number> = {
  BAD_REQUEST:          400,
  VALIDATION_ERROR:     400,
  UNAUTHORIZED:         401,
  FORBIDDEN:            403,
  NOT_FOUND:            404,
  CONFLICT:             409,
  GONE:                 410,
  RATE_LIMITED:         429,
  INTERNAL_ERROR:       500,
  SERVICE_UNAVAILABLE:  503,
  TIMEOUT:              504,
};

/** Status codes that are safe to retry */
export const RETRYABLE_STATUS_CODES = [408, 429, 500, 502, 503, 504] as const;

/** Default retry policy */
export const DEFAULT_RETRY_POLICY = {
  maxRetries: 3,
  baseDelayMs: 1000,
  maxDelayMs: 30000,
  jitterMs: 500,
} as const;
