{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Eggtimer.app recipes",
  "oneOf": [
    {
      "title": "Basic recipe (version 1)",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "version",
        "steps"
      ],
      "properties": {
        "version": {
          "const": 1
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "author": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "display": {
          "enum": [
            "digits",
            "ring",
            "bar"
          ]
        },
        "theme": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "paper": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "panel": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "ink": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "muted": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "line": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "accent": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "white": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "highlight": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            }
          }
        },
        "steps": {
          "type": "array",
          "minItems": 1,
          "maxItems": 12,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "seconds"
            ],
            "properties": {
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "seconds": {
                "type": "integer",
                "minimum": 1,
                "maximum": 315576000
              }
            }
          }
        },
        "cycles": {
          "type": "integer",
          "minimum": 1,
          "maximum": 12
        },
        "autoAdvance": {
          "type": "boolean"
        },
        "completion": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "message": {
              "type": "string",
              "minLength": 1,
              "maxLength": 160
            },
            "sound": {
              "type": "boolean"
            },
            "webhook": {
              "type": "boolean"
            }
          }
        }
      },
      "$comment": "The runtime also checks that sum(steps.seconds) * cycles is at most 315576000. No network targets or credentials belong in recipes."
    },
    {
      "title": "Interval recipe (version 2)",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "version",
        "steps"
      ],
      "properties": {
        "version": {
          "const": 2
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "author": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "display": {
          "enum": [
            "digits",
            "ring",
            "bar"
          ]
        },
        "theme": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "paper": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "panel": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "ink": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "muted": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "line": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "accent": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "white": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "highlight": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            }
          }
        },
        "steps": {
          "type": "array",
          "minItems": 1,
          "maxItems": 32,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "seconds"
            ],
            "properties": {
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "seconds": {
                "type": "number",
                "minimum": 0.1,
                "maximum": 315576000
              },
              "repeat": {
                "type": "integer",
                "minimum": 1,
                "maximum": 32
              }
            }
          }
        },
        "cycles": {
          "type": "integer",
          "minimum": 1,
          "maximum": 12
        },
        "autoAdvance": {
          "type": "boolean"
        },
        "completion": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "message": {
              "type": "string",
              "minLength": 1,
              "maxLength": 160
            },
            "sound": {
              "type": "boolean"
            },
            "webhook": {
              "type": "boolean"
            }
          }
        },
        "stepSound": {
          "type": "boolean"
        },
        "repeatLabel": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20
        },
        "note": {
          "type": "string",
          "maxLength": 320
        }
      },
      "$comment": "The runtime also limits expanded repetitions to 512 and total duration including repeats/cycles to 315576000 seconds."
    }
  ]
}
