{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/akeda-ru/json-schema/akeda-ru-assistant-digest-schema.json",
  "title": "AssistantDigest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/akeda-ru-assistant-api-openapi.yml#/components/schemas/AssistantDigest",
  "allOf": [
    {
      "$ref": "#/$defs/AssistantDigestInput"
    },
    {
      "type": "object",
      "required": [
        "id",
        "version",
        "next_run_at"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/UUID"
        },
        "version": {
          "type": "integer",
          "minimum": 1
        },
        "next_run_at": {
          "type": "string",
          "format": "date-time"
        },
        "last_run_at": {
          "type": "string",
          "format": "date-time"
        },
        "last_error": {
          "type": "string",
          "enum": [
            "",
            "access_removed",
            "source_unavailable"
          ]
        },
        "last_conversation_id": {
          "$ref": "#/$defs/UUID"
        }
      }
    }
  ],
  "$defs": {
    "AssistantDigestInput": {
      "type": "object",
      "required": [
        "name",
        "metric_ids",
        "period",
        "schedule_hour",
        "schedule_minute",
        "timezone",
        "weekdays_only",
        "locale",
        "enabled"
      ],
      "additionalProperties": false,
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "digest",
            "watch"
          ],
          "default": "digest",
          "description": "digest — сводка приходит по расписанию всегда; watch — сторож: приходит, только когда сработало правило владельца показателя (rules в каталоге показателей), и не повторяет ту же картину тревог"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "metric_ids": {
          "type": "array",
          "minItems": 1,
          "maxItems": 6,
          "uniqueItems": true,
          "items": {
            "type": "string"
          },
          "description": "Коды показателей витрины; у сторожа — только показатели с правилами"
        },
        "company": {
          "$ref": "#/$defs/UUID"
        },
        "project": {
          "$ref": "#/$defs/UUID"
        },
        "period": {
          "type": "string",
          "enum": [
            "this_month",
            "previous_month",
            "last_30_days"
          ]
        },
        "schedule_hour": {
          "type": "integer",
          "minimum": 0,
          "maximum": 23
        },
        "schedule_minute": {
          "type": "integer",
          "minimum": 0,
          "maximum": 59
        },
        "timezone": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "weekdays_only": {
          "type": "boolean"
        },
        "locale": {
          "type": "string",
          "enum": [
            "ru-RU",
            "en-US"
          ]
        },
        "enabled": {
          "type": "boolean"
        }
      }
    },
    "UUID": {
      "type": "string",
      "format": "uuid"
    }
  }
}