{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:package-index:0.1",
  "title": "Statyczny indeks pakietów Junexis 0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "packages"],
  "properties": {
    "schemaVersion": { "const": "junexis.package-index/0.1" },
    "packages": {
      "type": "array",
      "maxItems": 10000,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "version", "namespace", "manifest", "manifestSha256", "artifact", "artifactSha256"],
        "properties": {
          "id": { "$ref": "#/$defs/packageId" },
          "version": { "$ref": "#/$defs/semver" },
          "namespace": { "$ref": "#/$defs/moduleIdentity" },
          "manifest": { "const": "junexis.package.json" },
          "manifestSha256": { "$ref": "#/$defs/sha256" },
          "artifact": { "$ref": "#/$defs/indexPath" },
          "artifactSha256": { "$ref": "#/$defs/sha256" }
        }
      }
    }
  },
  "$defs": {
    "packageId": { "type": "string", "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$" },
    "moduleIdentity": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*$" },
    "indexPath": {
      "type": "string",
      "maxLength": 1024,
      "pattern": "^(?!.*(?:^|/)\\.{1,2}(?:/|$))[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*\\.zip$",
      "not": {
        "pattern": "(?:^|/)(?:[Cc][Oo][Nn]|[Pp][Rr][Nn]|[Aa][Uu][Xx]|[Nn][Uu][Ll]|[Cc][Oo][Mm][1-9]|[Ll][Pp][Tt][1-9])(?:\\.|/|$)"
      }
    },
    "semver": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-((?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$"
    },
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
  }
}