from typing import Any from modules.interfaces.interfaceAppModel import User from modules.interfaces.interfaceChatModel import ChatWorkflow class PublicService: """Lightweight proxy exposing only public callable attributes of a target. - Hides names starting with '_' - Optionally restricts to callables only - Optional name_filter predicate for allow-list patterns """ def __init__(self, target: Any, functions_only: bool = True, name_filter=None): self._target = target self._functions_only = functions_only self._name_filter = name_filter def __getattr__(self, name: str): if name.startswith('_'): raise AttributeError(f"'{type(self._target).__name__}' attribute '{name}' is private") if self._name_filter and not self._name_filter(name): raise AttributeError(f"'{name}' not exposed by policy") attr = getattr(self._target, name) if self._functions_only and not callable(attr): raise AttributeError(f"'{name}' is not a function") return attr def __dir__(self): names = [ n for n in dir(self._target) if not n.startswith('_') and (not self._functions_only or callable(getattr(self._target, n, None))) and (self._name_filter(n) if self._name_filter else True) ] return sorted(names) class Services: def __init__(self, user: User, workflow: ChatWorkflow = None): self.user: User = user self.workflow: ChatWorkflow = workflow # Initialize interfaces from modules.interfaces.interfaceChatObjects import getInterface as getChatInterface self.interfaceChat = getChatInterface(user) from modules.interfaces.interfaceAppObjects import getInterface as getAppInterface self.interfaceApp = getAppInterface(user) from modules.interfaces.interfaceComponentObjects import getInterface as getComponentInterface self.interfaceComponent = getComponentInterface(user) # Initialize service packages from .serviceDocument.mainServiceDocumentExtraction import DocumentExtractionService self.documentExtraction = PublicService(DocumentExtractionService(self)) from .serviceDocument.mainServiceDocumentGeneration import DocumentGenerationService self.documentGeneration = PublicService(DocumentGenerationService(self)) from .serviceNeutralization.mainServiceNeutralization import NeutralizationService self.neutralization = PublicService(NeutralizationService(self)) from .serviceSharepoint.mainServiceSharepoint import SharepointService self.sharepoint = PublicService(SharepointService(self)) from .serviceAi.mainServiceAi import AiService self.ai = PublicService(AiService(self)) from .serviceTicket.mainServiceTicket import TicketService self.ticket = PublicService(TicketService(self)) from .serviceWorkflow.mainServiceWorkflow import WorkflowService self.workflow = PublicService(WorkflowService(self)) def getInterface(user: User, workflow: ChatWorkflow) -> Services: return Services(user, workflow)