feat: accept nested local capability maps
This commit is contained in:
@@ -37,7 +37,6 @@ from wf_core.models.steps import (
|
||||
from wf_core.models.workflow_refs import WorkflowRef
|
||||
|
||||
from .draft_options import (
|
||||
_parse_map_flags,
|
||||
_parse_output_map_flags,
|
||||
_parse_route_flags,
|
||||
_parse_step_input_map_flags,
|
||||
@@ -149,11 +148,12 @@ def add_step_from_capability(
|
||||
`wf draft add capability report_ws --revision 1 --step render
|
||||
--capability local.report.render --route ok=__end__`
|
||||
|
||||
Repeat the flag for multiple bindings:
|
||||
`--input state.title=title --input state.summary=summary`
|
||||
Local input targets are rootless node-local paths. Repeat the flag for
|
||||
multiple bindings:
|
||||
`--input state.title=report.title --input state.summary=report.summary`
|
||||
`--bind-output title=state.title --bind-output summary=state.summary`
|
||||
"""
|
||||
input_map = _parse_map_flags(input_mapping)
|
||||
input_map = _parse_step_input_map_flags(input_mapping, option_name="--input")
|
||||
bind_outputs = _parse_output_map_flags(output_mapping)
|
||||
routes = _parse_route_flags(route)
|
||||
context = load_cli_context(ctx)
|
||||
|
||||
@@ -64,7 +64,7 @@ def _parse_output_map_flags(
|
||||
def _parse_step_input_map_flags(
|
||||
values: list[str] | None, *, option_name: str = "--map"
|
||||
) -> dict[str, str]:
|
||||
"""Parse graph-source to bare-local input mappings for one draft step."""
|
||||
"""Parse graph-source to rootless node-local mappings for one draft step."""
|
||||
parsed = _parse_assignment_flags(
|
||||
values,
|
||||
option_name=option_name,
|
||||
@@ -74,9 +74,16 @@ def _parse_step_input_map_flags(
|
||||
if target.startswith("local."):
|
||||
bare_target = target.removeprefix("local.")
|
||||
raise typer.BadParameter(
|
||||
f"{option_name} target must be a bare local field; "
|
||||
f"{option_name} target must be a rootless node-local path; "
|
||||
f"use {source}={bare_target}, not {source}={target}"
|
||||
)
|
||||
try:
|
||||
LocalPath.parse(target)
|
||||
except PathResolutionError as exc:
|
||||
raise typer.BadParameter(
|
||||
f"{option_name} target must be a rootless node-local path; "
|
||||
f"got {target!r}; use report.title or ."
|
||||
) from exc
|
||||
return parsed
|
||||
|
||||
|
||||
|
||||
@@ -399,7 +399,10 @@ def set_step_input_map(
|
||||
--map entries in one command for a complete replacement. Use --merge only
|
||||
when adding or updating entries across a later revision.
|
||||
|
||||
Targets are bare node-local field names. Use `--map input.text=text`, not
|
||||
Targets are rootless node-local paths. For example, use
|
||||
`--map input.title=report.title`, not
|
||||
`--map input.title=local.report.title`.
|
||||
Single-field targets remain valid: use `--map input.text=text`, not
|
||||
`--map input.text=local.text`.
|
||||
|
||||
Run `wf draft validate <workspace_id>` after map edits; validation reports
|
||||
@@ -536,11 +539,17 @@ def bind_draft(
|
||||
step_id: Annotated[str, typer.Option("--step", help="Draft step id.")],
|
||||
source_path: Annotated[
|
||||
str,
|
||||
typer.Option("--from", help="Source path, for example input.x or local.y."),
|
||||
typer.Option(
|
||||
"--from",
|
||||
help="Explicit source endpoint, such as input.title or local.report.title.",
|
||||
),
|
||||
],
|
||||
target_path: Annotated[
|
||||
str,
|
||||
typer.Option("--to", help="Target path, for example local.x or state.y."),
|
||||
typer.Option(
|
||||
"--to",
|
||||
help="Explicit target endpoint, such as local.report.title or state.x.",
|
||||
),
|
||||
],
|
||||
) -> None:
|
||||
"""Bind a capability step path and project missing schema when needed.
|
||||
@@ -549,6 +558,8 @@ def bind_draft(
|
||||
state/output for step outputs. If the workflow schema field already exists,
|
||||
the command reuses it and updates the step binding. For pure input-map edits
|
||||
where schema is already known, `wf draft set-input --merge` is also valid.
|
||||
Bind endpoints are rooted, including nested paths such as
|
||||
`input.title -> local.report.title`.
|
||||
Run `wf draft validate <workspace_id>` after this command.
|
||||
"""
|
||||
context = load_cli_context(ctx)
|
||||
|
||||
Reference in New Issue
Block a user