{
  "name": "Multi-API Data Aggregator",
  "version": "1.0.0",
  "description": "Fetches data from multiple APIs in parallel, transforms and combines results - demonstrates http_request and parallel execution",
  "input_schema": {
    "type": "object",
    "properties": {
      "user_id": {
        "type": "string",
        "description": "User ID to fetch data for"
      },
      "include_posts": {
        "type": "boolean",
        "default": true
      },
      "include_todos": {
        "type": "boolean",
        "default": true
      }
    },
    "required": ["user_id"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "user": { "type": "object" },
      "posts": { "type": "array" },
      "todos": { "type": "array" },
      "summary": { "type": "object" }
    }
  },
  "stages": [
    {
      "id": "fetch-user",
      "name": "Fetch User Profile",
      "component_type": "http_request",
      "config": {
        "url": "https://jsonplaceholder.typicode.com/users/{{input.user_id}}",
        "method": "GET",
        "timeout": 30,
        "headers": {
          "Accept": "application/json"
        }
      },
      "depends_on": [],
      "position": { "x": 100, "y": 200 }
    },
    {
      "id": "fetch-posts",
      "name": "Fetch User Posts",
      "component_type": "http_request",
      "config": {
        "url": "https://jsonplaceholder.typicode.com/posts",
        "method": "GET",
        "params": {
          "userId": "{{input.user_id}}"
        },
        "timeout": 30
      },
      "depends_on": [],
      "position": { "x": 100, "y": 350 }
    },
    {
      "id": "fetch-todos",
      "name": "Fetch User Todos",
      "component_type": "http_request",
      "config": {
        "url": "https://jsonplaceholder.typicode.com/todos",
        "method": "GET",
        "params": {
          "userId": "{{input.user_id}}"
        },
        "timeout": 30
      },
      "depends_on": [],
      "position": { "x": 100, "y": 500 }
    },
    {
      "id": "transform-user",
      "name": "Transform User Data",
      "component_type": "json_transform",
      "config": {
        "data": "{{upstream.fetch-user.body}}",
        "jmespath_expression": "{ id: id, name: name, username: username, email: email, company: company.name, city: address.city, website: website }"
      },
      "depends_on": ["fetch-user"],
      "position": { "x": 350, "y": 200 }
    },
    {
      "id": "transform-posts",
      "name": "Transform Posts",
      "component_type": "json_transform",
      "config": {
        "data": "{{upstream.fetch-posts.body}}",
        "jmespath_expression": "[*].{ id: id, title: title, body_preview: body[0:100] }"
      },
      "depends_on": ["fetch-posts"],
      "position": { "x": 350, "y": 350 }
    },
    {
      "id": "transform-todos",
      "name": "Transform Todos",
      "component_type": "json_transform",
      "config": {
        "data": "{{upstream.fetch-todos.body}}",
        "jmespath_expression": "{ all: [*].{ id: id, title: title, completed: completed }, completed: [?completed == `true`], pending: [?completed == `false`] }"
      },
      "depends_on": ["fetch-todos"],
      "position": { "x": 350, "y": 500 }
    },
    {
      "id": "aggregate-data",
      "name": "Aggregate All Data",
      "component_type": "json_transform",
      "config": {
        "data": {
          "user": "{{upstream.transform-user.result}}",
          "posts": "{{upstream.transform-posts.result}}",
          "todos": "{{upstream.transform-todos.result}}",
          "api_status": {
            "user_api": "{{upstream.fetch-user.status_code}}",
            "posts_api": "{{upstream.fetch-posts.status_code}}",
            "todos_api": "{{upstream.fetch-todos.status_code}}"
          }
        },
        "jmespath_expression": "{ user: user, posts: posts, todos: todos.all, summary: { total_posts: length(posts), completed_todos: length(todos.completed), pending_todos: length(todos.pending), api_calls_successful: (api_status.user_api == `200`) && (api_status.posts_api == `200`) && (api_status.todos_api == `200`) } }"
      },
      "depends_on": ["transform-user", "transform-posts", "transform-todos"],
      "position": { "x": 600, "y": 350 }
    },
    {
      "id": "log-summary",
      "name": "Log Aggregation Summary",
      "component_type": "logger",
      "config": {
        "message": "API aggregation complete",
        "level": "info",
        "data": "{{upstream.aggregate-data.result.summary}}",
        "tags": {
          "component": "api_aggregator",
          "user_id": "{{input.user_id}}"
        }
      },
      "depends_on": ["aggregate-data"],
      "position": { "x": 850, "y": 350 }
    }
  ],
  "output_stage_id": "aggregate-data"
}
