"""DobbyStore protocol definition."""

from typing import Protocol

from dobby.models import Project, Result, Task


class DobbyStore(Protocol):
    async def initialize(self) -> None: ...
    async def close(self) -> None: ...

    # Tasks
    async def create_task(self, task: Task) -> str: ...
    async def get_task(self, task_id: str) -> Task: ...
    async def update_task(self, task_id: str, **fields) -> None: ...
    async def list_tasks(
        self, project: str | None = None, status: str | None = None,
        search: str | None = None, sort: str = "created_at",
    ) -> list[Task]: ...
    async def get_pending_tasks(self, limit: int = 10) -> list[Task]: ...
    async def get_scheduled_tasks(self) -> list[Task]: ...
    async def list_tasks_by_batch(self, batch_id: str) -> list[Task]: ...
    async def list_batches(self) -> list[dict]: ...

    async def get_dependent_tasks(self, task_id: str) -> list[Task]: ...

    # Results
    async def store_result(self, result: Result) -> None: ...
    async def get_result(self, task_id: str) -> Result | None: ...
    async def list_results(
        self, project: str | None = None, task_id: str | None = None, last_n: int | None = None
    ) -> list[Result]: ...

    # Projects
    async def register_project(self, project: Project) -> None: ...
    async def get_project(self, name: str) -> Project | None: ...
    async def list_projects(self) -> list[Project]: ...
