{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://graxana.com/schemas/axima-workforce/manifest-v1.schema.json",
  "title": "AximaApp v2 to Axima Workforce bundle manifest v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["contract", "schema_version", "bundle_id", "created_at", "source", "entities", "preflight", "files", "checksums", "excluded_secret_classes"],
  "properties": {
    "contract": {"const": "axima-workforce-migration-bundle"},
    "schema_version": {"const": 1},
    "bundle_id": {"type": "string", "format": "uuid"},
    "created_at": {"type": "string", "format": "date-time"},
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["application", "application_version", "timezone", "currency"],
      "properties": {
        "application": {"const": "aximaapp_v2"},
        "application_version": {"type": ["string", "null"]},
        "timezone": {"type": "string", "minLength": 1},
        "currency": {"type": "string", "pattern": "^[A-Z]{3}$"}
      }
    },
    "entities": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": ["status", "count"],
        "properties": {
          "status": {"enum": ["available", "missing", "not_applicable"]},
          "file": {"type": ["string", "null"]},
          "count": {"type": "integer", "minimum": 0},
          "sha256": {"type": ["string", "null"], "pattern": "^[a-f0-9]{64}$"},
          "archive_only": {"type": "boolean"}
        }
      }
    },
    "preflight": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ready", "error_count", "warning_count", "file", "sha256"],
      "properties": {
        "ready": {"type": "boolean"},
        "error_count": {"type": "integer", "minimum": 0},
        "warning_count": {"type": "integer", "minimum": 0},
        "file": {"const": "preflight.json"},
        "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}
      }
    },
    "files": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["path", "sha256", "size_bytes"],
        "properties": {
          "path": {"type": "string", "pattern": "^files/[a-f0-9]{64}\\.[A-Za-z0-9]+$"},
          "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
          "size_bytes": {"type": "integer", "minimum": 0},
          "mime_type": {"type": ["string", "null"]},
          "source_name": {"type": ["string", "null"]}
        }
      }
    },
    "checksums": {
      "type": "object",
      "additionalProperties": false,
      "required": ["algorithm", "file"],
      "properties": {
        "algorithm": {"const": "sha256"},
        "file": {"const": "checksums.sha256"}
      }
    },
    "excluded_secret_classes": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {"type": "string"}
    }
  }
}
