{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/my-tv-channel-com/json-schema/my-tv-channel-com-rule-set-schema.json",
  "title": "RuleSet",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/my-tv-channel-com-openapi.yaml#/components/schemas/RuleSet",
  "type": "object",
  "required": [
    "channel_id",
    "rules"
  ],
  "properties": {
    "channel_id": {
      "type": "integer"
    },
    "timezone": {
      "type": "string",
      "description": "IANA name, e.g. `Europe/Paris`. **Set this** — rule times are wall clock in the channel timezone, and omitting it means UTC, which is almost never what the owner meant. `schedule_timezone` is also accepted."
    },
    "rules": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Rule"
      }
    }
  },
  "$defs": {
    "Rule": {
      "type": "object",
      "required": [
        "rule_type",
        "start_time",
        "days_mask",
        "selector_type",
        "selector_value"
      ],
      "description": "A `time_slot` puts something on at a time. A `daypart_weight` changes how likely\nsomething is during a window.\n\n**Slots start ON-OR-AFTER their time.** The programme running into a slot is never cut\nshort, so an 18:00 slot may actually begin at 18:02. That is deliberate — a linear\nchannel must not chop a video in half to hit a clock time. Do not report it as a fault.\n",
      "properties": {
        "rule_type": {
          "type": "string",
          "enum": [
            "time_slot",
            "daypart_weight"
          ]
        },
        "start_time": {
          "type": "string",
          "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$"
        },
        "end_time": {
          "type": "string",
          "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
          "description": "On a `time_slot`, this makes it a **block**: it keeps drawing from the selector until this time. Without it you get a single programme, not a morning of cartoons."
        },
        "days_mask": {
          "type": "integer",
          "minimum": 0,
          "maximum": 127,
          "description": "Bitmask — bit0=Mon, bit1=Tue … bit6=Sun. `127` = every day, `31` = Mon–Fri, `96` = weekend."
        },
        "selector_type": {
          "type": "string",
          "enum": [
            "asset",
            "tag",
            "playlist"
          ]
        },
        "selector_value": {
          "description": "An asset id, a tag string, or — for `playlist` — an array of asset ids, which play in order.",
          "oneOf": [
            {
              "type": "integer"
            },
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "integer"
              }
            }
          ]
        },
        "priority": {
          "type": "integer",
          "default": 0
        },
        "weight_multiplier": {
          "type": "number",
          "minimum": 0,
          "maximum": 10,
          "description": "`daypart_weight` only. `0` removes matching assets from that window entirely."
        }
      }
    }
  }
}