# Copyright (c) 2025 Patrick Motsch
# All rights reserved.
"""
Service Center Context.
Minimal context passed to services: user, mandate, feature instance, workflow.
"""

from dataclasses import dataclass
from typing import Any, Optional

from modules.datamodels.datamodelUam import User


@dataclass
class ServiceCenterContext:
    """Context for service resolution: user, mandate, feature instance, optional workflow."""

    user: User
    mandate_id: Optional[str] = None
    feature_instance_id: Optional[str] = None
    workflow_id: Optional[str] = None
    workflow: Any = None
    requireNeutralization: Optional[bool] = None
    # When workflow is absent (e.g. workspace agent), billing/UI still need feature code for transactions.
    feature_code: Optional[str] = None

    @property
    def mandateId(self) -> Optional[str]:
        """Alias for mandate_id (backward compatibility)."""
        return self.mandate_id

    @property
    def featureInstanceId(self) -> Optional[str]:
        """Alias for feature_instance_id (backward compatibility)."""
        return self.feature_instance_id
