p2: old style deprecated support + wf_authoring to use new stuff

holy moly file changes
This commit is contained in:
lda
2026-05-20 17:47:37 +07:00 Verified
parent 3683c23937
commit 1a2349e017
28 changed files with 702 additions and 137 deletions
+7 -4
View File
@@ -12,15 +12,16 @@ from wf_core.models.conditions import (
PathOperand,
VariadicCondition,
)
from wf_core.paths import GraphSourcePath
from .paths import GraphPath, context_path, input_path, state_path
def _operand(value: object) -> PathOperand | LiteralOperand:
if isinstance(value, PathExpr):
return PathOperand(path=value.path)
return PathOperand(path=GraphSourcePath.parse(value.path))
if isinstance(value, GraphPath):
return PathOperand(path=value.value)
return PathOperand(path=GraphSourcePath.parse(value.value))
return LiteralOperand(value=value)
@@ -61,7 +62,7 @@ class PathExpr:
return Expr(
BinaryCondition(
op=op,
left=PathOperand(path=self.path),
left=PathOperand(path=GraphSourcePath.parse(self.path)),
right=_operand(other),
)
)
@@ -126,7 +127,9 @@ def context(field: str) -> PathExpr:
def exists(value: PathExpr | GraphPath) -> Expr:
return Expr(ExistsCondition(op="exists", path=_path_str(value)))
return Expr(
ExistsCondition(op="exists", path=GraphSourcePath.parse(_path_str(value)))
)
def not_(value: Condition | Expr) -> Expr:
+12 -6
View File
@@ -2,11 +2,17 @@ from __future__ import annotations
from dataclasses import dataclass
from wf_core.paths import GraphSourcePath
@dataclass(frozen=True, slots=True)
class GraphPath:
value: str
def __post_init__(self) -> None:
"""Validate authoring paths at construction so invalid roots fail early."""
object.__setattr__(self, "value", str(GraphSourcePath.parse(self.value)))
def __str__(self) -> str:
return self.value
@@ -15,13 +21,13 @@ def graph_path(value: str) -> GraphPath:
return GraphPath(value)
def input_path(field: str) -> GraphPath:
return GraphPath(f"input.{field}")
def input_path(*parts: str) -> GraphPath:
return GraphPath(str(GraphSourcePath.input(*parts)))
def state_path(field: str) -> GraphPath:
return GraphPath(f"state.{field}")
def state_path(*parts: str) -> GraphPath:
return GraphPath(str(GraphSourcePath.state(*parts)))
def context_path(field: str) -> GraphPath:
return GraphPath(f"context.{field}")
def context_path(*parts: str) -> GraphPath:
return GraphPath(str(GraphSourcePath.context(*parts)))