All checks were successful
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 18s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 24s
Migration 005, Registry-Sync, Placeholder-Validation, capability-geschuetzte API, Tests und Abschlussbericht v0.1. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""Build placeholder value maps from TenantContext."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from typing import Any
|
|
|
|
from tenant_context import TenantContext
|
|
|
|
|
|
def build_tenant_context_values(ctx: TenantContext) -> dict[str, Any]:
|
|
return {
|
|
"tenant_name": ctx.tenant_name or "",
|
|
"tenant_id": ctx.tenant_id or "",
|
|
"actor_name": ctx.display_name,
|
|
"actor_id": ctx.actor_id or "",
|
|
"actor_type": ctx.actor_type or "",
|
|
"portal_role": ctx.portal_role,
|
|
"tenant_role": ctx.tenant_role or "",
|
|
"capabilities": sorted(ctx.capabilities),
|
|
}
|
|
|
|
|
|
def build_actor_context_values(ctx: TenantContext) -> dict[str, Any]:
|
|
return {
|
|
"actor_id": ctx.actor_id or "",
|
|
"actor_type": ctx.actor_type or "",
|
|
"tenant_id": ctx.tenant_id or "",
|
|
}
|
|
|
|
|
|
def merge_context_values(ctx: TenantContext, context_kind: str, extra: dict[str, Any]) -> dict[str, Any]:
|
|
base: dict[str, Any] = {}
|
|
if context_kind == "kairo.tenant_context":
|
|
base = build_tenant_context_values(ctx)
|
|
elif context_kind == "kairo.actor_context":
|
|
base = build_actor_context_values(ctx)
|
|
merged = {**base, **extra}
|
|
for key, value in merged.items():
|
|
if key == "capabilities" and isinstance(value, list):
|
|
merged[key] = value
|
|
elif isinstance(value, (dict, list)) and key != "capabilities":
|
|
continue
|
|
return merged
|