{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vendoo.local/contracts/module.schema.json",
  "title": "Vendoo Module Manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "id",
    "name",
    "version",
    "type",
    "status",
    "requires",
    "permissions",
    "provides",
    "consumes",
    "owns"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^vendoo\\.[a-z][a-z0-9-]*$"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$"
    },
    "type": {
      "enum": [
        "core",
        "feature",
        "adapter",
        "extension-host"
      ]
    },
    "status": {
      "enum": [
        "native",
        "legacy-bridge",
        "disabled"
      ]
    },
    "defaultEnabled": {
      "type": "boolean",
      "default": true
    },
    "description": {
      "type": "string",
      "maxLength": 500
    },
    "requires": {
      "$ref": "#/$defs/moduleIds"
    },
    "permissions": {
      "$ref": "#/$defs/capabilities"
    },
    "provides": {
      "$ref": "#/$defs/capabilities"
    },
    "consumes": {
      "$ref": "#/$defs/capabilities"
    },
    "owns": {
      "$ref": "#/$defs/capabilities"
    }
  },
  "$defs": {
    "moduleIds": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^vendoo\\.[a-z][a-z0-9-]*$"
      }
    },
    "capabilities": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]*(?:\\.[a-z][a-z0-9-]*)+$"
      }
    }
  }
}
