{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kabinethq.com/protocol/1/bootstrap.schema.json",
  "title": "Bootstrap",
  "description": "`GET /panel/bootstrap`: what this user may open, and how notifications reach them.",
  "$defs": {
    "Bootstrap": {
      "title": "Bootstrap",
      "type": "object",
      "required": ["resources", "pages", "notifications"],
      "properties": {
        "resources": { "type": "array", "items": { "$ref": "#/$defs/MenuItem" } },
        "pages": { "type": "array", "items": { "$ref": "#/$defs/MenuItem" } },
        "notifications": { "$ref": "#/$defs/NotificationsConfig" }
      },
      "additionalProperties": false
    },
    "MenuItem": {
      "title": "MenuItem",
      "type": "object",
      "required": ["name", "label"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "label": { "type": "string" }
      },
      "additionalProperties": false
    },
    "NotificationsConfig": {
      "title": "NotificationsConfig",
      "description": "`poll`: seconds between polls; `realtime`: `null` when the backend has no realtime server.",
      "type": "object",
      "required": ["poll", "realtime"],
      "properties": {
        "poll": { "type": "integer", "minimum": 1 },
        "realtime": { "oneOf": [{ "$ref": "#/$defs/Realtime" }, { "type": "null" }] }
      },
      "additionalProperties": false
    },
    "Realtime": {
      "title": "Realtime",
      "description": "Where new notifications are pushed (Pusher protocol). The backend picks `authEndpoint`.",
      "type": "object",
      "required": ["broadcaster", "key", "host", "port", "scheme", "authEndpoint", "channel", "event"],
      "properties": {
        "broadcaster": { "const": "reverb" },
        "key": { "type": "string", "minLength": 1 },
        "host": { "type": "string", "minLength": 1 },
        "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
        "scheme": { "enum": ["http", "https"] },
        "authEndpoint": { "type": "string", "pattern": "^/" },
        "channel": { "type": "string", "pattern": "^private-" },
        "event": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    }
  }
}
