{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:uninstall-plan:0.1",
  "title": "Plan odinstalowania Junexis 0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "planId", "operation", "createdAt", "rid", "expectedGeneration", "activeRelease", "mode", "explicitProfileDataConsentRequired", "items", "estimatedRemovalBytes", "restartRequired"],
  "properties": {
    "schemaVersion": { "const": "junexis.uninstall-plan/0.1" },
    "planId": { "$ref": "#/$defs/identifier" },
    "operation": { "const": "uninstall" },
    "createdAt": { "$ref": "#/$defs/timestamp" },
    "rid": { "enum": ["win-x64", "linux-x64", "osx-arm64"] },
    "expectedGeneration": { "type": "integer", "minimum": 1 },
    "activeRelease": { "$ref": "#/$defs/release" },
    "mode": { "enum": ["program-only", "program-and-cache", "all-platform-data"] },
    "explicitProfileDataConsentRequired": { "type": "boolean" },
    "items": {
      "type": "array",
      "minItems": 8,
      "maxItems": 8,
      "items": { "$ref": "#/$defs/item" }
    },
    "estimatedRemovalBytes": { "type": "integer", "minimum": 0 },
    "restartRequired": { "type": "boolean" }
  },
  "allOf": [
    {
      "if": { "properties": { "mode": { "const": "all-platform-data" } }, "required": ["mode"] },
      "then": { "properties": { "explicitProfileDataConsentRequired": { "const": true } } }
    },
    {
      "if": { "properties": { "mode": { "enum": ["program-only", "program-and-cache"] } }, "required": ["mode"] },
      "then": { "properties": { "explicitProfileDataConsentRequired": { "const": false } } }
    }
  ],
  "$defs": {
    "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}(?![\\s\\S])" },
    "timestamp": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
    "release": {
      "type": "object",
      "additionalProperties": false,
      "required": ["releaseId", "version", "manifestSha256"],
      "properties": {
        "releaseId": { "$ref": "#/$defs/identifier" },
        "version": { "$ref": "#/$defs/semver" },
        "manifestSha256": { "$ref": "#/$defs/sha256" }
      }
    },
    "item": {
      "type": "object",
      "additionalProperties": false,
      "required": ["category", "ownership", "action", "estimatedBytes", "message"],
      "properties": {
        "category": { "enum": ["program", "launcher", "cache", "settings", "provider-profiles", "laboratory-copies", "projects", "user-data"] },
        "ownership": { "enum": ["platform", "user"] },
        "action": { "enum": ["remove", "preserve"] },
        "estimatedBytes": { "type": "integer", "minimum": 0 },
        "message": { "type": "string", "minLength": 1, "maxLength": 512 }
      }
    }
  }
}
