{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "https://somod.json-schema.sodaru.com/ui-config/index.json",
  "title": "JSON Schema for UI Config in SOMOD",
  "definitions": {
    "somodAjvCompile": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::AjvCompile"
      ],
      "properties": {
        "SOMOD::AjvCompile": {
          "anyOf": [
            {
              "$ref": "http://json-schema.org/draft-07/schema"
            },
            {
              "$ref": "#/definitions/somodFunctions"
            }
          ]
        }
      }
    },
    "somodAnd": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::And"
      ],
      "properties": {
        "SOMOD::And": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "$ref": "#/definitions/somodFunctions"
              }
            ]
          },
          "minItems": 1
        }
      }
    },
    "somodEquals": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::Equals"
      ],
      "properties": {
        "SOMOD::Equals": {
          "type": "array",
          "items": {
            "anyOf": [
              true,
              {
                "$ref": "#/definitions/somodFunctions"
              }
            ]
          },
          "minItems": 2,
          "maxItems": 2
        }
      }
    },
    "somodFunctions": {
      "if": {
        "type": "object",
        "propertyNames": {
          "enum": [
            "SOMOD::AjvCompile",
            "SOMOD::And",
            "SOMOD::Or",
            "SOMOD::Equals",
            "SOMOD::If",
            "SOMOD::JsonParse",
            "SOMOD::JsonStringify",
            "SOMOD::Key",
            "SOMOD::Parameter"
          ]
        }
      },
      "then": {
        "oneOf": [
          {
            "$ref": "#/definitions/somodAjvCompile"
          },
          {
            "$ref": "#/definitions/somodAnd"
          },
          {
            "$ref": "#/definitions/somodOr"
          },
          {
            "$ref": "#/definitions/somodEquals"
          },
          {
            "$ref": "#/definitions/somodIf"
          },
          {
            "$ref": "#/definitions/somodJsonParse"
          },
          {
            "$ref": "#/definitions/somodJsonStringify"
          },
          {
            "$ref": "#/definitions/somodKey"
          },
          {
            "$ref": "#/definitions/somodParameter"
          }
        ]
      },
      "else": true
    },
    "somodIf": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::If"
      ],
      "properties": {
        "SOMOD::If": {
          "type": "array",
          "additionalItems": {
            "anyOf": [
              true,
              {
                "$ref": "#/definitions/somodFunctions"
              }
            ]
          },
          "items": [
            {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "$ref": "#/definitions/somodFunctions"
                }
              ]
            }
          ],
          "minItems": 2,
          "maxItems": 3
        }
      }
    },
    "somodJsonParse": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::JsonParse"
      ],
      "properties": {
        "SOMOD::JsonParse": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/definitions/somodFunctions"
            }
          ]
        }
      }
    },
    "somodJsonStringify": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::JsonStringify"
      ],
      "properties": {
        "SOMOD::JsonStringify": {
          "anyOf": [
            true,
            {
              "$ref": "#/definitions/somodFunctions"
            }
          ]
        }
      }
    },
    "somodKey": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::Key"
      ],
      "properties": {
        "SOMOD::Key": {
          "type": "array",
          "additionalItems": false,
          "items": [
            {
              "anyOf": [
                {
                  "type": "object"
                },
                {
                  "type": "array"
                },
                {
                  "$ref": "#/definitions/somodFunctions"
                }
              ]
            },
            {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number"
                },
                {
                  "$ref": "#/definitions/somodFunctions"
                }
              ]
            }
          ],
          "minItems": 2,
          "maxItems": 2
        }
      }
    },
    "somodOr": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::Or"
      ],
      "properties": {
        "SOMOD::Or": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "$ref": "#/definitions/somodFunctions"
              }
            ]
          },
          "minItems": 1
        }
      }
    },
    "somodParameter": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "SOMOD::Parameter"
      ],
      "properties": {
        "SOMOD::Parameter": {
          "type": "string",
          "description": "Must refer the parameter available for this module"
        }
      }
    },
    "runtimeConfig": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^[a-zA-Z][a-zA-Z0-9_]{0,63}$": {
          "$ref": "#/definitions/somodFunctions"
        }
      },
      "maxProperties": 32,
      "errorMessage": {
        "additionalProperties": "Config Name must contain only Letters, Numbers and Underscore. Must start with letters only"
      }
    }
  },
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "env": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^[A-Z][A-Z0-9_]{0,63}$": {
          "$ref": "#/definitions/somodFunctions"
        }
      },
      "maxProperties": 32,
      "errorMessage": {
        "additionalProperties": "Environmental Variable Name must contain only UpperCase Letters, Numbers and Underscore. Must start with letters only"
      }
    },
    "imageDomains": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "format": "hostname"
          },
          {
            "$ref": "#/definitions/somodFunctions"
          }
        ]
      },
      "maxItems": 16
    },
    "publicRuntimeConfig": {
      "$ref": "#/definitions/runtimeConfig"
    },
    "serverRuntimeConfig": {
      "$ref": "#/definitions/runtimeConfig"
    }
  }
}