{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://assets.tiantianspeak.com/schemas/catalog.schema.json",
  "title": "Catalog（目录文件）",
  "description": "在线题库详情页读的目录：`*.catalog.json`，与题库项同目录（`a.json` → `a.catalog.json`，`a.package.json` → `a.package.catalog.json`）。只有分组 / collection / 各篇标题，没有正文。由 `ddscli bank-catalog` 在发布时生成。",
  "type": "object",
  "required": [
    "nodes",
    "collectionCount",
    "itemCount"
  ],
  "properties": {
    "nodes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/node"
      }
    },
    "collectionCount": {
      "type": "integer",
      "minimum": 0
    },
    "itemCount": {
      "type": "integer",
      "minimum": 0
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "pattern": "^[^/\\s][^/]*(/[^/]+)*$",
        "description": "分级标签：用 `/` 分隔的层级路径，如 `HSK/初级`、`名著/外国文学`。"
      },
      "description": "入口文件（包或 collection）的分级标签；没有标签时省略。"
    }
  },
  "$defs": {
    "node": {
      "title": "目录行",
      "type": "object",
      "required": [
        "id",
        "title"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "行的唯一标识：包里是 `<入口路径>/<序号>…`，篇目是 `<上级id>#<序号>`。"
        },
        "title": {
          "type": "string"
        },
        "detail": {
          "type": "string",
          "description": "右侧说明，如 `12 篇`、`无法读取`。"
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/node"
          },
          "description": "分组 / collection 有 children；篇目是叶子。"
        },
        "zip": {
          "type": "string",
          "description": "这个节点是题库包里引用的 zip 时，该 zip 的路径（相对题库包文件）；详情页据此给这一行一个「只下载这一个」的按钮。只有题库包里直接引用的 zip 有，zip 里面的节点没有。"
        }
      },
      "additionalProperties": false
    }
  }
}
