// ── Error Codes ───────────────────────────────────────────────────────────────

export const ServiceErrorCode = {
  NETWORK_ERROR: 'network_error',
  UNAUTHORIZED: 'unauthorized',
  FORBIDDEN: 'forbidden',
  VALIDATION_ERROR: 'validation_error',
  NOT_FOUND: 'not_found',
  AI_GENERATION_FAILED: 'ai_generation_failed',
  BACKEND_UNAVAILABLE: 'backend_unavailable',
} as const
export type ServiceErrorCode = typeof ServiceErrorCode[keyof typeof ServiceErrorCode]

export interface ServiceError {
  code: ServiceErrorCode
  message: string
  details?: unknown
}

// ── Pagination ────────────────────────────────────────────────────────────────

export interface Pagination {
  total: number
  page: number
  pageSize: number
  hasMore: boolean
}

/** @deprecated Use Pagination */
export type ServiceMeta = Pagination

// ── Response Shapes ───────────────────────────────────────────────────────────

export interface ServiceResponse<T> {
  data: T
  meta?: Pagination
  pagination?: Pagination
  error?: ServiceError | string | null
}

export type ListResponse<T> = ServiceResponse<T[]>
export type ItemResponse<T> = ServiceResponse<T>
