AP1.10b/10c: Entity Field System mit dynamischen Vorhaben-Zusatzfeldern.
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 1m54s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 15s

EFS-Tabellen, Registry-Sync und Fields-API ermöglichen archetyp-spezifische Felder; Frontend rendert sie im Profil-Modal per FieldRenderer.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-09 13:53:07 +02:00
1 parent 408050bcb8
commit a6fc86025c
23 files changed
+1107 -20

No files matched your search

+16 -2
View File
@@ -1,4 +1,4 @@
"""Entity-Archetypen API — AP1.10a (In-Memory-Registry bis 10b)."""
"""Entity-Archetypen API — AP1.10a/10b."""
from __future__ import annotations
@@ -6,7 +6,8 @@ from typing import Optional
from capabilities import require_capability
from entity_archetypes import list_archetypes
from fastapi import APIRouter, Depends, Query
from entity_fields.service import list_field_definitions
from fastapi import APIRouter, Depends, HTTPException, Query
from tenant_context import TenantContext
router = APIRouter(prefix="/api/entity-archetypes", tags=["entity-archetypes"])
@@ -19,3 +20,16 @@ def get_entity_archetypes(
):
_ = ctx
return list_archetypes(entity_type=entity_type)
@router.get("/field-definitions")
def get_archetype_field_definitions(
entity_type: str = Query(..., min_length=1),
archetype_key: str = Query(..., min_length=1),
ctx: TenantContext = Depends(require_capability("kairo.initiative.read")),
):
_ = ctx
archetypes = list_archetypes(entity_type=entity_type)
if not any(item["key"] == archetype_key for item in archetypes):
raise HTTPException(status_code=404, detail="Archetyp nicht gefunden")
return list_field_definitions(archetype_key=archetype_key)
+62
View File
@@ -7,6 +7,11 @@ from typing import Literal, Optional
from capabilities import require_capability
from data_layer import initiative_snapshot as dl_initiative_snapshot
from entity_fields.service import (
get_entity_field_values,
list_field_definitions,
patch_entity_field_values,
)
from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel, Field
from steering.context import get_steering_context_dto
@@ -46,6 +51,10 @@ class InitiativeUpdateRequest(BaseModel):
owner_actor_id: Optional[str] = None
class InitiativeFieldsPatchRequest(BaseModel):
fields: dict[str, object] = Field(default_factory=dict)
class ActionCreateRequest(BaseModel):
title: str = Field(min_length=1, max_length=255)
description: str = ""
@@ -194,6 +203,59 @@ def get_initiative_steering_context(
return get_steering_context_dto(ctx, initiative_id=initiative_id)
def _require_initiative(*, tenant_id: str, initiative_id: str) -> dict:
initiative = initiative_service.get_initiative(
tenant_id=tenant_id, initiative_id=initiative_id
)
if not initiative:
raise HTTPException(status_code=404, detail="Vorhaben nicht gefunden")
return initiative
@router.get("/{initiative_id}/field-definitions")
def get_initiative_field_definitions(
initiative_id: str,
ctx: TenantContext = Depends(require_capability("kairo.initiative.read")),
):
initiative = _require_initiative(tenant_id=ctx.tenant_id, initiative_id=initiative_id)
return list_field_definitions(archetype_key=initiative["archetype_key"])
@router.get("/{initiative_id}/fields")
def get_initiative_fields(
initiative_id: str,
ctx: TenantContext = Depends(require_capability("kairo.initiative.read")),
):
initiative = _require_initiative(tenant_id=ctx.tenant_id, initiative_id=initiative_id)
definitions = list_field_definitions(archetype_key=initiative["archetype_key"])
return get_entity_field_values(
tenant_id=ctx.tenant_id,
entity_type="initiative",
entity_id=initiative_id,
definitions=definitions,
)
@router.patch("/{initiative_id}/fields")
def patch_initiative_fields(
initiative_id: str,
body: InitiativeFieldsPatchRequest,
ctx: TenantContext = Depends(require_capability("kairo.initiative.manage")),
):
initiative = _require_initiative(tenant_id=ctx.tenant_id, initiative_id=initiative_id)
definitions = list_field_definitions(archetype_key=initiative["archetype_key"])
try:
return patch_entity_field_values(
tenant_id=ctx.tenant_id,
entity_type="initiative",
entity_id=initiative_id,
definitions=definitions,
values=body.fields,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
@router.patch("/{initiative_id}")
def update_initiative(
initiative_id: str,