{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "evaluated_at",
    "evidence",
    "authorities",
    "intents",
    "attempts",
    "outcomes"
  ],
  "properties": {
    "schema": {
      "const": "varexis-transaction-input/1"
    },
    "evaluated_at": {
      "type": "string",
      "minLength": 1,
      "maxLength": 20,
      "format": "date-time"
    },
    "evidence": {
      "type": "array",
      "minItems": 0,
      "maxItems": 1000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "kind",
          "captured_on",
          "artifact_sha256",
          "reference"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "kind": {
            "enum": [
              "inventory",
              "export",
              "deletion",
              "retention",
              "exception",
              "residual",
              "authority",
              "approval",
              "outcome"
            ]
          },
          "captured_on": {
            "type": "string",
            "minLength": 1,
            "maxLength": 10,
            "format": "date"
          },
          "artifact_sha256": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[a-f0-9]{64}$"
          },
          "reference": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        }
      },
      "uniqueItems": true
    },
    "authorities": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "principal_id",
          "valid_from",
          "expires_at",
          "revoked_at",
          "merchant_ids",
          "recipient_ids",
          "currency",
          "per_transaction_max_minor",
          "budget_minor",
          "max_transactions",
          "allow_recurring",
          "allowed_conditions_sha256",
          "evidence_ref"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "principal_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "valid_from": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20,
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20,
            "format": "date-time"
          },
          "revoked_at": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 20,
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "merchant_ids": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80,
              "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
            },
            "uniqueItems": true
          },
          "recipient_ids": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80,
              "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
            },
            "uniqueItems": true
          },
          "currency": {
            "type": "string",
            "minLength": 1,
            "maxLength": 3,
            "pattern": "^[A-Z]{3}$"
          },
          "per_transaction_max_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "budget_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "max_transactions": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          },
          "allow_recurring": {
            "type": "boolean"
          },
          "allowed_conditions_sha256": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[a-f0-9]{64}$"
            },
            "uniqueItems": true
          },
          "evidence_ref": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "uniqueItems": true
    },
    "intents": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "logical_id",
          "authority_id",
          "principal_id",
          "revision",
          "amends",
          "terms",
          "approved_at",
          "approval_evidence_ref"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "logical_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "authority_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "principal_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          },
          "amends": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              {
                "type": "null"
              }
            ]
          },
          "terms": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "merchant_id",
              "recipient_id",
              "currency",
              "amount_minor",
              "recurring",
              "conditions_sha256"
            ],
            "properties": {
              "merchant_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              "recipient_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              "currency": {
                "type": "string",
                "minLength": 1,
                "maxLength": 3,
                "pattern": "^[A-Z]{3}$"
              },
              "amount_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000000000
              },
              "recurring": {
                "type": "boolean"
              },
              "conditions_sha256": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[a-f0-9]{64}$"
              }
            }
          },
          "approved_at": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20,
            "format": "date-time"
          },
          "approval_evidence_ref": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "uniqueItems": true
    },
    "attempts": {
      "type": "array",
      "minItems": 0,
      "maxItems": 1000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "intent_id",
          "sequence",
          "provider",
          "account_id",
          "region",
          "idempotency_key",
          "at",
          "terms_sha256"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "intent_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "sequence": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          },
          "provider": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "account_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "region": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "idempotency_key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "at": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20,
            "format": "date-time"
          },
          "terms_sha256": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[a-f0-9]{64}$"
          }
        }
      },
      "uniqueItems": true
    },
    "outcomes": {
      "type": "array",
      "minItems": 0,
      "maxItems": 1000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "attempt_id",
          "status",
          "payment_ref",
          "amount_minor",
          "currency",
          "merchant_id",
          "recipient_id",
          "evidence_ref"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "attempt_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "status": {
            "enum": [
              "succeeded",
              "failed",
              "pending",
              "unknown",
              "cancelled"
            ]
          },
          "payment_ref": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              {
                "type": "null"
              }
            ]
          },
          "amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "currency": {
            "type": "string",
            "minLength": 1,
            "maxLength": 3,
            "pattern": "^[A-Z]{3}$"
          },
          "merchant_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "recipient_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "evidence_ref": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "uniqueItems": true
    }
  }
}
