跳到主要内容

条件节点(type = "condition")

用于基于表达式进行多分支路由,后续边通过 sourcePortID 连接到不同后继节点。

Schema

  • 参考: ConditionNode.json
  • 核心字段:
    • data.conditions:数组,每个元素代表一个分支
      • key:分支端口 ID,对应 Edge 的 sourcePortID
      • value:条件表达式(left / operator / right

示例

通过 sourcePortID 路由到不同 End:

{
"nodes": [
{
"id": "start_0",
"type": "start",
"data": { "outputs": { "type": "object", "properties": { "query": { "type": "string" } } } }
},
{
"id": "condition_0",
"type": "condition",
"data": {
"title": "Condition",
"conditions": [
{
"key": "A",
"value": {
"left": { "type": "ref", "content": ["start_0", "query"] },
"operator": "contains",
"right": { "type": "constant", "content": "foo" }
}
},
{
"key": "B",
"value": {
"left": { "type": "ref", "content": ["start_0", "query"] },
"operator": "contains",
"right": { "type": "constant", "content": "bar" }
}
}
]
}
},
{
"id": "end_a",
"type": "end",
"data": {
"inputs": { "type": "object", "properties": { "result": { "type": "string" } } },
"inputsValues": { "result": { "type": "constant", "content": "branch A" } }
}
},
{
"id": "end_b",
"type": "end",
"data": {
"inputs": { "type": "object", "properties": { "result": { "type": "string" } } },
"inputsValues": { "result": { "type": "constant", "content": "branch B" } }
}
}
],
"edges": [
{ "sourceNodeID": "start_0", "targetNodeID": "condition_0" },
{ "sourceNodeID": "condition_0", "sourcePortID": "A", "targetNodeID": "end_a" },
{ "sourceNodeID": "condition_0", "sourcePortID": "B", "targetNodeID": "end_b" }
]
}