"""Abstract release provider and data models."""

from abc import ABC, abstractmethod
from dataclasses import dataclass


@dataclass(frozen=True)
class AssetInfo:
    """A single downloadable asset attached to a release."""

    name: str
    size: int
    download_url: str


@dataclass(frozen=True)
class ReleaseInfo:
    """A single release from the hosting platform."""

    tag: str
    version: str
    name: str
    body: str
    prerelease: bool
    published_at: str
    assets: tuple[AssetInfo, ...]


class ReleaseProvider(ABC):
    """Platform-agnostic interface for querying releases.

    Implement this for Gitea, GitHub, GitLab, etc.
    """

    @abstractmethod
    async def get_releases(self, limit: int = 10) -> list[ReleaseInfo]:
        """Fetch recent releases, newest first."""

    @abstractmethod
    def get_releases_page_url(self) -> str:
        """Return the user-facing URL of the releases page."""