{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api.craft.cloud/schemas/craft-cloud.schema.json",
  "title": "Craft Cloud configuration",
  "description": "Schema for craft-cloud.yaml.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "php-version": {
      "oneOf": [
        {
          "type": "string",
          "enum": ["8.5", "8.4", "8.3", "8.2"]
        },
        {
          "type": "number",
          "enum": [8.5, 8.4, 8.3, 8.2]
        }
      ]
    },
    "node-version": {
      "oneOf": [
        {
          "type": "string",
          "pattern": "^(24|22|21|20|19|18|17|16)(\\.\\d+){0,2}$"
        },
        {
          "type": "number",
          "anyOf": [
            {
              "minimum": 24,
              "exclusiveMaximum": 25
            },
            {
              "minimum": 22,
              "exclusiveMaximum": 23
            },
            {
              "minimum": 21,
              "exclusiveMaximum": 22
            },
            {
              "minimum": 20,
              "exclusiveMaximum": 21
            },
            {
              "minimum": 19,
              "exclusiveMaximum": 20
            },
            {
              "minimum": 18,
              "exclusiveMaximum": 19
            },
            {
              "minimum": 17,
              "exclusiveMaximum": 18
            },
            {
              "minimum": 16,
              "exclusiveMaximum": 17
            }
          ]
        }
      ]
    },
    "node-path": {
      "type": "string"
    },
    "npm-script": {
      "type": "string"
    },
    "app-path": {
      "type": "string"
    },
    "webroot": {
      "type": "string",
      "deprecated": true,
      "description": "Deprecated. Use webroot-path instead."
    },
    "webroot-path": {
      "type": "string"
    },
    "artifact-path": {
      "type": "string"
    },
    "cache": {
      "type": "object",
      "additionalProperties": true
    },
    "redirects": {
      "$ref": "#/$defs/gateway-rules"
    },
    "rewrites": {
      "$ref": "#/$defs/gateway-rules"
    }
  },
  "dependentRequired": {
    "node-path": ["node-version"],
    "npm-script": ["node-version"]
  },
  "not": {
    "required": ["webroot", "webroot-path"]
  },
  "$defs": {
    "gateway-rules": {
      "oneOf": [
        {
          "$ref": "#/$defs/gateway-rule"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/gateway-rule"
          }
        }
      ]
    },
    "gateway-rule": {
      "type": "object",
      "required": ["pattern", "destination"],
      "additionalProperties": true,
      "properties": {
        "pattern": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "subject": {
          "type": "string"
        },
        "destination": {
          "type": "string"
        },
        "status": {
          "type": "integer"
        },
        "headers": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    }
  }
}
