{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sortgames.com/schemas/myrpg-module-v1.json",
  "title": "MyRPG content module manifest v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "id", "name", "version", "description", "authors", "license", "engine", "classification", "content", "capabilities"],
  "properties": {
    "schema": { "const": "myrpg.module/v1" },
    "id": { "type": "string", "minLength": 3, "maxLength": 80, "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$" },
    "name": { "type": "string", "minLength": 1, "maxLength": 80 },
    "version": { "$ref": "#/$defs/version" },
    "description": { "type": "string", "minLength": 1, "maxLength": 500 },
    "authors": { "type": "array", "minItems": 1, "maxItems": 12, "items": { "type": "string", "minLength": 1, "maxLength": 80 } },
    "license": { "type": "string", "minLength": 1, "maxLength": 80 },
    "engine": {
      "type": "object",
      "additionalProperties": false,
      "required": ["minVersion"],
      "properties": { "minVersion": { "$ref": "#/$defs/version" } }
    },
    "classification": {
      "type": "object",
      "additionalProperties": false,
      "required": ["genres", "tags", "maturity"],
      "properties": {
        "genres": { "type": "array", "maxItems": 12, "items": { "type": "string", "minLength": 1, "maxLength": 32 } },
        "tags": { "type": "array", "maxItems": 24, "items": { "type": "string", "minLength": 1, "maxLength": 32 } },
        "maturity": { "enum": ["everyone", "teen", "mature"] }
      }
    },
    "content": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ruleset", "characterOptions", "setting", "adventure", "director"],
      "properties": {
        "ruleset": { "$ref": "#/$defs/path" },
        "characterOptions": { "$ref": "#/$defs/path" },
        "setting": { "$ref": "#/$defs/path" },
        "adventure": { "$ref": "#/$defs/path" },
        "director": { "$ref": "#/$defs/path" }
      }
    },
    "capabilities": {
      "type": "object",
      "additionalProperties": false,
      "required": ["executableCode", "networkAccess", "fileSystemAccess"],
      "properties": {
        "executableCode": { "const": false },
        "networkAccess": { "const": false },
        "fileSystemAccess": { "const": false }
      }
    }
  },
  "$defs": {
    "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$" },
    "path": {
      "type": "string",
      "minLength": 1,
      "maxLength": 180,
      "pattern": "^(?!/)(?![A-Za-z]:)(?!.*(?:^|/)\\.\\.(?:/|$))[^\\\\]+$"
    }
  }
}
