{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "TideStack capability catalog",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "minLength": 1
    },
    "schemaVersion": {
      "const": "1.0.0"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "revision": {
          "type": "string",
          "pattern": "^[a-f0-9]{40}$"
        },
        "basis": {
          "const": "working-tree"
        },
        "verification": {
          "const": "source-reviewed"
        },
        "runtimeVerified": {
          "const": false
        }
      },
      "required": [
        "revision",
        "basis",
        "verification",
        "runtimeVerified"
      ]
    },
    "scope": {
      "type": "string",
      "minLength": 1
    },
    "selectionRules": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "categories": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "name"
        ]
      }
    },
    "accessLabels": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "metadata": {
          "type": "string",
          "minLength": 1
        },
        "java": {
          "type": "string",
          "minLength": 1
        },
        "sdk": {
          "type": "string",
          "minLength": 1
        },
        "schema": {
          "type": "string",
          "minLength": 1
        },
        "module": {
          "type": "string",
          "minLength": 1
        },
        "spi": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "metadata",
        "java",
        "sdk",
        "schema",
        "module",
        "spi"
      ]
    },
    "availabilityLabels": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "assembled": {
          "type": "string",
          "minLength": 1
        },
        "host": {
          "type": "string",
          "minLength": 1
        },
        "optional": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "assembled",
        "host",
        "optional"
      ]
    },
    "exclusions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "reason": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "name",
          "reason"
        ]
      }
    },
    "capabilities": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^(fe|be)\\.[a-z0-9]+(?:[.-][a-z0-9]+)*$"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "side": {
            "enum": [
              "frontend",
              "backend"
            ]
          },
          "category": {
            "type": "string",
            "minLength": 1
          },
          "summary": {
            "type": "string",
            "minLength": 1
          },
          "useWhen": {
            "type": "string",
            "minLength": 1
          },
          "entryPoints": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 1,
            "uniqueItems": true
          },
          "access": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "enum": [
                "metadata",
                "java",
                "sdk",
                "schema",
                "module",
                "spi"
              ]
            }
          },
          "availability": {
            "enum": [
              "assembled",
              "host",
              "optional"
            ]
          },
          "requires": {
            "type": "string",
            "minLength": 1
          },
          "limits": {
            "type": "string",
            "minLength": 1
          },
          "modules": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 1,
            "uniqueItems": true
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 1,
            "uniqueItems": true
          },
          "docs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "path": {
                  "type": "string",
                  "minLength": 1
                },
                "coverage": {
                  "enum": [
                    "guide",
                    "related"
                  ]
                }
              },
              "required": [
                "path",
                "coverage"
              ]
            }
          },
          "related": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "verification": {
            "const": "source-reviewed"
          }
        },
        "required": [
          "id",
          "name",
          "side",
          "category",
          "summary",
          "useWhen",
          "entryPoints",
          "access",
          "availability",
          "requires",
          "limits",
          "modules",
          "sources",
          "docs",
          "related",
          "verification"
        ]
      }
    }
  },
  "required": [
    "$schema",
    "schemaVersion",
    "title",
    "source",
    "scope",
    "selectionRules",
    "categories",
    "accessLabels",
    "availabilityLabels",
    "exclusions",
    "capabilities"
  ]
}
