{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rehearse.kurvball.ca/schema/v1/drive.schema.json",
  "title": "Rehearse v1: rehearse drive --json",
  "description": "One step's result, in the drive result shape ({ok, command, ms, file, tree} or {ok: false, command, ms, failure, says}, as Ashlar's DriveResult reads it), with v and driver added, so a reader of that shape reads it unchanged. Two commands are Rehearse's own: start (it starts the driver) and fill (it fills a field by its name, in Rehearse's browser only); a service's own driver may have neither. Exit codes: 0 done, 1 failed, 2 usage.",
  "oneOf": [
    {
      "type": "object",
      "required": ["v", "ok", "command", "ms", "file", "tree", "driver"],
      "properties": {
        "v": {
          "$ref": "common.schema.json#/$defs/v"
        },
        "ok": {
          "const": true
        },
        "command": {
          "$ref": "#/$defs/command"
        },
        "ms": {
          "type": "integer",
          "minimum": 0
        },
        "file": {
          "description": "The file a screenshot or a recording saved.",
          "type": ["string", "null"]
        },
        "tree": {
          "description": "The accessibility tree a snapshot printed.",
          "type": ["string", "null"]
        },
        "driver": {
          "description": "Which driver did it; null for a stop when nothing was being driven.",
          "oneOf": [
            {
              "$ref": "#/$defs/driver"
            },
            {
              "type": "null"
            }
          ]
        },
        "errors": {
          "description": "Errors the page logged during the step.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "said": {
          "description": "Anything the driver couldn't do, such as signing in as a person.",
          "type": ["string", "null"]
        }
      }
    },
    {
      "type": "object",
      "required": ["v", "ok", "command", "ms", "failure", "says", "driver"],
      "properties": {
        "v": {
          "$ref": "common.schema.json#/$defs/v"
        },
        "ok": {
          "const": false
        },
        "command": {
          "oneOf": [
            {
              "$ref": "#/$defs/command"
            },
            {
              "type": "null"
            }
          ]
        },
        "ms": {
          "type": "integer",
          "minimum": 0
        },
        "failure": {
          "description": "Why a step failed; more may come.",
          "type": "string",
          "examples": ["usage", "not_found", "ambiguous", "not_running", "timed_out", "crashed"]
        },
        "says": {
          "type": "string"
        },
        "driver": {
          "oneOf": [
            {
              "$ref": "#/$defs/driver"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  ],
  "$defs": {
    "command": {
      "type": "string",
      "examples": ["start", "click", "type", "key", "fill", "snapshot", "screenshot", "record", "stop"]
    },
    "driver": {
      "description": "service: the service's own driver. browser: Rehearse's browser. More may come.",
      "type": "string",
      "examples": ["service", "browser"]
    }
  }
}
