from typing import Any from modules.interfaces.interfaceAppModel import User from modules.interfaces.interfaceChatModel import ChatWorkflow from modules.services.serviceWorkflows.mainServiceWorkflows import WorkflowService 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): self.user: User = user self.workflow: ChatWorkflow = workflow # Directly expose existing service modules from .serviceDocument.mainServiceDocumentExtraction import DocumentExtractionService self.document = PublicService(DocumentExtractionService(self)) from .serviceDocument.mainServiceDocumentGeneration import DocumentGenerationService self.document = PublicService(DocumentGenerationService(self)) from .serviceNeutralization.mainNeutralization import NeutralizationService self.neutralization = PublicService(NeutralizationService()) from .serviceSharepoint.mainSharepoint import SharePointService self.sharepoint = PublicService(SharePointService(self)) from .serviceAi.mainServiceAi import AiService self.ai = PublicService(AiService(self)) from .serviceWorkflows.mainServiceWorkflows import WorkflowService self.workflow = PublicService(WorkflowService(self)) # Initialize chat interface for workflow operations from modules.interfaces.interfaceChatObjects import getInterface as getChatInterface self.chatInterface = getChatInterface(user) # Chat interface wrapper methods def getWorkflow(self, workflowId: str): return self.chatInterface.getWorkflow(workflowId) def createWorkflow(self, workflowData: dict): return self.chatInterface.createWorkflow(workflowData) def updateWorkflow(self, workflowId: str, workflowData: dict): return self.chatInterface.updateWorkflow(workflowId, workflowData) def createMessage(self, messageData: dict): return self.chatInterface.createMessage(messageData) def updateMessage(self, messageId: str, messageData: dict): return self.chatInterface.updateMessage(messageId, messageData) def createLog(self, logData: dict): return self.chatInterface.createLog(logData) def updateWorkflowStats(self, workflowId: str, bytesSent: int = 0, bytesReceived: int = 0, tokenCount: int = 0): return self.chatInterface.updateWorkflowStats(workflowId, bytesSent, bytesReceived, tokenCount) @property def mandateId(self): return self.chatInterface.mandateId def getInterface(user: User, workflow: ChatWorkflow) -> Services: return Services(user, workflow)