{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openadhkar.org/v1/schema/source.schema.json",
  "title": "Open Adhkar source text",
  "type": "object",
  "required": [
    "collection_id",
    "version",
    "language",
    "divisions",
    "entries"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "collection_id": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "minLength": 1
    },
    "language": {
      "type": "string",
      "minLength": 1
    },
    "divisions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "parent_id",
          "level",
          "order",
          "title"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+:[a-z][0-9]+$"
          },
          "parent_id": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[a-z0-9-]+:[a-z][0-9]+$"
              },
              {
                "type": "null"
              }
            ]
          },
          "level": {
            "enum": [
              "section",
              "chapter"
            ]
          },
          "order": {
            "type": "integer",
            "minimum": 1
          },
          "title": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "division_id",
          "order",
          "display_number",
          "type",
          "text",
          "citation_raw",
          "printed_pages"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+:[a-z][0-9]+$"
          },
          "division_id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+:[a-z][0-9]+$"
          },
          "order": {
            "type": "integer",
            "minimum": 1
          },
          "display_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Number printed in the book; display only, not unique, never an id."
          },
          "type": {
            "enum": [
              "item",
              "quran",
              "remark",
              "text"
            ],
            "description": "item: numbered dhikr or du'aa'; quran: unnumbered Qur'an verse; remark: author's note; text: other unnumbered text."
          },
          "printed_pages": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1
            }
          },
          "text": {
            "type": "string",
            "minLength": 1
          },
          "citation_raw": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sources and virtues as printed, unparsed."
          },
          "note": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    }
  }
}
