# Copyright (c) 2025 Patrick Motsch # All rights reserved. """FeatureDataSource model for exposing feature instance data to the AI workspace. A FeatureDataSource links a FeatureInstance table (DATA_OBJECT) to a workspace so the agent can query structured feature data (e.g. TrusteePosition rows). """ from typing import Optional from pydantic import BaseModel, Field from modules.datamodels.datamodelBase import PowerOnModel from modules.shared.attributeUtils import registerModelLabels import uuid class FeatureDataSource(PowerOnModel): """A feature-instance table attached as data source in the AI workspace.""" id: str = Field(default_factory=lambda: str(uuid.uuid4()), description="Primary key") featureInstanceId: str = Field(description="FK to FeatureInstance") featureCode: str = Field(description="Feature code (e.g. trustee, commcoach)") tableName: str = Field(description="Table name from DATA_OBJECTS meta (e.g. TrusteePosition)") objectKey: str = Field(description="RBAC object key (e.g. data.feature.trustee.TrusteePosition)") label: str = Field(description="User-visible label") mandateId: str = Field(default="", description="Mandate scope") userId: str = Field(default="", description="Owner user ID") workspaceInstanceId: str = Field(description="Workspace instance where this source is used") scope: str = Field( default="personal", description="Data visibility scope: personal, featureInstance, mandate, global", json_schema_extra={"frontend_type": "select", "frontend_readonly": False, "frontend_required": False, "frontend_options": [ {"value": "personal", "label": {"en": "Personal", "de": "Persönlich"}}, {"value": "featureInstance", "label": {"en": "Feature Instance", "de": "Feature-Instanz"}}, {"value": "mandate", "label": {"en": "Mandate", "de": "Mandant"}}, {"value": "global", "label": {"en": "Global", "de": "Global"}}, ]} ) neutralize: bool = Field( default=False, description="Whether this data source should be neutralized before AI processing", json_schema_extra={"frontend_type": "checkbox", "frontend_readonly": False, "frontend_required": False} ) registerModelLabels( "FeatureDataSource", {"en": "Feature Data Source", "de": "Feature-Datenquelle", "fr": "Source de données fonctionnalité"}, { "id": {"en": "ID", "de": "ID", "fr": "ID"}, "featureInstanceId": {"en": "Feature Instance", "de": "Feature-Instanz", "fr": "Instance"}, "featureCode": {"en": "Feature", "de": "Feature", "fr": "Fonctionnalité"}, "tableName": {"en": "Table", "de": "Tabelle", "fr": "Table"}, "objectKey": {"en": "Object Key", "de": "Objekt-Schlüssel", "fr": "Clé objet"}, "label": {"en": "Label", "de": "Bezeichnung", "fr": "Libellé"}, "mandateId": {"en": "Mandate", "de": "Mandant", "fr": "Mandat"}, "userId": {"en": "User", "de": "Benutzer", "fr": "Utilisateur"}, "workspaceInstanceId": {"en": "Workspace", "de": "Workspace", "fr": "Espace de travail"}, }, )