{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developers.nextcommerce.com/capabilities.schema.json",
  "title": "Next Commerce platform capability map",
  "description": "A projection over the Next Commerce documentation sites and API specifications. Each capability connects merchant guides, developer guides, Admin API operations, webhook events, and AI agent skills under one stable id. The owning sources win whenever they disagree with this file.",
  "type": "object",
  "required": ["version", "generated_at", "sources", "bundles", "capabilities"],
  "properties": {
    "$schema": { "type": "string" },
    "version": { "const": 1 },
    "generated_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
    "sources": {
      "type": "object",
      "required": ["developer_docs", "merchant_docs", "changelog", "admin_api_spec", "admin_api_versions", "stable_api_version"],
      "properties": {
        "developer_docs": { "type": "string", "format": "uri" },
        "merchant_docs": { "type": "string", "format": "uri" },
        "changelog": { "type": "string", "format": "uri" },
        "admin_api_spec": { "type": "string", "format": "uri" },
        "admin_api_versions": { "type": "array", "items": { "type": "string" } },
        "stable_api_version": { "type": "string" }
      }
    },
    "bundles": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "title", "intro", "url", "capabilities"],
        "properties": {
          "id": { "$ref": "#/$defs/id" },
          "title": { "type": "string" },
          "intro": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "capabilities": { "type": "array", "items": { "$ref": "#/$defs/id" } }
        }
      }
    },
    "capabilities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "title", "summary", "audiences", "operator_docs", "developer_docs", "api_operations", "webhooks", "skills", "status", "last_verified", "notes"],
        "properties": {
          "id": { "$ref": "#/$defs/id" },
          "title": { "type": "string" },
          "summary": { "type": "string" },
          "audiences": { "type": "array", "items": { "enum": ["merchant", "developer"] } },
          "operator_docs": { "type": "array", "items": { "type": "string", "format": "uri" } },
          "developer_docs": { "type": "array", "items": { "type": "string", "format": "uri" } },
          "api_operations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["id", "method", "path", "summary", "url"],
              "properties": {
                "id": { "type": "string" },
                "method": { "enum": ["GET", "POST", "PUT", "PATCH", "DELETE"] },
                "path": { "type": "string" },
                "summary": { "type": "string" },
                "url": { "type": ["string", "null"] }
              }
            }
          },
          "webhooks": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["event", "url"],
              "properties": {
                "event": { "type": "string", "pattern": "^[a-z_]+\\.[a-z_]+$" },
                "url": { "type": ["string", "null"] }
              }
            }
          },
          "skills": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name", "url"],
              "properties": { "name": { "type": "string" }, "url": { "type": "string", "format": "uri" } }
            }
          },
          "status": { "enum": ["available", "beta", "deprecated"] },
          "last_verified": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
          "notes": { "type": "array", "items": { "type": "string" } }
        }
      }
    }
  },
  "$defs": {
    "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" }
  }
}
