// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

/**
 * Represents a Gitea user.
 */
export interface User {
  id: number;
  login: string;
  full_name: string;
  email: string;
  avatar_url: string;
  is_admin: boolean;
}

/**
 * Represents a Gitea repository.
 */
export interface Repository {
  id: number;
  name: string;
  full_name: string;
  owner?: User;
  description: string;
  private: boolean;
  fork: boolean;
  default_branch: string;
  stars_count: number;
  forks_count: number;
  clone_url: string;
  html_url: string;
}

/**
 * Represents a release attachment/asset.
 */
export interface Attachment {
  id: number;
  name: string;
  size: number;
  download_count: number;
  browser_download_url: string;
  created_at: string;
}

/**
 * Represents a Gitea release.
 */
export interface Release {
  id: number;
  tag_name: string;
  name: string;
  body: string;
  draft: boolean;
  prerelease: boolean;
  published_at: string;
  assets: Attachment[];
}

/**
 * Represents a chunked upload session.
 */
export interface UploadSession {
  id: string;
  file_name: string;
  file_size: number;
  chunk_size: number;
  total_chunks: number;
  chunks_received: number;
  status: 'pending' | 'uploading' | 'complete' | 'expired' | 'failed';
  expires_at: string;
  checksum?: string;
}

/**
 * Represents the result of a completed upload.
 */
export interface UploadResult {
  id: number;
  name: string;
  size: number;
  browser_download_url: string;
  checksum_verified: boolean;
}

/**
 * Represents upload progress.
 */
export interface Progress {
  /** Bytes uploaded so far */
  bytesDone: number;
  /** Total bytes to upload */
  bytesTotal: number;
  /** Number of chunks uploaded */
  chunksDone: number;
  /** Total number of chunks */
  chunksTotal: number;
  /** Percentage complete (0-100) */
  percent: number;
  /** Upload speed in bytes per second */
  speed: number;
  /** Estimated time remaining in milliseconds */
  eta: number;
}

/**
 * API error response from the server.
 */
export interface APIErrorResponse {
  code?: string;
  message: string;
  status?: number;
  details?: Record<string, unknown>;
}
