{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "DSH Plugin Manifest Community Draft v0.15",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "manifestVersion", "id", "name", "version", "facets", "requires", "permissions", "contributes", "subscriptions"],
  "properties": {
    "$schema": { "type": "string", "format": "uri" },
    "manifestVersion": { "const": "0.15" },
    "id": { "$ref": "#/$defs/namespacedId" },
    "name": { "type": "string", "minLength": 1 },
    "version": { "type": "string", "minLength": 1 },
    "facets": {
      "type": "object",
      "additionalProperties": false,
      "required": ["host"],
      "properties": {
        "host": {
          "type": "object",
          "additionalProperties": false,
          "required": ["entry", "apiVersion"],
          "properties": {
            "entry": { "type": "string", "minLength": 1, "pattern": "^(?![\\\\/])(?![A-Za-z]:[\\\\/])(?!.*(?:^|[\\\\/])\\.\\.(?:[\\\\/]|$)).+$" },
            "apiVersion": { "type": "string", "pattern": "^v[1-9][0-9]*(?:(?:alpha|beta)[1-9][0-9]*)?$" }
          }
        }
      }
    },
    "requires": {
      "type": "object",
      "additionalProperties": false,
      "required": ["contracts"],
      "properties": {
        "contracts": { "type": "array", "items": { "$ref": "#/$defs/contract" } },
        "services": { "type": "array", "maxItems": 0 }
      }
    },
    "permissions": { "type": "array", "items": { "$ref": "#/$defs/permission" } },
    "contributes": {
      "type": "object",
      "required": ["commands"],
      "properties": {
        "commands": { "type": "array", "items": { "$ref": "#/$defs/command" } },
        "panels": { "type": "array", "maxItems": 0 }
      },
      "patternProperties": { "^x-": { "type": "array" } },
      "additionalProperties": false
    },
    "subscriptions": {
      "type": "array",
      "items": {
        "oneOf": [
          { "type": "string", "minLength": 1 },
          { "$ref": "#/$defs/subscription" }
        ]
      }
    },
    "license": { "type": "string", "minLength": 1 },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repository"],
      "properties": {
        "repository": { "type": "string", "format": "uri" },
        "revision": { "type": "string", "minLength": 1 }
      }
    },
    "artifact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["digest", "algorithm", "path"],
      "properties": {
        "digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
        "algorithm": { "const": "sha256" },
        "path": { "type": "string", "minLength": 1 }
      }
    },
    "compat": {
      "type": "object",
      "additionalProperties": false,
      "properties": { "hosts": { "type": "array", "items": { "type": "string", "minLength": 1 } } }
    },
    "overrides": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["target", "kind"],
        "properties": {
          "target": { "type": "string", "minLength": 1 },
          "kind": { "enum": ["patch", "native", "build"] },
          "description": { "type": "string", "minLength": 1 }
        }
      }
    }
  },
  "patternProperties": { "^x-": {} },
  "$defs": {
    "namespacedId": { "type": "string", "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9][a-z0-9-]*)+$" },
    "apiVersion": { "type": "string", "pattern": "^[a-z][a-z0-9.-]*/v[1-9][0-9]*(?:(?:alpha|beta)[1-9][0-9]*)?$" },
    "kind": { "type": "string", "pattern": "^[A-Z][A-Za-z0-9]*$" },
    "contract": {
      "type": "object",
      "additionalProperties": false,
      "required": ["apiVersion", "kind"],
      "properties": {
        "apiVersion": { "$ref": "#/$defs/apiVersion" },
        "kind": { "$ref": "#/$defs/kind" },
        "optional": { "type": "boolean" },
        "fallback": { "type": "string", "minLength": 1 }
      }
    },
    "permission": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "scope"],
      "properties": {
        "name": { "$ref": "#/$defs/namespacedId" },
        "scope": { "type": "string", "minLength": 1 },
        "reason": { "type": "string", "minLength": 1 }
      }
    },
    "command": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "title"],
      "properties": {
        "id": { "$ref": "#/$defs/namespacedId" },
        "title": { "type": "string", "minLength": 1 },
        "description": { "type": "string", "minLength": 1 }
      }
    },
    "subscription": {
      "type": "object",
      "additionalProperties": false,
      "required": ["apiVersion", "kind"],
      "properties": {
        "apiVersion": { "$ref": "#/$defs/apiVersion" },
        "kind": { "$ref": "#/$defs/kind" },
        "scope": { "type": "string", "minLength": 1 }
      }
    }
  }
}
