{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/outblocks-project-configuration/latest.json",
  "title": "JSON schema for Outblocks project configuration files",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/outblocks/outblocks-cli/master/schema/schema-project.json",
    "sourceSha256": "2ef71e2809a08a078f988206ddb80de2eb4f0afc5a8670b53299ab67d4be0325",
    "fileMatch": [
      "project.outblocks.yaml",
      "project.outblocks.yml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "$defs": {
    "OutblocksProject": {
      "title": "Outblocks",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "dns": {
          "description": "Project-wide DNS setup.",
          "$ref": "#/$defs/DNS"
        },
        "state": {
          "description": "Project-wide state source.",
          "$ref": "#/$defs/State"
        },
        "secrets": {
          "description": "Project-wide secrets provider.",
          "$ref": "#/$defs/Secrets"
        },
        "dependencies": {
          "description": "Project-wide dependencies to provision.",
          "$ref": "#/$defs/Dependencies"
        },
        "monitoring": {
          "description": "Project monitoring setup.",
          "$ref": "#/$defs/Monitoring"
        },
        "plugins": {
          "description": "Project-wide plugins.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/Plugin"
          }
        },
        "defaults": {
          "description": "Project-wide default app settings.",
          "$ref": "#/$defs/Defaults"
        }
      },
      "additionalProperties": false
    },
    "DNS": {
      "title": "DNS",
      "type": "array",
      "items": {
        "oneOf": [
          {
            "required": [
              "domain"
            ]
          },
          {
            "required": [
              "domains"
            ]
          }
        ],
        "properties": {
          "domain": {
            "type": "string"
          },
          "domains": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "plugin": {
            "type": "string"
          },
          "ssl": {
            "description": "SSL configuration.",
            "$ref": "#/$defs/SSL"
          }
        },
        "additionalProperties": false,
        "type": "object"
      }
    },
    "SSL": {
      "title": "SSL",
      "type": "object",
      "properties": {
        "cert_file": {
          "description": "Public key file path. Required to be in PEM format.",
          "type": "string"
        },
        "key_file": {
          "description": "Private key file path. Required to be in PEM format.",
          "type": "string"
        },
        "cert": {
          "description": "Public key value in PEM format.",
          "type": "string"
        },
        "key": {
          "description": "Private key value in PEM format.",
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "State": {
      "type": "object",
      "title": "State",
      "properties": {
        "type": {
          "description": "State type, plugin specific value e.g. 'gcp' for gcp plugin or use 'local' for local state.",
          "type": "string"
        },
        "path": {
          "description": "Path of local state, used only when state type is 'local'.",
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": true
    },
    "Secrets": {
      "type": "object",
      "title": "Secrets",
      "properties": {
        "type": {
          "description": "Secrets provider type, plugin specific value e.g. 'gcp' for gcp plugin.",
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "Dependencies": {
      "title": "Dependencies",
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^[_a-zA-Z][a-zA-Z0-9_-]*$": {
          "type": "object",
          "properties": {
            "type": {
              "description": "The type of the dependency.",
              "type": "string"
            },
            "deploy": {
              "description": "Deploy config.",
              "$ref": "#/$defs/DependencyDeploy"
            },
            "run": {
              "description": "Run config.",
              "$ref": "#/$defs/DependencyRun"
            }
          },
          "required": [
            "type"
          ],
          "allOf": [
            {
              "if": {
                "properties": {
                  "type": {
                    "const": "storage"
                  }
                }
              },
              "then": {
                "properties": {
                  "versioning": {
                    "description": "Enables versioning for objects.",
                    "type": "boolean"
                  },
                  "location": {
                    "description": "Specify location for storage, refer to cloud provider docs for possible options.",
                    "type": "string"
                  },
                  "public": {
                    "description": "Makes whole storage public so that all objects can be accessed.",
                    "type": "boolean"
                  },
                  "max_versions": {
                    "description": "Maximum amount of versions to keep.",
                    "type": "integer"
                  },
                  "delete_in_days": {
                    "description": "Delete new objects after X days.",
                    "type": "integer"
                  },
                  "expire_versions_in_days": {
                    "description": "Expire archived versions after X days.",
                    "type": "integer"
                  },
                  "cors": {
                    "description": "CORS settings.",
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/DependencyStorageCORS"
                    }
                  }
                }
              }
            },
            {
              "if": {
                "anyOf": [
                  {
                    "properties": {
                      "type": {
                        "const": "mysql"
                      }
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "const": "postgresql"
                      }
                    }
                  }
                ]
              },
              "then": {
                "properties": {
                  "version": {
                    "description": "Specify version of database, refer to cloud provider docs for possible options.",
                    "type": "string"
                  },
                  "high_availability": {
                    "description": "Makes database highly available meaning it will have a read replica available in case of master failure.",
                    "type": "boolean"
                  },
                  "tier": {
                    "description": "Specify tier of database, refer to cloud provider docs for possible options.",
                    "type": "string"
                  },
                  "flags": {
                    "description": "Database flags, refer to cloud provider docs for possible options.",
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "users": {
                    "description": "Database users.",
                    "type": "object",
                    "additionalProperties": {
                      "$ref": "#/$defs/DependencyDatabaseUser"
                    }
                  }
                }
              }
            }
          ]
        }
      }
    },
    "DependencyDatabaseUser": {
      "title": "Database user",
      "type": "object",
      "properties": {
        "password": {
          "description": "Explicitly set password, defaults to a randomly generated string.",
          "type": "string"
        },
        "hostname": {
          "description": "Hostname that user is allowed to connect from. Not all databases may support it.",
          "type": "string"
        }
      }
    },
    "DependencyStorageCORS": {
      "title": "Storage CORS",
      "type": "object",
      "properties": {
        "origins": {
          "description": "The list of Origins eligible to receive CORS response headers. Note: \"*\" is permitted in the list of origins, and means \"any Origin\".",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "methods": {
          "description": "The list of HTTP methods on which to include CORS response headers, (GET, OPTIONS, POST, etc) Note: \"*\" is permitted in the list of methods, and means \"any method\".",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "response_headers": {
          "description": "The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "max_age_in_seconds": {
          "description": "The value in seconds to return in the Access-Control-Max-Age header used in preflight responses.",
          "type": "integer"
        }
      }
    },
    "DependencyRun": {
      "title": "Run",
      "type": "object",
      "properties": {
        "plugin": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "DependencyDeploy": {
      "title": "Deploy",
      "type": "object",
      "properties": {
        "plugin": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "Monitoring": {
      "title": "Monitoring",
      "type": "object",
      "properties": {
        "plugin": {
          "description": "Monitoring plugin override. Defaults to first supported plugin available.",
          "type": "string"
        },
        "channels": {
          "description": "Monitoring notification channels.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/MonitoringChannel"
          }
        },
        "targets": {
          "description": "Monitoring targets.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/MonitoringTarget"
          }
        }
      },
      "additionalProperties": false
    },
    "MonitoringChannel": {
      "title": "Monitoring channels",
      "type": "object",
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "slack"
              }
            }
          },
          "then": {
            "properties": {
              "token": {
                "description": "Bot user oauth token used for slack notification.",
                "type": "string"
              },
              "channel": {
                "description": "Channel used for slack notification.",
                "type": "string"
              }
            },
            "required": [
              "type",
              "token",
              "channel"
            ],
            "type": "object"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "email"
              }
            }
          },
          "then": {
            "properties": {
              "email": {
                "description": "Email used for email channel type.",
                "type": "string"
              }
            },
            "required": [
              "type",
              "email"
            ],
            "type": "object"
          }
        }
      ],
      "properties": {
        "type": {
          "description": "Notification channel type. Possible values: slack, email.",
          "type": "string",
          "enum": [
            "slack",
            "email"
          ]
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": true
    },
    "MonitoringTarget": {
      "title": "Monitoring target",
      "type": "object",
      "required": [
        "url"
      ],
      "properties": {
        "url": {
          "description": "Target full url.",
          "type": "string"
        },
        "frequency": {
          "description": "Check frequency in minutes. Defaults to 5 minutes.",
          "type": "integer",
          "enum": [
            1,
            5,
            10,
            15
          ]
        },
        "locations": {
          "description": "Check locations to use. Defaults to 'all'.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "Plugin": {
      "title": "Plugin",
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "Defaults": {
      "title": "Defaults",
      "type": "object",
      "properties": {
        "deploy": {
          "description": "Deploy config.",
          "$ref": "#/$defs/DefaultDeploy"
        },
        "dns": {
          "description": "DNS config.",
          "$ref": "#/$defs/DefaultDNS"
        },
        "run": {
          "description": "Run config.",
          "$ref": "#/$defs/DefaultRun"
        }
      },
      "additionalProperties": false
    },
    "DefaultDeploy": {
      "title": "Deploy defaults",
      "type": "object",
      "env": {
        "description": "Additional environment variables added to every app that supports environment variables.",
        "type": "object",
        "additionalProperties": {
          "type": "string"
        }
      },
      "properties": {
        "plugin": {
          "description": "Deploy plugin override. Defaults to first supported plugin available.",
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "DefaultDNS": {
      "title": "DNS defaults",
      "type": "object",
      "properties": {
        "plugin": {
          "description": "DNS plugin override. Defaults to first supported plugin available.",
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "DefaultRun": {
      "title": "Run defaults",
      "type": "object",
      "properties": {
        "plugin": {
          "description": "Run plugin override. Defaults to first supported plugin available.",
          "type": "string"
        },
        "env": {
          "description": "Additional environment variables added to every app that supports environment variables.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    }
  },
  "$ref": "#/$defs/OutblocksProject"
}
