{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "FunctionConfig": {
            "description": "Represents the configuration schema for a function.",
            "properties": {
                "apiRevision": {
                    "const": "edurata.io/workflow/v1",
                    "description": "Refers to the version of this schema and should be updated whenever the schema changes",
                    "title": "apiRevision",
                    "type": "string"
                },
                "code": {
                    "description": "Inline code. You don't need to put the handler function and can write the content of the function directly",
                    "title": "code",
                    "type": "string"
                },
                "description": {
                    "description": "An additional description of the workflow or function",
                    "title": "description",
                    "type": "string"
                },
                "entrypoint": {
                    "description": "Points to the entrypoint of the function. Defaults to index.js, index.py, index.sh, etc.",
                    "title": "entrypoint",
                    "type": "string"
                },
                "exclude": {
                    "description": "Specifies which files to exclude from the function. Can be a glob pattern. Defaults to none.",
                    "items": {
                        "type": "string"
                    },
                    "title": "exclude",
                    "type": "array"
                },
                "include": {
                    "description": "Specifies which files to include in the function. Can be a glob pattern. Defaults to all files in the same directory as the entrypoint.",
                    "items": {
                        "type": "string"
                    },
                    "title": "include",
                    "type": "array"
                },
                "interface": {
                    "$ref": "#/definitions/Interface",
                    "description": "The schema of inputs and outputs of this workflow or function",
                    "title": "interface"
                },
                "name": {
                    "description": "An identifier that is unique in the registry. It is used as reference in deployments or workflows.",
                    "title": "name",
                    "type": "string"
                },
                "registry": {
                    "$ref": "#/definitions/Registry",
                    "description": "If the source shouldn't be built but is already in an external registry, you can point to it here.",
                    "title": "registry"
                },
                "runtime": {
                    "description": "Specifies the programming language the code is written in.",
                    "enum": [
                        "docker",
                        "nodejs20",
                        "python3_10"
                    ],
                    "title": "runtime",
                    "type": "string"
                },
                "title": {
                    "description": "A short title that describes the workflow or function. This is NOT the id that will be used in the registry!",
                    "title": "title",
                    "type": "string"
                }
            },
            "title": "FunctionConfig",
            "type": "object"
        },
        "Interface": {
            "description": "Schema for an interface of a workflow or function.",
            "properties": {
                "inputs": {
                    "properties": {
                        "properties": {
                            "additionalProperties": {
                                "$ref": "#/definitions/InterfaceProperty"
                            },
                            "title": "properties",
                            "type": "object"
                        },
                        "required": {
                            "items": {
                                "type": "string"
                            },
                            "title": "required",
                            "type": "array"
                        }
                    },
                    "title": "inputs",
                    "type": "object"
                },
                "outputs": {
                    "properties": {
                        "properties": {
                            "additionalProperties": {
                                "$ref": "#/definitions/InterfaceProperty"
                            },
                            "title": "properties",
                            "type": "object"
                        },
                        "required": {
                            "items": {
                                "type": "string"
                            },
                            "title": "required",
                            "type": "array"
                        }
                    },
                    "title": "outputs",
                    "type": "object"
                }
            },
            "title": "Interface",
            "type": "object"
        },
        "InterfaceProperty": {
            "description": "Inspired by JSON Schema for easier conversion from and to other tools.",
            "properties": {
                "const": {
                    "$ref": "#/definitions/InterfaceProperty",
                    "description": "Inspired by JSON Schema for easier conversion from and to other tools.",
                    "title": "const"
                },
                "default": {
                    "$ref": "#/definitions/InterfaceProperty",
                    "description": "Inspired by JSON Schema for easier conversion from and to other tools.",
                    "title": "default"
                },
                "description": {
                    "title": "description",
                    "type": "string"
                },
                "enum": {
                    "items": {
                        "type": [
                            "string",
                            "number",
                            "boolean"
                        ]
                    },
                    "title": "enum",
                    "type": "array"
                },
                "examples": {
                    "items": {
                        "$ref": "#/definitions/InterfaceProperty"
                    },
                    "title": "examples",
                    "type": "array"
                },
                "items": {
                    "$ref": "#/definitions/InterfaceProperty",
                    "description": "Inspired by JSON Schema for easier conversion from and to other tools.",
                    "title": "items"
                },
                "properties": {
                    "additionalProperties": {
                        "$ref": "#/definitions/InterfaceProperty"
                    },
                    "title": "properties",
                    "type": "object"
                },
                "required": {
                    "items": {
                        "type": "string"
                    },
                    "title": "required",
                    "type": "array"
                },
                "title": {
                    "title": "title",
                    "type": "string"
                },
                "type": {
                    "$ref": "#/definitions/Interface",
                    "title": "type"
                }
            },
            "required": [
                "type"
            ],
            "title": "InterfaceProperty",
            "type": "object"
        },
        "Registry": {
            "description": "If a registry is used, this is the schema for it. Currently only supported for runtime: \"docker\"",
            "properties": {
                "tag": {
                    "title": "tag",
                    "type": "string"
                },
                "url": {
                    "title": "url",
                    "type": "string"
                }
            },
            "required": [
                "tag",
                "url"
            ],
            "title": "Registry",
            "type": "object"
        },
        "SourceImageRepo": {
            "description": "If the source is an image, you can point to an image repo and its tag.",
            "properties": {
                "imageRepoUrl": {
                    "description": "The url of the image repository. If dockerhub is used, url is optional.",
                    "title": "imageRepoUrl",
                    "type": "string"
                },
                "tag": {
                    "description": "The tag of the image.",
                    "title": "tag",
                    "type": "string"
                }
            },
            "required": [
                "imageRepoUrl",
                "tag"
            ],
            "title": "SourceImageRepo",
            "type": "object"
        },
        "SourceRegistry": {
            "description": "If the source is already in the registry you can point to an entry of the registry.",
            "properties": {
                "name": {
                    "description": "The name of the function in the registry.",
                    "title": "name",
                    "type": "string"
                },
                "revision": {
                    "description": "The revision of the function in the registry.",
                    "title": "revision",
                    "type": "string"
                }
            },
            "required": [
                "name"
            ],
            "title": "SourceRegistry",
            "type": "object"
        },
        "SourceRepo": {
            "description": "If the source is a git repository, this is the schema for it.",
            "properties": {
                "path": {
                    "description": "the path of where to find the function code inside the repository",
                    "title": "path",
                    "type": "string"
                },
                "ref": {
                    "description": "The ref of the git repository to use. Defaults to \"main\".",
                    "title": "ref",
                    "type": "string"
                },
                "repoUrl": {
                    "description": "the url of the git repository",
                    "title": "repoUrl",
                    "type": "string"
                }
            },
            "required": [
                "repoUrl"
            ],
            "title": "SourceRepo",
            "type": "object"
        },
        "Step": {
            "anyOf": [
                {
                    "$ref": "#/definitions/StepWithSource",
                    "description": "Schema for a workflow step with source"
                },
                {
                    "$ref": "#/definitions/StepWithInline",
                    "description": "Schema for a workflow step with a function directly defined inline with code property"
                }
            ],
            "title": "Step"
        },
        "StepDependency": {
            "description": "Schema for an educational function step dependency.",
            "properties": {
                "outputId": {
                    "description": "the name of the output of a step (thereby its function). has to be one of the outputs defined in\nFunctionSchema.interface.outputs of the dependent step mentioned with \"stepId\"",
                    "title": "outputId",
                    "type": "string"
                },
                "outputPath": {
                    "description": "only used when the output is a complex object and the value is inside. is a string with dot notation\nto point to the value. e.g. \"data.name\" to point to the value of the key \"name\" inside the object\n\"data\".",
                    "items": {
                        "type": "string"
                    },
                    "title": "outputPath",
                    "type": "array"
                },
                "props": {
                    "description": "If the dependency is a string with interpolated values, these are the interpolated values, if any.\nThese are mostly autopopulated and usually don't need to be set manually.",
                    "items": {
                        "$ref": "#/definitions/StepDependency"
                    },
                    "title": "props",
                    "type": "array"
                },
                "stepId": {
                    "description": "the step which to depend on. Needs to be one defined in the \"steps\" attribute of the workflow\ndefinition. Can be \"inputs\" to refer to the global inputs of the workflow. Can be \"each\" if the\nattribute \"foreach\" in the parent step is defined.",
                    "title": "stepId",
                    "type": "string"
                },
                "value": {
                    "description": "If you want to pass in a value directly instead of a step dependency, you can use this attribute.\nYou can also use interpolation here.",
                    "title": "value",
                    "type": "string"
                }
            },
            "title": "StepDependency",
            "type": "object"
        },
        "StepWithInline": {
            "allOf": [
                {
                    "properties": {
                        "description": {
                            "description": "An additional description next to the key of the step.",
                            "title": "description",
                            "type": "string"
                        },
                        "foreach": {
                            "anyOf": [
                                {
                                    "pattern": "^.*..*..*$",
                                    "type": "string"
                                },
                                {
                                    "$ref": "#/definitions/StepDependency"
                                }
                            ],
                            "description": "If defined and the dependency is of type array, this step will loop over the array. The props\nattribute can then use \"each\" as StepDependencySchema.stepId, pointing to each iteration.",
                            "title": "foreach"
                        },
                        "if": {
                            "description": "If defined, this step will only execute if the condition is true. The condition is a javascript boolean expression.",
                            "title": "if",
                            "type": "string"
                        }
                    },
                    "type": "object"
                },
                {
                    "$ref": "#/definitions/FunctionConfig"
                }
            ],
            "description": "Schema for a workflow step with a function directly defined inline with code property",
            "title": "StepWithInline"
        },
        "StepWithSource": {
            "allOf": [
                {
                    "properties": {
                        "description": {
                            "description": "An additional description next to the key of the step.",
                            "title": "description",
                            "type": "string"
                        },
                        "foreach": {
                            "anyOf": [
                                {
                                    "pattern": "^.*..*..*$",
                                    "type": "string"
                                },
                                {
                                    "$ref": "#/definitions/StepDependency"
                                }
                            ],
                            "description": "If defined and the dependency is of type array, this step will loop over the array. The props\nattribute can then use \"each\" as StepDependencySchema.stepId, pointing to each iteration.",
                            "title": "foreach"
                        },
                        "if": {
                            "description": "If defined, this step will only execute if the condition is true. The condition is a javascript boolean expression.",
                            "title": "if",
                            "type": "string"
                        }
                    },
                    "type": "object"
                },
                {
                    "properties": {
                        "props": {
                            "additionalProperties": {
                                "anyOf": [
                                    {
                                        "pattern": "^.*..*..*$",
                                        "type": "string"
                                    },
                                    {
                                        "$ref": "#/definitions/StepDependency"
                                    }
                                ]
                            },
                            "description": "Specifies where to get the input data (from other steps or the global inputs of the workflow defined in\nthe \"interface\" attribute at the top). Each key must be an input of this step and should be defined in\nFunctionSchema.interface.inputs of the function defined in \"source\".",
                            "title": "props",
                            "type": "object"
                        },
                        "source": {
                            "anyOf": [
                                {
                                    "$ref": "#/definitions/SourceImageRepo"
                                },
                                {
                                    "$ref": "#/definitions/SourceRegistry"
                                },
                                {
                                    "$ref": "#/definitions/SourceRepo"
                                }
                            ],
                            "description": "Specifies the source from which to obtain the code to execute in this step.",
                            "title": "source"
                        }
                    },
                    "type": "object"
                }
            ],
            "description": "Schema for a workflow step with source",
            "title": "StepWithSource"
        }
    },
    "description": "Represents the configuration schema for a workflow.",
    "properties": {
        "apiRevision": {
            "const": "edurata.io/workflow/v1",
            "description": "Refers to the version of this schema and should be updated whenever the schema changes",
            "title": "apiRevision",
            "type": "string"
        },
        "description": {
            "description": "An additional description of the workflow or function",
            "title": "description",
            "type": "string"
        },
        "interface": {
            "$ref": "#/definitions/Interface",
            "description": "The schema of inputs and outputs of this workflow or function",
            "title": "interface"
        },
        "name": {
            "description": "An identifier that is unique in the registry. It is used as reference in deployments or workflows.",
            "title": "name",
            "type": "string"
        },
        "schedule": {
            "description": "A cron schedule that determines when the workflow should be executed.",
            "title": "schedule",
            "type": "string"
        },
        "steps": {
            "additionalProperties": {
                "$ref": "#/definitions/Step"
            },
            "description": "Each step of the workflow specified by a unique key and its definition as a value.\nThe order of execution and dataflow is inferred by \"props\".",
            "title": "steps",
            "type": "object"
        },
        "title": {
            "description": "A short title that describes the workflow or function. This is NOT the id that will be used in the registry!",
            "title": "title",
            "type": "string"
        }
    },
    "required": [
        "steps"
    ],
    "type": "object"
}

