{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/flowral-app/json-schema/flowral-app-work-item-schema.json",
  "title": "WorkItem",
  "description": "A task in the context of \"what should be worked on\", flattened so a caller does not have to hold the flow to make sense of it.",
  "x-generated": "2026-11-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/flowral-app-openapi.json#/components/schemas/WorkItem",
  "type": "object",
  "properties": {
    "taskId": {
      "type": "string"
    },
    "taskName": {
      "type": "string"
    },
    "flowId": {
      "type": "string"
    },
    "flowName": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "blocked",
        "ready",
        "in_progress",
        "done"
      ]
    },
    "assigneeId": {
      "type": [
        "string",
        "null"
      ]
    },
    "estimateHours": {
      "type": [
        "number",
        "null"
      ]
    },
    "criticalPath": {
      "type": "boolean"
    },
    "subtasks": {
      "type": "array",
      "description": "This objective's sub-tasks, if it has any. An objective with sub-tasks completes through them rather than directly — see the Task schema — so a client offering \"start\"/\"complete\" on this item should check here first.",
      "items": {
        "$ref": "#/$defs/SubTask"
      }
    },
    "blockedBy": {
      "type": "array",
      "description": "On blocked work, the unfinished tasks holding it up, most-blocking first.",
      "items": {
        "type": "object",
        "properties": {
          "taskId": {
            "type": "string"
          },
          "taskName": {
            "type": "string"
          },
          "blocking": {
            "type": "integer",
            "description": "How many tasks this one is holding up."
          }
        }
      }
    }
  },
  "required": [
    "taskId",
    "taskName",
    "flowId",
    "flowName",
    "status",
    "subtasks"
  ],
  "$defs": {
    "SubTask": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "done": {
          "type": "boolean"
        },
        "assigneeId": {
          "type": [
            "string",
            "null"
          ],
          "description": "Workspace member id."
        },
        "estimateHours": {
          "type": [
            "number",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "name",
        "done"
      ]
    }
  }
}