{
  "version": "3.6",
  "name": "Batch Processing Workflow",
  "registry": {
    "services": [
      "ProcessItem(item(OBJECT)) RETURN processed(OBJECT), success(BOOL)"
    ],
    "components": [],
    "vars": [
      "$items([OBJECT])",
      "$results([OBJECT])",
      "$successCount(INT)"
    ],
    "files": {
      "inputs": [
        "Process/Input/items.json"
      ],
      "artifacts": [
        "Process/Artifacts/*"
      ]
    }
  },
  "steps": [
    {
      "id": "Set_InitResults",
      "target": "$results",
      "value": "[]",
      "next": "Set_InitCount"
    },
    {
      "id": "Set_InitCount",
      "target": "$successCount",
      "value": "0",
      "next": "Loop_ProcessItems"
    },
    {
      "id": "Loop_ProcessItems",
      "mode": "parallel",
      "source": "$items",
      "children": ["Service_ProcessItem"],
      "next": "Write_Summary"
    },
    {
      "id": "Service_ProcessItem",
      "in": {
        "item": "_item"
      },
      "out": {
        "$results[_index]": "_result.processed"
      },
      "next": "Write_ItemResult"
    },
    {
      "id": "Write_ItemResult",
      "target": "\"Process/Artifacts/item_\" + _index + \".json\"",
      "value": "_item",
      "mode": "overwrite"
    },
    {
      "id": "Write_Summary",
      "target": "\"Process/Artifacts/summary.json\"",
      "value": "$results",
      "mode": "overwrite",
      "next": "Stop_End"
    },
    {
      "id": "Stop_End"
    }
  ]
}
