API and persisted records use PowerOnModel system fields: - sysCreatedAt, sysCreatedBy, sysModifiedAt, sysModifiedBy Removed legacy JSON/DB field names: - _createdAt, _createdBy, _modifiedAt, _modifiedBy Frontend (frontend_nyla) and gateway call sites were updated accordingly. Database: - Bootstrap runs idempotent backfill (_migrateSystemFieldColumns) from old underscore columns and selected business duplicates into sys* where sys* IS NULL. - Re-run app bootstrap against each PostgreSQL database after deploy. - Optional: DROP INDEX IF EXISTS "idx_invitation_createdby" if an old index remains; new index: idx_invitation_syscreatedby on Invitation(sysCreatedBy). Tests: - RBAC integration tests aligned with current GROUP mandate filter and UserMandate-based UserConnection GROUP clause; buildRbacWhereClause(..., mandateId=...) must be passed explicitly (same as production request context).
58 lines
3.1 KiB
Python
58 lines
3.1 KiB
Python
# 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"},
|
|
},
|
|
)
|