# Copyright (c) 2025 Patrick Motsch
# All rights reserved.
"""
Service Center Registry.
Service definitions, dependency graph, and RBAC object keys.
"""

from typing import Dict, List, Any

# Core services: internal building blocks, no RBAC, never requested by features
CORE_SERVICES: Dict[str, Dict[str, Any]] = {
    "utils": {
        "module": "modules.serviceCenter.core.serviceUtils.mainServiceUtils",
        "class": "UtilsService",
        "dependencies": [],
    },
    "security": {
        "module": "modules.serviceCenter.core.serviceSecurity.mainServiceSecurity",
        "class": "SecurityService",
        "dependencies": [],
    },
    "streaming": {
        "module": "modules.serviceCenter.core.serviceStreaming.mainServiceStreaming",
        "class": "StreamingService",
        "dependencies": [],
    },
}

# Importable services: feature-facing, RBAC-protected
IMPORTABLE_SERVICES: Dict[str, Dict[str, Any]] = {
    "ticket": {
        "module": "modules.serviceCenter.services.serviceTicket.mainServiceTicket",
        "class": "TicketService",
        "dependencies": [],
        "objectKey": "service.ticket",
        "label": "Ticket-System",
    },
    "messaging": {
        "module": "modules.serviceCenter.services.serviceMessaging.mainServiceMessaging",
        "class": "MessagingService",
        "dependencies": [],
        "objectKey": "service.messaging",
        "label": "Nachrichten",
    },
    "billing": {
        "module": "modules.serviceCenter.services.serviceBilling.mainServiceBilling",
        "class": "BillingService",
        "dependencies": ["subscription"],
        "objectKey": "service.billing",
        "label": "Abrechnung",
    },
    "subscription": {
        "module": "modules.serviceCenter.services.serviceSubscription.mainServiceSubscription",
        "class": "SubscriptionService",
        "dependencies": [],
        "objectKey": "service.subscription",
        "label": "Abonnement",
    },
    "sharepoint": {
        "module": "modules.serviceCenter.services.serviceSharepoint.mainServiceSharepoint",
        "class": "SharepointService",
        "dependencies": ["security"],
        "objectKey": "service.sharepoint",
        "label": "SharePoint",
    },
    "clickup": {
        "module": "modules.serviceCenter.services.serviceClickup.mainServiceClickup",
        "class": "ClickupService",
        "dependencies": ["security"],
        "objectKey": "service.clickup",
        "label": "ClickUp",
    },
    "chat": {
        "module": "modules.serviceCenter.services.serviceChat.mainServiceChat",
        "class": "ChatService",
        "dependencies": ["utils"],
        "objectKey": "service.chat",
        "label": "Chat",
    },
    "extraction": {
        "module": "modules.serviceCenter.services.serviceExtraction.mainServiceExtraction",
        "class": "ExtractionService",
        "dependencies": ["chat", "utils"],
        "objectKey": "service.extraction",
        "label": "Extraktion",
    },
    "generation": {
        "module": "modules.serviceCenter.services.serviceGeneration.mainServiceGeneration",
        "class": "GenerationService",
        "dependencies": ["utils", "chat"],
        "objectKey": "service.generation",
        "label": "Generierung",
    },
    "ai": {
        "module": "modules.serviceCenter.services.serviceAi.mainServiceAi",
        "class": "AiService",
        "dependencies": ["chat", "utils", "extraction", "billing"],
        "objectKey": "service.ai",
        "label": "KI",
    },
    "web": {
        "module": "modules.serviceCenter.services.serviceWeb.mainServiceWeb",
        "class": "WebService",
        "dependencies": ["ai", "chat", "utils"],
        "objectKey": "service.web",
        "label": "Web-Recherche",
    },
    "neutralization": {
        "module": "modules.features.neutralization.serviceNeutralization.mainServiceNeutralization",
        "class": "NeutralizationService",
        "dependencies": ["extraction", "generation"],
        "objectKey": "service.neutralization",
        "label": "Neutralisierung",
    },
    "agent": {
        "module": "modules.serviceCenter.services.serviceAgent.mainServiceAgent",
        "class": "AgentService",
        "dependencies": ["ai", "chat", "utils", "extraction", "billing", "streaming", "knowledge"],
        "objectKey": "service.agent",
        "label": "Agent",
    },
    "knowledge": {
        "module": "modules.serviceCenter.services.serviceKnowledge.mainServiceKnowledge",
        "class": "KnowledgeService",
        "dependencies": ["ai"],
        "objectKey": "service.knowledge",
        "label": "Wissensspeicher",
    },
}

# RBAC objects for service-level access control (for catalog registration)
SERVICE_RBAC_OBJECTS: List[Dict[str, Any]] = [
    {"objectKey": s["objectKey"], "label": s["label"]}
    for s in IMPORTABLE_SERVICES.values()
    if "objectKey" in s
]
