{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "depend_process": {
      "type": "object",
      "properties": {
        "$and": {
          "type": "array",
          "items": { "$ref": "#/definitions/depend_process" }
        },
        "$or": {
          "type": "array",
          "items": { "$ref": "#/definitions/depend_process" }
        }
      }
    },
    "output_filter": {
      "type": "object",
      "properties": {
        "$and": {
          "type": "array",
          "items": { "$ref": "#/definitions/output_filter" }
        },
        "$or": {
          "type": "array",
          "items": { "$ref": "#/definitions/output_filter" }
        }
      }
    },
    "output_process": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["file_name", "write"],
        "properties": {
          "file_name": {
            "type": "string"
          },
          "write": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "concat": {
            "type": "boolean"
          },
          "maxsize": {
            "type": "string"
          }
        }
      }
    },
    "notifications_process": {
      "type": "object",
      "properties": {
        "on_start": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id"],
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        },
        "on_end": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id"],
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        },
        "on_fail": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id"],
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        },
        "on_retry": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id"],
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        },
        "on_queue": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id"],
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        },
        "on_timeout": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id"],
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        },
        "on_waiting_dependencies": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id"],
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "chain_action_on_fail_process": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "required": ["action"],
          "properties": {
            "action": {
              "type": "string"
            }
          }
        }
      ]
    }
  },
  "type": "array",
  "items": {
    "type": "object",
    "required": ["id", "name", "exec"],
    "properties": {
      "id": {
        "type": "string"
      },
      "name": {
        "type": "string"
      },
      "depends_process": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          { "$ref": "#/definitions/depend_process" }
        ]
      },
      "queue": {
        "type": "string"
      },
      "priority": {
        "type": "number"
      },
      "exec": {
        "type": "object",
        "required": ["id"],
        "properties": {
          "id": {
            "type": "string"
          },
          "command": {
            "type": "string"
          },
          "command_file": {
            "type": "string"
          }
        }
      },
      "retries": {
        "type": "number"
      },
      "retry_delay": {
        "type": ["number", "string"]
      },
      "notificate_only_last_fail": {
        "type": "boolean"
      },
      "timeout": {
        "type": "object",
        "required": ["delay"],
        "properties": {
          "action": {
            "type": "string"
          },
          "delay": {
            "type": ["number", "string"]
          }
        }
      },
      "chain_action_on_fail": {
        "$ref": "#/definitions/chain_action_on_fail_process"
      },
      "ignore_in_final_chain_status": {
        "type": "boolean"
      },
      "output": { "$ref": "#/definitions/output_process" },
      "output_filter": {
        "anyOf": [
          {
            "type": "object"
          },
          { "$ref": "#/definitions/output_filter" }
        ]
      },
      "output_order": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "output_share": {
        "type": "array",
        "items": {
          "type": "object",
          "required": ["key", "name", "value"],
          "properties": {
            "key": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "value": {
              "type": "string"
            }
          }
        }
      },
      "output_iterable": {
        "type": "string"
      },
      "notifications": { "$ref": "#/definitions/notifications_process" }
    }
  }
}
