{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/outblocks-app-configuration/latest.json",
  "title": "JSON schema for Outblocks App configuration files",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/outblocks/outblocks-cli/master/schema/schema-app.json",
    "sourceSha256": "e6646b7de87a556a9bedced223e29001af69f78ccf076811f214840f89a91a74",
    "fileMatch": [
      "app.outblocks.yaml",
      "app.outblocks.yml",
      "*.app.outblocks.yaml",
      "*.app.outblocks.yml",
      "outblocks.yaml",
      "outblocks.yml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "$defs": {
    "OutblocksApp": {
      "title": "OutblocksApp",
      "type": "object",
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "static"
              }
            }
          },
          "then": {
            "properties": {
              "routing": {
                "description": "Routing type. Defaults to 'react'.",
                "type": "string",
                "enum": [
                  "react",
                  "gatsby",
                  "disabled"
                ]
              },
              "remove_trailing_slash": {
                "description": "Remove trailing slash with permanent redirect. Currently used only for deployments. Defaults to 'true' when gatsby routing is used, 'false' otherwise.",
                "type": "boolean"
              },
              "basic_auth": {
                "description": "Static application basic authentication config. Currently used only for deployments.",
                "$ref": "#/$defs/StaticBasicAuth"
              },
              "build": {
                "description": "Static application build config used for deployment builds.",
                "$ref": "#/$defs/StaticBuild"
              },
              "deploy": {
                "description": "Static deploy config.",
                "$ref": "#/$defs/StaticDeploy"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "service"
              }
            }
          },
          "then": {
            "properties": {
              "private": {
                "description": "Marks app as private - won't allow unauthenticated access.",
                "type": "boolean"
              },
              "build": {
                "description": "Service application build config used for deployment builds.",
                "$ref": "#/$defs/ServiceBuild"
              },
              "container": {
                "description": "Service application container config used for docker based deployments/runs.",
                "$ref": "#/$defs/ServiceContainer"
              },
              "deploy": {
                "description": "Service deploy config.",
                "$ref": "#/$defs/ServiceDeploy"
              },
              "scheduler": {
                "description": "Service scheduler config.",
                "$ref": "#/$defs/Scheduler"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "function"
              }
            }
          },
          "then": {
            "required": [
              "type"
            ],
            "properties": {
              "private": {
                "description": "Marks app as private - won't allow unauthenticated access.",
                "type": "boolean"
              },
              "runtime": {
                "description": "The runtime in which the function is going to run, refer to cloud provider docs for possible options.",
                "type": "string"
              },
              "entrypoint": {
                "description": "Name of the function that will be executed when the function is triggered. Not all deployment plugins support it. Defaults to application name.",
                "type": "string"
              },
              "build": {
                "description": "Function application build config used for deployment builds.",
                "$ref": "#/$defs/FunctionBuild"
              },
              "deploy": {
                "description": "Function deploy config.",
                "$ref": "#/$defs/FunctionDeploy"
              },
              "package": {
                "description": "Function package config.",
                "$ref": "#/$defs/FunctionPackage"
              },
              "scheduler": {
                "description": "Function scheduler config.",
                "$ref": "#/$defs/Scheduler"
              }
            },
            "type": "object"
          }
        }
      ],
      "properties": {
        "name": {
          "description": "Name of the app. Defaults to directory name.",
          "type": "string"
        },
        "type": {
          "description": "Type of the app.",
          "type": "string",
          "enum": [
            "static",
            "function",
            "service"
          ]
        },
        "env": {
          "description": "Environment variables common for all operations.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "dir": {
          "description": "Working directory of the app where all commands will be run. Defaults to location of this yaml. All other dirs will be relative to this one.",
          "type": "string"
        },
        "url": {
          "description": "External URL of the app.",
          "type": "string"
        },
        "path_redirect": {
          "description": "Path redirect rewrites URL to specified path. URL path from 'url' field will be stripped and replaced with value below.",
          "type": "string"
        },
        "needs": {
          "description": "Application dependencies to inject.",
          "$ref": "#/$defs/Needs"
        },
        "run": {
          "description": "Run config used for dev builds during run.",
          "$ref": "#/$defs/Run"
        },
        "cdn": {
          "description": "CDN settings.",
          "$ref": "#/$defs/CDN"
        },
        "build": {
          "type": "object"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": true
    },
    "Needs": {
      "title": "Needs",
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^[_a-zA-Z][a-zA-Z0-9_-]*$": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "object"
            }
          ]
        }
      }
    },
    "Run": {
      "title": "Run config",
      "type": "object",
      "properties": {
        "plugin": {
          "description": "Run plugin override. Defaults to first supported plugin available.",
          "type": "string"
        },
        "command": {
          "description": "Command to be run to for dev mode.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "port": {
          "description": "Port override, by default just assigns next port starting from listen-port.",
          "type": "integer"
        },
        "env": {
          "description": "Additional environment variables available local run.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    },
    "StaticDeploy": {
      "title": "Static deploy config",
      "type": "object",
      "properties": {
        "plugin": {
          "description": "Deploy plugin override. Defaults to first supported plugin available.",
          "type": "string"
        },
        "min_scale": {
          "description": "Minimum scale of container deployment (used if deployment uses a container).",
          "type": "integer"
        },
        "max_scale": {
          "description": "Maximum scale of container deployment (used if deployment uses a container).",
          "type": "integer"
        },
        "timeout": {
          "description": "Execution timeout. Execution is considered failed and can be terminated if the function is not completed at the end of the timeout period.",
          "type": "integer"
        },
        "patterns": {
          "description": "File/dir patterns to exclude (or force include if starts with '!').",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    },
    "ServiceDeploy": {
      "title": "Service deploy config",
      "type": "object",
      "properties": {
        "plugin": {
          "description": "Deploy plugin override. Defaults to first supported plugin available.",
          "type": "string"
        },
        "env": {
          "description": "Additional environment variables.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "cpu_limit": {
          "description": "CPU limit of container deployment. 1.0 means 1 full core of CPU will be used.",
          "type": "number"
        },
        "memory_limit": {
          "description": "Memory limit in MiB of container deployment.",
          "type": "integer"
        },
        "min_scale": {
          "description": "Minimum scale of container deployment.",
          "type": "integer"
        },
        "max_scale": {
          "description": "Maximum scale of container deployment.",
          "type": "integer"
        },
        "timeout": {
          "description": "Execution timeout. Execution is considered failed and can be terminated if the function is not completed at the end of the timeout period.",
          "type": "integer"
        },
        "container": {
          "description": "Service application container config used for docker based deployments.",
          "$ref": "#/$defs/ServiceContainer"
        }
      },
      "additionalProperties": true
    },
    "Scheduler": {
      "title": "Scheduler config",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "cron": {
            "description": "Scheduler cron, e.g. */30 * * * * runs every 30 minutes.",
            "type": "string"
          },
          "name": {
            "description": "Name of cron (just for information purpose).",
            "type": "string"
          },
          "method": {
            "description": "HTTP method to use. Defaults to 'GET'.",
            "type": "string",
            "enum": [
              "GET",
              "POST",
              "HEAD",
              "PUT",
              "DELETE",
              "PATCH",
              "OPTIONS"
            ]
          },
          "path": {
            "description": "Path to call in current app url.",
            "type": "string"
          },
          "headers": {
            "description": "Additional headers to use for this call.",
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "cron"
        ],
        "additionalProperties": false
      }
    },
    "FunctionDeploy": {
      "title": "Function deploy config",
      "type": "object",
      "properties": {
        "plugin": {
          "description": "Deploy plugin override. Defaults to first supported plugin available.",
          "type": "string"
        },
        "env": {
          "description": "Additional environment variables.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "memory_limit": {
          "description": "Memory limit in MiB of function deployment.",
          "type": "integer"
        },
        "min_scale": {
          "description": "Minimum scale of container deployment (used if deployment uses a container).",
          "type": "integer"
        },
        "max_scale": {
          "description": "Maximum scale of container deployment (used if deployment uses a container).",
          "type": "integer"
        },
        "timeout": {
          "description": "Execution timeout. Execution is considered failed and can be terminated if the function is not completed at the end of the timeout period.",
          "type": "integer"
        }
      },
      "additionalProperties": true
    },
    "FunctionPackage": {
      "title": "Function package config",
      "type": "object",
      "properties": {
        "patterns": {
          "description": "Package patterns to exclude (or force include if starts with '!').",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "CDN": {
      "title": "CDN",
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "StaticBasicAuth": {
      "title": "Static app basic auth config",
      "type": "object",
      "properties": {
        "realm": {
          "description": "Basic auth realm name, defaults to 'restricted'.",
          "type": "string"
        },
        "users": {
          "description": "Basic auth users in form of `user: password` where password is either in plain text or in a form of apr1 hash (used by htpasswd).",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "StaticBuild": {
      "title": "Build static app",
      "type": "object",
      "properties": {
        "env": {
          "description": "Additional environment variables available during build.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "command": {
          "description": "Command to be run to generate output files.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "dir": {
          "description": "Output dir to where static files end up.",
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "ServiceBuild": {
      "title": "Service app build definition",
      "type": "object",
      "properties": {
        "image": {
          "description": "Docker image to use. If specified, will try to pull this image if skip-build is enabled.",
          "type": "string"
        },
        "skip_build": {
          "description": "Skip this image build phase. If enabled, requires image to be either present on docker host or custom image to be possible to pull.",
          "type": "boolean"
        },
        "skip_pull": {
          "description": "Skip this image dependencies pull phase. As a result, doesn't check for newer versions of tagged dependencies. Useful if dependencies do not exist outside of local docker.",
          "type": "boolean"
        },
        "build_args": {
          "description": "Docker build-args.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "secrets": {
          "description": "Docker build secrets.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "context": {
          "description": "Docker context directory, relative to application dir.",
          "type": "string"
        },
        "dockerfile": {
          "description": "Dockerfile to use, relative to context path. Defaults to 'Dockerfile'.",
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "FunctionBuild": {
      "title": "Build function app",
      "type": "object",
      "properties": {
        "env": {
          "description": "Additional environment variables available during build.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "command": {
          "description": "Command to be run to generate output files.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "dir": {
          "description": "Output dir to where built files end up.",
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "ServiceContainer": {
      "title": "Service app container definition",
      "type": "object",
      "properties": {
        "port": {
          "description": "Docker container port to use.",
          "type": "integer"
        },
        "command": {
          "description": "Docker command (CMD) to override.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "entrypoint": {
          "description": "Docker entrypoint (ENTRYPOINT) to override.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "liveness_probe": {
          "description": "Liveness probe definition.",
          "$ref": "#/$defs/ServiceContainerProbe"
        },
        "startup_probe": {
          "description": "Startup probe definition.",
          "$ref": "#/$defs/ServiceContainerProbe"
        }
      },
      "additionalProperties": false
    },
    "ServiceContainerProbe": {
      "title": "Service app container probe definition",
      "type": "object",
      "properties": {
        "http_path": {
          "description": "HTTP path to probe.",
          "type": "string"
        },
        "grpc_service": {
          "description": "GRPC service to probe.",
          "type": "string"
        },
        "port": {
          "description": "Port to use for probing. If not specified, default container port is used.",
          "type": "integer"
        },
        "initial_delay_seconds": {
          "description": "Number of seconds after the container has started before probes are initiated.",
          "type": "integer"
        },
        "period_seconds": {
          "description": "How often (in seconds) to perform the probe. Default to 10 seconds.",
          "type": "integer"
        },
        "timeout_seconds": {
          "description": "Number of seconds after which the probe times out. Defaults to 1 second.",
          "type": "integer"
        },
        "failure_threshold": {
          "description": "When a probe fails, Kubernetes will try failure_threshold times before giving up. Defaults to 3.",
          "type": "integer"
        }
      },
      "additionalProperties": false
    }
  },
  "$ref": "#/$defs/OutblocksApp"
}
