"""
Base Service Abstract Classes

Service layer abstractions for application and domain services.
"""

from abc import ABC
from typing import TypeVar, Generic, Optional
from uuid import UUID


class BaseService(ABC):
    """
    Abstract base class for domain services.
    
    Domain services are stateless and contain business logic
    that doesn't naturally fit within an entity or value object.
    
    Rules:
    - Must be stateless
    - No infrastructure dependencies
    - Only business logic
    - No persistence operations
    """
    
    pass


class BaseApplicationService(ABC):
    """
    Abstract base class for application services.
    
    Application services coordinate between use cases,
    manage transactions, and handle infrastructure-dependent tasks.
    
    Rules:
    - Coordinate multiple use cases
    - Handle infrastructure-dependent tasks
    - No business logic (delegate to domain)
    - No validation (handled by use cases)
    """
    
    pass


T = TypeVar('T')


class BaseCRUDService(Generic[T], ABC):
    """
    Base service providing standard CRUD operations.
    
    Provides a template for common CRUD operations
    that can be extended for specific entities.
    """
    
    def create(self, data: dict) -> T:
        """
        Create a new entity.
        
        Args:
            data: Dictionary with entity fields
            
        Returns:
            The created entity
        """
        raise NotImplementedError
    
    def get(self, id: UUID) -> Optional[T]:
        """
        Get entity by ID.
        
        Args:
            id: Entity UUID
            
        Returns:
            Entity if found, None otherwise
        """
        raise NotImplementedError
    
    def update(self, id: UUID, data: dict) -> Optional[T]:
        """
        Update an existing entity.
        
        Args:
            id: Entity UUID
            data: Fields to update
            
        Returns:
            Updated entity if found, None otherwise
        """
        raise NotImplementedError
    
    def delete(self, id: UUID) -> bool:
        """
        Delete an entity.
        
        Args:
            id: Entity UUID
            
        Returns:
            True if deleted, False if not found
        """
        raise NotImplementedError
    
    def list(self, **filters) -> list[T]:
        """
        List entities with optional filters.
        
        Args:
            **filters: Filter criteria
            
        Returns:
            List of matching entities
        """
        raise NotImplementedError
