{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://capp.local/schemas/capp.route-policy.v1.schema.json",
  "title": "cApp route policy v1",
  "type": "object",
  "required": [
    "protocol",
    "routes"
  ],
  "properties": {
    "protocol": {
      "const": "capp.route-policy.v1"
    },
    "siteId": {
      "type": [
        "string",
        "null"
      ]
    },
    "appId": {
      "type": [
        "string",
        "null"
      ]
    },
    "namespace": {
      "type": "string"
    },
    "mode": {
      "type": "string"
    },
    "routes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "path",
          "methods"
        ],
        "properties": {
          "path": {
            "type": "string",
            "pattern": "^/"
          },
          "methods": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "pattern": "^[A-Z]+$"
            }
          },
          "capability": {
            "type": "string",
            "minLength": 1
          },
          "risk": {
            "enum": [
              "low",
              "medium",
              "high",
              "critical"
            ]
          },
          "group": {
            "type": "string"
          },
          "online": {
            "type": "boolean"
          },
          "offline": {
            "type": "boolean"
          },
          "offlineCollection": {
            "type": [
              "string",
              "null"
            ]
          },
          "localHandler": {
            "type": [
              "string",
              "null"
            ]
          },
          "sync": {
            "type": "string"
          },
          "execution": {
            "enum": [
              "auto",
              "local-preferred",
              "local-only",
              "remote-preferred",
              "remote-only"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "excluded": {
            "type": "boolean"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "auth": {
            "type": "string"
          },
          "mode": {
            "type": "string"
          },
          "routeMode": {
            "type": "string"
          },
          "browserCallable": {
            "type": "boolean"
          },
          "receiptRequired": {
            "type": "boolean"
          },
          "approval": {
            "type": "string"
          },
          "replayProtection": {
            "type": "string"
          },
          "coldBehavior": {
            "type": "string"
          },
          "defaultEnabled": {
            "type": "boolean"
          },
          "metadata": {
            "type": "object"
          }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": true
}
