{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openadhkar.org/v1/schema/bundle.schema.json",
  "title": "Open Adhkar bundle",
  "type": "object",
  "required": [
    "collection",
    "divisions",
    "entries"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "collection": {
      "$ref": "collection.schema.json"
    },
    "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": "object",
            "properties": {
              "ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "en": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "ar"
            ],
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "division_id",
          "order",
          "display_number",
          "type",
          "text",
          "citation",
          "printed_pages",
          "translation_status"
        ],
        "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": "object",
            "properties": {
              "ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "en": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "ar"
            ],
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "citation": {
            "type": "object",
            "properties": {
              "ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "en": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "ar"
            ],
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "note": {
            "type": "object",
            "properties": {
              "ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "en": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "ar"
            ],
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "translation_status": {
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                {
                  "enum": [
                    "machine",
                    "machine-retranslated",
                    "reviewed"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            }
          }
        }
      }
    }
  }
}
