{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://smmods.com/api/v1/publishing/mod-release-submission.schema.json",
  "title": "SMMODS Mod Release Submission",
  "description": "Sidecar metadata supplied with an approved mod ZIP before publication into the static SMMODS catalog.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "mod",
    "release"
  ],
  "properties": {
    "schema": {
      "const": "smmods.mod-release-submission.v1"
    },
    "mod": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "summary",
        "description",
        "authors",
        "tags",
        "detailUrl"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "summary": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4000
        },
        "authors": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          }
        },
        "tags": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,31}$"
          }
        },
        "detailUrl": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://smmods\\.com/mods/.+/$"
        }
      }
    },
    "release": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "version",
        "targetGameBuild",
        "status",
        "artifactStatus",
        "downloadEnabled",
        "publishedAt",
        "dependencies",
        "releaseNotes"
      ],
      "properties": {
        "version": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+][A-Za-z0-9.-]+)?$"
        },
        "targetGameBuild": {
          "type": "string",
          "pattern": "^[0-9]+$"
        },
        "status": {
          "const": "published"
        },
        "artifactStatus": {
          "const": "published"
        },
        "downloadEnabled": {
          "const": true
        },
        "publishedAt": {
          "type": "string",
          "format": "date-time"
        },
        "dependencies": {
          "type": "object",
          "additionalProperties": false,
          "patternProperties": {
            "^[a-z0-9][a-z0-9._-]{1,63}$": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "releaseNotes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        },
        "modConfig": {
          "$ref": "#/$defs/modConfig"
        }
      }
    }
  },
  "$defs": {
    "modConfig": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "file",
        "settings"
      ],
      "properties": {
        "schema": {
          "const": "smmods.mod-config.v1"
        },
        "file": {
          "type": "string",
          "pattern": "^(?![A-Za-z]:)(?!/)(?!.*(?:^|[\\\\/])\\.\\.(?:[\\\\/]|$))[A-Za-z0-9._ -]+(?:[\\\\/][A-Za-z0-9._ -]+)*\\.json$"
        },
        "settings": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "label",
              "type",
              "default",
              "options"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9_]{0,63}$"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "type": {
                "const": "select"
              },
              "default": {
                "type": "string",
                "maxLength": 128
              },
              "requiresRestart": {
                "type": "boolean"
              },
              "options": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "value",
                    "label"
                  ],
                  "properties": {
                    "value": {
                      "type": "string",
                      "maxLength": 128
                    },
                    "label": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 80
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
