{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rehearse.kurvball.ca/schema/v1/flow.schema.json",
  "title": "*.flow.yaml",
  "description": "A flow: steps by accessible name, from a service's page or a piece's canvas. Rehearse observes the accessibility tree after each step. A module whose default export is {name, steps} (a reach script, as Ashlar writes them) is read the same way.",
  "type": "object",
  "required": ["name", "steps"],
  "properties": {
    "name": {
      "description": "What the flow tries, in plain words.",
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "describe": {
      "type": "string"
    },
    "service": {
      "description": "The service whose page it opens. Default the manifest's flows.service, then defaults.service.",
      "type": "string"
    },
    "piece": {
      "description": "Or a piece's id whose canvas it opens, for a screen that renders only as a story.",
      "type": "string"
    },
    "start": {
      "description": "The path it opens on the service, such as /settings. Default /.",
      "type": "string"
    },
    "world": {
      "type": "string"
    },
    "person": {
      "type": "string"
    },
    "covers": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "steps": {
      "type": "array",
      "minItems": 1,
      "maxItems": 60,
      "items": {
        "oneOf": [
          {
            "type": "object",
            "required": ["click"],
            "properties": {
              "click": {
                "$ref": "#/$defs/words"
              },
              "role": {
                "$ref": "#/$defs/role"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["type"],
            "properties": {
              "type": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["key"],
            "properties": {
              "key": {
                "$ref": "#/$defs/key"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["snapshot"],
            "properties": {
              "snapshot": {
                "$ref": "#/$defs/words"
              },
              "role": {
                "$ref": "#/$defs/role"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["fill"],
            "properties": {
              "fill": {
                "$ref": "#/$defs/words"
              },
              "role": {
                "$ref": "#/$defs/role"
              },
              "with": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        ]
      }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "words": {
      "description": "An accessible name, as a screen reader says it.",
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "role": {
      "description": "An ARIA role, as Playwright's getByRole takes it.",
      "enum": [
        "alert",
        "alertdialog",
        "application",
        "article",
        "banner",
        "blockquote",
        "button",
        "caption",
        "cell",
        "checkbox",
        "code",
        "columnheader",
        "combobox",
        "complementary",
        "contentinfo",
        "definition",
        "deletion",
        "dialog",
        "directory",
        "document",
        "emphasis",
        "feed",
        "figure",
        "form",
        "generic",
        "grid",
        "gridcell",
        "group",
        "heading",
        "img",
        "insertion",
        "link",
        "list",
        "listbox",
        "listitem",
        "log",
        "main",
        "marquee",
        "math",
        "meter",
        "menu",
        "menubar",
        "menuitem",
        "menuitemcheckbox",
        "menuitemradio",
        "navigation",
        "none",
        "note",
        "option",
        "paragraph",
        "presentation",
        "progressbar",
        "radio",
        "radiogroup",
        "region",
        "row",
        "rowgroup",
        "rowheader",
        "scrollbar",
        "search",
        "searchbox",
        "separator",
        "slider",
        "spinbutton",
        "status",
        "strong",
        "subscript",
        "superscript",
        "switch",
        "tab",
        "table",
        "tablist",
        "tabpanel",
        "term",
        "textbox",
        "time",
        "timer",
        "toolbar",
        "tooltip",
        "tree",
        "treegrid",
        "treeitem"
      ]
    },
    "key": {
      "description": "A key named as Playwright names it: Enter, Escape, Meta+k, ControlOrMeta+j.",
      "type": "string",
      "pattern": "^(?:(?:ControlOrMeta|Meta|Control|Alt|Shift)\\+)*(?:Enter|Escape|Tab|Backspace|Delete|Space|ArrowUp|ArrowDown|ArrowLeft|ArrowRight|Home|End|PageUp|PageDown|F(?:[1-9]|1[0-2])|[a-z0-9]|[,./;'`\\[\\]\\\\=-])$"
    }
  }
}
