{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mcbasic.org/schemas/component-sdk/package.schema.v1.json",
  "title": "McBasic Component SDK package manifest v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion", "id", "version", "minimumMcBasicVersion", "vendor",
    "description", "profile", "capabilities", "platforms", "components",
    "dependencies", "license"
  ],
  "properties": {
    "schemaVersion": { "const": 1 },
    "id": { "$ref": "#/$defs/qualifiedIdentifier" },
    "version": { "$ref": "#/$defs/semanticVersion" },
    "minimumMcBasicVersion": { "$ref": "#/$defs/semanticVersion" },
    "vendor": { "type": "string", "minLength": 1, "maxLength": 120 },
    "description": { "type": "string", "maxLength": 4000 },
    "profile": { "enum": ["Library", "UserControlLibrary", "CSharpComponent"] },
    "capabilities": {
      "type": "array",
      "uniqueItems": true,
      "items": { "type": "string", "minLength": 1 }
    },
    "platforms": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "enum": ["osx-arm64", "osx-x64", "windows-x64", "linux-x64"] }
    },
    "components": {
      "type": "array",
      "minItems": 1,
      "maxItems": 256,
      "items": { "$ref": "#/$defs/component" }
    },
    "dependencies": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "version"],
        "properties": {
          "id": { "$ref": "#/$defs/qualifiedIdentifier" },
          "version": { "$ref": "#/$defs/semanticVersion" }
        }
      }
    },
    "license": {
      "type": "object",
      "additionalProperties": false,
      "required": ["spdx", "path"],
      "properties": {
        "spdx": { "type": "string", "minLength": 1 },
        "path": { "$ref": "#/$defs/packagePath" }
      }
    }
  },
  "$defs": {
    "identifier": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
    "qualifiedIdentifier": {
      "type": "string",
      "pattern": "^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$"
    },
    "semanticVersion": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "packagePath": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.?/)(?!.*\\\\).+$"
    },
    "component": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id", "basicName", "displayName", "typeName", "runtimeType", "category",
        "nonVisual", "container", "metadata", "runtimeAssemblies"
      ],
      "properties": {
        "id": { "$ref": "#/$defs/qualifiedIdentifier" },
        "basicName": { "$ref": "#/$defs/identifier" },
        "displayName": { "type": "string", "minLength": 1 },
        "typeName": { "$ref": "#/$defs/identifier" },
        "runtimeType": { "type": "string", "minLength": 1 },
        "category": { "type": "string", "minLength": 1 },
        "nonVisual": { "type": "boolean" },
        "container": { "type": "boolean" },
        "metadata": { "$ref": "#/$defs/packagePath" },
        "icon": { "$ref": "#/$defs/packagePath" },
        "documentation": { "$ref": "#/$defs/packagePath" },
        "runtimeAssemblies": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/packagePath" }
        }
      }
    }
  }
}
