{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://glerp.ca/alpha/format/boite-v1.schema.json",
  "title": "alpha box, version 1",
  "description": "One or more boxes of links to import into alpha (https://glerp.ca/alpha/format). The same document can be written in YAML or in JSON. At most 500 links and sub-links per document.",
  "type": "object",
  "required": ["alpha", "boxes"],
  "additionalProperties": false,
  "properties": {
    "alpha": {
      "description": "Format version.",
      "const": 1
    },
    "page": {
      "description": "Suggested name of the page that receives the boxes.",
      "type": "string",
      "minLength": 1,
      "maxLength": 190
    },
    "boxes": {
      "description": "The boxes.",
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "items": { "$ref": "#/$defs/box" }
    }
  },
  "$defs": {
    "color": {
      "description": "Color shown by alpha.",
      "enum": ["gray", "green", "blue", "purple", "orange"]
    },
    "url": {
      "description": "Real http or https address, with no credentials, token, key or password in it.",
      "type": "string",
      "pattern": "^https?://[^\\s\"'<>`\\\\]+$",
      "maxLength": 2000
    },
    "box": {
      "type": "object",
      "required": ["title"],
      "additionalProperties": false,
      "properties": {
        "title": { "type": "string", "minLength": 1, "maxLength": 190 },
        "color": { "$ref": "#/$defs/color" },
        "links": {
          "type": "array",
          "maxItems": 500,
          "items": { "$ref": "#/$defs/link" }
        }
      }
    },
    "link": {
      "type": "object",
      "required": ["url"],
      "additionalProperties": false,
      "properties": {
        "title": { "description": "Short title; the site name when missing.", "type": "string", "maxLength": 300 },
        "url": { "$ref": "#/$defs/url" },
        "note": { "description": "One helpful sentence.", "type": "string", "maxLength": 500 },
        "color": { "$ref": "#/$defs/color" },
        "links": {
          "description": "Sub-links, one level only.",
          "type": "array",
          "maxItems": 500,
          "items": { "$ref": "#/$defs/sublink" }
        }
      }
    },
    "sublink": {
      "type": "object",
      "required": ["url"],
      "additionalProperties": false,
      "properties": {
        "title": { "type": "string", "maxLength": 300 },
        "url": { "$ref": "#/$defs/url" },
        "note": { "type": "string", "maxLength": 500 },
        "color": { "$ref": "#/$defs/color" }
      }
    }
  }
}
