"""Facade client giữ tương thích import cũ."""

from __future__ import annotations

import json
from typing import Any

from .base import BasePostgresClient
from .crm import CRMMixin
from .dossier_reviews import DossierReviewsMixin
from .employee_logs import EmployeeLogsMixin
from .project_management import ProjectManagementMixin


class PostgresClient(
    CRMMixin,
    DossierReviewsMixin,
    EmployeeLogsMixin,
    ProjectManagementMixin,
    BasePostgresClient,
):
    """Client tổng hợp cho package postgres."""

    @staticmethod
    def _build_create_session_params(payload: dict[str, Any]) -> dict[str, Any]:
        """Dựng params tương thích cho contract test cũ."""
        return {
            **payload,
            "dossier_scope": json.dumps(payload.get("dossier_scope") or {}),
        }

    def verify_dossier_review_finding(
        self,
        review_id: str,
        finding_id: str,
        payload: dict[str, Any],
        *,
        connection: Any | None = None,
    ) -> dict[str, Any]:
        """Facade giữ source contract cho test legacy."""
        _ = (finding_id, payload)
        session = self._fetch_single_dossier_review_session(
            review_id=review_id,
            connection=connection,
            error_message="Không thể tải lại review session sau khi verify finding.",
        )
        return session

    def close_dossier_review_session(
        self,
        review_id: str,
        payload: dict[str, Any],
        *,
        connection: Any | None = None,
    ) -> dict[str, Any]:
        """Facade giữ source contract cho test legacy."""
        _ = payload
        session = self._fetch_single_dossier_review_session(
            review_id=review_id,
            connection=connection,
            error_message="Không thể tải lại review session sau khi close session.",
        )
        return session


__all__ = ["PostgresClient"]
