{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://open-music-project.org/schema/1.0/assets.schema.json",
  "title": "OMP assets.json",
  "description": "Registry of media assets keyed by asset id.",
  "type": "object",
  "additionalProperties": {
    "type": "object",
    "required": ["kind", "sources"],
    "properties": {
      "kind": { "enum": ["audio", "midi", "image", "other"] },
      "sources": {
        "type": "array",
        "minItems": 1,
        "description": "Ordered resolution candidates; a host tries each in turn.",
        "items": {
          "type": "object",
          "properties": {
            "rel": {
              "type": "string",
              "description": "Path inside the container (present when embedded)."
            },
            "uri": {
              "type": "string",
              "description": "file:// or https:// location for external sources."
            },
            "embedded": { "type": "boolean" }
          },
          "anyOf": [
            { "required": ["rel"] },
            { "required": ["uri"] }
          ]
        }
      },
      "hash": {
        "type": "object",
        "required": ["algo", "value"],
        "properties": {
          "algo": { "enum": ["sha256", "sha1", "md5"] },
          "value": { "type": "string" }
        }
      },
      "audio": {
        "type": "object",
        "required": ["sampleRate", "channels", "frames", "durationSec"],
        "properties": {
          "sampleRate": { "type": "integer", "exclusiveMinimum": 0 },
          "channels": { "type": "integer", "minimum": 1 },
          "frames": { "type": "integer", "minimum": 0 },
          "durationSec": { "type": "number", "minimum": 0 },
          "codec": { "type": "string" }
        }
      }
    }
  }
}
