Rename planner and document rewrite: rewrite_documents moves qualified names of the renamed flow in every flow (ports, inputs, outputs) and dashboard binding (one key table, WIDGET_BINDINGS, shared with the WidgetDef accessors, legacy pages included), published and draft, as plain JSON with both variants above either version; plan_rename reports documents, counts, fingerprint, warnings and refusals; superuser plan routes for flows and dashboards; key residue classifies state as the mapper does; duplicate retargets inputs and outputs too; queue reports its Redis version and other consumers

This commit is contained in:
2026-11-02 21:06:39 +01:00
parent 81bd7c2724
commit fa2a213631
14 changed files with 1922 additions and 41 deletions
+34
View File
@@ -16,8 +16,10 @@ from fluksio.api.deps import (
DashboardStoreDep,
FlowControllerDep,
check_pin,
get_current_active_superuser,
get_current_user,
)
from fluksio.api.routes.alerts import read_config as read_alerts_config
from fluksio.flow.dashboards import (
DashboardCreate,
DashboardDef,
@@ -28,6 +30,7 @@ from fluksio.flow.dashboards import (
results_dashboard,
)
from fluksio.flow.events import event_bus
from fluksio.flow.rename import RenamePlan, RenamePlanRequest, plan_rename
from fluksio.flow.store import FlowNotFound, IdTaken, StaleVersion
from fluksio.models import Message
@@ -245,3 +248,34 @@ async def duplicate_dashboard(dashboard_id: str, store: DashboardStoreDep) -> An
return await run_in_threadpool(store.duplicate, dashboard_id)
except DashboardNotFound:
raise _missing(dashboard_id)
@router.post(
"/{dashboard_id}/rename/plan",
response_model=RenamePlan,
dependencies=[Depends(get_current_active_superuser)],
)
async def plan_dashboard_rename(
dashboard_id: str,
body: RenamePlanRequest,
store: DashboardStoreDep,
controller: FlowControllerDep,
) -> Any:
"""What renaming this dashboard's key would change, and what refuses it.
Changes nothing. Nothing binds to a dashboard's key, so the plan is the
dashboard alone; a superuser's all the same, as a flow's is.
"""
try:
return await run_in_threadpool(
lambda: plan_rename(
controller,
store,
"dashboard",
dashboard_id,
body.new_name,
read_alerts_config(),
)
)
except DashboardNotFound:
raise _missing(dashboard_id)
+36
View File
@@ -32,6 +32,7 @@ from fluksio.api.deps import (
CAMERA_IS_SUPERUSERS,
CODE_IS_SUPERUSERS,
CurrentUser,
DashboardStoreDep,
FlowControllerDep,
HiddenDep,
SessionDep,
@@ -39,10 +40,12 @@ from fluksio.api.deps import (
check_pin,
decode_token,
get_code_author,
get_current_active_superuser,
get_current_user,
hidden_from,
user_from_token,
)
from fluksio.api.routes.alerts import read_config as read_alerts_config
from fluksio.api.routes.messages import port_source
from fluksio.api.socket_auth import TICKET_TTL_S, issue_ticket, socket_token
from fluksio.core.config import settings
@@ -66,6 +69,7 @@ from fluksio.flow.events import event_bus
from fluksio.flow.messages import MEDIA_FAMILIES, DType, flow_of, qualify
from fluksio.flow.nodes.wren import TRAIN_FLOW, WrenNode, pack_meta
from fluksio.flow.pipeline import EngineHeld, ValidationIssue
from fluksio.flow.rename import RenamePlan, RenamePlanRequest, plan_rename
from fluksio.flow.runs import RunRejected
from fluksio.flow.schemas import (
NAME_PATTERN,
@@ -740,6 +744,38 @@ async def duplicate_flow(
return await run_in_threadpool(_detail, controller, copy)
@router.post(
"/{flow_id}/rename/plan",
response_model=RenamePlan,
dependencies=[Depends(get_current_active_superuser)],
)
async def plan_flow_rename(
flow_id: str,
body: RenamePlanRequest,
controller: FlowControllerDep,
dashboards: DashboardStoreDep,
) -> Any:
"""What renaming this flow's key would change, and what refuses it.
Changes nothing. A superuser's, as the rename is: the key names the
flow's messages, and renaming it rewrites every flow and dashboard that
names one, its history and its live state.
"""
try:
return await run_in_threadpool(
lambda: plan_rename(
controller,
dashboards,
"flow",
flow_id,
body.new_name,
read_alerts_config(),
)
)
except FlowNotFound:
raise _missing(flow_id)
# -----------------------------------------------------------------------------
# Node source
# -----------------------------------------------------------------------------