{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ggaction.github.io/ggaction/schemas/intent-taxonomy.schema.json",
  "title": "ggaction resolver intent taxonomy",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "packageVersion", "constraints", "providers"],
  "properties": {
    "schemaVersion": { "const": 2 },
    "packageVersion": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$"
    },
    "constraints": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "phrases"],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9]+(?:\\.[A-Za-z0-9]+)+$"
          },
          "phrases": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": { "type": "string", "minLength": 2, "maxLength": 100 }
          },
          "exclusiveGroup": { "type": "string", "minLength": 3, "maxLength": 80 },
          "shadows": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]+(?:\\.[A-Za-z0-9]+)+$"
            }
          },
          "unsupported": { "type": "string", "minLength": 20, "maxLength": 300 }
        }
      }
    },
    "providers": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "kind", "name", "order", "anchors", "covers"],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^(?:action|runtime)\\.[A-Za-z][A-Za-z0-9]*$"
          },
          "kind": { "enum": ["action", "runtime"] },
          "name": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9]*$" },
          "order": { "type": "integer", "minimum": 1, "maximum": 1000 },
          "anchors": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]+(?:\\.[A-Za-z0-9]+)+$"
            }
          },
          "covers": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]+(?:\\.[A-Za-z0-9]+)+$"
            }
          },
          "baseOptions": {
            "type": "object",
            "additionalProperties": { "type": "string", "minLength": 1, "maxLength": 700 }
          },
          "optionsByConstraint": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": { "type": "string", "minLength": 1, "maxLength": 700 }
            }
          },
          "signature": { "type": "string", "minLength": 10, "maxLength": 700 },
          "call": { "type": "string", "minLength": 3, "maxLength": 700 },
          "route": { "type": "string", "pattern": "^/" }
        },
        "allOf": [
          {
            "if": { "properties": { "kind": { "const": "runtime" } } },
            "then": {
              "required": ["signature", "call", "route"],
              "properties": {
                "signature": { "type": "string", "minLength": 10, "maxLength": 700 },
                "call": { "type": "string", "minLength": 3, "maxLength": 700 },
                "route": { "type": "string", "pattern": "^/" }
              }
            }
          }
        ]
      }
    }
  }
}
