{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/ksp-netkan/_shared/latest--CKAN.schema.json",
  "title": "CKAN JSON Schema",
  "description": "Schema for validating CKAN meta files",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/KSP-CKAN/CKAN/master/CKAN.schema",
    "sourceSha256": "fd7d387f9837abd1b941009301e08738c6d7f258d63e1c0eae1708af3dca7d0a"
  },
  "type": "object",
  "properties": {
    "spec_version": {
      "description": "Version of the CKAN spec this document uses",
      "oneOf": [
        {
          "type": "integer",
          "description": "The integer '1' is special case",
          "minimum": 1,
          "maximum": 1
        },
        {
          "type": "string",
          "description": "A vx.x string",
          "pattern": "^v[0-9]+\\.[0-9]+$"
        }
      ]
    },
    "name": {
      "description": "Human readable name of the mod",
      "type": "string"
    },
    "identifier": {
      "description": "Unique identifier for this mod",
      "$ref": "#/$defs/identifier"
    },
    "kind": {
      "description": "Package type, defaults to package",
      "enum": [
        "package",
        "metapackage",
        "dlc"
      ]
    },
    "abstract": {
      "description": "Short description of the mod",
      "type": "string"
    },
    "description": {
      "description": "Longer description of the mod",
      "type": "string"
    },
    "comment": {
      "description": "Free-form comment. Not displayed to users",
      "type": "string"
    },
    "author": {
      "description": "Author, or list of authors",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      ]
    },
    "download": {
      "description": "URL where mod can be downloaded by tools",
      "oneOf": [
        {
          "type": "string",
          "format": "uri"
        },
        {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri"
          },
          "uniqueItems": true
        }
      ]
    },
    "download_size": {
      "description": "The size of the download in bytes",
      "type": "integer"
    },
    "download_hash": {
      "description": "A object of hashes of the downloaded file",
      "type": "object",
      "properties": {
        "sha1": {
          "description": "SHA1 hash of the file",
          "type": "string"
        },
        "sha256": {
          "description": "SHA256 hash of the file",
          "type": "string"
        }
      }
    },
    "download_content_type": {
      "description": "The content type of the download",
      "type": "string"
    },
    "install_size": {
      "description": "The size of the installed files",
      "type": "integer"
    },
    "license": {
      "description": "Machine readable license, or array of licenses",
      "$ref": "#/$defs/licenses"
    },
    "version": {
      "description": "Version of the mod",
      "$ref": "#/$defs/version"
    },
    "release_status": {
      "description": "Optional release status",
      "enum": [
        "stable",
        "testing",
        "development"
      ]
    },
    "ksp_version": {
      "description": "Optional target game version",
      "$ref": "#/$defs/ksp_version"
    },
    "ksp_version_min": {
      "description": "Optional minimum game version",
      "$ref": "#/$defs/ksp_version"
    },
    "ksp_version_max": {
      "description": "Optional maximum game version",
      "$ref": "#/$defs/ksp_version"
    },
    "ksp_version_strict": {
      "description": "Optional enforcement of strict version checks (defaults to false)",
      "type": "boolean"
    },
    "tags": {
      "description": "A series of descriptive keywords to provide quick filtering and organization",
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9-]+$"
      }
    },
    "localizations": {
      "description": "A list of locale strings for which this mod includes localizations",
      "type": "array",
      "items": {
        "type": "string"
      },
      "uniqueItems": true
    },
    "depends": {
      "description": "Optional list of dependencies",
      "$ref": "#/$defs/relationship"
    },
    "recommends": {
      "description": "Optional list of recommended mods",
      "$ref": "#/$defs/relationship"
    },
    "suggests": {
      "description": "Optional list of recommended, but not essential mods",
      "$ref": "#/$defs/relationship"
    },
    "supports": {
      "description": "Optional list of supported mods",
      "$ref": "#/$defs/relationship"
    },
    "conflicts": {
      "description": "Optional list of conflicting mods",
      "$ref": "#/$defs/relationship"
    },
    "provides": {
      "description": "A list of virtual packages this mod provides",
      "type": "array",
      "items": {
        "$ref": "#/$defs/identifier"
      },
      "uniqueItems": true
    },
    "replaced_by": {
      "description": "Optional pointer to mod that should be selected instead and treated as an update to this mod",
      "type": "object",
      "properties": {
        "name": {
          "description": "Identifier of the mod",
          "$ref": "#/$defs/identifier"
        },
        "version": {
          "description": "Optional version",
          "$ref": "#/$defs/version"
        },
        "min_version": {
          "description": "Optional minimum version",
          "$ref": "#/$defs/version"
        }
      },
      "required": [
        "name"
      ]
    },
    "resources": {
      "description": "Additional resources",
      "type": "object",
      "properties": {
        "homepage": {
          "description": "Mod homepage",
          "type": "string",
          "format": "uri"
        },
        "bugtracker": {
          "description": "Mod bugtracker",
          "type": "string",
          "format": "uri"
        },
        "discussions": {
          "description": "Mod discussions",
          "type": "string",
          "format": "uri"
        },
        "license": {
          "description": "Mod license",
          "type": "string",
          "format": "uri"
        },
        "repository": {
          "description": "Mod repository",
          "type": "string",
          "format": "uri"
        },
        "ci": {
          "description": "Continuous Integration",
          "type": "string",
          "format": "uri"
        },
        "spacedock": {
          "description": "Project on SpaceDock",
          "type": "string",
          "format": "uri"
        },
        "curse": {
          "description": "Project on Curse",
          "type": "string",
          "format": "uri"
        },
        "manual": {
          "description": "Mod's manual",
          "type": "string",
          "format": "uri"
        },
        "metanetkan": {
          "description": "Mod's remote hosted netkan",
          "type": "string",
          "format": "uri"
        },
        "remote-avc": {
          "description": "Mod's remote hosted version file",
          "type": "string",
          "format": "uri"
        },
        "remote-swinfo": {
          "description": "Mod's remote hosted swinfo file",
          "type": "string",
          "format": "uri"
        },
        "store": {
          "description": "Purchase DLC here",
          "type": "string",
          "format": "uri"
        },
        "steamstore": {
          "description": "Purchase DLC on Steam here",
          "type": "string",
          "format": "uri"
        },
        "gogstore": {
          "description": "Purchase DLC on GOG here",
          "type": "string",
          "format": "uri"
        },
        "epicstore": {
          "description": "Purchase DLC on Epic Games Store here",
          "type": "string",
          "format": "uri"
        }
      }
    },
    "install": {
      "description": "List of install directives",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "file": {
            "description": "Path to file to install",
            "type": "string"
          },
          "find": {
            "description": "A directory to find for installation",
            "type": "string"
          },
          "find_regexp": {
            "description": "A regexp that matches the directory to install",
            "type": "string"
          },
          "find_matches_files": {
            "description": "If true, find directives match files as well as directories",
            "type": "boolean"
          },
          "install_to": {
            "description": "Where file should be installed to",
            "$ref": "#/$defs/install_to"
          },
          "as": {
            "description": "The name to give the matching directory or file when installed",
            "type": "string",
            "pattern": "^[^\\\\/]+$"
          },
          "filter": {
            "description": "List of files and directories that should be filtered from the install",
            "$ref": "#/$defs/one_or_more_strings"
          },
          "filter_regexp": {
            "description": "List of regexps that should filter files from this install",
            "$ref": "#/$defs/one_or_more_strings"
          },
          "include_only": {
            "description": "List of files and directories that should not be excluded from the install",
            "$ref": "#/$defs/one_or_more_strings"
          },
          "include_only_regexp": {
            "description": "List of regexps that should include files in this install",
            "$ref": "#/$defs/one_or_more_strings"
          }
        },
        "not": {
          "anyOf": [
            {
              "required": [
                "filter",
                "include_only"
              ]
            },
            {
              "required": [
                "filter",
                "include_only_regexp"
              ]
            },
            {
              "required": [
                "filter_regexp",
                "include_only"
              ]
            },
            {
              "required": [
                "filter_regexp",
                "include_only_regexp"
              ]
            }
          ]
        },
        "required": [
          "install_to"
        ],
        "oneOf": [
          {
            "required": [
              "file"
            ]
          },
          {
            "required": [
              "find"
            ]
          },
          {
            "required": [
              "find_regexp"
            ]
          }
        ]
      }
    },
    "release_date": {
      "description": "Optional timestamp when the described version of the mod was released",
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "spec_version",
    "name",
    "author",
    "abstract",
    "identifier",
    "license",
    "version"
  ],
  "$defs": {
    "identifier": {
      "description": "Unique identifier for this mod.",
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9-]+$"
    },
    "version": {
      "description": "A version string",
      "type": "string"
    },
    "ksp_version": {
      "description": "A game version",
      "type": "string",
      "pattern": "^(any|[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)$"
    },
    "relationship": {
      "description": "A relationship to a list of mods",
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "name": {
                "description": "Identifier of the mod",
                "$ref": "#/$defs/identifier"
              },
              "version": {
                "description": "Optional version",
                "$ref": "#/$defs/version"
              },
              "min_version": {
                "description": "Optional minimum version",
                "$ref": "#/$defs/version"
              },
              "max_version": {
                "description": "Optional maximum version",
                "$ref": "#/$defs/version"
              },
              "choice_help_text": {
                "description": "Optional help text shown when user has to choose among multiple modules",
                "type": "string"
              },
              "suppress_recommendations": {
                "description": "If true, don't check this mod or its dependencies for recommendations or suggestions",
                "type": "boolean"
              }
            },
            "required": [
              "name"
            ]
          },
          {
            "type": "object",
            "properties": {
              "any_of": {
                "description": "List of modules that can satisfy this relationship",
                "$ref": "#/$defs/relationship"
              },
              "choice_help_text": {
                "description": "Optional help text shown when user has to choose among multiple modules",
                "type": "string"
              }
            },
            "required": [
              "any_of"
            ]
          }
        ]
      }
    },
    "install_to": {
      "description": "Where file should be installed to. As of v1.2, GameData may take a path",
      "anyOf": [
        {
          "description": "Spec version 1 targets",
          "enum": [
            "GameData",
            "Ships",
            "GameRoot",
            "Tutorial",
            "Scenarios"
          ]
        },
        {
          "description": "Spec v1.2 GameData path",
          "type": "string",
          "pattern": "^GameData/"
        },
        {
          "description": "Spec v1.12 Ships subfolder paths",
          "type": "string",
          "pattern": "^Ships/(SPH|VAB|Script)$"
        },
        {
          "description": "Spec v1.16 thumbs paths",
          "type": "string",
          "pattern": "^Ships/@thumbs/(SPH|VAB)$"
        },
        {
          "description": "Spec v1.25 Missions path",
          "type": "string",
          "pattern": "^Missions"
        },
        {
          "description": "KSP2 default mods folder",
          "enum": [
            "GameData/Mods"
          ]
        },
        {
          "description": "KSP2 default mods folder with subfolder",
          "type": "string",
          "pattern": "^GameData/Mods/"
        },
        {
          "description": "KSP2 BepInEx plugins folder",
          "type": "string",
          "pattern": "^BepInEx/plugins$"
        }
      ]
    },
    "license": {
      "description": "A license.",
      "enum": [
        "public-domain",
        "AFL-3.0",
        "AGPL-3.0",
        "Apache",
        "Apache-1.0",
        "Apache-2.0",
        "APSL-2.0",
        "Artistic",
        "Artistic-1.0",
        "Artistic-2.0",
        "BSD-2-clause",
        "BSD-3-clause",
        "BSD-4-clause",
        "ISC",
        "CC-BY",
        "CC-BY-1.0",
        "CC-BY-2.0",
        "CC-BY-2.5",
        "CC-BY-3.0",
        "CC-BY-4.0",
        "CC-BY-SA",
        "CC-BY-SA-1.0",
        "CC-BY-SA-2.0",
        "CC-BY-SA-2.5",
        "CC-BY-SA-3.0",
        "CC-BY-SA-4.0",
        "CC-BY-NC",
        "CC-BY-NC-1.0",
        "CC-BY-NC-2.0",
        "CC-BY-NC-2.5",
        "CC-BY-NC-3.0",
        "CC-BY-NC-4.0",
        "CC-BY-NC-SA",
        "CC-BY-NC-SA-1.0",
        "CC-BY-NC-SA-2.0",
        "CC-BY-NC-SA-2.5",
        "CC-BY-NC-SA-3.0",
        "CC-BY-NC-SA-4.0",
        "CC-BY-NC-ND",
        "CC-BY-NC-ND-1.0",
        "CC-BY-NC-ND-2.0",
        "CC-BY-NC-ND-2.5",
        "CC-BY-NC-ND-3.0",
        "CC-BY-NC-ND-4.0",
        "CC-BY-ND",
        "CC-BY-ND-1.0",
        "CC-BY-ND-2.0",
        "CC-BY-ND-2.5",
        "CC-BY-ND-3.0",
        "CC-BY-ND-4.0",
        "CC0",
        "CDDL",
        "CPL",
        "EFL-1.0",
        "EFL-2.0",
        "Expat",
        "MIT",
        "GPL-1.0",
        "GPL-2.0",
        "GPL-3.0",
        "LGPL-2.0",
        "LGPL-2.1",
        "LGPL-3.0",
        "GFDL-1.0",
        "GFDL-1.1",
        "GFDL-1.2",
        "GFDL-1.3",
        "GFDL-NIV-1.0",
        "GFDL-NIV-1.1",
        "GFDL-NIV-1.2",
        "GFDL-NIV-1.3",
        "LPPL-1.0",
        "LPPL-1.1",
        "LPPL-1.2",
        "LPPL-1.3c",
        "MPL-1.0",
        "MPL-1.1",
        "MPL-2.0",
        "Ms-PL",
        "Ms-RL",
        "Perl",
        "Python-2.0",
        "QPL-1.0",
        "Unlicense",
        "W3C",
        "WTFPL",
        "Zlib",
        "Zope",
        "open-source",
        "restricted",
        "unrestricted",
        "unknown"
      ]
    },
    "redistributable_license": {
      "description": "A license that grants us the right to redistribute.",
      "enum": [
        "public-domain",
        "Apache",
        "Apache-1.0",
        "Apache-2.0",
        "Artistic",
        "Artistic-1.0",
        "Artistic-2.0",
        "BSD-2-clause",
        "BSD-3-clause",
        "BSD-4-clause",
        "ISC",
        "CC-BY",
        "CC-BY-1.0",
        "CC-BY-2.0",
        "CC-BY-2.5",
        "CC-BY-3.0",
        "CC-BY-4.0",
        "CC-BY-SA",
        "CC-BY-SA-1.0",
        "CC-BY-SA-2.0",
        "CC-BY-SA-2.5",
        "CC-BY-SA-3.0",
        "CC-BY-SA-4.0",
        "CC-BY-NC",
        "CC-BY-NC-1.0",
        "CC-BY-NC-2.0",
        "CC-BY-NC-2.5",
        "CC-BY-NC-3.0",
        "CC-BY-NC-4.0",
        "CC-BY-NC-SA",
        "CC-BY-NC-SA-1.0",
        "CC-BY-NC-SA-2.0",
        "CC-BY-NC-SA-2.5",
        "CC-BY-NC-SA-3.0",
        "CC-BY-NC-SA-4.0",
        "CC-BY-NC-ND",
        "CC-BY-NC-ND-1.0",
        "CC-BY-NC-ND-2.0",
        "CC-BY-NC-ND-2.5",
        "CC-BY-NC-ND-3.0",
        "CC-BY-NC-ND-4.0",
        "CC-BY-ND",
        "CC-BY-ND-1.0",
        "CC-BY-ND-2.0",
        "CC-BY-ND-2.5",
        "CC-BY-ND-3.0",
        "CC-BY-ND-4.0",
        "CC0",
        "CDDL",
        "CPL",
        "EFL-1.0",
        "EFL-2.0",
        "Expat",
        "MIT",
        "GPL-1.0",
        "GPL-2.0",
        "GPL-3.0",
        "LGPL-2.0",
        "LGPL-2.1",
        "LGPL-3.0",
        "GFDL-1.0",
        "GFDL-1.1",
        "GFDL-1.2",
        "GFDL-1.3",
        "GFDL-NIV-1.0",
        "GFDL-NIV-1.1",
        "GFDL-NIV-1.2",
        "GFDL-NIV-1.3",
        "LPPL-1.0",
        "LPPL-1.1",
        "LPPL-1.2",
        "LPPL-1.3c",
        "MPL-1.1",
        "MPL-2.0",
        "Perl",
        "Python-2.0",
        "QPL-1.0",
        "W3C",
        "Zlib",
        "Zope",
        "WTFPL",
        "Unlicense",
        "open-source",
        "unrestricted"
      ]
    },
    "licenses": {
      "description": "A license, or array of licenses",
      "anyOf": [
        {
          "$ref": "#/$defs/license"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/license"
          },
          "uniqueItems": true
        }
      ]
    },
    "one_or_more_strings": {
      "description": "One or more strings",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      ]
    }
  },
  "oneOf": [
    {
      "required": [
        "download"
      ]
    },
    {
      "properties": {
        "kind": {
          "enum": [
            "metapackage",
            "dlc"
          ]
        }
      },
      "not": {
        "required": [
          "download"
        ]
      },
      "required": [
        "kind"
      ],
      "type": "object"
    }
  ]
}
