{
  "$id": "http://asl-validator.cloud/map.json#",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "Type": {
      "type": "string",
      "enum": ["Map"]
    },
    "Next": {
      "type": "string"
    },
    "End": {
      "enum": [true]
    },
    "Comment": {
      "type": "string"
    },
    "OutputPath": {
      "$ref": "paths.json#/definitions/asl_path"
    },
    "InputPath": {
      "$ref": "paths.json#/definitions/asl_path"
    },
    "ResultPath": {
      "$ref": "paths.json#/definitions/asl_result_path"
    },
    "ItemsPath": {
      "$ref": "paths.json#/definitions/asl_ref_path"
    },
    "Label": {
      "type": "string"
    },
    "MaxConcurrency": {
      "type": "number",
      "minimum": 0
    },
    "MaxConcurrencyPath": {
      "$ref": "paths.json#/definitions/asl_ref_path"
    },
    "ItemReader": {
      "$comment": "A Map State MAY have an \"ItemReader\" field, whose value MUST be a JSON object and is called the ItemReader Configuration",
      "type": "object",
      "properties": {
        "Resource": {
          "$comment": "The ItemReader Configuration MUST have a \"Resource\" field, whose value MUST be a URI that uniquely identifies the specific task to execute. The States language does not constrain the URI scheme nor any other part of the URI.",
          "type": "string"
        },
        "Parameters": {
          "$comment": "The ItemReader Configuration MAY have a \"Parameters\" field, whose value MUST be a Payload Template.",
          "$ref": "paths.json#/definitions/asl_payload_template"
        },
        "ReaderConfig": {
          "$comment": "The ItemReader Configuration MAY have a \"ReaderConfig\" field whose value is a JSON object which MAY have a \"MaxItems\" field which MUST be a positive integer.",
          "type": "object",
          "properties": {
            "MaxItems": {
              "$comment": "MAY have a \"MaxItems\" field which MUST be a positive integer",
              "type": "integer",
              "minimum": 1
            },
            "MaxItemsPath": {
              "$comment": "A \"ReaderConfig\" field MAY have \"MaxItemsPath\" field which MUST be a Reference Path which, when resolved, MUST select a field whose value is a positive integer.",
              "$ref": "paths.json#/definitions/asl_ref_path"
            },
            "Arguments": {
              "$ref": "jsonata.json#/definitions/arguments"
            }
          },
          "additionalProperties": true
        }
      },
      "required": ["Resource"]
    },
    "ItemProcessor": {
      "type": "object",
      "allOf": [{ "$ref": "base-state-machine.json#" }],
      "$comment": "The \"ItemProcessor\" field MAY contain a field named \"ProcessorConfig\", whose value MUST be a JSON object whose value is defined by the interpreter.",
      "properties": {
        "ProcessorConfig": {
          "type": "object",
          "oneOf": [
            {
              "properties": {
                "Mode": {
                  "type": "string",
                  "enum": ["INLINE"]
                }
              },
              "required": ["Mode"]
            },
            {
              "properties": {
                "Mode": {
                  "type": "string",
                  "enum": ["DISTRIBUTED"]
                },
                "ExecutionType": {
                  "type": "string",
                  "enum": ["EXPRESS", "STANDARD"]
                }
              },
              "required": ["Mode", "ExecutionType"]
            }
          ]
        }
      }
    },
    "Iterator": {
      "$ref": "base-state-machine.json#"
    },
    "Parameters": {
      "$ref": "paths.json#/definitions/asl_payload_template"
    },
    "ItemSelector": {
      "$ref": "paths.json#/definitions/asl_payload_template"
    },
    "ItemBatcher": {
      "type": "object",
      "properties": {
        "MaxItemsPerBatch": {
          "type": "number",
          "minimum": 0
        },
        "MaxItemsPerBatchPath": {
          "$ref": "paths.json#/definitions/asl_ref_path"
        },
        "MaxInputBytesPerBatch": {
          "type": "number",
          "minimum": 0,
          "maximum": 262144
        },
        "MaxInputBytesPerBatchPath": {
          "$ref": "paths.json#/definitions/asl_ref_path"
        },
        "BatchInput": {
          "$ref": "paths.json#/definitions/asl_payload_template"
        }
      }
    },
    "ResultSelector": {
      "$ref": "paths.json#/definitions/asl_payload_template"
    },
    "ResultWriter": {
      "$comment": "Allow any object for now and update in a subsequent PR to support S3 buckets and other outputs",
      "type": "object"
    },
    "Retry": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ErrorEquals": {
            "type": "array",
            "items": {
              "$ref": "errors.json#"
            }
          },
          "IntervalSeconds": {
            "type": "number",
            "minimum": 0
          },
          "MaxAttempts": {
            "type": "number",
            "minimum": 0
          },
          "BackoffRate": {
            "type": "number",
            "minimum": 0
          }
        },
        "required": ["ErrorEquals"]
      }
    },
    "Catch": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ErrorEquals": {
            "type": "array",
            "items": {
              "$ref": "errors.json#"
            }
          },
          "Next": {
            "type": "string"
          }
        },
        "required": ["ErrorEquals", "Next"]
      }
    },
    "ToleratedFailureCount": {
      "type": "integer",
      "minimum": 0
    },
    "ToleratedFailureCountPath": {
      "$ref": "paths.json#/definitions/asl_ref_path"
    },
    "ToleratedFailurePercentage": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100
    },
    "ToleratedFailurePercentagePath": {
      "$ref": "paths.json#/definitions/asl_ref_path"
    },
    "Output": {
      "$ref": "jsonata.json#/definitions/output"
    },
    "Assign": {
      "$ref": "jsonata.json#/definitions/assign"
    },
    "QueryLanguage": {
      "$ref": "jsonata.json#/definitions/queryLanguage"
    }
  },
  "required": ["Type"],
  "additionalProperties": false
}
