{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:apuos:spkg:index:1.0",
  "title": "ApuOS package source index v1.0",
  "type": "object",
  "additionalProperties": false,
  "required": ["format_version", "source_id", "revision", "generated_at", "packages"],
  "properties": {
    "format_version": {"const": "1.0"},
    "source_id": {"type": "string", "pattern": "^[a-z][a-z0-9.-]{2,127}$"},
    "revision": {"type": "integer", "minimum": 1},
    "generated_at": {"type": "string", "format": "date-time"},
    "packages": {
      "type": "array", "maxItems": 10000,
      "items": {
        "type": "object", "additionalProperties": false,
        "required": ["pkg_id", "version", "architecture", "name", "description", "category", "author", "url", "size", "sha256", "key_id", "published_at"],
        "properties": {
          "pkg_id": {"type": "string", "maxLength": 128, "pattern": "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*){2,}$"},
          "version": {"type": "string", "maxLength": 60, "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"},
          "architecture": {"type": "array", "minItems": 1, "maxItems": 2, "uniqueItems": true, "items": {"enum": ["x86_64", "arm64"]}},
          "name": {"type": "string", "minLength": 1, "maxLength": 100},
          "description": {"type": "string", "minLength": 1, "maxLength": 4000},
          "category": {"enum": ["system", "storage", "network", "media", "development", "security", "business"]},
          "author": {"type": "string", "minLength": 1, "maxLength": 100},
          "url": {"type": "string", "maxLength": 256, "pattern": "^packages/[A-Za-z0-9][A-Za-z0-9._/-]*\\.spkg$"},
          "size": {"type": "integer", "minimum": 13, "maximum": 67125260},
          "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
          "key_id": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
          "published_at": {"type": "string", "format": "date-time"},
          "release_notes": {"type": "string", "maxLength": 10000},
          "withdrawn": {"type": "boolean"}
        }
      }
    }
  }
}
