Просмотр исходного кода

✨ v4 搜索页迁到 v6:搜索弹窗 + 整页 /search,词形 / 逐词 / 页码 / 补全迁 v3

v6 主导航「搜索」打开弹窗(快捷键 /),另有整页 /search(条件在地址栏、标题随检索词变)。
弹窗里的链接一律新标签页打开。四个标签页:
- 全文:/v3/search,按 category 分面筛选后重查;输入页码时不查
- 定义:逐词检索,目录树 + 词形 + 按书筛选,黑体范围
- 标题:/v3/tipitaka-chapters,按层级筛选
- 页码:按版本切换、按层级分卡片、目录树过滤,点进印本页 / CS 段落阅读页
搜索框带巴利词补全(补最后一个词,回车搜原文,选候选才替换)。

v2 → v3(v2 原样保留,规格里标 deprecated,CLAUDE.md 对照表各加一行):
- case/{word} → pali-word-forms/{word}(字典页 CaseList 一并切换)
- search-pali-wbw + search-pali-wbw-books → tipitaka-word-paragraphs (+/aggregate)
- search-page-number/{number} → tipitaka-page-numbers/{page}(edition / volume 过滤,带 tags)
- pali-word-index?view=key → pali-word-suggestions(与输入相同的在前,其余按出现次数降序)
书名与层级的批量查询抽成 V3\TipitakaBookService。

BookTree:受控选中、自定义计数、展开箭头随状态旋转;默认单选,多选时祖先与后代互斥。

测试:Pest、api-test 20–23、dashboard-test search / pali-word-forms。
规格与 dashboard-v6、wikipali-mobile 的 schema.d.ts 已重新生成(mobile 那份未提交)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 11 часов назад
Родитель
Сommit
8b29f9a0f8
96 измененных файлов с 15375 добавлено и 83 удалено
  1. 4 0
      CLAUDE.md
  2. 24 0
      api-test/cases/20_pali_word_forms.php
  3. 41 0
      api-test/cases/21_tipitaka_word_paragraphs.php
  4. 29 0
      api-test/cases/22_tipitaka_page_numbers.php
  5. 27 0
      api-test/cases/23_pali_word_suggestions.php
  6. 57 3
      api-test/client/.openapi-generator/FILES
  7. 487 0
      api-test/client/lib/Api/PaliWordFormsApi.php
  8. 503 0
      api-test/client/lib/Api/PaliWordSuggestionsApi.php
  9. 517 0
      api-test/client/lib/Api/TipitakaPageNumbersApi.php
  10. 857 0
      api-test/client/lib/Api/TipitakaWordParagraphsApi.php
  11. 443 0
      api-test/client/lib/Model/GetApiV3PaliWordFormsWord200Response.php
  12. 443 0
      api-test/client/lib/Model/GetApiV3PaliWordFormsWord200ResponseDataInner.php
  13. 477 0
      api-test/client/lib/Model/GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner.php
  14. 409 0
      api-test/client/lib/Model/GetApiV3PaliWordFormsWord200ResponseMeta.php
  15. 443 0
      api-test/client/lib/Model/GetApiV3PaliWordSuggestions200Response.php
  16. 4 4
      api-test/client/lib/Model/GetApiV3PaliWordSuggestions200ResponseMeta.php
  17. 3 3
      api-test/client/lib/Model/GetApiV3SearchSuggestions200Response.php
  18. 443 0
      api-test/client/lib/Model/GetApiV3TipitakaPageNumbersPage200Response.php
  19. 770 0
      api-test/client/lib/Model/GetApiV3TipitakaPageNumbersPage200ResponseDataInner.php
  20. 409 0
      api-test/client/lib/Model/GetApiV3TipitakaPageNumbersPage200ResponseMeta.php
  21. 443 0
      api-test/client/lib/Model/GetApiV3TipitakaWordParagraphs200Response.php
  22. 715 0
      api-test/client/lib/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInner.php
  23. 525 0
      api-test/client/lib/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner.php
  24. 443 0
      api-test/client/lib/Model/GetApiV3TipitakaWordParagraphsAggregate200Response.php
  25. 654 0
      api-test/client/lib/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner.php
  26. 477 0
      api-test/client/lib/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta.php
  27. 37 0
      api-v13/app/Http/Controllers/V3/PaliWordFormController.php
  28. 39 0
      api-v13/app/Http/Controllers/V3/PaliWordSuggestionController.php
  29. 42 0
      api-v13/app/Http/Controllers/V3/TipitakaPageNumberController.php
  30. 45 0
      api-v13/app/Http/Controllers/V3/TipitakaWordParagraphAggregateController.php
  31. 41 0
      api-v13/app/Http/Controllers/V3/TipitakaWordParagraphController.php
  32. 69 0
      api-v13/app/Http/Requests/V3/AggregateTipitakaWordParagraphRequest.php
  33. 27 0
      api-v13/app/Http/Requests/V3/IndexPaliWordSuggestionRequest.php
  34. 46 0
      api-v13/app/Http/Requests/V3/IndexTipitakaPageNumberRequest.php
  35. 33 0
      api-v13/app/Http/Requests/V3/IndexTipitakaWordParagraphRequest.php
  36. 27 0
      api-v13/app/Http/Resources/V3/PaliWordFormResource.php
  37. 25 0
      api-v13/app/Http/Resources/V3/PaliWordSuggestionResource.php
  38. 49 0
      api-v13/app/Http/Resources/V3/TipitakaPageNumberResource.php
  39. 41 0
      api-v13/app/Http/Resources/V3/TipitakaWordBookResource.php
  40. 45 0
      api-v13/app/Http/Resources/V3/TipitakaWordParagraphResource.php
  41. 85 0
      api-v13/app/Services/V3/PaliWordFormService.php
  42. 38 0
      api-v13/app/Services/V3/PaliWordSuggestionService.php
  43. 69 0
      api-v13/app/Services/V3/TipitakaBookService.php
  44. 100 0
      api-v13/app/Services/V3/TipitakaPageNumberService.php
  45. 252 0
      api-v13/app/Services/V3/TipitakaWordParagraphService.php
  46. 26 0
      api-v13/routes/v3/tipitaka.php
  47. 80 0
      api-v13/tests/Feature/PaliWordFormV3Test.php
  48. 50 0
      api-v13/tests/Feature/PaliWordSuggestionV3Test.php
  49. 102 0
      api-v13/tests/Feature/TipitakaPageNumberV3Test.php
  50. 140 0
      api-v13/tests/Feature/TipitakaWordParagraphV3Test.php
  51. 28 0
      dashboard-test/src/tests/pali-word-forms.spec.ts
  52. 391 0
      dashboard-test/src/tests/search.spec.ts
  53. 3 0
      dashboard-v6/src/Router.tsx
  54. 0 14
      dashboard-v6/src/api/dict.ts
  55. 65 0
      dashboard-v6/src/api/pali-word-form.ts
  56. 382 6
      dashboard-v6/src/api/schema.d.ts
  57. 150 0
      dashboard-v6/src/api/tipitaka-search.ts
  58. 29 35
      dashboard-v6/src/components/dict/CaseList.tsx
  59. 19 6
      dashboard-v6/src/components/navigation/MainMenu.tsx
  60. 66 6
      dashboard-v6/src/components/tipitaka/BookTree.tsx
  61. 150 0
      dashboard-v6/src/features/search/CategoryFacets.tsx
  62. 601 0
      dashboard-v6/src/features/search/DefinitionTab.tsx
  63. 253 0
      dashboard-v6/src/features/search/FullTextTab.tsx
  64. 26 0
      dashboard-v6/src/features/search/Highlight.tsx
  65. 29 0
      dashboard-v6/src/features/search/LayerTag.tsx
  66. 305 0
      dashboard-v6/src/features/search/PageTab.tsx
  67. 128 0
      dashboard-v6/src/features/search/SearchInput.tsx
  68. 75 0
      dashboard-v6/src/features/search/SearchModal.tsx
  69. 268 0
      dashboard-v6/src/features/search/SearchPanel.tsx
  70. 173 0
      dashboard-v6/src/features/search/TitleTab.tsx
  71. 50 0
      dashboard-v6/src/features/search/categories.ts
  72. 147 0
      dashboard-v6/src/features/search/hooks.ts
  73. 139 0
      dashboard-v6/src/features/search/state.ts
  74. 2 0
      dashboard-v6/src/locales/en-US.ts
  75. 77 0
      dashboard-v6/src/locales/en-US/search.ts
  76. 2 0
      dashboard-v6/src/locales/zh-Hans.ts
  77. 73 0
      dashboard-v6/src/locales/zh-Hans/search.ts
  78. 2 0
      dashboard-v6/src/locales/zh-Hant.ts
  79. 73 0
      dashboard-v6/src/locales/zh-Hant/search.ts
  80. 59 0
      dashboard-v6/src/pages/search.tsx
  81. 10 0
      openapi/public/assets/protocol/main.yaml
  82. 7 0
      openapi/public/assets/protocol/overrides/v2-case-case.yaml
  83. 7 0
      openapi/public/assets/protocol/overrides/v2-pali-word-index.yaml
  84. 8 0
      openapi/public/assets/protocol/overrides/v2-search-page-number-search-page-number.yaml
  85. 7 0
      openapi/public/assets/protocol/overrides/v2-search-pali-wbw-books.yaml
  86. 13 0
      openapi/public/assets/protocol/overrides/v2-search-pali-wbw.yaml
  87. 5 1
      openapi/public/assets/protocol/resources/auto/v2-case-case.yaml
  88. 5 1
      openapi/public/assets/protocol/resources/auto/v2-pali-word-index.yaml
  89. 6 1
      openapi/public/assets/protocol/resources/auto/v2-search-page-number-search-page-number.yaml
  90. 5 1
      openapi/public/assets/protocol/resources/auto/v2-search-pali-wbw-books.yaml
  91. 10 2
      openapi/public/assets/protocol/resources/auto/v2-search-pali-wbw.yaml
  92. 50 0
      openapi/public/assets/protocol/resources/auto/v3-pali-word-forms-word.yaml
  93. 58 0
      openapi/public/assets/protocol/resources/auto/v3-pali-word-suggestions.yaml
  94. 92 0
      openapi/public/assets/protocol/resources/auto/v3-tipitaka-page-numbers-page.yaml
  95. 78 0
      openapi/public/assets/protocol/resources/auto/v3-tipitaka-word-paragraphs-aggregate.yaml
  96. 94 0
      openapi/public/assets/protocol/resources/auto/v3-tipitaka-word-paragraphs.yaml

+ 4 - 0
CLAUDE.md

@@ -366,6 +366,10 @@ Resource / FormRequest / 测试同理;URL 只换版本前缀
 | `nissaya-card/{ending}` / `NissayaCardController@show` | `nissaya-cards/{ending}` / `V3\NissayaCardController`(逻辑在 `V3\NissayaCardService`) | 2026-11-17。缅文 nissaya 词尾卡片(v6 `components/nissaya/NissayaCard`),只读、公开。只给结构化数据:去掉 mustache 渲染的 markdown 分支、写死在后端的表头文字、拼好的 dashboard 链接(前端自己拼);术语一次批量查(v2 逐格位 N+1);词尾说明是新渲染器的 `body` 节点树。字段 `row`→`relations`、`case`→`cases[{case,label}]`、`local_relation`→`relation_label`、`local_ending`(分号拼接)→`local_endings`(数组);查不到的词尾回空卡片(200)。语法术语 channel 没有该语言时回退 en,`lang` 是实际用到的语言。v6 已切;mobile、插件不用 |
 | (无对应 v2 端点;早期 v3)`search`(GET / POST / `{id}`)/ `V3\SearchPlusController` | `search`(不变)/ `V3\SearchController`(逻辑在 `V3\SearchService`) | 2026-11-19,按现行 v3 规范重写(v2 的 `SearchController` 是 PostgreSQL 全文检索,另一套,不受影响)。控制器改名 `SearchPlusController`→`SearchController`;入参走 `IndexSearchRequest`:`q` 必填(不再 `match_all` 全索引),`search_mode` / `resource_type`(`tipitaka`/`original_text`/`term`)/ `granularity`(`book`/`chapter`/`session`/`paragraph`)按索引真实值校验,`page_size`→`per_page`(≤100),`page × per_page` > 10000 时 422(原来 OpenSearch 报错变 500)。响应从 OpenSearch 原始结构 `{success, data:{took, hits, aggregations}, query_info}` 改成 `{data:[hit], meta:{current_page, per_page, total, total_relation, last_page}}`,hit 是扁平字段(`related_id`、`title`、`content`、`highlight`、`bold[]`、`score`…),不再透出 `_source`;分面聚合改为 `facets=true` 才算(`meta.facets`)。错误走 Problem Details:搜索集群连不上 / 超时 / 过载 → 503 `search-unavailable`(原来 catch 后把原始报错 + 500 吐给客户端、且不写日志);`{id}` 只有文档不存在才 404(原来任何异常都 404)。共享的 `OpenSearchService::search()` 加了 `aggregations` 开关(默认 true,Library 与 AITermService 不变),顺带修 `channel` 过滤(text 字段用 term 永远不中→`match_phrase`)与数组 `related_id`(term→terms)。POST 保留(用户定)。wikipali-plugins(`phrase` / `find`)、agent-poc 召回评测脚本已切;v6、mobile 不调用。`search-suggest` 未迁 |
 | (无对应 v2 端点;早期 v3)`search-suggest` / `V3\SearchSuggestController` | `search-suggestions` / `V3\SearchSuggestionController`(逻辑在 `V3\SearchService::suggest`) | 2026-11-19。搜索框前缀补全(OpenSearch completion)。路径复数化,旧路径删除(404);`{success, data:{query, suggestions, total}}`→`{data:[{text, source, score, doc_id, resource_type, language, granularity, category}], meta:{total}}`;空 q 从 400 改 422;`fields` 按真实字段校验(`title_pali`/`title_zh`/`content_pali`/`content_zh`,旧注释写的 title/content/page_refs 一传就 400);`limit` 从「每个字段各取」(实际最多 4 倍)改成总条数,并按词去重;`language` 去掉(completion 忽略 query,从未生效,用户定);completion 只取四个元数据字段,不再逐条带回整篇 `_source`;搜索集群不可用 503。Library 搜索框(`resources/js/search-suggest.js`)已切,顺带修了候选文本未转义直接进 `innerHTML`。v4 的 `ChatInput` 还指着旧路径(线上不可达,不改) |
+| `case/{word}` / `CaseController@show` | `pali-word-forms/{word}` / `V3\PaliWordFormController`(逻辑在 `V3\PaliWordFormService`) | 2026-11-19。词形展开:词 → 可能的词根 → 每个词根在三藏里出现过的词形与次数、黑体次数。**改名**:v2 的 case 不是语法格,是词形展开。`rows[].word`→`data[].base`、`rows[].case`→`data[].forms`,去掉每条里多余的 `"0":"ending"`;没有任何词形出现过的词根不列(v2 给一个空 case 行);词不区分大小写;候选词形一次 `whereIn` 查 `word_indices`(v2 逐个查,一个词上百次)。词根推导仍用共享的 `CaseMan::WordToBase(…, verify: false)`(纯字符串运算)。v6(字典页 `CaseList`、搜索「定义」标签页)、wikipali-plugins(`forms` / `count` / `search --lemma` / `find`)已切;mobile 不用 |
+| `search-pali-wbw`(GET / POST)+ `search-pali-wbw-books` / `SearchPaliWbwController@index` + `@book_list` | `tipitaka-word-paragraphs`(+`/aggregate`)/ `V3\TipitakaWordParagraphController` + `V3\TipitakaWordParagraphAggregateController`(逻辑在 `V3\TipitakaWordParagraphService`) | 2026-11-19。按词形找段落(逐词表 `wbw_templates`,连音已拆开,精确匹配)+ 按书统计。**改名**,与 `tipitaka-related-paragraphs`(+`/aggregate`)同构。参数 `key`→`words`(≤200 个,空词形 422),`bold=on|off`→`bold=only|exclude`,`book`→`book_id`(逗号多选),`limit/offset`→`page/per_page`(≤100);`view`、`tags` 去掉(插件 `--tags` 改为先调 `/aggregate` 按书的 tag 筛 book_id)。字段 `paragraph`→`para`、`rank`→`score`(另有 `hits`)、`paliTitle`→`title`、`highlight`→`text`(整段正文,只含 `<b>` 黑体与 `<mark>` 命中词,其余已转义)、`ref`→`refs`(加 `volume`);不再给指向旧版 library 的 `link`(插件按坐标拼)。同分按经文顺序(v2 不定序)。段落、页码整页批量取(v2 每行 3~4 次查询)。`/aggregate` 同时给 `paragraphs` 与 `occurrences`(v2 只有词次 `count`),另给 `layer`、`tags`(字符串数组);`pcdBookId`→`book_id`。v6 搜索「定义」标签页、wikipali-plugins(`search` / `find` / `dist` / `ref`,CLI 输出字段名不变)已切;v6 的 `components/tipitaka/BookTreeWithTags.tsx` 仍调 v2,但它没有任何引用(死代码,用户定保留不动);mobile 不用 |
+| `search-page-number/{number}` / `SearchPageNumberController@show`(另含 v2 `search?view=page` 的「卷.页」查法) | `tipitaka-page-numbers/{page}` / `V3\TipitakaPageNumberController`(逻辑在 `V3\TipitakaPageNumberService`) | 2026-11-19。按印本页码找段落。**改名**。新增过滤 `edition`(PTS / My / VRI / Thai / Other / CS,与 `tipitaka-word-paragraphs` 的 `refs.type` 同名)与 `volume`(v2 只能查页码、各版本混在一起);v2 的 `type=para`(逐词表里 CS 版印的段落号 `para{n}`)→`edition=CS`,给了 `volume` 时不返回。字段:单字母 `type`→`edition`,`paragraph`→`para`,`pcd_book_id`→`book_id`,卷号 0(未知)→`volume: null`;新增 `book_title`、`book_para`(书名所在段,CS 段落号按书编号)、`edition_title`(静态书名表 `Http\Api\BookTitle` 里该版本的书名,v6 印本页阅读页按「版本_版本书名_卷_页」定位)、`layer`、`tags`(v6 按它做目录树过滤)。不分页(一个页码最多约一千处),按版本、书、卷、段排序;书名与层级批量取(`V3\TipitakaBookService`,逐词检索的 `/aggregate` 也改用它)。v6 搜索「页码」标签页已切;只有 v4 `PageNumberList` 用 v2;mobile、插件不用 |
+| `pali-word-index?view=key` / `WordIndexController@index` | `pali-word-suggestions` / `V3\PaliWordSuggestionController`(逻辑在 `V3\PaliWordSuggestionService`) | 2026-11-19。搜索框的巴利词补全(`word_indices`)。**改名**:v2 名字是表名,v3 按用途叫 suggestions,与 `search-suggestions`(OpenSearch completion,补标题与正文)并列。`key`→`q`,`rows`→`data`,`count`→`meta.total`,新增 `limit`(默认 10,≤50);只回 `word`/`count`/`bold`(v2 整行吐出);排序从「词长、去变音形」改成「与输入相同的在前,其余按出现次数降序」(v2 下 vit 补出 vītā/1、vitā/2 这类罕见短词形);`%`、`_` 按字面匹配;不区分大小写。v6 搜索框(`features/search/SearchInput`,补全最后一个词,回车搜原文、选候选才替换)已切;只有 v4 `FullSearchInput` 用 v2;mobile、插件不用 |
 
 **注意**:`tipitaka-reading` **不是** v2 `paragraph-content` / `chapter-content` 的替代品。
 那两个 v2 端点支持多 channel(`channels=a,b,c`)与 edit 模式、返回 sentenceIds 供编辑器用;

+ 24 - 0
api-test/cases/20_pali_word_forms.php

@@ -0,0 +1,24 @@
+<?php
+
+/*
+ * 词形展开:GET /v3/pali-word-forms/{word}(取代 v2 case/{word})。只读、公开。
+ * 各服务器的词频不同,只核对形状;N+1、大小写、排序由 api-v13 的 PaliWordFormV3Test 覆盖。
+ */
+
+test('GET /v3/pali-word-forms/{word} → 200,第一组是输入的词本身', function () {
+    $res = raw('GET', '/v3/pali-word-forms/'.rawurlencode('dhamma'));
+    assert_status(200, $res, 'word forms');
+    assert_has_key('total', $res['body']['meta'], 'meta');
+    $first = $res['body']['data'][0] ?? null;
+    assert_eq(true, $first !== null, '常见词至少有一组');
+    assert_eq('dhamma', $first['base'], '第一组是输入的词');
+    assert_eq(['word', 'count', 'bold'], array_keys($first['forms'][0]), '词形字段');
+});
+
+test('GET /v3/pali-word-forms/{不存在的词} → 200 空列表;过长 → 404', function () {
+    $res = raw('GET', '/v3/pali-word-forms/qqqzzzxx');
+    assert_status(200, $res, '空列表');
+    assert_eq([], $res['body']['data'], '没有词形');
+    $long = raw('GET', '/v3/pali-word-forms/'.str_repeat('a', 65));
+    assert_status(404, $long, '路径约束');
+});

+ 41 - 0
api-test/cases/21_tipitaka_word_paragraphs.php

@@ -0,0 +1,41 @@
+<?php
+
+/*
+ * 按词形找段落:GET /v3/tipitaka-word-paragraphs (+ /aggregate)(取代 v2 search-pali-wbw / -books)。只读、公开。
+ * 各服务器数据不同,只核对形状与几条不变量;高亮转义、N+1、黑体过滤由 api-v13 的 TipitakaWordParagraphV3Test 覆盖。
+ */
+
+const WORD_FORMS = 'dhammo,dhammaṃ,dhammassa';
+
+test('GET /v3/tipitaka-word-paragraphs → 200,分页、字段完整', function () {
+    $res = raw('GET', '/v3/tipitaka-word-paragraphs', ['words' => WORD_FORMS, 'per_page' => 3]);
+    assert_status(200, $res, 'word paragraphs');
+    foreach (['current_page', 'per_page', 'total', 'last_page'] as $key) {
+        assert_has_key($key, $res['body']['meta'], 'meta');
+    }
+    $row = $res['body']['data'][0] ?? null;
+    assert_eq(true, $row !== null, '常见词至少命中一段');
+    assert_eq(['id', 'book', 'para', 'score', 'hits', 'title', 'level', 'path', 'text', 'refs'], array_keys($row), '段落字段');
+    assert_eq("{$row['book']}-{$row['para']}", $row['id'], 'id 是 book-para');
+    assert_eq('WP', end($row['refs'])['type'], '最后一条 ref 是 WP 段落号');
+});
+
+test('GET /v3/tipitaka-word-paragraphs/aggregate → 每本书的段落数之和等于列表总数', function () {
+    $agg = raw('GET', '/v3/tipitaka-word-paragraphs/aggregate', ['words' => WORD_FORMS, 'bold' => 'only']);
+    assert_status(200, $agg, 'aggregate');
+    $list = raw('GET', '/v3/tipitaka-word-paragraphs', ['words' => WORD_FORMS, 'bold' => 'only', 'per_page' => 1]);
+    assert_eq($list['body']['meta']['total'], $agg['body']['meta']['paragraphs'], '段落总数一致');
+    $book = $agg['body']['data'][0] ?? null;
+    if ($book) {
+        assert_eq(['book_id', 'book', 'para', 'title', 'layer', 'tags', 'paragraphs', 'occurrences'], array_keys($book), '书字段');
+        $one = raw('GET', '/v3/tipitaka-word-paragraphs', ['words' => WORD_FORMS, 'bold' => 'only', 'book_id' => $book['book_id'], 'per_page' => 1]);
+        assert_eq($book['paragraphs'], $one['body']['meta']['total'], '按 book_id 过滤后的总数等于该书的段落数');
+    }
+});
+
+test('GET /v3/tipitaka-word-paragraphs 缺 words / 空词形 / bold 不对 → 422', function () {
+    assert_status(422, raw('GET', '/v3/tipitaka-word-paragraphs'), '缺 words');
+    assert_status(422, raw('GET', '/v3/tipitaka-word-paragraphs', ['words' => ',,']), '空词形');
+    assert_status(422, raw('GET', '/v3/tipitaka-word-paragraphs', ['words' => 'x', 'bold' => 'on']), 'bold=on 是 v2 写法');
+    assert_status(422, raw('GET', '/v3/tipitaka-word-paragraphs/aggregate'), 'aggregate 缺 words');
+});

+ 29 - 0
api-test/cases/22_tipitaka_page_numbers.php

@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * 按印本页码找段落:GET /v3/tipitaka-page-numbers/{page}(取代 v2 search-page-number)。只读、公开。
+ * 各服务器数据不同,只核对形状与过滤的不变量;N+1、排序、卷号 0 由 api-v13 的 TipitakaPageNumberV3Test 覆盖。
+ */
+
+test('GET /v3/tipitaka-page-numbers/{page} → 200,字段完整,meta.total 等于条数', function () {
+    $res = raw('GET', '/v3/tipitaka-page-numbers/100');
+    assert_status(200, $res, 'page numbers');
+    assert_eq(count($res['body']['data']), $res['body']['meta']['total'], 'total 等于条数(不分页)');
+    $row = $res['body']['data'][0] ?? null;
+    assert_eq(true, $row !== null, '第 100 页至少有一处');
+    assert_eq(['edition', 'volume', 'page', 'book', 'para', 'book_id', 'book_title', 'book_para', 'edition_title', 'layer', 'tags'], array_keys($row), '字段');
+});
+
+test('GET /v3/tipitaka-page-numbers/{page}?edition=&volume= → 只要这个版本这一卷', function () {
+    $res = raw('GET', '/v3/tipitaka-page-numbers/100', ['edition' => 'PTS', 'volume' => 2]);
+    assert_status(200, $res, 'filtered');
+    foreach ($res['body']['data'] as $row) {
+        assert_eq(['PTS', 2], [$row['edition'], $row['volume']], '过滤生效');
+    }
+});
+
+test('GET /v3/tipitaka-page-numbers 版本不对 / 卷号 0 → 422;页码不是数字 → 404', function () {
+    assert_status(422, raw('GET', '/v3/tipitaka-page-numbers/100', ['edition' => 'P']), 'edition=P 是 v2 的单字母');
+    assert_status(422, raw('GET', '/v3/tipitaka-page-numbers/100', ['volume' => 0]), 'volume=0');
+    assert_status(404, raw('GET', '/v3/tipitaka-page-numbers/abc'), '路径约束');
+});

+ 27 - 0
api-test/cases/23_pali_word_suggestions.php

@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * 巴利词补全:GET /v3/pali-word-suggestions?q=(取代 v2 pali-word-index?view=key)。只读、公开。
+ * 各服务器的词频不同,只核对形状与排序规则;通配符、去变音匹配由 api-v13 的 PaliWordSuggestionV3Test 覆盖。
+ */
+
+test('GET /v3/pali-word-suggestions → 200,都以前缀开头,与输入相同的在前、其余按次数降序', function () {
+    $res = raw('GET', '/v3/pali-word-suggestions?q=vitakk&limit=5');
+    assert_status(200, $res, 'suggestions');
+    $data = $res['body']['data'];
+    assert_eq(count($data), $res['body']['meta']['total'], 'meta.total 等于条数');
+    assert_eq(true, count($data) > 0 && count($data) <= 5, 'limit 生效');
+    assert_eq(['word', 'count', 'bold'], array_keys($data[0]), '字段');
+    foreach ($data as $w) {
+        assert_eq(true, str_starts_with($w['word'], 'vitakk'), "{$w['word']} 以前缀开头");
+    }
+    $counts = array_column($data, 'count');
+    $sorted = $counts;
+    rsort($sorted);
+    assert_eq($sorted, $counts, '按出现次数降序');
+});
+
+test('GET /v3/pali-word-suggestions 缺 q / limit 越界 → 422', function () {
+    assert_status(422, raw('GET', '/v3/pali-word-suggestions'), '缺 q');
+    assert_status(422, raw('GET', '/v3/pali-word-suggestions?q=a&limit=51'), 'limit 越界');
+});

+ 57 - 3
api-test/client/.openapi-generator/FILES

@@ -22,6 +22,8 @@ docs/Api/HeartbeatApi.md
 docs/Api/InvitesApi.md
 docs/Api/MeApi.md
 docs/Api/NissayaCardsApi.md
+docs/Api/PaliWordFormsApi.md
+docs/Api/PaliWordSuggestionsApi.md
 docs/Api/PasswordResetsApi.md
 docs/Api/ProgressApi.md
 docs/Api/ReactionsApi.md
@@ -35,9 +37,11 @@ docs/Api/TipitakaChannelsApi.md
 docs/Api/TipitakaChapterChannelsApi.md
 docs/Api/TipitakaChaptersApi.md
 docs/Api/TipitakaDiscussionsApi.md
+docs/Api/TipitakaPageNumbersApi.md
 docs/Api/TipitakaParagraphChannelsApi.md
 docs/Api/TipitakaReadingApi.md
 docs/Api/TipitakaRelatedParagraphsApi.md
+docs/Api/TipitakaWordParagraphsApi.md
 docs/Api/UpgradeApi.md
 docs/Api/UsersApi.md
 docs/Model/GetApiV3AdminAgentFeedback200Response.md
@@ -126,6 +130,12 @@ docs/Model/GetApiV3NissayaCardsEnding200ResponseDataRelationsInnerCategory.md
 docs/Model/GetApiV3NissayaCardsEnding200ResponseDataRelationsInnerFrom.md
 docs/Model/GetApiV3NissayaCardsEnding200ResponseDataRelationsInnerFromCasesInner.md
 docs/Model/GetApiV3NissayaCardsEnding200ResponseDataTerm.md
+docs/Model/GetApiV3PaliWordFormsWord200Response.md
+docs/Model/GetApiV3PaliWordFormsWord200ResponseDataInner.md
+docs/Model/GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner.md
+docs/Model/GetApiV3PaliWordFormsWord200ResponseMeta.md
+docs/Model/GetApiV3PaliWordSuggestions200Response.md
+docs/Model/GetApiV3PaliWordSuggestions200ResponseMeta.md
 docs/Model/GetApiV3PasswordResetsToken200Response.md
 docs/Model/GetApiV3PasswordResetsToken200ResponseData.md
 docs/Model/GetApiV3Progress200Response.md
@@ -139,7 +149,6 @@ docs/Model/GetApiV3Search200ResponseMetaFacetsValueInner.md
 docs/Model/GetApiV3SearchSearch200Response.md
 docs/Model/GetApiV3SearchSuggestions200Response.md
 docs/Model/GetApiV3SearchSuggestions200ResponseDataInner.md
-docs/Model/GetApiV3SearchSuggestions200ResponseMeta.md
 docs/Model/GetApiV3TipitakaChannels200Response.md
 docs/Model/GetApiV3TipitakaChannels200ResponseDataInner.md
 docs/Model/GetApiV3TipitakaChapterChannelsBookPara200Response.md
@@ -150,6 +159,9 @@ docs/Model/GetApiV3TipitakaChapters200Response.md
 docs/Model/GetApiV3TipitakaChapters200ResponseDataInner.md
 docs/Model/GetApiV3TipitakaChapters200ResponseDataInnerPathInner.md
 docs/Model/GetApiV3TipitakaChapters200ResponseDataInnerTranslationsInner.md
+docs/Model/GetApiV3TipitakaPageNumbersPage200Response.md
+docs/Model/GetApiV3TipitakaPageNumbersPage200ResponseDataInner.md
+docs/Model/GetApiV3TipitakaPageNumbersPage200ResponseMeta.md
 docs/Model/GetApiV3TipitakaReadingChannel200Response.md
 docs/Model/GetApiV3TipitakaReadingChannel200ResponseDataInner.md
 docs/Model/GetApiV3TipitakaReadingChannel200ResponseMeta.md
@@ -161,6 +173,12 @@ docs/Model/GetApiV3TipitakaRelatedParagraphsAggregate200Response.md
 docs/Model/GetApiV3TipitakaRelatedParagraphsAggregate200ResponseDataInner.md
 docs/Model/GetApiV3TipitakaRelatedParagraphsAggregateBookName200Response.md
 docs/Model/GetApiV3TipitakaRelatedParagraphsAggregateBookName200ResponseDataInner.md
+docs/Model/GetApiV3TipitakaWordParagraphs200Response.md
+docs/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInner.md
+docs/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner.md
+docs/Model/GetApiV3TipitakaWordParagraphsAggregate200Response.md
+docs/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner.md
+docs/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta.md
 docs/Model/GetApiV3Upgrade200Response.md
 docs/Model/MarkupElement.md
 docs/Model/MarkupNode.md
@@ -250,6 +268,8 @@ lib/Api/HeartbeatApi.php
 lib/Api/InvitesApi.php
 lib/Api/MeApi.php
 lib/Api/NissayaCardsApi.php
+lib/Api/PaliWordFormsApi.php
+lib/Api/PaliWordSuggestionsApi.php
 lib/Api/PasswordResetsApi.php
 lib/Api/ProgressApi.php
 lib/Api/ReactionsApi.php
@@ -263,9 +283,11 @@ lib/Api/TipitakaChannelsApi.php
 lib/Api/TipitakaChapterChannelsApi.php
 lib/Api/TipitakaChaptersApi.php
 lib/Api/TipitakaDiscussionsApi.php
+lib/Api/TipitakaPageNumbersApi.php
 lib/Api/TipitakaParagraphChannelsApi.php
 lib/Api/TipitakaReadingApi.php
 lib/Api/TipitakaRelatedParagraphsApi.php
+lib/Api/TipitakaWordParagraphsApi.php
 lib/Api/UpgradeApi.php
 lib/Api/UsersApi.php
 lib/ApiException.php
@@ -358,6 +380,12 @@ lib/Model/GetApiV3NissayaCardsEnding200ResponseDataRelationsInnerCategory.php
 lib/Model/GetApiV3NissayaCardsEnding200ResponseDataRelationsInnerFrom.php
 lib/Model/GetApiV3NissayaCardsEnding200ResponseDataRelationsInnerFromCasesInner.php
 lib/Model/GetApiV3NissayaCardsEnding200ResponseDataTerm.php
+lib/Model/GetApiV3PaliWordFormsWord200Response.php
+lib/Model/GetApiV3PaliWordFormsWord200ResponseDataInner.php
+lib/Model/GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner.php
+lib/Model/GetApiV3PaliWordFormsWord200ResponseMeta.php
+lib/Model/GetApiV3PaliWordSuggestions200Response.php
+lib/Model/GetApiV3PaliWordSuggestions200ResponseMeta.php
 lib/Model/GetApiV3PasswordResetsToken200Response.php
 lib/Model/GetApiV3PasswordResetsToken200ResponseData.php
 lib/Model/GetApiV3Progress200Response.php
@@ -371,7 +399,6 @@ lib/Model/GetApiV3Search200ResponseMetaFacetsValueInner.php
 lib/Model/GetApiV3SearchSearch200Response.php
 lib/Model/GetApiV3SearchSuggestions200Response.php
 lib/Model/GetApiV3SearchSuggestions200ResponseDataInner.php
-lib/Model/GetApiV3SearchSuggestions200ResponseMeta.php
 lib/Model/GetApiV3TipitakaChannels200Response.php
 lib/Model/GetApiV3TipitakaChannels200ResponseDataInner.php
 lib/Model/GetApiV3TipitakaChapterChannelsBookPara200Response.php
@@ -382,6 +409,9 @@ lib/Model/GetApiV3TipitakaChapters200Response.php
 lib/Model/GetApiV3TipitakaChapters200ResponseDataInner.php
 lib/Model/GetApiV3TipitakaChapters200ResponseDataInnerPathInner.php
 lib/Model/GetApiV3TipitakaChapters200ResponseDataInnerTranslationsInner.php
+lib/Model/GetApiV3TipitakaPageNumbersPage200Response.php
+lib/Model/GetApiV3TipitakaPageNumbersPage200ResponseDataInner.php
+lib/Model/GetApiV3TipitakaPageNumbersPage200ResponseMeta.php
 lib/Model/GetApiV3TipitakaReadingChannel200Response.php
 lib/Model/GetApiV3TipitakaReadingChannel200ResponseDataInner.php
 lib/Model/GetApiV3TipitakaReadingChannel200ResponseMeta.php
@@ -393,6 +423,12 @@ lib/Model/GetApiV3TipitakaRelatedParagraphsAggregate200Response.php
 lib/Model/GetApiV3TipitakaRelatedParagraphsAggregate200ResponseDataInner.php
 lib/Model/GetApiV3TipitakaRelatedParagraphsAggregateBookName200Response.php
 lib/Model/GetApiV3TipitakaRelatedParagraphsAggregateBookName200ResponseDataInner.php
+lib/Model/GetApiV3TipitakaWordParagraphs200Response.php
+lib/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInner.php
+lib/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner.php
+lib/Model/GetApiV3TipitakaWordParagraphsAggregate200Response.php
+lib/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner.php
+lib/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta.php
 lib/Model/GetApiV3Upgrade200Response.php
 lib/Model/MarkupElement.php
 lib/Model/MarkupNode.php
@@ -484,6 +520,8 @@ test/Api/HeartbeatApiTest.php
 test/Api/InvitesApiTest.php
 test/Api/MeApiTest.php
 test/Api/NissayaCardsApiTest.php
+test/Api/PaliWordFormsApiTest.php
+test/Api/PaliWordSuggestionsApiTest.php
 test/Api/PasswordResetsApiTest.php
 test/Api/ProgressApiTest.php
 test/Api/ReactionsApiTest.php
@@ -497,9 +535,11 @@ test/Api/TipitakaChannelsApiTest.php
 test/Api/TipitakaChapterChannelsApiTest.php
 test/Api/TipitakaChaptersApiTest.php
 test/Api/TipitakaDiscussionsApiTest.php
+test/Api/TipitakaPageNumbersApiTest.php
 test/Api/TipitakaParagraphChannelsApiTest.php
 test/Api/TipitakaReadingApiTest.php
 test/Api/TipitakaRelatedParagraphsApiTest.php
+test/Api/TipitakaWordParagraphsApiTest.php
 test/Api/UpgradeApiTest.php
 test/Api/UsersApiTest.php
 test/Model/GetApiV3AdminAgentFeedback200ResponseDataInnerTest.php
@@ -588,6 +628,12 @@ test/Model/GetApiV3NissayaCardsEnding200ResponseDataRelationsInnerTest.php
 test/Model/GetApiV3NissayaCardsEnding200ResponseDataTermTest.php
 test/Model/GetApiV3NissayaCardsEnding200ResponseDataTest.php
 test/Model/GetApiV3NissayaCardsEnding200ResponseTest.php
+test/Model/GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInnerTest.php
+test/Model/GetApiV3PaliWordFormsWord200ResponseDataInnerTest.php
+test/Model/GetApiV3PaliWordFormsWord200ResponseMetaTest.php
+test/Model/GetApiV3PaliWordFormsWord200ResponseTest.php
+test/Model/GetApiV3PaliWordSuggestions200ResponseMetaTest.php
+test/Model/GetApiV3PaliWordSuggestions200ResponseTest.php
 test/Model/GetApiV3PasswordResetsToken200ResponseDataTest.php
 test/Model/GetApiV3PasswordResetsToken200ResponseTest.php
 test/Model/GetApiV3Progress200ResponseDataInnerTest.php
@@ -600,7 +646,6 @@ test/Model/GetApiV3Search200ResponseMetaTest.php
 test/Model/GetApiV3Search200ResponseTest.php
 test/Model/GetApiV3SearchSearch200ResponseTest.php
 test/Model/GetApiV3SearchSuggestions200ResponseDataInnerTest.php
-test/Model/GetApiV3SearchSuggestions200ResponseMetaTest.php
 test/Model/GetApiV3SearchSuggestions200ResponseTest.php
 test/Model/GetApiV3TipitakaChannels200ResponseDataInnerTest.php
 test/Model/GetApiV3TipitakaChannels200ResponseTest.php
@@ -612,6 +657,9 @@ test/Model/GetApiV3TipitakaChapters200ResponseDataInnerPathInnerTest.php
 test/Model/GetApiV3TipitakaChapters200ResponseDataInnerTest.php
 test/Model/GetApiV3TipitakaChapters200ResponseDataInnerTranslationsInnerTest.php
 test/Model/GetApiV3TipitakaChapters200ResponseTest.php
+test/Model/GetApiV3TipitakaPageNumbersPage200ResponseDataInnerTest.php
+test/Model/GetApiV3TipitakaPageNumbersPage200ResponseMetaTest.php
+test/Model/GetApiV3TipitakaPageNumbersPage200ResponseTest.php
 test/Model/GetApiV3TipitakaReadingChannel200ResponseDataInnerTest.php
 test/Model/GetApiV3TipitakaReadingChannel200ResponseMetaTest.php
 test/Model/GetApiV3TipitakaReadingChannel200ResponseTest.php
@@ -623,6 +671,12 @@ test/Model/GetApiV3TipitakaRelatedParagraphsAggregate200ResponseDataInnerTest.ph
 test/Model/GetApiV3TipitakaRelatedParagraphsAggregate200ResponseTest.php
 test/Model/GetApiV3TipitakaRelatedParagraphsAggregateBookName200ResponseDataInnerTest.php
 test/Model/GetApiV3TipitakaRelatedParagraphsAggregateBookName200ResponseTest.php
+test/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInnerTest.php
+test/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInnerTest.php
+test/Model/GetApiV3TipitakaWordParagraphs200ResponseTest.php
+test/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInnerTest.php
+test/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseMetaTest.php
+test/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseTest.php
 test/Model/GetApiV3Upgrade200ResponseTest.php
 test/Model/MarkupElementTest.php
 test/Model/MarkupNodeTest.php

+ 487 - 0
api-test/client/lib/Api/PaliWordFormsApi.php

@@ -0,0 +1,487 @@
+<?php
+/**
+ * PaliWordFormsApi
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Api;
+
+use GuzzleHttp\Client;
+use GuzzleHttp\ClientInterface;
+use GuzzleHttp\Exception\ConnectException;
+use GuzzleHttp\Exception\RequestException;
+use GuzzleHttp\Psr7\MultipartStream;
+use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
+use WikipaliApi\ApiException;
+use WikipaliApi\Configuration;
+use WikipaliApi\FormDataProcessor;
+use WikipaliApi\HeaderSelector;
+use WikipaliApi\ObjectSerializer;
+
+/**
+ * PaliWordFormsApi Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+class PaliWordFormsApi
+{
+    /**
+     * @var ClientInterface
+     */
+    protected $client;
+
+    /**
+     * @var Configuration
+     */
+    protected $config;
+
+    /**
+     * @var HeaderSelector
+     */
+    protected $headerSelector;
+
+    /**
+     * @var int Host index
+     */
+    protected $hostIndex;
+
+    /** @var string[] $contentTypes **/
+    public const contentTypes = [
+        'getApiV3PaliWordFormsWord' => [
+            'application/json',
+        ],
+    ];
+
+    /**
+     * @param ClientInterface $client
+     * @param Configuration   $config
+     * @param HeaderSelector  $selector
+     * @param int             $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
+     */
+    public function __construct(
+        ?ClientInterface $client = null,
+        ?Configuration $config = null,
+        ?HeaderSelector $selector = null,
+        int $hostIndex = 0
+    ) {
+        $this->client = $client ?: new Client();
+        $this->config = $config ?: Configuration::getDefaultConfiguration();
+        $this->headerSelector = $selector ?: new HeaderSelector();
+        $this->hostIndex = $hostIndex;
+    }
+
+    /**
+     * Set the host index
+     *
+     * @param int $hostIndex Host index (required)
+     */
+    public function setHostIndex($hostIndex): void
+    {
+        $this->hostIndex = $hostIndex;
+    }
+
+    /**
+     * Get the host index
+     *
+     * @return int Host index
+     */
+    public function getHostIndex()
+    {
+        return $this->hostIndex;
+    }
+
+    /**
+     * @return Configuration
+     */
+    public function getConfig()
+    {
+        return $this->config;
+    }
+
+    /**
+     * Operation getApiV3PaliWordFormsWord
+     *
+     * 词形展开
+     *
+     * @param  string $word 巴利词,如 vitakka (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordFormsWord'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\GetApiV3PaliWordFormsWord200Response|\WikipaliApi\Model\ProblemDetails
+     */
+    public function getApiV3PaliWordFormsWord($word, string $contentType = self::contentTypes['getApiV3PaliWordFormsWord'][0])
+    {
+        list($response) = $this->getApiV3PaliWordFormsWordWithHttpInfo($word, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation getApiV3PaliWordFormsWordWithHttpInfo
+     *
+     * 词形展开
+     *
+     * @param  string $word 巴利词,如 vitakka (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordFormsWord'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\GetApiV3PaliWordFormsWord200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function getApiV3PaliWordFormsWordWithHttpInfo($word, string $contentType = self::contentTypes['getApiV3PaliWordFormsWord'][0])
+    {
+        $request = $this->getApiV3PaliWordFormsWordRequest($word, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\GetApiV3PaliWordFormsWord200Response',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\GetApiV3PaliWordFormsWord200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\GetApiV3PaliWordFormsWord200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation getApiV3PaliWordFormsWordAsync
+     *
+     * 词形展开
+     *
+     * @param  string $word 巴利词,如 vitakka (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordFormsWord'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3PaliWordFormsWordAsync($word, string $contentType = self::contentTypes['getApiV3PaliWordFormsWord'][0])
+    {
+        return $this->getApiV3PaliWordFormsWordAsyncWithHttpInfo($word, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation getApiV3PaliWordFormsWordAsyncWithHttpInfo
+     *
+     * 词形展开
+     *
+     * @param  string $word 巴利词,如 vitakka (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordFormsWord'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3PaliWordFormsWordAsyncWithHttpInfo($word, string $contentType = self::contentTypes['getApiV3PaliWordFormsWord'][0])
+    {
+        $returnType = '\WikipaliApi\Model\GetApiV3PaliWordFormsWord200Response';
+        $request = $this->getApiV3PaliWordFormsWordRequest($word, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'getApiV3PaliWordFormsWord'
+     *
+     * @param  string $word 巴利词,如 vitakka (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordFormsWord'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function getApiV3PaliWordFormsWordRequest($word, string $contentType = self::contentTypes['getApiV3PaliWordFormsWord'][0])
+    {
+
+        // verify the required parameter 'word' is set
+        if ($word === null || (is_array($word) && count($word) === 0)) {
+            throw new \InvalidArgumentException(
+                'Missing the required parameter $word when calling getApiV3PaliWordFormsWord'
+            );
+        }
+
+
+        $resourcePath = '/v3/pali-word-forms/{word}';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+
+
+        // path params
+        if ($word !== null) {
+            $resourcePath = str_replace(
+                '{word}',
+                ObjectSerializer::toPathValue($word),
+                $resourcePath
+            );
+        }
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'GET',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Create http client option
+     *
+     * @throws \RuntimeException on file opening failure
+     * @return array of http client options
+     */
+    protected function createHttpClientOption()
+    {
+        $options = [];
+        if ($this->config->getDebug()) {
+            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
+            if (!$options[RequestOptions::DEBUG]) {
+                throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
+            }
+        }
+
+        if ($this->config->getCertFile()) {
+            $options[RequestOptions::CERT] = $this->config->getCertFile();
+        }
+
+        if ($this->config->getKeyFile()) {
+            $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
+        }
+
+        return $options;
+    }
+
+    private function handleResponseWithDataType(
+        string $dataType,
+        RequestInterface $request,
+        ResponseInterface $response
+    ): array {
+        if ($dataType === '\SplFileObject') {
+            $content = $response->getBody(); //stream goes to serializer
+        } else {
+            $content = (string) $response->getBody();
+            if ($dataType !== 'string') {
+                try {
+                    $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $exception) {
+                    throw new ApiException(
+                        sprintf(
+                            'Error JSON decoding server response (%s)',
+                            $request->getUri()
+                        ),
+                        $response->getStatusCode(),
+                        $response->getHeaders(),
+                        $content
+                    );
+                }
+            }
+        }
+
+        return [
+            ObjectSerializer::deserialize($content, $dataType, []),
+            $response->getStatusCode(),
+            $response->getHeaders()
+        ];
+    }
+
+    private function responseWithinRangeCode(
+        string $rangeCode,
+        int $statusCode
+    ): bool {
+        $left = (int) ($rangeCode[0].'00');
+        $right = (int) ($rangeCode[0].'99');
+
+        return $statusCode >= $left && $statusCode <= $right;
+    }
+}

+ 503 - 0
api-test/client/lib/Api/PaliWordSuggestionsApi.php

@@ -0,0 +1,503 @@
+<?php
+/**
+ * PaliWordSuggestionsApi
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Api;
+
+use GuzzleHttp\Client;
+use GuzzleHttp\ClientInterface;
+use GuzzleHttp\Exception\ConnectException;
+use GuzzleHttp\Exception\RequestException;
+use GuzzleHttp\Psr7\MultipartStream;
+use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
+use WikipaliApi\ApiException;
+use WikipaliApi\Configuration;
+use WikipaliApi\FormDataProcessor;
+use WikipaliApi\HeaderSelector;
+use WikipaliApi\ObjectSerializer;
+
+/**
+ * PaliWordSuggestionsApi Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+class PaliWordSuggestionsApi
+{
+    /**
+     * @var ClientInterface
+     */
+    protected $client;
+
+    /**
+     * @var Configuration
+     */
+    protected $config;
+
+    /**
+     * @var HeaderSelector
+     */
+    protected $headerSelector;
+
+    /**
+     * @var int Host index
+     */
+    protected $hostIndex;
+
+    /** @var string[] $contentTypes **/
+    public const contentTypes = [
+        'getApiV3PaliWordSuggestions' => [
+            'application/json',
+        ],
+    ];
+
+    /**
+     * @param ClientInterface $client
+     * @param Configuration   $config
+     * @param HeaderSelector  $selector
+     * @param int             $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
+     */
+    public function __construct(
+        ?ClientInterface $client = null,
+        ?Configuration $config = null,
+        ?HeaderSelector $selector = null,
+        int $hostIndex = 0
+    ) {
+        $this->client = $client ?: new Client();
+        $this->config = $config ?: Configuration::getDefaultConfiguration();
+        $this->headerSelector = $selector ?: new HeaderSelector();
+        $this->hostIndex = $hostIndex;
+    }
+
+    /**
+     * Set the host index
+     *
+     * @param int $hostIndex Host index (required)
+     */
+    public function setHostIndex($hostIndex): void
+    {
+        $this->hostIndex = $hostIndex;
+    }
+
+    /**
+     * Get the host index
+     *
+     * @return int Host index
+     */
+    public function getHostIndex()
+    {
+        return $this->hostIndex;
+    }
+
+    /**
+     * @return Configuration
+     */
+    public function getConfig()
+    {
+        return $this->config;
+    }
+
+    /**
+     * Operation getApiV3PaliWordSuggestions
+     *
+     * 巴利词补全
+     *
+     * @param  string $q 已输入的前缀 (required)
+     * @param  int|null $limit 最多返回几条,上限 50 (optional, default to 10)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordSuggestions'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\GetApiV3PaliWordSuggestions200Response|\WikipaliApi\Model\ProblemDetails
+     */
+    public function getApiV3PaliWordSuggestions($q, $limit = 10, string $contentType = self::contentTypes['getApiV3PaliWordSuggestions'][0])
+    {
+        list($response) = $this->getApiV3PaliWordSuggestionsWithHttpInfo($q, $limit, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation getApiV3PaliWordSuggestionsWithHttpInfo
+     *
+     * 巴利词补全
+     *
+     * @param  string $q 已输入的前缀 (required)
+     * @param  int|null $limit 最多返回几条,上限 50 (optional, default to 10)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordSuggestions'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\GetApiV3PaliWordSuggestions200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function getApiV3PaliWordSuggestionsWithHttpInfo($q, $limit = 10, string $contentType = self::contentTypes['getApiV3PaliWordSuggestions'][0])
+    {
+        $request = $this->getApiV3PaliWordSuggestionsRequest($q, $limit, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\GetApiV3PaliWordSuggestions200Response',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\GetApiV3PaliWordSuggestions200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\GetApiV3PaliWordSuggestions200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation getApiV3PaliWordSuggestionsAsync
+     *
+     * 巴利词补全
+     *
+     * @param  string $q 已输入的前缀 (required)
+     * @param  int|null $limit 最多返回几条,上限 50 (optional, default to 10)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordSuggestions'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3PaliWordSuggestionsAsync($q, $limit = 10, string $contentType = self::contentTypes['getApiV3PaliWordSuggestions'][0])
+    {
+        return $this->getApiV3PaliWordSuggestionsAsyncWithHttpInfo($q, $limit, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation getApiV3PaliWordSuggestionsAsyncWithHttpInfo
+     *
+     * 巴利词补全
+     *
+     * @param  string $q 已输入的前缀 (required)
+     * @param  int|null $limit 最多返回几条,上限 50 (optional, default to 10)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordSuggestions'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3PaliWordSuggestionsAsyncWithHttpInfo($q, $limit = 10, string $contentType = self::contentTypes['getApiV3PaliWordSuggestions'][0])
+    {
+        $returnType = '\WikipaliApi\Model\GetApiV3PaliWordSuggestions200Response';
+        $request = $this->getApiV3PaliWordSuggestionsRequest($q, $limit, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'getApiV3PaliWordSuggestions'
+     *
+     * @param  string $q 已输入的前缀 (required)
+     * @param  int|null $limit 最多返回几条,上限 50 (optional, default to 10)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3PaliWordSuggestions'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function getApiV3PaliWordSuggestionsRequest($q, $limit = 10, string $contentType = self::contentTypes['getApiV3PaliWordSuggestions'][0])
+    {
+
+        // verify the required parameter 'q' is set
+        if ($q === null || (is_array($q) && count($q) === 0)) {
+            throw new \InvalidArgumentException(
+                'Missing the required parameter $q when calling getApiV3PaliWordSuggestions'
+            );
+        }
+
+
+
+        $resourcePath = '/v3/pali-word-suggestions';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $limit,
+            'limit', // param base name
+            'integer', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $q,
+            'q', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            true // required
+        ) ?? []);
+
+
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'GET',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Create http client option
+     *
+     * @throws \RuntimeException on file opening failure
+     * @return array of http client options
+     */
+    protected function createHttpClientOption()
+    {
+        $options = [];
+        if ($this->config->getDebug()) {
+            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
+            if (!$options[RequestOptions::DEBUG]) {
+                throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
+            }
+        }
+
+        if ($this->config->getCertFile()) {
+            $options[RequestOptions::CERT] = $this->config->getCertFile();
+        }
+
+        if ($this->config->getKeyFile()) {
+            $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
+        }
+
+        return $options;
+    }
+
+    private function handleResponseWithDataType(
+        string $dataType,
+        RequestInterface $request,
+        ResponseInterface $response
+    ): array {
+        if ($dataType === '\SplFileObject') {
+            $content = $response->getBody(); //stream goes to serializer
+        } else {
+            $content = (string) $response->getBody();
+            if ($dataType !== 'string') {
+                try {
+                    $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $exception) {
+                    throw new ApiException(
+                        sprintf(
+                            'Error JSON decoding server response (%s)',
+                            $request->getUri()
+                        ),
+                        $response->getStatusCode(),
+                        $response->getHeaders(),
+                        $content
+                    );
+                }
+            }
+        }
+
+        return [
+            ObjectSerializer::deserialize($content, $dataType, []),
+            $response->getStatusCode(),
+            $response->getHeaders()
+        ];
+    }
+
+    private function responseWithinRangeCode(
+        string $rangeCode,
+        int $statusCode
+    ): bool {
+        $left = (int) ($rangeCode[0].'00');
+        $right = (int) ($rangeCode[0].'99');
+
+        return $statusCode >= $left && $statusCode <= $right;
+    }
+}

+ 517 - 0
api-test/client/lib/Api/TipitakaPageNumbersApi.php

@@ -0,0 +1,517 @@
+<?php
+/**
+ * TipitakaPageNumbersApi
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Api;
+
+use GuzzleHttp\Client;
+use GuzzleHttp\ClientInterface;
+use GuzzleHttp\Exception\ConnectException;
+use GuzzleHttp\Exception\RequestException;
+use GuzzleHttp\Psr7\MultipartStream;
+use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
+use WikipaliApi\ApiException;
+use WikipaliApi\Configuration;
+use WikipaliApi\FormDataProcessor;
+use WikipaliApi\HeaderSelector;
+use WikipaliApi\ObjectSerializer;
+
+/**
+ * TipitakaPageNumbersApi Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+class TipitakaPageNumbersApi
+{
+    /**
+     * @var ClientInterface
+     */
+    protected $client;
+
+    /**
+     * @var Configuration
+     */
+    protected $config;
+
+    /**
+     * @var HeaderSelector
+     */
+    protected $headerSelector;
+
+    /**
+     * @var int Host index
+     */
+    protected $hostIndex;
+
+    /** @var string[] $contentTypes **/
+    public const contentTypes = [
+        'getApiV3TipitakaPageNumbersPage' => [
+            'application/json',
+        ],
+    ];
+
+    /**
+     * @param ClientInterface $client
+     * @param Configuration   $config
+     * @param HeaderSelector  $selector
+     * @param int             $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
+     */
+    public function __construct(
+        ?ClientInterface $client = null,
+        ?Configuration $config = null,
+        ?HeaderSelector $selector = null,
+        int $hostIndex = 0
+    ) {
+        $this->client = $client ?: new Client();
+        $this->config = $config ?: Configuration::getDefaultConfiguration();
+        $this->headerSelector = $selector ?: new HeaderSelector();
+        $this->hostIndex = $hostIndex;
+    }
+
+    /**
+     * Set the host index
+     *
+     * @param int $hostIndex Host index (required)
+     */
+    public function setHostIndex($hostIndex): void
+    {
+        $this->hostIndex = $hostIndex;
+    }
+
+    /**
+     * Get the host index
+     *
+     * @return int Host index
+     */
+    public function getHostIndex()
+    {
+        return $this->hostIndex;
+    }
+
+    /**
+     * @return Configuration
+     */
+    public function getConfig()
+    {
+        return $this->config;
+    }
+
+    /**
+     * Operation getApiV3TipitakaPageNumbersPage
+     *
+     * 按页码找段落
+     *
+     * @param  int $page 页码(或 CS 段落号) (required)
+     * @param  string|null $edition 只要这个版本 (optional)
+     * @param  int|null $volume 只要这一卷 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaPageNumbersPage'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200Response|\WikipaliApi\Model\ProblemDetails
+     */
+    public function getApiV3TipitakaPageNumbersPage($page, $edition = null, $volume = null, string $contentType = self::contentTypes['getApiV3TipitakaPageNumbersPage'][0])
+    {
+        list($response) = $this->getApiV3TipitakaPageNumbersPageWithHttpInfo($page, $edition, $volume, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation getApiV3TipitakaPageNumbersPageWithHttpInfo
+     *
+     * 按页码找段落
+     *
+     * @param  int $page 页码(或 CS 段落号) (required)
+     * @param  string|null $edition 只要这个版本 (optional)
+     * @param  int|null $volume 只要这一卷 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaPageNumbersPage'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function getApiV3TipitakaPageNumbersPageWithHttpInfo($page, $edition = null, $volume = null, string $contentType = self::contentTypes['getApiV3TipitakaPageNumbersPage'][0])
+    {
+        $request = $this->getApiV3TipitakaPageNumbersPageRequest($page, $edition, $volume, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200Response',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation getApiV3TipitakaPageNumbersPageAsync
+     *
+     * 按页码找段落
+     *
+     * @param  int $page 页码(或 CS 段落号) (required)
+     * @param  string|null $edition 只要这个版本 (optional)
+     * @param  int|null $volume 只要这一卷 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaPageNumbersPage'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3TipitakaPageNumbersPageAsync($page, $edition = null, $volume = null, string $contentType = self::contentTypes['getApiV3TipitakaPageNumbersPage'][0])
+    {
+        return $this->getApiV3TipitakaPageNumbersPageAsyncWithHttpInfo($page, $edition, $volume, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation getApiV3TipitakaPageNumbersPageAsyncWithHttpInfo
+     *
+     * 按页码找段落
+     *
+     * @param  int $page 页码(或 CS 段落号) (required)
+     * @param  string|null $edition 只要这个版本 (optional)
+     * @param  int|null $volume 只要这一卷 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaPageNumbersPage'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3TipitakaPageNumbersPageAsyncWithHttpInfo($page, $edition = null, $volume = null, string $contentType = self::contentTypes['getApiV3TipitakaPageNumbersPage'][0])
+    {
+        $returnType = '\WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200Response';
+        $request = $this->getApiV3TipitakaPageNumbersPageRequest($page, $edition, $volume, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'getApiV3TipitakaPageNumbersPage'
+     *
+     * @param  int $page 页码(或 CS 段落号) (required)
+     * @param  string|null $edition 只要这个版本 (optional)
+     * @param  int|null $volume 只要这一卷 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaPageNumbersPage'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function getApiV3TipitakaPageNumbersPageRequest($page, $edition = null, $volume = null, string $contentType = self::contentTypes['getApiV3TipitakaPageNumbersPage'][0])
+    {
+
+        // verify the required parameter 'page' is set
+        if ($page === null || (is_array($page) && count($page) === 0)) {
+            throw new \InvalidArgumentException(
+                'Missing the required parameter $page when calling getApiV3TipitakaPageNumbersPage'
+            );
+        }
+
+
+
+
+        $resourcePath = '/v3/tipitaka-page-numbers/{page}';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $edition,
+            'edition', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $volume,
+            'volume', // param base name
+            'integer', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+
+
+        // path params
+        if ($page !== null) {
+            $resourcePath = str_replace(
+                '{page}',
+                ObjectSerializer::toPathValue($page),
+                $resourcePath
+            );
+        }
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'GET',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Create http client option
+     *
+     * @throws \RuntimeException on file opening failure
+     * @return array of http client options
+     */
+    protected function createHttpClientOption()
+    {
+        $options = [];
+        if ($this->config->getDebug()) {
+            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
+            if (!$options[RequestOptions::DEBUG]) {
+                throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
+            }
+        }
+
+        if ($this->config->getCertFile()) {
+            $options[RequestOptions::CERT] = $this->config->getCertFile();
+        }
+
+        if ($this->config->getKeyFile()) {
+            $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
+        }
+
+        return $options;
+    }
+
+    private function handleResponseWithDataType(
+        string $dataType,
+        RequestInterface $request,
+        ResponseInterface $response
+    ): array {
+        if ($dataType === '\SplFileObject') {
+            $content = $response->getBody(); //stream goes to serializer
+        } else {
+            $content = (string) $response->getBody();
+            if ($dataType !== 'string') {
+                try {
+                    $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $exception) {
+                    throw new ApiException(
+                        sprintf(
+                            'Error JSON decoding server response (%s)',
+                            $request->getUri()
+                        ),
+                        $response->getStatusCode(),
+                        $response->getHeaders(),
+                        $content
+                    );
+                }
+            }
+        }
+
+        return [
+            ObjectSerializer::deserialize($content, $dataType, []),
+            $response->getStatusCode(),
+            $response->getHeaders()
+        ];
+    }
+
+    private function responseWithinRangeCode(
+        string $rangeCode,
+        int $statusCode
+    ): bool {
+        $left = (int) ($rangeCode[0].'00');
+        $right = (int) ($rangeCode[0].'99');
+
+        return $statusCode >= $left && $statusCode <= $right;
+    }
+}

+ 857 - 0
api-test/client/lib/Api/TipitakaWordParagraphsApi.php

@@ -0,0 +1,857 @@
+<?php
+/**
+ * TipitakaWordParagraphsApi
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Api;
+
+use GuzzleHttp\Client;
+use GuzzleHttp\ClientInterface;
+use GuzzleHttp\Exception\ConnectException;
+use GuzzleHttp\Exception\RequestException;
+use GuzzleHttp\Psr7\MultipartStream;
+use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
+use WikipaliApi\ApiException;
+use WikipaliApi\Configuration;
+use WikipaliApi\FormDataProcessor;
+use WikipaliApi\HeaderSelector;
+use WikipaliApi\ObjectSerializer;
+
+/**
+ * TipitakaWordParagraphsApi Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+class TipitakaWordParagraphsApi
+{
+    /**
+     * @var ClientInterface
+     */
+    protected $client;
+
+    /**
+     * @var Configuration
+     */
+    protected $config;
+
+    /**
+     * @var HeaderSelector
+     */
+    protected $headerSelector;
+
+    /**
+     * @var int Host index
+     */
+    protected $hostIndex;
+
+    /** @var string[] $contentTypes **/
+    public const contentTypes = [
+        'getApiV3TipitakaWordParagraphs' => [
+            'application/json',
+        ],
+        'getApiV3TipitakaWordParagraphsAggregate' => [
+            'application/json',
+        ],
+    ];
+
+    /**
+     * @param ClientInterface $client
+     * @param Configuration   $config
+     * @param HeaderSelector  $selector
+     * @param int             $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
+     */
+    public function __construct(
+        ?ClientInterface $client = null,
+        ?Configuration $config = null,
+        ?HeaderSelector $selector = null,
+        int $hostIndex = 0
+    ) {
+        $this->client = $client ?: new Client();
+        $this->config = $config ?: Configuration::getDefaultConfiguration();
+        $this->headerSelector = $selector ?: new HeaderSelector();
+        $this->hostIndex = $hostIndex;
+    }
+
+    /**
+     * Set the host index
+     *
+     * @param int $hostIndex Host index (required)
+     */
+    public function setHostIndex($hostIndex): void
+    {
+        $this->hostIndex = $hostIndex;
+    }
+
+    /**
+     * Get the host index
+     *
+     * @return int Host index
+     */
+    public function getHostIndex()
+    {
+        return $this->hostIndex;
+    }
+
+    /**
+     * @return Configuration
+     */
+    public function getConfig()
+    {
+        return $this->config;
+    }
+
+    /**
+     * Operation getApiV3TipitakaWordParagraphs
+     *
+     * 按词形找段落
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only,注释书里被解释的词)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string|null $book_id 只看这些书,逗号分隔的 book_id(见 &#x60;/aggregate&#x60;) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  int|null $per_page 每页条数,上限 100 (optional, default to 20)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphs'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200Response|\WikipaliApi\Model\ProblemDetails
+     */
+    public function getApiV3TipitakaWordParagraphs($words, $bold = null, $book_id = null, $page = 1, $per_page = 20, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphs'][0])
+    {
+        list($response) = $this->getApiV3TipitakaWordParagraphsWithHttpInfo($words, $bold, $book_id, $page, $per_page, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation getApiV3TipitakaWordParagraphsWithHttpInfo
+     *
+     * 按词形找段落
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only,注释书里被解释的词)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string|null $book_id 只看这些书,逗号分隔的 book_id(见 &#x60;/aggregate&#x60;) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  int|null $per_page 每页条数,上限 100 (optional, default to 20)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphs'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function getApiV3TipitakaWordParagraphsWithHttpInfo($words, $bold = null, $book_id = null, $page = 1, $per_page = 20, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphs'][0])
+    {
+        $request = $this->getApiV3TipitakaWordParagraphsRequest($words, $bold, $book_id, $page, $per_page, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200Response',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation getApiV3TipitakaWordParagraphsAsync
+     *
+     * 按词形找段落
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only,注释书里被解释的词)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string|null $book_id 只看这些书,逗号分隔的 book_id(见 &#x60;/aggregate&#x60;) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  int|null $per_page 每页条数,上限 100 (optional, default to 20)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphs'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3TipitakaWordParagraphsAsync($words, $bold = null, $book_id = null, $page = 1, $per_page = 20, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphs'][0])
+    {
+        return $this->getApiV3TipitakaWordParagraphsAsyncWithHttpInfo($words, $bold, $book_id, $page, $per_page, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation getApiV3TipitakaWordParagraphsAsyncWithHttpInfo
+     *
+     * 按词形找段落
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only,注释书里被解释的词)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string|null $book_id 只看这些书,逗号分隔的 book_id(见 &#x60;/aggregate&#x60;) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  int|null $per_page 每页条数,上限 100 (optional, default to 20)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphs'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3TipitakaWordParagraphsAsyncWithHttpInfo($words, $bold = null, $book_id = null, $page = 1, $per_page = 20, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphs'][0])
+    {
+        $returnType = '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200Response';
+        $request = $this->getApiV3TipitakaWordParagraphsRequest($words, $bold, $book_id, $page, $per_page, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'getApiV3TipitakaWordParagraphs'
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only,注释书里被解释的词)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string|null $book_id 只看这些书,逗号分隔的 book_id(见 &#x60;/aggregate&#x60;) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  int|null $per_page 每页条数,上限 100 (optional, default to 20)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphs'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function getApiV3TipitakaWordParagraphsRequest($words, $bold = null, $book_id = null, $page = 1, $per_page = 20, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphs'][0])
+    {
+
+        // verify the required parameter 'words' is set
+        if ($words === null || (is_array($words) && count($words) === 0)) {
+            throw new \InvalidArgumentException(
+                'Missing the required parameter $words when calling getApiV3TipitakaWordParagraphs'
+            );
+        }
+
+
+
+
+
+
+        $resourcePath = '/v3/tipitaka-word-paragraphs';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $words,
+            'words', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            true // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $bold,
+            'bold', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $book_id,
+            'book_id', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $page,
+            'page', // param base name
+            'integer', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $per_page,
+            'per_page', // param base name
+            'integer', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+
+
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'GET',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Operation getApiV3TipitakaWordParagraphsAggregate
+     *
+     * 按书统计命中
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200Response|\WikipaliApi\Model\ProblemDetails
+     */
+    public function getApiV3TipitakaWordParagraphsAggregate($words, $bold = null, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'][0])
+    {
+        list($response) = $this->getApiV3TipitakaWordParagraphsAggregateWithHttpInfo($words, $bold, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation getApiV3TipitakaWordParagraphsAggregateWithHttpInfo
+     *
+     * 按书统计命中
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function getApiV3TipitakaWordParagraphsAggregateWithHttpInfo($words, $bold = null, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'][0])
+    {
+        $request = $this->getApiV3TipitakaWordParagraphsAggregateRequest($words, $bold, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200Response',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation getApiV3TipitakaWordParagraphsAggregateAsync
+     *
+     * 按书统计命中
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3TipitakaWordParagraphsAggregateAsync($words, $bold = null, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'][0])
+    {
+        return $this->getApiV3TipitakaWordParagraphsAggregateAsyncWithHttpInfo($words, $bold, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation getApiV3TipitakaWordParagraphsAggregateAsyncWithHttpInfo
+     *
+     * 按书统计命中
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3TipitakaWordParagraphsAggregateAsyncWithHttpInfo($words, $bold = null, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'][0])
+    {
+        $returnType = '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200Response';
+        $request = $this->getApiV3TipitakaWordParagraphsAggregateRequest($words, $bold, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'getApiV3TipitakaWordParagraphsAggregate'
+     *
+     * @param  string $words 词形,逗号分隔,最多 200 个 (required)
+     * @param  string|null $bold 只看黑体(only)或排除黑体(exclude);不给则不限 (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function getApiV3TipitakaWordParagraphsAggregateRequest($words, $bold = null, string $contentType = self::contentTypes['getApiV3TipitakaWordParagraphsAggregate'][0])
+    {
+
+        // verify the required parameter 'words' is set
+        if ($words === null || (is_array($words) && count($words) === 0)) {
+            throw new \InvalidArgumentException(
+                'Missing the required parameter $words when calling getApiV3TipitakaWordParagraphsAggregate'
+            );
+        }
+
+
+
+        $resourcePath = '/v3/tipitaka-word-paragraphs/aggregate';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $words,
+            'words', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            true // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $bold,
+            'bold', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+
+
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'GET',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Create http client option
+     *
+     * @throws \RuntimeException on file opening failure
+     * @return array of http client options
+     */
+    protected function createHttpClientOption()
+    {
+        $options = [];
+        if ($this->config->getDebug()) {
+            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
+            if (!$options[RequestOptions::DEBUG]) {
+                throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
+            }
+        }
+
+        if ($this->config->getCertFile()) {
+            $options[RequestOptions::CERT] = $this->config->getCertFile();
+        }
+
+        if ($this->config->getKeyFile()) {
+            $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
+        }
+
+        return $options;
+    }
+
+    private function handleResponseWithDataType(
+        string $dataType,
+        RequestInterface $request,
+        ResponseInterface $response
+    ): array {
+        if ($dataType === '\SplFileObject') {
+            $content = $response->getBody(); //stream goes to serializer
+        } else {
+            $content = (string) $response->getBody();
+            if ($dataType !== 'string') {
+                try {
+                    $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $exception) {
+                    throw new ApiException(
+                        sprintf(
+                            'Error JSON decoding server response (%s)',
+                            $request->getUri()
+                        ),
+                        $response->getStatusCode(),
+                        $response->getHeaders(),
+                        $content
+                    );
+                }
+            }
+        }
+
+        return [
+            ObjectSerializer::deserialize($content, $dataType, []),
+            $response->getStatusCode(),
+            $response->getHeaders()
+        ];
+    }
+
+    private function responseWithinRangeCode(
+        string $rangeCode,
+        int $statusCode
+    ): bool {
+        $left = (int) ($rangeCode[0].'00');
+        $right = (int) ($rangeCode[0].'99');
+
+        return $statusCode >= $left && $statusCode <= $right;
+    }
+}

+ 443 - 0
api-test/client/lib/Model/GetApiV3PaliWordFormsWord200Response.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * GetApiV3PaliWordFormsWord200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3PaliWordFormsWord200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3PaliWordFormsWord200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_pali_word_forms_word__200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInner[]',
+        'meta' => '\WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseMeta'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null,
+        'meta' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false,
+        'meta' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data',
+        'meta' => 'meta'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData',
+        'meta' => 'setMeta'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData',
+        'meta' => 'getMeta'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+        $this->setIfExists('meta', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInner[]|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInner[]|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+
+    /**
+     * Gets meta
+     *
+     * @return \WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseMeta|null
+     */
+    public function getMeta()
+    {
+        return $this->container['meta'];
+    }
+
+    /**
+     * Sets meta
+     *
+     * @param \WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseMeta|null $meta meta
+     *
+     * @return self
+     */
+    public function setMeta($meta)
+    {
+        if (is_null($meta)) {
+            throw new \InvalidArgumentException('non-nullable meta cannot be null');
+        }
+        $this->container['meta'] = $meta;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 443 - 0
api-test/client/lib/Model/GetApiV3PaliWordFormsWord200ResponseDataInner.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * GetApiV3PaliWordFormsWord200ResponseDataInner
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3PaliWordFormsWord200ResponseDataInner Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3PaliWordFormsWord200ResponseDataInner implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_pali_word_forms_word__200_response_data_inner';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'base' => 'string',
+        'forms' => '\WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner[]'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'base' => null,
+        'forms' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'base' => false,
+        'forms' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'base' => 'base',
+        'forms' => 'forms'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'base' => 'setBase',
+        'forms' => 'setForms'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'base' => 'getBase',
+        'forms' => 'getForms'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('base', $data ?? [], null);
+        $this->setIfExists('forms', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets base
+     *
+     * @return string|null
+     */
+    public function getBase()
+    {
+        return $this->container['base'];
+    }
+
+    /**
+     * Sets base
+     *
+     * @param string|null $base base
+     *
+     * @return self
+     */
+    public function setBase($base)
+    {
+        if (is_null($base)) {
+            throw new \InvalidArgumentException('non-nullable base cannot be null');
+        }
+        $this->container['base'] = $base;
+
+        return $this;
+    }
+
+    /**
+     * Gets forms
+     *
+     * @return \WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner[]|null
+     */
+    public function getForms()
+    {
+        return $this->container['forms'];
+    }
+
+    /**
+     * Sets forms
+     *
+     * @param \WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner[]|null $forms forms
+     *
+     * @return self
+     */
+    public function setForms($forms)
+    {
+        if (is_null($forms)) {
+            throw new \InvalidArgumentException('non-nullable forms cannot be null');
+        }
+        $this->container['forms'] = $forms;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 477 - 0
api-test/client/lib/Model/GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner.php

@@ -0,0 +1,477 @@
+<?php
+/**
+ * GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_pali_word_forms_word__200_response_data_inner_forms_inner';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'word' => 'string',
+        'count' => 'int',
+        'bold' => 'int'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'word' => null,
+        'count' => null,
+        'bold' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'word' => false,
+        'count' => false,
+        'bold' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'word' => 'word',
+        'count' => 'count',
+        'bold' => 'bold'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'word' => 'setWord',
+        'count' => 'setCount',
+        'bold' => 'setBold'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'word' => 'getWord',
+        'count' => 'getCount',
+        'bold' => 'getBold'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('word', $data ?? [], null);
+        $this->setIfExists('count', $data ?? [], null);
+        $this->setIfExists('bold', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets word
+     *
+     * @return string|null
+     */
+    public function getWord()
+    {
+        return $this->container['word'];
+    }
+
+    /**
+     * Sets word
+     *
+     * @param string|null $word word
+     *
+     * @return self
+     */
+    public function setWord($word)
+    {
+        if (is_null($word)) {
+            throw new \InvalidArgumentException('non-nullable word cannot be null');
+        }
+        $this->container['word'] = $word;
+
+        return $this;
+    }
+
+    /**
+     * Gets count
+     *
+     * @return int|null
+     */
+    public function getCount()
+    {
+        return $this->container['count'];
+    }
+
+    /**
+     * Sets count
+     *
+     * @param int|null $count count
+     *
+     * @return self
+     */
+    public function setCount($count)
+    {
+        if (is_null($count)) {
+            throw new \InvalidArgumentException('non-nullable count cannot be null');
+        }
+        $this->container['count'] = $count;
+
+        return $this;
+    }
+
+    /**
+     * Gets bold
+     *
+     * @return int|null
+     */
+    public function getBold()
+    {
+        return $this->container['bold'];
+    }
+
+    /**
+     * Sets bold
+     *
+     * @param int|null $bold bold
+     *
+     * @return self
+     */
+    public function setBold($bold)
+    {
+        if (is_null($bold)) {
+            throw new \InvalidArgumentException('non-nullable bold cannot be null');
+        }
+        $this->container['bold'] = $bold;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 409 - 0
api-test/client/lib/Model/GetApiV3PaliWordFormsWord200ResponseMeta.php

@@ -0,0 +1,409 @@
+<?php
+/**
+ * GetApiV3PaliWordFormsWord200ResponseMeta
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3PaliWordFormsWord200ResponseMeta Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3PaliWordFormsWord200ResponseMeta implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_pali_word_forms_word__200_response_meta';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'total' => 'int'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'total' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'total' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'total' => 'total'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'total' => 'setTotal'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'total' => 'getTotal'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('total', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets total
+     *
+     * @return int|null
+     */
+    public function getTotal()
+    {
+        return $this->container['total'];
+    }
+
+    /**
+     * Sets total
+     *
+     * @param int|null $total 组数
+     *
+     * @return self
+     */
+    public function setTotal($total)
+    {
+        if (is_null($total)) {
+            throw new \InvalidArgumentException('non-nullable total cannot be null');
+        }
+        $this->container['total'] = $total;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 443 - 0
api-test/client/lib/Model/GetApiV3PaliWordSuggestions200Response.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * GetApiV3PaliWordSuggestions200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3PaliWordSuggestions200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3PaliWordSuggestions200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_pali_word_suggestions_200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner[]',
+        'meta' => '\WikipaliApi\Model\GetApiV3PaliWordSuggestions200ResponseMeta'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null,
+        'meta' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false,
+        'meta' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data',
+        'meta' => 'meta'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData',
+        'meta' => 'setMeta'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData',
+        'meta' => 'getMeta'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+        $this->setIfExists('meta', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner[]|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\GetApiV3PaliWordFormsWord200ResponseDataInnerFormsInner[]|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+
+    /**
+     * Gets meta
+     *
+     * @return \WikipaliApi\Model\GetApiV3PaliWordSuggestions200ResponseMeta|null
+     */
+    public function getMeta()
+    {
+        return $this->container['meta'];
+    }
+
+    /**
+     * Sets meta
+     *
+     * @param \WikipaliApi\Model\GetApiV3PaliWordSuggestions200ResponseMeta|null $meta meta
+     *
+     * @return self
+     */
+    public function setMeta($meta)
+    {
+        if (is_null($meta)) {
+            throw new \InvalidArgumentException('non-nullable meta cannot be null');
+        }
+        $this->container['meta'] = $meta;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 4 - 4
api-test/client/lib/Model/GetApiV3SearchSuggestions200ResponseMeta.php → api-test/client/lib/Model/GetApiV3PaliWordSuggestions200ResponseMeta.php

@@ -1,6 +1,6 @@
 <?php
 /**
- * GetApiV3SearchSuggestions200ResponseMeta
+ * GetApiV3PaliWordSuggestions200ResponseMeta
  *
  * PHP version 8.1
  *
@@ -32,7 +32,7 @@ use \ArrayAccess;
 use \WikipaliApi\ObjectSerializer;
 
 /**
- * GetApiV3SearchSuggestions200ResponseMeta Class Doc Comment
+ * GetApiV3PaliWordSuggestions200ResponseMeta Class Doc Comment
  *
  * @category Class
  * @package  WikipaliApi
@@ -40,7 +40,7 @@ use \WikipaliApi\ObjectSerializer;
  * @link     https://openapi-generator.tech
  * @implements \ArrayAccess<string, mixed>
  */
-class GetApiV3SearchSuggestions200ResponseMeta implements ModelInterface, ArrayAccess, \JsonSerializable
+class GetApiV3PaliWordSuggestions200ResponseMeta implements ModelInterface, ArrayAccess, \JsonSerializable
 {
     public const DISCRIMINATOR = null;
 
@@ -49,7 +49,7 @@ class GetApiV3SearchSuggestions200ResponseMeta implements ModelInterface, ArrayA
      *
      * @var string
      */
-    protected static $openAPIModelName = 'get_api_v3_search_suggestions_200_response_meta';
+    protected static $openAPIModelName = 'get_api_v3_pali_word_suggestions_200_response_meta';
 
     /**
      * Array of property to type mappings. Used for (de)serialization

+ 3 - 3
api-test/client/lib/Model/GetApiV3SearchSuggestions200Response.php

@@ -58,7 +58,7 @@ class GetApiV3SearchSuggestions200Response implements ModelInterface, ArrayAcces
      */
     protected static $openAPITypes = [
         'data' => '\WikipaliApi\Model\GetApiV3SearchSuggestions200ResponseDataInner[]',
-        'meta' => '\WikipaliApi\Model\GetApiV3SearchSuggestions200ResponseMeta'
+        'meta' => '\WikipaliApi\Model\GetApiV3PaliWordSuggestions200ResponseMeta'
     ];
 
     /**
@@ -326,7 +326,7 @@ class GetApiV3SearchSuggestions200Response implements ModelInterface, ArrayAcces
     /**
      * Gets meta
      *
-     * @return \WikipaliApi\Model\GetApiV3SearchSuggestions200ResponseMeta|null
+     * @return \WikipaliApi\Model\GetApiV3PaliWordSuggestions200ResponseMeta|null
      */
     public function getMeta()
     {
@@ -336,7 +336,7 @@ class GetApiV3SearchSuggestions200Response implements ModelInterface, ArrayAcces
     /**
      * Sets meta
      *
-     * @param \WikipaliApi\Model\GetApiV3SearchSuggestions200ResponseMeta|null $meta meta
+     * @param \WikipaliApi\Model\GetApiV3PaliWordSuggestions200ResponseMeta|null $meta meta
      *
      * @return self
      */

+ 443 - 0
api-test/client/lib/Model/GetApiV3TipitakaPageNumbersPage200Response.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * GetApiV3TipitakaPageNumbersPage200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaPageNumbersPage200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaPageNumbersPage200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_page_numbers_page__200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200ResponseDataInner[]',
+        'meta' => '\WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200ResponseMeta'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null,
+        'meta' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false,
+        'meta' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data',
+        'meta' => 'meta'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData',
+        'meta' => 'setMeta'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData',
+        'meta' => 'getMeta'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+        $this->setIfExists('meta', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200ResponseDataInner[]|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200ResponseDataInner[]|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+
+    /**
+     * Gets meta
+     *
+     * @return \WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200ResponseMeta|null
+     */
+    public function getMeta()
+    {
+        return $this->container['meta'];
+    }
+
+    /**
+     * Sets meta
+     *
+     * @param \WikipaliApi\Model\GetApiV3TipitakaPageNumbersPage200ResponseMeta|null $meta meta
+     *
+     * @return self
+     */
+    public function setMeta($meta)
+    {
+        if (is_null($meta)) {
+            throw new \InvalidArgumentException('non-nullable meta cannot be null');
+        }
+        $this->container['meta'] = $meta;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 770 - 0
api-test/client/lib/Model/GetApiV3TipitakaPageNumbersPage200ResponseDataInner.php

@@ -0,0 +1,770 @@
+<?php
+/**
+ * GetApiV3TipitakaPageNumbersPage200ResponseDataInner
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaPageNumbersPage200ResponseDataInner Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaPageNumbersPage200ResponseDataInner implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_page_numbers_page__200_response_data_inner';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'edition' => 'string',
+        'volume' => 'int',
+        'page' => 'int',
+        'book' => 'int',
+        'para' => 'int',
+        'book_id' => 'int',
+        'book_title' => 'string',
+        'book_para' => 'int',
+        'edition_title' => 'string',
+        'layer' => 'string',
+        'tags' => 'string[]'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'edition' => null,
+        'volume' => null,
+        'page' => null,
+        'book' => null,
+        'para' => null,
+        'book_id' => null,
+        'book_title' => null,
+        'book_para' => null,
+        'edition_title' => null,
+        'layer' => null,
+        'tags' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'edition' => false,
+        'volume' => true,
+        'page' => false,
+        'book' => false,
+        'para' => false,
+        'book_id' => false,
+        'book_title' => false,
+        'book_para' => false,
+        'edition_title' => true,
+        'layer' => true,
+        'tags' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'edition' => 'edition',
+        'volume' => 'volume',
+        'page' => 'page',
+        'book' => 'book',
+        'para' => 'para',
+        'book_id' => 'book_id',
+        'book_title' => 'book_title',
+        'book_para' => 'book_para',
+        'edition_title' => 'edition_title',
+        'layer' => 'layer',
+        'tags' => 'tags'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'edition' => 'setEdition',
+        'volume' => 'setVolume',
+        'page' => 'setPage',
+        'book' => 'setBook',
+        'para' => 'setPara',
+        'book_id' => 'setBookId',
+        'book_title' => 'setBookTitle',
+        'book_para' => 'setBookPara',
+        'edition_title' => 'setEditionTitle',
+        'layer' => 'setLayer',
+        'tags' => 'setTags'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'edition' => 'getEdition',
+        'volume' => 'getVolume',
+        'page' => 'getPage',
+        'book' => 'getBook',
+        'para' => 'getPara',
+        'book_id' => 'getBookId',
+        'book_title' => 'getBookTitle',
+        'book_para' => 'getBookPara',
+        'edition_title' => 'getEditionTitle',
+        'layer' => 'getLayer',
+        'tags' => 'getTags'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('edition', $data ?? [], null);
+        $this->setIfExists('volume', $data ?? [], null);
+        $this->setIfExists('page', $data ?? [], null);
+        $this->setIfExists('book', $data ?? [], null);
+        $this->setIfExists('para', $data ?? [], null);
+        $this->setIfExists('book_id', $data ?? [], null);
+        $this->setIfExists('book_title', $data ?? [], null);
+        $this->setIfExists('book_para', $data ?? [], null);
+        $this->setIfExists('edition_title', $data ?? [], null);
+        $this->setIfExists('layer', $data ?? [], null);
+        $this->setIfExists('tags', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets edition
+     *
+     * @return string|null
+     */
+    public function getEdition()
+    {
+        return $this->container['edition'];
+    }
+
+    /**
+     * Sets edition
+     *
+     * @param string|null $edition edition
+     *
+     * @return self
+     */
+    public function setEdition($edition)
+    {
+        if (is_null($edition)) {
+            throw new \InvalidArgumentException('non-nullable edition cannot be null');
+        }
+        $this->container['edition'] = $edition;
+
+        return $this;
+    }
+
+    /**
+     * Gets volume
+     *
+     * @return int|null
+     */
+    public function getVolume()
+    {
+        return $this->container['volume'];
+    }
+
+    /**
+     * Sets volume
+     *
+     * @param int|null $volume volume
+     *
+     * @return self
+     */
+    public function setVolume($volume)
+    {
+        if (is_null($volume)) {
+            array_push($this->openAPINullablesSetToNull, 'volume');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('volume', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['volume'] = $volume;
+
+        return $this;
+    }
+
+    /**
+     * Gets page
+     *
+     * @return int|null
+     */
+    public function getPage()
+    {
+        return $this->container['page'];
+    }
+
+    /**
+     * Sets page
+     *
+     * @param int|null $page page
+     *
+     * @return self
+     */
+    public function setPage($page)
+    {
+        if (is_null($page)) {
+            throw new \InvalidArgumentException('non-nullable page cannot be null');
+        }
+        $this->container['page'] = $page;
+
+        return $this;
+    }
+
+    /**
+     * Gets book
+     *
+     * @return int|null
+     */
+    public function getBook()
+    {
+        return $this->container['book'];
+    }
+
+    /**
+     * Sets book
+     *
+     * @param int|null $book book
+     *
+     * @return self
+     */
+    public function setBook($book)
+    {
+        if (is_null($book)) {
+            throw new \InvalidArgumentException('non-nullable book cannot be null');
+        }
+        $this->container['book'] = $book;
+
+        return $this;
+    }
+
+    /**
+     * Gets para
+     *
+     * @return int|null
+     */
+    public function getPara()
+    {
+        return $this->container['para'];
+    }
+
+    /**
+     * Sets para
+     *
+     * @param int|null $para para
+     *
+     * @return self
+     */
+    public function setPara($para)
+    {
+        if (is_null($para)) {
+            throw new \InvalidArgumentException('non-nullable para cannot be null');
+        }
+        $this->container['para'] = $para;
+
+        return $this;
+    }
+
+    /**
+     * Gets book_id
+     *
+     * @return int|null
+     */
+    public function getBookId()
+    {
+        return $this->container['book_id'];
+    }
+
+    /**
+     * Sets book_id
+     *
+     * @param int|null $book_id book_id
+     *
+     * @return self
+     */
+    public function setBookId($book_id)
+    {
+        if (is_null($book_id)) {
+            throw new \InvalidArgumentException('non-nullable book_id cannot be null');
+        }
+        $this->container['book_id'] = $book_id;
+
+        return $this;
+    }
+
+    /**
+     * Gets book_title
+     *
+     * @return string|null
+     */
+    public function getBookTitle()
+    {
+        return $this->container['book_title'];
+    }
+
+    /**
+     * Sets book_title
+     *
+     * @param string|null $book_title book_title
+     *
+     * @return self
+     */
+    public function setBookTitle($book_title)
+    {
+        if (is_null($book_title)) {
+            throw new \InvalidArgumentException('non-nullable book_title cannot be null');
+        }
+        $this->container['book_title'] = $book_title;
+
+        return $this;
+    }
+
+    /**
+     * Gets book_para
+     *
+     * @return int|null
+     */
+    public function getBookPara()
+    {
+        return $this->container['book_para'];
+    }
+
+    /**
+     * Sets book_para
+     *
+     * @param int|null $book_para book_para
+     *
+     * @return self
+     */
+    public function setBookPara($book_para)
+    {
+        if (is_null($book_para)) {
+            throw new \InvalidArgumentException('non-nullable book_para cannot be null');
+        }
+        $this->container['book_para'] = $book_para;
+
+        return $this;
+    }
+
+    /**
+     * Gets edition_title
+     *
+     * @return string|null
+     */
+    public function getEditionTitle()
+    {
+        return $this->container['edition_title'];
+    }
+
+    /**
+     * Sets edition_title
+     *
+     * @param string|null $edition_title edition_title
+     *
+     * @return self
+     */
+    public function setEditionTitle($edition_title)
+    {
+        if (is_null($edition_title)) {
+            array_push($this->openAPINullablesSetToNull, 'edition_title');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('edition_title', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['edition_title'] = $edition_title;
+
+        return $this;
+    }
+
+    /**
+     * Gets layer
+     *
+     * @return string|null
+     */
+    public function getLayer()
+    {
+        return $this->container['layer'];
+    }
+
+    /**
+     * Sets layer
+     *
+     * @param string|null $layer layer
+     *
+     * @return self
+     */
+    public function setLayer($layer)
+    {
+        if (is_null($layer)) {
+            array_push($this->openAPINullablesSetToNull, 'layer');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('layer', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['layer'] = $layer;
+
+        return $this;
+    }
+
+    /**
+     * Gets tags
+     *
+     * @return string[]|null
+     */
+    public function getTags()
+    {
+        return $this->container['tags'];
+    }
+
+    /**
+     * Sets tags
+     *
+     * @param string[]|null $tags tags
+     *
+     * @return self
+     */
+    public function setTags($tags)
+    {
+        if (is_null($tags)) {
+            throw new \InvalidArgumentException('non-nullable tags cannot be null');
+        }
+        $this->container['tags'] = $tags;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 409 - 0
api-test/client/lib/Model/GetApiV3TipitakaPageNumbersPage200ResponseMeta.php

@@ -0,0 +1,409 @@
+<?php
+/**
+ * GetApiV3TipitakaPageNumbersPage200ResponseMeta
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaPageNumbersPage200ResponseMeta Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaPageNumbersPage200ResponseMeta implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_page_numbers_page__200_response_meta';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'total' => 'int'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'total' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'total' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'total' => 'total'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'total' => 'setTotal'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'total' => 'getTotal'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('total', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets total
+     *
+     * @return int|null
+     */
+    public function getTotal()
+    {
+        return $this->container['total'];
+    }
+
+    /**
+     * Sets total
+     *
+     * @param int|null $total 命中数
+     *
+     * @return self
+     */
+    public function setTotal($total)
+    {
+        if (is_null($total)) {
+            throw new \InvalidArgumentException('non-nullable total cannot be null');
+        }
+        $this->container['total'] = $total;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 443 - 0
api-test/client/lib/Model/GetApiV3TipitakaWordParagraphs200Response.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * GetApiV3TipitakaWordParagraphs200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaWordParagraphs200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaWordParagraphs200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_word_paragraphs_200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200ResponseDataInner[]',
+        'meta' => '\WikipaliApi\Model\PaginationMeta'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null,
+        'meta' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false,
+        'meta' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data',
+        'meta' => 'meta'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData',
+        'meta' => 'setMeta'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData',
+        'meta' => 'getMeta'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+        $this->setIfExists('meta', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200ResponseDataInner[]|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200ResponseDataInner[]|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+
+    /**
+     * Gets meta
+     *
+     * @return \WikipaliApi\Model\PaginationMeta|null
+     */
+    public function getMeta()
+    {
+        return $this->container['meta'];
+    }
+
+    /**
+     * Sets meta
+     *
+     * @param \WikipaliApi\Model\PaginationMeta|null $meta meta
+     *
+     * @return self
+     */
+    public function setMeta($meta)
+    {
+        if (is_null($meta)) {
+            throw new \InvalidArgumentException('non-nullable meta cannot be null');
+        }
+        $this->container['meta'] = $meta;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 715 - 0
api-test/client/lib/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInner.php

@@ -0,0 +1,715 @@
+<?php
+/**
+ * GetApiV3TipitakaWordParagraphs200ResponseDataInner
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaWordParagraphs200ResponseDataInner Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaWordParagraphs200ResponseDataInner implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_word_paragraphs_200_response_data_inner';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'id' => 'string',
+        'book' => 'int',
+        'para' => 'int',
+        'score' => 'int',
+        'hits' => 'int',
+        'title' => 'string',
+        'level' => 'int',
+        'path' => '\WikipaliApi\Model\GetApiV3TipitakaChapters200ResponseDataInnerPathInner[]',
+        'text' => 'string',
+        'refs' => '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner[]'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'id' => null,
+        'book' => null,
+        'para' => null,
+        'score' => null,
+        'hits' => null,
+        'title' => null,
+        'level' => null,
+        'path' => null,
+        'text' => null,
+        'refs' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'id' => false,
+        'book' => false,
+        'para' => false,
+        'score' => false,
+        'hits' => false,
+        'title' => false,
+        'level' => false,
+        'path' => false,
+        'text' => false,
+        'refs' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'id' => 'id',
+        'book' => 'book',
+        'para' => 'para',
+        'score' => 'score',
+        'hits' => 'hits',
+        'title' => 'title',
+        'level' => 'level',
+        'path' => 'path',
+        'text' => 'text',
+        'refs' => 'refs'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'id' => 'setId',
+        'book' => 'setBook',
+        'para' => 'setPara',
+        'score' => 'setScore',
+        'hits' => 'setHits',
+        'title' => 'setTitle',
+        'level' => 'setLevel',
+        'path' => 'setPath',
+        'text' => 'setText',
+        'refs' => 'setRefs'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'id' => 'getId',
+        'book' => 'getBook',
+        'para' => 'getPara',
+        'score' => 'getScore',
+        'hits' => 'getHits',
+        'title' => 'getTitle',
+        'level' => 'getLevel',
+        'path' => 'getPath',
+        'text' => 'getText',
+        'refs' => 'getRefs'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('id', $data ?? [], null);
+        $this->setIfExists('book', $data ?? [], null);
+        $this->setIfExists('para', $data ?? [], null);
+        $this->setIfExists('score', $data ?? [], null);
+        $this->setIfExists('hits', $data ?? [], null);
+        $this->setIfExists('title', $data ?? [], null);
+        $this->setIfExists('level', $data ?? [], null);
+        $this->setIfExists('path', $data ?? [], null);
+        $this->setIfExists('text', $data ?? [], null);
+        $this->setIfExists('refs', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets id
+     *
+     * @return string|null
+     */
+    public function getId()
+    {
+        return $this->container['id'];
+    }
+
+    /**
+     * Sets id
+     *
+     * @param string|null $id id
+     *
+     * @return self
+     */
+    public function setId($id)
+    {
+        if (is_null($id)) {
+            throw new \InvalidArgumentException('non-nullable id cannot be null');
+        }
+        $this->container['id'] = $id;
+
+        return $this;
+    }
+
+    /**
+     * Gets book
+     *
+     * @return int|null
+     */
+    public function getBook()
+    {
+        return $this->container['book'];
+    }
+
+    /**
+     * Sets book
+     *
+     * @param int|null $book book
+     *
+     * @return self
+     */
+    public function setBook($book)
+    {
+        if (is_null($book)) {
+            throw new \InvalidArgumentException('non-nullable book cannot be null');
+        }
+        $this->container['book'] = $book;
+
+        return $this;
+    }
+
+    /**
+     * Gets para
+     *
+     * @return int|null
+     */
+    public function getPara()
+    {
+        return $this->container['para'];
+    }
+
+    /**
+     * Sets para
+     *
+     * @param int|null $para para
+     *
+     * @return self
+     */
+    public function setPara($para)
+    {
+        if (is_null($para)) {
+            throw new \InvalidArgumentException('non-nullable para cannot be null');
+        }
+        $this->container['para'] = $para;
+
+        return $this;
+    }
+
+    /**
+     * Gets score
+     *
+     * @return int|null
+     */
+    public function getScore()
+    {
+        return $this->container['score'];
+    }
+
+    /**
+     * Sets score
+     *
+     * @param int|null $score score
+     *
+     * @return self
+     */
+    public function setScore($score)
+    {
+        if (is_null($score)) {
+            throw new \InvalidArgumentException('non-nullable score cannot be null');
+        }
+        $this->container['score'] = $score;
+
+        return $this;
+    }
+
+    /**
+     * Gets hits
+     *
+     * @return int|null
+     */
+    public function getHits()
+    {
+        return $this->container['hits'];
+    }
+
+    /**
+     * Sets hits
+     *
+     * @param int|null $hits hits
+     *
+     * @return self
+     */
+    public function setHits($hits)
+    {
+        if (is_null($hits)) {
+            throw new \InvalidArgumentException('non-nullable hits cannot be null');
+        }
+        $this->container['hits'] = $hits;
+
+        return $this;
+    }
+
+    /**
+     * Gets title
+     *
+     * @return string|null
+     */
+    public function getTitle()
+    {
+        return $this->container['title'];
+    }
+
+    /**
+     * Sets title
+     *
+     * @param string|null $title title
+     *
+     * @return self
+     */
+    public function setTitle($title)
+    {
+        if (is_null($title)) {
+            throw new \InvalidArgumentException('non-nullable title cannot be null');
+        }
+        $this->container['title'] = $title;
+
+        return $this;
+    }
+
+    /**
+     * Gets level
+     *
+     * @return int|null
+     */
+    public function getLevel()
+    {
+        return $this->container['level'];
+    }
+
+    /**
+     * Sets level
+     *
+     * @param int|null $level level
+     *
+     * @return self
+     */
+    public function setLevel($level)
+    {
+        if (is_null($level)) {
+            throw new \InvalidArgumentException('non-nullable level cannot be null');
+        }
+        $this->container['level'] = $level;
+
+        return $this;
+    }
+
+    /**
+     * Gets path
+     *
+     * @return \WikipaliApi\Model\GetApiV3TipitakaChapters200ResponseDataInnerPathInner[]|null
+     */
+    public function getPath()
+    {
+        return $this->container['path'];
+    }
+
+    /**
+     * Sets path
+     *
+     * @param \WikipaliApi\Model\GetApiV3TipitakaChapters200ResponseDataInnerPathInner[]|null $path path
+     *
+     * @return self
+     */
+    public function setPath($path)
+    {
+        if (is_null($path)) {
+            throw new \InvalidArgumentException('non-nullable path cannot be null');
+        }
+        $this->container['path'] = $path;
+
+        return $this;
+    }
+
+    /**
+     * Gets text
+     *
+     * @return string|null
+     */
+    public function getText()
+    {
+        return $this->container['text'];
+    }
+
+    /**
+     * Sets text
+     *
+     * @param string|null $text text
+     *
+     * @return self
+     */
+    public function setText($text)
+    {
+        if (is_null($text)) {
+            throw new \InvalidArgumentException('non-nullable text cannot be null');
+        }
+        $this->container['text'] = $text;
+
+        return $this;
+    }
+
+    /**
+     * Gets refs
+     *
+     * @return \WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner[]|null
+     */
+    public function getRefs()
+    {
+        return $this->container['refs'];
+    }
+
+    /**
+     * Sets refs
+     *
+     * @param \WikipaliApi\Model\GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner[]|null $refs refs
+     *
+     * @return self
+     */
+    public function setRefs($refs)
+    {
+        if (is_null($refs)) {
+            throw new \InvalidArgumentException('non-nullable refs cannot be null');
+        }
+        $this->container['refs'] = $refs;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 525 - 0
api-test/client/lib/Model/GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner.php

@@ -0,0 +1,525 @@
+<?php
+/**
+ * GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaWordParagraphs200ResponseDataInnerRefsInner implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_word_paragraphs_200_response_data_inner_refs_inner';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'type' => 'string',
+        'volume' => 'int',
+        'page' => 'int',
+        'title' => 'string'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'type' => null,
+        'volume' => null,
+        'page' => null,
+        'title' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'type' => false,
+        'volume' => true,
+        'page' => false,
+        'title' => true
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'type' => 'type',
+        'volume' => 'volume',
+        'page' => 'page',
+        'title' => 'title'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'type' => 'setType',
+        'volume' => 'setVolume',
+        'page' => 'setPage',
+        'title' => 'setTitle'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'type' => 'getType',
+        'volume' => 'getVolume',
+        'page' => 'getPage',
+        'title' => 'getTitle'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('type', $data ?? [], null);
+        $this->setIfExists('volume', $data ?? [], null);
+        $this->setIfExists('page', $data ?? [], null);
+        $this->setIfExists('title', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets type
+     *
+     * @return string|null
+     */
+    public function getType()
+    {
+        return $this->container['type'];
+    }
+
+    /**
+     * Sets type
+     *
+     * @param string|null $type type
+     *
+     * @return self
+     */
+    public function setType($type)
+    {
+        if (is_null($type)) {
+            throw new \InvalidArgumentException('non-nullable type cannot be null');
+        }
+        $this->container['type'] = $type;
+
+        return $this;
+    }
+
+    /**
+     * Gets volume
+     *
+     * @return int|null
+     */
+    public function getVolume()
+    {
+        return $this->container['volume'];
+    }
+
+    /**
+     * Sets volume
+     *
+     * @param int|null $volume volume
+     *
+     * @return self
+     */
+    public function setVolume($volume)
+    {
+        if (is_null($volume)) {
+            array_push($this->openAPINullablesSetToNull, 'volume');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('volume', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['volume'] = $volume;
+
+        return $this;
+    }
+
+    /**
+     * Gets page
+     *
+     * @return int|null
+     */
+    public function getPage()
+    {
+        return $this->container['page'];
+    }
+
+    /**
+     * Sets page
+     *
+     * @param int|null $page page
+     *
+     * @return self
+     */
+    public function setPage($page)
+    {
+        if (is_null($page)) {
+            throw new \InvalidArgumentException('non-nullable page cannot be null');
+        }
+        $this->container['page'] = $page;
+
+        return $this;
+    }
+
+    /**
+     * Gets title
+     *
+     * @return string|null
+     */
+    public function getTitle()
+    {
+        return $this->container['title'];
+    }
+
+    /**
+     * Sets title
+     *
+     * @param string|null $title title
+     *
+     * @return self
+     */
+    public function setTitle($title)
+    {
+        if (is_null($title)) {
+            array_push($this->openAPINullablesSetToNull, 'title');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('title', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['title'] = $title;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 443 - 0
api-test/client/lib/Model/GetApiV3TipitakaWordParagraphsAggregate200Response.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * GetApiV3TipitakaWordParagraphsAggregate200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaWordParagraphsAggregate200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaWordParagraphsAggregate200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_word_paragraphs_aggregate_200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner[]',
+        'meta' => '\WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null,
+        'meta' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false,
+        'meta' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data',
+        'meta' => 'meta'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData',
+        'meta' => 'setMeta'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData',
+        'meta' => 'getMeta'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+        $this->setIfExists('meta', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner[]|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner[]|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+
+    /**
+     * Gets meta
+     *
+     * @return \WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta|null
+     */
+    public function getMeta()
+    {
+        return $this->container['meta'];
+    }
+
+    /**
+     * Sets meta
+     *
+     * @param \WikipaliApi\Model\GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta|null $meta meta
+     *
+     * @return self
+     */
+    public function setMeta($meta)
+    {
+        if (is_null($meta)) {
+            throw new \InvalidArgumentException('non-nullable meta cannot be null');
+        }
+        $this->container['meta'] = $meta;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 654 - 0
api-test/client/lib/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner.php

@@ -0,0 +1,654 @@
+<?php
+/**
+ * GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaWordParagraphsAggregate200ResponseDataInner implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_word_paragraphs_aggregate_200_response_data_inner';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'book_id' => 'int',
+        'book' => 'int',
+        'para' => 'int',
+        'title' => 'string',
+        'layer' => 'string',
+        'tags' => 'string[]',
+        'paragraphs' => 'int',
+        'occurrences' => 'int'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'book_id' => null,
+        'book' => null,
+        'para' => null,
+        'title' => null,
+        'layer' => null,
+        'tags' => null,
+        'paragraphs' => null,
+        'occurrences' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'book_id' => false,
+        'book' => false,
+        'para' => false,
+        'title' => false,
+        'layer' => true,
+        'tags' => false,
+        'paragraphs' => false,
+        'occurrences' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'book_id' => 'book_id',
+        'book' => 'book',
+        'para' => 'para',
+        'title' => 'title',
+        'layer' => 'layer',
+        'tags' => 'tags',
+        'paragraphs' => 'paragraphs',
+        'occurrences' => 'occurrences'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'book_id' => 'setBookId',
+        'book' => 'setBook',
+        'para' => 'setPara',
+        'title' => 'setTitle',
+        'layer' => 'setLayer',
+        'tags' => 'setTags',
+        'paragraphs' => 'setParagraphs',
+        'occurrences' => 'setOccurrences'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'book_id' => 'getBookId',
+        'book' => 'getBook',
+        'para' => 'getPara',
+        'title' => 'getTitle',
+        'layer' => 'getLayer',
+        'tags' => 'getTags',
+        'paragraphs' => 'getParagraphs',
+        'occurrences' => 'getOccurrences'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('book_id', $data ?? [], null);
+        $this->setIfExists('book', $data ?? [], null);
+        $this->setIfExists('para', $data ?? [], null);
+        $this->setIfExists('title', $data ?? [], null);
+        $this->setIfExists('layer', $data ?? [], null);
+        $this->setIfExists('tags', $data ?? [], null);
+        $this->setIfExists('paragraphs', $data ?? [], null);
+        $this->setIfExists('occurrences', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets book_id
+     *
+     * @return int|null
+     */
+    public function getBookId()
+    {
+        return $this->container['book_id'];
+    }
+
+    /**
+     * Sets book_id
+     *
+     * @param int|null $book_id book_id
+     *
+     * @return self
+     */
+    public function setBookId($book_id)
+    {
+        if (is_null($book_id)) {
+            throw new \InvalidArgumentException('non-nullable book_id cannot be null');
+        }
+        $this->container['book_id'] = $book_id;
+
+        return $this;
+    }
+
+    /**
+     * Gets book
+     *
+     * @return int|null
+     */
+    public function getBook()
+    {
+        return $this->container['book'];
+    }
+
+    /**
+     * Sets book
+     *
+     * @param int|null $book book
+     *
+     * @return self
+     */
+    public function setBook($book)
+    {
+        if (is_null($book)) {
+            throw new \InvalidArgumentException('non-nullable book cannot be null');
+        }
+        $this->container['book'] = $book;
+
+        return $this;
+    }
+
+    /**
+     * Gets para
+     *
+     * @return int|null
+     */
+    public function getPara()
+    {
+        return $this->container['para'];
+    }
+
+    /**
+     * Sets para
+     *
+     * @param int|null $para para
+     *
+     * @return self
+     */
+    public function setPara($para)
+    {
+        if (is_null($para)) {
+            throw new \InvalidArgumentException('non-nullable para cannot be null');
+        }
+        $this->container['para'] = $para;
+
+        return $this;
+    }
+
+    /**
+     * Gets title
+     *
+     * @return string|null
+     */
+    public function getTitle()
+    {
+        return $this->container['title'];
+    }
+
+    /**
+     * Sets title
+     *
+     * @param string|null $title title
+     *
+     * @return self
+     */
+    public function setTitle($title)
+    {
+        if (is_null($title)) {
+            throw new \InvalidArgumentException('non-nullable title cannot be null');
+        }
+        $this->container['title'] = $title;
+
+        return $this;
+    }
+
+    /**
+     * Gets layer
+     *
+     * @return string|null
+     */
+    public function getLayer()
+    {
+        return $this->container['layer'];
+    }
+
+    /**
+     * Sets layer
+     *
+     * @param string|null $layer layer
+     *
+     * @return self
+     */
+    public function setLayer($layer)
+    {
+        if (is_null($layer)) {
+            array_push($this->openAPINullablesSetToNull, 'layer');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('layer', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['layer'] = $layer;
+
+        return $this;
+    }
+
+    /**
+     * Gets tags
+     *
+     * @return string[]|null
+     */
+    public function getTags()
+    {
+        return $this->container['tags'];
+    }
+
+    /**
+     * Sets tags
+     *
+     * @param string[]|null $tags tags
+     *
+     * @return self
+     */
+    public function setTags($tags)
+    {
+        if (is_null($tags)) {
+            throw new \InvalidArgumentException('non-nullable tags cannot be null');
+        }
+        $this->container['tags'] = $tags;
+
+        return $this;
+    }
+
+    /**
+     * Gets paragraphs
+     *
+     * @return int|null
+     */
+    public function getParagraphs()
+    {
+        return $this->container['paragraphs'];
+    }
+
+    /**
+     * Sets paragraphs
+     *
+     * @param int|null $paragraphs paragraphs
+     *
+     * @return self
+     */
+    public function setParagraphs($paragraphs)
+    {
+        if (is_null($paragraphs)) {
+            throw new \InvalidArgumentException('non-nullable paragraphs cannot be null');
+        }
+        $this->container['paragraphs'] = $paragraphs;
+
+        return $this;
+    }
+
+    /**
+     * Gets occurrences
+     *
+     * @return int|null
+     */
+    public function getOccurrences()
+    {
+        return $this->container['occurrences'];
+    }
+
+    /**
+     * Sets occurrences
+     *
+     * @param int|null $occurrences occurrences
+     *
+     * @return self
+     */
+    public function setOccurrences($occurrences)
+    {
+        if (is_null($occurrences)) {
+            throw new \InvalidArgumentException('non-nullable occurrences cannot be null');
+        }
+        $this->container['occurrences'] = $occurrences;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 477 - 0
api-test/client/lib/Model/GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta.php

@@ -0,0 +1,477 @@
+<?php
+/**
+ * GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3TipitakaWordParagraphsAggregate200ResponseMeta implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_tipitaka_word_paragraphs_aggregate_200_response_meta';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'total' => 'int',
+        'paragraphs' => 'int',
+        'occurrences' => 'int'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'total' => null,
+        'paragraphs' => null,
+        'occurrences' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'total' => false,
+        'paragraphs' => false,
+        'occurrences' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'total' => 'total',
+        'paragraphs' => 'paragraphs',
+        'occurrences' => 'occurrences'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'total' => 'setTotal',
+        'paragraphs' => 'setParagraphs',
+        'occurrences' => 'setOccurrences'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'total' => 'getTotal',
+        'paragraphs' => 'getParagraphs',
+        'occurrences' => 'getOccurrences'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('total', $data ?? [], null);
+        $this->setIfExists('paragraphs', $data ?? [], null);
+        $this->setIfExists('occurrences', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets total
+     *
+     * @return int|null
+     */
+    public function getTotal()
+    {
+        return $this->container['total'];
+    }
+
+    /**
+     * Sets total
+     *
+     * @param int|null $total 书的数目
+     *
+     * @return self
+     */
+    public function setTotal($total)
+    {
+        if (is_null($total)) {
+            throw new \InvalidArgumentException('non-nullable total cannot be null');
+        }
+        $this->container['total'] = $total;
+
+        return $this;
+    }
+
+    /**
+     * Gets paragraphs
+     *
+     * @return int|null
+     */
+    public function getParagraphs()
+    {
+        return $this->container['paragraphs'];
+    }
+
+    /**
+     * Sets paragraphs
+     *
+     * @param int|null $paragraphs 命中段落总数
+     *
+     * @return self
+     */
+    public function setParagraphs($paragraphs)
+    {
+        if (is_null($paragraphs)) {
+            throw new \InvalidArgumentException('non-nullable paragraphs cannot be null');
+        }
+        $this->container['paragraphs'] = $paragraphs;
+
+        return $this;
+    }
+
+    /**
+     * Gets occurrences
+     *
+     * @return int|null
+     */
+    public function getOccurrences()
+    {
+        return $this->container['occurrences'];
+    }
+
+    /**
+     * Sets occurrences
+     *
+     * @param int|null $occurrences 词次总数
+     *
+     * @return self
+     */
+    public function setOccurrences($occurrences)
+    {
+        if (is_null($occurrences)) {
+            throw new \InvalidArgumentException('non-nullable occurrences cannot be null');
+        }
+        $this->container['occurrences'] = $occurrences;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 37 - 0
api-v13/app/Http/Controllers/V3/PaliWordFormController.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Resources\V3\PaliWordFormResource;
+use App\Services\V3\PaliWordFormService;
+
+/**
+ * 巴利词形展开(只读、公开)。
+ *
+ * 取代 `GET /v2/case/{word}`(`CaseController@show`)。v2 那份在 dashboard-v4 下线前原样保留,不要改动。
+ */
+class PaliWordFormController extends Controller
+{
+    public function __construct(private readonly PaliWordFormService $forms) {}
+
+    /**
+     * 词形展开
+     *
+     * 把一个巴利词还原成可能的词根,列出每个词根在三藏里实际出现过的词形(含 iti / api / ca / hi 连音),
+     * 带出现次数与黑体次数。第一组是输入的词本身,其后是推导出的词根;没有任何词形出现过的词根不列。
+     * 每组内按出现次数降序。词不区分大小写。
+     *
+     * @unauthenticated
+     *
+     * @urlParam word string required 巴利词,如 vitakka
+     *
+     * @meta total integer 组数
+     */
+    public function __invoke(string $word)
+    {
+        $groups = $this->forms->groups($word);
+
+        return PaliWordFormResource::collection($groups)->additional(['meta' => ['total' => count($groups)]]);
+    }
+}

+ 39 - 0
api-v13/app/Http/Controllers/V3/PaliWordSuggestionController.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\IndexPaliWordSuggestionRequest;
+use App\Http\Resources\V3\PaliWordSuggestionResource;
+use App\Services\V3\PaliWordSuggestionService;
+
+/**
+ * 巴利词补全(只读、公开)。
+ *
+ * 取代 `GET /v2/pali-word-index?view=key`(`WordIndexController@index`)。v2 那份在 dashboard-v4
+ * 下线前原样保留,不要改动。
+ */
+class PaliWordSuggestionController extends Controller
+{
+    public function __construct(private readonly PaliWordSuggestionService $words) {}
+
+    /**
+     * 巴利词补全
+     *
+     * 按已输入的前缀列出三藏里出现过的词形,带出现次数与黑体次数。前缀同时匹配去掉变音符号的写法
+     * (输入 dhamma 也能补出 dhammā),不区分大小写。与输入完全相同的词排在最前,其余按出现次数降序。
+     *
+     * @unauthenticated
+     *
+     * @queryParam q string required 已输入的前缀。Example: vitakk
+     * @queryParam limit integer 最多返回几条,上限 50。Default: 10
+     *
+     * @meta total integer 本次返回的条数
+     */
+    public function __invoke(IndexPaliWordSuggestionRequest $request)
+    {
+        $items = $this->words->suggest($request->validated('q'), $request->integer('limit', 10));
+
+        return PaliWordSuggestionResource::collection($items)->additional(['meta' => ['total' => count($items)]]);
+    }
+}

+ 42 - 0
api-v13/app/Http/Controllers/V3/TipitakaPageNumberController.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\IndexTipitakaPageNumberRequest;
+use App\Http\Resources\V3\TipitakaPageNumberResource;
+use App\Services\V3\TipitakaPageNumberService;
+
+/**
+ * 按印本页码找三藏段落(只读、公开)。
+ *
+ * 取代 `GET /v2/search-page-number/{number}`(`SearchPageNumberController@show`),以及 v2
+ * `search?view=page` 的「卷.页」查法。v2 那份在 dashboard-v4 下线前原样保留,不要改动。
+ */
+class TipitakaPageNumberController extends Controller
+{
+    public function __construct(private readonly TipitakaPageNumberService $pages) {}
+
+    /**
+     * 按页码找段落
+     *
+     * 一个页码在 PTS、缅甸版、VRI、泰国版、其他里各指一处或多处,另有 CS 版印的段落号(`edition=CS`)。
+     * 返回全部命中(不分页,通常几百条),按版本、书、卷、段排序。每条带书名、层级与该版本的书名。
+     * 卷号未知的记录 `volume` 为 null;给了 `volume` 就只要这一卷(CS 段落号不分卷,不返回)。
+     *
+     * @unauthenticated
+     *
+     * @urlParam page integer required 页码(或 CS 段落号)。Example: 100
+     *
+     * @queryParam edition string 只要这个版本。Enum: PTS,My,VRI,Thai,Other,CS
+     * @queryParam volume integer 只要这一卷。Example: 2
+     *
+     * @meta total integer 命中数
+     */
+    public function __invoke(IndexTipitakaPageNumberRequest $request, int $page)
+    {
+        $rows = $this->pages->find($page, $request->filters());
+
+        return TipitakaPageNumberResource::collection($rows)->additional(['meta' => ['total' => count($rows)]]);
+    }
+}

+ 45 - 0
api-v13/app/Http/Controllers/V3/TipitakaWordParagraphAggregateController.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\AggregateTipitakaWordParagraphRequest;
+use App\Http\Resources\V3\TipitakaWordBookResource;
+use App\Services\V3\TipitakaWordParagraphService;
+
+/**
+ * 按词形检索的出处分布(只读、公开)。
+ *
+ * 取代 `GET /v2/search-pali-wbw-books`(`SearchPaliWbwController@book_list`)。
+ * v2 那份在 dashboard-v4 下线前原样保留,不要改动。
+ */
+class TipitakaWordParagraphAggregateController extends Controller
+{
+    public function __construct(private readonly TipitakaWordParagraphService $paragraphs) {}
+
+    /**
+     * 按书统计命中
+     *
+     * 与 `GET /v3/tipitaka-word-paragraphs` 同样的检索条件,按书汇总:每本书命中多少段、多少词次,
+     * 按段落数降序,不分页。v2 只给词次;同一段里出现多次只算一段,所以两者不相等。
+     *
+     * @unauthenticated
+     *
+     * @queryParam words string required 词形,逗号分隔,最多 200 个。Example: vitakko,vitakkaṃ
+     * @queryParam bold string 只看黑体(only)或排除黑体(exclude);不给则不限。Enum: only,exclude
+     *
+     * @meta total integer 书的数目
+     * @meta paragraphs integer 命中段落总数
+     * @meta occurrences integer 词次总数
+     */
+    public function __invoke(AggregateTipitakaWordParagraphRequest $request)
+    {
+        $result = $this->paragraphs->books($request->criteria());
+
+        return TipitakaWordBookResource::collection($result['items'])->additional(['meta' => [
+            'total' => count($result['items']),
+            'paragraphs' => $result['paragraphs'],
+            'occurrences' => $result['occurrences'],
+        ]]);
+    }
+}

+ 41 - 0
api-v13/app/Http/Controllers/V3/TipitakaWordParagraphController.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\IndexTipitakaWordParagraphRequest;
+use App\Http\Resources\V3\TipitakaWordParagraphResource;
+use App\Services\V3\TipitakaWordParagraphService;
+
+/**
+ * 按词形找三藏段落(只读、公开)。
+ *
+ * 取代 `GET|POST /v2/search-pali-wbw`(`SearchPaliWbwController@index` / `@store`)。
+ * v2 那份在 dashboard-v4 下线前原样保留,不要改动。
+ */
+class TipitakaWordParagraphController extends Controller
+{
+    public function __construct(private readonly TipitakaWordParagraphService $paragraphs) {}
+
+    /**
+     * 按词形找段落
+     *
+     * 在逐词表里精确匹配词形(连音已拆开),返回命中的段落,按命中权重降序、同分按经文顺序。
+     * 词形先用 `GET /v3/pali-word-forms/{word}` 展开——拿词根直接查通常是 0 条。
+     * 每条带整段正文(只含 `<b>` 黑体与 `<mark>` 命中词的安全 HTML)、章节路径与各印本页码。
+     *
+     * @unauthenticated
+     *
+     * @queryParam words string required 词形,逗号分隔,最多 200 个。Example: vitakko,vitakkaṃ
+     * @queryParam bold string 只看黑体(only,注释书里被解释的词)或排除黑体(exclude);不给则不限。Enum: only,exclude
+     * @queryParam book_id string 只看这些书,逗号分隔的 book_id(见 `/aggregate`)。Example: 75,79
+     * @queryParam page integer 页码。Default: 1
+     * @queryParam per_page integer 每页条数,上限 100。Default: 20
+     */
+    public function index(IndexTipitakaWordParagraphRequest $request)
+    {
+        return TipitakaWordParagraphResource::collection(
+            $this->paragraphs->paragraphs($request->criteria(), (int) $request->validated('per_page', 20)),
+        );
+    }
+}

+ 69 - 0
api-v13/app/Http/Requests/V3/AggregateTipitakaWordParagraphRequest.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+/**
+ * `GET /v3/tipitaka-word-paragraphs/aggregate`:按书统计命中。
+ *
+ * 也是列表端点 `IndexTipitakaWordParagraphRequest` 的基类——两者的检索条件相同,
+ * 列表另有书的过滤与分页。
+ */
+class AggregateTipitakaWordParagraphRequest extends FormRequest
+{
+    /** 一次最多查多少个词形(一个常见词根展开后通常几十个) */
+    public const MAX_WORDS = 200;
+
+    public const BOLD = ['only', 'exclude'];
+
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        return [
+            'words' => ['required', 'string', 'max:6000', function (string $attribute, mixed $value, \Closure $fail): void {
+                $count = count(self::splitWords((string) $value));
+                if ($count === 0) {
+                    $fail(__('validation.required', ['attribute' => $attribute]));
+                } elseif ($count > self::MAX_WORDS) {
+                    $fail(__('validation.max.array', ['attribute' => $attribute, 'max' => self::MAX_WORDS]));
+                }
+            }],
+            'bold' => ['sometimes', 'string', 'in:'.implode(',', self::BOLD)],
+        ];
+    }
+
+    /**
+     * 逗号分隔的词形 → 去空白、去空项、去重。
+     *
+     * 空串绝不能进查询:`real` 为空的行有四百多万,覆盖几十万个段落。
+     *
+     * @return list<string>
+     */
+    public static function splitWords(string $value): array
+    {
+        $words = array_map('trim', explode(',', $value));
+
+        return array_values(array_unique(array_filter($words, fn (string $w): bool => $w !== '')));
+    }
+
+    /**
+     * Service 用的检索条件。
+     *
+     * @return array{words: list<string>, bold: string|null}
+     */
+    public function criteria(): array
+    {
+        return [
+            'words' => self::splitWords((string) $this->validated('words')),
+            'bold' => $this->validated('bold'),
+        ];
+    }
+}

+ 27 - 0
api-v13/app/Http/Requests/V3/IndexPaliWordSuggestionRequest.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+/**
+ * `GET /v3/pali-word-suggestions`:巴利词的前缀补全。
+ */
+class IndexPaliWordSuggestionRequest extends FormRequest
+{
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        return [
+            'q' => ['required', 'string', 'max:64'],
+            'limit' => ['sometimes', 'integer', 'min:1', 'max:50'],
+        ];
+    }
+}

+ 46 - 0
api-v13/app/Http/Requests/V3/IndexTipitakaPageNumberRequest.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+use App\Services\V3\TipitakaPageNumberService;
+use Illuminate\Foundation\Http\FormRequest;
+
+/**
+ * `GET /v3/tipitaka-page-numbers/{page}`:版本与卷号都是可选过滤。
+ */
+class IndexTipitakaPageNumberRequest extends FormRequest
+{
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        $editions = [...array_values(TipitakaPageNumberService::EDITIONS), TipitakaPageNumberService::CS];
+
+        return [
+            'edition' => ['sometimes', 'string', 'in:'.implode(',', $editions)],
+            'volume' => ['sometimes', 'integer', 'min:1', 'max:99'],
+        ];
+    }
+
+    /**
+     * @return array{edition?: string, volume?: int}
+     */
+    public function filters(): array
+    {
+        $filters = [];
+        if ($this->has('edition')) {
+            $filters['edition'] = (string) $this->validated('edition');
+        }
+        if ($this->has('volume')) {
+            $filters['volume'] = (int) $this->validated('volume');
+        }
+
+        return $filters;
+    }
+}

+ 33 - 0
api-v13/app/Http/Requests/V3/IndexTipitakaWordParagraphRequest.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+/**
+ * `GET /v3/tipitaka-word-paragraphs`:按词形找段落。检索条件同聚合端点,另加书的过滤与分页。
+ */
+class IndexTipitakaWordParagraphRequest extends AggregateTipitakaWordParagraphRequest
+{
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        return parent::rules() + [
+            'book_id' => ['sometimes', 'string', 'regex:/^\d+(,\d+)*$/', 'max:2000'],
+            'page' => ['sometimes', 'integer', 'min:1'],
+            'per_page' => ['sometimes', 'integer', 'min:1', 'max:100'],
+        ];
+    }
+
+    /**
+     * @return array{words: list<string>, bold: string|null, book_ids: list<int>}
+     */
+    public function criteria(): array
+    {
+        $bookIds = $this->validated('book_id');
+
+        return parent::criteria() + [
+            'book_ids' => $bookIds === null ? [] : array_values(array_unique(array_map('intval', explode(',', $bookIds)))),
+        ];
+    }
+}

+ 27 - 0
api-v13/app/Http/Resources/V3/PaliWordFormResource.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use Illuminate\Http\Request;
+
+/**
+ * 一个词根及其在三藏里出现过的词形(`word_indices` 表的计数)。
+ *
+ * `count` 是该词形的总出现次数,`bold` 是其中以黑体出现的次数(注释书里被解释的词)。
+ */
+class PaliWordFormResource extends BaseResource
+{
+    /**
+     * @return array{
+     *     base: string,
+     *     forms: list<array{word: string, count: int, bold: int}>
+     * }
+     */
+    public function toArray(Request $request): array
+    {
+        return [
+            'base' => (string) $this['base'],
+            'forms' => $this['forms'],
+        ];
+    }
+}

+ 25 - 0
api-v13/app/Http/Resources/V3/PaliWordSuggestionResource.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use Illuminate\Http\Request;
+
+/**
+ * 一个补全候选:三藏里出现过的词形(`word_indices`)。
+ *
+ * `count` 是总出现次数,`bold` 是其中以黑体出现的次数(注释书里被解释的词)。
+ */
+class PaliWordSuggestionResource extends BaseResource
+{
+    /**
+     * @return array{word: string, count: int, bold: int}
+     */
+    public function toArray(Request $request): array
+    {
+        return [
+            'word' => $this['word'],
+            'count' => $this['count'],
+            'bold' => $this['bold'],
+        ];
+    }
+}

+ 49 - 0
api-v13/app/Http/Resources/V3/TipitakaPageNumberResource.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use Illuminate\Http\Request;
+
+/**
+ * 一处印本页码(或 CS 段落号)在三藏里的位置。
+ *
+ * `edition`:PTS / My(缅甸第六次结集版)/ VRI / Thai / Other / CS(CS 版印的段落号)。
+ * `volume` 为 null 表示卷号未知(库里记作 0)或不分卷(CS)。`book` / `para` 是页码标记所在段落;
+ * `book_id` 是 `pcd_book_id`,`book_title` 是书名,`book_para` 是书名所在段(CS 段落号按书编号,定位要用它)。
+ * `edition_title` 是该版本的书名(静态书名表,PTS / 缅 / VRI 各有一套,其余用通用名;CS 为 null),
+ * v6 的印本页阅读页按「版本_版本书名_卷_页」定位。`tags` 是书的 tag(同 tipitaka-word-paragraphs/aggregate),客户端按它做目录过滤。
+ */
+class TipitakaPageNumberResource extends BaseResource
+{
+    /**
+     * @return array{
+     *     edition: string,
+     *     volume: int|null,
+     *     page: int,
+     *     book: int,
+     *     para: int,
+     *     book_id: int,
+     *     book_title: string,
+     *     book_para: int,
+     *     edition_title: string|null,
+     *     layer: string|null,
+     *     tags: list<string>
+     * }
+     */
+    public function toArray(Request $request): array
+    {
+        return [
+            'edition' => $this['edition'],
+            'volume' => $this['volume'],
+            'page' => $this['page'],
+            'book' => $this['book'],
+            'para' => $this['para'],
+            'book_id' => $this['book_id'],
+            'book_title' => $this['book_title'],
+            'book_para' => $this['book_para'],
+            'edition_title' => $this['edition_title'],
+            'layer' => $this['layer'],
+            'tags' => $this['tags'],
+        ];
+    }
+}

+ 41 - 0
api-v13/app/Http/Resources/V3/TipitakaWordBookResource.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use Illuminate\Http\Request;
+
+/**
+ * 按词形检索的一本书的命中统计。
+ *
+ * `book_id` 是 `pcd_book_id`(`book_titles.sn`),也是列表端点 `book_id` 过滤用的值;
+ * `book` / `para` 是书名所在段的坐标。`paragraphs` 是命中段落数,`occurrences` 是词次
+ * (同一段出现多次算多次)。`layer` 取自书的 tag(mula / atthakatha / tika / anna),没有则为 null。
+ */
+class TipitakaWordBookResource extends BaseResource
+{
+    /**
+     * @return array{
+     *     book_id: int,
+     *     book: int,
+     *     para: int,
+     *     title: string,
+     *     layer: string|null,
+     *     tags: list<string>,
+     *     paragraphs: int,
+     *     occurrences: int
+     * }
+     */
+    public function toArray(Request $request): array
+    {
+        return [
+            'book_id' => $this['book_id'],
+            'book' => $this['book'],
+            'para' => $this['para'],
+            'title' => $this['title'],
+            'layer' => $this['layer'],
+            'tags' => $this['tags'],
+            'paragraphs' => $this['paragraphs'],
+            'occurrences' => $this['occurrences'],
+        ];
+    }
+}

+ 45 - 0
api-v13/app/Http/Resources/V3/TipitakaWordParagraphResource.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use Illuminate\Http\Request;
+
+/**
+ * 按词形命中的一个三藏段落(`wbw_templates` 按段聚合 + `pali_texts` + `page_numbers`)。
+ *
+ * `text` 是整段正文的安全 HTML:只有 `<b>`(原文黑体,即注释书里被解释的词)与 `<mark>`(命中的词形),
+ * 其余全部已转义,可直接渲染。`refs` 是各印本页码(每种版本取段内第一个),最后一条 `WP` 是 WikiPali
+ * 段落号;`title` 是丛书缩写(缅甸版、PTS、WP 才有)。
+ */
+class TipitakaWordParagraphResource extends BaseResource
+{
+    /**
+     * @return array{
+     *     id: string,
+     *     book: int,
+     *     para: int,
+     *     score: int,
+     *     hits: int,
+     *     title: string,
+     *     level: int,
+     *     path: list<array{book: int, para: int, title: string, level: int}>,
+     *     text: string,
+     *     refs: list<array{type: string, volume: int|null, page: int, title: string|null}>
+     * }
+     */
+    public function toArray(Request $request): array
+    {
+        return [
+            'id' => "{$this['book']}-{$this['para']}",
+            'book' => $this['book'],
+            'para' => $this['para'],
+            'score' => $this['score'],
+            'hits' => $this['hits'],
+            'title' => $this['title'],
+            'level' => $this['level'],
+            'path' => $this['path'],
+            'text' => $this['text'],
+            'refs' => $this['refs'],
+        ];
+    }
+}

+ 85 - 0
api-v13/app/Services/V3/PaliWordFormService.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Services\V3;
+
+use App\Models\WordIndex;
+use App\Tools\CaseEnding;
+use App\Tools\CaseMan;
+
+/**
+ * 巴利词形展开:一个词 → 它可能的词根 → 每个词根在三藏里实际出现过的词形(含连音 iti / api / ca / hi)。
+ *
+ * 词根推导用共享的 `CaseMan::WordToBase(..., verify: false)`(纯字符串运算,不查库);
+ * 由词根生成词形的规则与 v2 `CaseMan::BaseToWord` 相同,但 v2 每个候选词形单独查一次
+ * `word_indices`(一个词上百次),这里先生成全部候选,再一次 whereIn 取出现次数。
+ */
+class PaliWordFormService
+{
+    /** 词尾表里低于这个置信度的规则不用(与 v2 /case 相同) */
+    private const CONFIDENCE = 0.2;
+
+    public function __construct(private readonly CaseMan $caseMan) {}
+
+    /**
+     * @return list<array{base: string, forms: list<array{word: string, count: int, bold: int}>}>
+     */
+    public function groups(string $word): array
+    {
+        $word = mb_strtolower(trim($word), 'UTF-8');
+
+        // 输入的词本身排第一组,其后是推导出的词根
+        $bases = array_values(array_unique([$word, ...array_map('strval', array_keys($this->caseMan->WordToBase($word, 1, false)))]));
+
+        $candidates = [];
+        foreach ($bases as $base) {
+            $candidates[$base] = $this->candidates($base);
+        }
+
+        $all = array_values(array_unique(array_merge(...array_values($candidates))));
+        $counts = $all === []
+            ? collect()
+            : WordIndex::whereIn('word', $all)->get(['word', 'count', 'bold'])->keyBy('word');
+
+        $groups = [];
+        foreach ($candidates as $base => $words) {
+            $forms = [];
+            foreach ($words as $form) {
+                if ($row = $counts->get($form)) {
+                    $forms[] = ['word' => $form, 'count' => (int) $row->count, 'bold' => (int) $row->bold];
+                }
+            }
+            if ($forms === []) {
+                continue;
+            }
+            usort($forms, fn (array $a, array $b) => $b['count'] <=> $a['count'] ?: strcmp($a['word'], $b['word']));
+            $groups[] = ['base' => (string) $base, 'forms' => $forms];
+        }
+
+        return $groups;
+    }
+
+    /**
+     * 由词根按词尾表生成候选词形,再对每个词形套连音规则。
+     *
+     * @return list<string>
+     */
+    private function candidates(string $base): array
+    {
+        $table = new CaseEnding;
+        $words = [];
+        foreach ($table->ending as [$from, $to, , , $confidence]) {
+            if ($confidence < self::CONFIDENCE || ! str_ends_with($base, $from)) {
+                continue;
+            }
+            $word = mb_substr($base, 0, mb_strlen($base, 'UTF-8') - mb_strlen($from, 'UTF-8'), 'UTF-8').$to;
+            $words[$word] = true;
+            foreach ($table->union as [$end, $joined]) {
+                if (str_ends_with($word, $end)) {
+                    $words[mb_substr($word, 0, mb_strlen($word, 'UTF-8') - mb_strlen($end, 'UTF-8'), 'UTF-8').$joined] = true;
+                }
+            }
+        }
+
+        return array_map('strval', array_keys($words));
+    }
+}

+ 38 - 0
api-v13/app/Services/V3/PaliWordSuggestionService.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Services\V3;
+
+use App\Models\WordIndex;
+use Illuminate\Contracts\Database\Eloquent\Builder;
+
+/**
+ * 巴利词的前缀补全(`word_indices`:三藏里出现过的每个词形及出现次数、黑体次数)。
+ *
+ * 前缀同时匹配原形与去变音形(`word_en`),所以不打变音符号也能补全(dhamma → dhammā)。
+ * 排序:与输入完全相同的词在前,其余按出现次数降序(v2 按词长排,短而罕见的词形挤掉常用词)。
+ */
+class PaliWordSuggestionService
+{
+    /**
+     * @return list<array{word: string, count: int, bold: int}>
+     */
+    public function suggest(string $prefix, int $limit): array
+    {
+        $prefix = mb_strtolower(trim($prefix), 'UTF-8');
+        $like = str_replace(['\\', '%', '_'], ['\\\\', '\\%', '\\_'], $prefix).'%';
+
+        return WordIndex::query()
+            ->where(fn (Builder $q) => $q->where('word', 'like', $like)->orWhere('word_en', 'like', $like))
+            ->orderByRaw('(word = ? or word_en = ?) desc', [$prefix, $prefix])
+            ->orderByDesc('count')
+            ->orderBy('word')
+            ->limit($limit)
+            ->get(['word', 'count', 'bold'])
+            ->map(fn (WordIndex $w) => [
+                'word' => (string) $w->word,
+                'count' => (int) $w->count,
+                'bold' => (int) $w->bold,
+            ])
+            ->all();
+    }
+}

+ 69 - 0
api-v13/app/Services/V3/TipitakaBookService.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace App\Services\V3;
+
+use App\Models\BookTitle;
+use App\Models\PaliText;
+use Illuminate\Contracts\Database\Eloquent\Builder;
+use Illuminate\Support\Collection;
+
+/**
+ * 按 `pcd_book_id`(`book_titles.sn`)批量取书的基本信息:书名所在段、书名、tag、层级。
+ *
+ * 检索结果按书汇总时用(逐词检索的 /aggregate、页码检索),一次两条查询,不逐本查。
+ */
+class TipitakaBookService
+{
+    /** 书的 tag → layer(同 TipitakaChapterService),一本书有多个时按这个顺序取第一个 */
+    private const LAYER_TAGS = ['mūla' => 'mula', 'aṭṭhakathā' => 'atthakatha', 'ṭīkā' => 'tika', 'añña' => 'anna'];
+
+    /**
+     * 结果以 book_id 为键;book_titles 里没有的书不在其中。
+     *
+     * @param  iterable<int>  $bookIds  pcd_book_id
+     * @return Collection<int, array{book_id: int, book: int, para: int, title: string, layer: string|null, tags: list<string>}>
+     */
+    public function find(iterable $bookIds): Collection
+    {
+        $ids = collect($bookIds)->map(fn ($id) => (int) $id)->unique()->values();
+        if ($ids->isEmpty()) {
+            return collect();
+        }
+
+        $titles = BookTitle::whereIn('sn', $ids)->get(['sn', 'book', 'paragraph']);
+        if ($titles->isEmpty()) {
+            return collect();
+        }
+
+        $heads = PaliText::query()
+            ->where(function (Builder $q) use ($titles) {
+                foreach ($titles as $title) {
+                    $q->orWhere(fn (Builder $q) => $q->where('book', $title->book)->where('paragraph', $title->paragraph));
+                }
+            })
+            ->with('tagMaps.tags')
+            ->get(['uid', 'book', 'paragraph', 'toc'])
+            ->keyBy(fn (PaliText $t) => "{$t->book}-{$t->paragraph}");
+
+        return $titles->mapWithKeys(function (BookTitle $title) use ($heads) {
+            $head = $heads->get("{$title->book}-{$title->paragraph}");
+            $tags = $head ? $head->tagMaps->map(fn ($map) => $map->tags?->name)->filter()->map('strval')->values()->all() : [];
+            $layer = null;
+            foreach (self::LAYER_TAGS as $tag => $value) {
+                if (in_array($tag, $tags, true)) {
+                    $layer = $value;
+                    break;
+                }
+            }
+
+            return [(int) $title->sn => [
+                'book_id' => (int) $title->sn,
+                'book' => (int) $title->book,
+                'para' => (int) $title->paragraph,
+                'title' => (string) ($head?->toc ?? ''),
+                'layer' => $layer,
+                'tags' => $tags,
+            ]];
+        });
+    }
+}

+ 100 - 0
api-v13/app/Services/V3/TipitakaPageNumberService.php

@@ -0,0 +1,100 @@
+<?php
+
+namespace App\Services\V3;
+
+use App\Http\Api\BookTitle as EditionBookTitles;
+use App\Models\PageNumber;
+use App\Models\WbwTemplate;
+
+/**
+ * 按印本页码找三藏段落:PTS、缅甸第六次结集版、VRI、泰国版、其他,以及 CS 版印的段落号。
+ *
+ * 印本页码在 `page_numbers`(每条是正文里一个页码标记的位置);CS 段落号在逐词表里
+ * (`real = para{n}` 的词元)。一个页码在各版本里加起来最多约一千处,不分页。
+ */
+class TipitakaPageNumberService
+{
+    /** page_numbers.type 代号 → 对外的版本名(与 tipitaka-word-paragraphs 的 refs.type 一致) */
+    public const EDITIONS = ['P' => 'PTS', 'M' => 'My', 'V' => 'VRI', 'T' => 'Thai', 'O' => 'Other'];
+
+    /** CS 版印的段落号 */
+    public const CS = 'CS';
+
+    /** 版本 → 静态书名表里该版本的书名字段(v6 印本页阅读页按它定位,同 QuoteLinkLoader) */
+    private const TITLE_FIELDS = ['PTS' => 'p_title', 'My' => 'm_title', 'VRI' => 'v_title'];
+
+    public function __construct(private readonly TipitakaBookService $books) {}
+
+    /**
+     * @param  array{edition?: string, volume?: int}  $filters
+     * @return list<array{
+     *     edition: string, volume: int|null, page: int, book: int, para: int,
+     *     book_id: int, book_title: string, book_para: int, edition_title: string|null, layer: string|null, tags: list<string>
+     * }>
+     */
+    public function find(int $page, array $filters): array
+    {
+        $edition = $filters['edition'] ?? null;
+        $volume = $filters['volume'] ?? null;
+        $rows = [];
+
+        if ($edition !== self::CS) {
+            $types = $edition === null ? array_keys(self::EDITIONS) : [array_search($edition, self::EDITIONS, true)];
+            $pages = PageNumber::query()
+                ->where('page', $page)
+                ->whereIn('type', $types)
+                ->when($volume !== null, fn ($q) => $q->where('volume', $volume))
+                ->get(['type', 'volume', 'page', 'book', 'paragraph', 'pcd_book_id']);
+            foreach ($pages as $p) {
+                $rows[] = [
+                    'edition' => self::EDITIONS[$p->type],
+                    // 0 是「卷号未知」
+                    'volume' => (int) $p->volume ?: null,
+                    'page' => (int) $p->page,
+                    'book' => (int) $p->book,
+                    'para' => (int) $p->paragraph,
+                    'book_id' => (int) $p->pcd_book_id,
+                ];
+            }
+        }
+
+        // CS 段落号不分卷:给了卷号就不查
+        if (($edition === null || $edition === self::CS) && $volume === null) {
+            $paras = WbwTemplate::where('real', "para{$page}")->get(['book', 'paragraph', 'pcd_book_id']);
+            foreach ($paras as $p) {
+                $rows[] = [
+                    'edition' => self::CS,
+                    'volume' => null,
+                    'page' => $page,
+                    'book' => (int) $p->book,
+                    'para' => (int) $p->paragraph,
+                    'book_id' => (int) $p->pcd_book_id,
+                ];
+            }
+        }
+
+        $books = $this->books->find(array_column($rows, 'book_id'));
+        $editionTitles = collect(EditionBookTitles::get())->keyBy('id');
+
+        $rows = array_map(function (array $row) use ($books, $editionTitles) {
+            $book = $books->get($row['book_id']);
+            $titles = $editionTitles->get($row['book_id']);
+            $field = self::TITLE_FIELDS[$row['edition']] ?? 'term';
+
+            return $row + [
+                'book_title' => $book['title'] ?? '',
+                'book_para' => $book['para'] ?? 0,
+                'edition_title' => $row['edition'] === self::CS ? null : ($titles[$field] ?? null),
+                'layer' => $book['layer'] ?? null,
+                'tags' => $book['tags'] ?? [],
+            ];
+        }, $rows);
+
+        // 按版本(PTS、缅、VRI、泰、其他、CS)、书、卷、段排
+        $order = array_flip([...array_values(self::EDITIONS), self::CS]);
+        usort($rows, fn (array $a, array $b) => [$order[$a['edition']], $a['book_id'], $a['volume'] ?? 0, $a['book'], $a['para']]
+            <=> [$order[$b['edition']], $b['book_id'], $b['volume'] ?? 0, $b['book'], $b['para']]);
+
+        return $rows;
+    }
+}

+ 252 - 0
api-v13/app/Services/V3/TipitakaWordParagraphService.php

@@ -0,0 +1,252 @@
+<?php
+
+namespace App\Services\V3;
+
+use App\Models\PageNumber;
+use App\Models\PaliText;
+use App\Models\WbwTemplate;
+use App\Services\PaliSeriesesService;
+use Illuminate\Contracts\Database\Eloquent\Builder;
+use Illuminate\Pagination\LengthAwarePaginator;
+use Illuminate\Support\Collection;
+
+/**
+ * 按词形找三藏段落(逐词表 `wbw_templates`:连音已拆开,每个词形精确匹配)。
+ *
+ * 与 OpenSearch 全文检索(`/v3/search`)互补:这里召回精确到词形、能区分黑体(注释书里
+ * 被解释的词),但不做模糊、不做多词共现。
+ *
+ * v2 `search-pali-wbw` 每行另查 3~4 次库(段落、标题、页码、丛书缩写),这里整页批量取。
+ */
+class TipitakaWordParagraphService
+{
+    /** page_numbers.type 代号 → 对外的版本名(与 v2 ref.type 相同,插件按它拼出处) */
+    private const EDITIONS = ['M' => 'My', 'P' => 'PTS', 'V' => 'VRI', 'T' => 'Thai', 'O' => 'Other'];
+
+    public function __construct(
+        private readonly PaliSeriesesService $serieses,
+        private readonly TipitakaBookService $books,
+    ) {}
+
+    /**
+     * 命中段落,按命中权重降序(同分按经文顺序)。
+     *
+     * @param  array{words: list<string>, bold: string|null, book_ids: list<int>}  $criteria
+     * @return LengthAwarePaginator<int, array{
+     *     book: int, para: int, score: int, hits: int, title: string, level: int,
+     *     path: list<array{book: int, para: int, title: string, level: int}>,
+     *     text: string,
+     *     refs: list<array{type: string, volume: int|null, page: int, title: string|null}>
+     * }>
+     */
+    public function paragraphs(array $criteria, int $perPage): LengthAwarePaginator
+    {
+        $page = $this->matches($criteria)
+            ->when($criteria['book_ids'] !== [], fn (Builder $q) => $q->whereIn('pcd_book_id', $criteria['book_ids']))
+            ->groupBy(['book', 'paragraph'])
+            ->selectRaw('book, paragraph, sum(weight) as score, count(*) as hits')
+            ->orderByDesc('score')
+            ->orderBy('book')
+            ->orderBy('paragraph')
+            ->paginate($perPage);
+
+        $rows = collect($page->items());
+        $texts = $this->paliTexts($rows);
+        $refs = $this->pageNumbers($rows);
+        $highlighter = $this->highlighter($criteria['words']);
+
+        return $page->setCollection($rows->map(function ($row) use ($texts, $refs, $highlighter) {
+            $book = (int) $row->book;
+            $para = (int) $row->paragraph;
+            $text = $texts->get("{$book}-{$para}");
+            $path = self::path($text?->path);
+            $series = $this->serieses->find($book, $para);
+
+            return [
+                'book' => $book,
+                'para' => $para,
+                'score' => (int) $row->score,
+                'hits' => (int) $row->hits,
+                // 标题段(level < 100)用自己的标题,正文段用所在章节的标题
+                'title' => $text && $text->level < 100 ? (string) $text->toc : (string) (end($path)['title'] ?? ''),
+                'level' => (int) ($text?->level ?? 100),
+                'path' => $path,
+                'text' => $highlighter((string) ($text?->html ?? '')),
+                'refs' => [
+                    ...array_map(fn (array $r) => $r + ['title' => match ($r['type']) {
+                        'My' => $series['abbr_my'] ?? null,
+                        'PTS' => $series['abbr_pts'] ?? null,
+                        default => null,
+                    }], $refs->get("{$book}-{$para}", [])),
+                    ['type' => 'WP', 'volume' => null, 'page' => $para, 'title' => $series['abbr_wp'] ?? null],
+                ],
+            ];
+        }));
+    }
+
+    /**
+     * 按书统计:每本书(pcd_book_id)命中多少段、多少词次。按段落数降序。
+     *
+     * @param  array{words: list<string>, bold: string|null}  $criteria
+     * @return array{
+     *     items: list<array{book_id: int, book: int, para: int, title: string, layer: string|null, tags: list<string>, paragraphs: int, occurrences: int}>,
+     *     paragraphs: int,
+     *     occurrences: int
+     * }
+     */
+    public function books(array $criteria): array
+    {
+        $groups = $this->matches($criteria)
+            ->groupBy('pcd_book_id')
+            ->selectRaw('pcd_book_id, count(*) as occurrences, count(distinct (book, paragraph)) as paragraphs')
+            ->orderByDesc('paragraphs')
+            ->orderBy('pcd_book_id')
+            ->get();
+
+        $books = $this->books->find($groups->pluck('pcd_book_id'));
+
+        $items = $groups->map(function ($group) use ($books) {
+            $book = $books->get((int) $group->pcd_book_id);
+
+            return [
+                'book_id' => (int) $group->pcd_book_id,
+                'book' => $book['book'] ?? 0,
+                'para' => $book['para'] ?? 0,
+                'title' => $book['title'] ?? '',
+                'layer' => $book['layer'] ?? null,
+                'tags' => $book['tags'] ?? [],
+                'paragraphs' => (int) $group->paragraphs,
+                'occurrences' => (int) $group->occurrences,
+            ];
+        })->values()->all();
+
+        return [
+            'items' => $items,
+            'paragraphs' => array_sum(array_column($items, 'paragraphs')),
+            'occurrences' => array_sum(array_column($items, 'occurrences')),
+        ];
+    }
+
+    /**
+     * 词形与黑体条件。
+     *
+     * @param  array{words: list<string>, bold: string|null}  $criteria
+     */
+    private function matches(array $criteria): Builder
+    {
+        return WbwTemplate::query()
+            ->whereIn('real', $criteria['words'])
+            ->when($criteria['bold'] === 'only', fn (Builder $q) => $q->where('style', 'bld'))
+            ->when($criteria['bold'] === 'exclude', fn (Builder $q) => $q->where(
+                fn (Builder $q) => $q->where('style', '<>', 'bld')->orWhereNull('style'),
+            ));
+    }
+
+    /**
+     * 本页段落的正文与路径,一次查完。
+     *
+     * @param  Collection<int, mixed>  $rows
+     * @return Collection<string, PaliText>
+     */
+    private function paliTexts(Collection $rows): Collection
+    {
+        if ($rows->isEmpty()) {
+            return collect();
+        }
+
+        return PaliText::query()
+            ->where(function (Builder $q) use ($rows) {
+                foreach ($rows as $row) {
+                    $q->orWhere(fn (Builder $q) => $q->where('book', $row->book)->where('paragraph', $row->paragraph));
+                }
+            })
+            ->get(['book', 'paragraph', 'level', 'toc', 'path', 'html'])
+            ->keyBy(fn (PaliText $t) => "{$t->book}-{$t->paragraph}");
+    }
+
+    /**
+     * 本页段落在各印本里的页码,每种版本取段落里第一个页码标记。一次查完。
+     *
+     * @param  Collection<int, mixed>  $rows
+     * @return Collection<string, list<array{type: string, volume: int|null, page: int}>>
+     */
+    private function pageNumbers(Collection $rows): Collection
+    {
+        if ($rows->isEmpty()) {
+            return collect();
+        }
+
+        return PageNumber::query()
+            ->where(function (Builder $q) use ($rows) {
+                foreach ($rows as $row) {
+                    $q->orWhere(fn (Builder $q) => $q->where('book', $row->book)->where('paragraph', $row->paragraph));
+                }
+            })
+            ->orderBy('wid')
+            ->get(['type', 'volume', 'page', 'book', 'paragraph'])
+            ->groupBy(fn (PageNumber $p) => "{$p->book}-{$p->paragraph}")
+            ->map(fn (Collection $pages) => $pages->unique('type')->map(fn (PageNumber $p) => [
+                'type' => self::EDITIONS[$p->type] ?? (string) $p->type,
+                'volume' => $p->volume === null ? null : (int) $p->volume,
+                'page' => (int) $p->page,
+            ])->values()->all());
+    }
+
+    /**
+     * `pali_texts.path`(JSON 字符串,level 有时是字符串)→ 规整的数组。
+     *
+     * @return list<array{book: int, para: int, title: string, level: int}>
+     */
+    private static function path(mixed $raw): array
+    {
+        $items = is_string($raw) ? json_decode($raw, true) : $raw;
+        if (! is_array($items)) {
+            return [];
+        }
+
+        return array_values(array_map(fn (array $p) => [
+            'book' => (int) ($p['book'] ?? 0),
+            'para' => (int) ($p['paragraph'] ?? 0),
+            'title' => (string) ($p['title'] ?? ''),
+            'level' => (int) ($p['level'] ?? 0),
+        ], array_filter($items, 'is_array')));
+    }
+
+    /**
+     * 正文 HTML → 只含 `<b>`(黑体)与 `<mark>`(命中词形)的安全 HTML。
+     *
+     * 其余标签全部去掉、正文全部转义,客户端可以直接作为 HTML 渲染。命中词按整词匹配
+     * (前后不是字母),不区分首字母大小写;词形以 ti / nti 结尾的,正文里常写成
+     * 「词’’ti」,所以也匹配去掉 ti 后的部分(同 v2)。
+     *
+     * @param  list<string>  $words
+     * @return \Closure(string): string
+     */
+    private function highlighter(array $words): \Closure
+    {
+        $variants = [];
+        foreach ($words as $word) {
+            $variants[] = $word;
+            if (str_ends_with($word, 'nti')) {
+                $variants[] = mb_substr($word, 0, -3, 'UTF-8');
+            } elseif (str_ends_with($word, 'ti')) {
+                $variants[] = mb_substr($word, 0, -2, 'UTF-8');
+            }
+        }
+        $variants = array_filter(array_unique($variants), fn (string $v) => mb_strlen($v, 'UTF-8') > 1);
+        usort($variants, fn (string $a, string $b) => mb_strlen($b, 'UTF-8') <=> mb_strlen($a, 'UTF-8'));
+        $alternatives = implode('|', array_map(fn (string $v) => preg_quote(htmlspecialchars($v, ENT_QUOTES, 'UTF-8'), '/'), $variants));
+        $pattern = $alternatives === '' ? null : '/(?<![\p{L}\p{M}])('.$alternatives.')(?![\p{L}\p{M}])/iu';
+
+        return function (string $html) use ($pattern): string {
+            // 黑体先换成占位符,去标签、解实体、整体转义,再换回 <b>
+            $text = preg_replace('/<span class=["\']bld["\']>(.*?)<\/span>/su', "\u{E000}$1\u{E001}", $html) ?? '';
+            $text = htmlspecialchars(trim(html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8')), ENT_QUOTES, 'UTF-8');
+            if ($pattern !== null) {
+                $text = preg_replace($pattern, '<mark>$1</mark>', $text) ?? $text;
+            }
+
+            return str_replace(["\u{E000}", "\u{E001}"], ['<b>', '</b>'], $text);
+        };
+    }
+}

+ 26 - 0
api-v13/routes/v3/tipitaka.php

@@ -18,14 +18,19 @@
 |
 */
 
+use App\Http\Controllers\V3\PaliWordFormController;
+use App\Http\Controllers\V3\PaliWordSuggestionController;
 use App\Http\Controllers\V3\TipitakaChannelController;
 use App\Http\Controllers\V3\TipitakaChapterChannelController;
 use App\Http\Controllers\V3\TipitakaChapterController;
 use App\Http\Controllers\V3\TipitakaDiscussionController;
+use App\Http\Controllers\V3\TipitakaPageNumberController;
 use App\Http\Controllers\V3\TipitakaParagraphChannelController;
 use App\Http\Controllers\V3\TipitakaReadingController;
 use App\Http\Controllers\V3\TipitakaRelatedParagraphAggregateController;
 use App\Http\Controllers\V3\TipitakaRelatedParagraphController;
+use App\Http\Controllers\V3\TipitakaWordParagraphAggregateController;
+use App\Http\Controllers\V3\TipitakaWordParagraphController;
 use Illuminate\Support\Facades\Route;
 
 // 只有 channel 必填,所以路径上只有它一个变量;book / chapter / para 全是 filter。
@@ -62,3 +67,24 @@ Route::get('tipitaka-related-paragraphs/aggregate/{book_name}', [TipitakaRelated
     ->name('tipitaka-related-paragraphs.aggregate.show');
 Route::get('tipitaka-related-paragraphs', [TipitakaRelatedParagraphController::class, 'index'])
     ->name('tipitaka-related-paragraphs.index');
+
+// 词形展开:一个词 → 词根 → 三藏里出现过的词形及次数。取代 v2 case/{word}
+Route::get('pali-word-forms/{word}', PaliWordFormController::class)
+    ->where('word', '[^/]{1,64}')
+    ->name('pali-word-forms.show');
+
+// 巴利词补全(搜索框):前缀 → 三藏里出现过的词形及次数。取代 v2 pali-word-index?view=key
+Route::get('pali-word-suggestions', PaliWordSuggestionController::class)
+    ->name('pali-word-suggestions.index');
+
+// 按词形找段落(逐词表)+ 按书统计。取代 v2 search-pali-wbw / search-pali-wbw-books。
+// 字面量段 aggregate 必须在前
+Route::get('tipitaka-word-paragraphs/aggregate', TipitakaWordParagraphAggregateController::class)
+    ->name('tipitaka-word-paragraphs.aggregate');
+Route::get('tipitaka-word-paragraphs', [TipitakaWordParagraphController::class, 'index'])
+    ->name('tipitaka-word-paragraphs.index');
+
+// 按印本页码(PTS / 缅 / VRI / 泰 / 其他)或 CS 段落号找段落。取代 v2 search-page-number
+Route::get('tipitaka-page-numbers/{page}', TipitakaPageNumberController::class)
+    ->whereNumber('page')
+    ->name('tipitaka-page-numbers.show');

+ 80 - 0
api-v13/tests/Feature/PaliWordFormV3Test.php

@@ -0,0 +1,80 @@
+<?php
+
+use App\Models\WordIndex;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Illuminate\Support\Facades\DB;
+
+uses(RefreshDatabase::class);
+
+/*
+ * GET /v3/pali-word-forms/{word}:词 → 词根 → 三藏里出现过的词形与次数(取代 v2 case/{word})。
+ * 这里断言的是形状而非契约(spectator 未安装,见 v3-resource skill 第 3 步)。
+ */
+
+function wordIndex(string $word, int $count, int $bold = 0): void
+{
+    WordIndex::forceCreate([
+        'id' => random_int(1, PHP_INT_MAX >> 33),
+        'word' => $word,
+        'word_en' => $word,
+        'count' => $count,
+        'normal' => $count - $bold,
+        'bold' => $bold,
+        'is_base' => 0,
+        'len' => mb_strlen($word),
+    ]);
+}
+
+it('lists the forms of the word itself first, sorted by count, with bold counts', function () {
+    wordIndex('vitakko', 1070, 52);
+    wordIndex('vitakkaṃ', 236, 21);
+    wordIndex('vitakkassāti', 3, 2);   // 连音 iti
+    wordIndex('unrelated', 99);
+
+    $res = $this->getJson('/api/v3/pali-word-forms/vitakka')->assertOk();
+
+    $res->assertJsonPath('data.0.base', 'vitakka')
+        ->assertJsonPath('data.0.forms', [
+            ['word' => 'vitakko', 'count' => 1070, 'bold' => 52],
+            ['word' => 'vitakkaṃ', 'count' => 236, 'bold' => 21],
+            ['word' => 'vitakkassāti', 'count' => 3, 'bold' => 2],
+        ])
+        ->assertJsonPath('meta.total', count($res->json('data')));
+
+    expect(collect($res->json('data'))->pluck('forms')->flatten(1)->pluck('word'))->not->toContain('unrelated');
+});
+
+it('is case-insensitive', function () {
+    wordIndex('vitakko', 10);
+
+    $this->getJson('/api/v3/pali-word-forms/Vitakka')
+        ->assertOk()
+        ->assertJsonPath('data.0.base', 'vitakka');
+});
+
+it('returns an empty list when no form occurs in the canon', function () {
+    $this->getJson('/api/v3/pali-word-forms/qqqzzz')
+        ->assertOk()
+        ->assertJsonPath('data', [])
+        ->assertJsonPath('meta.total', 0);
+});
+
+it('rejects an over-long word with 404 (path constraint)', function () {
+    $this->getJson('/api/v3/pali-word-forms/'.str_repeat('a', 65))->assertNotFound();
+});
+
+it('looks up all candidate forms in a single query', function () {
+    wordIndex('vitakko', 10);
+    wordIndex('dhammo', 10);
+
+    $queries = function (string $word): int {
+        DB::flushQueryLog();
+        DB::enableQueryLog();
+        $this->getJson("/api/v3/pali-word-forms/{$word}")->assertOk();
+
+        return count(DB::getQueryLog());
+    };
+
+    // 词根多少、候选词形多少都不影响查询次数
+    expect($queries('vitakka'))->toBe($queries('dhammo'))->toBe(1);
+});

+ 50 - 0
api-v13/tests/Feature/PaliWordSuggestionV3Test.php

@@ -0,0 +1,50 @@
+<?php
+
+use App\Models\WordIndex;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+
+uses(RefreshDatabase::class);
+
+/*
+ * GET /v3/pali-word-suggestions:搜索框的巴利词补全(取代 v2 pali-word-index?view=key)。
+ * 这里断言的是形状而非契约(spectator 未安装,见 v3-resource skill 第 3 步)。
+ */
+
+function suggestWord(string $word, string $wordEn, int $count, int $bold = 0): void
+{
+    WordIndex::forceCreate([
+        'id' => random_int(1, PHP_INT_MAX >> 33),
+        'word' => $word, 'word_en' => $wordEn, 'count' => $count, 'normal' => $count - $bold,
+        'bold' => $bold, 'is_base' => 0, 'len' => mb_strlen($word),
+    ]);
+}
+
+it('completes a prefix, exact match first then by count, matching words without diacritics', function () {
+    suggestWord('dhammā', 'dhamma', 19436, 413);
+    suggestWord('dhammaṃ', 'dhammam', 19963, 739);
+    suggestWord('dhammassa', 'dhammassa', 7423, 64);
+    suggestWord('adhamma', 'adhamma', 500);       // 不是前缀
+
+    $this->getJson('/api/v3/pali-word-suggestions?q=Dhamma')
+        ->assertOk()
+        ->assertJsonPath('meta.total', 3)
+        ->assertJsonPath('data', [
+            ['word' => 'dhammā', 'count' => 19436, 'bold' => 413],   // 去变音后与输入相同
+            ['word' => 'dhammaṃ', 'count' => 19963, 'bold' => 739],
+            ['word' => 'dhammassa', 'count' => 7423, 'bold' => 64],
+        ]);
+
+    $this->getJson('/api/v3/pali-word-suggestions?q=dhamma&limit=1')->assertJsonCount(1, 'data');
+});
+
+it('treats LIKE wildcards in the input literally', function () {
+    suggestWord('dhammo', 'dhammo', 10);
+
+    $this->getJson('/api/v3/pali-word-suggestions?q=dh%25')->assertOk()->assertJsonCount(0, 'data');
+    $this->getJson('/api/v3/pali-word-suggestions?q=dh_mmo')->assertOk()->assertJsonCount(0, 'data');
+});
+
+it('rejects a missing prefix and a limit out of range', function () {
+    $this->getJson('/api/v3/pali-word-suggestions')->assertStatus(422)->assertJsonValidationErrors('q');
+    $this->getJson('/api/v3/pali-word-suggestions?q=a&limit=51')->assertStatus(422)->assertJsonValidationErrors('limit');
+});

+ 102 - 0
api-v13/tests/Feature/TipitakaPageNumberV3Test.php

@@ -0,0 +1,102 @@
+<?php
+
+use App\Models\BookTitle;
+use App\Models\PageNumber;
+use App\Models\PaliText;
+use App\Models\Tag;
+use App\Models\TagMap;
+use App\Models\WbwTemplate;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Str;
+
+uses(RefreshDatabase::class);
+
+/*
+ * GET /v3/tipitaka-page-numbers/{page}:按印本页码 / CS 段落号找段落(取代 v2 search-page-number)。
+ * 这里断言的是形状而非契约(spectator 未安装,见 v3-resource skill 第 3 步)。
+ */
+
+function pageMark(string $type, int $volume, int $page, int $book, int $para, int $bookId): void
+{
+    PageNumber::forceCreate([
+        'type' => $type, 'volume' => $volume, 'page' => $page, 'book' => $book,
+        'paragraph' => $para, 'wid' => 1, 'pcd_book_id' => $bookId,
+    ]);
+}
+
+/**
+ * @param  list<string>  $tags
+ */
+function pageBook(int $bookId, int $book, string $toc, array $tags = []): void
+{
+    BookTitle::forceCreate(['sn' => $bookId, 'book' => $book, 'paragraph' => 3, 'title' => $toc]);
+    $head = PaliText::forceCreate([
+        'book' => $book, 'paragraph' => 3, 'level' => 1, 'class' => '', 'toc' => $toc,
+        'text' => '', 'html' => '', 'uid' => (string) Str::uuid(),
+    ]);
+    foreach ($tags as $name) {
+        $tag = Tag::forceCreate(['name' => $name, 'owner_id' => (string) Str::uuid()]);
+        TagMap::forceCreate(['table_name' => 'pali_texts', 'anchor_id' => $head->uid, 'tag_id' => $tag->id]);
+    }
+}
+
+it('finds a page across editions plus CS paragraph numbers, ordered by edition', function () {
+    // book_id 100 在静态书名表里:PTS 书名 dīghanikāya
+    pageBook(100, 94, '(DN) Mahāvaggapāḷi', ['sutta', 'mūla']);
+    pageMark('M', 0, 100, 94, 50, 100);
+    pageMark('P', 2, 100, 94, 40, 100);
+    pageMark('P', 2, 101, 94, 41, 100);       // 别的页
+    WbwTemplate::forceCreate([
+        'book' => 94, 'paragraph' => 60, 'wid' => 1, 'word' => 'para100', 'real' => 'para100', 'type' => '',
+        'gramma' => '', 'part' => '', 'style' => '', 'pcd_book_id' => 100, 'weight' => 1,
+    ]);
+
+    $this->getJson('/api/v3/tipitaka-page-numbers/100')
+        ->assertOk()
+        ->assertJsonPath('meta.total', 3)
+        ->assertJsonPath('data.*.edition', ['PTS', 'My', 'CS'])
+        ->assertJsonPath('data.0', [
+            'edition' => 'PTS', 'volume' => 2, 'page' => 100, 'book' => 94, 'para' => 40, 'book_id' => 100,
+            'book_title' => '(DN) Mahāvaggapāḷi', 'book_para' => 3, 'edition_title' => 'dīghanikāya', 'layer' => 'mula',
+            'tags' => ['sutta', 'mūla'],
+        ])
+        ->assertJsonPath('data.1.volume', null)         // 卷号 0 = 未知
+        ->assertJsonPath('data.2.edition_title', null);
+});
+
+it('filters by edition and volume; a volume excludes CS paragraph numbers', function () {
+    pageMark('P', 2, 100, 94, 40, 100);
+    pageMark('P', 3, 100, 95, 40, 101);
+    pageMark('M', 2, 100, 94, 50, 100);
+    WbwTemplate::forceCreate([
+        'book' => 94, 'paragraph' => 60, 'wid' => 1, 'word' => 'para100', 'real' => 'para100', 'type' => '',
+        'gramma' => '', 'part' => '', 'style' => '', 'pcd_book_id' => 100, 'weight' => 1,
+    ]);
+
+    $this->getJson('/api/v3/tipitaka-page-numbers/100?edition=PTS')->assertJsonPath('data.*.volume', [2, 3]);
+    $this->getJson('/api/v3/tipitaka-page-numbers/100?volume=2')->assertJsonPath('data.*.edition', ['PTS', 'My']);
+    $this->getJson('/api/v3/tipitaka-page-numbers/100?edition=CS')->assertJsonPath('data.*.para', [60]);
+});
+
+it('rejects invalid filters and non-numeric pages', function () {
+    $this->getJson('/api/v3/tipitaka-page-numbers/100?edition=P')->assertStatus(422)->assertJsonValidationErrors('edition');
+    $this->getJson('/api/v3/tipitaka-page-numbers/100?volume=0')->assertStatus(422)->assertJsonValidationErrors('volume');
+    $this->getJson('/api/v3/tipitaka-page-numbers/abc')->assertNotFound();
+});
+
+it('does not query per row', function () {
+    $queries = function (int $rows): int {
+        PageNumber::query()->delete();
+        for ($i = 1; $i <= $rows; $i++) {
+            pageMark('P', 1, 100, 1, $i, $i);
+        }
+        DB::flushQueryLog();
+        DB::enableQueryLog();
+        $this->getJson('/api/v3/tipitaka-page-numbers/100')->assertOk()->assertJsonCount($rows, 'data');
+
+        return count(DB::getQueryLog());
+    };
+
+    expect($queries(2))->toBe($queries(12));
+});

+ 140 - 0
api-v13/tests/Feature/TipitakaWordParagraphV3Test.php

@@ -0,0 +1,140 @@
+<?php
+
+use App\Models\BookTitle;
+use App\Models\PageNumber;
+use App\Models\PaliText;
+use App\Models\Tag;
+use App\Models\TagMap;
+use App\Models\WbwTemplate;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Str;
+
+uses(RefreshDatabase::class);
+
+/*
+ * GET /v3/tipitaka-word-paragraphs (+ /aggregate):按词形找段落、按书统计(取代 v2 search-pali-wbw / -books)。
+ * 这里断言的是形状而非契约(spectator 未安装,见 v3-resource skill 第 3 步)。
+ */
+
+function wbwToken(int $book, int $para, string $real, array $attrs = []): void
+{
+    WbwTemplate::forceCreate($attrs + [
+        'book' => $book, 'paragraph' => $para, 'wid' => 1, 'word' => $real, 'real' => $real,
+        'type' => '', 'gramma' => '', 'part' => '', 'style' => '', 'pcd_book_id' => $book, 'weight' => 1,
+    ]);
+}
+
+function wordPara(int $book, int $para, string $html, array $attrs = []): PaliText
+{
+    return PaliText::forceCreate($attrs + [
+        'book' => $book, 'paragraph' => $para, 'level' => 100, 'class' => '', 'toc' => '', 'text' => '',
+        'html' => $html, 'uid' => (string) Str::uuid(),
+        'path' => json_encode([
+            ['book' => $book, 'paragraph' => 1, 'title' => "Book {$book}", 'level' => '1'],
+            ['book' => $book, 'paragraph' => 2, 'title' => 'Chapter', 'level' => 2],
+        ]),
+    ]);
+}
+
+it('lists matching paragraphs by weight with path, safe highlighted text and page refs', function () {
+    wordPara(1, 10, '<p class="bodytext">Vitakketīti <span class="bld">vitakko</span>. <script>x</script> &amp; vitakkaṃ</p>');
+    wbwToken(1, 10, 'vitakko', ['style' => 'bld', 'weight' => 10]);
+    wbwToken(1, 10, 'vitakkaṃ', ['weight' => 1]);
+    wordPara(1, 20, '<p>vitakko</p>');
+    wbwToken(1, 20, 'vitakko', ['weight' => 1]);
+    PageNumber::forceCreate(['type' => 'P', 'volume' => 2, 'page' => 300, 'book' => 1, 'paragraph' => 10, 'wid' => 5, 'pcd_book_id' => 1]);
+    PageNumber::forceCreate(['type' => 'P', 'volume' => 2, 'page' => 299, 'book' => 1, 'paragraph' => 10, 'wid' => 1, 'pcd_book_id' => 1]);
+
+    $res = $this->getJson('/api/v3/tipitaka-word-paragraphs?words=vitakko,vitakkaṃ')->assertOk();
+
+    $res->assertJsonPath('meta.total', 2)
+        ->assertJsonPath('data.*.id', ['1-10', '1-20'])
+        ->assertJsonPath('data.0.score', 11)
+        ->assertJsonPath('data.0.hits', 2)
+        ->assertJsonPath('data.0.title', 'Chapter')
+        ->assertJsonPath('data.0.path.0', ['book' => 1, 'para' => 1, 'title' => 'Book 1', 'level' => 1])
+        ->assertJsonPath('data.0.refs.0', ['type' => 'PTS', 'volume' => 2, 'page' => 299, 'title' => 'Nam'])
+        ->assertJsonPath('data.0.refs.1.type', 'WP');
+
+    // 只有 <b> 与 <mark>,其余已转义;「Vitakketīti」不是命中词形,不标
+    expect($res->json('data.0.text'))
+        ->toBe('Vitakketīti <b><mark>vitakko</mark></b>. x &amp; <mark>vitakkaṃ</mark>');
+});
+
+it('filters bold-only, bold-excluded and by book_id', function () {
+    wordPara(1, 1, '<p>a</p>');
+    wordPara(2, 1, '<p>b</p>');
+    wbwToken(1, 1, 'vitakko', ['style' => 'bld']);
+    wbwToken(2, 1, 'vitakko');
+
+    $this->getJson('/api/v3/tipitaka-word-paragraphs?words=vitakko&bold=only')->assertJsonPath('data.*.id', ['1-1']);
+    $this->getJson('/api/v3/tipitaka-word-paragraphs?words=vitakko&bold=exclude')->assertJsonPath('data.*.id', ['2-1']);
+    $this->getJson('/api/v3/tipitaka-word-paragraphs?words=vitakko&book_id=2')->assertJsonPath('data.*.id', ['2-1']);
+});
+
+it('never matches the blank tokens when words has empty items', function () {
+    wordPara(1, 1, '<p>a</p>');
+    wbwToken(1, 1, '');
+
+    $this->getJson('/api/v3/tipitaka-word-paragraphs?words=,,')->assertStatus(422)->assertJsonValidationErrors('words');
+});
+
+it('rejects invalid parameters', function (array $query, string $field) {
+    $this->getJson('/api/v3/tipitaka-word-paragraphs?'.http_build_query($query))
+        ->assertStatus(422)
+        ->assertJsonValidationErrors($field);
+})->with([
+    'missing words' => [[], 'words'],
+    'bad bold' => [['words' => 'x', 'bold' => 'on'], 'bold'],
+    'bad book_id' => [['words' => 'x', 'book_id' => '1,a'], 'book_id'],
+    'per_page too large' => [['words' => 'x', 'per_page' => 101], 'per_page'],
+    'too many words' => [['words' => implode(',', range(1, 201))], 'words'],
+]);
+
+it('does not query per row', function () {
+    $queries = function (int $rows): int {
+        WbwTemplate::query()->delete();
+        for ($i = 1; $i <= $rows; $i++) {
+            wordPara(1, 100 + $i, '<p>vitakko</p>');
+            wbwToken(1, 100 + $i, 'vitakko');
+            PageNumber::forceCreate(['type' => 'M', 'volume' => 1, 'page' => $i, 'book' => 1, 'paragraph' => 100 + $i, 'wid' => 1, 'pcd_book_id' => 1]);
+        }
+        DB::flushQueryLog();
+        DB::enableQueryLog();
+        $this->getJson('/api/v3/tipitaka-word-paragraphs?words=vitakko')->assertOk()->assertJsonCount($rows, 'data');
+
+        return count(DB::getQueryLog());
+    };
+
+    expect($queries(2))->toBe($queries(10));
+});
+
+it('aggregates paragraphs and occurrences per book with layer from the book tags', function () {
+    $head = wordPara(5, 3, '', ['level' => 1, 'toc' => 'Dhammasaṅgaṇīpāḷi']);
+    BookTitle::forceCreate(['sn' => 79, 'book' => 5, 'paragraph' => 3, 'title' => 'dhs']);
+    $owner = (string) Str::uuid();
+    foreach (['abhidhamma', 'mūla'] as $name) {
+        $tag = Tag::forceCreate(['name' => $name, 'owner_id' => $owner]);
+        TagMap::forceCreate(['table_name' => 'pali_texts', 'anchor_id' => $head->uid, 'tag_id' => $tag->id]);
+    }
+    wbwToken(5, 10, 'vitakko', ['pcd_book_id' => 79]);
+    wbwToken(5, 10, 'vitakkaṃ', ['pcd_book_id' => 79]);
+    wbwToken(5, 11, 'vitakko', ['pcd_book_id' => 79]);
+    wbwToken(9, 1, 'vitakko', ['pcd_book_id' => 99]);   // 没有 book_titles 的书
+
+    $this->getJson('/api/v3/tipitaka-word-paragraphs/aggregate?words=vitakko,vitakkaṃ')
+        ->assertOk()
+        ->assertJsonPath('meta', ['total' => 2, 'paragraphs' => 3, 'occurrences' => 4])
+        ->assertJsonPath('data.0.book_id', 79)
+        ->assertJsonPath('data.0.title', 'Dhammasaṅgaṇīpāḷi')
+        ->assertJsonPath('data.0.layer', 'mula')
+        ->assertJsonPath('data.0.paragraphs', 2)
+        ->assertJsonPath('data.0.occurrences', 3)
+        ->assertJsonPath('data.1.book_id', 99)
+        ->assertJsonPath('data.1.layer', null);
+});
+
+it('requires words on the aggregate endpoint', function () {
+    $this->getJson('/api/v3/tipitaka-word-paragraphs/aggregate')->assertStatus(422)->assertJsonValidationErrors('words');
+});

+ 28 - 0
dashboard-test/src/tests/pali-word-forms.spec.ts

@@ -0,0 +1,28 @@
+import { test, expect } from '@playwright/test';
+import { collect } from '../lib/collect.js';
+
+/**
+ * 词形展开(v3 /pali-word-forms,取代 v2 case):字典页右栏的变格列表。
+ */
+test('字典页的变格列表走 v3 pali-word-forms,不再请求 v2 case', async ({ page }) => {
+  const log = collect(page);
+  const v2: string[] = [];
+  page.on('request', (r) => r.url().includes('/api/v2/case/') && v2.push(r.url()));
+  const forms = page.waitForResponse((r) => r.url().includes('/api/v3/pali-word-forms/vitakka'));
+
+  await page.goto('dictionary/vitakka', { waitUntil: 'networkidle' });
+
+  const res = await forms;
+  expect(res.status()).toBe(200);
+  const body = await res.json();
+  expect(body.data[0].base).toBe('vitakka');
+  // 默认选中词形最多的那组,组内全部勾选
+  type Group = { base: string; forms: { word: string }[] };
+  const group = (body.data as Group[]).reduce((a, b) => (b.forms.length > a.forms.length ? b : a));
+  const top = group.forms[0].word;
+  console.log(`>>> vitakka:${body.meta.total} 组;默认选中 ${group.base},最常见词形 ${top}`);
+
+  await expect(page.getByRole('checkbox', { name: new RegExp(`^${top}[\\s\\d,]*$`) })).toBeChecked();
+  expect(v2).toEqual([]);
+  log.dump('字典变格列表');
+});

+ 391 - 0
dashboard-test/src/tests/search.spec.ts

@@ -0,0 +1,391 @@
+import { test, expect, type Page } from '@playwright/test';
+import { collect } from '../lib/collect.js';
+
+/**
+ * workspace 搜索(取代 v4 的 /search 页):主导航「搜索」弹窗 + 整页 /workspace/search。
+ * 全文走 /v3/search(category 分面),标题走 /v3/tipitaka-chapters?q=;定义走 /v3/tipitaka-word-paragraphs,页码走 /v3/tipitaka-page-numbers(输入页码时全文不查)。
+ */
+const CHANNEL = '4a356b64-8e6b-414a-ae81-7dfa2d5b35b6';
+const READING = `workspace/tipitaka/chapter/83-150?channel=${CHANNEL}`;
+
+const searchResponse = (page: Page, test: (u: URL) => boolean = () => true) =>
+  page.waitForResponse((r) => {
+    const u = new URL(r.url());
+    return u.pathname === '/api/v3/search' && test(u);
+  });
+
+const openModal = async (page: Page) => {
+  await page.goto(READING, { waitUntil: 'networkidle' });
+  await page.getByRole('menuitem', { name: '搜索' }).click();
+  const dialog = page.getByRole('dialog');
+  await expect(dialog).toBeVisible();
+  return dialog;
+};
+
+test('主导航打开搜索弹窗:全文与标题同时查询,按层级筛选后分面重算', async ({ page }) => {
+  const log = collect(page);
+  const dialog = await openModal(page);
+
+  const fts = searchResponse(page);
+  const chapters = page.waitForResponse((r) => new URL(r.url()).pathname === '/api/v3/tipitaka-chapters');
+  await dialog.getByRole('combobox').fill('vitakka');
+  await dialog.getByRole('combobox').press('Enter');
+
+  const ftsRes = await fts;
+  expect(ftsRes.status()).toBe(200);
+  const q = new URL(ftsRes.url()).searchParams;
+  expect(q.get('resource_type')).toBe('tipitaka');
+  expect(q.get('granularity')).toBe('paragraph');
+  expect(q.get('facets')).toBe('true');
+  const body = await ftsRes.json();
+  expect(body.meta.total).toBeGreaterThan(0);
+  expect((await chapters).status()).toBe(200);
+  console.log(`>>> 全文 vitakka:${body.meta.total} 段;分类分面 ${body.meta.facets.category.length} 个`);
+
+  // 标签上显示命中数
+  await expect(dialog.getByRole('tab', { name: /全文/ })).toContainText(body.meta.total.toLocaleString());
+  // 第一条结果的坐标
+  await expect(dialog.getByText(body.data[0].related_id, { exact: true }).first()).toBeVisible();
+
+  // 选「义注」→ 带 category 重查,结果全是义注
+  const filtered = searchResponse(page, (u) => u.searchParams.get('category') === 'aṭṭhakathā');
+  await dialog.getByRole('checkbox', { name: /义注/ }).check();
+  const fBody = await (await filtered).json();
+  expect(fBody.meta.total).toBeGreaterThan(0);
+  expect(fBody.meta.total).toBeLessThan(body.meta.total);
+  for (const hit of fBody.data) expect(hit.category).toContain('aṭṭhakathā');
+  console.log(`>>> 筛选义注后:${fBody.meta.total} 段`);
+
+  // 同组单选:再选「复注」替换掉「义注」
+  const replaced = searchResponse(page, (u) => u.searchParams.get('category') === 'ṭīkā');
+  await dialog.getByRole('checkbox', { name: /复注/ }).check();
+  await replaced;
+  await expect(dialog.getByRole('checkbox', { name: /义注/ })).not.toBeChecked();
+
+  // 跨组叠加:再选「论」→ category=ṭīkā,abhidhamma
+  const both = searchResponse(page, (u) => u.searchParams.get('category') === 'ṭīkā,abhidhamma');
+  await dialog.getByRole('checkbox', { name: /论/ }).check();
+  await both;
+
+  log.dump('全文分面');
+});
+
+test('标题标签页按层级筛选;结果链接带上当前 channel,在新标签页打开、弹窗留着', async ({ page }) => {
+  const dialog = await openModal(page);
+  await dialog.getByRole('combobox').fill('vitakka');
+  await dialog.getByRole('combobox').press('Enter');
+  await dialog.getByRole('tab', { name: /标题/ }).click();
+
+  const mula = page.waitForResponse(
+    (r) => new URL(r.url()).pathname === '/api/v3/tipitaka-chapters' && new URL(r.url()).searchParams.get('layer') === 'mula',
+  );
+  await dialog.getByTitle('根本', { exact: true }).click();
+  const body = await (await mula).json();
+  expect(body.data.length).toBeGreaterThan(0);
+  for (const c of body.data) expect(c.layer).toBe('mula');
+
+  const first = body.data[0];
+  // 浮动容器里的链接一律在新标签页打开
+  const opened = page.context().waitForEvent('page');
+  await dialog.getByRole('link', { name: first.title }).first().click();
+  const tab = await opened;
+  await expect(tab).toHaveURL(new RegExp(`workspace/tipitaka/chapter/${first.book}-${first.para}\\?channel=${CHANNEL}`));
+  await tab.close();
+  await expect(dialog).toBeVisible();
+  await expect(page).toHaveURL(/workspace\/tipitaka\/chapter\/83-150/);
+});
+
+test('在新标签页打开整页搜索:条件进地址栏,刷新后仍在', async ({ page }) => {
+  const dialog = await openModal(page);
+  await dialog.getByRole('combobox').fill('vitakka');
+  await dialog.getByRole('combobox').press('Enter');
+  const filtered = searchResponse(page, (u) => u.searchParams.get('category') === 'mūla');
+  await dialog.getByRole('checkbox', { name: /根本/ }).check();
+  await filtered;
+
+  const opened = page.context().waitForEvent('page');
+  await dialog.getByRole('button', { name: 'export' }).click();
+  const full = await opened;
+  await expect(full).toHaveURL(/\/search\?q=vitakka&category=m%C5%ABla/);
+  // 整页是顶层的 /search,不在 workspace 下;原页面的弹窗还在
+  expect(new URL(full.url()).pathname).toMatch(/^\/[^/]+\/search$/);
+  await expect(dialog).toBeVisible();
+
+  const again = searchResponse(full, (u) => u.searchParams.get('category') === 'mūla');
+  await full.reload();
+  await again;
+  await expect(full.getByRole('checkbox', { name: /根本/ })).toBeChecked();
+  await expect(full.getByRole('combobox')).toHaveValue('vitakka');
+});
+
+test('输入数字自动切到页码标签页,全文不查', async ({ page }) => {
+  const dialog = await openModal(page);
+  const fts: string[] = [];
+  page.on('request', (r) => new URL(r.url()).pathname === '/api/v3/search' && fts.push(r.url()));
+  await dialog.getByRole('combobox').fill('2.100');
+  await dialog.getByRole('combobox').press('Enter');
+  await expect(dialog.getByRole('tab', { name: /页码/ })).toHaveAttribute('aria-selected', 'true');
+  await expect(dialog.getByRole('tab', { name: /全文/ })).toHaveText('全文');
+  await dialog.getByRole('tab', { name: /全文/ }).click();
+  await expect(dialog.getByText('这是页码,全文不检索数字')).toBeVisible();
+  expect(fts).toEqual([]);
+});
+
+const wordParagraphs = (page: Page, test: (u: URL) => boolean = () => true) =>
+  page.waitForResponse((r) => {
+    const u = new URL(r.url());
+    return u.pathname === '/api/v3/tipitaka-word-paragraphs' && test(u);
+  });
+
+test('定义标签页:展开词形 → 只看黑体检索,可按书与黑体范围筛选,不再请求 v2', async ({ page }) => {
+  const log = collect(page);
+  const v2: string[] = [];
+  page.on('request', (r) => /\/api\/v2\/(case|search-pali-wbw)/.test(r.url()) && v2.push(r.url()));
+  const dialog = await openModal(page);
+
+  const forms = page.waitForResponse((r) => r.url().includes('/api/v3/pali-word-forms/vitakka'));
+  const paras = wordParagraphs(page, (u) => u.searchParams.get('bold') === 'only');
+  const books = page.waitForResponse((r) => new URL(r.url()).pathname === '/api/v3/tipitaka-word-paragraphs/aggregate');
+  await dialog.getByRole('combobox').fill('vitakka');
+  await dialog.getByRole('combobox').press('Enter');
+
+  const formBody = await (await forms).json();
+  const defaultForms = formBody.data[0].forms.map((f: { word: string }) => f.word);
+  const parasRes = await paras;
+  expect(new URL(parasRes.url()).searchParams.get('words')?.split(',')).toEqual(defaultForms);
+  const parasBody = await parasRes.json();
+  expect(parasBody.meta.total).toBeGreaterThan(0);
+  const booksBody = await (await books).json();
+  console.log(`>>> 定义 vitakka:${defaultForms.length} 个词形,只看黑体 ${parasBody.meta.total} 段,分布在 ${booksBody.meta.total} 本书`);
+
+  await dialog.getByRole('tab', { name: /定义/ }).click();
+  await expect(dialog.getByRole('tab', { name: /定义/ })).toContainText(parasBody.meta.total.toLocaleString());
+  // 正文里黑体与命中词都标出来了
+  await expect(dialog.locator('.search-definition-text mark').first()).toBeVisible();
+  await expect(dialog.getByText(parasBody.data[0].id, { exact: true }).first()).toBeVisible();
+
+  // 勾选一本书 → 带 book_id 重查
+  const first = booksBody.data[0];
+  const byBook = wordParagraphs(page, (u) => u.searchParams.get('book_id') === String(first.book_id));
+  await dialog.getByRole('checkbox', { name: new RegExp(`^${first.title.replace(/[()]/g, '\\$&')}`) }).check();
+  const byBookBody = await (await byBook).json();
+  expect(byBookBody.meta.total).toBe(first.paragraphs);
+
+  // 改成「全部出现」→ 不带 bold,命中更多
+  const all = wordParagraphs(page, (u) => !u.searchParams.has('bold') && !u.searchParams.has('book_id'));
+  await dialog.getByText('全部出现', { exact: true }).click();
+  const allBody = await (await all).json();
+  expect(allBody.meta.total).toBeGreaterThan(parasBody.meta.total);
+
+  // 取消一个词形 → words 少一个
+  const fewer = wordParagraphs(page, (u) => u.searchParams.get('words')?.split(',').length === defaultForms.length - 1);
+  await dialog.getByRole('checkbox', { name: new RegExp(`^${defaultForms[0]}[\\s\\d,]*$`) }).first().uncheck();
+  await fewer;
+
+  expect(v2).toEqual([]);
+  log.dump('定义标签页');
+});
+
+test('定义标签页:多个词提示改用全文', async ({ page }) => {
+  const dialog = await openModal(page);
+  await dialog.getByRole('combobox').fill('vitakka vicāra');
+  await dialog.getByRole('combobox').press('Enter');
+  await dialog.getByRole('tab', { name: /定义/ }).click();
+  await expect(dialog.getByText('定义检索只支持单个词')).toBeVisible();
+});
+
+test('定义标签页:目录树按书的 tag 限定范围,条件进地址栏', async ({ page }) => {
+  const books = page.waitForResponse((r) => new URL(r.url()).pathname === '/api/v3/tipitaka-word-paragraphs/aggregate');
+  await page.goto('search?q=vitakka&tab=definition', { waitUntil: 'networkidle' });
+  const booksBody = await books.then((r) => r.json());
+  type Book = { book_id: number; tags: string[]; paragraphs: number };
+  const sutta = (booksBody.data as Book[]).filter((b) => b.tags.includes('sutta'));
+  const expected = sutta.reduce((n, b) => n + b.paragraphs, 0);
+
+  // 点「suttapiṭaka」→ 带上经藏全部命中书的 book_id 重查,总数等于这些书的段落数之和
+  const scoped = wordParagraphs(page, (u) => (u.searchParams.get('book_id') ?? '').split(',').length === sutta.length);
+  await page.getByText('suttapiṭaka', { exact: true }).first().click();
+  const scopedBody = await (await scoped).json();
+  expect(scopedBody.meta.total).toBe(expected);
+  await expect(page).toHaveURL(/scope=sutta/);
+  console.log(`>>> 定义 vitakka 只看黑体,限经藏:${sutta.length} 本书 ${expected} 段`);
+
+  // 刷新后范围还在
+  const again = wordParagraphs(page, (u) => u.searchParams.has('book_id'));
+  await page.reload();
+  expect((await (await again).json()).meta.total).toBe(expected);
+
+  // 清除选择 → 不再限定书
+  const cleared = wordParagraphs(page, (u) => !u.searchParams.has('book_id'));
+  await page.getByRole('button', { name: '清除选择' }).click();
+  await cleared;
+});
+
+const pageNumbers = (page: Page, test: (u: URL) => boolean = () => true) =>
+  page.waitForResponse((r) => {
+    const u = new URL(r.url());
+    return u.pathname.startsWith('/api/v3/tipitaka-page-numbers/') && test(u);
+  });
+
+test('页码标签页:输入页码自动切换、按版本分组,点进去在新标签页打开印本页阅读页', async ({ page }) => {
+  const log = collect(page);
+  const v2: string[] = [];
+  page.on('request', (r) => r.url().includes('/api/v2/search-page-number') && v2.push(r.url()));
+  const dialog = await openModal(page);
+
+  const res = pageNumbers(page, (u) => u.pathname.endsWith('/100') && !u.searchParams.has('volume'));
+  await dialog.getByRole('combobox').fill('100');
+  await dialog.getByRole('combobox').press('Enter');
+  const body = await (await res).json();
+  expect(body.meta.total).toBeGreaterThan(0);
+  await expect(dialog.getByRole('tab', { name: /页码/ })).toHaveAttribute('aria-selected', 'true');
+  await expect(dialog.getByRole('tab', { name: /页码/ })).toContainText(body.meta.total.toLocaleString());
+  const pts = (body.data as { edition: string }[]).filter((h) => h.edition === 'PTS').length;
+  console.log(`>>> 页码 100:共 ${body.meta.total} 处,PTS ${pts} 处`);
+
+  // 默认 PTS;点一条 → 新标签页打开印本页阅读页,能取到这一页
+  const opened = page.context().waitForEvent('page');
+  await dialog.locator('a[href*="/workspace/tipitaka/page/P_"]').first().click();
+  const tab = await opened;
+  const nav = await tab.waitForResponse((r) => r.url().includes('/api/v2/nav-page/'));
+  expect(nav.status()).toBe(200);
+  expect((await nav.json()).ok).toBe(true);
+  await tab.close();
+  await expect(dialog).toBeVisible();
+
+  // 切到 CS 段落号 → 链接指向 cs-para 阅读页
+  await dialog.getByText('CS 段落号').click();
+  const csOpened = page.context().waitForEvent('page');
+  await dialog.locator('a[href*="/workspace/tipitaka/cs-para/"]').first().click();
+  const csTab = await csOpened;
+  const csNav = await csTab.waitForResponse((r) => r.url().includes('/api/v2/nav-cs-para/'));
+  expect((await csNav.json()).ok).toBe(true);
+  await csTab.close();
+
+  expect(v2).toEqual([]);
+  log.dump('页码标签页');
+});
+
+test('页码标签页:「卷.页」只查这一卷;非页码时给出提示', async ({ page }) => {
+  const res = pageNumbers(page, (u) => u.pathname.endsWith('/100') && u.searchParams.get('volume') === '2');
+  await page.goto('search?q=2.100&tab=page', { waitUntil: 'networkidle' });
+  const body = await (await res).json();
+  for (const h of body.data) expect(h.volume).toBe(2);
+  await expect(page.getByText(`第 2 卷第 100 页共 ${body.meta.total} 处`)).toBeVisible();
+
+  await page.goto('search?q=vitakka&tab=page', { waitUntil: 'networkidle' });
+  await expect(page.getByText('输入页码数字')).toBeVisible();
+});
+
+test('页码标签页:目录树按书的 tag 过滤,版本计数跟着变,条件进地址栏', async ({ page }) => {
+  const res = pageNumbers(page, (u) => u.pathname.endsWith('/100'));
+  await page.goto('search?q=100&tab=page', { waitUntil: 'networkidle' });
+  await expect(page).toHaveTitle('100 - 页码 - 搜索');
+  type Hit = { edition: string; tags: string[]; book_title: string };
+  const hits = (await (await res).json()).data as Hit[];
+  const pts = hits.filter((h) => h.edition === 'PTS');
+  const ptsSutta = pts.filter((h) => h.tags.includes('sutta'));
+  expect(ptsSutta.length).toBeGreaterThan(0);
+  expect(ptsSutta.length).toBeLessThan(pts.length);
+  const ptsOption = page.locator('.ant-segmented-item').filter({ hasText: 'PTS' });
+  await expect(ptsOption).toContainText(String(pts.length));
+
+  // 点「suttapiṭaka」→ 只剩经藏的书,不重新请求
+  let refetched = false;
+  page.on('request', (r) => r.url().includes('/api/v3/tipitaka-page-numbers') && (refetched = true));
+  await page.getByText('suttapiṭaka', { exact: true }).first().click();
+  await expect(page).toHaveURL(/page_scope=sutta/);
+  await expect(ptsOption).toContainText(String(ptsSutta.length));
+  const outside = pts.find((h) => !h.tags.includes('sutta'))!;
+  await expect(page.getByText(outside.book_title, { exact: true })).toHaveCount(0);
+  expect(refetched).toBe(false);
+  console.log(`>>> 页码 100 PTS:${pts.length} 处,限经藏 ${ptsSutta.length} 处`);
+
+  // 刷新后范围还在
+  await page.reload({ waitUntil: 'networkidle' });
+  await expect(ptsOption).toContainText(String(ptsSutta.length));
+  expect(refetched).toBe(true); // 刷新才会重新请求
+});
+
+test('目录树默认单选;多选时选了子目录父目录取消、选了父目录子目录取消', async ({ page }) => {
+  await page.goto('search?q=100&tab=page', { waitUntil: 'networkidle' });
+  const scope = () => new URL(page.url()).searchParams.get('page_scope');
+  // 节点按 title 属性(巴利原名)找:显示的文字会按界面语言译成「律藏」「长部」
+  const node = (selector: string) => page.locator(`.ant-tree-node-content-wrapper${selector}`).first();
+
+  // 单选:点了别的就换成别的
+  await node('[title^="suttapi"]').click();
+  await expect.poll(scope).toBe('sutta');
+  await node('[title^="vinayapi"]').click();
+  await expect.poll(scope).toBe('vinaya');
+
+  // 打开多选:经藏与律藏可以并存;再选经藏下的长部,经藏取消
+  await page.getByRole('switch').click();
+  await node('[title^="suttapi"]').click();
+  await expect.poll(scope).toBe('vinaya;sutta');
+  await node('[title^="d"][title*="ghanik"]').click();
+  await expect.poll(scope).toBe('vinaya;sutta,dīghanikāya');
+  // 再选回经藏,长部取消
+  await node('[title^="suttapi"]').click();
+  await expect.poll(scope).toBe('vinaya;sutta');
+  // 地址栏先变、树后渲染:等树上的选中状态跟上再切换
+  await expect(node('[title^="d"][title*="ghanik"]')).not.toHaveClass(/ant-tree-node-selected/);
+  await expect(node('[title^="suttapi"]')).toHaveClass(/ant-tree-node-selected/);
+
+  // 切回单选只留最后选的
+  await page.getByRole('switch').click();
+  await expect.poll(scope).toBe('sutta');
+});
+
+test('搜索框补全巴利词:不打变音也能补全,回车搜原文,选候选替换最后一个词并搜索', async ({ page }) => {
+  const v2: string[] = [];
+  page.on('request', (r) => r.url().includes('/api/v2/pali-word-index') && v2.push(r.url()));
+  const dialog = await openModal(page);
+  const box = dialog.getByRole('combobox');
+
+  const suggest = page.waitForResponse((r) => {
+    const u = new URL(r.url());
+    return u.pathname === '/api/v3/pali-word-suggestions' && u.searchParams.get('q') === 'dhamma';
+  });
+  await box.fill('dhamma');
+  const body = await (await suggest).json();
+  const words = (body.data as { word: string }[]).map((w) => w.word);
+  expect(words.length).toBeGreaterThan(1);
+  const options = page.locator('.ant-select-dropdown:visible .ant-select-item-option');
+  await expect(options.first()).toContainText(words[0]);
+  console.log(`>>> 补全 dhamma:${words.slice(0, 5).join(', ')}`);
+
+  // 直接回车:搜的是输入的原文,不是第一个候选
+  const plain = searchResponse(page, (u) => u.searchParams.get('q') === 'dhamma');
+  await box.press('Enter');
+  await plain;
+  await expect(options).toHaveCount(0); // 搜索之后候选收起,不挡标签页
+
+  // 多个词时补全最后一个;方向键选第二个候选回车 → 替换最后一个词并搜索
+  const second = page.waitForResponse((r) => new URL(r.url()).searchParams.get('q') === 'vitakk');
+  await box.fill('sati vitakk');
+  const secondBody = await (await second).json();
+  const pick = (secondBody.data as { word: string }[])[1].word;
+  await expect(options.nth(1)).toContainText(pick);
+  const picked = searchResponse(page, (u) => u.searchParams.get('q') === `sati ${pick}`);
+  const queries: string[] = [];
+  page.on('request', (r) => {
+    const u = new URL(r.url());
+    if (u.pathname === '/api/v3/search') queries.push(u.searchParams.get('q') ?? '');
+  });
+  await box.press('ArrowDown');
+  await box.press('ArrowDown');
+  await box.press('Enter');
+  await picked;
+  await page.waitForTimeout(500);
+  await expect(box).toHaveValue(`sati ${pick}`);
+  expect(queries).toEqual([`sati ${pick}`]); // 回车只搜选中的候选,不再拿原文多搜一次
+
+  // 页码不补全
+  let pageSuggest = false;
+  page.on('request', (r) => r.url().includes('/api/v3/pali-word-suggestions?q=100') && (pageSuggest = true));
+  await box.fill('100');
+  await page.waitForTimeout(600);
+  expect(pageSuggest).toBe(false);
+  expect(v2).toEqual([]);
+});

+ 3 - 0
dashboard-v6/src/Router.tsx

@@ -38,6 +38,8 @@ const UsersResetPassword = lazy(() => import("./pages/users/reset-password"));
 const DashboardIndex = lazy(() => import("./pages/dashboard/index"));
 
 const Home = lazy(() => import("./pages/home"));
+// 整页搜索;workspace 的搜索弹窗「在整页打开」跳到这里
+const Search = lazy(() => import("./pages/search"));
 const WorkspaceHome = lazy(() => import("./pages/workspace/home"));
 const WorkspaceChat = lazy(() => import("./pages/workspace/chat"));
 
@@ -48,6 +50,7 @@ const router = createBrowserRouter(
       Component: RootLayout,
       children: [
         { index: true, Component: Home },
+        { path: "search", Component: Search },
         // 字典、语法手册:/dictionary、/grammar-book
         ...dictionaryRoutes,
         {

+ 0 - 14
dashboard-v6/src/api/dict.ts

@@ -107,20 +107,6 @@ export interface IUserDictDeleteRequest {
   id: string;
 }
 
-export interface ICaseItem {
-  word: string;
-  case: ICaseListData[];
-  count: number;
-}
-export interface ICaseListResponse {
-  ok: boolean;
-  message: string;
-  data: {
-    rows: ICaseItem[];
-    count: number;
-  };
-}
-
 export interface IFirstMeaning {
   word?: string;
   meaning?: string;

+ 65 - 0
dashboard-v6/src/api/pali-word-form.ts

@@ -0,0 +1,65 @@
+// src/api/pali-word-form.ts
+//
+// v3 词形展开(取代 v2 case/{word}):一个词 → 词根 → 三藏里出现过的词形与次数。
+import { api, unwrap, unwrapQuiet } from "./client";
+import type { paths } from "./schema";
+
+type Body =
+  paths["/v3/pali-word-forms/{word}"]["get"]["responses"][200]["content"]["application/json"];
+
+type RawGroup = NonNullable<Body["data"]>[number];
+export type WordForm = Required<NonNullable<RawGroup["forms"]>[number]>;
+export interface WordFormGroup {
+  base: string;
+  forms: WordForm[];
+}
+
+/**
+ * 第一组是输入的词本身,其后是推导出的词根;组内按出现次数降序。
+ * `quiet`:失败只抛不弹提示(调用方自己显示错误时用)。
+ */
+export const fetchWordForms = async (
+  word: string,
+  { quiet = false }: { quiet?: boolean } = {},
+): Promise<WordFormGroup[]> =>
+  (
+    (quiet ? unwrapQuiet : unwrap)(
+      await api.GET("/v3/pali-word-forms/{word}", {
+        params: { path: { word } },
+      }),
+    ).data ?? []
+  ).map((g) => ({
+    base: g.base ?? "",
+    forms: (g.forms ?? []).map((f) => ({
+      word: f.word ?? "",
+      count: f.count ?? 0,
+      bold: f.bold ?? 0,
+    })),
+  }));
+
+type SuggestionBody =
+  paths["/v3/pali-word-suggestions"]["get"]["responses"][200]["content"]["application/json"];
+export type WordSuggestion = Required<
+  NonNullable<SuggestionBody["data"]>[number]
+>;
+
+/**
+ * 巴利词补全(取代 v2 pali-word-index?view=key):前缀 → 三藏里出现过的词形。
+ * 与输入相同的在前,其余按出现次数降序;不打变音符号也能补全。失败只抛不弹(补全是辅助功能)。
+ */
+export const fetchWordSuggestions = async (
+  q: string,
+  signal?: AbortSignal,
+): Promise<WordSuggestion[]> =>
+  (
+    unwrapQuiet(
+      await api.GET("/v3/pali-word-suggestions", {
+        params: { query: { q } },
+        signal,
+      }),
+    ).data ?? []
+  ).map((w) => ({
+    word: w.word ?? "",
+    count: w.count ?? 0,
+    bold: w.bold ?? 0,
+  }));

+ 382 - 6
dashboard-v6/src/api/schema.d.ts

@@ -1157,7 +1157,10 @@ export interface paths {
         };
         /**
          * 输入一个单词,输出三藏中所有可能的变形
-         * @description 实现:`CaseController@show`
+         * @deprecated
+         * @description 已被 `GET /v3/pali-word-forms/{word}` 取代:候选词形一次批量查出现次数(v2 逐个词形查库,一个词上百次),
+         *     去掉了每条里多余的 `"0": "ending"` 键,词不区分大小写。字段:`rows[].word`→`data[].base`,`rows[].case`→`data[].forms`,
+         *     `count`→`meta.total`;没有任何词形出现过的词根不再列出。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
          */
         get: operations["get_api_v2_case_case_"];
         /**
@@ -4213,7 +4216,10 @@ export interface paths {
         };
         /**
          * 列出 pali-word-index
-         * @description 实现:`WordIndexController@index`
+         * @deprecated
+         * @description `view=key` 已被 `GET /v3/pali-word-suggestions?q=` 取代:排序从「词长、去变音形」改成「与输入相同的在前,其余按出现次数降序」
+         *     (v2 下短而罕见的词形挤掉常用词),只回 `word` / `count` / `bold` 三个字段,不再整行吐出;输入里的 `%`、`_` 按字面匹配;
+         *     `key`→`q`,`rows`→`data`,`count`→`meta.total`,可用 `limit`(默认 10,上限 50)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
          */
         get: operations["get_api_v2_pali_word_index"];
         put?: never;
@@ -5034,7 +5040,11 @@ export interface paths {
         };
         /**
          * 获取单个 search-page-number/{search_page_number}
-         * @description 实现:`SearchPageNumberController@show`
+         * @deprecated
+         * @description 已被 `GET /v3/tipitaka-page-numbers/{page}` 取代:可按版本 `edition`(PTS / My / VRI / Thai / Other / CS)与卷号 `volume` 过滤,
+         *     每条带书名、书名所在段、层级与该版本的书名(v2 只有坐标)。字段:`type`(单字母)→`edition`,`para` 类型→`edition=CS`,
+         *     `paragraph`→`para`,`pcd_book_id`→`book_id`,卷号 0 → `volume: null`。响应 `{ok, data: [...]}` → `{data, meta: {total}}`。
+         *     保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
          */
         get: operations["get_api_v2_search_page_number_search_page_number_"];
         /**
@@ -5066,13 +5076,19 @@ export interface paths {
         };
         /**
          * 列出 search-pali-wbw
-         * @description 实现:`SearchPaliWbwController@index`
+         * @deprecated
+         * @description 已被 `GET /v3/tipitaka-word-paragraphs` 取代:段落、标题、页码整页批量取(v2 每行另查 3~4 次库);`text` 只含 `<b>` 黑体与
+         *     `<mark>` 命中词的安全 HTML(v2 是整段原始 HTML 加字符串替换);不再给指向旧版 library 的 `link`。参数:`key`→`words`,
+         *     `bold=on|off`→`bold=only|exclude`,`book`→`book_id`,`limit`/`offset`→`per_page`/`page`;`view`、`tags` 去掉。
+         *     字段:`paragraph`→`para`,`rank`→`score`,`paliTitle`→`title`,`highlight`→`text`,`ref`→`refs`(多了 `volume`);`count`→`meta.total`。
+         *     保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
          */
         get: operations["get_api_v2_search_pali_wbw"];
         put?: never;
         /**
          * 新建 search-pali-wbw
-         * @description 实现:`SearchPaliWbwController@store`
+         * @deprecated
+         * @description 与 GET 相同,已被 `GET /v3/tipitaka-word-paragraphs` 取代。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
          */
         post: operations["post_api_v2_search_pali_wbw"];
         delete?: never;
@@ -5090,7 +5106,10 @@ export interface paths {
         };
         /**
          * book_list search-pali-wbw-books
-         * @description 实现:`SearchPaliWbwController@book_list`
+         * @deprecated
+         * @description 已被 `GET /v3/tipitaka-word-paragraphs/aggregate` 取代:同时给段落数 `paragraphs` 与词次 `occurrences`(v2 只有词次 `count`),
+         *     书名、tag 批量取(v2 每本书另查 3 次库),另给 `layer`。字段:`pcdBookId`→`book_id`,`paragraph`→`para`,`paliTitle`→`title`,
+         *     `tags[].name`→`tags`(字符串数组)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
          */
         get: operations["get_api_v2_search_pali_wbw_books"];
         put?: never;
@@ -8914,6 +8933,53 @@ export interface paths {
         patch?: never;
         trace?: never;
     };
+    "/v3/pali-word-forms/{word}": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 词形展开
+         * @description 把一个巴利词还原成可能的词根,列出每个词根在三藏里实际出现过的词形(含 iti / api / ca / hi 连音),
+         *     带出现次数与黑体次数。第一组是输入的词本身,其后是推导出的词根;没有任何词形出现过的词根不列。
+         *     每组内按出现次数降序。词不区分大小写。
+         *
+         *     实现:`V3\PaliWordFormController@__invoke`
+         */
+        get: operations["get_api_v3_pali_word_forms_word_"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
+    "/v3/pali-word-suggestions": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 巴利词补全
+         * @description 按已输入的前缀列出三藏里出现过的词形,带出现次数与黑体次数。前缀同时匹配去掉变音符号的写法
+         *     (输入 dhamma 也能补出 dhammā),不区分大小写。与输入完全相同的词排在最前,其余按出现次数降序。
+         *
+         *     实现:`V3\PaliWordSuggestionController@__invoke`
+         */
+        get: operations["get_api_v3_pali_word_suggestions"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
     "/v3/password-resets": {
         parameters: {
             query?: never;
@@ -9384,6 +9450,30 @@ export interface paths {
         patch?: never;
         trace?: never;
     };
+    "/v3/tipitaka-page-numbers/{page}": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 按页码找段落
+         * @description 一个页码在 PTS、缅甸版、VRI、泰国版、其他里各指一处或多处,另有 CS 版印的段落号(`edition=CS`)。
+         *     返回全部命中(不分页,通常几百条),按版本、书、卷、段排序。每条带书名、层级与该版本的书名。
+         *     卷号未知的记录 `volume` 为 null;给了 `volume` 就只要这一卷(CS 段落号不分卷,不返回)。
+         *
+         *     实现:`V3\TipitakaPageNumberController@__invoke`
+         */
+        get: operations["get_api_v3_tipitaka_page_numbers_page_"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
     "/v3/tipitaka-paragraph-channels/{book}/{para}": {
         parameters: {
             query?: never;
@@ -9503,6 +9593,53 @@ export interface paths {
         patch?: never;
         trace?: never;
     };
+    "/v3/tipitaka-word-paragraphs": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 按词形找段落
+         * @description 在逐词表里精确匹配词形(连音已拆开),返回命中的段落,按命中权重降序、同分按经文顺序。
+         *     词形先用 `GET /v3/pali-word-forms/{word}` 展开——拿词根直接查通常是 0 条。
+         *     每条带整段正文(只含 `<b>` 黑体与 `<mark>` 命中词的安全 HTML)、章节路径与各印本页码。
+         *
+         *     实现:`V3\TipitakaWordParagraphController@index`
+         */
+        get: operations["get_api_v3_tipitaka_word_paragraphs"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
+    "/v3/tipitaka-word-paragraphs/aggregate": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 按书统计命中
+         * @description 与 `GET /v3/tipitaka-word-paragraphs` 同样的检索条件,按书汇总:每本书命中多少段、多少词次,
+         *     按段落数降序,不分页。v2 只给词次;同一段里出现多次只算一段,所以两者不相等。
+         *
+         *     实现:`V3\TipitakaWordParagraphAggregateController@__invoke`
+         */
+        get: operations["get_api_v3_tipitaka_word_paragraphs_aggregate"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
     "/v3/upgrade": {
         parameters: {
             query?: never;
@@ -39967,6 +40104,82 @@ export interface operations {
             422: components["responses"]["ProblemValidation"];
         };
     };
+    get_api_v3_pali_word_forms_word_: {
+        parameters: {
+            query?: never;
+            header?: never;
+            path: {
+                /** @description 巴利词,如 vitakka */
+                word: string;
+            };
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            base?: string;
+                            forms?: {
+                                word?: string;
+                                count?: number;
+                                bold?: number;
+                            }[];
+                        }[];
+                        meta?: {
+                            /** @description 组数 */
+                            total?: number;
+                        };
+                    };
+                };
+            };
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
+    get_api_v3_pali_word_suggestions: {
+        parameters: {
+            query: {
+                /** @description 最多返回几条,上限 50 */
+                limit?: number;
+                /**
+                 * @description 已输入的前缀
+                 * @example vitakk
+                 */
+                q: string;
+            };
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            word?: string;
+                            count?: number;
+                            bold?: number;
+                        }[];
+                        meta?: {
+                            /** @description 本次返回的条数 */
+                            total?: number;
+                        };
+                    };
+                };
+            };
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
     post_api_v3_password_resets: {
         parameters: {
             query?: never;
@@ -41960,6 +42173,59 @@ export interface operations {
             422: components["responses"]["ProblemValidation"];
         };
     };
+    get_api_v3_tipitaka_page_numbers_page_: {
+        parameters: {
+            query?: {
+                /** @description 只要这个版本 */
+                edition?: "PTS" | "My" | "VRI" | "Thai" | "Other" | "CS";
+                /**
+                 * @description 只要这一卷
+                 * @example 2
+                 */
+                volume?: number;
+            };
+            header?: never;
+            path: {
+                /**
+                 * @description 页码(或 CS 段落号)
+                 * @example 100
+                 */
+                page: number;
+            };
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            edition?: string;
+                            volume?: number | null;
+                            page?: number;
+                            book?: number;
+                            para?: number;
+                            book_id?: number;
+                            book_title?: string;
+                            book_para?: number;
+                            edition_title?: string | null;
+                            layer?: string | null;
+                            tags?: string[];
+                        }[];
+                        meta?: {
+                            /** @description 命中数 */
+                            total?: number;
+                        };
+                    };
+                };
+            };
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
     get_api_v3_tipitaka_paragraph_channels_book_para_: {
         parameters: {
             query?: {
@@ -42243,6 +42509,116 @@ export interface operations {
             422: components["responses"]["ProblemValidation"];
         };
     };
+    get_api_v3_tipitaka_word_paragraphs: {
+        parameters: {
+            query: {
+                /**
+                 * @description 词形,逗号分隔,最多 200 个
+                 * @example vitakko,vitakkaṃ
+                 */
+                words: string;
+                /** @description 只看黑体(only,注释书里被解释的词)或排除黑体(exclude);不给则不限 */
+                bold?: "only" | "exclude";
+                /**
+                 * @description 只看这些书,逗号分隔的 book_id(见 `/aggregate`)
+                 * @example 75,79
+                 */
+                book_id?: string;
+                /** @description 页码 */
+                page?: number;
+                /** @description 每页条数,上限 100 */
+                per_page?: number;
+            };
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            id?: string;
+                            book?: number;
+                            para?: number;
+                            score?: number;
+                            hits?: number;
+                            title?: string;
+                            level?: number;
+                            path?: {
+                                book?: number;
+                                para?: number;
+                                title?: string;
+                                level?: number;
+                            }[];
+                            text?: string;
+                            refs?: {
+                                type?: string;
+                                volume?: number | null;
+                                page?: number;
+                                title?: string | null;
+                            }[];
+                        }[];
+                        meta?: components["schemas"]["PaginationMeta"];
+                    };
+                };
+            };
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
+    get_api_v3_tipitaka_word_paragraphs_aggregate: {
+        parameters: {
+            query: {
+                /**
+                 * @description 词形,逗号分隔,最多 200 个
+                 * @example vitakko,vitakkaṃ
+                 */
+                words: string;
+                /** @description 只看黑体(only)或排除黑体(exclude);不给则不限 */
+                bold?: "only" | "exclude";
+            };
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            book_id?: number;
+                            book?: number;
+                            para?: number;
+                            title?: string;
+                            layer?: string | null;
+                            tags?: string[];
+                            paragraphs?: number;
+                            occurrences?: number;
+                        }[];
+                        meta?: {
+                            /** @description 书的数目 */
+                            total?: number;
+                            /** @description 命中段落总数 */
+                            paragraphs?: number;
+                            /** @description 词次总数 */
+                            occurrences?: number;
+                        };
+                    };
+                };
+            };
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
     get_api_v3_upgrade: {
         parameters: {
             query?: never;

+ 150 - 0
dashboard-v6/src/api/tipitaka-search.ts

@@ -0,0 +1,150 @@
+// src/api/tipitaka-search.ts
+//
+// workspace 搜索面板用到的 v3 检索接口:
+// - 全文:`GET /v3/search`(OpenSearch,三藏段落)
+// - 标题:`GET /v3/tipitaka-chapters?q=`(章节名定位)
+import { api, unwrapQuiet } from "./client";
+import type { paths } from "./schema";
+
+/* ─── 全文 ─── */
+
+type SearchOp = paths["/v3/search"]["get"];
+type SearchQuery = SearchOp["parameters"]["query"];
+type SearchBody = SearchOp["responses"][200]["content"]["application/json"];
+
+export type SearchMode = NonNullable<SearchQuery["search_mode"]>;
+export type SearchHit = NonNullable<SearchBody["data"]>[number];
+export type SearchMeta = NonNullable<SearchBody["meta"]>;
+export type FacetBucket = { key: string; count: number };
+
+export interface IFullTextParams {
+  q: string;
+  mode: SearchMode;
+  /** 分类(书的标签),须全部命中 */
+  category: string[];
+  page: number;
+  perPage: number;
+}
+
+/**
+ * 三藏段落全文检索,带分面计数。
+ *
+ * 只查巴利原文段落(resource_type=tipitaka、granularity=paragraph),
+ * 分面只用 category(藏别 / 层级 / 书的标签混在一起,由调用方分组)。
+ * 失败不弹全局提示(unwrapQuiet):搜索面板自己显示错误,503 时也是。
+ */
+export const searchParagraphs = async (p: IFullTextParams) =>
+  unwrapQuiet(
+    await api.GET("/v3/search", {
+      params: {
+        query: {
+          q: p.q,
+          search_mode: p.mode,
+          resource_type: "tipitaka",
+          granularity: "paragraph",
+          category: p.category.length ? p.category.join(",") : undefined,
+          facets: true,
+          page: p.page,
+          per_page: p.perPage,
+        },
+      },
+    }),
+  );
+
+/* ─── 标题 ─── */
+
+type ChapterOp = paths["/v3/tipitaka-chapters"]["get"];
+type ChapterQuery = NonNullable<ChapterOp["parameters"]["query"]>;
+type ChapterBody = ChapterOp["responses"][200]["content"]["application/json"];
+
+export type ChapterLayer = NonNullable<ChapterQuery["layer"]>;
+export type ChapterHit = NonNullable<ChapterBody["data"]>[number];
+
+export interface IChapterParams {
+  q: string;
+  layer?: ChapterLayer;
+  page: number;
+  perPage: number;
+}
+
+/** 按章节名找章节(巴利名或译名,容错拼写与变音符号) */
+export const searchChapters = async (p: IChapterParams) =>
+  unwrapQuiet(
+    await api.GET("/v3/tipitaka-chapters", {
+      params: {
+        query: {
+          q: p.q,
+          layer: p.layer,
+          page: p.page,
+          per_page: p.perPage,
+        },
+      },
+    }),
+  );
+
+/* ─── 定义(逐词表,按词形精确匹配) ─── */
+
+type WordParagraphOp = paths["/v3/tipitaka-word-paragraphs"]["get"];
+type WordParagraphBody =
+  WordParagraphOp["responses"][200]["content"]["application/json"];
+type WordBookBody =
+  paths["/v3/tipitaka-word-paragraphs/aggregate"]["get"]["responses"][200]["content"]["application/json"];
+
+export type WordParagraph = NonNullable<WordParagraphBody["data"]>[number];
+export type WordParagraphMeta = NonNullable<WordParagraphBody["meta"]>;
+export type WordBook = NonNullable<WordBookBody["data"]>[number];
+export type WordBookMeta = NonNullable<WordBookBody["meta"]>;
+export type BoldScope = NonNullable<
+  NonNullable<WordParagraphOp["parameters"]["query"]>["bold"]
+>;
+
+export interface IWordParams {
+  /** 词形(由 /v3/pali-word-forms 展开) */
+  words: string[];
+  bold?: BoldScope;
+}
+
+/** 命中这些词形的段落,按命中权重降序 */
+export const searchWordParagraphs = async (
+  p: IWordParams & { bookIds: number[]; page: number; perPage: number },
+) =>
+  unwrapQuiet(
+    await api.GET("/v3/tipitaka-word-paragraphs", {
+      params: {
+        query: {
+          words: p.words.join(","),
+          bold: p.bold,
+          book_id: p.bookIds.length ? p.bookIds.join(",") : undefined,
+          page: p.page,
+          per_page: p.perPage,
+        },
+      },
+    }),
+  );
+
+/** 命中按书统计:每本书多少段、多少词次 */
+export const aggregateWordBooks = async (p: IWordParams) =>
+  unwrapQuiet(
+    await api.GET("/v3/tipitaka-word-paragraphs/aggregate", {
+      params: { query: { words: p.words.join(","), bold: p.bold } },
+    }),
+  );
+
+/* ─── 页码(印本页码与 CS 段落号) ─── */
+
+type PageNumberOp = paths["/v3/tipitaka-page-numbers/{page}"]["get"];
+type PageNumberBody =
+  PageNumberOp["responses"][200]["content"]["application/json"];
+
+export type PageNumberHit = NonNullable<PageNumberBody["data"]>[number];
+export type PageEdition = NonNullable<
+  NonNullable<PageNumberOp["parameters"]["query"]>["edition"]
+>;
+
+/** 某个页码在各版本里的全部位置(不分页);给了卷号就只要这一卷 */
+export const searchPageNumbers = async (page: number, volume?: number) =>
+  unwrapQuiet(
+    await api.GET("/v3/tipitaka-page-numbers/{page}", {
+      params: { path: { page }, query: { volume } },
+    }),
+  );

+ 29 - 35
dashboard-v6/src/components/dict/CaseList.tsx

@@ -2,12 +2,11 @@ import { Badge, Button, Card, Checkbox, Select, Space, Typography } from "antd";
 import { DownOutlined, UpOutlined } from "@ant-design/icons";
 import { useEffect, useMemo, useReducer, useRef, useState } from "react";
 
-import { get } from "../../request";
-import type {
-  ICaseItem,
-  ICaseListData,
-  ICaseListResponse,
-} from "../../api/dict";
+import {
+  fetchWordForms,
+  type WordForm,
+  type WordFormGroup,
+} from "../../api/pali-word-form";
 import type { CheckboxChangeEvent } from "antd/es/checkbox";
 
 const { Text } = Typography;
@@ -22,7 +21,7 @@ interface IWidget {
 // State shape + reducer — all mutations go through dispatch, never setState
 // ---------------------------------------------------------------------------
 interface State {
-  words: ICaseItem[];
+  words: WordFormGroup[];
   currWord: string | undefined;
   checkedList: string[];
 }
@@ -30,7 +29,7 @@ interface State {
 type Action =
   | {
       type: "FETCHED";
-      words: ICaseItem[];
+      words: WordFormGroup[];
       currWord: string;
       checkedList: string[];
     }
@@ -67,12 +66,9 @@ function reducer(state: State, action: Action): State {
 // ---------------------------------------------------------------------------
 // Helpers
 // ---------------------------------------------------------------------------
-function sortedCases(cases: ICaseListData[]): ICaseListData[] {
-  return cases.slice().sort((a, b) => b.count - a.count);
-}
-
-function allWords(cases: ICaseListData[]): string[] {
-  return sortedCases(cases).map((c) => c.word);
+// 组内已按出现次数降序(服务端排好)
+function allWords(forms: WordForm[]): string[] {
+  return forms.map((c) => c.word);
 }
 
 // ---------------------------------------------------------------------------
@@ -98,15 +94,12 @@ const CaseListWidget = ({ word, lines, onChange }: IWidget) => {
   const { words, currWord, checkedList } = isMultiWord ? INITIAL_STATE : state;
 
   // Derive caseData in render — no state, no effect
-  const caseData: ICaseListData[] | undefined = useMemo(
+  const caseData: WordForm[] | undefined = useMemo(
     () =>
       currWord
-        ? words
-            .find((item) => item.word === currWord)
-            ?.case.slice()
-            .sort((a, b) => b.count - a.count)
+        ? words.find((item) => item.base === currWord)?.forms
         : undefined,
-    [words, currWord]
+    [words, currWord],
   );
 
   // -------------------------------------------------------------------------
@@ -118,17 +111,18 @@ const CaseListWidget = ({ word, lines, onChange }: IWidget) => {
 
     let cancelled = false;
 
-    get<ICaseListResponse>(`/api/v2/case/${word}`).then((json) => {
-      if (cancelled) return;
-      if (json.ok && json.data.rows.length > 0) {
-        const sorted = json.data.rows.slice().sort((a, b) => b.count - a.count);
-        dispatch({
-          type: "FETCHED",
-          words: sorted,
-          currWord: sorted[0].word,
-          checkedList: allWords(sorted[0].case),
-        });
-      }
+    fetchWordForms(word).then((groups) => {
+      if (cancelled || groups.length === 0) return;
+      // 词形最多的词根排前面
+      const sorted = groups
+        .slice()
+        .sort((a, b) => b.forms.length - a.forms.length);
+      dispatch({
+        type: "FETCHED",
+        words: sorted,
+        currWord: sorted[0].base,
+        checkedList: allWords(sorted[0].forms),
+      });
     });
 
     return () => {
@@ -151,7 +145,7 @@ const CaseListWidget = ({ word, lines, onChange }: IWidget) => {
   // Event handlers — all state changes happen here, never inside effects
   // -------------------------------------------------------------------------
   const handleWordChange = (value: string) => {
-    const cases = words.find((item) => item.word === value)?.case ?? [];
+    const cases = words.find((item) => item.base === value)?.forms ?? [];
     dispatch({
       type: "SELECT_WORD",
       currWord: value,
@@ -205,16 +199,16 @@ const CaseListWidget = ({ word, lines, onChange }: IWidget) => {
               options={words.map((item) => ({
                 label: (
                   <Space>
-                    {item.word}
+                    {item.base}
                     <Badge
-                      count={item.count}
+                      count={item.forms.length}
                       color="lime"
                       status="default"
                       size="small"
                     />
                   </Space>
                 ),
-                value: item.word,
+                value: item.base,
               }))}
             />
           }

+ 19 - 6
dashboard-v6/src/components/navigation/MainMenu.tsx

@@ -19,9 +19,10 @@ import {
   TermIcon,
   TipitakaIcon,
 } from "../../assets/icon";
-import React, { useState } from "react";
+import React, { useEffect, useState } from "react";
 import RecentModal from "../recent/RecentModal.tsx";
 import SettingModal from "../setting/SettingModal.tsx";
+import SearchModal from "../../features/search/SearchModal";
 import ToolsModals from "./ToolsModals";
 import { isToolKey, type ToolKey } from "./tools";
 import { useIntl } from "react-intl";
@@ -176,10 +177,7 @@ function toAntdItems(items: MenuItem[]): MenuProps["items"] {
 }
 
 /* ================= 组件 ================= */
-interface Props {
-  onSearch?: () => void;
-}
-const Widget = ({ onSearch }: Props) => {
+const Widget = () => {
   const intl = useIntl(); //i18n
 
   const navigate = useNavigate();
@@ -188,8 +186,22 @@ const Widget = ({ onSearch }: Props) => {
 
   const [recentOpen, setRecentOpen] = useState(false);
   const [openSetting, setOpenSetting] = useState(false);
+  const [searchOpen, setSearchOpen] = useState(false);
   const [tool, setTool] = useState<ToolKey>();
 
+  /** 「/」打开搜索(输入框里打字时不算) */
+  useEffect(() => {
+    const onKey = (e: KeyboardEvent) => {
+      if (e.key !== "/" || e.ctrlKey || e.metaKey || e.altKey) return;
+      const el = e.target as HTMLElement | null;
+      if (el?.closest("input, textarea, select, [contenteditable='true']")) return;
+      e.preventDefault();
+      setSearchOpen(true);
+    };
+    window.addEventListener("keydown", onKey);
+    return () => window.removeEventListener("keydown", onKey);
+  }, []);
+
   /* ================= 菜单配置 ================= */
 
   const allItems: MenuItem[] = [
@@ -428,7 +440,7 @@ const Widget = ({ onSearch }: Props) => {
   /** 点击 */
   const handleClick: MenuProps["onClick"] = ({ key }) => {
     if (key === "search") {
-      onSearch?.();
+      setSearchOpen(true);
       return;
     } else if (key === "/workspace/recent") {
       setRecentOpen(true);
@@ -463,6 +475,7 @@ const Widget = ({ onSearch }: Props) => {
         }}
       />
       <SettingModal open={openSetting} onClose={() => setOpenSetting(false)} />
+      <SearchModal open={searchOpen} onClose={() => setSearchOpen(false)} />
       <ToolsModals tool={tool} onClose={() => setTool(undefined)} />
     </>
   );

+ 66 - 6
dashboard-v6/src/components/tipitaka/BookTree.tsx

@@ -31,6 +31,10 @@ interface IWidgetBookTree {
   multiSelect?: boolean;
   multiSelectable?: boolean;
   books?: IFtsData[];
+  /** 自定义节点计数(参数是节点的 tag);给了就不用 books 数书本数,计数为 0 的节点变淡 */
+  count?: (tags: string[]) => number;
+  /** 受控的选中节点(节点 key 是 tag 用逗号连起来) */
+  selectedKeys?: Key[];
   onChange?: (selectedKeys: Key[], path?: string[]) => void;
   onSelect?: (key?: Key) => void;
   onRootChange?: (value: string) => void;
@@ -41,13 +45,16 @@ const BookTreeWidget = ({
   multiSelect = false,
   multiSelectable = true,
   books,
+  count: countOf,
+  selectedKeys: controlledKeys,
   onChange,
   onSelect,
   onRootChange,
 }: IWidgetBookTree) => {
   const intl = useIntl();
   const [treeData, setTreeData] = useState<ITocTree[]>([]);
-  const [selectedKeys, setSelectedKeys] = useState<Key[]>([]);
+  const [innerKeys, setSelectedKeys] = useState<Key[]>([]);
+  const selectedKeys = controlledKeys ?? innerKeys;
   const [isMultiSelect, setIsMultiSelect] = useState(multiSelect);
   const [currTocStyle, setCurrTocStyle] = useState<string>();
   const [loading, setLoading] = useState<boolean>(false);
@@ -91,7 +98,7 @@ const BookTreeWidget = ({
       };
 
       const json = await get<IPaliBookListResponse[]>(
-        `/api/v2/pali-book-category/${value}`
+        `/api/v2/pali-book-category/${value}`,
       );
       const newTree: ITocTree[] = json.map(treeMap);
       setPathToNode(newTree, []);
@@ -104,6 +111,31 @@ const BookTreeWidget = ({
     }
   };
 
+  /** 节点 key → 它的全部祖先 key */
+  const ancestorsOf = (key: Key): Key[] => {
+    const walk = (nodes: ITocTree[], path: Key[]): Key[] | undefined => {
+      for (const node of nodes) {
+        if (node.key === key) return path;
+        const found = walk(node.children, [...path, node.key]);
+        if (found) return found;
+      }
+      return undefined;
+    };
+    return walk(treeData, []) ?? [];
+  };
+
+  /**
+   * 多选时,新选中的节点与已选的祖先 / 后代互斥:选了子目录,父目录取消;选了父目录,子目录取消
+   * (父目录已经包含子目录,两个都选没有意义,计数也会重复)。
+   */
+  const exclusive = (keys: Key[], picked: Key): Key[] => {
+    const up = ancestorsOf(picked);
+    return keys.filter(
+      (k) =>
+        k === picked || (!up.includes(k) && !ancestorsOf(k).includes(picked)),
+    );
+  };
+
   const handleClearSelection = () => {
     setSelectedKeys([]);
     if (typeof onChange !== "undefined") {
@@ -118,11 +150,13 @@ const BookTreeWidget = ({
       selectedNodes: ITocTree[];
       node: EventDataNode<ITocTree>;
       event: string;
-    }
+    },
   ) => {
-    console.log("tree selected", selectedKeys, info);
-    setSelectedKeys(selectedKeys);
     const node: ITocTree = info.node;
+    if (isMultiSelect && info.selected) {
+      selectedKeys = exclusive(selectedKeys, node.key);
+    }
+    setSelectedKeys(selectedKeys);
 
     if (typeof onChange !== "undefined") {
       onChange(selectedKeys, node.path);
@@ -133,6 +167,22 @@ const BookTreeWidget = ({
   };
 
   const titleRender = (node: ITocTree) => {
+    if (countOf) {
+      const n = countOf(node.tag);
+      return (
+        <Space style={{ opacity: n ? 1 : 0.45 }}>
+          <PaliText text={node.title} />
+          {n ? (
+            <Text
+              type="secondary"
+              style={{ fontVariantNumeric: "tabular-nums" }}
+            >
+              {n.toLocaleString()}
+            </Text>
+          ) : null}
+        </Space>
+      );
+    }
     //标签数量
     const tags = books?.filter((book) => {
       return node.tag.every((el) => {
@@ -186,6 +236,13 @@ const BookTreeWidget = ({
               defaultChecked={multiSelect}
               onChange={(checked) => {
                 setIsMultiSelect(checked);
+                // 切回单选时只留最后选的那一个
+                if (!checked && selectedKeys.length > 1) {
+                  const last = selectedKeys.slice(-1);
+                  setSelectedKeys(last);
+                  onChange?.(last);
+                  onSelect?.(last[0]);
+                }
               }}
             />
           </Flex>
@@ -198,7 +255,10 @@ const BookTreeWidget = ({
           selectedKeys={selectedKeys}
           multiple={isMultiSelect}
           showLine
-          switcherIcon={<DownOutlined />}
+          // 自定义图标时 antd 不会替它旋转(showLine 下尤其如此),按展开状态自己转;叶子不显示
+          switcherIcon={({ expanded, isLeaf }) =>
+            isLeaf ? null : <DownOutlined rotate={expanded ? 0 : -90} />
+          }
           defaultExpandedKeys={["sutta"]}
           onSelect={handleSelect}
           treeData={treeData}

+ 150 - 0
dashboard-v6/src/features/search/CategoryFacets.tsx

@@ -0,0 +1,150 @@
+import { Button, Checkbox, Flex, Typography, theme } from "antd";
+import { useIntl } from "react-intl";
+import type { FacetBucket } from "../../api/tipitaka-search";
+import {
+  LAYER_OPTIONS,
+  PITAKA_OPTIONS,
+  isLayerCategory,
+  isOtherCategory,
+  isPitakaCategory,
+  type ICategoryOption,
+} from "./categories";
+
+const { Text } = Typography;
+
+interface IOption {
+  key: string;
+  label: string;
+  count?: number;
+}
+
+interface IGroupProps {
+  title: string;
+  options: IOption[];
+  selected: string[];
+  onToggle: (key: string) => void;
+}
+
+const FacetGroup = ({ title, options, selected, onToggle }: IGroupProps) => {
+  const { token } = theme.useToken();
+  if (options.length === 0) {
+    return null;
+  }
+  return (
+    <div>
+      <Text
+        type="secondary"
+        style={{ fontSize: token.fontSizeSM, letterSpacing: "0.04em" }}
+      >
+        {title}
+      </Text>
+      <Flex vertical gap={2} style={{ marginTop: 4 }}>
+        {options.map((o) => (
+          <Checkbox
+            key={o.key}
+            checked={selected.includes(o.key)}
+            onChange={() => onToggle(o.key)}
+            style={{ opacity: o.count === 0 ? 0.45 : 1 }}
+          >
+            <Flex justify="space-between" gap={8} style={{ width: 176 }}>
+              <Text ellipsis={{ tooltip: o.label }}>{o.label}</Text>
+              <Text
+                type="secondary"
+                style={{ fontVariantNumeric: "tabular-nums" }}
+              >
+                {o.count?.toLocaleString() ?? ""}
+              </Text>
+            </Flex>
+          </Checkbox>
+        ))}
+      </Flex>
+    </div>
+  );
+};
+
+interface IWidget {
+  /** meta.facets.category:当前查询条件下各标签的段落数(后端只给前若干个) */
+  buckets: FacetBucket[];
+  selected: string[];
+  onChange: (category: string[]) => void;
+}
+
+/**
+ * 全文检索的分类筛选:把 category 分面拆成「层级 / 藏别 / 其他分类」三组。
+ *
+ * 选中后作为 category 过滤重新查询,计数随之按新条件重算。
+ * 层级、藏别组内单选(后端的 category 是「全部命中」,同组选两个必然为空),
+ * 其他分类可多选。后端只返回计数最多的若干个标签,不在其中的选项不显示数字。
+ */
+const CategoryFacets = ({ buckets, selected, onChange }: IWidget) => {
+  const intl = useIntl();
+  const count = new Map(buckets.map((b) => [b.key, b.count]));
+
+  const fixed = (list: ICategoryOption[]): IOption[] =>
+    list.map((o) => ({
+      key: o.key,
+      label: `${intl.formatMessage({ id: o.labelId })} ${o.key}`,
+      count: count.get(o.key),
+    }));
+
+  // 其他分类:分面里出现的,加上已选但这次分面里没有的(保证能取消)
+  const otherKeys = [
+    ...buckets.map((b) => b.key).filter(isOtherCategory),
+    ...selected.filter((k) => isOtherCategory(k) && !count.has(k)),
+  ];
+  const others: IOption[] = otherKeys.map((key) => ({
+    key,
+    label: key,
+    count: count.get(key),
+  }));
+
+  /** 层级、藏别:组内单选,再点一次取消 */
+  const toggleSingle = (key: string, inGroup: (k: string) => boolean) => {
+    if (selected.includes(key)) {
+      onChange(selected.filter((k) => k !== key));
+    } else {
+      onChange([...selected.filter((k) => !inGroup(k)), key]);
+    }
+  };
+  const toggleMulti = (key: string) =>
+    onChange(
+      selected.includes(key)
+        ? selected.filter((k) => k !== key)
+        : [...selected, key],
+    );
+
+  return (
+    <Flex vertical gap={18}>
+      <FacetGroup
+        title={intl.formatMessage({ id: "search.facet.layer" })}
+        options={fixed(LAYER_OPTIONS)}
+        selected={selected}
+        onToggle={(k) => toggleSingle(k, isLayerCategory)}
+      />
+      <FacetGroup
+        title={intl.formatMessage({ id: "search.facet.pitaka" })}
+        options={fixed(PITAKA_OPTIONS)}
+        selected={selected}
+        onToggle={(k) => toggleSingle(k, isPitakaCategory)}
+      />
+      <FacetGroup
+        title={intl.formatMessage({ id: "search.facet.other" })}
+        options={others}
+        selected={selected}
+        onToggle={toggleMulti}
+      />
+      {selected.length > 0 && (
+        <Button
+          size="small"
+          type="link"
+          style={{ alignSelf: "flex-start", padding: 0 }}
+          onClick={() => onChange([])}
+        >
+          {intl.formatMessage({ id: "search.facet.clear" })}
+        </Button>
+      )}
+    </Flex>
+  );
+};
+
+export default CategoryFacets;

+ 601 - 0
dashboard-v6/src/features/search/DefinitionTab.tsx

@@ -0,0 +1,601 @@
+import {
+  Alert,
+  Button,
+  Checkbox,
+  Empty,
+  Flex,
+  Pagination,
+  Segmented,
+  Spin,
+  Tag,
+  Typography,
+  message,
+  theme,
+} from "antd";
+import { CopyOutlined } from "@ant-design/icons";
+import { useState } from "react";
+import { useIntl } from "react-intl";
+import { Link } from "react-router";
+import type { WordBook, WordParagraph } from "../../api/tipitaka-search";
+import BookTree from "../../components/tipitaka/BookTree";
+import type { WordFormGroup } from "../../api/pali-word-form";
+import LayerTag from "./LayerTag";
+import {
+  DEFINITION_PER_PAGE,
+  type useWordBooks,
+  type useWordForms,
+  type useWordParagraphs,
+} from "./hooks";
+import {
+  DEFINITION_BOLDS,
+  type DefinitionBold,
+  type ISearchState,
+} from "./state";
+
+const { Text } = Typography;
+const PALI_FONT = '"Noto Serif", Georgia, "Times New Roman", serif';
+/** 第一组(输入的词本身)默认显示的词形数;其余词根默认折叠 */
+const FORMS_SHOWN = 8;
+/** 书单默认显示的条数 */
+const BOOKS_SHOWN = 12;
+
+type Ref = NonNullable<WordParagraph["refs"]>[number];
+
+/** 页码引用的显示:「PTS Nam 2.299」 */
+const refLabel = (r: Ref) =>
+  [r.type, r.title, `${r.volume ? `${r.volume}.` : ""}${r.page}`]
+    .filter(Boolean)
+    .join(" ");
+
+/** 复制用的引用:「WP 缩写 book:para; 各印本页码」(同 wikipali 插件的出处格式) */
+const citationOf = (p: WordParagraph): string => {
+  const refs = p.refs ?? [];
+  const wp = refs.find((r) => r.type === "WP");
+  const head = [wp?.title, `${p.book}:${p.para}`].filter(Boolean).join(" ");
+  return [head, ...refs.filter((r) => r.type !== "WP").map(refLabel)].join(
+    "; ",
+  );
+};
+
+/* ─── 左栏:词形 ─── */
+
+interface IFormsProps {
+  groups: WordFormGroup[];
+  selected: string[];
+  onChange: (forms: string[]) => void;
+}
+
+const FormGroups = ({ groups, selected, onChange }: IFormsProps) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  const [expanded, setExpanded] = useState<string[]>([]);
+  const chosen = new Set(selected);
+
+  const toggle = (word: string) =>
+    onChange(
+      chosen.has(word)
+        ? selected.filter((w) => w !== word)
+        : [...selected, word],
+    );
+  const toggleGroup = (g: WordFormGroup) => {
+    const words = g.forms.map((f) => f.word);
+    const all = words.every((w) => chosen.has(w));
+    onChange(
+      all
+        ? selected.filter((w) => !words.includes(w))
+        : [...selected, ...words.filter((w) => !chosen.has(w))],
+    );
+  };
+
+  return (
+    <Flex vertical gap={12}>
+      {groups.map((g, i) => {
+        const open = expanded.includes(g.base);
+        const limit = i === 0 ? FORMS_SHOWN : 0;
+        const shown = open ? g.forms : g.forms.slice(0, limit);
+        const all = g.forms.every((f) => chosen.has(f.word));
+        return (
+          <div
+            key={g.base}
+            style={
+              i > 0
+                ? {
+                    borderTop: `1px dashed ${token.colorBorder}`,
+                    paddingTop: 8,
+                  }
+                : undefined
+            }
+          >
+            <Flex justify="space-between" align="baseline">
+              <Text strong style={{ fontFamily: PALI_FONT }}>
+                {g.base}
+              </Text>
+              <Button
+                size="small"
+                type="link"
+                style={{ padding: 0 }}
+                onClick={() => toggleGroup(g)}
+              >
+                {intl.formatMessage({
+                  id: all ? "search.forms.none" : "search.forms.all",
+                })}
+              </Button>
+            </Flex>
+            <Flex vertical gap={1}>
+              {shown.map((f) => (
+                <Checkbox
+                  key={f.word}
+                  checked={chosen.has(f.word)}
+                  onChange={() => toggle(f.word)}
+                >
+                  <Flex justify="space-between" gap={6} style={{ width: 216 }}>
+                    <Text style={{ fontFamily: PALI_FONT }} ellipsis>
+                      {f.word}
+                    </Text>
+                    <Flex
+                      gap={6}
+                      style={{ fontVariantNumeric: "tabular-nums" }}
+                    >
+                      <Text type="secondary">{f.count.toLocaleString()}</Text>
+                      <Text
+                        strong
+                        type="secondary"
+                        style={{ width: 28, textAlign: "right" }}
+                        title={intl.formatMessage({ id: "search.forms.bold" })}
+                      >
+                        {f.bold ? f.bold.toLocaleString() : ""}
+                      </Text>
+                    </Flex>
+                  </Flex>
+                </Checkbox>
+              ))}
+            </Flex>
+            {g.forms.length > limit && (
+              <Button
+                size="small"
+                type="link"
+                style={{ padding: 0 }}
+                onClick={() =>
+                  setExpanded((e) =>
+                    open ? e.filter((b) => b !== g.base) : [...e, g.base],
+                  )
+                }
+              >
+                {intl.formatMessage(
+                  {
+                    id: open
+                      ? "search.show_less"
+                      : limit
+                        ? "search.show_more"
+                        : "search.forms.expand",
+                  },
+                  { n: g.forms.length - limit },
+                )}
+              </Button>
+            )}
+          </div>
+        );
+      })}
+    </Flex>
+  );
+};
+
+/* ─── 左栏:目录、书 ─── */
+
+/** 目录节点下命中的段落数:书的 tag 包含节点的全部 tag 就算在这个节点下 */
+const countInNode = (books: WordBook[], tags: string[]): number =>
+  books
+    .filter((b) => tags.every((t) => (b.tags ?? []).includes(t)))
+    .reduce((sum, b) => sum + (b.paragraphs ?? 0), 0);
+
+interface IBooksProps {
+  result: ReturnType<typeof useWordBooks>;
+  /** 目录范围内的书(没选目录就是全部) */
+  books: WordBook[];
+  selected: number[];
+  onChange: (bookIds: number[]) => void;
+}
+
+const BookList = ({ result, books, selected, onChange }: IBooksProps) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  const [showAll, setShowAll] = useState(false);
+  const max = Math.max(1, ...books.map((b) => b.paragraphs ?? 0));
+  const shown = showAll ? books : books.slice(0, BOOKS_SHOWN);
+
+  return (
+    <Spin spinning={result.loading}>
+      <Text
+        type="secondary"
+        style={{ fontSize: token.fontSizeSM, letterSpacing: "0.04em" }}
+      >
+        {intl.formatMessage(
+          { id: "search.books" },
+          { n: books.length.toLocaleString() },
+        )}
+      </Text>
+      <Flex vertical gap={0} style={{ marginTop: 4 }}>
+        {shown.map((b) => (
+          <div key={b.book_id}>
+            <Checkbox
+              checked={selected.includes(b.book_id ?? 0)}
+              onChange={(e) =>
+                onChange(
+                  e.target.checked
+                    ? [...selected, b.book_id ?? 0]
+                    : selected.filter((id) => id !== b.book_id),
+                )
+              }
+            >
+              <Flex justify="space-between" gap={6} style={{ width: 216 }}>
+                <Text
+                  style={{ fontFamily: PALI_FONT }}
+                  ellipsis={{ tooltip: b.title }}
+                >
+                  {b.title}
+                </Text>
+                <Text
+                  type="secondary"
+                  style={{ fontVariantNumeric: "tabular-nums" }}
+                  title={intl.formatMessage(
+                    { id: "search.books.tip" },
+                    { n: b.occurrences },
+                  )}
+                >
+                  {(b.paragraphs ?? 0).toLocaleString()}
+                </Text>
+              </Flex>
+            </Checkbox>
+            <div
+              style={{
+                height: 3,
+                margin: "1px 0 3px 24px",
+                borderRadius: 2,
+                background: token.colorFillSecondary,
+                overflow: "hidden",
+              }}
+            >
+              <div
+                style={{
+                  width: `${((b.paragraphs ?? 0) / max) * 100}%`,
+                  height: "100%",
+                  background: token.colorPrimary,
+                  opacity: 0.55,
+                }}
+              />
+            </div>
+          </div>
+        ))}
+      </Flex>
+      {books.length > BOOKS_SHOWN && (
+        <Button
+          size="small"
+          type="link"
+          style={{ padding: 0 }}
+          onClick={() => setShowAll((v) => !v)}
+        >
+          {intl.formatMessage(
+            { id: showAll ? "search.show_less" : "search.show_more" },
+            { n: books.length - BOOKS_SHOWN },
+          )}
+        </Button>
+      )}
+    </Spin>
+  );
+};
+
+/* ─── 右栏:一条结果 ─── */
+
+interface IHitProps {
+  hit: WordParagraph;
+  layer?: string | null;
+  channel?: string | null;
+  /** 链接在新标签页打开(在弹窗等浮动容器里时) */
+  newTab?: boolean;
+}
+
+const Hit = ({ hit, layer, channel, newTab }: IHitProps) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  // 去掉书系(level 0)与末尾的本段标题
+  const crumbs = (hit.path ?? [])
+    .filter((p) => (p.level ?? 0) > 0)
+    .map((p) => p.title)
+    .filter((t) => t && t !== hit.title);
+  const to =
+    `/workspace/tipitaka/para/${hit.id}` +
+    (channel ? `?channel=${channel}` : "");
+
+  const copy = () => {
+    navigator.clipboard
+      .writeText(citationOf(hit))
+      .then(() => message.success(intl.formatMessage({ id: "search.copied" })))
+      .catch(() =>
+        message.error(intl.formatMessage({ id: "search.copy_failed" })),
+      );
+  };
+
+  return (
+    <div
+      style={{
+        padding: "14px 0",
+        borderBottom: `1px solid ${token.colorBorderSecondary}`,
+      }}
+    >
+      <Flex gap={6} align="center" wrap>
+        <LayerTag layer={layer} />
+        <Text
+          type="secondary"
+          style={{ fontFamily: PALI_FONT, fontSize: token.fontSizeSM }}
+        >
+          {crumbs.join(" › ")}
+        </Text>
+      </Flex>
+      <Flex
+        justify="space-between"
+        align="baseline"
+        gap={12}
+        style={{ marginTop: 2 }}
+      >
+        <Flex gap={8} align="baseline" wrap style={{ minWidth: 0 }}>
+          <Link
+            to={to}
+            target={newTab ? "_blank" : undefined}
+            rel={newTab ? "noopener noreferrer" : undefined}
+            style={{ fontFamily: PALI_FONT, fontWeight: 600, fontSize: 15 }}
+          >
+            {hit.title || hit.id}
+          </Link>
+          <Text code style={{ fontSize: token.fontSizeSM }}>
+            {hit.id}
+          </Text>
+        </Flex>
+        <Button size="small" type="text" icon={<CopyOutlined />} onClick={copy}>
+          {intl.formatMessage({ id: "search.copy_citation" })}
+        </Button>
+      </Flex>
+      {/* text 由服务端生成:只含 <b> 与 <mark>,其余已转义 */}
+      <div
+        className="search-definition-text"
+        style={{
+          fontFamily: PALI_FONT,
+          fontSize: 15.5,
+          lineHeight: 1.75,
+          maxWidth: "78ch",
+          marginTop: 4,
+        }}
+        dangerouslySetInnerHTML={{ __html: hit.text ?? "" }}
+      />
+      {(hit.refs ?? []).length > 0 && (
+        <Flex gap={4} wrap style={{ marginTop: 6 }}>
+          {hit.refs?.map((r) => (
+            <Tag
+              key={r.type}
+              bordered
+              style={{ fontFamily: "monospace", marginInlineEnd: 0 }}
+            >
+              {refLabel(r)}
+            </Tag>
+          ))}
+        </Flex>
+      )}
+    </div>
+  );
+};
+
+/* ─── 标签页 ─── */
+
+interface IWidget {
+  state: ISearchState;
+  onChange: (patch: Partial<ISearchState>) => void;
+  forms: ReturnType<typeof useWordForms>;
+  /** 实际参与检索的词形(state.forms 或默认那一组) */
+  words: string[];
+  paragraphs: ReturnType<typeof useWordParagraphs>;
+  books: ReturnType<typeof useWordBooks>;
+  /** 目录范围内的书 */
+  scopeBooks: WordBook[];
+  /** 选了目录、但范围内一本命中的书都没有 */
+  scopeEmpty: boolean;
+  channel?: string | null;
+  /** 链接在新标签页打开(在弹窗等浮动容器里时) */
+  newTab?: boolean;
+}
+
+/**
+ * 定义标签页:逐词表按词形精确匹配。左栏勾选词形、按书筛选;默认只看黑体——
+ * 注释书用黑体标出正在解释的词,所以「只看黑体」就是找「哪里给这个词下了定义」。
+ */
+const DefinitionTab = ({
+  state,
+  onChange,
+  forms,
+  words,
+  paragraphs,
+  books,
+  scopeBooks,
+  scopeEmpty,
+  channel,
+  newTab,
+}: IWidget) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+
+  if (/\s/.test(state.q.trim())) {
+    return (
+      <Empty
+        style={{ marginTop: 64 }}
+        image={Empty.PRESENTED_IMAGE_SIMPLE}
+        description={intl.formatMessage({ id: "search.def.multiword" })}
+      />
+    );
+  }
+  if (forms.error) {
+    return (
+      <Alert
+        type="warning"
+        showIcon
+        style={{ margin: 16 }}
+        message={forms.error.message}
+      />
+    );
+  }
+  if (!forms.loading && forms.data && forms.data.length === 0) {
+    return (
+      <Empty
+        style={{ marginTop: 64 }}
+        image={Empty.PRESENTED_IMAGE_SIMPLE}
+        description={intl.formatMessage({ id: "search.def.no_forms" })}
+      />
+    );
+  }
+
+  const layerOf = new Map(
+    (books.data ?? []).map((b) => [`${b.book}`, b.layer]),
+  );
+  const total = paragraphs.meta?.total ?? 0;
+
+  return (
+    <Flex style={{ height: "100%", minHeight: 0 }}>
+      <div
+        style={{
+          width: 288,
+          flex: "none",
+          overflowY: "auto",
+          padding: "12px 12px 24px",
+          borderRight: `1px solid ${token.colorBorderSecondary}`,
+          background: token.colorFillQuaternary,
+        }}
+      >
+        <Spin spinning={forms.loading}>
+          <Flex vertical gap={20}>
+            {words.length > 0 && (
+              <div style={{ margin: "-10px -10px 0" }}>
+                <BookTree
+                  selectedKeys={state.scope}
+                  count={(tags) => countInNode(books.data ?? [], tags)}
+                  onChange={(keys) =>
+                    onChange({
+                      scope: keys.map(String),
+                      bookIds: [],
+                      defPage: 1,
+                    })
+                  }
+                  onRootChange={() =>
+                    onChange({ scope: [], bookIds: [], defPage: 1 })
+                  }
+                />
+              </div>
+            )}
+            <FormGroups
+              groups={forms.data ?? []}
+              selected={words}
+              onChange={(f) => onChange({ forms: f, bookIds: [], defPage: 1 })}
+            />
+            {words.length > 0 && (
+              <BookList
+                result={books}
+                books={scopeBooks}
+                selected={state.bookIds}
+                onChange={(bookIds) => onChange({ bookIds, defPage: 1 })}
+              />
+            )}
+          </Flex>
+        </Spin>
+      </div>
+      <Flex vertical style={{ flex: 1, minWidth: 0 }}>
+        <Flex
+          gap={12}
+          align="center"
+          wrap
+          style={{
+            padding: "10px 16px",
+            borderBottom: `1px solid ${token.colorBorderSecondary}`,
+          }}
+        >
+          <Text strong style={{ fontVariantNumeric: "tabular-nums" }}>
+            {intl.formatMessage(
+              { id: "search.total" },
+              { n: total.toLocaleString() },
+            )}
+          </Text>
+          <Text type="secondary">
+            {intl.formatMessage(
+              { id: "search.forms.selected" },
+              { n: words.length },
+            )}
+          </Text>
+          <Segmented<DefinitionBold>
+            size="small"
+            value={state.bold}
+            options={DEFINITION_BOLDS.map((b) => ({
+              value: b,
+              label: intl.formatMessage({ id: `search.bold.${b}` }),
+            }))}
+            onChange={(bold) => onChange({ bold, bookIds: [], defPage: 1 })}
+          />
+        </Flex>
+        <div
+          style={{
+            flex: 1,
+            minHeight: 0,
+            overflowY: "auto",
+            padding: "0 16px 24px",
+          }}
+        >
+          {scopeEmpty ? (
+            <Empty
+              style={{ marginTop: 48 }}
+              description={intl.formatMessage({ id: "search.def.scope_empty" })}
+            />
+          ) : words.length === 0 && !forms.loading ? (
+            <Empty
+              style={{ marginTop: 48 }}
+              description={intl.formatMessage({ id: "search.def.pick_forms" })}
+            />
+          ) : paragraphs.error ? (
+            <Alert
+              type="warning"
+              showIcon
+              style={{ marginTop: 16 }}
+              message={paragraphs.error.message}
+            />
+          ) : (
+            <Spin spinning={paragraphs.loading}>
+              {paragraphs.data && paragraphs.data.length === 0 ? (
+                <Empty
+                  style={{ marginTop: 48 }}
+                  description={intl.formatMessage({ id: "search.empty" })}
+                />
+              ) : (
+                (paragraphs.data ?? []).map((hit) => (
+                  <Hit
+                    key={hit.id}
+                    hit={hit}
+                    layer={layerOf.get(`${hit.book}`)}
+                    channel={channel}
+                    newTab={newTab}
+                  />
+                ))
+              )}
+              {total > DEFINITION_PER_PAGE && (
+                <Flex justify="center" style={{ paddingTop: 16 }}>
+                  <Pagination
+                    size="small"
+                    current={state.defPage}
+                    pageSize={DEFINITION_PER_PAGE}
+                    total={total}
+                    showSizeChanger={false}
+                    onChange={(defPage) => onChange({ defPage })}
+                  />
+                </Flex>
+              )}
+            </Spin>
+          )}
+        </div>
+      </Flex>
+    </Flex>
+  );
+};
+
+export default DefinitionTab;

+ 253 - 0
dashboard-v6/src/features/search/FullTextTab.tsx

@@ -0,0 +1,253 @@
+import {
+  Alert,
+  Button,
+  Empty,
+  Flex,
+  Pagination,
+  Segmented,
+  Spin,
+  Typography,
+  message,
+  theme,
+} from "antd";
+import { CopyOutlined } from "@ant-design/icons";
+import { useIntl } from "react-intl";
+import { Link } from "react-router";
+import type { SearchHit, SearchMode } from "../../api/tipitaka-search";
+import CategoryFacets from "./CategoryFacets";
+import Highlight from "./Highlight";
+import LayerTag from "./LayerTag";
+import { layerOf } from "./categories";
+import { FULLTEXT_PER_PAGE, type useFullTextSearch } from "./hooks";
+import { SEARCH_MODES, type ISearchState } from "./state";
+
+const { Text } = Typography;
+
+/** 索引里的 path 是「书系/书名/章/…/本段标题」:去掉开头的书系和末尾的本段标题 */
+const crumbsOf = (path?: string | null): string[] => {
+  const parts = (path ?? "").split("/").filter(Boolean);
+  return parts.slice(1, -1);
+};
+
+const PALI_FONT = '"Noto Serif", Georgia, "Times New Roman", serif';
+
+interface IHitProps {
+  hit: SearchHit;
+  channel?: string | null;
+  /** 链接在新标签页打开(在弹窗等浮动容器里时) */
+  newTab?: boolean;
+}
+
+const Hit = ({ hit, channel, newTab }: IHitProps) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  const crumbs = crumbsOf(hit.path);
+  const coord = hit.related_id ?? "";
+  const to =
+    `/workspace/tipitaka/para/${coord}` +
+    (channel ? `?channel=${channel}` : "");
+
+  const copy = () => {
+    const text =
+      [...crumbs, hit.title].filter(Boolean).join(" › ") + ` (${coord})`;
+    navigator.clipboard
+      .writeText(text)
+      .then(() => message.success(intl.formatMessage({ id: "search.copied" })))
+      .catch(() =>
+        message.error(intl.formatMessage({ id: "search.copy_failed" })),
+      );
+  };
+
+  return (
+    <div
+      style={{
+        padding: "14px 0",
+        borderBottom: `1px solid ${token.colorBorderSecondary}`,
+      }}
+    >
+      <Flex gap={6} align="center" wrap style={{ fontSize: token.fontSizeSM }}>
+        <LayerTag layer={layerOf(hit.category)} />
+        <Text
+          type="secondary"
+          style={{ fontFamily: PALI_FONT, fontSize: token.fontSizeSM }}
+        >
+          {crumbs.join(" › ")}
+        </Text>
+      </Flex>
+      <Flex
+        justify="space-between"
+        align="baseline"
+        gap={12}
+        style={{ marginTop: 2 }}
+      >
+        <Flex gap={8} align="baseline" wrap style={{ minWidth: 0 }}>
+          <Link
+            to={to}
+            target={newTab ? "_blank" : undefined}
+            rel={newTab ? "noopener noreferrer" : undefined}
+            style={{ fontFamily: PALI_FONT, fontWeight: 600, fontSize: 15 }}
+          >
+            {hit.title || coord}
+          </Link>
+          <Text code style={{ fontSize: token.fontSizeSM }}>
+            {coord}
+          </Text>
+        </Flex>
+        <Button size="small" type="text" icon={<CopyOutlined />} onClick={copy}>
+          {intl.formatMessage({ id: "search.copy_citation" })}
+        </Button>
+      </Flex>
+      <div
+        style={{
+          fontFamily: PALI_FONT,
+          fontSize: 15.5,
+          lineHeight: 1.75,
+          maxWidth: "78ch",
+          marginTop: 4,
+        }}
+      >
+        {hit.highlight ? (
+          <>
+            …<Highlight text={hit.highlight} />…
+          </>
+        ) : (
+          <>{(hit.content ?? "").slice(0, 240)}…</>
+        )}
+      </div>
+      {(hit.bold?.length ?? 0) > 0 && (
+        <Text type="secondary" style={{ fontSize: token.fontSizeSM }}>
+          {intl.formatMessage({ id: "search.bold_in_para" })}
+          <span style={{ fontFamily: PALI_FONT, fontWeight: 600 }}>
+            {hit.bold?.slice(0, 6).join(" · ")}
+          </span>
+        </Text>
+      )}
+    </div>
+  );
+};
+
+interface IWidget {
+  state: ISearchState;
+  result: ReturnType<typeof useFullTextSearch>;
+  onChange: (patch: Partial<ISearchState>) => void;
+  /** 当前阅读的 channel:跳到段落时沿用 */
+  channel?: string | null;
+  /** 链接在新标签页打开(在弹窗等浮动容器里时) */
+  newTab?: boolean;
+}
+
+/** 全文标签页:左栏分类筛选,右栏匹配方式 + 结果 + 分页 */
+const FullTextTab = ({ state, result, onChange, channel, newTab }: IWidget) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  const { loading, data, meta, error } = result;
+  const total = meta?.total ?? 0;
+  const lastPage = meta?.last_page ?? 1;
+
+  return (
+    <Flex style={{ height: "100%", minHeight: 0 }}>
+      <div
+        style={{
+          width: 232,
+          flex: "none",
+          overflowY: "auto",
+          padding: "12px 12px 24px",
+          borderRight: `1px solid ${token.colorBorderSecondary}`,
+          background: token.colorFillQuaternary,
+        }}
+      >
+        <CategoryFacets
+          buckets={meta?.facets?.category ?? []}
+          selected={state.category}
+          onChange={(category) => onChange({ category, page: 1 })}
+        />
+      </div>
+      <Flex vertical style={{ flex: 1, minWidth: 0 }}>
+        <Flex
+          gap={12}
+          align="center"
+          wrap
+          style={{
+            padding: "10px 16px",
+            borderBottom: `1px solid ${token.colorBorderSecondary}`,
+          }}
+        >
+          <Text strong style={{ fontVariantNumeric: "tabular-nums" }}>
+            {intl.formatMessage(
+              {
+                id:
+                  meta?.total_relation === "gte"
+                    ? "search.total.gte"
+                    : "search.total",
+              },
+              { n: total.toLocaleString() },
+            )}
+          </Text>
+          <Text type="secondary">
+            {intl.formatMessage({ id: "search.mode" })}
+          </Text>
+          <Segmented<SearchMode>
+            size="small"
+            value={state.mode}
+            options={SEARCH_MODES.map((m) => ({
+              value: m,
+              label: intl.formatMessage({ id: `search.mode.${m}` }),
+              title: intl.formatMessage({ id: `search.mode.${m}.tip` }),
+            }))}
+            onChange={(mode) => onChange({ mode, page: 1 })}
+          />
+        </Flex>
+        <div
+          style={{
+            flex: 1,
+            minHeight: 0,
+            overflowY: "auto",
+            padding: "0 16px 24px",
+          }}
+        >
+          {error ? (
+            <Alert
+              type="warning"
+              showIcon
+              style={{ marginTop: 16 }}
+              message={error.message}
+            />
+          ) : (
+            <Spin spinning={loading}>
+              {data && data.length === 0 ? (
+                <Empty
+                  style={{ marginTop: 48 }}
+                  description={intl.formatMessage({ id: "search.empty" })}
+                />
+              ) : (
+                (data ?? []).map((hit) => (
+                  <Hit
+                    key={hit.id}
+                    hit={hit}
+                    channel={channel}
+                    newTab={newTab}
+                  />
+                ))
+              )}
+              {total > FULLTEXT_PER_PAGE && (
+                <Flex justify="center" style={{ paddingTop: 16 }}>
+                  <Pagination
+                    size="small"
+                    current={state.page}
+                    pageSize={FULLTEXT_PER_PAGE}
+                    // 翻页深度受 OpenSearch 限制,超出 last_page 的页取不到
+                    total={Math.min(total, lastPage * FULLTEXT_PER_PAGE)}
+                    showSizeChanger={false}
+                    onChange={(page) => onChange({ page })}
+                  />
+                </Flex>
+              )}
+            </Spin>
+          )}
+        </div>
+      </Flex>
+    </Flex>
+  );
+};
+
+export default FullTextTab;

+ 26 - 0
dashboard-v6/src/features/search/Highlight.tsx

@@ -0,0 +1,26 @@
+import { Fragment } from "react";
+
+/**
+ * 显示 OpenSearch 的高亮片段。
+ *
+ * 片段里只有 `<mark>` 是高亮标记,其余都是正文;OpenSearch 默认不转义正文,
+ * 所以不能直接 dangerouslySetInnerHTML。这里按 `<mark>…</mark>` 切开,
+ * 正文部分当纯文本渲染。
+ */
+const Highlight = ({ text }: { text: string }) => {
+  const parts = text.split(/(<mark>[\s\S]*?<\/mark>)/g);
+  return (
+    <>
+      {parts.map((part, i) => {
+        const m = /^<mark>([\s\S]*)<\/mark>$/.exec(part);
+        return m ? (
+          <mark key={i}>{m[1]}</mark>
+        ) : (
+          <Fragment key={i}>{part}</Fragment>
+        );
+      })}
+    </>
+  );
+};
+
+export default Highlight;

+ 29 - 0
dashboard-v6/src/features/search/LayerTag.tsx

@@ -0,0 +1,29 @@
+import { Tag } from "antd";
+import { useIntl } from "react-intl";
+import type { ChapterLayer } from "../../api/tipitaka-search";
+
+const COLOR: Record<ChapterLayer, string> = {
+  mula: "green",
+  atthakatha: "blue",
+  tika: "magenta",
+  anna: "gold",
+};
+
+/** 根本 / 义注 / 复注 / 藏外 的彩色标签,全文与标题两个标签页共用 */
+const LayerTag = ({ layer }: { layer?: string | null }) => {
+  const intl = useIntl();
+  if (!layer || !(layer in COLOR)) {
+    return null;
+  }
+  return (
+    <Tag
+      color={COLOR[layer as ChapterLayer]}
+      bordered={false}
+      style={{ marginInlineEnd: 0 }}
+    >
+      {intl.formatMessage({ id: `search.layer.${layer}` })}
+    </Tag>
+  );
+};
+
+export default LayerTag;

+ 305 - 0
dashboard-v6/src/features/search/PageTab.tsx

@@ -0,0 +1,305 @@
+import {
+  Alert,
+  Card,
+  Empty,
+  Flex,
+  Segmented,
+  Spin,
+  Typography,
+  theme,
+} from "antd";
+import { useIntl } from "react-intl";
+import { Link } from "react-router";
+import type { PageNumberHit } from "../../api/tipitaka-search";
+import BookTree from "../../components/tipitaka/BookTree";
+import LayerTag from "./LayerTag";
+import type { usePageNumbers } from "./hooks";
+import type { ISearchState } from "./state";
+
+const { Text } = Typography;
+const PALI_FONT = '"Noto Serif", Georgia, "Times New Roman", serif';
+
+/** 版本的显示顺序(同后端排序) */
+const EDITIONS = ["PTS", "My", "VRI", "Thai", "Other", "CS"] as const;
+/** 印本页阅读页 id 的版本代号 */
+const EDITION_CODE: Record<string, string> = {
+  PTS: "P",
+  My: "M",
+  VRI: "V",
+  Thai: "T",
+  Other: "O",
+};
+const LAYERS = ["mula", "atthakatha", "tika", "anna", ""] as const;
+
+/** 同一本书、同一卷的同一页合成一条(一页可能跨几段) */
+interface IPageEntry {
+  key: string;
+  hit: PageNumberHit;
+  paras: number[];
+}
+
+const group = (hits: PageNumberHit[]): IPageEntry[] => {
+  const map = new Map<string, IPageEntry>();
+  for (const hit of hits) {
+    const key = `${hit.book_id}-${hit.volume ?? 0}-${hit.page}`;
+    const entry = map.get(key);
+    if (entry) {
+      entry.paras.push(hit.para ?? 0);
+    } else {
+      map.set(key, { key, hit, paras: [hit.para ?? 0] });
+    }
+  }
+  return [...map.values()];
+};
+
+/** 书的 tag 包含目录节点的全部 tag,就算在这个节点下(节点 key = tag 用逗号连起来) */
+const inNode = (hit: PageNumberHit, tags: string[]): boolean =>
+  tags.every((t) => (hit.tags ?? []).includes(t));
+
+/** 点进去的阅读页:印本页(版本_版本书名_卷_页)或 CS 段落号(书_书首段_段落号) */
+const linkOf = (e: IPageEntry, channel?: string | null): string => {
+  const h = e.hit;
+  const path =
+    h.edition === "CS"
+      ? `/workspace/tipitaka/cs-para/${h.book}_${h.book_para}_${h.page}`
+      : `/workspace/tipitaka/page/${EDITION_CODE[h.edition ?? ""] ?? "O"}_${
+          h.edition_title ?? ""
+        }_${h.volume ?? 0}_${h.page}`;
+  return path + (channel ? `?channel=${channel}` : "");
+};
+
+interface IWidget {
+  state: ISearchState;
+  onChange: (patch: Partial<ISearchState>) => void;
+  result: ReturnType<typeof usePageNumbers>;
+  /** 检索词能否解析成「页」或「卷.页」 */
+  valid: boolean;
+  /** 解析出的卷号 */
+  volume?: number;
+  channel?: string | null;
+  /** 链接在新标签页打开(在弹窗等浮动容器里时) */
+  newTab?: boolean;
+}
+
+/**
+ * 页码标签页:一个页码在 PTS、缅甸版、VRI、泰国版、其他里各指一处或多处,另有 CS 段落号。
+ * 先选版本,再按层级列出书;左栏目录树按书的 tag 过滤(在前端算,一个页码最多约一千处)。
+ * 点一条打开那一页(印本页阅读页,有上一页 / 下一页)。
+ */
+const PageTab = ({
+  state,
+  onChange,
+  result,
+  valid,
+  volume,
+  channel,
+  newTab,
+}: IWidget) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+
+  if (!valid) {
+    return (
+      <Empty
+        style={{ marginTop: 64 }}
+        image={Empty.PRESENTED_IMAGE_SIMPLE}
+        description={intl.formatMessage({ id: "search.page.hint" })}
+      />
+    );
+  }
+  if (result.error) {
+    return (
+      <Alert
+        type="warning"
+        showIcon
+        style={{ margin: 16 }}
+        message={result.error.message}
+      />
+    );
+  }
+
+  const all = result.data ?? [];
+  const nodes = state.pageScope.map((key) => key.split(","));
+  // 版本的计数跟着目录范围走;目录树的计数跟着当前版本走
+  const hits =
+    nodes.length === 0
+      ? all
+      : all.filter((h) => nodes.some((tags) => inNode(h, tags)));
+  const counts = new Map<string, number>();
+  for (const h of hits) {
+    counts.set(h.edition ?? "", (counts.get(h.edition ?? "") ?? 0) + 1);
+  }
+  const available = EDITIONS.filter((e) => counts.get(e));
+  const edition =
+    state.edition && counts.get(state.edition) ? state.edition : available[0];
+  const entries = group(hits.filter((h) => h.edition === edition));
+  // 没选目录时的当前版本(目录树计数用);选了目录、当前版本却被筛空时退回全部版本的第一个
+  const editionAll =
+    edition ??
+    (state.edition && all.some((h) => h.edition === state.edition)
+      ? state.edition
+      : EDITIONS.find((e) => all.some((h) => h.edition === e)));
+  const treeEntries = group(all.filter((h) => h.edition === editionAll));
+
+  return (
+    <Flex style={{ height: "100%", minHeight: 0 }}>
+      {all.length > 0 && (
+        <div
+          style={{
+            width: 288,
+            flex: "none",
+            overflowY: "auto",
+            padding: "2px 2px 24px",
+            borderRight: `1px solid ${token.colorBorderSecondary}`,
+            background: token.colorFillQuaternary,
+          }}
+        >
+          <BookTree
+            selectedKeys={state.pageScope}
+            count={(tags) =>
+              treeEntries.filter((e) => inNode(e.hit, tags)).length
+            }
+            onChange={(keys) => onChange({ pageScope: keys.map(String) })}
+            onRootChange={() => onChange({ pageScope: [] })}
+          />
+        </div>
+      )}
+      <Flex vertical style={{ flex: 1, minWidth: 0, minHeight: 0 }}>
+        <Flex
+          gap={12}
+          align="center"
+          wrap
+          style={{
+            padding: "10px 16px",
+            borderBottom: `1px solid ${token.colorBorderSecondary}`,
+          }}
+        >
+          <Text strong style={{ fontVariantNumeric: "tabular-nums" }}>
+            {intl.formatMessage(
+              { id: volume ? "search.page.total.volume" : "search.page.total" },
+              {
+                n: (result.meta?.total ?? 0).toLocaleString(),
+                volume,
+                page: parseInt(state.q.split(".").pop() ?? "", 10),
+              },
+            )}
+          </Text>
+          {available.length > 0 && (
+            <Segmented<string>
+              size="small"
+              value={edition}
+              options={available.map((e) => ({
+                value: e,
+                label: (
+                  <Flex gap={6} align="center">
+                    {intl.formatMessage({ id: `search.edition.${e}` })}
+                    <Text
+                      type="secondary"
+                      style={{ fontSize: token.fontSizeSM }}
+                    >
+                      {counts.get(e)}
+                    </Text>
+                  </Flex>
+                ),
+              }))}
+              onChange={(e) => onChange({ edition: e })}
+            />
+          )}
+        </Flex>
+        <div
+          style={{
+            flex: 1,
+            minHeight: 0,
+            overflowY: "auto",
+            padding: "12px 16px 24px",
+          }}
+        >
+          <Spin spinning={result.loading}>
+            {result.data && hits.length === 0 ? (
+              <Empty
+                style={{ marginTop: 48 }}
+                description={intl.formatMessage({
+                  id:
+                    all.length > 0 ? "search.page.scope_empty" : "search.empty",
+                })}
+              />
+            ) : (
+              <div
+                style={{
+                  display: "grid",
+                  gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
+                  gap: 12,
+                }}
+              >
+                {LAYERS.map((layer) => {
+                  const list = entries.filter(
+                    (e) => (e.hit.layer ?? "") === layer,
+                  );
+                  if (list.length === 0) return null;
+                  return (
+                    <Card
+                      key={layer || "none"}
+                      size="small"
+                      title={
+                        <Flex justify="space-between" align="center">
+                          {layer ? (
+                            <LayerTag layer={layer} />
+                          ) : (
+                            <Text type="secondary">
+                              {intl.formatMessage({ id: "search.layer.none" })}
+                            </Text>
+                          )}
+                          <Text type="secondary" style={{ fontWeight: 400 }}>
+                            {list.length}
+                          </Text>
+                        </Flex>
+                      }
+                      styles={{ body: { padding: "4px 0" } }}
+                    >
+                      {list.map((e) => (
+                        <Link
+                          key={e.key}
+                          to={linkOf(e, channel)}
+                          target={newTab ? "_blank" : undefined}
+                          rel={newTab ? "noopener noreferrer" : undefined}
+                          style={{ display: "block", padding: "4px 12px" }}
+                        >
+                          <Flex gap={8} align="baseline">
+                            <Text
+                              ellipsis={{ tooltip: e.hit.book_title }}
+                              style={{
+                                flex: 1,
+                                minWidth: 0,
+                                fontFamily: PALI_FONT,
+                                color: "inherit",
+                              }}
+                            >
+                              {e.hit.book_title}
+                            </Text>
+                            <Text
+                              type="secondary"
+                              style={{ fontFamily: "monospace", fontSize: 12 }}
+                            >
+                              {e.hit.edition === "CS"
+                                ? `§${e.hit.page}`
+                                : `${e.hit.volume ? `${e.hit.volume}.` : ""}${e.hit.page}`}
+                            </Text>
+                            <Text code style={{ fontSize: 11 }}>
+                              {`${e.hit.book}-${e.paras.join(",")}`}
+                            </Text>
+                          </Flex>
+                        </Link>
+                      ))}
+                    </Card>
+                  );
+                })}
+              </div>
+            )}
+          </Spin>
+        </div>
+      </Flex>
+    </Flex>
+  );
+};
+
+export default PageTab;

+ 128 - 0
dashboard-v6/src/features/search/SearchInput.tsx

@@ -0,0 +1,128 @@
+import { AutoComplete, Flex, Input, Typography, theme } from "antd";
+import { useEffect, useRef, useState } from "react";
+import { useIntl } from "react-intl";
+import {
+  fetchWordSuggestions,
+  type WordSuggestion,
+} from "../../api/pali-word-form";
+import { looksLikePageNumber } from "./state";
+
+const { Text } = Typography;
+const PALI_FONT = '"Noto Serif", Georgia, serif';
+/** 停止输入多久后再请求补全 */
+const DEBOUNCE_MS = 200;
+
+/** 补全的是最后一个词(空格或分号之后),前面的原样保留(同 v4) */
+const splitLast = (value: string): [head: string, last: string] => {
+  const i = Math.max(value.lastIndexOf(" "), value.lastIndexOf(";"));
+  return [value.slice(0, i + 1), value.slice(i + 1)];
+};
+
+interface IWidget {
+  value: string;
+  onChange: (value: string) => void;
+  onSearch: (value: string) => void;
+  autoFocus?: boolean;
+}
+
+/**
+ * 搜索框 + 巴利词补全(/v3/pali-word-suggestions)。
+ *
+ * 候选显示出现次数与黑体次数(黑体出现过的词加粗)。不默认选中第一项:直接回车搜的是输入的原文,
+ * 用方向键选中候选再回车(或点击)才替换最后一个词并立即搜索。页码输入不补全。
+ */
+const SearchInput = ({ value, onChange, onSearch, autoFocus }: IWidget) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  const [options, setOptions] = useState<WordSuggestion[]>([]);
+  const [head, last] = splitLast(value);
+  const prefix = last.trim();
+  const pending = useRef<AbortController | null>(null);
+  // 搜索之后收起候选(否则下拉挡住标签页);再次输入时才展开
+  const [open, setOpen] = useState(false);
+
+  useEffect(() => {
+    pending.current?.abort();
+    if (!prefix || looksLikePageNumber(prefix)) return;
+    const controller = new AbortController();
+    pending.current = controller;
+    const timer = setTimeout(() => {
+      fetchWordSuggestions(prefix, controller.signal)
+        .then((items) => {
+          if (!controller.signal.aborted) setOptions(items);
+        })
+        .catch(() => {
+          // 补全失败不打扰:没有候选就是了
+        });
+    }, DEBOUNCE_MS);
+    return () => {
+      clearTimeout(timer);
+      controller.abort();
+    };
+  }, [prefix]);
+
+  const shown = prefix && !looksLikePageNumber(prefix) ? options : [];
+
+  return (
+    <AutoComplete
+      value={value}
+      onChange={(v: string) => {
+        onChange(v);
+        setOpen(true);
+      }}
+      open={open && shown.length > 0}
+      onOpenChange={(o) => {
+        if (!o) setOpen(false);
+      }}
+      defaultActiveFirstOption={false}
+      // 候选由服务端按前缀(含去变音形)给出,不再按输入原文过滤,否则 dhamma 会把 dhammā 筛掉
+      filterOption={false}
+      popupMatchSelectWidth={360}
+      style={{ flex: 1, minWidth: 0 }}
+      options={shown.map((w) => ({
+        value: head + w.word,
+        label: (
+          <Flex justify="space-between" align="baseline" gap={12}>
+            <span style={{ fontFamily: PALI_FONT }}>
+              {w.bold > 0 ? <Text strong>{w.word}</Text> : w.word}
+            </span>
+            <Text
+              type="secondary"
+              style={{
+                fontSize: token.fontSizeSM,
+                fontVariantNumeric: "tabular-nums",
+              }}
+            >
+              {intl.formatMessage(
+                { id: "search.suggest.count" },
+                {
+                  count: w.count.toLocaleString(),
+                  bold: w.bold.toLocaleString(),
+                },
+              )}
+            </Text>
+          </Flex>
+        ),
+      }))}
+      onSelect={(v: string) => {
+        setOpen(false);
+        onChange(v);
+        onSearch(v);
+      }}
+    >
+      <Input.Search
+        size="large"
+        allowClear
+        autoFocus={autoFocus}
+        placeholder={intl.formatMessage({ id: "search.placeholder" })}
+        onSearch={(v) => {
+          setOpen(false);
+          onSearch(v);
+        }}
+        styles={{ input: { fontFamily: PALI_FONT } }}
+      />
+    </AutoComplete>
+  );
+};
+
+export default SearchInput;

+ 75 - 0
dashboard-v6/src/features/search/SearchModal.tsx

@@ -0,0 +1,75 @@
+import { Button, Modal, Tooltip } from "antd";
+import { CloseOutlined, ExportOutlined } from "@ant-design/icons";
+import { useState } from "react";
+import { useIntl } from "react-intl";
+import { fullUrl } from "../../utils";
+import SearchPanel from "./SearchPanel";
+import { initialSearchState, toSearchParams, type ISearchState } from "./state";
+
+interface IWidget {
+  open: boolean;
+  onClose: () => void;
+}
+
+/**
+ * workspace 主导航「搜索」打开的弹窗。
+ *
+ * 关闭后不销毁:再打开时检索词、筛选、页码都还在。
+ * 「在新标签页打开」把当前条件带到 /search,地址可以收藏、分享。弹窗里的链接(包括结果)都在新标签页打开。
+ */
+const SearchModal = ({ open, onClose }: IWidget) => {
+  const intl = useIntl();
+  const [state, setState] = useState<ISearchState>(initialSearchState);
+
+  // 浮动容器里的链接一律在新标签页打开,弹窗留着
+  const openFullPage = () => {
+    window.open(
+      fullUrl(`/search?${toSearchParams(state).toString()}`),
+      "_blank",
+    );
+  };
+
+  return (
+    <Modal
+      open={open}
+      onCancel={onClose}
+      footer={null}
+      closable={false}
+      width="min(1160px, calc(100vw - 32px))"
+      style={{ top: "5vh", paddingBottom: 0 }}
+      styles={{
+        container: {
+          padding: "14px 0 0",
+          height: "90vh",
+          display: "flex",
+          flexDirection: "column",
+          overflow: "hidden",
+        },
+        body: { flex: 1, minHeight: 0 },
+      }}
+    >
+      <SearchPanel
+        state={state}
+        onChange={(patch) => setState((s) => ({ ...s, ...patch }))}
+        newTab
+        autoFocus
+        extra={
+          <>
+            <Tooltip
+              title={intl.formatMessage({ id: "search.open_full_page" })}
+            >
+              <Button icon={<ExportOutlined />} onClick={openFullPage} />
+            </Tooltip>
+            <Button
+              icon={<CloseOutlined />}
+              onClick={onClose}
+              aria-label="close"
+            />
+          </>
+        }
+      />
+    </Modal>
+  );
+};
+
+export default SearchModal;

+ 268 - 0
dashboard-v6/src/features/search/SearchPanel.tsx

@@ -0,0 +1,268 @@
+import { Empty, Flex, Tabs, theme } from "antd";
+import { useMemo, useState, type ReactNode } from "react";
+import { useIntl } from "react-intl";
+import { useSearchParams } from "react-router";
+import DefinitionTab from "./DefinitionTab";
+import FullTextTab from "./FullTextTab";
+import PageTab from "./PageTab";
+import SearchInput from "./SearchInput";
+import TitleTab from "./TitleTab";
+import {
+  useChapterSearch,
+  useFullTextSearch,
+  usePageNumbers,
+  useWordBooks,
+  useWordForms,
+  useWordParagraphs,
+} from "./hooks";
+import {
+  SEARCH_TABS,
+  looksLikePageNumber,
+  parsePageQuery,
+  type ISearchState,
+  type SearchTab,
+} from "./state";
+
+interface IWidget {
+  state: ISearchState;
+  onChange: (patch: Partial<ISearchState>) => void;
+  /** 搜索框右边的额外按钮(弹窗里放「在整页打开」「关闭」) */
+  extra?: ReactNode;
+  /** 链接在新标签页打开(在弹窗等浮动容器里时) */
+  newTab?: boolean;
+  autoFocus?: boolean;
+}
+
+/**
+ * workspace 搜索面板:一个搜索框,下面四个标签页。弹窗与整页共用。
+ *
+ * - 全文:`/v3/search`,按分类(层级 / 藏别 / 其他)筛选
+ * - 定义:`/v3/pali-word-forms` 展开词形 → `/v3/tipitaka-word-paragraphs`(+ `/aggregate` 按书统计)
+ * - 标题:`/v3/tipitaka-chapters?q=`
+ * - 页码:`/v3/tipitaka-page-numbers/{page}`,PTS / 缅甸版 / VRI / 泰国版 / 其他与 CS 段落号
+ *
+ * 全文、定义、标题同时查询,标签上直接显示命中数。
+ */
+const SearchPanel = ({
+  state,
+  onChange,
+  extra,
+  newTab,
+  autoFocus,
+}: IWidget) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  // 输入框的草稿;检索词从外面变了(如浏览器后退)时跟着变
+  const [draft, setDraft] = useState(state.q);
+  const [syncedQ, setSyncedQ] = useState(state.q);
+  if (syncedQ !== state.q) {
+    setSyncedQ(state.q);
+    setDraft(state.q);
+  }
+
+  // 从阅读页打开时,跳到段落 / 章节沿用当前阅读的 channel
+  const [locationParams] = useSearchParams();
+  const channel = locationParams.get("channel");
+
+  // 输入的是页码(100、2.100)时全文不查:正文里的数字几乎都会命中,结果没有意义
+  const isPageQuery = looksLikePageNumber(state.q);
+  const fullText = useFullTextSearch(
+    isPageQuery ? "" : state.q,
+    state.mode,
+    state.category,
+    state.page,
+  );
+  const chapters = useChapterSearch(state.q, state.layer, state.titlePage);
+  const pageQuery = useMemo(() => parsePageQuery(state.q), [state.q]);
+  const pageNumbers = usePageNumbers(pageQuery);
+
+  // 定义:没勾选过就用输入词那一组(没有则第一组)的全部词形
+  const forms = useWordForms(state.q);
+  const words = useMemo(() => {
+    if (state.forms) return state.forms;
+    const groups = forms.data ?? [];
+    const q = state.q.trim().toLowerCase();
+    const group = groups.find((g) => g.base === q) ?? groups[0];
+    return group ? group.forms.map((f) => f.word) : [];
+  }, [state.forms, state.q, forms.data]);
+  const bold = state.bold === "all" ? undefined : state.bold;
+  const wordBooks = useWordBooks(words, bold);
+  // 目录范围内的书:书的 tag 包含某个选中节点的全部 tag
+  const scopeBooks = useMemo(() => {
+    const books = wordBooks.data ?? [];
+    if (state.scope.length === 0) return books;
+    const nodes = state.scope.map((key) => key.split(","));
+    return books.filter((b) =>
+      nodes.some((tags) => tags.every((t) => (b.tags ?? []).includes(t))),
+    );
+  }, [wordBooks.data, state.scope]);
+  // 最终的书过滤:勾了书就用勾的;只选了目录就用目录范围内的全部书(要等统计结果)
+  let bookIds: number[] | null = state.bookIds;
+  if (state.bookIds.length === 0 && state.scope.length > 0) {
+    bookIds = wordBooks.data
+      ? scopeBooks.map((b) => b.book_id ?? 0).filter(Boolean)
+      : null;
+  }
+  const scopeEmpty =
+    bookIds !== null && state.scope.length > 0 && bookIds.length === 0;
+  const wordParagraphs = useWordParagraphs(
+    words,
+    bold,
+    scopeEmpty ? null : bookIds,
+    state.defPage,
+  );
+
+  const submit = (value: string) => {
+    const q = value.trim();
+    let tab = state.tab;
+    if (looksLikePageNumber(q)) {
+      tab = "page";
+    } else if (tab === "page") {
+      tab = "fulltext";
+    }
+    onChange({
+      q,
+      tab,
+      page: 1,
+      titlePage: 1,
+      forms: undefined,
+      scope: [],
+      bookIds: [],
+      defPage: 1,
+      edition: undefined,
+      pageScope: [],
+    });
+  };
+
+  const count = (n?: number) =>
+    n === undefined ? null : (
+      <span
+        style={{
+          fontSize: token.fontSizeSM,
+          lineHeight: "18px",
+          padding: "0 7px",
+          borderRadius: 9,
+          background: token.colorFillSecondary,
+          color: token.colorTextSecondary,
+          fontVariantNumeric: "tabular-nums",
+        }}
+      >
+        {n.toLocaleString()}
+      </span>
+    );
+  const totals: Partial<Record<SearchTab, number | undefined>> = {
+    fulltext: state.q && !isPageQuery ? fullText.meta?.total : undefined,
+    title: state.q ? chapters.meta?.total : undefined,
+    page: pageQuery ? pageNumbers.meta?.total : undefined,
+    definition:
+      state.q && words.length ? wordParagraphs.meta?.total : undefined,
+  };
+
+  const pane = (tab: SearchTab): ReactNode => {
+    if (!state.q) {
+      return (
+        <Empty
+          style={{ marginTop: 64 }}
+          image={Empty.PRESENTED_IMAGE_SIMPLE}
+          description={intl.formatMessage({ id: "search.hint" })}
+        />
+      );
+    }
+    switch (tab) {
+      case "fulltext":
+        if (isPageQuery) {
+          return (
+            <Empty
+              style={{ marginTop: 64 }}
+              image={Empty.PRESENTED_IMAGE_SIMPLE}
+              description={intl.formatMessage({ id: "search.fulltext.page" })}
+            />
+          );
+        }
+        return (
+          <FullTextTab
+            state={state}
+            result={fullText}
+            onChange={onChange}
+            channel={channel}
+            newTab={newTab}
+          />
+        );
+      case "title":
+        return (
+          <TitleTab
+            state={state}
+            result={chapters}
+            onChange={onChange}
+            channel={channel}
+            newTab={newTab}
+          />
+        );
+      case "definition":
+        return (
+          <DefinitionTab
+            state={state}
+            onChange={onChange}
+            forms={forms}
+            words={words}
+            paragraphs={wordParagraphs}
+            books={wordBooks}
+            scopeBooks={scopeBooks}
+            scopeEmpty={scopeEmpty}
+            channel={channel}
+            newTab={newTab}
+          />
+        );
+      case "page":
+        return (
+          <PageTab
+            state={state}
+            onChange={onChange}
+            result={pageNumbers}
+            valid={pageQuery !== null}
+            volume={pageQuery?.volume}
+            channel={channel}
+            newTab={newTab}
+          />
+        );
+    }
+  };
+
+  return (
+    <Flex vertical style={{ height: "100%", minHeight: 0 }}>
+      <div
+        style={{
+          padding: "0 16px",
+          borderBottom: `1px solid ${token.colorBorderSecondary}`,
+        }}
+      >
+        <Flex gap={8} align="center">
+          <SearchInput
+            value={draft}
+            onChange={setDraft}
+            onSearch={submit}
+            autoFocus={autoFocus}
+          />
+          {extra}
+        </Flex>
+        <Tabs
+          activeKey={state.tab}
+          onChange={(k) => onChange({ tab: k as SearchTab })}
+          tabBarStyle={{ marginBottom: 0 }}
+          items={SEARCH_TABS.map((t) => ({
+            key: t,
+            label: (
+              <Flex gap={6} align="center">
+                {intl.formatMessage({ id: `search.tab.${t}` })}
+                {count(totals[t])}
+              </Flex>
+            ),
+          }))}
+        />
+      </div>
+      <div style={{ flex: 1, minHeight: 0 }}>{pane(state.tab)}</div>
+    </Flex>
+  );
+};
+
+export default SearchPanel;

+ 173 - 0
dashboard-v6/src/features/search/TitleTab.tsx

@@ -0,0 +1,173 @@
+import { Alert, Flex, Segmented, Table, Typography, theme } from "antd";
+import { useIntl } from "react-intl";
+import { Link } from "react-router";
+import type { ChapterHit, ChapterLayer } from "../../api/tipitaka-search";
+import LayerTag from "./LayerTag";
+import { TITLE_PER_PAGE, type useChapterSearch } from "./hooks";
+import type { ISearchState } from "./state";
+
+const { Text } = Typography;
+const PALI_FONT = '"Noto Serif", Georgia, "Times New Roman", serif';
+const LAYERS: ChapterLayer[] = ["mula", "atthakatha", "tika", "anna"];
+
+interface IWidget {
+  state: ISearchState;
+  result: ReturnType<typeof useChapterSearch>;
+  onChange: (patch: Partial<ISearchState>) => void;
+  channel?: string | null;
+  /** 链接在新标签页打开(在弹窗等浮动容器里时) */
+  newTab?: boolean;
+}
+
+/** 标题标签页:按章节名定位(/v3/tipitaka-chapters?q=),可按层级筛选 */
+const TitleTab = ({ state, result, onChange, channel, newTab }: IWidget) => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  const { loading, data, meta, error } = result;
+  const num = (n?: number) => (
+    <span style={{ fontVariantNumeric: "tabular-nums" }}>
+      {n?.toLocaleString() ?? "—"}
+    </span>
+  );
+
+  return (
+    <Flex vertical style={{ height: "100%", minHeight: 0 }}>
+      <Flex
+        gap={12}
+        align="center"
+        wrap
+        style={{
+          padding: "10px 16px",
+          borderBottom: `1px solid ${token.colorBorderSecondary}`,
+        }}
+      >
+        <Text strong>
+          {intl.formatMessage(
+            { id: "search.total.chapters" },
+            { n: (meta?.total ?? 0).toLocaleString() },
+          )}
+        </Text>
+        <Text type="secondary">
+          {intl.formatMessage({ id: "search.facet.layer" })}
+        </Text>
+        <Segmented<ChapterLayer | "">
+          size="small"
+          value={state.layer ?? ""}
+          options={[
+            { value: "", label: intl.formatMessage({ id: "search.all" }) },
+            ...LAYERS.map((l) => ({
+              value: l,
+              label: intl.formatMessage({ id: `search.layer.${l}` }),
+            })),
+          ]}
+          onChange={(v) => onChange({ layer: v || undefined, titlePage: 1 })}
+        />
+      </Flex>
+      <div
+        style={{
+          flex: 1,
+          minHeight: 0,
+          overflowY: "auto",
+          padding: "0 16px 16px",
+        }}
+      >
+        {error ? (
+          <Alert
+            type="warning"
+            showIcon
+            style={{ marginTop: 16 }}
+            message={error.message}
+          />
+        ) : (
+          <Table<ChapterHit>
+            size="small"
+            loading={loading}
+            dataSource={data}
+            rowKey={(r) => `${r.book}-${r.para}`}
+            scroll={{ x: 640 }}
+            locale={{ emptyText: intl.formatMessage({ id: "search.empty" }) }}
+            pagination={{
+              current: state.titlePage,
+              pageSize: TITLE_PER_PAGE,
+              total: meta?.total ?? 0,
+              showSizeChanger: false,
+              size: "small",
+              hideOnSinglePage: true,
+              onChange: (titlePage) => onChange({ titlePage }),
+            }}
+            columns={[
+              {
+                title: intl.formatMessage({ id: "search.col.chapter" }),
+                key: "title",
+                render: (_, r) => {
+                  const to =
+                    `/workspace/tipitaka/chapter/${r.book}-${r.para}` +
+                    (channel ? `?channel=${channel}` : "");
+                  return (
+                    <div>
+                      <Link
+                        to={to}
+                        target={newTab ? "_blank" : undefined}
+                        rel={newTab ? "noopener noreferrer" : undefined}
+                        style={{ fontFamily: PALI_FONT, fontWeight: 600 }}
+                      >
+                        {r.title}
+                      </Link>
+                      {(r.translations ?? []).length > 0 && (
+                        <Text type="secondary" style={{ marginInlineStart: 8 }}>
+                          {r.translations?.map((t) => t.title).join(" / ")}
+                        </Text>
+                      )}
+                      <div>
+                        <Text
+                          type="secondary"
+                          style={{
+                            fontFamily: PALI_FONT,
+                            fontSize: token.fontSizeSM,
+                          }}
+                        >
+                          {(r.path ?? [])
+                            .slice(1)
+                            .map((p) => p.title)
+                            .join(" › ")}
+                        </Text>
+                      </div>
+                    </div>
+                  );
+                },
+              },
+              {
+                title: intl.formatMessage({ id: "search.facet.layer" }),
+                key: "layer",
+                width: 80,
+                render: (_, r) => <LayerTag layer={r.layer} />,
+              },
+              {
+                title: intl.formatMessage({ id: "search.col.coord" }),
+                key: "coord",
+                width: 100,
+                render: (_, r) => <Text code>{`${r.book}-${r.para}`}</Text>,
+              },
+              {
+                title: intl.formatMessage({ id: "search.col.paragraphs" }),
+                key: "paragraphs",
+                align: "right",
+                width: 80,
+                render: (_, r) => num(r.paragraphs),
+              },
+              {
+                title: intl.formatMessage({ id: "search.col.chars" }),
+                key: "chars",
+                align: "right",
+                width: 100,
+                render: (_, r) => num(r.chars),
+              },
+            ]}
+          />
+        )}
+      </div>
+    </Flex>
+  );
+};
+
+export default TitleTab;

+ 50 - 0
dashboard-v6/src/features/search/categories.ts

@@ -0,0 +1,50 @@
+// 全文检索的 category 分面是书的标签,藏别、层级、书系混在一个列表里。
+// 这里把它分成三组显示;过滤时仍然都放进 category 参数(后端要求全部命中)。
+import type { ChapterLayer } from "../../api/tipitaka-search";
+
+export interface ICategoryOption {
+  /** 索引里的标签值 */
+  key: string;
+  /** 界面文案的 id */
+  labelId: string;
+}
+
+/** 层级:一段文字只属于其中一层,组内单选 */
+export const LAYER_OPTIONS: ICategoryOption[] = [
+  { key: "mūla", labelId: "search.layer.mula" },
+  { key: "aṭṭhakathā", labelId: "search.layer.atthakatha" },
+  { key: "ṭīkā", labelId: "search.layer.tika" },
+  { key: "añña", labelId: "search.layer.anna" },
+];
+
+/** 藏别:组内单选 */
+export const PITAKA_OPTIONS: ICategoryOption[] = [
+  { key: "vinaya", labelId: "search.pitaka.vinaya" },
+  { key: "sutta", labelId: "search.pitaka.sutta" },
+  { key: "abhidhamma", labelId: "search.pitaka.abhidhamma" },
+];
+
+const LAYER_KEYS = new Set(LAYER_OPTIONS.map((o) => o.key));
+const PITAKA_KEYS = new Set(PITAKA_OPTIONS.map((o) => o.key));
+
+/** 不属于层级、藏别的其余标签(尼柯耶、书系等),组内可多选(全部命中) */
+export const isOtherCategory = (key: string): boolean =>
+  !LAYER_KEYS.has(key) && !PITAKA_KEYS.has(key);
+
+export const isLayerCategory = (key: string): boolean => LAYER_KEYS.has(key);
+export const isPitakaCategory = (key: string): boolean => PITAKA_KEYS.has(key);
+
+/** 段落的 category → 章节接口的 layer 值(用于统一的层级标签) */
+const CATEGORY_TO_LAYER: Record<string, ChapterLayer> = {
+  mūla: "mula",
+  aṭṭhakathā: "atthakatha",
+  ṭīkā: "tika",
+  añña: "anna",
+};
+
+export const layerOf = (category?: string[]): ChapterLayer | undefined => {
+  for (const c of category ?? []) {
+    if (CATEGORY_TO_LAYER[c]) return CATEGORY_TO_LAYER[c];
+  }
+  return undefined;
+};

+ 147 - 0
dashboard-v6/src/features/search/hooks.ts

@@ -0,0 +1,147 @@
+import { useEffect, useState } from "react";
+import {
+  aggregateWordBooks,
+  searchChapters,
+  searchPageNumbers,
+  searchParagraphs,
+  searchWordParagraphs,
+  type BoldScope,
+  type ChapterHit,
+  type ChapterLayer,
+  type PageNumberHit,
+  type SearchHit,
+  type SearchMeta,
+  type SearchMode,
+  type WordBook,
+  type WordBookMeta,
+  type WordParagraph,
+  type WordParagraphMeta,
+} from "../../api/tipitaka-search";
+import { fetchWordForms, type WordFormGroup } from "../../api/pali-word-form";
+import type { ApiError } from "../../api/error";
+
+export const FULLTEXT_PER_PAGE = 20;
+export const TITLE_PER_PAGE = 20;
+export const DEFINITION_PER_PAGE = 20;
+
+export interface IRemote<T, M> {
+  loading: boolean;
+  data?: T[];
+  meta?: M;
+  error?: ApiError;
+}
+
+/**
+ * 发请求、丢弃过期响应的通用部分:条件变了,旧请求晚到的结果不能覆盖新的。
+ * `key` 为 null 时不查(没有检索词)。
+ */
+function useRemote<T, M>(
+  key: string | null,
+  load: () => Promise<{ data?: T[]; meta?: M }>,
+): IRemote<T, M> {
+  const [state, setState] = useState<IRemote<T, M>>({ loading: false });
+
+  useEffect(() => {
+    if (key === null) {
+      setState({ loading: false });
+      return;
+    }
+    let stale = false;
+    setState((s) => ({ ...s, loading: true, error: undefined }));
+    load()
+      .then((res) => {
+        if (!stale)
+          setState({ loading: false, data: res.data ?? [], meta: res.meta });
+      })
+      .catch((e: ApiError) => {
+        if (!stale) setState({ loading: false, error: e });
+      });
+    return () => {
+      stale = true;
+    };
+    // load 由 key 完全决定,不放进依赖
+    // eslint-disable-next-line react-hooks/exhaustive-deps
+  }, [key]);
+
+  return state;
+}
+
+export const useFullTextSearch = (
+  q: string,
+  mode: SearchMode,
+  category: string[],
+  page: number,
+) => {
+  const term = q.trim();
+  const params = { q: term, mode, category, page, perPage: FULLTEXT_PER_PAGE };
+  return useRemote<SearchHit, SearchMeta>(
+    term ? JSON.stringify(params) : null,
+    () => searchParagraphs(params),
+  );
+};
+
+export const useChapterSearch = (
+  q: string,
+  layer: ChapterLayer | undefined,
+  page: number,
+) => {
+  const term = q.trim();
+  const params = { q: term, layer, page, perPage: TITLE_PER_PAGE };
+  return useRemote<ChapterHit, { total?: number }>(
+    term ? JSON.stringify(params) : null,
+    () => searchChapters(params),
+  );
+};
+
+/** 定义:检索词展开成词形(只支持单个词) */
+export const useWordForms = (q: string) => {
+  const term = q.trim();
+  return useRemote<WordFormGroup, undefined>(
+    term && !/\s/.test(term) ? term : null,
+    () => fetchWordForms(term, { quiet: true }).then((data) => ({ data })),
+  );
+};
+
+/**
+ * 定义:命中这些词形的段落。
+ * `bookIds` 为 null 表示书的范围还没算出来(目录过滤要等按书统计的结果),先不查。
+ */
+export const useWordParagraphs = (
+  words: string[],
+  bold: BoldScope | undefined,
+  bookIds: number[] | null,
+  page: number,
+) => {
+  const params = {
+    words,
+    bold,
+    bookIds: bookIds ?? [],
+    page,
+    perPage: DEFINITION_PER_PAGE,
+  };
+  return useRemote<WordParagraph, WordParagraphMeta>(
+    words.length && bookIds !== null ? JSON.stringify(params) : null,
+    () => searchWordParagraphs(params),
+  );
+};
+
+/** 定义:命中按书统计 */
+export const useWordBooks = (words: string[], bold: BoldScope | undefined) => {
+  const params = { words, bold };
+  return useRemote<WordBook, WordBookMeta>(
+    words.length ? JSON.stringify(params) : null,
+    () => aggregateWordBooks(params),
+  );
+};
+
+/** 页码:检索词是「页」或「卷.页」时才查 */
+export const usePageNumbers = (
+  query: { page: number; volume?: number } | null,
+) =>
+  useRemote<PageNumberHit, { total?: number }>(
+    query ? JSON.stringify(query) : null,
+    () =>
+      query
+        ? searchPageNumbers(query.page, query.volume)
+        : Promise.resolve({ data: [] }),
+  );

+ 139 - 0
dashboard-v6/src/features/search/state.ts

@@ -0,0 +1,139 @@
+// 搜索面板的状态:弹窗里存在组件 state,整页(/search)存在地址栏,
+// 两边共用同一套字段,「在整页打开」只是把它序列化成查询串。
+import type {
+  BoldScope,
+  ChapterLayer,
+  SearchMode,
+} from "../../api/tipitaka-search";
+
+export type SearchTab = "fulltext" | "definition" | "title" | "page";
+
+export const SEARCH_TABS: SearchTab[] = [
+  "fulltext",
+  "definition",
+  "title",
+  "page",
+];
+
+export const SEARCH_MODES: SearchMode[] = ["fuzzy", "exact", "definition"];
+
+const CHAPTER_LAYERS: ChapterLayer[] = ["mula", "atthakatha", "tika", "anna"];
+
+/** 定义标签页的黑体范围:all 是不限 */
+export type DefinitionBold = BoldScope | "all";
+export const DEFINITION_BOLDS: DefinitionBold[] = ["only", "all", "exclude"];
+
+export interface ISearchState {
+  q: string;
+  tab: SearchTab;
+  /** 全文:匹配方式 */
+  mode: SearchMode;
+  /** 全文:已选的分类(书的标签),全部命中 */
+  category: string[];
+  /** 全文:页码 */
+  page: number;
+  /** 标题:层级 */
+  layer?: ChapterLayer;
+  /** 标题:页码 */
+  titlePage: number;
+  /** 定义:勾选的词形;undefined 表示按默认(输入词那一组的全部词形) */
+  forms?: string[];
+  /** 定义:黑体范围,默认只看黑体(被解释的词) */
+  bold: DefinitionBold;
+  /** 定义:目录树选中的节点(节点 key = 它的 tag 用逗号连起来);只看属于这些节点的书 */
+  scope: string[];
+  /** 定义:在目录范围内再勾选的书(book_id) */
+  bookIds: number[];
+  /** 定义:页码 */
+  defPage: number;
+  /** 页码:当前看的版本(PTS / My / VRI / Thai / Other / CS);不给就取第一个有结果的 */
+  edition?: string;
+  /** 页码:目录树选中的节点(同定义的 scope,两个标签页各管各的) */
+  pageScope: string[];
+}
+
+export const initialSearchState: ISearchState = {
+  q: "",
+  tab: "fulltext",
+  mode: "fuzzy",
+  category: [],
+  page: 1,
+  titlePage: 1,
+  bold: "only",
+  scope: [],
+  bookIds: [],
+  defPage: 1,
+  pageScope: [],
+};
+
+/** 纯数字或「卷.页」:大概率是在找页码 */
+export const looksLikePageNumber = (q: string): boolean =>
+  /^\d+(\.\d+)?$/.test(q.trim());
+
+/** 「100」→ 第 100 页;「2.100」→ 第 2 卷第 100 页 */
+export const parsePageQuery = (
+  q: string,
+): { page: number; volume?: number } | null => {
+  const m = /^(?:(\d+)\.)?(\d+)$/.exec(q.trim());
+  if (!m) return null;
+  const page = Number(m[2]);
+  const volume = m[1] ? Number(m[1]) : undefined;
+  if (page < 1 || (volume !== undefined && volume < 1)) return null;
+  return { page, volume };
+};
+
+const oneOf = <T extends string>(
+  list: readonly T[],
+  v: string | null,
+): T | undefined =>
+  v && (list as readonly string[]).includes(v) ? (v as T) : undefined;
+
+const positive = (v: string | null): number => {
+  const n = Number(v);
+  return Number.isInteger(n) && n > 0 ? n : 1;
+};
+
+const splitList = (v: string | null): string[] =>
+  (v ?? "")
+    .split(",")
+    .map((s) => s.trim())
+    .filter(Boolean);
+
+export const parseSearchParams = (sp: URLSearchParams): ISearchState => ({
+  q: sp.get("q") ?? "",
+  tab: oneOf(SEARCH_TABS, sp.get("tab")) ?? "fulltext",
+  mode: oneOf(SEARCH_MODES, sp.get("mode")) ?? "fuzzy",
+  category: splitList(sp.get("category")),
+  page: positive(sp.get("page")),
+  layer: oneOf(CHAPTER_LAYERS, sp.get("layer")),
+  titlePage: positive(sp.get("title_page")),
+  forms: sp.has("forms") ? splitList(sp.get("forms")) : undefined,
+  bold: oneOf(DEFINITION_BOLDS, sp.get("bold")) ?? "only",
+  scope: (sp.get("scope") ?? "").split(";").filter(Boolean),
+  bookIds: splitList(sp.get("book_id"))
+    .map(Number)
+    .filter((n) => Number.isInteger(n) && n > 0),
+  defPage: positive(sp.get("def_page")),
+  edition: sp.get("edition") ?? undefined,
+  pageScope: (sp.get("page_scope") ?? "").split(";").filter(Boolean),
+});
+
+/** 只写非默认值,地址短一些 */
+export const toSearchParams = (s: ISearchState): URLSearchParams => {
+  const sp = new URLSearchParams();
+  if (s.q) sp.set("q", s.q);
+  if (s.tab !== "fulltext") sp.set("tab", s.tab);
+  if (s.mode !== "fuzzy") sp.set("mode", s.mode);
+  if (s.category.length) sp.set("category", s.category.join(","));
+  if (s.page > 1) sp.set("page", String(s.page));
+  if (s.layer) sp.set("layer", s.layer);
+  if (s.titlePage > 1) sp.set("title_page", String(s.titlePage));
+  if (s.forms) sp.set("forms", s.forms.join(","));
+  if (s.bold !== "only") sp.set("bold", s.bold);
+  if (s.scope.length) sp.set("scope", s.scope.join(";"));
+  if (s.bookIds.length) sp.set("book_id", s.bookIds.join(","));
+  if (s.defPage > 1) sp.set("def_page", String(s.defPage));
+  if (s.edition) sp.set("edition", s.edition);
+  if (s.pageScope.length) sp.set("page_scope", s.pageScope.join(";"));
+  return sp;
+};

+ 2 - 0
dashboard-v6/src/locales/en-US.ts

@@ -12,6 +12,7 @@ import error from "./en-US/error";
 import pages from "./en-US/pages";
 import admin from "./en-US/admin";
 import adminStats from "./en-US/admin-stats";
+import search from "./en-US/search";
 
 const items = {
   "columns.library.title": "Library",
@@ -77,6 +78,7 @@ const items = {
   "channel.links.empty": "Not set",
   ...admin,
   ...adminStats,
+  ...search,
 };
 
 export default items;

+ 77 - 0
dashboard-v6/src/locales/en-US/search.ts

@@ -0,0 +1,77 @@
+// workspace 搜索面板(features/search)文案
+const items = {
+  "search.placeholder":
+    "Pāli word, phrase or chapter name, press Enter; type a number to find a page",
+  "search.hint": "Type a search term and press Enter",
+  "search.suggest.count": "{count} · bold {bold}",
+  "search.title": "Search",
+  "search.open_full_page": "Open in new tab",
+  "search.tab.fulltext": "Full text",
+  "search.tab.definition": "Definitions",
+  "search.tab.title": "Titles",
+  "search.tab.page": "Page numbers",
+  "search.facet.layer": "Layer",
+  "search.facet.pitaka": "Piṭaka",
+  "search.facet.other": "Other categories",
+  "search.facet.clear": "Clear filters",
+  "search.layer.mula": "Mūla",
+  "search.layer.atthakatha": "Aṭṭhakathā",
+  "search.layer.tika": "Ṭīkā",
+  "search.layer.anna": "Añña",
+  "search.pitaka.vinaya": "Vinaya",
+  "search.pitaka.sutta": "Sutta",
+  "search.pitaka.abhidhamma": "Abhidhamma",
+  "search.mode": "Match",
+  "search.mode.fuzzy": "Fuzzy",
+  "search.mode.fuzzy.tip": "Tolerates inflection, sandhi and diacritics",
+  "search.mode.exact": "Exact",
+  "search.mode.exact.tip": "This word form only",
+  "search.mode.definition": "Definitions first",
+  "search.mode.definition.tip":
+    "Paragraphs where the word is in bold (being defined) come first",
+  "search.total": "{n} paragraphs",
+  "search.total.gte": "At least {n} paragraphs",
+  "search.total.chapters": "{n} chapters",
+  "search.all": "All",
+  "search.empty": "No results",
+  "search.copy_citation": "Copy citation",
+  "search.copied": "Copied",
+  "search.copy_failed": "Could not copy. Select the text and copy it manually",
+  "search.bold_in_para": "Bold in this paragraph: ",
+  "search.col.chapter": "Chapter",
+  "search.col.coord": "Location",
+  "search.col.paragraphs": "Paragraphs",
+  "search.col.chars": "Characters",
+  "search.forms.all": "All",
+  "search.forms.none": "None",
+  "search.forms.bold": "Times in bold",
+  "search.forms.selected": "{n} forms selected",
+  "search.books": "Books ({n})",
+  "search.books.tip": "{n} occurrences",
+  "search.show_more": "Show {n} more",
+  "search.show_less": "Show less",
+  "search.bold.only": "Bold only",
+  "search.bold.all": "All occurrences",
+  "search.bold.exclude": "Not bold",
+  "search.def.multiword":
+    "Definitions take a single word. Use Full text for several words",
+  "search.def.no_forms":
+    "No form of this word occurs in the corpus. Check the spelling or try another stem",
+  "search.def.pick_forms": "Select word forms on the left",
+  "search.forms.expand": "Show {n} forms",
+  "search.def.scope_empty": "No hits in the selected sections",
+  "search.page.hint": "Type a page number, or volume.page, e.g. 100 or 2.100",
+  "search.page.scope_empty": "No results for this page in the selected sections",
+  "search.fulltext.page": "This looks like a page number, so full-text search is skipped. See the Page tab",
+  "search.page.total": "Page {page}: {n} places",
+  "search.page.total.volume": "Vol. {volume}, page {page}: {n} places",
+  "search.edition.PTS": "PTS",
+  "search.edition.My": "Myanmar",
+  "search.edition.VRI": "VRI",
+  "search.edition.Thai": "Thai",
+  "search.edition.Other": "Other",
+  "search.edition.CS": "CS paragraph",
+  "search.layer.none": "No layer",
+};
+
+export default items;

+ 2 - 0
dashboard-v6/src/locales/zh-Hans.ts

@@ -12,6 +12,7 @@ import error from "./zh-Hans/error";
 import pages from "./zh-Hans/pages";
 import admin from "./zh-Hans/admin";
 import adminStats from "./zh-Hans/admin-stats";
+import search from "./zh-Hans/search";
 
 const items = {
   "columns.library.title": "藏经阁",
@@ -77,6 +78,7 @@ const items = {
   "channel.links.empty": "未设置",
   ...admin,
   ...adminStats,
+  ...search,
 };
 
 export default items;

+ 73 - 0
dashboard-v6/src/locales/zh-Hans/search.ts

@@ -0,0 +1,73 @@
+// workspace 搜索面板(features/search)文案
+const items = {
+  "search.placeholder": "巴利词、短语或章节名,回车搜索;输入数字查页码",
+  "search.hint": "输入检索词后回车",
+  "search.suggest.count": "{count} 次 · 黑体 {bold}",
+  "search.title": "搜索",
+  "search.open_full_page": "在新标签页打开",
+  "search.tab.fulltext": "全文",
+  "search.tab.definition": "定义",
+  "search.tab.title": "标题",
+  "search.tab.page": "页码",
+  "search.facet.layer": "层级",
+  "search.facet.pitaka": "藏别",
+  "search.facet.other": "其他分类",
+  "search.facet.clear": "清除筛选",
+  "search.layer.mula": "根本",
+  "search.layer.atthakatha": "义注",
+  "search.layer.tika": "复注",
+  "search.layer.anna": "藏外",
+  "search.pitaka.vinaya": "律",
+  "search.pitaka.sutta": "经",
+  "search.pitaka.abhidhamma": "论",
+  "search.mode": "匹配",
+  "search.mode.fuzzy": "模糊",
+  "search.mode.fuzzy.tip": "变格、连音、变音符号都容错",
+  "search.mode.exact": "精确",
+  "search.mode.exact.tip": "只要这个词形",
+  "search.mode.definition": "定义优先",
+  "search.mode.definition.tip": "黑体(被解释的词)排在前面",
+  "search.total": "{n} 段",
+  "search.total.gte": "至少 {n} 段",
+  "search.total.chapters": "{n} 个章节",
+  "search.all": "全部",
+  "search.empty": "没有找到",
+  "search.copy_citation": "复制引用",
+  "search.copied": "已复制",
+  "search.copy_failed": "复制失败,请手动选择文字复制",
+  "search.bold_in_para": "本段黑体:",
+  "search.col.chapter": "章节",
+  "search.col.coord": "坐标",
+  "search.col.paragraphs": "段数",
+  "search.col.chars": "字符",
+  "search.forms.all": "全选",
+  "search.forms.none": "全不选",
+  "search.forms.bold": "黑体次数",
+  "search.forms.selected": "已选 {n} 个词形",
+  "search.books": "书({n})",
+  "search.books.tip": "{n} 词次",
+  "search.show_more": "展开其余 {n} 个",
+  "search.show_less": "收起",
+  "search.bold.only": "只看黑体",
+  "search.bold.all": "全部出现",
+  "search.bold.exclude": "非黑体",
+  "search.def.multiword": "定义检索只支持单个词;多个词请用「全文」",
+  "search.def.no_forms": "语料里没有这个词的任何词形,检查拼写或换一个词根",
+  "search.def.pick_forms": "在左边勾选要查的词形",
+  "search.forms.expand": "展开 {n} 个词形",
+  "search.def.scope_empty": "所选目录下没有命中",
+  "search.page.hint": "输入页码数字,或「卷.页」,如 100、2.100",
+  "search.page.scope_empty": "所选目录里没有这一页",
+  "search.fulltext.page": "这是页码,全文不检索数字。请到「页码」标签页查看",
+  "search.page.total": "第 {page} 页共 {n} 处",
+  "search.page.total.volume": "第 {volume} 卷第 {page} 页共 {n} 处",
+  "search.edition.PTS": "PTS",
+  "search.edition.My": "缅甸版",
+  "search.edition.VRI": "VRI",
+  "search.edition.Thai": "泰国版",
+  "search.edition.Other": "其他",
+  "search.edition.CS": "CS 段落号",
+  "search.layer.none": "未标层级",
+};
+
+export default items;

+ 2 - 0
dashboard-v6/src/locales/zh-Hant.ts

@@ -12,6 +12,7 @@ import error from "./zh-Hant/error";
 import pages from "./zh-Hant/pages";
 import admin from "./zh-Hant/admin";
 import adminStats from "./zh-Hant/admin-stats";
+import search from "./zh-Hant/search";
 
 const items = {
   "columns.library.title": "藏經閣",
@@ -77,6 +78,7 @@ const items = {
   "channel.links.empty": "未設定",
   ...admin,
   ...adminStats,
+  ...search,
 };
 
 export default items;

+ 73 - 0
dashboard-v6/src/locales/zh-Hant/search.ts

@@ -0,0 +1,73 @@
+// workspace 搜索面板(features/search)文案
+const items = {
+  "search.placeholder": "巴利詞、短語或章節名,Enter 搜尋;輸入數字查頁碼",
+  "search.hint": "輸入檢索詞後按 Enter",
+  "search.suggest.count": "{count} 次 · 黑體 {bold}",
+  "search.title": "搜尋",
+  "search.open_full_page": "在新分頁開啟",
+  "search.tab.fulltext": "全文",
+  "search.tab.definition": "定義",
+  "search.tab.title": "標題",
+  "search.tab.page": "頁碼",
+  "search.facet.layer": "層級",
+  "search.facet.pitaka": "藏別",
+  "search.facet.other": "其他分類",
+  "search.facet.clear": "清除篩選",
+  "search.layer.mula": "根本",
+  "search.layer.atthakatha": "義註",
+  "search.layer.tika": "復註",
+  "search.layer.anna": "藏外",
+  "search.pitaka.vinaya": "律",
+  "search.pitaka.sutta": "經",
+  "search.pitaka.abhidhamma": "論",
+  "search.mode": "匹配",
+  "search.mode.fuzzy": "模糊",
+  "search.mode.fuzzy.tip": "變格、連音、變音符號都容錯",
+  "search.mode.exact": "精確",
+  "search.mode.exact.tip": "只要這個詞形",
+  "search.mode.definition": "定義優先",
+  "search.mode.definition.tip": "黑體(被解釋的詞)排在前面",
+  "search.total": "{n} 段",
+  "search.total.gte": "至少 {n} 段",
+  "search.total.chapters": "{n} 個章節",
+  "search.all": "全部",
+  "search.empty": "沒有找到",
+  "search.copy_citation": "複製引用",
+  "search.copied": "已複製",
+  "search.copy_failed": "複製失敗,請手動選取文字複製",
+  "search.bold_in_para": "本段黑體:",
+  "search.col.chapter": "章節",
+  "search.col.coord": "座標",
+  "search.col.paragraphs": "段數",
+  "search.col.chars": "字元",
+  "search.forms.all": "全選",
+  "search.forms.none": "全不選",
+  "search.forms.bold": "黑體次數",
+  "search.forms.selected": "已選 {n} 個詞形",
+  "search.books": "書({n})",
+  "search.books.tip": "{n} 詞次",
+  "search.show_more": "展開其餘 {n} 個",
+  "search.show_less": "收起",
+  "search.bold.only": "只看黑體",
+  "search.bold.all": "全部出現",
+  "search.bold.exclude": "非黑體",
+  "search.def.multiword": "定義檢索只支援單個詞;多個詞請用「全文」",
+  "search.def.no_forms": "語料裡沒有這個詞的任何詞形,檢查拼寫或換一個詞根",
+  "search.def.pick_forms": "在左邊勾選要查的詞形",
+  "search.forms.expand": "展開 {n} 個詞形",
+  "search.def.scope_empty": "所選目錄下沒有命中",
+  "search.page.hint": "輸入頁碼數字,或「卷.頁」,如 100、2.100",
+  "search.page.scope_empty": "所選目錄裡沒有這一頁",
+  "search.fulltext.page": "這是頁碼,全文不檢索數字。請到「頁碼」標籤頁查看",
+  "search.page.total": "第 {page} 頁共 {n} 處",
+  "search.page.total.volume": "第 {volume} 卷第 {page} 頁共 {n} 處",
+  "search.edition.PTS": "PTS",
+  "search.edition.My": "緬甸版",
+  "search.edition.VRI": "VRI",
+  "search.edition.Thai": "泰國版",
+  "search.edition.Other": "其他",
+  "search.edition.CS": "CS 段落號",
+  "search.layer.none": "未標層級",
+};
+
+export default items;

+ 59 - 0
dashboard-v6/src/pages/search.tsx

@@ -0,0 +1,59 @@
+import { theme } from "antd";
+import { useIntl } from "react-intl";
+import { useSearchParams } from "react-router";
+import SearchPanel from "../features/search/SearchPanel";
+import {
+  parseSearchParams,
+  toSearchParams,
+  type ISearchState,
+} from "../features/search/state";
+
+/**
+ * /search:整页的搜索(不在 workspace 布局里)。条件全部在地址栏里(q、tab、mode、category…),
+ * 可以收藏、分享,也是 workspace 搜索弹窗「在整页打开」的去处。
+ */
+const Widget = () => {
+  const intl = useIntl();
+  const { token } = theme.useToken();
+  const [searchParams, setSearchParams] = useSearchParams();
+  const state = parseSearchParams(searchParams);
+
+  const onChange = (patch: Partial<ISearchState>) =>
+    setSearchParams(toSearchParams({ ...state, ...patch }), {
+      replace: !patch.q,
+    });
+
+  // 标签页标题:「检索词 - 标签页 - 搜索」,没有检索词时只写「搜索」
+  const name = intl.formatMessage({ id: "search.title" });
+  const title = state.q
+    ? `${state.q} - ${intl.formatMessage({ id: `search.tab.${state.tab}` })} - ${name}`
+    : name;
+
+  return (
+    <div
+      style={{
+        height: "100vh",
+        boxSizing: "border-box",
+        padding: 12,
+        background: token.colorBgLayout,
+      }}
+    >
+      <title>{title}</title>
+      <div
+        style={{
+          height: "100%",
+          maxWidth: 1400,
+          margin: "0 auto",
+          background: token.colorBgContainer,
+          borderRadius: token.borderRadiusLG,
+          paddingTop: 14,
+          overflow: "hidden",
+        }}
+      >
+        <SearchPanel state={state} onChange={onChange} autoFocus={!state.q} />
+      </div>
+    </div>
+  );
+};
+
+export default Widget;

+ 10 - 0
openapi/public/assets/protocol/main.yaml

@@ -841,6 +841,10 @@ paths:
     $ref: ./resources/auto/v3-me-reading-time.yaml
   '/v3/nissaya-cards/{ending}':
     $ref: ./resources/auto/v3-nissaya-cards-ending.yaml
+  '/v3/pali-word-forms/{word}':
+    $ref: ./resources/auto/v3-pali-word-forms-word.yaml
+  /v3/pali-word-suggestions:
+    $ref: ./resources/auto/v3-pali-word-suggestions.yaml
   /v3/password-resets:
     $ref: ./resources/auto/v3-password-resets.yaml
   '/v3/password-resets/{token}':
@@ -877,6 +881,8 @@ paths:
     $ref: ./resources/auto/v3-tipitaka-chapters.yaml
   '/v3/tipitaka-discussions/{channel}':
     $ref: ./resources/auto/v3-tipitaka-discussions-channel.yaml
+  '/v3/tipitaka-page-numbers/{page}':
+    $ref: ./resources/auto/v3-tipitaka-page-numbers-page.yaml
   '/v3/tipitaka-paragraph-channels/{book}/{para}':
     $ref: ./resources/auto/v3-tipitaka-paragraph-channels-book-para.yaml
   '/v3/tipitaka-reading/{channel}':
@@ -887,6 +893,10 @@ paths:
     $ref: ./resources/auto/v3-tipitaka-related-paragraphs-aggregate.yaml
   '/v3/tipitaka-related-paragraphs/aggregate/{book_name}':
     $ref: ./resources/auto/v3-tipitaka-related-paragraphs-aggregate-book-name.yaml
+  /v3/tipitaka-word-paragraphs:
+    $ref: ./resources/auto/v3-tipitaka-word-paragraphs.yaml
+  /v3/tipitaka-word-paragraphs/aggregate:
+    $ref: ./resources/auto/v3-tipitaka-word-paragraphs-aggregate.yaml
   /v3/upgrade:
     $ref: ./resources/auto/v3-upgrade.yaml
   /v3/users:

+ 7 - 0
openapi/public/assets/protocol/overrides/v2-case-case.yaml

@@ -0,0 +1,7 @@
+# 手写补充:v2 词形展开已被 v3 取代(2026-11-19)。
+get:
+  deprecated: true
+  description: |
+    已被 `GET /v3/pali-word-forms/{word}` 取代:候选词形一次批量查出现次数(v2 逐个词形查库,一个词上百次),
+    去掉了每条里多余的 `"0": "ending"` 键,词不区分大小写。字段:`rows[].word`→`data[].base`,`rows[].case`→`data[].forms`,
+    `count`→`meta.total`;没有任何词形出现过的词根不再列出。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。

+ 7 - 0
openapi/public/assets/protocol/overrides/v2-pali-word-index.yaml

@@ -0,0 +1,7 @@
+# 手写补充:v2 巴利词补全已被 v3 取代(2026-11-19)。
+get:
+  deprecated: true
+  description: |
+    `view=key` 已被 `GET /v3/pali-word-suggestions?q=` 取代:排序从「词长、去变音形」改成「与输入相同的在前,其余按出现次数降序」
+    (v2 下短而罕见的词形挤掉常用词),只回 `word` / `count` / `bold` 三个字段,不再整行吐出;输入里的 `%`、`_` 按字面匹配;
+    `key`→`q`,`rows`→`data`,`count`→`meta.total`,可用 `limit`(默认 10,上限 50)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。

+ 8 - 0
openapi/public/assets/protocol/overrides/v2-search-page-number-search-page-number.yaml

@@ -0,0 +1,8 @@
+# 手写补充:v2 页码检索已被 v3 取代(2026-11-19)。
+get:
+  deprecated: true
+  description: |
+    已被 `GET /v3/tipitaka-page-numbers/{page}` 取代:可按版本 `edition`(PTS / My / VRI / Thai / Other / CS)与卷号 `volume` 过滤,
+    每条带书名、书名所在段、层级与该版本的书名(v2 只有坐标)。字段:`type`(单字母)→`edition`,`para` 类型→`edition=CS`,
+    `paragraph`→`para`,`pcd_book_id`→`book_id`,卷号 0 → `volume: null`。响应 `{ok, data: [...]}` → `{data, meta: {total}}`。
+    保留仅为 dashboard-v4 兼容,待 v4 下线后删除。

+ 7 - 0
openapi/public/assets/protocol/overrides/v2-search-pali-wbw-books.yaml

@@ -0,0 +1,7 @@
+# 手写补充:v2 逐词检索的出处分布已被 v3 取代(2026-11-19)。
+get:
+  deprecated: true
+  description: |
+    已被 `GET /v3/tipitaka-word-paragraphs/aggregate` 取代:同时给段落数 `paragraphs` 与词次 `occurrences`(v2 只有词次 `count`),
+    书名、tag 批量取(v2 每本书另查 3 次库),另给 `layer`。字段:`pcdBookId`→`book_id`,`paragraph`→`para`,`paliTitle`→`title`,
+    `tags[].name`→`tags`(字符串数组)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。

+ 13 - 0
openapi/public/assets/protocol/overrides/v2-search-pali-wbw.yaml

@@ -0,0 +1,13 @@
+# 手写补充:v2 逐词检索已被 v3 取代(2026-11-19)。
+get:
+  deprecated: true
+  description: |
+    已被 `GET /v3/tipitaka-word-paragraphs` 取代:段落、标题、页码整页批量取(v2 每行另查 3~4 次库);`text` 只含 `<b>` 黑体与
+    `<mark>` 命中词的安全 HTML(v2 是整段原始 HTML 加字符串替换);不再给指向旧版 library 的 `link`。参数:`key`→`words`,
+    `bold=on|off`→`bold=only|exclude`,`book`→`book_id`,`limit`/`offset`→`per_page`/`page`;`view`、`tags` 去掉。
+    字段:`paragraph`→`para`,`rank`→`score`,`paliTitle`→`title`,`highlight`→`text`,`ref`→`refs`(多了 `volume`);`count`→`meta.total`。
+    保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
+post:
+  deprecated: true
+  description: |
+    与 GET 相同,已被 `GET /v3/tipitaka-word-paragraphs` 取代。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。

+ 5 - 1
openapi/public/assets/protocol/resources/auto/v2-case-case.yaml

@@ -4,7 +4,10 @@ get:
   tags:
     - case
   operationId: get_api_v2_case_case_
-  description: 实现:`CaseController@show`
+  description: |
+    已被 `GET /v3/pali-word-forms/{word}` 取代:候选词形一次批量查出现次数(v2 逐个词形查库,一个词上百次),
+    去掉了每条里多余的 `"0": "ending"` 键,词不区分大小写。字段:`rows[].word`→`data[].base`,`rows[].case`→`data[].forms`,
+    `count`→`meta.total`;没有任何词形出现过的词根不再列出。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
   parameters:
     -
       name: case
@@ -30,6 +33,7 @@ get:
       $ref: '../../main.yaml#/components/responses/Unauthorized'
     422:
       $ref: '../../main.yaml#/components/responses/ValidationError'
+  deprecated: true
 put:
   summary: '更新 case/{case}'
   tags:

+ 5 - 1
openapi/public/assets/protocol/resources/auto/v2-pali-word-index.yaml

@@ -4,7 +4,10 @@ get:
   tags:
     - pali-word-index
   operationId: get_api_v2_pali_word_index
-  description: 实现:`WordIndexController@index`
+  description: |
+    `view=key` 已被 `GET /v3/pali-word-suggestions?q=` 取代:排序从「词长、去变音形」改成「与输入相同的在前,其余按出现次数降序」
+    (v2 下短而罕见的词形挤掉常用词),只回 `word` / `count` / `bold` 三个字段,不再整行吐出;输入里的 `%`、`_` 按字面匹配;
+    `key`→`q`,`rows`→`data`,`count`→`meta.total`,可用 `limit`(默认 10,上限 50)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
   parameters:
     -
       name: view
@@ -76,6 +79,7 @@ get:
       $ref: '../../main.yaml#/components/responses/Unauthorized'
     422:
       $ref: '../../main.yaml#/components/responses/ValidationError'
+  deprecated: true
 post:
   summary: '新建 pali-word-index'
   tags:

+ 6 - 1
openapi/public/assets/protocol/resources/auto/v2-search-page-number-search-page-number.yaml

@@ -4,7 +4,11 @@ get:
   tags:
     - search-page-number
   operationId: get_api_v2_search_page_number_search_page_number_
-  description: 实现:`SearchPageNumberController@show`
+  description: |
+    已被 `GET /v3/tipitaka-page-numbers/{page}` 取代:可按版本 `edition`(PTS / My / VRI / Thai / Other / CS)与卷号 `volume` 过滤,
+    每条带书名、书名所在段、层级与该版本的书名(v2 只有坐标)。字段:`type`(单字母)→`edition`,`para` 类型→`edition=CS`,
+    `paragraph`→`para`,`pcd_book_id`→`book_id`,卷号 0 → `volume: null`。响应 `{ok, data: [...]}` → `{data, meta: {total}}`。
+    保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
   parameters:
     -
       name: search_page_number
@@ -30,6 +34,7 @@ get:
       $ref: '../../main.yaml#/components/responses/Unauthorized'
     422:
       $ref: '../../main.yaml#/components/responses/ValidationError'
+  deprecated: true
 put:
   summary: '更新 search-page-number/{search_page_number}'
   tags:

+ 5 - 1
openapi/public/assets/protocol/resources/auto/v2-search-pali-wbw-books.yaml

@@ -4,7 +4,10 @@ get:
   tags:
     - search-pali-wbw-books
   operationId: get_api_v2_search_pali_wbw_books
-  description: 实现:`SearchPaliWbwController@book_list`
+  description: |
+    已被 `GET /v3/tipitaka-word-paragraphs/aggregate` 取代:同时给段落数 `paragraphs` 与词次 `occurrences`(v2 只有词次 `count`),
+    书名、tag 批量取(v2 每本书另查 3 次库),另给 `layer`。字段:`pcdBookId`→`book_id`,`paragraph`→`para`,`paliTitle`→`title`,
+    `tags[].name`→`tags`(字符串数组)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
   parameters:
     -
       name: tags
@@ -47,3 +50,4 @@ get:
       $ref: '../../main.yaml#/components/responses/Unauthorized'
     422:
       $ref: '../../main.yaml#/components/responses/ValidationError'
+  deprecated: true

+ 10 - 2
openapi/public/assets/protocol/resources/auto/v2-search-pali-wbw.yaml

@@ -4,7 +4,12 @@ get:
   tags:
     - search-pali-wbw
   operationId: get_api_v2_search_pali_wbw
-  description: 实现:`SearchPaliWbwController@index`
+  description: |
+    已被 `GET /v3/tipitaka-word-paragraphs` 取代:段落、标题、页码整页批量取(v2 每行另查 3~4 次库);`text` 只含 `<b>` 黑体与
+    `<mark>` 命中词的安全 HTML(v2 是整段原始 HTML 加字符串替换);不再给指向旧版 library 的 `link`。参数:`key`→`words`,
+    `bold=on|off`→`bold=only|exclude`,`book`→`book_id`,`limit`/`offset`→`per_page`/`page`;`view`、`tags` 去掉。
+    字段:`paragraph`→`para`,`rank`→`score`,`paliTitle`→`title`,`highlight`→`text`,`ref`→`refs`(多了 `volume`);`count`→`meta.total`。
+    保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
   parameters:
     -
       name: book
@@ -83,12 +88,14 @@ get:
       $ref: '../../main.yaml#/components/responses/Unauthorized'
     422:
       $ref: '../../main.yaml#/components/responses/ValidationError'
+  deprecated: true
 post:
   summary: '新建 search-pali-wbw'
   tags:
     - search-pali-wbw
   operationId: post_api_v2_search_pali_wbw
-  description: 实现:`SearchPaliWbwController@store`
+  description: |
+    与 GET 相同,已被 `GET /v3/tipitaka-word-paragraphs` 取代。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
   responses:
     200:
       description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
@@ -107,3 +114,4 @@ post:
       $ref: '../../main.yaml#/components/responses/Unauthorized'
     422:
       $ref: '../../main.yaml#/components/responses/ValidationError'
+  deprecated: true

+ 50 - 0
openapi/public/assets/protocol/resources/auto/v3-pali-word-forms-word.yaml

@@ -0,0 +1,50 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-pali-word-forms-word.yaml
+get:
+  summary: 词形展开
+  tags:
+    - pali-word-forms
+  operationId: get_api_v3_pali_word_forms_word_
+  description: |-
+    把一个巴利词还原成可能的词根,列出每个词根在三藏里实际出现过的词形(含 iti / api / ca / hi 连音),
+    带出现次数与黑体次数。第一组是输入的词本身,其后是推导出的词根;没有任何词形出现过的词根不列。
+    每组内按出现次数降序。词不区分大小写。
+
+    实现:`V3\PaliWordFormController@__invoke`
+  security:
+    - {  }
+    -
+      bearerAuth: []
+  parameters:
+    -
+      name: word
+      in: path
+      required: true
+      schema:
+        type: string
+      description: '巴利词,如 vitakka'
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: array
+                items:
+                  type: object
+                  properties:
+                    base:
+                      type: string
+                    forms:
+                      type: array
+                      items: { type: object, properties: { word: { type: string }, count: { type: integer }, bold: { type: integer } } }
+              meta:
+                type: object
+                properties:
+                  total:
+                    type: integer
+                    description: 组数
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'

+ 58 - 0
openapi/public/assets/protocol/resources/auto/v3-pali-word-suggestions.yaml

@@ -0,0 +1,58 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-pali-word-suggestions.yaml
+get:
+  summary: 巴利词补全
+  tags:
+    - pali-word-suggestions
+  operationId: get_api_v3_pali_word_suggestions
+  description: |-
+    按已输入的前缀列出三藏里出现过的词形,带出现次数与黑体次数。前缀同时匹配去掉变音符号的写法
+    (输入 dhamma 也能补出 dhammā),不区分大小写。与输入完全相同的词排在最前,其余按出现次数降序。
+
+    实现:`V3\PaliWordSuggestionController@__invoke`
+  security:
+    - {  }
+    -
+      bearerAuth: []
+  parameters:
+    -
+      name: limit
+      in: query
+      schema:
+        type: integer
+        default: 10
+      description: '最多返回几条,上限 50'
+    -
+      name: q
+      in: query
+      schema:
+        type: string
+      description: 已输入的前缀
+      required: true
+      example: vitakk
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: array
+                items:
+                  type: object
+                  properties:
+                    word:
+                      type: string
+                    count:
+                      type: integer
+                    bold:
+                      type: integer
+              meta:
+                type: object
+                properties:
+                  total:
+                    type: integer
+                    description: 本次返回的条数
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'

+ 92 - 0
openapi/public/assets/protocol/resources/auto/v3-tipitaka-page-numbers-page.yaml

@@ -0,0 +1,92 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-tipitaka-page-numbers-page.yaml
+get:
+  summary: 按页码找段落
+  tags:
+    - tipitaka-page-numbers
+  operationId: get_api_v3_tipitaka_page_numbers_page_
+  description: |-
+    一个页码在 PTS、缅甸版、VRI、泰国版、其他里各指一处或多处,另有 CS 版印的段落号(`edition=CS`)。
+    返回全部命中(不分页,通常几百条),按版本、书、卷、段排序。每条带书名、层级与该版本的书名。
+    卷号未知的记录 `volume` 为 null;给了 `volume` 就只要这一卷(CS 段落号不分卷,不返回)。
+
+    实现:`V3\TipitakaPageNumberController@__invoke`
+  security:
+    - {  }
+    -
+      bearerAuth: []
+  parameters:
+    -
+      name: page
+      in: path
+      required: true
+      schema:
+        type: integer
+      description: '页码(或 CS 段落号)'
+      example: 100
+    -
+      name: edition
+      in: query
+      schema:
+        type: string
+        enum:
+          - PTS
+          - My
+          - VRI
+          - Thai
+          - Other
+          - CS
+      description: 只要这个版本
+    -
+      name: volume
+      in: query
+      schema:
+        type: integer
+      description: 只要这一卷
+      example: 2
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: array
+                items:
+                  type: object
+                  properties:
+                    edition:
+                      type: string
+                    volume:
+                      type: integer
+                      nullable: true
+                    page:
+                      type: integer
+                    book:
+                      type: integer
+                    para:
+                      type: integer
+                    book_id:
+                      type: integer
+                    book_title:
+                      type: string
+                    book_para:
+                      type: integer
+                    edition_title:
+                      type: string
+                      nullable: true
+                    layer:
+                      type: string
+                      nullable: true
+                    tags:
+                      type: array
+                      items: { type: string }
+              meta:
+                type: object
+                properties:
+                  total:
+                    type: integer
+                    description: 命中数
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'

+ 78 - 0
openapi/public/assets/protocol/resources/auto/v3-tipitaka-word-paragraphs-aggregate.yaml

@@ -0,0 +1,78 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-tipitaka-word-paragraphs-aggregate.yaml
+get:
+  summary: 按书统计命中
+  tags:
+    - tipitaka-word-paragraphs
+  operationId: get_api_v3_tipitaka_word_paragraphs_aggregate
+  description: |-
+    与 `GET /v3/tipitaka-word-paragraphs` 同样的检索条件,按书汇总:每本书命中多少段、多少词次,
+    按段落数降序,不分页。v2 只给词次;同一段里出现多次只算一段,所以两者不相等。
+
+    实现:`V3\TipitakaWordParagraphAggregateController@__invoke`
+  security:
+    - {  }
+    -
+      bearerAuth: []
+  parameters:
+    -
+      name: words
+      in: query
+      schema:
+        type: string
+      description: '词形,逗号分隔,最多 200 个'
+      required: true
+      example: 'vitakko,vitakkaṃ'
+    -
+      name: bold
+      in: query
+      schema:
+        type: string
+        enum:
+          - only
+          - exclude
+      description: 只看黑体(only)或排除黑体(exclude);不给则不限
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: array
+                items:
+                  type: object
+                  properties:
+                    book_id:
+                      type: integer
+                    book:
+                      type: integer
+                    para:
+                      type: integer
+                    title:
+                      type: string
+                    layer:
+                      type: string
+                      nullable: true
+                    tags:
+                      type: array
+                      items: { type: string }
+                    paragraphs:
+                      type: integer
+                    occurrences:
+                      type: integer
+              meta:
+                type: object
+                properties:
+                  total:
+                    type: integer
+                    description: 书的数目
+                  paragraphs:
+                    type: integer
+                    description: 命中段落总数
+                  occurrences:
+                    type: integer
+                    description: 词次总数
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'

+ 94 - 0
openapi/public/assets/protocol/resources/auto/v3-tipitaka-word-paragraphs.yaml

@@ -0,0 +1,94 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-tipitaka-word-paragraphs.yaml
+get:
+  summary: 按词形找段落
+  tags:
+    - tipitaka-word-paragraphs
+  operationId: get_api_v3_tipitaka_word_paragraphs
+  description: |-
+    在逐词表里精确匹配词形(连音已拆开),返回命中的段落,按命中权重降序、同分按经文顺序。
+    词形先用 `GET /v3/pali-word-forms/{word}` 展开——拿词根直接查通常是 0 条。
+    每条带整段正文(只含 `<b>` 黑体与 `<mark>` 命中词的安全 HTML)、章节路径与各印本页码。
+
+    实现:`V3\TipitakaWordParagraphController@index`
+  security:
+    - {  }
+    -
+      bearerAuth: []
+  parameters:
+    -
+      name: words
+      in: query
+      schema:
+        type: string
+      description: '词形,逗号分隔,最多 200 个'
+      required: true
+      example: 'vitakko,vitakkaṃ'
+    -
+      name: bold
+      in: query
+      schema:
+        type: string
+        enum:
+          - only
+          - exclude
+      description: 只看黑体(only,注释书里被解释的词)或排除黑体(exclude);不给则不限
+    -
+      name: book_id
+      in: query
+      schema:
+        type: string
+      description: '只看这些书,逗号分隔的 book_id(见 `/aggregate`)'
+      example: '75,79'
+    -
+      name: page
+      in: query
+      schema:
+        type: integer
+        default: 1
+      description: 页码
+    -
+      name: per_page
+      in: query
+      schema:
+        type: integer
+        default: 20
+      description: '每页条数,上限 100'
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: array
+                items:
+                  type: object
+                  properties:
+                    id:
+                      type: string
+                    book:
+                      type: integer
+                    para:
+                      type: integer
+                    score:
+                      type: integer
+                    hits:
+                      type: integer
+                    title:
+                      type: string
+                    level:
+                      type: integer
+                    path:
+                      type: array
+                      items: { type: object, properties: { book: { type: integer }, para: { type: integer }, title: { type: string }, level: { type: integer } } }
+                    text:
+                      type: string
+                    refs:
+                      type: array
+                      items: { type: object, properties: { type: { type: string }, volume: { type: integer, nullable: true }, page: { type: integer }, title: { type: string, nullable: true } } }
+              meta:
+                $ref: '../../main.yaml#/components/schemas/PaginationMeta'
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'