"""Load demand_belong_category associations."""
from __future__ import annotations

from typing import Any

from supply_infra.db.repositories.demand_belong_category_repo import (
    DemandBelongCategoryRepository,
)
from supply_infra.db.session import get_session


def list_demand_belong_categories() -> list[dict[str, Any]]:
    """Return all active demand ↔ category rows."""
    with get_session() as session:
        repo = DemandBelongCategoryRepository(session)
        rows = repo.list_active()
        return [
            {
                "id": row.id,
                "name": row.name,
                "category_id": row.category_id,
                "reason": row.reason,
            }
            for row in rows
        ]
