{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "StageTrace CLI export response 1.0",
  "type": "object",
  "required": [
    "schemaVersion",
    "command",
    "status",
    "data",
    "errors",
    "warnings",
    "timingMs"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.0"
    },
    "command": {
      "const": "export"
    },
    "status": {
      "type": "string",
      "enum": [
        "ok",
        "error"
      ]
    },
    "data": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "stageId",
            "outputs"
          ],
          "properties": {
            "stageId": {
              "type": "string"
            },
            "outputs": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "kind",
                  "outputPath",
                  "bytesWritten",
                  "overwritten"
                ],
                "properties": {
                  "kind": {
                    "type": "string"
                  },
                  "outputPath": {
                    "type": "string"
                  },
                  "bytesWritten": {
                    "type": "number"
                  },
                  "overwritten": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              }
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {},
          "additionalProperties": false
        }
      ]
    },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {"type": "string"},
          "message": {"type": "string"}
        },
        "additionalProperties": false
      }
    },
    "timingMs": {
      "type": "number"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "ok"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "stageId",
              "outputs"
            ],
            "properties": {
              "stageId": {
                "type": "string"
              },
              "outputs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "kind",
                    "outputPath",
                    "bytesWritten",
                    "overwritten"
                  ],
                  "properties": {
                    "kind": {
                      "type": "string"
                    },
                    "outputPath": {
                      "type": "string"
                    },
                    "bytesWritten": {
                      "type": "number"
                    },
                    "overwritten": {
                      "type": "boolean"
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "additionalProperties": false
          },
          "errors": {
            "type": "array",
            "maxItems": 0
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "error"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "properties": {
          "data": {
            "type": "object",
            "properties": {},
            "additionalProperties": false
          },
          "errors": {
            "type": "array",
            "minItems": 1
          }
        }
      }
    }
  ],
  "additionalProperties": false
}
