import typing
from ebookwords.adapter.db.models import Book, Chapter, BookRecord, ChapterRecord

__all__ = ["Book", "Chapter", "DatabaseClient", "get_database_client"]


class DatabaseClient(typing.Protocol):
    def add_book(self, ebook: Book) -> None: ...
    def get_book_list(self) -> typing.Iterator[BookRecord]: ...
    def get_chapter_list(self, ebook_id: int) -> typing.Iterator[ChapterRecord]: ...
    def get_book(self, ebook_id: int) -> BookRecord | None: ...
    def get_chapter_paragraphs(
        self, ebook_id: int, chapter_number: int
    ) -> typing.Iterator[str]: ...


def get_database_client() -> DatabaseClient:
    from ebookwords.adapter.db import sql

    return sql.SqlDatabaseClient(".test/test.sqlite")
