{
  "type": "object",
  "properties": {
    "do": {
      "$ref": "#/$defs/taskList",
      "title": "Do",
      "description": "Defines the task(s) the workflow must perform."
    },
    "document": {
      "type": "object",
      "properties": {
        "dsl": {
          "type": "string",
          "title": "WorkflowDSL",
          "description": "The version of the DSL used by the workflow.",
          "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
        },
        "metadata": {
          "type": "object",
          "title": "WorkflowMetadata",
          "description": "Holds additional information about the workflow.",
          "additionalProperties": true,
          "allOf": [
            {
              "$ref": "#/$defs/commonMetadata"
            },
            {
              "$ref": "#/$defs/documentMetadata"
            }
          ]
        },
        "summary": {
          "type": "string",
          "title": "WorkflowSummary",
          "description": "The workflow's Markdown summary."
        },
        "tags": {
          "type": "object",
          "title": "WorkflowTags",
          "description": "A key/value mapping of the workflow's tags, if any.",
          "additionalProperties": true
        },
        "taskQueue": {
          "type": "string",
          "title": "WorkflowTaskQueue",
          "description": "The Temporal task queue the workflow runs on.",
          "pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$"
        },
        "title": {
          "type": "string",
          "title": "WorkflowTitle",
          "description": "The workflow's title."
        },
        "version": {
          "type": "string",
          "title": "WorkflowVersion",
          "description": "The workflow's semantic version.",
          "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
        },
        "workflowType": {
          "type": "string",
          "title": "WorkflowType",
          "description": "The Temporal workflow type name.",
          "pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$"
        }
      },
      "title": "Document",
      "description": "Documents the workflow",
      "required": [
        "dsl",
        "taskQueue",
        "workflowType",
        "version"
      ],
      "unevaluatedProperties": false
    },
    "input": {
      "$ref": "#/$defs/input",
      "title": "Input",
      "description": "Configures the workflow's input."
    },
    "output": {
      "$ref": "#/$defs/output",
      "title": "Output",
      "description": "Configures the workflow's output."
    },
    "schedule": {
      "type": "object",
      "properties": {
        "cron": {
          "type": "string",
          "title": "ScheduleCron",
          "description": "Specifies the schedule using a cron expression, e.g., '0 0 * * *' for daily at midnight."
        },
        "every": {
          "$ref": "#/$defs/duration",
          "title": "ScheduleEvery",
          "description": "Specifies the duration of the interval at which the workflow should be executed."
        }
      },
      "title": "Schedule",
      "description": "Schedules the workflow.",
      "unevaluatedProperties": false
    },
    "timeout": {
      "title": "DoTimeout",
      "deprecated": true,
      "oneOf": [
        {
          "$ref": "#/$defs/timeout",
          "title": "TimeoutDefinition",
          "description": "The workflow's timeout configuration, if any."
        }
      ]
    }
  },
  "$id": "https://zigflow.dev/schemas/0.18.1/schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "callTask": {
      "title": "CallTask",
      "description": "Defines the call to perform.",
      "oneOf": [
        {
          "type": "object",
          "title": "CallActivity",
          "description": "Defines the external Temporal activity call to perform.",
          "required": [
            "call",
            "with"
          ],
          "unevaluatedProperties": false,
          "allOf": [
            {
              "$ref": "#/$defs/taskBase"
            },
            {
              "properties": {
                "call": {
                  "type": "string",
                  "const": "activity"
                },
                "with": {
                  "type": "object",
                  "properties": {
                    "arguments": {
                      "type": "array"
                    },
                    "name": {
                      "type": "string",
                      "title": "WithActivityName",
                      "description": "The name of the activity to call on the defined Activity service."
                    },
                    "taskQueue": {
                      "type": "string",
                      "title": "WithActivityTaskQueue",
                      "description": "The name of the task queue to call on the defined Activity service."
                    }
                  },
                  "title": "ActivityArguments",
                  "description": "The activity call arguments.",
                  "required": [
                    "name",
                    "taskQueue"
                  ],
                  "unevaluatedProperties": false
                }
              }
            }
          ]
        },
        {
          "type": "object",
          "title": "CallGRPC",
          "description": "Defines the GRPC call to perform.",
          "required": [
            "call",
            "with"
          ],
          "unevaluatedProperties": false,
          "allOf": [
            {
              "$ref": "#/$defs/taskBase"
            },
            {
              "properties": {
                "call": {
                  "type": "string",
                  "const": "grpc"
                },
                "with": {
                  "type": "object",
                  "properties": {
                    "arguments": {
                      "type": "object",
                      "title": "WithGRPCArguments",
                      "description": "The arguments, if any, to call the method with.",
                      "additionalProperties": true
                    },
                    "method": {
                      "type": "string",
                      "title": "WithGRPCMethod",
                      "description": "The name of the method to call on the defined GRPC service."
                    },
                    "proto": {
                      "$ref": "#/$defs/externalResource",
                      "title": "WithGRPCProto",
                      "description": "The proto resource that describes the GRPC service to call."
                    },
                    "service": {
                      "type": "object",
                      "properties": {
                        "host": {
                          "type": "string",
                          "title": "WithGRPCServiceHost",
                          "description": "The hostname of the GRPC service to call.",
                          "pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-.]{0,61}[a-zA-Z0-9])?$"
                        },
                        "name": {
                          "type": "string",
                          "title": "WithGRPCServiceName",
                          "description": "The name of the GRPC service to call."
                        },
                        "port": {
                          "type": "integer",
                          "title": "WithGRPCServicePort",
                          "description": "The port number of the GRPC service to call.",
                          "minimum": 0,
                          "maximum": 65535
                        }
                      },
                      "title": "WithGRPCService",
                      "required": [
                        "name",
                        "host"
                      ],
                      "unevaluatedProperties": false
                    }
                  },
                  "title": "GRPCArguments",
                  "description": "The GRPC call arguments.",
                  "required": [
                    "proto",
                    "service",
                    "method"
                  ],
                  "unevaluatedProperties": false
                }
              }
            }
          ]
        },
        {
          "type": "object",
          "title": "CallHTTP",
          "description": "Defines the HTTP call to perform.",
          "required": [
            "call",
            "with"
          ],
          "unevaluatedProperties": false,
          "allOf": [
            {
              "$ref": "#/$defs/taskBase"
            },
            {
              "properties": {
                "call": {
                  "type": "string",
                  "const": "http"
                },
                "with": {
                  "type": "object",
                  "properties": {
                    "body": {
                      "title": "HTTPBody",
                      "description": "The body, if any, of the HTTP request to perform."
                    },
                    "endpoint": {
                      "$ref": "#/$defs/endpoint",
                      "title": "HTTPEndpoint",
                      "description": "The HTTP endpoint to send the request to."
                    },
                    "headers": {
                      "title": "HTTPHeaders",
                      "description": "A name/value mapping of the headers, if any, of the HTTP request to perform.",
                      "oneOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        {
                          "$ref": "#/$defs/runtimeExpression"
                        }
                      ]
                    },
                    "method": {
                      "type": "string",
                      "title": "HTTPMethod",
                      "description": "The HTTP method of the HTTP request to perform."
                    },
                    "output": {
                      "type": "string",
                      "title": "HTTPOutput",
                      "description": "The http call output format. Defaults to 'content'.",
                      "enum": [
                        "raw",
                        "content",
                        "response"
                      ]
                    },
                    "query": {
                      "title": "HTTPQuery",
                      "description": "A name/value mapping of the query parameters, if any, of the HTTP request to perform.",
                      "additionalProperties": true,
                      "oneOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        {
                          "$ref": "#/$defs/runtimeExpression"
                        }
                      ]
                    },
                    "redirect": {
                      "type": "boolean",
                      "title": "HttpRedirect",
                      "description": "Specifies whether redirection status codes (`300-399`) should be treated as errors."
                    }
                  },
                  "title": "HTTPArguments",
                  "description": "The HTTP call arguments.",
                  "required": [
                    "method",
                    "endpoint"
                  ],
                  "unevaluatedProperties": false
                }
              }
            }
          ]
        }
      ]
    },
    "commonMetadata": {
      "type": "object",
      "properties": {
        "activityOptions": {
          "type": "object",
          "properties": {
            "disableEagerExecution": {
              "type": "boolean",
              "description": "If true, eager execution will not be requested, regardless of worker settings. If false, eager execution may still be disabled at the worker level or may not be requested due to lack of available slots."
            },
            "heartbeatTimeout": {
              "$ref": "#/$defs/duration",
              "title": "HeartbeatTimeout",
              "description": "Heartbeat interval. A heartbeat must be set and be called before the interval passes."
            },
            "priority": {
              "type": "object",
              "properties": {
                "fairnessKey": {
                  "type": "string",
                  "title": "FairnessKey",
                  "description": "A short string that's used as a key for a fairness balancing mechanism"
                },
                "fairnessWeight": {
                  "type": "number",
                  "title": "FairnessWeight",
                  "description": "Weight of a task can come from multiple sources for flexibility"
                },
                "priorityKey": {
                  "type": "integer",
                  "title": "PriorityKey",
                  "description": "A positive integer from 1 to n, where smaller integers correspond to higher priorities (tasks run sooner)",
                  "minimum": 1
                }
              },
              "title": "Priority",
              "description": "Configure an activity's priority and fairness",
              "additionalProperties": false
            },
            "retryPolicy": {
              "type": "object",
              "properties": {
                "backoffCoefficient": {
                  "type": "number",
                  "title": "BackoffCoefficient",
                  "description": "Coefficient used to calculate the next retry backoff interval.",
                  "default": 2.0
                },
                "initialInterval": {
                  "$ref": "#/$defs/duration",
                  "title": "InitialInterval",
                  "description": "Backoff interval for the first retry. If BackoffCoefficient is 1.0 then it is used for all retries."
                },
                "maximumAttempts": {
                  "type": "integer",
                  "title": "MaximumAttempts",
                  "description": "Maximum number of attempts. When exceeded the retries stop even if not expired yet.",
                  "default": 5
                },
                "maximumInterval": {
                  "$ref": "#/$defs/duration",
                  "title": "MaximumInterval",
                  "description": "Maximum backoff interval between retries."
                },
                "nonRetryableErrorTypes": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "title": "NonRetryableErrorTypes",
                  "description": "Temporal server will stop retry if error type matches this list.",
                  "default": []
                }
              },
              "title": "RetryPolicy",
              "description": "Specifies how to retry an Activity if an error occurs",
              "additionalProperties": false
            },
            "scheduleToCloseTimeout": {
              "$ref": "#/$defs/duration",
              "title": "ScheduleToCloseTimeout",
              "description": "Total time that a workflow is willing to wait for an Activity to complete."
            },
            "scheduleToStartTimeout": {
              "$ref": "#/$defs/duration",
              "title": "ScheduleToStartTimeout",
              "description": "Time that the Activity Task can stay in the Task Queue before it is picked up by a Worker. Do not specify this timeout unless using host specific Task Queues for Activity Tasks are being used for routing."
            },
            "startToCloseTimeout": {
              "$ref": "#/$defs/duration",
              "title": "StartToCloseTimeout",
              "description": "Maximum time of a single Activity execution attempt.",
              "default": {
                "seconds": 15
              }
            },
            "summary": {
              "type": "string",
              "description": "Add a summary to the Temporal workflow UI."
            }
          },
          "title": "ActivityOptionsMetadata",
          "additionalProperties": true
        }
      },
      "title": "CommonMetadata",
      "additionalProperties": true
    },
    "containerLifetime": {
      "type": "object",
      "properties": {
        "cleanup": {
          "type": "string",
          "title": "ContainerCleanupPolicy",
          "description": "The container cleanup policy to use",
          "default": "always",
          "enum": [
            "always",
            "never"
          ]
        }
      },
      "title": "ContainerLifetime",
      "description": "The configuration of a container's lifetime",
      "required": [
        "cleanup"
      ],
      "unevaluatedProperties": false
    },
    "doTask": {
      "type": "object",
      "title": "DoTask",
      "description": "Allows to execute a list of tasks in sequence.",
      "required": [
        "do"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "do": {
              "$ref": "#/$defs/taskList",
              "title": "DoTaskConfiguration",
              "description": "The configuration of the tasks to perform sequentially."
            }
          }
        }
      ]
    },
    "documentMetadata": {
      "type": "object",
      "properties": {
        "canMaxHistoryLength": {
          "type": "integer",
          "title": "ContinueAsNewMaxHistoryLength",
          "description": "Allows you to test the Continue-As-New functionality by specifying the max history length before triggering."
        },
        "scheduleId": {
          "type": "string",
          "title": "ScheduleID",
          "description": "Set the schedule ID. If not set, this will to zigflow_\u003cworkflow.document.workflowType\u003e"
        },
        "scheduleInput": {
          "type": "array",
          "title": "ScheduleInput",
          "description": "Set the input."
        },
        "scheduleWorkflowName": {
          "type": "string",
          "title": "ScheduleWorkflowName",
          "description": "Deprecated: use scheduleWorkflowType.",
          "deprecated": true,
          "minLength": 1
        },
        "scheduleWorkflowType": {
          "type": "string",
          "title": "ScheduleWorkflowType",
          "description": "The workflow type the schedule starts: the document.workflowType or a top-level Do task. Defaults to document.workflowType; required when every top-level task is a Do task.",
          "minLength": 1
        }
      },
      "title": "DocumentMetadata",
      "additionalProperties": true
    },
    "duration": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "days": {
              "type": "integer",
              "title": "DurationDays",
              "description": "Number of days, if any."
            },
            "hours": {
              "type": "integer",
              "title": "DurationHours",
              "description": "Number of hours, if any."
            },
            "milliseconds": {
              "type": "integer",
              "title": "DurationMilliseconds",
              "description": "Number of milliseconds, if any."
            },
            "minutes": {
              "type": "integer",
              "title": "DurationMinutes",
              "description": "Number of minutes, if any."
            },
            "seconds": {
              "type": "integer",
              "title": "DurationSeconds",
              "description": "Number of seconds, if any."
            }
          },
          "minProperties": 1,
          "unevaluatedProperties": false
        }
      ]
    },
    "endpoint": {
      "title": "Endpoint",
      "description": "Represents an endpoint.",
      "oneOf": [
        {
          "$ref": "#/$defs/runtimeExpression"
        },
        {
          "$ref": "#/$defs/uriTemplate"
        },
        {
          "type": "object",
          "properties": {
            "uri": {
              "title": "EndpointUri",
              "description": "The endpoint's URI.",
              "oneOf": [
                {
                  "$ref": "#/$defs/uriTemplate",
                  "title": "LiteralEndpointURI",
                  "description": "The literal endpoint's URI."
                },
                {
                  "$ref": "#/$defs/runtimeExpression",
                  "title": "ExpressionEndpointURI",
                  "description": "An expression based endpoint's URI."
                }
              ]
            }
          },
          "title": "EndpointConfiguration",
          "required": [
            "uri"
          ],
          "unevaluatedProperties": false
        }
      ]
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "title": "ErrorDetails",
          "description": "A human-readable explanation specific to this occurrence of the error.",
          "anyOf": [
            {
              "$ref": "#/$defs/runtimeExpression",
              "title": "ExpressionErrorDetails"
            },
            {
              "type": "string",
              "title": "LiteralErrorDetails"
            }
          ]
        },
        "instance": {
          "title": "ErrorInstance",
          "description": "A JSON Pointer used to reference the component the error originates from.",
          "oneOf": [
            {
              "type": "string",
              "title": "LiteralErrorInstance",
              "description": "The literal error instance.",
              "format": "json-pointer"
            },
            {
              "$ref": "#/$defs/runtimeExpression",
              "title": "ExpressionErrorInstance",
              "description": "An expression based error instance."
            }
          ]
        },
        "status": {
          "type": "integer",
          "title": "ErrorStatus",
          "description": "The status code generated by the origin for this occurrence of the error."
        },
        "title": {
          "title": "ErrorTitle",
          "description": "A short, human-readable summary of the error.",
          "anyOf": [
            {
              "$ref": "#/$defs/runtimeExpression",
              "title": "ExpressionErrorTitle"
            },
            {
              "type": "string",
              "title": "LiteralErrorTitle"
            }
          ]
        },
        "type": {
          "title": "ErrorType",
          "description": "A URI reference that identifies the error type.",
          "oneOf": [
            {
              "$ref": "#/$defs/uriTemplate",
              "title": "LiteralErrorType",
              "description": "The literal error type."
            },
            {
              "$ref": "#/$defs/runtimeExpression",
              "title": "ExpressionErrorType",
              "description": "An expression based error type."
            }
          ]
        }
      },
      "title": "Error",
      "description": "Represents an error.",
      "required": [
        "type",
        "status"
      ],
      "unevaluatedProperties": false
    },
    "eventConsumptionStrategy": {
      "type": "object",
      "title": "EventConsumptionStrategy",
      "description": "Describe the event consumption strategy to adopt.",
      "unevaluatedProperties": false,
      "oneOf": [
        {
          "properties": {
            "all": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/eventFilter"
              },
              "title": "AllEventConsumptionStrategyConfiguration",
              "description": "A list containing all the events that must be consumed."
            }
          },
          "title": "AllEventConsumptionStrategy",
          "required": [
            "all"
          ]
        },
        {
          "properties": {
            "any": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/eventFilter"
              },
              "title": "AnyEventConsumptionStrategyConfiguration",
              "description": "A list containing any of the events to consume."
            }
          },
          "title": "AnyEventConsumptionStrategy",
          "required": [
            "any"
          ]
        },
        {
          "properties": {
            "one": {
              "$ref": "#/$defs/eventFilter",
              "title": "OneEventConsumptionStrategyConfiguration",
              "description": "The single event to consume."
            }
          },
          "title": "OneEventConsumptionStrategy",
          "required": [
            "one"
          ]
        }
      ]
    },
    "eventFilter": {
      "type": "object",
      "properties": {
        "with": {
          "$ref": "#/$defs/eventProperties",
          "title": "WithEvent",
          "description": "An event filter is a mechanism used to selectively process or handle events based on predefined criteria, such as event type, source, or specific attributes.",
          "minProperties": 1
        }
      },
      "title": "EventFilter",
      "description": "An event filter is a mechanism used to selectively process or handle events based on predefined criteria, such as event type, source, or specific attributes.",
      "required": [
        "with"
      ],
      "unevaluatedProperties": false
    },
    "eventProperties": {
      "type": "object",
      "properties": {
        "data": {
          "title": "EventData",
          "description": "The event's payload data",
          "anyOf": [
            {
              "$ref": "#/$defs/runtimeExpression"
            },
            true
          ]
        },
        "datacontenttype": {
          "type": "string",
          "title": "EventDataContentType",
          "description": "Content type of data value. This attribute enables data to carry any type of content, whereby format and encoding might differ from that of the chosen event format."
        },
        "dataschema": {
          "title": "EventDataschema",
          "description": "The schema describing the event format.",
          "oneOf": [
            {
              "$ref": "#/$defs/uriTemplate",
              "title": "LiteralDataSchema",
              "description": "The literal event data schema."
            },
            {
              "$ref": "#/$defs/runtimeExpression",
              "title": "ExpressionDataSchema",
              "description": "An expression based event data schema."
            }
          ]
        },
        "id": {
          "type": "string",
          "title": "EventId",
          "description": "The event's unique identifier."
        },
        "source": {
          "title": "EventSource",
          "description": "Identifies the context in which an event happened.",
          "oneOf": [
            {
              "$ref": "#/$defs/uriTemplate"
            },
            {
              "$ref": "#/$defs/runtimeExpression"
            }
          ]
        },
        "subject": {
          "type": "string",
          "title": "EventSubject",
          "description": "The subject of the event."
        },
        "time": {
          "title": "EventTime",
          "description": "When the event occurred.",
          "oneOf": [
            {
              "type": "string",
              "title": "LiteralTime",
              "format": "date-time"
            },
            {
              "$ref": "#/$defs/runtimeExpression"
            }
          ]
        },
        "type": {
          "type": "string",
          "title": "EventType",
          "description": "This attribute contains a value describing the type of event related to the originating occurrence."
        }
      },
      "title": "EventProperties",
      "description": "Describes the properties of an event.",
      "additionalProperties": true
    },
    "export": {
      "type": "object",
      "properties": {
        "as": {
          "title": "ExportAs",
          "description": "A runtime expression, if any, used to export the output data to the context.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "object"
            }
          ]
        },
        "schema": {
          "$ref": "#/$defs/schema",
          "title": "ExportSchema",
          "description": "The schema used to describe and validate the workflow context."
        }
      },
      "title": "Export",
      "description": "Set the content of the context.",
      "unevaluatedProperties": false
    },
    "externalResource": {
      "type": "object",
      "properties": {
        "endpoint": {
          "$ref": "#/$defs/endpoint",
          "title": "ExternalResourceEndpoint",
          "description": "The endpoint of the external resource."
        },
        "name": {
          "type": "string",
          "title": "ExternalResourceName",
          "description": "The name of the external resource, if any."
        }
      },
      "title": "ExternalResource",
      "description": "Represents an external resource.",
      "required": [
        "endpoint"
      ],
      "unevaluatedProperties": false
    },
    "flowDirective": {
      "title": "FlowDirective",
      "description": "Represents different transition options for a workflow.",
      "anyOf": [
        {
          "type": "string",
          "title": "FlowDirectiveEnum",
          "default": "continue",
          "enum": [
            "continue",
            "exit",
            "end"
          ]
        },
        {
          "type": "string"
        }
      ]
    },
    "forTask": {
      "type": "object",
      "title": "ForTask",
      "description": "Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets.",
      "required": [
        "for",
        "do"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "do": {
              "$ref": "#/$defs/taskList",
              "title": "ForTaskDo"
            },
            "for": {
              "type": "object",
              "properties": {
                "at": {
                  "type": "string",
                  "title": "ForAt",
                  "description": "The name of the variable used to store the index of the current item being enumerated.",
                  "default": "index"
                },
                "each": {
                  "type": "string",
                  "title": "ForEach",
                  "description": "The name of the variable used to store the current item being enumerated.",
                  "default": "item"
                },
                "in": {
                  "type": "string",
                  "title": "ForIn",
                  "description": "A runtime expression used to get the collection to enumerate."
                }
              },
              "title": "ForTaskConfiguration",
              "description": "The definition of the loop that iterates over a range of values.",
              "required": [
                "in"
              ],
              "unevaluatedProperties": false
            },
            "while": {
              "type": "string",
              "title": "While",
              "description": "A runtime expression that represents the condition, if any, that must be met for the iteration to continue."
            }
          }
        }
      ]
    },
    "forkTask": {
      "type": "object",
      "title": "ForkTask",
      "description": "Allows workflows to execute multiple tasks concurrently and optionally race them against each other, with a single possible winner, which sets the task's output.",
      "required": [
        "fork"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "fork": {
              "type": "object",
              "properties": {
                "branches": {
                  "$ref": "#/$defs/taskList",
                  "title": "ForkBranches"
                },
                "compete": {
                  "type": "boolean",
                  "title": "ForkCompete",
                  "description": "Indicates whether or not the concurrent tasks are racing against each other, with a single possible winner, which sets the composite task's output.",
                  "default": false
                }
              },
              "title": "ForkTaskConfiguration",
              "description": "The configuration of the branches to perform concurrently.",
              "required": [
                "branches"
              ],
              "unevaluatedProperties": false
            }
          }
        }
      ]
    },
    "input": {
      "type": "object",
      "properties": {
        "schema": {
          "$ref": "#/$defs/schema",
          "title": "InputSchema",
          "description": "The schema used to describe and validate the input of the workflow or task."
        }
      },
      "title": "Input",
      "description": "Configures the input of a workflow or task.",
      "unevaluatedProperties": false
    },
    "listenTask": {
      "type": "object",
      "title": "ListenTask",
      "description": "Provides a mechanism for workflows to await and react to external events, enabling event-driven behaviour within workflow systems.",
      "required": [
        "listen"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "listen": {
              "type": "object",
              "properties": {
                "read": {
                  "type": "string",
                  "title": "ListenAndReadAs",
                  "description": "Specifies how events are read during the listen operation.",
                  "default": "data",
                  "enum": [
                    "data",
                    "envelope",
                    "raw"
                  ]
                },
                "to": {
                  "$ref": "#/$defs/eventConsumptionStrategy",
                  "title": "ListenTo",
                  "description": "Defines the event(s) to listen to."
                }
              },
              "title": "ListenTaskConfiguration",
              "description": "The configuration of the listener to use.",
              "required": [
                "to"
              ],
              "unevaluatedProperties": false
            }
          }
        }
      ]
    },
    "output": {
      "type": "object",
      "properties": {
        "as": {
          "title": "OutputAs",
          "description": "A runtime expression, if any, used to mutate and/or filter the output of the workflow or task.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "object"
            }
          ]
        },
        "schema": {
          "$ref": "#/$defs/schema",
          "title": "OutputSchema",
          "description": "The schema used to describe and validate the output of the workflow or task."
        }
      },
      "title": "Output",
      "description": "Configures the output of a workflow or task.",
      "unevaluatedProperties": false
    },
    "raiseTask": {
      "type": "object",
      "title": "RaiseTask",
      "description": "Intentionally triggers and propagates errors.",
      "required": [
        "raise"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "raise": {
              "type": "object",
              "properties": {
                "error": {
                  "title": "RaiseTaskError",
                  "oneOf": [
                    {
                      "$ref": "#/$defs/error",
                      "title": "RaiseErrorDefinition",
                      "description": "Defines the error to raise."
                    },
                    {
                      "type": "string",
                      "title": "RaiseErrorReference",
                      "description": "The name of the error to raise"
                    }
                  ]
                }
              },
              "title": "RaiseTaskConfiguration",
              "description": "The definition of the error to raise.",
              "required": [
                "error"
              ],
              "unevaluatedProperties": false
            }
          }
        }
      ]
    },
    "runTask": {
      "type": "object",
      "title": "RunTask",
      "description": "Provides the capability to execute external containers, shell commands, scripts, or workflows.",
      "required": [
        "run"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "run": {
              "type": "object",
              "properties": {
                "await": {
                  "type": "boolean",
                  "title": "AwaitProcessCompletion",
                  "description": "Whether to await the process completion before continuing.",
                  "default": true
                }
              },
              "title": "RunTaskConfiguration",
              "description": "The configuration of the process to execute.",
              "unevaluatedProperties": false,
              "oneOf": [
                {
                  "properties": {
                    "container": {
                      "type": "object",
                      "properties": {
                        "arguments": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "title": "ContainerArguments",
                          "description": "A list of the arguments, if any, passed as argv to the command or default container CMD"
                        },
                        "command": {
                          "type": "string",
                          "title": "ContainerCommand",
                          "description": "The command, if any, to execute on the container."
                        },
                        "environment": {
                          "type": "object",
                          "title": "ContainerEnvironment",
                          "description": "A key/value mapping of the environment variables, if any, to use when running the configured process."
                        },
                        "image": {
                          "type": "string",
                          "title": "ContainerImage",
                          "description": "The name of the container image to run."
                        },
                        "lifetime": {
                          "$ref": "#/$defs/containerLifetime",
                          "title": "ContainerLifetime",
                          "description": "An object, if any, used to configure the container's lifetime"
                        },
                        "name": {
                          "type": "string",
                          "title": "ContainerName",
                          "description": "A runtime expression, if any, used to give specific name to the container."
                        },
                        "pullPolicy": {
                          "type": "string",
                          "title": "PullPolicy",
                          "description": "Pull policy for the container image",
                          "enum": [
                            "always",
                            "never",
                            "ifNotPresent"
                          ]
                        },
                        "volumes": {
                          "type": "object",
                          "title": "ContainerVolumes",
                          "description": "The container's volume mappings, if any."
                        }
                      },
                      "title": "Container",
                      "description": "The configuration of the container to run.",
                      "required": [
                        "image",
                        "pullPolicy"
                      ],
                      "unevaluatedProperties": false
                    }
                  },
                  "title": "RunContainer",
                  "description": "Enables the execution of external processes encapsulated within a containerized environment.",
                  "required": [
                    "container"
                  ]
                },
                {
                  "properties": {
                    "script": {
                      "type": "object",
                      "properties": {
                        "arguments": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "title": "ScriptArguments",
                          "description": "A list of the arguments, if any, to the script as argv"
                        },
                        "environment": {
                          "type": "object",
                          "title": "ScriptEnvironment",
                          "description": "A key/value mapping of the environment variables, if any, to use when running the configured script process.",
                          "additionalProperties": true
                        },
                        "language": {
                          "type": "string",
                          "title": "ScriptLanguage",
                          "description": "The language of the script to run.",
                          "enum": [
                            "js",
                            "python"
                          ]
                        }
                      },
                      "title": "Script",
                      "description": "The configuration of the script to run.",
                      "required": [
                        "language"
                      ],
                      "unevaluatedProperties": false,
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "title": "InlineScriptCode"
                            }
                          },
                          "title": "InlineScript",
                          "description": "The script's code.",
                          "required": [
                            "code"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "source": {
                              "$ref": "#/$defs/externalResource",
                              "title": "ExternalScriptResource"
                            }
                          },
                          "title": "ExternalScript",
                          "description": "The script's resource.",
                          "required": [
                            "source"
                          ]
                        }
                      ]
                    }
                  },
                  "title": "RunScript",
                  "description": "Enables the execution of custom scripts or code within a workflow, empowering workflows to perform specialised logic, data processing, or integration tasks by executing user-defined scripts written in various programming languages.",
                  "required": [
                    "script"
                  ]
                },
                {
                  "properties": {
                    "shell": {
                      "type": "object",
                      "properties": {
                        "arguments": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "title": "ShellArguments",
                          "description": "A list of the arguments, if any, to the shell command as argv"
                        },
                        "command": {
                          "type": "string",
                          "title": "ShellCommand",
                          "description": "The shell command to run."
                        },
                        "environment": {
                          "type": "object",
                          "title": "ShellEnvironment",
                          "description": "A key/value mapping of the environment variables, if any, to use when running the configured process.",
                          "additionalProperties": true
                        }
                      },
                      "title": "Shell",
                      "description": "The configuration of the shell command to run.",
                      "required": [
                        "command"
                      ],
                      "unevaluatedProperties": false
                    }
                  },
                  "title": "RunShell",
                  "description": "Enables the execution of shell commands within a workflow, enabling workflows to interact with the underlying operating system and perform system-level operations, such as file manipulation, environment configuration, or system administration tasks.",
                  "required": [
                    "shell"
                  ]
                },
                {
                  "properties": {
                    "workflow": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "object",
                          "title": "SubflowInput",
                          "description": "The data, if any, to pass as input to the workflow to execute. The value should be validated against the target workflow's input schema, if specified.",
                          "additionalProperties": true
                        },
                        "taskQueue": {
                          "type": "string",
                          "title": "SubflowTaskQueue",
                          "description": "The Temporal task queue to start the child workflow on. If not set, the child workflow runs on the parent workflow's task queue.",
                          "minLength": 1
                        },
                        "type": {
                          "type": "string",
                          "title": "SubflowType",
                          "description": "The workflow type to run."
                        }
                      },
                      "title": "SubflowConfiguration",
                      "description": "The configuration of the workflow to run.",
                      "required": [
                        "type"
                      ],
                      "unevaluatedProperties": false
                    }
                  },
                  "title": "RunWorkflow",
                  "description": "Enables the invocation and execution of nested workflows within a parent workflow, facilitating modularization, reusability, and abstraction of complex logic or business processes by encapsulating them into standalone workflow units.",
                  "required": [
                    "workflow"
                  ]
                }
              ]
            }
          }
        }
      ]
    },
    "runtimeExpression": {
      "type": "string",
      "title": "RuntimeExpression",
      "description": "A runtime expression.",
      "pattern": "^\\s*\\$\\{.+\\}\\s*$"
    },
    "schema": {
      "type": "object",
      "properties": {
        "format": {
          "type": "string",
          "title": "SchemaFormat",
          "description": "The schema's format. Defaults to 'json'. The (optional) version of the format can be set using `{format}:{version}`.",
          "default": "json"
        }
      },
      "title": "Schema",
      "description": "Represents the definition of a schema.",
      "unevaluatedProperties": false,
      "oneOf": [
        {
          "properties": {
            "document": {
              "description": "The schema's inline definition."
            }
          },
          "title": "SchemaInline",
          "required": [
            "document"
          ]
        }
      ]
    },
    "setTask": {
      "type": "object",
      "title": "SetTask",
      "description": "A task used to set data.",
      "required": [
        "set"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "set": {
              "title": "SetTaskConfiguration",
              "description": "The data to set.",
              "oneOf": [
                {
                  "type": "object",
                  "minProperties": 1,
                  "additionalProperties": true
                },
                {
                  "type": "string"
                }
              ]
            }
          }
        }
      ]
    },
    "subscriptionIterator": {
      "type": "object",
      "properties": {
        "at": {
          "type": "string",
          "title": "SubscriptionIteratorIndex",
          "description": "The name of the variable used to store the index of the current item being enumerated.",
          "default": "index"
        },
        "do": {
          "$ref": "#/$defs/taskList",
          "title": "SubscriptionIteratorTasks",
          "description": "The tasks to perform for each consumed item."
        },
        "export": {
          "$ref": "#/$defs/export",
          "title": "SubscriptionIteratorExport",
          "description": "An object, if any, used to customise the content of the workflow context."
        },
        "item": {
          "type": "string",
          "title": "SubscriptionIteratorItem",
          "description": "The name of the variable used to store the current item being enumerated.",
          "default": "item"
        },
        "output": {
          "$ref": "#/$defs/output",
          "title": "SubscriptionIteratorOutput",
          "description": "An object, if any, used to customise the item's output and to document its schema."
        }
      },
      "title": "SubscriptionIterator",
      "description": "Configures the iteration over each item (event or message) consumed by a subscription.",
      "unevaluatedProperties": false
    },
    "switchTask": {
      "type": "object",
      "title": "SwitchTask",
      "description": "Enables conditional branching within workflows, allowing them to dynamically select different paths based on specified conditions or criteria.",
      "required": [
        "switch"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "switch": {
              "type": "array",
              "items": {
                "type": "object",
                "title": "SwitchItem",
                "minProperties": 1,
                "maxProperties": 1,
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "then": {
                      "$ref": "#/$defs/flowDirective",
                      "title": "SwitchCaseOutcome",
                      "description": "The flow directive to execute when the case matches."
                    },
                    "when": {
                      "type": "string",
                      "title": "SwitchCaseCondition",
                      "description": "A runtime expression used to determine whether or not the case matches."
                    }
                  },
                  "title": "SwitchCase",
                  "description": "The definition of a case within a switch task, defining a condition and corresponding tasks to execute if the condition is met.",
                  "required": [
                    "then"
                  ],
                  "unevaluatedProperties": false
                }
              },
              "title": "SwitchTaskConfiguration",
              "description": "The definition of the switch to use.",
              "minItems": 1
            }
          }
        }
      ]
    },
    "task": {
      "title": "Task",
      "description": "A discrete unit of work that contributes to achieving the overall objectives defined by the workflow.",
      "unevaluatedProperties": false,
      "oneOf": [
        {
          "$ref": "#/$defs/callTask"
        },
        {
          "$ref": "#/$defs/doTask"
        },
        {
          "$ref": "#/$defs/forTask"
        },
        {
          "$ref": "#/$defs/forkTask"
        },
        {
          "$ref": "#/$defs/listenTask"
        },
        {
          "$ref": "#/$defs/raiseTask"
        },
        {
          "$ref": "#/$defs/runTask"
        },
        {
          "$ref": "#/$defs/setTask"
        },
        {
          "$ref": "#/$defs/switchTask"
        },
        {
          "$ref": "#/$defs/tryTask"
        },
        {
          "$ref": "#/$defs/waitTask"
        }
      ]
    },
    "taskBase": {
      "type": "object",
      "properties": {
        "export": {
          "$ref": "#/$defs/export",
          "title": "TaskBaseExport",
          "description": "Export task output to context."
        },
        "if": {
          "type": "string",
          "title": "TaskBaseIf",
          "description": "A runtime expression, if any, used to determine whether or not the task should be run."
        },
        "input": {
          "$ref": "#/$defs/input",
          "title": "TaskBaseInput",
          "description": "Configure the task's input."
        },
        "metadata": {
          "type": "object",
          "title": "TaskBaseMetadata",
          "description": "Holds additional information about the task.",
          "additionalProperties": true,
          "allOf": [
            {
              "$ref": "#/$defs/commonMetadata"
            },
            {
              "$ref": "#/$defs/taskMetadata"
            }
          ]
        },
        "output": {
          "$ref": "#/$defs/output",
          "title": "TaskBaseOutput",
          "description": "Configure the task's output."
        },
        "then": {
          "$ref": "#/$defs/flowDirective",
          "title": "TaskBaseThen",
          "description": "The flow directive to be performed upon completion of the task."
        }
      },
      "title": "TaskBase",
      "description": "An object inherited by all tasks."
    },
    "taskList": {
      "type": "array",
      "items": {
        "type": "object",
        "title": "TaskItem",
        "minProperties": 1,
        "maxProperties": 1,
        "additionalProperties": {
          "$ref": "#/$defs/task"
        }
      },
      "title": "TaskList",
      "description": "List of named tasks to perform."
    },
    "taskMetadata": {
      "type": "object",
      "properties": {
        "__zigflow_id": {
          "type": "string",
          "title": "ZigflowID",
          "description": "A system-generated unique identifier for the task. This value is assigned automatically and should not be modified by users."
        },
        "heartbeat": {
          "$ref": "#/$defs/duration",
          "title": "Heartbeat",
          "description": "Heartbeats will be triggered after this time period."
        }
      },
      "title": "TaskMetadata",
      "additionalProperties": true
    },
    "timeout": {
      "type": "object",
      "properties": {
        "after": {
          "$ref": "#/$defs/duration",
          "title": "TimeoutAfter",
          "description": "The duration after which to timeout."
        }
      },
      "title": "Timeout",
      "description": "The definition of a timeout.",
      "required": [
        "after"
      ],
      "unevaluatedProperties": false
    },
    "tryTask": {
      "type": "object",
      "title": "TryTask",
      "description": "Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones.",
      "required": [
        "try",
        "catch"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "catch": {
              "type": "object",
              "properties": {
                "as": {
                  "type": "string",
                  "title": "CatchAs",
                  "description": "The name of the runtime expression variable to save the error as. Defaults to 'error'",
                  "default": "error"
                },
                "do": {
                  "$ref": "#/$defs/taskList",
                  "title": "TryTaskCatchDo",
                  "description": "The definition of the task(s) to run when catching an error.",
                  "minItems": 1
                }
              },
              "title": "TryTaskCatch",
              "description": "The object used to define the errors to catch.",
              "required": [
                "do"
              ],
              "unevaluatedProperties": false
            },
            "try": {
              "$ref": "#/$defs/taskList",
              "title": "TryTaskConfiguration",
              "description": "The task(s) to perform.",
              "minItems": 1
            }
          }
        }
      ]
    },
    "uriTemplate": {
      "title": "UriTemplate",
      "anyOf": [
        {
          "type": "string",
          "title": "LiteralUriTemplate",
          "pattern": "^[A-Za-z][A-Za-z0-9+\\-.]*://.*",
          "format": "uri-template"
        },
        {
          "type": "string",
          "title": "LiteralUri",
          "pattern": "^[A-Za-z][A-Za-z0-9+\\-.]*://.*",
          "format": "uri"
        }
      ]
    },
    "waitTask": {
      "type": "object",
      "title": "WaitTask",
      "description": "Allows workflows to pause or delay their execution for a specified period of time.",
      "required": [
        "wait"
      ],
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "#/$defs/taskBase"
        },
        {
          "properties": {
            "wait": {
              "title": "WaitTaskConfiguration",
              "description": "The amount of time to wait or an absolute moment in time to wait until.",
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "days": {
                      "title": "DurationDays",
                      "description": "Number of days, if any.",
                      "oneOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "$ref": "#/$defs/runtimeExpression"
                        }
                      ]
                    },
                    "hours": {
                      "title": "DurationHours",
                      "description": "Number of hours, if any.",
                      "oneOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "$ref": "#/$defs/runtimeExpression"
                        }
                      ]
                    },
                    "milliseconds": {
                      "title": "DurationMilliseconds",
                      "description": "Number of milliseconds, if any.",
                      "oneOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "$ref": "#/$defs/runtimeExpression"
                        }
                      ]
                    },
                    "minutes": {
                      "title": "DurationMinutes",
                      "description": "Number of minutes, if any.",
                      "oneOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "$ref": "#/$defs/runtimeExpression"
                        }
                      ]
                    },
                    "seconds": {
                      "title": "DurationSeconds",
                      "description": "Number of seconds, if any.",
                      "oneOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "$ref": "#/$defs/runtimeExpression"
                        }
                      ]
                    }
                  },
                  "title": "WaitDuration",
                  "description": "Duration to wait. Each numeric field may be a literal integer or a runtime expression that resolves to a number.",
                  "minProperties": 1,
                  "unevaluatedProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "until": {
                      "title": "WaitUntilTimestamp",
                      "description": "An RFC 3339 literal timestamp, or a runtime expression that resolves to one.",
                      "oneOf": [
                        {
                          "type": "string",
                          "pattern": "^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:[Zz]|[+-]\\d{2}:\\d{2})$"
                        },
                        {
                          "$ref": "#/$defs/runtimeExpression"
                        }
                      ]
                    }
                  },
                  "title": "WaitUntil",
                  "description": "An absolute moment in time to wait until.",
                  "required": [
                    "until"
                  ],
                  "unevaluatedProperties": false
                }
              ]
            }
          }
        }
      ]
    }
  },
  "title": "Zigflow",
  "description": "JSON Schema for a Zigflow workflow definition.",
  "required": [
    "do",
    "document"
  ]
}
