""" Shared utilities and services for YAZ Care Platform """ import logging as _logging # Import from core authentication system (consolidating auth systems) try: from ..core.auth import AuthService, get_current_user, require_permission, require_role except ImportError: # Fallback for development def require_permission(perm): # type: ignore[attr-defined, misc, dict-item, abstract, type-var, union-attr] return lambda f: f def get_current_user(): # type: ignore[attr-defined, misc, dict-item, abstract, type-var, union-attr] return {"user_id": "dev", "roles": ["admin"], "permissions": ["all"]} def require_role(role): # type: ignore[attr-defined, misc, dict-item, abstract, type-var, union-attr] return lambda f: f AuthService = None # type: ignore[abstract, assignment, attr-defined, dict-item, misc, type-var, union-attr] # Database exports from .db import get_db_session # Logging exports (inline — no separate module needed) def get_logger(name: str) -> _logging.Logger: """Get a configured logger instance.""" return _logging.getLogger(name) def setup_logging(level: str = "INFO") -> None: """Set up basic logging configuration.""" _logging.basicConfig(level=getattr(_logging, level.upper(), _logging.INFO)) # Models exports (if they exist) try: from .models.schemas import ErrorResponse, PaginatedResponse, StandardResponse except ImportError: # Create minimal response models if they don't exist from typing import Any, Optional from pydantic import BaseModel class StandardResponse(BaseModel): # type: ignore[call-arg, call-overload, no-redef] success: bool = True message: str = "" data: Any | None = None class ErrorResponse(BaseModel): # type: ignore[call-arg, call-overload, no-redef] success: bool = False error: str details: str | None = None class PaginatedResponse(BaseModel): # type: ignore[call-arg, call-overload, no-redef] items: list = [] total: int = 0 page: int = 1 pages: int = 1 # Settings exports from .settings import get_settings __all__ = [ # Authentication (from core) "get_current_user", "require_permission", "require_role", "AuthService", # Database "get_db_session", # Logging "get_logger", "setup_logging", # Models "PaginatedResponse", "StandardResponse", "ErrorResponse", # Settings "get_settings", ]