{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://grahamdumpleton.github.io/jupyterlab-workshop/schemas/v1alpha1/collection.schema.json",
  "title": "Workshop collection index",
  "description": "A published list of workshops that can be installed, with where to fetch each version from. The order of the list is the order the browser shows.",
  "type": "object",
  "required": ["version", "workshops"],
  "additionalProperties": false,
  "properties": {
    "version": {
      "const": 1
    },
    "id": {
      "type": "string",
      "minLength": 1,
      "pattern": "^\\S+$",
      "description": "The collection's identity, the same wherever the collection runs: the analytics service knows a collection by it, so a copy shipped in a Binder image and one subscribed to by URL report as one. An opaque string with no whitespace, unique by the author's own scheme; a prefix the author controls, then the collection, as in example.org/python-basics. Set it before collecting analytics and never change it: a change starts a new collection in the data, and a fork gets its own. Without one the collection is identified by where it was subscribed from."
    },
    "title": {
      "type": "string",
      "description": "Name shown in the browser."
    },
    "description": {
      "type": "string",
      "description": "A sentence or two shown under the title."
    },
    "publisher": {
      "description": "Who publishes it: a name, or an object with a name and a URL.",
      "oneOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "object",
          "required": ["name"],
          "additionalProperties": false,
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1
            },
            "url": {
              "type": "string"
            }
          }
        }
      ]
    },
    "homepage": {
      "type": "string",
      "description": "Web page about the collection."
    },
    "icon": {
      "type": "string",
      "description": "Icon shown beside the title: an http(s) URL, a URL relative to this file, or a data: URI. SVG preferred; any shape is scaled to fit a square."
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "ordered": {
      "type": "boolean",
      "description": "Whether the workshops form a sequence meant to be taken in the order listed, as a course does. The browser then numbers them and points at the next one to take."
    },
    "analytics": {
      "$ref": "#/definitions/analytics",
      "description": "Where progress events of every workshop the collection lists are reported, once the learner opts in from the trust dialog. A deployment's own analytics setting takes precedence; a workshop's own block is used only when no collection that lists it declares one."
    },
    "workshops": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "title", "versions"],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]*$"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "platforms": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["linux", "macos", "windows"]
            }
          },
          "frontends": {
            "type": "array",
            "description": "Frontends the workshop lists in its manifest; none means JupyterLab only.",
            "items": {
              "type": "string",
              "enum": ["jupyterlab", "jupyterlite"]
            }
          },
          "capabilities": {
            "type": "array",
            "description": "Capability names as the manifest declares them.",
            "items": {
              "type": "string"
            }
          },
          "duration": {
            "type": "string"
          },
          "authors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "homepage": {
            "type": "string",
            "pattern": "^https?://",
            "description": "Web page for the workshop, as its manifest gives it."
          },
          "issues": {
            "type": "string",
            "pattern": "^https?://",
            "description": "Where to report a problem with the workshop, as its manifest gives it."
          },
          "versions": {
            "type": "array",
            "minItems": 1,
            "description": "Versions newest first; the first is installed by default.",
            "items": {
              "type": "object",
              "required": ["version", "source"],
              "additionalProperties": false,
              "properties": {
                "version": {
                  "type": ["string", "number"]
                },
                "source": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "git": {
                      "type": "string",
                      "description": "Repository URL on a forge that serves archives."
                    },
                    "ref": {
                      "type": "string"
                    },
                    "subdir": {
                      "type": "string"
                    },
                    "archive": {
                      "type": "string",
                      "description": "Direct URL of a .zip or .tar.gz archive."
                    }
                  }
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$",
                  "description": "Expected SHA-256 of the archive; the install fails if it differs."
                }
              }
            }
          }
        }
      },
      "description": "The workshops, in the order they are shown; a course lists them in sequence."
    }
  },
  "definitions": {
    "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
          }
        }
      }
    }
  }
}
