{
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "title": {
      "title": "Title",
      "description": "The title of this product",
      "type": "string"
    },
    "versionCommand": {
      "title": "Version command",
      "description": "Command to fetch the products version.",
      "examples": ["helm version", "go version"],
      "type": "string"
    },
    "releasePolicyLink": {
      "title": "Release policy link",
      "description": "URL to the product's release policy page.",
      "type": "string",
      "format": "uri"
    },
    "iconUrl": {
      "title": "Icon url",
      "description": "URL to the product icon.",
      "type": "string",
      "format": "uri"
    },
    "category": {
      "title": "Category",
      "description": "Specify the category of this product.",
      "enum": [
        "app",
        "db",
        "device",
        "framework",
        "lang",
        "library",
        "os",
        "server-app",
        "service",
        "standard"
      ]
    },
    "permalink": {
      "title": "Permalink",
      "description": "The URL to this product within the endoflife.date website. Must start with a slash.",
      "examples": ["/foo", "/bar"],
      "$ref": "#/$defs/slug"
    },
    "tags": {
      "title": "Tags",
      "description": "Tags which fit this product. Only lowercase, numbers and minus are allowed. Separated via spaces.",
      "type": "string",
      "pattern": "^[a-z0-9\\-]+( [a-z0-9\\-]+)*$",
      "examples": ["foo bar"]
    },
    "alternate_urls": {
      "title": "Alternate URLs",
      "description": "Array of alternate urls for this product within the endoflife.date website. Must start with a slash.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/slug"
      }
    },
    "auto": {
      "type": "object",
      "required": ["methods"],
      "properties": {
        "cumulative": {
          "title": "Mark auto-update as being cumulative (optional, default = false)",
          "description": "When true, data won't be deleted before fetching new data.\nActivating cumulative updates is not recommended for most products, but could be useful for products that:\n - have a long history of releases that is long to fetch,\n - have a history of releases that is not available anymore.",
          "type": "boolean"
        },
        "methods": {
          "title": "Auto-update configs",
          "description": "See https://github.com/endoflife-date/endoflife.date/wiki/Automation",
          "type": "array",
          "items": {
            "$ref": "#/$defs/automethod"
          }
        }
      }
    },
    "customFields": {
      "title": "Custom fields",
      "description": "Array of custom fields for this product's releases.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/customField"
      }
    },
    "releases": {
      "title": "Releases",
      "description": "Array of releases for this product.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/release"
      }
    }
  },
  "required": ["title", "category", "permalink", "releases"],
  "$defs": {
    "boolOrDate": {
      "oneOf": [
        {
          "type": "string",
          "format": "date"
        },
        {
          "type": "boolean"
        }
      ]
    },
    "boolOrString": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "boolean"
        }
      ]
    },
    "slug": {
      "type": "string",
      "pattern": "^/"
    },
    "template": {
      "title": "Template",
      "description": "Template which will be used to create the final release.",
      "type": "string"
    },
    "regex": {
      "title": "Regex",
      "description": "Regex which will be used to filter the versions.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      ]
    },
    "customField": {
      "type": "object",
      "properties": {
        "name": {
          "title": "Name",
          "description": "Name of the custom field.",
          "examples": ["supportedIosVersions", "correspondingAndroidVersion"],
          "type": "string"
        },
        "display": {
          "title": "Display",
          "description": "Where to display the custom field.",
          "enum": [
            "none",
            "api-only",
            "after-release-column",
            "before-latest-column",
            "after-latest-column"
          ]
        },
        "label": {
          "title": "Label",
          "description": "Label of the custom column.",
          "type": "string"
        },
        "description": {
          "title": "Description",
          "description": "A description of what the custom column contains.",
          "type": "string"
        },
        "link": {
          "title": "Link",
          "description": "A link that gives more information about what the custom column contains.",
          "type": "string",
          "format": "uri-template"
        }
      },
      "required": ["property", "position", "label"]
    },
    "automethod": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "git": {
              "title": "Git",
              "description": "URL to git repo. Fetches releases from tags.",
              "type": "string"
            },
            "regex": {
              "$ref": "#/$defs/regex"
            },
            "regex_exclude": {
              "$ref": "#/$defs/regex"
            },
            "template": {
              "$ref": "#/$defs/template"
            }
          },
          "required": ["git"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "npm": {
              "title": "Npm",
              "description": "Name of the npm package to track.",
              "type": "string"
            },
            "regex": {
              "$ref": "#/$defs/regex"
            },
            "regex_exclude": {
              "$ref": "#/$defs/regex"
            },
            "template": {
              "$ref": "#/$defs/template"
            }
          },
          "required": ["npm"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "docker_hub": {
              "title": "Dockerhub",
              "description": "Image name on dockerhub to track.",
              "type": "string"
            },
            "regex": {
              "$ref": "#/$defs/regex"
            },
            "regex_exclude": {
              "$ref": "#/$defs/regex"
            },
            "template": {
              "$ref": "#/$defs/template"
            }
          },
          "required": ["docker_hub"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "distrowatch": {
              "title": "Distrowatch",
              "description": "Name of the distro on distrowatch.",
              "type": "string"
            },
            "regex": {
              "$ref": "#/$defs/regex"
            },
            "regex_exclude": {
              "$ref": "#/$defs/regex"
            },
            "template": {
              "$ref": "#/$defs/template"
            }
          },
          "required": ["distrowatch"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "custom": {
              "title": "Custom",
              "description": "Use a custom script in the release-data repo.",
              "type": "boolean"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "github_releases": {
              "title": "Github releases",
              "description": "Github repo to track the releases from in the format {author}/{repo}.",
              "type": "string"
            },
            "regex": {
              "$ref": "#/$defs/regex"
            },
            "regex_exclude": {
              "$ref": "#/$defs/regex"
            }
          },
          "required": ["github_releases"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "pypi": {
              "title": "Pypi",
              "description": "Package name on PyPI.",
              "type": "string"
            },
            "regex": {
              "$ref": "#/$defs/regex"
            },
            "regex_exclude": {
              "$ref": "#/$defs/regex"
            },
            "template": {
              "$ref": "#/$defs/template"
            }
          },
          "required": ["pypi"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "maven": {
              "title": "Maven",
              "description": "Package name on Maven.",
              "type": "string"
            },
            "regex": {
              "$ref": "#/$defs/regex"
            },
            "regex_exclude": {
              "$ref": "#/$defs/regex"
            },
            "template": {
              "$ref": "#/$defs/template"
            }
          },
          "required": ["maven"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "cgit": {
              "title": "Cgit",
              "description": "Fetch versions (from tags) with their dates from a cgit repository.",
              "type": "string"
            },
            "regex": {
              "$ref": "#/$defs/regex"
            },
            "regex_exclude": {
              "$ref": "#/$defs/regex"
            },
            "template": {
              "$ref": "#/$defs/template"
            }
          },
          "required": ["cgit"],
          "additionalProperties": false
        }
      ]
    },
    "release": {
      "type": "object",
      "properties": {
        "releaseCycle": {
          "title": "releaseCycle",
          "description": "The release cycle which this release is part of.",
          "examples": ["1", "1.0"],
          "type": "string",
          "pattern": "^[a-z0-9.\\-+_]+$"
        },
        "link": {
          "title": "Link",
          "description": "Link to changelog for the latest release in this cycle, or null if unavailable.",
          "oneOf": [
            {
              "type": "string",
              "format": "uri"
            },
            {
              "type": "null"
            }
          ]
        },
        "releaseLabel": {
          "title": "Release label",
          "description": "The human-readable name of this release.",
          "type": "string"
        },
        "eolColumn": {
          "title": "EOL column",
          "description": "Whether to show the EOL column, or a custom name for it.",
          "examples": ["General Support", false],
          "$ref": "#/$defs/boolOrString"
        },
        "eol": {
          "title": "End of Life (EOL)",
          "description": "End of all support, including security support. Date in the `yyyy-mm-dd` format, or `false` if not determined.",
          "$ref": "#/$defs/boolOrDate"
        },
        "eoasColumn": {
          "title": "End of active support (EOAS) column",
          "description": "Whether to show the end of active support column, or a custom name for it.",
          "$ref": "#/$defs/boolOrString"
        },
        "eoas": {
          "title": "End of active support (EOAS)",
          "description": "End of active support. Date in the `yyyy-mm-dd` format, or `false` if not determined.",
          "$ref": "#/$defs/boolOrDate"
        },
        "eoesColumn": {
          "title": "End of extended support column",
          "description": "Whether to show the end of extended support column, or a custom name for it.",
          "$ref": "#/$defs/boolOrString"
        },
        "eoes": {
          "title": "End of extended support (EOES)",
          "description": "End of extended support. Date in the `yyyy-mm-dd` format, or `false` if not determined.",
          "$ref": "#/$defs/boolOrDate"
        },
        "discontinuedColumn": {
          "title": "Discontinued column",
          "description": "Whether to show the discontinued column, or a custom name for it.",
          "$ref": "#/$defs/boolOrString"
        },
        "discontinued": {
          "title": "Discontinued",
          "description": "Whether this device version is no longer in production. Date in the `yyyy-mm-dd` format, or `false` if not determined.",
          "$ref": "#/$defs/boolOrDate"
        },
        "releaseDateColumn": {
          "title": "Release date column",
          "description": "Whether to show the release date column, or a custom name for it.",
          "$ref": "#/$defs/boolOrString"
        },
        "releaseDate": {
          "title": "Release date",
          "description": "Release date for the first release in this cycle.",
          "type": "string",
          "format": "date"
        },
        "latestColumn": {
          "title": "Release column",
          "description": "Whether to show the release column, or a custom name for it.",
          "$ref": "#/$defs/boolOrString"
        },
        "latest": {
          "title": "Latest release",
          "description": "The latest release in this cycle.",
          "type": "string"
        },
        "latestReleaseDate": {
          "title": "Latest release date",
          "description": "The date of the latest release.",
          "type": "string",
          "format": "date"
        }
      },
      "allOf": [
        {
          "if": {
            "required": ["eolColumn"],
            "properties": {
              "eolColumn": {
                "type": "string"
              }
            }
          },
          "then": {
            "required": ["eol"]
          }
        },
        {
          "if": {
            "required": ["eoasColumn"],
            "properties": {
              "eoasColumn": {
                "type": "string"
              }
            }
          },
          "then": {
            "required": ["eoas"]
          }
        },
        {
          "if": {
            "required": ["eoesColumn"],
            "properties": {
              "eoesColumn": {
                "type": "string"
              }
            }
          },
          "then": {
            "required": ["eoes"]
          }
        },
        {
          "if": {
            "required": ["discontinuedColumn"],
            "properties": {
              "discontinuedColumn": {
                "type": "string"
              }
            }
          },
          "then": {
            "required": ["discontinued"]
          }
        },
        {
          "if": {
            "required": ["releaseDateColumn"],
            "properties": {
              "releaseDateColumn": {
                "type": "string"
              }
            }
          },
          "then": {
            "required": ["releaseDate"]
          }
        },
        {
          "if": {
            "required": ["latestColumn"],
            "properties": {
              "latestColumn": {
                "type": "string"
              }
            }
          },
          "then": {
            "required": ["latest"]
          }
        }
      ],
      "required": ["releaseCycle"]
    }
  }
}
