Spaces:
Sleeping
Sleeping
File size: 1,653 Bytes
409c17a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
"""
Domain Layer - Interfaces (Ports)
Defines contracts for infrastructure implementations.
"""
from abc import ABC, abstractmethod
from typing import List, Optional
from uuid import UUID
from app.domain.entities import Document, DocumentChunk
class IDocumentRepository(ABC):
"""Repository interface for document persistence"""
@abstractmethod
async def create(self, document: Document) -> Document:
"""Create new document"""
pass
@abstractmethod
async def get_by_id(self, document_id: UUID) -> Optional[Document]:
"""Get document by ID"""
pass
@abstractmethod
async def update(self, document: Document) -> Document:
"""Update document"""
pass
@abstractmethod
async def list_by_department(
self, department: str, skip: int = 0, limit: int = 100
) -> List[Document]:
"""List documents by department"""
pass
@abstractmethod
async def delete(self, document_id: UUID) -> bool:
"""Delete document"""
pass
class IChunkRepository(ABC):
"""Repository interface for document chunks"""
@abstractmethod
async def create_bulk(self, chunks: List[DocumentChunk]) -> List[DocumentChunk]:
"""Create multiple chunks"""
pass
@abstractmethod
async def get_by_document_id(self, document_id: UUID) -> List[DocumentChunk]:
"""Get all chunks for a document"""
pass
@abstractmethod
async def delete_by_document_id(self, document_id: UUID) -> int:
"""Delete all chunks for a document"""
pass
|