from __future__ import annotations

from app.modules.rag.contracts import RagDocument
from app.modules.rag.persistence.repository import RagRepository


class RagDocumentUpserter:
    def __init__(self, repository: RagRepository) -> None:
        self._repository = repository

    def replace(self, rag_session_id: str, docs: list[RagDocument]) -> None:
        self._repository.replace_documents(rag_session_id, docs)

    def apply_changes(self, rag_session_id: str, delete_paths: list[str], docs: list[RagDocument]) -> None:
        self._repository.apply_document_changes(rag_session_id, delete_paths, docs)
