{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:sitla:payments:1:schema:evidence-bundle",
  "$comment": "SPDX-License-Identifier: CC0-1.0; a signed page is not proof of global completeness.",
  "type": "object",
  "properties": {
    "manifest": {
      "type": "object",
      "properties": {
        "type": {
          "const": "SitlaEvidenceExport"
        },
        "version": {
          "const": 1
        },
        "operator": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "account": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 2048
            },
            "controllerDid": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 2048
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "id",
            "controllerDid"
          ],
          "additionalProperties": false
        },
        "kind": {
          "enum": [
            "all",
            "payments"
          ]
        },
        "transactionId": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "exportedAt": {
          "type": "string",
          "pattern": "^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(?:\\.\\d{3})?Z$"
        },
        "complete": {
          "type": "boolean"
        },
        "cursor": {
          "type": "string",
          "maxLength": 2048
        },
        "nextCursor": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "limitations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "minItems": 1,
          "maxItems": 100
        },
        "records": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
              },
              "digest": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            },
            "required": [
              "id",
              "digest"
            ],
            "additionalProperties": false
          },
          "minItems": 0,
          "maxItems": 100
        },
        "statusObservations": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
              },
              "status": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2048
              },
              "observedAt": {
                "type": "string",
                "pattern": "^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(?:\\.\\d{3})?Z$"
              }
            },
            "required": [
              "id",
              "status",
              "observedAt"
            ],
            "additionalProperties": false
          },
          "minItems": 0,
          "maxItems": 100
        },
        "attachments": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2048
              },
              "reference": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2048
              },
              "digest": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            },
            "required": [
              "kind",
              "reference",
              "digest"
            ],
            "additionalProperties": false
          },
          "minItems": 0,
          "maxItems": 100
        },
        "schemaDigest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "keyMaterialDigest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "required": [
        "type",
        "version",
        "operator",
        "account",
        "kind",
        "transactionId",
        "exportedAt",
        "complete",
        "cursor",
        "nextCursor",
        "limitations",
        "records",
        "statusObservations",
        "attachments",
        "schemaDigest",
        "keyMaterialDigest"
      ],
      "additionalProperties": false
    },
    "signedManifest": {
      "type": "string",
      "minLength": 1,
      "maxLength": 65536
    },
    "records": {
      "type": "array",
      "items": {
        "type": "object"
      },
      "minItems": 0,
      "maxItems": 100
    },
    "attachments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "reference": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "document": {
            "type": "object"
          }
        },
        "required": [
          "kind",
          "reference",
          "document"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "maxItems": 100
    },
    "schema": {
      "type": "object"
    },
    "keyMaterial": {
      "type": "object",
      "properties": {
        "keys": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "minItems": 1,
          "maxItems": 100
        }
      },
      "required": [
        "keys"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "manifest",
    "signedManifest",
    "records",
    "attachments",
    "schema",
    "keyMaterial"
  ],
  "additionalProperties": false
}
