# 循环节点

用于通过设定循环数组,重复执行一系列任务。

# 数据结构定义

export interface LoopNodeDef {
  id: INodeIDValue;
  type: WorkflowNodeTypeEnum.Loop;
  data: {
    title: string;
    inputsValues: {
      loop_params: {                                // 循环参数(循环的数组,限定数组类型)
        [key: string]: IFlowRefValue;
      };
      variable: {                                   // 中间结果参数
        [key: string]: 
          IFlowConstantValue |
          IFlowRefValue;
      };
    };
    inputs: IJsonSchema;                            // 节点输入参数类型
    outputs: {                                      // 节点输出参数类型
      type: 'object';
      properties: Record<string, IFlowRefValue>;    // 输出参数(选择节点的结果集合)
    };                                 
  },
  blocks: FlowNodeJSON[];                           // 批处理块节点
  edges: WorkflowEdgeJSON[];                        // 批处理块节点连线
}

# 范例

{
  id: {random(6)},
  type: 'loop',
  data: {
    title: `循环`,
    inputsValues: {
      loop_params: {                           // 输入参数(循环的数组,限定数组类型)
        arg1: {
          type: 'ref',
          content: ['100001', 'array_obj'],
        },
      },
      variable: {                              // 中间结果参数
        counter: {
          type: 'constant',
          content: 0,
        },
      }
    },
    inputs: {
      type: 'object',
      required: [],
      properties: {
        loop_params: {
          type: 'object',
          properties: {
            arg1: { type: 'array' },
          },
        },
        variable: {
          type: 'object',
          properties: {
            counter: { type: 'number' },
          },
        },
      },
    },
    outputs: {
      type: 'object',
      properties: {
        result: {
          type: 'ref',
          content: ['126288', 'result'],
          schema: {
            type: 'array',
            items: {
              type: 'string',
            },
          },
        },
      },
    },
  },
  blocks: [
    {
      id: {random(6)},
      type: 'block-start',
      data: {},
    },
    {
      id: {random(6)},
      type: 'block-end',
      data: {},
    },
  ],
}