{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/skavio-eu/json-schema/skavio-eu-pipeline-run-schema.json",
  "title": "PipelineRun",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/skavio-eu-processing-openapi.json#/components/schemas/PipelineRun",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "pipeline_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "name": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "processing",
        "waiting_review",
        "paused",
        "pause_requested",
        "stopping",
        "completed",
        "failed",
        "cancelled"
      ]
    },
    "reason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "max_credits": {
      "type": "integer"
    },
    "charged_credits": {
      "type": "integer"
    },
    "reserved_credits": {
      "type": "integer"
    },
    "current_step_index": {
      "type": "integer"
    },
    "steps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PipelineStepState"
      }
    },
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "status",
    "max_credits",
    "charged_credits",
    "reserved_credits",
    "steps",
    "current_step_index",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "Job": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "operation": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "queued",
            "processing",
            "completed",
            "failed"
          ]
        },
        "stage": {
          "type": "string"
        },
        "estimated_credits": {
          "type": "integer"
        },
        "charged_credits": {
          "type": "integer"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "result": {
          "anyOf": [
            {
              "$ref": "#/$defs/JobResult"
            },
            {
              "type": "null"
            }
          ]
        },
        "created_at": {
          "type": "string"
        },
        "updated_at": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "operation",
        "status",
        "estimated_credits",
        "charged_credits",
        "result"
      ]
    },
    "JobResult": {
      "type": "object",
      "properties": {
        "files": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ResultFile"
          }
        },
        "documents": {
          "type": "integer"
        },
        "review_required_documents": {
          "type": "integer"
        },
        "estimated_time_saved_minutes": {
          "type": "integer"
        },
        "time_saved_basis": {
          "type": "string"
        }
      },
      "required": [
        "files"
      ]
    },
    "PipelineStepState": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "process",
            "review",
            "archive"
          ]
        },
        "status": {
          "type": "string"
        },
        "attempt": {
          "type": "integer"
        },
        "job": {
          "anyOf": [
            {
              "$ref": "#/$defs/Job"
            },
            {
              "type": "null"
            }
          ]
        },
        "approved_by": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        },
        "approved_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "archived_object_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "id",
        "kind",
        "status",
        "job",
        "attempt"
      ]
    },
    "ResultFile": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "size_bytes": {
          "type": "integer"
        },
        "download_path": {
          "type": "string",
          "description": "Authenticated path relative to the API server."
        },
        "storage_object_id": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name",
        "size_bytes",
        "download_path"
      ]
    }
  }
}