TorbatYar/backend/services/experience/app/commands/components.py
Mortezakoohjani 203671a7bf feat(experience): ship Experience Platform phases 11.0-11.10
Add the experience service with sites through analytics/AI hooks, migrations through 0011, and phase docs/manifests marking the track complete.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 11:43:10 +03:30

127 lines
3.9 KiB
Python

"""Component command handlers — Phase 11.2."""
from __future__ import annotations
from uuid import UUID
from sqlalchemy.ext.asyncio import AsyncSession
from app.schemas.components import (
ExperienceComponentCreate,
ExperienceComponentUpdate,
ExperienceComponentVersionCreate,
ExperienceComponentVersionUpdate,
PageComponentPlacementCreate,
PageComponentPlacementUpdate,
)
from app.services.components import ExperienceComponentService
from shared.security import CurrentUser
class ComponentCommands:
def __init__(self, session: AsyncSession) -> None:
self.service = ExperienceComponentService(session)
async def create_component(
self, tenant_id: UUID, body: ExperienceComponentCreate, *, actor: CurrentUser | None
):
return await self.service.create_component(tenant_id, body, actor=actor)
async def update_component(
self,
tenant_id: UUID,
component_id: UUID,
body: ExperienceComponentUpdate,
*,
actor: CurrentUser | None,
):
return await self.service.update_component(
tenant_id, component_id, body, actor=actor
)
async def activate_component(
self, tenant_id: UUID, component_id: UUID, *, actor: CurrentUser | None
):
return await self.service.activate_component(
tenant_id, component_id, actor=actor
)
async def deprecate_component(
self, tenant_id: UUID, component_id: UUID, *, actor: CurrentUser | None
):
return await self.service.deprecate_component(
tenant_id, component_id, actor=actor
)
async def archive_component(
self, tenant_id: UUID, component_id: UUID, *, actor: CurrentUser | None
):
return await self.service.archive_component(
tenant_id, component_id, actor=actor
)
async def soft_delete_component(
self, tenant_id: UUID, component_id: UUID, *, actor: CurrentUser | None
):
return await self.service.soft_delete_component(
tenant_id, component_id, actor=actor
)
async def create_version(
self,
tenant_id: UUID,
body: ExperienceComponentVersionCreate,
*,
actor: CurrentUser | None,
):
return await self.service.create_version(tenant_id, body, actor=actor)
async def update_version(
self,
tenant_id: UUID,
version_id: UUID,
body: ExperienceComponentVersionUpdate,
*,
actor: CurrentUser | None,
):
return await self.service.update_version(
tenant_id, version_id, body, actor=actor
)
async def publish_version(
self, tenant_id: UUID, version_id: UUID, *, actor: CurrentUser | None
):
return await self.service.publish_version(tenant_id, version_id, actor=actor)
async def retire_version(
self, tenant_id: UUID, version_id: UUID, *, actor: CurrentUser | None
):
return await self.service.retire_version(tenant_id, version_id, actor=actor)
async def create_placement(
self,
tenant_id: UUID,
body: PageComponentPlacementCreate,
*,
actor: CurrentUser | None,
):
return await self.service.create_placement(tenant_id, body, actor=actor)
async def update_placement(
self,
tenant_id: UUID,
placement_id: UUID,
body: PageComponentPlacementUpdate,
*,
actor: CurrentUser | None,
):
return await self.service.update_placement(
tenant_id, placement_id, body, actor=actor
)
async def soft_delete_placement(
self, tenant_id: UUID, placement_id: UUID, *, actor: CurrentUser | None
):
return await self.service.soft_delete_placement(
tenant_id, placement_id, actor=actor
)