{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://apinterface.com/schema/module.manifest.json",
  "title": "APInterface Module Manifest",
  "type": "object",
  "required": ["name", "version", "type", "compatibility", "entrypoint"],
  "properties": {
    "name": { "type": "string", "minLength": 1 },
    "version": { "type": "string", "minLength": 1 },
    "type": { "type": "string", "const": "module" },
    "compatibility": {
      "type": "object",
      "required": ["core"],
      "properties": {
        "core": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "entrypoint": { "type": "string", "minLength": 1 },
    "migrations": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "default": []
    },
    "displayName": { "type": "string" },
    "description": { "type": "string" },
    "credentialSlots": {
      "type": "array",
      "description": "Zugangsarten pro App (Core speichert verschlüsselt; UI unter /apps/<appKey>/access).",
      "items": {
        "type": "object",
        "required": ["id", "label", "kind"],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "label": { "type": "string", "minLength": 1, "maxLength": 255 },
          "kind": {
            "type": "string",
            "enum": ["secret", "password", "text", "choice"]
          },
          "required": { "type": "boolean", "default": false },
          "description": { "type": "string", "maxLength": 2000 },
          "options": {
            "type": "array",
            "description": "Bei kind=choice: Auswahloptionen (value/label).",
            "items": {
              "type": "object",
              "required": ["value", "label"],
              "additionalProperties": false,
              "properties": {
                "value": { "type": "string", "minLength": 1, "maxLength": 128 },
                "label": { "type": "string", "minLength": 1, "maxLength": 255 }
              }
            },
            "default": []
          },
          "credentialProbe": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "kind": { "type": "string", "enum": ["none", "mysql"] },
              "mysql": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "hostSlot": { "type": "string", "minLength": 1 },
                  "portSlot": { "type": "string" },
                  "userSlot": { "type": "string", "minLength": 1 },
                  "passwordSlot": { "type": "string", "minLength": 1 },
                  "databaseSlot": { "type": "string" }
                },
                "required": ["hostSlot", "userSlot", "passwordSlot"]
              }
            },
            "required": ["kind"]
          }
        }
      },
      "default": []
    },
    "httpApiV1": {
      "type": "boolean",
      "description": "true = Modul stellt HTTP-API v1 bereit (Datei src/api/registerApiV1.js, Export registerApiV1). Core mountet unter /api/v1/modules/<manifest-id>/; Clients brauchen PAT-Scope api.modules.invoke. Menschenlesbare Core-Doku: /docs/http-api-v1 — optionales apiV1Module fuer Drittentwickler-Metadaten."
    },
    "apiV1Module": {
      "type": "object",
      "description": "Optional: Metadaten fuer Drittentwickler und Marktplaetze (ersetzt httpApiV1 nicht; httpApiV1 sollte true sein, wenn Routen existieren).",
      "additionalProperties": false,
      "properties": {
        "registerPath": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255,
          "default": "src/api/registerApiV1.js",
          "description": "Relativ zum Modul-Release; Standard wie vom Core geladen."
        },
        "summary": {
          "type": "string",
          "maxLength": 2000,
          "description": "Kurzbeschreibung der Modul-API (Endpunkte, Use Cases)."
        },
        "documentationUrl": {
          "type": "string",
          "maxLength": 512,
          "description": "HTTPS-URL zu eurer ausfuehrlichen API-Doku (OpenAPI, README o. ae.)."
        }
      }
    }
  },
  "additionalProperties": false
}
