"""Health helpers for {{ module_title }}."""

from __future__ import annotations

from typing import Any, Dict, Mapping, Optional

from {{ module_import_base }}.inventory import {{ module_class_name }}
from {{ module_import_base }}.types.inventory import utc_now


def build_health_payload(
    *,
    service: Optional[{{ module_class_name }}] = None,
    extra: Optional[Mapping[str, Any]] = None,
) -> Dict[str, Any]:
    """Return a structured health payload for the inventory module."""

    inventory_service = service or {{ module_class_name }}()
    payload = inventory_service.health_check()
    payload.setdefault("checked_at", utc_now().isoformat())
    if extra:
        payload.setdefault("metadata", {}).update(dict(extra))
    return payload


def health_status(service: Optional[{{ module_class_name }}] = None) -> str:
    """Convenience wrapper returning the aggregate health status."""

    return build_health_payload(service=service)["status"]
