{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tune.toys/schemas/platform/sound-search.schema.json",
  "title": "SoundSearchParams",
  "description": "Query of GET /v1/sounds and /v1/sounds/facets: every filter optional, bounded, and owned by the page URL. Facet counts answer for the same filter set.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "q": {
      "type": "string",
      "minLength": 0,
      "maxLength": 128
    },
    "family": {
      "$ref": "enums.schema.json#/$defs/MediaFamily"
    },
    "soundType": {
      "$ref": "enums.schema.json#/$defs/SoundType"
    },
    "keyRoot": {
      "type": "integer",
      "minimum": 0,
      "maximum": 11,
      "description": "Pitch class of the key root: 0 = C … 11 = B."
    },
    "mode": {
      "$ref": "enums.schema.json#/$defs/MusicalMode"
    },
    "tonality": {
      "$ref": "enums.schema.json#/$defs/Tonality"
    },
    "camelot": {
      "type": "array",
      "maxItems": 24,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^(1[0-2]|[1-9])[AB]$",
        "description": "Camelot wheel code: 1A–12A minor, 1B–12B major."
      }
    },
    "bpmMin": {
      "type": "number",
      "minimum": 20,
      "maximum": 400
    },
    "bpmMax": {
      "type": "number",
      "minimum": 20,
      "maximum": 400
    },
    "meter": {
      "type": "string",
      "pattern": "^[1-9][0-9]?/(1|2|4|8|16)$"
    },
    "instruments": {
      "type": "array",
      "maxItems": 8,
      "uniqueItems": true,
      "items": {
        "$ref": "media-vocabulary.schema.json#/$defs/Instrument"
      }
    },
    "genres": {
      "type": "array",
      "maxItems": 8,
      "uniqueItems": true,
      "items": {
        "$ref": "media-vocabulary.schema.json#/$defs/Genre"
      }
    },
    "moods": {
      "type": "array",
      "maxItems": 8,
      "uniqueItems": true,
      "items": {
        "$ref": "media-vocabulary.schema.json#/$defs/Mood"
      }
    },
    "tags": {
      "type": "array",
      "maxItems": 8,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 40
      }
    },
    "durationMinMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "durationMaxMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "license": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "reusable": {
      "type": "boolean"
    },
    "owner": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Account handle."
    },
    "mine": {
      "type": "boolean",
      "description": "Only the caller's items, any visibility."
    },
    "sort": {
      "$ref": "#/$defs/SoundSort"
    },
    "offset": {
      "type": "integer",
      "minimum": 0,
      "maximum": 10000
    },
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 40
    }
  },
  "$defs": {
    "SoundSort": {
      "title": "SoundSort",
      "description": "Sort order of a sounds page.",
      "type": "string",
      "enum": [
        "relevance",
        "newest",
        "popular",
        "likes",
        "downloads",
        "duration",
        "tempo"
      ]
    },
    "FacetCount": {
      "title": "FacetCount",
      "description": "One facet value and how many items in the current filter set carry it.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "value": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": ["value", "count"]
    },
    "SoundFacets": {
      "title": "SoundFacets",
      "description": "Facet counts for a filter set, one list per facet column of the media index.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "family": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "soundType": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "keyRoot": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "mode": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "tonality": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "camelot": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "meter": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "instruments": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "genres": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "moods": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "license": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "channels": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        },
        "sampleRate": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "$ref": "#/$defs/FacetCount"
          }
        }
      },
      "required": [
        "family",
        "soundType",
        "keyRoot",
        "mode",
        "tonality",
        "camelot",
        "meter",
        "instruments",
        "genres",
        "moods",
        "license",
        "channels",
        "sampleRate"
      ]
    }
  }
}
