{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:channel-promotion:0.1",
  "title": "Promocja kanału Junexis 0.1",
  "description": "Podpisana decyzja o promocji niezmiennego artefaktu lub katalogu między sąsiednimi kanałami (dev -> preview, preview -> stable).",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "fromChannel",
    "toChannel",
    "target",
    "promotedAt",
    "promotedBy",
    "reason",
    "algorithm",
    "keyId",
    "signature"
  ],
  "properties": {
    "schemaVersion": { "const": "junexis.channel-promotion/0.1" },
    "fromChannel": { "enum": ["dev", "preview"] },
    "toChannel": { "enum": ["preview", "stable"] },
    "target": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "id", "version", "sha256"],
      "properties": {
        "type": { "enum": ["platform-release-catalog", "package", "provider"] },
        "id": { "$ref": "#/$defs/identifier" },
        "version": { "$ref": "#/$defs/semver" },
        "sha256": { "$ref": "#/$defs/sha256" }
      }
    },
    "promotedAt": { "$ref": "#/$defs/timestamp" },
    "promotedBy": { "type": "string", "minLength": 1, "maxLength": 256 },
    "reason": { "type": "string", "minLength": 1, "maxLength": 2048 },
    "algorithm": { "const": "ecdsa-p256-sha256-der" },
    "keyId": { "$ref": "#/$defs/keyId" },
    "signature": { "type": "string", "minLength": 1, "contentEncoding": "base64" }
  },
  "$defs": {
    "keyId": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "timestamp": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
    "identifier": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{1,127}$" },
    "semver": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$" },
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
  }
}
