"""Component query handlers — Phase 11.2."""
from __future__ import annotations

from uuid import UUID

from sqlalchemy.ext.asyncio import AsyncSession

from app.services.components import ExperienceComponentService
from app.specifications.components import (
    ComponentListSpec,
    ComponentVersionListSpec,
    PlacementListSpec,
)


class ComponentQueries:
    def __init__(self, session: AsyncSession) -> None:
        self.service = ExperienceComponentService(session)

    async def get_component(self, tenant_id: UUID, component_id: UUID):
        return await self.service.get_component(tenant_id, component_id)

    async def list_components(
        self,
        tenant_id: UUID,
        *,
        offset: int,
        limit: int,
        spec: ComponentListSpec | None,
    ):
        return await self.service.list_components(
            tenant_id, offset=offset, limit=limit, spec=spec
        )

    async def get_version(self, tenant_id: UUID, version_id: UUID):
        return await self.service.get_version(tenant_id, version_id)

    async def list_versions(
        self,
        tenant_id: UUID,
        *,
        offset: int,
        limit: int,
        spec: ComponentVersionListSpec | None,
    ):
        return await self.service.list_versions(
            tenant_id, offset=offset, limit=limit, spec=spec
        )

    async def get_placement(self, tenant_id: UUID, placement_id: UUID):
        return await self.service.get_placement(tenant_id, placement_id)

    async def list_placements(
        self,
        tenant_id: UUID,
        *,
        offset: int,
        limit: int,
        spec: PlacementListSpec | None,
    ):
        return await self.service.list_placements(
            tenant_id, offset=offset, limit=limit, spec=spec
        )
