{
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "bookSourceName": {
      "type": "string",
      "minLength": 1
    },
    "bookSourceUrl": {
      "type": "string",
      "format": "uri",
      "pattern": "^(https://[^?#@]+|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:[0-9]+)?(/[^?#@]*)?)$"
    },
    "bookSourceVersion": {
      "type": "string",
      "minLength": 1
    },
    "omniread": {
      "type": "object",
      "properties": {
        "version": {
          "const": 2
        },
        "apiBaseUrl": {
          "type": "string",
          "format": "uri",
          "pattern": "^(https://[^?#@]+|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:[0-9]+)?(/[^?#@]*)?)/$"
        },
        "mediaTypes": {
          "type": "array",
          "items": {
            "enum": [
              "novel",
              "comic",
              "audiobook",
              "video"
            ]
          },
          "uniqueItems": true,
          "minItems": 1
        },
        "providers": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1
              },
              "name": {
                "type": "string",
                "minLength": 1
              },
              "mediaTypes": {
                "type": "array",
                "items": {
                  "enum": [
                    "novel",
                    "comic",
                    "audiobook",
                    "video"
                  ]
                },
                "uniqueItems": true,
                "minItems": 1
              }
            },
            "required": [
              "id",
              "name",
              "mediaTypes"
            ],
            "additionalProperties": false
          }
        },
        "auth": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "method": {
                  "const": "none"
                }
              },
              "required": [
                "method"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "method": {
                  "enum": [
                    "password",
                    "apiKey"
                  ]
                },
                "loginPath": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)*$"
                },
                "sessionPath": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)*$"
                }
              },
              "required": [
                "method",
                "loginPath",
                "sessionPath"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "method": {
                  "const": "token"
                },
                "sessionPath": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)*$"
                }
              },
              "required": [
                "method",
                "sessionPath"
              ],
              "additionalProperties": false
            }
          ]
        },
        "management": {
          "type": "object",
          "properties": {
            "title": {
              "type": "string",
              "minLength": 1
            },
            "webUrl": {
              "type": "string",
              "format": "uri",
              "pattern": "^(https://[^?#@]+|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:[0-9]+)?(/[^?#@]*)?)$"
            },
            "accountPath": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)*$"
            },
            "webSession": {
              "const": "independent"
            }
          },
          "required": [
            "title",
            "webUrl",
            "webSession"
          ],
          "additionalProperties": false
        },
        "community": {
          "type": "object",
          "properties": {
            "readOnly": {
              "const": true
            },
            "media": {
              "type": "object",
              "properties": {
                "novel": {
                  "type": "object",
                  "properties": {
                    "anchors": {
                      "type": "array",
                      "minItems": 1,
                      "uniqueItems": true,
                      "items": {
                        "enum": [
                          "book",
                          "chapter",
                          "paragraph"
                        ]
                      }
                    },
                    "presentations": {
                      "type": "array",
                      "minItems": 1,
                      "uniqueItems": true,
                      "items": {
                        "enum": [
                          "list",
                          "featured"
                        ]
                      }
                    }
                  },
                  "required": [
                    "anchors",
                    "presentations"
                  ],
                  "additionalProperties": false
                },
                "comic": {
                  "type": "object",
                  "properties": {
                    "anchors": {
                      "type": "array",
                      "minItems": 1,
                      "uniqueItems": true,
                      "items": {
                        "enum": [
                          "book",
                          "chapter",
                          "comicPage"
                        ]
                      }
                    },
                    "presentations": {
                      "type": "array",
                      "minItems": 1,
                      "uniqueItems": true,
                      "items": {
                        "enum": [
                          "list",
                          "danmaku"
                        ]
                      }
                    }
                  },
                  "required": [
                    "anchors",
                    "presentations"
                  ],
                  "additionalProperties": false
                },
                "audiobook": {
                  "type": "object",
                  "properties": {
                    "anchors": {
                      "type": "array",
                      "minItems": 1,
                      "uniqueItems": true,
                      "items": {
                        "enum": [
                          "book",
                          "chapter",
                          "audioTime"
                        ]
                      }
                    },
                    "presentations": {
                      "type": "array",
                      "minItems": 1,
                      "uniqueItems": true,
                      "items": {
                        "enum": [
                          "list"
                        ]
                      }
                    }
                  },
                  "required": [
                    "anchors",
                    "presentations"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [],
              "additionalProperties": false,
              "minProperties": 1
            }
          },
          "required": [
            "readOnly",
            "media"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "version",
        "apiBaseUrl",
        "mediaTypes",
        "providers",
        "auth"
      ],
      "additionalProperties": false
    },
    "enabled": {
      "type": "boolean"
    }
  },
  "required": [
    "bookSourceName",
    "bookSourceUrl",
    "bookSourceVersion",
    "omniread"
  ],
  "additionalProperties": false,
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "云书阁 v2 书源声明",
  "description": "验证公开导入结构；App 另行校验同源、媒介子集及能力组合。v1 使用独立 source.schema.json。"
}
