{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Индекс каталога программ",
  "description": "Схема YAML Front Matter файла index.md для категории или программы.",
  "oneOf": [
    {
      "$ref": "#/$defs/category"
    },
    {
      "$ref": "#/$defs/program"
    }
  ],
  "$defs": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 240
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4000,
      "contentMediaType": "text/markdown"
    },
    "summary": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "targets": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "higold",
          "egold",
          "sgold",
          "odm",
          "apoxi",
          "brew"
        ]
      }
    },
    "url": {
      "type": "string",
      "format": "uri",
      "pattern": "^https?://"
    },
    "filePath": {
      "type": "string",
      "pattern": "^(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)files/.+$"
    },
    "screenshotPath": {
      "type": "string",
      "pattern": "^(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)img/.+\\.(?:png|jpe?g|webp|gif)$"
    },
    "file": {
      "title": "Файл программы",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "path"
      ],
      "properties": {
        "path": {
          "$ref": "#/$defs/filePath"
        },
        "description": {
          "$ref": "#/$defs/description"
        },
        "platform": {
          "type": "string",
          "enum": [
            "win32",
            "win64",
            "dos",
            "java",
            "j2me"
          ]
        }
      }
    },
    "version": {
      "title": "Версия программы",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "version",
        "files"
      ],
      "properties": {
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "pattern": "^[^/\\\\]+$"
        },
        "status": {
          "type": "string",
          "enum": [
            "current",
            "archived"
          ]
        },
        "released": {
          "type": "string",
          "format": "date"
        },
        "description": {
          "$ref": "#/$defs/description"
        },
        "files": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/file"
          }
        }
      }
    },
    "category": {
      "title": "Категория",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "format",
        "type",
        "name"
      ],
      "properties": {
        "format": {
          "const": 1
        },
        "type": {
          "const": "category"
        },
        "name": {
          "$ref": "#/$defs/name"
        },
        "order": {
          "type": "integer"
        }
      }
    },
    "program": {
      "title": "Программа",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "format",
        "type",
        "name",
        "summary",
        "screenshots",
        "versions"
      ],
      "properties": {
        "format": {
          "const": 1
        },
        "type": {
          "const": "program"
        },
        "name": {
          "$ref": "#/$defs/name"
        },
        "order": {
          "type": "integer"
        },
        "summary": {
          "$ref": "#/$defs/summary"
        },
        "targets": {
          "$ref": "#/$defs/targets"
        },
        "homepage": {
          "$ref": "#/$defs/url"
        },
        "source": {
          "$ref": "#/$defs/url"
        },
        "forum": {
          "$ref": "#/$defs/url"
        },
        "author": {
          "$ref": "#/$defs/name"
        },
        "screenshots": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/screenshotPath"
          }
        },
        "versions": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/version"
          }
        },
        "additional_files": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/file"
          }
        }
      }
    }
  }
}
