"""Publishing, SEO and PWA command handlers — Phase 11.7."""
from __future__ import annotations

from uuid import UUID

from sqlalchemy.ext.asyncio import AsyncSession

from app.schemas.publishing import (
    DomainEdgeBindingCreate,
    DomainEdgeBindingUpdate,
    PublishReleaseCreate,
    PublishReleaseUpdate,
    PwaManifestUpdate,
    PwaManifestUpsert,
    RobotsShellUpdate,
    RobotsShellUpsert,
    SeoMetadataUpdate,
    SeoMetadataUpsert,
    SitemapShellUpdate,
    SitemapShellUpsert,
)
from app.services.publishing import ExperiencePublishingService
from shared.security import CurrentUser


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

    async def create_publish_release(self, tenant_id: UUID, body: PublishReleaseCreate, *, actor: CurrentUser | None):
        return await self.service.create_publish_release(tenant_id, body, actor=actor)

    async def update_publish_release(self, tenant_id: UUID, entity_id: UUID, body: PublishReleaseUpdate, *, actor: CurrentUser | None):
        return await self.service.update_publish_release(tenant_id, entity_id, body, actor=actor)

    async def create_domain_edge_binding(self, tenant_id: UUID, body: DomainEdgeBindingCreate, *, actor: CurrentUser | None):
        return await self.service.create_domain_edge_binding(tenant_id, body, actor=actor)

    async def update_domain_edge_binding(self, tenant_id: UUID, entity_id: UUID, body: DomainEdgeBindingUpdate, *, actor: CurrentUser | None):
        return await self.service.update_domain_edge_binding(tenant_id, entity_id, body, actor=actor)

    async def upsert_seo(self, tenant_id: UUID, body: SeoMetadataUpsert, *, actor: CurrentUser | None):
        return await self.service.upsert_seo(tenant_id, body, actor=actor)

    async def update_seo(self, tenant_id: UUID, entity_id: UUID, body: SeoMetadataUpdate, *, actor: CurrentUser | None):
        return await self.service.update_seo(tenant_id, entity_id, body, actor=actor)

    async def upsert_sitemap(self, tenant_id: UUID, body: SitemapShellUpsert, *, actor: CurrentUser | None):
        return await self.service.upsert_sitemap(tenant_id, body, actor=actor)

    async def update_sitemap(self, tenant_id: UUID, entity_id: UUID, body: SitemapShellUpdate, *, actor: CurrentUser | None):
        return await self.service.update_sitemap(tenant_id, entity_id, body, actor=actor)

    async def upsert_robots(self, tenant_id: UUID, body: RobotsShellUpsert, *, actor: CurrentUser | None):
        return await self.service.upsert_robots(tenant_id, body, actor=actor)

    async def update_robots(self, tenant_id: UUID, entity_id: UUID, body: RobotsShellUpdate, *, actor: CurrentUser | None):
        return await self.service.update_robots(tenant_id, entity_id, body, actor=actor)

    async def upsert_pwa(self, tenant_id: UUID, body: PwaManifestUpsert, *, actor: CurrentUser | None):
        return await self.service.upsert_pwa(tenant_id, body, actor=actor)

    async def update_pwa(self, tenant_id: UUID, entity_id: UUID, body: PwaManifestUpdate, *, actor: CurrentUser | None):
        return await self.service.update_pwa(tenant_id, entity_id, body, actor=actor)
