{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mantismusic.app/docs/schemas/1.1/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" } } }
  },
  "$defs": {
    "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/" }
      }
    },
    "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" },
            "peaks": { "type": "array", "items": { "type": "number", "minimum": 0, "maximum": 1 } },
            "palette": { "$ref": "#/$defs/palette" },
            "bands": { "type": "string", "pattern": "^https?://" }
          }
        }
      }
    },
    "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" } } }
      }
    },
    "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" } }
    }
  }
}
