"""Server response mappers.

Convert domain models (from server_service) to response models (for HTTP API).

This is the mapping layer at the router boundary, ensuring the service layer
remains independent of HTTP response shapes.
"""

from __future__ import annotations

from app.models.server import ServerSettings, ServerSettingsResponse, ServerSettingsUpdate
from app.models.server_domain import DomainServerSettings, DomainServerSettingsResult
from app.utils.pagination import create_pagination_metadata


def map_domain_server_settings_to_response(
    domain_settings: DomainServerSettings,
) -> ServerSettings:
    """Convert domain server settings to response model."""
    return ServerSettings(
        log_level=domain_settings.log_level,
        log_target=domain_settings.log_target,
        syslog_socket=domain_settings.syslog_socket,
        db_path=domain_settings.db_path,
        db_purge_age=domain_settings.db_purge_age,
        db_max_matches=domain_settings.db_max_matches,
    )


def map_domain_server_settings_result_to_response(
    domain_result: DomainServerSettingsResult,
) -> ServerSettingsResponse:
    """Convert domain server settings result to response model."""
    return ServerSettingsResponse(
        settings=map_domain_server_settings_to_response(domain_result.settings),
        warnings=domain_result.warnings,
    )
