{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://metrix.bar/dashboards/schema.json",
  "title": "Dashboard Registry",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schema_version",
    "id",
    "name",
    "dashboards"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Editor schema hint only; schema_version determines the registry protocol."
    },
    "schema_version": {
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "dashboards": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "id",
          "name",
          "file",
          "protocol_version",
          "version",
          "sha256"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "file": {
            "type": "string",
            "pattern": "^(?!/|%2[fF])(?![^/]*:)(?!.*%(?:5[cC]|3[fF]|23))(?:[^%?#\\\\\\x00-\\x1f\\x7f]|%[0-9A-Fa-f]{2})*(?:\\.|%2[eE])(?:b|%62)(?:a|%61)(?:r|%72)$(?![\\s\\S])",
            "description": "Relative .bar path; percent encoding is allowed and decoded before path validation. No absolute path, query, fragment or backslash."
          },
          "protocol_version": {
            "const": "0"
          },
          "version": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$"
          },
          "category": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
            "default": "other"
          },
          "placements": {
            "type": "array",
            "items": {
              "enum": ["menubar", "sidebar-left", "sidebar-right", "sidebar-bottom"]
            },
            "uniqueItems": true,
            "description": "Author default entry placements; an empty array enables no entries. User settings may override these defaults."
          },
          "open_mode": {
            "type": "string",
            "enum": ["flyout", "dialog"],
            "description": "Author default presentation when opened. User settings may override this default."
          },
          "docs": {
            "type": "string",
            "description": "Plain-text setup instructions."
          },
          "description": {
            "type": "string"
          },
          "icon": {
            "type": "string"
          },
          "license": {
            "type": "string"
          },
          "homepage": {
            "type": "string",
            "format": "uri",
            "pattern": "^[hH][tT][tT][pP][sS]://(?:\\[[^\\]\\s/?#@]+\\]|[^\\s/?#@:%]+)(?::[0-9]*)?(?:[/?#]|$)",
            "description": "Absolute HTTPS URI with a nonempty host and no credentials; ports and fragments are allowed. Display only."
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      }
    }
  }
}
