{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mantismusic.app/docs/schemas/1.6/catalogue.schema.json",
  "title": "Mantis catalogue (catalogue.json), format 1",
  "type": "object",
  "required": ["@context", "@type", "@id", "name", "url", "track", "mantis"],
  "properties": {
    "@context": { "const": "https://schema.org" },
    "@type": { "const": "MusicGroup" },
    "@id": { "type": "string", "pattern": "^https?://.+#artist$" },
    "identifier": { "type": "string", "pattern": "^urn:uuid:" },
    "name": { "type": "string", "minLength": 1 },
    "url": { "type": "string", "pattern": "^https?://" },
    "description": { "type": "string" },
    "image": { "type": "string", "pattern": "^https?://" },
    "sameAs": { "type": "array", "items": { "type": "string", "pattern": "^https?://" } },
    "track": { "type": "array", "items": { "$ref": "#/$defs/work" } },
    "album": { "type": "array", "items": { "$ref": "#/$defs/release" } },
    "mantis": { "type": "object", "required": ["catalogue"], "properties": { "catalogue": { "const": 1 }, "updated": { "type": "string" }, "support": { "type": "array", "items": { "$ref": "#/$defs/link" } } } }
  },
  "$defs": {
    "link": {
      "type": "object",
      "required": ["service", "url", "name"],
      "properties": {
        "service": { "type": "string" },
        "url": { "type": "string", "pattern": "^https://" },
        "name": { "type": "string", "minLength": 1 },
        "kind": { "type": "string", "enum": ["membership", "tip", "store", "crowdfunding", "other"] },
        "title": { "type": "string", "minLength": 1 },
        "note": { "type": "string", "maxLength": 80 }
      }
    },
    "date": { "type": "string", "pattern": "^\\d{4}(-\\d{2}(-\\d{2})?)?$" },
    "ref": { "type": "object", "required": ["@id"], "properties": { "@id": { "type": "string", "pattern": "^https?://" }, "name": { "type": "string" } } },
    "audio": {
      "type": "object",
      "required": ["@type", "contentUrl", "encodingFormat"],
      "properties": {
        "@type": { "const": "AudioObject" },
        "contentUrl": { "type": "string", "pattern": "^https?://" },
        "encodingFormat": { "type": "string", "pattern": "^audio/" },
        "contentSize": { "type": "integer", "minimum": 0 }
      }
    },
    "lineTime": {
      "type": ["object", "null"],
      "required": ["start", "end"],
      "properties": {
        "start": { "type": "number", "minimum": 0 },
        "end": { "type": "number", "minimum": 0 },
        "words": { "type": "array", "items": { "type": ["array", "null"], "items": { "type": "number" } } }
      }
    },
    "work": {
      "type": "object",
      "required": ["@type", "@id", "name", "datePublished", "audio"],
      "properties": {
        "@type": { "const": "MusicRecording" },
        "@id": { "type": "string", "pattern": "^https?://" },
        "url": { "type": "string", "pattern": "^https?://" },
        "identifier": { "type": "string", "pattern": "^urn:uuid:" },
        "name": { "type": "string", "minLength": 1 },
        "byArtist": { "$ref": "#/$defs/ref" },
        "datePublished": { "$ref": "#/$defs/date" },
        "duration": { "type": "string", "pattern": "^PT(\\d+H)?(\\d+M)?(\\d+S)?$" },
        "genre": { "type": "array", "items": { "type": "string" } },
        "description": { "type": "string" },
        "image": { "type": "string", "pattern": "^https?://" },
        "thumbnailUrl": { "type": "string", "pattern": "^https?://" },
        "audio": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/audio" } },
        "lyrics": { "type": "object", "required": ["@type", "text"], "properties": { "@type": { "const": "CreativeWork" }, "text": { "type": "string" } } },
        "inAlbum": { "type": "array", "items": { "$ref": "#/$defs/ref" } },
        "discussionUrl": { "type": "string", "pattern": "^https?://" },
        "mantis": {
          "type": "object",
          "required": ["slug"],
          "properties": {
            "slug": { "type": "string", "pattern": "^[a-z0-9-]+$" },
            "bpm": { "type": "number" },
            "key": { "type": "string" },
            "mood": { "type": "array", "items": { "type": "string" } },
            "credits": { "type": "array", "items": { "type": "object", "required": ["role", "names"], "properties": { "role": { "type": "string" }, "names": { "type": "array", "items": { "type": "string" } } } } },
            "lyricTimes": { "type": "array", "items": { "$ref": "#/$defs/lineTime" } },
            "visualiser": { "type": "string" },
            "visualiserSections": { "type": "object" },
            "story": {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["url", "times"],
                "properties": {
                  "url": { "type": "string", "pattern": "^https?://" },
                  "times": { "type": "array", "minItems": 1, "items": { "type": "number", "minimum": 0 } },
                  "hold": { "type": "number", "minimum": 0 },
                  "source": { "enum": ["generated", "artist"] }
                }
              }
            },
            "peaks": { "type": "array", "items": { "type": "number", "minimum": 0, "maximum": 1 } },
            "palette": { "$ref": "#/$defs/palette" },
            "bands": { "type": "string", "pattern": "^https?://" },
            "lyricSync": { "type": "string", "pattern": "^https?://.+\\.json$" },
            "buy": { "$ref": "#/$defs/link" }
          }
        }
      }
    },
    "release": {
      "type": "object",
      "required": ["@type", "@id", "name", "track"],
      "properties": {
        "@type": { "const": "MusicAlbum" },
        "@id": { "type": "string", "pattern": "^https?://" },
        "name": { "type": "string", "minLength": 1 },
        "datePublished": { "$ref": "#/$defs/date" },
        "albumReleaseType": { "enum": ["https://schema.org/AlbumRelease", "https://schema.org/EPRelease", "https://schema.org/SingleRelease"] },
        "image": { "type": "string", "pattern": "^https?://" },
        "description": { "type": "string" },
        "numTracks": { "type": "integer", "minimum": 0 },
        "track": { "type": "array", "items": { "$ref": "#/$defs/ref" } },
        "mantis": { "type": "object", "properties": { "palette": { "$ref": "#/$defs/palette" }, "buy": { "$ref": "#/$defs/link" } } }
      }
    },
    "rgb": { "type": "array", "minItems": 3, "items": { "type": "number", "minimum": 0, "maximum": 1 } },
    "palette": {
      "type": "object",
      "required": ["bg", "a", "b", "c", "d"],
      "properties": { "bg": { "$ref": "#/$defs/rgb" }, "a": { "$ref": "#/$defs/rgb" }, "b": { "$ref": "#/$defs/rgb" }, "c": { "$ref": "#/$defs/rgb" }, "d": { "$ref": "#/$defs/rgb" } }
    }
  }
}
