{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.bseshop.com.tr/schemas/release-metadata-v1.json",
  "title": "BSE Shop Signed Release Metadata Payload v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["artifact", "channel", "migrations", "package", "permissions_added", "published_at", "requires", "security", "version"],
  "properties": {
    "artifact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["checksums_manifest_sha256", "sha256", "signature", "signing_key_id", "size_bytes"],
      "properties": {
        "checksums_manifest_sha256": { "$ref": "#/$defs/sha256" },
        "sha256": { "$ref": "#/$defs/sha256" },
        "signature": { "$ref": "#/$defs/base64url" },
        "signing_key_id": { "$ref": "#/$defs/code" },
        "size_bytes": { "type": "integer", "minimum": 1, "maximum": 16777216 }
      }
    },
    "channel": { "enum": ["stable", "candidate", "development"] },
    "migrations": {
      "type": "object",
      "additionalProperties": false,
      "required": ["count", "destructive"],
      "properties": {
        "count": { "type": "integer", "minimum": 0, "maximum": 10000 },
        "destructive": { "type": "boolean" }
      }
    },
    "package": { "type": "string", "pattern": "^(plugin|theme)/[a-z0-9]+(-[a-z0-9]+)*$" },
    "permissions_added": {
      "type": "array",
      "maxItems": 256,
      "uniqueItems": true,
      "items": { "type": "string" }
    },
    "published_at": { "type": "string", "format": "date-time" },
    "requires": {
      "type": "object",
      "additionalProperties": false,
      "required": ["core", "mariadb", "php", "plugins"],
      "properties": {
        "core": { "$ref": "#/$defs/range" },
        "mariadb": { "$ref": "#/$defs/range" },
        "php": { "$ref": "#/$defs/range" },
        "plugins": {
          "type": "object",
          "propertyNames": { "$ref": "#/$defs/slug" },
          "additionalProperties": { "$ref": "#/$defs/range" }
        }
      }
    },
    "security": {
      "type": "object",
      "additionalProperties": false,
      "required": ["advisory_id", "is_security_update"],
      "properties": {
        "advisory_id": { "type": ["string", "null"], "pattern": "^[A-Z0-9][A-Z0-9._-]{2,127}$" },
        "is_security_update": { "type": "boolean" }
      }
    },
    "version": { "$ref": "#/$defs/semver" }
  },
  "$defs": {
    "base64url": { "type": "string", "pattern": "^[A-Za-z0-9_-]+$" },
    "code": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,127}$" },
    "range": { "type": "string", "pattern": "^((>=|<=|>|<|=)?[0-9]+\\.[0-9]+(\\.[0-9]+)?)( ((>=|<=|>|<|=)?[0-9]+\\.[0-9]+(\\.[0-9]+)?))*$" },
    "semver": { "type": "string", "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" },
    "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "slug": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" }
  }
}
