{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://grahamdumpleton.github.io/jupyterlab-workshop/schemas/v1alpha1/workshop.schema.json",
  "title": "Workshop manifest",
  "description": "The workshop.yaml manifest of a guided JupyterLab workshop.",
  "type": "object",
  "required": ["apiVersion", "name", "title", "pages"],
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "const": "jupyterlab-workshop/v1alpha1"
    },
    "name": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$",
      "description": "Identifier used for directories and state; lower case letters, digits and hyphens."
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "description": "Version of the workshop, always a string: quote a value such as 1.10, which YAML would otherwise read as the number 1.1."
    },
    "description": {
      "type": "string"
    },
    "finish": {
      "type": "string",
      "description": "Markdown shown in the dialog when the learner presses Finish on the last page, such as where to go next."
    },
    "duration": {
      "type": "string",
      "description": "Expected duration such as 45m or 2h."
    },
    "authors": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "homepage": {
      "type": "string",
      "pattern": "^https?://",
      "description": "Web page for the workshop, such as the repository it is developed in; shown in the About dialog and the browser."
    },
    "issues": {
      "type": "string",
      "pattern": "^https?://",
      "description": "Where to report a problem with the workshop, such as the repository's issue tracker; shown in the About dialog and when the workshop is finished."
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "platforms": {
      "type": "array",
      "description": "Operating systems the workshop is written for. Advisory: the browser dims workshops that do not list the current one, the panel shows a banner, and the linter checks body variants against the list.",
      "items": {
        "type": "string",
        "enum": ["linux", "macos", "windows"]
      }
    },
    "frontends": {
      "type": "array",
      "description": "Frontends the workshop is written for. A manifest that lists none supports JupyterLab only; supporting JupyterLite is an explicit declaration, since it needs explicit work.",
      "items": {
        "type": "string",
        "enum": ["jupyterlab", "jupyterlite"]
      }
    },
    "capabilities": {
      "type": "array",
      "description": "What the workshop needs permission for: the names of the capabilities its actions use, each of which gates an action type. Write actions are always confined to the workshop's work directory, and terminal commands can reach anything the machine can, so nothing carries a scope.",
      "items": {
        "$ref": "#/definitions/capabilityName"
      }
    },
    "requires": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "tools": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name"],
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              },
              "optional": {
                "type": "boolean"
              },
              "platforms": {
                "type": "array",
                "description": "Platforms the tool is looked for on; every platform when absent. A tool that goes by another name elsewhere is a second entry with a disjoint list.",
                "items": {
                  "type": "string",
                  "enum": ["linux", "macos", "windows"]
                }
              },
              "frontends": {
                "type": "array",
                "description": "Frontends the tool is looked for under; every frontend when absent. Install advice for a missing tool is prose on the first page under a when block testing missing_tools.",
                "items": {
                  "type": "string",
                  "enum": ["jupyterlab", "jupyterlite"]
                }
              }
            }
          }
        },
        "shell": {
          "type": "string",
          "description": "The one shell the workshop is written for: bash, zsh, sh (any POSIX shell), fish, powershell or cmd. Set it only when the workshop truly supports one shell; a workshop that runs under several omits it and puts when conditions on the actions that differ. When the terminal shell does not satisfy it the panel shows a banner on the first page."
        }
      }
    },
    "environment": {
      "type": "object",
      "description": "An isolated Python environment created for the workshop from a requirements file, with its own kernel. Needs the install-packages capability.",
      "additionalProperties": false,
      "properties": {
        "requirements": {
          "type": "string",
          "description": "Requirements file relative to the workshop directory, installed into a virtual environment under _workshop/venv."
        },
        "kernel": {
          "type": "string",
          "description": "Base name of the kernelspec registered for the environment; defaults to workshop-<name>. The registered name adds a short hash of the workshop's location, so copies of the workshop in different directories keep separate kernels."
        },
        "terminals": {
          "type": "boolean",
          "description": "Whether workshop terminals, execute-capture and script checks see the environment first on their PATH once it exists; true unless set to false, for a workshop that teaches virtual environments itself."
        }
      }
    },
    "analytics": {
      "$ref": "#/definitions/analytics",
      "description": "Where progress events are reported, once the learner opts in from the trust dialog. A deployment's own analytics setting takes precedence over this block, as does the block of a subscribed collection that lists the workshop."
    },
    "resumable": {
      "type": "boolean",
      "default": false,
      "description": "Whether the workshop can be continued after the JupyterLab it ran under has restarted. Terminals, running programs and notebook kernel state do not survive a restart, so unless this is true a workshop reopened under a new JupyterLab asks whether to restart or continue. Set it only for a workshop whose steps leave nothing live behind, such as one that only edits files. A workshop whose later pages rely on what earlier pages ran in a notebook's kernel is not resumable, however little it writes to disk."
    },
    "variables": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name"],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
            "description": "Identifier, exported to workshop terminals in upper case; avoid names the shell or operating system already uses, such as path, term or temp."
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "boolean",
              "select",
              "multiselect",
              "secret",
              "path",
              "url",
              "email"
            ]
          },
          "description": {
            "type": "string"
          },
          "default": {
            "type": ["string", "number", "boolean"]
          },
          "required": {
            "type": "boolean"
          },
          "readonly": {
            "type": "boolean"
          },
          "secret": {
            "type": "boolean"
          },
          "options": {
            "type": "array",
            "items": {
              "type": ["string", "number"]
            }
          }
        }
      }
    },
    "instructions": {
      "type": "object",
      "additionalProperties": false,
      "description": "Where the instructions panel sits for the whole workshop: the sidebar it lives in and the fraction of the window that sidebar takes. Left out, the panelSide setting chooses the side and the width is left as the learner has it.",
      "properties": {
        "side": {
          "type": "string",
          "enum": ["left", "right"],
          "description": "Sidebar the panel lives in. The same for every step: a layout may change the width but never the side."
        },
        "width": {
          "type": "number",
          "exclusiveMinimum": 0,
          "exclusiveMaximum": 1,
          "description": "Fraction of the window width the panel's sidebar takes. A layout may override it for its own step."
        }
      }
    },
    "sidebar": {
      "type": "string",
      "minLength": 1,
      "description": "The sidebar the instructions are not in, when the workshop opens: hidden, the default, collapses it; a sidebar widget id such as filebrowser brings that widget forward there, moving it from the other sidebar if needed."
    },
    "layout": {
      "type": "string",
      "description": "Name of the layout applied when the workshop opens: one declared under layouts, or the built-in default (a terminal below whatever is open) or terminal-only (a terminal filling the main area)."
    },
    "layouts": {
      "type": "object",
      "description": "Named arrangements of the JupyterLab window, applied by the layout field when the workshop is first opened, by the layout directive from a page, and by the Reset Layout command. A layout describes the result: where things go, never what to close.",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "sidebar": {
            "type": "string",
            "minLength": 1,
            "description": "The sidebar the instructions are not in, while this layout is applied: hidden, or a sidebar widget id such as filebrowser. Left out, that sidebar is left as it is."
          },
          "instructions": {
            "type": "object",
            "additionalProperties": false,
            "description": "Width of the instructions sidebar for this step, overriding the top-level instructions width.",
            "properties": {
              "width": {
                "type": "number",
                "exclusiveMinimum": 0,
                "exclusiveMaximum": 1,
                "description": "Fraction of the window width the panel's sidebar takes while this layout is applied."
              }
            }
          },
          "main": {
            "$ref": "#/definitions/layoutArea",
            "description": "The main area as a tree of areas. Left out, the main area is left as it is."
          }
        }
      }
    },
    "gating": {
      "type": "string",
      "enum": ["off", "soft", "strict"]
    },
    "tracks": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id"],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      }
    },
    "env": {
      "$ref": "#/definitions/env",
      "description": "Environment variables exported to the workshop terminals alongside the variables, and set for checks and captures, such as PAGER: cat so that git and man do not wait for a key press in a small terminal. Values are strings only, as the environment holds them; quote a number or a true/false so YAML keeps it as written."
    },
    "defaults": {
      "$ref": "#/definitions/defaults",
      "description": "Fallback values applied under the options of every action directive."
    },
    "variants": {
      "type": "object",
      "description": "Overrides of env and defaults for one platform or frontend, keyed by the same names body markers use. The entries that apply are merged over the base in the order the markers are chosen: the frontend entry over the platform entry over the base. Only env and defaults may appear under an entry; whether one item of a list applies somewhere is said on the item, as a tool's platforms does.",
      "propertyNames": {
        "enum": ["jupyterlab", "jupyterlite", "linux", "macos", "windows"]
      },
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "env": {
            "$ref": "#/definitions/env",
            "description": "Environment variables merged over the manifest's env."
          },
          "defaults": {
            "$ref": "#/definitions/defaults",
            "description": "Action option defaults merged over the manifest's defaults."
          }
        }
      }
    },
    "pages": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      },
      "description": "Page files in order, relative to the workshop directory."
    }
  },
  "definitions": {
    "env": {
      "type": "object",
      "propertyNames": {
        "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
      },
      "additionalProperties": {
        "type": "string"
      }
    },
    "defaults": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "actions": {
          "type": "object",
          "description": "Default option values for every action directive, keyed by option name. Directive options are text, so the defaults are strings only; quote a number or a true/false.",
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "layoutArea": {
      "type": "object",
      "additionalProperties": false,
      "description": "One area of the main-area tree: either tabs, or a split into child areas. Exactly one of tabs and areas is given; lint reports an area with both or neither.",
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]*$",
          "description": "Name an action's area option can target; unique within a layout, and reusable across layouts."
        },
        "tabs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Widget references opened as tabs, the first active: terminal:<name>, file:<path>, markdown:<path>, notebook:<path> or launcher. An empty list is the placeholder that holds whatever else is open."
        },
        "split": {
          "type": "string",
          "enum": ["rows", "columns"],
          "description": "Direction the child areas are laid out in; rows unless said."
        },
        "areas": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/layoutArea"
          },
          "description": "Child areas of a split, in order."
        },
        "size": {
          "type": "number",
          "exclusiveMinimum": 0,
          "exclusiveMaximum": 1,
          "description": "Fraction of the parent split this area takes; siblings without one share the remainder equally."
        }
      }
    },
    "capabilityName": {
      "type": "string",
      "enum": [
        "terminal",
        "write-files",
        "install-packages",
        "kernel-exec",
        "auto-run",
        "ui-settings",
        "web-proxy"
      ]
    },
    "analytics": {
      "type": "object",
      "description": "Where progress events are reported: the sink they are posted to, the token they are posted with, and labels stamped on every event. The same block appears in a workshop manifest, in a collection index and in a deployment's settings, and the highest of those levels that has one applies whole.",
      "additionalProperties": false,
      "properties": {
        "sink": {
          "type": "string",
          "pattern": "^https?://",
          "description": "URL that receives batches of events as JSON lines by POST."
        },
        "token": {
          "type": "string",
          "minLength": 1,
          "description": "Token sent as a bearer credential in the Authorization header of every batch, issued by the sink's operator. Public wherever the block is public."
        },
        "labels": {
          "type": "object",
          "description": "Key and value pairs stamped on every event so reports can slice by them: a course, a cohort, a term. Labels are for slicing, never for identity; the workshop's name, source, collection, host and frontend are fields every event already carries. At most 16 labels.",
          "maxProperties": 16,
          "propertyNames": {
            "pattern": "^[a-z0-9_.-]+$",
            "maxLength": 63
          },
          "additionalProperties": {
            "type": "string",
            "maxLength": 128
          }
        }
      }
    }
  }
}
