{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://evidence.contact/workflow-compatibility.schema.json",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "protocol",
    "updatedAt",
    "access",
    "purpose",
    "capabilities",
    "runtimeAssessment",
    "readinessIsPaymentAuthority",
    "workflows",
    "clients",
    "settlementModes",
    "stopConditions",
    "validation",
    "httpSchema"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "minLength": 1
    },
    "protocol": {
      "const": "402mob.workflow-compatibility.v1"
    },
    "updatedAt": {
      "type": "string",
      "minLength": 1
    },
    "access": {
      "type": "string",
      "minLength": 1
    },
    "purpose": {
      "type": "string",
      "minLength": 1
    },
    "capabilities": {
      "type": "string",
      "minLength": 1
    },
    "httpSchema": {
      "type": "string",
      "minLength": 1
    },
    "runtimeAssessment": {
      "type": "string",
      "minLength": 1
    },
    "readinessIsPaymentAuthority": {
      "const": false
    },
    "workflows": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "goal",
          "settlementMode",
          "guide",
          "requires",
          "completion"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "goal": {
            "type": "string",
            "minLength": 1
          },
          "guide": {
            "type": "string",
            "minLength": 1
          },
          "completion": {
            "type": "string",
            "minLength": 1
          },
          "settlementMode": {
            "enum": [
              "none",
              "unagreed",
              "direct_prepared",
              "direct_prepayment",
              "protected_inspection",
              "protected_json"
            ]
          },
          "requires": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    },
    "clients": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "release",
          "steps",
          "missing",
          "guide"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "release": {
            "type": "string",
            "minLength": 1
          },
          "guide": {
            "type": "string",
            "minLength": 1
          },
          "distribution": {
            "type": "string",
            "minLength": 1
          },
          "steps": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "missing": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    },
    "settlementModes": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "direct_prepared",
        "direct_prepayment",
        "protected_inspection",
        "protected_json"
      ],
      "properties": {
        "direct_prepared": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "paymentRecipient",
            "delivery",
            "conditionalRefund",
            "qualityJudgment"
          ],
          "properties": {
            "paymentRecipient": {
              "type": "string",
              "minLength": 1
            },
            "delivery": {
              "type": "string",
              "minLength": 1
            },
            "conditionalRefund": {
              "type": "boolean"
            },
            "qualityJudgment": {
              "type": "boolean"
            }
          }
        },
        "direct_prepayment": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "paymentRecipient",
            "delivery",
            "conditionalRefund",
            "qualityJudgment"
          ],
          "properties": {
            "paymentRecipient": {
              "type": "string",
              "minLength": 1
            },
            "delivery": {
              "type": "string",
              "minLength": 1
            },
            "conditionalRefund": {
              "type": "boolean"
            },
            "qualityJudgment": {
              "type": "boolean"
            }
          }
        },
        "protected_inspection": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "paymentRecipient",
            "discoveryCapabilityConvention",
            "selectionPath",
            "requiredHandoff",
            "forbiddenHandoff",
            "configurationPath",
            "requireConfigured",
            "taskPolicy",
            "conditionalRefund",
            "refundScope",
            "qualityJudgment",
            "independentHttpObservation"
          ],
          "properties": {
            "paymentRecipient": {
              "type": "string",
              "minLength": 1
            },
            "discoveryCapabilityConvention": {
              "type": "string",
              "minLength": 1
            },
            "selectionPath": {
              "type": "string",
              "minLength": 1
            },
            "requiredHandoff": {
              "type": "string",
              "minLength": 1
            },
            "forbiddenHandoff": {
              "type": "string",
              "minLength": 1
            },
            "configurationPath": {
              "type": "string",
              "minLength": 1
            },
            "requireConfigured": {
              "type": "boolean"
            },
            "taskPolicy": {
              "type": "string",
              "minLength": 1
            },
            "conditionalRefund": {
              "type": "boolean"
            },
            "refundScope": {
              "type": "string",
              "minLength": 1
            },
            "qualityJudgment": {
              "type": "boolean"
            },
            "independentHttpObservation": {
              "type": "boolean"
            }
          }
        },
        "protected_json": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "paymentRecipient",
            "configurationPath",
            "requireConfigured",
            "taskPolicy",
            "conditionalRefund",
            "refundScope",
            "qualityJudgment"
          ],
          "properties": {
            "paymentRecipient": {
              "type": "string",
              "minLength": 1
            },
            "configurationPath": {
              "type": "string",
              "minLength": 1
            },
            "requireConfigured": {
              "type": "boolean"
            },
            "taskPolicy": {
              "type": "string",
              "minLength": 1
            },
            "conditionalRefund": {
              "type": "boolean"
            },
            "refundScope": {
              "type": "string",
              "minLength": 1
            },
            "qualityJudgment": {
              "type": "boolean"
            }
          }
        }
      }
    },
    "stopConditions": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "validation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "preparedPurchase",
        "freshRequestToDirectDelivery",
        "protectedInspection",
        "evidence",
        "protectedJson"
      ],
      "properties": {
        "preparedPurchase": {
          "type": "string",
          "minLength": 1
        },
        "freshRequestToDirectDelivery": {
          "type": "string",
          "minLength": 1
        },
        "protectedInspection": {
          "type": "string",
          "minLength": 1
        },
        "evidence": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "protectedJson": {
          "type": "string",
          "minLength": 1
        }
      }
    }
  }
}
