# 选择器节点

连接多个下游分支。只有当设定的条件满足时,相应的分支才会被执行。

# 数据结构定义

export interface ConditionNodeDef {
  id: INodeIDValue;
  type: WorkflowNodeTypeEnum.Condition;
  data: {
    title: string;
    inputsValues: {
      branches: [
        {
          id: INodeIDValue;                                 // 条件ID
          logic: IFlowConstantValue;                        // 逻辑操作符
          conditions: [
            {
              left: IFlowConstantValue | IFlowRefValue;     // 左操作数
              operator: IFlowConstantValue;                 // 操作符
              right: IFlowConstantValue | IFlowRefValue;    // 右操作数
            }
          ]
        }
      ],
    };
    inputs: IJsonSchema;                                    // 节点输入参数类型
  }
}

# 范例

{
  id: {random(6)},
  type: 'condition',
  data: {
    title: '选择器',
    inputsValues: {
      branches: [
        {
          id: {random(6)},                      // 条件ID
          logic: {                              // 逻辑操作符
            type: 'constant',
            content: 'and',
          },
          conditions: [
            {
              left: {                           // 左操作数
                type: 'ref',
                content: ['100001', 'query'],
              },
              operator: {                       // 操作符
                type: 'constant',
                content: 'equals',
              },
              right: {                          // 右操作数
                type: 'constant',
                content: 'Hello Flow.',
              }
            }
          ]
        },
        { 
          id: {random(6)},                      // 默认分支  
          logic: {
            type: 'constant',
            content: 'and',
          },
          conditions: []
        }
      ],
    },
    inputs: {
      type: 'object',
      properties: {
        branches: {
          type: 'array',
          items: {
            type: 'object',
            properties: {
              id: { type: 'string' },
              logic: { type: 'string' },
              conditions: {
                type: 'array',
                items: {
                  type: 'object',
                  properties: {
                    left: { type: 'string' },
                    operator: { type: 'string' },
                    right: { type: 'string' },
                  },
                },
              },
            },
          },
        },
      },
    },
  },
}