{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "PackingList",
  "description": "PKL XML — Packing List (SMPTE ST 2067-2 §9).\n\nAssets carry SHA-1 (default) or SHA-256 checksums. The algorithm is determined by the optional `<HashAlgorithm>` element on each asset.",
  "type": "object",
  "required": [
    "assetList",
    "id",
    "issueDate"
  ],
  "properties": {
    "annotationText": {
      "type": [
        "string",
        "null"
      ]
    },
    "assetList": {
      "$ref": "#/definitions/PklAssetList"
    },
    "creator": {
      "type": [
        "string",
        "null"
      ]
    },
    "groupId": {
      "description": "Optional group identifier for partial deliveries (SMPTE ST 2067-2 §9).",
      "anyOf": [
        {
          "$ref": "#/definitions/ImfUuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "id": {
      "$ref": "#/definitions/ImfUuid"
    },
    "issueDate": {
      "description": "ISO 8601 issue date.",
      "type": "string"
    },
    "issuer": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "definitions": {
    "AssetHash": {
      "description": "A decoded asset hash from a Packing List, per SMPTE ST 2067-2 §9.\n\nPKL files carry base64-encoded SHA-1 or SHA-256 digests for each tracked asset.",
      "type": "object",
      "required": [
        "algorithm",
        "bytes"
      ],
      "properties": {
        "algorithm": {
          "$ref": "#/definitions/HashAlgorithm"
        },
        "bytes": {
          "type": "array",
          "items": {
            "type": "integer",
            "format": "uint8",
            "minimum": 0.0
          }
        }
      }
    },
    "HashAlgorithm": {
      "description": "The hash algorithm used for a PKL asset digest.\n\nPer SMPTE ST 2067-2:2020 §9, SHA-1 is the default algorithm. SHA-256 is supported via the `<HashAlgorithm>` element using XML Digital Signature algorithm URIs.",
      "oneOf": [
        {
          "description": "SHA-1 (default per ST 2067-2 §9). URI: `http://www.w3.org/2000/09/xmldsig#sha1`",
          "type": "string",
          "enum": [
            "Sha1"
          ]
        },
        {
          "description": "SHA-256. URI: `http://www.w3.org/2001/04/xmlenc#sha256`",
          "type": "string",
          "enum": [
            "Sha256"
          ]
        }
      ]
    },
    "ImfUuid": {
      "description": "A SMPTE IMF UUID, serialised as a bare UUID string (e.g. \"0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca85\")",
      "type": "string",
      "format": "uuid"
    },
    "MimeType": {
      "description": "MIME type as used in `<Type>` elements in PKL assets (SMPTE ST 2067-2 §9).",
      "oneOf": [
        {
          "description": "`text/xml` — CPL and other XML documents",
          "type": "string",
          "enum": [
            "TextXml"
          ]
        },
        {
          "description": "`application/xml` — alternative XML MIME type",
          "type": "string",
          "enum": [
            "ApplicationXml"
          ]
        },
        {
          "description": "`application/mxf` — MXF essence files",
          "type": "string",
          "enum": [
            "ApplicationMxf"
          ]
        },
        {
          "description": "Unrecognised; the original string is preserved.",
          "type": "object",
          "required": [
            "Other"
          ],
          "properties": {
            "Other": {
              "type": "string"
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "PklAsset": {
      "description": "A single asset entry in a PKL.",
      "type": "object",
      "required": [
        "hash",
        "id",
        "mimeType",
        "size"
      ],
      "properties": {
        "annotationText": {
          "type": [
            "string",
            "null"
          ]
        },
        "hash": {
          "description": "SHA-1 digest decoded from the base64 `<Hash>` element (SMPTE ST 2067-2 §9.3).",
          "allOf": [
            {
              "$ref": "#/definitions/AssetHash"
            }
          ]
        },
        "id": {
          "$ref": "#/definitions/ImfUuid"
        },
        "mimeType": {
          "description": "MIME type of the asset file (SMPTE ST 2067-2 §9.4).",
          "allOf": [
            {
              "$ref": "#/definitions/MimeType"
            }
          ]
        },
        "originalFileName": {
          "type": [
            "string",
            "null"
          ]
        },
        "size": {
          "description": "File size in bytes.",
          "type": "integer",
          "format": "uint64",
          "minimum": 0.0
        }
      }
    },
    "PklAssetList": {
      "description": "The `<AssetList>` element in a PKL.",
      "type": "object",
      "required": [
        "assets"
      ],
      "properties": {
        "assets": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PklAsset"
          }
        }
      }
    }
  }
}