{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "daggry/work-item@1",
  "title": "daggry/work-item@1: the objective of a run, and the workspace and request it is for",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "objective": {
      "type": "string",
      "minLength": 1,
      "x-fact-class": "claimed",
      "description": "What the run is asked to do, as text. For an issue, its title and body when the run starts."
    },
    "origin": {
      "enum": [
        "issue",
        "pull-request",
        "trigger",
        "command"
      ],
      "x-fact-class": "derived",
      "description": "Where the objective came from."
    },
    "trigger": {
      "type": "string",
      "minLength": 1,
      "x-fact-class": "derived",
      "description": "The name of the trigger that started the run."
    },
    "event": {
      "x-fact-class": "derived",
      "type": "object",
      "additionalProperties": {
        "type": [
          "string",
          "integer",
          "boolean"
        ]
      },
      "description": "Fields of the event that started the run, such as a label or a schedule time."
    },
    "workspace": {
      "type": "string",
      "minLength": 1,
      "x-fact-class": "claimed"
    },
    "request": {
      "x-fact-class": "claimed",
      "type": "object",
      "required": [
        "ref",
        "title",
        "body"
      ],
      "additionalProperties": false,
      "properties": {
        "ref": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string"
        },
        "body": {
          "type": "string"
        }
      }
    },
    "repository": {
      "type": "string",
      "pattern": "^[^/\\s]+/[^/\\s]+$",
      "x-fact-class": "claimed"
    },
    "issue": {
      "x-fact-class": "claimed",
      "type": "object",
      "required": [
        "url",
        "number",
        "title",
        "body"
      ],
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "minLength": 1
        },
        "number": {
          "type": "integer",
          "minimum": 1
        },
        "title": {
          "type": "string"
        },
        "body": {
          "type": "string"
        }
      }
    }
  },
  "oneOf": [
    {
      "required": [
        "objective",
        "origin",
        "workspace",
        "request"
      ],
      "properties": {
        "repository": false,
        "issue": false
      }
    },
    {
      "required": [
        "objective",
        "origin",
        "repository",
        "issue"
      ],
      "properties": {
        "workspace": false,
        "request": false
      }
    }
  ]
}
