{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://forms.takoform.com/schemas/support/v1alpha1/host-support-profile.schema.json",
  "title": "Takoform Host Support Profile v1alpha1",
  "type": "object",
  "additionalProperties": false,
  "required": ["apiVersion", "kind"],
  "properties": {
    "apiVersion": {
      "const": "support.takoform.com/v1alpha1"
    },
    "kind": {
      "enum": ["FormSupport", "InterfaceSupport", "BindingSupport"]
    },
    "formRef": {
      "$ref": "https://forms.takoform.com/schemas/v1alpha3/form-ref.schema.json"
    },
    "interfaceRef": {
      "$ref": "https://forms.takoform.com/schemas/interfaces/v1alpha1/interface-ref.schema.json"
    },
    "bindingRef": {
      "$ref": "https://forms.takoform.com/schemas/bindings/v1alpha1/binding-ref.schema.json"
    },
    "operations": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "enum": ["create", "read", "update", "delete", "import", "observe", "refresh"]
      }
    },
    "supportedEnums": {
      "type": "object",
      "additionalProperties": false,
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-zA-Z0-9]{0,63}$",
        "x-takoform-fieldPolicy": "portable-data-only-v1"
      },
      "patternProperties": {
        "^[a-z][a-zA-Z0-9]{0,63}$": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "maxLength": 128
          }
        }
      },
      "description": "For each closed-enum desired field, the subset of enum values this host accepts."
    },
    "supportedRanges": {
      "type": "object",
      "additionalProperties": false,
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-zA-Z0-9]{0,63}$",
        "x-takoform-fieldPolicy": "portable-data-only-v1"
      },
      "patternProperties": {
        "^[a-z][a-zA-Z0-9]{0,63}$": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "minimum": {
              "type": ["integer", "string"]
            },
            "maximum": {
              "type": ["integer", "string"]
            }
          },
          "description": "Inclusive bounds this host accepts for one desired field; date-valued ranges use ISO 8601 date strings."
        }
      }
    },
    "supportedBindings": {
      "type": "array",
      "uniqueItems": true,
      "maxItems": 256,
      "items": {
        "type": "string",
        "maxLength": 256,
        "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z][a-z0-9]*)*@(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
      },
      "description": "Binding contracts this host implements, as name@version display refs; the exact digests are resolvable through the binding support endpoint."
    },
    "limits": {
      "type": "object",
      "additionalProperties": false,
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-zA-Z0-9]{0,63}$",
        "x-takoform-fieldPolicy": "portable-data-only-v1"
      },
      "patternProperties": {
        "^[a-z][a-zA-Z0-9]{0,63}$": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9223372036854775807
        }
      },
      "description": "Host capability ceilings such as maximumBundleBytes. Price, SKU, region, quota, and commercial policy never appear in a support profile."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": { "kind": { "const": "FormSupport" } },
        "required": ["kind"]
      },
      "then": {
        "required": ["formRef", "operations"],
        "not": {
          "anyOf": [{ "required": ["interfaceRef"] }, { "required": ["bindingRef"] }]
        }
      }
    },
    {
      "if": {
        "properties": { "kind": { "const": "InterfaceSupport" } },
        "required": ["kind"]
      },
      "then": {
        "required": ["interfaceRef"],
        "not": {
          "anyOf": [{ "required": ["formRef"] }, { "required": ["bindingRef"] }]
        }
      }
    },
    {
      "if": {
        "properties": { "kind": { "const": "BindingSupport" } },
        "required": ["kind"]
      },
      "then": {
        "required": ["bindingRef"],
        "not": {
          "anyOf": [{ "required": ["formRef"] }, { "required": ["interfaceRef"] }]
        }
      }
    }
  ]
}
